@ultrst-armada/kloks 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -1
- package/packages/backend/dist/api/index.js +2 -1
- package/packages/backend/dist/{chunk-5F5V7NAG.js → chunk-5Y7K7HAT.js} +4 -1
- package/packages/backend/dist/{chunk-SQKG3S6P.js → chunk-AUNIGE6Q.js} +2 -2
- package/packages/backend/dist/chunk-BRNWUIH5.js +197 -0
- package/packages/backend/dist/{chunk-NY2SQOXI.js → chunk-CDRHYO44.js} +4 -1
- package/packages/backend/dist/{chunk-ZBNSK26X.js → chunk-CV55JMT7.js} +6 -5
- package/packages/backend/dist/{chunk-OWMQLML7.js → chunk-EMSSTOOK.js} +33 -2
- package/packages/backend/dist/chunk-FSOOAU6G.js +1132 -0
- package/packages/backend/dist/chunk-GVMVYC6C.js +0 -0
- package/packages/backend/dist/chunk-I6T64MLT.js +171 -0
- package/packages/backend/dist/chunk-ICVDGH2I.js +889 -0
- package/packages/backend/dist/chunk-IP6XWQU2.js +48 -0
- package/packages/backend/dist/chunk-IRNQXVYA.js +746 -0
- package/packages/backend/dist/{chunk-POLVHTHJ.js → chunk-KCPQWJBO.js} +4 -1
- package/packages/backend/dist/chunk-LC6ULEM2.js +125 -0
- package/packages/backend/dist/{chunk-NTKUQVCQ.js → chunk-LMUMMVTU.js} +14 -2
- package/packages/backend/dist/chunk-LMY6MGFD.js +78 -0
- package/packages/backend/dist/{chunk-OQRQCDS6.js → chunk-TRJVVNO7.js} +2 -2
- package/packages/backend/dist/{chunk-KPLDYX5Z.js → chunk-TRP76UR2.js} +33 -26
- package/packages/backend/dist/{chunk-FK3OAUXM.js → chunk-WYEVA4RC.js} +4 -2
- package/packages/backend/dist/{chunk-Z6G32NQQ.js → chunk-XKUWLO2M.js} +12 -9
- package/packages/backend/dist/{chunk-OXEP3AP6.js → chunk-Z2CT2MJ2.js} +158 -1
- package/packages/backend/dist/control-plane/index.js +3 -1
- package/packages/backend/dist/core/b2DirectCore.test.d.ts +1 -0
- package/packages/backend/dist/core/cloudflareIntegrationCore.test.d.ts +1 -0
- package/packages/backend/dist/core/googleDriveOAuthCore.d.ts +51 -0
- package/packages/backend/dist/core/googleDriveOAuthCore.test.d.ts +1 -0
- package/packages/backend/dist/core/index.d.ts +3 -0
- package/packages/backend/dist/core/storageConnectionCore.d.ts +136 -0
- package/packages/backend/dist/core/storageConnectionCore.test.d.ts +1 -0
- package/packages/backend/dist/core/storageConnectionRuntimeCore.d.ts +57 -0
- package/packages/backend/dist/core/storageConnectionRuntimeCore.test.d.ts +1 -0
- package/packages/backend/dist/core/storageContracts.d.ts +77 -0
- package/packages/backend/dist/core/storageProviderRegistry.d.ts +7 -0
- package/packages/backend/dist/core/systemCredentialsCore.d.ts +46 -0
- package/packages/backend/dist/core/unifiedDb.d.ts +12 -2
- package/packages/backend/dist/core/unifiedDb.errors.test.d.ts +1 -0
- package/packages/backend/dist/core/unifiedDbNodeAdapter.d.ts +6 -0
- package/packages/backend/dist/core/workspaceBucketSyncCore.d.ts +3 -4
- package/packages/backend/dist/core/workspaceBucketSyncCore.test.d.ts +1 -0
- package/packages/backend/dist/core/workspaceCore.d.ts +25 -6
- package/packages/backend/dist/core/workspaceDataCore.test.d.ts +1 -0
- package/packages/backend/dist/core/workspaceFileCore.d.ts +25 -7
- package/packages/backend/dist/core/workspaceFileCore.test.d.ts +1 -0
- package/packages/backend/dist/core/workspaceFileNodeAdapter.d.ts +6 -0
- package/packages/backend/dist/core/workspaceStorageDetailsCore.d.ts +4 -8
- package/packages/backend/dist/core/workspaceStorageDetailsCore.test.d.ts +1 -0
- package/packages/backend/dist/development/index.js +1 -1
- package/packages/backend/dist/development/playwrightInspectionService.js +1 -1
- package/packages/backend/dist/development/playwrightInspectionSupport.d.ts +1 -0
- package/packages/backend/dist/index.js +22 -16
- package/packages/backend/dist/krnl-services.d.ts +0 -22
- package/packages/backend/dist/krnl-services.js +8 -19
- package/packages/backend/dist/krnl-services.node.d.ts +28 -0
- package/packages/backend/dist/node.d.ts +3 -0
- package/packages/backend/dist/node.js +636 -456
- package/packages/backend/dist/resolver/index.js +13 -0
- package/packages/backend/dist/resolver/systemDatabaseUrl.d.ts +16 -12
- package/packages/backend/dist/services/node.js +12 -10
- package/packages/backend/dist/srkl/index.js +6 -4
- package/packages/backend/dist/storage/B2DirectClient.d.ts +7 -13
- package/packages/backend/dist/storage/B2DirectClient.test.d.ts +1 -0
- package/packages/backend/dist/storage/GoogleDriveWorkspaceService.d.ts +5 -0
- package/packages/backend/dist/storage/index.js +4 -3
- package/packages/backend/dist/storage/node.js +7 -6
- package/packages/backend/dist/storage-workspace.js +1 -1
- package/packages/backend/dist/workspace/index.js +2 -1
- package/packages/backend/dist/workspace/node.js +12 -7
- package/packages/backend/dist/workspaceFileCore-UURQPP62.js +28 -0
- package/packages/backend/package.json +8 -3
- package/packages/services/dist/index.js +8 -2
- package/packages/state-graph/dist/browser.js +16 -16
- package/packages/state-graph/dist/index.js +16 -16
- package/packages/backend/dist/chunk-4QEMALXF.js +0 -90
- package/packages/backend/dist/chunk-AOZSDRNY.js +0 -159
- package/packages/backend/dist/chunk-GYSZ6CAX.js +0 -19
- package/packages/backend/dist/chunk-JCMB7BIM.js +0 -211
- package/packages/backend/dist/chunk-JGUWYVOL.js +0 -570
- package/packages/backend/dist/chunk-LMOM7CST.js +0 -427
- package/packages/state-graph/dist/{chunk-UKTICGGV.js → chunk-YUJC367F.js} +3 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toCamelCase,
|
|
3
|
+
toKebabCase,
|
|
4
|
+
toPascalCase
|
|
5
|
+
} from "./chunk-LMY6MGFD.js";
|
|
6
|
+
|
|
7
|
+
// ../functions/dist/chunk-6EHIZHO4.js
|
|
8
|
+
function deepClone(obj, seen = /* @__PURE__ */ new Map()) {
|
|
9
|
+
if (obj === null || typeof obj !== "object") {
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
if (seen.has(obj)) {
|
|
13
|
+
return seen.get(obj);
|
|
14
|
+
}
|
|
15
|
+
if (obj instanceof Date) {
|
|
16
|
+
return new Date(obj.getTime());
|
|
17
|
+
}
|
|
18
|
+
if (obj instanceof RegExp) {
|
|
19
|
+
return new RegExp(obj.source, obj.flags);
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(obj)) {
|
|
22
|
+
const cloneArr = [];
|
|
23
|
+
seen.set(obj, cloneArr);
|
|
24
|
+
for (const item of obj) {
|
|
25
|
+
cloneArr.push(deepClone(item, seen));
|
|
26
|
+
}
|
|
27
|
+
return cloneArr;
|
|
28
|
+
}
|
|
29
|
+
const cloneObj = Object.create(Object.getPrototypeOf(obj));
|
|
30
|
+
seen.set(obj, cloneObj);
|
|
31
|
+
for (const key of Reflect.ownKeys(obj)) {
|
|
32
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
|
|
33
|
+
if (descriptor) {
|
|
34
|
+
descriptor.value = deepClone(descriptor.value, seen);
|
|
35
|
+
Object.defineProperty(cloneObj, key, descriptor);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return cloneObj;
|
|
39
|
+
}
|
|
40
|
+
function deepMerge(base, ...overrides) {
|
|
41
|
+
let result = deepClone(base);
|
|
42
|
+
for (const override of overrides) {
|
|
43
|
+
if (override === null || typeof override !== "object") {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
for (const key of Object.keys(override)) {
|
|
47
|
+
const val = override[key];
|
|
48
|
+
if (val === void 0) {
|
|
49
|
+
delete result[key];
|
|
50
|
+
} else if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
51
|
+
if (result[key] && typeof result[key] === "object" && !Array.isArray(result[key])) {
|
|
52
|
+
result[key] = deepMerge(result[key], val);
|
|
53
|
+
} else {
|
|
54
|
+
result[key] = deepClone(val);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
result[key] = deepClone(val);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
var globalStore = globalThis;
|
|
64
|
+
if (!globalStore.__skipo_realtime_store) {
|
|
65
|
+
globalStore.__skipo_realtime_store = {
|
|
66
|
+
buffer: [],
|
|
67
|
+
listeners: /* @__PURE__ */ new Set()
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var store = globalStore.__skipo_realtime_store;
|
|
71
|
+
|
|
72
|
+
// ../functions/dist/index.js
|
|
73
|
+
import {
|
|
74
|
+
createService,
|
|
75
|
+
createServiceDefinition
|
|
76
|
+
} from "@ultrst-armada/krnl";
|
|
77
|
+
var FunctionsServiceDefinition = createServiceDefinition({
|
|
78
|
+
id: "kloks.functions.core",
|
|
79
|
+
name: "FunctionsService",
|
|
80
|
+
version: "1.0.0",
|
|
81
|
+
operations: {
|
|
82
|
+
toKebabCase: {
|
|
83
|
+
id: "FunctionsService.toKebabCase",
|
|
84
|
+
name: "toKebabCase",
|
|
85
|
+
handler: async (input) => toKebabCase(input.value)
|
|
86
|
+
},
|
|
87
|
+
toCamelCase: {
|
|
88
|
+
id: "FunctionsService.toCamelCase",
|
|
89
|
+
name: "toCamelCase",
|
|
90
|
+
handler: async (input) => toCamelCase(input.value)
|
|
91
|
+
},
|
|
92
|
+
toPascalCase: {
|
|
93
|
+
id: "FunctionsService.toPascalCase",
|
|
94
|
+
name: "toPascalCase",
|
|
95
|
+
handler: async (input) => toPascalCase(input.value)
|
|
96
|
+
},
|
|
97
|
+
deepClone: {
|
|
98
|
+
id: "FunctionsService.deepClone",
|
|
99
|
+
name: "deepClone",
|
|
100
|
+
handler: async (input) => deepClone(input.value)
|
|
101
|
+
},
|
|
102
|
+
deepMerge: {
|
|
103
|
+
id: "FunctionsService.deepMerge",
|
|
104
|
+
name: "deepMerge",
|
|
105
|
+
handler: async (input) => deepMerge(input.target, input.source)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
var defaultFunctionsService = createService(FunctionsServiceDefinition);
|
|
110
|
+
var FunctionsServiceFacade = {
|
|
111
|
+
id: FunctionsServiceDefinition.id,
|
|
112
|
+
name: FunctionsServiceDefinition.name,
|
|
113
|
+
version: FunctionsServiceDefinition.version,
|
|
114
|
+
runtime: "server",
|
|
115
|
+
deployment: "local",
|
|
116
|
+
definition: FunctionsServiceDefinition,
|
|
117
|
+
get telemetry() {
|
|
118
|
+
return defaultFunctionsService.telemetry;
|
|
119
|
+
},
|
|
120
|
+
createInstance: () => createService(FunctionsServiceDefinition),
|
|
121
|
+
execute: async (op, input) => {
|
|
122
|
+
await defaultFunctionsService.start();
|
|
123
|
+
return defaultFunctionsService.call(op, input);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
@@ -10,11 +10,19 @@ import {
|
|
|
10
10
|
// src/development/playwrightInspectionSupport.ts
|
|
11
11
|
import { createRequire } from "module";
|
|
12
12
|
import { existsSync } from "fs";
|
|
13
|
-
var require2 = createRequire(import.meta.url);
|
|
14
13
|
function findSystemChromiumExecutable() {
|
|
15
14
|
if (process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH && existsSync(process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH)) {
|
|
16
15
|
return process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
|
|
17
16
|
}
|
|
17
|
+
const runtimeRoot = process.env.PLAYWRIGHT_RUNTIME_PATH;
|
|
18
|
+
if (runtimeRoot) {
|
|
19
|
+
try {
|
|
20
|
+
const runtimeRequire = createRequire(`${runtimeRoot}/package.json`);
|
|
21
|
+
const executable = runtimeRequire("playwright").chromium.executablePath?.();
|
|
22
|
+
if (typeof executable === "string" && existsSync(executable)) return executable;
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
const candidates = [
|
|
19
27
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
20
28
|
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
@@ -31,8 +39,10 @@ function findSystemChromiumExecutable() {
|
|
|
31
39
|
return void 0;
|
|
32
40
|
}
|
|
33
41
|
function loadPlaywright() {
|
|
42
|
+
const runtimeRoot = process.env.PLAYWRIGHT_RUNTIME_PATH;
|
|
43
|
+
const requireFromRuntime = runtimeRoot ? createRequire(`${runtimeRoot}/package.json`) : createRequire(import.meta.url);
|
|
34
44
|
try {
|
|
35
|
-
return
|
|
45
|
+
return requireFromRuntime("playwright");
|
|
36
46
|
} catch {
|
|
37
47
|
throw new Error('Playwright is required for browser inspection. Install the optional "playwright" package and Chromium browser.');
|
|
38
48
|
}
|
|
@@ -68,8 +78,10 @@ var PlaywrightInspectionRuntime = class {
|
|
|
68
78
|
let browser;
|
|
69
79
|
try {
|
|
70
80
|
const executablePath = request.executablePath ?? findSystemChromiumExecutable();
|
|
81
|
+
const chromiumArgs = typeof process.getuid === "function" && process.getuid() === 0 ? ["--no-sandbox", "--disable-dev-shm-usage"] : [];
|
|
71
82
|
browser = await loadPlaywright().chromium.launch({
|
|
72
83
|
headless: true,
|
|
84
|
+
...chromiumArgs.length ? { args: chromiumArgs } : {},
|
|
73
85
|
...executablePath ? { executablePath } : {}
|
|
74
86
|
});
|
|
75
87
|
} catch (cause) {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// ../functions/dist/chunk-Z4LM5TOJ.js
|
|
2
|
+
function toCamelCase(str) {
|
|
3
|
+
return str.replace(/[-_]+/g, " ").replace(/[^\w\s]/g, "").replace(
|
|
4
|
+
/(?:^\w|[A-Z]|\b\w)/g,
|
|
5
|
+
(word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase()
|
|
6
|
+
).replace(/\s+/g, "");
|
|
7
|
+
}
|
|
8
|
+
function toPascalCase(str) {
|
|
9
|
+
const camel = toCamelCase(str);
|
|
10
|
+
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
11
|
+
}
|
|
12
|
+
function toKebabCase(str) {
|
|
13
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).replace(/[-_\s]+/g, "-").replace(/^[-_\s]+|[-_\s]+$/g, "").toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
function shortId(length = 8) {
|
|
16
|
+
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
17
|
+
let result = "";
|
|
18
|
+
for (let i = 0; i < length; i++) {
|
|
19
|
+
result += chars.charAt(Math.random() * chars.length | 0);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
var SkipoBase = class {
|
|
24
|
+
/** Unique instance identifier */
|
|
25
|
+
instanceId;
|
|
26
|
+
/** Human-readable component name */
|
|
27
|
+
name;
|
|
28
|
+
/** Logger instance */
|
|
29
|
+
logger;
|
|
30
|
+
/** Whether this component has been initialized */
|
|
31
|
+
initialized = false;
|
|
32
|
+
/** Whether this component has been disposed */
|
|
33
|
+
disposed = false;
|
|
34
|
+
constructor(config = { name: "SkipoComponent" }) {
|
|
35
|
+
this.instanceId = shortId();
|
|
36
|
+
this.name = config?.name ?? "SkipoComponent";
|
|
37
|
+
this.logger = config?.logger ?? console;
|
|
38
|
+
}
|
|
39
|
+
/** Initialize the component. Call before use. */
|
|
40
|
+
async initialize() {
|
|
41
|
+
if (this.initialized) return;
|
|
42
|
+
this.logger.log(`[${this.name}:${this.instanceId}] Initializing`);
|
|
43
|
+
await this.onInitialize();
|
|
44
|
+
this.initialized = true;
|
|
45
|
+
}
|
|
46
|
+
/** Override to add custom initialization logic */
|
|
47
|
+
async onInitialize() {
|
|
48
|
+
}
|
|
49
|
+
/** Dispose the component and release resources */
|
|
50
|
+
async dispose() {
|
|
51
|
+
if (this.disposed) return;
|
|
52
|
+
this.logger.log(`[${this.name}:${this.instanceId}] Disposing`);
|
|
53
|
+
await this.onDispose();
|
|
54
|
+
this.disposed = true;
|
|
55
|
+
}
|
|
56
|
+
/** Override to add custom cleanup logic */
|
|
57
|
+
async onDispose() {
|
|
58
|
+
}
|
|
59
|
+
/** Guard: throws if not initialized */
|
|
60
|
+
ensureInitialized() {
|
|
61
|
+
if (!this.initialized) {
|
|
62
|
+
throw new Error(`${this.name} has not been initialized. Call initialize() first.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Guard: throws if already disposed */
|
|
66
|
+
ensureNotDisposed() {
|
|
67
|
+
if (this.disposed) {
|
|
68
|
+
throw new Error(`${this.name} has been disposed and cannot be used.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
toCamelCase,
|
|
75
|
+
toPascalCase,
|
|
76
|
+
toKebabCase,
|
|
77
|
+
SkipoBase
|
|
78
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseStorageAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5Y7K7HAT.js";
|
|
4
4
|
import {
|
|
5
5
|
GoogleDriveWorkspaceService
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EMSSTOOK.js";
|
|
7
7
|
|
|
8
8
|
// src/storage/GoogleDriveStorageService.ts
|
|
9
9
|
var GoogleDriveStorageService = class extends BaseStorageAdapter {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveUserStorageConnectionSecret
|
|
3
|
+
} from "./chunk-FSOOAU6G.js";
|
|
1
4
|
import {
|
|
2
5
|
b2ListBuckets
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-I6T64MLT.js";
|
|
4
7
|
|
|
5
8
|
// src/srkl/SrklDiscoveryService.ts
|
|
6
9
|
var cachedSrklUrls = null;
|
|
@@ -52,23 +55,13 @@ async function getSrklAccounts(userId, service, queryDb) {
|
|
|
52
55
|
if (!seenKeys.has(key)) {
|
|
53
56
|
seenKeys.add(key);
|
|
54
57
|
accounts.push({
|
|
55
|
-
id: conn.id,
|
|
56
|
-
name: conn.label || conn.id,
|
|
57
|
-
provider: conn.provider,
|
|
58
|
-
serviceId: conn.provider,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
bucketName: conn.b2BucketName || conn.bucketName,
|
|
63
|
-
region: conn.b2Region || conn.region,
|
|
64
|
-
endpoint: conn.b2Endpoint || conn.endpoint,
|
|
65
|
-
email: conn.googleEmail,
|
|
66
|
-
rootFolderId: conn.googleRootFolderId,
|
|
67
|
-
rootFolderName: conn.googleRootFolderName,
|
|
68
|
-
accessToken: conn.googleAccessToken,
|
|
69
|
-
accessTokenExpiresAt: conn.googleAccessTokenExpiresAt,
|
|
70
|
-
refreshToken: conn.googleRefreshToken
|
|
71
|
-
}
|
|
58
|
+
id: String(conn.id),
|
|
59
|
+
name: String(conn.label || conn.id),
|
|
60
|
+
provider: String(conn.provider || ""),
|
|
61
|
+
serviceId: String(conn.provider || ""),
|
|
62
|
+
category: "storage",
|
|
63
|
+
status: conn.testStatus === "ok" ? "CONNECTED" : conn.enabled === false ? "DISABLED" : "ACTIVE",
|
|
64
|
+
emailOrSlug: conn.googleEmail || conn.label || conn.id
|
|
72
65
|
});
|
|
73
66
|
}
|
|
74
67
|
}
|
|
@@ -87,11 +80,19 @@ async function getSrklAccounts(userId, service, queryDb) {
|
|
|
87
80
|
for (const item of list) {
|
|
88
81
|
const sId = String(item.serviceId || item.id || "").toLowerCase();
|
|
89
82
|
if (service && !sId.includes(service.toLowerCase())) continue;
|
|
90
|
-
const
|
|
91
|
-
const key =
|
|
83
|
+
const id = String(item.id || `srkl-${sId}`);
|
|
84
|
+
const key = `id:${id}`;
|
|
92
85
|
if (!seenKeys.has(key)) {
|
|
93
86
|
seenKeys.add(key);
|
|
94
|
-
accounts.push(
|
|
87
|
+
accounts.push({
|
|
88
|
+
id,
|
|
89
|
+
name: String(item.name || item.label || sId),
|
|
90
|
+
serviceId: sId,
|
|
91
|
+
provider: String(item.provider || item.serviceId || ""),
|
|
92
|
+
category: String(item.category || "storage"),
|
|
93
|
+
status: String(item.status || "ACTIVE"),
|
|
94
|
+
...typeof item.emailOrSlug === "string" ? { emailOrSlug: item.emailOrSlug } : {}
|
|
95
|
+
});
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -102,12 +103,18 @@ async function getSrklAccounts(userId, service, queryDb) {
|
|
|
102
103
|
async function srklListBackblazeBuckets(keyId, applicationKey, _bucketId, _bucketName, userId, queryDb, accountId) {
|
|
103
104
|
let resolvedKeyId = (keyId || "").trim();
|
|
104
105
|
let resolvedAppKey = (applicationKey || "").trim();
|
|
105
|
-
if ((!resolvedKeyId || !resolvedAppKey) &&
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
if ((!resolvedKeyId || !resolvedAppKey) && userId) {
|
|
107
|
+
const matched = await resolveUserStorageConnectionSecret(
|
|
108
|
+
userId,
|
|
109
|
+
accountId,
|
|
110
|
+
queryDb,
|
|
111
|
+
"backblaze_b2"
|
|
112
|
+
);
|
|
108
113
|
if (matched) {
|
|
109
|
-
resolvedKeyId = matched.
|
|
110
|
-
resolvedAppKey =
|
|
114
|
+
resolvedKeyId = String(matched.b2KeyId || matched.keyId || matched.accessKeyId || "").trim();
|
|
115
|
+
resolvedAppKey = String(
|
|
116
|
+
matched.b2ApplicationKey || matched.applicationKey || matched.appKey || matched.secretAccessKey || ""
|
|
117
|
+
).trim();
|
|
111
118
|
}
|
|
112
119
|
}
|
|
113
120
|
if (!resolvedKeyId || !resolvedAppKey) {
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GoogleDriveStorageService
|
|
3
|
+
} from "./chunk-TRJVVNO7.js";
|
|
4
|
+
import {
|
|
5
|
+
SkipoBase
|
|
6
|
+
} from "./chunk-LMY6MGFD.js";
|
|
1
7
|
import {
|
|
2
8
|
createWorkspace,
|
|
3
9
|
deleteWorkspace,
|
|
4
10
|
findUserWorkspace,
|
|
5
11
|
getWorkspaces,
|
|
6
12
|
updateWorkspace
|
|
7
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IRNQXVYA.js";
|
|
8
14
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
15
|
+
queryUnifiedDb
|
|
16
|
+
} from "./chunk-FSOOAU6G.js";
|
|
11
17
|
import {
|
|
12
18
|
b2DownloadFile,
|
|
13
19
|
b2ListFileNames,
|
|
14
|
-
b2UploadFile
|
|
15
|
-
|
|
16
|
-
} from "./chunk-JCMB7BIM.js";
|
|
20
|
+
b2UploadFile
|
|
21
|
+
} from "./chunk-I6T64MLT.js";
|
|
17
22
|
|
|
18
23
|
// src/workspace/WorkspaceFS.ts
|
|
19
|
-
import { SkipoBase } from "@ultrst-armada/kloks/functions";
|
|
20
24
|
var WorkspaceFS = class extends SkipoBase {
|
|
21
25
|
primary;
|
|
22
26
|
syncEngine;
|
|
@@ -71,8 +75,7 @@ var WorkspaceFS = class extends SkipoBase {
|
|
|
71
75
|
};
|
|
72
76
|
|
|
73
77
|
// src/workspace/SyncEngine.ts
|
|
74
|
-
|
|
75
|
-
var SyncEngine = class extends SkipoBase2 {
|
|
78
|
+
var SyncEngine = class extends SkipoBase {
|
|
76
79
|
primary;
|
|
77
80
|
backups;
|
|
78
81
|
config;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StorageAdapterFactory
|
|
3
|
+
} from "./chunk-AUNIGE6Q.js";
|
|
4
|
+
import {
|
|
5
|
+
findUserWorkspace
|
|
6
|
+
} from "./chunk-IRNQXVYA.js";
|
|
7
|
+
|
|
1
8
|
// src/services/ServiceBoundary.ts
|
|
2
9
|
import {
|
|
3
10
|
createService,
|
|
@@ -327,6 +334,155 @@ var NodeGraphPersistenceService = class {
|
|
|
327
334
|
};
|
|
328
335
|
var nodeGraphPersistence = new NodeGraphPersistenceService();
|
|
329
336
|
|
|
337
|
+
// src/services/workspaceGraphService.ts
|
|
338
|
+
function slugify(name) {
|
|
339
|
+
const value = String(name || "").trim().replace(/[/\\]+/g, "_").replace(/[<>:"|?*]/g, "").slice(0, 80);
|
|
340
|
+
return value || "New Graph";
|
|
341
|
+
}
|
|
342
|
+
function storage() {
|
|
343
|
+
return StorageAdapterFactory.create({
|
|
344
|
+
provider: "local_fs",
|
|
345
|
+
basePath: process.env.KLOKS_GRAPH_STORAGE_ROOT || "./workspaces-data"
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
function graphPath(workspaceId, slug) {
|
|
349
|
+
return `workspaces/${workspaceId}/graphs/${slug}.graph.json`;
|
|
350
|
+
}
|
|
351
|
+
async function assertWorkspace(userId, workspaceId) {
|
|
352
|
+
const result = await findUserWorkspace(workspaceId);
|
|
353
|
+
if (!result.workspace || !result.user || result.user.id !== userId) {
|
|
354
|
+
throw new Error(`Workspace ${workspaceId} does not exist`);
|
|
355
|
+
}
|
|
356
|
+
return result.workspace;
|
|
357
|
+
}
|
|
358
|
+
async function readGraph(workspaceId, slug) {
|
|
359
|
+
const adapter = storage();
|
|
360
|
+
const path = graphPath(workspaceId, slug);
|
|
361
|
+
if (!await adapter.exists(path)) return null;
|
|
362
|
+
const raw = new TextDecoder().decode(await adapter.read(path));
|
|
363
|
+
return JSON.parse(raw);
|
|
364
|
+
}
|
|
365
|
+
async function writeGraph(document) {
|
|
366
|
+
const adapter = storage();
|
|
367
|
+
await adapter.write(graphPath(document.workspaceId, document.graphSlug), JSON.stringify(document, null, 2), "application/json");
|
|
368
|
+
}
|
|
369
|
+
function toDocument(workspaceId, id, name, slug, nodes = [], edges = [], createdAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
370
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
371
|
+
return {
|
|
372
|
+
$schema: "https://skipo.dev/schemas/node-graph.v1.json",
|
|
373
|
+
version: "1.0.0",
|
|
374
|
+
appId: workspaceId,
|
|
375
|
+
appName: name,
|
|
376
|
+
createdAt,
|
|
377
|
+
updatedAt: now,
|
|
378
|
+
exportedAt: now,
|
|
379
|
+
workspaceId,
|
|
380
|
+
graphId: id,
|
|
381
|
+
graphSlug: slug,
|
|
382
|
+
graph: { nodes, edges }
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
var workspaceGraphService = {
|
|
386
|
+
async listGraphs(userId, workspaceId) {
|
|
387
|
+
await assertWorkspace(userId, workspaceId);
|
|
388
|
+
const adapter = storage();
|
|
389
|
+
const files = await adapter.list(`workspaces/${workspaceId}/graphs`);
|
|
390
|
+
const graphs = [];
|
|
391
|
+
for (const file of files.filter((item) => item.path.endsWith(".graph.json"))) {
|
|
392
|
+
try {
|
|
393
|
+
const raw = new TextDecoder().decode(await adapter.read(file.path));
|
|
394
|
+
const graph = JSON.parse(raw);
|
|
395
|
+
graphs.push({
|
|
396
|
+
id: graph.graphId,
|
|
397
|
+
name: graph.appName,
|
|
398
|
+
slug: graph.graphSlug,
|
|
399
|
+
createdAt: graph.createdAt,
|
|
400
|
+
updatedAt: graph.updatedAt,
|
|
401
|
+
nodeCount: graph.graph.nodes.length
|
|
402
|
+
});
|
|
403
|
+
} catch {
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
graphs.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
407
|
+
return { success: true, graphs };
|
|
408
|
+
},
|
|
409
|
+
async createGraph(userId, workspaceId, input) {
|
|
410
|
+
await assertWorkspace(userId, workspaceId);
|
|
411
|
+
const targetName = String(input?.name || "").trim().slice(0, 80) || "New Graph";
|
|
412
|
+
const baseSlug = slugify(targetName);
|
|
413
|
+
let slug = baseSlug;
|
|
414
|
+
let n = 2;
|
|
415
|
+
while (await readGraph(workspaceId, slug)) slug = `${baseSlug} (${n++})`;
|
|
416
|
+
const graph = toDocument(workspaceId, `graph-${Date.now()}`, targetName, slug);
|
|
417
|
+
await writeGraph(graph);
|
|
418
|
+
return { success: true, graph, graphs: (await this.listGraphs(userId, workspaceId)).graphs };
|
|
419
|
+
},
|
|
420
|
+
async getGraph(userId, workspaceId, slug) {
|
|
421
|
+
await assertWorkspace(userId, workspaceId);
|
|
422
|
+
const graph = await readGraph(workspaceId, slug);
|
|
423
|
+
if (!graph) throw new Error(`Graph "${slug}" not found`);
|
|
424
|
+
return { success: true, graph };
|
|
425
|
+
},
|
|
426
|
+
async saveGraph(userId, workspaceId, slug, patch) {
|
|
427
|
+
await assertWorkspace(userId, workspaceId);
|
|
428
|
+
const existing = await readGraph(workspaceId, slug);
|
|
429
|
+
if (!existing) throw new Error(`Graph "${slug}" not found`);
|
|
430
|
+
const next = {
|
|
431
|
+
...existing,
|
|
432
|
+
appName: typeof patch.name === "string" && patch.name.trim() ? patch.name.trim().slice(0, 80) : existing.appName,
|
|
433
|
+
graph: {
|
|
434
|
+
nodes: Array.isArray(patch.nodes) ? patch.nodes : existing.graph.nodes,
|
|
435
|
+
edges: Array.isArray(patch.edges) ? patch.edges : existing.graph.edges
|
|
436
|
+
},
|
|
437
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
438
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
439
|
+
};
|
|
440
|
+
await writeGraph(next);
|
|
441
|
+
return { success: true, graph: next };
|
|
442
|
+
},
|
|
443
|
+
async deleteGraph(userId, workspaceId, slug) {
|
|
444
|
+
await assertWorkspace(userId, workspaceId);
|
|
445
|
+
const adapter = storage();
|
|
446
|
+
const path = graphPath(workspaceId, slug);
|
|
447
|
+
if (!await adapter.exists(path)) throw new Error(`Graph "${slug}" not found`);
|
|
448
|
+
await adapter.delete(path);
|
|
449
|
+
return { success: true, deletedSlug: slug, graphs: (await this.listGraphs(userId, workspaceId)).graphs };
|
|
450
|
+
},
|
|
451
|
+
async duplicateGraph(userId, workspaceId, slug, newName) {
|
|
452
|
+
const existing = (await this.getGraph(userId, workspaceId, slug)).graph;
|
|
453
|
+
const targetName = (newName || `${existing.appName} (Copy)`).trim().slice(0, 80);
|
|
454
|
+
const baseSlug = slugify(targetName);
|
|
455
|
+
let newSlug = baseSlug;
|
|
456
|
+
let n = 2;
|
|
457
|
+
while (await readGraph(workspaceId, newSlug)) newSlug = `${baseSlug} (${n++})`;
|
|
458
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
459
|
+
const graph = {
|
|
460
|
+
...JSON.parse(JSON.stringify(existing)),
|
|
461
|
+
graphId: `graph-${Date.now()}`,
|
|
462
|
+
graphSlug: newSlug,
|
|
463
|
+
appName: targetName,
|
|
464
|
+
createdAt: now,
|
|
465
|
+
updatedAt: now,
|
|
466
|
+
exportedAt: now
|
|
467
|
+
};
|
|
468
|
+
await writeGraph(graph);
|
|
469
|
+
return { success: true, graph, graphs: (await this.listGraphs(userId, workspaceId)).graphs };
|
|
470
|
+
},
|
|
471
|
+
async clearGraph(userId, workspaceId, slug) {
|
|
472
|
+
const existing = (await this.getGraph(userId, workspaceId, slug)).graph;
|
|
473
|
+
return this.saveGraph(userId, workspaceId, slug, { nodes: [], edges: [] });
|
|
474
|
+
},
|
|
475
|
+
async getGraphDocument(userId, workspaceId, slug) {
|
|
476
|
+
return (await this.getGraph(userId, workspaceId, slug)).graph;
|
|
477
|
+
},
|
|
478
|
+
async saveGraphDocument(userId, workspaceId, document) {
|
|
479
|
+
await assertWorkspace(userId, workspaceId);
|
|
480
|
+
if (document.workspaceId !== workspaceId) throw new Error("Graph workspace mismatch");
|
|
481
|
+
await writeGraph({ ...document, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), exportedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
482
|
+
return { success: true, graph: document };
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
330
486
|
export {
|
|
331
487
|
createLocalService,
|
|
332
488
|
createRemoteService,
|
|
@@ -339,5 +495,6 @@ export {
|
|
|
339
495
|
exportGraphAsJsonFile,
|
|
340
496
|
parseGraphJsonFile,
|
|
341
497
|
NodeGraphPersistenceService,
|
|
342
|
-
nodeGraphPersistence
|
|
498
|
+
nodeGraphPersistence,
|
|
499
|
+
workspaceGraphService
|
|
343
500
|
};
|
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
detectDatabaseEngine,
|
|
6
6
|
getSystemDatabaseUrls,
|
|
7
7
|
resolveSystemDatabaseClusterNodes
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-CV55JMT7.js";
|
|
9
|
+
import "../chunk-LC6ULEM2.js";
|
|
10
|
+
import "../chunk-LMY6MGFD.js";
|
|
9
11
|
export {
|
|
10
12
|
AuditLogger,
|
|
11
13
|
ControlPlaneManager,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file googleDriveOAuthCore.ts
|
|
3
|
+
* @description Fetch-native Google Drive OAuth state and authorization lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* Uses Web Crypto and Web APIs only. OAuth client configuration is system-owned;
|
|
6
|
+
* tokens are persisted through the user-owned Kloks storage connection core.
|
|
7
|
+
*/
|
|
8
|
+
import { type PublicStorageConnection } from './storageConnectionCore.js';
|
|
9
|
+
export interface GoogleDriveAuthorizationRequest {
|
|
10
|
+
authorizationUrl: string;
|
|
11
|
+
state: string;
|
|
12
|
+
nonce: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GoogleDriveAuthorizationState {
|
|
16
|
+
userId: string;
|
|
17
|
+
returnTo: string;
|
|
18
|
+
callbackOrigin: string;
|
|
19
|
+
nonce: string;
|
|
20
|
+
issuedAt: number;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
}
|
|
23
|
+
type OAuthQuery = (sql: string, params?: unknown[]) => Promise<{
|
|
24
|
+
rows: Array<Record<string, any>>;
|
|
25
|
+
}>;
|
|
26
|
+
/** Create the Google authorization URL and signed state for a verified Luth user. */
|
|
27
|
+
export declare function createGoogleDriveAuthorizationRequest(input: {
|
|
28
|
+
userId: string;
|
|
29
|
+
returnTo: string;
|
|
30
|
+
callbackOrigin: string;
|
|
31
|
+
}, query: OAuthQuery): Promise<GoogleDriveAuthorizationRequest>;
|
|
32
|
+
/** Verify state signature, nonce cookie, callback binding, TTL, and return origin. */
|
|
33
|
+
export declare function verifyGoogleDriveAuthorizationState(input: {
|
|
34
|
+
state: string;
|
|
35
|
+
nonceCookie: string;
|
|
36
|
+
callbackOrigin: string;
|
|
37
|
+
}, query: OAuthQuery): Promise<GoogleDriveAuthorizationState>;
|
|
38
|
+
/**
|
|
39
|
+
* Canonical callback boundary. The signed state and nonce cookie are verified
|
|
40
|
+
* before the authorization code is exchanged or any user connection is written.
|
|
41
|
+
*/
|
|
42
|
+
export declare function completeGoogleDriveAuthorizationCallback(input: {
|
|
43
|
+
state: string;
|
|
44
|
+
nonceCookie: string;
|
|
45
|
+
callbackOrigin: string;
|
|
46
|
+
code: string;
|
|
47
|
+
}, query: OAuthQuery): Promise<{
|
|
48
|
+
connection: PublicStorageConnection;
|
|
49
|
+
returnTo: string;
|
|
50
|
+
}>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './b2DirectCore.js';
|
|
2
|
+
export * from './storageConnectionCore.js';
|
|
3
|
+
export * from './storageConnectionRuntimeCore.js';
|
|
4
|
+
export * from './googleDriveOAuthCore.js';
|
|
2
5
|
export * from './unifiedDb.js';
|
|
3
6
|
export * from './workspaceSyncEngine.js';
|
|
4
7
|
export * from './SrklStorageService.js';
|