@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.
- package/dist/index.0.10.js +911 -129
- package/dist/index.0.9.js +22 -1
- package/dist/package.json +1 -1
- package/dist/v0.10/api/component.d.ts +3 -2
- package/dist/v0.10/api/forge.d.ts +24 -2
- package/dist/v0.10/api/index.d.ts +2 -0
- package/dist/v0.10/api/integrations/dms.d.ts +93 -1
- package/dist/v0.10/api/integrations.d.ts +38 -0
- package/dist/v0.10/api/kortex.d.ts +4 -1
- package/dist/v0.10/api/platform.d.ts +44 -0
- package/dist/v0.10/api/project.d.ts +52 -11
- package/dist/v0.10/api/sandbox.d.ts +126 -2
- package/dist/v0.10/api/transactions.d.ts +75 -0
- package/dist/v0.10/api/users.d.ts +22 -3
- package/dist/v0.10/api/workflow.d.ts +25 -1
- package/dist/v0.10/index.cjs.js +911 -129
- package/dist/v0.10/index.esm.js +911 -130
- package/dist/v0.10/types/component.d.ts +9 -1
- package/dist/v0.10/types/integrations.d.ts +142 -0
- package/dist/v0.10/types/kortex.d.ts +16 -1
- package/dist/v0.10/types/sandbox.d.ts +116 -0
- package/dist/v0.10/types/transactions.d.ts +198 -0
- package/dist/v0.10/types/users.d.ts +10 -0
- package/dist/v0.10/types/workflow.d.ts +104 -1
- package/dist/v0.9/api/users.d.ts +22 -3
- package/dist/v0.9/index.cjs.js +22 -1
- package/dist/v0.9/index.esm.js +22 -1
- package/dist/v0.9/types/component.d.ts +1 -0
- package/dist/v0.9/types/users.d.ts +10 -0
- package/package.json +1 -1
package/dist/v0.10/index.cjs.js
CHANGED
|
@@ -19066,6 +19066,9 @@ class PlatformBaseClient extends BaseClient {
|
|
|
19066
19066
|
this.env = null;
|
|
19067
19067
|
this.token = null;
|
|
19068
19068
|
this.host = null;
|
|
19069
|
+
this.env = env;
|
|
19070
|
+
this.token = token;
|
|
19071
|
+
this.host = host;
|
|
19069
19072
|
}
|
|
19070
19073
|
}
|
|
19071
19074
|
|
|
@@ -19083,6 +19086,7 @@ class Component extends PlatformBaseClient {
|
|
|
19083
19086
|
if (opts && opts.stream === true) {
|
|
19084
19087
|
let onMetaCallback = () => { };
|
|
19085
19088
|
let onDataCallback = () => { };
|
|
19089
|
+
let onCursorCallback = () => { };
|
|
19086
19090
|
let onErrorCallback;
|
|
19087
19091
|
let onEndCallback;
|
|
19088
19092
|
let isFirstLine = true;
|
|
@@ -19095,6 +19099,10 @@ class Component extends PlatformBaseClient {
|
|
|
19095
19099
|
onDataCallback = callback;
|
|
19096
19100
|
return chainable;
|
|
19097
19101
|
},
|
|
19102
|
+
onCursor: (callback) => {
|
|
19103
|
+
onCursorCallback = callback;
|
|
19104
|
+
return chainable;
|
|
19105
|
+
},
|
|
19098
19106
|
onError: (callback) => {
|
|
19099
19107
|
onErrorCallback = callback;
|
|
19100
19108
|
return chainable;
|
|
@@ -19113,6 +19121,11 @@ class Component extends PlatformBaseClient {
|
|
|
19113
19121
|
if (result instanceof Promise)
|
|
19114
19122
|
await result;
|
|
19115
19123
|
}
|
|
19124
|
+
else if ('next_cursor' in doc && !('uuid' in doc)) {
|
|
19125
|
+
const result = onCursorCallback(doc);
|
|
19126
|
+
if (result instanceof Promise)
|
|
19127
|
+
await result;
|
|
19128
|
+
}
|
|
19116
19129
|
else {
|
|
19117
19130
|
const result = onDataCallback(doc);
|
|
19118
19131
|
if (result instanceof Promise)
|
|
@@ -19183,6 +19196,8 @@ class Component extends PlatformBaseClient {
|
|
|
19183
19196
|
};
|
|
19184
19197
|
if (ctx.only && ctx.only.length > 0)
|
|
19185
19198
|
params.only = ctx.only;
|
|
19199
|
+
if (ctx.cursor)
|
|
19200
|
+
params.cursor = ctx.cursor;
|
|
19186
19201
|
if (Object.keys(ctx.$adv || {}).length > 0)
|
|
19187
19202
|
params.$adv = [(_b = ctx.$adv) !== null && _b !== void 0 ? _b : {}];
|
|
19188
19203
|
if (ctx.$aggregate && ctx.$aggregate.length > 0)
|
|
@@ -19849,11 +19864,32 @@ class Users extends PlatformBaseClient {
|
|
|
19849
19864
|
}
|
|
19850
19865
|
// Permissions & Roles
|
|
19851
19866
|
/**
|
|
19852
|
-
* Get
|
|
19867
|
+
* Get the current token's permissions.
|
|
19868
|
+
*
|
|
19869
|
+
* Returns the resolved permission set carried by the calling token. For a
|
|
19870
|
+
* forge actor token this is the scoped intersection minted at launch time —
|
|
19871
|
+
* see `getPrincipalPermissions()` for the underlying user's full set.
|
|
19853
19872
|
*/
|
|
19854
19873
|
async getPermissions() {
|
|
19855
19874
|
return await this.client.get("/v1/user/role/permissions");
|
|
19856
19875
|
}
|
|
19876
|
+
/**
|
|
19877
|
+
* Get the FULL permissions of the user the current token is acting on behalf
|
|
19878
|
+
* of (the "principal").
|
|
19879
|
+
*
|
|
19880
|
+
* When a forge app runs under an actor token, `getPermissions()` returns only
|
|
19881
|
+
* the token's scoped permissions — the intersection of the app's declared
|
|
19882
|
+
* runtime permissions and the user's permissions. This instead returns the
|
|
19883
|
+
* complete permission set of the underlying user, so the app can check what
|
|
19884
|
+
* that user is actually allowed to do, independent of what the app itself was
|
|
19885
|
+
* granted. The token scope is unchanged: this exposes knowledge, not capability.
|
|
19886
|
+
*
|
|
19887
|
+
* For a normal user session (no actor token) it returns the caller's own
|
|
19888
|
+
* permissions, identical to `getPermissions()`'s scope.
|
|
19889
|
+
*/
|
|
19890
|
+
async getPrincipalPermissions() {
|
|
19891
|
+
return await this.client.get("/v1/user/role/principal-permissions");
|
|
19892
|
+
}
|
|
19857
19893
|
/**
|
|
19858
19894
|
* Get list of available permissions
|
|
19859
19895
|
*/
|
|
@@ -19938,7 +19974,7 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
19938
19974
|
* @returns Promise resolving to the created/updated component
|
|
19939
19975
|
*/
|
|
19940
19976
|
async setup(data) {
|
|
19941
|
-
return await this.client.post("/
|
|
19977
|
+
return await this.client.post("/v4/system/component/setup", data);
|
|
19942
19978
|
}
|
|
19943
19979
|
}
|
|
19944
19980
|
|
|
@@ -20194,9 +20230,22 @@ class Ratchet extends PlatformBaseClient {
|
|
|
20194
20230
|
}
|
|
20195
20231
|
}
|
|
20196
20232
|
|
|
20233
|
+
/**
|
|
20234
|
+
* Sandbox client — spark (FaaS) functions/apps, long-running runtimes, and
|
|
20235
|
+
* their K8s deployments. All routes go through the `sandbox/…` gateway
|
|
20236
|
+
* prefix (`/luma/sandbox/v1/...`), matching the sandbox service's REST
|
|
20237
|
+
* surface (`internal/controllers/{spark.go,spark.v1.go,runtime.v1.go}` and
|
|
20238
|
+
* the deployment lifecycle in `internal/controllers/ecomm/deployment.go`).
|
|
20239
|
+
*/
|
|
20197
20240
|
class Sandbox extends PlatformBaseClient {
|
|
20241
|
+
// ---------------------------------------------------------------
|
|
20242
|
+
// Spark (FaaS functions / apps)
|
|
20243
|
+
// ---------------------------------------------------------------
|
|
20198
20244
|
/**
|
|
20199
|
-
* Call the sandbox service to execute a serverless function
|
|
20245
|
+
* Call the sandbox service to execute a serverless function.
|
|
20246
|
+
*
|
|
20247
|
+
* Kept for backwards compatibility — equivalent to
|
|
20248
|
+
* `execSpark(name, data)`.
|
|
20200
20249
|
*
|
|
20201
20250
|
* @param name
|
|
20202
20251
|
* @param data
|
|
@@ -20208,6 +20257,143 @@ class Sandbox extends PlatformBaseClient {
|
|
|
20208
20257
|
async spark(name, data) {
|
|
20209
20258
|
return await this.client.post(`/luma/sandbox/v1/spark/exec/${name}`, data);
|
|
20210
20259
|
}
|
|
20260
|
+
/**
|
|
20261
|
+
* Create a new spark (function or app).
|
|
20262
|
+
*
|
|
20263
|
+
* @example
|
|
20264
|
+
* const spark = await platform.sandbox().createSpark({ name: "myFunction", runtime: "node20", memory: 256 })
|
|
20265
|
+
*/
|
|
20266
|
+
async createSpark(payload) {
|
|
20267
|
+
return await this.client.post(`/luma/sandbox/v1/spark`, payload);
|
|
20268
|
+
}
|
|
20269
|
+
/**
|
|
20270
|
+
* Get a spark by uuid.
|
|
20271
|
+
*/
|
|
20272
|
+
async getSpark(uuid) {
|
|
20273
|
+
return await this.client.get(`/luma/sandbox/v1/spark/${uuid}`);
|
|
20274
|
+
}
|
|
20275
|
+
/**
|
|
20276
|
+
* Update a spark's memory/settings/env vars.
|
|
20277
|
+
*/
|
|
20278
|
+
async updateSpark(uuid, payload) {
|
|
20279
|
+
return await this.client.patch(`/luma/sandbox/v1/spark/${uuid}`, payload);
|
|
20280
|
+
}
|
|
20281
|
+
/**
|
|
20282
|
+
* Delete a spark.
|
|
20283
|
+
*/
|
|
20284
|
+
async deleteSpark(uuid) {
|
|
20285
|
+
return await this.client.delete(`/luma/sandbox/v1/spark/${uuid}`);
|
|
20286
|
+
}
|
|
20287
|
+
/**
|
|
20288
|
+
* List all sparks for the current project.
|
|
20289
|
+
*/
|
|
20290
|
+
async listSparks() {
|
|
20291
|
+
return await this.client.get(`/luma/sandbox/v1/spark`);
|
|
20292
|
+
}
|
|
20293
|
+
/**
|
|
20294
|
+
* Deploy a specific spark version to the dev environment.
|
|
20295
|
+
*/
|
|
20296
|
+
async deploySpark(uuid, version) {
|
|
20297
|
+
return await this.client.put(`/luma/sandbox/v1/spark/deploy/${uuid}/${version}`);
|
|
20298
|
+
}
|
|
20299
|
+
/**
|
|
20300
|
+
* Cancel an in-progress spark deployment.
|
|
20301
|
+
*
|
|
20302
|
+
* @param uuid
|
|
20303
|
+
* @param env - defaults to "dev" on the server if omitted
|
|
20304
|
+
*/
|
|
20305
|
+
async cancelSpark(uuid, env) {
|
|
20306
|
+
return await this.client.put(`/luma/sandbox/v1/spark/cancel/${uuid}`, undefined, { params: env ? { env } : undefined });
|
|
20307
|
+
}
|
|
20308
|
+
/**
|
|
20309
|
+
* Release a deployed spark version to the live/public environment.
|
|
20310
|
+
*/
|
|
20311
|
+
async releaseSpark(uuid, version) {
|
|
20312
|
+
return await this.client.put(`/luma/sandbox/v1/spark/release/${uuid}/${version}`);
|
|
20313
|
+
}
|
|
20314
|
+
/**
|
|
20315
|
+
* Execute a deployed spark by name. Mirrors `spark()` but accepts the
|
|
20316
|
+
* full request shape (method/query/headers) — the exec route accepts
|
|
20317
|
+
* GET/POST/PATCH/PUT/DELETE.
|
|
20318
|
+
*
|
|
20319
|
+
* @example
|
|
20320
|
+
* const result = await platform.sandbox().execSpark("myFunction", { foo: "bar" })
|
|
20321
|
+
* const result = await platform.sandbox().execSpark("myFunction", undefined, { method: "GET" })
|
|
20322
|
+
*/
|
|
20323
|
+
async execSpark(name, data, options) {
|
|
20324
|
+
var _a;
|
|
20325
|
+
const method = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : "POST").toLowerCase();
|
|
20326
|
+
return await this.client.request({
|
|
20327
|
+
url: `/luma/sandbox/v1/spark/exec/${name}`,
|
|
20328
|
+
method,
|
|
20329
|
+
data,
|
|
20330
|
+
params: options === null || options === void 0 ? void 0 : options.query,
|
|
20331
|
+
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
20332
|
+
});
|
|
20333
|
+
}
|
|
20334
|
+
/**
|
|
20335
|
+
* Fetch logs for a spark.
|
|
20336
|
+
*/
|
|
20337
|
+
async sparkLogs(uuid, params) {
|
|
20338
|
+
return await this.client.get(`/luma/sandbox/v1/spark/logs/${uuid}`, { params });
|
|
20339
|
+
}
|
|
20340
|
+
/**
|
|
20341
|
+
* Get the current project's spark tier (plan/quota).
|
|
20342
|
+
*/
|
|
20343
|
+
async sparkTier() {
|
|
20344
|
+
return await this.client.get(`/luma/sandbox/v1/spark/project/tier`);
|
|
20345
|
+
}
|
|
20346
|
+
// ---------------------------------------------------------------
|
|
20347
|
+
// Runtimes (long-running user API deployments)
|
|
20348
|
+
// ---------------------------------------------------------------
|
|
20349
|
+
/**
|
|
20350
|
+
* List all runtimes for the current project.
|
|
20351
|
+
*/
|
|
20352
|
+
async listRuntimes() {
|
|
20353
|
+
return await this.client.get(`/luma/sandbox/v1/runtime`);
|
|
20354
|
+
}
|
|
20355
|
+
/**
|
|
20356
|
+
* Create a new runtime.
|
|
20357
|
+
*/
|
|
20358
|
+
async createRuntime(payload) {
|
|
20359
|
+
return await this.client.post(`/luma/sandbox/v1/runtime`, payload);
|
|
20360
|
+
}
|
|
20361
|
+
/**
|
|
20362
|
+
* Get a runtime by ref (name/uuid).
|
|
20363
|
+
*/
|
|
20364
|
+
async getRuntime(ref) {
|
|
20365
|
+
return await this.client.get(`/luma/sandbox/v1/runtime/${ref}`);
|
|
20366
|
+
}
|
|
20367
|
+
/**
|
|
20368
|
+
* Update a runtime's image/resources/env vars/tags.
|
|
20369
|
+
*/
|
|
20370
|
+
async updateRuntime(ref, payload) {
|
|
20371
|
+
return await this.client.patch(`/luma/sandbox/v1/runtime/${ref}`, payload);
|
|
20372
|
+
}
|
|
20373
|
+
/**
|
|
20374
|
+
* Delete a runtime.
|
|
20375
|
+
*/
|
|
20376
|
+
async deleteRuntime(ref) {
|
|
20377
|
+
return await this.client.delete(`/luma/sandbox/v1/runtime/${ref}`);
|
|
20378
|
+
}
|
|
20379
|
+
/**
|
|
20380
|
+
* (Re)deploy a runtime.
|
|
20381
|
+
*/
|
|
20382
|
+
async deployRuntime(ref) {
|
|
20383
|
+
return await this.client.post(`/luma/sandbox/v1/runtime/${ref}/deploy`);
|
|
20384
|
+
}
|
|
20385
|
+
/**
|
|
20386
|
+
* Restart a running runtime.
|
|
20387
|
+
*/
|
|
20388
|
+
async restartRuntime(ref) {
|
|
20389
|
+
return await this.client.post(`/luma/sandbox/v1/runtime/${ref}/restart`);
|
|
20390
|
+
}
|
|
20391
|
+
/**
|
|
20392
|
+
* Fetch logs for a runtime.
|
|
20393
|
+
*/
|
|
20394
|
+
async runtimeLogs(ref, params) {
|
|
20395
|
+
return await this.client.get(`/luma/sandbox/v1/runtime/${ref}/logs`, { params });
|
|
20396
|
+
}
|
|
20211
20397
|
}
|
|
20212
20398
|
|
|
20213
20399
|
class System extends PlatformBaseClient {
|
|
@@ -20235,6 +20421,17 @@ class System extends PlatformBaseClient {
|
|
|
20235
20421
|
}
|
|
20236
20422
|
}
|
|
20237
20423
|
|
|
20424
|
+
function nodeControlQuery(options) {
|
|
20425
|
+
const params = new URLSearchParams();
|
|
20426
|
+
if ((options === null || options === void 0 ? void 0 : options.iterationIdx) !== undefined) {
|
|
20427
|
+
params.set('iteration_idx', String(options.iterationIdx));
|
|
20428
|
+
}
|
|
20429
|
+
if ((options === null || options === void 0 ? void 0 : options.parentNodeId) !== undefined) {
|
|
20430
|
+
params.set('parent_node_id', String(options.parentNodeId));
|
|
20431
|
+
}
|
|
20432
|
+
const qs = params.toString();
|
|
20433
|
+
return qs ? `?${qs}` : '';
|
|
20434
|
+
}
|
|
20238
20435
|
class Workflow extends PlatformBaseClient {
|
|
20239
20436
|
async create(data) {
|
|
20240
20437
|
return await this.client.post(`/v1/project/workflow/workflow`, data);
|
|
@@ -20257,8 +20454,123 @@ class Workflow extends PlatformBaseClient {
|
|
|
20257
20454
|
async publish(event, data) {
|
|
20258
20455
|
return await this.client.post(`/v1/project/workflow/workflow/event/${event}`, data);
|
|
20259
20456
|
}
|
|
20457
|
+
/**
|
|
20458
|
+
* Install (create + publish) a workflow in one call.
|
|
20459
|
+
* Rejects if a workflow with the same name + integrator already exists.
|
|
20460
|
+
*/
|
|
20461
|
+
async install(data) {
|
|
20462
|
+
return await this.client.post(`/v1/project/workflow/workflow/install`, data);
|
|
20463
|
+
}
|
|
20464
|
+
// --- Execution history ---
|
|
20465
|
+
async getHistory(query) {
|
|
20466
|
+
return await this.client.get(`/v1/project/workflow/workflows/history`, { params: query });
|
|
20467
|
+
}
|
|
20468
|
+
async getHistoryEntry(executionUuid) {
|
|
20469
|
+
return await this.client.get(`/v1/project/workflow/workflows/history/${executionUuid}`);
|
|
20470
|
+
}
|
|
20471
|
+
async getStats(query) {
|
|
20472
|
+
return await this.client.get(`/v1/project/workflow/workflows/stats`, { params: query });
|
|
20473
|
+
}
|
|
20474
|
+
// --- Running executions ---
|
|
20475
|
+
async getRunning(query) {
|
|
20476
|
+
return await this.client.get(`/v1/project/workflow/workflows/running`, { params: query });
|
|
20477
|
+
}
|
|
20478
|
+
async getRunningEntry(executionUuid) {
|
|
20479
|
+
return await this.client.get(`/v1/project/workflow/workflows/running/${executionUuid}`);
|
|
20480
|
+
}
|
|
20481
|
+
// --- Workflow execution control ---
|
|
20482
|
+
async pause(executionUuid) {
|
|
20483
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/pause`);
|
|
20484
|
+
}
|
|
20485
|
+
async resume(executionUuid) {
|
|
20486
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/resume`);
|
|
20487
|
+
}
|
|
20488
|
+
async kill(executionUuid) {
|
|
20489
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/kill`);
|
|
20490
|
+
}
|
|
20491
|
+
/**
|
|
20492
|
+
* Restart a failed/killed workflow execution from history.
|
|
20493
|
+
* `clearState: true` discards prior node state instead of a smart resume.
|
|
20494
|
+
*/
|
|
20495
|
+
async restart(executionUuid, options) {
|
|
20496
|
+
const qs = (options === null || options === void 0 ? void 0 : options.clearState) ? '?clear_state=true' : '';
|
|
20497
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/restart${qs}`);
|
|
20498
|
+
}
|
|
20499
|
+
// --- Node-level control ---
|
|
20500
|
+
async pauseNode(executionUuid, nodeId, options) {
|
|
20501
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/pause${nodeControlQuery(options)}`);
|
|
20502
|
+
}
|
|
20503
|
+
async resumeNode(executionUuid, nodeId, options) {
|
|
20504
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/resume${nodeControlQuery(options)}`);
|
|
20505
|
+
}
|
|
20506
|
+
async killNode(executionUuid, nodeId, options) {
|
|
20507
|
+
return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/kill${nodeControlQuery(options)}`);
|
|
20508
|
+
}
|
|
20509
|
+
// --- Errors ---
|
|
20510
|
+
async getErrors() {
|
|
20511
|
+
return await this.client.get(`/v1/project/workflow/errors`);
|
|
20512
|
+
}
|
|
20513
|
+
async removeError(id) {
|
|
20514
|
+
return await this.client.delete(`/v1/project/workflow/errors/${id}`);
|
|
20515
|
+
}
|
|
20516
|
+
async removeAllErrors() {
|
|
20517
|
+
return await this.client.delete(`/v1/project/workflow/errors`);
|
|
20518
|
+
}
|
|
20260
20519
|
}
|
|
20261
20520
|
|
|
20521
|
+
/**
|
|
20522
|
+
* Resolve the current app's UUID from the ambient platform context.
|
|
20523
|
+
* The platform injects it per-installation: FORGE_APP_UUID in __ENV_VARIABLES__
|
|
20524
|
+
* for public views, and forge_app_uuid in sessionStorage for platform views.
|
|
20525
|
+
* Returns null outside the browser (e.g. Node/CLI), where the caller must pass
|
|
20526
|
+
* an explicit appUuid.
|
|
20527
|
+
*/
|
|
20528
|
+
function resolveCurrentAppUuid() {
|
|
20529
|
+
var _a;
|
|
20530
|
+
if (!isBrowser)
|
|
20531
|
+
return null;
|
|
20532
|
+
// @ts-ignore
|
|
20533
|
+
const fromEnv = (_a = window.__ENV_VARIABLES__) === null || _a === void 0 ? void 0 : _a.FORGE_APP_UUID;
|
|
20534
|
+
if (fromEnv)
|
|
20535
|
+
return fromEnv;
|
|
20536
|
+
try {
|
|
20537
|
+
return sessionStorage.getItem("forge_app_uuid");
|
|
20538
|
+
}
|
|
20539
|
+
catch {
|
|
20540
|
+
return null;
|
|
20541
|
+
}
|
|
20542
|
+
}
|
|
20543
|
+
/**
|
|
20544
|
+
* Resolve a service target into { ref, serviceName }.
|
|
20545
|
+
*
|
|
20546
|
+
* Two forms, cleanly split:
|
|
20547
|
+
* - a bare service name (no "prn:" prefix) → the CURRENT app's service (the ref
|
|
20548
|
+
* is the current app's uuid, resolved from the platform context); or
|
|
20549
|
+
* - a service PRN `prn:forge:{ref}:service/{serviceName}` → ANOTHER app's service
|
|
20550
|
+
* (canonical PRN grammar: kind + name in the path, url-encoded).
|
|
20551
|
+
*
|
|
20552
|
+
* A PRN's `ref` may be an app **name** OR a uuid. Names aren't unique within a
|
|
20553
|
+
* project (a marketplace install and a custom app can share one), so the runtime
|
|
20554
|
+
* resolves a name deterministically **marketplace → custom**. Pass the uuid when
|
|
20555
|
+
* you need a *specific* app.
|
|
20556
|
+
*/
|
|
20557
|
+
function parseServiceTarget(target) {
|
|
20558
|
+
if (!target.startsWith("prn:")) {
|
|
20559
|
+
// bare service name → the current app
|
|
20560
|
+
return { ref: resolveCurrentAppUuid(), serviceName: target };
|
|
20561
|
+
}
|
|
20562
|
+
// PRN → another app. Path form: prn:forge:{ref}:service/{serviceName}
|
|
20563
|
+
// (the PRN path segment is "service/{name}", with the name url-encoded).
|
|
20564
|
+
const [, type, ref, ...rest] = target.split(":");
|
|
20565
|
+
const path = rest.join(":"); // the PRN path, e.g. "service/{name}"
|
|
20566
|
+
const [kind, ...nameParts] = path.split("/");
|
|
20567
|
+
const serviceName = decodeURIComponent(nameParts.join("/"));
|
|
20568
|
+
if (type !== "forge" || kind !== "service" || !ref || !serviceName) {
|
|
20569
|
+
throw new Error(`runService: invalid service PRN "${target}" ` +
|
|
20570
|
+
`(expected prn:forge:{ref}:service/{serviceName}, where ref is an app name or uuid)`);
|
|
20571
|
+
}
|
|
20572
|
+
return { ref, serviceName };
|
|
20573
|
+
}
|
|
20262
20574
|
class Forge extends PlatformBaseClient {
|
|
20263
20575
|
// --- Management (appservice) ---
|
|
20264
20576
|
async bundleUpload(buffer) {
|
|
@@ -20296,156 +20608,202 @@ class Forge extends PlatformBaseClient {
|
|
|
20296
20608
|
return await this.client.patch(`/luma/appservice/v1/forge/${ref}/variables`, current);
|
|
20297
20609
|
}
|
|
20298
20610
|
// --- Service execution (forge-runtime) ---
|
|
20299
|
-
|
|
20300
|
-
|
|
20611
|
+
/**
|
|
20612
|
+
* Run a Forge service: `runService(target, body?, { query?, headers? })`.
|
|
20613
|
+
* Mirrors `axios.post(url, data, config)` — the 2nd arg is the request payload.
|
|
20614
|
+
*
|
|
20615
|
+
* `target` is either:
|
|
20616
|
+
* - a bare service name — runs that service on the CURRENT app; or
|
|
20617
|
+
* - a service PRN `prn:forge:{ref}:service/{name}` — runs it on ANOTHER app,
|
|
20618
|
+
* where `ref` is the app's **name** or uuid. A name is resolved by the
|
|
20619
|
+
* runtime deterministically (marketplace → custom); use the uuid to pin a
|
|
20620
|
+
* specific app. This is the addressing to use where there's no ambient
|
|
20621
|
+
* "current app" — e.g. a workflow, which has no per-install uuid to hardcode.
|
|
20622
|
+
*
|
|
20623
|
+
* `body` is sent as the POST body; `options.query` / `options.headers` are optional.
|
|
20624
|
+
*
|
|
20625
|
+
* The current app's uuid (bare-name form) is resolved automatically from the
|
|
20626
|
+
* platform context (FORGE_APP_UUID for public views, forge_app_uuid in
|
|
20627
|
+
* sessionStorage for platform views), so app code never needs its own uuid.
|
|
20628
|
+
*
|
|
20629
|
+
* Resolving the app does NOT grant access. Execution is still authorized against
|
|
20630
|
+
* the caller's permissions — for a `platform`-access service the caller must hold
|
|
20631
|
+
* `service::{name} forge::{appUuid}`; `public`-access services require none. An
|
|
20632
|
+
* app's own runtime token is implicitly granted this for all of its own services.
|
|
20633
|
+
*/
|
|
20634
|
+
async runService(target, body, options) {
|
|
20635
|
+
var _a;
|
|
20636
|
+
const { ref, serviceName } = parseServiceTarget(target);
|
|
20301
20637
|
const queryString = (options === null || options === void 0 ? void 0 : options.query)
|
|
20302
20638
|
? '?' + new URLSearchParams(options.query).toString()
|
|
20303
20639
|
: '';
|
|
20304
20640
|
// @ts-ignore
|
|
20305
20641
|
const devServiceUrl = isBrowser && ((_a = window.__ENV_VARIABLES__) === null || _a === void 0 ? void 0 : _a.FORGE_DEV_SERVICE_URL);
|
|
20306
20642
|
if (devServiceUrl) {
|
|
20307
|
-
|
|
20643
|
+
// The dev service server routes by name; the ref is ignored.
|
|
20644
|
+
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);
|
|
20645
|
+
}
|
|
20646
|
+
if (!ref) {
|
|
20647
|
+
throw new Error("runService: could not resolve the current app from the platform context. " +
|
|
20648
|
+
"Use a service PRN with an explicit ref: prn:forge:{name|uuid}:service/{serviceName}.");
|
|
20308
20649
|
}
|
|
20309
|
-
|
|
20650
|
+
// Service execution is owned by the forge runtime (forge-runtime gateway ->
|
|
20651
|
+
// platform-forge), which resolves the ref (name → uuid, marketplace → custom)
|
|
20652
|
+
// and executes the service, enforcing `service::{name} forge::{uuid}`
|
|
20653
|
+
// for platform-access services before running.
|
|
20654
|
+
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);
|
|
20310
20655
|
}
|
|
20311
20656
|
}
|
|
20312
20657
|
|
|
20313
|
-
const BASE = '/luma/kortex/v1';
|
|
20658
|
+
const BASE$1 = '/luma/kortex/v1';
|
|
20314
20659
|
class Kortex extends PlatformBaseClient {
|
|
20315
20660
|
// ── Agents ──
|
|
20316
20661
|
async createAgent(data) {
|
|
20317
|
-
return await this.client.post(`${BASE}/agents`, data);
|
|
20662
|
+
return await this.client.post(`${BASE$1}/agents`, data);
|
|
20318
20663
|
}
|
|
20319
20664
|
async listAgents(params) {
|
|
20320
|
-
return await this.client.get(`${BASE}/agents`, { params });
|
|
20665
|
+
return await this.client.get(`${BASE$1}/agents`, { params });
|
|
20321
20666
|
}
|
|
20322
20667
|
async getAgent(uuid) {
|
|
20323
|
-
return await this.client.get(`${BASE}/agents/${uuid}`);
|
|
20668
|
+
return await this.client.get(`${BASE$1}/agents/${uuid}`);
|
|
20324
20669
|
}
|
|
20325
20670
|
async updateAgent(uuid, data) {
|
|
20326
|
-
return await this.client.patch(`${BASE}/agents/${uuid}`, data);
|
|
20671
|
+
return await this.client.patch(`${BASE$1}/agents/${uuid}`, data);
|
|
20327
20672
|
}
|
|
20328
20673
|
async deleteAgent(uuid) {
|
|
20329
|
-
return await this.client.delete(`${BASE}/agents/${uuid}`);
|
|
20674
|
+
return await this.client.delete(`${BASE$1}/agents/${uuid}`);
|
|
20330
20675
|
}
|
|
20331
20676
|
async listAgentKnowledgeBases(agentUUID) {
|
|
20332
|
-
return await this.client.get(`${BASE}/agents/${agentUUID}/knowledge-bases`);
|
|
20677
|
+
return await this.client.get(`${BASE$1}/agents/${agentUUID}/knowledge-bases`);
|
|
20333
20678
|
}
|
|
20334
20679
|
// ── Knowledge Bases ──
|
|
20335
20680
|
async createKnowledgeBase(data) {
|
|
20336
|
-
return await this.client.post(`${BASE}/knowledge-bases`, data);
|
|
20681
|
+
return await this.client.post(`${BASE$1}/knowledge-bases`, data);
|
|
20337
20682
|
}
|
|
20338
20683
|
async listKnowledgeBases(params) {
|
|
20339
|
-
return await this.client.get(`${BASE}/knowledge-bases`, { params });
|
|
20684
|
+
return await this.client.get(`${BASE$1}/knowledge-bases`, { params });
|
|
20340
20685
|
}
|
|
20341
20686
|
async getKnowledgeBase(uuid) {
|
|
20342
|
-
return await this.client.get(`${BASE}/knowledge-bases/${uuid}`);
|
|
20687
|
+
return await this.client.get(`${BASE$1}/knowledge-bases/${uuid}`);
|
|
20343
20688
|
}
|
|
20344
20689
|
async updateKnowledgeBase(uuid, data) {
|
|
20345
|
-
return await this.client.put(`${BASE}/knowledge-bases/${uuid}`, data);
|
|
20690
|
+
return await this.client.put(`${BASE$1}/knowledge-bases/${uuid}`, data);
|
|
20346
20691
|
}
|
|
20347
20692
|
async deleteKnowledgeBase(uuid) {
|
|
20348
|
-
return await this.client.delete(`${BASE}/knowledge-bases/${uuid}`);
|
|
20693
|
+
return await this.client.delete(`${BASE$1}/knowledge-bases/${uuid}`);
|
|
20694
|
+
}
|
|
20695
|
+
// Searches the knowledge bases attached to `data.agent_uuid` (collections
|
|
20696
|
+
// are derived from the agent, not passed explicitly). `top_k` is clamped
|
|
20697
|
+
// to 1-10 server-side. Response is `{ chunks: KnowledgeBaseSearchChunk[] }`.
|
|
20698
|
+
async searchKnowledgeBase(data) {
|
|
20699
|
+
return await this.client.post(`${BASE$1}/knowledge-bases/search`, data);
|
|
20349
20700
|
}
|
|
20350
20701
|
// ── Documents ──
|
|
20351
20702
|
async listDocuments(kbUUID, params) {
|
|
20352
|
-
return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents`, { params });
|
|
20703
|
+
return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, { params });
|
|
20353
20704
|
}
|
|
20354
20705
|
async uploadDocument(kbUUID, formData) {
|
|
20355
|
-
return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents`, formData, {
|
|
20706
|
+
return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, formData, {
|
|
20356
20707
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
20357
20708
|
timeout: 120000,
|
|
20358
20709
|
});
|
|
20359
20710
|
}
|
|
20360
20711
|
async getDocument(kbUUID, uuid) {
|
|
20361
|
-
return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
|
|
20712
|
+
return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
|
|
20362
20713
|
}
|
|
20363
20714
|
async deleteDocument(kbUUID, uuid) {
|
|
20364
|
-
return await this.client.delete(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
|
|
20715
|
+
return await this.client.delete(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
|
|
20365
20716
|
}
|
|
20366
20717
|
async retryDocument(kbUUID, uuid) {
|
|
20367
|
-
return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
|
|
20718
|
+
return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
|
|
20368
20719
|
}
|
|
20369
20720
|
// ── Conversations ──
|
|
20370
20721
|
async createConversation(data) {
|
|
20371
|
-
return await this.client.post(`${BASE}/conversations`, data);
|
|
20722
|
+
return await this.client.post(`${BASE$1}/conversations`, data);
|
|
20372
20723
|
}
|
|
20373
20724
|
async listConversations(params) {
|
|
20374
|
-
return await this.client.get(`${BASE}/conversations`, { params });
|
|
20725
|
+
return await this.client.get(`${BASE$1}/conversations`, { params });
|
|
20375
20726
|
}
|
|
20376
20727
|
async getConversation(uuid) {
|
|
20377
|
-
return await this.client.get(`${BASE}/conversations/${uuid}`);
|
|
20728
|
+
return await this.client.get(`${BASE$1}/conversations/${uuid}`);
|
|
20378
20729
|
}
|
|
20379
20730
|
async updateConversation(uuid, data) {
|
|
20380
|
-
return await this.client.put(`${BASE}/conversations/${uuid}`, data);
|
|
20731
|
+
return await this.client.put(`${BASE$1}/conversations/${uuid}`, data);
|
|
20381
20732
|
}
|
|
20382
20733
|
async deleteConversation(uuid) {
|
|
20383
|
-
return await this.client.delete(`${BASE}/conversations/${uuid}`);
|
|
20734
|
+
return await this.client.delete(`${BASE$1}/conversations/${uuid}`);
|
|
20384
20735
|
}
|
|
20385
20736
|
async archiveConversation(uuid) {
|
|
20386
|
-
return await this.client.post(`${BASE}/conversations/${uuid}/archive`);
|
|
20737
|
+
return await this.client.post(`${BASE$1}/conversations/${uuid}/archive`);
|
|
20387
20738
|
}
|
|
20388
20739
|
async unarchiveConversation(uuid) {
|
|
20389
|
-
return await this.client.post(`${BASE}/conversations/${uuid}/unarchive`);
|
|
20740
|
+
return await this.client.post(`${BASE$1}/conversations/${uuid}/unarchive`);
|
|
20390
20741
|
}
|
|
20391
20742
|
async addParticipant(conversationUUID, data) {
|
|
20392
|
-
return await this.client.post(`${BASE}/conversations/${conversationUUID}/participants`, data);
|
|
20743
|
+
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/participants`, data);
|
|
20393
20744
|
}
|
|
20394
20745
|
async removeParticipant(conversationUUID, agentUUID) {
|
|
20395
|
-
return await this.client.delete(`${BASE}/conversations/${conversationUUID}/participants/${agentUUID}`);
|
|
20746
|
+
return await this.client.delete(`${BASE$1}/conversations/${conversationUUID}/participants/${agentUUID}`);
|
|
20396
20747
|
}
|
|
20397
20748
|
// ── Messages / Completions ──
|
|
20398
20749
|
async sendMessage(conversationUUID, data) {
|
|
20399
|
-
return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, data);
|
|
20750
|
+
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, data);
|
|
20400
20751
|
}
|
|
20401
20752
|
async streamMessage(conversationUUID, data) {
|
|
20402
|
-
return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
|
|
20753
|
+
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
|
|
20403
20754
|
responseType: 'stream',
|
|
20404
20755
|
timeout: 120000,
|
|
20405
20756
|
});
|
|
20406
20757
|
}
|
|
20407
20758
|
async listMessages(conversationUUID, params) {
|
|
20408
|
-
return await this.client.get(`${BASE}/conversations/${conversationUUID}/messages`, { params });
|
|
20759
|
+
return await this.client.get(`${BASE$1}/conversations/${conversationUUID}/messages`, { params });
|
|
20409
20760
|
}
|
|
20410
20761
|
async injectMessage(conversationUUID, data) {
|
|
20411
|
-
return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages/inject`, data);
|
|
20762
|
+
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
|
|
20412
20763
|
}
|
|
20413
20764
|
// ── OCR ──
|
|
20414
20765
|
async ocr(data) {
|
|
20415
|
-
return await this.client.post(`${BASE}/ocr`, data, { timeout: 120000 });
|
|
20766
|
+
return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
|
|
20767
|
+
}
|
|
20768
|
+
// ── Workflow ──
|
|
20769
|
+
async workflowComplete(data) {
|
|
20770
|
+
return await this.client.post(`${BASE$1}/workflow/complete`, data);
|
|
20771
|
+
}
|
|
20772
|
+
async workflowOcr(data) {
|
|
20773
|
+
return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
|
|
20416
20774
|
}
|
|
20417
20775
|
// ── User Access ──
|
|
20418
20776
|
async createUserAccess(data) {
|
|
20419
|
-
return await this.client.post(`${BASE}/user-access`, data);
|
|
20777
|
+
return await this.client.post(`${BASE$1}/user-access`, data);
|
|
20420
20778
|
}
|
|
20421
20779
|
async listUserAccess(params) {
|
|
20422
|
-
return await this.client.get(`${BASE}/user-access`, { params });
|
|
20780
|
+
return await this.client.get(`${BASE$1}/user-access`, { params });
|
|
20423
20781
|
}
|
|
20424
20782
|
async getUserAccess(uuid) {
|
|
20425
|
-
return await this.client.get(`${BASE}/user-access/${uuid}`);
|
|
20783
|
+
return await this.client.get(`${BASE$1}/user-access/${uuid}`);
|
|
20426
20784
|
}
|
|
20427
20785
|
async updateUserAccess(uuid, data) {
|
|
20428
|
-
return await this.client.patch(`${BASE}/user-access/${uuid}`, data);
|
|
20786
|
+
return await this.client.patch(`${BASE$1}/user-access/${uuid}`, data);
|
|
20429
20787
|
}
|
|
20430
20788
|
async deleteUserAccess(uuid) {
|
|
20431
|
-
return await this.client.delete(`${BASE}/user-access/${uuid}`);
|
|
20789
|
+
return await this.client.delete(`${BASE$1}/user-access/${uuid}`);
|
|
20432
20790
|
}
|
|
20433
20791
|
async getUserMonthlyUsage(uuid, params) {
|
|
20434
|
-
return await this.client.get(`${BASE}/user-access/${uuid}/usage`, { params });
|
|
20792
|
+
return await this.client.get(`${BASE$1}/user-access/${uuid}/usage`, { params });
|
|
20435
20793
|
}
|
|
20436
20794
|
async getUserUsageBreakdown(uuid) {
|
|
20437
|
-
return await this.client.get(`${BASE}/user-access/${uuid}/usage/breakdown`);
|
|
20795
|
+
return await this.client.get(`${BASE$1}/user-access/${uuid}/usage/breakdown`);
|
|
20438
20796
|
}
|
|
20439
20797
|
async getMyAccess() {
|
|
20440
|
-
return await this.client.get(`${BASE}/my-access`);
|
|
20798
|
+
return await this.client.get(`${BASE$1}/my-access`);
|
|
20441
20799
|
}
|
|
20442
20800
|
// ── Usage (Admin) ──
|
|
20443
20801
|
async listUsage(params) {
|
|
20444
|
-
return await this.client.get(`${BASE}/usage`, { params });
|
|
20802
|
+
return await this.client.get(`${BASE$1}/usage`, { params });
|
|
20445
20803
|
}
|
|
20446
20804
|
// ── Tier ──
|
|
20447
20805
|
async getTier() {
|
|
20448
|
-
return await this.client.get(`${BASE}/tier`);
|
|
20806
|
+
return await this.client.get(`${BASE$1}/tier`);
|
|
20449
20807
|
}
|
|
20450
20808
|
}
|
|
20451
20809
|
|
|
@@ -20476,12 +20834,50 @@ class Project extends PlatformBaseClient {
|
|
|
20476
20834
|
return await this.client.patch("/v1/project/archive");
|
|
20477
20835
|
}
|
|
20478
20836
|
/**
|
|
20479
|
-
* Invite
|
|
20480
|
-
*
|
|
20481
|
-
*
|
|
20837
|
+
* Invite one or more users to the project.
|
|
20838
|
+
*
|
|
20839
|
+
* `POST /v1/project/invite` only accepts a single `email` per request
|
|
20840
|
+
* (see `InviteToProject` in platform-api's
|
|
20841
|
+
* `internal/project/controllers/invite.go`), so this method issues one
|
|
20842
|
+
* request per entry in `emails`, sequentially, with body
|
|
20843
|
+
* `{ email, role_uuid: roles, subject?, comment? }`.
|
|
20844
|
+
*
|
|
20845
|
+
* Return shape (always a single `AxiosResponse`, so existing callers
|
|
20846
|
+
* that do `(await project.invite(...)).data` keep compiling/working
|
|
20847
|
+
* unchanged):
|
|
20848
|
+
* - Exactly one email: the raw `AxiosResponse` from that single request
|
|
20849
|
+
* (`.data` is that invite's response body, as before).
|
|
20850
|
+
* - More than one email: a response shaped like the last request's
|
|
20851
|
+
* `AxiosResponse`, but with `.data` replaced by an array of each
|
|
20852
|
+
* individual request's `.data`, in the same order as `emails`.
|
|
20853
|
+
*
|
|
20854
|
+
* @param emails Array of email addresses to invite
|
|
20855
|
+
* @param roles Array of role UUIDs to grant every invitee
|
|
20856
|
+
* @param extra Optional subject/comment applied to every invite
|
|
20482
20857
|
*/
|
|
20483
|
-
async invite(emails, roles) {
|
|
20484
|
-
|
|
20858
|
+
async invite(emails, roles, extra) {
|
|
20859
|
+
const bodyExtra = {};
|
|
20860
|
+
if ((extra === null || extra === void 0 ? void 0 : extra.subject) !== undefined)
|
|
20861
|
+
bodyExtra.subject = extra.subject;
|
|
20862
|
+
if ((extra === null || extra === void 0 ? void 0 : extra.comment) !== undefined)
|
|
20863
|
+
bodyExtra.comment = extra.comment;
|
|
20864
|
+
const responses = [];
|
|
20865
|
+
for (const email of emails) {
|
|
20866
|
+
const res = await this.client.post("/v1/project/invite", {
|
|
20867
|
+
email,
|
|
20868
|
+
role_uuid: roles,
|
|
20869
|
+
...bodyExtra,
|
|
20870
|
+
});
|
|
20871
|
+
responses.push(res);
|
|
20872
|
+
}
|
|
20873
|
+
if (responses.length === 1) {
|
|
20874
|
+
return responses[0];
|
|
20875
|
+
}
|
|
20876
|
+
const last = responses[responses.length - 1];
|
|
20877
|
+
return {
|
|
20878
|
+
...last,
|
|
20879
|
+
data: responses.map((r) => r.data),
|
|
20880
|
+
};
|
|
20485
20881
|
}
|
|
20486
20882
|
/**
|
|
20487
20883
|
* Get list of project invites
|
|
@@ -20611,25 +21007,49 @@ class Project extends PlatformBaseClient {
|
|
|
20611
21007
|
return await this.client.get("/v1/project/template/workspace");
|
|
20612
21008
|
}
|
|
20613
21009
|
/**
|
|
20614
|
-
* Install a template
|
|
20615
|
-
*
|
|
21010
|
+
* Install a template.
|
|
21011
|
+
*
|
|
21012
|
+
* `POST /v1/project/template/install` decodes body `TemplateInstall = { id,
|
|
21013
|
+
* data, activation_code }` and resolves the target workspace from the
|
|
21014
|
+
* `X-Workspace-Uuid` request header (not the body) — see platform-api's
|
|
21015
|
+
* `template_install.go`. This method keeps the ergonomic object-arg
|
|
21016
|
+
* signature but maps it onto that contract: `template_id` becomes body
|
|
21017
|
+
* `id`, `workspace_uuid` is sent as the `X-Workspace-Uuid` header, and any
|
|
21018
|
+
* `data`/`activation_code` passed in are forwarded in the body as-is.
|
|
21019
|
+
*
|
|
21020
|
+
* @param data `{ template_id, workspace_uuid, data?, activation_code? }`
|
|
20616
21021
|
*/
|
|
20617
21022
|
async installTemplate(data) {
|
|
20618
|
-
|
|
21023
|
+
const { template_id, workspace_uuid, ...rest } = data;
|
|
21024
|
+
return await this.client.post("/v1/project/template/install", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
|
|
20619
21025
|
}
|
|
20620
21026
|
/**
|
|
20621
|
-
* Uninstall a template
|
|
20622
|
-
*
|
|
21027
|
+
* Uninstall a template.
|
|
21028
|
+
*
|
|
21029
|
+
* `POST /v1/project/template/uninstall` decodes body `TemplateInstall = {
|
|
21030
|
+
* id, data, activation_code }` and resolves the target workspace from the
|
|
21031
|
+
* `X-Workspace-Uuid` request header (not the body) — see platform-api's
|
|
21032
|
+
* `template_uninstall.go`. See `installTemplate` for the mapping.
|
|
21033
|
+
*
|
|
21034
|
+
* @param data `{ template_id, workspace_uuid, data?, activation_code? }`
|
|
20623
21035
|
*/
|
|
20624
21036
|
async uninstallTemplate(data) {
|
|
20625
|
-
|
|
21037
|
+
const { template_id, workspace_uuid, ...rest } = data;
|
|
21038
|
+
return await this.client.post("/v1/project/template/uninstall", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
|
|
20626
21039
|
}
|
|
20627
21040
|
/**
|
|
20628
|
-
* Upgrade a template
|
|
20629
|
-
*
|
|
21041
|
+
* Upgrade a template.
|
|
21042
|
+
*
|
|
21043
|
+
* `POST /v1/project/template/upgrade` decodes body `TemplateInstall = {
|
|
21044
|
+
* id, data, activation_code }` and resolves the target workspace from the
|
|
21045
|
+
* `X-Workspace-Uuid` request header (not the body) — see platform-api's
|
|
21046
|
+
* `template_upgrade.go`. See `installTemplate` for the mapping.
|
|
21047
|
+
*
|
|
21048
|
+
* @param data `{ template_id, workspace_uuid, data?, activation_code? }`
|
|
20630
21049
|
*/
|
|
20631
21050
|
async upgradeTemplate(data) {
|
|
20632
|
-
|
|
21051
|
+
const { template_id, workspace_uuid, ...rest } = data;
|
|
21052
|
+
return await this.client.post("/v1/project/template/upgrade", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
|
|
20633
21053
|
}
|
|
20634
21054
|
}
|
|
20635
21055
|
|
|
@@ -20649,62 +21069,6 @@ class Config extends PlatformBaseClient {
|
|
|
20649
21069
|
}
|
|
20650
21070
|
}
|
|
20651
21071
|
|
|
20652
|
-
// apis
|
|
20653
|
-
class Platform extends PlatformBaseClient {
|
|
20654
|
-
getPlatformClient() {
|
|
20655
|
-
return this.client;
|
|
20656
|
-
}
|
|
20657
|
-
getPlatformBaseURL() {
|
|
20658
|
-
var _a;
|
|
20659
|
-
return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
|
|
20660
|
-
}
|
|
20661
|
-
apiUser() {
|
|
20662
|
-
return (new APIUser()).setClient(this.client);
|
|
20663
|
-
}
|
|
20664
|
-
function() {
|
|
20665
|
-
return (new Functions()).setClient(this.client);
|
|
20666
|
-
}
|
|
20667
|
-
user() {
|
|
20668
|
-
return (new Users()).setClient(this.client);
|
|
20669
|
-
}
|
|
20670
|
-
app(appType) {
|
|
20671
|
-
return (new Apps(appType)).setClient(this.client);
|
|
20672
|
-
}
|
|
20673
|
-
forge() {
|
|
20674
|
-
return (new Forge()).setClient(this.client);
|
|
20675
|
-
}
|
|
20676
|
-
kortex() {
|
|
20677
|
-
return (new Kortex()).setClient(this.client);
|
|
20678
|
-
}
|
|
20679
|
-
component(ref) {
|
|
20680
|
-
return (new Component(ref)).setClient(this.client);
|
|
20681
|
-
}
|
|
20682
|
-
componentUtils() {
|
|
20683
|
-
return (new ComponentUtils()).setClient(this.client);
|
|
20684
|
-
}
|
|
20685
|
-
ratchet() {
|
|
20686
|
-
return (new Ratchet()).setClient(this.client);
|
|
20687
|
-
}
|
|
20688
|
-
sandbox() {
|
|
20689
|
-
return (new Sandbox()).setClient(this.client);
|
|
20690
|
-
}
|
|
20691
|
-
system() {
|
|
20692
|
-
return (new System()).setClient(this.client);
|
|
20693
|
-
}
|
|
20694
|
-
workflow() {
|
|
20695
|
-
return (new Workflow()).setClient(this.client);
|
|
20696
|
-
}
|
|
20697
|
-
thunder() {
|
|
20698
|
-
return (new Thunder()).setClient(this.client);
|
|
20699
|
-
}
|
|
20700
|
-
project() {
|
|
20701
|
-
return (new Project()).setClient(this.client);
|
|
20702
|
-
}
|
|
20703
|
-
config() {
|
|
20704
|
-
return (new Config()).setClient(this.client);
|
|
20705
|
-
}
|
|
20706
|
-
}
|
|
20707
|
-
|
|
20708
21072
|
class IntegrationsBaseClient extends BaseClient {
|
|
20709
21073
|
constructor(options) {
|
|
20710
21074
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -21583,6 +21947,135 @@ class DMS extends IntegrationsBaseClient {
|
|
|
21583
21947
|
timeout: 120000
|
|
21584
21948
|
});
|
|
21585
21949
|
}
|
|
21950
|
+
// ===================================================================
|
|
21951
|
+
// Backup (Library Export Archives)
|
|
21952
|
+
// ===================================================================
|
|
21953
|
+
/**
|
|
21954
|
+
* Create a library export archive (a snapshot of the project's library or a directory within it)
|
|
21955
|
+
*
|
|
21956
|
+
* The library is resolved server-side from the project in the auth context —
|
|
21957
|
+
* there is a single library per project.
|
|
21958
|
+
*
|
|
21959
|
+
* @param payload - Optional export scope/format options
|
|
21960
|
+
* @returns `{ mode, export }` when the export is queued asynchronously.
|
|
21961
|
+
* Depending on server-side sizing, the endpoint may instead stream the
|
|
21962
|
+
* archive back directly as a binary response body (not this JSON shape).
|
|
21963
|
+
*
|
|
21964
|
+
* @example
|
|
21965
|
+
* ```typescript
|
|
21966
|
+
* const result = await dms.createExport({ path: 'legal', format: 'zip' });
|
|
21967
|
+
* ```
|
|
21968
|
+
*/
|
|
21969
|
+
async createExport(payload) {
|
|
21970
|
+
return this.request('POST', `library/exports`, { data: payload !== null && payload !== void 0 ? payload : {} });
|
|
21971
|
+
}
|
|
21972
|
+
/**
|
|
21973
|
+
* List export archives for the project's library
|
|
21974
|
+
*/
|
|
21975
|
+
async listExports() {
|
|
21976
|
+
return this.request('GET', `library/exports`);
|
|
21977
|
+
}
|
|
21978
|
+
/**
|
|
21979
|
+
* Get a single export archive (an archived snapshot of a library/dir)
|
|
21980
|
+
*
|
|
21981
|
+
* @param exportUuid - Export UUID
|
|
21982
|
+
* @returns `{ export, download_url }`
|
|
21983
|
+
*/
|
|
21984
|
+
async getExport(exportUuid) {
|
|
21985
|
+
return this.request('GET', `library/exports/${exportUuid}`);
|
|
21986
|
+
}
|
|
21987
|
+
// ===================================================================
|
|
21988
|
+
// Policies (Quota / File-Type / Notification, library & dir scope)
|
|
21989
|
+
// ===================================================================
|
|
21990
|
+
/**
|
|
21991
|
+
* Get the effective library-level policy for the project's library
|
|
21992
|
+
*/
|
|
21993
|
+
async getLibraryPolicy() {
|
|
21994
|
+
return this.request('GET', `library/policy`);
|
|
21995
|
+
}
|
|
21996
|
+
/**
|
|
21997
|
+
* Set/update the library-level policy for the project's library
|
|
21998
|
+
*
|
|
21999
|
+
* @param payload - Policy fields to set
|
|
22000
|
+
*/
|
|
22001
|
+
async setLibraryPolicy(payload) {
|
|
22002
|
+
return this.request('PUT', `library/policy`, { data: payload });
|
|
22003
|
+
}
|
|
22004
|
+
/**
|
|
22005
|
+
* Get the directory-level policy (resolves platform-default → library → dir)
|
|
22006
|
+
*
|
|
22007
|
+
* @param path - Directory path
|
|
22008
|
+
*/
|
|
22009
|
+
async getDirPolicy(path) {
|
|
22010
|
+
return this.request('GET', `library/dir/policy`, { params: { path } });
|
|
22011
|
+
}
|
|
22012
|
+
/**
|
|
22013
|
+
* Set/update the directory-level policy
|
|
22014
|
+
*
|
|
22015
|
+
* @param path - Directory path
|
|
22016
|
+
* @param payload - Policy fields to set (only fields provided override the library policy)
|
|
22017
|
+
*/
|
|
22018
|
+
async setDirPolicy(path, payload) {
|
|
22019
|
+
return this.request('PUT', `library/dir/policy`, { data: payload, params: { path } });
|
|
22020
|
+
}
|
|
22021
|
+
/**
|
|
22022
|
+
* Remove a directory-level policy override (directory falls back to the library policy)
|
|
22023
|
+
*
|
|
22024
|
+
* @param path - Directory path
|
|
22025
|
+
*/
|
|
22026
|
+
async deleteDirPolicy(path) {
|
|
22027
|
+
return this.request('DELETE', `library/dir/policy`, { params: { path } });
|
|
22028
|
+
}
|
|
22029
|
+
// ===================================================================
|
|
22030
|
+
// Reminders (Notification Rules & Per-File Notifications)
|
|
22031
|
+
// ===================================================================
|
|
22032
|
+
/**
|
|
22033
|
+
* List notification rules for the project's library
|
|
22034
|
+
*/
|
|
22035
|
+
async listNotificationRules() {
|
|
22036
|
+
return this.request('GET', `library/notification-rules`);
|
|
22037
|
+
}
|
|
22038
|
+
/**
|
|
22039
|
+
* Create a recurring reminder (notification rule) for a media file
|
|
22040
|
+
*
|
|
22041
|
+
* @param payload - Recurring reminder definition (media_uuid/file_key, frequency, start_at, ...)
|
|
22042
|
+
*/
|
|
22043
|
+
async createNotificationRule(payload) {
|
|
22044
|
+
return this.request('POST', `library/notification-rules`, { data: payload });
|
|
22045
|
+
}
|
|
22046
|
+
/**
|
|
22047
|
+
* Delete a notification rule
|
|
22048
|
+
*
|
|
22049
|
+
* @param ruleUuid - Notification rule UUID
|
|
22050
|
+
*/
|
|
22051
|
+
async deleteNotificationRule(ruleUuid) {
|
|
22052
|
+
return this.request('DELETE', `library/notification-rules/${ruleUuid}`);
|
|
22053
|
+
}
|
|
22054
|
+
/**
|
|
22055
|
+
* List custom reminders scheduled for a specific file
|
|
22056
|
+
*
|
|
22057
|
+
* @param mediaUuid - Media UUID
|
|
22058
|
+
*/
|
|
22059
|
+
async listFileNotifications(mediaUuid) {
|
|
22060
|
+
return this.request('GET', `library/media/${mediaUuid}/notifications`);
|
|
22061
|
+
}
|
|
22062
|
+
/**
|
|
22063
|
+
* Create a custom reminder for a specific file
|
|
22064
|
+
*
|
|
22065
|
+
* @param mediaUuid - Media UUID
|
|
22066
|
+
* @param payload - Reminder details (note, notify_at, optional recipient)
|
|
22067
|
+
*/
|
|
22068
|
+
async createFileNotification(mediaUuid, payload) {
|
|
22069
|
+
return this.request('POST', `library/media/${mediaUuid}/notifications`, { data: payload });
|
|
22070
|
+
}
|
|
22071
|
+
/**
|
|
22072
|
+
* Cancel/delete a custom file reminder
|
|
22073
|
+
*
|
|
22074
|
+
* @param notificationUuid - Notification UUID
|
|
22075
|
+
*/
|
|
22076
|
+
async deleteFileNotification(notificationUuid) {
|
|
22077
|
+
return this.request('DELETE', `library/notifications/${notificationUuid}`);
|
|
22078
|
+
}
|
|
21586
22079
|
async request(method, endpoint, params) {
|
|
21587
22080
|
return await this.client.request({
|
|
21588
22081
|
method: method,
|
|
@@ -22752,6 +23245,65 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
22752
23245
|
const { data } = await this.client.get("/v1/integrations");
|
|
22753
23246
|
return data.find((i) => i.id == id && i.status == "active") !== undefined;
|
|
22754
23247
|
}
|
|
23248
|
+
/**
|
|
23249
|
+
* Install (integrate) an integration into the current project.
|
|
23250
|
+
* POST /v1/integrate
|
|
23251
|
+
*/
|
|
23252
|
+
async install(id, data) {
|
|
23253
|
+
const { data: resp } = await this.client.post("/v1/integrate", {
|
|
23254
|
+
id,
|
|
23255
|
+
...(data !== undefined ? { data } : {}),
|
|
23256
|
+
});
|
|
23257
|
+
return resp;
|
|
23258
|
+
}
|
|
23259
|
+
/**
|
|
23260
|
+
* Uninstall (remove) an integration from the current project.
|
|
23261
|
+
* PUT /v1/integrate
|
|
23262
|
+
*/
|
|
23263
|
+
async uninstall(id) {
|
|
23264
|
+
const { data } = await this.client.put("/v1/integrate", { id });
|
|
23265
|
+
return data;
|
|
23266
|
+
}
|
|
23267
|
+
/**
|
|
23268
|
+
* Activate an installed integration.
|
|
23269
|
+
* POST /v1/integration/{id}/activate
|
|
23270
|
+
*/
|
|
23271
|
+
async activate(id) {
|
|
23272
|
+
const { data } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/activate`);
|
|
23273
|
+
return data;
|
|
23274
|
+
}
|
|
23275
|
+
/**
|
|
23276
|
+
* Deactivate an installed integration.
|
|
23277
|
+
* POST /v1/integration/{id}/deactivate
|
|
23278
|
+
*/
|
|
23279
|
+
async deactivate(id) {
|
|
23280
|
+
const { data } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/deactivate`);
|
|
23281
|
+
return data;
|
|
23282
|
+
}
|
|
23283
|
+
/**
|
|
23284
|
+
* Advance/update the onboarding state of an installed integration.
|
|
23285
|
+
* POST /v1/integration/{id}/onboarding
|
|
23286
|
+
*/
|
|
23287
|
+
async onboarding(id, data) {
|
|
23288
|
+
const { data: resp } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/onboarding`, data);
|
|
23289
|
+
return resp;
|
|
23290
|
+
}
|
|
23291
|
+
/**
|
|
23292
|
+
* List marketplace-available integrations (subscription/geo aware).
|
|
23293
|
+
* GET /v1/marketplace/integrations
|
|
23294
|
+
*/
|
|
23295
|
+
async marketplace() {
|
|
23296
|
+
const { data } = await this.client.get("/v1/marketplace/integrations");
|
|
23297
|
+
return data;
|
|
23298
|
+
}
|
|
23299
|
+
/**
|
|
23300
|
+
* List explorable integration templates (subscription/geo aware).
|
|
23301
|
+
* GET /v1/integrations/explore
|
|
23302
|
+
*/
|
|
23303
|
+
async explore() {
|
|
23304
|
+
const { data } = await this.client.get("/v1/integrations/explore");
|
|
23305
|
+
return data;
|
|
23306
|
+
}
|
|
22755
23307
|
getInterfaceOf(id) {
|
|
22756
23308
|
try {
|
|
22757
23309
|
return this.integrations[id];
|
|
@@ -22764,57 +23316,286 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
22764
23316
|
|
|
22765
23317
|
class Satellites extends IntegrationsBaseClient {
|
|
22766
23318
|
async list() {
|
|
22767
|
-
const { data } = await this.client.get('/satellites/templates');
|
|
23319
|
+
const { data } = await this.client.get('/v1/satellites/templates');
|
|
22768
23320
|
return data;
|
|
22769
23321
|
}
|
|
22770
23322
|
async create(payload) {
|
|
22771
|
-
const { data } = await this.client.post('/satellites/templates', payload.template);
|
|
23323
|
+
const { data } = await this.client.post('/v1/satellites/templates', payload.template);
|
|
22772
23324
|
if (payload.schema) {
|
|
22773
23325
|
await this.createVersion(data.id, payload.schema);
|
|
22774
23326
|
}
|
|
22775
23327
|
return data;
|
|
22776
23328
|
}
|
|
22777
23329
|
async get(id) {
|
|
22778
|
-
const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}`);
|
|
23330
|
+
const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}`);
|
|
22779
23331
|
return data;
|
|
22780
23332
|
}
|
|
22781
23333
|
async delete(id) {
|
|
22782
|
-
const { data } = await this.client.delete(`/satellites/templates/${encodeURIComponent(id)}`);
|
|
23334
|
+
const { data } = await this.client.delete(`/v1/satellites/templates/${encodeURIComponent(id)}`);
|
|
22783
23335
|
return data;
|
|
22784
23336
|
}
|
|
22785
23337
|
async createVersion(id, payload) {
|
|
22786
|
-
const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/versions`, payload);
|
|
23338
|
+
const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`, payload);
|
|
22787
23339
|
return data;
|
|
22788
23340
|
}
|
|
22789
23341
|
async versions(id) {
|
|
22790
|
-
const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/versions`);
|
|
23342
|
+
const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`);
|
|
22791
23343
|
return data;
|
|
22792
23344
|
}
|
|
22793
23345
|
async deploy(id, payload) {
|
|
22794
|
-
const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/deploy`, payload);
|
|
23346
|
+
const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/deploy`, payload);
|
|
22795
23347
|
return data;
|
|
22796
23348
|
}
|
|
22797
23349
|
async rollback(id, payload) {
|
|
22798
|
-
const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/rollback`, payload);
|
|
23350
|
+
const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/rollback`, payload);
|
|
22799
23351
|
return data;
|
|
22800
23352
|
}
|
|
22801
23353
|
async permissions(id) {
|
|
22802
|
-
const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/permissions`);
|
|
23354
|
+
const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/permissions`);
|
|
22803
23355
|
return data;
|
|
22804
23356
|
}
|
|
22805
23357
|
async logs(id, params = {}) {
|
|
22806
23358
|
const since = params.since instanceof Date ? params.since.toISOString() : params.since;
|
|
22807
|
-
const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/logs`, {
|
|
23359
|
+
const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/logs`, {
|
|
22808
23360
|
params: since ? { since } : undefined,
|
|
22809
23361
|
});
|
|
22810
23362
|
return data;
|
|
22811
23363
|
}
|
|
22812
23364
|
async execute(id, command, payload = {}) {
|
|
22813
|
-
const { data } = await this.client.post(`/satellites/${encodeURIComponent(id)}/commands/${encodeURIComponent(command)}/execute`, payload);
|
|
23365
|
+
const { data } = await this.client.post(`/v1/satellites/${encodeURIComponent(id)}/commands/${encodeURIComponent(command)}/execute`, payload);
|
|
22814
23366
|
return data;
|
|
22815
23367
|
}
|
|
22816
23368
|
}
|
|
22817
23369
|
|
|
23370
|
+
const BASE = "/luma/transactions/v1";
|
|
23371
|
+
/**
|
|
23372
|
+
* Transactions client — billing/subscriptions, invoices, credits/balance,
|
|
23373
|
+
* usage pricing and per-project billing-mode overrides. All routes go
|
|
23374
|
+
* through the `transactions/…` gateway prefix (`/luma/transactions/v1/...`),
|
|
23375
|
+
* matching the transactions service's REST surface
|
|
23376
|
+
* (`internal/controllers/{subscription,invoices,topup,credit_history,billing_modes,prices,balance}.go`).
|
|
23377
|
+
*
|
|
23378
|
+
* This is the **billing** service — not distributed/database transactions.
|
|
23379
|
+
*/
|
|
23380
|
+
class Transactions extends PlatformBaseClient {
|
|
23381
|
+
// ---------------------------------------------------------------
|
|
23382
|
+
// Subscriptions
|
|
23383
|
+
// ---------------------------------------------------------------
|
|
23384
|
+
/**
|
|
23385
|
+
* List all subscriptions (including expired) for the current project.
|
|
23386
|
+
*
|
|
23387
|
+
* @example
|
|
23388
|
+
* const subs = await platform.transactions().getSubscriptions()
|
|
23389
|
+
*/
|
|
23390
|
+
async getSubscriptions() {
|
|
23391
|
+
return await this.client.get(`${BASE}/billing/subscription`);
|
|
23392
|
+
}
|
|
23393
|
+
/**
|
|
23394
|
+
* Renew an expired subscription (and any others sharing its bundle
|
|
23395
|
+
* `ref_no`) — creates a renewal invoice and returns a checkout link.
|
|
23396
|
+
*/
|
|
23397
|
+
async renewSubscription(payload) {
|
|
23398
|
+
return await this.client.post(`${BASE}/subscription/renew`, payload);
|
|
23399
|
+
}
|
|
23400
|
+
/**
|
|
23401
|
+
* Cancel a subscription. Issues a refund automatically if still within
|
|
23402
|
+
* the refund period.
|
|
23403
|
+
*/
|
|
23404
|
+
async cancelSubscription(payload) {
|
|
23405
|
+
return await this.client.post(`${BASE}/subscription/cancel`, payload);
|
|
23406
|
+
}
|
|
23407
|
+
// ---------------------------------------------------------------
|
|
23408
|
+
// Invoices
|
|
23409
|
+
// ---------------------------------------------------------------
|
|
23410
|
+
/**
|
|
23411
|
+
* List all invoices for the current project.
|
|
23412
|
+
*/
|
|
23413
|
+
async getInvoices() {
|
|
23414
|
+
return await this.client.get(`${BASE}/billing/invoices`);
|
|
23415
|
+
}
|
|
23416
|
+
/**
|
|
23417
|
+
* Get a single invoice by uuid.
|
|
23418
|
+
*/
|
|
23419
|
+
async getInvoice(uuid) {
|
|
23420
|
+
return await this.client.get(`${BASE}/billing/invoice/${uuid}`);
|
|
23421
|
+
}
|
|
23422
|
+
/**
|
|
23423
|
+
* Download an invoice as a PDF. Resolves with the raw PDF bytes
|
|
23424
|
+
* (`responseType: "arraybuffer"`).
|
|
23425
|
+
*
|
|
23426
|
+
* @example
|
|
23427
|
+
* const { data } = await platform.transactions().getInvoicePdf(uuid)
|
|
23428
|
+
* fs.writeFileSync("invoice.pdf", Buffer.from(data))
|
|
23429
|
+
*/
|
|
23430
|
+
async getInvoicePdf(uuid) {
|
|
23431
|
+
return await this.client.get(`${BASE}/billing/invoice/${uuid}/pdf`, {
|
|
23432
|
+
responseType: "arraybuffer",
|
|
23433
|
+
});
|
|
23434
|
+
}
|
|
23435
|
+
// ---------------------------------------------------------------
|
|
23436
|
+
// Balance / credits / top-up
|
|
23437
|
+
// ---------------------------------------------------------------
|
|
23438
|
+
/**
|
|
23439
|
+
* Get the current project's credit balance.
|
|
23440
|
+
*/
|
|
23441
|
+
async getBalance() {
|
|
23442
|
+
return await this.client.get(`${BASE}/billing/balance`);
|
|
23443
|
+
}
|
|
23444
|
+
/**
|
|
23445
|
+
* Generate a checkout link to manually top up the project's credit balance.
|
|
23446
|
+
*/
|
|
23447
|
+
async topUp(payload) {
|
|
23448
|
+
return await this.client.post(`${BASE}/billing/topup`, payload);
|
|
23449
|
+
}
|
|
23450
|
+
/**
|
|
23451
|
+
* Get the project's credit activity (deductions/top-ups) history, paginated.
|
|
23452
|
+
*/
|
|
23453
|
+
async getCreditsHistory(query) {
|
|
23454
|
+
return await this.client.get(`${BASE}/billing/credits/history`, {
|
|
23455
|
+
params: query,
|
|
23456
|
+
});
|
|
23457
|
+
}
|
|
23458
|
+
// ---------------------------------------------------------------
|
|
23459
|
+
// Prices
|
|
23460
|
+
// ---------------------------------------------------------------
|
|
23461
|
+
/**
|
|
23462
|
+
* Get the usage-based pricing table for a given currency.
|
|
23463
|
+
*
|
|
23464
|
+
* @param currency - ISO 4217 currency code, e.g. "USD" or "RSD".
|
|
23465
|
+
*/
|
|
23466
|
+
async getPrices(currency) {
|
|
23467
|
+
return await this.client.get(`${BASE}/prices/${currency}`);
|
|
23468
|
+
}
|
|
23469
|
+
// ---------------------------------------------------------------
|
|
23470
|
+
// Billing modes (per-project usage billing overrides)
|
|
23471
|
+
// ---------------------------------------------------------------
|
|
23472
|
+
/**
|
|
23473
|
+
* Get the project's usage-billing-mode overrides plus platform defaults.
|
|
23474
|
+
*/
|
|
23475
|
+
async getBillingModes() {
|
|
23476
|
+
return await this.client.get(`${BASE}/billing/billing-modes`);
|
|
23477
|
+
}
|
|
23478
|
+
/**
|
|
23479
|
+
* Set the billing mode ("credits" | "hybrid" | "invoice") for a usage
|
|
23480
|
+
* option code on the current project.
|
|
23481
|
+
*/
|
|
23482
|
+
async updateBillingModes(payload) {
|
|
23483
|
+
return await this.client.put(`${BASE}/billing/billing-modes`, payload);
|
|
23484
|
+
}
|
|
23485
|
+
}
|
|
23486
|
+
|
|
23487
|
+
// apis
|
|
23488
|
+
class Platform extends PlatformBaseClient {
|
|
23489
|
+
getPlatformClient() {
|
|
23490
|
+
return this.client;
|
|
23491
|
+
}
|
|
23492
|
+
getPlatformBaseURL() {
|
|
23493
|
+
var _a;
|
|
23494
|
+
return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
|
|
23495
|
+
}
|
|
23496
|
+
apiUser() {
|
|
23497
|
+
return (new APIUser()).setClient(this.client);
|
|
23498
|
+
}
|
|
23499
|
+
function() {
|
|
23500
|
+
return (new Functions()).setClient(this.client);
|
|
23501
|
+
}
|
|
23502
|
+
user() {
|
|
23503
|
+
return (new Users()).setClient(this.client);
|
|
23504
|
+
}
|
|
23505
|
+
app(appType) {
|
|
23506
|
+
return (new Apps(appType)).setClient(this.client);
|
|
23507
|
+
}
|
|
23508
|
+
forge() {
|
|
23509
|
+
return (new Forge()).setClient(this.client);
|
|
23510
|
+
}
|
|
23511
|
+
kortex() {
|
|
23512
|
+
return (new Kortex()).setClient(this.client);
|
|
23513
|
+
}
|
|
23514
|
+
component(ref) {
|
|
23515
|
+
return (new Component(ref)).setClient(this.client);
|
|
23516
|
+
}
|
|
23517
|
+
componentUtils() {
|
|
23518
|
+
return (new ComponentUtils()).setClient(this.client);
|
|
23519
|
+
}
|
|
23520
|
+
ratchet() {
|
|
23521
|
+
return (new Ratchet()).setClient(this.client);
|
|
23522
|
+
}
|
|
23523
|
+
sandbox() {
|
|
23524
|
+
return (new Sandbox()).setClient(this.client);
|
|
23525
|
+
}
|
|
23526
|
+
system() {
|
|
23527
|
+
return (new System()).setClient(this.client);
|
|
23528
|
+
}
|
|
23529
|
+
workflow() {
|
|
23530
|
+
return (new Workflow()).setClient(this.client);
|
|
23531
|
+
}
|
|
23532
|
+
thunder() {
|
|
23533
|
+
return (new Thunder()).setClient(this.client);
|
|
23534
|
+
}
|
|
23535
|
+
project() {
|
|
23536
|
+
return (new Project()).setClient(this.client);
|
|
23537
|
+
}
|
|
23538
|
+
config() {
|
|
23539
|
+
return (new Config()).setClient(this.client);
|
|
23540
|
+
}
|
|
23541
|
+
/**
|
|
23542
|
+
* Convenience factory for the Integrations gateway façade.
|
|
23543
|
+
*
|
|
23544
|
+
* Integrations live behind a different gateway (`INTEGRATION_API` /
|
|
23545
|
+
* `host/luma/integrations`) than the rest of the platform API, so this
|
|
23546
|
+
* returns an independently-configured `Integrations` client (it does not
|
|
23547
|
+
* reuse `this.client`, whose base URL points at the platform host). The
|
|
23548
|
+
* Platform's resolved token/env/host are propagated so the child client
|
|
23549
|
+
* carries the same credentials.
|
|
23550
|
+
*/
|
|
23551
|
+
integrations() {
|
|
23552
|
+
return new Integrations(this.getIntegrationsGatewayOptions());
|
|
23553
|
+
}
|
|
23554
|
+
/**
|
|
23555
|
+
* Convenience factory for the Satellites (custom JSON-RPC integrations) client.
|
|
23556
|
+
*
|
|
23557
|
+
* Same gateway note as `integrations()` — Satellites talks to the
|
|
23558
|
+
* integrations gateway, not the platform host, so a fresh, independently
|
|
23559
|
+
* configured client is returned, with the Platform's credentials propagated.
|
|
23560
|
+
*/
|
|
23561
|
+
satellites() {
|
|
23562
|
+
return new Satellites(this.getIntegrationsGatewayOptions());
|
|
23563
|
+
}
|
|
23564
|
+
/**
|
|
23565
|
+
* Builds the options for a child integrations-gateway client (`Integrations`/
|
|
23566
|
+
* `Satellites`), propagating this Platform's resolved token/env, and deriving
|
|
23567
|
+
* the gateway host from this Platform's host when one was explicitly set.
|
|
23568
|
+
* When `this.host` is unset, `host` is left `undefined` so the child client's
|
|
23569
|
+
* own env-var/default resolution applies.
|
|
23570
|
+
*/
|
|
23571
|
+
getIntegrationsGatewayOptions() {
|
|
23572
|
+
var _a, _b;
|
|
23573
|
+
return {
|
|
23574
|
+
token: (_a = this.token) !== null && _a !== void 0 ? _a : undefined,
|
|
23575
|
+
env: (_b = this.env) !== null && _b !== void 0 ? _b : undefined,
|
|
23576
|
+
host: this.host ? `${this.host.replace(/\/+$/, "")}/luma/integrations` : undefined,
|
|
23577
|
+
};
|
|
23578
|
+
}
|
|
23579
|
+
/**
|
|
23580
|
+
* Transactions (billing) client — subscriptions, invoices, credits/balance,
|
|
23581
|
+
* usage pricing and billing-mode overrides. Reached through the platform
|
|
23582
|
+
* gateway (`transactions/…`), so it reuses `this.client` like the other
|
|
23583
|
+
* native/proxied-service factories.
|
|
23584
|
+
*
|
|
23585
|
+
* This is the **billing** service — not distributed/database transactions.
|
|
23586
|
+
*/
|
|
23587
|
+
transactions() {
|
|
23588
|
+
return (new Transactions()).setClient(this.client);
|
|
23589
|
+
}
|
|
23590
|
+
/**
|
|
23591
|
+
* Alias for `transactions()` — reads more naturally at call sites that
|
|
23592
|
+
* only care about billing (`platform.billing().getBalance()`).
|
|
23593
|
+
*/
|
|
23594
|
+
billing() {
|
|
23595
|
+
return this.transactions();
|
|
23596
|
+
}
|
|
23597
|
+
}
|
|
23598
|
+
|
|
22818
23599
|
// PRN — Protokol Resource Name
|
|
22819
23600
|
//
|
|
22820
23601
|
// Format:
|
|
@@ -22993,6 +23774,7 @@ exports.SerbiaMinFin = MinFin;
|
|
|
22993
23774
|
exports.System = System;
|
|
22994
23775
|
exports.Thunder = Thunder;
|
|
22995
23776
|
exports.Timber = Timber;
|
|
23777
|
+
exports.Transactions = Transactions;
|
|
22996
23778
|
exports.Users = Users;
|
|
22997
23779
|
exports.VPFR = VPFR;
|
|
22998
23780
|
exports.Workflow = Workflow;
|