@w6w/sdk 0.4.0 → 0.6.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 (86) hide show
  1. package/README.md +24 -21
  2. package/dist/mod.d.ts +6 -2
  3. package/dist/mod.d.ts.map +1 -1
  4. package/dist/mod.js +4 -2
  5. package/dist/mod.js.map +1 -1
  6. package/dist/src/client.d.ts +32 -9
  7. package/dist/src/client.d.ts.map +1 -1
  8. package/dist/src/client.js +33 -8
  9. package/dist/src/client.js.map +1 -1
  10. package/dist/src/config.d.ts +2 -2
  11. package/dist/src/config.js +3 -3
  12. package/dist/src/config.js.map +1 -1
  13. package/dist/src/connections.d.ts +2 -2
  14. package/dist/src/connections.js +1 -1
  15. package/dist/src/console/aliases.d.ts +137 -0
  16. package/dist/src/console/aliases.d.ts.map +1 -0
  17. package/dist/src/console/aliases.js +113 -0
  18. package/dist/src/console/aliases.js.map +1 -0
  19. package/dist/src/console/api-calls.d.ts +2 -2
  20. package/dist/src/console/api-calls.js +1 -1
  21. package/dist/src/console/apps.d.ts +4 -4
  22. package/dist/src/console/apps.js +3 -3
  23. package/dist/src/console/auth.d.ts +204 -6
  24. package/dist/src/console/auth.d.ts.map +1 -1
  25. package/dist/src/console/auth.js +155 -5
  26. package/dist/src/console/auth.js.map +1 -1
  27. package/dist/src/console/connections.d.ts +2 -2
  28. package/dist/src/console/connections.js +1 -1
  29. package/dist/src/console/dashboard.d.ts +2 -2
  30. package/dist/src/console/dashboard.js +1 -1
  31. package/dist/src/console/endpoints.d.ts +25 -7
  32. package/dist/src/console/endpoints.d.ts.map +1 -1
  33. package/dist/src/console/endpoints.js +1 -1
  34. package/dist/src/console/endpoints.js.map +1 -1
  35. package/dist/src/console/functions.d.ts +2 -2
  36. package/dist/src/console/functions.js +1 -1
  37. package/dist/src/console/mod.d.ts +15 -5
  38. package/dist/src/console/mod.d.ts.map +1 -1
  39. package/dist/src/console/mod.js +12 -2
  40. package/dist/src/console/mod.js.map +1 -1
  41. package/dist/src/console/passkeys.d.ts +246 -0
  42. package/dist/src/console/passkeys.d.ts.map +1 -0
  43. package/dist/src/console/passkeys.js +192 -0
  44. package/dist/src/console/passkeys.js.map +1 -0
  45. package/dist/src/console/projects.d.ts +2 -2
  46. package/dist/src/console/projects.js +1 -1
  47. package/dist/src/console/reliability.d.ts +2 -2
  48. package/dist/src/console/reliability.js +1 -1
  49. package/dist/src/console/saved-tests.d.ts +3 -3
  50. package/dist/src/console/saved-tests.js +2 -2
  51. package/dist/src/console/schedules.d.ts +2 -2
  52. package/dist/src/console/schedules.js +1 -1
  53. package/dist/src/console/step-tests.d.ts +3 -3
  54. package/dist/src/console/step-tests.js +2 -2
  55. package/dist/src/console/subscriptions.d.ts +2 -2
  56. package/dist/src/console/subscriptions.js +1 -1
  57. package/dist/src/console/tenant-oauth-apps.d.ts +2 -2
  58. package/dist/src/console/tenant-oauth-apps.js +1 -1
  59. package/dist/src/console/tokens.d.ts +2 -2
  60. package/dist/src/console/tokens.js +1 -1
  61. package/dist/src/console/vault.d.ts +2 -2
  62. package/dist/src/console/vault.js +1 -1
  63. package/dist/src/console/workflows.d.ts +2 -2
  64. package/dist/src/console/workflows.js +1 -1
  65. package/dist/src/documents.d.ts +2 -2
  66. package/dist/src/documents.js +1 -1
  67. package/dist/src/endpoints.d.ts +75 -0
  68. package/dist/src/endpoints.d.ts.map +1 -0
  69. package/dist/src/endpoints.js +47 -0
  70. package/dist/src/endpoints.js.map +1 -0
  71. package/dist/src/functions.d.ts +88 -0
  72. package/dist/src/functions.d.ts.map +1 -0
  73. package/dist/src/functions.js +56 -0
  74. package/dist/src/functions.js.map +1 -0
  75. package/dist/src/me.d.ts +2 -2
  76. package/dist/src/me.js +1 -1
  77. package/dist/src/run.d.ts +9 -4
  78. package/dist/src/run.d.ts.map +1 -1
  79. package/dist/src/run.js +3 -2
  80. package/dist/src/run.js.map +1 -1
  81. package/dist/src/vars.d.ts +2 -2
  82. package/dist/src/vars.js +1 -1
  83. package/dist/src/version.js +1 -1
  84. package/dist/src/workflows.d.ts +2 -2
  85. package/dist/src/workflows.js +1 -1
  86. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../../../src/console/passkeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAG1E;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,yFAAyF;IACzF,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,0EAA0E;IAC1E,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,6FAA6F;AAC7F,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yGAAyG;AACzG,MAAM,WAAW,yBAAyB;IACxC,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mCAAmC;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,WAAW;;IAGtB;;OAEG;gBACS,IAAI,EAAE,YAAY;IAI9B;;;;;;;OAOG;IACG,mBAAmB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAS5D;;;;;;;;;;OAUG;IACG,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1E;;;;;;;;;;;;;OAaG;IACG,qBAAqB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAU9D;;;;;;;;;;;;;;OAcG;IACG,oBAAoB,CACxB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,mCAAmC,CAAC;IAU/C;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAKhC;;;;;;;;OAQG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -0,0 +1,192 @@
1
+ /**
2
+ * `client.console.passkeys.*` — WebAuthn passkey management and login for
3
+ * self-serve Studio users (T1.1.5).
4
+ *
5
+ * **Studio-internal, not the published partner contract.** This namespace
6
+ * lives under the `console` subpath export (`@w6w/sdk/console`), excluded from
7
+ * `endpoints.json` and from the root barrel (`mod.ts`) — see `docs/console.md`
8
+ * and HITL-1 in this task's contract. `@w6w/sdk`'s instance-state mechanism
9
+ * pin still applies here exactly as it does to every other namespace
10
+ * (`docs/implementation.md` §MECHANISM PIN — instance state, never globals):
11
+ * this class holds no state of its own beyond the injected host, so two
12
+ * clients in one process never share a credential.
13
+ *
14
+ * **Who this is for (HITL-3).** Passkeys belong to self-serve Studio users
15
+ * only; a partner-tenant user's IdP owns its identity. No eligibility logic
16
+ * lives here — the server enforces it (`PasskeyNotEligibleError`), and this
17
+ * module is a plain transport shim over whatever it decides.
18
+ *
19
+ * **Two routes, four methods, split by who is authenticated.** The management
20
+ * quartet (`registrationOptions`, `registrationVerify`, `list`, `revoke`) is
21
+ * GUARDED, mirroring `packages/server/packages/api/data/passkeys.ts`'s own
22
+ * doc comment ("Registered BELOW the auth guard"). The login pair
23
+ * (`authenticationOptions`, `authenticationVerify`) is PUBLIC, mirroring
24
+ * `packages/server/packages/api/id/passkey-login.ts`'s own doc comment ("BOTH
25
+ * routes are PUBLIC and UNAUTHENTICATED by construction") — discoverable
26
+ * credentials, no identifier in the request body (P1). Each of those two
27
+ * methods passes `requireAuth: false`, the same mechanism
28
+ * `console.auth.login`/`signup`/`checkAccountSlug` rely on: without it a
29
+ * tokenless client (the normal case at the login screen, before any session
30
+ * exists) would hit `requireToken`'s `ConfigError` before `fetch` is ever
31
+ * called.
32
+ *
33
+ * **`authenticationVerify` mints a session, the same way `login` does
34
+ * (HITL-5).** A verified passkey assertion is a standalone alternative to a
35
+ * password, not a second factor — so its response is token-bearing, exactly
36
+ * like `console.auth.login`'s. It is a SEPARATE type from `LoginResponse`
37
+ * (`./auth.ts`), not a reuse: the server route is byte-shape-identical to
38
+ * `user-login.ts`'s login body (`id/passkey-login.ts`'s own doc comment) which
39
+ * carries `role`, `tenant` and `emailVerified` on `user` — fields
40
+ * `console.auth`'s `LoginResponse.user` does not declare.
41
+ *
42
+ * **WebAuthn ceremony payloads (`options`/`response`) are opaque JSON, typed
43
+ * as `Record<string, unknown>`, never as `@simplewebauthn/*` types.** This
44
+ * package has no dependency on `@simplewebauthn` (browser or server) and
45
+ * adding one only to type two pass-through fields would be a new dependency
46
+ * for zero behavioural gain — `inputs.touch` for this task explicitly
47
+ * excludes `package.json`. A caller passes the browser's own
48
+ * `PublicKeyCredentialCreationOptionsJSON`/`...RequestOptionsJSON` (from
49
+ * `options`) into `navigator.credentials.create()`/`.get()` (or a helper such
50
+ * as `@simplewebauthn/browser`'s `startRegistration`/`startAuthentication`)
51
+ * and forwards what comes back as `response` — this module never inspects
52
+ * either shape, only relays it.
53
+ *
54
+ * @module
55
+ */
56
+ import { path } from "../http.js";
57
+ import { unwrap } from "../types.js";
58
+ /**
59
+ * The `console.passkeys` namespace on a `W6WClient`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * // Registration (authenticated).
64
+ * const { options, challengeToken } = await client.console.passkeys.registrationOptions();
65
+ * const response = await startRegistration({ optionsJSON: options }); // e.g. @simplewebauthn/browser
66
+ * const passkey = await client.console.passkeys.registrationVerify({ challengeToken, response });
67
+ *
68
+ * // Login (public — works on a tokenless client).
69
+ * const opts = await client.console.passkeys.authenticationOptions();
70
+ * const assertion = await startAuthentication({ optionsJSON: opts.options });
71
+ * const { token } = await client.console.passkeys.authenticationVerify({
72
+ * challengeToken: opts.challengeToken,
73
+ * response: assertion,
74
+ * });
75
+ * ```
76
+ */
77
+ export class PasskeysApi {
78
+ #host;
79
+ /**
80
+ * @param host - The client this namespace issues requests through.
81
+ */
82
+ constructor(host) {
83
+ this.#host = host;
84
+ }
85
+ /**
86
+ * A fresh registration challenge, scoped to the caller's own identity.
87
+ *
88
+ * AUTHENTICATED — the default `requireAuth` applies.
89
+ *
90
+ * @returns The ceremony options and a single-use challenge token.
91
+ * @throws {ApiError} `400 passkey_not_configured`, `403 passkey_not_eligible`.
92
+ */
93
+ async registrationOptions() {
94
+ const res = await this.#host.request({
95
+ method: "POST",
96
+ path: "/me/passkeys/options",
97
+ body: {},
98
+ });
99
+ return res.body;
100
+ }
101
+ /**
102
+ * Verify a registration ceremony and store the credential.
103
+ *
104
+ * AUTHENTICATED — the default `requireAuth` applies.
105
+ *
106
+ * @param input - The challenge token from `registrationOptions()`, the browser's ceremony
107
+ * response, and an optional caller-chosen label.
108
+ * @returns The stored passkey's metadata, unwrapped from the `passkey` envelope.
109
+ * @throws {ApiError} `400 passkey_registration_failed`, `403 passkey_not_eligible`,
110
+ * `409 passkey_already_registered`.
111
+ */
112
+ async registrationVerify(input) {
113
+ const res = await this.#host.request({
114
+ method: "POST",
115
+ path: "/me/passkeys",
116
+ body: input,
117
+ });
118
+ return unwrap(res, "passkey");
119
+ }
120
+ /**
121
+ * A fresh authentication challenge. No identifier is sent or accepted —
122
+ * discoverable credentials only (P1): the owner is resolved server-side
123
+ * from the assertion itself, never from anything this call sends.
124
+ *
125
+ * PUBLIC — sends no bearer, even on a client that already holds one
126
+ * (`requireAuth: false`). Without it, the login screen (the normal case:
127
+ * no session exists yet) could never call this method at all — a tokenless
128
+ * client would hit `requireToken`'s `ConfigError` before `fetch` is ever
129
+ * called.
130
+ *
131
+ * @returns The ceremony options and a single-use challenge token.
132
+ * @throws {ApiError} `400 passkey_not_configured`.
133
+ */
134
+ async authenticationOptions() {
135
+ const res = await this.#host.request({
136
+ method: "POST",
137
+ path: "/auth/passkey/options",
138
+ body: {},
139
+ requireAuth: false,
140
+ });
141
+ return res.body;
142
+ }
143
+ /**
144
+ * Verify an authentication (login) ceremony and mint a session — the same
145
+ * way `console.auth.login` does (HITL-5).
146
+ *
147
+ * PUBLIC — sends no bearer, even on a client that already holds one
148
+ * (`requireAuth: false`). Every failure mode past a malformed body is the
149
+ * same `401 passkey_rejected` (P9): unknown credential, revoked credential,
150
+ * wrong kind, bad signature, counter regression, and a spent/invalid
151
+ * challenge are indistinguishable to the caller.
152
+ *
153
+ * @param input - The challenge token from `authenticationOptions()` and the browser's ceremony
154
+ * response.
155
+ * @returns The token, the caller's identity, and the token's lifetime.
156
+ * @throws {ApiError} `401 passkey_rejected` on any verification failure.
157
+ */
158
+ async authenticationVerify(input) {
159
+ const res = await this.#host.request({
160
+ method: "POST",
161
+ path: "/auth/passkey/verify",
162
+ body: input,
163
+ requireAuth: false,
164
+ });
165
+ return res.body;
166
+ }
167
+ /**
168
+ * List the caller's own passkeys.
169
+ *
170
+ * AUTHENTICATED — the default `requireAuth` applies.
171
+ *
172
+ * @returns The caller's passkeys, unwrapped from the `passkeys` envelope. Never the empty array
173
+ * collapsed to `undefined` — an empty account gets `[]`.
174
+ */
175
+ async list() {
176
+ const res = await this.#host.request({ method: "GET", path: "/me/passkeys" });
177
+ return unwrap(res, "passkeys");
178
+ }
179
+ /**
180
+ * Revoke (delete) one of the caller's own passkeys.
181
+ *
182
+ * AUTHENTICATED — the default `requireAuth` applies.
183
+ *
184
+ * @param id - The passkey id.
185
+ * @returns Nothing: the server answers `204` with no body.
186
+ * @throws {ApiError} `404 passkey_not_found`.
187
+ */
188
+ async revoke(id) {
189
+ await this.#host.request({ method: "DELETE", path: path `/me/passkeys/${id}` });
190
+ }
191
+ }
192
+ //# sourceMappingURL=passkeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkeys.js","sourceRoot":"","sources":["../../../src/console/passkeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAqB,IAAI,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqGrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,WAAW;IACb,KAAK,CAAe;IAE7B;;OAEG;IACH,YAAY,IAAkB;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,mBAAmB;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAyB;YAC3D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,kBAAkB,CAAC,KAA8B;QACrD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QACH,OAAO,MAAM,CAAU,GAAG,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,qBAAqB;QACzB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAyB;YAC3D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,uBAAuB;YAC7B,IAAI,EAAE,EAAE;YACR,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,oBAAoB,CACxB,KAAgC;QAEhC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsC;YACxE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACvF,OAAO,MAAM,CAAY,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAA,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1F,CAAC;CACF"}
@@ -30,7 +30,7 @@
30
30
  */
31
31
  import { type HttpResponse, type RequestOptions } from "../http.ts";
32
32
  /**
33
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
33
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
34
34
  * else. Structural rather than a concrete client type, so the namespace stays
35
35
  * independently constructible in a test and this module never imports the
36
36
  * client back — mirrors `VarsHost` in `../vars.ts`.
@@ -55,7 +55,7 @@ export interface Project {
55
55
  updatedAt: string;
56
56
  }
57
57
  /**
58
- * The `console.projects` namespace on a `W6wClient`.
58
+ * The `console.projects` namespace on a `W6WClient`.
59
59
  *
60
60
  * @example
61
61
  * ```ts
@@ -31,7 +31,7 @@
31
31
  import { path } from "../http.js";
32
32
  import { unwrap } from "../types.js";
33
33
  /**
34
- * The `console.projects` namespace on a `W6wClient`.
34
+ * The `console.projects` namespace on a `W6WClient`.
35
35
  *
36
36
  * @example
37
37
  * ```ts
@@ -22,7 +22,7 @@
22
22
  */
23
23
  import type { HttpResponse, RequestOptions } from "../http.ts";
24
24
  /**
25
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
25
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
26
26
  * else. Structural rather than a concrete client type, so the namespace stays
27
27
  * independently constructible in a test and this module never imports the
28
28
  * client back — mirrors `VarsHost` in `../vars.ts`.
@@ -123,7 +123,7 @@ export interface ReliabilityServices {
123
123
  services: ReliabilityService[];
124
124
  }
125
125
  /**
126
- * The `console.reliability` namespace on a `W6wClient`.
126
+ * The `console.reliability` namespace on a `W6WClient`.
127
127
  *
128
128
  * @example
129
129
  * ```ts
@@ -21,7 +21,7 @@
21
21
  * @module
22
22
  */
23
23
  /**
24
- * The `console.reliability` namespace on a `W6wClient`.
24
+ * The `console.reliability` namespace on a `W6WClient`.
25
25
  *
26
26
  * @example
27
27
  * ```ts
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * **`recordTestRun` returns the REAL created row, not `void`.** Studio's
20
20
  * current `client.ts` discards it to `void` (`.then(() => {})`) only so its
21
- * `api` object stays assignable to `@w6w/ui`'s `W6wApi.recordTestRun`
21
+ * `api` object stays assignable to `@w6w/ui`'s `W6WApi.recordTestRun`
22
22
  * (typed `Promise<void>`, `packages/ui/src/provider.tsx:168-177`) — that is
23
23
  * STUDIO's constraint, not the SDK's. Mirrors T2.2.1's `deleteApp` precedent:
24
24
  * a "complete client" returns genuinely informative data and discards only
@@ -35,7 +35,7 @@
35
35
  */
36
36
  import { type HttpResponse, type RequestOptions } from "../http.ts";
37
37
  /**
38
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
38
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
39
39
  * else. Structural rather than a concrete client type, so the namespace stays
40
40
  * independently constructible in a test and this module never imports the
41
41
  * client back — mirrors `ConnectionsHost` in `./connections.ts`.
@@ -89,7 +89,7 @@ export interface SavedTestRun {
89
89
  createdAt: string;
90
90
  }
91
91
  /**
92
- * The `console.savedTests` namespace on a `W6wClient`.
92
+ * The `console.savedTests` namespace on a `W6WClient`.
93
93
  *
94
94
  * @example
95
95
  * ```ts
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * **`recordTestRun` returns the REAL created row, not `void`.** Studio's
20
20
  * current `client.ts` discards it to `void` (`.then(() => {})`) only so its
21
- * `api` object stays assignable to `@w6w/ui`'s `W6wApi.recordTestRun`
21
+ * `api` object stays assignable to `@w6w/ui`'s `W6WApi.recordTestRun`
22
22
  * (typed `Promise<void>`, `packages/ui/src/provider.tsx:168-177`) — that is
23
23
  * STUDIO's constraint, not the SDK's. Mirrors T2.2.1's `deleteApp` precedent:
24
24
  * a "complete client" returns genuinely informative data and discards only
@@ -36,7 +36,7 @@
36
36
  import { path } from "../http.js";
37
37
  import { unwrap } from "../types.js";
38
38
  /**
39
- * The `console.savedTests` namespace on a `W6wClient`.
39
+ * The `console.savedTests` namespace on a `W6WClient`.
40
40
  *
41
41
  * @example
42
42
  * ```ts
@@ -34,7 +34,7 @@
34
34
  */
35
35
  import { type HttpResponse, type RequestOptions } from "../http.ts";
36
36
  /**
37
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
37
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
38
38
  * else. Structural rather than a concrete client type, so the namespace stays
39
39
  * independently constructible in a test and this module never imports the
40
40
  * client back — mirrors `VarsHost` in `../vars.ts`.
@@ -72,7 +72,7 @@ export interface ScheduleUpsertInput {
72
72
  variables?: Record<string, unknown>;
73
73
  }
74
74
  /**
75
- * The `console.schedules` namespace on a `W6wClient`.
75
+ * The `console.schedules` namespace on a `W6WClient`.
76
76
  *
77
77
  * @example
78
78
  * ```ts
@@ -36,7 +36,7 @@ import { path } from "../http.js";
36
36
  import { ApiError } from "../errors.js";
37
37
  import { unwrap } from "../types.js";
38
38
  /**
39
- * The `console.schedules` namespace on a `W6wClient`.
39
+ * The `console.schedules` namespace on a `W6WClient`.
40
40
  *
41
41
  * @example
42
42
  * ```ts
@@ -28,7 +28,7 @@
28
28
  *
29
29
  * **`recordRun` returns the REAL created row, not `void`.** Studio's current
30
30
  * `client.ts` discards it to `void` (`.then(() => {})`) only so its `api`
31
- * object stays assignable to `@w6w/ui`'s `W6wApi.recordStepTestRun` (typed
31
+ * object stays assignable to `@w6w/ui`'s `W6WApi.recordStepTestRun` (typed
32
32
  * `Promise<void>`, `packages/ui/src/provider.tsx:211-221`) — that is
33
33
  * STUDIO's constraint, not the SDK's. Mirrors `./saved-tests.ts`'s
34
34
  * `recordTestRun` exactly; the void-discard happens at studio's own repo
@@ -43,7 +43,7 @@
43
43
  */
44
44
  import { type HttpResponse, type RequestOptions } from "../http.ts";
45
45
  /**
46
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
46
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
47
47
  * else. Structural rather than a concrete client type, so the namespace stays
48
48
  * independently constructible in a test and this module never imports the
49
49
  * client back — mirrors `ConnectionsHost` in `./connections.ts`.
@@ -86,7 +86,7 @@ export interface StepTestRun {
86
86
  createdAt: string;
87
87
  }
88
88
  /**
89
- * The `console.stepTests` namespace on a `W6wClient`.
89
+ * The `console.stepTests` namespace on a `W6WClient`.
90
90
  *
91
91
  * @example
92
92
  * ```ts
@@ -28,7 +28,7 @@
28
28
  *
29
29
  * **`recordRun` returns the REAL created row, not `void`.** Studio's current
30
30
  * `client.ts` discards it to `void` (`.then(() => {})`) only so its `api`
31
- * object stays assignable to `@w6w/ui`'s `W6wApi.recordStepTestRun` (typed
31
+ * object stays assignable to `@w6w/ui`'s `W6WApi.recordStepTestRun` (typed
32
32
  * `Promise<void>`, `packages/ui/src/provider.tsx:211-221`) — that is
33
33
  * STUDIO's constraint, not the SDK's. Mirrors `./saved-tests.ts`'s
34
34
  * `recordTestRun` exactly; the void-discard happens at studio's own repo
@@ -44,7 +44,7 @@
44
44
  import { path } from "../http.js";
45
45
  import { unwrap } from "../types.js";
46
46
  /**
47
- * The `console.stepTests` namespace on a `W6wClient`.
47
+ * The `console.stepTests` namespace on a `W6WClient`.
48
48
  *
49
49
  * @example
50
50
  * ```ts
@@ -45,7 +45,7 @@
45
45
  */
46
46
  import { type HttpResponse, type RequestOptions } from "../http.ts";
47
47
  /**
48
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
48
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
49
49
  * else. Structural rather than a concrete client type, so the namespace stays
50
50
  * independently constructible in a test and this module never imports the
51
51
  * client back — mirrors `VarsHost` in `../vars.ts`.
@@ -97,7 +97,7 @@ export interface TriggerEventSummary {
97
97
  runId: string | null;
98
98
  }
99
99
  /**
100
- * The `console.subscriptions` namespace on a `W6wClient`.
100
+ * The `console.subscriptions` namespace on a `W6WClient`.
101
101
  *
102
102
  * @example
103
103
  * ```ts
@@ -46,7 +46,7 @@
46
46
  import { path } from "../http.js";
47
47
  import { unwrap } from "../types.js";
48
48
  /**
49
- * The `console.subscriptions` namespace on a `W6wClient`.
49
+ * The `console.subscriptions` namespace on a `W6WClient`.
50
50
  *
51
51
  * @example
52
52
  * ```ts
@@ -48,7 +48,7 @@
48
48
  */
49
49
  import { type HttpResponse, type RequestOptions } from "../http.ts";
50
50
  /**
51
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
51
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
52
52
  * else. Structural rather than a concrete client type, so the namespace stays
53
53
  * independently constructible in a test and this module never imports the
54
54
  * client back — mirrors `AuthHost` in `./auth.ts`.
@@ -131,7 +131,7 @@ export interface SetTenantOAuthAppInput {
131
131
  disabled?: boolean;
132
132
  }
133
133
  /**
134
- * The `console.tenantOAuthApps` namespace on a `W6wClient` — the caller's own
134
+ * The `console.tenantOAuthApps` namespace on a `W6WClient` — the caller's own
135
135
  * tenant, never a tenant of its choosing.
136
136
  *
137
137
  * @example
@@ -75,7 +75,7 @@ function toSetBody(input) {
75
75
  return body;
76
76
  }
77
77
  /**
78
- * The `console.tenantOAuthApps` namespace on a `W6wClient` — the caller's own
78
+ * The `console.tenantOAuthApps` namespace on a `W6WClient` — the caller's own
79
79
  * tenant, never a tenant of its choosing.
80
80
  *
81
81
  * @example
@@ -40,7 +40,7 @@
40
40
  */
41
41
  import { type HttpResponse, type RequestOptions } from "../http.ts";
42
42
  /**
43
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
43
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
44
44
  * else. Structural rather than a concrete client type, so the namespace stays
45
45
  * independently constructible in a test and this module never imports the
46
46
  * client back — mirrors `ConnectionsHost` in `./connections.ts`.
@@ -88,7 +88,7 @@ export interface CreateTokenResponse {
88
88
  secret: string;
89
89
  }
90
90
  /**
91
- * The `console.tokens` namespace on a `W6wClient`.
91
+ * The `console.tokens` namespace on a `W6WClient`.
92
92
  *
93
93
  * @example
94
94
  * ```ts
@@ -41,7 +41,7 @@
41
41
  import { path } from "../http.js";
42
42
  import { unwrap } from "../types.js";
43
43
  /**
44
- * The `console.tokens` namespace on a `W6wClient`.
44
+ * The `console.tokens` namespace on a `W6WClient`.
45
45
  *
46
46
  * @example
47
47
  * ```ts
@@ -40,7 +40,7 @@
40
40
  */
41
41
  import { type HttpResponse, type RequestOptions } from "../http.ts";
42
42
  /**
43
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
43
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
44
44
  * else. Structural rather than a concrete client type, so the namespace stays
45
45
  * independently constructible in a test and this module never imports the
46
46
  * client back — mirrors `ConnectionsHost` in `./connections.ts`.
@@ -85,7 +85,7 @@ export interface SecretValue {
85
85
  iv: string;
86
86
  }
87
87
  /**
88
- * The `console.vault` namespace on a `W6wClient`.
88
+ * The `console.vault` namespace on a `W6WClient`.
89
89
  *
90
90
  * @example
91
91
  * ```ts
@@ -41,7 +41,7 @@
41
41
  import { path } from "../http.js";
42
42
  import { unwrap } from "../types.js";
43
43
  /**
44
- * The `console.vault` namespace on a `W6wClient`.
44
+ * The `console.vault` namespace on a `W6WClient`.
45
45
  *
46
46
  * @example
47
47
  * ```ts
@@ -54,7 +54,7 @@
54
54
  import { type HttpResponse, type RequestOptions } from "../http.ts";
55
55
  import { type RunStatus, type StepError } from "../types.ts";
56
56
  /**
57
- * The slice of `W6wClient` this namespace needs: the transport, and nothing
57
+ * The slice of `W6WClient` this namespace needs: the transport, and nothing
58
58
  * else. Structural rather than a concrete client type, so the namespace stays
59
59
  * independently constructible in a test and this module never imports the
60
60
  * client back — mirrors `SchedulesHost` in `./schedules.ts`.
@@ -117,7 +117,7 @@ export interface RunSummary {
117
117
  finishedAt: string | null;
118
118
  }
119
119
  /**
120
- * The `console.workflows` namespace on a `W6wClient`.
120
+ * The `console.workflows` namespace on a `W6WClient`.
121
121
  *
122
122
  * @example
123
123
  * ```ts
@@ -56,7 +56,7 @@ import { unwrap } from "../types.js";
56
56
  /** The precondition header `upsert` sends when `ifUnmodifiedSince` is given. */
57
57
  const PRECONDITION_HEADER = "x-w6w-if-unmodified-since";
58
58
  /**
59
- * The `console.workflows` namespace on a `W6wClient`.
59
+ * The `console.workflows` namespace on a `W6WClient`.
60
60
  *
61
61
  * @example
62
62
  * ```ts
@@ -24,7 +24,7 @@ import type { ResolvedConfig } from "./config.ts";
24
24
  import { type HttpResponse, type RequestOptions } from "./http.ts";
25
25
  import { type Doc, type DocFormat } from "./types.ts";
26
26
  /**
27
- * The slice of `W6wClient` this namespace needs: the transport, plus
27
+ * The slice of `W6WClient` this namespace needs: the transport, plus
28
28
  * the resolved configuration it reads the **default project** out of. Structural
29
29
  * rather than a concrete client type, so the namespace stays independently
30
30
  * constructible in a test and this module never imports the client back.
@@ -78,7 +78,7 @@ export interface DocumentPatch {
78
78
  description?: string;
79
79
  }
80
80
  /**
81
- * The `documents` namespace on a `W6wClient`.
81
+ * The `documents` namespace on a `W6WClient`.
82
82
  *
83
83
  * @example
84
84
  * ```ts
@@ -23,7 +23,7 @@
23
23
  import { path } from "./http.js";
24
24
  import { unwrap } from "./types.js";
25
25
  /**
26
- * The `documents` namespace on a `W6wClient`.
26
+ * The `documents` namespace on a `W6WClient`.
27
27
  *
28
28
  * @example
29
29
  * ```ts
@@ -0,0 +1,75 @@
1
+ /**
2
+ * `client.endpoints.*` — run an Endpoint by the key you gave it.
3
+ *
4
+ * An Endpoint is a callable entry point that dispatches to whatever it targets:
5
+ * an app action, a Function, or a Workflow. Before this namespace existed,
6
+ * calling one meant `client.run({ urn: "ep_…" })` — an opaque id, buried inside
7
+ * an object, for an Endpoint the user named `send-email`. Now:
8
+ *
9
+ * ```ts
10
+ * await client.endpoints.run("send-email", { payload: { to, subject } });
11
+ * ```
12
+ *
13
+ * The name is the FIRST argument, matching `workflows.run` and `functions.run`,
14
+ * so all three runnable kinds read alike.
15
+ *
16
+ * ID OR KEY, one argument: `/endpoints/{idOrKey}/invoke` accepts either, because
17
+ * an id carries a kind prefix (and so an underscore) while a key is kebab-case
18
+ * (which forbids one). No flag, no prefix — pass whichever you have.
19
+ *
20
+ * UNLIKE `functions.run`, THIS RETURNS AN ENVELOPE, and that asymmetry is the
21
+ * honest one: a Function's kind is settled by the method name, but an Endpoint
22
+ * dispatches to one of three things and the caller genuinely does not know which
23
+ * answered. The `kind` discriminant is information here, not ceremony — and the
24
+ * Workflow arm is asynchronous (`202`, a `runId`) where the other two are not.
25
+ */
26
+ import type { ResolvedConfig } from "./config.ts";
27
+ import { type HttpResponse, type RequestOptions } from "./http.ts";
28
+ import type { RunEnvelope } from "./types.ts";
29
+ /**
30
+ * What this namespace needs from the client — the same narrow seam
31
+ * `WorkflowsApi` and `FunctionsApi` take.
32
+ */
33
+ export interface EndpointsHost {
34
+ /** The resolved configuration. */
35
+ readonly config: ResolvedConfig;
36
+ /** Perform one request. */
37
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
38
+ }
39
+ /** Per-call options for `endpoints.run`. */
40
+ export interface EndpointRunOptions {
41
+ /**
42
+ * The Endpoint's input, by input key.
43
+ *
44
+ * Named `payload` for the same reason as `functions.run`: one word across
45
+ * every runnable kind, even though the wire spells this one `input`.
46
+ */
47
+ payload?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * The `endpoints` namespace on a `W6WClient`.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const envelope = await client.endpoints.run("send-email", { payload: { to } });
55
+ * if (envelope.kind === "workflow") console.log(envelope.runId); // async arm
56
+ * ```
57
+ */
58
+ export declare class EndpointsApi {
59
+ #private;
60
+ /**
61
+ * @param host - The client this namespace issues requests through.
62
+ */
63
+ constructor(host: EndpointsHost);
64
+ /**
65
+ * Run one Endpoint; the envelope's `kind` says which arm answered.
66
+ *
67
+ * @param name - The Endpoint's key (`"send-email"`) or its `ep_…` id. Percent-encoded into the path.
68
+ * @param options - `payload`, the Endpoint's input.
69
+ * @returns The `kind`-discriminated envelope, returned exactly as it arrived.
70
+ * @throws {ApiError} `404 unknown_endpoint` when no Endpoint of that name exists for the caller.
71
+ * @throws {ApiError} `bad_response` when a success body carries no string `kind`.
72
+ */
73
+ run(name: string, options?: EndpointRunOptions): Promise<RunEnvelope>;
74
+ }
75
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED,4CAA4C;AAC5C,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAY;;IAGvB;;OAEG;gBACS,IAAI,EAAE,aAAa;IAI/B;;;;;;;;OAQG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAyB5E"}