@ptkl/sdk 1.13.0 → 1.15.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.
@@ -99,6 +99,9 @@ class PlatformBaseClient extends BaseClient {
99
99
  this.env = null;
100
100
  this.token = null;
101
101
  this.host = null;
102
+ this.env = env;
103
+ this.token = token;
104
+ this.host = host;
102
105
  }
103
106
  }
104
107
 
@@ -116,6 +119,7 @@ class Component extends PlatformBaseClient {
116
119
  if (opts && opts.stream === true) {
117
120
  let onMetaCallback = () => { };
118
121
  let onDataCallback = () => { };
122
+ let onCursorCallback = () => { };
119
123
  let onErrorCallback;
120
124
  let onEndCallback;
121
125
  let isFirstLine = true;
@@ -128,6 +132,10 @@ class Component extends PlatformBaseClient {
128
132
  onDataCallback = callback;
129
133
  return chainable;
130
134
  },
135
+ onCursor: (callback) => {
136
+ onCursorCallback = callback;
137
+ return chainable;
138
+ },
131
139
  onError: (callback) => {
132
140
  onErrorCallback = callback;
133
141
  return chainable;
@@ -146,6 +154,11 @@ class Component extends PlatformBaseClient {
146
154
  if (result instanceof Promise)
147
155
  await result;
148
156
  }
157
+ else if ('next_cursor' in doc && !('uuid' in doc)) {
158
+ const result = onCursorCallback(doc);
159
+ if (result instanceof Promise)
160
+ await result;
161
+ }
149
162
  else {
150
163
  const result = onDataCallback(doc);
151
164
  if (result instanceof Promise)
@@ -216,6 +229,8 @@ class Component extends PlatformBaseClient {
216
229
  };
217
230
  if (ctx.only && ctx.only.length > 0)
218
231
  params.only = ctx.only;
232
+ if (ctx.cursor)
233
+ params.cursor = ctx.cursor;
219
234
  if (Object.keys(ctx.$adv || {}).length > 0)
220
235
  params.$adv = [(_b = ctx.$adv) !== null && _b !== void 0 ? _b : {}];
221
236
  if (ctx.$aggregate && ctx.$aggregate.length > 0)
@@ -882,11 +897,32 @@ class Users extends PlatformBaseClient {
882
897
  }
883
898
  // Permissions & Roles
884
899
  /**
885
- * Get user permissions
900
+ * Get the current token's permissions.
901
+ *
902
+ * Returns the resolved permission set carried by the calling token. For a
903
+ * forge actor token this is the scoped intersection minted at launch time —
904
+ * see `getPrincipalPermissions()` for the underlying user's full set.
886
905
  */
887
906
  async getPermissions() {
888
907
  return await this.client.get("/v1/user/role/permissions");
889
908
  }
909
+ /**
910
+ * Get the FULL permissions of the user the current token is acting on behalf
911
+ * of (the "principal").
912
+ *
913
+ * When a forge app runs under an actor token, `getPermissions()` returns only
914
+ * the token's scoped permissions — the intersection of the app's declared
915
+ * runtime permissions and the user's permissions. This instead returns the
916
+ * complete permission set of the underlying user, so the app can check what
917
+ * that user is actually allowed to do, independent of what the app itself was
918
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
919
+ *
920
+ * For a normal user session (no actor token) it returns the caller's own
921
+ * permissions, identical to `getPermissions()`'s scope.
922
+ */
923
+ async getPrincipalPermissions() {
924
+ return await this.client.get("/v1/user/role/principal-permissions");
925
+ }
890
926
  /**
891
927
  * Get list of available permissions
892
928
  */
@@ -971,7 +1007,7 @@ class ComponentUtils extends PlatformBaseClient {
971
1007
  * @returns Promise resolving to the created/updated component
972
1008
  */
973
1009
  async setup(data) {
974
- return await this.client.post("/v3/system/component/setup", data);
1010
+ return await this.client.post("/v4/system/component/setup", data);
975
1011
  }
976
1012
  }
977
1013
 
@@ -1227,9 +1263,22 @@ class Ratchet extends PlatformBaseClient {
1227
1263
  }
1228
1264
  }
1229
1265
 
1266
+ /**
1267
+ * Sandbox client — spark (FaaS) functions/apps, long-running runtimes, and
1268
+ * their K8s deployments. All routes go through the `sandbox/…` gateway
1269
+ * prefix (`/luma/sandbox/v1/...`), matching the sandbox service's REST
1270
+ * surface (`internal/controllers/{spark.go,spark.v1.go,runtime.v1.go}` and
1271
+ * the deployment lifecycle in `internal/controllers/ecomm/deployment.go`).
1272
+ */
1230
1273
  class Sandbox extends PlatformBaseClient {
1274
+ // ---------------------------------------------------------------
1275
+ // Spark (FaaS functions / apps)
1276
+ // ---------------------------------------------------------------
1231
1277
  /**
1232
- * Call the sandbox service to execute a serverless function
1278
+ * Call the sandbox service to execute a serverless function.
1279
+ *
1280
+ * Kept for backwards compatibility — equivalent to
1281
+ * `execSpark(name, data)`.
1233
1282
  *
1234
1283
  * @param name
1235
1284
  * @param data
@@ -1241,6 +1290,143 @@ class Sandbox extends PlatformBaseClient {
1241
1290
  async spark(name, data) {
1242
1291
  return await this.client.post(`/luma/sandbox/v1/spark/exec/${name}`, data);
1243
1292
  }
1293
+ /**
1294
+ * Create a new spark (function or app).
1295
+ *
1296
+ * @example
1297
+ * const spark = await platform.sandbox().createSpark({ name: "myFunction", runtime: "node20", memory: 256 })
1298
+ */
1299
+ async createSpark(payload) {
1300
+ return await this.client.post(`/luma/sandbox/v1/spark`, payload);
1301
+ }
1302
+ /**
1303
+ * Get a spark by uuid.
1304
+ */
1305
+ async getSpark(uuid) {
1306
+ return await this.client.get(`/luma/sandbox/v1/spark/${uuid}`);
1307
+ }
1308
+ /**
1309
+ * Update a spark's memory/settings/env vars.
1310
+ */
1311
+ async updateSpark(uuid, payload) {
1312
+ return await this.client.patch(`/luma/sandbox/v1/spark/${uuid}`, payload);
1313
+ }
1314
+ /**
1315
+ * Delete a spark.
1316
+ */
1317
+ async deleteSpark(uuid) {
1318
+ return await this.client.delete(`/luma/sandbox/v1/spark/${uuid}`);
1319
+ }
1320
+ /**
1321
+ * List all sparks for the current project.
1322
+ */
1323
+ async listSparks() {
1324
+ return await this.client.get(`/luma/sandbox/v1/spark`);
1325
+ }
1326
+ /**
1327
+ * Deploy a specific spark version to the dev environment.
1328
+ */
1329
+ async deploySpark(uuid, version) {
1330
+ return await this.client.put(`/luma/sandbox/v1/spark/deploy/${uuid}/${version}`);
1331
+ }
1332
+ /**
1333
+ * Cancel an in-progress spark deployment.
1334
+ *
1335
+ * @param uuid
1336
+ * @param env - defaults to "dev" on the server if omitted
1337
+ */
1338
+ async cancelSpark(uuid, env) {
1339
+ return await this.client.put(`/luma/sandbox/v1/spark/cancel/${uuid}`, undefined, { params: env ? { env } : undefined });
1340
+ }
1341
+ /**
1342
+ * Release a deployed spark version to the live/public environment.
1343
+ */
1344
+ async releaseSpark(uuid, version) {
1345
+ return await this.client.put(`/luma/sandbox/v1/spark/release/${uuid}/${version}`);
1346
+ }
1347
+ /**
1348
+ * Execute a deployed spark by name. Mirrors `spark()` but accepts the
1349
+ * full request shape (method/query/headers) — the exec route accepts
1350
+ * GET/POST/PATCH/PUT/DELETE.
1351
+ *
1352
+ * @example
1353
+ * const result = await platform.sandbox().execSpark("myFunction", { foo: "bar" })
1354
+ * const result = await platform.sandbox().execSpark("myFunction", undefined, { method: "GET" })
1355
+ */
1356
+ async execSpark(name, data, options) {
1357
+ var _a;
1358
+ const method = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : "POST").toLowerCase();
1359
+ return await this.client.request({
1360
+ url: `/luma/sandbox/v1/spark/exec/${name}`,
1361
+ method,
1362
+ data,
1363
+ params: options === null || options === void 0 ? void 0 : options.query,
1364
+ headers: options === null || options === void 0 ? void 0 : options.headers,
1365
+ });
1366
+ }
1367
+ /**
1368
+ * Fetch logs for a spark.
1369
+ */
1370
+ async sparkLogs(uuid, params) {
1371
+ return await this.client.get(`/luma/sandbox/v1/spark/logs/${uuid}`, { params });
1372
+ }
1373
+ /**
1374
+ * Get the current project's spark tier (plan/quota).
1375
+ */
1376
+ async sparkTier() {
1377
+ return await this.client.get(`/luma/sandbox/v1/spark/project/tier`);
1378
+ }
1379
+ // ---------------------------------------------------------------
1380
+ // Runtimes (long-running user API deployments)
1381
+ // ---------------------------------------------------------------
1382
+ /**
1383
+ * List all runtimes for the current project.
1384
+ */
1385
+ async listRuntimes() {
1386
+ return await this.client.get(`/luma/sandbox/v1/runtime`);
1387
+ }
1388
+ /**
1389
+ * Create a new runtime.
1390
+ */
1391
+ async createRuntime(payload) {
1392
+ return await this.client.post(`/luma/sandbox/v1/runtime`, payload);
1393
+ }
1394
+ /**
1395
+ * Get a runtime by ref (name/uuid).
1396
+ */
1397
+ async getRuntime(ref) {
1398
+ return await this.client.get(`/luma/sandbox/v1/runtime/${ref}`);
1399
+ }
1400
+ /**
1401
+ * Update a runtime's image/resources/env vars/tags.
1402
+ */
1403
+ async updateRuntime(ref, payload) {
1404
+ return await this.client.patch(`/luma/sandbox/v1/runtime/${ref}`, payload);
1405
+ }
1406
+ /**
1407
+ * Delete a runtime.
1408
+ */
1409
+ async deleteRuntime(ref) {
1410
+ return await this.client.delete(`/luma/sandbox/v1/runtime/${ref}`);
1411
+ }
1412
+ /**
1413
+ * (Re)deploy a runtime.
1414
+ */
1415
+ async deployRuntime(ref) {
1416
+ return await this.client.post(`/luma/sandbox/v1/runtime/${ref}/deploy`);
1417
+ }
1418
+ /**
1419
+ * Restart a running runtime.
1420
+ */
1421
+ async restartRuntime(ref) {
1422
+ return await this.client.post(`/luma/sandbox/v1/runtime/${ref}/restart`);
1423
+ }
1424
+ /**
1425
+ * Fetch logs for a runtime.
1426
+ */
1427
+ async runtimeLogs(ref, params) {
1428
+ return await this.client.get(`/luma/sandbox/v1/runtime/${ref}/logs`, { params });
1429
+ }
1244
1430
  }
1245
1431
 
1246
1432
  class System extends PlatformBaseClient {
@@ -1268,6 +1454,17 @@ class System extends PlatformBaseClient {
1268
1454
  }
1269
1455
  }
1270
1456
 
1457
+ function nodeControlQuery(options) {
1458
+ const params = new URLSearchParams();
1459
+ if ((options === null || options === void 0 ? void 0 : options.iterationIdx) !== undefined) {
1460
+ params.set('iteration_idx', String(options.iterationIdx));
1461
+ }
1462
+ if ((options === null || options === void 0 ? void 0 : options.parentNodeId) !== undefined) {
1463
+ params.set('parent_node_id', String(options.parentNodeId));
1464
+ }
1465
+ const qs = params.toString();
1466
+ return qs ? `?${qs}` : '';
1467
+ }
1271
1468
  class Workflow extends PlatformBaseClient {
1272
1469
  async create(data) {
1273
1470
  return await this.client.post(`/v1/project/workflow/workflow`, data);
@@ -1290,8 +1487,123 @@ class Workflow extends PlatformBaseClient {
1290
1487
  async publish(event, data) {
1291
1488
  return await this.client.post(`/v1/project/workflow/workflow/event/${event}`, data);
1292
1489
  }
1490
+ /**
1491
+ * Install (create + publish) a workflow in one call.
1492
+ * Rejects if a workflow with the same name + integrator already exists.
1493
+ */
1494
+ async install(data) {
1495
+ return await this.client.post(`/v1/project/workflow/workflow/install`, data);
1496
+ }
1497
+ // --- Execution history ---
1498
+ async getHistory(query) {
1499
+ return await this.client.get(`/v1/project/workflow/workflows/history`, { params: query });
1500
+ }
1501
+ async getHistoryEntry(executionUuid) {
1502
+ return await this.client.get(`/v1/project/workflow/workflows/history/${executionUuid}`);
1503
+ }
1504
+ async getStats(query) {
1505
+ return await this.client.get(`/v1/project/workflow/workflows/stats`, { params: query });
1506
+ }
1507
+ // --- Running executions ---
1508
+ async getRunning(query) {
1509
+ return await this.client.get(`/v1/project/workflow/workflows/running`, { params: query });
1510
+ }
1511
+ async getRunningEntry(executionUuid) {
1512
+ return await this.client.get(`/v1/project/workflow/workflows/running/${executionUuid}`);
1513
+ }
1514
+ // --- Workflow execution control ---
1515
+ async pause(executionUuid) {
1516
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/pause`);
1517
+ }
1518
+ async resume(executionUuid) {
1519
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/resume`);
1520
+ }
1521
+ async kill(executionUuid) {
1522
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/kill`);
1523
+ }
1524
+ /**
1525
+ * Restart a failed/killed workflow execution from history.
1526
+ * `clearState: true` discards prior node state instead of a smart resume.
1527
+ */
1528
+ async restart(executionUuid, options) {
1529
+ const qs = (options === null || options === void 0 ? void 0 : options.clearState) ? '?clear_state=true' : '';
1530
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/restart${qs}`);
1531
+ }
1532
+ // --- Node-level control ---
1533
+ async pauseNode(executionUuid, nodeId, options) {
1534
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/pause${nodeControlQuery(options)}`);
1535
+ }
1536
+ async resumeNode(executionUuid, nodeId, options) {
1537
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/resume${nodeControlQuery(options)}`);
1538
+ }
1539
+ async killNode(executionUuid, nodeId, options) {
1540
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/kill${nodeControlQuery(options)}`);
1541
+ }
1542
+ // --- Errors ---
1543
+ async getErrors() {
1544
+ return await this.client.get(`/v1/project/workflow/errors`);
1545
+ }
1546
+ async removeError(id) {
1547
+ return await this.client.delete(`/v1/project/workflow/errors/${id}`);
1548
+ }
1549
+ async removeAllErrors() {
1550
+ return await this.client.delete(`/v1/project/workflow/errors`);
1551
+ }
1293
1552
  }
1294
1553
 
1554
+ /**
1555
+ * Resolve the current app's UUID from the ambient platform context.
1556
+ * The platform injects it per-installation: FORGE_APP_UUID in __ENV_VARIABLES__
1557
+ * for public views, and forge_app_uuid in sessionStorage for platform views.
1558
+ * Returns null outside the browser (e.g. Node/CLI), where the caller must pass
1559
+ * an explicit appUuid.
1560
+ */
1561
+ function resolveCurrentAppUuid() {
1562
+ var _a;
1563
+ if (!isBrowser)
1564
+ return null;
1565
+ // @ts-ignore
1566
+ const fromEnv = (_a = window.__ENV_VARIABLES__) === null || _a === void 0 ? void 0 : _a.FORGE_APP_UUID;
1567
+ if (fromEnv)
1568
+ return fromEnv;
1569
+ try {
1570
+ return sessionStorage.getItem("forge_app_uuid");
1571
+ }
1572
+ catch {
1573
+ return null;
1574
+ }
1575
+ }
1576
+ /**
1577
+ * Resolve a service target into { ref, serviceName }.
1578
+ *
1579
+ * Two forms, cleanly split:
1580
+ * - a bare service name (no "prn:" prefix) → the CURRENT app's service (the ref
1581
+ * is the current app's uuid, resolved from the platform context); or
1582
+ * - a service PRN `prn:forge:{ref}:service/{serviceName}` → ANOTHER app's service
1583
+ * (canonical PRN grammar: kind + name in the path, url-encoded).
1584
+ *
1585
+ * A PRN's `ref` may be an app **name** OR a uuid. Names aren't unique within a
1586
+ * project (a marketplace install and a custom app can share one), so the runtime
1587
+ * resolves a name deterministically **marketplace → custom**. Pass the uuid when
1588
+ * you need a *specific* app.
1589
+ */
1590
+ function parseServiceTarget(target) {
1591
+ if (!target.startsWith("prn:")) {
1592
+ // bare service name → the current app
1593
+ return { ref: resolveCurrentAppUuid(), serviceName: target };
1594
+ }
1595
+ // PRN → another app. Path form: prn:forge:{ref}:service/{serviceName}
1596
+ // (the PRN path segment is "service/{name}", with the name url-encoded).
1597
+ const [, type, ref, ...rest] = target.split(":");
1598
+ const path = rest.join(":"); // the PRN path, e.g. "service/{name}"
1599
+ const [kind, ...nameParts] = path.split("/");
1600
+ const serviceName = decodeURIComponent(nameParts.join("/"));
1601
+ if (type !== "forge" || kind !== "service" || !ref || !serviceName) {
1602
+ throw new Error(`runService: invalid service PRN "${target}" ` +
1603
+ `(expected prn:forge:{ref}:service/{serviceName}, where ref is an app name or uuid)`);
1604
+ }
1605
+ return { ref, serviceName };
1606
+ }
1295
1607
  class Forge extends PlatformBaseClient {
1296
1608
  // --- Management (appservice) ---
1297
1609
  async bundleUpload(buffer) {
@@ -1329,156 +1641,202 @@ class Forge extends PlatformBaseClient {
1329
1641
  return await this.client.patch(`/luma/appservice/v1/forge/${ref}/variables`, current);
1330
1642
  }
1331
1643
  // --- Service execution (forge-runtime) ---
1332
- async callService(appUuid, serviceName, options) {
1333
- var _a, _b, _c;
1644
+ /**
1645
+ * Run a Forge service: `runService(target, body?, { query?, headers? })`.
1646
+ * Mirrors `axios.post(url, data, config)` — the 2nd arg is the request payload.
1647
+ *
1648
+ * `target` is either:
1649
+ * - a bare service name — runs that service on the CURRENT app; or
1650
+ * - a service PRN `prn:forge:{ref}:service/{name}` — runs it on ANOTHER app,
1651
+ * where `ref` is the app's **name** or uuid. A name is resolved by the
1652
+ * runtime deterministically (marketplace → custom); use the uuid to pin a
1653
+ * specific app. This is the addressing to use where there's no ambient
1654
+ * "current app" — e.g. a workflow, which has no per-install uuid to hardcode.
1655
+ *
1656
+ * `body` is sent as the POST body; `options.query` / `options.headers` are optional.
1657
+ *
1658
+ * The current app's uuid (bare-name form) is resolved automatically from the
1659
+ * platform context (FORGE_APP_UUID for public views, forge_app_uuid in
1660
+ * sessionStorage for platform views), so app code never needs its own uuid.
1661
+ *
1662
+ * Resolving the app does NOT grant access. Execution is still authorized against
1663
+ * the caller's permissions — for a `platform`-access service the caller must hold
1664
+ * `service::{name} forge::{appUuid}`; `public`-access services require none. An
1665
+ * app's own runtime token is implicitly granted this for all of its own services.
1666
+ */
1667
+ async runService(target, body, options) {
1668
+ var _a;
1669
+ const { ref, serviceName } = parseServiceTarget(target);
1334
1670
  const queryString = (options === null || options === void 0 ? void 0 : options.query)
1335
1671
  ? '?' + new URLSearchParams(options.query).toString()
1336
1672
  : '';
1337
1673
  // @ts-ignore
1338
1674
  const devServiceUrl = isBrowser && ((_a = window.__ENV_VARIABLES__) === null || _a === void 0 ? void 0 : _a.FORGE_DEV_SERVICE_URL);
1339
1675
  if (devServiceUrl) {
1340
- return axios.post(`${devServiceUrl}/${serviceName}${queryString}`, (_b = options === null || options === void 0 ? void 0 : options.body) !== null && _b !== void 0 ? _b : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1676
+ // The dev service server routes by name; the ref is ignored.
1677
+ return axios.post(`${devServiceUrl}/${serviceName}${queryString}`, body !== null && body !== void 0 ? body : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1341
1678
  }
1342
- return await this.client.post(`/luma/forge-runtime/api/services/${appUuid}/${serviceName}${queryString}`, (_c = options === null || options === void 0 ? void 0 : options.body) !== null && _c !== void 0 ? _c : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1679
+ if (!ref) {
1680
+ throw new Error("runService: could not resolve the current app from the platform context. " +
1681
+ "Use a service PRN with an explicit ref: prn:forge:{name|uuid}:service/{serviceName}.");
1682
+ }
1683
+ // Service execution is owned by the forge runtime (forge-runtime gateway ->
1684
+ // platform-forge), which resolves the ref (name → uuid, marketplace → custom)
1685
+ // and executes the service, enforcing `service::{name} forge::{uuid}`
1686
+ // for platform-access services before running.
1687
+ return await this.client.post(`/luma/forge-runtime/api/services/${ref}/${serviceName}${queryString}`, body !== null && body !== void 0 ? body : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1343
1688
  }
1344
1689
  }
1345
1690
 
1346
- const BASE = '/luma/kortex/v1';
1691
+ const BASE$1 = '/luma/kortex/v1';
1347
1692
  class Kortex extends PlatformBaseClient {
1348
1693
  // ── Agents ──
1349
1694
  async createAgent(data) {
1350
- return await this.client.post(`${BASE}/agents`, data);
1695
+ return await this.client.post(`${BASE$1}/agents`, data);
1351
1696
  }
1352
1697
  async listAgents(params) {
1353
- return await this.client.get(`${BASE}/agents`, { params });
1698
+ return await this.client.get(`${BASE$1}/agents`, { params });
1354
1699
  }
1355
1700
  async getAgent(uuid) {
1356
- return await this.client.get(`${BASE}/agents/${uuid}`);
1701
+ return await this.client.get(`${BASE$1}/agents/${uuid}`);
1357
1702
  }
1358
1703
  async updateAgent(uuid, data) {
1359
- return await this.client.patch(`${BASE}/agents/${uuid}`, data);
1704
+ return await this.client.patch(`${BASE$1}/agents/${uuid}`, data);
1360
1705
  }
1361
1706
  async deleteAgent(uuid) {
1362
- return await this.client.delete(`${BASE}/agents/${uuid}`);
1707
+ return await this.client.delete(`${BASE$1}/agents/${uuid}`);
1363
1708
  }
1364
1709
  async listAgentKnowledgeBases(agentUUID) {
1365
- return await this.client.get(`${BASE}/agents/${agentUUID}/knowledge-bases`);
1710
+ return await this.client.get(`${BASE$1}/agents/${agentUUID}/knowledge-bases`);
1366
1711
  }
1367
1712
  // ── Knowledge Bases ──
1368
1713
  async createKnowledgeBase(data) {
1369
- return await this.client.post(`${BASE}/knowledge-bases`, data);
1714
+ return await this.client.post(`${BASE$1}/knowledge-bases`, data);
1370
1715
  }
1371
1716
  async listKnowledgeBases(params) {
1372
- return await this.client.get(`${BASE}/knowledge-bases`, { params });
1717
+ return await this.client.get(`${BASE$1}/knowledge-bases`, { params });
1373
1718
  }
1374
1719
  async getKnowledgeBase(uuid) {
1375
- return await this.client.get(`${BASE}/knowledge-bases/${uuid}`);
1720
+ return await this.client.get(`${BASE$1}/knowledge-bases/${uuid}`);
1376
1721
  }
1377
1722
  async updateKnowledgeBase(uuid, data) {
1378
- return await this.client.put(`${BASE}/knowledge-bases/${uuid}`, data);
1723
+ return await this.client.put(`${BASE$1}/knowledge-bases/${uuid}`, data);
1379
1724
  }
1380
1725
  async deleteKnowledgeBase(uuid) {
1381
- return await this.client.delete(`${BASE}/knowledge-bases/${uuid}`);
1726
+ return await this.client.delete(`${BASE$1}/knowledge-bases/${uuid}`);
1727
+ }
1728
+ // Searches the knowledge bases attached to `data.agent_uuid` (collections
1729
+ // are derived from the agent, not passed explicitly). `top_k` is clamped
1730
+ // to 1-10 server-side. Response is `{ chunks: KnowledgeBaseSearchChunk[] }`.
1731
+ async searchKnowledgeBase(data) {
1732
+ return await this.client.post(`${BASE$1}/knowledge-bases/search`, data);
1382
1733
  }
1383
1734
  // ── Documents ──
1384
1735
  async listDocuments(kbUUID, params) {
1385
- return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents`, { params });
1736
+ return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, { params });
1386
1737
  }
1387
1738
  async uploadDocument(kbUUID, formData) {
1388
- return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents`, formData, {
1739
+ return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, formData, {
1389
1740
  headers: { 'Content-Type': 'multipart/form-data' },
1390
1741
  timeout: 120000,
1391
1742
  });
1392
1743
  }
1393
1744
  async getDocument(kbUUID, uuid) {
1394
- return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1745
+ return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1395
1746
  }
1396
1747
  async deleteDocument(kbUUID, uuid) {
1397
- return await this.client.delete(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1748
+ return await this.client.delete(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1398
1749
  }
1399
1750
  async retryDocument(kbUUID, uuid) {
1400
- return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
1751
+ return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
1401
1752
  }
1402
1753
  // ── Conversations ──
1403
1754
  async createConversation(data) {
1404
- return await this.client.post(`${BASE}/conversations`, data);
1755
+ return await this.client.post(`${BASE$1}/conversations`, data);
1405
1756
  }
1406
1757
  async listConversations(params) {
1407
- return await this.client.get(`${BASE}/conversations`, { params });
1758
+ return await this.client.get(`${BASE$1}/conversations`, { params });
1408
1759
  }
1409
1760
  async getConversation(uuid) {
1410
- return await this.client.get(`${BASE}/conversations/${uuid}`);
1761
+ return await this.client.get(`${BASE$1}/conversations/${uuid}`);
1411
1762
  }
1412
1763
  async updateConversation(uuid, data) {
1413
- return await this.client.put(`${BASE}/conversations/${uuid}`, data);
1764
+ return await this.client.put(`${BASE$1}/conversations/${uuid}`, data);
1414
1765
  }
1415
1766
  async deleteConversation(uuid) {
1416
- return await this.client.delete(`${BASE}/conversations/${uuid}`);
1767
+ return await this.client.delete(`${BASE$1}/conversations/${uuid}`);
1417
1768
  }
1418
1769
  async archiveConversation(uuid) {
1419
- return await this.client.post(`${BASE}/conversations/${uuid}/archive`);
1770
+ return await this.client.post(`${BASE$1}/conversations/${uuid}/archive`);
1420
1771
  }
1421
1772
  async unarchiveConversation(uuid) {
1422
- return await this.client.post(`${BASE}/conversations/${uuid}/unarchive`);
1773
+ return await this.client.post(`${BASE$1}/conversations/${uuid}/unarchive`);
1423
1774
  }
1424
1775
  async addParticipant(conversationUUID, data) {
1425
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/participants`, data);
1776
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/participants`, data);
1426
1777
  }
1427
1778
  async removeParticipant(conversationUUID, agentUUID) {
1428
- return await this.client.delete(`${BASE}/conversations/${conversationUUID}/participants/${agentUUID}`);
1779
+ return await this.client.delete(`${BASE$1}/conversations/${conversationUUID}/participants/${agentUUID}`);
1429
1780
  }
1430
1781
  // ── Messages / Completions ──
1431
1782
  async sendMessage(conversationUUID, data) {
1432
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, data);
1783
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, data);
1433
1784
  }
1434
1785
  async streamMessage(conversationUUID, data) {
1435
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
1786
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
1436
1787
  responseType: 'stream',
1437
1788
  timeout: 120000,
1438
1789
  });
1439
1790
  }
1440
1791
  async listMessages(conversationUUID, params) {
1441
- return await this.client.get(`${BASE}/conversations/${conversationUUID}/messages`, { params });
1792
+ return await this.client.get(`${BASE$1}/conversations/${conversationUUID}/messages`, { params });
1442
1793
  }
1443
1794
  async injectMessage(conversationUUID, data) {
1444
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages/inject`, data);
1795
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
1445
1796
  }
1446
1797
  // ── OCR ──
1447
1798
  async ocr(data) {
1448
- return await this.client.post(`${BASE}/ocr`, data, { timeout: 120000 });
1799
+ return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
1800
+ }
1801
+ // ── Workflow ──
1802
+ async workflowComplete(data) {
1803
+ return await this.client.post(`${BASE$1}/workflow/complete`, data);
1804
+ }
1805
+ async workflowOcr(data) {
1806
+ return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
1449
1807
  }
1450
1808
  // ── User Access ──
1451
1809
  async createUserAccess(data) {
1452
- return await this.client.post(`${BASE}/user-access`, data);
1810
+ return await this.client.post(`${BASE$1}/user-access`, data);
1453
1811
  }
1454
1812
  async listUserAccess(params) {
1455
- return await this.client.get(`${BASE}/user-access`, { params });
1813
+ return await this.client.get(`${BASE$1}/user-access`, { params });
1456
1814
  }
1457
1815
  async getUserAccess(uuid) {
1458
- return await this.client.get(`${BASE}/user-access/${uuid}`);
1816
+ return await this.client.get(`${BASE$1}/user-access/${uuid}`);
1459
1817
  }
1460
1818
  async updateUserAccess(uuid, data) {
1461
- return await this.client.patch(`${BASE}/user-access/${uuid}`, data);
1819
+ return await this.client.patch(`${BASE$1}/user-access/${uuid}`, data);
1462
1820
  }
1463
1821
  async deleteUserAccess(uuid) {
1464
- return await this.client.delete(`${BASE}/user-access/${uuid}`);
1822
+ return await this.client.delete(`${BASE$1}/user-access/${uuid}`);
1465
1823
  }
1466
1824
  async getUserMonthlyUsage(uuid, params) {
1467
- return await this.client.get(`${BASE}/user-access/${uuid}/usage`, { params });
1825
+ return await this.client.get(`${BASE$1}/user-access/${uuid}/usage`, { params });
1468
1826
  }
1469
1827
  async getUserUsageBreakdown(uuid) {
1470
- return await this.client.get(`${BASE}/user-access/${uuid}/usage/breakdown`);
1828
+ return await this.client.get(`${BASE$1}/user-access/${uuid}/usage/breakdown`);
1471
1829
  }
1472
1830
  async getMyAccess() {
1473
- return await this.client.get(`${BASE}/my-access`);
1831
+ return await this.client.get(`${BASE$1}/my-access`);
1474
1832
  }
1475
1833
  // ── Usage (Admin) ──
1476
1834
  async listUsage(params) {
1477
- return await this.client.get(`${BASE}/usage`, { params });
1835
+ return await this.client.get(`${BASE$1}/usage`, { params });
1478
1836
  }
1479
1837
  // ── Tier ──
1480
1838
  async getTier() {
1481
- return await this.client.get(`${BASE}/tier`);
1839
+ return await this.client.get(`${BASE$1}/tier`);
1482
1840
  }
1483
1841
  }
1484
1842
 
@@ -1509,12 +1867,50 @@ class Project extends PlatformBaseClient {
1509
1867
  return await this.client.patch("/v1/project/archive");
1510
1868
  }
1511
1869
  /**
1512
- * Invite a user to the project
1513
- * @param emails Array of emails
1514
- * @param roles Array of role UUIDs
1870
+ * Invite one or more users to the project.
1871
+ *
1872
+ * `POST /v1/project/invite` only accepts a single `email` per request
1873
+ * (see `InviteToProject` in platform-api's
1874
+ * `internal/project/controllers/invite.go`), so this method issues one
1875
+ * request per entry in `emails`, sequentially, with body
1876
+ * `{ email, role_uuid: roles, subject?, comment? }`.
1877
+ *
1878
+ * Return shape (always a single `AxiosResponse`, so existing callers
1879
+ * that do `(await project.invite(...)).data` keep compiling/working
1880
+ * unchanged):
1881
+ * - Exactly one email: the raw `AxiosResponse` from that single request
1882
+ * (`.data` is that invite's response body, as before).
1883
+ * - More than one email: a response shaped like the last request's
1884
+ * `AxiosResponse`, but with `.data` replaced by an array of each
1885
+ * individual request's `.data`, in the same order as `emails`.
1886
+ *
1887
+ * @param emails Array of email addresses to invite
1888
+ * @param roles Array of role UUIDs to grant every invitee
1889
+ * @param extra Optional subject/comment applied to every invite
1515
1890
  */
1516
- async invite(emails, roles) {
1517
- return await this.client.post("/v1/project/invite", { emails: emails.join(","), roles });
1891
+ async invite(emails, roles, extra) {
1892
+ const bodyExtra = {};
1893
+ if ((extra === null || extra === void 0 ? void 0 : extra.subject) !== undefined)
1894
+ bodyExtra.subject = extra.subject;
1895
+ if ((extra === null || extra === void 0 ? void 0 : extra.comment) !== undefined)
1896
+ bodyExtra.comment = extra.comment;
1897
+ const responses = [];
1898
+ for (const email of emails) {
1899
+ const res = await this.client.post("/v1/project/invite", {
1900
+ email,
1901
+ role_uuid: roles,
1902
+ ...bodyExtra,
1903
+ });
1904
+ responses.push(res);
1905
+ }
1906
+ if (responses.length === 1) {
1907
+ return responses[0];
1908
+ }
1909
+ const last = responses[responses.length - 1];
1910
+ return {
1911
+ ...last,
1912
+ data: responses.map((r) => r.data),
1913
+ };
1518
1914
  }
1519
1915
  /**
1520
1916
  * Get list of project invites
@@ -1644,25 +2040,49 @@ class Project extends PlatformBaseClient {
1644
2040
  return await this.client.get("/v1/project/template/workspace");
1645
2041
  }
1646
2042
  /**
1647
- * Install a template
1648
- * @param data Installation data
2043
+ * Install a template.
2044
+ *
2045
+ * `POST /v1/project/template/install` decodes body `TemplateInstall = { id,
2046
+ * data, activation_code }` and resolves the target workspace from the
2047
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
2048
+ * `template_install.go`. This method keeps the ergonomic object-arg
2049
+ * signature but maps it onto that contract: `template_id` becomes body
2050
+ * `id`, `workspace_uuid` is sent as the `X-Workspace-Uuid` header, and any
2051
+ * `data`/`activation_code` passed in are forwarded in the body as-is.
2052
+ *
2053
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
1649
2054
  */
1650
2055
  async installTemplate(data) {
1651
- return await this.client.post("/v1/project/template/install", data);
2056
+ const { template_id, workspace_uuid, ...rest } = data;
2057
+ return await this.client.post("/v1/project/template/install", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
1652
2058
  }
1653
2059
  /**
1654
- * Uninstall a template
1655
- * @param data Uninstallation data
2060
+ * Uninstall a template.
2061
+ *
2062
+ * `POST /v1/project/template/uninstall` decodes body `TemplateInstall = {
2063
+ * id, data, activation_code }` and resolves the target workspace from the
2064
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
2065
+ * `template_uninstall.go`. See `installTemplate` for the mapping.
2066
+ *
2067
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
1656
2068
  */
1657
2069
  async uninstallTemplate(data) {
1658
- return await this.client.post("/v1/project/template/uninstall", data);
2070
+ const { template_id, workspace_uuid, ...rest } = data;
2071
+ return await this.client.post("/v1/project/template/uninstall", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
1659
2072
  }
1660
2073
  /**
1661
- * Upgrade a template
1662
- * @param data Upgrade data
2074
+ * Upgrade a template.
2075
+ *
2076
+ * `POST /v1/project/template/upgrade` decodes body `TemplateInstall = {
2077
+ * id, data, activation_code }` and resolves the target workspace from the
2078
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
2079
+ * `template_upgrade.go`. See `installTemplate` for the mapping.
2080
+ *
2081
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
1663
2082
  */
1664
2083
  async upgradeTemplate(data) {
1665
- return await this.client.post("/v1/project/template/upgrade", data);
2084
+ const { template_id, workspace_uuid, ...rest } = data;
2085
+ return await this.client.post("/v1/project/template/upgrade", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
1666
2086
  }
1667
2087
  }
1668
2088
 
@@ -1682,62 +2102,6 @@ class Config extends PlatformBaseClient {
1682
2102
  }
1683
2103
  }
1684
2104
 
1685
- // apis
1686
- class Platform extends PlatformBaseClient {
1687
- getPlatformClient() {
1688
- return this.client;
1689
- }
1690
- getPlatformBaseURL() {
1691
- var _a;
1692
- return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
1693
- }
1694
- apiUser() {
1695
- return (new APIUser()).setClient(this.client);
1696
- }
1697
- function() {
1698
- return (new Functions()).setClient(this.client);
1699
- }
1700
- user() {
1701
- return (new Users()).setClient(this.client);
1702
- }
1703
- app(appType) {
1704
- return (new Apps(appType)).setClient(this.client);
1705
- }
1706
- forge() {
1707
- return (new Forge()).setClient(this.client);
1708
- }
1709
- kortex() {
1710
- return (new Kortex()).setClient(this.client);
1711
- }
1712
- component(ref) {
1713
- return (new Component(ref)).setClient(this.client);
1714
- }
1715
- componentUtils() {
1716
- return (new ComponentUtils()).setClient(this.client);
1717
- }
1718
- ratchet() {
1719
- return (new Ratchet()).setClient(this.client);
1720
- }
1721
- sandbox() {
1722
- return (new Sandbox()).setClient(this.client);
1723
- }
1724
- system() {
1725
- return (new System()).setClient(this.client);
1726
- }
1727
- workflow() {
1728
- return (new Workflow()).setClient(this.client);
1729
- }
1730
- thunder() {
1731
- return (new Thunder()).setClient(this.client);
1732
- }
1733
- project() {
1734
- return (new Project()).setClient(this.client);
1735
- }
1736
- config() {
1737
- return (new Config()).setClient(this.client);
1738
- }
1739
- }
1740
-
1741
2105
  class IntegrationsBaseClient extends BaseClient {
1742
2106
  constructor(options) {
1743
2107
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2616,6 +2980,135 @@ class DMS extends IntegrationsBaseClient {
2616
2980
  timeout: 120000
2617
2981
  });
2618
2982
  }
2983
+ // ===================================================================
2984
+ // Backup (Library Export Archives)
2985
+ // ===================================================================
2986
+ /**
2987
+ * Create a library export archive (a snapshot of the project's library or a directory within it)
2988
+ *
2989
+ * The library is resolved server-side from the project in the auth context —
2990
+ * there is a single library per project.
2991
+ *
2992
+ * @param payload - Optional export scope/format options
2993
+ * @returns `{ mode, export }` when the export is queued asynchronously.
2994
+ * Depending on server-side sizing, the endpoint may instead stream the
2995
+ * archive back directly as a binary response body (not this JSON shape).
2996
+ *
2997
+ * @example
2998
+ * ```typescript
2999
+ * const result = await dms.createExport({ path: 'legal', format: 'zip' });
3000
+ * ```
3001
+ */
3002
+ async createExport(payload) {
3003
+ return this.request('POST', `library/exports`, { data: payload !== null && payload !== void 0 ? payload : {} });
3004
+ }
3005
+ /**
3006
+ * List export archives for the project's library
3007
+ */
3008
+ async listExports() {
3009
+ return this.request('GET', `library/exports`);
3010
+ }
3011
+ /**
3012
+ * Get a single export archive (an archived snapshot of a library/dir)
3013
+ *
3014
+ * @param exportUuid - Export UUID
3015
+ * @returns `{ export, download_url }`
3016
+ */
3017
+ async getExport(exportUuid) {
3018
+ return this.request('GET', `library/exports/${exportUuid}`);
3019
+ }
3020
+ // ===================================================================
3021
+ // Policies (Quota / File-Type / Notification, library & dir scope)
3022
+ // ===================================================================
3023
+ /**
3024
+ * Get the effective library-level policy for the project's library
3025
+ */
3026
+ async getLibraryPolicy() {
3027
+ return this.request('GET', `library/policy`);
3028
+ }
3029
+ /**
3030
+ * Set/update the library-level policy for the project's library
3031
+ *
3032
+ * @param payload - Policy fields to set
3033
+ */
3034
+ async setLibraryPolicy(payload) {
3035
+ return this.request('PUT', `library/policy`, { data: payload });
3036
+ }
3037
+ /**
3038
+ * Get the directory-level policy (resolves platform-default → library → dir)
3039
+ *
3040
+ * @param path - Directory path
3041
+ */
3042
+ async getDirPolicy(path) {
3043
+ return this.request('GET', `library/dir/policy`, { params: { path } });
3044
+ }
3045
+ /**
3046
+ * Set/update the directory-level policy
3047
+ *
3048
+ * @param path - Directory path
3049
+ * @param payload - Policy fields to set (only fields provided override the library policy)
3050
+ */
3051
+ async setDirPolicy(path, payload) {
3052
+ return this.request('PUT', `library/dir/policy`, { data: payload, params: { path } });
3053
+ }
3054
+ /**
3055
+ * Remove a directory-level policy override (directory falls back to the library policy)
3056
+ *
3057
+ * @param path - Directory path
3058
+ */
3059
+ async deleteDirPolicy(path) {
3060
+ return this.request('DELETE', `library/dir/policy`, { params: { path } });
3061
+ }
3062
+ // ===================================================================
3063
+ // Reminders (Notification Rules & Per-File Notifications)
3064
+ // ===================================================================
3065
+ /**
3066
+ * List notification rules for the project's library
3067
+ */
3068
+ async listNotificationRules() {
3069
+ return this.request('GET', `library/notification-rules`);
3070
+ }
3071
+ /**
3072
+ * Create a recurring reminder (notification rule) for a media file
3073
+ *
3074
+ * @param payload - Recurring reminder definition (media_uuid/file_key, frequency, start_at, ...)
3075
+ */
3076
+ async createNotificationRule(payload) {
3077
+ return this.request('POST', `library/notification-rules`, { data: payload });
3078
+ }
3079
+ /**
3080
+ * Delete a notification rule
3081
+ *
3082
+ * @param ruleUuid - Notification rule UUID
3083
+ */
3084
+ async deleteNotificationRule(ruleUuid) {
3085
+ return this.request('DELETE', `library/notification-rules/${ruleUuid}`);
3086
+ }
3087
+ /**
3088
+ * List custom reminders scheduled for a specific file
3089
+ *
3090
+ * @param mediaUuid - Media UUID
3091
+ */
3092
+ async listFileNotifications(mediaUuid) {
3093
+ return this.request('GET', `library/media/${mediaUuid}/notifications`);
3094
+ }
3095
+ /**
3096
+ * Create a custom reminder for a specific file
3097
+ *
3098
+ * @param mediaUuid - Media UUID
3099
+ * @param payload - Reminder details (note, notify_at, optional recipient)
3100
+ */
3101
+ async createFileNotification(mediaUuid, payload) {
3102
+ return this.request('POST', `library/media/${mediaUuid}/notifications`, { data: payload });
3103
+ }
3104
+ /**
3105
+ * Cancel/delete a custom file reminder
3106
+ *
3107
+ * @param notificationUuid - Notification UUID
3108
+ */
3109
+ async deleteFileNotification(notificationUuid) {
3110
+ return this.request('DELETE', `library/notifications/${notificationUuid}`);
3111
+ }
2619
3112
  async request(method, endpoint, params) {
2620
3113
  return await this.client.request({
2621
3114
  method: method,
@@ -3785,6 +4278,65 @@ class Integrations extends IntegrationsBaseClient {
3785
4278
  const { data } = await this.client.get("/v1/integrations");
3786
4279
  return data.find((i) => i.id == id && i.status == "active") !== undefined;
3787
4280
  }
4281
+ /**
4282
+ * Install (integrate) an integration into the current project.
4283
+ * POST /v1/integrate
4284
+ */
4285
+ async install(id, data) {
4286
+ const { data: resp } = await this.client.post("/v1/integrate", {
4287
+ id,
4288
+ ...(data !== undefined ? { data } : {}),
4289
+ });
4290
+ return resp;
4291
+ }
4292
+ /**
4293
+ * Uninstall (remove) an integration from the current project.
4294
+ * PUT /v1/integrate
4295
+ */
4296
+ async uninstall(id) {
4297
+ const { data } = await this.client.put("/v1/integrate", { id });
4298
+ return data;
4299
+ }
4300
+ /**
4301
+ * Activate an installed integration.
4302
+ * POST /v1/integration/{id}/activate
4303
+ */
4304
+ async activate(id) {
4305
+ const { data } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/activate`);
4306
+ return data;
4307
+ }
4308
+ /**
4309
+ * Deactivate an installed integration.
4310
+ * POST /v1/integration/{id}/deactivate
4311
+ */
4312
+ async deactivate(id) {
4313
+ const { data } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/deactivate`);
4314
+ return data;
4315
+ }
4316
+ /**
4317
+ * Advance/update the onboarding state of an installed integration.
4318
+ * POST /v1/integration/{id}/onboarding
4319
+ */
4320
+ async onboarding(id, data) {
4321
+ const { data: resp } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/onboarding`, data);
4322
+ return resp;
4323
+ }
4324
+ /**
4325
+ * List marketplace-available integrations (subscription/geo aware).
4326
+ * GET /v1/marketplace/integrations
4327
+ */
4328
+ async marketplace() {
4329
+ const { data } = await this.client.get("/v1/marketplace/integrations");
4330
+ return data;
4331
+ }
4332
+ /**
4333
+ * List explorable integration templates (subscription/geo aware).
4334
+ * GET /v1/integrations/explore
4335
+ */
4336
+ async explore() {
4337
+ const { data } = await this.client.get("/v1/integrations/explore");
4338
+ return data;
4339
+ }
3788
4340
  getInterfaceOf(id) {
3789
4341
  try {
3790
4342
  return this.integrations[id];
@@ -3797,57 +4349,286 @@ class Integrations extends IntegrationsBaseClient {
3797
4349
 
3798
4350
  class Satellites extends IntegrationsBaseClient {
3799
4351
  async list() {
3800
- const { data } = await this.client.get('/satellites/templates');
4352
+ const { data } = await this.client.get('/v1/satellites/templates');
3801
4353
  return data;
3802
4354
  }
3803
4355
  async create(payload) {
3804
- const { data } = await this.client.post('/satellites/templates', payload.template);
4356
+ const { data } = await this.client.post('/v1/satellites/templates', payload.template);
3805
4357
  if (payload.schema) {
3806
4358
  await this.createVersion(data.id, payload.schema);
3807
4359
  }
3808
4360
  return data;
3809
4361
  }
3810
4362
  async get(id) {
3811
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}`);
4363
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}`);
3812
4364
  return data;
3813
4365
  }
3814
4366
  async delete(id) {
3815
- const { data } = await this.client.delete(`/satellites/templates/${encodeURIComponent(id)}`);
4367
+ const { data } = await this.client.delete(`/v1/satellites/templates/${encodeURIComponent(id)}`);
3816
4368
  return data;
3817
4369
  }
3818
4370
  async createVersion(id, payload) {
3819
- const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/versions`, payload);
4371
+ const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`, payload);
3820
4372
  return data;
3821
4373
  }
3822
4374
  async versions(id) {
3823
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/versions`);
4375
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`);
3824
4376
  return data;
3825
4377
  }
3826
4378
  async deploy(id, payload) {
3827
- const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/deploy`, payload);
4379
+ const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/deploy`, payload);
3828
4380
  return data;
3829
4381
  }
3830
4382
  async rollback(id, payload) {
3831
- const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/rollback`, payload);
4383
+ const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/rollback`, payload);
3832
4384
  return data;
3833
4385
  }
3834
4386
  async permissions(id) {
3835
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/permissions`);
4387
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/permissions`);
3836
4388
  return data;
3837
4389
  }
3838
4390
  async logs(id, params = {}) {
3839
4391
  const since = params.since instanceof Date ? params.since.toISOString() : params.since;
3840
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/logs`, {
4392
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/logs`, {
3841
4393
  params: since ? { since } : undefined,
3842
4394
  });
3843
4395
  return data;
3844
4396
  }
3845
4397
  async execute(id, command, payload = {}) {
3846
- const { data } = await this.client.post(`/satellites/${encodeURIComponent(id)}/commands/${encodeURIComponent(command)}/execute`, payload);
4398
+ const { data } = await this.client.post(`/v1/satellites/${encodeURIComponent(id)}/commands/${encodeURIComponent(command)}/execute`, payload);
3847
4399
  return data;
3848
4400
  }
3849
4401
  }
3850
4402
 
4403
+ const BASE = "/luma/transactions/v1";
4404
+ /**
4405
+ * Transactions client — billing/subscriptions, invoices, credits/balance,
4406
+ * usage pricing and per-project billing-mode overrides. All routes go
4407
+ * through the `transactions/…` gateway prefix (`/luma/transactions/v1/...`),
4408
+ * matching the transactions service's REST surface
4409
+ * (`internal/controllers/{subscription,invoices,topup,credit_history,billing_modes,prices,balance}.go`).
4410
+ *
4411
+ * This is the **billing** service — not distributed/database transactions.
4412
+ */
4413
+ class Transactions extends PlatformBaseClient {
4414
+ // ---------------------------------------------------------------
4415
+ // Subscriptions
4416
+ // ---------------------------------------------------------------
4417
+ /**
4418
+ * List all subscriptions (including expired) for the current project.
4419
+ *
4420
+ * @example
4421
+ * const subs = await platform.transactions().getSubscriptions()
4422
+ */
4423
+ async getSubscriptions() {
4424
+ return await this.client.get(`${BASE}/billing/subscription`);
4425
+ }
4426
+ /**
4427
+ * Renew an expired subscription (and any others sharing its bundle
4428
+ * `ref_no`) — creates a renewal invoice and returns a checkout link.
4429
+ */
4430
+ async renewSubscription(payload) {
4431
+ return await this.client.post(`${BASE}/subscription/renew`, payload);
4432
+ }
4433
+ /**
4434
+ * Cancel a subscription. Issues a refund automatically if still within
4435
+ * the refund period.
4436
+ */
4437
+ async cancelSubscription(payload) {
4438
+ return await this.client.post(`${BASE}/subscription/cancel`, payload);
4439
+ }
4440
+ // ---------------------------------------------------------------
4441
+ // Invoices
4442
+ // ---------------------------------------------------------------
4443
+ /**
4444
+ * List all invoices for the current project.
4445
+ */
4446
+ async getInvoices() {
4447
+ return await this.client.get(`${BASE}/billing/invoices`);
4448
+ }
4449
+ /**
4450
+ * Get a single invoice by uuid.
4451
+ */
4452
+ async getInvoice(uuid) {
4453
+ return await this.client.get(`${BASE}/billing/invoice/${uuid}`);
4454
+ }
4455
+ /**
4456
+ * Download an invoice as a PDF. Resolves with the raw PDF bytes
4457
+ * (`responseType: "arraybuffer"`).
4458
+ *
4459
+ * @example
4460
+ * const { data } = await platform.transactions().getInvoicePdf(uuid)
4461
+ * fs.writeFileSync("invoice.pdf", Buffer.from(data))
4462
+ */
4463
+ async getInvoicePdf(uuid) {
4464
+ return await this.client.get(`${BASE}/billing/invoice/${uuid}/pdf`, {
4465
+ responseType: "arraybuffer",
4466
+ });
4467
+ }
4468
+ // ---------------------------------------------------------------
4469
+ // Balance / credits / top-up
4470
+ // ---------------------------------------------------------------
4471
+ /**
4472
+ * Get the current project's credit balance.
4473
+ */
4474
+ async getBalance() {
4475
+ return await this.client.get(`${BASE}/billing/balance`);
4476
+ }
4477
+ /**
4478
+ * Generate a checkout link to manually top up the project's credit balance.
4479
+ */
4480
+ async topUp(payload) {
4481
+ return await this.client.post(`${BASE}/billing/topup`, payload);
4482
+ }
4483
+ /**
4484
+ * Get the project's credit activity (deductions/top-ups) history, paginated.
4485
+ */
4486
+ async getCreditsHistory(query) {
4487
+ return await this.client.get(`${BASE}/billing/credits/history`, {
4488
+ params: query,
4489
+ });
4490
+ }
4491
+ // ---------------------------------------------------------------
4492
+ // Prices
4493
+ // ---------------------------------------------------------------
4494
+ /**
4495
+ * Get the usage-based pricing table for a given currency.
4496
+ *
4497
+ * @param currency - ISO 4217 currency code, e.g. "USD" or "RSD".
4498
+ */
4499
+ async getPrices(currency) {
4500
+ return await this.client.get(`${BASE}/prices/${currency}`);
4501
+ }
4502
+ // ---------------------------------------------------------------
4503
+ // Billing modes (per-project usage billing overrides)
4504
+ // ---------------------------------------------------------------
4505
+ /**
4506
+ * Get the project's usage-billing-mode overrides plus platform defaults.
4507
+ */
4508
+ async getBillingModes() {
4509
+ return await this.client.get(`${BASE}/billing/billing-modes`);
4510
+ }
4511
+ /**
4512
+ * Set the billing mode ("credits" | "hybrid" | "invoice") for a usage
4513
+ * option code on the current project.
4514
+ */
4515
+ async updateBillingModes(payload) {
4516
+ return await this.client.put(`${BASE}/billing/billing-modes`, payload);
4517
+ }
4518
+ }
4519
+
4520
+ // apis
4521
+ class Platform extends PlatformBaseClient {
4522
+ getPlatformClient() {
4523
+ return this.client;
4524
+ }
4525
+ getPlatformBaseURL() {
4526
+ var _a;
4527
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
4528
+ }
4529
+ apiUser() {
4530
+ return (new APIUser()).setClient(this.client);
4531
+ }
4532
+ function() {
4533
+ return (new Functions()).setClient(this.client);
4534
+ }
4535
+ user() {
4536
+ return (new Users()).setClient(this.client);
4537
+ }
4538
+ app(appType) {
4539
+ return (new Apps(appType)).setClient(this.client);
4540
+ }
4541
+ forge() {
4542
+ return (new Forge()).setClient(this.client);
4543
+ }
4544
+ kortex() {
4545
+ return (new Kortex()).setClient(this.client);
4546
+ }
4547
+ component(ref) {
4548
+ return (new Component(ref)).setClient(this.client);
4549
+ }
4550
+ componentUtils() {
4551
+ return (new ComponentUtils()).setClient(this.client);
4552
+ }
4553
+ ratchet() {
4554
+ return (new Ratchet()).setClient(this.client);
4555
+ }
4556
+ sandbox() {
4557
+ return (new Sandbox()).setClient(this.client);
4558
+ }
4559
+ system() {
4560
+ return (new System()).setClient(this.client);
4561
+ }
4562
+ workflow() {
4563
+ return (new Workflow()).setClient(this.client);
4564
+ }
4565
+ thunder() {
4566
+ return (new Thunder()).setClient(this.client);
4567
+ }
4568
+ project() {
4569
+ return (new Project()).setClient(this.client);
4570
+ }
4571
+ config() {
4572
+ return (new Config()).setClient(this.client);
4573
+ }
4574
+ /**
4575
+ * Convenience factory for the Integrations gateway façade.
4576
+ *
4577
+ * Integrations live behind a different gateway (`INTEGRATION_API` /
4578
+ * `host/luma/integrations`) than the rest of the platform API, so this
4579
+ * returns an independently-configured `Integrations` client (it does not
4580
+ * reuse `this.client`, whose base URL points at the platform host). The
4581
+ * Platform's resolved token/env/host are propagated so the child client
4582
+ * carries the same credentials.
4583
+ */
4584
+ integrations() {
4585
+ return new Integrations(this.getIntegrationsGatewayOptions());
4586
+ }
4587
+ /**
4588
+ * Convenience factory for the Satellites (custom JSON-RPC integrations) client.
4589
+ *
4590
+ * Same gateway note as `integrations()` — Satellites talks to the
4591
+ * integrations gateway, not the platform host, so a fresh, independently
4592
+ * configured client is returned, with the Platform's credentials propagated.
4593
+ */
4594
+ satellites() {
4595
+ return new Satellites(this.getIntegrationsGatewayOptions());
4596
+ }
4597
+ /**
4598
+ * Builds the options for a child integrations-gateway client (`Integrations`/
4599
+ * `Satellites`), propagating this Platform's resolved token/env, and deriving
4600
+ * the gateway host from this Platform's host when one was explicitly set.
4601
+ * When `this.host` is unset, `host` is left `undefined` so the child client's
4602
+ * own env-var/default resolution applies.
4603
+ */
4604
+ getIntegrationsGatewayOptions() {
4605
+ var _a, _b;
4606
+ return {
4607
+ token: (_a = this.token) !== null && _a !== void 0 ? _a : undefined,
4608
+ env: (_b = this.env) !== null && _b !== void 0 ? _b : undefined,
4609
+ host: this.host ? `${this.host.replace(/\/+$/, "")}/luma/integrations` : undefined,
4610
+ };
4611
+ }
4612
+ /**
4613
+ * Transactions (billing) client — subscriptions, invoices, credits/balance,
4614
+ * usage pricing and billing-mode overrides. Reached through the platform
4615
+ * gateway (`transactions/…`), so it reuses `this.client` like the other
4616
+ * native/proxied-service factories.
4617
+ *
4618
+ * This is the **billing** service — not distributed/database transactions.
4619
+ */
4620
+ transactions() {
4621
+ return (new Transactions()).setClient(this.client);
4622
+ }
4623
+ /**
4624
+ * Alias for `transactions()` — reads more naturally at call sites that
4625
+ * only care about billing (`platform.billing().getBalance()`).
4626
+ */
4627
+ billing() {
4628
+ return this.transactions();
4629
+ }
4630
+ }
4631
+
3851
4632
  // PRN — Protokol Resource Name
3852
4633
  //
3853
4634
  // Format:
@@ -4000,4 +4781,4 @@ class Invoicing extends PlatformBaseClient {
4000
4781
  }
4001
4782
  }
4002
4783
 
4003
- export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Ecommerce, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Kortex, Mail, NBS, PRN, Payments, Platform, Project, Ratchet, Sandbox, Satellites, MinFin as SerbiaMinFin, System, Thunder, Timber, Users, VPFR, Workflow, parsePRN };
4784
+ export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Ecommerce, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Kortex, Mail, NBS, PRN, Payments, Platform, Project, Ratchet, Sandbox, Satellites, MinFin as SerbiaMinFin, System, Thunder, Timber, Transactions, Users, VPFR, Workflow, parsePRN };