@permute/sdk 0.5.0 → 0.6.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 CHANGED
@@ -442,11 +442,11 @@ Identical contents reuse existing files. Changed contents at the same path are s
442
442
 
443
443
  Visitors sign in through Permute and need app read permission. HTML receives a revision-specific base URL; use relative URLs for bundled and public assets. Inline scripts, external requests, workers, and server runtimes are not supported. Keep API keys and secrets out of compiled browser files. Restore a historical revision with `client.revisions.restore`, then publish the resulting draft to roll back. See the [complete app guide](https://permute.ai/docs/guides/deploy-app) for creation, directory uploads, updates, and rollback.
444
444
 
445
- ### Deploy a build directory (SDK 0.5.0+)
445
+ ### Deploy a build directory (SDK 0.6.0)
446
446
 
447
447
  The Node/Bun entry `@permute/sdk/deploy` combines validation, upload, draft save,
448
- and publication for an existing live app. Available in SDK 0.5.0 and later; the
449
- individual calls above remain available for separate draft review and publication.
448
+ and publication for an existing live app. Use SDK 0.6.0 for the grant-based app
449
+ API shown here.
450
450
 
451
451
  ```ts
452
452
  import { deployApp } from '@permute/sdk/deploy';
@@ -458,15 +458,13 @@ console.log(deployed.url, deployed.revisionId, deployed.changed);
458
458
  The helper rejects symbolic links, unsupported paths, missing `index.html`, and
459
459
  oversized builds before uploading. It requires the current draft to be published;
460
460
  after reviewing an existing draft, pass its exact `expectedDraft` to approve
461
- replacing it. Omitted `actions` and `sourceIds` preserve current bindings (an empty
462
- array clears them). To change action bindings, supply explicit published revisions:
461
+ replacing it. Omitted `actions` preserve current bindings (an empty array clears them). To change action bindings, supply explicit published revisions:
463
462
 
464
463
  ```ts
465
464
  await deployApp(client, {
466
465
  appId,
467
466
  directory: './dist',
468
467
  actions: [{ actionId, revisionId: publishedActionRevisionId }],
469
- sourceIds: [databaseId],
470
468
  });
471
469
  ```
472
470
 
@@ -499,10 +497,11 @@ const request = { requestId: crypto.randomUUID(), input: { name: 'Ada' } };
499
497
  const receipt = await app.actions.invoke('actn_example', request);
500
498
  ```
501
499
 
502
- The client reads the hosted page's revision-pinned base URL. Save the app's `sourceIds` and
500
+ The client reads the hosted page's revision-pinned base URL. Save
503
501
  `actions: [{ actionId, revisionId }]` with its site manifest, then publish the app revision.
504
- Queries require a declared source and the signed-in user's current read permission;
505
- actions use the pinned published action revision and the user's invocation permission.
502
+ Queries require current app and user read permissions. The query request selects its
503
+ sources; source grants take effect without republishing.
504
+ Actions require both app and user invocation permissions and use the pinned published revision.
506
505
  Read scope is source-level; client-supplied SQL is not a row-level authorization policy.
507
506
  Keep the same request ID and input when retrying an uncertain action response. The client
508
507
  does not retry writes automatically. A 401 requires signing in again.
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, AppDraftList, AppCreateRequest, AppUpdateRequest, AppDeleted, AppUploadsRequest, AppUploads, AppSiteSaveRequest, 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, AnswerJobResponse, AnswerResponse, PermuteClientOptions, PermuteRequestOptions, QueryRequest, QueryResponse, SearchRequest, SearchResponse, SourceDetail, CatalogTable, SourceList, CustomDatasetCreateRequest, DatasetDeleteResponse, DatasetResponse, FileDatasetCreateRequest, 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,8 @@ export declare class PermuteClient {
93
93
  transact(databaseId: string, body: DatabaseTransactionRequest, options?: PermuteRequestOptions): Promise<DatabaseTransactionReceipt>;
94
94
  };
95
95
  readonly apps: {
96
+ listGrants(applicationId: string, options?: PermuteRequestOptions): Promise<AppGrants>;
97
+ setGrant(applicationId: string, resourceId: string, body: AppGrantSetRequest, options?: PermuteRequestOptions): Promise<AppGrants>;
96
98
  list(options?: PermuteRequestOptions): Promise<AppDraftList>;
97
99
  create(body: AppCreateRequest, options?: PermuteRequestOptions): Promise<AppDraft>;
98
100
  get(applicationId: string, options?: PermuteRequestOptions): Promise<AppDraft>;
package/dist/client.js CHANGED
@@ -335,6 +335,8 @@ export class PermuteClient {
335
335
  transact: (databaseId, body, options) => this.request('databaseTransactionsCreate', { pathParams: { databaseId }, body }, options),
336
336
  };
337
337
  this.apps = {
338
+ listGrants: (applicationId, options) => this.request('appsGrantsList', { pathParams: { applicationId } }, options),
339
+ setGrant: (applicationId, resourceId, body, options) => this.request('appsGrantsSet', { pathParams: { applicationId, resourceId }, body }, options),
338
340
  prepareUploads: (applicationId, body, options) => this.request('appsUploadsCreate', { pathParams: { applicationId }, body }, options),
339
341
  uploadFiles: async (applicationId, files, options) => {
340
342
  const contents = await Promise.all(files.map(async (file) => ({
package/dist/deploy.d.ts CHANGED
@@ -9,8 +9,6 @@ export interface DeployAppOptions {
9
9
  expectedDraft?: AppSiteSaveRequest['expectedDraft'];
10
10
  /** Omit to preserve bindings; [] removes them. Revisions must already be published. */
11
11
  actions?: AppSiteSaveRequest['actions'];
12
- /** Omit to preserve source bindings; [] removes them. */
13
- sourceIds?: AppSiteSaveRequest['sourceIds'];
14
12
  }
15
13
  /** Upload, save, and publish an existing live app. Builds and provisions nothing; never retries mutations. */
16
14
  export declare function deployApp(client: PermuteClient, options: DeployAppOptions, requestOptions?: PermuteRequestOptions): Promise<{
package/dist/deploy.js CHANGED
@@ -45,7 +45,6 @@ async function readBuild(directory, body, spa, signal) {
45
45
  if (!manifest.some((file) => file.path === 'index.html') ||
46
46
  manifest.reduce((total, file) => total + file.size, 0) > 50 * 1024 * 1024 ||
47
47
  new Set(body.actions?.map((action) => action.actionId)).size !== (body.actions?.length ?? 0) ||
48
- new Set(body.sourceIds).size !== (body.sourceIds?.length ?? 0) ||
49
48
  !validateSite({ ...body, site: { files: manifest, spa } })) {
50
49
  throw new PermuteApiError({
51
50
  status: 0,
@@ -107,7 +106,6 @@ export async function deployApp(client, options, requestOptions) {
107
106
  expectedDraft: expected,
108
107
  site: revision.value.site,
109
108
  actions: revision.value.actions,
110
- sourceIds: revision.value.sourceIds,
111
109
  };
112
110
  const localManifest = files.map(({ path, data }) => ({
113
111
  path,
@@ -118,9 +116,7 @@ export async function deployApp(client, options, requestOptions) {
118
116
  previous.site.spa === spa &&
119
117
  isDeepStrictEqual(new Map(previous.site.files.map((file) => [file.path, file])), new Map(localManifest.map((file) => [file.path, file]))) &&
120
118
  (bindings.actions === undefined ||
121
- isDeepStrictEqual(new Map((previous.actions ?? []).map((action) => [action.actionId, action.revisionId])), new Map(bindings.actions.map((action) => [action.actionId, action.revisionId])))) &&
122
- (bindings.sourceIds === undefined ||
123
- isDeepStrictEqual(new Set(previous.sourceIds ?? []), new Set(bindings.sourceIds)))) {
119
+ isDeepStrictEqual(new Map((previous.actions ?? []).map((action) => [action.actionId, action.revisionId])), new Map(bindings.actions.map((action) => [action.actionId, action.revisionId]))))) {
124
120
  const current = await client.revisions.list(appId, requestOptions);
125
121
  if (current.version !== history.version)
126
122
  conflict('App changed during inspection. Review the current refs.');
@@ -253,6 +253,30 @@ export interface components {
253
253
  workspaceId: string;
254
254
  }[];
255
255
  };
256
+ AppGrantParams: {
257
+ applicationId: string;
258
+ resourceId: string;
259
+ };
260
+ AppGrants: {
261
+ canManage: boolean;
262
+ items: {
263
+ /** Format: date-time */
264
+ expiresAt?: string | null;
265
+ /** @enum {string} */
266
+ level: 'read' | 'write' | 'admin';
267
+ resourceId: string;
268
+ resourceType?: string;
269
+ subResourceId?: string;
270
+ }[];
271
+ };
272
+ AppGrantSetRequest: {
273
+ /** Format: date-time */
274
+ expiresAt?: string | null;
275
+ /** @enum {string|null} */
276
+ level: 'read' | 'write' | 'admin' | null;
277
+ resourceType?: string;
278
+ subResourceId?: string;
279
+ };
256
280
  AppIdParams: {
257
281
  applicationId: string;
258
282
  };
@@ -273,7 +297,6 @@ export interface components {
273
297
  }[];
274
298
  spa: boolean;
275
299
  };
276
- sourceIds?: string[];
277
300
  };
278
301
  AppUpdateRequest: {
279
302
  description: string;
@@ -8,7 +8,7 @@ export interface RuntimeRoute {
8
8
  querySchema: JsonSchema | null;
9
9
  responseSchema: JsonSchema;
10
10
  }
11
- export type PublicApiOperationId = 'connectorSessionsCreate' | 'connectorSessionsGet' | 'resourceRevisionsList' | 'resourceRevisionsGet' | 'resourceRevisionsRestore' | 'resourcesPublish' | 'actionsList' | 'actionsCreate' | 'actionsGet' | 'actionsDelete' | 'actionDefinitionGet' | 'actionDefinitionSave' | 'actionsInvoke' | 'workspacesList' | 'workspacesCreate' | 'workspacesGet' | 'workspacesUpdate' | 'workspacesDelete' | 'sourcesList' | 'sourcesGet' | 'dashboardsSourceGet' | 'dashboardsSourceUpdate' | 'datasetsCreate' | 'datasetsGetByKey' | 'datasetsGet' | 'datasetsDelete' | 'datasetsDownload' | 'datasetsWriteTables' | 'searchCreate' | 'answerJobsCreate' | 'answerJobsGet' | 'queriesCreate' | 'operationRunsList' | 'operationsList' | 'operationsGet' | 'operationsUpdate' | 'operationsSourceGet' | 'operationsSourceUpdate' | 'operationsRunsList' | 'operationsRun' | 'operationsRunOutput' | 'dataFlowsCreate' | 'dataFlowsGet' | 'dataFlowsCommand' | 'factsList' | 'factsCreate' | 'factsGet' | 'factsUpdate' | 'factsDelete' | 'skillsList' | 'skillsGet' | 'skillsUpdate' | 'skillsDelete' | 'organizationSkillsList' | 'organizationSkillsGet' | 'organizationSkillsUpdate' | 'organizationSkillsDelete' | 'databasesList' | 'databasesCreate' | 'databasesGet' | 'databasesDelete' | 'databaseDefinitionGet' | 'databaseDefinitionSave' | 'databaseTablesList' | 'databaseTablesCreate' | 'databaseRecordsList' | 'databaseTransactionsCreate' | 'appsList' | 'appsCreate' | 'appsGet' | 'appsUpdate' | 'appsDelete' | 'appsUploadsCreate' | 'appsSiteUpdate' | 'writeSyncsList' | 'writeSyncsCreate' | 'writeSyncsDestinations' | 'writeSyncsGet' | 'writeSyncsUpdate' | 'writeSyncsDelete' | 'writeSyncsPreview' | 'writeSyncsPause' | 'writeSyncsListRuns' | 'writeSyncsGetRun' | 'writeSyncsExecute';
11
+ export type PublicApiOperationId = 'connectorSessionsCreate' | 'connectorSessionsGet' | 'resourceRevisionsList' | 'resourceRevisionsGet' | 'resourceRevisionsRestore' | 'resourcesPublish' | 'actionsList' | 'actionsCreate' | 'actionsGet' | 'actionsDelete' | 'actionDefinitionGet' | 'actionDefinitionSave' | 'actionsInvoke' | 'workspacesList' | 'workspacesCreate' | 'workspacesGet' | 'workspacesUpdate' | 'workspacesDelete' | 'sourcesList' | 'sourcesGet' | 'dashboardsSourceGet' | 'dashboardsSourceUpdate' | 'datasetsCreate' | 'datasetsGetByKey' | 'datasetsGet' | 'datasetsDelete' | 'datasetsDownload' | 'datasetsWriteTables' | 'searchCreate' | 'answerJobsCreate' | 'answerJobsGet' | 'queriesCreate' | 'operationRunsList' | 'operationsList' | 'operationsGet' | 'operationsUpdate' | 'operationsSourceGet' | 'operationsSourceUpdate' | 'operationsRunsList' | 'operationsRun' | 'operationsRunOutput' | 'dataFlowsCreate' | 'dataFlowsGet' | 'dataFlowsCommand' | 'factsList' | 'factsCreate' | 'factsGet' | 'factsUpdate' | 'factsDelete' | 'skillsList' | 'skillsGet' | 'skillsUpdate' | 'skillsDelete' | 'organizationSkillsList' | 'organizationSkillsGet' | 'organizationSkillsUpdate' | 'organizationSkillsDelete' | 'databasesList' | 'databasesCreate' | 'databasesGet' | 'databasesDelete' | 'databaseDefinitionGet' | 'databaseDefinitionSave' | 'databaseTablesList' | 'databaseTablesCreate' | 'databaseRecordsList' | 'databaseTransactionsCreate' | 'appsGrantsList' | 'appsGrantsSet' | 'appsList' | 'appsCreate' | 'appsGet' | 'appsUpdate' | 'appsDelete' | 'appsUploadsCreate' | 'appsSiteUpdate' | 'writeSyncsList' | 'writeSyncsCreate' | 'writeSyncsDestinations' | 'writeSyncsGet' | 'writeSyncsUpdate' | 'writeSyncsDelete' | 'writeSyncsPreview' | 'writeSyncsPause' | 'writeSyncsListRuns' | 'writeSyncsGetRun' | 'writeSyncsExecute';
12
12
  export declare const publicApiRoutes: Record<PublicApiOperationId, RuntimeRoute>;
13
13
  export declare const Providers: {
14
14
  readonly ACUMATICA: "acumatica";
@@ -6521,6 +6521,136 @@ export const publicApiRoutes = {
6521
6521
  additionalProperties: false,
6522
6522
  },
6523
6523
  },
6524
+ appsGrantsList: {
6525
+ operationId: 'appsGrantsList',
6526
+ method: 'GET',
6527
+ path: '/v1/apps/{applicationId}/grants',
6528
+ scope: 'workspace',
6529
+ bodySchema: null,
6530
+ querySchema: null,
6531
+ responseSchema: {
6532
+ type: 'object',
6533
+ properties: {
6534
+ items: {
6535
+ type: 'array',
6536
+ items: {
6537
+ type: 'object',
6538
+ properties: {
6539
+ resourceId: {
6540
+ type: 'string',
6541
+ minLength: 1,
6542
+ maxLength: 128,
6543
+ },
6544
+ resourceType: {
6545
+ type: 'string',
6546
+ minLength: 1,
6547
+ maxLength: 128,
6548
+ },
6549
+ subResourceId: {
6550
+ type: 'string',
6551
+ minLength: 1,
6552
+ maxLength: 128,
6553
+ },
6554
+ expiresAt: {
6555
+ type: 'string',
6556
+ format: 'date-time',
6557
+ nullable: true,
6558
+ },
6559
+ level: {
6560
+ type: 'string',
6561
+ enum: ['read', 'write', 'admin'],
6562
+ },
6563
+ },
6564
+ required: ['resourceId', 'level'],
6565
+ additionalProperties: false,
6566
+ },
6567
+ },
6568
+ canManage: {
6569
+ type: 'boolean',
6570
+ },
6571
+ },
6572
+ required: ['items', 'canManage'],
6573
+ additionalProperties: false,
6574
+ },
6575
+ },
6576
+ appsGrantsSet: {
6577
+ operationId: 'appsGrantsSet',
6578
+ method: 'PUT',
6579
+ path: '/v1/apps/{applicationId}/grants/{resourceId}',
6580
+ scope: 'workspace',
6581
+ bodySchema: {
6582
+ type: 'object',
6583
+ properties: {
6584
+ resourceType: {
6585
+ type: 'string',
6586
+ minLength: 1,
6587
+ maxLength: 128,
6588
+ },
6589
+ subResourceId: {
6590
+ type: 'string',
6591
+ minLength: 1,
6592
+ maxLength: 128,
6593
+ },
6594
+ expiresAt: {
6595
+ type: 'string',
6596
+ format: 'date-time',
6597
+ nullable: true,
6598
+ },
6599
+ level: {
6600
+ type: 'string',
6601
+ enum: ['read', 'write', 'admin', null],
6602
+ nullable: true,
6603
+ },
6604
+ },
6605
+ required: ['level'],
6606
+ additionalProperties: false,
6607
+ },
6608
+ querySchema: null,
6609
+ responseSchema: {
6610
+ type: 'object',
6611
+ properties: {
6612
+ items: {
6613
+ type: 'array',
6614
+ items: {
6615
+ type: 'object',
6616
+ properties: {
6617
+ resourceId: {
6618
+ type: 'string',
6619
+ minLength: 1,
6620
+ maxLength: 128,
6621
+ },
6622
+ resourceType: {
6623
+ type: 'string',
6624
+ minLength: 1,
6625
+ maxLength: 128,
6626
+ },
6627
+ subResourceId: {
6628
+ type: 'string',
6629
+ minLength: 1,
6630
+ maxLength: 128,
6631
+ },
6632
+ expiresAt: {
6633
+ type: 'string',
6634
+ format: 'date-time',
6635
+ nullable: true,
6636
+ },
6637
+ level: {
6638
+ type: 'string',
6639
+ enum: ['read', 'write', 'admin'],
6640
+ },
6641
+ },
6642
+ required: ['resourceId', 'level'],
6643
+ additionalProperties: false,
6644
+ },
6645
+ },
6646
+ canManage: {
6647
+ type: 'boolean',
6648
+ },
6649
+ },
6650
+ required: ['items', 'canManage'],
6651
+ additionalProperties: false,
6652
+ },
6653
+ },
6524
6654
  appsList: {
6525
6655
  operationId: 'appsList',
6526
6656
  method: 'GET',
@@ -7018,14 +7148,6 @@ export const publicApiRoutes = {
7018
7148
  },
7019
7149
  maxItems: 100,
7020
7150
  },
7021
- sourceIds: {
7022
- type: 'array',
7023
- items: {
7024
- type: 'string',
7025
- minLength: 1,
7026
- },
7027
- maxItems: 100,
7028
- },
7029
7151
  expectedDraft: {
7030
7152
  type: 'object',
7031
7153
  properties: {
package/dist/types.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { components } from './generated/openapi.js';
2
2
  type PublicApiSchema<Name extends keyof components['schemas']> = components['schemas'][Name];
3
+ export type AppGrants = PublicApiSchema<'AppGrants'>;
4
+ export type AppGrantSetRequest = PublicApiSchema<'AppGrantSetRequest'>;
3
5
  export type BusinessAction = PublicApiSchema<'BusinessAction'>;
4
6
  export type BusinessActionList = PublicApiSchema<'BusinessActionList'>;
5
7
  export type ActionCreateRequest = PublicApiSchema<'ActionCreateRequest'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@permute/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "TypeScript client for the Permute public API",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",