@gravity-rail/sdk 0.47.0 → 0.49.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.
Files changed (47) hide show
  1. package/README.md +114 -8
  2. package/dist/agui.cjs +17 -2
  3. package/dist/agui.cjs.map +1 -1
  4. package/dist/agui.d.cts +9 -1
  5. package/dist/agui.d.ts +9 -1
  6. package/dist/agui.js +15 -1
  7. package/dist/agui.js.map +1 -1
  8. package/dist/{chat-interaction-Bqj3Vbst.d.cts → chat-interaction-D4Edo92W.d.ts} +241 -36
  9. package/dist/{chat-interaction-DiZVtDRE.d.ts → chat-interaction-e5vHKt5j.d.cts} +241 -36
  10. package/dist/{chunk-72SWNLVD.js → chunk-MMDSZ25F.js} +1 -1
  11. package/dist/chunk-MMDSZ25F.js.map +1 -0
  12. package/dist/{chunk-67QXTQVL.js → chunk-TGL72KPS.js} +59 -118
  13. package/dist/chunk-TGL72KPS.js.map +1 -0
  14. package/dist/{chunk-N4GQWNGU.js → chunk-XQTPXOBU.js} +204 -50
  15. package/dist/chunk-XQTPXOBU.js.map +1 -0
  16. package/dist/helpers.cjs.map +1 -1
  17. package/dist/helpers.d.cts +4 -4
  18. package/dist/helpers.d.ts +4 -4
  19. package/dist/helpers.js +1 -1
  20. package/dist/index.cjs +262 -164
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +7 -6
  23. package/dist/index.d.ts +7 -6
  24. package/dist/index.js +9 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal.cjs +262 -164
  27. package/dist/internal.cjs.map +1 -1
  28. package/dist/internal.d.cts +148 -6
  29. package/dist/internal.d.ts +148 -6
  30. package/dist/internal.js +9 -3
  31. package/dist/internal.js.map +1 -1
  32. package/dist/{member-import-D7U4kDIy.d.cts → member-import-9zHkUjcn.d.cts} +1 -1
  33. package/dist/{member-import-C2Xt_o5d.d.ts → member-import-ocJ_K474.d.ts} +1 -1
  34. package/dist/{revision-state-DaVz2528.d.ts → path-CQBykGoj.d.cts} +64 -3
  35. package/dist/{revision-state-ZC4qP3CS.d.cts → path-DVWLvQS-.d.ts} +64 -3
  36. package/dist/schemas.cjs +58 -15
  37. package/dist/schemas.cjs.map +1 -1
  38. package/dist/schemas.d.cts +19 -3
  39. package/dist/schemas.d.ts +19 -3
  40. package/dist/schemas.js +58 -16
  41. package/dist/schemas.js.map +1 -1
  42. package/dist/{tasks-Ca6yfsj2.d.cts → tasks-DsNsbco5.d.cts} +66 -14
  43. package/dist/{tasks-Ca6yfsj2.d.ts → tasks-DsNsbco5.d.ts} +66 -14
  44. package/package.json +2 -2
  45. package/dist/chunk-67QXTQVL.js.map +0 -1
  46. package/dist/chunk-72SWNLVD.js.map +0 -1
  47. package/dist/chunk-N4GQWNGU.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ApiError,
3
3
  BaseApiClient
4
- } from "./chunk-67QXTQVL.js";
4
+ } from "./chunk-TGL72KPS.js";
5
5
 
6
6
  // src/api/abilities.ts
7
7
  var AbilitiesApi = class extends BaseApiClient {
@@ -1028,18 +1028,13 @@ var AuthApi = class extends BaseApiClient {
1028
1028
  }
1029
1029
  return await response.json();
1030
1030
  }
1031
- /** Request a cross-domain authentication token for single sign-on across domains. */
1031
+ /** @deprecated Browser continuity uses top-level /auth/continue navigation. */
1032
1032
  async requestCrossDomainToken() {
1033
- return this.fetch("auth/cross-domain-token", {
1034
- method: "POST"
1035
- });
1033
+ throw new Error("Use top-level /auth/continue navigation. CLI login uses OAuth with PKCE.");
1036
1034
  }
1037
- /** Exchange a cross-domain token for an authenticated session token. */
1038
- async exchangeToken(token) {
1039
- return this.fetch("auth/exchange-token", {
1040
- method: "POST",
1041
- body: JSON.stringify({ token })
1042
- });
1035
+ /** @deprecated Browser handoffs redeem only at the destination Next server. */
1036
+ async exchangeToken(_token) {
1037
+ throw new Error("Use top-level /auth/continue navigation. CLI login uses OAuth with PKCE.");
1043
1038
  }
1044
1039
  /** Exchange a global Account login for an opaque org-scoped session handle. */
1045
1040
  async exchangeSession(request) {
@@ -1220,9 +1215,17 @@ var AuthApi = class extends BaseApiClient {
1220
1215
  );
1221
1216
  }
1222
1217
  // ===== ORGANIZATION MEMBERSHIP METHODS =====
1223
- /** List all organizations the current account belongs to. */
1224
- async getMyOrganizations() {
1225
- return this.fetch("o/mine");
1218
+ /** A searchable page of the current account's organizations. */
1219
+ async getMyOrganizations(options) {
1220
+ const params = new URLSearchParams();
1221
+ if (options?.page) params.set("page", String(options.page));
1222
+ if (options?.pageSize) params.set("pageSize", String(options.pageSize));
1223
+ if (options?.canCreateWorkspace) params.set("canCreateWorkspace", "true");
1224
+ if (options?.search) params.set("search", options.search);
1225
+ if (options?.organizationSlug !== void 0)
1226
+ params.set("organizationSlug", options.organizationSlug);
1227
+ for (const uuid of options?.organizationUuids ?? []) params.append("organizationUuids", uuid);
1228
+ return this.fetch(`o/mine?${params}`);
1226
1229
  }
1227
1230
  // ===== CREDENTIAL CHANGE METHODS =====
1228
1231
  /**
@@ -4134,14 +4137,7 @@ var InquiriesApi = class extends BaseApiClient {
4134
4137
  }
4135
4138
  const queryString = params.toString();
4136
4139
  const url = queryString ? `inquiries/export/csv?${queryString}` : "inquiries/export/csv";
4137
- const response = await fetch(`${this.baseUrl}/api/v2/${url}`, {
4138
- method: "GET",
4139
- credentials: "include"
4140
- });
4141
- if (!response.ok) {
4142
- const error = await response.json();
4143
- throw new Error(error.detail || "Export failed");
4144
- }
4140
+ const response = await this.fetchRaw(url, { method: "GET" });
4145
4141
  return response.blob();
4146
4142
  }
4147
4143
  };
@@ -5421,8 +5417,12 @@ var OrgApi = class extends BaseApiClient {
5421
5417
  * figure — the caps belong to the organization, so `cap - oneWorkspace`
5422
5418
  * describes nothing.
5423
5419
  */
5424
- async getOrgWorkspaceUsage(orgIdOrUuid) {
5425
- return this.fetch(`o/${orgIdOrUuid}/usage/workspaces`);
5420
+ async getOrgWorkspaceUsage(orgIdOrUuid, options) {
5421
+ const params = new URLSearchParams();
5422
+ if (options?.page) params.set("page", String(options.page));
5423
+ if (options?.pageSize) params.set("pageSize", String(options.pageSize));
5424
+ if (options?.search) params.set("search", options.search);
5425
+ return this.fetch(`o/${orgIdOrUuid}/usage/workspaces?${params}`);
5426
5426
  }
5427
5427
  /**
5428
5428
  * List members of an organization.
@@ -5546,8 +5546,14 @@ var OrgApi = class extends BaseApiClient {
5546
5546
  * counts. Any org member may call it — members get the workspaces they
5547
5547
  * belong to, org:read holders get all of them.
5548
5548
  */
5549
- async getOrganizationWorkspaceSummaries(orgIdOrUuid) {
5550
- return this.fetch(`o/${orgIdOrUuid}/workspaces/summary`);
5549
+ async getOrganizationWorkspaceSummaries(orgIdOrUuid, options) {
5550
+ const params = new URLSearchParams();
5551
+ if (options?.page) params.set("page", String(options.page));
5552
+ if (options?.pageSize) params.set("pageSize", String(options.pageSize));
5553
+ if (options?.search) params.set("search", options.search);
5554
+ return this.fetch(
5555
+ `o/${orgIdOrUuid}/workspaces/summary?${params}`
5556
+ );
5551
5557
  }
5552
5558
  /**
5553
5559
  * Workspace-schema aggregates for one card, plus the caller's own member
@@ -6284,18 +6290,18 @@ function businessProfilePath(orgUuid, legalEntityUuid) {
6284
6290
  // src/api/oauth.ts
6285
6291
  function getOAuthPath(providerSlug, action) {
6286
6292
  if (providerSlug === "google_calendar") {
6287
- return `oauth/google/calendar/${action}`;
6293
+ return `api/v2/oauth/google/calendar/${action}`;
6288
6294
  }
6289
6295
  if (providerSlug === "gmail") {
6290
- return `oauth/google/gmail/${action}`;
6296
+ return `api/v2/oauth/google/gmail/${action}`;
6291
6297
  }
6292
6298
  if (providerSlug === "gdrive") {
6293
- return `oauth/google/drive/${action}`;
6299
+ return `api/v2/oauth/google/drive/${action}`;
6294
6300
  }
6295
6301
  if (providerSlug === "gsheets") {
6296
- return `oauth/google/sheets/${action}`;
6302
+ return `api/v2/oauth/google/sheets/${action}`;
6297
6303
  }
6298
- return `oauth/${providerSlug}/${action}`;
6304
+ return `api/v2/oauth/${providerSlug}/${action}`;
6299
6305
  }
6300
6306
  function buildAuthorizeQuery(options) {
6301
6307
  if (!options) return "";
@@ -8932,7 +8938,8 @@ var WorkflowsApi = class extends BaseApiClient {
8932
8938
  /**
8933
8939
  * Classify the prompts of a Workflow's draft revision.
8934
8940
  *
8935
- * A decision model reads each Task that has a prompt and reports which
8941
+ * A decision model reads each live Task with Workflow or Task instructions
8942
+ * and reports which
8936
8943
  * prompt classifications probably apply. Each call asks the model again.
8937
8944
  */
8938
8945
  async getWorkflowPromptClassifications(wid, workflowId) {
@@ -10317,22 +10324,32 @@ function planFields(options) {
10317
10324
  }
10318
10325
  return fields;
10319
10326
  }
10327
+ function workspaceDirectoryParams(options = {}) {
10328
+ const params = new URLSearchParams();
10329
+ if (options.page !== void 0) params.set("page", String(options.page));
10330
+ if (options.pageSize !== void 0) params.set("pageSize", String(options.pageSize));
10331
+ if (options.search) params.set("search", options.search);
10332
+ if (options.organizationUuid) params.set("organizationUuid", options.organizationUuid);
10333
+ for (const uuid of options.workspaceUuids ?? []) params.append("workspaceUuids", uuid);
10334
+ for (const id of options.workspaceIds ?? []) params.append("workspaceIds", String(id));
10335
+ return params;
10336
+ }
10320
10337
  var WorkspacesApi = class extends BaseApiClient {
10321
- /** List all workspaces accessible to the current user. */
10322
- async getWorkspaces() {
10323
- return this.fetch("w/");
10338
+ /** A bounded page of workspaces accessible to the current account. */
10339
+ async getWorkspaces(options) {
10340
+ return this.fetch(`w/?${workspaceDirectoryParams(options)}`);
10324
10341
  }
10325
- /**
10326
- * Compact rows for the workspaces a companion device could enter — the
10327
- * Lantern picker. Filtered by the same admission policy a device
10328
- * credential is gated by, without needing the device credential.
10329
- */
10330
- async getDeviceAdmissibleWorkspaces() {
10331
- return this.fetch("w/?can_use_device=1");
10342
+ /** A bounded page of companion-device candidates, with admission checked per row. */
10343
+ async getDeviceAdmissibleWorkspaces(options) {
10344
+ const params = workspaceDirectoryParams(options);
10345
+ params.set("can_use_device", "1");
10346
+ return this.fetch(`w/?${params}`);
10332
10347
  }
10333
- /** List all publicly visible workspaces. */
10334
- async getPublicWorkspaces() {
10335
- return this.fetch("w/public");
10348
+ /** A bounded page of publicly visible workspaces. */
10349
+ async getPublicWorkspaces(options) {
10350
+ return this.fetch(
10351
+ `w/public?${workspaceDirectoryParams(options)}`
10352
+ );
10336
10353
  }
10337
10354
  /** Get a single workspace by ID. */
10338
10355
  async getWorkspace(wid) {
@@ -10615,13 +10632,22 @@ var WorkspacesApi = class extends BaseApiClient {
10615
10632
  * @param scope - Export scope ("workflows" for all workflows only). Cannot be combined with workflowId.
10616
10633
  * @param exclude - Comma-separated entity categories to exclude (e.g. "channels")
10617
10634
  */
10618
- async exportWorkspace(wid, workflowId, scope, exclude) {
10635
+ async exportWorkspace(wid, workflowId, scope, exclude, options) {
10619
10636
  const searchParams = new URLSearchParams();
10620
10637
  if (workflowId !== void 0) searchParams.set("workflow_id", String(workflowId));
10621
10638
  if (scope !== void 0) searchParams.set("scope", scope);
10622
10639
  if (exclude !== void 0) searchParams.set("exclude", exclude);
10640
+ if (options?.revisionId !== void 0)
10641
+ searchParams.set("revision_id", String(options.revisionId));
10642
+ if (options?.revisionMode !== void 0) {
10643
+ searchParams.set("revision_mode", options.revisionMode);
10644
+ } else if (options?.revisionId === void 0) {
10645
+ searchParams.set("revision_mode", "active");
10646
+ }
10623
10647
  const qs = searchParams.toString();
10624
- return this.fetch(`w/${wid}/export${qs ? `?${qs}` : ""}`);
10648
+ const data = await this.fetch(`w/${wid}/export${qs ? `?${qs}` : ""}`);
10649
+ this.verifyExportSelection(data, workflowId, options);
10650
+ return data;
10625
10651
  }
10626
10652
  /** Preview the result of importing workspace configuration without applying changes.
10627
10653
  *
@@ -10680,15 +10706,60 @@ var WorkspacesApi = class extends BaseApiClient {
10680
10706
  * target workspace.
10681
10707
  */
10682
10708
  /** Download a workspace export ZIP (``export.json`` + file blobs). */
10683
- async exportWorkspaceZip(wid, workflowId, scope, exclude) {
10709
+ async exportWorkspaceZip(wid, workflowId, scope, exclude, options) {
10684
10710
  const searchParams = new URLSearchParams();
10685
10711
  if (workflowId !== void 0) searchParams.set("workflow_id", String(workflowId));
10686
10712
  if (scope !== void 0) searchParams.set("scope", scope);
10687
10713
  if (exclude !== void 0) searchParams.set("exclude", exclude);
10714
+ if (options?.revisionId !== void 0)
10715
+ searchParams.set("revision_id", String(options.revisionId));
10716
+ if (options?.revisionMode !== void 0) {
10717
+ searchParams.set("revision_mode", options.revisionMode);
10718
+ } else if (options?.revisionId === void 0) {
10719
+ searchParams.set("revision_mode", "active");
10720
+ }
10688
10721
  const qs = searchParams.toString();
10689
10722
  const response = await this.fetchRaw(`w/${wid}/export.zip${qs ? `?${qs}` : ""}`);
10723
+ if (options?.revisionId !== void 0 || options?.revisionMode === "all") {
10724
+ const version = response.headers.get("X-Gravityrail-Export-Version");
10725
+ const selection = response.headers.get("X-Gravityrail-Export-Selection");
10726
+ const selected = options?.revisionId !== void 0;
10727
+ if (version !== (selected ? "1.0" : "2.0") || selection !== (selected ? "selected" : "all") || selected && (workflowId === void 0 || !response.headers.get("X-Gravityrail-Export-Revision-Uuid")?.trim() || !response.headers.get("X-Gravityrail-Export-Workflow-Uuid")?.trim())) {
10728
+ try {
10729
+ await response.body?.cancel();
10730
+ } catch {
10731
+ }
10732
+ throw new Error(
10733
+ "Server did not return verified Workflow revision export headers. Request an explicit active snapshot or use a server that supports export provenance."
10734
+ );
10735
+ }
10736
+ }
10690
10737
  return response.arrayBuffer();
10691
10738
  }
10739
+ // Compatibility shape check only. The backend WorkspaceExportData
10740
+ // _validate_revision_archive owns full graph/publication invariants.
10741
+ verifyExportSelection(data, workflowId, options) {
10742
+ const hasUuid = (value) => typeof value === "string" && value.trim().length > 0;
10743
+ if (options?.revisionId !== void 0) {
10744
+ const revisions = data?.workflowRevisions;
10745
+ if (workflowId === void 0 || data?.version !== "1.0" || data.workflowRevisionSelection !== "selected" || !Array.isArray(revisions) || revisions.length !== 1) {
10746
+ throw new Error(
10747
+ "Server did not return the requested Workflow revision. Use a server that supports revision selection."
10748
+ );
10749
+ }
10750
+ if (!hasUuid(revisions[0]?.uuid) || !hasUuid(revisions[0]?.workflow?.uuid) || !hasUuid(data.workflows?.[0]?.uuid) || data.workflows?.length !== 1 || revisions[0]?.workflow?.uuid !== data.workflows[0]?.uuid) {
10751
+ throw new Error("Server export does not match the requested Workflow revision.");
10752
+ }
10753
+ } else if (options?.revisionMode === "all" && (data?.version !== "2.0" || data.workflowRevisionSelection !== "all" || !Array.isArray(data.workflowRevisions) || !Array.isArray(data.workflows) || data.workflows.some(
10754
+ (workflow) => !hasUuid(workflow?.uuid) || !data.workflowRevisions?.some(
10755
+ (revision) => hasUuid(revision?.uuid) && revision?.workflow?.uuid === workflow.uuid
10756
+ )
10757
+ ))) {
10758
+ throw new Error(
10759
+ "Server did not return all Workflow revisions. Request an explicit active snapshot or use a server that supports revision archives."
10760
+ );
10761
+ }
10762
+ }
10692
10763
  /** Import workspace configuration from exported JSON, or from a ZIP archive.
10693
10764
  * Pass ``archive`` (the ZIP from ``exportWorkspaceZip``) to restore file
10694
10765
  * contents. ``exportData`` may be omitted when the ZIP contains it.
@@ -16662,6 +16733,86 @@ function getRevisionState(workflow, revision) {
16662
16733
  };
16663
16734
  }
16664
16735
 
16736
+ // src/workflows/path.ts
16737
+ function getPathDefinition(path) {
16738
+ if (path.routing != null) {
16739
+ const routing = path.routing;
16740
+ if (typeof routing !== "object" || Array.isArray(routing)) return null;
16741
+ const fields = routing;
16742
+ if (fields.kind !== void 0 && fields.kind !== "outcome" || typeof fields.outcome !== "string" || !/^[a-z][a-z0-9_]{0,31}$/.test(fields.outcome) || Object.keys(fields).some((key) => key !== "kind" && key !== "outcome"))
16743
+ return null;
16744
+ return {
16745
+ availability: { kind: "always", expression: null, decisionPrompt: null },
16746
+ selection: {
16747
+ mode: "automatic",
16748
+ rule: "task_outcome",
16749
+ choicePrompt: null,
16750
+ condition: null,
16751
+ outcome: fields.outcome,
16752
+ policy: "matching_outcome",
16753
+ priority: null
16754
+ }
16755
+ };
16756
+ }
16757
+ const expression = path.celCondition?.trim() ? path.celCondition : null;
16758
+ const automatic = expression !== null && Boolean(path.required || path.autoNext);
16759
+ return {
16760
+ availability: {
16761
+ kind: expression === null ? "always" : "cel",
16762
+ expression,
16763
+ decisionPrompt: null
16764
+ },
16765
+ selection: {
16766
+ mode: automatic ? "automatic" : "choice",
16767
+ rule: automatic ? "when_available" : "choice",
16768
+ choicePrompt: automatic ? null : path.choicePrompt?.trim() || null,
16769
+ condition: null,
16770
+ outcome: null,
16771
+ policy: automatic ? "first_match" : "choose_one",
16772
+ priority: automatic ? path.order ?? 0 : null
16773
+ }
16774
+ };
16775
+ }
16776
+ function pathDraftFromStorage(path) {
16777
+ const definition = getPathDefinition(path);
16778
+ if (!definition || definition.selection.rule === "task_outcome") {
16779
+ throw new Error("This Path requires its dedicated routing editor.");
16780
+ }
16781
+ return {
16782
+ availabilityCondition: path.celCondition ?? "",
16783
+ selectionMode: definition.selection.mode,
16784
+ choicePrompt: path.choicePrompt ?? "",
16785
+ selectionPriority: path.order ?? 0
16786
+ };
16787
+ }
16788
+ function pathDraftToStorage(draft, original) {
16789
+ const initial = pathDraftFromStorage(original);
16790
+ const hasCondition = draft.availabilityCondition.trim() !== "";
16791
+ if (draft.selectionMode === "automatic" && !hasCondition) {
16792
+ throw new Error("Automatic Path selection requires a CEL condition.");
16793
+ }
16794
+ if (draft.availabilityCondition === initial.availabilityCondition && draft.selectionMode === initial.selectionMode && draft.choicePrompt === initial.choicePrompt && draft.selectionPriority === initial.selectionPriority)
16795
+ return original;
16796
+ const celCondition = draft.availabilityCondition === initial.availabilityCondition ? original.celCondition : draft.availabilityCondition.trim() ? draft.availabilityCondition : null;
16797
+ const choicePrompt = draft.choicePrompt === initial.choicePrompt ? original.choicePrompt : draft.choicePrompt.trim() ? draft.choicePrompt : null;
16798
+ let autoNext = original.autoNext;
16799
+ let required = original.required;
16800
+ if (draft.selectionMode === "automatic" && initial.selectionMode !== "automatic") {
16801
+ autoNext = true;
16802
+ } else if (draft.selectionMode === "choice" && (hasCondition || initial.availabilityCondition.trim() !== "") && Boolean(autoNext || required)) {
16803
+ autoNext = false;
16804
+ required = false;
16805
+ }
16806
+ return {
16807
+ ...original,
16808
+ celCondition,
16809
+ choicePrompt,
16810
+ autoNext,
16811
+ required,
16812
+ ...draft.selectionPriority === initial.selectionPriority ? {} : { order: draft.selectionPriority }
16813
+ };
16814
+ }
16815
+
16665
16816
  export {
16666
16817
  AbilitiesApi,
16667
16818
  ResourceWorkflowsApi,
@@ -16967,6 +17118,9 @@ export {
16967
17118
  SCOPES,
16968
17119
  ScopeManager,
16969
17120
  SCOPE_PRESETS,
16970
- getRevisionState
17121
+ getRevisionState,
17122
+ getPathDefinition,
17123
+ pathDraftFromStorage,
17124
+ pathDraftToStorage
16971
17125
  };
16972
- //# sourceMappingURL=chunk-N4GQWNGU.js.map
17126
+ //# sourceMappingURL=chunk-XQTPXOBU.js.map