@w6w/sdk 0.3.0 → 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 (84) hide show
  1. package/dist/src/client.d.ts +28 -0
  2. package/dist/src/client.d.ts.map +1 -1
  3. package/dist/src/client.js +29 -0
  4. package/dist/src/client.js.map +1 -1
  5. package/dist/src/console/api-calls.d.ts +80 -0
  6. package/dist/src/console/api-calls.d.ts.map +1 -0
  7. package/dist/src/console/api-calls.js +69 -0
  8. package/dist/src/console/api-calls.js.map +1 -0
  9. package/dist/src/console/apps.d.ts +689 -0
  10. package/dist/src/console/apps.d.ts.map +1 -0
  11. package/dist/src/console/apps.js +402 -0
  12. package/dist/src/console/apps.js.map +1 -0
  13. package/dist/src/console/auth.d.ts +241 -0
  14. package/dist/src/console/auth.d.ts.map +1 -0
  15. package/dist/src/console/auth.js +173 -0
  16. package/dist/src/console/auth.js.map +1 -0
  17. package/dist/src/console/connections.d.ts +188 -0
  18. package/dist/src/console/connections.d.ts.map +1 -0
  19. package/dist/src/console/connections.js +182 -0
  20. package/dist/src/console/connections.js.map +1 -0
  21. package/dist/src/console/dashboard.d.ts +102 -0
  22. package/dist/src/console/dashboard.d.ts.map +1 -0
  23. package/dist/src/console/dashboard.js +59 -0
  24. package/dist/src/console/dashboard.js.map +1 -0
  25. package/dist/src/console/endpoints.d.ts +264 -0
  26. package/dist/src/console/endpoints.d.ts.map +1 -0
  27. package/dist/src/console/endpoints.js +164 -0
  28. package/dist/src/console/endpoints.js.map +1 -0
  29. package/dist/src/console/functions.d.ts +165 -0
  30. package/dist/src/console/functions.d.ts.map +1 -0
  31. package/dist/src/console/functions.js +117 -0
  32. package/dist/src/console/functions.js.map +1 -0
  33. package/dist/src/console/mod.d.ts +131 -0
  34. package/dist/src/console/mod.d.ts.map +1 -0
  35. package/dist/src/console/mod.js +121 -0
  36. package/dist/src/console/mod.js.map +1 -0
  37. package/dist/src/console/projects.d.ts +107 -0
  38. package/dist/src/console/projects.d.ts.map +1 -0
  39. package/dist/src/console/projects.js +97 -0
  40. package/dist/src/console/projects.js.map +1 -0
  41. package/dist/src/console/reliability.d.ts +149 -0
  42. package/dist/src/console/reliability.d.ts.map +1 -0
  43. package/dist/src/console/reliability.js +56 -0
  44. package/dist/src/console/reliability.js.map +1 -0
  45. package/dist/src/console/saved-tests.d.ts +198 -0
  46. package/dist/src/console/saved-tests.d.ts.map +1 -0
  47. package/dist/src/console/saved-tests.js +172 -0
  48. package/dist/src/console/saved-tests.js.map +1 -0
  49. package/dist/src/console/schedules.d.ts +127 -0
  50. package/dist/src/console/schedules.d.ts.map +1 -0
  51. package/dist/src/console/schedules.js +118 -0
  52. package/dist/src/console/schedules.js.map +1 -0
  53. package/dist/src/console/step-tests.d.ts +159 -0
  54. package/dist/src/console/step-tests.d.ts.map +1 -0
  55. package/dist/src/console/step-tests.js +129 -0
  56. package/dist/src/console/step-tests.js.map +1 -0
  57. package/dist/src/console/subscriptions.d.ts +199 -0
  58. package/dist/src/console/subscriptions.d.ts.map +1 -0
  59. package/dist/src/console/subscriptions.js +191 -0
  60. package/dist/src/console/subscriptions.js.map +1 -0
  61. package/dist/src/console/tenant-oauth-apps.d.ts +188 -0
  62. package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -0
  63. package/dist/src/console/tenant-oauth-apps.js +152 -0
  64. package/dist/src/console/tenant-oauth-apps.js.map +1 -0
  65. package/dist/src/console/tokens.d.ts +159 -0
  66. package/dist/src/console/tokens.d.ts.map +1 -0
  67. package/dist/src/console/tokens.js +145 -0
  68. package/dist/src/console/tokens.js.map +1 -0
  69. package/dist/src/console/vault.d.ts +188 -0
  70. package/dist/src/console/vault.d.ts.map +1 -0
  71. package/dist/src/console/vault.js +164 -0
  72. package/dist/src/console/vault.js.map +1 -0
  73. package/dist/src/console/workflows.d.ts +243 -0
  74. package/dist/src/console/workflows.d.ts.map +1 -0
  75. package/dist/src/console/workflows.js +205 -0
  76. package/dist/src/console/workflows.js.map +1 -0
  77. package/dist/src/http.d.ts +32 -2
  78. package/dist/src/http.d.ts.map +1 -1
  79. package/dist/src/http.js +11 -2
  80. package/dist/src/http.js.map +1 -1
  81. package/dist/src/types.d.ts +2 -2
  82. package/dist/src/types.d.ts.map +1 -1
  83. package/dist/src/version.js +1 -1
  84. package/package.json +5 -1
@@ -0,0 +1,689 @@
1
+ /**
2
+ * `client.console.apps.*` — the app catalog (install, inspect, invoke,
3
+ * per-installation OAuth config), relocated from the studio's own API
4
+ * 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
+ * **The largest single domain in this project** — 16 methods, relocated from
16
+ * `packages/studio/src/api/client.ts`'s single `// Apps` comment block
17
+ * (`client.ts:235-393` on the studio base tree). Method names below are
18
+ * SHORTENED (dropping the `App`/`Apps` prefix `client.ts`'s flat method names
19
+ * carry) to match `console.projects`'s/`console.schedules`'s own short-verb
20
+ * convention — a naming-only change: every wire call (method/path/body/query)
21
+ * is unchanged.
22
+ *
23
+ * **`listApiCalls` is deliberately NOT modeled here** — it lives under the
24
+ * same `client.ts` comment block but has no named apps-domain consumer (its
25
+ * only caller is reliability's drill-down page); it groups with a future
26
+ * `reliability`+`api-calls` sub-project instead. See this task's contract
27
+ * Requirement and `plan.md`'s FINDINGS DISPOSITION.
28
+ *
29
+ * **Two live server routes with zero client-side coverage ever are also
30
+ * excluded**: `DELETE /apps/:id/versions/:version` and
31
+ * `PATCH /apps/:id/lifecycle` — both `requireOperator`-gated, neither was ever
32
+ * wrapped in `client.ts` at all (not just zero callers). `requireOperator`
33
+ * otherwise has no bearing on this file: access control is unaffected by this
34
+ * relocation — every route reachable through `console.*` (this domain
35
+ * included) requires only an authenticated principal client-side, and the
36
+ * console/partner split is a naming and export-surface fence, not an
37
+ * authorization boundary. The methods below that DO happen to hit a
38
+ * `requireOperator` route server-side (`listOAuthConfig`,
39
+ * `upsertOAuthConfig`, `deleteOAuthConfig`, `preview`, `refresh`) still send
40
+ * the request the same way as every other method here; a non-operator caller
41
+ * simply gets a `403` back from the server like any other `ApiError`.
42
+ *
43
+ * **Four methods are HITL-4 dead code** — `getHealth`, `listOAuthConfig`,
44
+ * `upsertOAuthConfig`, `deleteOAuthConfig` have zero call sites anywhere in
45
+ * studio or `@w6w/ui`. They are still built to full type fidelity (real
46
+ * implementation, JSDoc, `@throws`) for SDK/wrapper coverage; only the test
47
+ * bar for them is deliberately lighter.
48
+ *
49
+ * **`delete`'s return value is a deliberate asymmetry** vs. `projects.delete`
50
+ * and `schedules.delete` in this same package: those two discard the server's
51
+ * uninformative `{ok: true}` and resolve `void`. This app-catalog delete does
52
+ * NOT — the server answers `{removed: number}`, a genuinely informative count
53
+ * (`apps-catalog.ts:646-651`), and this method preserves it instead of
54
+ * "fixing" it to match the other two.
55
+ *
56
+ * None of these 16 methods take a `project` scoping parameter — apps operate
57
+ * at the account/global level — so `AppsHost` needs only the transport,
58
+ * mirroring `VarsHost`/`ProjectsHost`, not `DocumentsHost`.
59
+ *
60
+ * @module
61
+ */
62
+ import { type HttpResponse, type RequestOptions } from "../http.ts";
63
+ /**
64
+ * The slice of `W6wClient` this namespace needs: the transport, and nothing
65
+ * else. Structural rather than a concrete client type, so the namespace stays
66
+ * independently constructible in a test and this module never imports the
67
+ * client back — mirrors `VarsHost` in `../vars.ts`.
68
+ */
69
+ export interface AppsHost {
70
+ /** Perform one request. */
71
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
72
+ }
73
+ /**
74
+ * An app's catalog summary, as `list` projects it. Field-for-field per
75
+ * `packages/studio/src/api/types.ts:10-32` — this module does not redesign
76
+ * the shape, only gives it a second home.
77
+ */
78
+ /**
79
+ * The incoming state a single-step test is run against — what the upstream
80
+ * steps last produced. The server projects it onto the scope roots an
81
+ * `ExprValue` reads (`steps.<id>.output`, `trigger.event`), so a step whose
82
+ * params reference an upstream step resolves them instead of getting `""`.
83
+ *
84
+ * Deliberately loose about `output`: it is whatever that step returned.
85
+ */
86
+ export interface InvokeStartState {
87
+ steps?: Record<string, {
88
+ output?: unknown;
89
+ }>;
90
+ trigger?: {
91
+ event?: unknown;
92
+ };
93
+ }
94
+ /** Options for {@link AppsNamespace.invoke}. */
95
+ export interface InvokeOptions {
96
+ /** Run the action with this connection; omitted, the server picks one. */
97
+ connectionId?: string;
98
+ /** Which project's vars and documents `ExprValue` params resolve against. */
99
+ project?: string;
100
+ /** Upstream state to resolve `steps.<id>.output` / `trigger.event` against. */
101
+ state?: InvokeStartState;
102
+ }
103
+ export interface AppSummary {
104
+ id: string;
105
+ displayName: string;
106
+ version: string;
107
+ description: string;
108
+ categories: string[];
109
+ sourceRef: string;
110
+ importedAt: string;
111
+ /** Inlined data: URI (or absolute URL) for the app's icon. May be empty. */
112
+ iconSvg?: string;
113
+ /** Optional dark-mode variant; when present, AppIcon uses it in dark theme. */
114
+ iconSvgDark?: string;
115
+ brandColor?: string;
116
+ brandColorDark?: string;
117
+ versionCount?: number;
118
+ maturity?: string;
119
+ visibility?: string;
120
+ successor?: string;
121
+ /** Number of health checks declared by the app's manifest. */
122
+ healthCheckCount?: number;
123
+ /** True when at least one declared health check is app-scoped and needs no credential. */
124
+ hasPublicHealthCheck?: boolean;
125
+ /**
126
+ * True when the app declares an `oauth2` auth method. Server-computed from
127
+ * `app.latest.auth` by `summarize` (`packages/server/packages/api/wire-summary.ts:81`),
128
+ * so no client ever re-derives it and no caller needs the per-app
129
+ * `GET /apps/:id/auths` read just to know whether OAuth is on the table.
130
+ */
131
+ supportsOAuth?: boolean;
132
+ /**
133
+ * Ownership sentinels: neither set -> global · `tenant` set, `subject` empty
134
+ * -> tenant-owned · both -> user-owned. Projected server-side by `wireOwner`
135
+ * (`wire-summary.ts:70-72`), which is why both members are plain strings here
136
+ * and never `undefined`.
137
+ *
138
+ * **Optional on this type even though the server always sends it**
139
+ * (`WireAppSummary.owner` at `wire-summary.ts:57` is required and has shipped
140
+ * since T2.2): the type is also satisfied by a literal a caller writes and by
141
+ * an older host, and declaring it required would break both.
142
+ */
143
+ owner?: {
144
+ tenant: string;
145
+ subject: string;
146
+ };
147
+ }
148
+ /**
149
+ * One declared parameter of an action. Field-for-field per
150
+ * `packages/studio/src/api/types.ts:35-42`.
151
+ */
152
+ export interface ActionParam {
153
+ key: string;
154
+ label?: string;
155
+ type: "string" | "text" | "number" | "boolean" | "json" | "secret" | string;
156
+ required?: boolean;
157
+ default?: unknown;
158
+ hint?: string;
159
+ }
160
+ /** An app-declared action. Field-for-field per `packages/studio/src/api/types.ts:44-51`. */
161
+ export interface ActionDef {
162
+ key: string;
163
+ type: string;
164
+ title: string;
165
+ description?: string;
166
+ params?: ActionParam[];
167
+ output?: unknown;
168
+ }
169
+ /**
170
+ * One outbound HTTP call an action made while running — the exact (redacted)
171
+ * request sent to the third-party API and the response it returned. Rides
172
+ * along with an `invoke` result. Field-for-field per
173
+ * `packages/studio/src/api/types.ts:59-80`.
174
+ */
175
+ export interface ApiCallRecord {
176
+ id?: string;
177
+ appId?: string;
178
+ actionKey?: string;
179
+ connectionId?: string | null;
180
+ sessionId?: string | null;
181
+ host: string;
182
+ method: string;
183
+ /** 0 when the request never produced a response (`error` says why). */
184
+ status: number;
185
+ url?: string;
186
+ requestHeaders?: Record<string, string>;
187
+ requestBody?: string | null;
188
+ responseHeaders?: Record<string, string>;
189
+ responseBody?: string | null;
190
+ responseBytes?: number;
191
+ durationMs?: number;
192
+ /** A captured body hit the size cap and was cut. */
193
+ truncated?: boolean;
194
+ error?: string | null;
195
+ createdAt?: string;
196
+ }
197
+ /**
198
+ * One field on an Auth method's connection form. Field-for-field per
199
+ * `packages/studio/src/api/types.ts:83-90`.
200
+ */
201
+ export interface AuthField {
202
+ key: string;
203
+ label: string;
204
+ type: "string" | "number" | "boolean" | "secret" | string;
205
+ required?: boolean;
206
+ default?: unknown;
207
+ hint?: string;
208
+ }
209
+ /**
210
+ * Auth method declaration as exposed by an app's manifest. Field-for-field
211
+ * per `packages/studio/src/api/types.ts:93-114`.
212
+ */
213
+ export interface AuthDef {
214
+ key: string;
215
+ type: "oauth2" | "apiKey" | "basic" | "bearer" | "custom" | string;
216
+ displayName?: string;
217
+ description?: string;
218
+ connectionLabel?: string;
219
+ fields?: AuthField[];
220
+ /** OAuth2 endpoints (only present when type === "oauth2"). */
221
+ oauth2?: Record<string, unknown>;
222
+ /**
223
+ * Server-side availability flag. False when the method requires per-host
224
+ * configuration that hasn't been provided yet (e.g. an oauth2 method with
225
+ * no app_oauth_config row). The connection modal filters these out.
226
+ */
227
+ available?: boolean;
228
+ /**
229
+ * Names of host-side config keys this method needs. Present on `oauth2`
230
+ * (["clientId", "clientSecret", "redirectUri"]). Empty / undefined for
231
+ * types that source everything from end-user input.
232
+ */
233
+ requiresHostConfig?: string[];
234
+ }
235
+ /**
236
+ * One entry in a pack preview — the shallow peek returned by `preview`.
237
+ * Field-for-field per `packages/studio/src/api/types.ts:120-131`.
238
+ */
239
+ export interface PackEntryPreview {
240
+ path: string;
241
+ id?: string;
242
+ displayName?: string;
243
+ version?: string;
244
+ description?: string;
245
+ alreadyRegistered: boolean;
246
+ pinnedVersion?: string;
247
+ pinnedId?: string;
248
+ optional?: boolean;
249
+ peekError?: string;
250
+ }
251
+ /** Field-for-field per `packages/studio/src/api/types.ts:133-139`. */
252
+ export interface PackPreviewInfo {
253
+ name: string;
254
+ displayName?: string;
255
+ description?: string;
256
+ version?: string;
257
+ count: number;
258
+ }
259
+ /**
260
+ * `preview`'s result — a discriminated union on `kind`. Field-for-field per
261
+ * `packages/studio/src/api/types.ts:141-143`.
262
+ */
263
+ export type PreviewSourceResponse = {
264
+ kind: "app";
265
+ sourceRef: string;
266
+ app: {
267
+ id?: string;
268
+ version?: string;
269
+ displayName?: string;
270
+ };
271
+ } | {
272
+ kind: "pack";
273
+ sourceRef: string;
274
+ pack: PackPreviewInfo;
275
+ entries: PackEntryPreview[];
276
+ };
277
+ /**
278
+ * `import`'s result — a discriminated union on `kind`. Field-for-field per
279
+ * `packages/studio/src/api/types.ts:146-172`.
280
+ */
281
+ export type ImportResponse = {
282
+ kind: "app";
283
+ sourceRef: string;
284
+ app: Record<string, unknown>;
285
+ actions: ActionDef[];
286
+ registered: boolean;
287
+ latestAdvanced: boolean;
288
+ } | {
289
+ kind: "pack";
290
+ sourceRef: string;
291
+ pack: PackPreviewInfo;
292
+ registered: number;
293
+ failed: number;
294
+ results: Array<{
295
+ path: string;
296
+ ok: true;
297
+ id: string;
298
+ version: string;
299
+ registered: boolean;
300
+ latestAdvanced: boolean;
301
+ } | {
302
+ path: string;
303
+ ok: false;
304
+ optional: boolean;
305
+ error: {
306
+ code: string;
307
+ message: string;
308
+ };
309
+ }>;
310
+ };
311
+ /**
312
+ * `refresh`'s result — a re-import from the app's recorded source.
313
+ * Field-for-field per `packages/studio/src/api/types.ts:175-188`.
314
+ */
315
+ export interface RefreshAppResponse {
316
+ app: Record<string, unknown>;
317
+ actions: ActionDef[];
318
+ sourceRef: string;
319
+ version: string;
320
+ digest: string;
321
+ /** True when the refresh stored a new version (false → content unchanged). */
322
+ registered: boolean;
323
+ latestAdvanced: boolean;
324
+ /** True when the stored version was auto-bumped past the source's manifest version. */
325
+ bumped: boolean;
326
+ /** The source manifest's version, unchanged — diff against `version` to spot a bump. */
327
+ sourceVersion: string;
328
+ }
329
+ /**
330
+ * Public projection of a stored per-installation OAuth config. Secret never
331
+ * leaves the server. Field-for-field per
332
+ * `packages/studio/src/api/types.ts:191-200`.
333
+ */
334
+ export interface OAuthConfigSummary {
335
+ appId: string;
336
+ authKey: string;
337
+ clientId: string;
338
+ redirectUri: string;
339
+ hasClientSecret: true;
340
+ extra: Record<string, unknown>;
341
+ createdAt: string;
342
+ updatedAt: string;
343
+ }
344
+ /** Health-model literal unions, mirroring @w6w/types. */
345
+ export type HealthState = "ok" | "degraded" | "down" | "unknown";
346
+ export type HealthKind = "service" | "credential" | "quota" | "dependency";
347
+ export type HealthScope = "app" | "connection";
348
+ export type CredentialPosture = "none" | "context" | "signed";
349
+ export type HealthSeverity = "fatal" | "degraded" | "informational";
350
+ /**
351
+ * Declared health-check metadata as exposed on an app detail. A thin local
352
+ * copy of the persisted `HealthCheck` (no probe fn). Field-for-field per
353
+ * `packages/studio/src/api/types.ts:213-224`.
354
+ */
355
+ export interface HealthCheckMeta {
356
+ key: string;
357
+ title: string;
358
+ description?: string;
359
+ kind: HealthKind;
360
+ scope?: HealthScope;
361
+ covers?: string[];
362
+ credential?: CredentialPosture;
363
+ severity?: HealthSeverity;
364
+ /** Present when the check can't run (e.g. missing host config); `reason` explains why. */
365
+ unavailable?: {
366
+ reason: string;
367
+ };
368
+ }
369
+ /** One quota line reported by a health probe. Field-for-field per `types.ts:227-233`. */
370
+ export interface HealthQuota {
371
+ id?: string;
372
+ limit?: number;
373
+ remaining?: number;
374
+ resetAt?: string;
375
+ unit?: string;
376
+ }
377
+ /** The outcome payload a single health probe returns. Field-for-field per `types.ts:236-243`. */
378
+ export interface HealthReport {
379
+ state: HealthState;
380
+ message?: string;
381
+ components?: Record<string, {
382
+ state: HealthState;
383
+ message?: string;
384
+ }>;
385
+ quota?: HealthQuota[];
386
+ ttlSeconds?: number;
387
+ latencyMs?: number;
388
+ }
389
+ /** One probe's result within a verdict. Field-for-field per `types.ts:246-252`. */
390
+ export interface HealthResult {
391
+ key: string;
392
+ check: HealthCheckMeta;
393
+ report: HealthReport;
394
+ checkedAt: string;
395
+ durationMs: number;
396
+ }
397
+ /**
398
+ * Live health verdict for an app, returned by `getHealthStatus`.
399
+ * Field-for-field per `packages/studio/src/api/types.ts:258-262`.
400
+ */
401
+ export interface AppHealthStatus {
402
+ state: HealthState;
403
+ attributedTo: string[];
404
+ results: HealthResult[];
405
+ }
406
+ /**
407
+ * The full app detail — one registered app's latest manifest, actions and
408
+ * overlay. Field-for-field per `packages/studio/src/api/types.ts:264-274`.
409
+ */
410
+ export interface AppDetail {
411
+ app: Record<string, unknown> & {
412
+ displayName?: string;
413
+ };
414
+ actions: ActionDef[];
415
+ health?: HealthCheckMeta[];
416
+ sourceRef: string;
417
+ version?: string;
418
+ digest?: string;
419
+ versionCount?: number;
420
+ overlay?: Record<string, unknown>;
421
+ effective?: {
422
+ maturity: string;
423
+ visibility: string;
424
+ successor?: string;
425
+ };
426
+ }
427
+ /**
428
+ * App-declared trigger as returned by `getTriggers`. Same shape as
429
+ * `ActionDef` minus `execute` — declaration only, no behavior.
430
+ * Field-for-field per `packages/studio/src/api/types.ts:426-434`.
431
+ */
432
+ export interface TriggerDef {
433
+ key: string;
434
+ title: string;
435
+ description?: string;
436
+ requiresAuth?: boolean;
437
+ params?: unknown[];
438
+ output?: unknown;
439
+ sample?: unknown;
440
+ }
441
+ /** The body of `upsertOAuthConfig`, forwarded verbatim. */
442
+ export interface UpsertOAuthConfigInput {
443
+ clientId: string;
444
+ clientSecret: string;
445
+ redirectUri: string;
446
+ extra?: Record<string, unknown>;
447
+ }
448
+ /**
449
+ * The `console.apps` namespace on a `W6wClient`.
450
+ *
451
+ * @example
452
+ * ```ts
453
+ * const apps = await client.console.apps.list();
454
+ * const detail = await client.console.apps.get(apps[0].id);
455
+ * const result = await client.console.apps.invoke(detail.app.id as string, "send", { to: "a@b.com" });
456
+ * ```
457
+ */
458
+ export declare class AppsApi {
459
+ #private;
460
+ /**
461
+ * @param host - The client this namespace issues requests through.
462
+ */
463
+ constructor(host: AppsHost);
464
+ /**
465
+ * List every registered app the caller can see.
466
+ *
467
+ * Every consumer treats this as the complete catalog with no "load more"
468
+ * UI, so this method fetches every page itself — a bare `GET /apps` only
469
+ * returns the server's default page and would silently hide anything past
470
+ * it. Capped at 20 pages (~4000 apps at the 200-per-page size) as a runaway
471
+ * backstop, not an expected limit; relocated verbatim from
472
+ * `client.ts:244-256`.
473
+ *
474
+ * @returns Every app summary across all pages, in the order the server sent them.
475
+ * @throws {ApiError} On any non-2xx.
476
+ */
477
+ list(): Promise<AppSummary[]>;
478
+ /**
479
+ * Fetch one registered app's detail (latest manifest + actions + overlay).
480
+ *
481
+ * @param id - The app id.
482
+ * @returns The whole response body — no envelope key to peel.
483
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
484
+ */
485
+ get(id: string): Promise<AppDetail>;
486
+ /**
487
+ * List an app's auth methods, annotated with `available` and any
488
+ * `requiresHostConfig` fields.
489
+ *
490
+ * @param id - The app id.
491
+ * @returns The auth methods, unwrapped from the `auths` envelope.
492
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
493
+ */
494
+ getAuth(id: string): Promise<AuthDef[]>;
495
+ /**
496
+ * Fetch an app's declared actions.
497
+ *
498
+ * Sourced from the app detail's `actions` array — a separate call from
499
+ * {@linkcode get}, relocated verbatim from `client.ts:268-271` rather than
500
+ * refactored to call `get` internally.
501
+ *
502
+ * @param id - The app id.
503
+ * @returns The declared actions; `[]` when the app declares none.
504
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
505
+ */
506
+ getActions(id: string): Promise<ActionDef[]>;
507
+ /**
508
+ * List an app's declared triggers.
509
+ *
510
+ * @param id - The app id.
511
+ * @returns The declared triggers, unwrapped from the `triggers` envelope.
512
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
513
+ */
514
+ getTriggers(id: string): Promise<TriggerDef[]>;
515
+ /**
516
+ * Fetch an app's declared health-check metadata.
517
+ *
518
+ * **Dead code (HITL-4)** — zero call sites anywhere in studio or
519
+ * `@w6w/ui`. Built for SDK completeness only; see this module's header.
520
+ * Sourced from the app detail's `health` array — a separate call from
521
+ * {@linkcode get}, relocated verbatim from `client.ts:278-281` rather than
522
+ * refactored to call `get` internally.
523
+ *
524
+ * @param id - The app id.
525
+ * @returns The declared health checks; `[]` when the app declares none.
526
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
527
+ */
528
+ getHealth(id: string): Promise<HealthCheckMeta[]>;
529
+ /**
530
+ * Run an app's PUBLIC health checks and return the live verdict.
531
+ *
532
+ * @param id - The app id.
533
+ * @returns The whole response body — no envelope key to peel.
534
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
535
+ */
536
+ getHealthStatus(id: string): Promise<AppHealthStatus>;
537
+ /**
538
+ * List every stored per-installation OAuth config summary for an app (no secrets).
539
+ *
540
+ * **Dead code (HITL-4)** — zero call sites anywhere in studio or
541
+ * `@w6w/ui`. Built for SDK completeness only; see this module's header.
542
+ *
543
+ * @param appId - The app id.
544
+ * @returns The configs, unwrapped from the `configs` envelope.
545
+ * @throws {ApiError} `404 unknown_app` when there is no such id.
546
+ */
547
+ listOAuthConfig(appId: string): Promise<OAuthConfigSummary[]>;
548
+ /**
549
+ * Upsert the OAuth client credentials for one (app, auth method).
550
+ *
551
+ * **Dead code (HITL-4)** — zero call sites anywhere in studio or
552
+ * `@w6w/ui`. Built for SDK completeness only; see this module's header.
553
+ *
554
+ * @param appId - The app id.
555
+ * @param authKey - The oauth2 auth method's key, as declared by the app's manifest.
556
+ * @param body - The client credentials, forwarded verbatim.
557
+ * @returns The stored config summary (the server answers `201`).
558
+ * @throws {ApiError} `404 unknown_app`/`unknown_auth`; `400 invalid_auth_type`/`invalid_body`.
559
+ */
560
+ upsertOAuthConfig(appId: string, authKey: string, body: UpsertOAuthConfigInput): Promise<OAuthConfigSummary>;
561
+ /**
562
+ * Remove the stored OAuth client credentials for one (app, auth method).
563
+ *
564
+ * **Dead code (HITL-4)** — zero call sites anywhere in studio or
565
+ * `@w6w/ui`. Built for SDK completeness only; see this module's header.
566
+ * Returns nothing: the server's `{ok: true}` carries no information a
567
+ * caller can use, mirroring `documents.ts`'s/`projects.ts`'s established
568
+ * delete convention.
569
+ *
570
+ * @param appId - The app id.
571
+ * @param authKey - The oauth2 auth method's key.
572
+ * @throws {ApiError} `404 unknown_oauth_config` when there is no such config.
573
+ */
574
+ deleteOAuthConfig(appId: string, authKey: string): Promise<void>;
575
+ /**
576
+ * Kick off an OAuth 2.0 flow: the server builds the provider's authorize
577
+ * URL for the caller to open.
578
+ *
579
+ * No studio-page caller, but this method's shape must exactly match
580
+ * `W6wApi.startAppOAuthFlow`'s signature on the `@w6w/ui` facade
581
+ * (`packages/ui/src/provider.tsx:110-114`), which calls it.
582
+ *
583
+ * @param appId - The app id.
584
+ * @param authKey - The oauth2 auth method's key, as declared by the app's manifest.
585
+ * @param body - Optional display name for the resulting connection; omitted fields are left to the server.
586
+ * @returns The whole response body — no envelope key to peel.
587
+ * @throws {ApiError} `404 unknown_app`/`unknown_auth`; `400 invalid_auth_type`; `409 oauth_not_configured`.
588
+ */
589
+ startOAuthFlow(appId: string, authKey: string, body?: {
590
+ displayName?: string;
591
+ }): Promise<{
592
+ authorizationUrl: string;
593
+ state: string;
594
+ expiresIn: number;
595
+ }>;
596
+ /**
597
+ * Peek what installing a source ref would touch, without persisting
598
+ * anything. Distinguishes a single-app ref from a pack ref, and (for a
599
+ * pack) previews each entry for a checkbox picker.
600
+ *
601
+ * @param source - A source ref (e.g. `github:org/repo`, `file:./local-app`).
602
+ * @param opts - `refresh: true` busts the sources cache — needed for a
603
+ * moving GitHub pointer (`@main`, `@HEAD`, or no `@ref`) whenever the
604
+ * remote has advanced since the last fetch.
605
+ * @returns The whole response body — a `kind`-discriminated union, no envelope key to peel.
606
+ * @throws {ApiError} `400 invalid_source` and whatever the source resolution itself raises.
607
+ */
608
+ preview(source: string, opts?: {
609
+ refresh?: boolean;
610
+ }): Promise<PreviewSourceResponse>;
611
+ /**
612
+ * Install a single app or a pack from a source ref.
613
+ *
614
+ * @param source - A source ref (e.g. `github:org/repo`, `file:./local-app`).
615
+ * @param opts - `paths` (pack refs only) limits which entries are
616
+ * installed — omitted, every entry is installed. `refresh: true` busts the
617
+ * sources cache (see {@linkcode preview}).
618
+ * @returns The whole response body — a `kind`-discriminated union, no envelope key to peel.
619
+ * @throws {ApiError} `400 invalid_source`; `403 user_import_disabled`/`local_import_forbidden` for a non-operator.
620
+ */
621
+ import(source: string, opts?: {
622
+ paths?: string[];
623
+ refresh?: boolean;
624
+ }): Promise<ImportResponse>;
625
+ /**
626
+ * Re-resolve an already-registered app from its recorded source ref and
627
+ * re-register it (operator-only server-side — non-operators get a `403`).
628
+ *
629
+ * @param id - The app id.
630
+ * @param opts - `force: true` busts the sources cache ("Reload"); the
631
+ * server ignores unknown fields, so `force` is harmless until server-side
632
+ * handling for it lands.
633
+ * @returns The whole response body — no envelope key to peel.
634
+ * @throws {ApiError} `404 unknown_app`; `403` for a non-operator.
635
+ */
636
+ refresh(id: string, opts?: {
637
+ force?: boolean;
638
+ }): Promise<RefreshAppResponse>;
639
+ /**
640
+ * Invoke one of an app's actions.
641
+ *
642
+ * This method's shape must exactly match `W6wApi.invokeAction`'s signature on
643
+ * the `@w6w/ui` facade (`packages/ui/src/provider.tsx`). It now models the
644
+ * WHOLE of that `opts` — `project` and `state` included.
645
+ *
646
+ * **They are not decoration, and modelling only `connectionId` was a live
647
+ * bug.** `params` may contain unresolved `ExprValue` envelopes, which the
648
+ * server resolves against an ambient scope built from exactly these two
649
+ * fields (`invoke.ts` → `buildAmbientScope`): `state` seeds
650
+ * `steps.<id>.output` and `trigger.event`, `project` chooses which project's
651
+ * vars and documents are in scope. Dropped, every
652
+ * `{{ steps.<id>.output.<field> }}` in a step test resolves to the empty
653
+ * string and the action fails on a required param it was visibly given — the
654
+ * editor's own preview resolves locally and shows the right value, so the
655
+ * failure reads as an app bug rather than a lost field.
656
+ *
657
+ * @param appId - The app id.
658
+ * @param actionKey - The action's key, as declared by the app's manifest.
659
+ * @param params - The action's parameters, forwarded verbatim.
660
+ * @param opts - `connectionId` to run with (omitted, the server picks);
661
+ * `project` to scope vars/documents to; `state` to resolve upstream
662
+ * references against.
663
+ * @returns The whole response body — no envelope key to peel.
664
+ * @throws {ApiError} On any non-2xx, including an action's own failure (`424`).
665
+ */
666
+ invoke(appId: string, actionKey: string, params: Record<string, unknown>, opts?: InvokeOptions): Promise<{
667
+ value: unknown;
668
+ logs?: string[];
669
+ apiCalls?: ApiCallRecord[];
670
+ }>;
671
+ /**
672
+ * Unregister an app (all versions by default).
673
+ *
674
+ * **Returns the server's real value, unlike `projects.delete`/`schedules.delete`
675
+ * in this same package** — the server answers `{removed: number}`, a
676
+ * genuinely informative count (`apps-catalog.ts:646-651`), and this method
677
+ * preserves it rather than discarding it to `void`. This is the one
678
+ * deliberate asymmetry vs. this package's other two `delete` conventions;
679
+ * see this module's header.
680
+ *
681
+ * @param appId - The app id.
682
+ * @returns `{removed}` — how many versions were unregistered.
683
+ * @throws {ApiError} `404 unknown_app`; `403 forbidden` when a non-operator does not own the app.
684
+ */
685
+ delete(appId: string): Promise<{
686
+ removed: number;
687
+ }>;
688
+ }
689
+ //# sourceMappingURL=apps.d.ts.map