@pilot-status/sdk 0.18.0 → 0.20.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/CHANGELOG.md +62 -0
- package/README.md +87 -1
- package/dist/client.d.ts +38 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +24 -0
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/billing.d.ts +58 -8
- package/dist/resources/billing.d.ts.map +1 -1
- package/dist/resources/billing.js +96 -7
- package/dist/resources/billing.js.map +1 -1
- package/dist/resources/templates.d.ts +13 -1
- package/dist/resources/templates.d.ts.map +1 -1
- package/dist/resources/templates.js +18 -0
- package/dist/resources/templates.js.map +1 -1
- package/dist/resources/workspace-webhooks.d.ts +46 -0
- package/dist/resources/workspace-webhooks.d.ts.map +1 -0
- package/dist/resources/workspace-webhooks.js +83 -0
- package/dist/resources/workspace-webhooks.js.map +1 -0
- package/dist/resources/workspace.d.ts +3 -0
- package/dist/resources/workspace.d.ts.map +1 -1
- package/dist/resources/workspace.js +4 -0
- package/dist/resources/workspace.js.map +1 -1
- package/dist/resources/workspaces.d.ts +47 -0
- package/dist/resources/workspaces.d.ts.map +1 -0
- package/dist/resources/workspaces.js +75 -0
- package/dist/resources/workspaces.js.map +1 -0
- package/dist/types.d.ts +318 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/webhooks/types.d.ts +20 -0
- package/dist/webhooks/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { compact } from "../internal.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Billing (`/v1/billing/*`). Requires a tenant-scoped credential (with an account key,
|
|
4
|
+
* `workspaceId`). Card payments through Stripe Elements answer 503
|
|
5
|
+
* `PAYMENTS_NOT_CONFIGURED` while the platform has no Stripe publishable key.
|
|
6
|
+
*/
|
|
3
7
|
export class BillingResource {
|
|
4
8
|
#http;
|
|
5
9
|
constructor(http) {
|
|
6
10
|
this.#http = http;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
10
|
-
* (`POST /v1/billing/checkout`).
|
|
13
|
+
* `POST /v1/billing/checkout`.
|
|
11
14
|
*
|
|
12
|
-
* **Nothing is charged here.**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* **Nothing is charged here.** `purpose: "add_card"` returns the `url` of a hosted
|
|
16
|
+
* page that saves a card. `purpose: "wallet_topup"` (requires `amount`, in the
|
|
17
|
+
* account currency) creates a PENDING order (`orderId`, poll it with
|
|
18
|
+
* {@link getTopup}) and returns either a hosted page `url` (`method: "card"`, the
|
|
19
|
+
* default) or, with `method: "pix"` (BRL workspaces only, 400 `PIX_NOT_ELIGIBLE`
|
|
20
|
+
* otherwise), the Pix to show the payer in `pix.copyPaste` / `pix.qrCode`.
|
|
21
|
+
* `method` is sent only when given; `successUrl`/`cancelUrl` with a Pix, or
|
|
22
|
+
* `method` on `add_card`, is 400 `FIELD_NOT_APPLICABLE`.
|
|
16
23
|
*/
|
|
17
24
|
async createCheckout(input) {
|
|
18
25
|
return this.#http.requestJson({
|
|
@@ -21,10 +28,92 @@ export class BillingResource {
|
|
|
21
28
|
body: compact({
|
|
22
29
|
purpose: input.purpose,
|
|
23
30
|
amount: input.amount,
|
|
31
|
+
method: input.method,
|
|
24
32
|
successUrl: input.successUrl,
|
|
25
33
|
cancelUrl: input.cancelUrl,
|
|
26
34
|
}),
|
|
27
35
|
});
|
|
28
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* `GET /v1/billing/topups/{id}` — the status of a wallet top-up order (`pending`,
|
|
39
|
+
* `paid`, `expired`, `failed`). Read-only: polling it calls no payment provider.
|
|
40
|
+
* Another workspace's id is 404 `TOPUP_NOT_FOUND`, like an unknown one.
|
|
41
|
+
*/
|
|
42
|
+
async getTopup(id) {
|
|
43
|
+
return this.#http.requestJson({
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: `/v1/billing/topups/${encodeURIComponent(id)}`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `POST /v1/billing/card/setup-intent` — a Stripe SetupIntent to save a card with
|
|
50
|
+
* the Payment Element on YOUR page (`stripe.confirmSetup(...)`); the card goes
|
|
51
|
+
* browser → Stripe. OWNER only (`billing:payment_method:manage`). Sends no body.
|
|
52
|
+
* ⛔ `clientSecret` lets its holder confirm the intent: never log it.
|
|
53
|
+
*/
|
|
54
|
+
async createCardSetupIntent() {
|
|
55
|
+
return this.#http.requestJson({
|
|
56
|
+
method: "POST",
|
|
57
|
+
path: "/v1/billing/card/setup-intent",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `POST /v1/billing/card/setup-intent/{id}/sync` — call right after
|
|
62
|
+
* `confirmSetup` resolves: the server reads the SetupIntent from Stripe and, if it
|
|
63
|
+
* `succeeded`, makes the card the workspace's saved card now (`saved: true`).
|
|
64
|
+
* Idempotent. Not succeeded yet → `saved: false` and Stripe's `status`. A
|
|
65
|
+
* malformed id is 400 `INVALID_SETUP_INTENT_ID`; unknown or another workspace's,
|
|
66
|
+
* 404 `SETUP_INTENT_NOT_FOUND`.
|
|
67
|
+
*/
|
|
68
|
+
async syncCardSetupIntent(setupIntentId) {
|
|
69
|
+
return this.#http.requestJson({
|
|
70
|
+
method: "POST",
|
|
71
|
+
path: `/v1/billing/card/setup-intent/${encodeURIComponent(setupIntentId)}/sync`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* `POST /v1/billing/payment-intents` — a transparent wallet top-up: a PENDING
|
|
76
|
+
* order and a card PaymentIntent for `stripe.confirmPayment(...)` on YOUR page.
|
|
77
|
+
* Nothing is charged here. OWNER only (`billing:wallet:topup`).
|
|
78
|
+
*
|
|
79
|
+
* `options.idempotencyKey` (optional) goes out as the `Idempotency-Key` header:
|
|
80
|
+
* reuse it on retry and the server returns the SAME order and PaymentIntent
|
|
81
|
+
* (`replayed: true`) instead of creating another; the same key with a different
|
|
82
|
+
* body is 409 `IDEMPOTENCY_KEY_REUSED`, while the first call runs 409
|
|
83
|
+
* `IDEMPOTENCY_KEY_IN_USE`. This POST is never retried automatically by the SDK.
|
|
84
|
+
* Resolves to `{ paymentIntent, replayed }`, `paymentIntent` being the body untouched.
|
|
85
|
+
*/
|
|
86
|
+
async createPaymentIntent(input, options) {
|
|
87
|
+
const idempotencyKey = options?.idempotencyKey;
|
|
88
|
+
if (idempotencyKey !== undefined &&
|
|
89
|
+
(typeof idempotencyKey !== "string" || idempotencyKey.length === 0)) {
|
|
90
|
+
throw new TypeError("idempotencyKey must be a non-empty string when provided");
|
|
91
|
+
}
|
|
92
|
+
const res = await this.#http.requestJsonWithHeaders({
|
|
93
|
+
method: "POST",
|
|
94
|
+
path: "/v1/billing/payment-intents",
|
|
95
|
+
...(idempotencyKey !== undefined
|
|
96
|
+
? { headers: { "Idempotency-Key": idempotencyKey } }
|
|
97
|
+
: {}),
|
|
98
|
+
body: compact({ purpose: input.purpose, amount: input.amount, saveCard: input.saveCard }),
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
paymentIntent: res.body,
|
|
102
|
+
replayed: res.headers.get("idempotent-replayed") === "true",
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* `POST /v1/billing/payment-intents/{id}/sync` — call right after
|
|
107
|
+
* `confirmPayment` resolves: the server reads the PaymentIntent from Stripe and, if
|
|
108
|
+
* it `succeeded`, credits the wallet exactly once (`credited: true` on that call
|
|
109
|
+
* only). It never charges. A malformed id is 400 `INVALID_PAYMENT_INTENT_ID`;
|
|
110
|
+
* unknown or another workspace's, 404 `PAYMENT_INTENT_NOT_FOUND`.
|
|
111
|
+
*/
|
|
112
|
+
async syncPaymentIntent(paymentIntentId) {
|
|
113
|
+
return this.#http.requestJson({
|
|
114
|
+
method: "POST",
|
|
115
|
+
path: `/v1/billing/payment-intents/${encodeURIComponent(paymentIntentId)}/sync`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
29
118
|
}
|
|
30
119
|
//# sourceMappingURL=billing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAczC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACf,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,cAAc,CAAC,KAAoB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiB;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,OAAO,CAAC;gBACV,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;aAC7B,CAAC;SACL,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAU;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EA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,GAAG,CAAC,IAAI;YACvB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,KAAK,MAAM;SAC9D,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,iBAAiB,CAAC,eAAuB;QAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAoB;YAC7C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,+BAA+B,kBAAkB,CAAC,eAAe,CAAC,OAAO;SAClF,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type { CreateTemplateInput, TemplateDeleteResult, TemplateDetail, TemplateListItem, UpdateTemplateInput } from "../types.js";
|
|
2
|
+
import type { CreateTemplateInput, TemplateDeleteResult, TemplateDetail, TemplateInsights, TemplateInsightsOptions, TemplateListItem, UpdateTemplateInput } from "../types.js";
|
|
3
3
|
export declare class TemplatesResource {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(http: HttpClient);
|
|
@@ -22,6 +22,18 @@ export declare class TemplatesResource {
|
|
|
22
22
|
create(input: CreateTemplateInput): Promise<TemplateDetail>;
|
|
23
23
|
/** Rewrites the body (and re-submits it to Meta). `examples` is still mandatory, for the NEW body. */
|
|
24
24
|
update(id: string, input: UpdateTemplateInput): Promise<TemplateDetail>;
|
|
25
|
+
/**
|
|
26
|
+
* Meta's analytics for the template over the last `days` (7, 30 or 90; the
|
|
27
|
+
* server defaults to 30): sent/delivered/read totals, read rate, button
|
|
28
|
+
* clicks and a daily series.
|
|
29
|
+
*
|
|
30
|
+
* The first call may enable template insights on the WABA at Meta. Errors:
|
|
31
|
+
* 400 `INVALID_DAYS`, 404 `TEMPLATE_NOT_FOUND`, 409 `TEMPLATE_NOT_ON_META` /
|
|
32
|
+
* `NO_META_NUMBER_FOR_WABA`, 422 `TEMPLATE_INSIGHTS_UNAVAILABLE_SMB` (WhatsApp
|
|
33
|
+
* Business App / coexistence accounts: Meta gives no insights there),
|
|
34
|
+
* 422 `META_REJECTED`, 503 `META_UNAVAILABLE`.
|
|
35
|
+
*/
|
|
36
|
+
insights(id: string, options?: TemplateInsightsOptions): Promise<TemplateInsights>;
|
|
25
37
|
/**
|
|
26
38
|
* Deletes the template (on Meta too, when it is a Meta template). Irreversible.
|
|
27
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAErB,qBAAa,iBAAiB;;gBAGd,IAAI,EAAE,UAAU;IAI5B;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAOnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO9C;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAejE,sGAAsG;IAChG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ7E;;;;;;;;;OASG;IACG,MAAM,CACR,EAAE,EAAE,MAAM,EACV,OAAO,GAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAO,GAC7C,OAAO,CAAC,oBAAoB,CAAC;CASnC"}
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAErB,qBAAa,iBAAiB;;gBAGd,IAAI,EAAE,UAAU;IAI5B;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAOnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO9C;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAejE,sGAAsG;IAChG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ7E;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ5F;;;;;;;;;OASG;IACG,MAAM,CACR,EAAE,EAAE,MAAM,EACV,OAAO,GAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAO,GAC7C,OAAO,CAAC,oBAAoB,CAAC;CASnC"}
|
|
@@ -52,6 +52,24 @@ export class TemplatesResource {
|
|
|
52
52
|
body: { body: input.body, examples: input.examples },
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Meta's analytics for the template over the last `days` (7, 30 or 90; the
|
|
57
|
+
* server defaults to 30): sent/delivered/read totals, read rate, button
|
|
58
|
+
* clicks and a daily series.
|
|
59
|
+
*
|
|
60
|
+
* The first call may enable template insights on the WABA at Meta. Errors:
|
|
61
|
+
* 400 `INVALID_DAYS`, 404 `TEMPLATE_NOT_FOUND`, 409 `TEMPLATE_NOT_ON_META` /
|
|
62
|
+
* `NO_META_NUMBER_FOR_WABA`, 422 `TEMPLATE_INSIGHTS_UNAVAILABLE_SMB` (WhatsApp
|
|
63
|
+
* Business App / coexistence accounts: Meta gives no insights there),
|
|
64
|
+
* 422 `META_REJECTED`, 503 `META_UNAVAILABLE`.
|
|
65
|
+
*/
|
|
66
|
+
async insights(id, options = {}) {
|
|
67
|
+
return this.#http.requestJson({
|
|
68
|
+
method: "GET",
|
|
69
|
+
path: `/v1/templates/${encodeURIComponent(id)}/insights`,
|
|
70
|
+
query: compact({ days: options.days }),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
55
73
|
/**
|
|
56
74
|
* Deletes the template (on Meta too, when it is a Meta template). Irreversible.
|
|
57
75
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAWzC,MAAM,OAAO,iBAAiB;IACjB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAqB;YAC9C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;SACxB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiB;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,iBAAiB,kBAAkB,CAAC,EAAE,CAAC,EAAE;SAClD,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,KAA0B;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiB;YAC1C,MAAM,EAAE,MAAM;YACd,I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AgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC;SACL,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { CreateWorkspaceWebhookInput, CreateWorkspaceWebhookResponse, ListWorkspaceWebhookDeliveriesParams, UpdateWorkspaceWebhookInput, WorkspaceWebhookDeleteResult, WorkspaceWebhookDeliveryList, WorkspaceWebhookDeliveryResponse, WorkspaceWebhookList, WorkspaceWebhookResponse } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Workspace webhooks (`/v1/workspace/webhooks*`) — events of the WORKSPACE, not of a
|
|
5
|
+
* number: every phone-line event plus `wallet.topup_paid`.
|
|
6
|
+
*
|
|
7
|
+
* It is the SAME registry as `client.phoneLines.webhooks` (same rows, `plwh_` secret,
|
|
8
|
+
* signature and deliveries), seen with the wider event set: this surface lists every
|
|
9
|
+
* webhook of the workspace and accepts `wallet.*` events. ⚠️ `"*"` means every
|
|
10
|
+
* PHONE-LINE event only — `wallet.topup_paid` is opt-in: name it
|
|
11
|
+
* (`["*", "wallet.topup_paid"]`).
|
|
12
|
+
*
|
|
13
|
+
* Requires a TENANT-scoped key with `phone_lines:webhooks` (ADMIN and up). Another
|
|
14
|
+
* workspace's webhook is 404 `WEBHOOK_NOT_FOUND`. Every method resolves to the
|
|
15
|
+
* response body untouched. Verify deliveries with `verifyWebhookSignature` and the
|
|
16
|
+
* webhook's `plwh_` secret.
|
|
17
|
+
*/
|
|
18
|
+
export declare class WorkspaceWebhooksResource {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(http: HttpClient);
|
|
21
|
+
/** `GET /v1/workspace/webhooks` — every webhook of the workspace (oldest first) and the event catalogue. Never the secret. */
|
|
22
|
+
list(): Promise<WorkspaceWebhookList>;
|
|
23
|
+
/** `GET /v1/workspace/webhooks/{id}` — never the secret. */
|
|
24
|
+
get(id: string): Promise<WorkspaceWebhookResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* `POST /v1/workspace/webhooks` → HTTP 201 `{ webhook }` WITH `secret` (`plwh_…`),
|
|
27
|
+
* the only time it is ever returned: store it right away.
|
|
28
|
+
*
|
|
29
|
+
* ⚠️ Not idempotent, and never retried by the SDK. `events`: a non-empty list of
|
|
30
|
+
* workspace events and/or `"*"` (phone-line events only).
|
|
31
|
+
*/
|
|
32
|
+
create(input: CreateWorkspaceWebhookInput): Promise<CreateWorkspaceWebhookResponse>;
|
|
33
|
+
/** `PATCH /v1/workspace/webhooks/{id}` — omitted fields stay; `events` REPLACES the list; `active: false` pauses. */
|
|
34
|
+
update(id: string, input: UpdateWorkspaceWebhookInput): Promise<WorkspaceWebhookResponse>;
|
|
35
|
+
/** `DELETE /v1/workspace/webhooks/{id}` — irreversible, deletes the delivery history too. */
|
|
36
|
+
delete(id: string): Promise<WorkspaceWebhookDeleteResult>;
|
|
37
|
+
/** `GET /v1/workspace/webhooks/{id}/deliveries` — newest first, never the payload. `limit` 1–200 (default 50). */
|
|
38
|
+
listDeliveries(id: string, params?: ListWorkspaceWebhookDeliveriesParams): Promise<WorkspaceWebhookDeliveryList>;
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/workspace/webhooks/{id}/deliveries/{deliveryId}` — one delivery in full,
|
|
41
|
+
* `payload` being the exact signed JSON string. ⛔ A `phone_line.code_received`
|
|
42
|
+
* payload carries the activation code. 404 `WEBHOOK_DELIVERY_NOT_FOUND` otherwise.
|
|
43
|
+
*/
|
|
44
|
+
getDelivery(id: string, deliveryId: string): Promise<WorkspaceWebhookDeliveryResponse>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=workspace-webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/workspace-webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,2BAA2B,EAC3B,8BAA8B,EAC9B,oCAAoC,EACpC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,oBAAoB,EACpB,wBAAwB,EAC3B,MAAM,aAAa,CAAC;AAIrB;;;;;;;;;;;;;;GAcG;AACH,qBAAa,yBAAyB;;gBAGtB,IAAI,EAAE,UAAU;IAI5B,8HAA8H;IACxH,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI3C,4DAA4D;IACtD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAOxD;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAQzF,qHAAqH;IAC/G,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAQ/F,6FAA6F;IACvF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAO/D,kHAAkH;IAC5G,cAAc,CAChB,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,oCAAoC,GAC9C,OAAO,CAAC,4BAA4B,CAAC;IAQxC;;;;OAIG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gCAAgC,CAAC;CAM/F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { compact } from "../internal.js";
|
|
2
|
+
const WEBHOOKS_PATH = "/v1/workspace/webhooks";
|
|
3
|
+
/**
|
|
4
|
+
* Workspace webhooks (`/v1/workspace/webhooks*`) — events of the WORKSPACE, not of a
|
|
5
|
+
* number: every phone-line event plus `wallet.topup_paid`.
|
|
6
|
+
*
|
|
7
|
+
* It is the SAME registry as `client.phoneLines.webhooks` (same rows, `plwh_` secret,
|
|
8
|
+
* signature and deliveries), seen with the wider event set: this surface lists every
|
|
9
|
+
* webhook of the workspace and accepts `wallet.*` events. ⚠️ `"*"` means every
|
|
10
|
+
* PHONE-LINE event only — `wallet.topup_paid` is opt-in: name it
|
|
11
|
+
* (`["*", "wallet.topup_paid"]`).
|
|
12
|
+
*
|
|
13
|
+
* Requires a TENANT-scoped key with `phone_lines:webhooks` (ADMIN and up). Another
|
|
14
|
+
* workspace's webhook is 404 `WEBHOOK_NOT_FOUND`. Every method resolves to the
|
|
15
|
+
* response body untouched. Verify deliveries with `verifyWebhookSignature` and the
|
|
16
|
+
* webhook's `plwh_` secret.
|
|
17
|
+
*/
|
|
18
|
+
export class WorkspaceWebhooksResource {
|
|
19
|
+
#http;
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.#http = http;
|
|
22
|
+
}
|
|
23
|
+
/** `GET /v1/workspace/webhooks` — every webhook of the workspace (oldest first) and the event catalogue. Never the secret. */
|
|
24
|
+
async list() {
|
|
25
|
+
return this.#http.requestJson({ method: "GET", path: WEBHOOKS_PATH });
|
|
26
|
+
}
|
|
27
|
+
/** `GET /v1/workspace/webhooks/{id}` — never the secret. */
|
|
28
|
+
async get(id) {
|
|
29
|
+
return this.#http.requestJson({
|
|
30
|
+
method: "GET",
|
|
31
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `POST /v1/workspace/webhooks` → HTTP 201 `{ webhook }` WITH `secret` (`plwh_…`),
|
|
36
|
+
* the only time it is ever returned: store it right away.
|
|
37
|
+
*
|
|
38
|
+
* ⚠️ Not idempotent, and never retried by the SDK. `events`: a non-empty list of
|
|
39
|
+
* workspace events and/or `"*"` (phone-line events only).
|
|
40
|
+
*/
|
|
41
|
+
async create(input) {
|
|
42
|
+
return this.#http.requestJson({
|
|
43
|
+
method: "POST",
|
|
44
|
+
path: WEBHOOKS_PATH,
|
|
45
|
+
body: compact({ name: input.name, url: input.url, events: input.events }),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** `PATCH /v1/workspace/webhooks/{id}` — omitted fields stay; `events` REPLACES the list; `active: false` pauses. */
|
|
49
|
+
async update(id, input) {
|
|
50
|
+
return this.#http.requestJson({
|
|
51
|
+
method: "PATCH",
|
|
52
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
53
|
+
body: compact({ name: input.name, url: input.url, events: input.events, active: input.active }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** `DELETE /v1/workspace/webhooks/{id}` — irreversible, deletes the delivery history too. */
|
|
57
|
+
async delete(id) {
|
|
58
|
+
return this.#http.requestJson({
|
|
59
|
+
method: "DELETE",
|
|
60
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** `GET /v1/workspace/webhooks/{id}/deliveries` — newest first, never the payload. `limit` 1–200 (default 50). */
|
|
64
|
+
async listDeliveries(id, params) {
|
|
65
|
+
return this.#http.requestJson({
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}/deliveries`,
|
|
68
|
+
query: compact({ limit: params?.limit }),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `GET /v1/workspace/webhooks/{id}/deliveries/{deliveryId}` — one delivery in full,
|
|
73
|
+
* `payload` being the exact signed JSON string. ⛔ A `phone_line.code_received`
|
|
74
|
+
* payload carries the activation code. 404 `WEBHOOK_DELIVERY_NOT_FOUND` otherwise.
|
|
75
|
+
*/
|
|
76
|
+
async getDelivery(id, deliveryId) {
|
|
77
|
+
return this.#http.requestJson({
|
|
78
|
+
method: "GET",
|
|
79
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}`,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=workspace-webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-webhooks.js","sourceRoot":"","sources":["../../src/resources/workspace-webhooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAazC,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,yBAAyB;IACzB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,8HAA8H;IAC9H,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAuB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,GAAG,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAA2B;YACpD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG,aAAa,IAAI,kBAAkB,CAAC,EAAE,CAAC,EAAE;SACrD,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,KAAkC;QAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiC;YAC1D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;SAC5E,CAAC,CAAC;IACP,CAAC;IAED,qHAAqH;IACrH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,KAAkC;QACvD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAA2B;Y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3
|
import type { WorkspaceDetail, WorkspaceMember, WorkspaceMemberList } from "../types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Workspace members — **read-only**.
|
|
@@ -43,6 +44,8 @@ export declare class WorkspaceMembersResource {
|
|
|
43
44
|
export declare class WorkspaceResource {
|
|
44
45
|
#private;
|
|
45
46
|
readonly members: WorkspaceMembersResource;
|
|
47
|
+
/** Workspace webhooks (`/v1/workspace/webhooks*`): phone-line and wallet events. */
|
|
48
|
+
readonly webhooks: WorkspaceWebhooksResource;
|
|
46
49
|
constructor(http: HttpClient);
|
|
47
50
|
/**
|
|
48
51
|
* `GET /v1/workspace` — `{ id, name, plan, seatsUsed, seatLimit }`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB;;gBAGrB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;OAaG;IACG,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAKxC;;;;;;;OAOG;IACG,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAMtD;AAED,wDAAwD;AACxD,qBAAa,iBAAiB;;IAE1B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB;;gBAGrB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;OAaG;IACG,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAKxC;;;;;;;OAOG;IACG,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAMtD;AAED,wDAAwD;AACxD,qBAAa,iBAAiB;;IAE1B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;gBAEjC,IAAI,EAAE,UAAU;IAM5B;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;CAMxC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkspaceWebhooksResource } from "./workspace-webhooks.js";
|
|
1
2
|
/**
|
|
2
3
|
* Workspace members — **read-only**.
|
|
3
4
|
*
|
|
@@ -51,9 +52,12 @@ export class WorkspaceMembersResource {
|
|
|
51
52
|
export class WorkspaceResource {
|
|
52
53
|
#http;
|
|
53
54
|
members;
|
|
55
|
+
/** Workspace webhooks (`/v1/workspace/webhooks*`): phone-line and wallet events. */
|
|
56
|
+
webhooks;
|
|
54
57
|
constructor(http) {
|
|
55
58
|
this.#http = http;
|
|
56
59
|
this.members = new WorkspaceMembersResource(http);
|
|
60
|
+
this.webhooks = new WorkspaceWebhooksResource(http);
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* `GET /v1/workspace` — `{ id, name, plan, seatsUsed, seatLimit }`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAAwB;IACxB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB;SAChC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,wDAAwD;AACxD,MAAM,OAAO,iBAAiB;IACjB,KAAK,CAAa;IAClB,OAAO,CAA2B;IAC3C,oFAAoF;IAC3E,QAAQ,CAA4B;IAE7C,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAkB;YAC3C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;SACxB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { AccountWorkspaceList, CreatedWorkspace, CreatedWorkspaceKey, CreateWorkspaceInput, CreateWorkspaceKeyInput, RevokedWorkspaceKey, WorkspaceKeyList } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The keys of ONE workspace (`/v1/workspaces/{id}/api-keys*`), managed with an ACCOUNT
|
|
5
|
+
* key and the user's LIVE role there. Not a member (or the workspace does not exist /
|
|
6
|
+
* is archived) → 403 `WORKSPACE_MEMBERSHIP_REQUIRED`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class WorkspaceApiKeysResource {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
/** `GET /v1/workspaces/{id}/api-keys` — the workspace's keys, MASKED (ADMIN and up). */
|
|
12
|
+
list(workspaceId: string): Promise<WorkspaceKeyList>;
|
|
13
|
+
/**
|
|
14
|
+
* `POST /v1/workspaces/{id}/api-keys` → HTTP 201 — mints a NAMED `ps_workspace_`
|
|
15
|
+
* key (never the primary); `apiKey.key` is shown ONCE. ADMIN and up. 409
|
|
16
|
+
* `WORKSPACE_KEY_LIMIT_REACHED` (with `limit`) at the cap. Not idempotent.
|
|
17
|
+
*/
|
|
18
|
+
create(workspaceId: string, input: CreateWorkspaceKeyInput): Promise<CreatedWorkspaceKey>;
|
|
19
|
+
/**
|
|
20
|
+
* `DELETE /v1/workspaces/{id}/api-keys/{keyId}` — revokes a NAMED key (effective on
|
|
21
|
+
* the next request). The primary key is 409 `PRIMARY_KEY_NOT_REVOCABLE` (rotate it
|
|
22
|
+
* with `POST /v1/api-keys/regenerate` and `workspaceId` instead); an unknown id is 404 `API_KEY_NOT_FOUND`.
|
|
23
|
+
*/
|
|
24
|
+
revoke(workspaceId: string, keyId: string): Promise<RevokedWorkspaceKey>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Account-level workspaces (`/v1/workspaces*`). ⛔ ACCOUNT key (`ps_account_`) ONLY —
|
|
28
|
+
* any other credential (workspace key, number key, OAuth token) is 403
|
|
29
|
+
* `ACCOUNT_KEY_REQUIRED`. `workspaceId` is not needed here: these routes name their
|
|
30
|
+
* workspace in the path. Every method resolves to the response body untouched.
|
|
31
|
+
*/
|
|
32
|
+
export declare class WorkspacesResource {
|
|
33
|
+
#private;
|
|
34
|
+
readonly apiKeys: WorkspaceApiKeysResource;
|
|
35
|
+
constructor(http: HttpClient);
|
|
36
|
+
/** `GET /v1/workspaces` — the workspaces the key's user is an ACTIVE member of, with their role. */
|
|
37
|
+
list(): Promise<AccountWorkspaceList>;
|
|
38
|
+
/**
|
|
39
|
+
* `POST /v1/workspaces` → HTTP 201 — a workspace owned by the key's user, with its
|
|
40
|
+
* PRIMARY key in `apiKey` (shown once; `null` if minting failed — then mint one with
|
|
41
|
+
* `apiKeys.create()`, do NOT create the workspace again). 409
|
|
42
|
+
* `WORKSPACE_LIMIT_REACHED` (with `limit`) at the user's ceiling. Not idempotent,
|
|
43
|
+
* never retried by the SDK.
|
|
44
|
+
*/
|
|
45
|
+
create(input: CreateWorkspaceInput): Promise<CreatedWorkspace>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../src/resources/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACR,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,aAAa,CAAC;AAQrB;;;;GAIG;AACH,qBAAa,wBAAwB;;gBAGrB,IAAI,EAAE,UAAU;IAI5B,wFAAwF;IAClF,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;;;OAIG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ/F;;;;OAIG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAMjF;AAED;;;;;GAKG;AACH,qBAAa,kBAAkB;;IAE3B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;gBAE/B,IAAI,EAAE,UAAU;IAK5B,oGAAoG;IAC9F,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI3C;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAOvE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const WORKSPACES_PATH = "/v1/workspaces";
|
|
2
|
+
function keysPath(workspaceId) {
|
|
3
|
+
return `${WORKSPACES_PATH}/${encodeURIComponent(workspaceId)}/api-keys`;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The keys of ONE workspace (`/v1/workspaces/{id}/api-keys*`), managed with an ACCOUNT
|
|
7
|
+
* key and the user's LIVE role there. Not a member (or the workspace does not exist /
|
|
8
|
+
* is archived) → 403 `WORKSPACE_MEMBERSHIP_REQUIRED`.
|
|
9
|
+
*/
|
|
10
|
+
export class WorkspaceApiKeysResource {
|
|
11
|
+
#http;
|
|
12
|
+
constructor(http) {
|
|
13
|
+
this.#http = http;
|
|
14
|
+
}
|
|
15
|
+
/** `GET /v1/workspaces/{id}/api-keys` — the workspace's keys, MASKED (ADMIN and up). */
|
|
16
|
+
async list(workspaceId) {
|
|
17
|
+
return this.#http.requestJson({ method: "GET", path: keysPath(workspaceId) });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `POST /v1/workspaces/{id}/api-keys` → HTTP 201 — mints a NAMED `ps_workspace_`
|
|
21
|
+
* key (never the primary); `apiKey.key` is shown ONCE. ADMIN and up. 409
|
|
22
|
+
* `WORKSPACE_KEY_LIMIT_REACHED` (with `limit`) at the cap. Not idempotent.
|
|
23
|
+
*/
|
|
24
|
+
async create(workspaceId, input) {
|
|
25
|
+
return this.#http.requestJson({
|
|
26
|
+
method: "POST",
|
|
27
|
+
path: keysPath(workspaceId),
|
|
28
|
+
body: { name: input.name },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `DELETE /v1/workspaces/{id}/api-keys/{keyId}` — revokes a NAMED key (effective on
|
|
33
|
+
* the next request). The primary key is 409 `PRIMARY_KEY_NOT_REVOCABLE` (rotate it
|
|
34
|
+
* with `POST /v1/api-keys/regenerate` and `workspaceId` instead); an unknown id is 404 `API_KEY_NOT_FOUND`.
|
|
35
|
+
*/
|
|
36
|
+
async revoke(workspaceId, keyId) {
|
|
37
|
+
return this.#http.requestJson({
|
|
38
|
+
method: "DELETE",
|
|
39
|
+
path: `${keysPath(workspaceId)}/${encodeURIComponent(keyId)}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Account-level workspaces (`/v1/workspaces*`). ⛔ ACCOUNT key (`ps_account_`) ONLY —
|
|
45
|
+
* any other credential (workspace key, number key, OAuth token) is 403
|
|
46
|
+
* `ACCOUNT_KEY_REQUIRED`. `workspaceId` is not needed here: these routes name their
|
|
47
|
+
* workspace in the path. Every method resolves to the response body untouched.
|
|
48
|
+
*/
|
|
49
|
+
export class WorkspacesResource {
|
|
50
|
+
#http;
|
|
51
|
+
apiKeys;
|
|
52
|
+
constructor(http) {
|
|
53
|
+
this.#http = http;
|
|
54
|
+
this.apiKeys = new WorkspaceApiKeysResource(http);
|
|
55
|
+
}
|
|
56
|
+
/** `GET /v1/workspaces` — the workspaces the key's user is an ACTIVE member of, with their role. */
|
|
57
|
+
async list() {
|
|
58
|
+
return this.#http.requestJson({ method: "GET", path: WORKSPACES_PATH });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `POST /v1/workspaces` → HTTP 201 — a workspace owned by the key's user, with its
|
|
62
|
+
* PRIMARY key in `apiKey` (shown once; `null` if minting failed — then mint one with
|
|
63
|
+
* `apiKeys.create()`, do NOT create the workspace again). 409
|
|
64
|
+
* `WORKSPACE_LIMIT_REACHED` (with `limit`) at the user's ceiling. Not idempotent,
|
|
65
|
+
* never retried by the SDK.
|
|
66
|
+
*/
|
|
67
|
+
async create(input) {
|
|
68
|
+
return this.#http.requestJson({
|
|
69
|
+
method: "POST",
|
|
70
|
+
path: WORKSPACES_PATH,
|
|
71
|
+
body: { name: input.name },
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/resources/workspaces.ts"],"names":[],"mappings":"AAWA,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC,SAAS,QAAQ,CAAC,WAAmB;IACjC,OAAO,GAAG,eAAe,IAAI,kBAAkB,CAAC,WAAW,CAAC,WAAW,CAAC;AAC5E,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,wBAAwB;IACxB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,wFAAwF;IACxF,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAmB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,KAA8B;QAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC;YAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;SAC7B,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,KAAa;QAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MA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