@ptkl/sdk 1.14.0 → 1.16.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.
@@ -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
+ }
@@ -1,5 +1,5 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
- import { UserClaims, UserModel, Role, CreateRoleRequest, EditRoleRequest, RoleModel, Permission } from "../types/users";
2
+ import { UserClaims, UserModel, Role, CreateRoleRequest, EditRoleRequest, RoleModel, Permission, Permissions } from "../types/users";
3
3
  import { AxiosResponse } from "axios";
4
4
  export default class Users extends PlatformBaseClient {
5
5
  auth(username: string, password: string, project: string): Promise<AxiosResponse<any>>;
@@ -28,9 +28,28 @@ export default class Users extends PlatformBaseClient {
28
28
  */
29
29
  editProfile(data: any): Promise<AxiosResponse<any>>;
30
30
  /**
31
- * Get user permissions
31
+ * Get the current token's permissions.
32
+ *
33
+ * Returns the resolved permission set carried by the calling token. For a
34
+ * forge actor token this is the scoped intersection minted at launch time —
35
+ * see `getPrincipalPermissions()` for the underlying user's full set.
32
36
  */
33
- getPermissions(): Promise<AxiosResponse<Permission[]>>;
37
+ getPermissions(): Promise<AxiosResponse<Permissions>>;
38
+ /**
39
+ * Get the FULL permissions of the user the current token is acting on behalf
40
+ * of (the "principal").
41
+ *
42
+ * When a forge app runs under an actor token, `getPermissions()` returns only
43
+ * the token's scoped permissions — the intersection of the app's declared
44
+ * runtime permissions and the user's permissions. This instead returns the
45
+ * complete permission set of the underlying user, so the app can check what
46
+ * that user is actually allowed to do, independent of what the app itself was
47
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
48
+ *
49
+ * For a normal user session (no actor token) it returns the caller's own
50
+ * permissions, identical to `getPermissions()`'s scope.
51
+ */
52
+ getPrincipalPermissions(): Promise<AxiosResponse<Permissions>>;
34
53
  /**
35
54
  * Get list of available permissions
36
55
  */
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import PlatformBaseClient from "./platformBaseClient";
3
- import { WorkflowModel, WorkflowCreatePayload, WorkflowUpdatePayload, WorkflowListResponse } from '../types/workflow';
3
+ import { WorkflowModel, WorkflowCreatePayload, WorkflowUpdatePayload, WorkflowListResponse, WorkflowInstallPayload, WorkflowHistoryQuery, WorkflowHistoryListResponse, WorkflowHistoryEntry, WorkflowStatsQuery, WorkflowStats, WorkflowRunningQuery, WorkflowRunningListResponse, WorkflowRunningExecution, WorkflowControlResponse, WorkflowRestartOptions, WorkflowRestartResponse, WorkflowNodeControlOptions, WorkflowErrorListResponse } from '../types/workflow';
4
4
  export default class Workflow extends PlatformBaseClient {
5
5
  create(data: WorkflowCreatePayload): Promise<AxiosResponse<WorkflowModel>>;
6
6
  update(id: string, data: WorkflowUpdatePayload): Promise<AxiosResponse<WorkflowModel>>;
@@ -9,4 +9,28 @@ export default class Workflow extends PlatformBaseClient {
9
9
  delete(id: string): Promise<AxiosResponse<void>>;
10
10
  trigger(id: string, event: string, data: any): Promise<AxiosResponse<any, any>>;
11
11
  publish(event: string, data: any): Promise<AxiosResponse<any, any>>;
12
+ /**
13
+ * Install (create + publish) a workflow in one call.
14
+ * Rejects if a workflow with the same name + integrator already exists.
15
+ */
16
+ install(data: WorkflowInstallPayload): Promise<AxiosResponse<WorkflowModel>>;
17
+ getHistory(query?: WorkflowHistoryQuery): Promise<AxiosResponse<WorkflowHistoryListResponse>>;
18
+ getHistoryEntry(executionUuid: string): Promise<AxiosResponse<WorkflowHistoryEntry>>;
19
+ getStats(query?: WorkflowStatsQuery): Promise<AxiosResponse<WorkflowStats>>;
20
+ getRunning(query?: WorkflowRunningQuery): Promise<AxiosResponse<WorkflowRunningListResponse>>;
21
+ getRunningEntry(executionUuid: string): Promise<AxiosResponse<WorkflowRunningExecution>>;
22
+ pause(executionUuid: string): Promise<AxiosResponse<WorkflowControlResponse>>;
23
+ resume(executionUuid: string): Promise<AxiosResponse<WorkflowControlResponse>>;
24
+ kill(executionUuid: string): Promise<AxiosResponse<WorkflowControlResponse>>;
25
+ /**
26
+ * Restart a failed/killed workflow execution from history.
27
+ * `clearState: true` discards prior node state instead of a smart resume.
28
+ */
29
+ restart(executionUuid: string, options?: WorkflowRestartOptions): Promise<AxiosResponse<WorkflowRestartResponse>>;
30
+ pauseNode(executionUuid: string, nodeId: number, options?: WorkflowNodeControlOptions): Promise<AxiosResponse<WorkflowControlResponse>>;
31
+ resumeNode(executionUuid: string, nodeId: number, options?: WorkflowNodeControlOptions): Promise<AxiosResponse<WorkflowControlResponse>>;
32
+ killNode(executionUuid: string, nodeId: number, options?: WorkflowNodeControlOptions): Promise<AxiosResponse<WorkflowControlResponse>>;
33
+ getErrors(): Promise<AxiosResponse<WorkflowErrorListResponse>>;
34
+ removeError(id: string): Promise<AxiosResponse<WorkflowControlResponse>>;
35
+ removeAllErrors(): Promise<AxiosResponse<WorkflowControlResponse>>;
12
36
  }