@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.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/src/client.d.ts +33 -1
  3. package/dist/src/client.d.ts.map +1 -1
  4. package/dist/src/client.js +34 -1
  5. package/dist/src/client.js.map +1 -1
  6. package/dist/src/console/api-calls.d.ts +80 -0
  7. package/dist/src/console/api-calls.d.ts.map +1 -0
  8. package/dist/src/console/api-calls.js +69 -0
  9. package/dist/src/console/api-calls.js.map +1 -0
  10. package/dist/src/console/apps.d.ts +689 -0
  11. package/dist/src/console/apps.d.ts.map +1 -0
  12. package/dist/src/console/apps.js +402 -0
  13. package/dist/src/console/apps.js.map +1 -0
  14. package/dist/src/console/auth.d.ts +241 -0
  15. package/dist/src/console/auth.d.ts.map +1 -0
  16. package/dist/src/console/auth.js +173 -0
  17. package/dist/src/console/auth.js.map +1 -0
  18. package/dist/src/console/connections.d.ts +188 -0
  19. package/dist/src/console/connections.d.ts.map +1 -0
  20. package/dist/src/console/connections.js +182 -0
  21. package/dist/src/console/connections.js.map +1 -0
  22. package/dist/src/console/dashboard.d.ts +102 -0
  23. package/dist/src/console/dashboard.d.ts.map +1 -0
  24. package/dist/src/console/dashboard.js +59 -0
  25. package/dist/src/console/dashboard.js.map +1 -0
  26. package/dist/src/console/endpoints.d.ts +264 -0
  27. package/dist/src/console/endpoints.d.ts.map +1 -0
  28. package/dist/src/console/endpoints.js +164 -0
  29. package/dist/src/console/endpoints.js.map +1 -0
  30. package/dist/src/console/functions.d.ts +165 -0
  31. package/dist/src/console/functions.d.ts.map +1 -0
  32. package/dist/src/console/functions.js +117 -0
  33. package/dist/src/console/functions.js.map +1 -0
  34. package/dist/src/console/mod.d.ts +131 -0
  35. package/dist/src/console/mod.d.ts.map +1 -0
  36. package/dist/src/console/mod.js +121 -0
  37. package/dist/src/console/mod.js.map +1 -0
  38. package/dist/src/console/projects.d.ts +107 -0
  39. package/dist/src/console/projects.d.ts.map +1 -0
  40. package/dist/src/console/projects.js +97 -0
  41. package/dist/src/console/projects.js.map +1 -0
  42. package/dist/src/console/reliability.d.ts +149 -0
  43. package/dist/src/console/reliability.d.ts.map +1 -0
  44. package/dist/src/console/reliability.js +56 -0
  45. package/dist/src/console/reliability.js.map +1 -0
  46. package/dist/src/console/saved-tests.d.ts +198 -0
  47. package/dist/src/console/saved-tests.d.ts.map +1 -0
  48. package/dist/src/console/saved-tests.js +172 -0
  49. package/dist/src/console/saved-tests.js.map +1 -0
  50. package/dist/src/console/schedules.d.ts +127 -0
  51. package/dist/src/console/schedules.d.ts.map +1 -0
  52. package/dist/src/console/schedules.js +118 -0
  53. package/dist/src/console/schedules.js.map +1 -0
  54. package/dist/src/console/step-tests.d.ts +159 -0
  55. package/dist/src/console/step-tests.d.ts.map +1 -0
  56. package/dist/src/console/step-tests.js +129 -0
  57. package/dist/src/console/step-tests.js.map +1 -0
  58. package/dist/src/console/subscriptions.d.ts +199 -0
  59. package/dist/src/console/subscriptions.d.ts.map +1 -0
  60. package/dist/src/console/subscriptions.js +191 -0
  61. package/dist/src/console/subscriptions.js.map +1 -0
  62. package/dist/src/console/tenant-oauth-apps.d.ts +188 -0
  63. package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -0
  64. package/dist/src/console/tenant-oauth-apps.js +152 -0
  65. package/dist/src/console/tenant-oauth-apps.js.map +1 -0
  66. package/dist/src/console/tokens.d.ts +159 -0
  67. package/dist/src/console/tokens.d.ts.map +1 -0
  68. package/dist/src/console/tokens.js +145 -0
  69. package/dist/src/console/tokens.js.map +1 -0
  70. package/dist/src/console/vault.d.ts +188 -0
  71. package/dist/src/console/vault.d.ts.map +1 -0
  72. package/dist/src/console/vault.js +164 -0
  73. package/dist/src/console/vault.js.map +1 -0
  74. package/dist/src/console/workflows.d.ts +243 -0
  75. package/dist/src/console/workflows.d.ts.map +1 -0
  76. package/dist/src/console/workflows.js +205 -0
  77. package/dist/src/console/workflows.js.map +1 -0
  78. package/dist/src/http.d.ts +32 -2
  79. package/dist/src/http.d.ts.map +1 -1
  80. package/dist/src/http.js +11 -2
  81. package/dist/src/http.js.map +1 -1
  82. package/dist/src/types.d.ts +2 -2
  83. package/dist/src/types.d.ts.map +1 -1
  84. package/dist/src/version.js +1 -1
  85. package/dist/src/workflows.d.ts +11 -4
  86. package/dist/src/workflows.d.ts.map +1 -1
  87. package/dist/src/workflows.js +3 -3
  88. package/dist/src/workflows.js.map +1 -1
  89. package/package.json +5 -1
@@ -0,0 +1,149 @@
1
+ /**
2
+ * `client.console.reliability.*` — the account-scoped reliability board,
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: `list`, `GET /reliability/services`. Unlike `documents`/
15
+ * `vars`, the server's response carries **no envelope key** — the
16
+ * `ReliabilityServices`-shaped object IS the top-level response body
17
+ * (verified against `packages/server/packages/api/admin/reliability.ts:407-432`,
18
+ * which answers `c.json(board)`) — so `list` returns `res.body` directly and
19
+ * never calls this package's `unwrap()` helper.
20
+ *
21
+ * @module
22
+ */
23
+ import type { HttpResponse, RequestOptions } from "../http.ts";
24
+ /**
25
+ * The slice of `W6wClient` this namespace needs: the transport, and nothing
26
+ * else. Structural rather than a concrete client type, so the namespace stays
27
+ * independently constructible in a test and this module never imports the
28
+ * client back — mirrors `VarsHost` in `../vars.ts`.
29
+ */
30
+ export interface ReliabilityHost {
31
+ /** Perform one request. */
32
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
33
+ }
34
+ /**
35
+ * The four states a service (or one of its days) can be in — the RFC's
36
+ * `HealthReport.state` union (`core/rfcs/healthcheck.md`). There is no fifth
37
+ * state: a service the account made no calls to is `unknown`, never `ok`.
38
+ */
39
+ export type ReliabilityState = "ok" | "degraded" | "down" | "unknown";
40
+ /** The error mix the server counts per service and per day. Names are wire-pinned. */
41
+ export interface ReliabilityErrorMix {
42
+ e4xx: number;
43
+ e429: number;
44
+ eAuth: number;
45
+ e5xx: number;
46
+ }
47
+ /** One calendar day of one service's uptime strip. */
48
+ export interface ReliabilityUptimeDay {
49
+ day: string;
50
+ state: ReliabilityState;
51
+ calls: number;
52
+ errors: ReliabilityErrorMix;
53
+ }
54
+ /** The vendor's own verdict for one service. See `ReliabilityService.vendorStatus`. */
55
+ export interface ReliabilityVendorStatus {
56
+ state: ReliabilityState;
57
+ /** The deciding check's own words, rendered verbatim. Null when all clear. */
58
+ message: string | null;
59
+ checkedAt: string;
60
+ /** Keys of the checks behind a non-`ok` verdict. Empty when `ok`. */
61
+ attributedTo: string[];
62
+ }
63
+ /** One row of the service board — a single external service the account calls. */
64
+ export interface ReliabilityService {
65
+ appId: string;
66
+ displayName: string;
67
+ state: ReliabilityState;
68
+ hasDeclaredHealth: boolean;
69
+ calls: number;
70
+ errors: ReliabilityErrorMix;
71
+ /** Null when the window holds no timed calls (the board renders "—"). */
72
+ p95Ms: number | null;
73
+ openAdvisories: number;
74
+ /** Non-null while an outage is still open. */
75
+ ongoingOutageId: string | null;
76
+ /** Null when the account has never called this service. Drives the server's
77
+ * recency ordering (`?limit=N`) — the client never re-sorts by it. */
78
+ lastCallAt: string | null;
79
+ /**
80
+ * Gap-free, exactly `window.days` entries, ONE PER CALENDAR DAY, OLDEST FIRST —
81
+ * including days with no data (`state: "unknown"`, `calls: 0`). The client
82
+ * never synthesises a missing day and never re-sorts: if entries are missing or
83
+ * out of order that is a server bug to report, not to paper over.
84
+ */
85
+ uptime: ReliabilityUptimeDay[];
86
+ /**
87
+ * What the VENDOR publishes about itself, from the app's declared public
88
+ * health check (Slack's `status.slack.com`, SendGrid's status page, …).
89
+ *
90
+ * A SECOND, INDEPENDENT signal — never a restatement of `state` above, which
91
+ * is strictly "did your calls succeed". Your credential can be revoked while
92
+ * the vendor is green, and the vendor can be down in a window where you made
93
+ * no calls at all, so the board shows both and folds neither into the other.
94
+ *
95
+ * `null` means the app publishes no public check — a different fact from
96
+ * `state: "unknown"` ("it publishes one and we could not read it"), and the
97
+ * board renders them differently.
98
+ */
99
+ vendorStatus: ReliabilityVendorStatus | null;
100
+ }
101
+ /**
102
+ * Account-scoped reliability board (server `GET /reliability/services?days=…`,
103
+ * T4.1.1). A free-form fetch seam, so this shape mirrors the server envelope
104
+ * field for field — the field names below are PINNED by
105
+ * `contracts/T4.1.1.contract.md` and must not be renamed on either side. This
106
+ * relocates that pin from `packages/studio/src/api/client.ts:212-295` rather
107
+ * than redesigning it.
108
+ */
109
+ export interface ReliabilityServices {
110
+ account: string;
111
+ window: {
112
+ from: string;
113
+ to: string;
114
+ days: number;
115
+ };
116
+ /** The server's own wording for what "uptime" measures here — displayed verbatim. */
117
+ uptimeMeans: string;
118
+ definition: {
119
+ id: string;
120
+ version: string;
121
+ source: string;
122
+ };
123
+ services: ReliabilityService[];
124
+ }
125
+ /**
126
+ * The `console.reliability` namespace on a `W6wClient`.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const board = await client.console.reliability.list(30, 5);
131
+ * ```
132
+ */
133
+ export declare class ReliabilityApi {
134
+ #private;
135
+ /**
136
+ * @param host - The client this namespace issues requests through.
137
+ */
138
+ constructor(host: ReliabilityHost);
139
+ /**
140
+ * Fetch the account-scoped reliability board.
141
+ *
142
+ * @param days - The window size in days. Omitted, the server applies its own default.
143
+ * @param limit - Cap on the number of services returned, most-recently-called first. Omitted, no cap.
144
+ * @returns The board, exactly as the server sent it — no envelope key to peel.
145
+ * @throws {ApiError} On any non-2xx.
146
+ */
147
+ list(days?: number, limit?: number): Promise<ReliabilityServices>;
148
+ }
149
+ //# sourceMappingURL=reliability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reliability.d.ts","sourceRoot":"","sources":["../../../src/console/reliability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;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;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtE,sFAAsF;AACtF,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,uFAAuF;AACvF,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,gBAAgB,CAAC;IACxB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,gBAAgB,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,CAAC;IAC5B,yEAAyE;IACzE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;0EACsE;IACtE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;OAKG;IACH,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAC9C;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,qFAAqF;IACrF,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,qBAAa,cAAc;;IAGzB;;OAEG;gBACS,IAAI,EAAE,eAAe;IAIjC;;;;;;;OAOG;IACG,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAQxE"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `client.console.reliability.*` — the account-scoped reliability board,
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: `list`, `GET /reliability/services`. Unlike `documents`/
15
+ * `vars`, the server's response carries **no envelope key** — the
16
+ * `ReliabilityServices`-shaped object IS the top-level response body
17
+ * (verified against `packages/server/packages/api/admin/reliability.ts:407-432`,
18
+ * which answers `c.json(board)`) — so `list` returns `res.body` directly and
19
+ * never calls this package's `unwrap()` helper.
20
+ *
21
+ * @module
22
+ */
23
+ /**
24
+ * The `console.reliability` namespace on a `W6wClient`.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const board = await client.console.reliability.list(30, 5);
29
+ * ```
30
+ */
31
+ export class ReliabilityApi {
32
+ #host;
33
+ /**
34
+ * @param host - The client this namespace issues requests through.
35
+ */
36
+ constructor(host) {
37
+ this.#host = host;
38
+ }
39
+ /**
40
+ * Fetch the account-scoped reliability board.
41
+ *
42
+ * @param days - The window size in days. Omitted, the server applies its own default.
43
+ * @param limit - Cap on the number of services returned, most-recently-called first. Omitted, no cap.
44
+ * @returns The board, exactly as the server sent it — no envelope key to peel.
45
+ * @throws {ApiError} On any non-2xx.
46
+ */
47
+ async list(days, limit) {
48
+ const res = await this.#host.request({
49
+ method: "GET",
50
+ path: "/reliability/services",
51
+ query: { days, limit },
52
+ });
53
+ return res.body;
54
+ }
55
+ }
56
+ //# sourceMappingURL=reliability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reliability.js","sourceRoot":"","sources":["../../../src/console/reliability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwGH;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAChB,KAAK,CAAkB;IAEhC;;OAEG;IACH,YAAY,IAAqB;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,IAAa,EAAE,KAAc;QACtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB;YACxD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB;YAC7B,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;SACvB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * `client.console.savedTests.*` — reusable, connection-scoped named test
3
+ * inputs for an app action, plus the tester's run-log, relocated from the
4
+ * 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
+ * Six methods relocate from the studio's own `// Saved tests` comment block
16
+ * (`packages/studio/src/api/client.ts:259-315` on the studio base tree) —
17
+ * field-for-field, not redesigned.
18
+ *
19
+ * **`recordTestRun` returns the REAL created row, not `void`.** Studio's
20
+ * current `client.ts` discards it to `void` (`.then(() => {})`) only so its
21
+ * `api` object stays assignable to `@w6w/ui`'s `W6wApi.recordTestRun`
22
+ * (typed `Promise<void>`, `packages/ui/src/provider.tsx:168-177`) — that is
23
+ * STUDIO's constraint, not the SDK's. Mirrors T2.2.1's `deleteApp` precedent:
24
+ * a "complete client" returns genuinely informative data and discards only
25
+ * boilerplate (`delete` below discards the true-boilerplate `{ok:true}`).
26
+ * The void-discard for `recordTestRun` happens at studio's own repo layer
27
+ * (`src/repos/saved-tests.ts`, a later task), not here.
28
+ *
29
+ * None of these methods take a `project` scoping parameter — saved tests
30
+ * carry no `?project=`, the server scopes by connection/tenant — so
31
+ * `SavedTestsHost` needs only the transport, mirroring `ConnectionsHost`, not
32
+ * `DocumentsHost`.
33
+ *
34
+ * @module
35
+ */
36
+ import { type HttpResponse, type RequestOptions } from "../http.ts";
37
+ /**
38
+ * The slice of `W6wClient` this namespace needs: the transport, and nothing
39
+ * else. Structural rather than a concrete client type, so the namespace stays
40
+ * independently constructible in a test and this module never imports the
41
+ * client back — mirrors `ConnectionsHost` in `./connections.ts`.
42
+ */
43
+ export interface SavedTestsHost {
44
+ /** Perform one request. */
45
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
46
+ }
47
+ /**
48
+ * A saved test — a named set of input values for an app action, scoped to a
49
+ * connection. Lets a caller re-run an action with a remembered payload.
50
+ */
51
+ export interface SavedTest {
52
+ id: string;
53
+ connectionId: string;
54
+ appId: string;
55
+ actionKey: string;
56
+ name: string;
57
+ values: Record<string, unknown>;
58
+ createdAt: string;
59
+ updatedAt: string;
60
+ /** When this saved test was last run (ISO), or null/undefined if never run. */
61
+ lastRunAt?: string | null;
62
+ /** Whether the most recent run succeeded, or null/undefined if never run. */
63
+ lastRunOk?: boolean | null;
64
+ /** Short headline for the most recent run's outcome, or null/undefined if never run. */
65
+ lastRunSummary?: string | null;
66
+ }
67
+ /**
68
+ * One row from a connection's `run_log`-backed test-run history (thin — NOT
69
+ * the full `SavedTestRun` create response; the full `result` payload stays
70
+ * server-side).
71
+ */
72
+ export interface TestRunSummary {
73
+ id: string;
74
+ actionKey: string;
75
+ ok: boolean;
76
+ summary: string | null;
77
+ occurredAt: string;
78
+ }
79
+ /** The real row `recordTestRun` creates (mirrors the server's `SavedTestRun`). */
80
+ export interface SavedTestRun {
81
+ id: string;
82
+ savedTestId: string | null;
83
+ connectionId: string;
84
+ appId: string;
85
+ actionKey: string;
86
+ ok: boolean;
87
+ summary: string | null;
88
+ result: unknown;
89
+ createdAt: string;
90
+ }
91
+ /**
92
+ * The `console.savedTests` namespace on a `W6wClient`.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const tests = await client.console.savedTests.list("conn_1");
97
+ * const created = await client.console.savedTests.create("conn_1", {
98
+ * actionKey: "send",
99
+ * name: "Happy path",
100
+ * values: { to: "a@b.com" },
101
+ * });
102
+ * const run = await client.console.savedTests.recordTestRun("conn_1", {
103
+ * savedTestId: created.id,
104
+ * actionKey: "send",
105
+ * ok: true,
106
+ * });
107
+ * await client.console.savedTests.delete("conn_1", created.id);
108
+ * ```
109
+ */
110
+ export declare class SavedTestsApi {
111
+ #private;
112
+ /**
113
+ * @param host - The client this namespace issues requests through.
114
+ */
115
+ constructor(host: SavedTestsHost);
116
+ /**
117
+ * List a connection's saved tests.
118
+ *
119
+ * @param connectionId - The `conn_…` id.
120
+ * @returns The saved tests, unwrapped from the `savedTests` envelope.
121
+ * @throws {ApiError} `404 unknown_connection` when there is no such connection.
122
+ */
123
+ list(connectionId: string): Promise<SavedTest[]>;
124
+ /**
125
+ * Create a saved test for a connection.
126
+ *
127
+ * @param connectionId - The `conn_…` id.
128
+ * @param body - `actionKey` and `name` (unique per connection), plus the
129
+ * `values` payload to remember — forwarded verbatim.
130
+ * @returns The created saved test, unwrapped from the `savedTest` envelope (the server answers `201`).
131
+ * @throws {ApiError} `400 invalid_name`/`invalid_action_key`/`invalid_values`;
132
+ * `404 unknown_connection`; `409 duplicate_saved_test`.
133
+ */
134
+ create(connectionId: string, body: {
135
+ actionKey: string;
136
+ name: string;
137
+ values: Record<string, unknown>;
138
+ }): Promise<SavedTest>;
139
+ /**
140
+ * Update a saved test: rename it and/or replace its `values`.
141
+ *
142
+ * @param connectionId - The `conn_…` id.
143
+ * @param id - The saved test's id.
144
+ * @param patch - `name` and/or `values`, forwarded verbatim.
145
+ * @returns The updated saved test, unwrapped from the `savedTest` envelope.
146
+ * @throws {ApiError} `400 invalid_name`/`invalid_values`; `404 unknown_saved_test`;
147
+ * `409 duplicate_saved_test`.
148
+ */
149
+ update(connectionId: string, id: string, patch: {
150
+ name?: string;
151
+ values?: Record<string, unknown>;
152
+ }): Promise<SavedTest>;
153
+ /**
154
+ * Delete a saved test.
155
+ *
156
+ * Returns nothing: the server's `{ok: true}` carries no information a
157
+ * caller can use — true boilerplate, unlike {@linkcode recordTestRun}
158
+ * below, which preserves its real row.
159
+ *
160
+ * @param connectionId - The `conn_…` id.
161
+ * @param id - The saved test's id.
162
+ * @throws {ApiError} `404 unknown_saved_test` when there is no such id.
163
+ */
164
+ delete(connectionId: string, id: string): Promise<void>;
165
+ /**
166
+ * Record the outcome of an action-test run against a connection. Appends a
167
+ * run-log row server-side; when `savedTestId` is present, the saved test's
168
+ * `lastRun*` fields are updated too.
169
+ *
170
+ * Returns the REAL created row — see this module's header. Does NOT
171
+ * discard to `void`; a caller wanting the studio-facade `void` shape
172
+ * adapts it themselves.
173
+ *
174
+ * @param connectionId - The `conn_…` id.
175
+ * @param body - `savedTestId` (optional), `actionKey`, `ok`, and optional
176
+ * `summary`/`result`, forwarded verbatim.
177
+ * @returns The created `SavedTestRun`, unwrapped from the `run` envelope (the server answers `201`).
178
+ * @throws {ApiError} `404 unknown_connection` when there is no such connection.
179
+ */
180
+ recordTestRun(connectionId: string, body: {
181
+ savedTestId?: string | null;
182
+ actionKey: string;
183
+ ok: boolean;
184
+ summary?: string;
185
+ result?: unknown;
186
+ }): Promise<SavedTestRun>;
187
+ /**
188
+ * Run history for a connection from the unified `run_log` ledger — thin
189
+ * rows; the full `result` payload from {@linkcode recordTestRun} stays
190
+ * server-side.
191
+ *
192
+ * @param connectionId - The `conn_…` id.
193
+ * @returns The runs, most-recent-first, unwrapped from the `runs` envelope.
194
+ * @throws {ApiError} `404 unknown_connection` when there is no such connection.
195
+ */
196
+ listTestRuns(connectionId: string): Promise<TestRunSummary[]>;
197
+ }
198
+ //# sourceMappingURL=saved-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-tests.d.ts","sourceRoot":"","sources":["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YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAOpE"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * `client.console.savedTests.*` — reusable, connection-scoped named test
3
+ * inputs for an app action, plus the tester's run-log, relocated from the
4
+ * 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
+ * Six methods relocate from the studio's own `// Saved tests` comment block
16
+ * (`packages/studio/src/api/client.ts:259-315` on the studio base tree) —
17
+ * field-for-field, not redesigned.
18
+ *
19
+ * **`recordTestRun` returns the REAL created row, not `void`.** Studio's
20
+ * current `client.ts` discards it to `void` (`.then(() => {})`) only so its
21
+ * `api` object stays assignable to `@w6w/ui`'s `W6wApi.recordTestRun`
22
+ * (typed `Promise<void>`, `packages/ui/src/provider.tsx:168-177`) — that is
23
+ * STUDIO's constraint, not the SDK's. Mirrors T2.2.1's `deleteApp` precedent:
24
+ * a "complete client" returns genuinely informative data and discards only
25
+ * boilerplate (`delete` below discards the true-boilerplate `{ok:true}`).
26
+ * The void-discard for `recordTestRun` happens at studio's own repo layer
27
+ * (`src/repos/saved-tests.ts`, a later task), not here.
28
+ *
29
+ * None of these methods take a `project` scoping parameter — saved tests
30
+ * carry no `?project=`, the server scopes by connection/tenant — so
31
+ * `SavedTestsHost` needs only the transport, mirroring `ConnectionsHost`, not
32
+ * `DocumentsHost`.
33
+ *
34
+ * @module
35
+ */
36
+ import { path } from "../http.js";
37
+ import { unwrap } from "../types.js";
38
+ /**
39
+ * The `console.savedTests` namespace on a `W6wClient`.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const tests = await client.console.savedTests.list("conn_1");
44
+ * const created = await client.console.savedTests.create("conn_1", {
45
+ * actionKey: "send",
46
+ * name: "Happy path",
47
+ * values: { to: "a@b.com" },
48
+ * });
49
+ * const run = await client.console.savedTests.recordTestRun("conn_1", {
50
+ * savedTestId: created.id,
51
+ * actionKey: "send",
52
+ * ok: true,
53
+ * });
54
+ * await client.console.savedTests.delete("conn_1", created.id);
55
+ * ```
56
+ */
57
+ export class SavedTestsApi {
58
+ #host;
59
+ /**
60
+ * @param host - The client this namespace issues requests through.
61
+ */
62
+ constructor(host) {
63
+ this.#host = host;
64
+ }
65
+ /**
66
+ * List a connection's saved tests.
67
+ *
68
+ * @param connectionId - The `conn_…` id.
69
+ * @returns The saved tests, unwrapped from the `savedTests` envelope.
70
+ * @throws {ApiError} `404 unknown_connection` when there is no such connection.
71
+ */
72
+ async list(connectionId) {
73
+ const res = await this.#host.request({
74
+ method: "GET",
75
+ path: path `/connections/${connectionId}/saved-tests`,
76
+ });
77
+ return unwrap(res, "savedTests");
78
+ }
79
+ /**
80
+ * Create a saved test for a connection.
81
+ *
82
+ * @param connectionId - The `conn_…` id.
83
+ * @param body - `actionKey` and `name` (unique per connection), plus the
84
+ * `values` payload to remember — forwarded verbatim.
85
+ * @returns The created saved test, unwrapped from the `savedTest` envelope (the server answers `201`).
86
+ * @throws {ApiError} `400 invalid_name`/`invalid_action_key`/`invalid_values`;
87
+ * `404 unknown_connection`; `409 duplicate_saved_test`.
88
+ */
89
+ async create(connectionId, body) {
90
+ const res = await this.#host.request({
91
+ method: "POST",
92
+ path: path `/connections/${connectionId}/saved-tests`,
93
+ body,
94
+ });
95
+ return unwrap(res, "savedTest");
96
+ }
97
+ /**
98
+ * Update a saved test: rename it and/or replace its `values`.
99
+ *
100
+ * @param connectionId - The `conn_…` id.
101
+ * @param id - The saved test's id.
102
+ * @param patch - `name` and/or `values`, forwarded verbatim.
103
+ * @returns The updated saved test, unwrapped from the `savedTest` envelope.
104
+ * @throws {ApiError} `400 invalid_name`/`invalid_values`; `404 unknown_saved_test`;
105
+ * `409 duplicate_saved_test`.
106
+ */
107
+ async update(connectionId, id, patch) {
108
+ const res = await this.#host.request({
109
+ method: "PATCH",
110
+ path: path `/connections/${connectionId}/saved-tests/${id}`,
111
+ body: patch,
112
+ });
113
+ return unwrap(res, "savedTest");
114
+ }
115
+ /**
116
+ * Delete a saved test.
117
+ *
118
+ * Returns nothing: the server's `{ok: true}` carries no information a
119
+ * caller can use — true boilerplate, unlike {@linkcode recordTestRun}
120
+ * below, which preserves its real row.
121
+ *
122
+ * @param connectionId - The `conn_…` id.
123
+ * @param id - The saved test's id.
124
+ * @throws {ApiError} `404 unknown_saved_test` when there is no such id.
125
+ */
126
+ async delete(connectionId, id) {
127
+ await this.#host.request({
128
+ method: "DELETE",
129
+ path: path `/connections/${connectionId}/saved-tests/${id}`,
130
+ });
131
+ }
132
+ /**
133
+ * Record the outcome of an action-test run against a connection. Appends a
134
+ * run-log row server-side; when `savedTestId` is present, the saved test's
135
+ * `lastRun*` fields are updated too.
136
+ *
137
+ * Returns the REAL created row — see this module's header. Does NOT
138
+ * discard to `void`; a caller wanting the studio-facade `void` shape
139
+ * adapts it themselves.
140
+ *
141
+ * @param connectionId - The `conn_…` id.
142
+ * @param body - `savedTestId` (optional), `actionKey`, `ok`, and optional
143
+ * `summary`/`result`, forwarded verbatim.
144
+ * @returns The created `SavedTestRun`, unwrapped from the `run` envelope (the server answers `201`).
145
+ * @throws {ApiError} `404 unknown_connection` when there is no such connection.
146
+ */
147
+ async recordTestRun(connectionId, body) {
148
+ const res = await this.#host.request({
149
+ method: "POST",
150
+ path: path `/connections/${connectionId}/test-runs`,
151
+ body,
152
+ });
153
+ return unwrap(res, "run");
154
+ }
155
+ /**
156
+ * Run history for a connection from the unified `run_log` ledger — thin
157
+ * rows; the full `result` payload from {@linkcode recordTestRun} stays
158
+ * server-side.
159
+ *
160
+ * @param connectionId - The `conn_…` id.
161
+ * @returns The runs, most-recent-first, unwrapped from the `runs` envelope.
162
+ * @throws {ApiError} `404 unknown_connection` when there is no such connection.
163
+ */
164
+ async listTestRuns(connectionId) {
165
+ const res = await this.#host.request({
166
+ method: "GET",
167
+ path: path `/connections/${connectionId}/test-runs`,
168
+ });
169
+ return unwrap(res, "runs");
170
+ }
171
+ }
172
+ //# sourceMappingURL=saved-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-tests.js","sourceRoot":"","sources":["../../../src/console/saved-tests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAqB,IAAI,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA4DrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,aAAa;IACf,KAAK,CAAiB;IAE/B;;OAEG;IACH,YAAY,IAAoB;QAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,YAAoB;QAC7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,CAAA,gBAAgB,YAAY,cAAc;SACrD,CAAC,CAAC;QACH,OAAO,MAAM,CAAc,GAAG,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CACV,YAAoB,EACpB,IAA0E;QAE1E,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAA,gBAAgB,YAAY,cAAc;YACpD,IAAI;SACL,CAAC,CAAC;QACH,OAAO,MAAM,CAAY,GAAG,EAAE,WAAW,CAAC,CAAC;IA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