@permute/sdk 0.5.0 → 0.7.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 +229 -20
- package/dist/app.d.ts +16 -2
- package/dist/app.js +25 -5
- package/dist/bridge.d.ts +10 -0
- package/dist/bridge.js +62 -0
- package/dist/client.d.ts +123 -5
- package/dist/client.js +110 -100
- package/dist/deploy.d.ts +77 -5
- package/dist/deploy.js +137 -63
- package/dist/generated/openapi.d.ts +354 -13
- package/dist/generated/runtime-contract.d.ts +2 -1
- package/dist/generated/runtime-contract.js +100 -8558
- package/dist/index.d.ts +1 -0
- 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 +19 -0
- package/package.json +3 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PermuteApiError } from './errors.js';
|
|
2
2
|
import type { BusinessAction, BusinessActionList, ActionCreateRequest, ActionDefinition, ActionDefinitionSaveRequest, ActionDefinitionSaved, ActionRequest, ActionReceipt } from './types.js';
|
|
3
|
-
import type { ConnectorSession, ConnectorSessionCreated, ConnectorSessionCreateRequest, Database, AppDraft, AppDraftList, AppCreateRequest, AppUpdateRequest, AppDeleted, AppUploadsRequest, AppUploads, AppSiteSaveRequest, AppUploadFile, DatabaseList, DatabaseCreateRequest, DatabaseDefinition, DatabaseDefinitionSaveRequest, DatabaseDefinitionSaved, DatabaseTables, DatabaseTableCreateRequest, DatabaseTableCreated, DatabaseRecords, DatabaseRecordsQuery, DatabaseTransactionRequest, DatabaseTransactionReceipt, WriteSync, WriteSyncCreateRequest, WriteSyncUpdateRequest, WriteSyncDetail, WriteSyncList, WriteSyncDeleted, WriteSyncDestinations, WriteSyncRun, WriteSyncRunList, WriteSyncRunQuery, WriteSyncExecution, ResourceVersionState, ResourceRevisionList, ResourceRevision, ResourceVersionRequest, ResourcePublishRequest, Fact, FactList, FactWriteRequest, SkillList, SkillContent, SkillWriteRequest, KnowledgeWriteResponse, OperationRunGroup, OperationRunQuery, Operation, OperationList, OperationListQuery, OperationSource, OperationSourceUpdateRequest, OperationUpdateRequest, OperationRunRequest, OperationRunStarted, OperationRunList, OperationRunOutput, DataFlow, DataFlowCreateRequest, DataFlowCommandRequest, DataFlowCommandResponse, Workspace, WorkspaceCreateRequest, WorkspaceDeleteResponse, WorkspaceList, WorkspaceUpdateRequest, AnswerRequest,
|
|
3
|
+
import type { ConnectorSession, ConnectorSessionCreated, ConnectorSessionCreateRequest, Database, AppDraft, AppAccess, AppAddressSettings, AppAddressSetRequest, AppAccessSetRequest, AppDraftList, AppCreateRequest, AppUpdateRequest, AppDeleted, AppUploadsRequest, AppUploads, AppSiteSaveRequest, AppSourceFileQuery, AppSourceFileContent, AppGrants, AppGrantSetRequest, AppUploadFile, DatabaseList, DatabaseCreateRequest, DatabaseDefinition, DatabaseDefinitionSaveRequest, DatabaseDefinitionSaved, DatabaseTables, DatabaseTableCreateRequest, DatabaseTableCreated, DatabaseRecords, DatabaseRecordsQuery, DatabaseTransactionRequest, DatabaseTransactionReceipt, WriteSync, WriteSyncCreateRequest, WriteSyncUpdateRequest, WriteSyncDetail, WriteSyncList, WriteSyncDeleted, WriteSyncDestinations, WriteSyncRun, WriteSyncRunList, WriteSyncRunQuery, WriteSyncExecution, ResourceVersionState, ResourceRevisionList, ResourceRevision, ResourceVersionRequest, ResourcePublishRequest, Fact, FactList, FactWriteRequest, SkillList, SkillContent, SkillWriteRequest, KnowledgeWriteResponse, OperationRunGroup, OperationRunQuery, Operation, OperationList, OperationListQuery, OperationSource, OperationSourceUpdateRequest, OperationUpdateRequest, OperationRunRequest, OperationRunStarted, OperationRunList, OperationRunOutput, DataFlow, DataFlowCreateRequest, DataFlowCommandRequest, DataFlowCommandResponse, Workspace, WorkspaceCreateRequest, WorkspaceDeleteResponse, WorkspaceList, WorkspaceUpdateRequest, AnswerRequest, AnswerResponse, PermuteClientOptions, PermuteRequestOptions, QueryRequest, SearchRequest, SourceDetail, CatalogTable, SourceList, CustomDatasetCreateRequest, DatasetDeleteResponse, DatasetResponse, FileDatasetCreateRequest, FileDatasetMetadataCreateRequest, FileDatasetResponse, DatasetRows, CustomDatasetResponse, DashboardSource, DashboardSourceUpdateRequest } from './types.js';
|
|
4
4
|
type DatasetWriteInput = {
|
|
5
5
|
tables: Record<string, DatasetRows>;
|
|
6
6
|
mode: 'replace';
|
|
@@ -93,6 +93,12 @@ export declare class PermuteClient {
|
|
|
93
93
|
transact(databaseId: string, body: DatabaseTransactionRequest, options?: PermuteRequestOptions): Promise<DatabaseTransactionReceipt>;
|
|
94
94
|
};
|
|
95
95
|
readonly apps: {
|
|
96
|
+
address(applicationId: string, options?: PermuteRequestOptions): Promise<AppAddressSettings>;
|
|
97
|
+
setAddress(applicationId: string, body: AppAddressSetRequest, options?: PermuteRequestOptions): Promise<AppAddressSettings>;
|
|
98
|
+
access(applicationId: string, options?: PermuteRequestOptions): Promise<AppAccess>;
|
|
99
|
+
setAccess(applicationId: string, body: AppAccessSetRequest, options?: PermuteRequestOptions): Promise<AppAccess>;
|
|
100
|
+
listGrants(applicationId: string, options?: PermuteRequestOptions): Promise<AppGrants>;
|
|
101
|
+
setGrant(applicationId: string, resourceId: string, body: AppGrantSetRequest, options?: PermuteRequestOptions): Promise<AppGrants>;
|
|
96
102
|
list(options?: PermuteRequestOptions): Promise<AppDraftList>;
|
|
97
103
|
create(body: AppCreateRequest, options?: PermuteRequestOptions): Promise<AppDraft>;
|
|
98
104
|
get(applicationId: string, options?: PermuteRequestOptions): Promise<AppDraft>;
|
|
@@ -101,6 +107,7 @@ export declare class PermuteClient {
|
|
|
101
107
|
prepareUploads(applicationId: string, body: AppUploadsRequest, options?: PermuteRequestOptions): Promise<AppUploads>;
|
|
102
108
|
uploadFiles(applicationId: string, files: AppUploadFile[], options?: PermuteRequestOptions): Promise<AppUploadsRequest['files']>;
|
|
103
109
|
saveSite(applicationId: string, body: AppSiteSaveRequest, options?: PermuteRequestOptions): Promise<AppDraft>;
|
|
110
|
+
sourceFile(applicationId: string, query: AppSourceFileQuery, options?: PermuteRequestOptions): Promise<AppSourceFileContent>;
|
|
104
111
|
};
|
|
105
112
|
readonly connectorSessions: {
|
|
106
113
|
create(request: ConnectorSessionCreateRequest, options?: PermuteRequestOptions): Promise<ConnectorSessionCreated>;
|
|
@@ -156,6 +163,7 @@ export declare class PermuteClient {
|
|
|
156
163
|
};
|
|
157
164
|
readonly datasets: {
|
|
158
165
|
create: {
|
|
166
|
+
(request: FileDatasetMetadataCreateRequest, options?: PermuteRequestOptions): Promise<PermuteFileDataset>;
|
|
159
167
|
(request: CustomDatasetCreateRequest, options?: PermuteRequestOptions): Promise<PermuteDataset>;
|
|
160
168
|
(request: FileDatasetCreateRequest, options?: PermuteRequestOptions): Promise<PermuteFileDataset>;
|
|
161
169
|
};
|
|
@@ -171,12 +179,122 @@ export declare class PermuteClient {
|
|
|
171
179
|
private readonly defaultHeaders;
|
|
172
180
|
private readonly fetchImpl;
|
|
173
181
|
constructor(options: PermuteClientOptions);
|
|
174
|
-
search(request: SearchRequest, options?: PermuteRequestOptions)
|
|
182
|
+
search: (request: SearchRequest, options?: PermuteRequestOptions) => Promise<{
|
|
183
|
+
items: {
|
|
184
|
+
citation?: {
|
|
185
|
+
[key: string]: unknown;
|
|
186
|
+
};
|
|
187
|
+
content: string;
|
|
188
|
+
metadata?: {
|
|
189
|
+
[key: string]: unknown;
|
|
190
|
+
};
|
|
191
|
+
score?: number;
|
|
192
|
+
sourceId?: string;
|
|
193
|
+
title?: string;
|
|
194
|
+
type: "record" | "document" | "table" | "text_block" | "unknown";
|
|
195
|
+
}[];
|
|
196
|
+
meta: {
|
|
197
|
+
candidateCount?: number;
|
|
198
|
+
reranked: boolean;
|
|
199
|
+
strategy: "semantic";
|
|
200
|
+
totalMs?: number;
|
|
201
|
+
};
|
|
202
|
+
}>;
|
|
175
203
|
answer(request: AnswerRequest, options?: PermuteRequestOptions): Promise<AnswerResponse>;
|
|
176
|
-
answerJobs(request: AnswerRequest, options?: PermuteRequestOptions)
|
|
177
|
-
|
|
204
|
+
answerJobs: (request: AnswerRequest, options?: PermuteRequestOptions) => Promise<{
|
|
205
|
+
answerJobId: string;
|
|
206
|
+
completedAt?: string | null;
|
|
207
|
+
createdAt?: string;
|
|
208
|
+
error?: string;
|
|
209
|
+
pollAfterMs?: number;
|
|
210
|
+
result?: {
|
|
211
|
+
answer: string;
|
|
212
|
+
assumptions?: {
|
|
213
|
+
[key: string]: unknown;
|
|
214
|
+
}[];
|
|
215
|
+
charts?: {
|
|
216
|
+
[key: string]: unknown;
|
|
217
|
+
}[];
|
|
218
|
+
citations: {
|
|
219
|
+
metadata?: {
|
|
220
|
+
[key: string]: unknown;
|
|
221
|
+
};
|
|
222
|
+
ref?: string;
|
|
223
|
+
sourceId?: string;
|
|
224
|
+
title?: string;
|
|
225
|
+
type: "text" | "table" | "web" | "fact";
|
|
226
|
+
url?: string;
|
|
227
|
+
}[];
|
|
228
|
+
confidence?: {
|
|
229
|
+
queryComplexity: "high" | "medium" | "low";
|
|
230
|
+
reason: string;
|
|
231
|
+
score: number;
|
|
232
|
+
};
|
|
233
|
+
followUps?: string[];
|
|
234
|
+
};
|
|
235
|
+
startedAt?: string | null;
|
|
236
|
+
status: "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
237
|
+
updatedAt?: string;
|
|
238
|
+
}>;
|
|
239
|
+
getAnswerJob: (answerJobId: string, options?: PermuteRequestOptions) => Promise<{
|
|
240
|
+
answerJobId: string;
|
|
241
|
+
completedAt?: string | null;
|
|
242
|
+
createdAt?: string;
|
|
243
|
+
error?: string;
|
|
244
|
+
pollAfterMs?: number;
|
|
245
|
+
result?: {
|
|
246
|
+
answer: string;
|
|
247
|
+
assumptions?: {
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
}[];
|
|
250
|
+
charts?: {
|
|
251
|
+
[key: string]: unknown;
|
|
252
|
+
}[];
|
|
253
|
+
citations: {
|
|
254
|
+
metadata?: {
|
|
255
|
+
[key: string]: unknown;
|
|
256
|
+
};
|
|
257
|
+
ref?: string;
|
|
258
|
+
sourceId?: string;
|
|
259
|
+
title?: string;
|
|
260
|
+
type: "text" | "table" | "web" | "fact";
|
|
261
|
+
url?: string;
|
|
262
|
+
}[];
|
|
263
|
+
confidence?: {
|
|
264
|
+
queryComplexity: "high" | "medium" | "low";
|
|
265
|
+
reason: string;
|
|
266
|
+
score: number;
|
|
267
|
+
};
|
|
268
|
+
followUps?: string[];
|
|
269
|
+
};
|
|
270
|
+
startedAt?: string | null;
|
|
271
|
+
status: "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
272
|
+
updatedAt?: string;
|
|
273
|
+
}>;
|
|
178
274
|
withWorkspace(workspaceId: string): PermuteClient;
|
|
179
|
-
query(request: QueryRequest, options?: PermuteRequestOptions)
|
|
275
|
+
query: (request: QueryRequest, options?: PermuteRequestOptions) => Promise<{
|
|
276
|
+
columns: {
|
|
277
|
+
name: string;
|
|
278
|
+
type?: string;
|
|
279
|
+
}[];
|
|
280
|
+
executionMs: number;
|
|
281
|
+
queryId: string;
|
|
282
|
+
rowCount: number;
|
|
283
|
+
rows: {
|
|
284
|
+
[key: string]: unknown;
|
|
285
|
+
}[];
|
|
286
|
+
sourceIds: string[];
|
|
287
|
+
sql: string;
|
|
288
|
+
timings?: {
|
|
289
|
+
initializationMs: number;
|
|
290
|
+
sourceLoadMs: number;
|
|
291
|
+
sourceValidationMs: number;
|
|
292
|
+
sqlExecutionMs: number;
|
|
293
|
+
totalMs: number;
|
|
294
|
+
};
|
|
295
|
+
truncated: boolean;
|
|
296
|
+
}>;
|
|
297
|
+
private bindMethod;
|
|
180
298
|
private request;
|
|
181
299
|
private validateRequestBody;
|
|
182
300
|
private validateRequestQuery;
|
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) {
|
|
@@ -293,49 +294,56 @@ export class PermuteClient {
|
|
|
293
294
|
this.defaultHeaders = options.headers ?? {};
|
|
294
295
|
this.fetchImpl = fetchImpl.bind(globalThis);
|
|
295
296
|
this.revisions = {
|
|
296
|
-
list: (resourceId, options) =>
|
|
297
|
-
get: (resourceId, revisionId, options) =>
|
|
298
|
-
restore: (resourceId, revisionId, body, options) =>
|
|
299
|
-
publish: (resourceId, body, options) =>
|
|
297
|
+
list: this.bindMethod('resourceRevisionsList', (apiRequest) => (resourceId, options) => apiRequest({ pathParams: { resourceId } }, options)),
|
|
298
|
+
get: this.bindMethod('resourceRevisionsGet', (apiRequest) => (resourceId, revisionId, options) => apiRequest({ pathParams: { resourceId, revisionId } }, options)),
|
|
299
|
+
restore: this.bindMethod('resourceRevisionsRestore', (apiRequest) => (resourceId, revisionId, body, options) => apiRequest({ pathParams: { resourceId, revisionId }, body }, options)),
|
|
300
|
+
publish: this.bindMethod('resourcesPublish', (apiRequest) => (resourceId, body, options) => apiRequest({ pathParams: { resourceId }, body }, options)),
|
|
300
301
|
};
|
|
301
302
|
this.facts = {
|
|
302
|
-
list:
|
|
303
|
-
get: (factId, options) =>
|
|
304
|
-
create: (body, options) =>
|
|
305
|
-
update: (factId, body, options) =>
|
|
306
|
-
delete: (factId, options) =>
|
|
303
|
+
list: this.bindMethod('factsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
304
|
+
get: this.bindMethod('factsGet', (apiRequest) => (factId, options) => apiRequest({ pathParams: { factId } }, options)),
|
|
305
|
+
create: this.bindMethod('factsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
306
|
+
update: this.bindMethod('factsUpdate', (apiRequest) => (factId, body, options) => apiRequest({ pathParams: { factId }, body }, options)),
|
|
307
|
+
delete: this.bindMethod('factsDelete', (apiRequest) => (factId, options) => apiRequest({ pathParams: { factId } }, options)),
|
|
307
308
|
};
|
|
308
309
|
const skillsClient = (prefix) => ({
|
|
309
|
-
list:
|
|
310
|
-
get: (path, options) =>
|
|
311
|
-
update: (path, body, options) =>
|
|
312
|
-
delete: (path, options) =>
|
|
310
|
+
list: this.bindMethod(`${prefix}List`, (apiRequest) => (options) => apiRequest({}, options)),
|
|
311
|
+
get: this.bindMethod(`${prefix}Get`, (apiRequest) => (path, options) => apiRequest({ pathParams: { path } }, options)),
|
|
312
|
+
update: this.bindMethod(`${prefix}Update`, (apiRequest) => (path, body, options) => apiRequest({ pathParams: { path }, body }, options)),
|
|
313
|
+
delete: this.bindMethod(`${prefix}Delete`, (apiRequest) => (path, options) => apiRequest({ pathParams: { path } }, options)),
|
|
313
314
|
});
|
|
314
315
|
this.skills = skillsClient('skills');
|
|
315
316
|
this.organizationSkills = skillsClient('organizationSkills');
|
|
316
317
|
this.actions = {
|
|
317
|
-
list:
|
|
318
|
-
create: (body, options) =>
|
|
319
|
-
get: (actionId, options) =>
|
|
320
|
-
delete: (actionId, options) =>
|
|
321
|
-
definition: (actionId, options) =>
|
|
322
|
-
saveDefinition: (actionId, body, options) =>
|
|
323
|
-
invoke: (actionId, body, options) =>
|
|
318
|
+
list: this.bindMethod('actionsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
319
|
+
create: this.bindMethod('actionsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
320
|
+
get: this.bindMethod('actionsGet', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
321
|
+
delete: this.bindMethod('actionsDelete', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
322
|
+
definition: this.bindMethod('actionDefinitionGet', (apiRequest) => (actionId, options) => apiRequest({ pathParams: { actionId } }, options)),
|
|
323
|
+
saveDefinition: this.bindMethod('actionDefinitionSave', (apiRequest) => (actionId, body, options) => apiRequest({ pathParams: { actionId }, body }, options)),
|
|
324
|
+
invoke: this.bindMethod('actionsInvoke', (apiRequest) => (actionId, body, options) => apiRequest({ pathParams: { actionId }, body }, options)),
|
|
324
325
|
};
|
|
325
326
|
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) =>
|
|
327
|
+
list: this.bindMethod('databasesList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
328
|
+
create: this.bindMethod('databasesCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
329
|
+
get: this.bindMethod('databasesGet', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
330
|
+
delete: this.bindMethod('databasesDelete', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
331
|
+
definition: this.bindMethod('databaseDefinitionGet', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
332
|
+
saveDefinition: this.bindMethod('databaseDefinitionSave', (apiRequest) => (databaseId, body, options) => apiRequest({ pathParams: { databaseId }, body }, options)),
|
|
333
|
+
tables: this.bindMethod('databaseTablesList', (apiRequest) => (databaseId, options) => apiRequest({ pathParams: { databaseId } }, options)),
|
|
334
|
+
createTable: this.bindMethod('databaseTablesCreate', (apiRequest) => (databaseId, body, options) => apiRequest({ pathParams: { databaseId }, body }, options)),
|
|
335
|
+
records: this.bindMethod('databaseRecordsList', (apiRequest) => (databaseId, table, query = {}, options) => apiRequest({ pathParams: { databaseId, table }, query }, options)),
|
|
336
|
+
transact: this.bindMethod('databaseTransactionsCreate', (apiRequest) => (databaseId, body, options) => apiRequest({ pathParams: { databaseId }, body }, options)),
|
|
336
337
|
};
|
|
337
338
|
this.apps = {
|
|
338
|
-
|
|
339
|
+
sourceFile: this.bindMethod('appsSourceFileGet', (apiRequest) => (applicationId, query, options) => apiRequest({ pathParams: { applicationId }, query }, options)),
|
|
340
|
+
address: this.bindMethod('appsAddressGet', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
341
|
+
setAddress: this.bindMethod('appsAddressSet', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
342
|
+
access: this.bindMethod('appsAccessGet', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
343
|
+
setAccess: this.bindMethod('appsAccessSet', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
344
|
+
listGrants: this.bindMethod('appsGrantsList', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
345
|
+
setGrant: this.bindMethod('appsGrantsSet', (apiRequest) => (applicationId, resourceId, body, options) => apiRequest({ pathParams: { applicationId, resourceId }, body }, options)),
|
|
346
|
+
prepareUploads: this.bindMethod('appsUploadsCreate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
339
347
|
uploadFiles: async (applicationId, files, options) => {
|
|
340
348
|
const contents = await Promise.all(files.map(async (file) => ({
|
|
341
349
|
path: file.path,
|
|
@@ -371,71 +379,73 @@ export class PermuteClient {
|
|
|
371
379
|
}
|
|
372
380
|
return manifest;
|
|
373
381
|
},
|
|
374
|
-
saveSite: (applicationId, body, options) =>
|
|
375
|
-
list:
|
|
376
|
-
create: (body, options) =>
|
|
377
|
-
get: (applicationId, options) =>
|
|
378
|
-
update: (applicationId, body, options) =>
|
|
379
|
-
delete: (applicationId, options) =>
|
|
382
|
+
saveSite: this.bindMethod('appsSiteUpdate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
383
|
+
list: this.bindMethod('appsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
384
|
+
create: this.bindMethod('appsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
385
|
+
get: this.bindMethod('appsGet', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
386
|
+
update: this.bindMethod('appsUpdate', (apiRequest) => (applicationId, body, options) => apiRequest({ pathParams: { applicationId }, body }, options)),
|
|
387
|
+
delete: this.bindMethod('appsDelete', (apiRequest) => (applicationId, options) => apiRequest({ pathParams: { applicationId } }, options)),
|
|
380
388
|
};
|
|
381
389
|
this.connectorSessions = {
|
|
382
|
-
create: (body, options) =>
|
|
383
|
-
get: (sessionId, options) =>
|
|
390
|
+
create: this.bindMethod('connectorSessionsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
391
|
+
get: this.bindMethod('connectorSessionsGet', (apiRequest) => (sessionId, options) => apiRequest({ pathParams: { sessionId } }, options)),
|
|
384
392
|
};
|
|
385
393
|
this.writeSyncs = {
|
|
386
|
-
list:
|
|
387
|
-
create: (body, options) =>
|
|
388
|
-
get: (writeSyncId, options) =>
|
|
389
|
-
update: (writeSyncId, body, options) =>
|
|
390
|
-
delete: (writeSyncId, options) =>
|
|
391
|
-
destinations:
|
|
392
|
-
preview: (writeSyncId, options) =>
|
|
393
|
-
pause: (writeSyncId, options) =>
|
|
394
|
-
listRuns: (writeSyncId, options) =>
|
|
395
|
-
getRun: (writeSyncId, runId, query = {}, options) =>
|
|
396
|
-
execute: (writeSyncId, runId, options) =>
|
|
394
|
+
list: this.bindMethod('writeSyncsList', (apiRequest) => (options) => apiRequest({}, options)),
|
|
395
|
+
create: this.bindMethod('writeSyncsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
396
|
+
get: this.bindMethod('writeSyncsGet', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
397
|
+
update: this.bindMethod('writeSyncsUpdate', (apiRequest) => (writeSyncId, body, options) => apiRequest({ pathParams: { writeSyncId }, body }, options)),
|
|
398
|
+
delete: this.bindMethod('writeSyncsDelete', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
399
|
+
destinations: this.bindMethod('writeSyncsDestinations', (apiRequest) => (options) => apiRequest({}, options)),
|
|
400
|
+
preview: this.bindMethod('writeSyncsPreview', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
401
|
+
pause: this.bindMethod('writeSyncsPause', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
402
|
+
listRuns: this.bindMethod('writeSyncsListRuns', (apiRequest) => (writeSyncId, options) => apiRequest({ pathParams: { writeSyncId } }, options)),
|
|
403
|
+
getRun: this.bindMethod('writeSyncsGetRun', (apiRequest) => (writeSyncId, runId, query = {}, options) => apiRequest({ pathParams: { writeSyncId, runId }, query }, options)),
|
|
404
|
+
execute: this.bindMethod('writeSyncsExecute', (apiRequest) => (writeSyncId, runId, options) => apiRequest({ pathParams: { writeSyncId, runId } }, options)),
|
|
397
405
|
};
|
|
398
406
|
this.workspaces = {
|
|
399
|
-
list:
|
|
400
|
-
create: (request, requestOptions) =>
|
|
401
|
-
get: (workspaceId, requestOptions) =>
|
|
402
|
-
update: (workspaceId, request, requestOptions) =>
|
|
403
|
-
delete: (workspaceId, requestOptions) =>
|
|
407
|
+
list: this.bindMethod('workspacesList', (apiRequest) => (requestOptions) => apiRequest({}, requestOptions)),
|
|
408
|
+
create: this.bindMethod('workspacesCreate', (apiRequest) => (request, requestOptions) => apiRequest({ body: request }, requestOptions)),
|
|
409
|
+
get: this.bindMethod('workspacesGet', (apiRequest) => (workspaceId, requestOptions) => apiRequest({ pathParams: { workspaceId } }, requestOptions)),
|
|
410
|
+
update: this.bindMethod('workspacesUpdate', (apiRequest) => (workspaceId, request, requestOptions) => apiRequest({ pathParams: { workspaceId }, body: request }, requestOptions)),
|
|
411
|
+
delete: this.bindMethod('workspacesDelete', (apiRequest) => (workspaceId, requestOptions) => apiRequest({ pathParams: { workspaceId } }, requestOptions)),
|
|
404
412
|
};
|
|
405
413
|
this.sources = {
|
|
406
|
-
list:
|
|
407
|
-
get: (sourceId, requestOptions) =>
|
|
408
|
-
listTables: async (sourceId, requestOptions) => (await
|
|
414
|
+
list: this.bindMethod('sourcesList', (apiRequest) => (requestOptions) => apiRequest({}, requestOptions)),
|
|
415
|
+
get: this.bindMethod('sourcesGet', (apiRequest) => (sourceId, requestOptions) => apiRequest({ pathParams: { sourceId } }, requestOptions)),
|
|
416
|
+
listTables: this.bindMethod('sourcesGet', (apiRequest) => async (sourceId, requestOptions) => (await apiRequest({
|
|
409
417
|
pathParams: { sourceId },
|
|
410
418
|
query: { includeFields: 'false' },
|
|
411
|
-
}, requestOptions)).tables,
|
|
412
|
-
describeTable: async (sourceId, tableId, requestOptions) => (await
|
|
419
|
+
}, requestOptions)).tables),
|
|
420
|
+
describeTable: this.bindMethod('sourcesGet', (apiRequest) => async (sourceId, tableId, requestOptions) => (await apiRequest({
|
|
413
421
|
pathParams: { sourceId },
|
|
414
422
|
query: { tableId },
|
|
415
|
-
}, requestOptions)).tables[0],
|
|
423
|
+
}, requestOptions)).tables[0]),
|
|
416
424
|
};
|
|
425
|
+
const listOperationRuns = this.bindMethod('operationsRunsList', (apiRequest) => (operationId, options) => apiRequest({ pathParams: { operationId } }, options));
|
|
426
|
+
const listWorkflowRuns = this.bindMethod('operationRunsList', (apiRequest) => (query, options) => apiRequest({ query }, options));
|
|
417
427
|
this.operations = {
|
|
418
|
-
list: (query = {}, options) =>
|
|
419
|
-
get: (operationId, options) =>
|
|
420
|
-
update: (operationId, body, options) =>
|
|
421
|
-
getSource: (operationId, options) =>
|
|
422
|
-
updateSource: (operationId, body, options) =>
|
|
423
|
-
getRunOutput: (operationId, runId, options) =>
|
|
424
|
-
listRuns: ((input, options) => typeof input === 'string'
|
|
425
|
-
?
|
|
426
|
-
:
|
|
427
|
-
run: (operationId, body, options) =>
|
|
428
|
+
list: this.bindMethod('operationsList', (apiRequest) => (query = {}, options) => apiRequest({ query }, options)),
|
|
429
|
+
get: this.bindMethod('operationsGet', (apiRequest) => (operationId, options) => apiRequest({ pathParams: { operationId } }, options)),
|
|
430
|
+
update: this.bindMethod('operationsUpdate', (apiRequest) => (operationId, body, options) => apiRequest({ pathParams: { operationId }, body }, options)),
|
|
431
|
+
getSource: this.bindMethod('operationsSourceGet', (apiRequest) => (operationId, options) => apiRequest({ pathParams: { operationId } }, options)),
|
|
432
|
+
updateSource: this.bindMethod('operationsSourceUpdate', (apiRequest) => (operationId, body, options) => apiRequest({ pathParams: { operationId }, body }, options)),
|
|
433
|
+
getRunOutput: this.bindMethod('operationsRunOutput', (apiRequest) => (operationId, runId, options) => apiRequest({ pathParams: { operationId, runId } }, options)),
|
|
434
|
+
listRuns: SdkMethodFactory.compose([listOperationRuns, listWorkflowRuns], ((input, options) => typeof input === 'string'
|
|
435
|
+
? listOperationRuns(input, options)
|
|
436
|
+
: listWorkflowRuns(input, options))),
|
|
437
|
+
run: this.bindMethod('operationsRun', (apiRequest) => (operationId, body, options) => apiRequest({ pathParams: { operationId }, body }, options)),
|
|
428
438
|
};
|
|
429
439
|
this.dataFlows = {
|
|
430
|
-
create: (body, options) =>
|
|
431
|
-
get: (dataFlowId, options) =>
|
|
432
|
-
command: (dataFlowId, body, options) =>
|
|
440
|
+
create: this.bindMethod('dataFlowsCreate', (apiRequest) => (body, options) => apiRequest({ body }, options)),
|
|
441
|
+
get: this.bindMethod('dataFlowsGet', (apiRequest) => (dataFlowId, options) => apiRequest({ pathParams: { dataFlowId } }, options)),
|
|
442
|
+
command: this.bindMethod('dataFlowsCommand', (apiRequest) => (dataFlowId, body, options) => apiRequest({ pathParams: { dataFlowId }, body }, options)),
|
|
433
443
|
};
|
|
434
444
|
this.dashboards = {
|
|
435
|
-
getSource: (dashboardId, requestOptions) =>
|
|
436
|
-
updateSource: (dashboardId, request, requestOptions) =>
|
|
445
|
+
getSource: this.bindMethod('dashboardsSourceGet', (apiRequest) => (dashboardId, requestOptions) => apiRequest({ pathParams: { dashboardId } }, requestOptions)),
|
|
446
|
+
updateSource: this.bindMethod('dashboardsSourceUpdate', (apiRequest) => (dashboardId, request, requestOptions) => apiRequest({ pathParams: { dashboardId }, body: request }, requestOptions)),
|
|
437
447
|
};
|
|
438
|
-
const readDataset = (datasetId, requestOptions) =>
|
|
448
|
+
const readDataset = this.bindMethod('datasetsGet', (apiRequest) => (datasetId, requestOptions) => apiRequest({ pathParams: { datasetId } }, requestOptions));
|
|
439
449
|
const writeDatasetTables = async (datasetId, request, requestOptions) => {
|
|
440
450
|
const encoded = encodeDatasetWrite(request);
|
|
441
451
|
const body = request.mode === 'replace'
|
|
@@ -503,9 +513,9 @@ export class PermuteClient {
|
|
|
503
513
|
const wrapDataset = (dataset) => dataset.type === 'custom'
|
|
504
514
|
? new PermuteDataset(dataset, writeDatasetTables, readDataset)
|
|
505
515
|
: new PermuteFileDataset(dataset, readDataset);
|
|
506
|
-
const createDataset = async (request, requestOptions) => {
|
|
516
|
+
const createDataset = this.bindMethod('datasetsCreate', (apiRequest) => async (request, requestOptions) => {
|
|
507
517
|
if (request.type === 'custom') {
|
|
508
|
-
const dataset = await
|
|
518
|
+
const dataset = await apiRequest({ body: request }, requestOptions);
|
|
509
519
|
return new PermuteDataset(requireCustomDataset(dataset), writeDatasetTables, readDataset);
|
|
510
520
|
}
|
|
511
521
|
const { data, headers, sizeBytes: declaredSize, ...createRequest } = request;
|
|
@@ -522,10 +532,10 @@ export class PermuteClient {
|
|
|
522
532
|
throw new PermuteApiError({
|
|
523
533
|
status: 0,
|
|
524
534
|
code: 'missing_file_size',
|
|
525
|
-
message: 'sizeBytes is required
|
|
535
|
+
message: 'sizeBytes is required without data or when the upload body size cannot be inferred',
|
|
526
536
|
});
|
|
527
537
|
}
|
|
528
|
-
const response = await
|
|
538
|
+
const response = await apiRequest({ body: { ...createRequest, sizeBytes } }, requestOptions);
|
|
529
539
|
const dataset = new PermuteFileDataset(requireFileDataset(response), readDataset);
|
|
530
540
|
const target = dataset.data.upload;
|
|
531
541
|
if (!target) {
|
|
@@ -535,6 +545,8 @@ export class PermuteClient {
|
|
|
535
545
|
message: `Dataset ${dataset.id} did not include a file upload target`,
|
|
536
546
|
});
|
|
537
547
|
}
|
|
548
|
+
if (data === undefined)
|
|
549
|
+
return dataset;
|
|
538
550
|
const uploadResponse = await this.fetchImpl(target.url, {
|
|
539
551
|
method: target.method,
|
|
540
552
|
headers: { ...headers, ...target.headers },
|
|
@@ -549,27 +561,28 @@ export class PermuteClient {
|
|
|
549
561
|
});
|
|
550
562
|
}
|
|
551
563
|
return dataset;
|
|
552
|
-
};
|
|
564
|
+
});
|
|
553
565
|
this.datasets = {
|
|
554
566
|
create: createDataset,
|
|
555
|
-
getByKey: async (key, requestOptions) => {
|
|
556
|
-
const dataset = await
|
|
567
|
+
getByKey: this.bindMethod('datasetsGetByKey', (apiRequest) => async (key, requestOptions) => {
|
|
568
|
+
const dataset = await apiRequest({ query: { key } }, requestOptions);
|
|
557
569
|
return wrapDataset(dataset);
|
|
558
|
-
},
|
|
570
|
+
}),
|
|
559
571
|
get: async (datasetId, requestOptions) => {
|
|
560
572
|
const dataset = await readDataset(datasetId, requestOptions);
|
|
561
573
|
return wrapDataset(dataset);
|
|
562
574
|
},
|
|
563
|
-
download: async (datasetId, requestOptions) => {
|
|
564
|
-
const { url } = await
|
|
575
|
+
download: this.bindMethod('datasetsDownload', (apiRequest) => async (datasetId, requestOptions) => {
|
|
576
|
+
const { url } = await apiRequest({ pathParams: { datasetId } }, requestOptions);
|
|
565
577
|
return url;
|
|
566
|
-
},
|
|
567
|
-
delete: (datasetId, requestOptions) =>
|
|
578
|
+
}),
|
|
579
|
+
delete: this.bindMethod('datasetsDelete', (apiRequest) => (datasetId, requestOptions) => apiRequest({ pathParams: { datasetId } }, requestOptions)),
|
|
568
580
|
};
|
|
581
|
+
this.apps.uploadFiles = SdkMethodFactory.compose([this.apps.prepareUploads], this.apps.uploadFiles);
|
|
582
|
+
this.datasets.get = SdkMethodFactory.compose([readDataset], this.datasets.get);
|
|
583
|
+
this.answer = SdkMethodFactory.compose([this.answerJobs, this.getAnswerJob], this.answer.bind(this));
|
|
569
584
|
}
|
|
570
|
-
|
|
571
|
-
return await this.request('searchCreate', { body: request }, options);
|
|
572
|
-
}
|
|
585
|
+
search = this.bindMethod('searchCreate', (apiRequest) => (request, options) => apiRequest({ body: request }, options));
|
|
573
586
|
async answer(request, options) {
|
|
574
587
|
let job = await this.answerJobs(request, options);
|
|
575
588
|
const deadline = pollingDeadline(options);
|
|
@@ -592,12 +605,8 @@ export class PermuteClient {
|
|
|
592
605
|
message: job.error ?? `Answer job ${job.status}`,
|
|
593
606
|
});
|
|
594
607
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
async getAnswerJob(answerJobId, options) {
|
|
599
|
-
return await this.request('answerJobsGet', { pathParams: { answerJobId } }, options);
|
|
600
|
-
}
|
|
608
|
+
answerJobs = this.bindMethod('answerJobsCreate', (apiRequest) => (request, options) => apiRequest({ body: request }, options));
|
|
609
|
+
getAnswerJob = this.bindMethod('answerJobsGet', (apiRequest) => (answerJobId, options) => apiRequest({ pathParams: { answerJobId } }, options));
|
|
601
610
|
withWorkspace(workspaceId) {
|
|
602
611
|
if (!workspaceId.trim()) {
|
|
603
612
|
throw new PermuteApiError({ status: 0, code: 'missing_workspace_id', message: 'workspaceId is required' });
|
|
@@ -610,8 +619,9 @@ export class PermuteClient {
|
|
|
610
619
|
headers: this.defaultHeaders,
|
|
611
620
|
});
|
|
612
621
|
}
|
|
613
|
-
|
|
614
|
-
|
|
622
|
+
query = this.bindMethod('queriesCreate', (apiRequest) => (request, options) => apiRequest({ body: request }, options));
|
|
623
|
+
bindMethod(operationId, create) {
|
|
624
|
+
return SdkMethodFactory.create(operationId, create((input, options) => this.request(operationId, input, options)));
|
|
615
625
|
}
|
|
616
626
|
async request(operationId, input, options) {
|
|
617
627
|
const route = routeFor(operationId);
|
package/dist/deploy.d.ts
CHANGED
|
@@ -1,17 +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
|
-
/** Omit to preserve source bindings; [] removes them. */
|
|
13
|
-
sourceIds?: AppSiteSaveRequest['sourceIds'];
|
|
14
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
|
+
}>;
|
|
15
87
|
/** Upload, save, and publish an existing live app. Builds and provisions nothing; never retries mutations. */
|
|
16
88
|
export declare function deployApp(client: PermuteClient, options: DeployAppOptions, requestOptions?: PermuteRequestOptions): Promise<{
|
|
17
89
|
url: string;
|