@gravity-rail/sdk 0.16.0 → 0.17.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 (36) hide show
  1. package/dist/{chunk-4B7T6MBH.js → chunk-CEFOCGYO.js} +300 -64
  2. package/dist/chunk-CEFOCGYO.js.map +1 -0
  3. package/dist/{chunk-GP6ICMWF.js → chunk-PJFEGUHM.js} +8 -1
  4. package/dist/chunk-PJFEGUHM.js.map +1 -0
  5. package/dist/{client-3xYGmF3t.d.ts → client-8xakCsVs.d.cts} +1030 -179
  6. package/dist/{client-BhO_UFFz.d.cts → client-ASnNEN1U.d.ts} +1030 -179
  7. package/dist/helpers.cjs +7 -0
  8. package/dist/helpers.cjs.map +1 -1
  9. package/dist/helpers.d.cts +2 -2
  10. package/dist/helpers.d.ts +2 -2
  11. package/dist/helpers.js +1 -1
  12. package/dist/index.cjs +354 -61
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +23 -5
  15. package/dist/index.d.ts +23 -5
  16. package/dist/index.js +73 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/internal.cjs +360 -63
  19. package/dist/internal.cjs.map +1 -1
  20. package/dist/internal.d.cts +33 -7
  21. package/dist/internal.d.ts +33 -7
  22. package/dist/internal.js +61 -4
  23. package/dist/internal.js.map +1 -1
  24. package/dist/{revision-state-Dx8gCQIj.d.cts → revision-state-BDsQo_xD.d.cts} +2 -2
  25. package/dist/{revision-state-Dma10N9s.d.ts → revision-state-Cz3mcUHc.d.ts} +2 -2
  26. package/dist/schemas.cjs +170 -216
  27. package/dist/schemas.cjs.map +1 -1
  28. package/dist/schemas.d.cts +2 -2
  29. package/dist/schemas.d.ts +2 -2
  30. package/dist/schemas.js +170 -209
  31. package/dist/schemas.js.map +1 -1
  32. package/dist/{tasks-vupYoJgG.d.cts → tasks-Z4GcIqgO.d.cts} +190 -73
  33. package/dist/{tasks-vupYoJgG.d.ts → tasks-Z4GcIqgO.d.ts} +190 -73
  34. package/package.json +2 -2
  35. package/dist/chunk-4B7T6MBH.js.map +0 -1
  36. package/dist/chunk-GP6ICMWF.js.map +0 -1
package/dist/index.js CHANGED
@@ -44,6 +44,7 @@ import {
44
44
  MemberImportValidationError,
45
45
  MemberType,
46
46
  MenuItemResponseItemType,
47
+ MergeMemberRolesRequestAccessStrategy,
47
48
  ModelProvider,
48
49
  ModelType,
49
50
  NO_ASSISTANT_PARTICIPANT_CHAT_TYPES,
@@ -101,9 +102,12 @@ import {
101
102
  WIDGET_SLUGS,
102
103
  WORKFLOW_IMPLICIT_USE_SCOPE,
103
104
  WorkflowAccessWarningResourceType,
105
+ WorkflowRoutingMode,
104
106
  WorkspaceFeature,
105
107
  WorkspaceProvisionStatus,
108
+ archivedMemberConflictId,
106
109
  areDependenciesSatisfied,
110
+ asIdentifiedMemberContactConflict,
107
111
  canPreviewVoice,
108
112
  clearRegistry,
109
113
  createWorkspaceClient,
@@ -126,9 +130,12 @@ import {
126
130
  getTTSProvider,
127
131
  getVoiceModelId,
128
132
  initializeFeatures,
133
+ isAccountContactConflict,
129
134
  isAgentNoteOrigin,
130
135
  isChatType,
131
136
  isFeatureAvailable,
137
+ isIdentifiedMemberContactConflict,
138
+ isMemberContactConflict,
132
139
  isPositiveRating,
133
140
  isRegistryInitialized,
134
141
  isSMSDeliveryFailureStatus,
@@ -138,7 +145,7 @@ import {
138
145
  roleWorkflowAccess,
139
146
  usesBuiltinAssistant,
140
147
  validateFeatureDependencies
141
- } from "./chunk-4B7T6MBH.js";
148
+ } from "./chunk-CEFOCGYO.js";
142
149
  import {
143
150
  AttendeeResponseStatus,
144
151
  AttendeeStatus,
@@ -159,7 +166,7 @@ import {
159
166
  BaseApiClient,
160
167
  getCookieValue,
161
168
  parseOrgAuthChallenge
162
- } from "./chunk-GP6ICMWF.js";
169
+ } from "./chunk-PJFEGUHM.js";
163
170
 
164
171
  // src/workspace-builder/resource.ts
165
172
  function isRecord(value) {
@@ -971,6 +978,16 @@ var TaskBuilder = class extends WorkspaceBuilderResource {
971
978
  description;
972
979
  transitions = [];
973
980
  eventRules = [];
981
+ /** Child task ids the server already has, recorded when this task is adopted. */
982
+ existingChildIds = /* @__PURE__ */ new Set();
983
+ /** Record the edges an adopted task already carries, so a re-run adds only what is missing. */
984
+ adopt(existing) {
985
+ super.adopt(existing);
986
+ for (const child of existing.childTasks ?? []) {
987
+ const id = child.taskId ?? child.id;
988
+ if (typeof id === "number") this.existingChildIds.add(id);
989
+ }
990
+ }
974
991
  transitionsTo(child, when, autoNext = false, required = false, celCondition) {
975
992
  if (child === this) {
976
993
  throw new Error(`Task '${this.name}' cannot transition to itself`);
@@ -1281,7 +1298,53 @@ ${"=".repeat(50)}`);
1281
1298
  writeLine("\n Journey warnings:");
1282
1299
  for (const problem of problems) writeLine(` ! ${problem}`);
1283
1300
  }
1301
+ /**
1302
+ * Problems that make the plan unwritable, found before the first write.
1303
+ *
1304
+ * The API validates each CEL when you save it, and its diagnosis is right —
1305
+ * but it fires per-write, so a plan whose edges reference a non-collection
1306
+ * form gets four labels, two forms, a workflow and six tasks created before
1307
+ * the seventh call rejects it. The operator is left with a half-built
1308
+ * program to hand-repair. Checking here costs nothing and writes nothing.
1309
+ *
1310
+ * Deliberately narrow: only cross-resource facts the builder can see with
1311
+ * certainty. Per-field CEL schema checking stays server-side, where the
1312
+ * real validator lives — duplicating it here would drift.
1313
+ */
1314
+ preflight() {
1315
+ const problems = [];
1316
+ const forms = this.resources.filter(
1317
+ (resource) => resource instanceof FormBuilder
1318
+ );
1319
+ const collectionBySlug = new Map(forms.map((form) => [form.slug, form.collection]));
1320
+ const reference = /assignment\.collections\.([A-Za-z0-9_]+)/g;
1321
+ for (const resource of this.sortedResources()) {
1322
+ if (!(resource instanceof TaskBuilder)) continue;
1323
+ for (const transition of resource.transitions) {
1324
+ const cel = transition.celCondition;
1325
+ if (!cel) continue;
1326
+ for (const [, slug] of cel.matchAll(reference)) {
1327
+ if (!collectionBySlug.has(slug)) continue;
1328
+ if (!collectionBySlug.get(slug)) {
1329
+ problems.push(
1330
+ `task '${transition.parent.name}' \u2192 '${transition.child.name}': CEL reads assignment.collections.${slug}, but this plan creates '${slug}' as a non-collection form. Declare it with { collection: true }.`
1331
+ );
1332
+ }
1333
+ }
1334
+ }
1335
+ }
1336
+ return [...new Set(problems)];
1337
+ }
1284
1338
  async apply() {
1339
+ const problems = this.preflight();
1340
+ if (problems.length) {
1341
+ writeLine("\nPlan rejected \u2014 nothing was created:");
1342
+ for (const problem of problems) writeLine(` ! ${problem}`);
1343
+ throw new Error(
1344
+ `Plan has ${problems.length} problem(s) and was not applied:
1345
+ ` + problems.map((problem) => ` - ${problem}`).join("\n")
1346
+ );
1347
+ }
1285
1348
  const resources = this.sortedResources();
1286
1349
  await this.resolveExisting(resources);
1287
1350
  const summary = {};
@@ -1468,6 +1531,7 @@ Done! Created ${count} resources.`);
1468
1531
  const childTasks = transitions.flatMap((transition) => {
1469
1532
  const taskId = transition.child._id;
1470
1533
  if (taskId === void 0 || taskId === parent._id) return [];
1534
+ if (parent.existingChildIds.has(taskId)) return [];
1471
1535
  return [
1472
1536
  {
1473
1537
  taskId,
@@ -1858,6 +1922,7 @@ export {
1858
1922
  MemberType,
1859
1923
  MenuItemResponseItemType,
1860
1924
  MenuItemResponseItemType as MenuItemType,
1925
+ MergeMemberRolesRequestAccessStrategy,
1861
1926
  ModelProvider,
1862
1927
  ModelType,
1863
1928
  NO_ASSISTANT_PARTICIPANT_CHAT_TYPES,
@@ -1921,11 +1986,14 @@ export {
1921
1986
  WorkflowAccessWarningResourceType,
1922
1987
  WorkflowBuilder,
1923
1988
  WorkflowAccessWarningResourceType as WorkflowResourceType,
1989
+ WorkflowRoutingMode,
1924
1990
  WorkspaceBuilder,
1925
1991
  WorkspaceBuilderResource,
1926
1992
  WorkspaceFeature,
1927
1993
  WorkspaceProvisionStatus,
1994
+ archivedMemberConflictId,
1928
1995
  areDependenciesSatisfied,
1996
+ asIdentifiedMemberContactConflict,
1929
1997
  canPreviewVoice,
1930
1998
  clearRegistry,
1931
1999
  createWorkspaceClient,
@@ -1949,9 +2017,12 @@ export {
1949
2017
  getTTSProvider,
1950
2018
  getVoiceModelId,
1951
2019
  initializeFeatures,
2020
+ isAccountContactConflict,
1952
2021
  isAgentNoteOrigin,
1953
2022
  isChatType,
1954
2023
  isFeatureAvailable,
2024
+ isIdentifiedMemberContactConflict,
2025
+ isMemberContactConflict,
1955
2026
  isPositiveRating,
1956
2027
  isRegistryInitialized,
1957
2028
  isSMSDeliveryFailureStatus,