@sequenceholdings/managed-functions 0.4.4 → 0.5.1
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/README.md +147 -12
- package/dist/abrigo-contract.d.ts +2 -92
- package/dist/abrigo-contract.js +12 -53
- package/dist/abrigo-response.d.ts +1 -6
- package/dist/abrigo-response.js +3 -25
- package/dist/abrigo.d.ts +5 -5
- package/dist/abrigo.js +66 -92
- package/dist/agent-evidence.d.ts +5 -5
- package/dist/agent-evidence.js +58 -48
- package/dist/agent-source-evidence-contract.d.ts +2 -1197
- package/dist/agent-source-evidence-contract.js +24 -94
- package/dist/agents-contract.d.ts +2 -99
- package/dist/agents-contract.js +13 -67
- package/dist/agents.d.ts +5 -5
- package/dist/agents.js +79 -44
- package/dist/capabilities.d.ts +1 -1
- package/dist/capabilities.js +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +4 -1
- package/dist/directory-config.d.ts +1 -23
- package/dist/directory-config.js +8 -20
- package/dist/directory-contract.d.ts +2 -68
- package/dist/directory-contract.js +13 -55
- package/dist/directory-roster-contract.d.ts +2 -22
- package/dist/directory-roster-contract.js +7 -22
- package/dist/directory.d.ts +4 -8
- package/dist/directory.js +15 -33
- package/dist/group-roster-access.d.ts +7 -0
- package/dist/group-roster-access.js +8 -0
- package/dist/index.d.ts +49 -46
- package/dist/index.js +8 -1
- package/dist/invocation-client.d.ts +4 -4
- package/dist/invocation-client.js +32 -60
- package/dist/invocation-contract.d.ts +2 -59
- package/dist/invocation-contract.js +10 -61
- package/dist/invocation.d.ts +4 -4
- package/dist/invocation.js +42 -63
- package/dist/lattice-provenance-contract.d.ts +2 -607
- package/dist/lattice-provenance-contract.js +14 -154
- package/dist/lattice-provenance.d.ts +3 -3
- package/dist/lattice-provenance.js +46 -97
- package/dist/monitoring-annotations.d.ts +2 -53
- package/dist/monitoring-annotations.js +2 -51
- package/dist/monitoring-contract.d.ts +5 -460
- package/dist/monitoring-contract.js +37 -77
- package/dist/monitoring-events.d.ts +2 -252
- package/dist/monitoring-events.js +15 -125
- package/dist/monitoring.d.ts +3 -3
- package/dist/monitoring.js +41 -41
- package/dist/orm.d.ts +10 -1
- package/dist/orm.js +27 -7
- package/dist/platform-client.d.ts +27 -0
- package/dist/platform-client.js +79 -0
- package/dist/platform-domains.d.ts +1671 -0
- package/dist/platform-domains.js +77 -0
- package/dist/processes-contract.d.ts +2 -149
- package/dist/processes-contract.js +17 -100
- package/dist/processes.d.ts +3 -3
- package/dist/processes.js +64 -49
- package/dist/runtime.cjs +4257 -1667
- package/dist/service-directory-roster.d.ts +12 -3
- package/dist/service-directory-roster.js +11 -17
- package/dist/service-directory.d.ts +4 -8
- package/dist/service-directory.js +16 -67
- package/dist/storage.d.ts +70 -35
- package/dist/storage.js +12 -5
- package/dist/workflow-source-contract.d.ts +2 -524
- package/dist/workflow-source-contract.js +16 -56
- package/dist/workflow-source.d.ts +3 -3
- package/dist/workflow-source.js +106 -43
- package/package.json +4 -3
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function createServiceRosterReader({ origin, token, expiresAt, fetchImpl }: {
|
|
1
|
+
import type { DirectoryRosterQuery } from "./directory-roster-contract";
|
|
2
|
+
export declare function createServiceRosterReader({ origin, token, expiresAt, fetchImpl, }: {
|
|
3
3
|
origin: string;
|
|
4
4
|
token: string;
|
|
5
5
|
expiresAt: number;
|
|
6
6
|
fetchImpl: typeof fetch;
|
|
7
|
-
}): (input: DirectoryRosterQuery) => Promise<
|
|
7
|
+
}): (input: DirectoryRosterQuery) => Promise<{
|
|
8
|
+
members: {
|
|
9
|
+
id: string;
|
|
10
|
+
sub: string;
|
|
11
|
+
name: string;
|
|
12
|
+
email: string;
|
|
13
|
+
deactivated: false;
|
|
14
|
+
}[];
|
|
15
|
+
nextCursor: string | null;
|
|
16
|
+
}>;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createServiceRosterReader = createServiceRosterReader;
|
|
4
|
-
const
|
|
4
|
+
const browser_1 = require("@sequenceholdings/platform/browser");
|
|
5
5
|
const directory_contract_1 = require("./directory-contract");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
function createServiceRosterReader({ origin, token, expiresAt, fetchImpl, }) {
|
|
7
|
+
const client = (0, browser_1.createDirectoryClient)({
|
|
8
|
+
transport: (0, browser_1.createPlatformTransport)({
|
|
9
|
+
baseUrl: origin,
|
|
10
|
+
auth: { kind: "invocation-directory", token },
|
|
11
|
+
fetchImpl,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
8
14
|
return async (input) => {
|
|
9
15
|
if (expiresAt <= Date.now() / 1000)
|
|
10
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(401,
|
|
11
|
-
|
|
12
|
-
if (!query.success)
|
|
13
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(400, 'invalid_request', 'Invalid group roster request');
|
|
14
|
-
const response = await fetchImpl(`${origin}${directory_roster_contract_1.FUNCTION_DIRECTORY_ROSTER_PATH}`, { method: 'POST', headers: { 'content-type': 'application/json', [directory_contract_1.FUNCTION_DIRECTORY_TOKEN_HEADER]: token }, body: JSON.stringify(query.data), redirect: 'error', signal: AbortSignal.timeout(30_000) });
|
|
15
|
-
const body = await response.json().catch(() => null);
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
const error = zod_1.z.object({ code: zod_1.z.string().max(128).optional(), detail: zod_1.z.string().max(2000).optional() }).safeParse(body);
|
|
18
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(response.status, error.success ? error.data.code ?? 'directory_roster_failed' : 'directory_roster_failed', error.success ? error.data.detail ?? 'Group roster read failed' : 'Group roster read failed');
|
|
19
|
-
}
|
|
20
|
-
const result = directory_roster_contract_1.directoryRosterPageSchema.safeParse(body);
|
|
21
|
-
if (!result.success || result.data.members.length > query.data.limit || new Set(result.data.members.map(member => member.id)).size !== result.data.members.length)
|
|
22
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(502, 'malformed_response', 'Atlas returned an invalid group roster');
|
|
23
|
-
return result.data;
|
|
16
|
+
throw new directory_contract_1.DirectoryPrincipalResolveError(401, "expired_context", "The directory credential expired; start a new invocation");
|
|
17
|
+
return client.listGroupMembers(input);
|
|
24
18
|
};
|
|
25
19
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type DirectoryPrincipalResolveRequest, type DirectoryPrincipalResolution } from './directory-contract';
|
|
1
|
+
import { type DirectoryClient } from "@sequenceholdings/platform/browser";
|
|
3
2
|
export interface FunctionServiceDirectoryOptions {
|
|
4
3
|
request: {
|
|
5
|
-
headers: Pick<Headers,
|
|
4
|
+
headers: Pick<Headers, "get"> | Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
6
5
|
};
|
|
7
6
|
baseUrl: string;
|
|
8
7
|
fetchImpl?: typeof globalThis.fetch;
|
|
9
8
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
resolve(input: DirectoryPrincipalResolveRequest): Promise<DirectoryPrincipalResolution>;
|
|
13
|
-
}
|
|
14
|
-
export declare function createFunctionServiceDirectoryClient({ request, baseUrl, fetchImpl }: FunctionServiceDirectoryOptions): FunctionServiceDirectoryClient;
|
|
9
|
+
export type FunctionServiceDirectoryClient = DirectoryClient;
|
|
10
|
+
export declare function createFunctionServiceDirectoryClient({ request, baseUrl, fetchImpl, }: FunctionServiceDirectoryOptions): FunctionServiceDirectoryClient;
|
|
@@ -1,74 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFunctionServiceDirectoryClient = createFunctionServiceDirectoryClient;
|
|
4
|
-
const
|
|
5
|
-
const zod_1 = require("zod");
|
|
4
|
+
const browser_1 = require("@sequenceholdings/platform/browser");
|
|
6
5
|
const directory_contract_1 = require("./directory-contract");
|
|
7
|
-
function
|
|
6
|
+
function createFunctionServiceDirectoryClient({ request, baseUrl, fetchImpl, }) {
|
|
8
7
|
const headers = request.headers;
|
|
9
|
-
const matches = typeof headers.get ===
|
|
10
|
-
|
|
8
|
+
const matches = typeof headers.get === "function"
|
|
9
|
+
? [headers.get(directory_contract_1.FUNCTION_DIRECTORY_TOKEN_HEADER)]
|
|
10
|
+
: Object.entries(headers)
|
|
11
|
+
.filter(([key]) => key.toLowerCase() === directory_contract_1.FUNCTION_DIRECTORY_TOKEN_HEADER)
|
|
12
|
+
.map(([, value]) => value);
|
|
11
13
|
const token = matches[0];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
throw refused();
|
|
24
|
-
}
|
|
25
|
-
const parsed = zod_1.z.object({ audience: zod_1.z.literal('atlas-managed-function-directory-resolve'), sub: zod_1.z.string().startsWith('service-account|'), functionId: zod_1.z.string().min(1), invocationId: zod_1.z.string().min(1), exp: zod_1.z.number() }).safeParse(value);
|
|
26
|
-
if (!parsed.success)
|
|
27
|
-
throw refused();
|
|
28
|
-
return { token, expiresAt: parsed.data.exp };
|
|
29
|
-
}
|
|
30
|
-
function origin(baseUrl) {
|
|
31
|
-
const refused = () => new directory_contract_1.DirectoryPrincipalResolveError(400, 'invalid_configuration', 'Configure a trusted HTTPS Atlas origin without credentials, path, query or fragment');
|
|
32
|
-
let url;
|
|
33
|
-
try {
|
|
34
|
-
url = new URL(baseUrl);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
throw refused();
|
|
38
|
-
}
|
|
39
|
-
const loopback = url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
40
|
-
if ((!loopback && url.protocol !== 'https:') || url.username || url.password || url.pathname !== '/' || url.search || url.hash)
|
|
41
|
-
throw refused();
|
|
42
|
-
return url.origin;
|
|
43
|
-
}
|
|
44
|
-
function completeResolution({ result, query }) {
|
|
45
|
-
const expected = new Set(query.lookups.map((lookup) => `${lookup.type}:${lookup.value}`));
|
|
46
|
-
const received = [...result.resolved.map((value) => value.lookup), ...result.unresolved];
|
|
47
|
-
const actual = new Set(received.map((lookup) => `${lookup.type}:${lookup.value}`));
|
|
48
|
-
return received.length === expected.size && actual.size === expected.size && [...actual].every((key) => expected.has(key))
|
|
49
|
-
&& result.resolved.every((value) => value.lookup.type !== 'email' || value.email === value.lookup.value);
|
|
50
|
-
}
|
|
51
|
-
function createFunctionServiceDirectoryClient({ request, baseUrl, fetchImpl = globalThis.fetch }) {
|
|
52
|
-
const url = `${origin(baseUrl)}${directory_contract_1.FUNCTION_DIRECTORY_RESOLVE_PATH}`;
|
|
53
|
-
const { token, expiresAt } = credential({ request });
|
|
54
|
-
return {
|
|
55
|
-
listGroupMembers: (0, service_directory_roster_1.createServiceRosterReader)({ origin: origin(baseUrl), token, expiresAt, fetchImpl }),
|
|
56
|
-
async resolve(input) {
|
|
57
|
-
if (expiresAt <= Date.now() / 1000)
|
|
58
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(401, 'expired_context', 'The directory credential expired; start a new invocation');
|
|
59
|
-
const query = directory_contract_1.directoryPrincipalResolveRequestSchema.safeParse(input);
|
|
60
|
-
if (!query.success)
|
|
61
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(400, 'invalid_request', 'Invalid exact directory resolution request');
|
|
62
|
-
const response = await fetchImpl(url, { method: 'POST', headers: { 'content-type': 'application/json', [directory_contract_1.FUNCTION_DIRECTORY_TOKEN_HEADER]: token }, body: JSON.stringify(query.data), redirect: 'error', signal: AbortSignal.timeout(30_000) });
|
|
63
|
-
const body = await response.json().catch(() => null);
|
|
64
|
-
if (!response.ok) {
|
|
65
|
-
const error = zod_1.z.object({ code: zod_1.z.string().max(128).optional(), detail: zod_1.z.string().max(2000).optional() }).safeParse(body);
|
|
66
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(response.status, error.success ? error.data.code ?? 'directory_resolve_failed' : 'directory_resolve_failed', error.success ? error.data.detail ?? 'Directory resolution failed' : 'Directory resolution failed');
|
|
67
|
-
}
|
|
68
|
-
const result = directory_contract_1.directoryPrincipalResolutionSchema.safeParse(body);
|
|
69
|
-
if (!result.success || !completeResolution({ result: result.data, query: query.data }))
|
|
70
|
-
throw new directory_contract_1.DirectoryPrincipalResolveError(502, 'malformed_response', 'Atlas returned an invalid directory resolution');
|
|
71
|
-
return result.data;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
14
|
+
if (matches.length !== 1 || typeof token !== "string")
|
|
15
|
+
throw new directory_contract_1.DirectoryPrincipalResolveError(401, "invalid_context", "This invocation has no valid directory credential");
|
|
16
|
+
return (0, browser_1.createDirectoryClient)({
|
|
17
|
+
transport: (0, browser_1.createPlatformTransport)({
|
|
18
|
+
baseUrl,
|
|
19
|
+
auth: { kind: "invocation-directory", token },
|
|
20
|
+
fetchImpl,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
74
23
|
}
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare function createFunctionStorageClient({ baseUrl, headers, mode, }: {
|
|
1
|
+
export declare function createFunctionStorageClient({ baseUrl, headers, mode, fetchImpl, }: {
|
|
2
2
|
baseUrl: string;
|
|
3
|
-
headers: Record<string, string | string[] | undefined
|
|
4
|
-
mode?:
|
|
3
|
+
headers: Pick<Headers, "get"> | Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
4
|
+
mode?: "user" | "service";
|
|
5
|
+
fetchImpl?: typeof globalThis.fetch;
|
|
5
6
|
}): {
|
|
6
7
|
capabilities: () => Promise<{
|
|
7
8
|
canProvision: boolean;
|
|
@@ -16,7 +17,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
16
17
|
max: number;
|
|
17
18
|
};
|
|
18
19
|
}>;
|
|
19
|
-
list: (options?: import("@sequenceholdings/storage").StorageListOptions) => Promise<{
|
|
20
|
+
list: (options?: import("@sequenceholdings/platform/storage").StorageListOptions) => Promise<{
|
|
20
21
|
items: {
|
|
21
22
|
id: string;
|
|
22
23
|
name: string;
|
|
@@ -32,7 +33,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
32
33
|
}[];
|
|
33
34
|
nextCursor: string | null;
|
|
34
35
|
}>;
|
|
35
|
-
shared: (options?: import("@sequenceholdings/storage").StorageListOptions & {
|
|
36
|
+
shared: (options?: import("@sequenceholdings/platform/storage").StorageListOptions & {
|
|
36
37
|
trash?: boolean;
|
|
37
38
|
}) => Promise<{
|
|
38
39
|
items: {
|
|
@@ -54,7 +55,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
54
55
|
}[];
|
|
55
56
|
nextCursor: string | null;
|
|
56
57
|
}>;
|
|
57
|
-
apply: (manifest: import("@sequenceholdings/storage").WorkspaceManifest) => Promise<{
|
|
58
|
+
apply: (manifest: import("@sequenceholdings/platform/storage").WorkspaceManifest) => Promise<{
|
|
58
59
|
id: string;
|
|
59
60
|
name: string;
|
|
60
61
|
description: string;
|
|
@@ -86,7 +87,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
86
87
|
workspaceId: string;
|
|
87
88
|
targetId: string | null;
|
|
88
89
|
kind: "purge" | "delete_version";
|
|
89
|
-
status: "
|
|
90
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
90
91
|
completed: number;
|
|
91
92
|
total: number;
|
|
92
93
|
error: string | null;
|
|
@@ -94,7 +95,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
94
95
|
updatedAt: string;
|
|
95
96
|
canRetry: boolean;
|
|
96
97
|
}>;
|
|
97
|
-
list: (options?: import("@sequenceholdings/storage").StorageListOptions & {
|
|
98
|
+
list: (options?: import("@sequenceholdings/platform/storage").StorageListOptions & {
|
|
98
99
|
parentId?: string | null;
|
|
99
100
|
trash?: boolean;
|
|
100
101
|
}) => Promise<{
|
|
@@ -134,6 +135,40 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
134
135
|
size: number | null;
|
|
135
136
|
contentType: string | null;
|
|
136
137
|
}>;
|
|
138
|
+
getNodeWithAncestors: (id: string) => Promise<{
|
|
139
|
+
id: string;
|
|
140
|
+
workspaceId: string;
|
|
141
|
+
parentId: string | null;
|
|
142
|
+
name: string;
|
|
143
|
+
kind: "file" | "folder";
|
|
144
|
+
state: "active" | "trashed" | "purging";
|
|
145
|
+
restricted: boolean;
|
|
146
|
+
revision: number;
|
|
147
|
+
currentVersionId: string | null;
|
|
148
|
+
metadata: Record<string, string>;
|
|
149
|
+
createdAt: string;
|
|
150
|
+
updatedAt: string;
|
|
151
|
+
role: "viewer" | "editor" | "admin";
|
|
152
|
+
size: number | null;
|
|
153
|
+
contentType: string | null;
|
|
154
|
+
ancestors: {
|
|
155
|
+
id: string;
|
|
156
|
+
workspaceId: string;
|
|
157
|
+
parentId: string | null;
|
|
158
|
+
name: string;
|
|
159
|
+
kind: "file" | "folder";
|
|
160
|
+
state: "active" | "trashed" | "purging";
|
|
161
|
+
restricted: boolean;
|
|
162
|
+
revision: number;
|
|
163
|
+
currentVersionId: string | null;
|
|
164
|
+
metadata: Record<string, string>;
|
|
165
|
+
createdAt: string;
|
|
166
|
+
updatedAt: string;
|
|
167
|
+
role: "viewer" | "editor" | "admin";
|
|
168
|
+
size: number | null;
|
|
169
|
+
contentType: string | null;
|
|
170
|
+
}[];
|
|
171
|
+
}>;
|
|
137
172
|
createFolder: (name: string, parentId?: string | null, { idempotencyKey, }?: {
|
|
138
173
|
idempotencyKey?: string;
|
|
139
174
|
}) => Promise<{
|
|
@@ -153,7 +188,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
153
188
|
size: number | null;
|
|
154
189
|
contentType: string | null;
|
|
155
190
|
}>;
|
|
156
|
-
update: (id: string, input: import("zod").input<typeof import("@sequenceholdings/storage").updateNodeSchema>) => Promise<{
|
|
191
|
+
update: (id: string, input: import("zod").input<typeof import("@sequenceholdings/platform/storage").updateNodeSchema>) => Promise<{
|
|
157
192
|
id: string;
|
|
158
193
|
workspaceId: string;
|
|
159
194
|
parentId: string | null;
|
|
@@ -209,7 +244,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
209
244
|
workspaceId: string;
|
|
210
245
|
targetId: string | null;
|
|
211
246
|
kind: "purge" | "delete_version";
|
|
212
|
-
status: "
|
|
247
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
213
248
|
completed: number;
|
|
214
249
|
total: number;
|
|
215
250
|
error: string | null;
|
|
@@ -258,7 +293,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
258
293
|
workspaceId: string;
|
|
259
294
|
targetId: string | null;
|
|
260
295
|
kind: "purge" | "delete_version";
|
|
261
|
-
status: "
|
|
296
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
262
297
|
completed: number;
|
|
263
298
|
total: number;
|
|
264
299
|
error: string | null;
|
|
@@ -270,7 +305,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
270
305
|
revision: number;
|
|
271
306
|
restricted: boolean;
|
|
272
307
|
grants: {
|
|
273
|
-
type: "user" | "
|
|
308
|
+
type: "user" | "service_account" | "group" | "organization";
|
|
274
309
|
id: string;
|
|
275
310
|
role: "viewer" | "editor" | "admin";
|
|
276
311
|
}[];
|
|
@@ -279,11 +314,11 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
279
314
|
workspaceAdminOverride: true;
|
|
280
315
|
displayNames: Record<string, string>;
|
|
281
316
|
}>;
|
|
282
|
-
setAccess: (input: import("zod").input<typeof import("@sequenceholdings/storage").updateStorageAccessSchema>, id?: string) => Promise<{
|
|
317
|
+
setAccess: (input: import("zod").input<typeof import("@sequenceholdings/platform/storage").updateStorageAccessSchema>, id?: string) => Promise<{
|
|
283
318
|
revision: number;
|
|
284
319
|
restricted: boolean;
|
|
285
320
|
grants: {
|
|
286
|
-
type: "user" | "
|
|
321
|
+
type: "user" | "service_account" | "group" | "organization";
|
|
287
322
|
id: string;
|
|
288
323
|
role: "viewer" | "editor" | "admin";
|
|
289
324
|
}[];
|
|
@@ -299,7 +334,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
299
334
|
revision: number;
|
|
300
335
|
restricted: boolean;
|
|
301
336
|
grants: {
|
|
302
|
-
type: "user" | "
|
|
337
|
+
type: "user" | "service_account" | "group" | "organization";
|
|
303
338
|
id: string;
|
|
304
339
|
role: "viewer" | "editor" | "admin";
|
|
305
340
|
}[];
|
|
@@ -311,14 +346,14 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
311
346
|
operations: (options?: {
|
|
312
347
|
before?: string;
|
|
313
348
|
limit?: number;
|
|
314
|
-
scope?: import("@sequenceholdings/storage").StorageOperationScope;
|
|
349
|
+
scope?: import("@sequenceholdings/platform/storage").StorageOperationScope;
|
|
315
350
|
}) => Promise<{
|
|
316
351
|
items: {
|
|
317
352
|
id: string;
|
|
318
353
|
workspaceId: string;
|
|
319
354
|
targetId: string | null;
|
|
320
355
|
kind: "purge" | "delete_version";
|
|
321
|
-
status: "
|
|
356
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
322
357
|
completed: number;
|
|
323
358
|
total: number;
|
|
324
359
|
error: string | null;
|
|
@@ -333,7 +368,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
333
368
|
workspaceId: string;
|
|
334
369
|
targetId: string | null;
|
|
335
370
|
kind: "purge" | "delete_version";
|
|
336
|
-
status: "
|
|
371
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
337
372
|
completed: number;
|
|
338
373
|
total: number;
|
|
339
374
|
error: string | null;
|
|
@@ -342,12 +377,12 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
342
377
|
canRetry: boolean;
|
|
343
378
|
}>;
|
|
344
379
|
uploads: {
|
|
345
|
-
start: (input: import("@sequenceholdings/storage").StartStorageUpload) => Promise<{
|
|
380
|
+
start: (input: import("@sequenceholdings/platform/storage").StartStorageUpload) => Promise<{
|
|
346
381
|
id: string;
|
|
347
382
|
fileId: string;
|
|
348
383
|
uploadUrl: string | null;
|
|
349
384
|
expiresAt: string;
|
|
350
|
-
state: "
|
|
385
|
+
state: "aborted" | "pending" | "complete";
|
|
351
386
|
versionId: string | null;
|
|
352
387
|
maxBytes: number;
|
|
353
388
|
}>;
|
|
@@ -356,16 +391,16 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
356
391
|
fileId: string;
|
|
357
392
|
uploadUrl: string | null;
|
|
358
393
|
expiresAt: string;
|
|
359
|
-
state: "
|
|
394
|
+
state: "aborted" | "pending" | "complete";
|
|
360
395
|
versionId: string | null;
|
|
361
396
|
maxBytes: number;
|
|
362
397
|
}>;
|
|
363
|
-
complete: (id: string, input?: import("@sequenceholdings/storage").CompleteStorageUpload) => Promise<{
|
|
398
|
+
complete: (id: string, input?: import("@sequenceholdings/platform/storage").CompleteStorageUpload) => Promise<{
|
|
364
399
|
id: string;
|
|
365
400
|
fileId: string;
|
|
366
401
|
uploadUrl: string | null;
|
|
367
402
|
expiresAt: string;
|
|
368
|
-
state: "
|
|
403
|
+
state: "aborted" | "pending" | "complete";
|
|
369
404
|
versionId: string | null;
|
|
370
405
|
maxBytes: number;
|
|
371
406
|
}>;
|
|
@@ -374,17 +409,17 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
374
409
|
fileId: string;
|
|
375
410
|
uploadUrl: string | null;
|
|
376
411
|
expiresAt: string;
|
|
377
|
-
state: "
|
|
412
|
+
state: "aborted" | "pending" | "complete";
|
|
378
413
|
versionId: string | null;
|
|
379
414
|
maxBytes: number;
|
|
380
415
|
}>;
|
|
381
|
-
startBatch: (items: import("@sequenceholdings/storage").StartStorageUpload[]) => Promise<{
|
|
416
|
+
startBatch: (items: import("@sequenceholdings/platform/storage").StartStorageUpload[]) => Promise<{
|
|
382
417
|
items: {
|
|
383
418
|
id: string;
|
|
384
419
|
fileId: string;
|
|
385
420
|
uploadUrl: string | null;
|
|
386
421
|
expiresAt: string;
|
|
387
|
-
state: "
|
|
422
|
+
state: "aborted" | "pending" | "complete";
|
|
388
423
|
versionId: string | null;
|
|
389
424
|
maxBytes: number;
|
|
390
425
|
}[];
|
|
@@ -394,7 +429,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
394
429
|
id: string;
|
|
395
430
|
fileId: string;
|
|
396
431
|
name: string;
|
|
397
|
-
state: "
|
|
432
|
+
state: "aborted" | "pending" | "complete";
|
|
398
433
|
expiresAt: string;
|
|
399
434
|
maxBytes: number;
|
|
400
435
|
expectedSize: number | null;
|
|
@@ -412,7 +447,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
412
447
|
id: string;
|
|
413
448
|
fileId: string;
|
|
414
449
|
name: string;
|
|
415
|
-
state: "
|
|
450
|
+
state: "aborted" | "pending" | "complete";
|
|
416
451
|
expiresAt: string;
|
|
417
452
|
maxBytes: number;
|
|
418
453
|
expectedSize: number | null;
|
|
@@ -424,7 +459,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
424
459
|
id: string;
|
|
425
460
|
fileId: string;
|
|
426
461
|
name: string;
|
|
427
|
-
state: "
|
|
462
|
+
state: "aborted" | "pending" | "complete";
|
|
428
463
|
expiresAt: string;
|
|
429
464
|
maxBytes: number;
|
|
430
465
|
expectedSize: number | null;
|
|
@@ -436,7 +471,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
436
471
|
id: string;
|
|
437
472
|
fileId: string;
|
|
438
473
|
name: string;
|
|
439
|
-
state: "
|
|
474
|
+
state: "aborted" | "pending" | "complete";
|
|
440
475
|
expiresAt: string;
|
|
441
476
|
maxBytes: number;
|
|
442
477
|
expectedSize: number | null;
|
|
@@ -445,27 +480,27 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
445
480
|
message: string;
|
|
446
481
|
}[];
|
|
447
482
|
}>;
|
|
448
|
-
resume(id: string, source: import("@sequenceholdings/storage").StorageUploadSource, options?: import("@sequenceholdings/storage").StorageTransferOptions & {
|
|
483
|
+
resume(id: string, source: import("@sequenceholdings/platform/storage").StorageUploadSource, options?: import("@sequenceholdings/platform/storage").StorageTransferOptions & {
|
|
449
484
|
size?: number;
|
|
450
485
|
}): Promise<{
|
|
451
486
|
id: string;
|
|
452
487
|
fileId: string;
|
|
453
488
|
uploadUrl: string | null;
|
|
454
489
|
expiresAt: string;
|
|
455
|
-
state: "
|
|
490
|
+
state: "aborted" | "pending" | "complete";
|
|
456
491
|
versionId: string | null;
|
|
457
492
|
maxBytes: number;
|
|
458
493
|
}>;
|
|
459
|
-
put(input: Omit<import("@sequenceholdings/storage").StartStorageUpload, "idempotencyKey"> & {
|
|
494
|
+
put(input: Omit<import("@sequenceholdings/platform/storage").StartStorageUpload, "idempotencyKey"> & {
|
|
460
495
|
idempotencyKey?: string;
|
|
461
|
-
}, source: import("@sequenceholdings/storage").StorageUploadSource, { keepSessionOnFailure, ...options }?: import("@sequenceholdings/storage").StorageTransferOptions & {
|
|
496
|
+
}, source: import("@sequenceholdings/platform/storage").StorageUploadSource, { keepSessionOnFailure, ...options }?: import("@sequenceholdings/platform/storage").StorageTransferOptions & {
|
|
462
497
|
keepSessionOnFailure?: boolean;
|
|
463
498
|
}): Promise<{
|
|
464
499
|
id: string;
|
|
465
500
|
fileId: string;
|
|
466
501
|
uploadUrl: string | null;
|
|
467
502
|
expiresAt: string;
|
|
468
|
-
state: "
|
|
503
|
+
state: "aborted" | "pending" | "complete";
|
|
469
504
|
versionId: string | null;
|
|
470
505
|
maxBytes: number;
|
|
471
506
|
}>;
|
package/dist/storage.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFunctionStorageClient = createFunctionStorageClient;
|
|
4
|
-
const storage_1 = require("@sequenceholdings/storage");
|
|
5
|
-
function createFunctionStorageClient({ baseUrl, headers, mode =
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const storage_1 = require("@sequenceholdings/platform/storage");
|
|
5
|
+
function createFunctionStorageClient({ baseUrl, headers, mode = "user", fetchImpl, }) {
|
|
6
|
+
const name = mode === "service" ? storage_1.STORAGE_SERVICE_TOKEN_HEADER : storage_1.STORAGE_TOKEN_HEADER;
|
|
7
|
+
const values = typeof headers.get === "function"
|
|
8
|
+
? [headers.get(name)]
|
|
9
|
+
: Object.entries(headers)
|
|
10
|
+
.filter(([key]) => key.toLowerCase() === name)
|
|
11
|
+
.map(([, value]) => value);
|
|
12
|
+
const token = values.length === 1 ? values[0] : undefined;
|
|
13
|
+
if (typeof token !== "string" || !token)
|
|
14
|
+
throw new Error("Storage access is not declared for this function invocation");
|
|
9
15
|
return (0, storage_1.createStorageClient)({
|
|
10
16
|
baseUrl,
|
|
17
|
+
fetch: fetchImpl,
|
|
11
18
|
getHeaders: () => ({ [storage_1.STORAGE_TOKEN_HEADER]: token }),
|
|
12
19
|
});
|
|
13
20
|
}
|