@w6w/sdk 0.5.0 → 0.9.8

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 (132) hide show
  1. package/README.md +185 -32
  2. package/dist/mod.d.ts +10 -4
  3. package/dist/mod.d.ts.map +1 -1
  4. package/dist/mod.js +3 -0
  5. package/dist/mod.js.map +1 -1
  6. package/dist/src/client.d.ts +37 -5
  7. package/dist/src/client.d.ts.map +1 -1
  8. package/dist/src/client.js +40 -5
  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 +41 -5
  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/aliases.d.ts +137 -0
  19. package/dist/src/console/aliases.d.ts.map +1 -0
  20. package/dist/src/console/aliases.js +113 -0
  21. package/dist/src/console/aliases.js.map +1 -0
  22. package/dist/src/console/api-calls.d.ts +4 -3
  23. package/dist/src/console/api-calls.d.ts.map +1 -1
  24. package/dist/src/console/api-calls.js +4 -3
  25. package/dist/src/console/api-calls.js.map +1 -1
  26. package/dist/src/console/apps.d.ts +181 -8
  27. package/dist/src/console/apps.d.ts.map +1 -1
  28. package/dist/src/console/apps.js +67 -12
  29. package/dist/src/console/apps.js.map +1 -1
  30. package/dist/src/console/auth.d.ts +245 -7
  31. package/dist/src/console/auth.d.ts.map +1 -1
  32. package/dist/src/console/auth.js +177 -8
  33. package/dist/src/console/auth.js.map +1 -1
  34. package/dist/src/console/commerce.d.ts +428 -0
  35. package/dist/src/console/commerce.d.ts.map +1 -0
  36. package/dist/src/console/commerce.js +220 -0
  37. package/dist/src/console/commerce.js.map +1 -0
  38. package/dist/src/console/dashboard.d.ts +8 -0
  39. package/dist/src/console/dashboard.d.ts.map +1 -1
  40. package/dist/src/console/dashboard.js.map +1 -1
  41. package/dist/src/console/endpoints.d.ts +79 -6
  42. package/dist/src/console/endpoints.d.ts.map +1 -1
  43. package/dist/src/console/endpoints.js.map +1 -1
  44. package/dist/src/console/functions.d.ts +35 -4
  45. package/dist/src/console/functions.d.ts.map +1 -1
  46. package/dist/src/console/functions.js +13 -0
  47. package/dist/src/console/functions.js.map +1 -1
  48. package/dist/src/console/mod.d.ts +32 -7
  49. package/dist/src/console/mod.d.ts.map +1 -1
  50. package/dist/src/console/mod.js +26 -1
  51. package/dist/src/console/mod.js.map +1 -1
  52. package/dist/src/console/otp.d.ts +127 -0
  53. package/dist/src/console/otp.d.ts.map +1 -0
  54. package/dist/src/console/otp.js +118 -0
  55. package/dist/src/console/otp.js.map +1 -0
  56. package/dist/src/console/passkeys.d.ts +246 -0
  57. package/dist/src/console/passkeys.d.ts.map +1 -0
  58. package/dist/src/console/passkeys.js +192 -0
  59. package/dist/src/console/passkeys.js.map +1 -0
  60. package/dist/src/console/reliability.d.ts +101 -6
  61. package/dist/src/console/reliability.d.ts.map +1 -1
  62. package/dist/src/console/reliability.js +16 -5
  63. package/dist/src/console/reliability.js.map +1 -1
  64. package/dist/src/console/step-tests.d.ts +7 -1
  65. package/dist/src/console/step-tests.d.ts.map +1 -1
  66. package/dist/src/console/step-tests.js +1 -1
  67. package/dist/src/console/step-tests.js.map +1 -1
  68. package/dist/src/console/subscriptions.d.ts +38 -16
  69. package/dist/src/console/subscriptions.d.ts.map +1 -1
  70. package/dist/src/console/subscriptions.js +7 -13
  71. package/dist/src/console/subscriptions.js.map +1 -1
  72. package/dist/src/console/tenant-login-flags.d.ts +106 -0
  73. package/dist/src/console/tenant-login-flags.d.ts.map +1 -0
  74. package/dist/src/console/tenant-login-flags.js +113 -0
  75. package/dist/src/console/tenant-login-flags.js.map +1 -0
  76. package/dist/src/console/tenant-oauth-apps.d.ts +75 -14
  77. package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -1
  78. package/dist/src/console/tenant-oauth-apps.js +37 -11
  79. package/dist/src/console/tenant-oauth-apps.js.map +1 -1
  80. package/dist/src/console/tokens.d.ts +2 -0
  81. package/dist/src/console/tokens.d.ts.map +1 -1
  82. package/dist/src/console/tokens.js.map +1 -1
  83. package/dist/src/console/workflows.d.ts +14 -0
  84. package/dist/src/console/workflows.d.ts.map +1 -1
  85. package/dist/src/console/workflows.js +13 -0
  86. package/dist/src/console/workflows.js.map +1 -1
  87. package/dist/src/documents.d.ts +9 -5
  88. package/dist/src/documents.d.ts.map +1 -1
  89. package/dist/src/documents.js +6 -3
  90. package/dist/src/documents.js.map +1 -1
  91. package/dist/src/endpoints.d.ts +75 -0
  92. package/dist/src/endpoints.d.ts.map +1 -0
  93. package/dist/src/endpoints.js +47 -0
  94. package/dist/src/endpoints.js.map +1 -0
  95. package/dist/src/functions.d.ts +236 -0
  96. package/dist/src/functions.d.ts.map +1 -0
  97. package/dist/src/functions.js +201 -0
  98. package/dist/src/functions.js.map +1 -0
  99. package/dist/src/http.d.ts +58 -10
  100. package/dist/src/http.d.ts.map +1 -1
  101. package/dist/src/http.js +82 -11
  102. package/dist/src/http.js.map +1 -1
  103. package/dist/src/me.d.ts +3 -2
  104. package/dist/src/me.d.ts.map +1 -1
  105. package/dist/src/me.js +7 -2
  106. package/dist/src/me.js.map +1 -1
  107. package/dist/src/run.d.ts +19 -5
  108. package/dist/src/run.d.ts.map +1 -1
  109. package/dist/src/run.js +14 -4
  110. package/dist/src/run.js.map +1 -1
  111. package/dist/src/server/mod.d.ts +100 -0
  112. package/dist/src/server/mod.d.ts.map +1 -0
  113. package/dist/src/server/mod.js +121 -0
  114. package/dist/src/server/mod.js.map +1 -0
  115. package/dist/src/team.d.ts +204 -0
  116. package/dist/src/team.d.ts.map +1 -0
  117. package/dist/src/team.js +161 -0
  118. package/dist/src/team.js.map +1 -0
  119. package/dist/src/types.d.ts +143 -10
  120. package/dist/src/types.d.ts.map +1 -1
  121. package/dist/src/types.js +27 -0
  122. package/dist/src/types.js.map +1 -1
  123. package/dist/src/vars.d.ts +5 -3
  124. package/dist/src/vars.d.ts.map +1 -1
  125. package/dist/src/vars.js +14 -4
  126. package/dist/src/vars.js.map +1 -1
  127. package/dist/src/version.js +1 -1
  128. package/dist/src/workflows.d.ts +261 -9
  129. package/dist/src/workflows.d.ts.map +1 -1
  130. package/dist/src/workflows.js +246 -7
  131. package/dist/src/workflows.js.map +1 -1
  132. package/package.json +5 -1
@@ -0,0 +1,201 @@
1
+ import { ApiError } from "./errors.js";
2
+ import { path } from "./http.js";
3
+ import { mintId, unwrap } from "./types.js";
4
+ /**
5
+ * The `functions` namespace on a `W6WClient`.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const output = await client.functions.run("send-email", {
10
+ * payload: { to: "ada@example.com", subject: "Hi", html: "<p>Hello</p>" },
11
+ * });
12
+ *
13
+ * // The definition lifecycle.
14
+ * const fns = await client.functions.list();
15
+ * const { function: def } = await client.functions.get(fns[0].id);
16
+ * await client.functions.update(fns[0].id, { ...def, description: "Send an email" });
17
+ * ```
18
+ */
19
+ export class FunctionsApi {
20
+ #host;
21
+ /**
22
+ * @param host - The client this namespace issues requests through.
23
+ */
24
+ constructor(host) {
25
+ this.#host = host;
26
+ }
27
+ /**
28
+ * Run one Function and return its output.
29
+ *
30
+ * Returns the Function's OUTPUT, not an envelope. `client.run` returns a
31
+ * `kind`-discriminated envelope because the caller does not know what the URN
32
+ * will resolve to; here the kind is in the method name, so the discriminant
33
+ * would be a field the caller has to unwrap to learn nothing.
34
+ *
35
+ * @param name - The Function's key (`"send-email"`) or its `fn_…` id. Percent-encoded into the path.
36
+ * @param options - `payload`, the Function's canonical inputs.
37
+ * @returns The Function's output, unwrapped from the `output` envelope.
38
+ * @throws {ApiError} `404 unknown_function` when no Function of that name exists for the caller.
39
+ * @throws {ApiError} `422 function_incomplete` when the Function has no runnable `impl`.
40
+ * @throws {ApiError} `bad_response` when a success body carries no `output` key at all.
41
+ */
42
+ async run(name, options) {
43
+ const res = await this.#host.request({
44
+ method: "POST",
45
+ path: path `/functions/${name}/invoke`,
46
+ body: { inputs: options?.payload ?? {} },
47
+ });
48
+ // Deliberately NOT `unwrap(res, "output")`. That helper treats `null` as
49
+ // "the server did not send what it promised" — correct for a `documents` or
50
+ // `vars` envelope, where null is never a document. It is wrong here: a
51
+ // Function's output is an OPAQUE pass-through, and an action that returns
52
+ // nothing yields `{"output": null}`, which is a successful run and not a
53
+ // malformed response. So the guard is PRESENCE of the key, not truthiness
54
+ // of the value.
55
+ const body = res.body;
56
+ if (typeof body !== "object" || body === null || !("output" in body)) {
57
+ throw new ApiError(res.status, "bad_response", `Server returned a ${res.status} with no "output" in the response body.`, body);
58
+ }
59
+ return body.output;
60
+ }
61
+ /**
62
+ * List the caller's Function definitions.
63
+ *
64
+ * This is how a caller discovers a `key` to pass to {@linkcode run} — the
65
+ * same job `workflows.list` and `connections.list` do for their own ids (D4),
66
+ * and the reason a read-only integration needs no other write access.
67
+ *
68
+ * Each row already carries `valid`, computed server-side; there is no second
69
+ * call to make to find out whether a Function is runnable.
70
+ *
71
+ * **No `project` parameter.** Unlike workflows and documents, the route reads
72
+ * no `?project=` at all (`admin/functions.ts`) — sending one would be
73
+ * inventing a parameter, which is the failure mode `endpoints.json` warns
74
+ * about.
75
+ *
76
+ * @param options - Optional per-call transport options (`signal` to abort).
77
+ * @returns The Functions, unwrapped from the `functions` envelope.
78
+ * @throws {ApiError} On any non-2xx.
79
+ */
80
+ async list(options) {
81
+ const res = await this.#host.request({
82
+ method: "GET",
83
+ path: "/functions",
84
+ signal: options?.signal,
85
+ });
86
+ return unwrap(res, "functions");
87
+ }
88
+ /**
89
+ * Fetch one Function's stored definition.
90
+ *
91
+ * Returns the whole body — `{function, valid}` — rather than splicing `valid`
92
+ * into the definition. See {@linkcode FunctionDetail.valid} for why that
93
+ * placement matters on the way back OUT of this method.
94
+ *
95
+ * @param id - The `fn_…` id, or the Function's `key`. Percent-encoded into the path.
96
+ * @param options - Optional per-call transport options (`signal` to abort).
97
+ * @returns The definition and the server's runnability verdict.
98
+ * @throws {ApiError} `404 unknown_function` when there is no such Function for this caller.
99
+ */
100
+ async get(id, options) {
101
+ const res = await this.#host.request({
102
+ method: "GET",
103
+ path: path `/functions/${id}`,
104
+ signal: options?.signal,
105
+ });
106
+ return res.body;
107
+ }
108
+ /**
109
+ * Create a Function.
110
+ *
111
+ * **The id is minted client-side when the definition does not carry one** —
112
+ * `POST /functions` requires `id` and never generates one, exactly as the
113
+ * workflow route does. `key` is NOT minted: it is the name the Function is
114
+ * called by, so it is the caller's to choose, and the server validates it on
115
+ * first save only (3–39 chars, lowercase, single hyphens, no `_`). That
116
+ * grammar is what keeps `/functions/{idOrKey}/invoke` unambiguous — a key
117
+ * containing `_` could be mistaken for an `fn_…` id.
118
+ *
119
+ * `create` and {@linkcode update} reach the SAME upsert route; posting a
120
+ * definition whose id already exists overwrites it.
121
+ *
122
+ * @param definition - The whole Function definition, forwarded verbatim apart from a minted `id`.
123
+ * @returns The new Function's id and key.
124
+ * @throws {ApiError} `400 invalid_function` — no `key`, no `inputs` array, or a malformed `impl`.
125
+ * @throws {ApiError} `409 function_conflict` — another `(tenant, subject)` already owns that id.
126
+ * @throws {ApiError} `409 function_key_conflict` — that `key` is already taken in this scope.
127
+ */
128
+ async create(definition) {
129
+ const body = typeof definition.id === "string" && definition.id.length > 0
130
+ ? definition
131
+ : { ...definition, id: mintId("fn") };
132
+ return await this.#save(body);
133
+ }
134
+ /**
135
+ * Overwrite a Function's stored definition.
136
+ *
137
+ * **A full replacement, not a patch** — the server has one write route and it
138
+ * stores what it is given, so read with {@linkcode get}, change what you mean
139
+ * to change, and send the whole thing back. There is no concurrency
140
+ * precondition on this route (workflows have one; Functions do not), so the
141
+ * write is last-write-wins.
142
+ *
143
+ * `id` comes from the FIRST ARGUMENT and is pinned into the body, overriding
144
+ * any `id` the definition carries — otherwise `update("fn_a", defOfB)` would
145
+ * quietly write to B.
146
+ *
147
+ * Do not send back the `valid` field: it is not part of the stored document,
148
+ * and {@linkcode get} deliberately leaves it outside the definition so that
149
+ * a read-modify-write round trip cannot pick it up by accident.
150
+ *
151
+ * @param id - The `fn_…` id to write to.
152
+ * @param definition - The whole replacement definition.
153
+ * @returns The Function's id and key.
154
+ * @throws {ApiError} `400 invalid_function` — structurally invalid body.
155
+ * @throws {ApiError} `409 function_conflict` — another `(tenant, subject)` owns this id.
156
+ * @throws {ApiError} `409 function_key_conflict` — the new `key` is already taken in this scope.
157
+ */
158
+ async update(id, definition) {
159
+ return await this.#save({ ...definition, id });
160
+ }
161
+ /**
162
+ * Delete a Function.
163
+ *
164
+ * Not idempotent, and deliberately so: deleting an id that is not there is
165
+ * `404 unknown_function`, not a silent success — the same pin
166
+ * `documents.delete` carries.
167
+ *
168
+ * **Nothing checks for callers first.** A Function may be referenced by an
169
+ * Endpoint, by a Workflow step, or by another Function's `impl` (D-8), and
170
+ * the server does not walk those references; they break at call time. Deleting
171
+ * a Function that something else calls is the caller's decision to get right.
172
+ *
173
+ * Returns nothing: the server's `{ok: true}` carries no information a caller
174
+ * can use (`docs/implementation.md` §5).
175
+ *
176
+ * @param id - The `fn_…` id, or the Function's `key`.
177
+ * @throws {ApiError} `404 unknown_function` when there is no such Function for this caller.
178
+ */
179
+ async delete(id) {
180
+ await this.#host.request({ method: "DELETE", path: path `/functions/${id}` });
181
+ }
182
+ /**
183
+ * The one POST both {@linkcode create} and {@linkcode update} go through.
184
+ *
185
+ * Private and shared rather than duplicated: the route answers `201` with the
186
+ * id and key under a `function` envelope, and two copies of that unwrap is
187
+ * two places for a server change to be half-applied.
188
+ *
189
+ * @param body - The complete definition, id already resolved.
190
+ * @returns The saved Function's id and key.
191
+ */
192
+ async #save(body) {
193
+ const res = await this.#host.request({
194
+ method: "POST",
195
+ path: "/functions",
196
+ body,
197
+ });
198
+ return unwrap(res, "function");
199
+ }
200
+ }
201
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","s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c,EAAE,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,KAAK,CAAC,IAAwB;QAClC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,IAAI;SACL,CAAC,CAAC;QACH,OAAO,MAAM,CAA8B,GAAG,EAAE,UAAU,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -1,12 +1,24 @@
1
1
  /**
2
- * The transport: one `request()`, three failure modes, no policy.
2
+ * The transport: one `request()`, three failure modes, and one opt-in policy.
3
3
  *
4
4
  * Everything the operation modules do goes through {@linkcode request}. It
5
5
  * attaches the bearer, serialises a JSON body, reads the response exactly once,
6
6
  * parses it guardedly, and raises one of the three failure modes pinned in
7
- * `docs/implementation.md` §3 — and nothing else. In particular it does **not**
8
- * retry, does **not** refresh a token, does **not** poll, and does **not**
9
- * inspect an error code to decide on a side effect. A `401` raises and stops.
7
+ * `docs/implementation.md` §3 — and nothing else. It does **not** poll and does
8
+ * **not** inspect an error code to decide on a side effect, beyond the one
9
+ * policy described next.
10
+ *
11
+ * **The one exception is opt-in**: when `config.refreshOnUnauthorized` is
12
+ * `true`, `config.token` is a function, and the request used a bearer
13
+ * (`requireAuth !== false`), a `401` whose `code` is exactly `"unauthorized"`
14
+ * is given a single recovery attempt — the provider is called once more with
15
+ * `{forceRefresh: true}` and, if that yields a usable token, the identical
16
+ * request is re-sent once with it by calling `request()` a second time (never
17
+ * a third). Off by default, this is exactly the old unconditional "a `401`
18
+ * raises and stops" behaviour. `config.onUnauthorized`, when set, receives the
19
+ * terminal `401`/`unauthorized` `ApiError` of a bearer request — after a failed
20
+ * retry, or immediately when recovery is off or impossible — at most once per
21
+ * call, never on success, and never for a `requireAuth: false` request.
10
22
  *
11
23
  * It also returns the **HTTP status** alongside the parsed body, because a
12
24
  * `202` is a normal outcome on this API (a queued workflow run), not an error —
@@ -45,12 +57,12 @@ export interface RequestOptions {
45
57
  /** Request body. Serialised as JSON when present; omit it for a bodiless request. */
46
58
  body?: unknown;
47
59
  /**
48
- * Extra headers to send with this request. Applied as the **base** the
49
- * transport builds on, never the other way around: the bearer
50
- * (`authorization`) and, when a body is present, `content-type` are set
51
- * *after* this base, so a caller-supplied entry with either of those names
52
- * can never override what this transport sets. Any other header name passes
53
- * through untouched.
60
+ * Extra headers to send with this request. Precedence, low to high: the
61
+ * client's own `headers` default < this option < the bearer
62
+ * (`authorization`) and, when a body is present, `content-type`, which this
63
+ * transport sets *after* both and which neither can ever override. A
64
+ * same-named entry here beats the client default; any other header name
65
+ * passes through untouched.
54
66
  */
55
67
  headers?: Record<string, string>;
56
68
  /**
@@ -67,6 +79,32 @@ export interface RequestOptions {
67
79
  * in the first place.
68
80
  */
69
81
  requireAuth?: boolean;
82
+ /**
83
+ * Abort this specific request. Local request control only — it is never
84
+ * serialized into the URL or the body, and the server never sees it. Wired
85
+ * straight through to the injected `fetch`'s own `RequestInit.signal`, so
86
+ * cancellation semantics are whatever the runtime's `fetch` already gives an
87
+ * aborted request; this transport adds no polling, retry or timeout policy
88
+ * on top of it (see this module's header).
89
+ */
90
+ signal?: AbortSignal;
91
+ }
92
+ /**
93
+ * Per-call transport options shared by every read method a react hook calls
94
+ * (R-7): today, just an optional {@linkcode AbortSignal}. A thin, deliberately
95
+ * minimal bag rather than reusing {@linkcode RequestOptions} itself — the
96
+ * typed per-method option interfaces (`DocumentOptions`,
97
+ * `WorkflowListOptions`, …) extend this one, and a method with no options
98
+ * today takes a bare `options?: CallOptions`, so `signal` lands in exactly one
99
+ * place for every read operation.
100
+ *
101
+ * `signal` reaches the injected `fetch` unchanged through
102
+ * {@linkcode RequestOptions.signal} and is NEVER serialized into the URL or
103
+ * the body — see that field's own doc for the cancellation semantics.
104
+ */
105
+ export interface CallOptions {
106
+ /** Abort this call. See {@linkcode RequestOptions.signal}. */
107
+ signal?: AbortSignal;
70
108
  }
71
109
  /**
72
110
  * A successful response: the parsed body plus the status that carried it.
@@ -149,6 +187,16 @@ export declare function buildUrl(config: ResolvedConfig, options: RequestOptions
149
187
  * deliberately a 4xx so Cloudflare cannot swallow it. It is never a transport
150
188
  * error and is never normalised into a 5xx.
151
189
  *
190
+ * **Recovery (opt-in, this module's header).** When a `401`/`unauthorized`
191
+ * {@linkcode ApiError} is about to be raised and `config.refreshOnUnauthorized
192
+ * === true && typeof config.token === "function" && options.requireAuth !==
193
+ * false`, this function calls `config.token({forceRefresh: true})` once; a
194
+ * usable result re-enters `request()` itself — never a second mapper — with a
195
+ * config carrying that **string**, which is what caps the retry at one: the
196
+ * recursive call's `config.token` is no longer a function, so its own recovery
197
+ * check is false by construction. `config.onUnauthorized` is invoked with
198
+ * whichever `401`/`unauthorized` error turns out to be terminal.
199
+ *
152
200
  * @param config - Resolved configuration (base URL and credential).
153
201
  * @param fetchImpl - The transport to use; injected, never read from a module global.
154
202
  * @param options - The request.
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAgB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGhF;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAEhF,oCAAoC;AACpC,MAAM,WAAW,cAAc;IAC7B,mBAAmB;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,qFAAqF;IACrF,IAAI,CA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IACnB,MAAM,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,qFAAqF;IACrF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW;IAC1B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAM/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAOhF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CA2H1B"}
package/dist/src/http.js CHANGED
@@ -1,12 +1,24 @@
1
1
  /**
2
- * The transport: one `request()`, three failure modes, no policy.
2
+ * The transport: one `request()`, three failure modes, and one opt-in policy.
3
3
  *
4
4
  * Everything the operation modules do goes through {@linkcode request}. It
5
5
  * attaches the bearer, serialises a JSON body, reads the response exactly once,
6
6
  * parses it guardedly, and raises one of the three failure modes pinned in
7
- * `docs/implementation.md` §3 — and nothing else. In particular it does **not**
8
- * retry, does **not** refresh a token, does **not** poll, and does **not**
9
- * inspect an error code to decide on a side effect. A `401` raises and stops.
7
+ * `docs/implementation.md` §3 — and nothing else. It does **not** poll and does
8
+ * **not** inspect an error code to decide on a side effect, beyond the one
9
+ * policy described next.
10
+ *
11
+ * **The one exception is opt-in**: when `config.refreshOnUnauthorized` is
12
+ * `true`, `config.token` is a function, and the request used a bearer
13
+ * (`requireAuth !== false`), a `401` whose `code` is exactly `"unauthorized"`
14
+ * is given a single recovery attempt — the provider is called once more with
15
+ * `{forceRefresh: true}` and, if that yields a usable token, the identical
16
+ * request is re-sent once with it by calling `request()` a second time (never
17
+ * a third). Off by default, this is exactly the old unconditional "a `401`
18
+ * raises and stops" behaviour. `config.onUnauthorized`, when set, receives the
19
+ * terminal `401`/`unauthorized` `ApiError` of a bearer request — after a failed
20
+ * retry, or immediately when recovery is off or impossible — at most once per
21
+ * call, never on success, and never for a `requireAuth: false` request.
10
22
  *
11
23
  * It also returns the **HTTP status** alongside the parsed body, because a
12
24
  * `202` is a normal outcome on this API (a queued workflow run), not an error —
@@ -98,6 +110,16 @@ export function buildUrl(config, options) {
98
110
  * deliberately a 4xx so Cloudflare cannot swallow it. It is never a transport
99
111
  * error and is never normalised into a 5xx.
100
112
  *
113
+ * **Recovery (opt-in, this module's header).** When a `401`/`unauthorized`
114
+ * {@linkcode ApiError} is about to be raised and `config.refreshOnUnauthorized
115
+ * === true && typeof config.token === "function" && options.requireAuth !==
116
+ * false`, this function calls `config.token({forceRefresh: true})` once; a
117
+ * usable result re-enters `request()` itself — never a second mapper — with a
118
+ * config carrying that **string**, which is what caps the retry at one: the
119
+ * recursive call's `config.token` is no longer a function, so its own recovery
120
+ * check is false by construction. `config.onUnauthorized` is invoked with
121
+ * whichever `401`/`unauthorized` error turns out to be terminal.
122
+ *
101
123
  * @param config - Resolved configuration (base URL and credential).
102
124
  * @param fetchImpl - The transport to use; injected, never read from a module global.
103
125
  * @param options - The request.
@@ -107,18 +129,21 @@ export function buildUrl(config, options) {
107
129
  */
108
130
  export async function request(config, fetchImpl, options) {
109
131
  const url = buildUrl(config, options);
110
- // The caller-supplied headers are the BASE the transport builds on, never the
111
- // reverse: `authorization` and `content-type` are set below, after this base,
112
- // so nothing a caller passes here can shadow the bearer this transport
113
- // attaches or the content-type it advertises for a JSON body.
114
- const headers = new Headers(options.headers);
132
+ // Precedence, low to high: the client's own default `headers` < this
133
+ // request's `headers` < the bearer/content-type this transport re-pins
134
+ // below. `.set` on an already-present name overrides it, which is what lets
135
+ // a per-request header beat a same-named client default.
136
+ const headers = new Headers(config.headers);
137
+ for (const [name, value] of Object.entries(options.headers ?? {})) {
138
+ headers.set(name, value);
139
+ }
115
140
  // Resolved per request rather than at construction: a client with no token is
116
141
  // constructible (so a CLI's --help works offline) and fails here instead.
117
142
  // Skipped entirely when `requireAuth: false` — not just left unset, but never
118
143
  // even attempted, so a tokenless client can call a public route without
119
144
  // `requireToken` raising first.
120
145
  if (options.requireAuth !== false) {
121
- headers.set("authorization", `Bearer ${requireToken(config)}`);
146
+ headers.set("authorization", `Bearer ${await requireToken(config)}`);
122
147
  }
123
148
  const hasBody = options.body !== undefined;
124
149
  if (hasBody)
@@ -129,9 +154,22 @@ export async function request(config, fetchImpl, options) {
129
154
  method: options.method,
130
155
  headers,
131
156
  body: hasBody ? JSON.stringify(options.body) : undefined,
157
+ signal: options.signal,
132
158
  });
133
159
  }
134
160
  catch (err) {
161
+ // An aborted request is a distinct, recognizable outcome from an actual
162
+ // network failure — a caller that cancelled a stale search/tab-switch
163
+ // request must be able to tell "I cancelled this" from "the server is
164
+ // unreachable" without inspecting `err.message` text. `signal.aborted` is
165
+ // checked rather than matching only on `err.name === "AbortError"`
166
+ // because it is the runtime-agnostic source of truth (the DOM/undici
167
+ // `fetch` both set it synchronously before the promise rejects).
168
+ const cancelled = options.signal?.aborted === true ||
169
+ (err instanceof Error && err.name === "AbortError");
170
+ if (cancelled) {
171
+ throw new ApiError(0, "cancelled", `Request cancelled (${options.method} ${url}).`);
172
+ }
135
173
  throw new ApiError(0, "network_error", `Could not reach the w6w server (${options.method} ${url}). ` +
136
174
  `It may be down or unreachable. (${err instanceof Error ? err.message : String(err)})`);
137
175
  }
@@ -152,7 +190,40 @@ export async function request(config, fetchImpl, options) {
152
190
  }
153
191
  if (!res.ok) {
154
192
  const envelope = data?.error ?? {};
155
- throw new ApiError(res.status, envelope.code ?? "error", envelope.message ?? res.statusText, data);
193
+ const apiError = new ApiError(res.status, envelope.code ?? "error", envelope.message ?? res.statusText, data);
194
+ const isUnauthorized = apiError.status === 401 && apiError.code === "unauthorized";
195
+ const { token } = config;
196
+ if (config.refreshOnUnauthorized === true &&
197
+ typeof token === "function" &&
198
+ options.requireAuth !== false &&
199
+ isUnauthorized) {
200
+ let refreshed;
201
+ try {
202
+ // The one and only forced refresh: never passed by ordinary
203
+ // resolution, passed here exactly once.
204
+ refreshed = await token({ forceRefresh: true });
205
+ }
206
+ catch {
207
+ refreshed = undefined;
208
+ }
209
+ if (typeof refreshed === "string" && refreshed.trim().length > 0) {
210
+ // Re-enter request() itself — the only status→ApiError mapper in this
211
+ // module — rather than re-implementing it. The retried config carries
212
+ // the refreshed token as a plain STRING, so this recursive call's own
213
+ // `typeof config.token === "function"` check is false: that is what
214
+ // caps this at one retry, never a third attempt, AND it is why the
215
+ // recursive call's own terminal-error handling below (not a second
216
+ // copy of it here) is what calls `onUnauthorized` on a retry that
217
+ // still comes back 401 — calling it here too would fire it twice.
218
+ return await request({ ...config, token: refreshed }, fetchImpl, options);
219
+ }
220
+ // No usable refreshed token (nullish, blank, or the provider threw):
221
+ // no retry — fall through and report the ORIGINAL 401.
222
+ }
223
+ if (isUnauthorized && options.requireAuth !== false) {
224
+ config.onUnauthorized?.(apiError);
225
+ }
226
+ throw apiError;
156
227
  }
157
228
  return { status: res.status, body: data };
158
229
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAkB,YAAY,EAAuB,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAoEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,IAAI,CAAC,OAA6B,EAAE,GAAG,MAAgB;IACrE,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,CACnB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,EAC9E,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAsB,EAAE,OAAuB;IACtE,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAChE,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,OAAO,GAAG,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACvE,CAAC;AAED;;;;;;;;;;;;;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AC;QAEzB,IACE,MAAM,CAAC,qBAAqB,KAAK,IAAI;YACrC,OAAO,KAAK,KAAK,UAAU;YAC3B,OAAO,CAAC,WAAW,KAAK,KAAK;YAC7B,cAAc,EACd,CAAC;YACD,IAAI,SAAoC,CAAC;YACzC,IAAI,CAAC;gBACH,4DAA4D;gBAC5D,wCAAwC;gBACxC,SAAS,GAAG,MAAM,KAAK,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS,GAAG,SAAS,CAAC;YACxB,CAAC;YAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjE,sEAAsE;gBACtE,sEAAsE;gBACtE,sEAAsE;gBACtE,oEAAoE;gBACpE,mEAAmE;gBACnE,mEAAmE;gBACnE,kEAAkE;gBAClE,kEAAkE;gBAClE,OAAO,MAAM,OAAO,CAAI,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC;YACD,qEAAqE;YACrE,uDAAuD;QACzD,CAAC;QAED,IAAI,cAAc,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;YACpD,MAAM,CAAC,cAAc,EAAE,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,QAAQ,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAS,EAAE,CAAC;AACjD,CAAC"}
package/dist/src/me.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  *
22
22
  * @module
23
23
  */
24
- import type { HttpResponse, RequestOptions } from "./http.ts";
24
+ import type { CallOptions, HttpResponse, RequestOptions } from "./http.ts";
25
25
  import type { Me } from "./types.ts";
26
26
  /**
27
27
  * The slice of `W6WClient` this operation needs: the transport, and nothing
@@ -43,11 +43,12 @@ export interface MeHost {
43
43
  * the server sent the block at all.
44
44
  *
45
45
  * @param host - The client this operation issues its request through.
46
+ * @param options - Optional per-call transport options (`signal` to abort).
46
47
  * @returns The caller's identity, with `versions.wrapper` filled in.
47
48
  * @throws {ApiError} On any non-2xx, e.g. `401` when the token is not accepted.
48
49
  * @throws {ApiError} `bad_response` when a 2xx body is not a plain object — an
49
50
  * array included, since `typeof [] === "object"` and a spread array yields
50
51
  * character-indexed keys rather than identity fields.
51
52
  */
52
- export declare function fetchMe(host: MeHost): Promise<Me>;
53
+ export declare function fetchMe(host: MeHost, options?: CallOptions): Promise<Me>;
53
54
  //# sourceMappingURL=me.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../src/me.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGrC;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAuCvD"}
1
+ {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../src/me.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGrC;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC,CA2C9E"}
package/dist/src/me.js CHANGED
@@ -33,14 +33,19 @@ import { VERSION } from "./version.js";
33
33
  * the server sent the block at all.
34
34
  *
35
35
  * @param host - The client this operation issues its request through.
36
+ * @param options - Optional per-call transport options (`signal` to abort).
36
37
  * @returns The caller's identity, with `versions.wrapper` filled in.
37
38
  * @throws {ApiError} On any non-2xx, e.g. `401` when the token is not accepted.
38
39
  * @throws {ApiError} `bad_response` when a 2xx body is not a plain object — an
39
40
  * array included, since `typeof [] === "object"` and a spread array yields
40
41
  * character-indexed keys rather than identity fields.
41
42
  */
42
- export async function fetchMe(host) {
43
- const res = await host.request({ method: "GET", path: "/auth/me" });
43
+ export async function fetchMe(host, options) {
44
+ const res = await host.request({
45
+ method: "GET",
46
+ path: "/auth/me",
47
+ signal: options?.signal,
48
+ });
44
49
  const body = res.body;
45
50
  // A body that is not an object cannot be identity data. Raise rather than
46
51
  // spread it — the same `bad_response` class the envelope reader uses for the
@@ -1 +1 @@
1
- {"version":3,"file":"me.js","sourceRoot":"","sources":["../../src/me.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAavC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY;IACxC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI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POST, one kind-tagged body, no envelope key. The URN resolves over the
5
- * four runnable arms — `conn_…`, `wf_…`, `fn_…`, `ep_…` (D16) — and the answer
6
- * says which one it hit:
5
+ * `conn_…`, `wf_…`, `fn_…` and `ep_…` arms (D16), and, additionally, an
6
+ * account-scoped alias name (kebab-slug, `_`-free, which is why no flag is
7
+ * needed to disambiguate the two) — and the answer says which one it hit:
7
8
  *
8
9
  * | `kind` | Field | HTTP |
9
10
  * |---|---|---|
@@ -11,11 +12,20 @@
11
12
  * | `"function"` | `output` | `200` |
12
13
  * | `"workflow"` | `runId` + `status` | `202` |
13
14
  *
14
- * `value` and `output` are **deliberately different names** and are never
15
- * normalised into one field: the discrimination is the whole point of the
15
+ * `value` and `output` were **deliberately different names** and `value` is
16
+ * never removed: the discrimination is the whole point of the
16
17
  * operation (D3). `202` on the workflow arm is **success** — the run is queued
17
18
  * and `runId` is how the caller follows it.
18
19
  *
20
+ * ── The invocation frame ──
21
+ * Since 2026-08-20 every arm also carries the platform's own record of the
22
+ * attempt — `invocationId` (`inv_…`), `status`, `startedAt`, `finishedAt`,
23
+ * `durationMs` — and the action arm carries `output` beside `value`, with the
24
+ * identical payload. All additive; nothing was renamed. `status` is the
25
+ * PLATFORM's verdict (`succeeded` | `failed` | `queued`), not one the target
26
+ * reported inside its own payload, and `invocationId` (this call) is not
27
+ * `runId` (the queued workflow run a call may have started).
28
+ *
19
29
  * ── The unknown fourth kind ──
20
30
  * A `kind` this release has never heard of is **returned verbatim**, never
21
31
  * raised (`docs/implementation.md` §5). `run` dispatches on whatever a URN
@@ -63,7 +73,11 @@ export interface RunHost {
63
73
  * uses it for its `wf_…` id.)
64
74
  */
65
75
  export interface RunInput {
66
- /** What to run: `conn_…`, `wf_…`, `fn_…` or `ep_…`. */
76
+ /**
77
+ * What to run: `conn_…`, `wf_…`, `fn_…`, `ep_…`, or, additionally, an
78
+ * account-scoped alias name (kebab-slug, `_`-free, which is why no flag is
79
+ * needed to disambiguate the two).
80
+ */
67
81
  urn: string;
68
82
  /**
69
83
  * Which action to invoke. Optional, because a workflow, function or endpoint
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BjF"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BjF"}
package/dist/src/run.js CHANGED
@@ -2,8 +2,9 @@
2
2
  * `client.run({urn, action, payload})` — run anything a URN addresses.
3
3
  *
4
4
  * One POST, one kind-tagged body, no envelope key. The URN resolves over the
5
- * four runnable arms — `conn_…`, `wf_…`, `fn_…`, `ep_…` (D16) — and the answer
6
- * says which one it hit:
5
+ * `conn_…`, `wf_…`, `fn_…` and `ep_…` arms (D16), and, additionally, an
6
+ * account-scoped alias name (kebab-slug, `_`-free, which is why no flag is
7
+ * needed to disambiguate the two) — and the answer says which one it hit:
7
8
  *
8
9
  * | `kind` | Field | HTTP |
9
10
  * |---|---|---|
@@ -11,11 +12,20 @@
11
12
  * | `"function"` | `output` | `200` |
12
13
  * | `"workflow"` | `runId` + `status` | `202` |
13
14
  *
14
- * `value` and `output` are **deliberately different names** and are never
15
- * normalised into one field: the discrimination is the whole point of the
15
+ * `value` and `output` were **deliberately different names** and `value` is
16
+ * never removed: the discrimination is the whole point of the
16
17
  * operation (D3). `202` on the workflow arm is **success** — the run is queued
17
18
  * and `runId` is how the caller follows it.
18
19
  *
20
+ * ── The invocation frame ──
21
+ * Since 2026-08-20 every arm also carries the platform's own record of the
22
+ * attempt — `invocationId` (`inv_…`), `status`, `startedAt`, `finishedAt`,
23
+ * `durationMs` — and the action arm carries `output` beside `value`, with the
24
+ * identical payload. All additive; nothing was renamed. `status` is the
25
+ * PLATFORM's verdict (`succeeded` | `failed` | `queued`), not one the target
26
+ * reported inside its own payload, and `invocationId` (this call) is not
27
+ * `runId` (the queued workflow run a call may have started).
28
+ *
19
29
  * ── The unknown fourth kind ──
20
30
  * A `kind` this release has never heard of is **returned verbatim**, never
21
31
  * raised (`docs/implementation.md` §5). `run` dispatches on whatever a URN
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAoCvC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAa,EAAE,KAAe;IACzD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAU;QACtC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE;YACJ,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,oEAAoE;YACpE,0EAA0E;YAC1E,mBAAmB;YACnB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE;SAC7B;KACF,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACtB,IACE,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QACzC,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,EACrD,CAAC;QACD,MAAM,IAAI,QAAQ,CAChB,GAAG,CAAC,MAAM,EACV,cAAc,EACd,qBAAqB,GAAG,CAAC,MAAM,uCAAuC,EACtE,IAAI,CACL,CAAC;IACJ,CAAC;IACD,qEAAqE;IACrE,yEAAyE;IACzE,wBAAwB;IACxB,OAAO,IAAmB,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../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