This commit is contained in:
Rizky 2023-10-31 16:43:56 +07:00
parent 1022a8b50a
commit 7d405e5145
11 changed files with 63 additions and 78 deletions

View File

@ -1,54 +1,52 @@
export const SyncActionDefinition = {
"code": {
"create": "0",
"list": "1",
"load": "2"
"open": "0",
"close": "1"
},
"site": {
"list": "3",
"group": "4",
"load": "5",
"update": "6"
"list": "2",
"group": "3",
"load": "4",
"update": "5"
},
"comp": {
"new": "7",
"list": "8",
"group": "9",
"load": "10"
"new": "6",
"list": "7",
"group": "8",
"load": "9"
},
"page": {
"list": "11",
"load": "12"
"list": "10",
"load": "11"
},
"yjs": {
"um": "13",
"sv_local": "14",
"diff_local": "15",
"sv_remote": "16"
"um": "12",
"sv_local": "13",
"diff_local": "14",
"sv_remote": "15"
},
"activity": "17",
"activity": "16",
"client": {
"info": "18"
"info": "17"
}
};
export const SyncActionPaths = {
"0": "code.create",
"1": "code.list",
"2": "code.load",
"3": "site.list",
"4": "site.group",
"5": "site.load",
"6": "site.update",
"7": "comp.new",
"8": "comp.list",
"9": "comp.group",
"10": "comp.load",
"11": "page.list",
"12": "page.load",
"13": "yjs.um",
"14": "yjs.sv_local",
"15": "yjs.diff_local",
"16": "yjs.sv_remote",
"17": "activity",
"18": "client.info"
"0": "code.open",
"1": "code.close",
"2": "site.list",
"3": "site.group",
"4": "site.load",
"5": "site.update",
"6": "comp.new",
"7": "comp.list",
"8": "comp.group",
"9": "comp.load",
"10": "page.list",
"11": "page.load",
"12": "yjs.um",
"13": "yjs.sv_local",
"14": "yjs.diff_local",
"15": "yjs.sv_remote",
"16": "activity",
"17": "client.info"
};

View File

@ -14,14 +14,12 @@ import { Activity, ActivityKind } from "./type";
WILL *BREAK* OFFLINE STORAGE --
ONLY ADDITION IS ALLOWED
*/
export type SAction = typeof SyncActions;
export const SyncActions = {
code: {
create: async (id_site: string, name: string) => ({}) as { id: string },
list: async (id_site: string) => ({}) as { ids: string[] },
load: async (id: string) => ({}) as { bin: Uint8Array } | void,
open: async (id_site: string) => ({}) as { id: string },
close: async (id_site: string) => ({}) as { id: string },
},
site: {
list: async () =>

View File

@ -1,11 +1,11 @@
import { SAction } from "../actions";
import { SyncConnection } from "../type";
export const code_load: SAction["code"]["load"] = async function (
export const code_close: SAction["code"]["close"] = async function (
this: SyncConnection,
) {
let result = null as unknown as Awaited<
ReturnType<SAction["code"]["load"]>
ReturnType<SAction["code"]["close"]>
>;
return result;
}

View File

@ -1,11 +0,0 @@
import { SAction } from "../actions";
import { SyncConnection } from "../type";
export const code_create: SAction["code"]["create"] = async function (
this: SyncConnection,
) {
let result = null as unknown as Awaited<
ReturnType<SAction["code"]["create"]>
>;
return result;
}

View File

@ -1,11 +1,11 @@
import { SAction } from "../actions";
import { SyncConnection } from "../type";
export const code_list: SAction["code"]["list"] = async function (
export const code_open: SAction["code"]["open"] = async function (
this: SyncConnection,
) {
let result = null as unknown as Awaited<
ReturnType<SAction["code"]["list"]>
ReturnType<SAction["code"]["open"]>
>;
return result;
}

View File

@ -1,6 +1,5 @@
export * from "./code_create";
export * from "./code_list";
export * from "./code_load";
export * from "./code_open";
export * from "./code_close";
export * from "./site_list";
export * from "./site_group";
export * from "./site_load";

BIN
bun.lockb

Binary file not shown.

View File

@ -25,6 +25,7 @@
},
"dependencies": {
"brotli-wasm": "^2.0.1",
"fdir": "^6.1.0"
"fdir": "^6.1.0",
"typescript": "^5.2.2"
}
}

View File

@ -26,10 +26,12 @@ if (g.mode === "dev") {
await startDevWatcher();
}
/** init lmdb */
user.conf.init();
snapshot.init();
await preparePrisma();
await ensureNotRunning();
@ -39,12 +41,17 @@ if (g.db) {
});
}
await initSrv();
await syncActionDefinition();
await generateAPIFrm();
await prepareApiRoutes();
await prepareAPITypes();
await parcelBuild();
await createServer();
g.status = "ready";
await prepareAPITypes();
await parcelBuild();
// await createServer();
// g.status = "ready";

View File

@ -35,6 +35,7 @@ export const ${name} = {
const targetFile = dir.path("app/srv/exports.d.ts");
const args = [
process.execPath,
dir.path("node_modules/.bin/tsc"),
dir.path("app/srv/exports.ts"),
"--declaration",
@ -43,19 +44,10 @@ export const ${name} = {
targetFile,
];
if (g.mode === "dev") {
const tsc = spawn(
[
dir.path("node_modules/.bin/tsc"),
dir.path("app/srv/exports.ts"),
"--declaration",
"--emitDeclarationOnly",
"--outFile",
targetFile,
],
{
const tsc = spawn(args, {
cwd: dir.path(`node_modules/.bin`),
}
);
});
await tsc.exited;
}

View File

@ -6,6 +6,7 @@ import { g } from "./global";
const decoder = new TextDecoder();
export const parcelBuild = async () => {
await dirAsync("app/static");
const args = [
"node",
dir.path("node_modules/.bin/parcel"),