@w6w/sdk 0.9.16 → 0.9.24
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.
- package/README.md +1 -1
- package/dist/mod.d.ts +11 -0
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +6 -0
- package/dist/mod.js.map +1 -1
- package/dist/src/agents.d.ts +33 -0
- package/dist/src/agents.d.ts.map +1 -0
- package/dist/src/agents.js +73 -0
- package/dist/src/agents.js.map +1 -0
- package/dist/src/assets.d.ts +56 -0
- package/dist/src/assets.d.ts.map +1 -0
- package/dist/src/assets.js +143 -0
- package/dist/src/assets.js.map +1 -0
- package/dist/src/client.d.ts +21 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +29 -0
- package/dist/src/client.js.map +1 -1
- package/dist/src/connections.d.ts +8 -3
- package/dist/src/connections.d.ts.map +1 -1
- package/dist/src/connections.js +6 -2
- package/dist/src/connections.js.map +1 -1
- package/dist/src/console/apps.d.ts +13 -0
- package/dist/src/console/apps.d.ts.map +1 -1
- package/dist/src/console/apps.js +3 -0
- package/dist/src/console/apps.js.map +1 -1
- package/dist/src/console/connections.d.ts +71 -11
- package/dist/src/console/connections.d.ts.map +1 -1
- package/dist/src/console/connections.js +27 -6
- package/dist/src/console/connections.js.map +1 -1
- package/dist/src/console/credentials.d.ts +183 -0
- package/dist/src/console/credentials.d.ts.map +1 -0
- package/dist/src/console/credentials.js +186 -0
- package/dist/src/console/credentials.js.map +1 -0
- package/dist/src/console/mod.d.ts +17 -2
- package/dist/src/console/mod.d.ts.map +1 -1
- package/dist/src/console/mod.js +15 -0
- package/dist/src/console/mod.js.map +1 -1
- package/dist/src/console/models.d.ts +208 -0
- package/dist/src/console/models.d.ts.map +1 -0
- package/dist/src/console/models.js +186 -0
- package/dist/src/console/models.js.map +1 -0
- package/dist/src/console/storage.d.ts +221 -0
- package/dist/src/console/storage.d.ts.map +1 -0
- package/dist/src/console/storage.js +198 -0
- package/dist/src/console/storage.js.map +1 -0
- package/dist/src/console/tokens.d.ts +53 -3
- package/dist/src/console/tokens.d.ts.map +1 -1
- package/dist/src/console/tokens.js +35 -4
- package/dist/src/console/tokens.js.map +1 -1
- package/dist/src/console/vault.d.ts +2 -2
- package/dist/src/console/vault.d.ts.map +1 -1
- package/dist/src/console/vault.js +1 -1
- package/dist/src/context.d.ts +68 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +195 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/http.d.ts +19 -1
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +21 -3
- package/dist/src/http.js.map +1 -1
- package/dist/src/models.d.ts +141 -0
- package/dist/src/models.d.ts.map +1 -0
- package/dist/src/models.js +128 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/skills.d.ts +29 -0
- package/dist/src/skills.d.ts.map +1 -0
- package/dist/src/skills.js +55 -0
- package/dist/src/skills.js.map +1 -0
- package/dist/src/types.d.ts +415 -8
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/vars.d.ts +2 -2
- package/dist/src/vars.d.ts.map +1 -1
- package/dist/src/vars.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/workflows.d.ts +6 -6
- package/dist/src/workflows.d.ts.map +1 -1
- package/dist/src/workflows.js +7 -5
- package/dist/src/workflows.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.models.*` — the model registry's console-only routes: catalog
|
|
3
|
+
* edits, rates, discovery, providers, budgets (CRUD + usage) and route writes.
|
|
4
|
+
*
|
|
5
|
+
* **Studio-internal, not the published partner contract.** The six stable
|
|
6
|
+
* operations (`models.list|get`, `modelRoutes.list|get|complete`,
|
|
7
|
+
* `modelUsage.query`) live on the root client (`../models.ts`,
|
|
8
|
+
* `endpoints.json`). This namespace lives under the `console` subpath export
|
|
9
|
+
* and is excluded from `endpoints.json` and the root barrel.
|
|
10
|
+
*
|
|
11
|
+
* **`complete` is deliberately NOT modeled here.** `client.modelRoutes.complete`
|
|
12
|
+
* already reaches it and returns the flat envelope as-is; a second method would
|
|
13
|
+
* give a caller two ways to the same route (the precedent of
|
|
14
|
+
* `console/aliases.ts`). Catalog writes and budget writes need a tenant admin.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { ApiError } from "../errors.js";
|
|
19
|
+
import { path } from "../http.js";
|
|
20
|
+
import { unwrap } from "../types.js";
|
|
21
|
+
/**
|
|
22
|
+
* The budget write routes answer the budget object FLAT (`c.json(created, 201)`),
|
|
23
|
+
* not under a `budget` key. Accept that, and refuse a body that is not one.
|
|
24
|
+
*/
|
|
25
|
+
function budgetBody(res) {
|
|
26
|
+
const body = res.body;
|
|
27
|
+
if (typeof body === "object" && body !== null && !Array.isArray(body) &&
|
|
28
|
+
typeof body.id === "string") {
|
|
29
|
+
return body;
|
|
30
|
+
}
|
|
31
|
+
throw new ApiError(res.status, "bad_response", `Server returned a ${res.status} without a budget object in the response body.`, body);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The `console.models` namespace on a `W6WClient`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* await client.console.models.discover("conn_1");
|
|
39
|
+
* await client.console.models.createRoute({ name: "chat", model: "mdl_1", connection: "conn_1" });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class ModelsConsoleApi {
|
|
43
|
+
#host;
|
|
44
|
+
/** @param host - The client this namespace issues requests through. */
|
|
45
|
+
constructor(host) {
|
|
46
|
+
this.#host = host;
|
|
47
|
+
}
|
|
48
|
+
/** `PATCH /models/:id` — edit a catalog entry (tenant admin). */
|
|
49
|
+
async updateModel(id, patch) {
|
|
50
|
+
const res = await this.#host.request({
|
|
51
|
+
method: "PATCH",
|
|
52
|
+
path: path `/models/${id}`,
|
|
53
|
+
body: patch,
|
|
54
|
+
});
|
|
55
|
+
return unwrap(res, "model");
|
|
56
|
+
}
|
|
57
|
+
/** `PUT /models/:id/rates` — store a rate card (tenant admin, `201`). */
|
|
58
|
+
async putRates(id, input) {
|
|
59
|
+
const res = await this.#host.request({
|
|
60
|
+
method: "PUT",
|
|
61
|
+
path: path `/models/${id}/rates`,
|
|
62
|
+
body: input,
|
|
63
|
+
});
|
|
64
|
+
return unwrap(res, "rate");
|
|
65
|
+
}
|
|
66
|
+
/** `POST /models/discover` — sync a connection's models into the catalog (tenant admin). */
|
|
67
|
+
async discover(connection) {
|
|
68
|
+
const res = await this.#host.request({
|
|
69
|
+
method: "POST",
|
|
70
|
+
path: "/models/discover",
|
|
71
|
+
body: { connection },
|
|
72
|
+
});
|
|
73
|
+
return res.body;
|
|
74
|
+
}
|
|
75
|
+
/** `GET /models/providers` — the providers the host maps. */
|
|
76
|
+
async providers() {
|
|
77
|
+
const res = await this.#host.request({ method: "GET", path: "/models/providers" });
|
|
78
|
+
return unwrap(res, "providers");
|
|
79
|
+
}
|
|
80
|
+
/** `GET /model-budgets` — the project's budgets. */
|
|
81
|
+
async listBudgets(options) {
|
|
82
|
+
const res = await this.#host.request({
|
|
83
|
+
method: "GET",
|
|
84
|
+
path: "/model-budgets",
|
|
85
|
+
query: { project: options?.project },
|
|
86
|
+
signal: options?.signal,
|
|
87
|
+
});
|
|
88
|
+
return unwrap(res, "budgets");
|
|
89
|
+
}
|
|
90
|
+
/** `POST /model-budgets` — create a budget (tenant admin, `201`). */
|
|
91
|
+
async createBudget(input, options) {
|
|
92
|
+
const res = await this.#host.request({
|
|
93
|
+
method: "POST",
|
|
94
|
+
path: "/model-budgets",
|
|
95
|
+
query: { project: options?.project },
|
|
96
|
+
body: input,
|
|
97
|
+
signal: options?.signal,
|
|
98
|
+
});
|
|
99
|
+
return budgetBody(res);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* `PATCH /model-budgets/:id` — edit a budget (tenant admin).
|
|
103
|
+
*
|
|
104
|
+
* The id resolves inside `?project=` (the default project when omitted), so a
|
|
105
|
+
* budget in another project needs `project` here, or the server answers 404.
|
|
106
|
+
*
|
|
107
|
+
* @throws {ApiError} `404 model_budget_not_found`.
|
|
108
|
+
*/
|
|
109
|
+
async updateBudget(id, patch, options) {
|
|
110
|
+
const res = await this.#host.request({
|
|
111
|
+
method: "PATCH",
|
|
112
|
+
path: path `/model-budgets/${id}`,
|
|
113
|
+
query: { project: options?.project },
|
|
114
|
+
body: patch,
|
|
115
|
+
signal: options?.signal,
|
|
116
|
+
});
|
|
117
|
+
return budgetBody(res);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* `DELETE /model-budgets/:id` — delete a budget (tenant admin). Resolves to nothing.
|
|
121
|
+
*
|
|
122
|
+
* @throws {ApiError} `404 model_budget_not_found` (pass `project` for a non-default project).
|
|
123
|
+
*/
|
|
124
|
+
async deleteBudget(id, options) {
|
|
125
|
+
await this.#host.request({
|
|
126
|
+
method: "DELETE",
|
|
127
|
+
path: path `/model-budgets/${id}`,
|
|
128
|
+
query: { project: options?.project },
|
|
129
|
+
signal: options?.signal,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `GET /model-budgets/:id/usage` — a budget's used/reserved counters.
|
|
134
|
+
*
|
|
135
|
+
* @throws {ApiError} `404 model_budget_not_found` (pass `project` for a non-default project).
|
|
136
|
+
*/
|
|
137
|
+
async budgetUsage(id, options) {
|
|
138
|
+
const res = await this.#host.request({
|
|
139
|
+
method: "GET",
|
|
140
|
+
path: path `/model-budgets/${id}/usage`,
|
|
141
|
+
query: { project: options?.project },
|
|
142
|
+
signal: options?.signal,
|
|
143
|
+
});
|
|
144
|
+
return res.body;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* `POST /model-routes` — create a route (`201`).
|
|
148
|
+
*
|
|
149
|
+
* @throws {ApiError} `409 model_route_exists`, `400 invalid_route_name`.
|
|
150
|
+
*/
|
|
151
|
+
async createRoute(input, options) {
|
|
152
|
+
const res = await this.#host.request({
|
|
153
|
+
method: "POST",
|
|
154
|
+
path: "/model-routes",
|
|
155
|
+
query: { project: options?.project },
|
|
156
|
+
body: input,
|
|
157
|
+
signal: options?.signal,
|
|
158
|
+
});
|
|
159
|
+
return unwrap(res, "route");
|
|
160
|
+
}
|
|
161
|
+
/** `PATCH /model-routes/:name` — edit a route. */
|
|
162
|
+
async updateRoute(name, patch, options) {
|
|
163
|
+
const res = await this.#host.request({
|
|
164
|
+
method: "PATCH",
|
|
165
|
+
path: path `/model-routes/${name}`,
|
|
166
|
+
query: { project: options?.project },
|
|
167
|
+
body: patch,
|
|
168
|
+
signal: options?.signal,
|
|
169
|
+
});
|
|
170
|
+
return unwrap(res, "route");
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* `DELETE /model-routes/:name` — delete a route. Resolves to nothing.
|
|
174
|
+
*
|
|
175
|
+
* @throws {ApiError} `404 model_route_not_found`.
|
|
176
|
+
*/
|
|
177
|
+
async deleteRoute(name, options) {
|
|
178
|
+
await this.#host.request({
|
|
179
|
+
method: "DELETE",
|
|
180
|
+
path: path `/model-routes/${name}`,
|
|
181
|
+
query: { project: options?.project },
|
|
182
|
+
signal: options?.signal,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/console/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAqB,IAAI,EAAuB,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgIrC;;;GAGG;AACH,SAAS,UAAU,CAAC,GAA0B;IAC5C,MAAM,IAAI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AO,EAAE;YACpC,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAa,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,WAAW,CACf,IAAY,EACZ,KAAsB,EACtB,OAA8B;QAE9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,IAAI,CAAA,iBAAiB,IAAI,EAAE;YACjC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;YACpC,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAa,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,OAA8B;QAC5D,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAChC,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,IAAI,CAAA,iBAAiB,IAAI,EAAE;YACjC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;YACpC,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,221 @@
|
|
|
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 { type HttpResponse, type RequestOptions } from "../http.ts";
|
|
29
|
+
/** The slice of `W6WClient` this namespace needs: the transport. */
|
|
30
|
+
export interface StorageConsoleHost {
|
|
31
|
+
/** Perform one request. */
|
|
32
|
+
request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
33
|
+
}
|
|
34
|
+
/** Per-call options for the reads. */
|
|
35
|
+
export interface StorageConsoleOptions {
|
|
36
|
+
/** Abort signal. */
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}
|
|
39
|
+
/** Options for `bindings.list`. */
|
|
40
|
+
export interface ListStorageBindingsOptions extends StorageConsoleOptions {
|
|
41
|
+
/** Include retired bindings (the server elides them by default). */
|
|
42
|
+
includeRetired?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** One binding's newest revision, as the wire exposes it: identity only, no destination. */
|
|
45
|
+
export interface StorageBindingRevisionRef {
|
|
46
|
+
id: string;
|
|
47
|
+
revision: number;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
}
|
|
50
|
+
/** The stored outcome of the last reachability probe: a code and a timestamp, never a free-form blob. */
|
|
51
|
+
export interface StorageBindingHealth {
|
|
52
|
+
ok?: boolean;
|
|
53
|
+
code?: string;
|
|
54
|
+
checkedAt?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A storage binding, as the server sends it.
|
|
58
|
+
*
|
|
59
|
+
* `serverDefault` marks the account using the server's own store; `status` is
|
|
60
|
+
* `active` until the binding is retired (`retiredAt` then carries the moment).
|
|
61
|
+
*/
|
|
62
|
+
export interface StorageBinding {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
/** Store kind — `s3` today. */
|
|
66
|
+
provider: string;
|
|
67
|
+
connectionId: string | null;
|
|
68
|
+
serverDefault: boolean;
|
|
69
|
+
status: string;
|
|
70
|
+
health: StorageBindingHealth;
|
|
71
|
+
activeRevisionId: string | null;
|
|
72
|
+
revision: StorageBindingRevisionRef | null;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
updatedAt: string;
|
|
75
|
+
retiredAt: string | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Body of `bindings.create`.
|
|
79
|
+
*
|
|
80
|
+
* The destination fields go **up** only: the caller supplies them once (they
|
|
81
|
+
* reach the service through the account's connection), and no read returns
|
|
82
|
+
* them. `rootPrefix` is refused when it is non-empty; the store's prefix is
|
|
83
|
+
* the server's to choose.
|
|
84
|
+
*/
|
|
85
|
+
export interface CreateStorageBindingInput {
|
|
86
|
+
name?: string;
|
|
87
|
+
connectionId: string;
|
|
88
|
+
bucket: string;
|
|
89
|
+
region: string;
|
|
90
|
+
endpoint?: string;
|
|
91
|
+
forcePathStyle?: boolean;
|
|
92
|
+
rootPrefix?: string;
|
|
93
|
+
}
|
|
94
|
+
/** What `bindings.migrate` accepted: the jobs it enqueued, not the jobs themselves. */
|
|
95
|
+
export interface StorageMigration {
|
|
96
|
+
bindingId: string;
|
|
97
|
+
toRevisionId: string;
|
|
98
|
+
/** How many copies the runner queued (`202 Accepted`). */
|
|
99
|
+
enqueued: number;
|
|
100
|
+
}
|
|
101
|
+
/** The effective caps: `account setting ⊓ server ceiling`, per field. */
|
|
102
|
+
export interface AgentLimits {
|
|
103
|
+
maxFileBytes: number;
|
|
104
|
+
maxPackageBytes: number;
|
|
105
|
+
maxFiles: number;
|
|
106
|
+
}
|
|
107
|
+
/** The account's own stored values; `null` means "not set — use the default". */
|
|
108
|
+
export interface AgentSettingsValues {
|
|
109
|
+
maxFileBytes: number | null;
|
|
110
|
+
maxPackageBytes: number | null;
|
|
111
|
+
maxFiles: number | null;
|
|
112
|
+
retentionDays: number | null;
|
|
113
|
+
storageBindingId: string | null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `GET`/`PATCH /agent-settings` — the effective limits, the stored values
|
|
117
|
+
* behind them, and when the row last changed (`null` until the first patch).
|
|
118
|
+
*/
|
|
119
|
+
export interface AgentSettings {
|
|
120
|
+
limits: AgentLimits;
|
|
121
|
+
settings: AgentSettingsValues;
|
|
122
|
+
updatedAt: string | null;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Body of `settings.patch` — an allowlist of the five settable fields, key by
|
|
126
|
+
* key. An omitted field is left alone; `null` clears it back to the default.
|
|
127
|
+
*
|
|
128
|
+
* The server validates it (unknown field, a non-positive or non-integer value,
|
|
129
|
+
* a value above the operator's ceiling ⇒ `422`; an unknown binding id ⇒ the
|
|
130
|
+
* uniform `404`), so nothing is pre-validated here.
|
|
131
|
+
*/
|
|
132
|
+
export type AgentSettingsPatch = Partial<AgentSettingsValues>;
|
|
133
|
+
/**
|
|
134
|
+
* `client.console.storage.bindings.*` — `GET|POST /storage-bindings`,
|
|
135
|
+
* `GET|DELETE /storage-bindings/:id`, `POST /storage-bindings/:id/migrate`.
|
|
136
|
+
*
|
|
137
|
+
* Reads are open to account members; `create`, `delete` and `migrate` need an
|
|
138
|
+
* account admin (`403 forbidden` otherwise).
|
|
139
|
+
*/
|
|
140
|
+
export declare class StorageBindingsApi {
|
|
141
|
+
#private;
|
|
142
|
+
/** @param host - The client this namespace issues requests through. */
|
|
143
|
+
constructor(host: StorageConsoleHost);
|
|
144
|
+
/** `GET /storage-bindings` — the account's bindings, retired ones elided unless asked for. */
|
|
145
|
+
list(options?: ListStorageBindingsOptions): Promise<StorageBinding[]>;
|
|
146
|
+
/**
|
|
147
|
+
* `POST /storage-bindings` — store a destination (`201`, the binding answered flat).
|
|
148
|
+
*
|
|
149
|
+
* @throws {ApiError} `403 forbidden` (not an account admin), `422` for a refused
|
|
150
|
+
* destination (a non-empty `rootPrefix`, an unreachable endpoint).
|
|
151
|
+
*/
|
|
152
|
+
create(input: CreateStorageBindingInput, options?: StorageConsoleOptions): Promise<StorageBinding>;
|
|
153
|
+
/**
|
|
154
|
+
* `GET /storage-bindings/:id` — one binding.
|
|
155
|
+
*
|
|
156
|
+
* @throws {ApiError} `404 not_found` — uniform, so another account's id is
|
|
157
|
+
* indistinguishable from a nonexistent one.
|
|
158
|
+
*/
|
|
159
|
+
get(id: string, options?: StorageConsoleOptions): Promise<StorageBinding>;
|
|
160
|
+
/**
|
|
161
|
+
* `DELETE /storage-bindings/:id` — retire a binding. Resolves to nothing.
|
|
162
|
+
*
|
|
163
|
+
* Retire, not erase: the row stays readable (with `includeRetired`) so
|
|
164
|
+
* versions that live on it keep their provenance.
|
|
165
|
+
*
|
|
166
|
+
* @throws {ApiError} `409` while asset versions still sit under the binding
|
|
167
|
+
* (`connection_in_use`-shaped refusal), `403 forbidden`, `404 not_found`.
|
|
168
|
+
*/
|
|
169
|
+
delete(id: string, options?: StorageConsoleOptions): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* `POST /storage-bindings/:id/migrate` — enqueue copy → verify → swap onto a
|
|
172
|
+
* new revision (`202`).
|
|
173
|
+
*
|
|
174
|
+
* The migration is asynchronous: the answer counts the jobs, and the caller
|
|
175
|
+
* polls the binding (`get`) or the version it moves.
|
|
176
|
+
*
|
|
177
|
+
* @throws {ApiError} `403 forbidden`, `404 not_found`, `409` when a migration
|
|
178
|
+
* is already running.
|
|
179
|
+
*/
|
|
180
|
+
migrate(id: string, options?: StorageConsoleOptions): Promise<StorageMigration>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* `client.console.storage.settings.*` — `GET|PATCH /agent-settings`.
|
|
184
|
+
*
|
|
185
|
+
* Account-scoped (§P4/A-D4): members may read, only an account admin may patch.
|
|
186
|
+
*/
|
|
187
|
+
export declare class AgentSettingsApi {
|
|
188
|
+
#private;
|
|
189
|
+
/** @param host - The client this namespace issues requests through. */
|
|
190
|
+
constructor(host: StorageConsoleHost);
|
|
191
|
+
/** `GET /agent-settings` — the effective limits and the stored values behind them. */
|
|
192
|
+
get(options?: StorageConsoleOptions): Promise<AgentSettings>;
|
|
193
|
+
/**
|
|
194
|
+
* `PATCH /agent-settings` — change the stored values. Fields are sent by
|
|
195
|
+
* omission; `null` clears one back to the default.
|
|
196
|
+
*
|
|
197
|
+
* @throws {ApiError} `403 forbidden` (not an account admin), `422` for an
|
|
198
|
+
* unknown field, a non-positive value or one above the server ceiling, and
|
|
199
|
+
* the uniform `404` for an unknown `storageBindingId`.
|
|
200
|
+
*/
|
|
201
|
+
patch(input: AgentSettingsPatch, options?: StorageConsoleOptions): Promise<AgentSettings>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The `console.storage` namespace on a `W6WClient` — bindings and the agent
|
|
205
|
+
* limits they bound.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const [binding] = await client.console.storage.bindings.list();
|
|
210
|
+
* await client.console.storage.settings.patch({ maxFileBytes: 10 * 1024 * 1024 });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export declare class StorageConsoleApi {
|
|
214
|
+
/** `console.storage.bindings.*`. */
|
|
215
|
+
readonly bindings: StorageBindingsApi;
|
|
216
|
+
/** `console.storage.settings.*`. */
|
|
217
|
+
readonly settings: AgentSettingsApi;
|
|
218
|
+
/** @param host - The client this namespace group issues requests through. */
|
|
219
|
+
constructor(host: StorageConsoleHost);
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/console/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAG1E,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB;IACpC,oBAAoB;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,mCAAmC;AACnC,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE,oEAAoE;IACpE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,4FAA4F;AAC5F,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,yGAAyG;AACzG,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CA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AAQ,EAAE,gBAAgB,CAAC;IAEpC,6EAA6E;gBACjE,IAAI,EAAE,kBAAkB;CAIrC"}
|
|
@@ -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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