@nsp-labs/agnostic-sdk 0.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/CHANGELOG.md +14 -0
- package/LICENSE +15 -0
- package/README.md +195 -0
- package/package.json +47 -0
- package/src/generated/openapi.d.ts +1214 -0
- package/src/generated/openapi.js +7 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +24 -0
- package/src/lib/context.d.ts +3 -0
- package/src/lib/context.js +70 -0
- package/src/lib/errors.d.ts +14 -0
- package/src/lib/errors.js +57 -0
- package/src/lib/http-client.d.ts +18 -0
- package/src/lib/http-client.js +65 -0
- package/src/lib/runtime-client.d.ts +91 -0
- package/src/lib/runtime-client.js +394 -0
- package/src/lib/types.d.ts +224 -0
- package/src/lib/types.js +3 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeWorkflowRunsNamespace = exports.RuntimeWorkflowsNamespace = exports.RuntimeGatewayNamespace = exports.RuntimeJobsNamespace = exports.RuntimeEventsNamespace = exports.RuntimeDataViewTableClient = exports.RuntimeDataViewClient = exports.RuntimeDataRecordsClient = exports.RuntimeDataTableClient = exports.RuntimeDataNamespace = exports.RuntimeContextNamespace = exports.RuntimeAppAuthNamespace = exports.AgnosticRuntime = void 0;
|
|
4
|
+
exports.createAgnosticRuntime = createAgnosticRuntime;
|
|
5
|
+
const http_client_1 = require("./http-client");
|
|
6
|
+
const context_1 = require("./context");
|
|
7
|
+
const errors_1 = require("./errors");
|
|
8
|
+
const APP_AUTH_VERIFY_SESSION_PATH = '/api/v1/runtime/app-auth/session/verify';
|
|
9
|
+
const APP_AUTH_USER_PATH = '/api/v1/runtime/app-auth/users/{userId}';
|
|
10
|
+
const AUTH_CONTEXT_PATH = '/api/v1/runtime/auth/context';
|
|
11
|
+
const DATA_RECORDS_PATH = '/api/v1/runtime/data/tables/{tableName}/records';
|
|
12
|
+
const DATA_RECORD_PATH = '/api/v1/runtime/data/tables/{tableName}/records/{recordId}';
|
|
13
|
+
const DATA_VIEW_WINDOW_PATH = '/api/v1/runtime/data/views/{viewId}/table/window';
|
|
14
|
+
const EVENTS_PATH = '/api/v1/runtime/events/{eventName}';
|
|
15
|
+
const JOBS_PATH = '/api/v1/runtime/jobs/{jobName}';
|
|
16
|
+
const GATEWAY_PATH = '/api/v1/runtime/gateway/{routeName}';
|
|
17
|
+
const WORKFLOWS_START_PATH = '/api/v1/runtime/workflows/{workflowSlug}/runs';
|
|
18
|
+
const WORKFLOW_RUN_PATH = '/api/v1/runtime/workflow-runs/{runId}';
|
|
19
|
+
const WORKFLOW_RUN_STEPS_PATH = '/api/v1/runtime/workflow-runs/{runId}/steps';
|
|
20
|
+
const DEFAULT_WAIT_TIMEOUT_MS = 60_000;
|
|
21
|
+
const DEFAULT_WAIT_POLL_INTERVAL_MS = 1_000;
|
|
22
|
+
const TERMINAL_WORKFLOW_STATUSES = new Set([
|
|
23
|
+
'succeeded',
|
|
24
|
+
'failed',
|
|
25
|
+
'cancelled',
|
|
26
|
+
]);
|
|
27
|
+
class AgnosticRuntime {
|
|
28
|
+
constructor(config = {}) {
|
|
29
|
+
this.runtimeContext = (0, context_1.resolveRuntimeContext)(config);
|
|
30
|
+
this.openapi = (0, http_client_1.createRuntimeOpenApiClient)({
|
|
31
|
+
actor: config.actor,
|
|
32
|
+
context: this.runtimeContext,
|
|
33
|
+
fetch: config.fetch,
|
|
34
|
+
});
|
|
35
|
+
this.auth = new RuntimeAppAuthNamespace(this.openapi);
|
|
36
|
+
this.context = new RuntimeContextNamespace(this.openapi);
|
|
37
|
+
this.data = new RuntimeDataNamespace(this.openapi);
|
|
38
|
+
this.events = new RuntimeEventsNamespace(this.openapi);
|
|
39
|
+
this.jobs = new RuntimeJobsNamespace(this.openapi);
|
|
40
|
+
this.gateway = new RuntimeGatewayNamespace(this.openapi);
|
|
41
|
+
this.workflowRuns = new RuntimeWorkflowRunsNamespace(this.openapi);
|
|
42
|
+
this.workflows = new RuntimeWorkflowsNamespace(this.openapi, this.workflowRuns);
|
|
43
|
+
}
|
|
44
|
+
getRuntimeContext() {
|
|
45
|
+
return { ...this.runtimeContext };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.AgnosticRuntime = AgnosticRuntime;
|
|
49
|
+
class RuntimeAppAuthNamespace {
|
|
50
|
+
constructor(openapi) {
|
|
51
|
+
this.openapi = openapi;
|
|
52
|
+
}
|
|
53
|
+
async requireSession(request, options) {
|
|
54
|
+
const sessionToken = typeof request === 'string'
|
|
55
|
+
? normalizeSessionToken(request)
|
|
56
|
+
: extractAppSessionToken(request);
|
|
57
|
+
if (!sessionToken) {
|
|
58
|
+
throw new errors_1.AgnosticRuntimeError({
|
|
59
|
+
status: 0,
|
|
60
|
+
code: 'app_auth_session_missing',
|
|
61
|
+
message: 'App Auth session token was not found in the request',
|
|
62
|
+
details: {
|
|
63
|
+
accepted: ['Authorization: Bearer <token>', 'agnostic_app_session_*'],
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const result = await this.openapi.POST(APP_AUTH_VERIFY_SESSION_PATH, {
|
|
68
|
+
body: { sessionToken },
|
|
69
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
70
|
+
});
|
|
71
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to verify App Auth session');
|
|
72
|
+
}
|
|
73
|
+
async getUser(userId, options) {
|
|
74
|
+
const result = await this.openapi.GET(APP_AUTH_USER_PATH, {
|
|
75
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
76
|
+
params: {
|
|
77
|
+
path: { userId },
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to load App Auth user');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.RuntimeAppAuthNamespace = RuntimeAppAuthNamespace;
|
|
84
|
+
function createAgnosticRuntime(config = {}) {
|
|
85
|
+
return new AgnosticRuntime(config);
|
|
86
|
+
}
|
|
87
|
+
class RuntimeContextNamespace {
|
|
88
|
+
constructor(openapi) {
|
|
89
|
+
this.openapi = openapi;
|
|
90
|
+
}
|
|
91
|
+
async get(options) {
|
|
92
|
+
const result = await this.openapi.GET(AUTH_CONTEXT_PATH, {
|
|
93
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
94
|
+
});
|
|
95
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to load runtime context');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.RuntimeContextNamespace = RuntimeContextNamespace;
|
|
99
|
+
class RuntimeDataNamespace {
|
|
100
|
+
constructor(openapi) {
|
|
101
|
+
this.openapi = openapi;
|
|
102
|
+
}
|
|
103
|
+
table(tableName) {
|
|
104
|
+
return new RuntimeDataTableClient(this.openapi, tableName);
|
|
105
|
+
}
|
|
106
|
+
view(viewId) {
|
|
107
|
+
return new RuntimeDataViewClient(this.openapi, viewId);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.RuntimeDataNamespace = RuntimeDataNamespace;
|
|
111
|
+
class RuntimeDataTableClient {
|
|
112
|
+
constructor(openapi, tableName) {
|
|
113
|
+
this.tableName = tableName;
|
|
114
|
+
this.records = new RuntimeDataRecordsClient(openapi, tableName);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.RuntimeDataTableClient = RuntimeDataTableClient;
|
|
118
|
+
class RuntimeDataRecordsClient {
|
|
119
|
+
constructor(openapi, tableName) {
|
|
120
|
+
this.openapi = openapi;
|
|
121
|
+
this.tableName = tableName;
|
|
122
|
+
}
|
|
123
|
+
async list(query = {}, options) {
|
|
124
|
+
const result = await this.openapi.GET(DATA_RECORDS_PATH, {
|
|
125
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
126
|
+
params: {
|
|
127
|
+
path: { tableName: this.tableName },
|
|
128
|
+
query: query,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to list data records');
|
|
132
|
+
}
|
|
133
|
+
async create(input, options) {
|
|
134
|
+
const result = await this.openapi.POST(DATA_RECORDS_PATH, {
|
|
135
|
+
body: normalizeCreateRecordInput(input),
|
|
136
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
137
|
+
params: {
|
|
138
|
+
path: { tableName: this.tableName },
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to create data record');
|
|
142
|
+
}
|
|
143
|
+
async update(recordId, input, options) {
|
|
144
|
+
const result = await this.openapi.PATCH(DATA_RECORD_PATH, {
|
|
145
|
+
body: normalizeUpdateRecordInput(input),
|
|
146
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
147
|
+
params: {
|
|
148
|
+
path: { recordId, tableName: this.tableName },
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to update data record');
|
|
152
|
+
}
|
|
153
|
+
async delete(recordId, options) {
|
|
154
|
+
const result = await this.openapi.DELETE(DATA_RECORD_PATH, {
|
|
155
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
156
|
+
params: {
|
|
157
|
+
path: { recordId, tableName: this.tableName },
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to delete data record');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.RuntimeDataRecordsClient = RuntimeDataRecordsClient;
|
|
164
|
+
class RuntimeDataViewClient {
|
|
165
|
+
constructor(openapi, viewId) {
|
|
166
|
+
this.table = new RuntimeDataViewTableClient(openapi, viewId);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.RuntimeDataViewClient = RuntimeDataViewClient;
|
|
170
|
+
class RuntimeDataViewTableClient {
|
|
171
|
+
constructor(openapi, viewId) {
|
|
172
|
+
this.openapi = openapi;
|
|
173
|
+
this.viewId = viewId;
|
|
174
|
+
}
|
|
175
|
+
async window(query = {}, options) {
|
|
176
|
+
const result = await this.openapi.GET(DATA_VIEW_WINDOW_PATH, {
|
|
177
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
178
|
+
params: {
|
|
179
|
+
path: { viewId: this.viewId },
|
|
180
|
+
query: query,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to load data view window');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.RuntimeDataViewTableClient = RuntimeDataViewTableClient;
|
|
187
|
+
class RuntimeEventsNamespace {
|
|
188
|
+
constructor(openapi) {
|
|
189
|
+
this.openapi = openapi;
|
|
190
|
+
}
|
|
191
|
+
async publish(eventName, payload = {}, options = {}) {
|
|
192
|
+
const result = await this.openapi.POST(EVENTS_PATH, {
|
|
193
|
+
body: {
|
|
194
|
+
delaySeconds: options.delaySeconds,
|
|
195
|
+
messageDeduplicationId: options.messageDeduplicationId,
|
|
196
|
+
messageGroupId: options.messageGroupId,
|
|
197
|
+
payload,
|
|
198
|
+
},
|
|
199
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
200
|
+
params: {
|
|
201
|
+
path: { eventName },
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to publish runtime event');
|
|
205
|
+
}
|
|
206
|
+
async publishBatch(eventName, messages, options) {
|
|
207
|
+
return Promise.all(messages.map((message) => this.publish(eventName, message.payload ?? {}, {
|
|
208
|
+
...(options ?? {}),
|
|
209
|
+
...(message.options ?? {}),
|
|
210
|
+
})));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.RuntimeEventsNamespace = RuntimeEventsNamespace;
|
|
214
|
+
class RuntimeJobsNamespace {
|
|
215
|
+
constructor(openapi) {
|
|
216
|
+
this.openapi = openapi;
|
|
217
|
+
}
|
|
218
|
+
async enqueue(jobName, payload = {}, options = {}) {
|
|
219
|
+
const result = await this.openapi.POST(JOBS_PATH, {
|
|
220
|
+
body: {
|
|
221
|
+
delaySeconds: options.delaySeconds,
|
|
222
|
+
messageDeduplicationId: options.messageDeduplicationId,
|
|
223
|
+
messageGroupId: options.messageGroupId,
|
|
224
|
+
payload,
|
|
225
|
+
},
|
|
226
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
227
|
+
params: {
|
|
228
|
+
path: { jobName },
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to enqueue runtime job');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.RuntimeJobsNamespace = RuntimeJobsNamespace;
|
|
235
|
+
class RuntimeGatewayNamespace {
|
|
236
|
+
constructor(openapi) {
|
|
237
|
+
this.openapi = openapi;
|
|
238
|
+
}
|
|
239
|
+
async call(routeName, payload = {}, options = {}) {
|
|
240
|
+
const result = await this.openapi.POST(GATEWAY_PATH, {
|
|
241
|
+
body: {
|
|
242
|
+
headers: options.headers,
|
|
243
|
+
payload,
|
|
244
|
+
query: options.query,
|
|
245
|
+
},
|
|
246
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
247
|
+
params: {
|
|
248
|
+
path: { routeName },
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to call runtime gateway route');
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.RuntimeGatewayNamespace = RuntimeGatewayNamespace;
|
|
255
|
+
class RuntimeWorkflowsNamespace {
|
|
256
|
+
constructor(openapi, workflowRuns) {
|
|
257
|
+
this.openapi = openapi;
|
|
258
|
+
this.workflowRuns = workflowRuns;
|
|
259
|
+
}
|
|
260
|
+
async start(workflowSlug, inputPayload = {}, options) {
|
|
261
|
+
const result = await this.openapi.POST(WORKFLOWS_START_PATH, {
|
|
262
|
+
body: { inputPayload },
|
|
263
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
264
|
+
params: {
|
|
265
|
+
path: { workflowSlug },
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to start runtime workflow');
|
|
269
|
+
}
|
|
270
|
+
async getRun(runId, options) {
|
|
271
|
+
return this.workflowRuns.get(runId, options);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.RuntimeWorkflowsNamespace = RuntimeWorkflowsNamespace;
|
|
275
|
+
class RuntimeWorkflowRunsNamespace {
|
|
276
|
+
constructor(openapi) {
|
|
277
|
+
this.openapi = openapi;
|
|
278
|
+
}
|
|
279
|
+
async get(runId, options) {
|
|
280
|
+
const result = await this.openapi.GET(WORKFLOW_RUN_PATH, {
|
|
281
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
282
|
+
params: {
|
|
283
|
+
path: { runId },
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to load workflow run');
|
|
287
|
+
}
|
|
288
|
+
async wait(runId, options = {}) {
|
|
289
|
+
const startedAt = Date.now();
|
|
290
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
291
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_WAIT_POLL_INTERVAL_MS;
|
|
292
|
+
while (true) {
|
|
293
|
+
const run = await this.get(runId, options);
|
|
294
|
+
if (TERMINAL_WORKFLOW_STATUSES.has(run.status)) {
|
|
295
|
+
return run;
|
|
296
|
+
}
|
|
297
|
+
if (Date.now() - startedAt >= timeoutMs) {
|
|
298
|
+
throw new errors_1.AgnosticRuntimeError({
|
|
299
|
+
status: 0,
|
|
300
|
+
code: 'workflow_run_wait_timeout',
|
|
301
|
+
message: `Workflow run ${runId} did not finish before timeout`,
|
|
302
|
+
details: { runId, timeoutMs, status: run.status },
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
await sleep(pollIntervalMs);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
async listSteps(runId, options) {
|
|
309
|
+
const result = await this.openapi.GET(WORKFLOW_RUN_STEPS_PATH, {
|
|
310
|
+
headers: (0, http_client_1.runtimeRequestHeaders)(options),
|
|
311
|
+
params: {
|
|
312
|
+
path: { runId },
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
return (0, http_client_1.unwrapRuntimeResult)(result, 'Failed to list workflow run steps');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.RuntimeWorkflowRunsNamespace = RuntimeWorkflowRunsNamespace;
|
|
319
|
+
function normalizeCreateRecordInput(input) {
|
|
320
|
+
if (isRecord(input) && isRecord(input['values'])) {
|
|
321
|
+
return input;
|
|
322
|
+
}
|
|
323
|
+
return { values: input };
|
|
324
|
+
}
|
|
325
|
+
function normalizeUpdateRecordInput(input) {
|
|
326
|
+
if (isRecord(input) && ('values' in input || 'remove' in input)) {
|
|
327
|
+
return input;
|
|
328
|
+
}
|
|
329
|
+
return { values: input };
|
|
330
|
+
}
|
|
331
|
+
function isRecord(value) {
|
|
332
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
333
|
+
}
|
|
334
|
+
function extractAppSessionToken(request) {
|
|
335
|
+
const authorization = readHeader(request.headers, 'authorization');
|
|
336
|
+
const bearerMatch = /^Bearer\s+(.+)$/i.exec(authorization ?? '');
|
|
337
|
+
if (bearerMatch) {
|
|
338
|
+
return normalizeSessionToken(bearerMatch[1]);
|
|
339
|
+
}
|
|
340
|
+
return extractAppSessionCookie(readHeader(request.headers, 'cookie'));
|
|
341
|
+
}
|
|
342
|
+
function extractAppSessionCookie(cookieHeader) {
|
|
343
|
+
if (!cookieHeader) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
for (const cookie of cookieHeader.split(';')) {
|
|
347
|
+
const [name, ...valueParts] = cookie.trim().split('=');
|
|
348
|
+
if (!name.startsWith('agnostic_app_session_')) {
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
const rawValue = valueParts.join('=');
|
|
352
|
+
return normalizeSessionToken(decodeCookieValue(rawValue));
|
|
353
|
+
}
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
function readHeader(headers, name) {
|
|
357
|
+
if (!headers) {
|
|
358
|
+
return undefined;
|
|
359
|
+
}
|
|
360
|
+
const getter = headers.get;
|
|
361
|
+
if (typeof getter === 'function') {
|
|
362
|
+
const value = getter.call(headers, name);
|
|
363
|
+
return typeof value === 'string' ? value : undefined;
|
|
364
|
+
}
|
|
365
|
+
const record = headers;
|
|
366
|
+
const lowerName = name.toLowerCase();
|
|
367
|
+
const headerKey = Object.keys(record).find((key) => key.toLowerCase() === lowerName);
|
|
368
|
+
const value = headerKey ? record[headerKey] : undefined;
|
|
369
|
+
if (Array.isArray(value)) {
|
|
370
|
+
return value[0];
|
|
371
|
+
}
|
|
372
|
+
return typeof value === 'string' ? value : undefined;
|
|
373
|
+
}
|
|
374
|
+
function normalizeSessionToken(value) {
|
|
375
|
+
if (typeof value !== 'string') {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
const trimmed = value.trim();
|
|
379
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
380
|
+
}
|
|
381
|
+
function decodeCookieValue(value) {
|
|
382
|
+
try {
|
|
383
|
+
return decodeURIComponent(value);
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
return value;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function sleep(ms) {
|
|
390
|
+
return new Promise((resolve) => {
|
|
391
|
+
setTimeout(resolve, ms);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=runtime-client.js.map
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
export type RuntimeScalar = string | number | boolean | null;
|
|
2
|
+
export type RuntimeJsonValue = RuntimeScalar | RuntimeJsonValue[] | {
|
|
3
|
+
[key: string]: RuntimeJsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type RuntimeRowValue = RuntimeScalar | RuntimeJsonValue[] | {
|
|
6
|
+
[key: string]: RuntimeJsonValue;
|
|
7
|
+
} | undefined;
|
|
8
|
+
export type RuntimeRowData = Record<string, RuntimeRowValue>;
|
|
9
|
+
export type RuntimeActorType = 'app_user' | 'platform_user' | 'runtime' | 'system';
|
|
10
|
+
export interface RuntimeActorMetadata {
|
|
11
|
+
type: RuntimeActorType;
|
|
12
|
+
id?: string;
|
|
13
|
+
tenantId?: string;
|
|
14
|
+
role?: string;
|
|
15
|
+
scopes?: string[];
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface RuntimeContextEnvironment {
|
|
19
|
+
AGNOSTIC_API_URL?: string;
|
|
20
|
+
AGNOSTIC_PROJECT_ID?: string;
|
|
21
|
+
AGNOSTIC_ENVIRONMENT?: string;
|
|
22
|
+
AGNOSTIC_RUNTIME_TOKEN?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AgnosticRuntimeConfig {
|
|
25
|
+
apiUrl?: string;
|
|
26
|
+
projectId?: string;
|
|
27
|
+
environment?: string;
|
|
28
|
+
token?: string;
|
|
29
|
+
actor?: RuntimeActorMetadata | null;
|
|
30
|
+
fetch?: typeof fetch;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolvedRuntimeContext {
|
|
33
|
+
apiUrl: string;
|
|
34
|
+
projectId: string;
|
|
35
|
+
environment: string;
|
|
36
|
+
token: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RuntimeRequestOptions {
|
|
39
|
+
actor?: RuntimeActorMetadata | null;
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
export type RuntimeHeaderValue = string | string[] | undefined;
|
|
43
|
+
export interface RuntimeAppAuthRequestLike {
|
|
44
|
+
headers?: Headers | Record<string, RuntimeHeaderValue> | {
|
|
45
|
+
get(name: string): string | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface RuntimeAppAuthUserClaims {
|
|
49
|
+
id: string;
|
|
50
|
+
realmId: string;
|
|
51
|
+
email: string;
|
|
52
|
+
emailVerified: boolean;
|
|
53
|
+
displayName: string | null;
|
|
54
|
+
avatarUrl: string | null;
|
|
55
|
+
status: 'active' | 'disabled' | 'suspended';
|
|
56
|
+
metadata: Record<string, unknown>;
|
|
57
|
+
scopes: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface RuntimeAppAuthSessionClaims {
|
|
60
|
+
id: string;
|
|
61
|
+
expiresAt: string;
|
|
62
|
+
createdAt: string;
|
|
63
|
+
device: string | null;
|
|
64
|
+
ipAddress: string | null;
|
|
65
|
+
}
|
|
66
|
+
export interface RuntimeAppAuthCachePolicy {
|
|
67
|
+
ttlSeconds: number;
|
|
68
|
+
expiresAt: string;
|
|
69
|
+
}
|
|
70
|
+
export interface RuntimeAppAuthActor {
|
|
71
|
+
type: 'app_user';
|
|
72
|
+
id: string;
|
|
73
|
+
tenantId?: string;
|
|
74
|
+
role?: string;
|
|
75
|
+
scopes?: string[];
|
|
76
|
+
}
|
|
77
|
+
export interface RuntimeAppAuthSession {
|
|
78
|
+
user: RuntimeAppAuthUserClaims;
|
|
79
|
+
session: RuntimeAppAuthSessionClaims;
|
|
80
|
+
actor: RuntimeAppAuthActor;
|
|
81
|
+
verifiedAt: string;
|
|
82
|
+
cache: RuntimeAppAuthCachePolicy;
|
|
83
|
+
}
|
|
84
|
+
export interface RuntimeAppAuthUserResult {
|
|
85
|
+
user: RuntimeAppAuthUserClaims;
|
|
86
|
+
actor: RuntimeAppAuthActor;
|
|
87
|
+
}
|
|
88
|
+
export interface RuntimeListRecordsOptions {
|
|
89
|
+
cursor?: string;
|
|
90
|
+
filter?: Record<string, unknown>;
|
|
91
|
+
limit?: number;
|
|
92
|
+
q?: string;
|
|
93
|
+
sort?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface RuntimeListWindowOptions {
|
|
96
|
+
cursor?: string;
|
|
97
|
+
limit?: number;
|
|
98
|
+
}
|
|
99
|
+
export interface RuntimeRecord {
|
|
100
|
+
id: string;
|
|
101
|
+
values: RuntimeRowData;
|
|
102
|
+
}
|
|
103
|
+
export interface RuntimeRecordsList {
|
|
104
|
+
records: RuntimeRecord[];
|
|
105
|
+
limit: number;
|
|
106
|
+
nextCursor: string | null;
|
|
107
|
+
hasMore: boolean;
|
|
108
|
+
loadedCount: number;
|
|
109
|
+
totalCount: number;
|
|
110
|
+
}
|
|
111
|
+
export interface RuntimeCreateRecordInput {
|
|
112
|
+
id?: string;
|
|
113
|
+
values: RuntimeRowData;
|
|
114
|
+
}
|
|
115
|
+
export interface RuntimeUpdateRecordInput {
|
|
116
|
+
values?: RuntimeRowData;
|
|
117
|
+
remove?: string[];
|
|
118
|
+
}
|
|
119
|
+
export interface RuntimeRecordMutation {
|
|
120
|
+
id: string;
|
|
121
|
+
record?: RuntimeRecord;
|
|
122
|
+
rowsAffected: number;
|
|
123
|
+
}
|
|
124
|
+
export interface RuntimeDataField {
|
|
125
|
+
name: string;
|
|
126
|
+
displayName: string;
|
|
127
|
+
type: string;
|
|
128
|
+
ydbType?: string;
|
|
129
|
+
nullable?: boolean;
|
|
130
|
+
required?: boolean;
|
|
131
|
+
readonly?: boolean;
|
|
132
|
+
hidden?: boolean;
|
|
133
|
+
system?: boolean;
|
|
134
|
+
metadata?: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
export interface RuntimeDataViewState {
|
|
137
|
+
fieldOrder: string[];
|
|
138
|
+
hiddenFields: string[];
|
|
139
|
+
fieldWidths: Record<string, number>;
|
|
140
|
+
settings: Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
export interface RuntimeTableWindow {
|
|
143
|
+
fields: RuntimeDataField[];
|
|
144
|
+
rows: RuntimeRecord[];
|
|
145
|
+
limit: number;
|
|
146
|
+
nextCursor: string | null;
|
|
147
|
+
hasMore: boolean;
|
|
148
|
+
loadedCount: number;
|
|
149
|
+
totalCount: number;
|
|
150
|
+
viewState: RuntimeDataViewState;
|
|
151
|
+
}
|
|
152
|
+
export interface RuntimeQueueOptions {
|
|
153
|
+
delaySeconds?: number;
|
|
154
|
+
messageDeduplicationId?: string;
|
|
155
|
+
messageGroupId?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface RuntimeQueuedMessage {
|
|
158
|
+
name: string;
|
|
159
|
+
queueId: string;
|
|
160
|
+
queueName: string;
|
|
161
|
+
environment: string;
|
|
162
|
+
messageId: string;
|
|
163
|
+
md5OfMessageBody?: string;
|
|
164
|
+
requestId?: string;
|
|
165
|
+
}
|
|
166
|
+
export interface RuntimeGatewayCallOptions extends RuntimeRequestOptions {
|
|
167
|
+
headers?: Record<string, string>;
|
|
168
|
+
query?: Record<string, string>;
|
|
169
|
+
}
|
|
170
|
+
export interface RuntimeGatewayCallResult {
|
|
171
|
+
routeName: string;
|
|
172
|
+
routePath: string;
|
|
173
|
+
status: number;
|
|
174
|
+
data: unknown;
|
|
175
|
+
headers: Record<string, string>;
|
|
176
|
+
}
|
|
177
|
+
export type WorkflowRunStatus = 'queued' | 'running' | 'waiting' | 'succeeded' | 'failed' | 'cancelled';
|
|
178
|
+
export interface RuntimeWorkflowRun {
|
|
179
|
+
id: string;
|
|
180
|
+
workflowId: string;
|
|
181
|
+
workflowVersionId: string | null;
|
|
182
|
+
environmentId: string;
|
|
183
|
+
triggerId: string | null;
|
|
184
|
+
status: WorkflowRunStatus;
|
|
185
|
+
inputPayload: Record<string, unknown>;
|
|
186
|
+
testDefinition?: Record<string, unknown> | null;
|
|
187
|
+
actorMetadata?: RuntimeActorMetadata | null;
|
|
188
|
+
startedAt: string | null;
|
|
189
|
+
finishedAt: string | null;
|
|
190
|
+
}
|
|
191
|
+
export interface RuntimeWorkflowStepRun {
|
|
192
|
+
id: string;
|
|
193
|
+
workflowRunId: string;
|
|
194
|
+
nodeId: string;
|
|
195
|
+
parentStepRunId: string | null;
|
|
196
|
+
tokenId: string;
|
|
197
|
+
branchId: string;
|
|
198
|
+
loopId: string | null;
|
|
199
|
+
itemIndex: number | null;
|
|
200
|
+
joinKey: string | null;
|
|
201
|
+
status: string;
|
|
202
|
+
attempt: number;
|
|
203
|
+
inputRef: string | null;
|
|
204
|
+
outputRef: string | null;
|
|
205
|
+
inputSummary: Record<string, unknown> | null;
|
|
206
|
+
outputSummary: Record<string, unknown> | null;
|
|
207
|
+
startedAt: string | null;
|
|
208
|
+
finishedAt: string | null;
|
|
209
|
+
error: Record<string, unknown> | null;
|
|
210
|
+
}
|
|
211
|
+
export interface RuntimeWorkflowWaitOptions extends RuntimeRequestOptions {
|
|
212
|
+
pollIntervalMs?: number;
|
|
213
|
+
timeoutMs?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface RuntimeIdentityContext {
|
|
216
|
+
tokenId: string;
|
|
217
|
+
projectId: string;
|
|
218
|
+
environment: string;
|
|
219
|
+
runtimeType: 'service' | 'worker' | 'automation';
|
|
220
|
+
serviceId?: string | null;
|
|
221
|
+
workerId?: string | null;
|
|
222
|
+
capabilities: string[];
|
|
223
|
+
actor?: RuntimeActorMetadata | null;
|
|
224
|
+
}
|
package/src/lib/types.js
ADDED