@w6w/sdk 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/client.d.ts +33 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +34 -1
- package/dist/src/client.js.map +1 -1
- package/dist/src/console/api-calls.d.ts +80 -0
- package/dist/src/console/api-calls.d.ts.map +1 -0
- package/dist/src/console/api-calls.js +69 -0
- package/dist/src/console/api-calls.js.map +1 -0
- package/dist/src/console/apps.d.ts +689 -0
- package/dist/src/console/apps.d.ts.map +1 -0
- package/dist/src/console/apps.js +402 -0
- package/dist/src/console/apps.js.map +1 -0
- package/dist/src/console/auth.d.ts +241 -0
- package/dist/src/console/auth.d.ts.map +1 -0
- package/dist/src/console/auth.js +173 -0
- package/dist/src/console/auth.js.map +1 -0
- package/dist/src/console/connections.d.ts +188 -0
- package/dist/src/console/connections.d.ts.map +1 -0
- package/dist/src/console/connections.js +182 -0
- package/dist/src/console/connections.js.map +1 -0
- package/dist/src/console/dashboard.d.ts +102 -0
- package/dist/src/console/dashboard.d.ts.map +1 -0
- package/dist/src/console/dashboard.js +59 -0
- package/dist/src/console/dashboard.js.map +1 -0
- package/dist/src/console/endpoints.d.ts +264 -0
- package/dist/src/console/endpoints.d.ts.map +1 -0
- package/dist/src/console/endpoints.js +164 -0
- package/dist/src/console/endpoints.js.map +1 -0
- package/dist/src/console/functions.d.ts +165 -0
- package/dist/src/console/functions.d.ts.map +1 -0
- package/dist/src/console/functions.js +117 -0
- package/dist/src/console/functions.js.map +1 -0
- package/dist/src/console/mod.d.ts +131 -0
- package/dist/src/console/mod.d.ts.map +1 -0
- package/dist/src/console/mod.js +121 -0
- package/dist/src/console/mod.js.map +1 -0
- package/dist/src/console/projects.d.ts +107 -0
- package/dist/src/console/projects.d.ts.map +1 -0
- package/dist/src/console/projects.js +97 -0
- package/dist/src/console/projects.js.map +1 -0
- package/dist/src/console/reliability.d.ts +149 -0
- package/dist/src/console/reliability.d.ts.map +1 -0
- package/dist/src/console/reliability.js +56 -0
- package/dist/src/console/reliability.js.map +1 -0
- package/dist/src/console/saved-tests.d.ts +198 -0
- package/dist/src/console/saved-tests.d.ts.map +1 -0
- package/dist/src/console/saved-tests.js +172 -0
- package/dist/src/console/saved-tests.js.map +1 -0
- package/dist/src/console/schedules.d.ts +127 -0
- package/dist/src/console/schedules.d.ts.map +1 -0
- package/dist/src/console/schedules.js +118 -0
- package/dist/src/console/schedules.js.map +1 -0
- package/dist/src/console/step-tests.d.ts +159 -0
- package/dist/src/console/step-tests.d.ts.map +1 -0
- package/dist/src/console/step-tests.js +129 -0
- package/dist/src/console/step-tests.js.map +1 -0
- package/dist/src/console/subscriptions.d.ts +199 -0
- package/dist/src/console/subscriptions.d.ts.map +1 -0
- package/dist/src/console/subscriptions.js +191 -0
- package/dist/src/console/subscriptions.js.map +1 -0
- package/dist/src/console/tenant-oauth-apps.d.ts +188 -0
- package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -0
- package/dist/src/console/tenant-oauth-apps.js +152 -0
- package/dist/src/console/tenant-oauth-apps.js.map +1 -0
- package/dist/src/console/tokens.d.ts +159 -0
- package/dist/src/console/tokens.d.ts.map +1 -0
- package/dist/src/console/tokens.js +145 -0
- package/dist/src/console/tokens.js.map +1 -0
- package/dist/src/console/vault.d.ts +188 -0
- package/dist/src/console/vault.d.ts.map +1 -0
- package/dist/src/console/vault.js +164 -0
- package/dist/src/console/vault.js.map +1 -0
- package/dist/src/console/workflows.d.ts +243 -0
- package/dist/src/console/workflows.d.ts.map +1 -0
- package/dist/src/console/workflows.js +205 -0
- package/dist/src/console/workflows.js.map +1 -0
- package/dist/src/http.d.ts +32 -2
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +11 -2
- package/dist/src/http.js.map +1 -1
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/workflows.d.ts +11 -4
- package/dist/src/workflows.d.ts.map +1 -1
- package/dist/src/workflows.js +3 -3
- package/dist/src/workflows.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/console/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED,qFAAqF;AACrF,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;4FAC4F;AAC5F,MAAM,WAAW,WAAW;IAC1B,KAAK,EAA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W,GAAG,OAAO,CAAC,cAAc,CAAC;IAUzD;;;;;;;;;;;OAWG;IACG,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAUvE;;;;;;;;;;;;OAYG;IACG,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAS/E;;;;;;;;;;;;;;;;OAgBG;IACG,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;CAOlC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.auth.*` — self-serve login and signup, relocated from the
|
|
3
|
+
* studio's own API client.
|
|
4
|
+
*
|
|
5
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
6
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded from
|
|
7
|
+
* `endpoints.json` and from the root barrel (`mod.ts`) — see `docs/console.md`
|
|
8
|
+
* and HITL-1 in this task's contract. `@w6w/sdk`'s instance-state mechanism
|
|
9
|
+
* pin still applies here exactly as it does to every other namespace
|
|
10
|
+
* (`docs/implementation.md` §MECHANISM PIN — instance state, never globals):
|
|
11
|
+
* this class holds no state of its own beyond the injected host, so two
|
|
12
|
+
* clients in one process never share a credential.
|
|
13
|
+
*
|
|
14
|
+
* **The public/authenticated split is per-method, not per-file.** `login`,
|
|
15
|
+
* `signup` and `checkAccountSlug` are registered server-side ABOVE
|
|
16
|
+
* `app.use("*", authGuard)` (`packages/server/packages/api/data/signup.ts:23-41`
|
|
17
|
+
* and `id/auth.ts:22-55`) and must never read a principal — any bearer a
|
|
18
|
+
* caller sends is inert on these three routes, so each passes
|
|
19
|
+
* `requireAuth: false` and the transport never even attempts to attach one
|
|
20
|
+
* (`../http.ts`, HITL-9). `createAccount` is the authenticated counterpart
|
|
21
|
+
* (`id/signup.ts:33-78`) and uses the default, unconditional `requireAuth`.
|
|
22
|
+
* `login` is how a caller gets a token in the first place — without
|
|
23
|
+
* `requireAuth: false` it could never be called by a tokenless client, since
|
|
24
|
+
* `requireToken` would raise before the request ever reached `fetch`.
|
|
25
|
+
*
|
|
26
|
+
* **`getMe` IS modeled here now — that changed, and this is why.** This file
|
|
27
|
+
* previously said it was deliberately not modeled, because `client.me()`
|
|
28
|
+
* (`../me.ts`, base surface) covered `GET /auth/me` exactly. It no longer does.
|
|
29
|
+
* The route answers additively with a **studio-internal capability field**,
|
|
30
|
+
* `tenantAdmin` (`plan-B.md` § WIRE PINS W1/W9), and the published `Me`
|
|
31
|
+
* (`../types.ts:104-123`) deliberately does not carry it: `Me` is part of the
|
|
32
|
+
* published partner contract — `endpoints.json` names it as the `me`
|
|
33
|
+
* operation's `returns` — so declaring a field there would be a
|
|
34
|
+
* publish-in-lockstep change across every language wrapper (CLAUDE.md), for
|
|
35
|
+
* what is a studio-only authorization hint. The console surface is exactly the
|
|
36
|
+
* place a studio-only projection belongs, so the capability is typed on
|
|
37
|
+
* {@linkcode ConsoleMe} instead, and `client.me()` stays untouched and keeps
|
|
38
|
+
* returning the published shape. Both read the same route; they differ only in
|
|
39
|
+
* what they promise about the body.
|
|
40
|
+
*
|
|
41
|
+
* **Response shapes are flat, no envelope key**, mirroring
|
|
42
|
+
* `console/reliability.ts`'s own pattern (verified against the server route
|
|
43
|
+
* handlers, not assumed) — every method here returns `res.body` directly and
|
|
44
|
+
* never calls this package's `unwrap()` helper.
|
|
45
|
+
*
|
|
46
|
+
* @module
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* The `console.auth` namespace on a `W6wClient`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const { token } = await client.console.auth.login("user", "pass");
|
|
54
|
+
* const me = await client.console.auth.getMe();
|
|
55
|
+
* if (me.tenantAdmin) { // tenant-admin surface
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export class AuthApi {
|
|
60
|
+
#host;
|
|
61
|
+
/**
|
|
62
|
+
* @param host - The client this namespace issues requests through.
|
|
63
|
+
*/
|
|
64
|
+
constructor(host) {
|
|
65
|
+
this.#host = host;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Authenticate with the configured credential and mint a session token.
|
|
69
|
+
*
|
|
70
|
+
* PUBLIC — sends no bearer, even on a client that already holds one
|
|
71
|
+
* (`requireAuth: false`).
|
|
72
|
+
*
|
|
73
|
+
* @param username - The account username.
|
|
74
|
+
* @param password - The account password.
|
|
75
|
+
* @returns The token, the caller's identity, and the token's lifetime.
|
|
76
|
+
* @throws {ApiError} On any non-2xx, e.g. `401` for invalid credentials.
|
|
77
|
+
*/
|
|
78
|
+
async login(username, password) {
|
|
79
|
+
const res = await this.#host.request({
|
|
80
|
+
method: "POST",
|
|
81
|
+
path: "/auth/login",
|
|
82
|
+
body: { username, password },
|
|
83
|
+
requireAuth: false,
|
|
84
|
+
});
|
|
85
|
+
return res.body;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Self-serve signup: creates the user and mints a `role: "user"` session.
|
|
89
|
+
*
|
|
90
|
+
* PUBLIC — sends no bearer, even on a client that already holds one
|
|
91
|
+
* (`requireAuth: false`).
|
|
92
|
+
*
|
|
93
|
+
* @param input - Email, password, and the optional displayName/inviteToken.
|
|
94
|
+
* @returns The token, its lifetime, the created user, and the invite's account (else `null`).
|
|
95
|
+
* @throws {ApiError} On any non-2xx, e.g. `409` when the email is taken.
|
|
96
|
+
*/
|
|
97
|
+
async signup(input) {
|
|
98
|
+
const res = await this.#host.request({
|
|
99
|
+
method: "POST",
|
|
100
|
+
path: "/auth/signup",
|
|
101
|
+
body: input,
|
|
102
|
+
requireAuth: false,
|
|
103
|
+
});
|
|
104
|
+
return res.body;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check whether an account slug is free, and get free alternatives if not.
|
|
108
|
+
*
|
|
109
|
+
* PUBLIC — sends no bearer, even on a client that already holds one
|
|
110
|
+
* (`requireAuth: false`). Advisory only: the unique index decides at create
|
|
111
|
+
* time, so a `409` from `createAccount` is a normal outcome, not a
|
|
112
|
+
* contradiction of what this returned.
|
|
113
|
+
*
|
|
114
|
+
* @param name - The slug (or candidate name) to check.
|
|
115
|
+
* @returns The server's normalization of `name`, whether it is available, and up to five alternatives.
|
|
116
|
+
* @throws {ApiError} On any non-2xx.
|
|
117
|
+
*/
|
|
118
|
+
async checkAccountSlug(name) {
|
|
119
|
+
const res = await this.#host.request({
|
|
120
|
+
method: "GET",
|
|
121
|
+
path: "/auth/signup/slug-available",
|
|
122
|
+
query: { name },
|
|
123
|
+
requireAuth: false,
|
|
124
|
+
});
|
|
125
|
+
return res.body;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create an account for the caller and re-issue the session with its claim.
|
|
129
|
+
*
|
|
130
|
+
* AUTHENTICATED — the default `requireAuth` applies. NOTE the returned
|
|
131
|
+
* token is minted `role: "user"` unconditionally (`id/auth.ts:112`), so
|
|
132
|
+
* adopting it downgrades an operator; this method never writes the session
|
|
133
|
+
* itself, the caller decides.
|
|
134
|
+
*
|
|
135
|
+
* @param name - The account's display name.
|
|
136
|
+
* @param slug - The account's slug.
|
|
137
|
+
* @returns The created account, a re-issued token carrying its claim, and the token's lifetime.
|
|
138
|
+
* @throws {ApiError} On any non-2xx, e.g. `409` when the slug is taken.
|
|
139
|
+
*/
|
|
140
|
+
async createAccount(name, slug) {
|
|
141
|
+
const res = await this.#host.request({
|
|
142
|
+
method: "POST",
|
|
143
|
+
path: "/accounts",
|
|
144
|
+
body: { name, slug },
|
|
145
|
+
});
|
|
146
|
+
return res.body;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Read the caller's identity **and its tenant-admin capability**.
|
|
150
|
+
*
|
|
151
|
+
* AUTHENTICATED — the default `requireAuth` applies, unlike `login`,
|
|
152
|
+
* `signup` and `checkAccountSlug`. `/auth/me` reads the principal, so a
|
|
153
|
+
* request without a bearer is a `401`, and a tokenless client raises
|
|
154
|
+
* `ConfigError` before `fetch` is ever called.
|
|
155
|
+
*
|
|
156
|
+
* Same route as the base surface's `client.me()`; this one promises the
|
|
157
|
+
* console projection ({@linkcode ConsoleMe}) instead of the published `Me`.
|
|
158
|
+
* Unlike `client.me()` it does **not** fill in a `versions.wrapper` entry
|
|
159
|
+
* from this package's own `VERSION` (`../me.ts` does that): what this returns
|
|
160
|
+
* is the server's body, verbatim.
|
|
161
|
+
*
|
|
162
|
+
* @returns The caller's identity, plus `tenantAdmin`.
|
|
163
|
+
* @throws {ApiError} On any non-2xx, e.g. `401` when the bearer is missing or expired.
|
|
164
|
+
*/
|
|
165
|
+
async getMe() {
|
|
166
|
+
const res = await this.#host.request({
|
|
167
|
+
method: "GET",
|
|
168
|
+
path: "/auth/me",
|
|
169
|
+
});
|
|
170
|
+
return res.body;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/console/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAwHH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,OAAO;IACT,KAAK,CAAW;IAEzB;;OAEG;IACH,YAAY,IAAc;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,QAAgB;QAC5C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB;YAClD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;YAC5B,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC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connections (list-for-app, get, create, update, test, delete), relocated
|
|
4
|
+
* from the studio's own API client.
|
|
5
|
+
*
|
|
6
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
7
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded from
|
|
8
|
+
* `endpoints.json` and from the root barrel (`mod.ts`) — see `docs/console.md`
|
|
9
|
+
* and HITL-1 in this task's contract. `@w6w/sdk`'s instance-state mechanism
|
|
10
|
+
* pin still applies here exactly as it does to every other namespace
|
|
11
|
+
* (`docs/implementation.md` §MECHANISM PIN — instance state, never globals):
|
|
12
|
+
* this class holds no state of its own beyond the injected host, so two
|
|
13
|
+
* clients in one process never share a credential.
|
|
14
|
+
*
|
|
15
|
+
* **Console placement is a resolved HITL, not a default applied without
|
|
16
|
+
* thought — see `HITL-10` in `HITL.md` and `plan.md`'s SP2.3 section for the
|
|
17
|
+
* full investigation.** `endpoints.json`'s `outOfScope` entry for connections
|
|
18
|
+
* writes frames the eventual intent as a real partner operation, unlike
|
|
19
|
+
* `projects`/`schedules`/`apps`; the server routes this file wraps are plain,
|
|
20
|
+
* stateless handlers over an already-resolved payload for both real studio
|
|
21
|
+
* call sites, which makes console placement technically safe for studio's own
|
|
22
|
+
* use — it does not by itself justify promoting straight to the partner
|
|
23
|
+
* surface (cli/python lockstep; no partner-facing OAuth-flow counterpart
|
|
24
|
+
* exists yet either). Console placement is the pinned default here; partner
|
|
25
|
+
* promotion is deferred to a dedicated future project.
|
|
26
|
+
*
|
|
27
|
+
* **`listConnections` (base `client.connections.list()`,
|
|
28
|
+
* `../connections.ts:47-64`) is deliberately NOT relocated here** — it is the
|
|
29
|
+
* one method of the seven studio call sites that already has a home on the
|
|
30
|
+
* pre-existing BASE namespace; duplicating it under `console.connections`
|
|
31
|
+
* would give a caller two ways to reach the same route. See this task's
|
|
32
|
+
* contract Requirement.
|
|
33
|
+
*
|
|
34
|
+
* Six methods relocate from the studio's single `// Connections` comment block
|
|
35
|
+
* (`packages/studio/src/api/client.ts:252-298` on the studio base tree) —
|
|
36
|
+
* field-for-field, not redesigned.
|
|
37
|
+
*
|
|
38
|
+
* None of these methods take a `project` scoping parameter — connections carry
|
|
39
|
+
* no `?project=`, the server scopes by tenant/account from the credential
|
|
40
|
+
* alone — so `ConnectionsHost` needs only the transport, mirroring
|
|
41
|
+
* `VarsHost`/the base `ConnectionsHost`, not `DocumentsHost`.
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/
|
|
45
|
+
import { type HttpResponse, type RequestOptions } from "../http.ts";
|
|
46
|
+
import { type ConnectionSummary } from "../types.ts";
|
|
47
|
+
/**
|
|
48
|
+
* The slice of `W6wClient` this namespace needs: the transport, and nothing
|
|
49
|
+
* else. Structural rather than a concrete client type, so the namespace stays
|
|
50
|
+
* independently constructible in a test and this module never imports the
|
|
51
|
+
* client back — mirrors `VarsHost` in `../vars.ts`.
|
|
52
|
+
*/
|
|
53
|
+
export interface ConnectionsHost {
|
|
54
|
+
/** Perform one request. */
|
|
55
|
+
request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* `test`'s result — the whole response body, no envelope key
|
|
59
|
+
* (`packages/server/packages/api/admin/connections.ts:151-190`). Three
|
|
60
|
+
* possible 200-status shapes:
|
|
61
|
+
*
|
|
62
|
+
* - `{ok: true, untested: true, message}` — no safe probe action exists for
|
|
63
|
+
* this connection's app.
|
|
64
|
+
* - `{ok: true, actionKey}` — the probe action ran and passed.
|
|
65
|
+
* - `{ok: false, actionKey, error: {message}}` — the probe action ran and
|
|
66
|
+
* failed. **Still a 200** — a failed test is data, never a raised error,
|
|
67
|
+
* the same rule `client.run()`/`workflows.run()` already document for a
|
|
68
|
+
* failed run.
|
|
69
|
+
*
|
|
70
|
+
* Only a genuine non-2xx (e.g. `404 unknown_connection`) raises `ApiError`.
|
|
71
|
+
*/
|
|
72
|
+
export interface ConnectionTestResult {
|
|
73
|
+
ok: boolean;
|
|
74
|
+
actionKey?: string;
|
|
75
|
+
untested?: boolean;
|
|
76
|
+
message?: string;
|
|
77
|
+
error?: {
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The `console.connections` namespace on a `W6wClient`.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const conns = await client.console.connections.listForApp("sendgrid");
|
|
87
|
+
* const created = await client.console.connections.create("sendgrid", {
|
|
88
|
+
* authKey: "apiKey",
|
|
89
|
+
* credential: { key: "sk_live_…" },
|
|
90
|
+
* });
|
|
91
|
+
* const result = await client.console.connections.test(created.id);
|
|
92
|
+
* if (!result.ok) console.log(result.error?.message);
|
|
93
|
+
* await client.console.connections.delete(created.id);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare class ConnectionsApi {
|
|
97
|
+
#private;
|
|
98
|
+
/**
|
|
99
|
+
* @param host - The client this namespace issues requests through.
|
|
100
|
+
*/
|
|
101
|
+
constructor(host: ConnectionsHost);
|
|
102
|
+
/**
|
|
103
|
+
* List an app's connections.
|
|
104
|
+
*
|
|
105
|
+
* @param appId - The app id.
|
|
106
|
+
* @returns The connections, unwrapped from the `connections` envelope.
|
|
107
|
+
* @throws {ApiError} `404 unknown_app` when there is no such app.
|
|
108
|
+
*/
|
|
109
|
+
listForApp(appId: string): Promise<ConnectionSummary[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Fetch one connection.
|
|
112
|
+
*
|
|
113
|
+
* No 404 special-casing — propagates as `ApiError` like every other "get"
|
|
114
|
+
* in this package except `console.schedules.get`, which has its own
|
|
115
|
+
* documented, unrelated exception.
|
|
116
|
+
*
|
|
117
|
+
* @param id - The `conn_…` id.
|
|
118
|
+
* @returns The connection, unwrapped from the `connection` envelope.
|
|
119
|
+
* @throws {ApiError} `404 unknown_connection` when there is no such id.
|
|
120
|
+
*/
|
|
121
|
+
get(id: string): Promise<ConnectionSummary>;
|
|
122
|
+
/**
|
|
123
|
+
* Create a connection for an app.
|
|
124
|
+
*
|
|
125
|
+
* `credential` is opaque — forwarded verbatim, never inspected, logged, or
|
|
126
|
+
* transformed. This is a security-adjacent discipline, not a style note:
|
|
127
|
+
* the whole point of this field is a caller-opaque secret payload.
|
|
128
|
+
*
|
|
129
|
+
* @param appId - The app id.
|
|
130
|
+
* @param body - `authKey` selects the app's auth method; `credential` is
|
|
131
|
+
* the secret payload it needs; `displayName` and `profile` are optional.
|
|
132
|
+
* @returns The created connection, unwrapped from the `connection` envelope (the server answers `201`).
|
|
133
|
+
* @throws {ApiError} `400 invalid_auth_key`/`invalid_credential`; `404 unknown_app`.
|
|
134
|
+
*/
|
|
135
|
+
create(appId: string, body: {
|
|
136
|
+
authKey: string;
|
|
137
|
+
credential: Record<string, unknown>;
|
|
138
|
+
displayName?: string;
|
|
139
|
+
profile?: Record<string, unknown>;
|
|
140
|
+
}): Promise<ConnectionSummary>;
|
|
141
|
+
/**
|
|
142
|
+
* Update a connection: rename it and/or replace its credential.
|
|
143
|
+
*
|
|
144
|
+
* `credential` is opaque — forwarded verbatim, never inspected, logged, or
|
|
145
|
+
* transformed, same discipline as {@linkcode create}. The body is sent
|
|
146
|
+
* exactly as given; this method does not pre-validate it — the server also
|
|
147
|
+
* validates "nothing to update" and answers `400 invalid_body` itself.
|
|
148
|
+
*
|
|
149
|
+
* @param id - The `conn_…` id.
|
|
150
|
+
* @param body - `displayName` and/or `credential`, forwarded verbatim.
|
|
151
|
+
* @returns The updated connection, unwrapped from the `connection` envelope.
|
|
152
|
+
* @throws {ApiError} `400 invalid_body` ("Nothing to update"); `404 unknown_connection`.
|
|
153
|
+
*/
|
|
154
|
+
update(id: string, body: {
|
|
155
|
+
displayName?: string;
|
|
156
|
+
credential?: Record<string, unknown>;
|
|
157
|
+
}): Promise<ConnectionSummary>;
|
|
158
|
+
/**
|
|
159
|
+
* Probe a connection by running a safe read action of its app.
|
|
160
|
+
*
|
|
161
|
+
* **No envelope key — the whole body IS the result**, mirroring
|
|
162
|
+
* `console.reliability.list`'s pattern. A failed probe (`ok: false`) is
|
|
163
|
+
* still a `200` and resolves normally; this method never throws on it — the
|
|
164
|
+
* same rule `client.run()`/`workflows.run()` already document: a failed
|
|
165
|
+
* run (here, a failed test) is data. Only a genuine non-2xx (e.g.
|
|
166
|
+
* `404 unknown_connection`) raises `ApiError`. See {@linkcode ConnectionTestResult}.
|
|
167
|
+
*
|
|
168
|
+
* @param id - The `conn_…` id.
|
|
169
|
+
* @returns The whole response body — no envelope key to peel.
|
|
170
|
+
* @throws {ApiError} `404 unknown_connection` when there is no such id.
|
|
171
|
+
*/
|
|
172
|
+
test(id: string): Promise<ConnectionTestResult>;
|
|
173
|
+
/**
|
|
174
|
+
* Delete a connection.
|
|
175
|
+
*
|
|
176
|
+
* Returns nothing: the server's `{ok: true}` carries no information a
|
|
177
|
+
* caller can use, mirroring `console.projects.delete`/
|
|
178
|
+
* `console.schedules.delete` in this same package (NOT
|
|
179
|
+
* `console.apps.delete`, which is the one documented exception, preserving
|
|
180
|
+
* a genuinely informative `{removed: number}`) — connections delete has no
|
|
181
|
+
* such value to preserve.
|
|
182
|
+
*
|
|
183
|
+
* @param id - The `conn_…` id.
|
|
184
|
+
* @throws {ApiError} `404 unknown_connection` when there is no such id.
|
|
185
|
+
*/
|
|
186
|
+
delete(id: string): Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../../src/console/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,KAAK,iBAAiB,EAAU,MAAM,aAAa,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WA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,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQrD;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.connections.*` — the app-catalog write surface for
|
|
3
|
+
* connections (list-for-app, get, create, update, test, delete), relocated
|
|
4
|
+
* from the studio's own API client.
|
|
5
|
+
*
|
|
6
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
7
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded from
|
|
8
|
+
* `endpoints.json` and from the root barrel (`mod.ts`) — see `docs/console.md`
|
|
9
|
+
* and HITL-1 in this task's contract. `@w6w/sdk`'s instance-state mechanism
|
|
10
|
+
* pin still applies here exactly as it does to every other namespace
|
|
11
|
+
* (`docs/implementation.md` §MECHANISM PIN — instance state, never globals):
|
|
12
|
+
* this class holds no state of its own beyond the injected host, so two
|
|
13
|
+
* clients in one process never share a credential.
|
|
14
|
+
*
|
|
15
|
+
* **Console placement is a resolved HITL, not a default applied without
|
|
16
|
+
* thought — see `HITL-10` in `HITL.md` and `plan.md`'s SP2.3 section for the
|
|
17
|
+
* full investigation.** `endpoints.json`'s `outOfScope` entry for connections
|
|
18
|
+
* writes frames the eventual intent as a real partner operation, unlike
|
|
19
|
+
* `projects`/`schedules`/`apps`; the server routes this file wraps are plain,
|
|
20
|
+
* stateless handlers over an already-resolved payload for both real studio
|
|
21
|
+
* call sites, which makes console placement technically safe for studio's own
|
|
22
|
+
* use — it does not by itself justify promoting straight to the partner
|
|
23
|
+
* surface (cli/python lockstep; no partner-facing OAuth-flow counterpart
|
|
24
|
+
* exists yet either). Console placement is the pinned default here; partner
|
|
25
|
+
* promotion is deferred to a dedicated future project.
|
|
26
|
+
*
|
|
27
|
+
* **`listConnections` (base `client.connections.list()`,
|
|
28
|
+
* `../connections.ts:47-64`) is deliberately NOT relocated here** — it is the
|
|
29
|
+
* one method of the seven studio call sites that already has a home on the
|
|
30
|
+
* pre-existing BASE namespace; duplicating it under `console.connections`
|
|
31
|
+
* would give a caller two ways to reach the same route. See this task's
|
|
32
|
+
* contract Requirement.
|
|
33
|
+
*
|
|
34
|
+
* Six methods relocate from the studio's single `// Connections` comment block
|
|
35
|
+
* (`packages/studio/src/api/client.ts:252-298` on the studio base tree) —
|
|
36
|
+
* field-for-field, not redesigned.
|
|
37
|
+
*
|
|
38
|
+
* None of these methods take a `project` scoping parameter — connections carry
|
|
39
|
+
* no `?project=`, the server scopes by tenant/account from the credential
|
|
40
|
+
* alone — so `ConnectionsHost` needs only the transport, mirroring
|
|
41
|
+
* `VarsHost`/the base `ConnectionsHost`, not `DocumentsHost`.
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/
|
|
45
|
+
import { path } from "../http.js";
|
|
46
|
+
import { unwrap } from "../types.js";
|
|
47
|
+
/**
|
|
48
|
+
* The `console.connections` namespace on a `W6wClient`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const conns = await client.console.connections.listForApp("sendgrid");
|
|
53
|
+
* const created = await client.console.connections.create("sendgrid", {
|
|
54
|
+
* authKey: "apiKey",
|
|
55
|
+
* credential: { key: "sk_live_…" },
|
|
56
|
+
* });
|
|
57
|
+
* const result = await client.console.connections.test(created.id);
|
|
58
|
+
* if (!result.ok) console.log(result.error?.message);
|
|
59
|
+
* await client.console.connections.delete(created.id);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export class ConnectionsApi {
|
|
63
|
+
#host;
|
|
64
|
+
/**
|
|
65
|
+
* @param host - The client this namespace issues requests through.
|
|
66
|
+
*/
|
|
67
|
+
constructor(host) {
|
|
68
|
+
this.#host = host;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* List an app's connections.
|
|
72
|
+
*
|
|
73
|
+
* @param appId - The app id.
|
|
74
|
+
* @returns The connections, unwrapped from the `connections` envelope.
|
|
75
|
+
* @throws {ApiError} `404 unknown_app` when there is no such app.
|
|
76
|
+
*/
|
|
77
|
+
async listForApp(appId) {
|
|
78
|
+
const res = await this.#host.request({
|
|
79
|
+
method: "GET",
|
|
80
|
+
path: path `/apps/${appId}/connections`,
|
|
81
|
+
});
|
|
82
|
+
return unwrap(res, "connections");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Fetch one connection.
|
|
86
|
+
*
|
|
87
|
+
* No 404 special-casing — propagates as `ApiError` like every other "get"
|
|
88
|
+
* in this package except `console.schedules.get`, which has its own
|
|
89
|
+
* documented, unrelated exception.
|
|
90
|
+
*
|
|
91
|
+
* @param id - The `conn_…` id.
|
|
92
|
+
* @returns The connection, unwrapped from the `connection` envelope.
|
|
93
|
+
* @throws {ApiError} `404 unknown_connection` when there is no such id.
|
|
94
|
+
*/
|
|
95
|
+
async get(id) {
|
|
96
|
+
const res = await this.#host.request({
|
|
97
|
+
method: "GET",
|
|
98
|
+
path: path `/connections/${id}`,
|
|
99
|
+
});
|
|
100
|
+
return unwrap(res, "connection");
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a connection for an app.
|
|
104
|
+
*
|
|
105
|
+
* `credential` is opaque — forwarded verbatim, never inspected, logged, or
|
|
106
|
+
* transformed. This is a security-adjacent discipline, not a style note:
|
|
107
|
+
* the whole point of this field is a caller-opaque secret payload.
|
|
108
|
+
*
|
|
109
|
+
* @param appId - The app id.
|
|
110
|
+
* @param body - `authKey` selects the app's auth method; `credential` is
|
|
111
|
+
* the secret payload it needs; `displayName` and `profile` are optional.
|
|
112
|
+
* @returns The created connection, unwrapped from the `connection` envelope (the server answers `201`).
|
|
113
|
+
* @throws {ApiError} `400 invalid_auth_key`/`invalid_credential`; `404 unknown_app`.
|
|
114
|
+
*/
|
|
115
|
+
async create(appId, body) {
|
|
116
|
+
const res = await this.#host.request({
|
|
117
|
+
method: "POST",
|
|
118
|
+
path: path `/apps/${appId}/connections`,
|
|
119
|
+
body,
|
|
120
|
+
});
|
|
121
|
+
return unwrap(res, "connection");
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Update a connection: rename it and/or replace its credential.
|
|
125
|
+
*
|
|
126
|
+
* `credential` is opaque — forwarded verbatim, never inspected, logged, or
|
|
127
|
+
* transformed, same discipline as {@linkcode create}. The body is sent
|
|
128
|
+
* exactly as given; this method does not pre-validate it — the server also
|
|
129
|
+
* validates "nothing to update" and answers `400 invalid_body` itself.
|
|
130
|
+
*
|
|
131
|
+
* @param id - The `conn_…` id.
|
|
132
|
+
* @param body - `displayName` and/or `credential`, forwarded verbatim.
|
|
133
|
+
* @returns The updated connection, unwrapped from the `connection` envelope.
|
|
134
|
+
* @throws {ApiError} `400 invalid_body` ("Nothing to update"); `404 unknown_connection`.
|
|
135
|
+
*/
|
|
136
|
+
async update(id, body) {
|
|
137
|
+
const res = await this.#host.request({
|
|
138
|
+
method: "PATCH",
|
|
139
|
+
path: path `/connections/${id}`,
|
|
140
|
+
body,
|
|
141
|
+
});
|
|
142
|
+
return unwrap(res, "connection");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Probe a connection by running a safe read action of its app.
|
|
146
|
+
*
|
|
147
|
+
* **No envelope key — the whole body IS the result**, mirroring
|
|
148
|
+
* `console.reliability.list`'s pattern. A failed probe (`ok: false`) is
|
|
149
|
+
* still a `200` and resolves normally; this method never throws on it — the
|
|
150
|
+
* same rule `client.run()`/`workflows.run()` already document: a failed
|
|
151
|
+
* run (here, a failed test) is data. Only a genuine non-2xx (e.g.
|
|
152
|
+
* `404 unknown_connection`) raises `ApiError`. See {@linkcode ConnectionTestResult}.
|
|
153
|
+
*
|
|
154
|
+
* @param id - The `conn_…` id.
|
|
155
|
+
* @returns The whole response body — no envelope key to peel.
|
|
156
|
+
* @throws {ApiError} `404 unknown_connection` when there is no such id.
|
|
157
|
+
*/
|
|
158
|
+
async test(id) {
|
|
159
|
+
const res = await this.#host.request({
|
|
160
|
+
method: "POST",
|
|
161
|
+
path: path `/connections/${id}/test`,
|
|
162
|
+
});
|
|
163
|
+
return res.body;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Delete a connection.
|
|
167
|
+
*
|
|
168
|
+
* Returns nothing: the server's `{ok: true}` carries no information a
|
|
169
|
+
* caller can use, mirroring `console.projects.delete`/
|
|
170
|
+
* `console.schedules.delete` in this same package (NOT
|
|
171
|
+
* `console.apps.delete`, which is the one documented exception, preserving
|
|
172
|
+
* a genuinely informative `{removed: number}`) — connections delete has no
|
|
173
|
+
* such value to preserve.
|
|
174
|
+
*
|
|
175
|
+
* @param id - The `conn_…` id.
|
|
176
|
+
* @throws {ApiError} `404 unknown_connection` when there is no such id.
|
|
177
|
+
*/
|
|
178
|
+
async delete(id) {
|
|
179
|
+
await this.#host.request({ method: "DELETE", path: path `/connections/${id}` });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/console/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAqB,IAAI,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAA0B,MAAM,EAAE,MAAM,aAAa,CAAC;AAoC7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAc;IAChB,KAAK,CAAkB;IAEhC;;OAEG;IACH,YAAY,IAAqB;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa;QAC5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,KAAK;YACb,IAAI,EA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,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAA,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1F,CAAC;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.dashboard.*` — the account-scoped dashboard rollup,
|
|
3
|
+
* relocated from the studio's own API client.
|
|
4
|
+
*
|
|
5
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
6
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded from
|
|
7
|
+
* `endpoints.json` and from the root barrel (`mod.ts`) — see `docs/console.md`
|
|
8
|
+
* and HITL-1 in this task's contract. `@w6w/sdk`'s instance-state mechanism
|
|
9
|
+
* pin still applies here exactly as it does to every other namespace
|
|
10
|
+
* (`docs/implementation.md` §MECHANISM PIN — instance state, never globals):
|
|
11
|
+
* this class holds no state of its own beyond the injected host, so two
|
|
12
|
+
* clients in one process never share a credential.
|
|
13
|
+
*
|
|
14
|
+
* One operation: `stats`, `GET /dashboard/stats`. AUTHENTICATED — the account
|
|
15
|
+
* is derived server-side from the principal (`admin/dashboard.ts:44-96`), so
|
|
16
|
+
* this uses the default, unconditional `requireAuth` (HITL-9); the client
|
|
17
|
+
* never sends an account. Unlike `client.documents.*` and `client.vars.*`,
|
|
18
|
+
* the response carries **no envelope key** — the `DashboardStats`-shaped
|
|
19
|
+
* object IS the top-level response body (`admin/dashboard.ts:90-95`, which
|
|
20
|
+
* answers `c.json({range, headline, series, recent})`), so `stats` returns
|
|
21
|
+
* `res.body` directly and never calls this package's `unwrap()` helper.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import type { HttpResponse, RequestOptions } from "../http.ts";
|
|
26
|
+
/**
|
|
27
|
+
* The slice of `W6wClient` this namespace needs: the transport, and nothing
|
|
28
|
+
* else. Structural rather than a concrete client type, so the namespace stays
|
|
29
|
+
* independently constructible in a test and this module never imports the
|
|
30
|
+
* client back — mirrors `ReliabilityHost` in `./reliability.ts`.
|
|
31
|
+
*/
|
|
32
|
+
export interface DashboardHost {
|
|
33
|
+
/** Perform one request. */
|
|
34
|
+
request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
35
|
+
}
|
|
36
|
+
/** Optional window/bucketing for `stats`. Omitted fields fall back to the server's own defaults. */
|
|
37
|
+
export interface DashboardStatsParams {
|
|
38
|
+
from?: string;
|
|
39
|
+
to?: string;
|
|
40
|
+
bucket?: "day" | "week";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Account-scoped dashboard rollup over the `run_log` ledger (server `GET
|
|
44
|
+
* /dashboard/stats`). A free-form fetch seam, so this shape mirrors the
|
|
45
|
+
* server envelope field for field — relocated verbatim from
|
|
46
|
+
* `packages/studio/src/api/client.ts:189-197` rather than redesigned. The
|
|
47
|
+
* account is derived server-side from the session; the client never sends
|
|
48
|
+
* one. The `series` array is the charts-later seam (a flat payload the studio
|
|
49
|
+
* slices client-side; no chart dependency).
|
|
50
|
+
*/
|
|
51
|
+
export interface DashboardStats {
|
|
52
|
+
range: {
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
bucket: "day" | "week";
|
|
56
|
+
};
|
|
57
|
+
headline: {
|
|
58
|
+
workflowRuns: number;
|
|
59
|
+
succeeded: number;
|
|
60
|
+
failed: number;
|
|
61
|
+
};
|
|
62
|
+
series: Array<{
|
|
63
|
+
bucket: string;
|
|
64
|
+
kind: string;
|
|
65
|
+
ok: boolean | null;
|
|
66
|
+
count: number;
|
|
67
|
+
}>;
|
|
68
|
+
recent: Array<{
|
|
69
|
+
id: string;
|
|
70
|
+
kind: string;
|
|
71
|
+
ok: boolean | null;
|
|
72
|
+
summary: string | null;
|
|
73
|
+
occurredAt: string;
|
|
74
|
+
workflowId: string | null;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The `console.dashboard` namespace on a `W6wClient`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const rollup = await client.console.dashboard.stats({ bucket: "week" });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare class DashboardApi {
|
|
86
|
+
#private;
|
|
87
|
+
/**
|
|
88
|
+
* @param host - The client this namespace issues requests through.
|
|
89
|
+
*/
|
|
90
|
+
constructor(host: DashboardHost);
|
|
91
|
+
/**
|
|
92
|
+
* Fetch the account-scoped dashboard rollup.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Optional `from`/`to`/`bucket`; each is forwarded as a
|
|
95
|
+
* query parameter when given, and omitted from the query string entirely
|
|
96
|
+
* when not (the server applies its own defaults).
|
|
97
|
+
* @returns The rollup, exactly as the server sent it — no envelope key to peel.
|
|
98
|
+
* @throws {ApiError} On any non-2xx.
|
|
99
|
+
*/
|
|
100
|
+
stats(params?: DashboardStatsParams): Promise<DashboardStats>;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../../src/console/dashboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED,oGAAoG;AACpG,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,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