added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions

View File

@@ -18,12 +18,12 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
action: string,
module: Module,
res: ResponseObject<ConfigUpdateResponse<Module>>,
path?: string
path?: string,
): Promise<boolean> {
const base: Partial<NotificationData> = {
id: "schema-" + [action, module, path].join("-"),
position: "top-right",
autoClose: 3000
autoClose: 3000,
};
if (res.success === true) {
@@ -35,8 +35,8 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
...prev,
config: {
...prev.config,
[module]: res.config
}
[module]: res.config,
},
};
});
}
@@ -45,7 +45,7 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
...base,
title: `Config updated: ${ucFirst(module)}`,
color: "blue",
message: `Operation ${action.toUpperCase()} at ${module}${path ? "." + path : ""}`
message: `Operation ${action.toUpperCase()} at ${module}${path ? "." + path : ""}`,
});
} else {
notifications.show({
@@ -54,7 +54,7 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
color: "red",
withCloseButton: true,
autoClose: false,
message: res.error ?? "Failed to complete config update"
message: res.error ?? "Failed to complete config update",
});
}
@@ -66,7 +66,7 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
set: async <Module extends keyof ModuleConfigs>(
module: keyof ModuleConfigs,
value: ModuleConfigs[Module],
force?: boolean
force?: boolean,
) => {
const res = await api.system.setConfig(module, value, force);
return await handleConfigUpdate("set", module, res);
@@ -74,7 +74,7 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
patch: async <Module extends keyof ModuleConfigs>(
module: Module,
path: string,
value: any
value: any,
): Promise<boolean> => {
const res = await api.system.patchConfig(module, path, value);
return await handleConfigUpdate("patch", module, res, path);
@@ -82,7 +82,7 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
overwrite: async <Module extends keyof ModuleConfigs>(
module: Module,
path: string,
value: any
value: any,
) => {
const res = await api.system.overwriteConfig(module, path, value);
return await handleConfigUpdate("overwrite", module, res, path);
@@ -94,6 +94,6 @@ export function getSchemaActions({ api, setSchema, reloadSchema }: SchemaActions
remove: async <Module extends keyof ModuleConfigs>(module: Module, path: string) => {
const res = await api.system.removeConfig(module, path);
return await handleConfigUpdate("remove", module, res, path);
}
},
};
}

View File

@@ -69,6 +69,6 @@ export const useAuth = (options?: { baseUrl?: string }): UseAuth => {
register,
logout,
setToken,
verify
verify,
};
};

View File

@@ -14,7 +14,7 @@ export function useBkndAuth() {
return true;
}
return false;
}
},
},
roles: {
add: async (name: string, data: any = {}) => {
@@ -31,8 +31,8 @@ export function useBkndAuth() {
return await bkndActions.remove("auth", `roles.${name}`);
}
return false;
}
}
},
},
};
const minimum_permissions = [
@@ -40,7 +40,7 @@ export function useBkndAuth() {
"system.access.api",
"system.config.read",
"system.config.read.secrets",
"system.build"
"system.build",
];
const $auth = {
roles: {
@@ -49,19 +49,21 @@ export function useBkndAuth() {
has_admin: Object.entries(config.auth.roles ?? {}).some(
([name, role]) =>
role.implicit_allow ||
minimum_permissions.every((p) => role.permissions?.includes(p))
)
minimum_permissions.every((p) => role.permissions?.includes(p)),
),
},
routes: {
settings: app.getSettingsPath(["auth"]),
listUsers: app.getAbsolutePath("/data/" + routes.data.entity.list(config.auth.entity_name))
}
listUsers: app.getAbsolutePath(
"/data/" + routes.data.entity.list(config.auth.entity_name),
),
},
};
return {
$auth,
config: config.auth,
schema: schema.auth,
actions
actions,
};
}

View File

@@ -8,7 +8,7 @@ import {
entitiesSchema,
entityFields,
fieldsSchema,
relationsSchema
relationsSchema,
} from "data/data-schema";
import { useBknd } from "ui/client/bknd";
import type { TSchemaActions } from "ui/client/schema/actions";
@@ -28,7 +28,7 @@ export function useBkndData() {
console.log("create entity", { data });
const validated = parse(entitiesSchema, data, {
skipMark: true,
forceParse: true
forceParse: true,
});
console.log("validated", validated);
// @todo: check for existing?
@@ -46,12 +46,12 @@ export function useBkndData() {
return await bkndActions.overwrite(
"data",
`entities.${entityName}.config`,
partial
partial,
);
},
fields: entityFieldActions(bkndActions, entityName)
fields: entityFieldActions(bkndActions, entityName),
};
}
},
},
relations: {
add: async (relation: TAppDataRelation) => {
@@ -59,12 +59,12 @@ export function useBkndData() {
const name = crypto.randomUUID();
const validated = parse(Type.Union(relationsSchema), relation, {
skipMark: true,
forceParse: true
forceParse: true,
});
console.log("validated", validated);
return await bkndActions.add("data", `relations.${name}`, validated);
}
}
},
},
};
const $data = {
entity: (name: string) => entities[name],
@@ -72,8 +72,8 @@ export function useBkndData() {
system: (name: string) => ({
any: entities[name]?.type === "system",
users: name === config.auth.entity_name,
media: name === config.media.entity_name
})
media: name === config.media.entity_name,
}),
};
return {
@@ -82,7 +82,7 @@ export function useBkndData() {
relations: app.relations,
config: config.data,
schema: schema.data,
actions
actions,
};
}
@@ -91,7 +91,7 @@ const modals = {
createEntity: () =>
bkndModals.open(bkndModals.ids.dataCreate, {
initialPath: ["entities", "entity"],
initialState: { action: "entity" }
initialState: { action: "entity" },
}),
createRelation: (entity?: string) =>
bkndModals.open(bkndModals.ids.dataCreate, {
@@ -99,9 +99,9 @@ const modals = {
initialState: {
action: "relation",
relations: {
create: [{ source: entity, type: "n:1" } as any]
}
}
create: [{ source: entity, type: "n:1" } as any],
},
},
}),
createMedia: (entity?: string) =>
bkndModals.open(bkndModals.ids.dataCreate, {
@@ -109,10 +109,10 @@ const modals = {
initialState: {
action: "template-media",
initial: {
entity
}
}
})
entity,
},
},
}),
};
function entityFieldActions(bkndActions: TSchemaActions, entityName: string) {
@@ -121,7 +121,7 @@ function entityFieldActions(bkndActions: TSchemaActions, entityName: string) {
console.log("create field", { name, field });
const validated = parse(fieldsSchema, field, {
skipMark: true,
forceParse: true
forceParse: true,
});
console.log("validated", validated);
return await bkndActions.add("data", `entities.${entityName}.fields.${name}`, validated);
@@ -132,12 +132,12 @@ function entityFieldActions(bkndActions: TSchemaActions, entityName: string) {
try {
const validated = parse(entityFields, fields, {
skipMark: true,
forceParse: true
forceParse: true,
});
const res = await bkndActions.overwrite(
"data",
`entities.${entityName}.fields`,
validated
validated,
);
console.log("res", res);
//bkndActions.set("data", "entities", fields);
@@ -149,6 +149,6 @@ function entityFieldActions(bkndActions: TSchemaActions, entityName: string) {
alert("An error occured, check console. There will be nice error handling soon.");
}
}
}
},
};
}

View File

@@ -13,8 +13,8 @@ export function useFlows() {
console.log("parsed", parsed);
const res = await bkndActions.add("flows", `flows.${name}`, parsed);
console.log("res", res);
}
}
},
},
};
return { flows: app.flows, config: config.flows, actions };

View File

@@ -13,8 +13,8 @@ export function useBkndMedia() {
}
return false;
}
}
},
},
};
const $media = {};
@@ -22,6 +22,6 @@ export function useBkndMedia() {
$media,
config: config.media,
schema: schema.media,
actions
actions,
};
}

View File

@@ -9,15 +9,15 @@ export function useBkndSystem() {
theme: {
set: async (scheme: "light" | "dark") => {
return await bkndActions.patch("server", "admin", {
color_scheme: scheme
color_scheme: scheme,
});
},
toggle: async () => {
return await bkndActions.patch("server", "admin", {
color_scheme: theme === "light" ? "dark" : "light"
color_scheme: theme === "light" ? "dark" : "light",
});
}
}
},
},
};
const $system = {};
@@ -26,7 +26,7 @@ export function useBkndSystem() {
config: config.server,
schema: schema.server,
theme,
actions
actions,
};
}
@@ -36,6 +36,6 @@ export function useBkndSystemTheme() {
return {
theme: $sys.theme,
set: $sys.actions.theme.set,
toggle: () => $sys.actions.theme.toggle()
toggle: () => $sys.actions.theme.toggle(),
};
}