@w6w/sdk 0.5.0 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -32
- package/dist/mod.d.ts +10 -4
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +3 -0
- package/dist/mod.js.map +1 -1
- package/dist/src/client.d.ts +37 -5
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +40 -5
- package/dist/src/client.js.map +1 -1
- package/dist/src/config.d.ts +83 -6
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +41 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/connections.d.ts +3 -2
- package/dist/src/connections.d.ts.map +1 -1
- package/dist/src/connections.js +7 -2
- package/dist/src/connections.js.map +1 -1
- package/dist/src/console/aliases.d.ts +137 -0
- package/dist/src/console/aliases.d.ts.map +1 -0
- package/dist/src/console/aliases.js +113 -0
- package/dist/src/console/aliases.js.map +1 -0
- package/dist/src/console/api-calls.d.ts +4 -3
- package/dist/src/console/api-calls.d.ts.map +1 -1
- package/dist/src/console/api-calls.js +4 -3
- package/dist/src/console/api-calls.js.map +1 -1
- package/dist/src/console/apps.d.ts +181 -8
- package/dist/src/console/apps.d.ts.map +1 -1
- package/dist/src/console/apps.js +67 -12
- package/dist/src/console/apps.js.map +1 -1
- package/dist/src/console/auth.d.ts +245 -7
- package/dist/src/console/auth.d.ts.map +1 -1
- package/dist/src/console/auth.js +177 -8
- package/dist/src/console/auth.js.map +1 -1
- package/dist/src/console/commerce.d.ts +428 -0
- package/dist/src/console/commerce.d.ts.map +1 -0
- package/dist/src/console/commerce.js +220 -0
- package/dist/src/console/commerce.js.map +1 -0
- package/dist/src/console/dashboard.d.ts +8 -0
- package/dist/src/console/dashboard.d.ts.map +1 -1
- package/dist/src/console/dashboard.js.map +1 -1
- package/dist/src/console/endpoints.d.ts +79 -6
- package/dist/src/console/endpoints.d.ts.map +1 -1
- package/dist/src/console/endpoints.js.map +1 -1
- package/dist/src/console/functions.d.ts +35 -4
- package/dist/src/console/functions.d.ts.map +1 -1
- package/dist/src/console/functions.js +13 -0
- package/dist/src/console/functions.js.map +1 -1
- package/dist/src/console/mod.d.ts +32 -7
- package/dist/src/console/mod.d.ts.map +1 -1
- package/dist/src/console/mod.js +26 -1
- package/dist/src/console/mod.js.map +1 -1
- package/dist/src/console/otp.d.ts +127 -0
- package/dist/src/console/otp.d.ts.map +1 -0
- package/dist/src/console/otp.js +118 -0
- package/dist/src/console/otp.js.map +1 -0
- package/dist/src/console/passkeys.d.ts +246 -0
- package/dist/src/console/passkeys.d.ts.map +1 -0
- package/dist/src/console/passkeys.js +192 -0
- package/dist/src/console/passkeys.js.map +1 -0
- package/dist/src/console/reliability.d.ts +101 -6
- package/dist/src/console/reliability.d.ts.map +1 -1
- package/dist/src/console/reliability.js +16 -5
- package/dist/src/console/reliability.js.map +1 -1
- package/dist/src/console/step-tests.d.ts +7 -1
- package/dist/src/console/step-tests.d.ts.map +1 -1
- package/dist/src/console/step-tests.js +1 -1
- package/dist/src/console/step-tests.js.map +1 -1
- package/dist/src/console/subscriptions.d.ts +38 -16
- package/dist/src/console/subscriptions.d.ts.map +1 -1
- package/dist/src/console/subscriptions.js +7 -13
- package/dist/src/console/subscriptions.js.map +1 -1
- package/dist/src/console/tenant-login-flags.d.ts +106 -0
- package/dist/src/console/tenant-login-flags.d.ts.map +1 -0
- package/dist/src/console/tenant-login-flags.js +113 -0
- package/dist/src/console/tenant-login-flags.js.map +1 -0
- package/dist/src/console/tenant-oauth-apps.d.ts +75 -14
- package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -1
- package/dist/src/console/tenant-oauth-apps.js +37 -11
- package/dist/src/console/tenant-oauth-apps.js.map +1 -1
- package/dist/src/console/tokens.d.ts +2 -0
- package/dist/src/console/tokens.d.ts.map +1 -1
- package/dist/src/console/tokens.js.map +1 -1
- package/dist/src/console/workflows.d.ts +14 -0
- package/dist/src/console/workflows.d.ts.map +1 -1
- package/dist/src/console/workflows.js +13 -0
- package/dist/src/console/workflows.js.map +1 -1
- package/dist/src/documents.d.ts +9 -5
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +6 -3
- package/dist/src/documents.js.map +1 -1
- package/dist/src/endpoints.d.ts +75 -0
- package/dist/src/endpoints.d.ts.map +1 -0
- package/dist/src/endpoints.js +47 -0
- package/dist/src/endpoints.js.map +1 -0
- package/dist/src/functions.d.ts +236 -0
- package/dist/src/functions.d.ts.map +1 -0
- package/dist/src/functions.js +201 -0
- package/dist/src/functions.js.map +1 -0
- package/dist/src/http.d.ts +58 -10
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +82 -11
- package/dist/src/http.js.map +1 -1
- package/dist/src/me.d.ts +3 -2
- package/dist/src/me.d.ts.map +1 -1
- package/dist/src/me.js +7 -2
- package/dist/src/me.js.map +1 -1
- package/dist/src/run.d.ts +19 -5
- package/dist/src/run.d.ts.map +1 -1
- package/dist/src/run.js +14 -4
- package/dist/src/run.js.map +1 -1
- package/dist/src/server/mod.d.ts +100 -0
- package/dist/src/server/mod.d.ts.map +1 -0
- package/dist/src/server/mod.js +121 -0
- package/dist/src/server/mod.js.map +1 -0
- package/dist/src/team.d.ts +204 -0
- package/dist/src/team.d.ts.map +1 -0
- package/dist/src/team.js +161 -0
- package/dist/src/team.js.map +1 -0
- package/dist/src/types.d.ts +143 -10
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +27 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/vars.d.ts +5 -3
- package/dist/src/vars.d.ts.map +1 -1
- package/dist/src/vars.js +14 -4
- package/dist/src/vars.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/workflows.d.ts +261 -9
- package/dist/src/workflows.d.ts.map +1 -1
- package/dist/src/workflows.js +246 -7
- package/dist/src/workflows.js.map +1 -1
- package/package.json +5 -1
package/dist/src/config.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
+
import { type ApiError } from "./errors.ts";
|
|
11
12
|
/**
|
|
12
13
|
* The API's base path, from the shared contract's `basePath`
|
|
13
14
|
* (`packages/wrappers/endpoints.json`).
|
|
@@ -31,6 +32,28 @@ export declare const BASE_PATH = "";
|
|
|
31
32
|
* narrower one), while a fake only has to accept a URL string.
|
|
32
33
|
*/
|
|
33
34
|
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
35
|
+
/**
|
|
36
|
+
* A per-request token supplier.
|
|
37
|
+
*
|
|
38
|
+
* Called **per request** — never cached after it settles, never resolved once
|
|
39
|
+
* at construction — so a host can rotate or mint a token out-of-band (a tenant
|
|
40
|
+
* exchange, a short-lived partner credential) and have the very next call pick
|
|
41
|
+
* it up. Requests that are in flight **concurrently** on one client share ONE
|
|
42
|
+
* supplier call (and its result); a request that starts after it settled calls
|
|
43
|
+
* the supplier again. Memoize the supplier yourself if minting is expensive.
|
|
44
|
+
* `ctx.forceRefresh` is set to `true` exactly once, on the single
|
|
45
|
+
* recovery retry a `401`/`unauthorized` triggers (`docs/implementation.md`
|
|
46
|
+
* §3); every ordinary per-request resolution omits it. A `string` `token` is
|
|
47
|
+
* the degenerate case of this shape — it behaves exactly as before.
|
|
48
|
+
*
|
|
49
|
+
* May return synchronously or return a `Promise`; either is awaited before the
|
|
50
|
+
* bearer is attached. A nullish or blank (after trimming) result is treated
|
|
51
|
+
* exactly like a nullish/blank static token — a {@linkcode ConfigError}, never
|
|
52
|
+
* a request sent with no credential.
|
|
53
|
+
*/
|
|
54
|
+
export type TokenProvider = (ctx?: {
|
|
55
|
+
forceRefresh?: boolean;
|
|
56
|
+
}) => string | null | undefined | Promise<string | null | undefined>;
|
|
34
57
|
/** Constructor options for a client. Every field is optional. */
|
|
35
58
|
export interface W6WClientOptions {
|
|
36
59
|
/**
|
|
@@ -42,8 +65,40 @@ export interface W6WClientOptions {
|
|
|
42
65
|
* Overrides `W6W_BASE_URL`.
|
|
43
66
|
*/
|
|
44
67
|
baseUrl?: string;
|
|
45
|
-
/**
|
|
46
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Bearer token, resolved on **every** request — not just once at
|
|
70
|
+
* construction. A plain `string` is sent verbatim on every call, exactly as
|
|
71
|
+
* before; a {@linkcode TokenProvider} function is called (and awaited)
|
|
72
|
+
* per request (concurrent requests share one in-flight call), so a host can hand back a token minted or rotated after
|
|
73
|
+
* this client was constructed. Overrides `W6W_TOKEN`, which stays a plain
|
|
74
|
+
* string (there is no environment-variable spelling of a supplier).
|
|
75
|
+
*/
|
|
76
|
+
token?: string | TokenProvider;
|
|
77
|
+
/**
|
|
78
|
+
* Opt in to a single, one-shot recovery when a request fails with
|
|
79
|
+
* `401`/`unauthorized`: `token` (which must be a function for this to do
|
|
80
|
+
* anything) is called once more with `{forceRefresh: true}`, and if that
|
|
81
|
+
* yields a usable value the SAME request is re-sent once with it. Off
|
|
82
|
+
* (`false`) by default — the behaviour before this option existed. Never
|
|
83
|
+
* retries a second time, never retries any other status or code, and never
|
|
84
|
+
* applies to a `requireAuth: false` request.
|
|
85
|
+
*/
|
|
86
|
+
refreshOnUnauthorized?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Called with the terminal `401`/`unauthorized` {@linkcode ApiError} of a
|
|
89
|
+
* bearer request — after a failed recovery retry, or immediately when
|
|
90
|
+
* recovery is off or not possible (a static `token`) — at most once per
|
|
91
|
+
* call. Never called on success, never called twice, and never called for a
|
|
92
|
+
* `requireAuth: false` request.
|
|
93
|
+
*/
|
|
94
|
+
onUnauthorized?: (error: ApiError) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Default headers sent with every request. This is the **base** every
|
|
97
|
+
* per-request `headers` option builds on: a per-request header with the
|
|
98
|
+
* same name wins, and neither can ever displace the bearer this transport
|
|
99
|
+
* attaches (`authorization`) or the `content-type` it sets for a JSON body.
|
|
100
|
+
*/
|
|
101
|
+
headers?: Record<string, string>;
|
|
47
102
|
/**
|
|
48
103
|
* Default project id for the project-scoped operations — `documents.*` and
|
|
49
104
|
* `workflows.list`, which read it too.
|
|
@@ -69,8 +124,14 @@ export interface ResolvedConfig {
|
|
|
69
124
|
* value that is not an absolute `http(s)` URL with a host.
|
|
70
125
|
*/
|
|
71
126
|
readonly baseUrl: string;
|
|
72
|
-
/** The bearer token, or `null` when none was configured. */
|
|
73
|
-
readonly token: string | null;
|
|
127
|
+
/** The bearer token or supplier, or `null` when none was configured. */
|
|
128
|
+
readonly token: string | TokenProvider | null;
|
|
129
|
+
/** Opt-in one-shot 401 recovery. Defaults to `false`. */
|
|
130
|
+
readonly refreshOnUnauthorized: boolean;
|
|
131
|
+
/** Terminal-401 callback, or `null` when none was configured. */
|
|
132
|
+
readonly onUnauthorized: ((error: ApiError) => void) | null;
|
|
133
|
+
/** Default headers sent with every request. Defaults to `{}`. */
|
|
134
|
+
readonly headers: Record<string, string>;
|
|
74
135
|
/** Default project id, or `null`. */
|
|
75
136
|
readonly project: string | null;
|
|
76
137
|
}
|
|
@@ -146,14 +207,30 @@ export declare function resolveConfig(options?: W6WClientOptions): ResolvedConfi
|
|
|
146
207
|
* There are no anonymous operations in this surface
|
|
147
208
|
* (`docs/implementation.md` §2).
|
|
148
209
|
*
|
|
210
|
+
* **Resolved per call, never cached after it settles.** When `config.token` is
|
|
211
|
+
* a {@linkcode TokenProvider} it is called (and its result awaited) right here —
|
|
212
|
+
* a plain string is the degenerate case that needs no call at all. Ordinary
|
|
213
|
+
* calls (`ctx?.forceRefresh` not `true`) that overlap on one `config` share ONE
|
|
214
|
+
* in-flight supplier call; the slot is dropped when it settles, on success or
|
|
215
|
+
* failure, so nothing is cached. A forced refresh neither joins nor fills that
|
|
216
|
+
* slot. `ctx` is
|
|
217
|
+
* forwarded verbatim to the provider; passing `{forceRefresh: true}` is the
|
|
218
|
+
* one and only seam `request()`'s recovery retry uses (`docs/implementation.md`
|
|
219
|
+
* §3) — ordinary resolution never passes it.
|
|
220
|
+
*
|
|
149
221
|
* A blank token counts as no token, for the same reason a blank base URL does:
|
|
150
222
|
* `W6W_TOKEN=` is how a shell or a Dockerfile spells "I meant to set this and
|
|
151
223
|
* did not", and `Authorization: Bearer ` would turn that into an opaque 401
|
|
152
|
-
* instead of the one message that explains it.
|
|
224
|
+
* instead of the one message that explains it. The same rule applies to
|
|
225
|
+
* whatever a provider returns: nullish or blank is treated exactly like a
|
|
226
|
+
* nullish/blank static token — the error never echoes the value either way.
|
|
153
227
|
*
|
|
154
228
|
* @param config - The resolved configuration.
|
|
229
|
+
* @param ctx - Forwarded to a function-typed `token`; unused for a string one.
|
|
155
230
|
* @returns The configured token, verbatim.
|
|
156
231
|
* @throws {ConfigError} When no non-blank token is configured.
|
|
157
232
|
*/
|
|
158
|
-
export declare function requireToken(config: ResolvedConfig
|
|
233
|
+
export declare function requireToken(config: ResolvedConfig, ctx?: {
|
|
234
|
+
forceRefresh?: boolean;
|
|
235
|
+
}): Promise<string>;
|
|
159
236
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,KAAK,QAAQ,EAAe,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,GAAG,CAAC,EAAE;IAAE,Y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AW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAuBlD;AAkBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,gBAAqB,GAAG,cAAc,CAY5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,cAAc,EACtB,GAAG,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/B,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
package/dist/src/config.js
CHANGED
|
@@ -86,7 +86,7 @@ export function joinBaseUrl(origin) {
|
|
|
86
86
|
throw new ConfigError("No w6w base URL is configured. Pass one to the client " +
|
|
87
87
|
'(new W6WClient({ baseUrl: "https://api.example.com" })) or set the ' +
|
|
88
88
|
`${ENV_BASE_URL} environment variable. It holds the server's origin, ` +
|
|
89
|
-
|
|
89
|
+
'e.g. "https://api.example.com" — the API is served at its root, so no ' +
|
|
90
90
|
"path is appended.");
|
|
91
91
|
}
|
|
92
92
|
if (!ABSOLUTE_HTTP_ORIGIN.test(trimmed) || !parses(trimmed)) {
|
|
@@ -138,6 +138,9 @@ export function resolveConfig(options = {}) {
|
|
|
138
138
|
// never answer differently for the same input.
|
|
139
139
|
baseUrl: joinBaseUrl(options.baseUrl ?? readEnv(ENV_BASE_URL) ?? ""),
|
|
140
140
|
token: options.token ?? readEnv(ENV_TOKEN) ?? null,
|
|
141
|
+
refreshOnUnauthorized: options.refreshOnUnauthorized ?? false,
|
|
142
|
+
onUnauthorized: options.onUnauthorized ?? null,
|
|
143
|
+
headers: options.headers ?? {},
|
|
141
144
|
project: options.project ?? null,
|
|
142
145
|
};
|
|
143
146
|
}
|
|
@@ -149,21 +152,54 @@ export function resolveConfig(options = {}) {
|
|
|
149
152
|
* There are no anonymous operations in this surface
|
|
150
153
|
* (`docs/implementation.md` §2).
|
|
151
154
|
*
|
|
155
|
+
* **Resolved per call, never cached after it settles.** When `config.token` is
|
|
156
|
+
* a {@linkcode TokenProvider} it is called (and its result awaited) right here —
|
|
157
|
+
* a plain string is the degenerate case that needs no call at all. Ordinary
|
|
158
|
+
* calls (`ctx?.forceRefresh` not `true`) that overlap on one `config` share ONE
|
|
159
|
+
* in-flight supplier call; the slot is dropped when it settles, on success or
|
|
160
|
+
* failure, so nothing is cached. A forced refresh neither joins nor fills that
|
|
161
|
+
* slot. `ctx` is
|
|
162
|
+
* forwarded verbatim to the provider; passing `{forceRefresh: true}` is the
|
|
163
|
+
* one and only seam `request()`'s recovery retry uses (`docs/implementation.md`
|
|
164
|
+
* §3) — ordinary resolution never passes it.
|
|
165
|
+
*
|
|
152
166
|
* A blank token counts as no token, for the same reason a blank base URL does:
|
|
153
167
|
* `W6W_TOKEN=` is how a shell or a Dockerfile spells "I meant to set this and
|
|
154
168
|
* did not", and `Authorization: Bearer ` would turn that into an opaque 401
|
|
155
|
-
* instead of the one message that explains it.
|
|
169
|
+
* instead of the one message that explains it. The same rule applies to
|
|
170
|
+
* whatever a provider returns: nullish or blank is treated exactly like a
|
|
171
|
+
* nullish/blank static token — the error never echoes the value either way.
|
|
156
172
|
*
|
|
157
173
|
* @param config - The resolved configuration.
|
|
174
|
+
* @param ctx - Forwarded to a function-typed `token`; unused for a string one.
|
|
158
175
|
* @returns The configured token, verbatim.
|
|
159
176
|
* @throws {ConfigError} When no non-blank token is configured.
|
|
160
177
|
*/
|
|
161
|
-
export function requireToken(config) {
|
|
162
|
-
if (config.token
|
|
178
|
+
export function requireToken(config, ctx) {
|
|
179
|
+
if (typeof config.token !== "function" || ctx?.forceRefresh === true) {
|
|
180
|
+
return resolveToken(config, ctx);
|
|
181
|
+
}
|
|
182
|
+
const pending = inflightTokens.get(config);
|
|
183
|
+
if (pending)
|
|
184
|
+
return pending;
|
|
185
|
+
const flight = resolveToken(config, ctx);
|
|
186
|
+
inflightTokens.set(config, flight);
|
|
187
|
+
const clear = () => {
|
|
188
|
+
if (inflightTokens.get(config) === flight)
|
|
189
|
+
inflightTokens.delete(config);
|
|
190
|
+
};
|
|
191
|
+
flight.then(clear, clear);
|
|
192
|
+
return flight;
|
|
193
|
+
}
|
|
194
|
+
/** One in-flight ordinary supplier call per config (never a module-level slot). */
|
|
195
|
+
const inflightTokens = new WeakMap();
|
|
196
|
+
async function resolveToken(config, ctx) {
|
|
197
|
+
const raw = typeof config.token === "function" ? await config.token(ctx) : config.token;
|
|
198
|
+
if (raw === null || raw === undefined || raw.trim().length === 0) {
|
|
163
199
|
throw new ConfigError("No w6w API token is configured. Pass one to the client " +
|
|
164
200
|
'(new W6WClient({ token: "…" })) or set the ' +
|
|
165
201
|
`${ENV_TOKEN} environment variable. Every w6w API operation is authenticated.`);
|
|
166
202
|
}
|
|
167
|
-
return
|
|
203
|
+
return raw;
|
|
168
204
|
}
|
|
169
205
|
//# sourceMappingURL=config.js.map
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAiB,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAyH5B;;;;;;;;;;GAUG;AACH,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,0EAA0E;IAC1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AAE,CAAC;QACjE,MAAM,IAAI,WAAW,CACnB,yDAAyD;YACvD,6CAA6C;YAC7C,GAAG,SAAS,kEAAkE,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @module
|
|
21
21
|
*/
|
|
22
|
-
import type { HttpResponse, RequestOptions } from "./http.ts";
|
|
22
|
+
import type { CallOptions, HttpResponse, RequestOptions } from "./http.ts";
|
|
23
23
|
import { type ConnectionSummary } from "./types.ts";
|
|
24
24
|
/**
|
|
25
25
|
* The slice of `W6WClient` this namespace needs: the transport, and nothing
|
|
@@ -50,9 +50,10 @@ export declare class ConnectionsApi {
|
|
|
50
50
|
/**
|
|
51
51
|
* List the caller's connections.
|
|
52
52
|
*
|
|
53
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
53
54
|
* @returns The connections, unwrapped from the `connections` envelope.
|
|
54
55
|
* @throws {ApiError} On any non-2xx.
|
|
55
56
|
*/
|
|
56
|
-
list(): Promise<ConnectionSummary[]>;
|
|
57
|
+
list(options?: CallOptions): Promise<ConnectionSummary[]>;
|
|
57
58
|
}
|
|
58
59
|
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,KAAK,iBAAiB,EAAU,MAAM,YAAY,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAc;;IAGzB;;OAEG;gBACS,IAAI,EAAE,eAAe;IAIjC;;;;;;OAMG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;CAQhE"}
|
package/dist/src/connections.js
CHANGED
|
@@ -41,11 +41,16 @@ export class ConnectionsApi {
|
|
|
41
41
|
/**
|
|
42
42
|
* List the caller's connections.
|
|
43
43
|
*
|
|
44
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
44
45
|
* @returns The connections, unwrapped from the `connections` envelope.
|
|
45
46
|
* @throws {ApiError} On any non-2xx.
|
|
46
47
|
*/
|
|
47
|
-
async list() {
|
|
48
|
-
const res = await this.#host.request({
|
|
48
|
+
async list(options) {
|
|
49
|
+
const res = await this.#host.request({
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: "/connections",
|
|
52
|
+
signal: options?.signal,
|
|
53
|
+
});
|
|
49
54
|
return unwrap(res, "connections");
|
|
50
55
|
}
|
|
51
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAA0B,MAAM,EAAE,MAAM,YAAY,CAAC;AAa5D;;;;;;;;;GASG;AACH,MAAM,OAAO,cAAc;IAChB,KAAK,CAAkB;IAEhC;;OAEG;IACH,YAAY,IAAqB;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAA0B,MAAM,EAAE,MAAM,YAAY,CAAC;AAa5D;;;;;;;;;GASG;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,IAAI,CAAC,OAAqB;QAC9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAsB,GAAG,EAAE,aAAa,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.aliases.*` — account-scoped alias management
|
|
3
|
+
* (`list`/`get`/`upsert`/`delete`) for the names `run`'s URN dispatch
|
|
4
|
+
* resolves alongside its four `conn_…`/`wf_…`/`fn_…`/`ep_…` arms
|
|
5
|
+
* (`src/run.ts`).
|
|
6
|
+
*
|
|
7
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
8
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded
|
|
9
|
+
* from `endpoints.json` and from the root barrel (`mod.ts`) — see
|
|
10
|
+
* `docs/console.md` and HITL-2 in this project's contract. This surface is
|
|
11
|
+
* **new**: unlike `console.functions`/`console.endpoints`, there is no
|
|
12
|
+
* pre-existing `studio/src/api/client.ts` alias code being relocated here —
|
|
13
|
+
* Studio never had alias CRUD before this project. `@w6w/sdk`'s
|
|
14
|
+
* instance-state mechanism pin still applies here exactly as it does to
|
|
15
|
+
* every other namespace (`docs/implementation.md` §MECHANISM PIN — instance
|
|
16
|
+
* state, never globals): this class holds no state of its own beyond the
|
|
17
|
+
* injected host, so two clients in one process never share a credential.
|
|
18
|
+
*
|
|
19
|
+
* **`invoke`/`run` is deliberately NOT modeled here.** The base
|
|
20
|
+
* `client.run({urn: aliasName, payload})` (already-published surface,
|
|
21
|
+
* `endpoints.json`-named, exported from the root `mod.ts`) already reaches
|
|
22
|
+
* an alias's target — an alias name is one of `run`'s runnable `urn` arms,
|
|
23
|
+
* alongside `conn_…`/`wf_…`/`fn_…`/`ep_…` (`src/run.ts`). Adding a duplicate
|
|
24
|
+
* `console.aliases.invoke` would give a caller two ways to reach the same
|
|
25
|
+
* route — the exact anti-duplication defect `console/functions.ts:15-26`
|
|
26
|
+
* flags for Functions, applied here with alias/`run` substituted for
|
|
27
|
+
* function/`run`; `console.endpoints`/`console.workflows` follow the same
|
|
28
|
+
* precedent. No invoke method lives here, and none should be added later
|
|
29
|
+
* without re-litigating this reasoning.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
import { type HttpResponse, type RequestOptions } from "../http.ts";
|
|
34
|
+
import type { EndpointTarget } from "./endpoints.ts";
|
|
35
|
+
/**
|
|
36
|
+
* The slice of `W6WClient` this namespace needs: the transport, and nothing
|
|
37
|
+
* else. Structural rather than a concrete client type, so the namespace
|
|
38
|
+
* stays independently constructible in a test and this module never
|
|
39
|
+
* imports the client back — mirrors `FunctionsHost` in `./functions.ts`.
|
|
40
|
+
*/
|
|
41
|
+
export interface AliasesHost {
|
|
42
|
+
/** Perform one request. */
|
|
43
|
+
request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An alias definition — an account-scoped name bound to one runnable
|
|
47
|
+
* target, typed with the same {@linkcode EndpointTarget} union
|
|
48
|
+
* `console.endpoints` dispatches to. Unlike `EndpointDef.target`, an
|
|
49
|
+
* alias's `target` may also carry the `endpoint` arm
|
|
50
|
+
* ({@linkcode EndpointRefTarget}) — dispatching to another Endpoint by id is
|
|
51
|
+
* legal for an alias only, so `run`'s URN dispatch can resolve it by name
|
|
52
|
+
* instead of by id.
|
|
53
|
+
*
|
|
54
|
+
* `name` is **immutable after first save** (HITL-3): a save that changes
|
|
55
|
+
* `name` on an already-stored alias answers `409 alias_name_immutable`.
|
|
56
|
+
*/
|
|
57
|
+
export interface AliasDef {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
displayName?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
target: EndpointTarget;
|
|
63
|
+
}
|
|
64
|
+
/** One row of `list`'s result — an alias's summary, not its full definition. */
|
|
65
|
+
export interface AliasSummary {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
displayName: string;
|
|
69
|
+
description: string;
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
target: EndpointTarget;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The `console.aliases` namespace on a `W6WClient`.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const aliases = await client.console.aliases.list();
|
|
79
|
+
* const alias = await client.console.aliases.get(aliases[0].id);
|
|
80
|
+
* await client.console.aliases.upsert({ ...alias, description: "Send email" });
|
|
81
|
+
* await client.console.aliases.delete(alias.id);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare class AliasesApi {
|
|
85
|
+
#private;
|
|
86
|
+
/**
|
|
87
|
+
* @param host - The client this namespace issues requests through.
|
|
88
|
+
*/
|
|
89
|
+
constructor(host: AliasesHost);
|
|
90
|
+
/**
|
|
91
|
+
* List the caller's aliases.
|
|
92
|
+
*
|
|
93
|
+
* @returns The aliases, unwrapped from the `aliases` envelope.
|
|
94
|
+
*/
|
|
95
|
+
list(): Promise<AliasSummary[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch one alias's stored definition.
|
|
98
|
+
*
|
|
99
|
+
* No server-computed field to splice in — unlike
|
|
100
|
+
* {@linkcode FunctionsApi.get}'s `valid` merge, this returns
|
|
101
|
+
* `unwrap<AliasDef>(res, "alias")` plainly.
|
|
102
|
+
*
|
|
103
|
+
* @param id - The alias's `id`.
|
|
104
|
+
* @returns The alias definition, unwrapped from the `alias` envelope.
|
|
105
|
+
* @throws {ApiError} `404 unknown_alias` when there is no such id.
|
|
106
|
+
*/
|
|
107
|
+
get(id: string): Promise<AliasDef>;
|
|
108
|
+
/**
|
|
109
|
+
* Register (create or overwrite) an alias definition.
|
|
110
|
+
*
|
|
111
|
+
* `definition` is the whole definition, sent verbatim as the request body
|
|
112
|
+
* — not wrapped in an envelope key.
|
|
113
|
+
*
|
|
114
|
+
* @param definition - The whole alias definition, forwarded verbatim.
|
|
115
|
+
* @returns The new/updated alias's id and name.
|
|
116
|
+
* @throws {ApiError} `400 invalid_alias` — structurally invalid body.
|
|
117
|
+
* @throws {ApiError} `409 alias_conflict` — another `(tenant,subject)` owns this id.
|
|
118
|
+
* @throws {ApiError} `409 alias_name_conflict` — another alias already owns this name.
|
|
119
|
+
* @throws {ApiError} `409 alias_name_immutable` — `name` changed on an already-stored alias (HITL-3).
|
|
120
|
+
*/
|
|
121
|
+
upsert(definition: AliasDef): Promise<{
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Delete an alias.
|
|
127
|
+
*
|
|
128
|
+
* Returns nothing: the server's `{ok: true}` carries no information a
|
|
129
|
+
* caller can use, mirroring `console.vault.delete`/`console.projects.delete`
|
|
130
|
+
* in this same package.
|
|
131
|
+
*
|
|
132
|
+
* @param id - The alias's `id`.
|
|
133
|
+
* @throws {ApiError} `404 unknown_alias` when there is no such id.
|
|
134
|
+
*/
|
|
135
|
+
delete(id: string): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../../src/console/aliases.ts"],"names":[],"mappings":"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AO,CAAC,IAAI,CAAC;CAGxC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.aliases.*` — account-scoped alias management
|
|
3
|
+
* (`list`/`get`/`upsert`/`delete`) for the names `run`'s URN dispatch
|
|
4
|
+
* resolves alongside its four `conn_…`/`wf_…`/`fn_…`/`ep_…` arms
|
|
5
|
+
* (`src/run.ts`).
|
|
6
|
+
*
|
|
7
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
8
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded
|
|
9
|
+
* from `endpoints.json` and from the root barrel (`mod.ts`) — see
|
|
10
|
+
* `docs/console.md` and HITL-2 in this project's contract. This surface is
|
|
11
|
+
* **new**: unlike `console.functions`/`console.endpoints`, there is no
|
|
12
|
+
* pre-existing `studio/src/api/client.ts` alias code being relocated here —
|
|
13
|
+
* Studio never had alias CRUD before this project. `@w6w/sdk`'s
|
|
14
|
+
* instance-state mechanism pin still applies here exactly as it does to
|
|
15
|
+
* every other namespace (`docs/implementation.md` §MECHANISM PIN — instance
|
|
16
|
+
* state, never globals): this class holds no state of its own beyond the
|
|
17
|
+
* injected host, so two clients in one process never share a credential.
|
|
18
|
+
*
|
|
19
|
+
* **`invoke`/`run` is deliberately NOT modeled here.** The base
|
|
20
|
+
* `client.run({urn: aliasName, payload})` (already-published surface,
|
|
21
|
+
* `endpoints.json`-named, exported from the root `mod.ts`) already reaches
|
|
22
|
+
* an alias's target — an alias name is one of `run`'s runnable `urn` arms,
|
|
23
|
+
* alongside `conn_…`/`wf_…`/`fn_…`/`ep_…` (`src/run.ts`). Adding a duplicate
|
|
24
|
+
* `console.aliases.invoke` would give a caller two ways to reach the same
|
|
25
|
+
* route — the exact anti-duplication defect `console/functions.ts:15-26`
|
|
26
|
+
* flags for Functions, applied here with alias/`run` substituted for
|
|
27
|
+
* function/`run`; `console.endpoints`/`console.workflows` follow the same
|
|
28
|
+
* precedent. No invoke method lives here, and none should be added later
|
|
29
|
+
* without re-litigating this reasoning.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
import { path } from "../http.js";
|
|
34
|
+
import { unwrap } from "../types.js";
|
|
35
|
+
/**
|
|
36
|
+
* The `console.aliases` namespace on a `W6WClient`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const aliases = await client.console.aliases.list();
|
|
41
|
+
* const alias = await client.console.aliases.get(aliases[0].id);
|
|
42
|
+
* await client.console.aliases.upsert({ ...alias, description: "Send email" });
|
|
43
|
+
* await client.console.aliases.delete(alias.id);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export class AliasesApi {
|
|
47
|
+
#host;
|
|
48
|
+
/**
|
|
49
|
+
* @param host - The client this namespace issues requests through.
|
|
50
|
+
*/
|
|
51
|
+
constructor(host) {
|
|
52
|
+
this.#host = host;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* List the caller's aliases.
|
|
56
|
+
*
|
|
57
|
+
* @returns The aliases, unwrapped from the `aliases` envelope.
|
|
58
|
+
*/
|
|
59
|
+
async list() {
|
|
60
|
+
const res = await this.#host.request({ method: "GET", path: "/aliases" });
|
|
61
|
+
return unwrap(res, "aliases");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Fetch one alias's stored definition.
|
|
65
|
+
*
|
|
66
|
+
* No server-computed field to splice in — unlike
|
|
67
|
+
* {@linkcode FunctionsApi.get}'s `valid` merge, this returns
|
|
68
|
+
* `unwrap<AliasDef>(res, "alias")` plainly.
|
|
69
|
+
*
|
|
70
|
+
* @param id - The alias's `id`.
|
|
71
|
+
* @returns The alias definition, unwrapped from the `alias` envelope.
|
|
72
|
+
* @throws {ApiError} `404 unknown_alias` when there is no such id.
|
|
73
|
+
*/
|
|
74
|
+
async get(id) {
|
|
75
|
+
const res = await this.#host.request({ method: "GET", path: path `/aliases/${id}` });
|
|
76
|
+
return unwrap(res, "alias");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Register (create or overwrite) an alias definition.
|
|
80
|
+
*
|
|
81
|
+
* `definition` is the whole definition, sent verbatim as the request body
|
|
82
|
+
* — not wrapped in an envelope key.
|
|
83
|
+
*
|
|
84
|
+
* @param definition - The whole alias definition, forwarded verbatim.
|
|
85
|
+
* @returns The new/updated alias's id and name.
|
|
86
|
+
* @throws {ApiError} `400 invalid_alias` — structurally invalid body.
|
|
87
|
+
* @throws {ApiError} `409 alias_conflict` — another `(tenant,subject)` owns this id.
|
|
88
|
+
* @throws {ApiError} `409 alias_name_conflict` — another alias already owns this name.
|
|
89
|
+
* @throws {ApiError} `409 alias_name_immutable` — `name` changed on an already-stored alias (HITL-3).
|
|
90
|
+
*/
|
|
91
|
+
async upsert(definition) {
|
|
92
|
+
const res = await this.#host.request({
|
|
93
|
+
method: "POST",
|
|
94
|
+
path: "/aliases",
|
|
95
|
+
body: definition,
|
|
96
|
+
});
|
|
97
|
+
return unwrap(res, "alias");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Delete an alias.
|
|
101
|
+
*
|
|
102
|
+
* Returns nothing: the server's `{ok: true}` carries no information a
|
|
103
|
+
* caller can use, mirroring `console.vault.delete`/`console.projects.delete`
|
|
104
|
+
* in this same package.
|
|
105
|
+
*
|
|
106
|
+
* @param id - The alias's `id`.
|
|
107
|
+
* @throws {ApiError} `404 unknown_alias` when there is no such id.
|
|
108
|
+
*/
|
|
109
|
+
async delete(id) {
|
|
110
|
+
await this.#host.request({ method: "DELETE", path: path `/aliases/${id}` });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.js","sourceRoot":"","sources":["../../../src/console/aliases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAqB,I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F,CAAC;CACF"}
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
* result type) and `console/mod.ts` already re-exports it — this module
|
|
21
21
|
* imports it as a type and uses it verbatim as `list`'s return element type.
|
|
22
22
|
*
|
|
23
|
-
* `api-calls` is scoped to the caller
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* `api-calls` is scoped to the caller and can be narrowed to one project. The
|
|
24
|
+
* reliability detail page always supplies that project so its drill-down rows
|
|
25
|
+
* are the same rows that produced the reliability numbers.
|
|
26
26
|
*
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
@@ -46,6 +46,7 @@ export interface ApiCallsHost {
|
|
|
46
46
|
* values.
|
|
47
47
|
*/
|
|
48
48
|
export interface ApiCallsFilter {
|
|
49
|
+
project?: string;
|
|
49
50
|
appId?: string;
|
|
50
51
|
actionKey?: string;
|
|
51
52
|
connectionId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-calls.d.ts","sourceRoot":"","sources":["../../../src/console/api-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK/C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,qBAAa,WAAW;;IAGtB;;OAEG;gBACS,IAAI,EAAE,YAAY;IAI9B;;;;;;;OAOG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"api-calls.d.ts","sourceRoot":"","sources":["../../../src/console/api-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK/C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,qBAAa,WAAW;;IAGtB;;OAEG;gBACS,IAAI,EAAE,YAAY;IAI9B;;;;;;;OAOG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAe9D"}
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
* result type) and `console/mod.ts` already re-exports it — this module
|
|
21
21
|
* imports it as a type and uses it verbatim as `list`'s return element type.
|
|
22
22
|
*
|
|
23
|
-
* `api-calls` is scoped to the caller
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* `api-calls` is scoped to the caller and can be narrowed to one project. The
|
|
24
|
+
* reliability detail page always supplies that project so its drill-down rows
|
|
25
|
+
* are the same rows that produced the reliability numbers.
|
|
26
26
|
*
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
@@ -57,6 +57,7 @@ export class ApiCallsApi {
|
|
|
57
57
|
path: "/api-calls",
|
|
58
58
|
query: {
|
|
59
59
|
appId: filter?.appId,
|
|
60
|
+
project: filter?.project,
|
|
60
61
|
actionKey: filter?.actionKey,
|
|
61
62
|
connectionId: filter?.connectionId,
|
|
62
63
|
sessionId: filter?.sessionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-calls.js","sourceRoot":"","sources":["../../../src/console/api-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api-calls.js","sourceRoot":"","sources":["../../../src/console/api-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmCrC;;;;;;;GAOG;AACH,MAAM,OAAO,WAAW;IACb,KAAK,CAAe;IAE7B;;OAEG;IACH,YAAY,IAAkB;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,MAAuB;QAChC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE;gBACL,KAAK,EAAE,MAAM,EAAE,KAAK;gBACpB,OAAO,EAAE,MAAM,EAAE,OAAO;gBACxB,SAAS,EAAE,MAAM,EAAE,SAAS;gBAC5B,YAAY,EAAE,MAAM,EAAE,YAAY;gBAClC,SAAS,EAAE,MAAM,EAAE,SAAS;gBAC5B,KAAK,EAAE,MAAM,EAAE,KAAK;aACrB;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAkB,GAAG,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC;CACF"}
|