@w6w/sdk 0.9.15 → 0.9.23

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 (91) hide show
  1. package/README.md +21 -16
  2. package/dist/mod.d.ts +12 -1
  3. package/dist/mod.d.ts.map +1 -1
  4. package/dist/mod.js +7 -1
  5. package/dist/mod.js.map +1 -1
  6. package/dist/src/agents.d.ts +33 -0
  7. package/dist/src/agents.d.ts.map +1 -0
  8. package/dist/src/agents.js +73 -0
  9. package/dist/src/agents.js.map +1 -0
  10. package/dist/src/assets.d.ts +56 -0
  11. package/dist/src/assets.d.ts.map +1 -0
  12. package/dist/src/assets.js +143 -0
  13. package/dist/src/assets.js.map +1 -0
  14. package/dist/src/client.d.ts +24 -3
  15. package/dist/src/client.d.ts.map +1 -1
  16. package/dist/src/client.js +32 -3
  17. package/dist/src/client.js.map +1 -1
  18. package/dist/src/config.d.ts +14 -8
  19. package/dist/src/config.d.ts.map +1 -1
  20. package/dist/src/config.js +15 -9
  21. package/dist/src/config.js.map +1 -1
  22. package/dist/src/connections.d.ts +8 -3
  23. package/dist/src/connections.d.ts.map +1 -1
  24. package/dist/src/connections.js +6 -2
  25. package/dist/src/connections.js.map +1 -1
  26. package/dist/src/console/apps.d.ts +13 -0
  27. package/dist/src/console/apps.d.ts.map +1 -1
  28. package/dist/src/console/apps.js +3 -0
  29. package/dist/src/console/apps.js.map +1 -1
  30. package/dist/src/console/connections.d.ts +71 -11
  31. package/dist/src/console/connections.d.ts.map +1 -1
  32. package/dist/src/console/connections.js +27 -6
  33. package/dist/src/console/connections.js.map +1 -1
  34. package/dist/src/console/credentials.d.ts +183 -0
  35. package/dist/src/console/credentials.d.ts.map +1 -0
  36. package/dist/src/console/credentials.js +186 -0
  37. package/dist/src/console/credentials.js.map +1 -0
  38. package/dist/src/console/mod.d.ts +17 -2
  39. package/dist/src/console/mod.d.ts.map +1 -1
  40. package/dist/src/console/mod.js +15 -0
  41. package/dist/src/console/mod.js.map +1 -1
  42. package/dist/src/console/models.d.ts +208 -0
  43. package/dist/src/console/models.d.ts.map +1 -0
  44. package/dist/src/console/models.js +186 -0
  45. package/dist/src/console/models.js.map +1 -0
  46. package/dist/src/console/storage.d.ts +221 -0
  47. package/dist/src/console/storage.d.ts.map +1 -0
  48. package/dist/src/console/storage.js +198 -0
  49. package/dist/src/console/storage.js.map +1 -0
  50. package/dist/src/console/tokens.d.ts +53 -3
  51. package/dist/src/console/tokens.d.ts.map +1 -1
  52. package/dist/src/console/tokens.js +35 -4
  53. package/dist/src/console/tokens.js.map +1 -1
  54. package/dist/src/console/vault.d.ts +2 -2
  55. package/dist/src/console/vault.d.ts.map +1 -1
  56. package/dist/src/console/vault.js +1 -1
  57. package/dist/src/context.d.ts +68 -0
  58. package/dist/src/context.d.ts.map +1 -0
  59. package/dist/src/context.js +195 -0
  60. package/dist/src/context.js.map +1 -0
  61. package/dist/src/errors.d.ts +2 -2
  62. package/dist/src/errors.js +2 -2
  63. package/dist/src/http.d.ts +19 -1
  64. package/dist/src/http.d.ts.map +1 -1
  65. package/dist/src/http.js +21 -3
  66. package/dist/src/http.js.map +1 -1
  67. package/dist/src/models.d.ts +141 -0
  68. package/dist/src/models.d.ts.map +1 -0
  69. package/dist/src/models.js +128 -0
  70. package/dist/src/models.js.map +1 -0
  71. package/dist/src/server/mod.d.ts +11 -10
  72. package/dist/src/server/mod.d.ts.map +1 -1
  73. package/dist/src/server/mod.js +11 -9
  74. package/dist/src/server/mod.js.map +1 -1
  75. package/dist/src/skills.d.ts +29 -0
  76. package/dist/src/skills.d.ts.map +1 -0
  77. package/dist/src/skills.js +55 -0
  78. package/dist/src/skills.js.map +1 -0
  79. package/dist/src/types.d.ts +415 -8
  80. package/dist/src/types.d.ts.map +1 -1
  81. package/dist/src/types.js +1 -1
  82. package/dist/src/types.js.map +1 -1
  83. package/dist/src/vars.d.ts +2 -2
  84. package/dist/src/vars.d.ts.map +1 -1
  85. package/dist/src/vars.js +1 -1
  86. package/dist/src/version.js +1 -1
  87. package/dist/src/workflows.d.ts +6 -6
  88. package/dist/src/workflows.d.ts.map +1 -1
  89. package/dist/src/workflows.js +7 -5
  90. package/dist/src/workflows.js.map +1 -1
  91. package/package.json +1 -1
@@ -0,0 +1,198 @@
1
+ /**
2
+ * `client.console.storage.*` — the account's storage bindings and agent-limit
3
+ * settings: the managed-store destination an account uploads to, and the caps
4
+ * (§P4: `max_file_bytes`, `max_package_bytes`, `max_files`, `retentionDays`)
5
+ * that apply to those uploads.
6
+ *
7
+ * **Studio-internal, not the published partner contract.** Both routes are
8
+ * account-admin surfaces (a member's write answers `403 forbidden`; another
9
+ * account's id is the uniform `404`) and live under the `console` subpath
10
+ * export only — deliberately absent from `endpoints.json` and from the root
11
+ * barrel, exactly like `console.models`' catalog edits (P-D5's console-only
12
+ * rule).
13
+ *
14
+ * **Nothing here carries a destination or a credential.** T4.1.1's wire shape
15
+ * is an allowlist: a binding never returns its bucket, region, endpoint, root
16
+ * prefix, credential or a revision's `config`, and settings never return a
17
+ * storage path — only the numeric limits and a binding *id*. The types below
18
+ * model that allowlist, not the row, so there is no field for a caller to be
19
+ * tempted by.
20
+ *
21
+ * **The account is never a parameter.** Both services resolve the account from
22
+ * the caller's own credential (the account scope on the bearer) plus a
23
+ * server-side admin check, never from an id this client sends — the same rule
24
+ * `console.tenantLoginFlags` and `console.tenantOAuthApps` follow.
25
+ *
26
+ * @module
27
+ */
28
+ import { ApiError } from "../errors.js";
29
+ import { path } from "../http.js";
30
+ import { unwrap } from "../types.js";
31
+ /**
32
+ * A binding is answered FLAT (`c.json(bindingJson(view))`), not inside an
33
+ * envelope. Accept that, and refuse a body that is not one.
34
+ */
35
+ function bindingBody(res) {
36
+ const body = res.body;
37
+ if (typeof body === "object" && body !== null && !Array.isArray(body) &&
38
+ typeof body.id === "string") {
39
+ return body;
40
+ }
41
+ throw new ApiError(res.status, "bad_response", `Server returned a ${res.status} without a binding object in the response body.`, body);
42
+ }
43
+ /** The same allowlist for settings, whose only required key is the effective `limits`. */
44
+ function settingsBody(res) {
45
+ const body = res.body;
46
+ if (typeof body === "object" && body !== null && !Array.isArray(body) &&
47
+ typeof body.limits === "object") {
48
+ return body;
49
+ }
50
+ throw new ApiError(res.status, "bad_response", `Server returned a ${res.status} without a settings object in the response body.`, body);
51
+ }
52
+ /**
53
+ * `client.console.storage.bindings.*` — `GET|POST /storage-bindings`,
54
+ * `GET|DELETE /storage-bindings/:id`, `POST /storage-bindings/:id/migrate`.
55
+ *
56
+ * Reads are open to account members; `create`, `delete` and `migrate` need an
57
+ * account admin (`403 forbidden` otherwise).
58
+ */
59
+ export class StorageBindingsApi {
60
+ #host;
61
+ /** @param host - The client this namespace issues requests through. */
62
+ constructor(host) {
63
+ this.#host = host;
64
+ }
65
+ /** `GET /storage-bindings` — the account's bindings, retired ones elided unless asked for. */
66
+ async list(options) {
67
+ const res = await this.#host.request({
68
+ method: "GET",
69
+ path: "/storage-bindings",
70
+ query: { includeRetired: options?.includeRetired },
71
+ signal: options?.signal,
72
+ });
73
+ return unwrap(res, "bindings");
74
+ }
75
+ /**
76
+ * `POST /storage-bindings` — store a destination (`201`, the binding answered flat).
77
+ *
78
+ * @throws {ApiError} `403 forbidden` (not an account admin), `422` for a refused
79
+ * destination (a non-empty `rootPrefix`, an unreachable endpoint).
80
+ */
81
+ async create(input, options) {
82
+ const res = await this.#host.request({
83
+ method: "POST",
84
+ path: "/storage-bindings",
85
+ body: input,
86
+ signal: options?.signal,
87
+ });
88
+ return bindingBody(res);
89
+ }
90
+ /**
91
+ * `GET /storage-bindings/:id` — one binding.
92
+ *
93
+ * @throws {ApiError} `404 not_found` — uniform, so another account's id is
94
+ * indistinguishable from a nonexistent one.
95
+ */
96
+ async get(id, options) {
97
+ const res = await this.#host.request({
98
+ method: "GET",
99
+ path: path `/storage-bindings/${id}`,
100
+ signal: options?.signal,
101
+ });
102
+ return bindingBody(res);
103
+ }
104
+ /**
105
+ * `DELETE /storage-bindings/:id` — retire a binding. Resolves to nothing.
106
+ *
107
+ * Retire, not erase: the row stays readable (with `includeRetired`) so
108
+ * versions that live on it keep their provenance.
109
+ *
110
+ * @throws {ApiError} `409` while asset versions still sit under the binding
111
+ * (`connection_in_use`-shaped refusal), `403 forbidden`, `404 not_found`.
112
+ */
113
+ async delete(id, options) {
114
+ await this.#host.request({
115
+ method: "DELETE",
116
+ path: path `/storage-bindings/${id}`,
117
+ signal: options?.signal,
118
+ });
119
+ }
120
+ /**
121
+ * `POST /storage-bindings/:id/migrate` — enqueue copy → verify → swap onto a
122
+ * new revision (`202`).
123
+ *
124
+ * The migration is asynchronous: the answer counts the jobs, and the caller
125
+ * polls the binding (`get`) or the version it moves.
126
+ *
127
+ * @throws {ApiError} `403 forbidden`, `404 not_found`, `409` when a migration
128
+ * is already running.
129
+ */
130
+ async migrate(id, options) {
131
+ const res = await this.#host.request({
132
+ method: "POST",
133
+ path: path `/storage-bindings/${id}/migrate`,
134
+ signal: options?.signal,
135
+ });
136
+ return res.body;
137
+ }
138
+ }
139
+ /**
140
+ * `client.console.storage.settings.*` — `GET|PATCH /agent-settings`.
141
+ *
142
+ * Account-scoped (§P4/A-D4): members may read, only an account admin may patch.
143
+ */
144
+ export class AgentSettingsApi {
145
+ #host;
146
+ /** @param host - The client this namespace issues requests through. */
147
+ constructor(host) {
148
+ this.#host = host;
149
+ }
150
+ /** `GET /agent-settings` — the effective limits and the stored values behind them. */
151
+ async get(options) {
152
+ const res = await this.#host.request({
153
+ method: "GET",
154
+ path: "/agent-settings",
155
+ signal: options?.signal,
156
+ });
157
+ return settingsBody(res);
158
+ }
159
+ /**
160
+ * `PATCH /agent-settings` — change the stored values. Fields are sent by
161
+ * omission; `null` clears one back to the default.
162
+ *
163
+ * @throws {ApiError} `403 forbidden` (not an account admin), `422` for an
164
+ * unknown field, a non-positive value or one above the server ceiling, and
165
+ * the uniform `404` for an unknown `storageBindingId`.
166
+ */
167
+ async patch(input, options) {
168
+ const res = await this.#host.request({
169
+ method: "PATCH",
170
+ path: "/agent-settings",
171
+ body: input,
172
+ signal: options?.signal,
173
+ });
174
+ return settingsBody(res);
175
+ }
176
+ }
177
+ /**
178
+ * The `console.storage` namespace on a `W6WClient` — bindings and the agent
179
+ * limits they bound.
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * const [binding] = await client.console.storage.bindings.list();
184
+ * await client.console.storage.settings.patch({ maxFileBytes: 10 * 1024 * 1024 });
185
+ * ```
186
+ */
187
+ export class StorageConsoleApi {
188
+ /** `console.storage.bindings.*`. */
189
+ bindings;
190
+ /** `console.storage.settings.*`. */
191
+ settings;
192
+ /** @param host - The client this namespace group issues requests through. */
193
+ constructor(host) {
194
+ this.bindings = new StorageBindingsApi(host);
195
+ this.settings = new AgentSettingsApi(host);
196
+ }
197
+ }
198
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/console/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAqB,IAAI,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAsHrC;;;GAGG;AACH,SAAS,WAAW,CAAC,GAA0B;IAC7C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACtB,IACE,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACjE,OAAQ,IAAgC,CAAC,EAAE,KAAK,QAAQ,EACxD,CAAC;QACD,OAAO,IAAsB,CAAC;IAChC,CAAC;IACD,MAAM,IAAI,QAAQ,CAChB,GAAG,CAAC,MAAM,EACV,cAAc,EACd,qBAAqB,GAAG,CAAC,MAAM,iDAAiD,EAChF,IAAI,CACL,CAAC;AACJ,CAAC;AAED,0FAA0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,MAAM;SACxB,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,CAAC,KAAyB,EAAE,OAA+B;QACpE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAiB;IAC5B,oCAAoC;IAC3B,QAAQ,CAAqB;IACtC,oCAAoC;IAC3B,QAAQ,CAAmB;IAEpC,6EAA6E;IAC7E,YAAY,IAAwB;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -74,6 +74,41 @@ export interface ApiToken {
74
74
  revokedAt: string | null;
75
75
  /** ISO-8601 timestamp of the token's last authenticated use, or `null` while unused. Optional: absent on a server build that predates this field. */
76
76
  lastUsedAt?: string | null;
77
+ /** What the token may do, or `null` for legacy full access (every token created without scopes). */
78
+ scopes: TokenScopes | null;
79
+ /** The IP allow-list in canonical `addr/prefix` form. `[]` means any IP. */
80
+ allowedIps: string[];
81
+ }
82
+ /**
83
+ * A token's scopes (wire version 1). `null` on {@linkcode ApiToken.scopes} means
84
+ * legacy full access. Reads are always allowed; the server rejects any other
85
+ * shape with `400 invalid_scopes`.
86
+ */
87
+ export interface TokenScopes {
88
+ /** Always `1`. */
89
+ v: 1;
90
+ /** Which callables the token may invoke: all, none, or an explicit list of `fn_`/`ep_`/`wf_` ids (1..100). */
91
+ invoke: "all" | "none" | {
92
+ callables: string[];
93
+ };
94
+ /** Which kinds of definition the token may manage. */
95
+ manage: {
96
+ functions: boolean;
97
+ endpoints: boolean;
98
+ workflows: boolean;
99
+ };
100
+ }
101
+ /** Options for {@linkcode TokensApi.create}. */
102
+ export interface CreateTokenOptions {
103
+ /** Caller-chosen label. */
104
+ name: string;
105
+ /** Scopes; omit for full access. */
106
+ scopes?: TokenScopes;
107
+ /**
108
+ * IP allow-list. A string (comma/whitespace separated) or an array, sent
109
+ * exactly as given — the server parses and canonicalizes it. Omit for any IP.
110
+ */
111
+ allowedIps?: string | string[];
77
112
  }
78
113
  /**
79
114
  * `create`'s result — the token's metadata plus its plaintext secret, shown
@@ -127,11 +162,26 @@ export declare class TokensApi {
127
162
  * established "no envelope key" pattern. `unwrap()` is deliberately not
128
163
  * called here: there is no single key to unwrap.
129
164
  *
130
- * @param name - Caller-chosen label.
165
+ * @param nameOrOptions - A label, or `{name, scopes?, allowedIps?}`. The string
166
+ * form sends exactly `{name}`; undefined options are omitted from the body.
131
167
  * @returns The created token's metadata plus its one-time plaintext secret.
132
- * @throws {ApiError} `400 invalid_name`.
168
+ * @throws {ApiError} `400 invalid_name`/`invalid_scopes`/`invalid_allowed_ips`.
169
+ */
170
+ create(nameOrOptions: string | CreateTokenOptions): Promise<CreateTokenResponse>;
171
+ /**
172
+ * Rotate a token: mint a new secret for it. **The old secret stops working
173
+ * at once.** **Returns the new plaintext secret exactly once** — like
174
+ * {@linkcode create}, there is no reveal-later route, so a caller that does
175
+ * not capture it here has permanently lost it.
176
+ *
177
+ * No envelope key to peel — the whole body IS `{token, secret}`, so this
178
+ * returns `res.body` as `create` does, not via `unwrap()`.
179
+ *
180
+ * @param id - The token id.
181
+ * @returns The token's metadata plus its new one-time plaintext secret.
182
+ * @throws {ApiError} `404 unknown_token`/`unknown_account`.
133
183
  */
134
- create(name: string): Promise<CreateTokenResponse>;
184
+ rotate(id: string): Promise<CreateTokenResponse>;
135
185
  /**
136
186
  * Disable a token. Reversible — see {@linkcode enable}.
137
187
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/console/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAG1E;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED,yFAAyF;AACzF,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,MAAM,EAAE,cAAc,CAAC;IACvB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,qJAAqJ;IACrJ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,KAAK,EAAE,QAAQ,CAAC;IAChB,uFAAuF;IACvF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,SAAS;;IAGpB;;OAEG;gBACS,IAAI,EAAE,UAAU;IAI5B;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAKj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C,QAAQ,CAAC;IAS5C;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAS3C;;;;;;OAMG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAQ5C"}
@@ -83,15 +83,46 @@ export class TokensApi {
83
83
  * established "no envelope key" pattern. `unwrap()` is deliberately not
84
84
  * called here: there is no single key to unwrap.
85
85
  *
86
- * @param name - Caller-chosen label.
86
+ * @param nameOrOptions - A label, or `{name, scopes?, allowedIps?}`. The string
87
+ * form sends exactly `{name}`; undefined options are omitted from the body.
87
88
  * @returns The created token's metadata plus its one-time plaintext secret.
88
- * @throws {ApiError} `400 invalid_name`.
89
+ * @throws {ApiError} `400 invalid_name`/`invalid_scopes`/`invalid_allowed_ips`.
89
90
  */
90
- async create(name) {
91
+ async create(nameOrOptions) {
92
+ const body = typeof nameOrOptions === "string"
93
+ ? { name: nameOrOptions }
94
+ : { name: nameOrOptions.name };
95
+ if (typeof nameOrOptions !== "string") {
96
+ if (nameOrOptions.scopes !== undefined)
97
+ body.scopes = nameOrOptions.scopes;
98
+ if (nameOrOptions.allowedIps !== undefined)
99
+ body.allowedIps = nameOrOptions.allowedIps;
100
+ }
91
101
  const res = await this.#host.request({
92
102
  method: "POST",
93
103
  path: "/tokens",
94
- body: { name },
104
+ body,
105
+ });
106
+ return res.body;
107
+ }
108
+ /**
109
+ * Rotate a token: mint a new secret for it. **The old secret stops working
110
+ * at once.** **Returns the new plaintext secret exactly once** — like
111
+ * {@linkcode create}, there is no reveal-later route, so a caller that does
112
+ * not capture it here has permanently lost it.
113
+ *
114
+ * No envelope key to peel — the whole body IS `{token, secret}`, so this
115
+ * returns `res.body` as `create` does, not via `unwrap()`.
116
+ *
117
+ * @param id - The token id.
118
+ * @returns The token's metadata plus its new one-time plaintext secret.
119
+ * @throws {ApiError} `404 unknown_token`/`unknown_account`.
120
+ */
121
+ async rotate(id) {
122
+ const res = await this.#host.request({
123
+ method: "POST",
124
+ path: path `/tokens/${id}/rotate`,
125
+ body: {},
95
126
  });
96
127
  return res.body;
97
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/console/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAqB,IAAI,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAwDrC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,SAAS;IACX,KAAK,CAAa;IAE3B;;OAEG;IACH,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAClF,OAAO,MAAM,CAAa,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB;YACxD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAA,WAAW,EAAE,UAAU;YACjC,IAAI,EAAE,EAAE;S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I,EAAE,EAAE;SACT,CAAC,CAAC;QACH,OAAO,MAAM,CAAW,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAA,WAAW,EAAE,SAAS;YAChC,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,OAAO,MAAM,CAAW,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAA,WAAW,EAAE,SAAS;YAChC,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,OAAO,MAAM,CAAW,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -58,7 +58,7 @@ export interface VaultHost {
58
58
  export interface VaultSecretSummary {
59
59
  /** Server-issued id, `sec_…`. */
60
60
  id: string;
61
- /** Caller-chosen name, matching `^[a-z_][a-z0-9_]*$`. */
61
+ /** Caller-chosen name, matching `^[A-Za-z_][A-Za-z0-9_]*$` (case-sensitive). */
62
62
  name: string;
63
63
  /** Free-text description; `""` when unset. */
64
64
  description: string;
@@ -128,7 +128,7 @@ export declare class VaultApi {
128
128
  * `value` is opaque — forwarded verbatim, never inspected, logged, or
129
129
  * transformed.
130
130
  *
131
- * @param body - `name` (unique, matches `^[a-z_][a-z0-9_]*$`), `value` (the
131
+ * @param body - `name` (unique, matches `^[A-Za-z_][A-Za-z0-9_]*$`), `value` (the
132
132
  * plaintext to store), and an optional `description`.
133
133
  * @returns The created secret, unwrapped from the `secret` envelope (the
134
134
  * server answers `201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;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ;;IAGnB;;OAEG;gBACS,IAAI,EAAE,SAAS;IAI3B;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAK3C;;;;;;;;;;;OAWG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAKlD;;;;;;;;;;;OAWG;IACG,MAAM,CACV,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1D,OAAO,CAAC,kBAAkB,CAAC;IAK9B;;;;;;;;;;OAUG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7C,OAAO,CAAC,kBAAkB,CAAC;IAS9B;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAQhD"}
@@ -92,7 +92,7 @@ export class VaultApi {
92
92
  * `value` is opaque — forwarded verbatim, never inspected, logged, or
93
93
  * transformed.
94
94
  *
95
- * @param body - `name` (unique, matches `^[a-z_][a-z0-9_]*$`), `value` (the
95
+ * @param body - `name` (unique, matches `^[A-Za-z_][A-Za-z0-9_]*$`), `value` (the
96
96
  * plaintext to store), and an optional `description`.
97
97
  * @returns The created secret, unwrapped from the `secret` envelope (the
98
98
  * server answers `201`). Never carries `value`.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * `client.context.*` — context collections and their text entries (contract 0.11.0).
3
+ *
4
+ * `entries.update` is a precondition write: it sends the body `revision` and,
5
+ * when given, the `x-w6w-if-unmodified-since` header. A missing header is a
6
+ * `428`, a stale one a `409` — both surface as {@linkcode ApiError}.
7
+ *
8
+ * @module
9
+ */
10
+ import { type CallOptions, type HttpResponse, type RequestOptions } from "./http.ts";
11
+ import { type ContextApi as ContextApiShape, type ContextCollection, type ContextEntry, type ContextEntryView, type CreateContextCollectionInput, type CreateContextEntryInput, type CreateStandaloneContextEntryInput, type ListArchivedOptions, type ListContextEntriesOptions, type ListPagedOptions, type PreconditionOptions, type UpdateContextCollectionInput, type UpdateContextEntryInput } from "./types.ts";
12
+ /** The slice of `W6WClient` this namespace needs: the transport and nothing else. */
13
+ export interface ContextHost {
14
+ /** Perform one request. */
15
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
16
+ }
17
+ /** The `client.context.entries.*` half. */
18
+ declare class CollectionEntriesApi {
19
+ #private;
20
+ constructor(host: ContextHost);
21
+ /** List a collection's entries. `id` is the collection id. */
22
+ list(id: string, opts?: ListArchivedOptions): Promise<ContextEntry[]>;
23
+ /** Add a text entry to a collection. */
24
+ create(id: string, input: CreateContextEntryInput, opts?: CallOptions): Promise<ContextEntryView>;
25
+ /** Replace an entry's text. Sends body `revision` and the precondition header when given. */
26
+ update(id: string, entryId: string, input: UpdateContextEntryInput, opts?: PreconditionOptions): Promise<ContextEntryView>;
27
+ }
28
+ /** `client.context` — see the module doc. */
29
+ export declare class ContextApi implements ContextApiShape {
30
+ #private;
31
+ /** Text entries of a collection. */
32
+ readonly entries: CollectionEntriesApi;
33
+ constructor(host: ContextHost);
34
+ /** List collections visible to the caller. */
35
+ list(opts?: ListPagedOptions): Promise<ContextCollection[]>;
36
+ /** Create an (empty) collection. */
37
+ create(input: CreateContextCollectionInput, opts?: CallOptions): Promise<ContextCollection>;
38
+ /** Fetch one collection. */
39
+ get(id: string, opts?: CallOptions): Promise<ContextCollection>;
40
+ /** Patch a collection's name, description or tags. */
41
+ update(id: string, patch: UpdateContextCollectionInput, opts?: CallOptions): Promise<ContextCollection>;
42
+ /** Archive a collection; returns the archived row. */
43
+ archive(id: string, opts?: CallOptions): Promise<ContextCollection>;
44
+ }
45
+ /**
46
+ * `client.contextEntries.*` — top-level, collection-independent context entries
47
+ * (contract 0.12.0). `update` is a precondition write like `context.entries.update`.
48
+ */
49
+ export declare class ContextEntriesApi {
50
+ #private;
51
+ constructor(host: ContextHost);
52
+ /** List entries visible to the caller; `collectionId` filters to one collection. */
53
+ list(opts?: ListContextEntriesOptions): Promise<ContextEntry[]>;
54
+ /** Create a text entry, optionally a member of `collectionIds`. */
55
+ create(input: CreateStandaloneContextEntryInput, opts?: CallOptions): Promise<ContextEntryView>;
56
+ /** Fetch one entry. */
57
+ get(id: string, opts?: CallOptions): Promise<ContextEntryView>;
58
+ /** Replace an entry's text. Sends body `revision` and the precondition header when given. */
59
+ update(id: string, input: UpdateContextEntryInput, opts?: PreconditionOptions): Promise<ContextEntryView>;
60
+ /** Archive an entry. */
61
+ archive(id: string, opts?: CallOptions): Promise<ContextEntry>;
62
+ /** Add an entry to a collection (idempotent). */
63
+ addToCollection(id: string, collectionId: string, opts?: CallOptions): Promise<ContextEntry>;
64
+ /** Remove an entry from a collection (idempotent). */
65
+ removeFromCollection(id: string, collectionId: string, opts?: CallOptions): Promise<ContextEntry>;
66
+ }
67
+ export {};
68
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EACL,KAAK,UAAU,IAAI,eAAe,EAClC,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,gBA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
3
+ *
4
+ * `entries.update` is a precondition write: it sends the body `revision` and,
5
+ * when given, the `x-w6w-if-unmodified-since` header. A missing header is a
6
+ * `428`, a stale one a `409` — both surface as {@linkcode ApiError}.
7
+ *
8
+ * @module
9
+ */
10
+ import { path } from "./http.js";
11
+ import { unwrap, } from "./types.js";
12
+ /** The precondition header (same name as the workflow and function arms). */
13
+ const PRECONDITION_HEADER = "x-w6w-if-unmodified-since";
14
+ /** The `client.context.entries.*` half. */
15
+ class CollectionEntriesApi {
16
+ #host;
17
+ constructor(host) {
18
+ this.#host = host;
19
+ }
20
+ /** List a collection's entries. `id` is the collection id. */
21
+ async list(id, opts) {
22
+ const res = await this.#host.request({
23
+ method: "GET",
24
+ path: path `/context-collections/${id}/entries`,
25
+ query: { includeArchived: opts?.includeArchived },
26
+ signal: opts?.signal,
27
+ });
28
+ return unwrap(res, "entries");
29
+ }
30
+ /** Add a text entry to a collection. */
31
+ async create(id, input, opts) {
32
+ const res = await this.#host.request({
33
+ method: "POST",
34
+ path: path `/context-collections/${id}/entries`,
35
+ body: input,
36
+ signal: opts?.signal,
37
+ });
38
+ return unwrap(res, "entry");
39
+ }
40
+ /** Replace an entry's text. Sends body `revision` and the precondition header when given. */
41
+ async update(id, entryId, input, opts) {
42
+ const res = await this.#host.request({
43
+ method: "PUT",
44
+ path: path `/context-collections/${id}/entries/${entryId}`,
45
+ body: input,
46
+ ...(opts?.ifUnmodifiedSince
47
+ ? { headers: { [PRECONDITION_HEADER]: opts.ifUnmodifiedSince } }
48
+ : {}),
49
+ signal: opts?.signal,
50
+ });
51
+ return unwrap(res, "entry");
52
+ }
53
+ }
54
+ /** `client.context` — see the module doc. */
55
+ export class ContextApi {
56
+ #host;
57
+ /** Text entries of a collection. */
58
+ entries;
59
+ constructor(host) {
60
+ this.#host = host;
61
+ this.entries = new CollectionEntriesApi(host);
62
+ }
63
+ /** List collections visible to the caller. */
64
+ async list(opts) {
65
+ const res = await this.#host.request({
66
+ method: "GET",
67
+ path: "/context-collections",
68
+ query: { includeArchived: opts?.includeArchived, limit: opts?.limit },
69
+ signal: opts?.signal,
70
+ });
71
+ return unwrap(res, "collections");
72
+ }
73
+ /** Create an (empty) collection. */
74
+ async create(input, opts) {
75
+ const res = await this.#host.request({
76
+ method: "POST",
77
+ path: "/context-collections",
78
+ body: input,
79
+ signal: opts?.signal,
80
+ });
81
+ return unwrap(res, "collection");
82
+ }
83
+ /** Fetch one collection. */
84
+ async get(id, opts) {
85
+ const res = await this.#host.request({
86
+ method: "GET",
87
+ path: path `/context-collections/${id}`,
88
+ signal: opts?.signal,
89
+ });
90
+ return unwrap(res, "collection");
91
+ }
92
+ /** Patch a collection's name, description or tags. */
93
+ async update(id, patch, opts) {
94
+ const res = await this.#host.request({
95
+ method: "PATCH",
96
+ path: path `/context-collections/${id}`,
97
+ body: patch,
98
+ signal: opts?.signal,
99
+ });
100
+ return unwrap(res, "collection");
101
+ }
102
+ /** Archive a collection; returns the archived row. */
103
+ async archive(id, opts) {
104
+ const res = await this.#host.request({
105
+ method: "POST",
106
+ path: path `/context-collections/${id}/archive`,
107
+ signal: opts?.signal,
108
+ });
109
+ return unwrap(res, "collection");
110
+ }
111
+ }
112
+ /**
113
+ * `client.contextEntries.*` — top-level, collection-independent context entries
114
+ * (contract 0.12.0). `update` is a precondition write like `context.entries.update`.
115
+ */
116
+ export class ContextEntriesApi {
117
+ #host;
118
+ constructor(host) {
119
+ this.#host = host;
120
+ }
121
+ /** List entries visible to the caller; `collectionId` filters to one collection. */
122
+ async list(opts) {
123
+ const res = await this.#host.request({
124
+ method: "GET",
125
+ path: "/context-entries",
126
+ query: {
127
+ collectionId: opts?.collectionId,
128
+ includeArchived: opts?.includeArchived,
129
+ project: opts?.project,
130
+ },
131
+ signal: opts?.signal,
132
+ });
133
+ return unwrap(res, "entries");
134
+ }
135
+ /** Create a text entry, optionally a member of `collectionIds`. */
136
+ async create(input, opts) {
137
+ const res = await this.#host.request({
138
+ method: "POST",
139
+ path: "/context-entries",
140
+ body: input,
141
+ signal: opts?.signal,
142
+ });
143
+ return unwrap(res, "entry");
144
+ }
145
+ /** Fetch one entry. */
146
+ async get(id, opts) {
147
+ const res = await this.#host.request({
148
+ method: "GET",
149
+ path: path `/context-entries/${id}`,
150
+ signal: opts?.signal,
151
+ });
152
+ return unwrap(res, "entry");
153
+ }
154
+ /** Replace an entry's text. Sends body `revision` and the precondition header when given. */
155
+ async update(id, input, opts) {
156
+ const res = await this.#host.request({
157
+ method: "PUT",
158
+ path: path `/context-entries/${id}`,
159
+ body: input,
160
+ ...(opts?.ifUnmodifiedSince
161
+ ? { headers: { [PRECONDITION_HEADER]: opts.ifUnmodifiedSince } }
162
+ : {}),
163
+ signal: opts?.signal,
164
+ });
165
+ return unwrap(res, "entry");
166
+ }
167
+ /** Archive an entry. */
168
+ async archive(id, opts) {
169
+ const res = await this.#host.request({
170
+ method: "POST",
171
+ path: path `/context-entries/${id}/archive`,
172
+ signal: opts?.signal,
173
+ });
174
+ return unwrap(res, "entry");
175
+ }
176
+ /** Add an entry to a collection (idempotent). */
177
+ async addToCollection(id, collectionId, opts) {
178
+ const res = await this.#host.request({
179
+ method: "PUT",
180
+ path: path `/context-entries/${id}/collections/${collectionId}`,
181
+ signal: opts?.signal,
182
+ });
183
+ return unwrap(res, "entry");
184
+ }
185
+ /** Remove an entry from a collection (idempotent). */
186
+ async removeFromCollection(id, collectionId, opts) {
187
+ const res = await this.#host.request({
188
+ method: "DELETE",
189
+ path: path `/context-entries/${id}/collections/${collectionId}`,
190
+ signal: opts?.signal,
191
+ });
192
+ return unwrap(res, "entry");
193
+ }
194
+ }
195
+ //# sourceMappingURL=context.js.map