@gravity-rail/sdk 0.8.0 → 0.11.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 +45 -8
- package/dist/chunk-FSSXKQR5.js +471 -0
- package/dist/chunk-FSSXKQR5.js.map +1 -0
- package/dist/{chunk-QS6ZRQUZ.js → chunk-V7ZKEH4V.js} +8 -1
- package/dist/chunk-V7ZKEH4V.js.map +1 -0
- package/dist/{chunk-ML55PVP7.js → chunk-YESHLUL7.js} +1435 -703
- package/dist/chunk-YESHLUL7.js.map +1 -0
- package/dist/{client-C2aWAalu.d.cts → client-BCgXtr8p.d.cts} +3684 -1291
- package/dist/{client-CLGovEox.d.ts → client-Dh1l20Ue.d.ts} +3684 -1291
- package/dist/helpers.cjs +177 -13
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +82 -3
- package/dist/helpers.d.ts +82 -3
- package/dist/helpers.js +155 -12
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +1679 -420
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -24
- package/dist/index.d.ts +32 -24
- package/dist/index.js +193 -113
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +1742 -413
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +634 -29
- package/dist/internal.d.ts +634 -29
- package/dist/internal.js +140 -7
- package/dist/internal.js.map +1 -1
- package/dist/realtime.cjs +43 -0
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +26 -0
- package/dist/realtime.d.ts +26 -0
- package/dist/realtime.js +43 -0
- package/dist/realtime.js.map +1 -1
- package/dist/{scopes-D6a_Mvqr.d.ts → revision-state-BTF-MnbW.d.cts} +270 -23
- package/dist/{scopes-CDaJBQVT.d.cts → revision-state-DOH1NMGb.d.ts} +270 -23
- package/dist/schemas.cjs +56 -117
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +121 -484
- package/dist/schemas.d.ts +121 -484
- package/dist/schemas.js +55 -114
- package/dist/schemas.js.map +1 -1
- package/dist/{inquiries-CmECZnkl.d.cts → tasks-C4aYbWVv.d.cts} +944 -148
- package/dist/{inquiries-CmECZnkl.d.ts → tasks-C4aYbWVv.d.ts} +944 -148
- package/package.json +5 -5
- package/dist/chunk-ML55PVP7.js.map +0 -1
- package/dist/chunk-QS6ZRQUZ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,16 +6,15 @@ import {
|
|
|
6
6
|
AccessGrantStatus,
|
|
7
7
|
AccessGrantTrigger,
|
|
8
8
|
AccessLevel,
|
|
9
|
-
ApiError,
|
|
10
9
|
AppsApi,
|
|
11
10
|
BUILTIN_ASSISTANT_CHAT_TYPES,
|
|
12
|
-
BaseApiClient,
|
|
13
11
|
BuildersApi,
|
|
14
12
|
BulkMemberResultStatus,
|
|
15
13
|
BusinessIndustry,
|
|
16
14
|
BusinessType,
|
|
17
15
|
CELApi,
|
|
18
16
|
CHAT_TYPES,
|
|
17
|
+
CapabilityClass,
|
|
19
18
|
ConsentMethod,
|
|
20
19
|
CriterionType,
|
|
21
20
|
DEFAULT_CHAT_MODEL,
|
|
@@ -38,6 +37,9 @@ import {
|
|
|
38
37
|
MASKED_SECRET_SENTINEL,
|
|
39
38
|
McpServerState,
|
|
40
39
|
MemberFeature,
|
|
40
|
+
MemberImportMatchInfoMatchType,
|
|
41
|
+
MemberImportPreviewRowAction,
|
|
42
|
+
MemberImportValidationError,
|
|
41
43
|
MemberType,
|
|
42
44
|
MenuItemResponseItemType,
|
|
43
45
|
ModelProvider,
|
|
@@ -57,7 +59,12 @@ import {
|
|
|
57
59
|
PERMISSION_NONE,
|
|
58
60
|
PERMISSION_USE,
|
|
59
61
|
PERMISSION_VERIFY,
|
|
62
|
+
PIDS_DISPOSITIONS,
|
|
63
|
+
PIDS_SOURCES,
|
|
64
|
+
POSITIVE_RATING_THRESHOLD,
|
|
60
65
|
ProductType,
|
|
66
|
+
QUERY_VALUELESS_OPS,
|
|
67
|
+
QueriesApi,
|
|
61
68
|
REALTIME_MODEL_CUSTOM,
|
|
62
69
|
REALTIME_MODEL_GEMINI,
|
|
63
70
|
REALTIME_MODEL_GEMINI_VERTEX,
|
|
@@ -85,10 +92,10 @@ import {
|
|
|
85
92
|
TTS_MODEL_ELEVENLABS_FLASH,
|
|
86
93
|
TTS_MODEL_ELEVENLABS_MULTILINGUAL,
|
|
87
94
|
TTS_MODEL_ELEVENLABS_TURBO,
|
|
88
|
-
TTS_MODEL_POCKET,
|
|
89
95
|
TTS_PREVIEW_PROVIDERS,
|
|
90
96
|
TemplatesApi,
|
|
91
97
|
ToolkitState,
|
|
98
|
+
WIDGET_SLUGS,
|
|
92
99
|
WorkflowAccessWarningResourceType,
|
|
93
100
|
WorkspaceFeature,
|
|
94
101
|
WorkspaceProvisionStatus,
|
|
@@ -105,24 +112,25 @@ import {
|
|
|
105
112
|
getApplicableResourceSlugs,
|
|
106
113
|
getApplicableResources,
|
|
107
114
|
getAvailableFeaturesForUpgrade,
|
|
108
|
-
getCookieValue,
|
|
109
115
|
getFeature,
|
|
110
116
|
getFeaturesByCategory,
|
|
111
117
|
getFeaturesByVisibility,
|
|
112
118
|
getMissingDependencies,
|
|
113
119
|
getResourceMetadata,
|
|
120
|
+
getRevisionState,
|
|
114
121
|
getScopeFromProductType,
|
|
115
122
|
getTTSProvider,
|
|
116
123
|
getVoiceModelId,
|
|
117
124
|
initializeFeatures,
|
|
118
125
|
isChatType,
|
|
119
126
|
isFeatureAvailable,
|
|
127
|
+
isPositiveRating,
|
|
120
128
|
isRegistryInitialized,
|
|
121
129
|
isSMSDeliveryFailureStatus,
|
|
122
130
|
requiresAssistantParticipant,
|
|
123
131
|
usesBuiltinAssistant,
|
|
124
132
|
validateFeatureDependencies
|
|
125
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-YESHLUL7.js";
|
|
126
134
|
import {
|
|
127
135
|
AttendeeResponseStatus,
|
|
128
136
|
AttendeeStatus,
|
|
@@ -133,10 +141,16 @@ import {
|
|
|
133
141
|
CalendarSource,
|
|
134
142
|
DataCategory,
|
|
135
143
|
DataFieldType,
|
|
144
|
+
DataRecordRetirementResponseReason,
|
|
136
145
|
DataSensitivity,
|
|
137
146
|
DataTypeRecordScope,
|
|
138
147
|
IndexStatus
|
|
139
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-V7ZKEH4V.js";
|
|
149
|
+
import {
|
|
150
|
+
ApiError,
|
|
151
|
+
BaseApiClient,
|
|
152
|
+
getCookieValue
|
|
153
|
+
} from "./chunk-FSSXKQR5.js";
|
|
140
154
|
|
|
141
155
|
// src/workspace-builder/resource.ts
|
|
142
156
|
function isRecord(value) {
|
|
@@ -155,6 +169,24 @@ var WorkspaceBuilderResource = class {
|
|
|
155
169
|
_uuid;
|
|
156
170
|
_created = false;
|
|
157
171
|
_existed = false;
|
|
172
|
+
/** Server-assigned numeric id — available after apply() or adopt(). */
|
|
173
|
+
get id() {
|
|
174
|
+
if (this._id === void 0) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`${this.constructor.name} has no id yet \u2014 ids are assigned during apply(). Pass the builder object itself where a reference is needed; refs resolve at apply time.`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return this._id;
|
|
180
|
+
}
|
|
181
|
+
/** Server-assigned uuid — available after apply() or adopt(). */
|
|
182
|
+
get uuid() {
|
|
183
|
+
if (this._uuid === void 0) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`${this.constructor.name} has no uuid yet \u2014 uuids are assigned during apply(). Pass the builder object itself where a reference is needed; refs resolve at apply time.`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return this._uuid;
|
|
189
|
+
}
|
|
158
190
|
matchKey() {
|
|
159
191
|
return void 0;
|
|
160
192
|
}
|
|
@@ -184,26 +216,25 @@ var MemberFilterBuilder = class extends WorkspaceBuilderResource {
|
|
|
184
216
|
super();
|
|
185
217
|
this.name = name;
|
|
186
218
|
this.description = options.description ?? "";
|
|
219
|
+
this.query = options.query ?? null;
|
|
187
220
|
}
|
|
221
|
+
name;
|
|
188
222
|
description;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
...options.objectIds ? { objectIds: options.objectIds } : {},
|
|
195
|
-
...options.query ? { query: options.query } : {}
|
|
196
|
-
});
|
|
223
|
+
/** Query-engine predicate (JSON IR) authored on MemberFilter.query. */
|
|
224
|
+
query = null;
|
|
225
|
+
/** Set the filter's query-engine predicate (JSON IR). */
|
|
226
|
+
setQuery(query) {
|
|
227
|
+
this.query = query;
|
|
197
228
|
return this;
|
|
198
229
|
}
|
|
199
230
|
planLine() {
|
|
200
|
-
return `MemberFilter: ${this.name}${this.
|
|
231
|
+
return `MemberFilter: ${this.name}${this.query ? " (query)" : ""}`;
|
|
201
232
|
}
|
|
202
233
|
async apply(client) {
|
|
203
234
|
const payload = {
|
|
204
235
|
name: this.name,
|
|
205
236
|
description: this.description,
|
|
206
|
-
|
|
237
|
+
query: this.query
|
|
207
238
|
};
|
|
208
239
|
const result = await client.createMemberFilter(payload);
|
|
209
240
|
this._id = result.id;
|
|
@@ -219,6 +250,8 @@ var RoutineBuilder = class extends WorkspaceBuilderResource {
|
|
|
219
250
|
this.active = options.active ?? false;
|
|
220
251
|
this.description = options.description ?? "";
|
|
221
252
|
}
|
|
253
|
+
name;
|
|
254
|
+
cronSchedule;
|
|
222
255
|
active;
|
|
223
256
|
description;
|
|
224
257
|
rules = [];
|
|
@@ -280,6 +313,7 @@ var NotificationRuleBuilder = class extends WorkspaceBuilderResource {
|
|
|
280
313
|
this.notifyEmail = Boolean(options.notifyEmail ?? options.notify_email);
|
|
281
314
|
this.notifyVoice = Boolean(options.notifyVoice ?? options.notify_voice);
|
|
282
315
|
}
|
|
316
|
+
name;
|
|
283
317
|
noticeType;
|
|
284
318
|
memberId;
|
|
285
319
|
workflow;
|
|
@@ -504,6 +538,11 @@ var JourneyStepBuilder = class extends WorkspaceBuilderResource {
|
|
|
504
538
|
this.workflow = workflow;
|
|
505
539
|
this.description = description;
|
|
506
540
|
}
|
|
541
|
+
name;
|
|
542
|
+
journey;
|
|
543
|
+
order;
|
|
544
|
+
workflow;
|
|
545
|
+
description;
|
|
507
546
|
connections = [];
|
|
508
547
|
connectsTo(child, condition, required = false, timeoutSeconds) {
|
|
509
548
|
this.connections.push({ parent: this, child, condition, required, timeoutSeconds });
|
|
@@ -532,6 +571,7 @@ var JourneyBuilder = class extends WorkspaceBuilderResource {
|
|
|
532
571
|
this.name = name;
|
|
533
572
|
this.description = options.description ?? "";
|
|
534
573
|
}
|
|
574
|
+
name;
|
|
535
575
|
description;
|
|
536
576
|
steps = [];
|
|
537
577
|
goals = [];
|
|
@@ -602,6 +642,9 @@ var RoleUpdate = class extends WorkspaceBuilderResource {
|
|
|
602
642
|
this.workflowIds = workflowIds;
|
|
603
643
|
this.dataTypeIds = dataTypeIds;
|
|
604
644
|
}
|
|
645
|
+
roleId;
|
|
646
|
+
workflowIds;
|
|
647
|
+
dataTypeIds;
|
|
605
648
|
planLine() {
|
|
606
649
|
const parts = [];
|
|
607
650
|
if (this.workflowIds) parts.push(`workflows=${JSON.stringify(this.workflowIds)}`);
|
|
@@ -643,6 +686,7 @@ var AbilityDef = class {
|
|
|
643
686
|
if (inputKey in options) this.perms[outputKey] = options[inputKey];
|
|
644
687
|
}
|
|
645
688
|
}
|
|
689
|
+
abilityType;
|
|
646
690
|
uuid = crypto.randomUUID();
|
|
647
691
|
config;
|
|
648
692
|
enabled;
|
|
@@ -673,13 +717,25 @@ var TaskBuilder = class extends WorkspaceBuilderResource {
|
|
|
673
717
|
this.start = start;
|
|
674
718
|
this.description = description;
|
|
675
719
|
}
|
|
720
|
+
name;
|
|
721
|
+
workflow;
|
|
722
|
+
prompt;
|
|
723
|
+
start;
|
|
724
|
+
description;
|
|
676
725
|
transitions = [];
|
|
677
726
|
eventRules = [];
|
|
678
|
-
transitionsTo(child, when, autoNext = false, required = false) {
|
|
727
|
+
transitionsTo(child, when, autoNext = false, required = false, celCondition) {
|
|
679
728
|
if (child === this) {
|
|
680
729
|
throw new Error(`Task '${this.name}' cannot transition to itself`);
|
|
681
730
|
}
|
|
682
|
-
this.transitions.push({
|
|
731
|
+
this.transitions.push({
|
|
732
|
+
parent: this,
|
|
733
|
+
child,
|
|
734
|
+
when,
|
|
735
|
+
autoNext,
|
|
736
|
+
required,
|
|
737
|
+
celCondition
|
|
738
|
+
});
|
|
683
739
|
return this;
|
|
684
740
|
}
|
|
685
741
|
onEnter(action, params = {}, name) {
|
|
@@ -702,8 +758,13 @@ var TaskBuilder = class extends WorkspaceBuilderResource {
|
|
|
702
758
|
}
|
|
703
759
|
async apply(client) {
|
|
704
760
|
if (this._existed || this.workflow._id === void 0) return;
|
|
761
|
+
if (this.workflow._draftRevisionId === void 0) {
|
|
762
|
+
throw new Error(
|
|
763
|
+
`Workflow '${this.workflow.name}' has no draft revision id; cannot create tasks. Tasks attach to a WorkflowRevision, not the stable workflow root.`
|
|
764
|
+
);
|
|
765
|
+
}
|
|
705
766
|
const result = await client.createTask({
|
|
706
|
-
|
|
767
|
+
workflowRevisionId: this.workflow._draftRevisionId,
|
|
707
768
|
name: this.name,
|
|
708
769
|
prompt: this.prompt,
|
|
709
770
|
description: this.description
|
|
@@ -719,13 +780,18 @@ var WorkflowBuilder = class extends WorkspaceBuilderResource {
|
|
|
719
780
|
this.name = name;
|
|
720
781
|
this.description = options.description ?? "";
|
|
721
782
|
this.prompt = options.prompt;
|
|
722
|
-
this.
|
|
783
|
+
this.copyFromAgentId = options.copyFromAgentId;
|
|
723
784
|
}
|
|
785
|
+
name;
|
|
724
786
|
description;
|
|
725
787
|
prompt;
|
|
726
|
-
|
|
788
|
+
copyFromAgentId;
|
|
727
789
|
tasks = [];
|
|
728
790
|
abilities = [];
|
|
791
|
+
/** The DRAFT revision's id — where tasks and graph edits attach.
|
|
792
|
+
* `_id` is the STABLE workflow root id; the two are different entities
|
|
793
|
+
* and (after any publish) different numbers. */
|
|
794
|
+
_draftRevisionId;
|
|
729
795
|
task(name, options = {}) {
|
|
730
796
|
const task = new TaskBuilder(
|
|
731
797
|
name,
|
|
@@ -748,10 +814,14 @@ var WorkflowBuilder = class extends WorkspaceBuilderResource {
|
|
|
748
814
|
return this.name;
|
|
749
815
|
}
|
|
750
816
|
adopt(existing) {
|
|
751
|
-
|
|
817
|
+
const root = existing.workflow ?? existing;
|
|
818
|
+
super.adopt(root);
|
|
819
|
+
const draft = existing.draftRevision;
|
|
820
|
+
this._draftRevisionId = draft?.id ?? root.draftRevisionId;
|
|
752
821
|
const start = this.startTask;
|
|
753
|
-
|
|
754
|
-
|
|
822
|
+
const startTaskId = draft?.startTaskId;
|
|
823
|
+
if (start && startTaskId) {
|
|
824
|
+
start._id = startTaskId;
|
|
755
825
|
start._existed = true;
|
|
756
826
|
}
|
|
757
827
|
}
|
|
@@ -761,12 +831,6 @@ var WorkflowBuilder = class extends WorkspaceBuilderResource {
|
|
|
761
831
|
if (this.abilities.length) details.push(`${this.abilities.length} abilities`);
|
|
762
832
|
return `Workflow: ${this.name}${details.length ? ` (${details.join(", ")})` : ""}`;
|
|
763
833
|
}
|
|
764
|
-
needsDefaultAgent() {
|
|
765
|
-
return !this._existed && this.agentId === void 0;
|
|
766
|
-
}
|
|
767
|
-
setAgentId(agentId) {
|
|
768
|
-
this.agentId = agentId;
|
|
769
|
-
}
|
|
770
834
|
async apply(client) {
|
|
771
835
|
if (this._existed) return;
|
|
772
836
|
const payload = {
|
|
@@ -774,63 +838,16 @@ var WorkflowBuilder = class extends WorkspaceBuilderResource {
|
|
|
774
838
|
description: this.description,
|
|
775
839
|
createMode: "taskless",
|
|
776
840
|
...this.prompt ? { prompt: this.prompt } : {},
|
|
777
|
-
...this.
|
|
841
|
+
...this.copyFromAgentId ? { copyFromAgentId: this.copyFromAgentId } : {},
|
|
778
842
|
...this.abilities.length ? { abilities: this.abilities.map((ability) => ability.toAbility()) } : {}
|
|
779
843
|
};
|
|
780
844
|
const result = await client.createWorkflow(payload);
|
|
781
|
-
this._id = result.id;
|
|
782
|
-
this._uuid = result.uuid;
|
|
845
|
+
this._id = result.workflow.id;
|
|
846
|
+
this._uuid = result.workflow.uuid;
|
|
847
|
+
this._draftRevisionId = result.draftRevision.id;
|
|
783
848
|
this._created = true;
|
|
784
849
|
}
|
|
785
850
|
};
|
|
786
|
-
var WORKSPACE_BUILDER_DEFAULT_AGENT_NAME = "Workspace Setup Agent";
|
|
787
|
-
var WORKSPACE_BUILDER_DEFAULT_AGENT_PROMPT = "You help workspace members complete the workflow you are assigned to. Follow the task prompts, collect requested information accurately, and escalate when the workflow asks you to.";
|
|
788
|
-
async function getOrCreateDefaultWorkflowAgent(client) {
|
|
789
|
-
const existingAgents = recordsFromResponse(
|
|
790
|
-
await client.getAgents({ pageSize: 100, includeArchived: false })
|
|
791
|
-
);
|
|
792
|
-
const existing = existingAgents.find((agent) => !agent.isArchived) ?? existingAgents[0];
|
|
793
|
-
if (existing) {
|
|
794
|
-
return {
|
|
795
|
-
id: numberField(existing, "id"),
|
|
796
|
-
name: stringField(existing, "name"),
|
|
797
|
-
created: false
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
const roles = recordsFromResponse(await client.getMemberRoles());
|
|
801
|
-
const role = roles.find((candidate) => stringField(candidate, "name").toLowerCase() === "agent") ?? roles[0];
|
|
802
|
-
if (!role) {
|
|
803
|
-
throw new Error("Cannot create default workflow agent: workspace has no member roles");
|
|
804
|
-
}
|
|
805
|
-
const payload = {
|
|
806
|
-
name: WORKSPACE_BUILDER_DEFAULT_AGENT_NAME,
|
|
807
|
-
memberRoleId: numberField(role, "id"),
|
|
808
|
-
chatModelId: DEFAULT_CHAT_MODEL,
|
|
809
|
-
systemPrompt: WORKSPACE_BUILDER_DEFAULT_AGENT_PROMPT
|
|
810
|
-
};
|
|
811
|
-
const created = await client.createAgent(payload);
|
|
812
|
-
return {
|
|
813
|
-
id: created.id,
|
|
814
|
-
name: created.name ?? WORKSPACE_BUILDER_DEFAULT_AGENT_NAME,
|
|
815
|
-
created: true
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
function recordsFromResponse(value) {
|
|
819
|
-
if (Array.isArray(value)) return value;
|
|
820
|
-
if (value && typeof value === "object" && Array.isArray(value.items)) {
|
|
821
|
-
return value.items;
|
|
822
|
-
}
|
|
823
|
-
return [];
|
|
824
|
-
}
|
|
825
|
-
function numberField(record, key) {
|
|
826
|
-
const value = record[key];
|
|
827
|
-
if (typeof value !== "number") throw new Error(`Expected numeric ${key}`);
|
|
828
|
-
return value;
|
|
829
|
-
}
|
|
830
|
-
function stringField(record, key) {
|
|
831
|
-
const value = record[key];
|
|
832
|
-
return typeof value === "string" ? value : "";
|
|
833
|
-
}
|
|
834
851
|
var AgentBuilder = class extends WorkspaceBuilderResource {
|
|
835
852
|
constructor(name, options = {}) {
|
|
836
853
|
super();
|
|
@@ -841,6 +858,7 @@ var AgentBuilder = class extends WorkspaceBuilderResource {
|
|
|
841
858
|
this.tools = options.tools ?? [];
|
|
842
859
|
this.codeInterpreterEnabled = options.codeInterpreterEnabled ?? options.code_interpreter_enabled ?? false;
|
|
843
860
|
}
|
|
861
|
+
name;
|
|
844
862
|
chatModelId;
|
|
845
863
|
systemPrompt;
|
|
846
864
|
memberRoleId;
|
|
@@ -892,6 +910,7 @@ var WorkspaceBuilder = class {
|
|
|
892
910
|
constructor(client) {
|
|
893
911
|
this.client = client;
|
|
894
912
|
}
|
|
913
|
+
client;
|
|
895
914
|
resources = [];
|
|
896
915
|
form(name, options = {}) {
|
|
897
916
|
const form = new FormBuilder(name, options.slug, options);
|
|
@@ -995,7 +1014,6 @@ ${"=".repeat(50)}`);
|
|
|
995
1014
|
await this.resolveExisting(resources);
|
|
996
1015
|
const summary = {};
|
|
997
1016
|
writeLine("Applying...");
|
|
998
|
-
await this.ensureWorkflowAgents(resources, summary);
|
|
999
1017
|
for (const resource of resources) {
|
|
1000
1018
|
try {
|
|
1001
1019
|
if (resource._existed) {
|
|
@@ -1016,7 +1034,7 @@ ${"=".repeat(50)}`);
|
|
|
1016
1034
|
writeLine(` Skipped: ${resource.planLine()}`);
|
|
1017
1035
|
}
|
|
1018
1036
|
} catch (err) {
|
|
1019
|
-
writeLine(
|
|
1037
|
+
writeLine(formatApplyFailureLine(resource, err));
|
|
1020
1038
|
throw new ApplyError(resource, err, summary);
|
|
1021
1039
|
}
|
|
1022
1040
|
}
|
|
@@ -1056,9 +1074,11 @@ Done! Created ${count} resources.`);
|
|
|
1056
1074
|
}
|
|
1057
1075
|
}
|
|
1058
1076
|
if (!workflowNames.size) return;
|
|
1059
|
-
|
|
1077
|
+
const existingWorkflows = await this.client.getWorkflows();
|
|
1078
|
+
for (const { workflow: existing } of existingWorkflows.items) {
|
|
1060
1079
|
if (existing.name && workflowNames.has(existing.name)) {
|
|
1061
|
-
|
|
1080
|
+
const detail = await this.client.getWorkflow(existing.id);
|
|
1081
|
+
workflowNames.get(existing.name).adopt(detail);
|
|
1062
1082
|
}
|
|
1063
1083
|
}
|
|
1064
1084
|
const adoptedWorkflows = resources.filter(
|
|
@@ -1067,7 +1087,9 @@ Done! Created ${count} resources.`);
|
|
|
1067
1087
|
if (!adoptedWorkflows.length) return;
|
|
1068
1088
|
const existingTasks = await this.client.getTasks();
|
|
1069
1089
|
for (const workflow of adoptedWorkflows) {
|
|
1070
|
-
const workflowTasks = existingTasks.filter(
|
|
1090
|
+
const workflowTasks = existingTasks.filter(
|
|
1091
|
+
(task) => (task.workflowRevisionId ?? task.workflowId) === workflow._draftRevisionId
|
|
1092
|
+
);
|
|
1071
1093
|
const taskByName = new Map(workflowTasks.map((task) => [task.name, task]));
|
|
1072
1094
|
for (const taskBuilder of workflow.tasks) {
|
|
1073
1095
|
const match = taskByName.get(taskBuilder.name);
|
|
@@ -1089,21 +1111,6 @@ Done! Created ${count} resources.`);
|
|
|
1089
1111
|
}
|
|
1090
1112
|
}
|
|
1091
1113
|
}
|
|
1092
|
-
async ensureWorkflowAgents(resources, summary) {
|
|
1093
|
-
const workflows = resources.filter(
|
|
1094
|
-
(resource) => resource instanceof WorkflowBuilder && resource.needsDefaultAgent()
|
|
1095
|
-
);
|
|
1096
|
-
if (!workflows.length) return;
|
|
1097
|
-
const agent = await getOrCreateDefaultWorkflowAgent(this.client);
|
|
1098
|
-
for (const workflow of workflows) workflow.setAgentId(agent.id);
|
|
1099
|
-
if (agent.created) {
|
|
1100
|
-
summary.agents ??= [];
|
|
1101
|
-
summary.agents.push(agent.id);
|
|
1102
|
-
writeLine(` Created Agent: ${agent.name} -> id=${agent.id}`);
|
|
1103
|
-
} else {
|
|
1104
|
-
writeLine(` Using Agent: ${agent.name || agent.id} -> id=${agent.id}`);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
1114
|
sortedResources() {
|
|
1108
1115
|
const all = [];
|
|
1109
1116
|
for (const resource of this.resources) {
|
|
@@ -1167,7 +1174,7 @@ Done! Created ${count} resources.`);
|
|
|
1167
1174
|
{
|
|
1168
1175
|
taskId,
|
|
1169
1176
|
choicePrompt: transition.when,
|
|
1170
|
-
celCondition: null,
|
|
1177
|
+
celCondition: transition.celCondition ?? null,
|
|
1171
1178
|
autoNext: transition.autoNext,
|
|
1172
1179
|
required: transition.required
|
|
1173
1180
|
}
|
|
@@ -1273,16 +1280,21 @@ Done! Created ${count} resources.`);
|
|
|
1273
1280
|
}
|
|
1274
1281
|
};
|
|
1275
1282
|
var ApplyError = class extends Error {
|
|
1283
|
+
createdSoFar;
|
|
1284
|
+
#resource;
|
|
1285
|
+
#cause;
|
|
1276
1286
|
constructor(resource, cause, createdSoFar) {
|
|
1277
|
-
super(
|
|
1278
|
-
|
|
1279
|
-
Already created: ${JSON.stringify(
|
|
1280
|
-
createdSoFar
|
|
1281
|
-
)}`
|
|
1282
|
-
);
|
|
1283
|
-
this.resource = resource;
|
|
1284
|
-
this.cause = cause;
|
|
1287
|
+
super(formatApplyErrorMessage(resource, cause, createdSoFar));
|
|
1288
|
+
this.name = "ApplyError";
|
|
1285
1289
|
this.createdSoFar = createdSoFar;
|
|
1290
|
+
this.#resource = resource;
|
|
1291
|
+
this.#cause = cause;
|
|
1292
|
+
}
|
|
1293
|
+
get resource() {
|
|
1294
|
+
return this.#resource;
|
|
1295
|
+
}
|
|
1296
|
+
get cause() {
|
|
1297
|
+
return this.#cause;
|
|
1286
1298
|
}
|
|
1287
1299
|
};
|
|
1288
1300
|
function resourceKey(resource) {
|
|
@@ -1303,7 +1315,7 @@ var SEARCHABLE_EVENT_RULE_SOURCE_FIELDS = [
|
|
|
1303
1315
|
"taskId",
|
|
1304
1316
|
"dataTypeId",
|
|
1305
1317
|
"routineId",
|
|
1306
|
-
"
|
|
1318
|
+
"workflowRevisionId",
|
|
1307
1319
|
"journeyStepId"
|
|
1308
1320
|
];
|
|
1309
1321
|
var EVENT_RULE_SOURCE_FIELDS = [
|
|
@@ -1393,8 +1405,64 @@ function handleEventRuleApplyFailure(resourceName, err) {
|
|
|
1393
1405
|
writeLine(` FAILED: Event rule on '${resourceName}': ${summary}`);
|
|
1394
1406
|
throw new Error(`Failed wiring event rule on '${resourceName}': ${summary}`);
|
|
1395
1407
|
}
|
|
1408
|
+
function writeScopeForResource(resource) {
|
|
1409
|
+
if (resource instanceof FormBuilder) return "datatypes:write";
|
|
1410
|
+
if (resource instanceof WorkflowBuilder || resource instanceof TaskBuilder) {
|
|
1411
|
+
return "workflows:write";
|
|
1412
|
+
}
|
|
1413
|
+
if (resource instanceof AgentBuilder) return "agents:write";
|
|
1414
|
+
if (resource instanceof MemberLabelBuilder || resource instanceof MemberFilterBuilder) {
|
|
1415
|
+
return "members:write";
|
|
1416
|
+
}
|
|
1417
|
+
if (resource instanceof RoutineBuilder || resource instanceof NotificationRuleBuilder) {
|
|
1418
|
+
return "automations:admin";
|
|
1419
|
+
}
|
|
1420
|
+
if (resource instanceof JourneyBuilder || resource instanceof JourneyStepBuilder) {
|
|
1421
|
+
return "journeys:write";
|
|
1422
|
+
}
|
|
1423
|
+
if (resource instanceof RoleUpdate) return "member_roles:write";
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
function scopeRetryHint(resource) {
|
|
1427
|
+
const scope = writeScopeForResource(resource);
|
|
1428
|
+
return scope ? ` (retry exec with scopes=['${scope}'])` : "";
|
|
1429
|
+
}
|
|
1430
|
+
function formatApplyFailureLine(resource, err) {
|
|
1431
|
+
const line = ` FAILED: ${resource.planLine()}: ${summarizeError(err)}`;
|
|
1432
|
+
return hasStatus(err, 403) ? `${line}${scopeRetryHint(resource)}` : line;
|
|
1433
|
+
}
|
|
1434
|
+
function formatApplyErrorMessage(resource, cause, createdSoFar) {
|
|
1435
|
+
let message = `Failed creating ${resource.planLine()}: ${summarizeError(cause)}`;
|
|
1436
|
+
if (hasStatus(cause, 403)) {
|
|
1437
|
+
const scope = writeScopeForResource(resource);
|
|
1438
|
+
if (scope) {
|
|
1439
|
+
message += `
|
|
1440
|
+
Retry exec with scopes=['${scope}']`;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
const createdKeys = Object.keys(createdSoFar);
|
|
1444
|
+
if (createdKeys.length > 0) {
|
|
1445
|
+
message += `
|
|
1446
|
+
Already created: ${JSON.stringify(createdSoFar)}`;
|
|
1447
|
+
}
|
|
1448
|
+
return message;
|
|
1449
|
+
}
|
|
1396
1450
|
function summarizeError(err) {
|
|
1397
|
-
if (err
|
|
1451
|
+
if (hasStatus(err, 403)) {
|
|
1452
|
+
return "Insufficient permissions for this operation";
|
|
1453
|
+
}
|
|
1454
|
+
if (err instanceof ApiError) {
|
|
1455
|
+
const msg = err.message.trim();
|
|
1456
|
+
const availableTypesIdx = msg.indexOf("Available types:");
|
|
1457
|
+
if (availableTypesIdx !== -1) {
|
|
1458
|
+
const head = msg.slice(0, availableTypesIdx).trim().replace(/\.$/, "");
|
|
1459
|
+
return head ? `${head}.` : "Request failed";
|
|
1460
|
+
}
|
|
1461
|
+
return msg.length > 240 ? `${msg.slice(0, 237)}...` : msg;
|
|
1462
|
+
}
|
|
1463
|
+
if (err instanceof Error) {
|
|
1464
|
+
return err.name || "Error";
|
|
1465
|
+
}
|
|
1398
1466
|
return typeof err;
|
|
1399
1467
|
}
|
|
1400
1468
|
function hasStatus(err, status) {
|
|
@@ -1440,6 +1508,7 @@ export {
|
|
|
1440
1508
|
CalendarScheduleAvailabilityType,
|
|
1441
1509
|
CalendarScheduleRecurrence,
|
|
1442
1510
|
CalendarSource,
|
|
1511
|
+
CapabilityClass,
|
|
1443
1512
|
ConsentMethod,
|
|
1444
1513
|
CriterionType,
|
|
1445
1514
|
DEFAULT_CHAT_MODEL,
|
|
@@ -1448,6 +1517,7 @@ export {
|
|
|
1448
1517
|
DEFAULT_VOICE_INFERENCE_MODEL,
|
|
1449
1518
|
DataCategory,
|
|
1450
1519
|
DataFieldType,
|
|
1520
|
+
DataRecordRetirementResponseReason,
|
|
1451
1521
|
DataSensitivity,
|
|
1452
1522
|
DataTypeRecordScope,
|
|
1453
1523
|
DriverMode,
|
|
@@ -1471,6 +1541,9 @@ export {
|
|
|
1471
1541
|
McpServerState,
|
|
1472
1542
|
MemberFeature,
|
|
1473
1543
|
MemberFilterBuilder,
|
|
1544
|
+
MemberImportMatchInfoMatchType,
|
|
1545
|
+
MemberImportPreviewRowAction,
|
|
1546
|
+
MemberImportValidationError,
|
|
1474
1547
|
MemberLabelBuilder,
|
|
1475
1548
|
MemberType,
|
|
1476
1549
|
MenuItemResponseItemType,
|
|
@@ -1493,7 +1566,12 @@ export {
|
|
|
1493
1566
|
PERMISSION_NONE,
|
|
1494
1567
|
PERMISSION_USE,
|
|
1495
1568
|
PERMISSION_VERIFY,
|
|
1569
|
+
PIDS_DISPOSITIONS,
|
|
1570
|
+
PIDS_SOURCES,
|
|
1571
|
+
POSITIVE_RATING_THRESHOLD,
|
|
1496
1572
|
ProductType,
|
|
1573
|
+
QUERY_VALUELESS_OPS,
|
|
1574
|
+
QueriesApi,
|
|
1497
1575
|
REALTIME_MODEL_CUSTOM,
|
|
1498
1576
|
REALTIME_MODEL_GEMINI,
|
|
1499
1577
|
REALTIME_MODEL_GEMINI_VERTEX,
|
|
@@ -1523,11 +1601,11 @@ export {
|
|
|
1523
1601
|
TTS_MODEL_ELEVENLABS_FLASH,
|
|
1524
1602
|
TTS_MODEL_ELEVENLABS_MULTILINGUAL,
|
|
1525
1603
|
TTS_MODEL_ELEVENLABS_TURBO,
|
|
1526
|
-
TTS_MODEL_POCKET,
|
|
1527
1604
|
TTS_PREVIEW_PROVIDERS,
|
|
1528
1605
|
TaskBuilder,
|
|
1529
1606
|
TemplatesApi,
|
|
1530
1607
|
ToolkitState,
|
|
1608
|
+
WIDGET_SLUGS,
|
|
1531
1609
|
WorkflowAccessWarningResourceType,
|
|
1532
1610
|
WorkflowBuilder,
|
|
1533
1611
|
WorkflowAccessWarningResourceType as WorkflowResourceType,
|
|
@@ -1553,12 +1631,14 @@ export {
|
|
|
1553
1631
|
getFeaturesByVisibility,
|
|
1554
1632
|
getMissingDependencies,
|
|
1555
1633
|
getResourceMetadata,
|
|
1634
|
+
getRevisionState,
|
|
1556
1635
|
getScopeFromProductType,
|
|
1557
1636
|
getTTSProvider,
|
|
1558
1637
|
getVoiceModelId,
|
|
1559
1638
|
initializeFeatures,
|
|
1560
1639
|
isChatType,
|
|
1561
1640
|
isFeatureAvailable,
|
|
1641
|
+
isPositiveRating,
|
|
1562
1642
|
isRegistryInitialized,
|
|
1563
1643
|
isSMSDeliveryFailureStatus,
|
|
1564
1644
|
requiresAssistantParticipant,
|