@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.9.js CHANGED
@@ -582,11 +582,32 @@ var ProtokolSDK09 = (function (exports, axios) {
582
582
  }
583
583
  // Permissions & Roles
584
584
  /**
585
- * Get user permissions
585
+ * Get the current token's permissions.
586
+ *
587
+ * Returns the resolved permission set carried by the calling token. For a
588
+ * forge actor token this is the scoped intersection minted at launch time —
589
+ * see `getPrincipalPermissions()` for the underlying user's full set.
586
590
  */
587
591
  async getPermissions() {
588
592
  return await this.client.get("/v1/user/role/permissions");
589
593
  }
594
+ /**
595
+ * Get the FULL permissions of the user the current token is acting on behalf
596
+ * of (the "principal").
597
+ *
598
+ * When a forge app runs under an actor token, `getPermissions()` returns only
599
+ * the token's scoped permissions — the intersection of the app's declared
600
+ * runtime permissions and the user's permissions. This instead returns the
601
+ * complete permission set of the underlying user, so the app can check what
602
+ * that user is actually allowed to do, independent of what the app itself was
603
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
604
+ *
605
+ * For a normal user session (no actor token) it returns the caller's own
606
+ * permissions, identical to `getPermissions()`'s scope.
607
+ */
608
+ async getPrincipalPermissions() {
609
+ return await this.client.get("/v1/user/role/principal-permissions");
610
+ }
590
611
  /**
591
612
  * Get list of available permissions
592
613
  */
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",
@@ -1,4 +1,4 @@
1
- import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, StreamHandler, AggregateChainable, FindChainable, FindStreamMeta, FindStreamMetaCallback, ComponentOptions, UpdateManyOptions, CreateManyOptions, Extension, Policy } from "../types/component";
1
+ import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, StreamHandler, AggregateChainable, FindChainable, FindStreamMeta, FindStreamMetaCallback, FindStreamCursor, FindStreamCursorCallback, ComponentOptions, UpdateManyOptions, CreateManyOptions, Extension, Policy } from "../types/component";
2
2
  import PlatformBaseClient from "./platformBaseClient";
3
3
  import { AxiosResponse } from "axios";
4
4
  import type { ComponentModels, ComponentFunctions } from "../types/functions";
@@ -46,6 +46,7 @@ export default class Component<C extends string = string> extends PlatformBaseCl
46
46
  total: number;
47
47
  page: number;
48
48
  pages: number;
49
+ next_cursor?: string;
49
50
  }>>;
50
51
  /**
51
52
  * FindOne method to search for a single model
@@ -329,4 +330,4 @@ export default class Component<C extends string = string> extends PlatformBaseCl
329
330
  */
330
331
  private _streamNDJSONNode;
331
332
  }
332
- export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, StreamHandler, AggregateChainable, FindChainable, FindStreamMeta, FindStreamMetaCallback, ComponentOptions, Extension, };
333
+ export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, StreamHandler, AggregateChainable, FindChainable, FindStreamMeta, FindStreamMetaCallback, FindStreamCursor, FindStreamCursorCallback, ComponentOptions, Extension, };
@@ -8,8 +8,30 @@ export default class Forge extends PlatformBaseClient {
8
8
  getVariables(ref: string): Promise<any>;
9
9
  updateVariables(ref: string, variables: Record<string, any>): Promise<any>;
10
10
  addVariable(ref: string, key: string, value: any): Promise<any>;
11
- callService(appUuid: string, serviceName: string, options?: {
12
- body?: any;
11
+ /**
12
+ * Run a Forge service: `runService(target, body?, { query?, headers? })`.
13
+ * Mirrors `axios.post(url, data, config)` — the 2nd arg is the request payload.
14
+ *
15
+ * `target` is either:
16
+ * - a bare service name — runs that service on the CURRENT app; or
17
+ * - a service PRN `prn:forge:{ref}:service/{name}` — runs it on ANOTHER app,
18
+ * where `ref` is the app's **name** or uuid. A name is resolved by the
19
+ * runtime deterministically (marketplace → custom); use the uuid to pin a
20
+ * specific app. This is the addressing to use where there's no ambient
21
+ * "current app" — e.g. a workflow, which has no per-install uuid to hardcode.
22
+ *
23
+ * `body` is sent as the POST body; `options.query` / `options.headers` are optional.
24
+ *
25
+ * The current app's uuid (bare-name form) is resolved automatically from the
26
+ * platform context (FORGE_APP_UUID for public views, forge_app_uuid in
27
+ * sessionStorage for platform views), so app code never needs its own uuid.
28
+ *
29
+ * Resolving the app does NOT grant access. Execution is still authorized against
30
+ * the caller's permissions — for a `platform`-access service the caller must hold
31
+ * `service::{name} forge::{appUuid}`; `public`-access services require none. An
32
+ * app's own runtime token is implicitly granted this for all of its own services.
33
+ */
34
+ runService(target: string, body?: any, options?: {
13
35
  query?: Record<string, string>;
14
36
  headers?: Record<string, string>;
15
37
  }): Promise<any>;
@@ -35,3 +35,5 @@ export { default as VPFR } from './integrations/serbia/minfin/vpfr';
35
35
  export { default as Mail } from './integrations/mail';
36
36
  export { default as Ecommerce } from './integrations/ecommerce';
37
37
  export { default as Timber } from './integrations/timber';
38
+ export { default as Transactions } from './transactions';
39
+ export type { ISODateString as TransactionsISODateString, Subscription as TransactionsSubscription, RenewSubscriptionPayload, RenewSubscriptionResult, CancelSubscriptionPayload, CancelSubscriptionResult, InvoiceStatus as TransactionsInvoiceStatus, InvoiceLineItem as TransactionsInvoiceLineItem, Invoice as TransactionsInvoice, BalanceResult, TopUpPayload as TransactionsTopUpPayload, TopUpResult as TransactionsTopUpResult, CreditsHistoryQuery, CreditsHistoryItem, CreditsHistoryResult, UsagePriceEntry, SubscriptionPrices, BillingMode, BillingModeEntry, GetBillingModesResult, UpdateBillingModePayload, UpdateBillingModeResult, } from '../types/transactions';
@@ -1,6 +1,6 @@
1
1
  import IntegrationsBaseClient from "../integrationsBaseClient";
2
2
  import { AxiosResponse } from "axios";
3
- import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, PDF2HTMLOptions, MediaUploadPayload, MediaUploadBase64Payload, DocumentListParams, DocumentListResponse, DocumentCreatePayload, DocumentUpdatePayload, DocumentRestorePayload, DocumentCommentPayload, DocumentResponse, DocumentGeneratePayload, DocumentGenerateResponse, DocumentRevisionListResponse, ExtractTextPayload, ExtractTextResult, OCRExtractPayload, OCRExtractResult } from "../../types/integrations";
3
+ import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, PDF2HTMLOptions, MediaUploadPayload, MediaUploadBase64Payload, DocumentListParams, DocumentListResponse, DocumentCreatePayload, DocumentUpdatePayload, DocumentRestorePayload, DocumentCommentPayload, DocumentResponse, DocumentGeneratePayload, DocumentGenerateResponse, DocumentRevisionListResponse, ExtractTextPayload, ExtractTextResult, OCRExtractPayload, OCRExtractResult, LibraryExportCreatePayload, LibraryExportListResponse, MediaExportCreateResult, LibraryExportGetResult, LibraryPolicy, LibraryPolicyPayload, DirPolicy, DirPolicyPayload, NotificationRuleCreatePayload, NotificationRule, NotificationRuleListResponse, FileNotificationCreatePayload, FileNotification, FileNotificationListResponse } from "../../types/integrations";
4
4
  /**
5
5
  * Document Management System (DMS) API client
6
6
  *
@@ -510,6 +510,98 @@ export default class DMS extends IntegrationsBaseClient {
510
510
  * ```
511
511
  */
512
512
  ocrExtract(payload: OCRExtractPayload): Promise<AxiosResponse<OCRExtractResult>>;
513
+ /**
514
+ * Create a library export archive (a snapshot of the project's library or a directory within it)
515
+ *
516
+ * The library is resolved server-side from the project in the auth context —
517
+ * there is a single library per project.
518
+ *
519
+ * @param payload - Optional export scope/format options
520
+ * @returns `{ mode, export }` when the export is queued asynchronously.
521
+ * Depending on server-side sizing, the endpoint may instead stream the
522
+ * archive back directly as a binary response body (not this JSON shape).
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const result = await dms.createExport({ path: 'legal', format: 'zip' });
527
+ * ```
528
+ */
529
+ createExport(payload?: LibraryExportCreatePayload): Promise<AxiosResponse<MediaExportCreateResult>>;
530
+ /**
531
+ * List export archives for the project's library
532
+ */
533
+ listExports(): Promise<AxiosResponse<LibraryExportListResponse>>;
534
+ /**
535
+ * Get a single export archive (an archived snapshot of a library/dir)
536
+ *
537
+ * @param exportUuid - Export UUID
538
+ * @returns `{ export, download_url }`
539
+ */
540
+ getExport(exportUuid: string): Promise<AxiosResponse<LibraryExportGetResult>>;
541
+ /**
542
+ * Get the effective library-level policy for the project's library
543
+ */
544
+ getLibraryPolicy(): Promise<AxiosResponse<LibraryPolicy>>;
545
+ /**
546
+ * Set/update the library-level policy for the project's library
547
+ *
548
+ * @param payload - Policy fields to set
549
+ */
550
+ setLibraryPolicy(payload: LibraryPolicyPayload): Promise<AxiosResponse<LibraryPolicy>>;
551
+ /**
552
+ * Get the directory-level policy (resolves platform-default → library → dir)
553
+ *
554
+ * @param path - Directory path
555
+ */
556
+ getDirPolicy(path: string): Promise<AxiosResponse<DirPolicy>>;
557
+ /**
558
+ * Set/update the directory-level policy
559
+ *
560
+ * @param path - Directory path
561
+ * @param payload - Policy fields to set (only fields provided override the library policy)
562
+ */
563
+ setDirPolicy(path: string, payload: DirPolicyPayload): Promise<AxiosResponse<DirPolicy>>;
564
+ /**
565
+ * Remove a directory-level policy override (directory falls back to the library policy)
566
+ *
567
+ * @param path - Directory path
568
+ */
569
+ deleteDirPolicy(path: string): Promise<AxiosResponse<any>>;
570
+ /**
571
+ * List notification rules for the project's library
572
+ */
573
+ listNotificationRules(): Promise<AxiosResponse<NotificationRuleListResponse>>;
574
+ /**
575
+ * Create a recurring reminder (notification rule) for a media file
576
+ *
577
+ * @param payload - Recurring reminder definition (media_uuid/file_key, frequency, start_at, ...)
578
+ */
579
+ createNotificationRule(payload: NotificationRuleCreatePayload): Promise<AxiosResponse<NotificationRule>>;
580
+ /**
581
+ * Delete a notification rule
582
+ *
583
+ * @param ruleUuid - Notification rule UUID
584
+ */
585
+ deleteNotificationRule(ruleUuid: string): Promise<AxiosResponse<any>>;
586
+ /**
587
+ * List custom reminders scheduled for a specific file
588
+ *
589
+ * @param mediaUuid - Media UUID
590
+ */
591
+ listFileNotifications(mediaUuid: string): Promise<AxiosResponse<FileNotificationListResponse>>;
592
+ /**
593
+ * Create a custom reminder for a specific file
594
+ *
595
+ * @param mediaUuid - Media UUID
596
+ * @param payload - Reminder details (note, notify_at, optional recipient)
597
+ */
598
+ createFileNotification(mediaUuid: string, payload: FileNotificationCreatePayload): Promise<AxiosResponse<FileNotification>>;
599
+ /**
600
+ * Cancel/delete a custom file reminder
601
+ *
602
+ * @param notificationUuid - Notification UUID
603
+ */
604
+ deleteFileNotification(notificationUuid: string): Promise<AxiosResponse<any>>;
513
605
  request(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
514
606
  requestv2(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
515
607
  requestv1(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
@@ -27,5 +27,43 @@ export default class Integrations extends IntegrationsBaseClient {
27
27
  list(): Promise<any>;
28
28
  isInstalled(id: string): Promise<boolean>;
29
29
  isActive(id: string): Promise<boolean>;
30
+ /**
31
+ * Install (integrate) an integration into the current project.
32
+ * POST /v1/integrate
33
+ */
34
+ install(id: string, data?: Record<string, any>): Promise<any>;
35
+ /**
36
+ * Uninstall (remove) an integration from the current project.
37
+ * PUT /v1/integrate
38
+ */
39
+ uninstall(id: string): Promise<any>;
40
+ /**
41
+ * Activate an installed integration.
42
+ * POST /v1/integration/{id}/activate
43
+ */
44
+ activate(id: string): Promise<any>;
45
+ /**
46
+ * Deactivate an installed integration.
47
+ * POST /v1/integration/{id}/deactivate
48
+ */
49
+ deactivate(id: string): Promise<any>;
50
+ /**
51
+ * Advance/update the onboarding state of an installed integration.
52
+ * POST /v1/integration/{id}/onboarding
53
+ */
54
+ onboarding(id: string, data: {
55
+ step: string;
56
+ data?: Record<string, any>;
57
+ }): Promise<any>;
58
+ /**
59
+ * List marketplace-available integrations (subscription/geo aware).
60
+ * GET /v1/marketplace/integrations
61
+ */
62
+ marketplace(): Promise<any>;
63
+ /**
64
+ * List explorable integration templates (subscription/geo aware).
65
+ * GET /v1/integrations/explore
66
+ */
67
+ explore(): Promise<any>;
30
68
  getInterfaceOf(id: string): any;
31
69
  }
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import PlatformBaseClient from "./platformBaseClient";
3
- import { PagedResponse, PaginationParams, Agent, AgentCreatePayload, AgentUpdatePayload, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, Message, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier } from '../types/kortex';
3
+ import { PagedResponse, PaginationParams, Agent, AgentCreatePayload, AgentUpdatePayload, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, Message, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchResult, KortexWorkflowPayload, KortexWorkflowResult } from '../types/kortex';
4
4
  export default class Kortex extends PlatformBaseClient {
5
5
  createAgent(data: AgentCreatePayload): Promise<AxiosResponse<Agent>>;
6
6
  listAgents(params?: PaginationParams): Promise<AxiosResponse<PagedResponse<Agent>>>;
@@ -13,6 +13,7 @@ export default class Kortex extends PlatformBaseClient {
13
13
  getKnowledgeBase(uuid: string): Promise<AxiosResponse<KnowledgeBase>>;
14
14
  updateKnowledgeBase(uuid: string, data: KnowledgeBaseUpdatePayload): Promise<AxiosResponse<KnowledgeBase>>;
15
15
  deleteKnowledgeBase(uuid: string): Promise<AxiosResponse<void>>;
16
+ searchKnowledgeBase(data: KnowledgeBaseSearchPayload): Promise<AxiosResponse<KnowledgeBaseSearchResult>>;
16
17
  listDocuments(kbUUID: string, params?: PaginationParams): Promise<AxiosResponse<PagedResponse<Document>>>;
17
18
  uploadDocument(kbUUID: string, formData: FormData): Promise<AxiosResponse<Document>>;
18
19
  getDocument(kbUUID: string, uuid: string): Promise<AxiosResponse<Document>>;
@@ -35,6 +36,8 @@ export default class Kortex extends PlatformBaseClient {
35
36
  listMessages(conversationUUID: string, params?: PaginationParams): Promise<AxiosResponse<PagedResponse<Message>>>;
36
37
  injectMessage(conversationUUID: string, data: InjectMessagePayload): Promise<AxiosResponse<Message>>;
37
38
  ocr(data: OCRPayload): Promise<AxiosResponse<OCRResult>>;
39
+ workflowComplete(data: KortexWorkflowPayload): Promise<AxiosResponse<KortexWorkflowResult>>;
40
+ workflowOcr(data: OCRPayload): Promise<AxiosResponse<OCRResult>>;
38
41
  createUserAccess(data: UserAccessCreatePayload): Promise<AxiosResponse<UserAccess>>;
39
42
  listUserAccess(params?: PaginationParams): Promise<AxiosResponse<PagedResponse<UserAccess>>>;
40
43
  getUserAccess(uuid: string): Promise<AxiosResponse<UserAccess>>;
@@ -15,6 +15,9 @@ import Kortex from "./kortex";
15
15
  import Project from "./project";
16
16
  import Config from "./config";
17
17
  import PlatformBaseClient from "./platformBaseClient";
18
+ import Integrations from "./integrations";
19
+ import Satellites from "./satellites";
20
+ import Transactions from "./transactions";
18
21
  export default class Platform extends PlatformBaseClient {
19
22
  getPlatformClient(): AxiosInstance;
20
23
  getPlatformBaseURL(): string;
@@ -33,4 +36,45 @@ export default class Platform extends PlatformBaseClient {
33
36
  thunder(): Thunder;
34
37
  project(): Project;
35
38
  config(): Config;
39
+ /**
40
+ * Convenience factory for the Integrations gateway façade.
41
+ *
42
+ * Integrations live behind a different gateway (`INTEGRATION_API` /
43
+ * `host/luma/integrations`) than the rest of the platform API, so this
44
+ * returns an independently-configured `Integrations` client (it does not
45
+ * reuse `this.client`, whose base URL points at the platform host). The
46
+ * Platform's resolved token/env/host are propagated so the child client
47
+ * carries the same credentials.
48
+ */
49
+ integrations(): Integrations;
50
+ /**
51
+ * Convenience factory for the Satellites (custom JSON-RPC integrations) client.
52
+ *
53
+ * Same gateway note as `integrations()` — Satellites talks to the
54
+ * integrations gateway, not the platform host, so a fresh, independently
55
+ * configured client is returned, with the Platform's credentials propagated.
56
+ */
57
+ satellites(): Satellites;
58
+ /**
59
+ * Builds the options for a child integrations-gateway client (`Integrations`/
60
+ * `Satellites`), propagating this Platform's resolved token/env, and deriving
61
+ * the gateway host from this Platform's host when one was explicitly set.
62
+ * When `this.host` is unset, `host` is left `undefined` so the child client's
63
+ * own env-var/default resolution applies.
64
+ */
65
+ private getIntegrationsGatewayOptions;
66
+ /**
67
+ * Transactions (billing) client — subscriptions, invoices, credits/balance,
68
+ * usage pricing and billing-mode overrides. Reached through the platform
69
+ * gateway (`transactions/…`), so it reuses `this.client` like the other
70
+ * native/proxied-service factories.
71
+ *
72
+ * This is the **billing** service — not distributed/database transactions.
73
+ */
74
+ transactions(): Transactions;
75
+ /**
76
+ * Alias for `transactions()` — reads more naturally at call sites that
77
+ * only care about billing (`platform.billing().getBalance()`).
78
+ */
79
+ billing(): Transactions;
36
80
  }
@@ -23,11 +23,31 @@ export default class Project extends PlatformBaseClient {
23
23
  */
24
24
  archive(): Promise<AxiosResponse<any>>;
25
25
  /**
26
- * Invite a user to the project
27
- * @param emails Array of emails
28
- * @param roles Array of role UUIDs
29
- */
30
- invite(emails: string[], roles: string[]): Promise<AxiosResponse<any>>;
26
+ * Invite one or more users to the project.
27
+ *
28
+ * `POST /v1/project/invite` only accepts a single `email` per request
29
+ * (see `InviteToProject` in platform-api's
30
+ * `internal/project/controllers/invite.go`), so this method issues one
31
+ * request per entry in `emails`, sequentially, with body
32
+ * `{ email, role_uuid: roles, subject?, comment? }`.
33
+ *
34
+ * Return shape (always a single `AxiosResponse`, so existing callers
35
+ * that do `(await project.invite(...)).data` keep compiling/working
36
+ * unchanged):
37
+ * - Exactly one email: the raw `AxiosResponse` from that single request
38
+ * (`.data` is that invite's response body, as before).
39
+ * - More than one email: a response shaped like the last request's
40
+ * `AxiosResponse`, but with `.data` replaced by an array of each
41
+ * individual request's `.data`, in the same order as `emails`.
42
+ *
43
+ * @param emails Array of email addresses to invite
44
+ * @param roles Array of role UUIDs to grant every invitee
45
+ * @param extra Optional subject/comment applied to every invite
46
+ */
47
+ invite(emails: string[], roles: string[], extra?: {
48
+ subject?: string;
49
+ comment?: string;
50
+ }): Promise<AxiosResponse<any>>;
31
51
  /**
32
52
  * Get list of project invites
33
53
  */
@@ -122,8 +142,17 @@ export default class Project extends PlatformBaseClient {
122
142
  */
123
143
  getWorkspaceTemplates(): Promise<AxiosResponse<any>>;
124
144
  /**
125
- * Install a template
126
- * @param data Installation data
145
+ * Install a template.
146
+ *
147
+ * `POST /v1/project/template/install` decodes body `TemplateInstall = { id,
148
+ * data, activation_code }` and resolves the target workspace from the
149
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
150
+ * `template_install.go`. This method keeps the ergonomic object-arg
151
+ * signature but maps it onto that contract: `template_id` becomes body
152
+ * `id`, `workspace_uuid` is sent as the `X-Workspace-Uuid` header, and any
153
+ * `data`/`activation_code` passed in are forwarded in the body as-is.
154
+ *
155
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
127
156
  */
128
157
  installTemplate(data: {
129
158
  template_id: string;
@@ -131,8 +160,14 @@ export default class Project extends PlatformBaseClient {
131
160
  [key: string]: any;
132
161
  }): Promise<AxiosResponse<any>>;
133
162
  /**
134
- * Uninstall a template
135
- * @param data Uninstallation data
163
+ * Uninstall a template.
164
+ *
165
+ * `POST /v1/project/template/uninstall` decodes body `TemplateInstall = {
166
+ * id, data, activation_code }` and resolves the target workspace from the
167
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
168
+ * `template_uninstall.go`. See `installTemplate` for the mapping.
169
+ *
170
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
136
171
  */
137
172
  uninstallTemplate(data: {
138
173
  template_id: string;
@@ -140,8 +175,14 @@ export default class Project extends PlatformBaseClient {
140
175
  [key: string]: any;
141
176
  }): Promise<AxiosResponse<any>>;
142
177
  /**
143
- * Upgrade a template
144
- * @param data Upgrade data
178
+ * Upgrade a template.
179
+ *
180
+ * `POST /v1/project/template/upgrade` decodes body `TemplateInstall = {
181
+ * id, data, activation_code }` and resolves the target workspace from the
182
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
183
+ * `template_upgrade.go`. See `installTemplate` for the mapping.
184
+ *
185
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
145
186
  */
146
187
  upgradeTemplate(data: {
147
188
  template_id: string;
@@ -1,7 +1,19 @@
1
+ import { AxiosResponse } from "axios";
1
2
  import PlatformBaseClient from "./platformBaseClient";
3
+ import type { CreateSparkPayload, UpdateSparkPayload, Spark, SparkEnv, SparkLogsParams, SparkTier, CreateRuntimePayload, UpdateRuntimePayload, Runtime, RuntimeLogsParams } from "../types/sandbox";
4
+ /**
5
+ * Sandbox client — spark (FaaS) functions/apps, long-running runtimes, and
6
+ * their K8s deployments. All routes go through the `sandbox/…` gateway
7
+ * prefix (`/luma/sandbox/v1/...`), matching the sandbox service's REST
8
+ * surface (`internal/controllers/{spark.go,spark.v1.go,runtime.v1.go}` and
9
+ * the deployment lifecycle in `internal/controllers/ecomm/deployment.go`).
10
+ */
2
11
  export default class Sandbox extends PlatformBaseClient {
3
12
  /**
4
- * Call the sandbox service to execute a serverless function
13
+ * Call the sandbox service to execute a serverless function.
14
+ *
15
+ * Kept for backwards compatibility — equivalent to
16
+ * `execSpark(name, data)`.
5
17
  *
6
18
  * @param name
7
19
  * @param data
@@ -10,5 +22,117 @@ export default class Sandbox extends PlatformBaseClient {
10
22
  * @example
11
23
  * const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
12
24
  */
13
- spark(name: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
25
+ spark(name: string, data: any): Promise<AxiosResponse<any, any>>;
26
+ /**
27
+ * Create a new spark (function or app).
28
+ *
29
+ * @example
30
+ * const spark = await platform.sandbox().createSpark({ name: "myFunction", runtime: "node20", memory: 256 })
31
+ */
32
+ createSpark(payload: CreateSparkPayload): Promise<AxiosResponse<Spark>>;
33
+ /**
34
+ * Get a spark by uuid.
35
+ */
36
+ getSpark(uuid: string): Promise<AxiosResponse<Spark>>;
37
+ /**
38
+ * Update a spark's memory/settings/env vars.
39
+ */
40
+ updateSpark(uuid: string, payload: UpdateSparkPayload): Promise<AxiosResponse<Spark>>;
41
+ /**
42
+ * Delete a spark.
43
+ */
44
+ deleteSpark(uuid: string): Promise<AxiosResponse<{
45
+ status: boolean;
46
+ }>>;
47
+ /**
48
+ * List all sparks for the current project.
49
+ */
50
+ listSparks(): Promise<AxiosResponse<Spark[]>>;
51
+ /**
52
+ * Deploy a specific spark version to the dev environment.
53
+ */
54
+ deploySpark(uuid: string, version: string): Promise<AxiosResponse<{
55
+ status: boolean;
56
+ }>>;
57
+ /**
58
+ * Cancel an in-progress spark deployment.
59
+ *
60
+ * @param uuid
61
+ * @param env - defaults to "dev" on the server if omitted
62
+ */
63
+ cancelSpark(uuid: string, env?: SparkEnv): Promise<AxiosResponse<{
64
+ status: boolean;
65
+ }>>;
66
+ /**
67
+ * Release a deployed spark version to the live/public environment.
68
+ */
69
+ releaseSpark(uuid: string, version: string): Promise<AxiosResponse<{
70
+ status: boolean;
71
+ }>>;
72
+ /**
73
+ * Execute a deployed spark by name. Mirrors `spark()` but accepts the
74
+ * full request shape (method/query/headers) — the exec route accepts
75
+ * GET/POST/PATCH/PUT/DELETE.
76
+ *
77
+ * @example
78
+ * const result = await platform.sandbox().execSpark("myFunction", { foo: "bar" })
79
+ * const result = await platform.sandbox().execSpark("myFunction", undefined, { method: "GET" })
80
+ */
81
+ execSpark(name: string, data?: any, options?: {
82
+ method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
83
+ query?: Record<string, string>;
84
+ headers?: Record<string, string>;
85
+ }): Promise<AxiosResponse<any>>;
86
+ /**
87
+ * Fetch logs for a spark.
88
+ */
89
+ sparkLogs(uuid: string, params?: SparkLogsParams): Promise<AxiosResponse<any>>;
90
+ /**
91
+ * Get the current project's spark tier (plan/quota).
92
+ */
93
+ sparkTier(): Promise<AxiosResponse<SparkTier>>;
94
+ /**
95
+ * List all runtimes for the current project.
96
+ */
97
+ listRuntimes(): Promise<AxiosResponse<Runtime[]>>;
98
+ /**
99
+ * Create a new runtime.
100
+ */
101
+ createRuntime(payload: CreateRuntimePayload): Promise<AxiosResponse<{
102
+ status: boolean;
103
+ }>>;
104
+ /**
105
+ * Get a runtime by ref (name/uuid).
106
+ */
107
+ getRuntime(ref: string): Promise<AxiosResponse<{
108
+ status: boolean;
109
+ }>>;
110
+ /**
111
+ * Update a runtime's image/resources/env vars/tags.
112
+ */
113
+ updateRuntime(ref: string, payload: UpdateRuntimePayload): Promise<AxiosResponse<{
114
+ status: boolean;
115
+ }>>;
116
+ /**
117
+ * Delete a runtime.
118
+ */
119
+ deleteRuntime(ref: string): Promise<AxiosResponse<{
120
+ status: boolean;
121
+ }>>;
122
+ /**
123
+ * (Re)deploy a runtime.
124
+ */
125
+ deployRuntime(ref: string): Promise<AxiosResponse<{
126
+ status: boolean;
127
+ }>>;
128
+ /**
129
+ * Restart a running runtime.
130
+ */
131
+ restartRuntime(ref: string): Promise<AxiosResponse<{
132
+ status: boolean;
133
+ }>>;
134
+ /**
135
+ * Fetch logs for a runtime.
136
+ */
137
+ runtimeLogs(ref: string, params?: RuntimeLogsParams): Promise<AxiosResponse<any>>;
14
138
  }
@@ -0,0 +1,75 @@
1
+ import { AxiosResponse } from "axios";
2
+ import PlatformBaseClient from "./platformBaseClient";
3
+ import type { Subscription, RenewSubscriptionPayload, RenewSubscriptionResult, CancelSubscriptionPayload, CancelSubscriptionResult, Invoice, BalanceResult, TopUpPayload, TopUpResult, CreditsHistoryQuery, CreditsHistoryResult, SubscriptionPrices, GetBillingModesResult, UpdateBillingModePayload, UpdateBillingModeResult } from "../types/transactions";
4
+ /**
5
+ * Transactions client — billing/subscriptions, invoices, credits/balance,
6
+ * usage pricing and per-project billing-mode overrides. All routes go
7
+ * through the `transactions/…` gateway prefix (`/luma/transactions/v1/...`),
8
+ * matching the transactions service's REST surface
9
+ * (`internal/controllers/{subscription,invoices,topup,credit_history,billing_modes,prices,balance}.go`).
10
+ *
11
+ * This is the **billing** service — not distributed/database transactions.
12
+ */
13
+ export default class Transactions extends PlatformBaseClient {
14
+ /**
15
+ * List all subscriptions (including expired) for the current project.
16
+ *
17
+ * @example
18
+ * const subs = await platform.transactions().getSubscriptions()
19
+ */
20
+ getSubscriptions(): Promise<AxiosResponse<Subscription[]>>;
21
+ /**
22
+ * Renew an expired subscription (and any others sharing its bundle
23
+ * `ref_no`) — creates a renewal invoice and returns a checkout link.
24
+ */
25
+ renewSubscription(payload: RenewSubscriptionPayload): Promise<AxiosResponse<RenewSubscriptionResult>>;
26
+ /**
27
+ * Cancel a subscription. Issues a refund automatically if still within
28
+ * the refund period.
29
+ */
30
+ cancelSubscription(payload: CancelSubscriptionPayload): Promise<AxiosResponse<CancelSubscriptionResult>>;
31
+ /**
32
+ * List all invoices for the current project.
33
+ */
34
+ getInvoices(): Promise<AxiosResponse<Invoice[]>>;
35
+ /**
36
+ * Get a single invoice by uuid.
37
+ */
38
+ getInvoice(uuid: string): Promise<AxiosResponse<Invoice>>;
39
+ /**
40
+ * Download an invoice as a PDF. Resolves with the raw PDF bytes
41
+ * (`responseType: "arraybuffer"`).
42
+ *
43
+ * @example
44
+ * const { data } = await platform.transactions().getInvoicePdf(uuid)
45
+ * fs.writeFileSync("invoice.pdf", Buffer.from(data))
46
+ */
47
+ getInvoicePdf(uuid: string): Promise<AxiosResponse<ArrayBuffer>>;
48
+ /**
49
+ * Get the current project's credit balance.
50
+ */
51
+ getBalance(): Promise<AxiosResponse<BalanceResult>>;
52
+ /**
53
+ * Generate a checkout link to manually top up the project's credit balance.
54
+ */
55
+ topUp(payload: TopUpPayload): Promise<AxiosResponse<TopUpResult>>;
56
+ /**
57
+ * Get the project's credit activity (deductions/top-ups) history, paginated.
58
+ */
59
+ getCreditsHistory(query?: CreditsHistoryQuery): Promise<AxiosResponse<CreditsHistoryResult>>;
60
+ /**
61
+ * Get the usage-based pricing table for a given currency.
62
+ *
63
+ * @param currency - ISO 4217 currency code, e.g. "USD" or "RSD".
64
+ */
65
+ getPrices(currency: string): Promise<AxiosResponse<SubscriptionPrices>>;
66
+ /**
67
+ * Get the project's usage-billing-mode overrides plus platform defaults.
68
+ */
69
+ getBillingModes(): Promise<AxiosResponse<GetBillingModesResult>>;
70
+ /**
71
+ * Set the billing mode ("credits" | "hybrid" | "invoice") for a usage
72
+ * option code on the current project.
73
+ */
74
+ updateBillingModes(payload: UpdateBillingModePayload): Promise<AxiosResponse<UpdateBillingModeResult>>;
75
+ }