@w6w/sdk 0.6.0 → 0.9.9

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 (120) hide show
  1. package/README.md +166 -16
  2. package/dist/mod.d.ts +7 -5
  3. package/dist/mod.d.ts.map +1 -1
  4. package/dist/mod.js +1 -0
  5. package/dist/mod.js.map +1 -1
  6. package/dist/src/client.d.ts +11 -2
  7. package/dist/src/client.d.ts.map +1 -1
  8. package/dist/src/client.js +12 -2
  9. package/dist/src/client.js.map +1 -1
  10. package/dist/src/config.d.ts +83 -6
  11. package/dist/src/config.d.ts.map +1 -1
  12. package/dist/src/config.js +40 -4
  13. package/dist/src/config.js.map +1 -1
  14. package/dist/src/connections.d.ts +3 -2
  15. package/dist/src/connections.d.ts.map +1 -1
  16. package/dist/src/connections.js +7 -2
  17. package/dist/src/connections.js.map +1 -1
  18. package/dist/src/console/api-calls.d.ts +4 -3
  19. package/dist/src/console/api-calls.d.ts.map +1 -1
  20. package/dist/src/console/api-calls.js +4 -3
  21. package/dist/src/console/api-calls.js.map +1 -1
  22. package/dist/src/console/apps.d.ts +181 -8
  23. package/dist/src/console/apps.d.ts.map +1 -1
  24. package/dist/src/console/apps.js +67 -12
  25. package/dist/src/console/apps.js.map +1 -1
  26. package/dist/src/console/auth.d.ts +43 -3
  27. package/dist/src/console/auth.d.ts.map +1 -1
  28. package/dist/src/console/auth.js +23 -4
  29. package/dist/src/console/auth.js.map +1 -1
  30. package/dist/src/console/commerce.d.ts +428 -0
  31. package/dist/src/console/commerce.d.ts.map +1 -0
  32. package/dist/src/console/commerce.js +220 -0
  33. package/dist/src/console/commerce.js.map +1 -0
  34. package/dist/src/console/dashboard.d.ts +8 -0
  35. package/dist/src/console/dashboard.d.ts.map +1 -1
  36. package/dist/src/console/dashboard.js.map +1 -1
  37. package/dist/src/console/endpoints.d.ts +57 -2
  38. package/dist/src/console/endpoints.d.ts.map +1 -1
  39. package/dist/src/console/endpoints.js.map +1 -1
  40. package/dist/src/console/functions.d.ts +35 -4
  41. package/dist/src/console/functions.d.ts.map +1 -1
  42. package/dist/src/console/functions.js +13 -0
  43. package/dist/src/console/functions.js.map +1 -1
  44. package/dist/src/console/mod.d.ts +22 -7
  45. package/dist/src/console/mod.d.ts.map +1 -1
  46. package/dist/src/console/mod.js +16 -1
  47. package/dist/src/console/mod.js.map +1 -1
  48. package/dist/src/console/otp.d.ts +127 -0
  49. package/dist/src/console/otp.d.ts.map +1 -0
  50. package/dist/src/console/otp.js +118 -0
  51. package/dist/src/console/otp.js.map +1 -0
  52. package/dist/src/console/reliability.d.ts +101 -6
  53. package/dist/src/console/reliability.d.ts.map +1 -1
  54. package/dist/src/console/reliability.js +16 -5
  55. package/dist/src/console/reliability.js.map +1 -1
  56. package/dist/src/console/step-tests.d.ts +7 -1
  57. package/dist/src/console/step-tests.d.ts.map +1 -1
  58. package/dist/src/console/step-tests.js +1 -1
  59. package/dist/src/console/step-tests.js.map +1 -1
  60. package/dist/src/console/subscriptions.d.ts +38 -16
  61. package/dist/src/console/subscriptions.d.ts.map +1 -1
  62. package/dist/src/console/subscriptions.js +7 -13
  63. package/dist/src/console/subscriptions.js.map +1 -1
  64. package/dist/src/console/tenant-login-flags.d.ts +106 -0
  65. package/dist/src/console/tenant-login-flags.d.ts.map +1 -0
  66. package/dist/src/console/tenant-login-flags.js +113 -0
  67. package/dist/src/console/tenant-login-flags.js.map +1 -0
  68. package/dist/src/console/tenant-oauth-apps.d.ts +75 -14
  69. package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -1
  70. package/dist/src/console/tenant-oauth-apps.js +37 -11
  71. package/dist/src/console/tenant-oauth-apps.js.map +1 -1
  72. package/dist/src/console/tokens.d.ts +2 -0
  73. package/dist/src/console/tokens.d.ts.map +1 -1
  74. package/dist/src/console/tokens.js.map +1 -1
  75. package/dist/src/console/workflows.d.ts +14 -0
  76. package/dist/src/console/workflows.d.ts.map +1 -1
  77. package/dist/src/console/workflows.js +13 -0
  78. package/dist/src/console/workflows.js.map +1 -1
  79. package/dist/src/documents.d.ts +9 -5
  80. package/dist/src/documents.d.ts.map +1 -1
  81. package/dist/src/documents.js +6 -3
  82. package/dist/src/documents.js.map +1 -1
  83. package/dist/src/functions.d.ts +149 -1
  84. package/dist/src/functions.d.ts.map +1 -1
  85. package/dist/src/functions.js +145 -0
  86. package/dist/src/functions.js.map +1 -1
  87. package/dist/src/http.d.ts +58 -10
  88. package/dist/src/http.d.ts.map +1 -1
  89. package/dist/src/http.js +82 -11
  90. package/dist/src/http.js.map +1 -1
  91. package/dist/src/me.d.ts +3 -2
  92. package/dist/src/me.d.ts.map +1 -1
  93. package/dist/src/me.js +7 -2
  94. package/dist/src/me.js.map +1 -1
  95. package/dist/src/run.d.ts +11 -2
  96. package/dist/src/run.d.ts.map +1 -1
  97. package/dist/src/run.js +11 -2
  98. package/dist/src/run.js.map +1 -1
  99. package/dist/src/server/mod.d.ts +100 -0
  100. package/dist/src/server/mod.d.ts.map +1 -0
  101. package/dist/src/server/mod.js +121 -0
  102. package/dist/src/server/mod.js.map +1 -0
  103. package/dist/src/team.d.ts +204 -0
  104. package/dist/src/team.d.ts.map +1 -0
  105. package/dist/src/team.js +161 -0
  106. package/dist/src/team.js.map +1 -0
  107. package/dist/src/types.d.ts +143 -10
  108. package/dist/src/types.d.ts.map +1 -1
  109. package/dist/src/types.js +27 -0
  110. package/dist/src/types.js.map +1 -1
  111. package/dist/src/vars.d.ts +5 -3
  112. package/dist/src/vars.d.ts.map +1 -1
  113. package/dist/src/vars.js +14 -4
  114. package/dist/src/vars.js.map +1 -1
  115. package/dist/src/version.js +1 -1
  116. package/dist/src/workflows.d.ts +261 -9
  117. package/dist/src/workflows.d.ts.map +1 -1
  118. package/dist/src/workflows.js +246 -7
  119. package/dist/src/workflows.js.map +1 -1
  120. package/package.json +5 -1
@@ -0,0 +1,204 @@
1
+ /**
2
+ * `client.team.*` — the caller's account team, self-service.
3
+ *
4
+ * Six operations, one HTTP call each: list the roster, invite someone (or mint
5
+ * an open, shareable invite link), list open invites, revoke one, change a
6
+ * member's role, remove a member. Nothing here composes two requests or
7
+ * filters a list client-side — `team.invites()` returns only OPEN invites
8
+ * because the **server** filters them, not because this module scans the
9
+ * account's whole invite history and drops the closed ones
10
+ * (`docs/implementation.md`'s "what a wrapper is" rule, mirrored from
11
+ * `documents.ts`'s header).
12
+ *
13
+ * **Not project-scoped.** Team membership is an account-wide concept, so
14
+ * (unlike `documents`) this namespace carries no `?project=` anywhere and is
15
+ * handed the transport only — the same narrow host `connections.ts` and
16
+ * `vars.ts` use, so a caller cannot even accidentally reach a default project
17
+ * to send.
18
+ *
19
+ * `docs/team.md`'s pinned wire contract (mirrored in this task's `plan.md`
20
+ * §"Pinned wire contract") is the source these six methods transcribe:
21
+ *
22
+ * ```
23
+ * GET /me/account/members → 200 { members: TeamMember[] }
24
+ * POST /me/account/invites { email?, role? } → 201 { invite: TeamInviteWithLink }
25
+ * GET /me/account/invites → 200 { invites: TeamInvite[] }
26
+ * DELETE /me/account/invites/:id → 200 { ok: true }
27
+ * PATCH /me/account/members/:userId { role } → 200 { member: TeamMember }
28
+ * DELETE /me/account/members/:userId → 200 { ok: true }
29
+ * ```
30
+ *
31
+ * This module implements the client half of the server's live
32
+ * `/me/account/...` routes (`endpoints.json`: `status: "required"` for each).
33
+ * Calling any of these against a server that has not shipped T1.2.1 yet
34
+ * answers `404`, which reaches the caller as an ordinary `ApiError`.
35
+ *
36
+ * @module
37
+ */
38
+ import { type HttpResponse, type RequestOptions } from "./http.ts";
39
+ /**
40
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
41
+ * else. Team operations carry no per-call scope to resolve, so — as with
42
+ * `connections` and `vars` — this host cannot reach the client's
43
+ * configuration even by accident.
44
+ */
45
+ export interface TeamHost {
46
+ /** Perform one request. */
47
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
48
+ }
49
+ /**
50
+ * One member of the caller's account team, as the roster projects it.
51
+ *
52
+ * `email`/`displayName` are nullable rather than defaulted to `""`: a member
53
+ * whose profile carries neither is a real, distinct state (a machine
54
+ * principal, or a user who has set up neither) and flattening it to an empty
55
+ * string would make "no display name" indistinguishable from "the server sent
56
+ * an empty one".
57
+ */
58
+ export interface TeamMember {
59
+ /** The member's `usr_…` id — addresses `setRole` and `removeMember`. */
60
+ userId: string;
61
+ /** The member's email, or `null` when the profile carries none. */
62
+ email: string | null;
63
+ /** The member's display name, or `null` when unset. */
64
+ displayName: string | null;
65
+ /** The member's role within the account, e.g. `"owner"`, `"admin"`, `"member"`. */
66
+ role: string;
67
+ /** ISO-8601 timestamp: when this membership began. */
68
+ createdAt: string;
69
+ }
70
+ /**
71
+ * One invite, as `team.invites()` lists it.
72
+ *
73
+ * Deliberately carries no `token` — see {@linkcode TeamInviteWithLink}, the
74
+ * only response that does, and only once.
75
+ */
76
+ export interface TeamInvite {
77
+ /** The invite's own id — addresses `revokeInvite`. */
78
+ id: string;
79
+ /** The account this invite joins. */
80
+ account: string;
81
+ /** The invited email, or `null` for an open (link-only) invite. */
82
+ email: string | null;
83
+ /** The role the invite grants on redemption, or `null` (server defaults to `"member"`). */
84
+ role: string | null;
85
+ /** ISO-8601 expiry, or `null` for an invite that does not expire. */
86
+ expiresAt: string | null;
87
+ /** ISO-8601 timestamp: when this invite was created. */
88
+ createdAt: string;
89
+ }
90
+ /**
91
+ * What `team.invite()` returns: a {@linkcode TeamInvite} plus the redemption
92
+ * material, present **only** in this one response.
93
+ *
94
+ * The server never re-sends `token` or `redemptionLink` from any other route
95
+ * — `team.invites()` lists the invite without them — so a caller that drops
96
+ * this return value cannot recover it and must revoke and re-invite instead.
97
+ */
98
+ export interface TeamInviteWithLink extends TeamInvite {
99
+ /** The plaintext redemption token. Shown once. */
100
+ token: string;
101
+ /** The ready-to-share redemption URL, built around `token`. Shown once. */
102
+ redemptionLink: string;
103
+ }
104
+ /**
105
+ * The body of `team.invite()`.
106
+ *
107
+ * Both fields are optional: an omitted `email` mints an OPEN invite (a
108
+ * shareable link with no target address), and an omitted `role` defaults
109
+ * server-side to `"member"`. `"owner"` is refused — there is no self-service
110
+ * path to a second owner.
111
+ */
112
+ export interface TeamInviteInput {
113
+ /** The address to invite. Omitted for an open, shareable invite. */
114
+ email?: string;
115
+ /** The role the invite grants on redemption. Omitted defaults to `"member"`. */
116
+ role?: string;
117
+ }
118
+ /**
119
+ * The `team` namespace on a `W6WClient`.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * const members = await client.team.members();
124
+ * const { redemptionLink } = await client.team.invite({ role: "admin" });
125
+ * await client.team.setRole(members[0].userId, "admin");
126
+ * ```
127
+ */
128
+ export declare class TeamApi {
129
+ #private;
130
+ /**
131
+ * @param host - The client this namespace issues requests through.
132
+ */
133
+ constructor(host: TeamHost);
134
+ /**
135
+ * List the caller's account team.
136
+ *
137
+ * Member-readable: any active member of the account may call this,
138
+ * regardless of role — only the write operations below require
139
+ * `canManageMembers`.
140
+ *
141
+ * @returns The team, unwrapped from the `members` envelope.
142
+ * @throws {ApiError} On any non-2xx.
143
+ */
144
+ members(): Promise<TeamMember[]>;
145
+ /**
146
+ * Invite someone to the account, or mint an open, shareable invite link.
147
+ *
148
+ * @param input - `email` and `role`, both optional.
149
+ * @returns The created invite, including its one-time `token` and `redemptionLink`.
150
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
151
+ * @throws {ApiError} `400 invalid_role` for `role: "owner"` or an unrecognised role.
152
+ */
153
+ invite(input?: TeamInviteInput): Promise<TeamInviteWithLink>;
154
+ /**
155
+ * List the account's open (pending, unrevoked, unexpired) invites.
156
+ *
157
+ * The filtering happens server-side — this is one `GET`, never a
158
+ * list-then-filter over the account's whole invite history.
159
+ *
160
+ * @returns The open invites, unwrapped from the `invites` envelope.
161
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
162
+ */
163
+ invites(): Promise<TeamInvite[]>;
164
+ /**
165
+ * Revoke a pending invite before it is redeemed.
166
+ *
167
+ * Not idempotent: revoking an invite that is already used or already
168
+ * revoked is a rejected request, not a silent success.
169
+ *
170
+ * @param id - The invite's own id (see: `team.invites()`).
171
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
172
+ * @throws {ApiError} `404 invite_not_found` for an unknown id.
173
+ * @throws {ApiError} `409 invite_not_open` when it was already used or revoked.
174
+ */
175
+ revokeInvite(id: string): Promise<void>;
176
+ /**
177
+ * Change a team member's role.
178
+ *
179
+ * @param userId - The member's `usr_…` id (see: `team.members()`).
180
+ * @param role - The role to set.
181
+ * @returns The updated member.
182
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
183
+ * @throws {ApiError} `403 cannot_change_owner_role` for `role: "owner"` or when
184
+ * `userId` is the account's current owner — there is no self-service ownership transfer.
185
+ * @throws {ApiError} `400 invalid_role` for an unrecognised role.
186
+ * @throws {ApiError} `404 member_not_found` for an unknown `userId`.
187
+ */
188
+ setRole(userId: string, role: string): Promise<TeamMember>;
189
+ /**
190
+ * Remove a member from the account.
191
+ *
192
+ * Tombstones the membership server-side rather than deleting it outright
193
+ * (D-R3), but that is a server implementation detail this method does not
194
+ * surface — it returns nothing, the same pin as `documents.delete`.
195
+ *
196
+ * @param userId - The member's `usr_…` id (see: `team.members()`).
197
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
198
+ * @throws {ApiError} `403 cannot_remove_owner` when `userId` is the account's owner.
199
+ * @throws {ApiError} `404 member_not_found` for an unknown `userId`.
200
+ * @throws {ApiError} `409 last_member` when `userId` is the account's only active member.
201
+ */
202
+ removeMember(userId: string): Promise<void>;
203
+ }
204
+ //# sourceMappingURL=team.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.d.ts","sourceRoot":"","sources":["../../src/team.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGzE;;;;;GAKG;AACH,MAAM,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;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,GAAE,eAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAYtE;;;;;;;;OAQG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAKtC;;;;;;;;;;OAUG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7C;;;;;;;;;;;OAWG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAShE;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlD"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * `client.team.*` — the caller's account team, self-service.
3
+ *
4
+ * Six operations, one HTTP call each: list the roster, invite someone (or mint
5
+ * an open, shareable invite link), list open invites, revoke one, change a
6
+ * member's role, remove a member. Nothing here composes two requests or
7
+ * filters a list client-side — `team.invites()` returns only OPEN invites
8
+ * because the **server** filters them, not because this module scans the
9
+ * account's whole invite history and drops the closed ones
10
+ * (`docs/implementation.md`'s "what a wrapper is" rule, mirrored from
11
+ * `documents.ts`'s header).
12
+ *
13
+ * **Not project-scoped.** Team membership is an account-wide concept, so
14
+ * (unlike `documents`) this namespace carries no `?project=` anywhere and is
15
+ * handed the transport only — the same narrow host `connections.ts` and
16
+ * `vars.ts` use, so a caller cannot even accidentally reach a default project
17
+ * to send.
18
+ *
19
+ * `docs/team.md`'s pinned wire contract (mirrored in this task's `plan.md`
20
+ * §"Pinned wire contract") is the source these six methods transcribe:
21
+ *
22
+ * ```
23
+ * GET /me/account/members → 200 { members: TeamMember[] }
24
+ * POST /me/account/invites { email?, role? } → 201 { invite: TeamInviteWithLink }
25
+ * GET /me/account/invites → 200 { invites: TeamInvite[] }
26
+ * DELETE /me/account/invites/:id → 200 { ok: true }
27
+ * PATCH /me/account/members/:userId { role } → 200 { member: TeamMember }
28
+ * DELETE /me/account/members/:userId → 200 { ok: true }
29
+ * ```
30
+ *
31
+ * This module implements the client half of the server's live
32
+ * `/me/account/...` routes (`endpoints.json`: `status: "required"` for each).
33
+ * Calling any of these against a server that has not shipped T1.2.1 yet
34
+ * answers `404`, which reaches the caller as an ordinary `ApiError`.
35
+ *
36
+ * @module
37
+ */
38
+ import { path } from "./http.js";
39
+ import { unwrap } from "./types.js";
40
+ /**
41
+ * The `team` namespace on a `W6WClient`.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const members = await client.team.members();
46
+ * const { redemptionLink } = await client.team.invite({ role: "admin" });
47
+ * await client.team.setRole(members[0].userId, "admin");
48
+ * ```
49
+ */
50
+ export class TeamApi {
51
+ #host;
52
+ /**
53
+ * @param host - The client this namespace issues requests through.
54
+ */
55
+ constructor(host) {
56
+ this.#host = host;
57
+ }
58
+ /**
59
+ * List the caller's account team.
60
+ *
61
+ * Member-readable: any active member of the account may call this,
62
+ * regardless of role — only the write operations below require
63
+ * `canManageMembers`.
64
+ *
65
+ * @returns The team, unwrapped from the `members` envelope.
66
+ * @throws {ApiError} On any non-2xx.
67
+ */
68
+ async members() {
69
+ const res = await this.#host.request({ method: "GET", path: "/me/account/members" });
70
+ return unwrap(res, "members");
71
+ }
72
+ /**
73
+ * Invite someone to the account, or mint an open, shareable invite link.
74
+ *
75
+ * @param input - `email` and `role`, both optional.
76
+ * @returns The created invite, including its one-time `token` and `redemptionLink`.
77
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
78
+ * @throws {ApiError} `400 invalid_role` for `role: "owner"` or an unrecognised role.
79
+ */
80
+ async invite(input = {}) {
81
+ const res = await this.#host.request({
82
+ method: "POST",
83
+ path: "/me/account/invites",
84
+ // Assembled field by field, exactly the two documented fields: an
85
+ // `undefined` one is dropped by JSON serialisation rather than sent as
86
+ // an explicit `null`.
87
+ body: { email: input.email, role: input.role },
88
+ });
89
+ return unwrap(res, "invite");
90
+ }
91
+ /**
92
+ * List the account's open (pending, unrevoked, unexpired) invites.
93
+ *
94
+ * The filtering happens server-side — this is one `GET`, never a
95
+ * list-then-filter over the account's whole invite history.
96
+ *
97
+ * @returns The open invites, unwrapped from the `invites` envelope.
98
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
99
+ */
100
+ async invites() {
101
+ const res = await this.#host.request({ method: "GET", path: "/me/account/invites" });
102
+ return unwrap(res, "invites");
103
+ }
104
+ /**
105
+ * Revoke a pending invite before it is redeemed.
106
+ *
107
+ * Not idempotent: revoking an invite that is already used or already
108
+ * revoked is a rejected request, not a silent success.
109
+ *
110
+ * @param id - The invite's own id (see: `team.invites()`).
111
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
112
+ * @throws {ApiError} `404 invite_not_found` for an unknown id.
113
+ * @throws {ApiError} `409 invite_not_open` when it was already used or revoked.
114
+ */
115
+ async revokeInvite(id) {
116
+ await this.#host.request({
117
+ method: "DELETE",
118
+ path: path `/me/account/invites/${id}`,
119
+ });
120
+ }
121
+ /**
122
+ * Change a team member's role.
123
+ *
124
+ * @param userId - The member's `usr_…` id (see: `team.members()`).
125
+ * @param role - The role to set.
126
+ * @returns The updated member.
127
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
128
+ * @throws {ApiError} `403 cannot_change_owner_role` for `role: "owner"` or when
129
+ * `userId` is the account's current owner — there is no self-service ownership transfer.
130
+ * @throws {ApiError} `400 invalid_role` for an unrecognised role.
131
+ * @throws {ApiError} `404 member_not_found` for an unknown `userId`.
132
+ */
133
+ async setRole(userId, role) {
134
+ const res = await this.#host.request({
135
+ method: "PATCH",
136
+ path: path `/me/account/members/${userId}`,
137
+ body: { role },
138
+ });
139
+ return unwrap(res, "member");
140
+ }
141
+ /**
142
+ * Remove a member from the account.
143
+ *
144
+ * Tombstones the membership server-side rather than deleting it outright
145
+ * (D-R3), but that is a server implementation detail this method does not
146
+ * surface — it returns nothing, the same pin as `documents.delete`.
147
+ *
148
+ * @param userId - The member's `usr_…` id (see: `team.members()`).
149
+ * @throws {ApiError} `403 forbidden` without `canManageMembers`.
150
+ * @throws {ApiError} `403 cannot_remove_owner` when `userId` is the account's owner.
151
+ * @throws {ApiError} `404 member_not_found` for an unknown `userId`.
152
+ * @throws {ApiError} `409 last_member` when `userId` is the account's only active member.
153
+ */
154
+ async removeMember(userId) {
155
+ await this.#host.request({
156
+ method: "DELETE",
157
+ path: path `/me/account/members/${userId}`,
158
+ });
159
+ }
160
+ }
161
+ //# sourceMappingURL=team.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.js","sourceRoot":"","sources":["../../src/team.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAqB,IAAI,EAAuB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAsFpC;;;;;;;;;GASG;AACH,MAAM,OAAO,OAAO;IACT,KAAK,CAAW;IAEzB;;OAEG;IACH,YAAY,IAAc;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC;QAC9F,OAAO,MAAM,CAAe,GAAG,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,QAAyB,EAAE;QACtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB;YAC3B,kEAAkE;YAClE,uEAAuE;YACvE,sBAAsB;YACtB,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;SAC/C,CAAC,CAAC;QACH,OAAO,MAAM,CAAqB,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC;QAC9F,OAAO,MAAM,CAAe,GAAG,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,YAAY,CAAC,EAAU;QAC3B,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAChC,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,IAAI,CAAA,uBAAuB,EAAE,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY;QACxC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,IAAI,CAAA,uBAAuB,MAAM,EAAE;YACzC,IAAI,EAAE,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;QACH,OAAO,MAAM,CAAa,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAChC,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,IAAI,CAAA,uBAAuB,MAAM,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -122,6 +122,16 @@ export interface Me {
122
122
  * would be a server change that the wrapper version-bumps with.
123
123
  */
124
124
  export type ConnectionState = "pending" | "connected" | "needs_refresh" | "broken" | "revoked";
125
+ /** The display metadata of a connection's app, inlined on each {@link ConnectionSummary}. */
126
+ export interface ConnectionAppMeta {
127
+ displayName: string;
128
+ /** Light-theme icon, a `data:image/svg+xml;base64,…` URI. */
129
+ iconSvg?: string;
130
+ /** Dark-theme icon, a `data:image/svg+xml;base64,…` URI. */
131
+ iconSvgDark?: string;
132
+ brandColor?: string;
133
+ brandColorDark?: string;
134
+ }
125
135
  /**
126
136
  * A connection, as the list route projects it.
127
137
  *
@@ -141,8 +151,10 @@ export interface ConnectionSummary {
141
151
  appId: string;
142
152
  /** Which of the app's auth methods this connection uses. */
143
153
  authKey: string;
144
- /** The subject that owns the connection. */
145
- owner: string;
154
+ /** The tenant that owns the connection. */
155
+ tenant: string;
156
+ /** The subject (the partner's user id) that owns the connection. */
157
+ subject: string;
146
158
  /** Human-chosen label. */
147
159
  displayName: string;
148
160
  /** Lifecycle state. */
@@ -157,6 +169,11 @@ export interface ConnectionSummary {
157
169
  createdAt: string;
158
170
  /** ISO-8601 timestamp. */
159
171
  updatedAt: string;
172
+ /**
173
+ * The connection's app, inlined so a list needs no second fetch for names and icons.
174
+ * `null` means the server found no app row; absent means an older server.
175
+ */
176
+ app?: ConnectionAppMeta | null;
160
177
  }
161
178
  /** Lifecycle state of a workflow: an editable draft, a published live one, or archived. */
162
179
  export type WorkflowStatus = "draft" | "active" | "archived";
@@ -170,6 +187,8 @@ export type WorkflowStatus = "draft" | "active" | "archived";
170
187
  export interface WorkflowSummary {
171
188
  /** Server-issued id, `wf_…`. This is the handle a URN addresses. */
172
189
  id: string;
190
+ /** The callable key, or `null` when this workflow has none yet — the normal state for every workflow that predates keys. */
191
+ key: string | null;
173
192
  /** Stable slug, e.g. `"welcome-email"`. */
174
193
  name: string;
175
194
  /** Human-readable label. */
@@ -185,6 +204,36 @@ export interface WorkflowSummary {
185
204
  /** ISO-8601 timestamp. */
186
205
  updatedAt: string;
187
206
  }
207
+ /**
208
+ * A Function definition, as the list route projects it.
209
+ *
210
+ * `key` is the name the Function is CALLED by — `client.functions.run(key)` —
211
+ * and `displayName` is the label a human reads; the server falls back to the
212
+ * key when no display name was set, so `displayName` is never empty and never a
213
+ * substitute for `key`.
214
+ *
215
+ * There is no `status` here, and no lifecycle to have one: a Function is either
216
+ * runnable or not, which is what {@linkcode FunctionSummary.valid} answers.
217
+ */
218
+ export interface FunctionSummary {
219
+ /** Server-issued id, `fn_…`. */
220
+ id: string;
221
+ /** The callable name, e.g. `"send-email"`. Kebab-case, never contains `_`. */
222
+ key: string;
223
+ /** Human-readable label; falls back to `key` server-side. */
224
+ displayName: string;
225
+ /** Free-text description; `""` when unset. */
226
+ description: string;
227
+ /** ISO-8601 timestamp. */
228
+ updatedAt: string;
229
+ /**
230
+ * Whether this Function can actually be run — server-computed, from the same
231
+ * single predicate the invoke path guards with (`db/repos/functions.ts`'s
232
+ * `isFunctionValid`). A draft with no `impl` is `false`, and running it is
233
+ * `422 function_incomplete`.
234
+ */
235
+ valid: boolean;
236
+ }
188
237
  /**
189
238
  * Lifecycle state of a run.
190
239
  *
@@ -228,14 +277,67 @@ export interface RunResult {
228
277
  /** Per-step failures, when the server reports them. */
229
278
  stepErrors?: StepError[];
230
279
  }
280
+ /**
281
+ * The invocation FRAME every `RunEnvelope` arm carries — the platform's own
282
+ * record of the attempt, as opposed to whatever the target returned.
283
+ *
284
+ * Added by the server on 2026-08-20 and purely ADDITIVE: no existing field was
285
+ * renamed, removed or re-typed, so code written against the three-arm shape
286
+ * keeps compiling and keeps working.
287
+ *
288
+ * Every field is OPTIONAL here, and that is deliberate rather than lazy: an
289
+ * installed SDK talks to whichever server version is deployed, and a required
290
+ * field would make this type a lie against any server older than the change.
291
+ * Treat an absent `invocationId` as "this server does not record invocations
292
+ * yet", never as an error.
293
+ */
294
+ export interface InvocationFrame {
295
+ /**
296
+ * This attempt's id, `inv_…`. Resolves through `GET /invocations/{id}` to the
297
+ * stored inputs, output, error and timing.
298
+ *
299
+ * NOT the same thing as {@linkcode WorkflowRunEnvelope.runId}, and neither
300
+ * replaces the other: this names the CALL, `runId` names the queued workflow
301
+ * RUN that a call may have started. On the workflow arm both can be present
302
+ * and they mean different things.
303
+ */
304
+ invocationId?: string;
305
+ /**
306
+ * The PLATFORM's verdict on the attempt — `"succeeded"`, `"failed"` or, on
307
+ * the workflow arm, `"queued"`.
308
+ *
309
+ * Not to be confused with any status the target reported inside its own
310
+ * payload: a SendGrid send whose `output` reads `{statusCode: 202}` is
311
+ * SendGrid describing its own request, not this platform describing the call.
312
+ */
313
+ status?: "succeeded" | "failed" | "queued" | string;
314
+ /** When the attempt started, ISO-8601. */
315
+ startedAt?: string;
316
+ /** When it reached a terminal state, ISO-8601. */
317
+ finishedAt?: string;
318
+ /** Wall-clock duration in milliseconds. */
319
+ durationMs?: number;
320
+ }
231
321
  /** `run` resolved a `conn_…` URN and executed an app action. HTTP `200`. */
232
- export interface ActionRunEnvelope {
322
+ export interface ActionRunEnvelope extends InvocationFrame {
233
323
  kind: "action";
234
- /** The action's return value. Opaque pass-through. */
324
+ /**
325
+ * The action's return value. Opaque pass-through.
326
+ *
327
+ * @deprecated Read {@linkcode ActionRunEnvelope.output} instead — it is the
328
+ * one payload field every arm agrees on. `value` carries the identical value
329
+ * and is not going away without a major bump, but new code should not reach
330
+ * for a name that only one arm has.
331
+ */
235
332
  value: unknown;
333
+ /**
334
+ * The action's return value, under the name every arm shares. Optional
335
+ * because a server older than 2026-08-20 sends only `value`.
336
+ */
337
+ output?: unknown;
236
338
  }
237
339
  /** `run` resolved a `fn_…` / `ep_…` URN and executed it. HTTP `200`. */
238
- export interface FunctionRunEnvelope {
340
+ export interface FunctionRunEnvelope extends InvocationFrame {
239
341
  kind: "function";
240
342
  /** The function's output. Opaque pass-through. */
241
343
  output: unknown;
@@ -246,9 +348,14 @@ export interface FunctionRunEnvelope {
246
348
  * `202` is **success**: the run is queued, and `runId` is how the caller follows
247
349
  * it. There is no `?wait=` on this operation — use `workflows.run` for that (D4).
248
350
  */
249
- export interface WorkflowRunEnvelope {
351
+ export interface WorkflowRunEnvelope extends InvocationFrame {
250
352
  kind: "workflow";
251
- /** Server-issued run handle. */
353
+ /**
354
+ * Server-issued run handle — the QUEUED RUN, not the call that queued it.
355
+ * Follow it with `workflows.getRun`. See
356
+ * {@linkcode InvocationFrame.invocationId} for the other id and why they are
357
+ * not the same.
358
+ */
252
359
  runId: string;
253
360
  /** Where the run has got to; `"queued"` immediately after dispatch. */
254
361
  status: RunStatus;
@@ -269,9 +376,13 @@ export type UnknownRunEnvelope = {
269
376
  /**
270
377
  * What `client.run()` returns: three known arms plus an open one.
271
378
  *
272
- * `value` (action) and `output` (function) are **deliberately different names**
273
- * for the two synchronous arms and are never normalised into one field — the
274
- * discrimination is the point (D3).
379
+ * `value` (action) and `output` (function) were **deliberately different names**
380
+ * for the two synchronous arms, and the guards below still discriminate on
381
+ * `kind` rather than on which field is present. Since 2026-08-20 the server
382
+ * also sends `output` on the action arm, carrying the same value as `value` —
383
+ * so `output` is now the field name every arm shares and the one new code
384
+ * should read. `value` is kept, unchanged, for every caller written before
385
+ * that (D3).
275
386
  *
276
387
  * **The union is open, and narrowing on `kind` alone does not work.** Because
277
388
  * the fourth arm admits any `kind: string`, a bare `env.kind === "workflow"`
@@ -359,4 +470,26 @@ export declare function isTerminalRunStatus(status: RunStatus): boolean;
359
470
  * key, or the key is `null`.
360
471
  */
361
472
  export declare function unwrap<T>(res: HttpResponse<unknown>, key: string): T;
473
+ /**
474
+ * Mint a client-side id for a definition the caller is creating.
475
+ *
476
+ * **Both `POST /workflows` and `POST /functions` REQUIRE an `id` in the body
477
+ * and never generate one** (`admin/workflows.ts`'s and `admin/functions.ts`'s
478
+ * `validateDefinition`: "`id` is required."). The id is synthetic and never
479
+ * user-facing — the display name is what a user sees and edits — so a caller
480
+ * writing `create({name: "…", steps: […]})` should not have to know that, and
481
+ * every consumer that does know it has ended up writing the same four lines
482
+ * (studio's `newWorkflowId`/`newFunctionId`, `WorkflowsPage.tsx:141` and
483
+ * `FunctionsPage.tsx:49`). This is that function, once.
484
+ *
485
+ * `crypto.randomUUID` is present on every runtime this package supports (Node
486
+ * 19+, Deno, Bun, browsers) but is guarded anyway, byte-for-byte as studio
487
+ * guards it: the fallback keeps `create` working on an older Node rather than
488
+ * throwing a `TypeError` from inside the SDK, and the ids only need to be
489
+ * unique per scope, not unguessable — the server owns ownership, not the id.
490
+ *
491
+ * @param prefix - The kind prefix, without its underscore: `"wf"` or `"fn"`.
492
+ * @returns A new id of the form `wf_…` / `fn_…`.
493
+ */
494
+ export declare function mintId(prefix: string): string;
362
495
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,GAAG;IAClB,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,mFAAmF;AACnF,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG;IAClB,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,IAA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AAM,WAAW,GACnB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,IAAI,iBAAiB,CAEtE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,IAAI,mBAAmB,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,IAAI,mBAAmB,CAE1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAE9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAcpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK7C"}
package/dist/src/types.js CHANGED
@@ -106,4 +106,31 @@ export function unwrap(res, key) {
106
106
  }
107
107
  throw new ApiError(res.status, "bad_response", `Server returned a ${res.status} with no "${key}" in the response body.`, body);
108
108
  }
109
+ /**
110
+ * Mint a client-side id for a definition the caller is creating.
111
+ *
112
+ * **Both `POST /workflows` and `POST /functions` REQUIRE an `id` in the body
113
+ * and never generate one** (`admin/workflows.ts`'s and `admin/functions.ts`'s
114
+ * `validateDefinition`: "`id` is required."). The id is synthetic and never
115
+ * user-facing — the display name is what a user sees and edits — so a caller
116
+ * writing `create({name: "…", steps: […]})` should not have to know that, and
117
+ * every consumer that does know it has ended up writing the same four lines
118
+ * (studio's `newWorkflowId`/`newFunctionId`, `WorkflowsPage.tsx:141` and
119
+ * `FunctionsPage.tsx:49`). This is that function, once.
120
+ *
121
+ * `crypto.randomUUID` is present on every runtime this package supports (Node
122
+ * 19+, Deno, Bun, browsers) but is guarded anyway, byte-for-byte as studio
123
+ * guards it: the fallback keeps `create` working on an older Node rather than
124
+ * throwing a `TypeError` from inside the SDK, and the ids only need to be
125
+ * unique per scope, not unguessable — the server owns ownership, not the id.
126
+ *
127
+ * @param prefix - The kind prefix, without its underscore: `"wf"` or `"fn"`.
128
+ * @returns A new id of the form `wf_…` / `fn_…`.
129
+ */
130
+ export function mintId(prefix) {
131
+ const uuid = typeof crypto !== "undefined" && "randomUUID" in crypto
132
+ ? crypto.randomUUID()
133
+ : Math.floor(Math.random() * 1e16).toString(36);
134
+ return `${prefix}_${uuid}`;
135
+ }
109
136
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqSvC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAgB;IAC1C,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAgB;IAC5C,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAgB;IAC5C,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC;AACjC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,UAAU,CAAC;AAChF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,MAAM,CAAI,GAA0B,EAAE,GAAW;IAC/D,MAAM,IAA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