@ultrst-armada/kloks 2.0.5 → 2.1.0
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 +71 -1
- package/packages/backend/dist/{chunk-IRNQXVYA.js → chunk-23LS4LWC.js} +2 -2
- package/packages/backend/dist/chunk-3UZFKB4M.js +28 -0
- package/packages/backend/dist/chunk-5GW5PJWQ.js +96 -0
- package/packages/backend/dist/chunk-5SXOQAAX.js +41 -0
- package/packages/backend/dist/chunk-5UVJDX7Q.js +44 -0
- package/packages/backend/dist/chunk-6BL5DXFZ.js +43 -0
- package/packages/backend/dist/{chunk-Z2CT2MJ2.js → chunk-6I7I4C6H.js} +1 -1
- package/packages/backend/dist/{chunk-TRP76UR2.js → chunk-DJ457D5D.js} +1 -1
- package/packages/backend/dist/{chunk-WYEVA4RC.js → chunk-DTPCWHQJ.js} +1 -1
- package/packages/backend/dist/{chunk-XKUWLO2M.js → chunk-ENMIBY2V.js} +2 -2
- package/packages/backend/dist/chunk-EQFZX3JT.js +63 -0
- package/packages/backend/dist/chunk-FKK23J2A.js +363 -0
- package/packages/backend/dist/{chunk-BRNWUIH5.js → chunk-GTKW4IGC.js} +1 -1
- package/packages/backend/dist/chunk-HRJCGJTR.js +261 -0
- package/packages/backend/dist/chunk-IKDYKRVH.js +51 -0
- package/packages/backend/dist/chunk-JGR6BJVX.js +74 -0
- package/packages/backend/dist/chunk-NFK6YFTA.js +157 -0
- package/packages/backend/dist/chunk-NZWCPJDJ.js +82 -0
- package/packages/backend/dist/chunk-OT2PSPBK.js +74 -0
- package/packages/backend/dist/chunk-QYWVZBI6.js +54 -0
- package/packages/backend/dist/{chunk-ICVDGH2I.js → chunk-U7T65YUP.js} +5 -5
- package/packages/backend/dist/chunk-YFMHT77Z.js +58 -0
- package/packages/backend/dist/client-JXGCPWEA.js +7 -0
- package/packages/backend/dist/index.d.ts +1 -0
- package/packages/backend/dist/index.js +118 -9
- package/packages/backend/dist/krnl-services.js +6 -6
- package/packages/backend/dist/node.d.ts +1 -0
- package/packages/backend/dist/node.js +79 -43
- package/packages/backend/dist/provider-services/capacity.d.ts +2 -0
- package/packages/backend/dist/provider-services/client.d.ts +18 -0
- package/packages/backend/dist/provider-services/cloudflare.d.ts +6 -0
- package/packages/backend/dist/provider-services/facades.d.ts +44 -0
- package/packages/backend/dist/provider-services/gemini.d.ts +8 -0
- package/packages/backend/dist/provider-services/google/cloud-run.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/cloud-run.js +9 -0
- package/packages/backend/dist/provider-services/google/cloud-shell.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/cloud-shell.js +9 -0
- package/packages/backend/dist/provider-services/google/cloud-storage.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/cloud-storage.js +9 -0
- package/packages/backend/dist/provider-services/google/drive.d.ts +4 -0
- package/packages/backend/dist/provider-services/google/drive.js +20 -0
- package/packages/backend/dist/provider-services/google/gemini.d.ts +2 -0
- package/packages/backend/dist/provider-services/google/gemini.js +10 -0
- package/packages/backend/dist/provider-services/google/index.d.ts +3 -0
- package/packages/backend/dist/provider-services/google/index.js +17 -0
- package/packages/backend/dist/provider-services/google/vertex-ai.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/vertex-ai.js +9 -0
- package/packages/backend/dist/provider-services/index.d.ts +11 -0
- package/packages/backend/dist/provider-services/index.js +118 -0
- package/packages/backend/dist/provider-services/node.d.ts +4 -0
- package/packages/backend/dist/provider-services/node.js +40 -0
- package/packages/backend/dist/provider-services/operations.d.ts +28 -0
- package/packages/backend/dist/provider-services/operations.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/provider-services.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/registry.d.ts +16 -0
- package/packages/backend/dist/provider-services/storage/backblaze-b2.d.ts +7 -0
- package/packages/backend/dist/provider-services/storage/backblaze-b2.js +8 -0
- package/packages/backend/dist/provider-services/storage/contract.d.ts +45 -0
- package/packages/backend/dist/provider-services/storage/dropbox.d.ts +3 -0
- package/packages/backend/dist/provider-services/storage/dropbox.js +12 -0
- package/packages/backend/dist/provider-services/storage/github.d.ts +4 -0
- package/packages/backend/dist/provider-services/storage/github.js +12 -0
- package/packages/backend/dist/provider-services/storage/google-drive.d.ts +4 -0
- package/packages/backend/dist/provider-services/storage/index.d.ts +7 -0
- package/packages/backend/dist/provider-services/storage/node.d.ts +2 -0
- package/packages/backend/dist/provider-services/storage/node.js +17 -0
- package/packages/backend/dist/provider-services/storage/service.d.ts +27 -0
- package/packages/backend/dist/provider-services/storage/storage-contract.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/storage-facades.d.ts +55 -0
- package/packages/backend/dist/provider-services/storage-node.d.ts +11 -0
- package/packages/backend/dist/provider-services/storage-providers.d.ts +30 -0
- package/packages/backend/dist/provider-services/storage-providers.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/storage.d.ts +3 -0
- package/packages/backend/dist/provider-services/storage.js +29 -0
- package/packages/backend/dist/provider-services/types.d.ts +61 -0
- package/packages/backend/dist/provider-services/vercel.d.ts +13 -0
- package/packages/backend/dist/services/node.js +5 -5
- package/packages/backend/dist/srkl/index.js +4 -4
- package/packages/backend/dist/workspace/node.js +6 -6
- package/packages/backend/dist/{workspaceFileCore-UURQPP62.js → workspaceFileCore-RQO7YMRD.js} +3 -3
- package/packages/backend/package.json +71 -1
- package/packages/state-graph/dist/browser.js +16 -16
- package/packages/state-graph/dist/index.js +16 -16
- package/packages/backend/dist/{chunk-FSOOAU6G.js → chunk-TOLAWKAY.js} +4 -4
- package/packages/state-graph/dist/{chunk-YUJC367F.js → chunk-UKTICGGV.js} +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrst-armada/kloks",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -127,6 +127,76 @@
|
|
|
127
127
|
"import": "./packages/backend/dist/development/playwrightInspectionService.js",
|
|
128
128
|
"default": "./packages/backend/dist/development/playwrightInspectionService.js"
|
|
129
129
|
},
|
|
130
|
+
"./provider-services": {
|
|
131
|
+
"types": "./packages/backend/dist/provider-services/index.d.ts",
|
|
132
|
+
"import": "./packages/backend/dist/provider-services/index.js",
|
|
133
|
+
"default": "./packages/backend/dist/provider-services/index.js"
|
|
134
|
+
},
|
|
135
|
+
"./provider-services/storage": {
|
|
136
|
+
"types": "./packages/backend/dist/provider-services/storage.d.ts",
|
|
137
|
+
"import": "./packages/backend/dist/provider-services/storage.js",
|
|
138
|
+
"default": "./packages/backend/dist/provider-services/storage.js"
|
|
139
|
+
},
|
|
140
|
+
"./provider-services/storage/node": {
|
|
141
|
+
"types": "./packages/backend/dist/provider-services/storage/node.d.ts",
|
|
142
|
+
"import": "./packages/backend/dist/provider-services/storage/node.js",
|
|
143
|
+
"default": "./packages/backend/dist/provider-services/storage/node.js"
|
|
144
|
+
},
|
|
145
|
+
"./provider-services/storage/github": {
|
|
146
|
+
"types": "./packages/backend/dist/provider-services/storage/github.d.ts",
|
|
147
|
+
"import": "./packages/backend/dist/provider-services/storage/github.js",
|
|
148
|
+
"default": "./packages/backend/dist/provider-services/storage/github.js"
|
|
149
|
+
},
|
|
150
|
+
"./provider-services/storage/backblaze-b2": {
|
|
151
|
+
"types": "./packages/backend/dist/provider-services/storage/backblaze-b2.d.ts",
|
|
152
|
+
"import": "./packages/backend/dist/provider-services/storage/backblaze-b2.js",
|
|
153
|
+
"default": "./packages/backend/dist/provider-services/storage/backblaze-b2.js"
|
|
154
|
+
},
|
|
155
|
+
"./provider-services/storage/dropbox": {
|
|
156
|
+
"types": "./packages/backend/dist/provider-services/storage/dropbox.d.ts",
|
|
157
|
+
"import": "./packages/backend/dist/provider-services/storage/dropbox.js",
|
|
158
|
+
"default": "./packages/backend/dist/provider-services/storage/dropbox.js"
|
|
159
|
+
},
|
|
160
|
+
"./provider-services/google": {
|
|
161
|
+
"types": "./packages/backend/dist/provider-services/google/index.d.ts",
|
|
162
|
+
"import": "./packages/backend/dist/provider-services/google/index.js",
|
|
163
|
+
"default": "./packages/backend/dist/provider-services/google/index.js"
|
|
164
|
+
},
|
|
165
|
+
"./provider-services/google/drive": {
|
|
166
|
+
"types": "./packages/backend/dist/provider-services/google/drive.d.ts",
|
|
167
|
+
"import": "./packages/backend/dist/provider-services/google/drive.js",
|
|
168
|
+
"default": "./packages/backend/dist/provider-services/google/drive.js"
|
|
169
|
+
},
|
|
170
|
+
"./provider-services/google/gemini": {
|
|
171
|
+
"types": "./packages/backend/dist/provider-services/google/gemini.d.ts",
|
|
172
|
+
"import": "./packages/backend/dist/provider-services/google/gemini.js",
|
|
173
|
+
"default": "./packages/backend/dist/provider-services/google/gemini.js"
|
|
174
|
+
},
|
|
175
|
+
"./provider-services/google/cloud-run": {
|
|
176
|
+
"types": "./packages/backend/dist/provider-services/google/cloud-run.d.ts",
|
|
177
|
+
"import": "./packages/backend/dist/provider-services/google/cloud-run.js",
|
|
178
|
+
"default": "./packages/backend/dist/provider-services/google/cloud-run.js"
|
|
179
|
+
},
|
|
180
|
+
"./provider-services/google/cloud-storage": {
|
|
181
|
+
"types": "./packages/backend/dist/provider-services/google/cloud-storage.d.ts",
|
|
182
|
+
"import": "./packages/backend/dist/provider-services/google/cloud-storage.js",
|
|
183
|
+
"default": "./packages/backend/dist/provider-services/google/cloud-storage.js"
|
|
184
|
+
},
|
|
185
|
+
"./provider-services/google/cloud-shell": {
|
|
186
|
+
"types": "./packages/backend/dist/provider-services/google/cloud-shell.d.ts",
|
|
187
|
+
"import": "./packages/backend/dist/provider-services/google/cloud-shell.js",
|
|
188
|
+
"default": "./packages/backend/dist/provider-services/google/cloud-shell.js"
|
|
189
|
+
},
|
|
190
|
+
"./provider-services/google/vertex-ai": {
|
|
191
|
+
"types": "./packages/backend/dist/provider-services/google/vertex-ai.d.ts",
|
|
192
|
+
"import": "./packages/backend/dist/provider-services/google/vertex-ai.js",
|
|
193
|
+
"default": "./packages/backend/dist/provider-services/google/vertex-ai.js"
|
|
194
|
+
},
|
|
195
|
+
"./provider-services/node": {
|
|
196
|
+
"types": "./packages/backend/dist/provider-services/node.d.ts",
|
|
197
|
+
"import": "./packages/backend/dist/provider-services/node.js",
|
|
198
|
+
"default": "./packages/backend/dist/provider-services/node.js"
|
|
199
|
+
},
|
|
130
200
|
"./ai-provider": {
|
|
131
201
|
"types": "./packages/backend/dist/ai-provider/index.d.ts",
|
|
132
202
|
"import": "./packages/backend/dist/ai-provider/index.js",
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
deleteWorkspaceFolder,
|
|
3
3
|
readWorkspaceFile,
|
|
4
4
|
writeWorkspaceFile
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GTKW4IGC.js";
|
|
6
6
|
import {
|
|
7
7
|
createGoogleDriveWorkspaceClient,
|
|
8
8
|
listUserStorageConnections,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
resolveUserWorkspaceStorageAssociation,
|
|
12
12
|
testBackblazeCredentials,
|
|
13
13
|
toPublicStorageConnection
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TOLAWKAY.js";
|
|
15
15
|
import {
|
|
16
16
|
b2ListBuckets,
|
|
17
17
|
b2ListFileNames
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderClient
|
|
3
|
+
} from "./chunk-YFMHT77Z.js";
|
|
4
|
+
|
|
5
|
+
// src/provider-services/gemini.ts
|
|
6
|
+
async function listGeminiModels(connection, transport = fetch) {
|
|
7
|
+
const client = createProviderClient({ ...connection, providerId: "google-gemini" }, transport);
|
|
8
|
+
const { data } = await client.request({
|
|
9
|
+
path: "/v1beta/models"
|
|
10
|
+
});
|
|
11
|
+
return Array.isArray(data?.models) ? data.models : [];
|
|
12
|
+
}
|
|
13
|
+
function getGeminiQuotaStatus(accountId) {
|
|
14
|
+
return {
|
|
15
|
+
providerId: "google",
|
|
16
|
+
serviceId: "google-gemini",
|
|
17
|
+
accountId,
|
|
18
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19
|
+
metrics: [],
|
|
20
|
+
coverage: "unavailable",
|
|
21
|
+
error: "Model and project quota data must be measured or obtained from rate-limit headers"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
listGeminiModels,
|
|
27
|
+
getGeminiQuotaStatus
|
|
28
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderClient
|
|
3
|
+
} from "./chunk-YFMHT77Z.js";
|
|
4
|
+
import {
|
|
5
|
+
resolveProviderServiceId
|
|
6
|
+
} from "./chunk-FKK23J2A.js";
|
|
7
|
+
|
|
8
|
+
// src/provider-services/storage-providers.ts
|
|
9
|
+
function serviceConnection(connection, provider) {
|
|
10
|
+
if (resolveProviderServiceId(connection.providerId) !== provider)
|
|
11
|
+
throw new Error("Credential provider does not match the requested service");
|
|
12
|
+
return connection;
|
|
13
|
+
}
|
|
14
|
+
function githubName(value) {
|
|
15
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(value) || value === "." || value === "..")
|
|
16
|
+
throw new Error("Invalid GitHub repository owner or name");
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function safeRepositoryPath(path) {
|
|
20
|
+
const parts = path.split("/");
|
|
21
|
+
if (parts.some((part) => part === "" || part === "." || part === ".."))
|
|
22
|
+
throw new Error("Invalid repository path");
|
|
23
|
+
return parts.map(encodeURIComponent).join("/");
|
|
24
|
+
}
|
|
25
|
+
async function listGitHubRepositories(connection, transport = fetch, page = 1) {
|
|
26
|
+
if (!Number.isSafeInteger(page) || page < 1 || page > 1e4)
|
|
27
|
+
throw new Error("Invalid GitHub repositories page");
|
|
28
|
+
const { data } = await createProviderClient(serviceConnection(connection, "github"), transport).request({
|
|
29
|
+
path: "/user/repos",
|
|
30
|
+
query: {
|
|
31
|
+
per_page: 100,
|
|
32
|
+
page,
|
|
33
|
+
affiliation: "owner,collaborator,organization_member"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!Array.isArray(data)) throw new Error("Invalid GitHub repositories response");
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
async function listGitHubRepositoryContents(connection, owner, repo, path = "", transport = fetch) {
|
|
40
|
+
const suffix = path ? "/" + safeRepositoryPath(path) : "";
|
|
41
|
+
const { data } = await createProviderClient(serviceConnection(connection, "github"), transport).request({
|
|
42
|
+
path: `/repos/${githubName(owner)}/${githubName(repo)}/contents${suffix}`
|
|
43
|
+
});
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
async function listGitLabProjects(connection, transport = fetch) {
|
|
47
|
+
const { data } = await createProviderClient(serviceConnection(connection, "gitlab"), transport).request({
|
|
48
|
+
path: "/api/v4/projects",
|
|
49
|
+
query: { membership: true, per_page: 100 }
|
|
50
|
+
});
|
|
51
|
+
if (!Array.isArray(data)) throw new Error("Invalid GitLab projects response");
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
async function listGitLabRepositoryTree(connection, project, path = "", transport = fetch) {
|
|
55
|
+
const key = String(project).trim();
|
|
56
|
+
if (!key || key.includes("?") || key.includes("#")) throw new Error("GitLab project required");
|
|
57
|
+
if (path) safeRepositoryPath(path);
|
|
58
|
+
const { data } = await createProviderClient(serviceConnection(connection, "gitlab"), transport).request({
|
|
59
|
+
path: `/api/v4/projects/${encodeURIComponent(key)}/repository/tree`,
|
|
60
|
+
query: { per_page: 100, ...path ? { path } : {} }
|
|
61
|
+
});
|
|
62
|
+
if (!Array.isArray(data)) throw new Error("Invalid GitLab repository tree response");
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
async function listDropboxFolder(connection, path = "", transport = fetch) {
|
|
66
|
+
if (path && (!path.startsWith("/") || path.split("/").includes("..")))
|
|
67
|
+
throw new Error("Dropbox path must be an absolute path within the account");
|
|
68
|
+
const { data } = await createProviderClient(serviceConnection(connection, "dropbox"), transport).request({
|
|
69
|
+
path: "/2/files/list_folder",
|
|
70
|
+
method: "POST",
|
|
71
|
+
body: { path, recursive: false, limit: 100 }
|
|
72
|
+
});
|
|
73
|
+
if (!Array.isArray(data?.entries) || typeof data.cursor !== "string" || typeof data.has_more !== "boolean")
|
|
74
|
+
throw new Error("Invalid Dropbox folder response");
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
async function continueDropboxFolder(connection, cursor, transport = fetch) {
|
|
78
|
+
if (!cursor || typeof cursor !== "string") throw new Error("Dropbox cursor required");
|
|
79
|
+
const { data } = await createProviderClient(serviceConnection(connection, "dropbox"), transport).request({
|
|
80
|
+
path: "/2/files/list_folder/continue",
|
|
81
|
+
method: "POST",
|
|
82
|
+
body: { cursor }
|
|
83
|
+
});
|
|
84
|
+
if (!Array.isArray(data?.entries) || typeof data.cursor !== "string" || typeof data.has_more !== "boolean")
|
|
85
|
+
throw new Error("Invalid Dropbox cursor response");
|
|
86
|
+
return data;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
listGitHubRepositories,
|
|
91
|
+
listGitHubRepositoryContents,
|
|
92
|
+
listGitLabProjects,
|
|
93
|
+
listGitLabRepositoryTree,
|
|
94
|
+
listDropboxFolder,
|
|
95
|
+
continueDropboxFolder
|
|
96
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/provider-services/capacity.ts
|
|
2
|
+
function calculateProviderCapacity(snapshot, now = /* @__PURE__ */ new Date(), maxAgeMs = 10 * 6e4) {
|
|
3
|
+
const checkedAt = now.toISOString();
|
|
4
|
+
const unknown = (reason) => ({ status: "unknown", weight: 0, percentRemaining: null, bottleneck: null, reason, checkedAt });
|
|
5
|
+
const timestamp = Date.parse(snapshot.capturedAt);
|
|
6
|
+
if (!Number.isFinite(timestamp) || now.getTime() < timestamp - 3e4 || now.getTime() - timestamp > maxAgeMs) return unknown("Telemetry is stale or undated");
|
|
7
|
+
if (snapshot.error || snapshot.coverage === "unavailable") {
|
|
8
|
+
return unknown(snapshot.error || "Provider quota telemetry unavailable");
|
|
9
|
+
}
|
|
10
|
+
const enforced = snapshot.metrics.filter((m) => m.enforceable);
|
|
11
|
+
if (!enforced.length) return unknown("No provider-confirmed renewable quota windows");
|
|
12
|
+
if (snapshot.coverage !== "complete") return unknown("Required quota coverage is incomplete");
|
|
13
|
+
let bottleneck = null;
|
|
14
|
+
let minimum = 1;
|
|
15
|
+
for (const metric of enforced) {
|
|
16
|
+
if (metric.source !== "provider" || !validQuota(metric) || !metric.resetAt || Date.parse(metric.resetAt) <= now.getTime()) {
|
|
17
|
+
return unknown("Quota metric missing, estimated, or outside its reset window: " + metric.id);
|
|
18
|
+
}
|
|
19
|
+
const remaining = Math.max(0, Math.min(1, (metric.limit - metric.used) / metric.limit));
|
|
20
|
+
if (!bottleneck || remaining < minimum) {
|
|
21
|
+
minimum = remaining;
|
|
22
|
+
bottleneck = metric;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const status = minimum === 0 ? "exhausted" : "eligible";
|
|
26
|
+
return {
|
|
27
|
+
status,
|
|
28
|
+
weight: status === "eligible" ? Number(minimum.toFixed(4)) : 0,
|
|
29
|
+
percentRemaining: Math.round(minimum * 100),
|
|
30
|
+
bottleneck: bottleneck?.id ?? null,
|
|
31
|
+
reason: status === "eligible" ? "Provider-measured quota remaining" : "A required quota is exhausted",
|
|
32
|
+
checkedAt
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function validQuota(metric) {
|
|
36
|
+
return metric.used !== null && metric.limit !== null && Number.isFinite(metric.used) && Number.isFinite(metric.limit) && metric.used >= 0 && metric.limit > 0 && typeof metric.resetAt === "string" && Number.isFinite(Date.parse(metric.resetAt));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
calculateProviderCapacity
|
|
41
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/provider-services/storage/contract.ts
|
|
2
|
+
var UnsupportedStorageOperation = class extends Error {
|
|
3
|
+
constructor(providerId, operation) {
|
|
4
|
+
super(`Storage provider ${providerId} does not support ${operation} through this adapter`);
|
|
5
|
+
this.providerId = providerId;
|
|
6
|
+
this.operation = operation;
|
|
7
|
+
this.name = "UnsupportedStorageOperation";
|
|
8
|
+
}
|
|
9
|
+
providerId;
|
|
10
|
+
operation;
|
|
11
|
+
code = "STORAGE_OPERATION_UNSUPPORTED";
|
|
12
|
+
};
|
|
13
|
+
function assertStorageOperation(service, operation) {
|
|
14
|
+
if (!service.capabilities[operation])
|
|
15
|
+
throw new UnsupportedStorageOperation(service.providerId, operation);
|
|
16
|
+
}
|
|
17
|
+
function normalizeStoragePath(path = "") {
|
|
18
|
+
if (path.includes("\\") || path.includes("?") || path.includes("#") || /[\x00-\x1f]/.test(path))
|
|
19
|
+
throw new Error("Invalid storage path");
|
|
20
|
+
const parts = path.replace(/^\/+|\/+$/g, "").split("/").filter(Boolean);
|
|
21
|
+
if (parts.some((p) => p === "." || p === ".." || p === "%2e" || p === "%2e%2e"))
|
|
22
|
+
throw new Error("Storage path traversal is not permitted");
|
|
23
|
+
return parts.join("/");
|
|
24
|
+
}
|
|
25
|
+
function readOnlyService(id) {
|
|
26
|
+
return {
|
|
27
|
+
read: async () => {
|
|
28
|
+
throw new UnsupportedStorageOperation(id, "read");
|
|
29
|
+
},
|
|
30
|
+
write: async () => {
|
|
31
|
+
throw new UnsupportedStorageOperation(id, "write");
|
|
32
|
+
},
|
|
33
|
+
delete: async () => {
|
|
34
|
+
throw new UnsupportedStorageOperation(id, "delete");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
UnsupportedStorageOperation,
|
|
41
|
+
assertStorageOperation,
|
|
42
|
+
normalizeStoragePath,
|
|
43
|
+
readOnlyService
|
|
44
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeStoragePath
|
|
3
|
+
} from "./chunk-5UVJDX7Q.js";
|
|
4
|
+
import {
|
|
5
|
+
GoogleDriveWorkspaceService
|
|
6
|
+
} from "./chunk-EMSSTOOK.js";
|
|
7
|
+
|
|
8
|
+
// src/provider-services/storage/google-drive.ts
|
|
9
|
+
function createGoogleDriveStorageService(options) {
|
|
10
|
+
const drive = new GoogleDriveWorkspaceService(options);
|
|
11
|
+
return {
|
|
12
|
+
providerId: "google-drive",
|
|
13
|
+
capabilities: Object.freeze({ list: true, read: true, write: true, delete: true }),
|
|
14
|
+
async list(path = "", cursor) {
|
|
15
|
+
if (cursor) throw new Error("Google Drive adapter handles pagination internally");
|
|
16
|
+
const files = await drive.list(normalizeStoragePath(path));
|
|
17
|
+
return {
|
|
18
|
+
entries: files.map((file) => ({
|
|
19
|
+
id: String(file.id || file.path),
|
|
20
|
+
path: "/" + file.path,
|
|
21
|
+
name: file.path.split("/").pop() || file.path,
|
|
22
|
+
kind: file.isFolder ? "folder" : "file",
|
|
23
|
+
...Number.isFinite(file.size) ? { size: file.size } : {}
|
|
24
|
+
})),
|
|
25
|
+
nextCursor: null,
|
|
26
|
+
complete: true
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
read(path) {
|
|
30
|
+
return drive.read(normalizeStoragePath(path));
|
|
31
|
+
},
|
|
32
|
+
write(path, content, contentType) {
|
|
33
|
+
return drive.write(normalizeStoragePath(path), content, contentType);
|
|
34
|
+
},
|
|
35
|
+
delete(path) {
|
|
36
|
+
return drive.delete(normalizeStoragePath(path));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
createGoogleDriveStorageService
|
|
43
|
+
};
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
findUserWorkspace,
|
|
11
11
|
getWorkspaces,
|
|
12
12
|
updateWorkspace
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-23LS4LWC.js";
|
|
14
14
|
import {
|
|
15
15
|
queryUnifiedDb
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-TOLAWKAY.js";
|
|
17
17
|
import {
|
|
18
18
|
b2DownloadFile,
|
|
19
19
|
b2ListFileNames,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderClient
|
|
3
|
+
} from "./chunk-YFMHT77Z.js";
|
|
4
|
+
|
|
5
|
+
// src/provider-services/operations.ts
|
|
6
|
+
async function cfGet(connection, path, transport = fetch) {
|
|
7
|
+
const client = createProviderClient({ ...connection, providerId: "cloudflare" }, transport);
|
|
8
|
+
const { data } = await client.request({ path });
|
|
9
|
+
if (!data?.success) throw new Error("Cloudflare operation was rejected");
|
|
10
|
+
return data.result;
|
|
11
|
+
}
|
|
12
|
+
function cfAccount(connection) {
|
|
13
|
+
if (!/^[a-f0-9]{32}$/i.test(connection.accountScope || ""))
|
|
14
|
+
throw new Error("Cloudflare account tag required");
|
|
15
|
+
return connection.accountScope;
|
|
16
|
+
}
|
|
17
|
+
async function listCloudflareWorkers(connection, transport = fetch) {
|
|
18
|
+
return cfGet(connection, `/client/v4/accounts/${cfAccount(connection)}/workers/scripts`, transport);
|
|
19
|
+
}
|
|
20
|
+
async function listCloudflarePages(connection, transport = fetch) {
|
|
21
|
+
return cfGet(connection, `/client/v4/accounts/${cfAccount(connection)}/pages/projects`, transport);
|
|
22
|
+
}
|
|
23
|
+
async function listCloudflareAccounts(connection, transport = fetch) {
|
|
24
|
+
return cfGet(connection, "/client/v4/accounts?per_page=50", transport);
|
|
25
|
+
}
|
|
26
|
+
async function listVercelProjects(connection, transport = fetch) {
|
|
27
|
+
const client = createProviderClient({ ...connection, providerId: "vercel" }, transport);
|
|
28
|
+
const { data } = await client.request({
|
|
29
|
+
path: "/v9/projects",
|
|
30
|
+
query: connection.accountScope ? { teamId: connection.accountScope } : {}
|
|
31
|
+
});
|
|
32
|
+
if (!Array.isArray(data?.projects)) throw new Error("Unexpected Vercel projects response");
|
|
33
|
+
return data.projects;
|
|
34
|
+
}
|
|
35
|
+
async function listVercelDeployments(connection, transport = fetch) {
|
|
36
|
+
const client = createProviderClient({ ...connection, providerId: "vercel" }, transport);
|
|
37
|
+
const { data } = await client.request({
|
|
38
|
+
path: "/v6/deployments",
|
|
39
|
+
query: {
|
|
40
|
+
limit: 30,
|
|
41
|
+
...connection.accountScope ? { teamId: connection.accountScope } : {}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (!Array.isArray(data?.deployments)) throw new Error("Unexpected Vercel deployments response");
|
|
45
|
+
return data.deployments;
|
|
46
|
+
}
|
|
47
|
+
async function getGoogleAccountProfile(connection, transport = fetch) {
|
|
48
|
+
const client = createProviderClient({ ...connection, providerId: "google" }, transport);
|
|
49
|
+
const { data } = await client.request({
|
|
50
|
+
path: "/oauth2/v3/userinfo"
|
|
51
|
+
});
|
|
52
|
+
if (!data?.sub) throw new Error("Unexpected Google identity response");
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
listCloudflareWorkers,
|
|
58
|
+
listCloudflarePages,
|
|
59
|
+
listCloudflareAccounts,
|
|
60
|
+
listVercelProjects,
|
|
61
|
+
listVercelDeployments,
|
|
62
|
+
getGoogleAccountProfile
|
|
63
|
+
};
|