fix
This commit is contained in:
parent
b4608a7e33
commit
caba4368ca
|
|
@ -36,6 +36,7 @@ model component_group {
|
|||
id String @id(map: "site_comp_group_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
name String
|
||||
shared Boolean @default(false)
|
||||
code_comp code_comp[]
|
||||
component component[]
|
||||
component_site component_site[]
|
||||
}
|
||||
|
|
@ -223,6 +224,7 @@ model site {
|
|||
is_deleted Boolean @default(false)
|
||||
responsive String @default("all")
|
||||
npm_cache String @default(" ") @db.VarChar
|
||||
code_site code_site[]
|
||||
component_site component_site[]
|
||||
npm_site npm_site[]
|
||||
page page[]
|
||||
|
|
@ -275,3 +277,51 @@ model user {
|
|||
org_user org_user[]
|
||||
site site[]
|
||||
}
|
||||
|
||||
model code {
|
||||
id String @id(map: "code_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
name String @db.Uuid
|
||||
code_comp code_comp[]
|
||||
code_file code_file[]
|
||||
code_npm code_npm[]
|
||||
code_site code_site[]
|
||||
}
|
||||
|
||||
model code_comp {
|
||||
id_code String @db.Uuid
|
||||
id_comp_group String @db.Uuid
|
||||
code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
component_group component_group @relation(fields: [id_comp_group], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@id([id_code, id_comp_group], map: "code_comp_id_code_id_comp_group")
|
||||
}
|
||||
|
||||
model code_npm {
|
||||
id String @id(map: "code_npm_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
module String
|
||||
version String
|
||||
bundled Boolean
|
||||
import_as Json @default("{\"main\": {\"mode\": \"default\", \"name\": \"\"}, \"names\": []}")
|
||||
id_code String @db.Uuid
|
||||
code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
}
|
||||
|
||||
model code_site {
|
||||
id_code String @db.Uuid
|
||||
id_site String @db.Uuid
|
||||
is_main Boolean @default(true)
|
||||
code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
site site @relation(fields: [id_site], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@id([id_code, id_site], map: "code_site_id_code_id_site")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model code_file {
|
||||
id String @id(map: "code_src_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
name String
|
||||
src String
|
||||
id_code String @db.Uuid
|
||||
type String @default("f") @db.Char(1)
|
||||
code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "code_src_id_code_fkey")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,50 @@
|
|||
export const SyncActionDefinition = {
|
||||
"code": {
|
||||
"create": "0"
|
||||
},
|
||||
"site": {
|
||||
"list": "0",
|
||||
"group": "1",
|
||||
"load": "2",
|
||||
"update": "3"
|
||||
"list": "1",
|
||||
"group": "2",
|
||||
"load": "3",
|
||||
"update": "4"
|
||||
},
|
||||
"comp": {
|
||||
"new": "4",
|
||||
"list": "5",
|
||||
"group": "6",
|
||||
"load": "7"
|
||||
"new": "5",
|
||||
"list": "6",
|
||||
"group": "7",
|
||||
"load": "8"
|
||||
},
|
||||
"page": {
|
||||
"list": "8",
|
||||
"load": "9"
|
||||
"list": "9",
|
||||
"load": "10"
|
||||
},
|
||||
"yjs": {
|
||||
"um": "10",
|
||||
"sv_local": "11",
|
||||
"diff_local": "12",
|
||||
"sv_remote": "13"
|
||||
"um": "11",
|
||||
"sv_local": "12",
|
||||
"diff_local": "13",
|
||||
"sv_remote": "14"
|
||||
},
|
||||
"activity": "14",
|
||||
"activity": "15",
|
||||
"client": {
|
||||
"info": "15"
|
||||
"info": "16"
|
||||
}
|
||||
};
|
||||
export const SyncActionPaths = {
|
||||
"0": "site.list",
|
||||
"1": "site.group",
|
||||
"2": "site.load",
|
||||
"3": "site.update",
|
||||
"4": "comp.new",
|
||||
"5": "comp.list",
|
||||
"6": "comp.group",
|
||||
"7": "comp.load",
|
||||
"8": "page.list",
|
||||
"9": "page.load",
|
||||
"10": "yjs.um",
|
||||
"11": "yjs.sv_local",
|
||||
"12": "yjs.diff_local",
|
||||
"13": "yjs.sv_remote",
|
||||
"14": "activity",
|
||||
"15": "client.info"
|
||||
"0": "code.create",
|
||||
"1": "site.list",
|
||||
"2": "site.group",
|
||||
"3": "site.load",
|
||||
"4": "site.update",
|
||||
"5": "comp.new",
|
||||
"6": "comp.list",
|
||||
"7": "comp.group",
|
||||
"8": "comp.load",
|
||||
"9": "page.list",
|
||||
"10": "page.load",
|
||||
"11": "yjs.um",
|
||||
"12": "yjs.sv_local",
|
||||
"13": "yjs.diff_local",
|
||||
"14": "yjs.sv_remote",
|
||||
"15": "activity",
|
||||
"16": "client.info"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import { Activity, ActivityKind } from "./type";
|
|||
export type SAction = typeof SyncActions;
|
||||
|
||||
export const SyncActions = {
|
||||
code: {
|
||||
create: async (id_site: string, name: string) => ({}),
|
||||
},
|
||||
site: {
|
||||
list: async () =>
|
||||
({}) as Record<string, { id: string; name: string; domain: string }>,
|
||||
|
|
@ -41,13 +44,14 @@ export const SyncActions = {
|
|||
item_id: string;
|
||||
item: IItem;
|
||||
}) => {},
|
||||
list: () => ({}) as Record<string, Exclude<component, "content_tree">>,
|
||||
list: async () =>
|
||||
({}) as Record<string, Exclude<component, "content_tree">>,
|
||||
group: async (id_site: string) =>
|
||||
({}) as Record<string, { id: string; name: string; comps: string[] }>,
|
||||
load: async (id: string) => ({}) as EComp | void,
|
||||
},
|
||||
page: {
|
||||
list: (id_site: string) =>
|
||||
list: async (id_site: string) =>
|
||||
({}) as Record<string, Exclude<page, "content_tree">>,
|
||||
load: async (id: string) => ({}) as EPage | void,
|
||||
},
|
||||
|
|
@ -74,7 +78,7 @@ export const SyncActions = {
|
|||
diff: Uint8Array
|
||||
) => ({}) as { diff: Uint8Array } | void,
|
||||
},
|
||||
activity: (
|
||||
activity: async (
|
||||
target: { comp_id?: string; page_id?: string; item_id: string },
|
||||
kind: ActivityKind,
|
||||
activity: Activity
|
||||
|
|
|
|||
|
|
@ -40,9 +40,14 @@ export const EdNpmImport = ({ mode }: { mode: "page" | "site" }) => {
|
|||
mode,
|
||||
mode === "site" ? p.site.id || "" : p.page.cur.id
|
||||
);
|
||||
local.size = parseInt(size) || 0;
|
||||
local.status = "ready";
|
||||
local.render();
|
||||
if (size === "bundling") {
|
||||
local.bundling = true;
|
||||
local.render();
|
||||
} else {
|
||||
local.size = parseInt(size) || 0;
|
||||
local.status = "ready";
|
||||
local.render();
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
reload();
|
||||
|
|
@ -179,8 +184,13 @@ export const EdNpmImport = ({ mode }: { mode: "page" | "site" }) => {
|
|||
)}
|
||||
>
|
||||
<div
|
||||
onClick={async () => {
|
||||
if (local.bundling) return;
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (local.bundling) {
|
||||
console.log("Already bundling");
|
||||
return;
|
||||
}
|
||||
local.bundling = true;
|
||||
local.render();
|
||||
|
||||
|
|
@ -217,9 +227,11 @@ export const EdNpmImport = ({ mode }: { mode: "page" | "site" }) => {
|
|||
</Popover>
|
||||
)}
|
||||
</div>
|
||||
<div className="px-2 flex items-center font-mono border-l text-[10px]">
|
||||
{formatBytes(local.size)}
|
||||
</div>
|
||||
{!local.bundling && (
|
||||
<div className="px-2 flex items-center font-mono border-l text-[10px]">
|
||||
{formatBytes(local.size)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{local.list.length > 0 && (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { dir } from "dir";
|
||||
import { SyncActions } from "../../../app/srv/ws/sync/actions";
|
||||
import { readAsync, writeAsync } from "fs-jetpack";
|
||||
import { existsAsync, readAsync, writeAsync } from "fs-jetpack";
|
||||
|
||||
export const syncActionDefinition = async () => {
|
||||
const def: any = {};
|
||||
|
|
@ -22,6 +22,29 @@ export const syncActionDefinition = async () => {
|
|||
};
|
||||
walk(SyncActions, def, []);
|
||||
|
||||
const index_js = [];
|
||||
for (const [k, v] of Object.entries(paths)) {
|
||||
const arr = v.split(".");
|
||||
const name = arr.join("_");
|
||||
const path = dir.path(`app/srv/ws/sync/actions/${name}.ts`);
|
||||
const saction = arr.map((e) => `["${e}"]`).join("");
|
||||
if (!(await existsAsync(path))) {
|
||||
const code = `
|
||||
import { SAction } from "../actions";
|
||||
import { SyncConnection } from "../type";
|
||||
export const ${name}: SAction${saction} = async function (
|
||||
this: SyncConnection,
|
||||
) {
|
||||
let result = null as unknown as Awaited<
|
||||
ReturnType<SAction${saction}>
|
||||
>;
|
||||
return result;
|
||||
}`;
|
||||
await writeAsync(path, code);
|
||||
}
|
||||
index_js.push(`export * from "./${name}";`);
|
||||
}
|
||||
|
||||
const content = `\
|
||||
export const SyncActionDefinition = ${JSON.stringify(def, null, 2)};
|
||||
export const SyncActionPaths = ${JSON.stringify(paths, null, 2)};
|
||||
|
|
|
|||
Loading…
Reference in New Issue