@gravity-rail/sdk 0.46.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 +116 -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-0MSzmdxz.d.cts → chat-interaction-D4Edo92W.d.ts} +273 -48
  9. package/dist/{chat-interaction-CO9ecTSn.d.ts → chat-interaction-e5vHKt5j.d.cts} +273 -48
  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-I7BMDNPO.js → chunk-XQTPXOBU.js} +249 -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 +307 -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 +307 -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-Cc3-CIi5.d.ts → path-CQBykGoj.d.cts} +64 -3
  35. package/dist/{revision-state-m6Cjyr4M.d.cts → path-DVWLvQS-.d.ts} +64 -3
  36. package/dist/schemas.cjs +60 -15
  37. package/dist/schemas.cjs.map +1 -1
  38. package/dist/schemas.d.cts +34 -3
  39. package/dist/schemas.d.ts +34 -3
  40. package/dist/schemas.js +60 -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-I7BMDNPO.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
  /**
@@ -2340,6 +2343,45 @@ var CustomToolkitsApi = class extends BaseApiClient {
2340
2343
 
2341
2344
  // src/api/data-types.ts
2342
2345
  var DataTypesApi = class extends BaseApiClient {
2346
+ /** Read an anonymous Form's visitor-writable schema without a Member session. */
2347
+ async getAnonymousFormSchema(wid, formUuid) {
2348
+ return this.fetchPublicAnonymousForm(
2349
+ `w/${encodeURIComponent(wid)}/anonymous-forms/${encodeURIComponent(formUuid)}`
2350
+ );
2351
+ }
2352
+ /** Submit visitor-provided values. No cookie or API credential is sent. */
2353
+ async submitAnonymousForm(wid, formUuid, input) {
2354
+ return this.fetchPublicAnonymousForm(
2355
+ `w/${encodeURIComponent(wid)}/anonymous-forms/${encodeURIComponent(formUuid)}/submissions`,
2356
+ { method: "POST", body: JSON.stringify(input) }
2357
+ );
2358
+ }
2359
+ async fetchPublicAnonymousForm(endpoint, options = {}) {
2360
+ const headers = new Headers(options.headers);
2361
+ if (options.body !== void 0) headers.set("Content-Type", "application/json");
2362
+ let response;
2363
+ try {
2364
+ response = await this.fetchFunction(`${this.baseUrl}/api/v2/${endpoint}`, {
2365
+ ...options,
2366
+ credentials: "omit",
2367
+ headers
2368
+ });
2369
+ } catch {
2370
+ throw new ApiError("Anonymous Form request failed", 0);
2371
+ }
2372
+ if (!response.ok) {
2373
+ let message = `Request failed with status ${response.status}`;
2374
+ try {
2375
+ const body = await response.json();
2376
+ if (typeof body.detail === "string" && body.detail.length > 0) {
2377
+ message = body.detail;
2378
+ }
2379
+ } catch {
2380
+ }
2381
+ throw new ApiError(message, response.status);
2382
+ }
2383
+ return await response.json();
2384
+ }
2343
2385
  /** Read the local Form's draft and optimistic publication counters. */
2344
2386
  async getDataTypeDraft(wid, id) {
2345
2387
  return this.fetch(`w/${wid}/data-types/${id}/schema-draft`);
@@ -4095,14 +4137,7 @@ var InquiriesApi = class extends BaseApiClient {
4095
4137
  }
4096
4138
  const queryString = params.toString();
4097
4139
  const url = queryString ? `inquiries/export/csv?${queryString}` : "inquiries/export/csv";
4098
- const response = await fetch(`${this.baseUrl}/api/v2/${url}`, {
4099
- method: "GET",
4100
- credentials: "include"
4101
- });
4102
- if (!response.ok) {
4103
- const error = await response.json();
4104
- throw new Error(error.detail || "Export failed");
4105
- }
4140
+ const response = await this.fetchRaw(url, { method: "GET" });
4106
4141
  return response.blob();
4107
4142
  }
4108
4143
  };
@@ -5382,8 +5417,12 @@ var OrgApi = class extends BaseApiClient {
5382
5417
  * figure — the caps belong to the organization, so `cap - oneWorkspace`
5383
5418
  * describes nothing.
5384
5419
  */
5385
- async getOrgWorkspaceUsage(orgIdOrUuid) {
5386
- 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}`);
5387
5426
  }
5388
5427
  /**
5389
5428
  * List members of an organization.
@@ -5507,8 +5546,14 @@ var OrgApi = class extends BaseApiClient {
5507
5546
  * counts. Any org member may call it — members get the workspaces they
5508
5547
  * belong to, org:read holders get all of them.
5509
5548
  */
5510
- async getOrganizationWorkspaceSummaries(orgIdOrUuid) {
5511
- 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
+ );
5512
5557
  }
5513
5558
  /**
5514
5559
  * Workspace-schema aggregates for one card, plus the caller's own member
@@ -6245,18 +6290,18 @@ function businessProfilePath(orgUuid, legalEntityUuid) {
6245
6290
  // src/api/oauth.ts
6246
6291
  function getOAuthPath(providerSlug, action) {
6247
6292
  if (providerSlug === "google_calendar") {
6248
- return `oauth/google/calendar/${action}`;
6293
+ return `api/v2/oauth/google/calendar/${action}`;
6249
6294
  }
6250
6295
  if (providerSlug === "gmail") {
6251
- return `oauth/google/gmail/${action}`;
6296
+ return `api/v2/oauth/google/gmail/${action}`;
6252
6297
  }
6253
6298
  if (providerSlug === "gdrive") {
6254
- return `oauth/google/drive/${action}`;
6299
+ return `api/v2/oauth/google/drive/${action}`;
6255
6300
  }
6256
6301
  if (providerSlug === "gsheets") {
6257
- return `oauth/google/sheets/${action}`;
6302
+ return `api/v2/oauth/google/sheets/${action}`;
6258
6303
  }
6259
- return `oauth/${providerSlug}/${action}`;
6304
+ return `api/v2/oauth/${providerSlug}/${action}`;
6260
6305
  }
6261
6306
  function buildAuthorizeQuery(options) {
6262
6307
  if (!options) return "";
@@ -8893,7 +8938,8 @@ var WorkflowsApi = class extends BaseApiClient {
8893
8938
  /**
8894
8939
  * Classify the prompts of a Workflow's draft revision.
8895
8940
  *
8896
- * 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
8897
8943
  * prompt classifications probably apply. Each call asks the model again.
8898
8944
  */
8899
8945
  async getWorkflowPromptClassifications(wid, workflowId) {
@@ -10278,22 +10324,32 @@ function planFields(options) {
10278
10324
  }
10279
10325
  return fields;
10280
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
+ }
10281
10337
  var WorkspacesApi = class extends BaseApiClient {
10282
- /** List all workspaces accessible to the current user. */
10283
- async getWorkspaces() {
10284
- 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)}`);
10285
10341
  }
10286
- /**
10287
- * Compact rows for the workspaces a companion device could enter — the
10288
- * Lantern picker. Filtered by the same admission policy a device
10289
- * credential is gated by, without needing the device credential.
10290
- */
10291
- async getDeviceAdmissibleWorkspaces() {
10292
- 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}`);
10293
10347
  }
10294
- /** List all publicly visible workspaces. */
10295
- async getPublicWorkspaces() {
10296
- 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
+ );
10297
10353
  }
10298
10354
  /** Get a single workspace by ID. */
10299
10355
  async getWorkspace(wid) {
@@ -10576,13 +10632,22 @@ var WorkspacesApi = class extends BaseApiClient {
10576
10632
  * @param scope - Export scope ("workflows" for all workflows only). Cannot be combined with workflowId.
10577
10633
  * @param exclude - Comma-separated entity categories to exclude (e.g. "channels")
10578
10634
  */
10579
- async exportWorkspace(wid, workflowId, scope, exclude) {
10635
+ async exportWorkspace(wid, workflowId, scope, exclude, options) {
10580
10636
  const searchParams = new URLSearchParams();
10581
10637
  if (workflowId !== void 0) searchParams.set("workflow_id", String(workflowId));
10582
10638
  if (scope !== void 0) searchParams.set("scope", scope);
10583
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
+ }
10584
10647
  const qs = searchParams.toString();
10585
- 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;
10586
10651
  }
10587
10652
  /** Preview the result of importing workspace configuration without applying changes.
10588
10653
  *
@@ -10641,15 +10706,60 @@ var WorkspacesApi = class extends BaseApiClient {
10641
10706
  * target workspace.
10642
10707
  */
10643
10708
  /** Download a workspace export ZIP (``export.json`` + file blobs). */
10644
- async exportWorkspaceZip(wid, workflowId, scope, exclude) {
10709
+ async exportWorkspaceZip(wid, workflowId, scope, exclude, options) {
10645
10710
  const searchParams = new URLSearchParams();
10646
10711
  if (workflowId !== void 0) searchParams.set("workflow_id", String(workflowId));
10647
10712
  if (scope !== void 0) searchParams.set("scope", scope);
10648
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
+ }
10649
10721
  const qs = searchParams.toString();
10650
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
+ }
10651
10737
  return response.arrayBuffer();
10652
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
+ }
10653
10763
  /** Import workspace configuration from exported JSON, or from a ZIP archive.
10654
10764
  * Pass ``archive`` (the ZIP from ``exportWorkspaceZip``) to restore file
10655
10765
  * contents. ``exportData`` may be omitted when the ZIP contains it.
@@ -12037,6 +12147,7 @@ var WORKSPACE_METHOD_NAMES = [
12037
12147
  "getAgents",
12038
12148
  "getAnonymousResolution",
12039
12149
  "getAnonymousFormSubmission",
12150
+ "getAnonymousFormSchema",
12040
12151
  "getAnonymousResolutions",
12041
12152
  "getApiKeys",
12042
12153
  "getArchiveBlockers",
@@ -12422,6 +12533,7 @@ var WORKSPACE_METHOD_NAMES = [
12422
12533
  "linkUnlinkedSalesforceMembersByIdentity",
12423
12534
  "listAbilities",
12424
12535
  "listAnonymousFormSubmissions",
12536
+ "submitAnonymousForm",
12425
12537
  "listAppConnections",
12426
12538
  "listAvailableAppConnections",
12427
12539
  "listInstallations",
@@ -12875,6 +12987,8 @@ function bindTrackedLinksMethods(target, trackedLinks) {
12875
12987
 
12876
12988
  // src/client/bindings/data-types.ts
12877
12989
  function bindDataTypesMethods(target, dataTypes) {
12990
+ target.getAnonymousFormSchema = dataTypes.getAnonymousFormSchema.bind(dataTypes);
12991
+ target.submitAnonymousForm = dataTypes.submitAnonymousForm.bind(dataTypes);
12878
12992
  target.getDataTypeDraft = dataTypes.getDataTypeDraft.bind(dataTypes);
12879
12993
  target.saveDataTypeDraft = dataTypes.saveDataTypeDraft.bind(dataTypes);
12880
12994
  target.publishDataTypeDraft = dataTypes.publishDataTypeDraft.bind(dataTypes);
@@ -14069,6 +14183,8 @@ var GravityRailClient = class {
14069
14183
  getCelContext;
14070
14184
  validateCelExpression;
14071
14185
  // Data Types API
14186
+ getAnonymousFormSchema;
14187
+ submitAnonymousForm;
14072
14188
  getDataTypes;
14073
14189
  getDataTypeDraft;
14074
14190
  saveDataTypeDraft;
@@ -16617,6 +16733,86 @@ function getRevisionState(workflow, revision) {
16617
16733
  };
16618
16734
  }
16619
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
+
16620
16816
  export {
16621
16817
  AbilitiesApi,
16622
16818
  ResourceWorkflowsApi,
@@ -16922,6 +17118,9 @@ export {
16922
17118
  SCOPES,
16923
17119
  ScopeManager,
16924
17120
  SCOPE_PRESETS,
16925
- getRevisionState
17121
+ getRevisionState,
17122
+ getPathDefinition,
17123
+ pathDraftFromStorage,
17124
+ pathDraftToStorage
16926
17125
  };
16927
- //# sourceMappingURL=chunk-I7BMDNPO.js.map
17126
+ //# sourceMappingURL=chunk-XQTPXOBU.js.map