@pilot-status/sdk 0.5.0 → 0.9.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/README.md +181 -19
  3. package/dist/client.d.ts +53 -2
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +54 -4
  6. package/dist/client.js.map +1 -1
  7. package/dist/errors.d.ts +58 -0
  8. package/dist/errors.d.ts.map +1 -1
  9. package/dist/errors.js +65 -0
  10. package/dist/errors.js.map +1 -1
  11. package/dist/http.d.ts +6 -0
  12. package/dist/http.d.ts.map +1 -1
  13. package/dist/http.js +3 -0
  14. package/dist/http.js.map +1 -1
  15. package/dist/index.d.ts +12 -5
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +10 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/internal.d.ts +19 -0
  20. package/dist/internal.d.ts.map +1 -0
  21. package/dist/internal.js +27 -0
  22. package/dist/internal.js.map +1 -0
  23. package/dist/resources/api-keys.d.ts +20 -7
  24. package/dist/resources/api-keys.d.ts.map +1 -1
  25. package/dist/resources/api-keys.js +18 -5
  26. package/dist/resources/api-keys.js.map +1 -1
  27. package/dist/resources/billing.d.ts +18 -0
  28. package/dist/resources/billing.d.ts.map +1 -0
  29. package/dist/resources/billing.js +30 -0
  30. package/dist/resources/billing.js.map +1 -0
  31. package/dist/resources/branding.d.ts +18 -0
  32. package/dist/resources/branding.d.ts.map +1 -0
  33. package/dist/resources/branding.js +29 -0
  34. package/dist/resources/branding.js.map +1 -0
  35. package/dist/resources/chatwoot.d.ts +57 -0
  36. package/dist/resources/chatwoot.d.ts.map +1 -0
  37. package/dist/resources/chatwoot.js +117 -0
  38. package/dist/resources/chatwoot.js.map +1 -0
  39. package/dist/resources/conversations.d.ts +16 -0
  40. package/dist/resources/conversations.d.ts.map +1 -0
  41. package/dist/resources/conversations.js +28 -0
  42. package/dist/resources/conversations.js.map +1 -0
  43. package/dist/resources/embed.d.ts +24 -0
  44. package/dist/resources/embed.d.ts.map +1 -0
  45. package/dist/resources/embed.js +37 -0
  46. package/dist/resources/embed.js.map +1 -0
  47. package/dist/resources/flows.d.ts +203 -0
  48. package/dist/resources/flows.d.ts.map +1 -0
  49. package/dist/resources/flows.js +289 -0
  50. package/dist/resources/flows.js.map +1 -0
  51. package/dist/resources/groups.d.ts +37 -1
  52. package/dist/resources/groups.d.ts.map +1 -1
  53. package/dist/resources/groups.js +91 -0
  54. package/dist/resources/groups.js.map +1 -1
  55. package/dist/resources/messages.d.ts +43 -1
  56. package/dist/resources/messages.d.ts.map +1 -1
  57. package/dist/resources/messages.js +113 -1
  58. package/dist/resources/messages.js.map +1 -1
  59. package/dist/resources/meta.d.ts +19 -0
  60. package/dist/resources/meta.d.ts.map +1 -0
  61. package/dist/resources/meta.js +31 -0
  62. package/dist/resources/meta.js.map +1 -0
  63. package/dist/resources/numbers.d.ts +63 -1
  64. package/dist/resources/numbers.d.ts.map +1 -1
  65. package/dist/resources/numbers.js +101 -0
  66. package/dist/resources/numbers.js.map +1 -1
  67. package/dist/resources/service-window.d.ts +20 -0
  68. package/dist/resources/service-window.d.ts.map +1 -0
  69. package/dist/resources/service-window.js +26 -0
  70. package/dist/resources/service-window.js.map +1 -0
  71. package/dist/resources/subscription.d.ts +43 -0
  72. package/dist/resources/subscription.d.ts.map +1 -0
  73. package/dist/resources/subscription.js +60 -0
  74. package/dist/resources/subscription.js.map +1 -0
  75. package/dist/resources/templates.d.ts +31 -1
  76. package/dist/resources/templates.d.ts.map +1 -1
  77. package/dist/resources/templates.js +56 -0
  78. package/dist/resources/templates.js.map +1 -1
  79. package/dist/resources/webhooks.d.ts +53 -0
  80. package/dist/resources/webhooks.d.ts.map +1 -0
  81. package/dist/resources/webhooks.js +97 -0
  82. package/dist/resources/webhooks.js.map +1 -0
  83. package/dist/resources/workspace.d.ts +57 -0
  84. package/dist/resources/workspace.d.ts.map +1 -0
  85. package/dist/resources/workspace.js +73 -0
  86. package/dist/resources/workspace.js.map +1 -0
  87. package/dist/types.d.ts +993 -23
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.js.map +1 -1
  90. package/dist/webhooks/parse.d.ts +16 -0
  91. package/dist/webhooks/parse.d.ts.map +1 -1
  92. package/dist/webhooks/parse.js +109 -0
  93. package/dist/webhooks/parse.js.map +1 -1
  94. package/dist/webhooks/signature.d.ts +42 -0
  95. package/dist/webhooks/signature.d.ts.map +1 -0
  96. package/dist/webhooks/signature.js +40 -0
  97. package/dist/webhooks/signature.js.map +1 -0
  98. package/dist/webhooks/types.d.ts +144 -2
  99. package/dist/webhooks/types.d.ts.map +1 -1
  100. package/package.json +5 -3
  101. package/dist/messages.test.d.ts +0 -2
  102. package/dist/messages.test.d.ts.map +0 -1
  103. package/dist/messages.test.js +0 -107
  104. package/dist/messages.test.js.map +0 -1
  105. package/dist/numbers.test.d.ts +0 -2
  106. package/dist/numbers.test.d.ts.map +0 -1
  107. package/dist/numbers.test.js +0 -57
  108. package/dist/numbers.test.js.map +0 -1
  109. package/dist/resources/groups.test.d.ts +0 -2
  110. package/dist/resources/groups.test.d.ts.map +0 -1
  111. package/dist/resources/groups.test.js +0 -19
  112. package/dist/resources/groups.test.js.map +0 -1
  113. package/dist/resources/newsletters.test.d.ts +0 -2
  114. package/dist/resources/newsletters.test.d.ts.map +0 -1
  115. package/dist/resources/newsletters.test.js +0 -19
  116. package/dist/resources/newsletters.test.js.map +0 -1
  117. package/dist/resources/projects.d.ts +0 -9
  118. package/dist/resources/projects.d.ts.map +0 -1
  119. package/dist/resources/projects.js +0 -23
  120. package/dist/resources/projects.js.map +0 -1
  121. package/dist/resources/templates.test.d.ts +0 -2
  122. package/dist/resources/templates.test.d.ts.map +0 -1
  123. package/dist/resources/templates.test.js +0 -28
  124. package/dist/resources/templates.test.js.map +0 -1
@@ -0,0 +1,53 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { CreateWebhookInput, UpdateWebhookInput, Webhook, WebhookDeleteResult, WebhookLogEntry, WebhookLogsParams } from "../types.js";
3
+ /**
4
+ * CRUD of the webhook subscriptions (`/v1/webhooks*`).
5
+ *
6
+ * ⚠️ The signing `secret` NEVER comes back in any of these responses — anyone who
7
+ * could read it would be able to FORGE signed events for the customer's endpoint.
8
+ * It is shown only once, in the dashboard. To validate a received delivery use
9
+ * {@link ../webhooks/signature.js#verifyWebhookSignature}.
10
+ */
11
+ export declare class WebhooksResource {
12
+ #private;
13
+ constructor(http: HttpClient);
14
+ /**
15
+ * The webhooks visible to the credential's scope.
16
+ *
17
+ * With a number in play (a number key, or `whatsappNumberId` on the client)
18
+ * the list is STRICTLY that number's webhooks — legacy webhooks with no
19
+ * subscription at all are left out on purpose.
20
+ */
21
+ list(): Promise<Webhook[]>;
22
+ /**
23
+ * Creates a webhook bound to ONE number.
24
+ *
25
+ * An empty or omitted `events` **fires nothing**: there is no implicit
26
+ * subscribe-to-everything — pass `["*"]` for all of them. Events the number's
27
+ * provider does not emit are silently discarded.
28
+ *
29
+ * With a tenant-scoped key and no `whatsappNumberId` on the client, the body's
30
+ * `whatsappNumberId` field is mandatory (400 `NUMBER_REQUIRED`).
31
+ */
32
+ create(input: CreateWebhookInput): Promise<Webhook>;
33
+ get(id: string): Promise<Webhook>;
34
+ /**
35
+ * Partial update. `events` is a REPLACEMENT of the whole list, not a merge —
36
+ * sending `[]` turns off every delivery without deleting the webhook (the same
37
+ * as `active: false`, by a different route).
38
+ *
39
+ * A webhook's number is not editable: delete it and recreate it.
40
+ */
41
+ update(id: string, input: UpdateWebhookInput): Promise<Webhook>;
42
+ /** Irreversible: deletes the subscription and the delivery logs. To merely pause, use `update(id, { active: false })`. */
43
+ delete(id: string): Promise<WebhookDeleteResult>;
44
+ /**
45
+ * Recent delivery attempts (`limit` 1–50).
46
+ *
47
+ * ⚠️ On a per-number OAuth connection this route answers 400 `NUMBER_REQUIRED`
48
+ * without `x-whatsapp-number-id` — build the client with `whatsappNumberId`,
49
+ * or use `client.withNumber(id).webhooks.logs(...)`.
50
+ */
51
+ logs(id: string, params?: WebhookLogsParams): Promise<WebhookLogEntry[]>;
52
+ }
53
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACpB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,qBAAa,gBAAgB;;gBAGb,IAAI,EAAE,UAAU;IAI5B;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAOhC;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAanD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvC;;;;;;OAMG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAarE,0HAA0H;IACpH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOtD;;;;;;OAMG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAOjF"}
@@ -0,0 +1,97 @@
1
+ import { compact } from "../internal.js";
2
+ /**
3
+ * CRUD of the webhook subscriptions (`/v1/webhooks*`).
4
+ *
5
+ * ⚠️ The signing `secret` NEVER comes back in any of these responses — anyone who
6
+ * could read it would be able to FORGE signed events for the customer's endpoint.
7
+ * It is shown only once, in the dashboard. To validate a received delivery use
8
+ * {@link ../webhooks/signature.js#verifyWebhookSignature}.
9
+ */
10
+ export class WebhooksResource {
11
+ #http;
12
+ constructor(http) {
13
+ this.#http = http;
14
+ }
15
+ /**
16
+ * The webhooks visible to the credential's scope.
17
+ *
18
+ * With a number in play (a number key, or `whatsappNumberId` on the client)
19
+ * the list is STRICTLY that number's webhooks — legacy webhooks with no
20
+ * subscription at all are left out on purpose.
21
+ */
22
+ async list() {
23
+ return this.#http.requestJson({
24
+ method: "GET",
25
+ path: "/v1/webhooks",
26
+ });
27
+ }
28
+ /**
29
+ * Creates a webhook bound to ONE number.
30
+ *
31
+ * An empty or omitted `events` **fires nothing**: there is no implicit
32
+ * subscribe-to-everything — pass `["*"]` for all of them. Events the number's
33
+ * provider does not emit are silently discarded.
34
+ *
35
+ * With a tenant-scoped key and no `whatsappNumberId` on the client, the body's
36
+ * `whatsappNumberId` field is mandatory (400 `NUMBER_REQUIRED`).
37
+ */
38
+ async create(input) {
39
+ return this.#http.requestJson({
40
+ method: "POST",
41
+ path: "/v1/webhooks",
42
+ body: compact({
43
+ url: input.url,
44
+ name: input.name,
45
+ events: input.events,
46
+ whatsappNumberId: input.whatsappNumberId,
47
+ }),
48
+ });
49
+ }
50
+ async get(id) {
51
+ return this.#http.requestJson({
52
+ method: "GET",
53
+ path: `/v1/webhooks/${encodeURIComponent(id)}`,
54
+ });
55
+ }
56
+ /**
57
+ * Partial update. `events` is a REPLACEMENT of the whole list, not a merge —
58
+ * sending `[]` turns off every delivery without deleting the webhook (the same
59
+ * as `active: false`, by a different route).
60
+ *
61
+ * A webhook's number is not editable: delete it and recreate it.
62
+ */
63
+ async update(id, input) {
64
+ return this.#http.requestJson({
65
+ method: "PATCH",
66
+ path: `/v1/webhooks/${encodeURIComponent(id)}`,
67
+ body: compact({
68
+ name: input.name,
69
+ url: input.url,
70
+ active: input.active,
71
+ events: input.events,
72
+ }),
73
+ });
74
+ }
75
+ /** Irreversible: deletes the subscription and the delivery logs. To merely pause, use `update(id, { active: false })`. */
76
+ async delete(id) {
77
+ return this.#http.requestJson({
78
+ method: "DELETE",
79
+ path: `/v1/webhooks/${encodeURIComponent(id)}`,
80
+ });
81
+ }
82
+ /**
83
+ * Recent delivery attempts (`limit` 1–50).
84
+ *
85
+ * ⚠️ On a per-number OAuth connection this route answers 400 `NUMBER_REQUIRED`
86
+ * without `x-whatsapp-number-id` — build the client with `whatsappNumberId`,
87
+ * or use `client.withNumber(id).webhooks.logs(...)`.
88
+ */
89
+ async logs(id, params) {
90
+ return this.#http.requestJson({
91
+ method: "GET",
92
+ path: `/v1/webhooks/${encodeURIComponent(id)}/logs`,
93
+ query: compact({ limit: params?.limit, event: params?.event }),
94
+ });
95
+ }
96
+ }
97
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAUzC;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAChB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAY;YACrC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc;SACvB,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CAAC,KAAyB;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAU;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,OAAO,CAAC;gBACV,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;aAC3C,CAAC;SACL,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAU;YACnC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE;SACjD,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,KAAyB;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAU;YACnC,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE;YAC9C,IAAI,EAAE,OAAO,CAAC;gBACV,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM;aACvB,CAAC;SACL,CAAC,CAAC;IACP,CAAC;IAED,0HAA0H;IAC1H,KAAK,CAAC,MAAM,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE;SACjD,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,EAAU,EAAE,MAA0B;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAoB;YAC7C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,OAAO;YACnD,KAAK,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;SACjE,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,57 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { WorkspaceDetail, WorkspaceMember, WorkspaceMemberList } from "../types.js";
3
+ /**
4
+ * Workspace members — **read-only**.
5
+ *
6
+ * Inviting, resending an invite, changing a role and removing DO EXIST in `/v1`,
7
+ * but they only accept an OAuth principal: member writes require a user on the
8
+ * wire, and a `ps_` key has none (`ApiKey.createdByUserId` is provenance, not
9
+ * authorization). Since this SDK only speaks `x-api-key`, exposing `invite()`
10
+ * here would mean publishing a method that answers
11
+ * `403 MACHINE_CREDENTIAL_CANNOT_MANAGE_MEMBERS` 100% of the time — a trap, not a
12
+ * feature. Use the dashboard or an OAuth connector.
13
+ */
14
+ export declare class WorkspaceMembersResource {
15
+ #private;
16
+ constructor(http: HttpClient);
17
+ /**
18
+ * ACTIVE and PENDING members in a single list (`GET /v1/workspace/members`).
19
+ *
20
+ * A pending invite NEVER carries a token nor an `inviteUrl`: we only store the
21
+ * hash, so the link is not re-derivable once it has been issued.
22
+ *
23
+ * Requires a tenant-scoped credential; a number key gets a 403.
24
+ *
25
+ * ⚠️ The route answers an ENVELOPE — `{ members, seatsUsed, seatLimit }` — and
26
+ * `requestJson` hands the parsed body straight back. Without the unwrap below,
27
+ * this method resolved to that object while claiming to be an array, so the
28
+ * first `.map()` a caller wrote threw `map is not a function`. Use
29
+ * {@link listWithSeats} when the seat counters matter.
30
+ */
31
+ list(): Promise<WorkspaceMember[]>;
32
+ /**
33
+ * The same call as {@link list}, returning the route's body verbatim so the
34
+ * seat counters are not thrown away.
35
+ *
36
+ * `seatsUsed` and `seatLimit` are the ones `GET /v1/workspace` reports, sent
37
+ * here too so "who is in the workspace" and "is there room for one more" cost
38
+ * a single round trip. `seatsUsed` counts ACTIVE members **and** PENDING
39
+ * invites still inside their window — an invite holds its seat, otherwise the
40
+ * cap would be bypassable by mass-inviting.
41
+ */
42
+ listWithSeats(): Promise<WorkspaceMemberList>;
43
+ }
44
+ /** The credential's workspace (account) — read-only. */
45
+ export declare class WorkspaceResource {
46
+ #private;
47
+ readonly members: WorkspaceMembersResource;
48
+ constructor(http: HttpClient);
49
+ /**
50
+ * `GET /v1/workspace` — `{ id, name, plan, seatsUsed, seatLimit }`.
51
+ *
52
+ * `seatsUsed` counts ACTIVE members **and** PENDING invites: an invite already
53
+ * holds the seat, otherwise the cap would be bypassable by mass-inviting.
54
+ */
55
+ get(): Promise<WorkspaceDetail>;
56
+ }
57
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +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;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAMtD;AAED,wDAAwD;AACxD,qBAAa,iBAAiB;;IAE1B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;gBAE/B,IAAI,EAAE,UAAU;IAK5B;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;CAMxC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Workspace members — **read-only**.
3
+ *
4
+ * Inviting, resending an invite, changing a role and removing DO EXIST in `/v1`,
5
+ * but they only accept an OAuth principal: member writes require a user on the
6
+ * wire, and a `ps_` key has none (`ApiKey.createdByUserId` is provenance, not
7
+ * authorization). Since this SDK only speaks `x-api-key`, exposing `invite()`
8
+ * here would mean publishing a method that answers
9
+ * `403 MACHINE_CREDENTIAL_CANNOT_MANAGE_MEMBERS` 100% of the time — a trap, not a
10
+ * feature. Use the dashboard or an OAuth connector.
11
+ */
12
+ export class WorkspaceMembersResource {
13
+ #http;
14
+ constructor(http) {
15
+ this.#http = http;
16
+ }
17
+ /**
18
+ * ACTIVE and PENDING members in a single list (`GET /v1/workspace/members`).
19
+ *
20
+ * A pending invite NEVER carries a token nor an `inviteUrl`: we only store the
21
+ * hash, so the link is not re-derivable once it has been issued.
22
+ *
23
+ * Requires a tenant-scoped credential; a number key gets a 403.
24
+ *
25
+ * ⚠️ The route answers an ENVELOPE — `{ members, seatsUsed, seatLimit }` — and
26
+ * `requestJson` hands the parsed body straight back. Without the unwrap below,
27
+ * this method resolved to that object while claiming to be an array, so the
28
+ * first `.map()` a caller wrote threw `map is not a function`. Use
29
+ * {@link listWithSeats} when the seat counters matter.
30
+ */
31
+ async list() {
32
+ const page = await this.listWithSeats();
33
+ return page.members;
34
+ }
35
+ /**
36
+ * The same call as {@link list}, returning the route's body verbatim so the
37
+ * seat counters are not thrown away.
38
+ *
39
+ * `seatsUsed` and `seatLimit` are the ones `GET /v1/workspace` reports, sent
40
+ * here too so "who is in the workspace" and "is there room for one more" cost
41
+ * a single round trip. `seatsUsed` counts ACTIVE members **and** PENDING
42
+ * invites still inside their window — an invite holds its seat, otherwise the
43
+ * cap would be bypassable by mass-inviting.
44
+ */
45
+ async listWithSeats() {
46
+ return this.#http.requestJson({
47
+ method: "GET",
48
+ path: "/v1/workspace/members",
49
+ });
50
+ }
51
+ }
52
+ /** The credential's workspace (account) — read-only. */
53
+ export class WorkspaceResource {
54
+ #http;
55
+ members;
56
+ constructor(http) {
57
+ this.#http = http;
58
+ this.members = new WorkspaceMembersResource(http);
59
+ }
60
+ /**
61
+ * `GET /v1/workspace` — `{ id, name, plan, seatsUsed, seatLimit }`.
62
+ *
63
+ * `seatsUsed` counts ACTIVE members **and** PENDING invites: an invite already
64
+ * holds the seat, otherwise the cap would be bypassable by mass-inviting.
65
+ */
66
+ async get() {
67
+ return this.#http.requestJson({
68
+ method: "GET",
69
+ path: "/v1/workspace",
70
+ });
71
+ }
72
+ }
73
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;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;;;;;;;;;OASG;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;IAE3C,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACtD,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"}