@nsp-labs/agnostic-sdk 1.1.0 → 1.5.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/CHANGELOG.md +58 -0
- package/README.md +88 -1
- package/package.json +1 -1
- package/src/generated/openapi.d.ts +998 -10
- package/src/index.d.ts +2 -2
- package/src/index.js +4 -1
- package/src/lib/manifest.d.ts +5 -3
- package/src/lib/manifest.js +23 -3
- package/src/lib/runtime-client.d.ts +27 -1
- package/src/lib/runtime-client.js +105 -1
- package/src/lib/types.d.ts +105 -0
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AgnosticRuntime, RuntimeAppAuthNamespace, RuntimeContextNamespace, RuntimeDataNamespace, RuntimeDataRecordsClient, RuntimeDataTableClient, RuntimeDataViewClient, RuntimeDataViewTableClient, RuntimeWorkflowRunsNamespace, RuntimeWorkflowsNamespace, createAgnosticRuntime, } from './lib/runtime-client';
|
|
1
|
+
export { AgnosticRuntime, RuntimeAppAuthNamespace, RuntimeContextNamespace, RuntimeDataNamespace, RuntimeDataRecordsClient, RuntimeDataTableClient, RuntimeDataViewClient, RuntimeDataViewTableClient, RuntimeAnonymousUploadsClient, RuntimeStorageBucketClient, RuntimeStorageNamespace, RuntimeWorkflowRunsNamespace, RuntimeWorkflowsNamespace, createAgnosticRuntime, } from './lib/runtime-client';
|
|
2
2
|
export { normalizeApiUrl, resolveRuntimeContext } from './lib/context';
|
|
3
3
|
export { AgnosticRuntimeError } from './lib/errors';
|
|
4
4
|
export { AGNOSTIC_RUNTIME_SDK_MANIFEST, type AgnosticRuntimeSdkManifest, } from './lib/manifest';
|
|
5
|
-
export type { AgnosticRuntimeConfig, ResolvedRuntimeContext, RuntimeActorMetadata, RuntimeActorType, RuntimeAppAuthActor, RuntimeAppAuthCachePolicy, RuntimeAppAuthRequestLike, RuntimeAppAuthSession, RuntimeAppAuthSessionClaims, RuntimeAppAuthUserClaims, RuntimeAppAuthUserResult, RuntimeCreateRecordInput, RuntimeDataField, RuntimeDataViewState, RuntimeIdentityContext, RuntimeListRecordsOptions, RuntimeListWindowOptions, RuntimeRecord, RuntimeRecordMutation, RuntimeRecordsList, RuntimeRequestOptions, RuntimeRowData, RuntimeRowValue, RuntimeTableWindow, RuntimeUpdateRecordInput, RuntimeWorkflowRun, RuntimeWorkflowStepRun, RuntimeWorkflowWaitOptions, WorkflowRunStatus, } from './lib/types';
|
|
5
|
+
export type { RuntimeQueryRecordsInput, RuntimeBatchQueryItem, RuntimeBatchQueryResult, AgnosticRuntimeConfig, RuntimeAggregateMetric, RuntimeAggregateOperation, RuntimeAggregateOrderBy, RuntimeAggregateRecordsInput, RuntimeAggregateRecordsResult, RuntimeAggregateRow, ResolvedRuntimeContext, RuntimeActorMetadata, RuntimeActorType, RuntimeAnonymousClaimFileHandle, RuntimeAnonymousClaimInput, RuntimeAnonymousClaimResult, RuntimeAppAuthActor, RuntimeAppAuthCachePolicy, RuntimeAppAuthRequestLike, RuntimeAppAuthSession, RuntimeAppAuthSessionClaims, RuntimeAppAuthUserClaims, RuntimeAppAuthUserResult, RuntimeCreateRecordInput, RuntimeCreateFileUploadInput, RuntimeDataField, RuntimeDataViewState, RuntimeIdentityContext, RuntimeFileAccessMode, RuntimeFileDownloadUrl, RuntimeFileObject, RuntimeFileObjectStatus, RuntimeFileUploadCompletion, RuntimeFileUploadGrant, RuntimeListRecordsOptions, RuntimeListWindowOptions, RuntimeRecord, RuntimeRecordMutation, RuntimeRecordsList, RuntimeRequestOptions, RuntimeRowData, RuntimeRowValue, RuntimeTableWindow, RuntimeUpdateRecordInput, RuntimeWorkflowRun, RuntimeWorkflowStepRun, RuntimeWorkflowWaitOptions, WorkflowRunStatus, } from './lib/types';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AGNOSTIC_RUNTIME_SDK_MANIFEST = exports.AgnosticRuntimeError = exports.resolveRuntimeContext = exports.normalizeApiUrl = exports.createAgnosticRuntime = exports.RuntimeWorkflowsNamespace = exports.RuntimeWorkflowRunsNamespace = exports.RuntimeDataViewTableClient = exports.RuntimeDataViewClient = exports.RuntimeDataTableClient = exports.RuntimeDataRecordsClient = exports.RuntimeDataNamespace = exports.RuntimeContextNamespace = exports.RuntimeAppAuthNamespace = exports.AgnosticRuntime = void 0;
|
|
3
|
+
exports.AGNOSTIC_RUNTIME_SDK_MANIFEST = exports.AgnosticRuntimeError = exports.resolveRuntimeContext = exports.normalizeApiUrl = exports.createAgnosticRuntime = exports.RuntimeWorkflowsNamespace = exports.RuntimeWorkflowRunsNamespace = exports.RuntimeStorageNamespace = exports.RuntimeStorageBucketClient = exports.RuntimeAnonymousUploadsClient = exports.RuntimeDataViewTableClient = exports.RuntimeDataViewClient = exports.RuntimeDataTableClient = exports.RuntimeDataRecordsClient = exports.RuntimeDataNamespace = exports.RuntimeContextNamespace = exports.RuntimeAppAuthNamespace = exports.AgnosticRuntime = void 0;
|
|
4
4
|
var runtime_client_1 = require("./lib/runtime-client");
|
|
5
5
|
Object.defineProperty(exports, "AgnosticRuntime", { enumerable: true, get: function () { return runtime_client_1.AgnosticRuntime; } });
|
|
6
6
|
Object.defineProperty(exports, "RuntimeAppAuthNamespace", { enumerable: true, get: function () { return runtime_client_1.RuntimeAppAuthNamespace; } });
|
|
@@ -10,6 +10,9 @@ Object.defineProperty(exports, "RuntimeDataRecordsClient", { enumerable: true, g
|
|
|
10
10
|
Object.defineProperty(exports, "RuntimeDataTableClient", { enumerable: true, get: function () { return runtime_client_1.RuntimeDataTableClient; } });
|
|
11
11
|
Object.defineProperty(exports, "RuntimeDataViewClient", { enumerable: true, get: function () { return runtime_client_1.RuntimeDataViewClient; } });
|
|
12
12
|
Object.defineProperty(exports, "RuntimeDataViewTableClient", { enumerable: true, get: function () { return runtime_client_1.RuntimeDataViewTableClient; } });
|
|
13
|
+
Object.defineProperty(exports, "RuntimeAnonymousUploadsClient", { enumerable: true, get: function () { return runtime_client_1.RuntimeAnonymousUploadsClient; } });
|
|
14
|
+
Object.defineProperty(exports, "RuntimeStorageBucketClient", { enumerable: true, get: function () { return runtime_client_1.RuntimeStorageBucketClient; } });
|
|
15
|
+
Object.defineProperty(exports, "RuntimeStorageNamespace", { enumerable: true, get: function () { return runtime_client_1.RuntimeStorageNamespace; } });
|
|
13
16
|
Object.defineProperty(exports, "RuntimeWorkflowRunsNamespace", { enumerable: true, get: function () { return runtime_client_1.RuntimeWorkflowRunsNamespace; } });
|
|
14
17
|
Object.defineProperty(exports, "RuntimeWorkflowsNamespace", { enumerable: true, get: function () { return runtime_client_1.RuntimeWorkflowsNamespace; } });
|
|
15
18
|
Object.defineProperty(exports, "createAgnosticRuntime", { enumerable: true, get: function () { return runtime_client_1.createAgnosticRuntime; } });
|
package/src/lib/manifest.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const AGNOSTIC_RUNTIME_SDK_MANIFEST: Readonly<{
|
|
|
9
9
|
readonly schema: "agnostic_runtime_sdk_manifest.v1";
|
|
10
10
|
readonly package: Readonly<{
|
|
11
11
|
name: "@nsp-labs/agnostic-sdk";
|
|
12
|
-
version: "1.
|
|
12
|
+
version: "1.5.0";
|
|
13
13
|
factory: "createAgnosticRuntime";
|
|
14
14
|
runtime: "server_only";
|
|
15
15
|
}>;
|
|
@@ -18,12 +18,13 @@ export declare const AGNOSTIC_RUNTIME_SDK_MANIFEST: Readonly<{
|
|
|
18
18
|
environmentVariables: readonly string[];
|
|
19
19
|
secretEnvironmentVariables: readonly string[];
|
|
20
20
|
}>;
|
|
21
|
-
readonly rootMembers: readonly [...("data" | "auth" | "context" | "workflows" | "workflowRuns")[], "getRuntimeContext"];
|
|
21
|
+
readonly rootMembers: readonly [...("data" | "auth" | "context" | "storage" | "workflows" | "workflowRuns")[], "getRuntimeContext"];
|
|
22
22
|
readonly clientMethods: readonly ["getRuntimeContext"];
|
|
23
23
|
readonly namespaces: Readonly<{
|
|
24
24
|
auth: readonly ("requireSession" | "getSession" | "requireScopes" | "getUser")[];
|
|
25
25
|
context: readonly "get"[];
|
|
26
|
-
data: readonly ("table(name).records.delete" | "table(name).records.list" | "table(name).records.create" | "table(name).records.update" | "view(id).table.window")[];
|
|
26
|
+
data: readonly ("batchQuery" | "table(name).records.delete" | "table(name).records.query" | "table(name).records.list" | "table(name).records.aggregate" | "table(name).records.create" | "table(name).records.update" | "view(id).table.window")[];
|
|
27
|
+
storage: readonly ("bucket(name).get" | "bucket(name).delete" | "bucket(name).createUpload" | "bucket(name).completeUpload" | "bucket(name).createDownloadUrl" | "bucket(name).anonymousUploads.claim")[];
|
|
27
28
|
workflows: readonly ("start" | "getRun")[];
|
|
28
29
|
workflowRuns: readonly ("get" | "wait" | "listSteps")[];
|
|
29
30
|
}>;
|
|
@@ -32,6 +33,7 @@ export declare const AGNOSTIC_RUNTIME_SDK_MANIFEST: Readonly<{
|
|
|
32
33
|
controlPlaneProvisioning: "agent_product_tools";
|
|
33
34
|
runtimeAccess: "server_sdk";
|
|
34
35
|
browserAccess: "public_api_or_app_auth_session";
|
|
36
|
+
appAuthSelfService: "public_api_via_project_backend_bff";
|
|
35
37
|
browserPackageImportAllowed: false;
|
|
36
38
|
browserRuntimeTokenAllowed: false;
|
|
37
39
|
}>;
|
package/src/lib/manifest.js
CHANGED
|
@@ -11,12 +11,14 @@ const AUTH_KEYS_LITERAL = [
|
|
|
11
11
|
const AUTH_KEYS = AUTH_KEYS_LITERAL;
|
|
12
12
|
const CONTEXT_KEYS_LITERAL = ['get'];
|
|
13
13
|
const CONTEXT_KEYS = CONTEXT_KEYS_LITERAL;
|
|
14
|
-
const DATA_NAMESPACE_KEYS_LITERAL = ['table', 'view'];
|
|
14
|
+
const DATA_NAMESPACE_KEYS_LITERAL = ['table', 'view', 'batchQuery'];
|
|
15
15
|
const DATA_NAMESPACE_KEYS = DATA_NAMESPACE_KEYS_LITERAL;
|
|
16
16
|
const DATA_TABLE_KEYS_LITERAL = ['records'];
|
|
17
17
|
const DATA_TABLE_KEYS = DATA_TABLE_KEYS_LITERAL;
|
|
18
18
|
const DATA_RECORD_KEYS_LITERAL = [
|
|
19
19
|
'list',
|
|
20
|
+
'query',
|
|
21
|
+
'aggregate',
|
|
20
22
|
'create',
|
|
21
23
|
'update',
|
|
22
24
|
'delete',
|
|
@@ -26,6 +28,19 @@ const DATA_VIEW_KEYS_LITERAL = ['table'];
|
|
|
26
28
|
const DATA_VIEW_KEYS = DATA_VIEW_KEYS_LITERAL;
|
|
27
29
|
const DATA_VIEW_TABLE_KEYS_LITERAL = ['window'];
|
|
28
30
|
const DATA_VIEW_TABLE_KEYS = DATA_VIEW_TABLE_KEYS_LITERAL;
|
|
31
|
+
const STORAGE_NAMESPACE_KEYS_LITERAL = ['bucket'];
|
|
32
|
+
const STORAGE_NAMESPACE_KEYS = STORAGE_NAMESPACE_KEYS_LITERAL;
|
|
33
|
+
const STORAGE_BUCKET_KEYS_LITERAL = [
|
|
34
|
+
'anonymousUploads',
|
|
35
|
+
'createUpload',
|
|
36
|
+
'completeUpload',
|
|
37
|
+
'get',
|
|
38
|
+
'createDownloadUrl',
|
|
39
|
+
'delete',
|
|
40
|
+
];
|
|
41
|
+
const STORAGE_BUCKET_KEYS = STORAGE_BUCKET_KEYS_LITERAL;
|
|
42
|
+
const ANONYMOUS_UPLOAD_KEYS_LITERAL = ['claim'];
|
|
43
|
+
const ANONYMOUS_UPLOAD_KEYS = ANONYMOUS_UPLOAD_KEYS_LITERAL;
|
|
29
44
|
const WORKFLOW_KEYS_LITERAL = ['start', 'getRun'];
|
|
30
45
|
const WORKFLOW_KEYS = WORKFLOW_KEYS_LITERAL;
|
|
31
46
|
const WORKFLOW_RUN_KEYS_LITERAL = ['get', 'wait', 'listSteps'];
|
|
@@ -37,6 +52,11 @@ const NAMESPACES = Object.freeze({
|
|
|
37
52
|
data: Object.freeze([
|
|
38
53
|
...DATA_RECORD_KEYS.map((method) => `${DATA_NAMESPACE_KEYS[0]}(name).${DATA_TABLE_KEYS[0]}.${method}`),
|
|
39
54
|
...DATA_VIEW_TABLE_KEYS.map((method) => `${DATA_NAMESPACE_KEYS[1]}(id).${DATA_VIEW_KEYS[0]}.${method}`),
|
|
55
|
+
DATA_NAMESPACE_KEYS[2],
|
|
56
|
+
]),
|
|
57
|
+
storage: Object.freeze([
|
|
58
|
+
...STORAGE_BUCKET_KEYS.filter((method) => method !== 'anonymousUploads').map((method) => `${STORAGE_NAMESPACE_KEYS[0]}(name).${method}`),
|
|
59
|
+
...ANONYMOUS_UPLOAD_KEYS.map((method) => `${STORAGE_NAMESPACE_KEYS[0]}(name).${STORAGE_BUCKET_KEYS[0]}.${method}`),
|
|
40
60
|
]),
|
|
41
61
|
workflows: Object.freeze([...WORKFLOW_KEYS]),
|
|
42
62
|
workflowRuns: Object.freeze([...WORKFLOW_RUN_KEYS]),
|
|
@@ -50,7 +70,7 @@ const MANIFEST_CONTRACT = Object.freeze({
|
|
|
50
70
|
schema: 'agnostic_runtime_sdk_manifest.v1',
|
|
51
71
|
package: Object.freeze({
|
|
52
72
|
name: '@nsp-labs/agnostic-sdk',
|
|
53
|
-
version: '1.
|
|
73
|
+
version: '1.5.0',
|
|
54
74
|
factory: 'createAgnosticRuntime',
|
|
55
75
|
runtime: 'server_only',
|
|
56
76
|
}),
|
|
@@ -73,12 +93,12 @@ const MANIFEST_CONTRACT = Object.freeze({
|
|
|
73
93
|
'gateway',
|
|
74
94
|
'jobs',
|
|
75
95
|
'realtime',
|
|
76
|
-
'storage',
|
|
77
96
|
]),
|
|
78
97
|
boundaries: Object.freeze({
|
|
79
98
|
controlPlaneProvisioning: 'agent_product_tools',
|
|
80
99
|
runtimeAccess: 'server_sdk',
|
|
81
100
|
browserAccess: 'public_api_or_app_auth_session',
|
|
101
|
+
appAuthSelfService: 'public_api_via_project_backend_bff',
|
|
82
102
|
browserPackageImportAllowed: false,
|
|
83
103
|
browserRuntimeTokenAllowed: false,
|
|
84
104
|
}),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type RuntimeOpenApiClient } from './http-client';
|
|
2
|
-
import type { AgnosticRuntimeConfig, ResolvedRuntimeContext, RuntimeAppAuthRequestLike, RuntimeAppAuthSession, RuntimeAppAuthUserResult, RuntimeCreateRecordInput, RuntimeIdentityContext, RuntimeListRecordsOptions, RuntimeListWindowOptions, RuntimeRecordMutation, RuntimeRecordsList, RuntimeRequestOptions, RuntimeRowData, RuntimeTableWindow, RuntimeUpdateRecordInput, RuntimeWorkflowRun, RuntimeWorkflowStepRun, RuntimeWorkflowWaitOptions } from './types';
|
|
2
|
+
import type { AgnosticRuntimeConfig, ResolvedRuntimeContext, RuntimeAppAuthRequestLike, RuntimeAppAuthSession, RuntimeAppAuthUserResult, RuntimeAnonymousClaimInput, RuntimeAnonymousClaimResult, RuntimeAggregateRecordsInput, RuntimeAggregateRecordsResult, RuntimeCreateFileUploadInput, RuntimeCreateRecordInput, RuntimeIdentityContext, RuntimeFileDownloadUrl, RuntimeFileObject, RuntimeFileUploadCompletion, RuntimeFileUploadGrant, RuntimeListRecordsOptions, RuntimeQueryRecordsInput, RuntimeBatchQueryItem, RuntimeBatchQueryResult, RuntimeListWindowOptions, RuntimeRecordMutation, RuntimeRecordsList, RuntimeRequestOptions, RuntimeRowData, RuntimeTableWindow, RuntimeUpdateRecordInput, RuntimeWorkflowRun, RuntimeWorkflowStepRun, RuntimeWorkflowWaitOptions } from './types';
|
|
3
3
|
export declare class AgnosticRuntime {
|
|
4
4
|
readonly auth: RuntimeAppAuthNamespace;
|
|
5
5
|
readonly context: RuntimeContextNamespace;
|
|
6
6
|
readonly data: RuntimeDataNamespace;
|
|
7
|
+
readonly storage: RuntimeStorageNamespace;
|
|
7
8
|
readonly workflows: RuntimeWorkflowsNamespace;
|
|
8
9
|
readonly workflowRuns: RuntimeWorkflowRunsNamespace;
|
|
9
10
|
private readonly openapi;
|
|
@@ -30,6 +31,29 @@ export declare class RuntimeDataNamespace {
|
|
|
30
31
|
constructor(openapi: RuntimeOpenApiClient);
|
|
31
32
|
table(tableName: string): RuntimeDataTableClient;
|
|
32
33
|
view(viewId: string): RuntimeDataViewClient;
|
|
34
|
+
batchQuery(queries: RuntimeBatchQueryItem[], options?: RuntimeRequestOptions): Promise<RuntimeBatchQueryResult>;
|
|
35
|
+
}
|
|
36
|
+
export declare class RuntimeStorageNamespace {
|
|
37
|
+
private readonly openapi;
|
|
38
|
+
constructor(openapi: RuntimeOpenApiClient);
|
|
39
|
+
bucket(bucketIdOrSlug: string): RuntimeStorageBucketClient;
|
|
40
|
+
}
|
|
41
|
+
export declare class RuntimeStorageBucketClient {
|
|
42
|
+
private readonly openapi;
|
|
43
|
+
private readonly bucketIdOrSlug;
|
|
44
|
+
readonly anonymousUploads: RuntimeAnonymousUploadsClient;
|
|
45
|
+
constructor(openapi: RuntimeOpenApiClient, bucketIdOrSlug: string);
|
|
46
|
+
createUpload(input: RuntimeCreateFileUploadInput, options?: RuntimeRequestOptions): Promise<RuntimeFileUploadGrant>;
|
|
47
|
+
completeUpload(uploadId: string, options?: RuntimeRequestOptions): Promise<RuntimeFileUploadCompletion>;
|
|
48
|
+
get(fileId: string, options?: RuntimeRequestOptions): Promise<RuntimeFileObject>;
|
|
49
|
+
createDownloadUrl(fileId: string, options?: RuntimeRequestOptions): Promise<RuntimeFileDownloadUrl>;
|
|
50
|
+
delete(fileId: string, options?: RuntimeRequestOptions): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare class RuntimeAnonymousUploadsClient {
|
|
53
|
+
private readonly openapi;
|
|
54
|
+
private readonly bucketIdOrSlug;
|
|
55
|
+
constructor(openapi: RuntimeOpenApiClient, bucketIdOrSlug: string);
|
|
56
|
+
claim(input: RuntimeAnonymousClaimInput, options?: RuntimeRequestOptions): Promise<RuntimeAnonymousClaimResult>;
|
|
33
57
|
}
|
|
34
58
|
export declare class RuntimeDataTableClient {
|
|
35
59
|
private readonly tableName;
|
|
@@ -41,6 +65,8 @@ export declare class RuntimeDataRecordsClient {
|
|
|
41
65
|
private readonly tableName;
|
|
42
66
|
constructor(openapi: RuntimeOpenApiClient, tableName: string);
|
|
43
67
|
list(query?: RuntimeListRecordsOptions, options?: RuntimeRequestOptions): Promise<RuntimeRecordsList>;
|
|
68
|
+
query(input?: RuntimeQueryRecordsInput, options?: RuntimeRequestOptions): Promise<RuntimeRecordsList>;
|
|
69
|
+
aggregate(input: RuntimeAggregateRecordsInput, options?: RuntimeRequestOptions): Promise<RuntimeAggregateRecordsResult>;
|
|
44
70
|
create(input: RuntimeCreateRecordInput | RuntimeRowData, options?: RuntimeRequestOptions): Promise<RuntimeRecordMutation>;
|
|
45
71
|
update(recordId: string, input: RuntimeUpdateRecordInput | RuntimeRowData, options?: RuntimeRequestOptions): Promise<RuntimeRecordMutation>;
|
|
46
72
|
delete(recordId: string, options?: RuntimeRequestOptions): Promise<RuntimeRecordMutation>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuntimeWorkflowRunsNamespace = exports.RuntimeWorkflowsNamespace = exports.RuntimeDataViewTableClient = exports.RuntimeDataViewClient = exports.RuntimeDataRecordsClient = exports.RuntimeDataTableClient = exports.RuntimeDataNamespace = exports.RuntimeContextNamespace = exports.RuntimeAppAuthNamespace = exports.AgnosticRuntime = void 0;
|
|
3
|
+
exports.RuntimeWorkflowRunsNamespace = exports.RuntimeWorkflowsNamespace = exports.RuntimeDataViewTableClient = exports.RuntimeDataViewClient = exports.RuntimeDataRecordsClient = exports.RuntimeDataTableClient = exports.RuntimeAnonymousUploadsClient = exports.RuntimeStorageBucketClient = exports.RuntimeStorageNamespace = exports.RuntimeDataNamespace = exports.RuntimeContextNamespace = exports.RuntimeAppAuthNamespace = exports.AgnosticRuntime = void 0;
|
|
4
4
|
exports.createAgnosticRuntime = createAgnosticRuntime;
|
|
5
5
|
const http_client_1 = require("./http-client");
|
|
6
6
|
const context_1 = require("./context");
|
|
@@ -9,8 +9,16 @@ const APP_AUTH_VERIFY_SESSION_PATH = '/api/v1/runtime/app-auth/session/verify';
|
|
|
9
9
|
const APP_AUTH_USER_PATH = '/api/v1/runtime/app-auth/users/{userId}';
|
|
10
10
|
const AUTH_CONTEXT_PATH = '/api/v1/runtime/auth/context';
|
|
11
11
|
const DATA_RECORDS_PATH = '/api/v1/runtime/data/tables/{tableName}/records';
|
|
12
|
+
const DATA_QUERY_PATH = '/api/v1/runtime/data/tables/{tableName}/records/query';
|
|
13
|
+
const DATA_BATCH_QUERY_PATH = '/api/v1/runtime/data/records/batch-query';
|
|
14
|
+
const DATA_AGGREGATE_PATH = '/api/v1/runtime/data/tables/{tableName}/records/aggregate';
|
|
12
15
|
const DATA_RECORD_PATH = '/api/v1/runtime/data/tables/{tableName}/records/{recordId}';
|
|
13
16
|
const DATA_VIEW_WINDOW_PATH = '/api/v1/runtime/data/views/{viewId}/table/window';
|
|
17
|
+
const FILES_ANONYMOUS_CLAIM_PATH = '/api/v1/runtime/files/buckets/{bucketRef}/anonymous-upload-sessions/claim';
|
|
18
|
+
const FILES_UPLOADS_PATH = '/api/v1/runtime/files/buckets/{bucketRef}/uploads';
|
|
19
|
+
const FILES_UPLOAD_COMPLETE_PATH = '/api/v1/runtime/files/buckets/{bucketRef}/uploads/{uploadId}/complete';
|
|
20
|
+
const FILES_OBJECT_PATH = '/api/v1/runtime/files/buckets/{bucketRef}/objects/{fileId}';
|
|
21
|
+
const FILES_DOWNLOAD_PATH = '/api/v1/runtime/files/buckets/{bucketRef}/objects/{fileId}/download';
|
|
14
22
|
const WORKFLOWS_START_PATH = '/api/v1/runtime/workflows/{workflowSlug}/runs';
|
|
15
23
|
const WORKFLOW_RUN_PATH = '/api/v1/runtime/workflow-runs/{runId}';
|
|
16
24
|
const WORKFLOW_RUN_STEPS_PATH = '/api/v1/runtime/workflow-runs/{runId}/steps';
|
|
@@ -32,6 +40,7 @@ class AgnosticRuntime {
|
|
|
32
40
|
this.auth = new RuntimeAppAuthNamespace(this.openapi);
|
|
33
41
|
this.context = new RuntimeContextNamespace(this.openapi);
|
|
34
42
|
this.data = new RuntimeDataNamespace(this.openapi);
|
|
43
|
+
this.storage = new RuntimeStorageNamespace(this.openapi);
|
|
35
44
|
this.workflowRuns = new RuntimeWorkflowRunsNamespace(this.openapi);
|
|
36
45
|
this.workflows = new RuntimeWorkflowsNamespace(this.openapi, this.workflowRuns);
|
|
37
46
|
}
|
|
@@ -131,8 +140,85 @@ class RuntimeDataNamespace {
|
|
|
131
140
|
view(viewId) {
|
|
132
141
|
return new RuntimeDataViewClient(this.openapi, viewId);
|
|
133
142
|
}
|
|
143
|
+
async batchQuery(queries, options) {
|
|
144
|
+
const result = await this.openapi.POST(DATA_BATCH_QUERY_PATH, {
|
|
145
|
+
body: { queries },
|
|
146
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
147
|
+
});
|
|
148
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to batch query data records');
|
|
149
|
+
}
|
|
134
150
|
}
|
|
135
151
|
exports.RuntimeDataNamespace = RuntimeDataNamespace;
|
|
152
|
+
class RuntimeStorageNamespace {
|
|
153
|
+
constructor(openapi) {
|
|
154
|
+
this.openapi = openapi;
|
|
155
|
+
}
|
|
156
|
+
bucket(bucketIdOrSlug) {
|
|
157
|
+
return new RuntimeStorageBucketClient(this.openapi, bucketIdOrSlug);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.RuntimeStorageNamespace = RuntimeStorageNamespace;
|
|
161
|
+
class RuntimeStorageBucketClient {
|
|
162
|
+
constructor(openapi, bucketIdOrSlug) {
|
|
163
|
+
this.openapi = openapi;
|
|
164
|
+
this.bucketIdOrSlug = bucketIdOrSlug;
|
|
165
|
+
this.anonymousUploads = new RuntimeAnonymousUploadsClient(openapi, bucketIdOrSlug);
|
|
166
|
+
}
|
|
167
|
+
async createUpload(input, options) {
|
|
168
|
+
const result = await this.openapi.POST(FILES_UPLOADS_PATH, {
|
|
169
|
+
body: input,
|
|
170
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
171
|
+
params: { path: { bucketRef: this.bucketIdOrSlug } },
|
|
172
|
+
});
|
|
173
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to create file upload');
|
|
174
|
+
}
|
|
175
|
+
async completeUpload(uploadId, options) {
|
|
176
|
+
const result = await this.openapi.POST(FILES_UPLOAD_COMPLETE_PATH, {
|
|
177
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
178
|
+
params: { path: { bucketRef: this.bucketIdOrSlug, uploadId } },
|
|
179
|
+
});
|
|
180
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to complete file upload');
|
|
181
|
+
}
|
|
182
|
+
async get(fileId, options) {
|
|
183
|
+
const result = await this.openapi.GET(FILES_OBJECT_PATH, {
|
|
184
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
185
|
+
params: { path: { bucketRef: this.bucketIdOrSlug, fileId } },
|
|
186
|
+
});
|
|
187
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to load file status');
|
|
188
|
+
}
|
|
189
|
+
async createDownloadUrl(fileId, options) {
|
|
190
|
+
const result = await this.openapi.POST(FILES_DOWNLOAD_PATH, {
|
|
191
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
192
|
+
params: { path: { bucketRef: this.bucketIdOrSlug, fileId } },
|
|
193
|
+
});
|
|
194
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to create file download URL');
|
|
195
|
+
}
|
|
196
|
+
async delete(fileId, options) {
|
|
197
|
+
const result = await this.openapi.DELETE(FILES_OBJECT_PATH, {
|
|
198
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
199
|
+
params: { path: { bucketRef: this.bucketIdOrSlug, fileId } },
|
|
200
|
+
});
|
|
201
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to delete file');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.RuntimeStorageBucketClient = RuntimeStorageBucketClient;
|
|
205
|
+
class RuntimeAnonymousUploadsClient {
|
|
206
|
+
constructor(openapi, bucketIdOrSlug) {
|
|
207
|
+
this.openapi = openapi;
|
|
208
|
+
this.bucketIdOrSlug = bucketIdOrSlug;
|
|
209
|
+
}
|
|
210
|
+
async claim(input, options) {
|
|
211
|
+
const result = await this.openapi.POST(FILES_ANONYMOUS_CLAIM_PATH, {
|
|
212
|
+
body: input,
|
|
213
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
214
|
+
params: {
|
|
215
|
+
path: { bucketRef: this.bucketIdOrSlug },
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to claim anonymous uploads');
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.RuntimeAnonymousUploadsClient = RuntimeAnonymousUploadsClient;
|
|
136
222
|
class RuntimeDataTableClient {
|
|
137
223
|
constructor(openapi, tableName) {
|
|
138
224
|
this.tableName = tableName;
|
|
@@ -155,6 +241,24 @@ class RuntimeDataRecordsClient {
|
|
|
155
241
|
});
|
|
156
242
|
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to list data records');
|
|
157
243
|
}
|
|
244
|
+
async query(input = {}, options) {
|
|
245
|
+
const result = await this.openapi.POST(DATA_QUERY_PATH, {
|
|
246
|
+
body: input,
|
|
247
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
248
|
+
params: { path: { tableName: this.tableName } },
|
|
249
|
+
});
|
|
250
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to query data records');
|
|
251
|
+
}
|
|
252
|
+
async aggregate(input, options) {
|
|
253
|
+
const result = await this.openapi.POST(DATA_AGGREGATE_PATH, {
|
|
254
|
+
body: input,
|
|
255
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
256
|
+
params: {
|
|
257
|
+
path: { tableName: this.tableName },
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to aggregate data records');
|
|
261
|
+
}
|
|
158
262
|
async create(input, options) {
|
|
159
263
|
const result = await this.openapi.POST(DATA_RECORDS_PATH, {
|
|
160
264
|
body: normalizeCreateRecordInput(input),
|
package/src/lib/types.d.ts
CHANGED
|
@@ -39,6 +39,72 @@ export interface RuntimeRequestOptions {
|
|
|
39
39
|
actor?: RuntimeActorMetadata | null;
|
|
40
40
|
headers?: Record<string, string>;
|
|
41
41
|
}
|
|
42
|
+
export interface RuntimeAnonymousClaimInput {
|
|
43
|
+
token: string;
|
|
44
|
+
externalRef: string;
|
|
45
|
+
idempotencyKey: string;
|
|
46
|
+
}
|
|
47
|
+
export interface RuntimeAnonymousClaimFileHandle {
|
|
48
|
+
fileId: string;
|
|
49
|
+
status: 'ready' | 'processing';
|
|
50
|
+
}
|
|
51
|
+
export interface RuntimeAnonymousClaimResult {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
bucketId: string;
|
|
54
|
+
externalRef: string;
|
|
55
|
+
claimedAt: string;
|
|
56
|
+
files: RuntimeAnonymousClaimFileHandle[];
|
|
57
|
+
}
|
|
58
|
+
export type RuntimeFileAccessMode = 'private' | 'authenticated' | 'team' | 'public';
|
|
59
|
+
export type RuntimeFileObjectStatus = 'pending_upload' | 'uploaded' | 'scanning' | 'ready' | 'verified_unclaimed' | 'claimed_ready' | 'deleting' | 'deleted' | 'rejected' | 'quarantined' | 'expired';
|
|
60
|
+
export interface RuntimeCreateFileUploadInput {
|
|
61
|
+
fileName: string;
|
|
62
|
+
contentType: string;
|
|
63
|
+
size: number;
|
|
64
|
+
checksumSha256: string;
|
|
65
|
+
access?: RuntimeFileAccessMode;
|
|
66
|
+
idempotencyKey: string;
|
|
67
|
+
}
|
|
68
|
+
export interface RuntimeFileUploadGrant {
|
|
69
|
+
id: string;
|
|
70
|
+
fileId: string;
|
|
71
|
+
bucketId: string;
|
|
72
|
+
status: 'issued' | 'uploaded' | 'verifying' | 'completed' | 'rejected' | 'expired';
|
|
73
|
+
expectedSizeBytes: number;
|
|
74
|
+
expiresAt: string;
|
|
75
|
+
completedAt: string | null;
|
|
76
|
+
uploadUrl: string;
|
|
77
|
+
uploadUrlExpiresAt: string;
|
|
78
|
+
requiredHeaders: Readonly<Record<string, string>>;
|
|
79
|
+
}
|
|
80
|
+
export interface RuntimeFileObject {
|
|
81
|
+
id: string;
|
|
82
|
+
bucketId: string;
|
|
83
|
+
projectId: string;
|
|
84
|
+
environment: string;
|
|
85
|
+
originalName: string;
|
|
86
|
+
detectedMime: string | null;
|
|
87
|
+
sizeBytes: number | null;
|
|
88
|
+
checksumSha256: string | null;
|
|
89
|
+
status: RuntimeFileObjectStatus;
|
|
90
|
+
access: RuntimeFileAccessMode;
|
|
91
|
+
readyAt: string | null;
|
|
92
|
+
deletedAt: string | null;
|
|
93
|
+
billableUntil: string | null;
|
|
94
|
+
physicalDeleteDueAt: string | null;
|
|
95
|
+
physicalDeletedAt: string | null;
|
|
96
|
+
expiresAt: string | null;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
updatedAt: string;
|
|
99
|
+
}
|
|
100
|
+
export interface RuntimeFileUploadCompletion {
|
|
101
|
+
upload: Omit<RuntimeFileUploadGrant, 'uploadUrl' | 'uploadUrlExpiresAt' | 'requiredHeaders'>;
|
|
102
|
+
file: RuntimeFileObject;
|
|
103
|
+
}
|
|
104
|
+
export interface RuntimeFileDownloadUrl {
|
|
105
|
+
url: string;
|
|
106
|
+
expiresAt: string;
|
|
107
|
+
}
|
|
42
108
|
export type RuntimeHeaderValue = string | string[] | undefined;
|
|
43
109
|
export interface RuntimeAppAuthRequestLike {
|
|
44
110
|
headers?: Headers | Record<string, RuntimeHeaderValue> | {
|
|
@@ -92,6 +158,45 @@ export interface RuntimeListRecordsOptions {
|
|
|
92
158
|
q?: string;
|
|
93
159
|
sort?: string;
|
|
94
160
|
}
|
|
161
|
+
export type RuntimeAggregateOperation = 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
162
|
+
export interface RuntimeQueryRecordsInput extends RuntimeListRecordsOptions {
|
|
163
|
+
/** Technical names; id is always included. Omit to read all fields. */
|
|
164
|
+
fields?: string[];
|
|
165
|
+
}
|
|
166
|
+
export interface RuntimeBatchQueryItem {
|
|
167
|
+
tableName: string;
|
|
168
|
+
query: RuntimeQueryRecordsInput;
|
|
169
|
+
}
|
|
170
|
+
export interface RuntimeBatchQueryResult {
|
|
171
|
+
/** Independent pages, in request order; no shared transactional snapshot. */
|
|
172
|
+
results: RuntimeRecordsList[];
|
|
173
|
+
}
|
|
174
|
+
export interface RuntimeAggregateMetric {
|
|
175
|
+
operation: RuntimeAggregateOperation;
|
|
176
|
+
field?: string;
|
|
177
|
+
as: string;
|
|
178
|
+
}
|
|
179
|
+
export interface RuntimeAggregateOrderBy {
|
|
180
|
+
by: string;
|
|
181
|
+
direction: 'asc' | 'desc';
|
|
182
|
+
}
|
|
183
|
+
export interface RuntimeAggregateRecordsInput {
|
|
184
|
+
filter?: Record<string, unknown>;
|
|
185
|
+
q?: string;
|
|
186
|
+
groupBy?: string[];
|
|
187
|
+
metrics: RuntimeAggregateMetric[];
|
|
188
|
+
orderBy?: RuntimeAggregateOrderBy[];
|
|
189
|
+
limit?: number;
|
|
190
|
+
}
|
|
191
|
+
export interface RuntimeAggregateRow {
|
|
192
|
+
dimensions: Record<string, RuntimeScalar>;
|
|
193
|
+
metrics: Record<string, string | number | null>;
|
|
194
|
+
}
|
|
195
|
+
export interface RuntimeAggregateRecordsResult {
|
|
196
|
+
rows: RuntimeAggregateRow[];
|
|
197
|
+
limit: number;
|
|
198
|
+
hasMore: boolean;
|
|
199
|
+
}
|
|
95
200
|
export interface RuntimeListWindowOptions {
|
|
96
201
|
cursor?: string;
|
|
97
202
|
limit?: number;
|