@gravity-rail/sdk 0.18.1 → 0.21.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/dist/{chunk-PUIYXJSZ.js → chunk-24L4RD4Z.js} +479 -39
- package/dist/chunk-24L4RD4Z.js.map +1 -0
- package/dist/{chunk-2YLKG4TT.js → chunk-3HAV5XUJ.js} +1 -1
- package/dist/chunk-3HAV5XUJ.js.map +1 -0
- package/dist/{chunk-PJFEGUHM.js → chunk-7OLBLLV7.js} +6 -2
- package/dist/{chunk-PJFEGUHM.js.map → chunk-7OLBLLV7.js.map} +1 -1
- package/dist/{client-B-jmQ4UA.d.cts → client-B0eh2BEY.d.cts} +1315 -285
- package/dist/{client-CatNn6FD.d.ts → client-CFz-BGmY.d.ts} +1315 -285
- package/dist/helpers.cjs +141 -0
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +17 -3
- package/dist/helpers.d.ts +17 -3
- package/dist/helpers.js +127 -1
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +578 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -5
- package/dist/index.d.ts +28 -5
- package/dist/index.js +123 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +485 -39
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +630 -551
- package/dist/internal.d.ts +630 -551
- package/dist/internal.js +9 -5
- package/dist/internal.js.map +1 -1
- package/dist/{revision-state-Fw1jsQOa.d.ts → revision-state-KfOztBkY.d.ts} +53 -172
- package/dist/{revision-state-CuESPYpi.d.cts → revision-state-fJ9PM15N.d.cts} +53 -172
- package/dist/schemas.cjs +31 -5
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +37 -14
- package/dist/schemas.d.ts +37 -14
- package/dist/schemas.js +31 -6
- package/dist/schemas.js.map +1 -1
- package/dist/{tasks-GVbVa_Lj.d.cts → tasks-WH_VfzMv.d.cts} +351 -16
- package/dist/{tasks-GVbVa_Lj.d.ts → tasks-WH_VfzMv.d.ts} +351 -16
- package/package.json +6 -6
- package/dist/chunk-2YLKG4TT.js.map +0 -1
- package/dist/chunk-PUIYXJSZ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -72,7 +72,6 @@ import {
|
|
|
72
72
|
REALTIME_MODEL_CUSTOM,
|
|
73
73
|
REALTIME_MODEL_GEMINI,
|
|
74
74
|
REALTIME_MODEL_GEMINI_VERTEX,
|
|
75
|
-
REALTIME_MODEL_NOVA_SONIC,
|
|
76
75
|
REALTIME_MODEL_OPENAI,
|
|
77
76
|
REALTIME_MODEL_OPENAI_2,
|
|
78
77
|
REALTIME_MODEL_OPENAI_MINI,
|
|
@@ -143,7 +142,7 @@ import {
|
|
|
143
142
|
roleWorkflowAccess,
|
|
144
143
|
usesBuiltinAssistant,
|
|
145
144
|
validateFeatureDependencies
|
|
146
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-24L4RD4Z.js";
|
|
147
146
|
import {
|
|
148
147
|
AttendeeResponseStatus,
|
|
149
148
|
AttendeeStatus,
|
|
@@ -158,13 +157,13 @@ import {
|
|
|
158
157
|
DataSensitivity,
|
|
159
158
|
DataTypeRecordScope,
|
|
160
159
|
IndexStatus
|
|
161
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-3HAV5XUJ.js";
|
|
162
161
|
import {
|
|
163
162
|
ApiError,
|
|
164
163
|
BaseApiClient,
|
|
165
164
|
getCookieValue,
|
|
166
165
|
parseOrgAuthChallenge
|
|
167
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-7OLBLLV7.js";
|
|
168
167
|
|
|
169
168
|
// src/workspace-builder/resource.ts
|
|
170
169
|
function isRecord(value) {
|
|
@@ -315,6 +314,7 @@ var RoutineBuilder = class extends WorkspaceBuilderResource {
|
|
|
315
314
|
return `Routine: ${this.name} (${parts.join(", ")})`;
|
|
316
315
|
}
|
|
317
316
|
async apply(client) {
|
|
317
|
+
if (this._existed) return;
|
|
318
318
|
const eventRules = this.rules.map((rule) => {
|
|
319
319
|
const actionParams = { ...rule.actionParams };
|
|
320
320
|
if (rule.workflow?._id !== void 0) actionParams.workflowId = rule.workflow._id;
|
|
@@ -370,6 +370,7 @@ var NotificationRuleBuilder = class extends WorkspaceBuilderResource {
|
|
|
370
370
|
return `NotificationRule: ${this.name}${parts.length ? ` (${parts.join(", ")})` : ""}`;
|
|
371
371
|
}
|
|
372
372
|
async apply(client) {
|
|
373
|
+
if (this._existed) return;
|
|
373
374
|
if (this.memberId === void 0) {
|
|
374
375
|
throw new Error(`Notification rule '${this.name}' requires memberId`);
|
|
375
376
|
}
|
|
@@ -904,6 +905,7 @@ var RoleUpdate = class extends WorkspaceBuilderResource {
|
|
|
904
905
|
return `RoleUpdate: roleId=${this.roleId}${parts.length ? ` (${parts.join(", ")})` : ""}`;
|
|
905
906
|
}
|
|
906
907
|
async apply(client) {
|
|
908
|
+
if (this._existed) return;
|
|
907
909
|
const payload = {};
|
|
908
910
|
if (this.workflowIds) payload.workflowIds = this.workflowIds;
|
|
909
911
|
if (this.dataTypeIds) payload.dataTypeIds = this.dataTypeIds;
|
|
@@ -1133,6 +1135,7 @@ var AgentBuilder = class extends WorkspaceBuilderResource {
|
|
|
1133
1135
|
return `Agent: ${this.name}${parts.length ? ` (${parts.join(", ")})` : ""}`;
|
|
1134
1136
|
}
|
|
1135
1137
|
async apply(client) {
|
|
1138
|
+
if (this._existed) return;
|
|
1136
1139
|
if (this.memberRoleId === void 0) {
|
|
1137
1140
|
throw new Error(`Agent '${this.name}' requires memberRoleId`);
|
|
1138
1141
|
}
|
|
@@ -1168,6 +1171,25 @@ var PHASES = /* @__PURE__ */ new Map([
|
|
|
1168
1171
|
[JourneyBuilder, 7],
|
|
1169
1172
|
[JourneyStepBuilder, 8]
|
|
1170
1173
|
]);
|
|
1174
|
+
var LIST_PAGE_SIZE = 100;
|
|
1175
|
+
async function collectPages(fetchPage) {
|
|
1176
|
+
const first = await fetchPage(1);
|
|
1177
|
+
const all = [...first.items];
|
|
1178
|
+
const totalPages = first.totalPages ?? 1;
|
|
1179
|
+
for (let page = 2; page <= totalPages; page++) {
|
|
1180
|
+
const next = await fetchPage(page);
|
|
1181
|
+
if (!next.items.length) break;
|
|
1182
|
+
all.push(...next.items);
|
|
1183
|
+
}
|
|
1184
|
+
return all;
|
|
1185
|
+
}
|
|
1186
|
+
function sameIdSet(left, right) {
|
|
1187
|
+
const target = new Set(right);
|
|
1188
|
+
return target.size === new Set(left).size && left.every((id) => target.has(id));
|
|
1189
|
+
}
|
|
1190
|
+
function notificationRuleKey(noticeType, memberId, workflowId) {
|
|
1191
|
+
return JSON.stringify([noticeType, memberId, workflowId]);
|
|
1192
|
+
}
|
|
1171
1193
|
function phaseFor(resource) {
|
|
1172
1194
|
let ctor = resource.constructor;
|
|
1173
1195
|
while (ctor) {
|
|
@@ -1430,6 +1452,103 @@ Done! Created ${count} resources.`);
|
|
|
1430
1452
|
journeyNames.get(existing.name).adopt(detail);
|
|
1431
1453
|
}
|
|
1432
1454
|
}
|
|
1455
|
+
const agentNames = new Map(
|
|
1456
|
+
resources.filter((resource) => resource instanceof AgentBuilder).map((resource) => [resource.name, resource])
|
|
1457
|
+
);
|
|
1458
|
+
if (agentNames.size) {
|
|
1459
|
+
for (const existing of await collectPages(
|
|
1460
|
+
(page) => this.client.getAgents({ page, pageSize: LIST_PAGE_SIZE })
|
|
1461
|
+
)) {
|
|
1462
|
+
if (existing.name && agentNames.has(existing.name)) {
|
|
1463
|
+
agentNames.get(existing.name).adopt(existing);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
const routineNames = new Map(
|
|
1468
|
+
resources.filter((resource) => resource instanceof RoutineBuilder).map((resource) => [resource.name, resource])
|
|
1469
|
+
);
|
|
1470
|
+
if (routineNames.size) {
|
|
1471
|
+
for (const existing of await collectPages(
|
|
1472
|
+
(page) => this.client.getRoutines({ page, pageSize: LIST_PAGE_SIZE })
|
|
1473
|
+
)) {
|
|
1474
|
+
if (existing.name && routineNames.has(existing.name)) {
|
|
1475
|
+
routineNames.get(existing.name).adopt(existing);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
await this.resolveExistingRoleUpdates(resources);
|
|
1480
|
+
await this.resolveExistingWorkflows(resources, workflowNames);
|
|
1481
|
+
await this.resolveExistingNotificationRules(resources);
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Adopt a role update whose grants the server already has.
|
|
1485
|
+
*
|
|
1486
|
+
* A role update is a replace-semantics PUT, not a create, so its identity is
|
|
1487
|
+
* the role id and "already applied" means the id sets match exactly. Subset
|
|
1488
|
+
* would be wrong: `roleUpdate(7, [])` asks to *clear* the role's workflow
|
|
1489
|
+
* access, and treating that as satisfied by a role that still has grants
|
|
1490
|
+
* would silently skip a real change.
|
|
1491
|
+
*
|
|
1492
|
+
* Only the fields this update declares are compared — an update that passes
|
|
1493
|
+
* `workflowIds` and omits `dataTypeIds` never touches data-type access, so
|
|
1494
|
+
* that access cannot make it stale.
|
|
1495
|
+
*/
|
|
1496
|
+
async resolveExistingRoleUpdates(resources) {
|
|
1497
|
+
const updates = resources.filter(
|
|
1498
|
+
(resource) => resource instanceof RoleUpdate
|
|
1499
|
+
);
|
|
1500
|
+
if (!updates.length) return;
|
|
1501
|
+
const rolesById = new Map(
|
|
1502
|
+
(await this.client.getMemberRoles()).map((role) => [role.id, role])
|
|
1503
|
+
);
|
|
1504
|
+
for (const update of updates) {
|
|
1505
|
+
const role = rolesById.get(update.roleId);
|
|
1506
|
+
if (!role) continue;
|
|
1507
|
+
const workflowsSettled = update.workflowIds === void 0 || sameIdSet(
|
|
1508
|
+
update.workflowIds,
|
|
1509
|
+
(role.workflowAccess ?? []).map((access) => access.workflowId)
|
|
1510
|
+
);
|
|
1511
|
+
const dataTypesSettled = update.dataTypeIds === void 0 || sameIdSet(
|
|
1512
|
+
update.dataTypeIds,
|
|
1513
|
+
(role.dataTypeAccess ?? []).map((access) => access.dataTypeId)
|
|
1514
|
+
);
|
|
1515
|
+
if (workflowsSettled && dataTypesSettled) update.adopt(role);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Adopt notification rules the server already has.
|
|
1520
|
+
*
|
|
1521
|
+
* There is no name on the server row — `NotificationRule` is keyed by what
|
|
1522
|
+
* it does — so identity is the composite the API enforces uniqueness on in
|
|
1523
|
+
* practice: notice type, recipient, and subject workflow.
|
|
1524
|
+
*/
|
|
1525
|
+
async resolveExistingNotificationRules(resources) {
|
|
1526
|
+
const rules = resources.filter(
|
|
1527
|
+
(resource) => resource instanceof NotificationRuleBuilder
|
|
1528
|
+
);
|
|
1529
|
+
if (!rules.length) return;
|
|
1530
|
+
const identified = rules.flatMap((rule) => {
|
|
1531
|
+
if (rule.memberId === void 0) return [];
|
|
1532
|
+
if (rule.workflow && rule.workflow._id === void 0) return [];
|
|
1533
|
+
return [
|
|
1534
|
+
[
|
|
1535
|
+
notificationRuleKey(rule.noticeType, rule.memberId, rule.workflow?._id ?? null),
|
|
1536
|
+
rule
|
|
1537
|
+
]
|
|
1538
|
+
];
|
|
1539
|
+
});
|
|
1540
|
+
if (!identified.length) return;
|
|
1541
|
+
const byKey = new Map(identified);
|
|
1542
|
+
for (const existing of await this.client.getNotificationRules()) {
|
|
1543
|
+
const key = notificationRuleKey(
|
|
1544
|
+
existing.noticeType,
|
|
1545
|
+
existing.memberId,
|
|
1546
|
+
existing.workflowId ?? null
|
|
1547
|
+
);
|
|
1548
|
+
byKey.get(key)?.adopt(existing);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
async resolveExistingWorkflows(resources, workflowNames) {
|
|
1433
1552
|
if (!workflowNames.size) return;
|
|
1434
1553
|
const existingWorkflows = await this.client.getWorkflows();
|
|
1435
1554
|
for (const { workflow: existing } of existingWorkflows.items) {
|
|
@@ -1949,7 +2068,6 @@ export {
|
|
|
1949
2068
|
REALTIME_MODEL_CUSTOM,
|
|
1950
2069
|
REALTIME_MODEL_GEMINI,
|
|
1951
2070
|
REALTIME_MODEL_GEMINI_VERTEX,
|
|
1952
|
-
REALTIME_MODEL_NOVA_SONIC,
|
|
1953
2071
|
REALTIME_MODEL_OPENAI,
|
|
1954
2072
|
REALTIME_MODEL_OPENAI_2,
|
|
1955
2073
|
REALTIME_MODEL_OPENAI_MINI,
|