@permute/sdk 0.6.0 → 0.8.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/README.md +358 -22
- package/dist/app.d.ts +24 -2
- package/dist/app.js +31 -5
- package/dist/auth/oauth.d.ts +64 -0
- package/dist/auth/oauth.js +221 -0
- package/dist/auth/store.d.ts +39 -0
- package/dist/auth/store.js +70 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +1 -0
- package/dist/bridge.d.ts +10 -0
- package/dist/bridge.js +62 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +127 -0
- package/dist/client.d.ts +152 -10
- package/dist/client.js +142 -105
- package/dist/deploy.d.ts +77 -3
- package/dist/deploy.js +136 -58
- package/dist/generated/openapi.d.ts +726 -16
- package/dist/generated/runtime-contract.d.ts +34 -27
- package/dist/generated/runtime-contract.js +123 -8680
- package/dist/index.d.ts +16 -15
- package/dist/index.js +1 -0
- package/dist/method.d.ts +10 -0
- package/dist/method.js +21 -0
- package/dist/sourceFiles.d.ts +16 -0
- package/dist/sourceFiles.js +114 -0
- package/dist/types.d.ts +45 -1
- package/package.json +15 -3
package/dist/client.js
CHANGED
|
@@ -3,6 +3,7 @@ export { PermuteApiError } from './errors.js';
|
|
|
3
3
|
import { Ajv } from 'ajv';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { publicApiRoutes } from './generated/runtime-contract.js';
|
|
6
|
+
import { SdkMethodFactory } from './method.js';
|
|
6
7
|
const DEFAULT_BASE_URL = 'https://api.permute.ai';
|
|
7
8
|
const DEFAULT_POLL_TIMEOUT_MS = 20 * 60 * 1000;
|
|
8
9
|
function routeFor(operationId) {
|
|
@@ -250,11 +251,14 @@ export class PermuteFileDataset {
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
export class PermuteClient {
|
|
254
|
+
permissions;
|
|
255
|
+
accessRequests;
|
|
253
256
|
revisions;
|
|
254
257
|
facts;
|
|
255
258
|
skills;
|
|
256
259
|
organizationSkills;
|
|
257
260
|
actions;
|
|
261
|
+
emails;
|
|
258
262
|
databases;
|
|
259
263
|
apps;
|
|
260
264
|
connectorSessions;
|
|
@@ -266,17 +270,18 @@ export class PermuteClient {
|
|
|
266
270
|
dashboards;
|
|
267
271
|
datasets;
|
|
268
272
|
apiKey;
|
|
273
|
+
accessToken;
|
|
269
274
|
baseUrl;
|
|
270
275
|
/** Workspace selected for workspace-scoped API operations. */
|
|
271
276
|
workspaceId;
|
|
272
277
|
defaultHeaders;
|
|
273
278
|
fetchImpl;
|
|
274
279
|
constructor(options) {
|
|
275
|
-
if (!options.apiKey) {
|
|
280
|
+
if ((!options.apiKey && !options.accessToken) || (options.apiKey && options.accessToken)) {
|
|
276
281
|
throw new PermuteApiError({
|
|
277
282
|
status: 0,
|
|
278
283
|
code: 'missing_api_key',
|
|
279
|
-
message: 'apiKey
|
|
284
|
+
message: 'Provide apiKey or accessToken',
|
|
280
285
|
});
|
|
281
286
|
}
|
|
282
287
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
@@ -288,56 +293,85 @@ export class PermuteClient {
|
|
|
288
293
|
});
|
|
289
294
|
}
|
|
290
295
|
this.apiKey = options.apiKey;
|
|
296
|
+
this.accessToken = options.accessToken;
|
|
291
297
|
this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
292
298
|
this.workspaceId = options.workspaceId;
|
|
293
299
|
this.defaultHeaders = options.headers ?? {};
|
|
294
300
|
this.fetchImpl = fetchImpl.bind(globalThis);
|
|
301
|
+
this.permissions = {
|
|
302
|
+
update: this.bindMethod('permissionsUpdate', (request) => (permissionId, body, options) => request({ pathParams: { permissionId }, body }, options)),
|
|
303
|
+
list: this.bindMethod('permissionsList', (request) => (query, options) => request({ query }, options)),
|
|
304
|
+
create: this.bindMethod('permissionsCreate', (request) => (body, options) => request({ body }, options)),
|
|
305
|
+
delete: this.bindMethod('permissionsDelete', (request) => (permissionId, options) => request({ pathParams: { permissionId } }, options)),
|
|
306
|
+
inspect: this.bindMethod('permissionsInspect', (request) => (body, options) => request({ body }, options)),
|
|
307
|
+
};
|
|
308
|
+
this.accessRequests = {
|
|
309
|
+
create: this.bindMethod('accessRequestsCreate', (request) => (body, options) => request({ body }, options)),
|
|
310
|
+
list: this.bindMethod('accessRequestsList', (request) => (query, options) => request({ query }, options)),
|
|
311
|
+
get: this.bindMethod('accessRequestsGet', (request) => (requestId, options) => request({ pathParams: { requestId } }, options)),
|
|
312
|
+
decide: this.bindMethod('accessRequestsDecide', (request) => (requestId, body, options) => request({ pathParams: { requestId }, body }, options)),
|
|
313
|
+
};
|
|
295
314
|
this.revisions = {
|
|
296
|
-
list: (resourceId, options) =>
|
|
297
|
-
get: (resourceId, revisionId, options) =>
|
|
298
|
-
restore: (resourceId, revisionId, body, options) =>
|
|
299
|
-
publish: (resourceId, body, options) =>
|
|
315
|
+
list: this.bindMethod('resourceRevisionsList', (apiRequest) => (resourceId, options) => apiRequest({ pathParams: { resourceId } }, options)),
|
|
316
|
+
get: this.bindMethod('resourceRevisionsGet', (apiRequest) => (resourceId, revisionId, options) => apiRequest({ pathParams: { resourceId, revisionId } }, options)),
|
|
317
|
+
restore: this.bindMethod('resourceRevisionsRestore', (apiRequest) => (resourceId, revisionId, body, options) => apiRequest({ pathParams: { resourceId, revisionId }, body }, options)),
|
|
318
|
+
publish: this.bindMethod('resourcesPublish', (apiRequest) => (resourceId, body, options) => apiRequest({ pathParams: { resourceId }, body }, options)),
|
|
300
319
|
};
|
|
301
320
|
this.facts = {
|
|
302
|
-
list:
|
|
303
|
-
get: (factId, options) =>
|
|
304
|
-
create: (body, options) =>
|
|
305
|
-
update: (factId, body, options) =>
|
|
306
|
-
delete: (factId, options) =>
|
|
321
|
+
list: this.bindMethod('factsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
322
|
+
get: this.bindMethod('factsGet', (apiRequest) => (factId, options) => apiRequest({ pathParams: { factId } }, options)),
|
|
323
|
+
create: this.bindMethod('factsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
324
|
+
update: this.bindMethod('factsUpdate', (apiRequest) => (factId, body, options) => apiRequest({ pathParams: { factId }, body }, options)),
|
|
325
|
+
delete: this.bindMethod('factsDelete', (apiRequest) => (factId, options) => apiRequest({ pathParams: { factId } }, options)),
|
|
307
326
|
};
|
|
308
327
|
const skillsClient = (prefix) => ({
|
|
309
|
-
list:
|
|
310
|
-
get: (path, options) =>
|
|
311
|
-
update: (path, body, options) =>
|
|
312
|
-
delete: (path, options) =>
|
|
328
|
+
list: this.bindMethod(`${prefix}List`, (apiRequest) => (options) => apiRequest({}, options)),
|
|
329
|
+
get: this.bindMethod(`${prefix}Get`, (apiRequest) => (path, options) => apiRequest({ pathParams: { path } }, options)),
|
|
330
|
+
update: this.bindMethod(`${prefix}Update`, (apiRequest) => (path, body, options) => apiRequest({ pathParams: { path }, body }, options)),
|
|
331
|
+
delete: this.bindMethod(`${prefix}Delete`, (apiRequest) => (path, options) => apiRequest({ pathParams: { path } }, options)),
|
|
313
332
|
});
|
|
314
333
|
this.skills = skillsClient('skills');
|
|
315
334
|
this.organizationSkills = skillsClient('organizationSkills');
|
|
316
335
|
this.actions = {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
336
|
+
requestPublication: this.bindMethod('actionsPublicationRequestsCreate', (apiRequest) => (actionId, body, options) => apiRequest({ pathParams: { actionId }, body }, options)),
|
|
337
|
+
publicationRequests: this.bindMethod('actionsPublicationRequestsList', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
338
|
+
decidePublication: this.bindMethod('actionsPublicationRequestsDecide', (apiRequest) => (actionId, requestId, body, options) => apiRequest({ pathParams: { actionId, requestId }, body }, options)),
|
|
339
|
+
list: this.bindMethod('actionsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
340
|
+
create: this.bindMethod('actionsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
341
|
+
get: this.bindMethod('actionsGet', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
342
|
+
delete: this.bindMethod('actionsDelete', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
343
|
+
definition: this.bindMethod('actionDefinitionGet', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
344
|
+
saveDefinition: this.bindMethod('actionDefinitionSave', (apiRequest) => (actionId, body, options) => apiRequest({ pathParams: { actionId }, body }, options)),
|
|
345
|
+
invoke: this.bindMethod('actionsInvoke', (apiRequest) => (actionId, body, options) => apiRequest({ pathParams: { actionId }, body }, options)),
|
|
346
|
+
};
|
|
347
|
+
this.emails = {
|
|
348
|
+
get: this.bindMethod('emailsGet', (request) => (options) => request({}, options)),
|
|
349
|
+
send: this.bindMethod('emailsSend', (request) => (body, options) => request({ body }, options)),
|
|
324
350
|
};
|
|
325
351
|
this.databases = {
|
|
326
|
-
list:
|
|
327
|
-
create: (body, options) =>
|
|
328
|
-
get: (databaseId, options) =>
|
|
329
|
-
delete: (databaseId, options) =>
|
|
330
|
-
definition: (databaseId, options) =>
|
|
331
|
-
saveDefinition: (databaseId, body, options) =>
|
|
332
|
-
tables: (databaseId, options) =>
|
|
333
|
-
createTable: (databaseId, body, options) =>
|
|
334
|
-
records: (databaseId, table, query = {}, options) =>
|
|
335
|
-
transact: (databaseId, body, options) =>
|
|
352
|
+
list: this.bindMethod('databasesList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
353
|
+
create: this.bindMethod('databasesCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
354
|
+
get: this.bindMethod('databasesGet', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
355
|
+
delete: this.bindMethod('databasesDelete', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
356
|
+
definition: this.bindMethod('databaseDefinitionGet', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
357
|
+
saveDefinition: this.bindMethod('databaseDefinitionSave', (apiRequest) => (databaseId, body, options) => apiRequest({ pathParams: { databaseId }, body }, options)),
|
|
358
|
+
tables: this.bindMethod('databaseTablesList', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
359
|
+
createTable: this.bindMethod('databaseTablesCreate', (apiRequest) => (databaseId, body, options) => apiRequest({ pathParams: { databaseId }, body }, options)),
|
|
360
|
+
records: this.bindMethod('databaseRecordsList', (apiRequest) => (databaseId, table, query = {}, options) => apiRequest({ pathParams: { databaseId, table }, query }, options)),
|
|
361
|
+
transact: this.bindMethod('databaseTransactionsCreate', (apiRequest) => (databaseId, body, options) => apiRequest({ pathParams: { databaseId }, body }, options)),
|
|
336
362
|
};
|
|
337
363
|
this.apps = {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
364
|
+
requestPublication: this.bindMethod('appsPublicationRequestsCreate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
365
|
+
publicationRequests: this.bindMethod('appsPublicationRequestsList', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
366
|
+
decidePublication: this.bindMethod('appsPublicationRequestsDecide', (apiRequest) => (applicationId, requestId, body, options) => apiRequest({ pathParams: { applicationId, requestId }, body }, options)),
|
|
367
|
+
sourceFile: this.bindMethod('appsSourceFileGet', (apiRequest) => (applicationId, query, options) => apiRequest({ pathParams: { applicationId }, query }, options)),
|
|
368
|
+
address: this.bindMethod('appsAddressGet', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
369
|
+
setAddress: this.bindMethod('appsAddressSet', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
370
|
+
access: this.bindMethod('appsAccessGet', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
371
|
+
setAccess: this.bindMethod('appsAccessSet', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
372
|
+
listGrants: this.bindMethod('appsGrantsList', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
373
|
+
setGrant: this.bindMethod('appsGrantsSet', (apiRequest) => (applicationId, resourceId, body, options) => apiRequest({ pathParams: { applicationId, resourceId }, body }, options)),
|
|
374
|
+
prepareUploads: this.bindMethod('appsUploadsCreate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
341
375
|
uploadFiles: async (applicationId, files, options) => {
|
|
342
376
|
const contents = await Promise.all(files.map(async (file) => ({
|
|
343
377
|
path: file.path,
|
|
@@ -373,71 +407,73 @@ export class PermuteClient {
|
|
|
373
407
|
}
|
|
374
408
|
return manifest;
|
|
375
409
|
},
|
|
376
|
-
saveSite: (applicationId, body, options) =>
|
|
377
|
-
list:
|
|
378
|
-
create: (body, options) =>
|
|
379
|
-
get: (applicationId, options) =>
|
|
380
|
-
update: (applicationId, body, options) =>
|
|
381
|
-
delete: (applicationId, options) =>
|
|
410
|
+
saveSite: this.bindMethod('appsSiteUpdate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
411
|
+
list: this.bindMethod('appsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
412
|
+
create: this.bindMethod('appsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
413
|
+
get: this.bindMethod('appsGet', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
414
|
+
update: this.bindMethod('appsUpdate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
415
|
+
delete: this.bindMethod('appsDelete', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
382
416
|
};
|
|
383
417
|
this.connectorSessions = {
|
|
384
|
-
create: (body, options) =>
|
|
385
|
-
get: (sessionId, options) =>
|
|
418
|
+
create: this.bindMethod('connectorSessionsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
419
|
+
get: this.bindMethod('connectorSessionsGet', (apiRequest) => (sessionId, options) => apiRequest({ pathParams: { sessionId } }, options)),
|
|
386
420
|
};
|
|
387
421
|
this.writeSyncs = {
|
|
388
|
-
list:
|
|
389
|
-
create: (body, options) =>
|
|
390
|
-
get: (writeSyncId, options) =>
|
|
391
|
-
update: (writeSyncId, body, options) =>
|
|
392
|
-
delete: (writeSyncId, options) =>
|
|
393
|
-
destinations:
|
|
394
|
-
preview: (writeSyncId, options) =>
|
|
395
|
-
pause: (writeSyncId, options) =>
|
|
396
|
-
listRuns: (writeSyncId, options) =>
|
|
397
|
-
getRun: (writeSyncId, runId, query = {}, options) =>
|
|
398
|
-
execute: (writeSyncId, runId, options) =>
|
|
422
|
+
list: this.bindMethod('writeSyncsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
423
|
+
create: this.bindMethod('writeSyncsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
424
|
+
get: this.bindMethod('writeSyncsGet', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
425
|
+
update: this.bindMethod('writeSyncsUpdate', (apiRequest) => (writeSyncId, body, options) => apiRequest({ pathParams: { writeSyncId }, body }, options)),
|
|
426
|
+
delete: this.bindMethod('writeSyncsDelete', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
427
|
+
destinations: this.bindMethod('writeSyncsDestinations', (apiRequest) => (options) => apiRequest({}, options)),
|
|
428
|
+
preview: this.bindMethod('writeSyncsPreview', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
429
|
+
pause: this.bindMethod('writeSyncsPause', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
430
|
+
listRuns: this.bindMethod('writeSyncsListRuns', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
431
|
+
getRun: this.bindMethod('writeSyncsGetRun', (apiRequest) => (writeSyncId, runId, query = {}, options) => apiRequest({ pathParams: { writeSyncId, runId }, query }, options)),
|
|
432
|
+
execute: this.bindMethod('writeSyncsExecute', (apiRequest) => (writeSyncId, runId, options) => apiRequest({ pathParams: { writeSyncId, runId } }, options)),
|
|
399
433
|
};
|
|
400
434
|
this.workspaces = {
|
|
401
|
-
list:
|
|
402
|
-
create: (request, requestOptions) =>
|
|
403
|
-
get: (workspaceId, requestOptions) =>
|
|
404
|
-
update: (workspaceId, request, requestOptions) =>
|
|
405
|
-
delete: (workspaceId, requestOptions) =>
|
|
435
|
+
list: this.bindMethod('workspacesList', (apiRequest) => (requestOptions) => apiRequest({}, requestOptions)),
|
|
436
|
+
create: this.bindMethod('workspacesCreate', (apiRequest) => (request, requestOptions) => apiRequest({ body: request }, requestOptions)),
|
|
437
|
+
get: this.bindMethod('workspacesGet', (apiRequest) => (workspaceId, requestOptions) => apiRequest({ pathParams: { workspaceId } }, requestOptions)),
|
|
438
|
+
update: this.bindMethod('workspacesUpdate', (apiRequest) => (workspaceId, request, requestOptions) => apiRequest({ pathParams: { workspaceId }, body: request }, requestOptions)),
|
|
439
|
+
delete: this.bindMethod('workspacesDelete', (apiRequest) => (workspaceId, requestOptions) => apiRequest({ pathParams: { workspaceId } }, requestOptions)),
|
|
406
440
|
};
|
|
407
441
|
this.sources = {
|
|
408
|
-
list:
|
|
409
|
-
get: (sourceId, requestOptions) =>
|
|
410
|
-
listTables: async (sourceId, requestOptions) => (await
|
|
442
|
+
list: this.bindMethod('sourcesList', (apiRequest) => (requestOptions) => apiRequest({}, requestOptions)),
|
|
443
|
+
get: this.bindMethod('sourcesGet', (apiRequest) => (sourceId, requestOptions) => apiRequest({ pathParams: { sourceId } }, requestOptions)),
|
|
444
|
+
listTables: this.bindMethod('sourcesGet', (apiRequest) => async (sourceId, requestOptions) => (await apiRequest({
|
|
411
445
|
pathParams: { sourceId },
|
|
412
446
|
query: { includeFields: 'false' },
|
|
413
|
-
}, requestOptions)).tables,
|
|
414
|
-
describeTable: async (sourceId, tableId, requestOptions) => (await
|
|
447
|
+
}, requestOptions)).tables),
|
|
448
|
+
describeTable: this.bindMethod('sourcesGet', (apiRequest) => async (sourceId, tableId, requestOptions) => (await apiRequest({
|
|
415
449
|
pathParams: { sourceId },
|
|
416
450
|
query: { tableId },
|
|
417
|
-
}, requestOptions)).tables[0],
|
|
451
|
+
}, requestOptions)).tables[0]),
|
|
418
452
|
};
|
|
453
|
+
const listOperationRuns = this.bindMethod('operationsRunsList', (apiRequest) => (operationId, options) => apiRequest({ pathParams: { operationId } }, options));
|
|
454
|
+
const listWorkflowRuns = this.bindMethod('operationRunsList', (apiRequest) => (query, options) => apiRequest({ query }, options));
|
|
419
455
|
this.operations = {
|
|
420
|
-
list: (query = {}, options) =>
|
|
421
|
-
get: (operationId, options) =>
|
|
422
|
-
update: (operationId, body, options) =>
|
|
423
|
-
getSource: (operationId, options) =>
|
|
424
|
-
updateSource: (operationId, body, options) =>
|
|
425
|
-
getRunOutput: (operationId, runId, options) =>
|
|
426
|
-
listRuns: ((input, options) => typeof input === 'string'
|
|
427
|
-
?
|
|
428
|
-
:
|
|
429
|
-
run: (operationId, body, options) =>
|
|
456
|
+
list: this.bindMethod('operationsList', (apiRequest) => (query = {}, options) => apiRequest({ query }, options)),
|
|
457
|
+
get: this.bindMethod('operationsGet', (apiRequest) => (operationId, options) => apiRequest({ pathParams: { operationId } }, options)),
|
|
458
|
+
update: this.bindMethod('operationsUpdate', (apiRequest) => (operationId, body, options) => apiRequest({ pathParams: { operationId }, body }, options)),
|
|
459
|
+
getSource: this.bindMethod('operationsSourceGet', (apiRequest) => (operationId, options) => apiRequest({ pathParams: { operationId } }, options)),
|
|
460
|
+
updateSource: this.bindMethod('operationsSourceUpdate', (apiRequest) => (operationId, body, options) => apiRequest({ pathParams: { operationId }, body }, options)),
|
|
461
|
+
getRunOutput: this.bindMethod('operationsRunOutput', (apiRequest) => (operationId, runId, options) => apiRequest({ pathParams: { operationId, runId } }, options)),
|
|
462
|
+
listRuns: SdkMethodFactory.compose([listOperationRuns, listWorkflowRuns], ((input, options) => typeof input === 'string'
|
|
463
|
+
? listOperationRuns(input, options)
|
|
464
|
+
: listWorkflowRuns(input, options))),
|
|
465
|
+
run: this.bindMethod('operationsRun', (apiRequest) => (operationId, body, options) => apiRequest({ pathParams: { operationId }, body }, options)),
|
|
430
466
|
};
|
|
431
467
|
this.dataFlows = {
|
|
432
|
-
create: (body, options) =>
|
|
433
|
-
get: (dataFlowId, options) =>
|
|
434
|
-
command: (dataFlowId, body, options) =>
|
|
468
|
+
create: this.bindMethod('dataFlowsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
469
|
+
get: this.bindMethod('dataFlowsGet', (apiRequest) => (dataFlowId, options) => apiRequest({ pathParams: { dataFlowId } }, options)),
|
|
470
|
+
command: this.bindMethod('dataFlowsCommand', (apiRequest) => (dataFlowId, body, options) => apiRequest({ pathParams: { dataFlowId }, body }, options)),
|
|
435
471
|
};
|
|
436
472
|
this.dashboards = {
|
|
437
|
-
getSource: (dashboardId, requestOptions) =>
|
|
438
|
-
updateSource: (dashboardId, request, requestOptions) =>
|
|
473
|
+
getSource: this.bindMethod('dashboardsSourceGet', (apiRequest) => (dashboardId, requestOptions) => apiRequest({ pathParams: { dashboardId } }, requestOptions)),
|
|
474
|
+
updateSource: this.bindMethod('dashboardsSourceUpdate', (apiRequest) => (dashboardId, request, requestOptions) => apiRequest({ pathParams: { dashboardId }, body: request }, requestOptions)),
|
|
439
475
|
};
|
|
440
|
-
const readDataset = (datasetId, requestOptions) =>
|
|
476
|
+
const readDataset = this.bindMethod('datasetsGet', (apiRequest) => (datasetId, requestOptions) => apiRequest({ pathParams: { datasetId } }, requestOptions));
|
|
441
477
|
const writeDatasetTables = async (datasetId, request, requestOptions) => {
|
|
442
478
|
const encoded = encodeDatasetWrite(request);
|
|
443
479
|
const body = request.mode === 'replace'
|
|
@@ -505,9 +541,9 @@ export class PermuteClient {
|
|
|
505
541
|
const wrapDataset = (dataset) => dataset.type === 'custom'
|
|
506
542
|
? new PermuteDataset(dataset, writeDatasetTables, readDataset)
|
|
507
543
|
: new PermuteFileDataset(dataset, readDataset);
|
|
508
|
-
const createDataset = async (request, requestOptions) => {
|
|
544
|
+
const createDataset = this.bindMethod('datasetsCreate', (apiRequest) => async (request, requestOptions) => {
|
|
509
545
|
if (request.type === 'custom') {
|
|
510
|
-
const dataset = await
|
|
546
|
+
const dataset = await apiRequest({ body: request }, requestOptions);
|
|
511
547
|
return new PermuteDataset(requireCustomDataset(dataset), writeDatasetTables, readDataset);
|
|
512
548
|
}
|
|
513
549
|
const { data, headers, sizeBytes: declaredSize, ...createRequest } = request;
|
|
@@ -524,10 +560,10 @@ export class PermuteClient {
|
|
|
524
560
|
throw new PermuteApiError({
|
|
525
561
|
status: 0,
|
|
526
562
|
code: 'missing_file_size',
|
|
527
|
-
message: 'sizeBytes is required
|
|
563
|
+
message: 'sizeBytes is required without data or when the upload body size cannot be inferred',
|
|
528
564
|
});
|
|
529
565
|
}
|
|
530
|
-
const response = await
|
|
566
|
+
const response = await apiRequest({ body: { ...createRequest, sizeBytes } }, requestOptions);
|
|
531
567
|
const dataset = new PermuteFileDataset(requireFileDataset(response), readDataset);
|
|
532
568
|
const target = dataset.data.upload;
|
|
533
569
|
if (!target) {
|
|
@@ -537,6 +573,8 @@ export class PermuteClient {
|
|
|
537
573
|
message: `Dataset ${dataset.id} did not include a file upload target`,
|
|
538
574
|
});
|
|
539
575
|
}
|
|
576
|
+
if (data === undefined)
|
|
577
|
+
return dataset;
|
|
540
578
|
const uploadResponse = await this.fetchImpl(target.url, {
|
|
541
579
|
method: target.method,
|
|
542
580
|
headers: { ...headers, ...target.headers },
|
|
@@ -551,27 +589,28 @@ export class PermuteClient {
|
|
|
551
589
|
});
|
|
552
590
|
}
|
|
553
591
|
return dataset;
|
|
554
|
-
};
|
|
592
|
+
});
|
|
555
593
|
this.datasets = {
|
|
556
594
|
create: createDataset,
|
|
557
|
-
getByKey: async (key, requestOptions) => {
|
|
558
|
-
const dataset = await
|
|
595
|
+
getByKey: this.bindMethod('datasetsGetByKey', (apiRequest) => async (key, requestOptions) => {
|
|
596
|
+
const dataset = await apiRequest({ query: { key } }, requestOptions);
|
|
559
597
|
return wrapDataset(dataset);
|
|
560
|
-
},
|
|
598
|
+
}),
|
|
561
599
|
get: async (datasetId, requestOptions) => {
|
|
562
600
|
const dataset = await readDataset(datasetId, requestOptions);
|
|
563
601
|
return wrapDataset(dataset);
|
|
564
602
|
},
|
|
565
|
-
download: async (datasetId, requestOptions) => {
|
|
566
|
-
const { url } = await
|
|
603
|
+
download: this.bindMethod('datasetsDownload', (apiRequest) => async (datasetId, requestOptions) => {
|
|
604
|
+
const { url } = await apiRequest({ pathParams: { datasetId } }, requestOptions);
|
|
567
605
|
return url;
|
|
568
|
-
},
|
|
569
|
-
delete: (datasetId, requestOptions) =>
|
|
606
|
+
}),
|
|
607
|
+
delete: this.bindMethod('datasetsDelete', (apiRequest) => (datasetId, requestOptions) => apiRequest({ pathParams: { datasetId } }, requestOptions)),
|
|
570
608
|
};
|
|
609
|
+
this.apps.uploadFiles = SdkMethodFactory.compose([this.apps.prepareUploads], this.apps.uploadFiles);
|
|
610
|
+
this.datasets.get = SdkMethodFactory.compose([readDataset], this.datasets.get);
|
|
611
|
+
this.answer = SdkMethodFactory.compose([this.answerJobs, this.getAnswerJob], this.answer.bind(this));
|
|
571
612
|
}
|
|
572
|
-
|
|
573
|
-
return await this.request('searchCreate', { body: request }, options);
|
|
574
|
-
}
|
|
613
|
+
search = this.bindMethod('searchCreate', (apiRequest) => (request, options) => apiRequest({ body: request }, options));
|
|
575
614
|
async answer(request, options) {
|
|
576
615
|
let job = await this.answerJobs(request, options);
|
|
577
616
|
const deadline = pollingDeadline(options);
|
|
@@ -594,33 +633,31 @@ export class PermuteClient {
|
|
|
594
633
|
message: job.error ?? `Answer job ${job.status}`,
|
|
595
634
|
});
|
|
596
635
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
async getAnswerJob(answerJobId, options) {
|
|
601
|
-
return await this.request('answerJobsGet', { pathParams: { answerJobId } }, options);
|
|
602
|
-
}
|
|
636
|
+
answerJobs = this.bindMethod('answerJobsCreate', (apiRequest) => (request, options) => apiRequest({ body: request }, options));
|
|
637
|
+
getAnswerJob = this.bindMethod('answerJobsGet', (apiRequest) => (answerJobId, options) => apiRequest({ pathParams: { answerJobId } }, options));
|
|
603
638
|
withWorkspace(workspaceId) {
|
|
604
639
|
if (!workspaceId.trim()) {
|
|
605
640
|
throw new PermuteApiError({ status: 0, code: 'missing_workspace_id', message: 'workspaceId is required' });
|
|
606
641
|
}
|
|
607
642
|
return new PermuteClient({
|
|
608
643
|
apiKey: this.apiKey,
|
|
644
|
+
accessToken: this.accessToken,
|
|
609
645
|
baseUrl: this.baseUrl,
|
|
610
646
|
workspaceId,
|
|
611
647
|
fetch: this.fetchImpl,
|
|
612
648
|
headers: this.defaultHeaders,
|
|
613
649
|
});
|
|
614
650
|
}
|
|
615
|
-
|
|
616
|
-
|
|
651
|
+
query = this.bindMethod('queriesCreate', (apiRequest) => (request, options) => apiRequest({ body: request }, options));
|
|
652
|
+
bindMethod(operationId, create) {
|
|
653
|
+
return SdkMethodFactory.create(operationId, create((input, options) => this.request(operationId, input, options)));
|
|
617
654
|
}
|
|
618
655
|
async request(operationId, input, options) {
|
|
619
656
|
const route = routeFor(operationId);
|
|
620
657
|
const body = this.validateRequestBody(route, operationId, input.body);
|
|
621
658
|
const query = this.validateRequestQuery(route, operationId, input.query);
|
|
622
659
|
const headers = {
|
|
623
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
660
|
+
Authorization: `Bearer ${this.accessToken ? await this.accessToken() : this.apiKey}`,
|
|
624
661
|
...this.defaultHeaders,
|
|
625
662
|
...options?.headers,
|
|
626
663
|
};
|
package/dist/deploy.d.ts
CHANGED
|
@@ -1,15 +1,89 @@
|
|
|
1
1
|
import type { PermuteClient } from './client.js';
|
|
2
|
-
import type { AppSiteSaveRequest, PermuteRequestOptions } from './types.js';
|
|
2
|
+
import type { AppSiteSaveRequest, AppSource, PermuteRequestOptions } from './types.js';
|
|
3
3
|
export interface DeployAppOptions {
|
|
4
4
|
appId: string;
|
|
5
5
|
directory: string;
|
|
6
|
+
/** Original project files and the instructions used to compile directory. */
|
|
7
|
+
source: {
|
|
8
|
+
directory: string;
|
|
9
|
+
build: AppSource['build'];
|
|
10
|
+
};
|
|
6
11
|
/** Defaults to true. */
|
|
7
12
|
spa?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
expectedDraft
|
|
13
|
+
/** Token from checkout or a reviewed app draft. Never infer the base of local source from newer remote work. */
|
|
14
|
+
expectedDraft: AppSiteSaveRequest['expectedDraft'];
|
|
10
15
|
/** Omit to preserve bindings; [] removes them. Revisions must already be published. */
|
|
11
16
|
actions?: AppSiteSaveRequest['actions'];
|
|
12
17
|
}
|
|
18
|
+
/** Save a shared source checkpoint without compiling or publishing. */
|
|
19
|
+
export declare function saveAppSource(client: PermuteClient, options: {
|
|
20
|
+
appId: string;
|
|
21
|
+
source: DeployAppOptions['source'];
|
|
22
|
+
expectedDraft: AppSiteSaveRequest['expectedDraft'];
|
|
23
|
+
}, requestOptions?: PermuteRequestOptions): Promise<{
|
|
24
|
+
chat?: {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
};
|
|
27
|
+
createdAt: string;
|
|
28
|
+
deployment: {
|
|
29
|
+
error: string | null;
|
|
30
|
+
revisionId: string;
|
|
31
|
+
status: 'deploying' | 'live' | 'deleting' | 'failed' | 'deleted';
|
|
32
|
+
url: string;
|
|
33
|
+
} | null;
|
|
34
|
+
description: string;
|
|
35
|
+
draft: {
|
|
36
|
+
revisionId: string;
|
|
37
|
+
sequence: number;
|
|
38
|
+
};
|
|
39
|
+
favicon?: {
|
|
40
|
+
path: string;
|
|
41
|
+
sha256: string;
|
|
42
|
+
size: number;
|
|
43
|
+
} | null;
|
|
44
|
+
id: string;
|
|
45
|
+
login?: {
|
|
46
|
+
header?: string;
|
|
47
|
+
primaryColor?: string;
|
|
48
|
+
secondaryColor?: string;
|
|
49
|
+
sidePanelImage?: {
|
|
50
|
+
path: string;
|
|
51
|
+
sha256: string;
|
|
52
|
+
size: number;
|
|
53
|
+
};
|
|
54
|
+
subheader?: string;
|
|
55
|
+
subtitle?: string;
|
|
56
|
+
title?: string;
|
|
57
|
+
} | null;
|
|
58
|
+
name: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
workspaceId: string;
|
|
61
|
+
}>;
|
|
62
|
+
/** Materialize the draft or an exact historical source revision into a new folder. Never overwrites files. */
|
|
63
|
+
export declare function checkoutApp(client: PermuteClient, options: {
|
|
64
|
+
appId: string;
|
|
65
|
+
directory: string;
|
|
66
|
+
revisionId?: string;
|
|
67
|
+
}, requestOptions?: PermuteRequestOptions): Promise<{
|
|
68
|
+
revisionId: string;
|
|
69
|
+
source: {
|
|
70
|
+
build: {
|
|
71
|
+
command: string;
|
|
72
|
+
outputDirectory: string;
|
|
73
|
+
runtime: string;
|
|
74
|
+
};
|
|
75
|
+
files: {
|
|
76
|
+
executable?: boolean;
|
|
77
|
+
path: string;
|
|
78
|
+
sha256: string;
|
|
79
|
+
size: number;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
82
|
+
expectedDraft: {
|
|
83
|
+
revisionId: string;
|
|
84
|
+
sequence: number;
|
|
85
|
+
} | null;
|
|
86
|
+
}>;
|
|
13
87
|
/** Upload, save, and publish an existing live app. Builds and provisions nothing; never retries mutations. */
|
|
14
88
|
export declare function deployApp(client: PermuteClient, options: DeployAppOptions, requestOptions?: PermuteRequestOptions): Promise<{
|
|
15
89
|
url: string;
|