@sequenceholdings/managed-functions 0.4.5 → 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 +4251 -1666
- 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 +36 -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<{
|
|
@@ -187,7 +188,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
187
188
|
size: number | null;
|
|
188
189
|
contentType: string | null;
|
|
189
190
|
}>;
|
|
190
|
-
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<{
|
|
191
192
|
id: string;
|
|
192
193
|
workspaceId: string;
|
|
193
194
|
parentId: string | null;
|
|
@@ -243,7 +244,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
243
244
|
workspaceId: string;
|
|
244
245
|
targetId: string | null;
|
|
245
246
|
kind: "purge" | "delete_version";
|
|
246
|
-
status: "
|
|
247
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
247
248
|
completed: number;
|
|
248
249
|
total: number;
|
|
249
250
|
error: string | null;
|
|
@@ -292,7 +293,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
292
293
|
workspaceId: string;
|
|
293
294
|
targetId: string | null;
|
|
294
295
|
kind: "purge" | "delete_version";
|
|
295
|
-
status: "
|
|
296
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
296
297
|
completed: number;
|
|
297
298
|
total: number;
|
|
298
299
|
error: string | null;
|
|
@@ -304,7 +305,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
304
305
|
revision: number;
|
|
305
306
|
restricted: boolean;
|
|
306
307
|
grants: {
|
|
307
|
-
type: "user" | "
|
|
308
|
+
type: "user" | "service_account" | "group" | "organization";
|
|
308
309
|
id: string;
|
|
309
310
|
role: "viewer" | "editor" | "admin";
|
|
310
311
|
}[];
|
|
@@ -313,11 +314,11 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
313
314
|
workspaceAdminOverride: true;
|
|
314
315
|
displayNames: Record<string, string>;
|
|
315
316
|
}>;
|
|
316
|
-
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<{
|
|
317
318
|
revision: number;
|
|
318
319
|
restricted: boolean;
|
|
319
320
|
grants: {
|
|
320
|
-
type: "user" | "
|
|
321
|
+
type: "user" | "service_account" | "group" | "organization";
|
|
321
322
|
id: string;
|
|
322
323
|
role: "viewer" | "editor" | "admin";
|
|
323
324
|
}[];
|
|
@@ -333,7 +334,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
333
334
|
revision: number;
|
|
334
335
|
restricted: boolean;
|
|
335
336
|
grants: {
|
|
336
|
-
type: "user" | "
|
|
337
|
+
type: "user" | "service_account" | "group" | "organization";
|
|
337
338
|
id: string;
|
|
338
339
|
role: "viewer" | "editor" | "admin";
|
|
339
340
|
}[];
|
|
@@ -345,14 +346,14 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
345
346
|
operations: (options?: {
|
|
346
347
|
before?: string;
|
|
347
348
|
limit?: number;
|
|
348
|
-
scope?: import("@sequenceholdings/storage").StorageOperationScope;
|
|
349
|
+
scope?: import("@sequenceholdings/platform/storage").StorageOperationScope;
|
|
349
350
|
}) => Promise<{
|
|
350
351
|
items: {
|
|
351
352
|
id: string;
|
|
352
353
|
workspaceId: string;
|
|
353
354
|
targetId: string | null;
|
|
354
355
|
kind: "purge" | "delete_version";
|
|
355
|
-
status: "
|
|
356
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
356
357
|
completed: number;
|
|
357
358
|
total: number;
|
|
358
359
|
error: string | null;
|
|
@@ -367,7 +368,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
367
368
|
workspaceId: string;
|
|
368
369
|
targetId: string | null;
|
|
369
370
|
kind: "purge" | "delete_version";
|
|
370
|
-
status: "
|
|
371
|
+
status: "running" | "failed" | "queued" | "succeeded";
|
|
371
372
|
completed: number;
|
|
372
373
|
total: number;
|
|
373
374
|
error: string | null;
|
|
@@ -376,12 +377,12 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
376
377
|
canRetry: boolean;
|
|
377
378
|
}>;
|
|
378
379
|
uploads: {
|
|
379
|
-
start: (input: import("@sequenceholdings/storage").StartStorageUpload) => Promise<{
|
|
380
|
+
start: (input: import("@sequenceholdings/platform/storage").StartStorageUpload) => Promise<{
|
|
380
381
|
id: string;
|
|
381
382
|
fileId: string;
|
|
382
383
|
uploadUrl: string | null;
|
|
383
384
|
expiresAt: string;
|
|
384
|
-
state: "
|
|
385
|
+
state: "aborted" | "pending" | "complete";
|
|
385
386
|
versionId: string | null;
|
|
386
387
|
maxBytes: number;
|
|
387
388
|
}>;
|
|
@@ -390,16 +391,16 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
390
391
|
fileId: string;
|
|
391
392
|
uploadUrl: string | null;
|
|
392
393
|
expiresAt: string;
|
|
393
|
-
state: "
|
|
394
|
+
state: "aborted" | "pending" | "complete";
|
|
394
395
|
versionId: string | null;
|
|
395
396
|
maxBytes: number;
|
|
396
397
|
}>;
|
|
397
|
-
complete: (id: string, input?: import("@sequenceholdings/storage").CompleteStorageUpload) => Promise<{
|
|
398
|
+
complete: (id: string, input?: import("@sequenceholdings/platform/storage").CompleteStorageUpload) => Promise<{
|
|
398
399
|
id: string;
|
|
399
400
|
fileId: string;
|
|
400
401
|
uploadUrl: string | null;
|
|
401
402
|
expiresAt: string;
|
|
402
|
-
state: "
|
|
403
|
+
state: "aborted" | "pending" | "complete";
|
|
403
404
|
versionId: string | null;
|
|
404
405
|
maxBytes: number;
|
|
405
406
|
}>;
|
|
@@ -408,17 +409,17 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
408
409
|
fileId: string;
|
|
409
410
|
uploadUrl: string | null;
|
|
410
411
|
expiresAt: string;
|
|
411
|
-
state: "
|
|
412
|
+
state: "aborted" | "pending" | "complete";
|
|
412
413
|
versionId: string | null;
|
|
413
414
|
maxBytes: number;
|
|
414
415
|
}>;
|
|
415
|
-
startBatch: (items: import("@sequenceholdings/storage").StartStorageUpload[]) => Promise<{
|
|
416
|
+
startBatch: (items: import("@sequenceholdings/platform/storage").StartStorageUpload[]) => Promise<{
|
|
416
417
|
items: {
|
|
417
418
|
id: string;
|
|
418
419
|
fileId: string;
|
|
419
420
|
uploadUrl: string | null;
|
|
420
421
|
expiresAt: string;
|
|
421
|
-
state: "
|
|
422
|
+
state: "aborted" | "pending" | "complete";
|
|
422
423
|
versionId: string | null;
|
|
423
424
|
maxBytes: number;
|
|
424
425
|
}[];
|
|
@@ -428,7 +429,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
428
429
|
id: string;
|
|
429
430
|
fileId: string;
|
|
430
431
|
name: string;
|
|
431
|
-
state: "
|
|
432
|
+
state: "aborted" | "pending" | "complete";
|
|
432
433
|
expiresAt: string;
|
|
433
434
|
maxBytes: number;
|
|
434
435
|
expectedSize: number | null;
|
|
@@ -446,7 +447,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
446
447
|
id: string;
|
|
447
448
|
fileId: string;
|
|
448
449
|
name: string;
|
|
449
|
-
state: "
|
|
450
|
+
state: "aborted" | "pending" | "complete";
|
|
450
451
|
expiresAt: string;
|
|
451
452
|
maxBytes: number;
|
|
452
453
|
expectedSize: number | null;
|
|
@@ -458,7 +459,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
458
459
|
id: string;
|
|
459
460
|
fileId: string;
|
|
460
461
|
name: string;
|
|
461
|
-
state: "
|
|
462
|
+
state: "aborted" | "pending" | "complete";
|
|
462
463
|
expiresAt: string;
|
|
463
464
|
maxBytes: number;
|
|
464
465
|
expectedSize: number | null;
|
|
@@ -470,7 +471,7 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
470
471
|
id: string;
|
|
471
472
|
fileId: string;
|
|
472
473
|
name: string;
|
|
473
|
-
state: "
|
|
474
|
+
state: "aborted" | "pending" | "complete";
|
|
474
475
|
expiresAt: string;
|
|
475
476
|
maxBytes: number;
|
|
476
477
|
expectedSize: number | null;
|
|
@@ -479,27 +480,27 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
|
|
|
479
480
|
message: string;
|
|
480
481
|
}[];
|
|
481
482
|
}>;
|
|
482
|
-
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 & {
|
|
483
484
|
size?: number;
|
|
484
485
|
}): Promise<{
|
|
485
486
|
id: string;
|
|
486
487
|
fileId: string;
|
|
487
488
|
uploadUrl: string | null;
|
|
488
489
|
expiresAt: string;
|
|
489
|
-
state: "
|
|
490
|
+
state: "aborted" | "pending" | "complete";
|
|
490
491
|
versionId: string | null;
|
|
491
492
|
maxBytes: number;
|
|
492
493
|
}>;
|
|
493
|
-
put(input: Omit<import("@sequenceholdings/storage").StartStorageUpload, "idempotencyKey"> & {
|
|
494
|
+
put(input: Omit<import("@sequenceholdings/platform/storage").StartStorageUpload, "idempotencyKey"> & {
|
|
494
495
|
idempotencyKey?: string;
|
|
495
|
-
}, 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 & {
|
|
496
497
|
keepSessionOnFailure?: boolean;
|
|
497
498
|
}): Promise<{
|
|
498
499
|
id: string;
|
|
499
500
|
fileId: string;
|
|
500
501
|
uploadUrl: string | null;
|
|
501
502
|
expiresAt: string;
|
|
502
|
-
state: "
|
|
503
|
+
state: "aborted" | "pending" | "complete";
|
|
503
504
|
versionId: string | null;
|
|
504
505
|
maxBytes: number;
|
|
505
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
|
}
|