@ptkl/sdk 1.14.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,6 +1487,68 @@ 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
 
1295
1554
  /**
@@ -1402,7 +1661,8 @@ class Forge extends PlatformBaseClient {
1402
1661
  *
1403
1662
  * Resolving the app does NOT grant access. Execution is still authorized against
1404
1663
  * the caller's permissions — for a `platform`-access service the caller must hold
1405
- * `execute forge::service::{appUuid}::{name}`; `public`-access services require none.
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.
1406
1666
  */
1407
1667
  async runService(target, body, options) {
1408
1668
  var _a;
@@ -1422,148 +1682,161 @@ class Forge extends PlatformBaseClient {
1422
1682
  }
1423
1683
  // Service execution is owned by the forge runtime (forge-runtime gateway ->
1424
1684
  // platform-forge), which resolves the ref (name → uuid, marketplace → custom)
1425
- // and executes the service, enforcing `execute forge::service::{uuid}::{name}`
1685
+ // and executes the service, enforcing `service::{name} forge::{uuid}`
1426
1686
  // for platform-access services before running.
1427
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);
1428
1688
  }
1429
1689
  }
1430
1690
 
1431
- const BASE = '/luma/kortex/v1';
1691
+ const BASE$1 = '/luma/kortex/v1';
1432
1692
  class Kortex extends PlatformBaseClient {
1433
1693
  // ── Agents ──
1434
1694
  async createAgent(data) {
1435
- return await this.client.post(`${BASE}/agents`, data);
1695
+ return await this.client.post(`${BASE$1}/agents`, data);
1436
1696
  }
1437
1697
  async listAgents(params) {
1438
- return await this.client.get(`${BASE}/agents`, { params });
1698
+ return await this.client.get(`${BASE$1}/agents`, { params });
1439
1699
  }
1440
1700
  async getAgent(uuid) {
1441
- return await this.client.get(`${BASE}/agents/${uuid}`);
1701
+ return await this.client.get(`${BASE$1}/agents/${uuid}`);
1442
1702
  }
1443
1703
  async updateAgent(uuid, data) {
1444
- return await this.client.patch(`${BASE}/agents/${uuid}`, data);
1704
+ return await this.client.patch(`${BASE$1}/agents/${uuid}`, data);
1445
1705
  }
1446
1706
  async deleteAgent(uuid) {
1447
- return await this.client.delete(`${BASE}/agents/${uuid}`);
1707
+ return await this.client.delete(`${BASE$1}/agents/${uuid}`);
1448
1708
  }
1449
1709
  async listAgentKnowledgeBases(agentUUID) {
1450
- return await this.client.get(`${BASE}/agents/${agentUUID}/knowledge-bases`);
1710
+ return await this.client.get(`${BASE$1}/agents/${agentUUID}/knowledge-bases`);
1451
1711
  }
1452
1712
  // ── Knowledge Bases ──
1453
1713
  async createKnowledgeBase(data) {
1454
- return await this.client.post(`${BASE}/knowledge-bases`, data);
1714
+ return await this.client.post(`${BASE$1}/knowledge-bases`, data);
1455
1715
  }
1456
1716
  async listKnowledgeBases(params) {
1457
- return await this.client.get(`${BASE}/knowledge-bases`, { params });
1717
+ return await this.client.get(`${BASE$1}/knowledge-bases`, { params });
1458
1718
  }
1459
1719
  async getKnowledgeBase(uuid) {
1460
- return await this.client.get(`${BASE}/knowledge-bases/${uuid}`);
1720
+ return await this.client.get(`${BASE$1}/knowledge-bases/${uuid}`);
1461
1721
  }
1462
1722
  async updateKnowledgeBase(uuid, data) {
1463
- return await this.client.put(`${BASE}/knowledge-bases/${uuid}`, data);
1723
+ return await this.client.put(`${BASE$1}/knowledge-bases/${uuid}`, data);
1464
1724
  }
1465
1725
  async deleteKnowledgeBase(uuid) {
1466
- 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);
1467
1733
  }
1468
1734
  // ── Documents ──
1469
1735
  async listDocuments(kbUUID, params) {
1470
- return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents`, { params });
1736
+ return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, { params });
1471
1737
  }
1472
1738
  async uploadDocument(kbUUID, formData) {
1473
- return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents`, formData, {
1739
+ return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, formData, {
1474
1740
  headers: { 'Content-Type': 'multipart/form-data' },
1475
1741
  timeout: 120000,
1476
1742
  });
1477
1743
  }
1478
1744
  async getDocument(kbUUID, uuid) {
1479
- return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1745
+ return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1480
1746
  }
1481
1747
  async deleteDocument(kbUUID, uuid) {
1482
- return await this.client.delete(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1748
+ return await this.client.delete(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1483
1749
  }
1484
1750
  async retryDocument(kbUUID, uuid) {
1485
- 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`);
1486
1752
  }
1487
1753
  // ── Conversations ──
1488
1754
  async createConversation(data) {
1489
- return await this.client.post(`${BASE}/conversations`, data);
1755
+ return await this.client.post(`${BASE$1}/conversations`, data);
1490
1756
  }
1491
1757
  async listConversations(params) {
1492
- return await this.client.get(`${BASE}/conversations`, { params });
1758
+ return await this.client.get(`${BASE$1}/conversations`, { params });
1493
1759
  }
1494
1760
  async getConversation(uuid) {
1495
- return await this.client.get(`${BASE}/conversations/${uuid}`);
1761
+ return await this.client.get(`${BASE$1}/conversations/${uuid}`);
1496
1762
  }
1497
1763
  async updateConversation(uuid, data) {
1498
- return await this.client.put(`${BASE}/conversations/${uuid}`, data);
1764
+ return await this.client.put(`${BASE$1}/conversations/${uuid}`, data);
1499
1765
  }
1500
1766
  async deleteConversation(uuid) {
1501
- return await this.client.delete(`${BASE}/conversations/${uuid}`);
1767
+ return await this.client.delete(`${BASE$1}/conversations/${uuid}`);
1502
1768
  }
1503
1769
  async archiveConversation(uuid) {
1504
- return await this.client.post(`${BASE}/conversations/${uuid}/archive`);
1770
+ return await this.client.post(`${BASE$1}/conversations/${uuid}/archive`);
1505
1771
  }
1506
1772
  async unarchiveConversation(uuid) {
1507
- return await this.client.post(`${BASE}/conversations/${uuid}/unarchive`);
1773
+ return await this.client.post(`${BASE$1}/conversations/${uuid}/unarchive`);
1508
1774
  }
1509
1775
  async addParticipant(conversationUUID, data) {
1510
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/participants`, data);
1776
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/participants`, data);
1511
1777
  }
1512
1778
  async removeParticipant(conversationUUID, agentUUID) {
1513
- return await this.client.delete(`${BASE}/conversations/${conversationUUID}/participants/${agentUUID}`);
1779
+ return await this.client.delete(`${BASE$1}/conversations/${conversationUUID}/participants/${agentUUID}`);
1514
1780
  }
1515
1781
  // ── Messages / Completions ──
1516
1782
  async sendMessage(conversationUUID, data) {
1517
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, data);
1783
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, data);
1518
1784
  }
1519
1785
  async streamMessage(conversationUUID, data) {
1520
- 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 }, {
1521
1787
  responseType: 'stream',
1522
1788
  timeout: 120000,
1523
1789
  });
1524
1790
  }
1525
1791
  async listMessages(conversationUUID, params) {
1526
- return await this.client.get(`${BASE}/conversations/${conversationUUID}/messages`, { params });
1792
+ return await this.client.get(`${BASE$1}/conversations/${conversationUUID}/messages`, { params });
1527
1793
  }
1528
1794
  async injectMessage(conversationUUID, data) {
1529
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages/inject`, data);
1795
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
1530
1796
  }
1531
1797
  // ── OCR ──
1532
1798
  async ocr(data) {
1533
- 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 });
1534
1807
  }
1535
1808
  // ── User Access ──
1536
1809
  async createUserAccess(data) {
1537
- return await this.client.post(`${BASE}/user-access`, data);
1810
+ return await this.client.post(`${BASE$1}/user-access`, data);
1538
1811
  }
1539
1812
  async listUserAccess(params) {
1540
- return await this.client.get(`${BASE}/user-access`, { params });
1813
+ return await this.client.get(`${BASE$1}/user-access`, { params });
1541
1814
  }
1542
1815
  async getUserAccess(uuid) {
1543
- return await this.client.get(`${BASE}/user-access/${uuid}`);
1816
+ return await this.client.get(`${BASE$1}/user-access/${uuid}`);
1544
1817
  }
1545
1818
  async updateUserAccess(uuid, data) {
1546
- return await this.client.patch(`${BASE}/user-access/${uuid}`, data);
1819
+ return await this.client.patch(`${BASE$1}/user-access/${uuid}`, data);
1547
1820
  }
1548
1821
  async deleteUserAccess(uuid) {
1549
- return await this.client.delete(`${BASE}/user-access/${uuid}`);
1822
+ return await this.client.delete(`${BASE$1}/user-access/${uuid}`);
1550
1823
  }
1551
1824
  async getUserMonthlyUsage(uuid, params) {
1552
- return await this.client.get(`${BASE}/user-access/${uuid}/usage`, { params });
1825
+ return await this.client.get(`${BASE$1}/user-access/${uuid}/usage`, { params });
1553
1826
  }
1554
1827
  async getUserUsageBreakdown(uuid) {
1555
- return await this.client.get(`${BASE}/user-access/${uuid}/usage/breakdown`);
1828
+ return await this.client.get(`${BASE$1}/user-access/${uuid}/usage/breakdown`);
1556
1829
  }
1557
1830
  async getMyAccess() {
1558
- return await this.client.get(`${BASE}/my-access`);
1831
+ return await this.client.get(`${BASE$1}/my-access`);
1559
1832
  }
1560
1833
  // ── Usage (Admin) ──
1561
1834
  async listUsage(params) {
1562
- return await this.client.get(`${BASE}/usage`, { params });
1835
+ return await this.client.get(`${BASE$1}/usage`, { params });
1563
1836
  }
1564
1837
  // ── Tier ──
1565
1838
  async getTier() {
1566
- return await this.client.get(`${BASE}/tier`);
1839
+ return await this.client.get(`${BASE$1}/tier`);
1567
1840
  }
1568
1841
  }
1569
1842
 
@@ -1594,12 +1867,50 @@ class Project extends PlatformBaseClient {
1594
1867
  return await this.client.patch("/v1/project/archive");
1595
1868
  }
1596
1869
  /**
1597
- * Invite a user to the project
1598
- * @param emails Array of emails
1599
- * @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
1600
1890
  */
1601
- async invite(emails, roles) {
1602
- 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
+ };
1603
1914
  }
1604
1915
  /**
1605
1916
  * Get list of project invites
@@ -1729,25 +2040,49 @@ class Project extends PlatformBaseClient {
1729
2040
  return await this.client.get("/v1/project/template/workspace");
1730
2041
  }
1731
2042
  /**
1732
- * Install a template
1733
- * @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? }`
1734
2054
  */
1735
2055
  async installTemplate(data) {
1736
- 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 } });
1737
2058
  }
1738
2059
  /**
1739
- * Uninstall a template
1740
- * @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? }`
1741
2068
  */
1742
2069
  async uninstallTemplate(data) {
1743
- 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 } });
1744
2072
  }
1745
2073
  /**
1746
- * Upgrade a template
1747
- * @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? }`
1748
2082
  */
1749
2083
  async upgradeTemplate(data) {
1750
- 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 } });
1751
2086
  }
1752
2087
  }
1753
2088
 
@@ -1767,62 +2102,6 @@ class Config extends PlatformBaseClient {
1767
2102
  }
1768
2103
  }
1769
2104
 
1770
- // apis
1771
- class Platform extends PlatformBaseClient {
1772
- getPlatformClient() {
1773
- return this.client;
1774
- }
1775
- getPlatformBaseURL() {
1776
- var _a;
1777
- return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
1778
- }
1779
- apiUser() {
1780
- return (new APIUser()).setClient(this.client);
1781
- }
1782
- function() {
1783
- return (new Functions()).setClient(this.client);
1784
- }
1785
- user() {
1786
- return (new Users()).setClient(this.client);
1787
- }
1788
- app(appType) {
1789
- return (new Apps(appType)).setClient(this.client);
1790
- }
1791
- forge() {
1792
- return (new Forge()).setClient(this.client);
1793
- }
1794
- kortex() {
1795
- return (new Kortex()).setClient(this.client);
1796
- }
1797
- component(ref) {
1798
- return (new Component(ref)).setClient(this.client);
1799
- }
1800
- componentUtils() {
1801
- return (new ComponentUtils()).setClient(this.client);
1802
- }
1803
- ratchet() {
1804
- return (new Ratchet()).setClient(this.client);
1805
- }
1806
- sandbox() {
1807
- return (new Sandbox()).setClient(this.client);
1808
- }
1809
- system() {
1810
- return (new System()).setClient(this.client);
1811
- }
1812
- workflow() {
1813
- return (new Workflow()).setClient(this.client);
1814
- }
1815
- thunder() {
1816
- return (new Thunder()).setClient(this.client);
1817
- }
1818
- project() {
1819
- return (new Project()).setClient(this.client);
1820
- }
1821
- config() {
1822
- return (new Config()).setClient(this.client);
1823
- }
1824
- }
1825
-
1826
2105
  class IntegrationsBaseClient extends BaseClient {
1827
2106
  constructor(options) {
1828
2107
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2701,6 +2980,135 @@ class DMS extends IntegrationsBaseClient {
2701
2980
  timeout: 120000
2702
2981
  });
2703
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
+ }
2704
3112
  async request(method, endpoint, params) {
2705
3113
  return await this.client.request({
2706
3114
  method: method,
@@ -3870,6 +4278,65 @@ class Integrations extends IntegrationsBaseClient {
3870
4278
  const { data } = await this.client.get("/v1/integrations");
3871
4279
  return data.find((i) => i.id == id && i.status == "active") !== undefined;
3872
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
+ }
3873
4340
  getInterfaceOf(id) {
3874
4341
  try {
3875
4342
  return this.integrations[id];
@@ -3882,57 +4349,286 @@ class Integrations extends IntegrationsBaseClient {
3882
4349
 
3883
4350
  class Satellites extends IntegrationsBaseClient {
3884
4351
  async list() {
3885
- const { data } = await this.client.get('/satellites/templates');
4352
+ const { data } = await this.client.get('/v1/satellites/templates');
3886
4353
  return data;
3887
4354
  }
3888
4355
  async create(payload) {
3889
- const { data } = await this.client.post('/satellites/templates', payload.template);
4356
+ const { data } = await this.client.post('/v1/satellites/templates', payload.template);
3890
4357
  if (payload.schema) {
3891
4358
  await this.createVersion(data.id, payload.schema);
3892
4359
  }
3893
4360
  return data;
3894
4361
  }
3895
4362
  async get(id) {
3896
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}`);
4363
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}`);
3897
4364
  return data;
3898
4365
  }
3899
4366
  async delete(id) {
3900
- const { data } = await this.client.delete(`/satellites/templates/${encodeURIComponent(id)}`);
4367
+ const { data } = await this.client.delete(`/v1/satellites/templates/${encodeURIComponent(id)}`);
3901
4368
  return data;
3902
4369
  }
3903
4370
  async createVersion(id, payload) {
3904
- 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);
3905
4372
  return data;
3906
4373
  }
3907
4374
  async versions(id) {
3908
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/versions`);
4375
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`);
3909
4376
  return data;
3910
4377
  }
3911
4378
  async deploy(id, payload) {
3912
- 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);
3913
4380
  return data;
3914
4381
  }
3915
4382
  async rollback(id, payload) {
3916
- 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);
3917
4384
  return data;
3918
4385
  }
3919
4386
  async permissions(id) {
3920
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/permissions`);
4387
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/permissions`);
3921
4388
  return data;
3922
4389
  }
3923
4390
  async logs(id, params = {}) {
3924
4391
  const since = params.since instanceof Date ? params.since.toISOString() : params.since;
3925
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/logs`, {
4392
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/logs`, {
3926
4393
  params: since ? { since } : undefined,
3927
4394
  });
3928
4395
  return data;
3929
4396
  }
3930
4397
  async execute(id, command, payload = {}) {
3931
- 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);
3932
4399
  return data;
3933
4400
  }
3934
4401
  }
3935
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
+
3936
4632
  // PRN — Protokol Resource Name
3937
4633
  //
3938
4634
  // Format:
@@ -4085,4 +4781,4 @@ class Invoicing extends PlatformBaseClient {
4085
4781
  }
4086
4782
  }
4087
4783
 
4088
- 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 };