@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/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, AnswerJobResponse, AnswerResponse, PermuteClientOptions, PermuteRequestOptions, QueryRequest, QueryResponse, SearchRequest, SearchResponse, SourceDetail, CatalogTable, SourceList, CustomDatasetCreateRequest, DatasetDeleteResponse, DatasetResponse, FileDatasetCreateRequest, FileDatasetResponse, DatasetRows, CustomDatasetResponse, DashboardSource, DashboardSourceUpdateRequest } from './types.js';
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): Promise<SearchResponse>;
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): Promise<AnswerJobResponse>;
177
- getAnswerJob(answerJobId: string, options?: PermuteRequestOptions): Promise<AnswerJobResponse>;
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): Promise<QueryResponse>;
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) => this.request('resourceRevisionsList', { pathParams: { resourceId } }, options),
297
- get: (resourceId, revisionId, options) => this.request('resourceRevisionsGet', { pathParams: { resourceId, revisionId } }, options),
298
- restore: (resourceId, revisionId, body, options) => this.request('resourceRevisionsRestore', { pathParams: { resourceId, revisionId }, body }, options),
299
- publish: (resourceId, body, options) => this.request('resourcesPublish', { pathParams: { 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: (options) => this.request('factsList', {}, options),
303
- get: (factId, options) => this.request('factsGet', { pathParams: { factId } }, options),
304
- create: (body, options) => this.request('factsCreate', { body }, options),
305
- update: (factId, body, options) => this.request('factsUpdate', { pathParams: { factId }, body }, options),
306
- delete: (factId, options) => this.request('factsDelete', { pathParams: { 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: (options) => this.request(`${prefix}List`, {}, options),
310
- get: (path, options) => this.request(`${prefix}Get`, { pathParams: { path } }, options),
311
- update: (path, body, options) => this.request(`${prefix}Update`, { pathParams: { path }, body }, options),
312
- delete: (path, options) => this.request(`${prefix}Delete`, { pathParams: { 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: (options) => this.request('actionsList', {}, options),
318
- create: (body, options) => this.request('actionsCreate', { body }, options),
319
- get: (actionId, options) => this.request('actionsGet', { pathParams: { actionId } }, options),
320
- delete: (actionId, options) => this.request('actionsDelete', { pathParams: { actionId } }, options),
321
- definition: (actionId, options) => this.request('actionDefinitionGet', { pathParams: { actionId } }, options),
322
- saveDefinition: (actionId, body, options) => this.request('actionDefinitionSave', { pathParams: { actionId }, body }, options),
323
- invoke: (actionId, body, options) => this.request('actionsInvoke', { pathParams: { 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: (options) => this.request('databasesList', {}, options),
327
- create: (body, options) => this.request('databasesCreate', { body }, options),
328
- get: (databaseId, options) => this.request('databasesGet', { pathParams: { databaseId } }, options),
329
- delete: (databaseId, options) => this.request('databasesDelete', { pathParams: { databaseId } }, options),
330
- definition: (databaseId, options) => this.request('databaseDefinitionGet', { pathParams: { databaseId } }, options),
331
- saveDefinition: (databaseId, body, options) => this.request('databaseDefinitionSave', { pathParams: { databaseId }, body }, options),
332
- tables: (databaseId, options) => this.request('databaseTablesList', { pathParams: { databaseId } }, options),
333
- createTable: (databaseId, body, options) => this.request('databaseTablesCreate', { pathParams: { databaseId }, body }, options),
334
- records: (databaseId, table, query = {}, options) => this.request('databaseRecordsList', { pathParams: { databaseId, table }, query }, options),
335
- transact: (databaseId, body, options) => this.request('databaseTransactionsCreate', { pathParams: { 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
- prepareUploads: (applicationId, body, options) => this.request('appsUploadsCreate', { pathParams: { applicationId }, body }, options),
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) => this.request('appsSiteUpdate', { pathParams: { applicationId }, body }, options),
375
- list: (options) => this.request('appsList', {}, options),
376
- create: (body, options) => this.request('appsCreate', { body }, options),
377
- get: (applicationId, options) => this.request('appsGet', { pathParams: { applicationId } }, options),
378
- update: (applicationId, body, options) => this.request('appsUpdate', { pathParams: { applicationId }, body }, options),
379
- delete: (applicationId, options) => this.request('appsDelete', { pathParams: { 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) => this.request('connectorSessionsCreate', { body }, options),
383
- get: (sessionId, options) => this.request('connectorSessionsGet', { pathParams: { 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: (options) => this.request('writeSyncsList', {}, options),
387
- create: (body, options) => this.request('writeSyncsCreate', { body }, options),
388
- get: (writeSyncId, options) => this.request('writeSyncsGet', { pathParams: { writeSyncId } }, options),
389
- update: (writeSyncId, body, options) => this.request('writeSyncsUpdate', { pathParams: { writeSyncId }, body }, options),
390
- delete: (writeSyncId, options) => this.request('writeSyncsDelete', { pathParams: { writeSyncId } }, options),
391
- destinations: (options) => this.request('writeSyncsDestinations', {}, options),
392
- preview: (writeSyncId, options) => this.request('writeSyncsPreview', { pathParams: { writeSyncId } }, options),
393
- pause: (writeSyncId, options) => this.request('writeSyncsPause', { pathParams: { writeSyncId } }, options),
394
- listRuns: (writeSyncId, options) => this.request('writeSyncsListRuns', { pathParams: { writeSyncId } }, options),
395
- getRun: (writeSyncId, runId, query = {}, options) => this.request('writeSyncsGetRun', { pathParams: { writeSyncId, runId }, query }, options),
396
- execute: (writeSyncId, runId, options) => this.request('writeSyncsExecute', { pathParams: { 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: (requestOptions) => this.request('workspacesList', {}, requestOptions),
400
- create: (request, requestOptions) => this.request('workspacesCreate', { body: request }, requestOptions),
401
- get: (workspaceId, requestOptions) => this.request('workspacesGet', { pathParams: { workspaceId } }, requestOptions),
402
- update: (workspaceId, request, requestOptions) => this.request('workspacesUpdate', { pathParams: { workspaceId }, body: request }, requestOptions),
403
- delete: (workspaceId, requestOptions) => this.request('workspacesDelete', { pathParams: { 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: (requestOptions) => this.request('sourcesList', {}, requestOptions),
407
- get: (sourceId, requestOptions) => this.request('sourcesGet', { pathParams: { sourceId } }, requestOptions),
408
- listTables: async (sourceId, requestOptions) => (await this.request('sourcesGet', {
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 this.request('sourcesGet', {
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) => this.request('operationsList', { query }, options),
419
- get: (operationId, options) => this.request('operationsGet', { pathParams: { operationId } }, options),
420
- update: (operationId, body, options) => this.request('operationsUpdate', { pathParams: { operationId }, body }, options),
421
- getSource: (operationId, options) => this.request('operationsSourceGet', { pathParams: { operationId } }, options),
422
- updateSource: (operationId, body, options) => this.request('operationsSourceUpdate', { pathParams: { operationId }, body }, options),
423
- getRunOutput: (operationId, runId, options) => this.request('operationsRunOutput', { pathParams: { operationId, runId } }, options),
424
- listRuns: ((input, options) => typeof input === 'string'
425
- ? this.request('operationsRunsList', { pathParams: { operationId: input } }, options)
426
- : this.request('operationRunsList', { query: input }, options)),
427
- run: (operationId, body, options) => this.request('operationsRun', { pathParams: { 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) => this.request('dataFlowsCreate', { body }, options),
431
- get: (dataFlowId, options) => this.request('dataFlowsGet', { pathParams: { dataFlowId } }, options),
432
- command: (dataFlowId, body, options) => this.request('dataFlowsCommand', { pathParams: { 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) => this.request('dashboardsSourceGet', { pathParams: { dashboardId } }, requestOptions),
436
- updateSource: (dashboardId, request, requestOptions) => this.request('dashboardsSourceUpdate', { pathParams: { dashboardId }, body: 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) => this.request('datasetsGet', { pathParams: { 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 this.request('datasetsCreate', { body: request }, requestOptions);
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 when the SDK cannot determine the upload body size',
535
+ message: 'sizeBytes is required without data or when the upload body size cannot be inferred',
526
536
  });
527
537
  }
528
- const response = await this.request('datasetsCreate', { body: { ...createRequest, sizeBytes } }, requestOptions);
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 this.request('datasetsGetByKey', { query: { key } }, requestOptions);
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 this.request('datasetsDownload', { pathParams: { datasetId } }, requestOptions);
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) => this.request('datasetsDelete', { pathParams: { 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
- async search(request, options) {
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
- async answerJobs(request, options) {
596
- return await this.request('answerJobsCreate', { body: request }, options);
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
- async query(request, options) {
614
- return await this.request('queriesCreate', { body: request }, options);
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
- /** Explicitly approve replacing this exact draft. Omit to require a clean published app. */
9
- expectedDraft?: AppSiteSaveRequest['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;