@crvouga/mockingbird-service-junction 0.1.0 → 0.1.2

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 (62) hide show
  1. package/README.md +23 -11
  2. package/dist/index.d.ts +492 -21
  3. package/dist/index.js +6086 -107
  4. package/dist/index.js.map +7 -1
  5. package/package.json +11 -10
  6. package/dist/catalog.d.ts +0 -63
  7. package/dist/catalog.d.ts.map +0 -1
  8. package/dist/catalog.js +0 -736
  9. package/dist/catalog.js.map +0 -1
  10. package/dist/coverage-corpus.d.ts +0 -76
  11. package/dist/coverage-corpus.d.ts.map +0 -1
  12. package/dist/coverage-corpus.js +0 -166
  13. package/dist/coverage-corpus.js.map +0 -1
  14. package/dist/generated/openapi.d.ts +0 -7
  15. package/dist/generated/openapi.d.ts.map +0 -1
  16. package/dist/generated/openapi.js +0 -5
  17. package/dist/generated/openapi.js.map +0 -1
  18. package/dist/index.d.ts.map +0 -1
  19. package/dist/lab-accounts.d.ts +0 -38
  20. package/dist/lab-accounts.d.ts.map +0 -1
  21. package/dist/lab-accounts.js +0 -213
  22. package/dist/lab-accounts.js.map +0 -1
  23. package/dist/orders.d.ts +0 -18
  24. package/dist/orders.d.ts.map +0 -1
  25. package/dist/orders.js +0 -1247
  26. package/dist/orders.js.map +0 -1
  27. package/dist/prefetch.d.ts +0 -43
  28. package/dist/prefetch.d.ts.map +0 -1
  29. package/dist/prefetch.js +0 -131
  30. package/dist/prefetch.js.map +0 -1
  31. package/dist/reshape.d.ts +0 -22
  32. package/dist/reshape.d.ts.map +0 -1
  33. package/dist/reshape.js +0 -190
  34. package/dist/reshape.js.map +0 -1
  35. package/dist/results.d.ts +0 -19
  36. package/dist/results.d.ts.map +0 -1
  37. package/dist/results.js +0 -221
  38. package/dist/results.js.map +0 -1
  39. package/dist/scheduling.d.ts +0 -113
  40. package/dist/scheduling.d.ts.map +0 -1
  41. package/dist/scheduling.js +0 -1508
  42. package/dist/scheduling.js.map +0 -1
  43. package/dist/sealed-corpus.d.ts +0 -28
  44. package/dist/sealed-corpus.d.ts.map +0 -1
  45. package/dist/sealed-corpus.js +0 -17
  46. package/dist/sealed-corpus.js.map +0 -1
  47. package/dist/seed-from.d.ts +0 -27
  48. package/dist/seed-from.d.ts.map +0 -1
  49. package/dist/seed-from.js +0 -523
  50. package/dist/seed-from.js.map +0 -1
  51. package/dist/seeds.d.ts +0 -9
  52. package/dist/seeds.d.ts.map +0 -1
  53. package/dist/seeds.js +0 -9
  54. package/dist/seeds.js.map +0 -1
  55. package/dist/state.d.ts +0 -270
  56. package/dist/state.d.ts.map +0 -1
  57. package/dist/state.js +0 -448
  58. package/dist/state.js.map +0 -1
  59. package/dist/users.d.ts +0 -13
  60. package/dist/users.d.ts.map +0 -1
  61. package/dist/users.js +0 -669
  62. package/dist/users.js.map +0 -1
package/README.md CHANGED
@@ -23,9 +23,8 @@ npm install -D @crvouga/mockingbird-service-junction
23
23
  ```
24
24
 
25
25
  ESM only. Requires Node >= 22 or Bun >= 1.2. No native dependencies: state lives in an in-memory
26
- SQLite engine (`@crvouga/mockingbird-service-sqlite`, pure TypeScript). To serve it over HTTP also
27
- install `@crvouga/mockingbird-adapter-node` (works under Node and Bun) or
28
- `@crvouga/mockingbird-adapter-bun`.
26
+ SQLite engine (pure TypeScript, bundled in). To serve it over HTTP use `Bun.serve` under Bun, or
27
+ install `@hono/node-server` under Node.
29
28
 
30
29
  ## Usage
31
30
 
@@ -99,21 +98,34 @@ delayed transition is applied on the next `GET /v3/order/{id}` whose `now` is pa
99
98
  ### Over HTTP
100
99
 
101
100
  ```ts
102
- import { serve } from "@crvouga/mockingbird-adapter-node"
103
101
  import { JunctionAPI } from "@crvouga/mockingbird-service-junction"
104
102
 
105
103
  const junction = new JunctionAPI()
106
- const server = await serve(junction, { port: 0, host: "127.0.0.1" }) // port 0 = ephemeral
107
- const address = server.address()
108
- if (address === null || typeof address === "string") throw new Error("not listening")
109
- const baseUrl = `http://127.0.0.1:${address.port}`
104
+ const server = Bun.serve({
105
+ port: 0, // ephemeral
106
+ hostname: "127.0.0.1",
107
+ fetch: (request) => junction.fetch(request),
108
+ })
109
+ const baseUrl = `http://127.0.0.1:${server.port}`
110
110
 
111
111
  const response = await fetch(`${baseUrl}/v2/user`, {
112
112
  headers: { "x-vital-api-key": "sk_us_mockingbird" },
113
113
  })
114
114
  console.log(response.status) // 200
115
115
 
116
- server.close()
116
+ server.stop()
117
+ ```
118
+
119
+ On Node use any Fetch-style server, e.g. `@hono/node-server` (`npm install -D @hono/node-server`),
120
+ whose callback receives the bound port:
121
+
122
+ ```js
123
+ import { serve } from "@hono/node-server"
124
+ const server = serve(
125
+ { fetch: (request) => junction.fetch(request), port: 0, hostname: "127.0.0.1" },
126
+ (info) => console.log(`http://127.0.0.1:${info.port}`),
127
+ )
128
+ // ... later: server.close()
117
129
  ```
118
130
 
119
131
  ### Pointing `@tryvital/vital-node` at it
@@ -217,7 +229,7 @@ it always comes from the deterministic generator.
217
229
 
218
230
  | Export | Description |
219
231
  | --- | --- |
220
- | `JunctionAPI` | Class. `new JunctionAPI(options?)`; implements `FetchAPI` (`fetch(request: Request): Promise<Response>`). |
232
+ | `JunctionAPI` | Class. `new JunctionAPI(options?)`; implements the Fetch contract `fetch(request: Request): Promise<Response>`. |
221
233
  | `JUNCTION_NAMESPACE` | `"junction"` — SQLite namespace holding the mock's state when sharing a `sqlite` client. |
222
234
  | `document` | The vendored Junction OpenAPI document (Mockingbird subset) that drives routing. |
223
235
  | `operationIds` | Every `operationId` in `document`. |
@@ -316,4 +328,4 @@ Webhook parity needs a public receiver; see
316
328
  [docs/webhook-parity.md](https://github.com/crvouga/mockingbird/blob/main/packages/service/junction/docs/webhook-parity.md).
317
329
  The `client-parity*.ts` SDK scenarios are deprecated as proof and kept only as manual probes.
318
330
 
319
- Part of [mockingbird](https://github.com/crvouga/mockingbird) — agent integration guide: [`@crvouga/mockingbird`](https://github.com/crvouga/mockingbird/tree/main/packages/facade#readme).
331
+ Part of [mockingbird](https://github.com/crvouga/mockingbird) — agent integration guide: [README](https://github.com/crvouga/mockingbird#readme) · [llms.txt](https://github.com/crvouga/mockingbird/blob/main/llms.txt).
package/dist/index.d.ts CHANGED
@@ -1,31 +1,500 @@
1
- import type { FetchAPI } from "@crvouga/mockingbird-core";
2
- import { type APIOptions } from "@crvouga/mockingbird-service";
3
- import type { SqliteClient } from "@crvouga/mockingbird-sqlite";
4
- import type { Hono } from "hono";
5
- import type { SealedCorpus } from "./sealed-corpus.js";
6
- import { type SeedObservations, type SeedReport, type SeedSource } from "./seed-from.js";
7
- import { type JunctionWebhookEvent, type JunctionWebhookOptions, type WebhookPublisher } from "./state.js";
8
- export { COVERAGE_ZIPS, PHLEBOTOMY_AVAILABILITY_ZIPS, PSC_AVAILABILITY_ZIPS, PSC_LAB_IDS, } from "./coverage-corpus.js";
9
- export type { OperationId, SupportedOperationId } from "./generated/openapi.js";
10
- export { document, operationIds, supportedOperationIds } from "./generated/openapi.js";
11
- export { prefetchCoverageObservations } from "./prefetch.js";
12
- export { AVAILABILITY_ADDRESS, AVAILABILITY_START_DATE, reshapeCoverageGeoCommand, } from "./reshape.js";
13
- export { parseSealedCorpus, SEALED_CORPUS_VERSION, type SealedCorpus, } from "./sealed-corpus.js";
14
- export type { SeedObservations, SeedReport, SeedSource } from "./seed-from.js";
15
- export type { GetCacheEntry, JunctionWebhookEvent, JunctionWebhookOptions, WebhookPublisher, } from "./state.js";
16
- export { observationCacheKey } from "./state.js";
17
- export declare const JUNCTION_NAMESPACE = "junction";
1
+ import { Hono } from 'hono';
2
+
3
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
4
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
5
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
6
+ type SqliteRunResult$1 = {
7
+ changes: number;
8
+ lastInsertRowid: number | bigint;
9
+ };
10
+ /**
11
+ * Prepared statement bound to a {@link SqliteClient}.
12
+ *
13
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
14
+ */
15
+ interface SqliteStatement$1 {
16
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
17
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
18
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
19
+ }
20
+ /**
21
+ * Sync SQLite client port owned by Mockingbird.
22
+ *
23
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
24
+ * `bun:sqlite` instances all work when they expose this surface.
25
+ */
26
+ interface SqliteClient$1 {
27
+ exec(sql: string): void;
28
+ prepare(sql: string): SqliteStatement$1;
29
+ transaction<T>(fn: () => T): T;
30
+ }
31
+
32
+ /** Options every provider constructor accepts. */
33
+ type APIOptions = {
34
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
35
+ sqlite?: SqliteClient$1;
36
+ /** Clock used for `created`-style fields. Default `Date.now`. */
37
+ now?: () => number;
38
+ };
39
+
40
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
41
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
42
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
43
+ type SqliteRunResult = {
44
+ changes: number;
45
+ lastInsertRowid: number | bigint;
46
+ };
47
+ /**
48
+ * Prepared statement bound to a {@link SqliteClient}.
49
+ *
50
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
51
+ */
52
+ interface SqliteStatement {
53
+ run(...params: SqliteValue[]): SqliteRunResult;
54
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
55
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
56
+ }
57
+ /**
58
+ * Sync SQLite client port owned by Mockingbird.
59
+ *
60
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
61
+ * `bun:sqlite` instances all work when they expose this surface.
62
+ */
63
+ interface SqliteClient {
64
+ exec(sql: string): void;
65
+ prepare(sql: string): SqliteStatement;
66
+ transaction<T>(fn: () => T): T;
67
+ }
68
+
69
+ /** Lab-test catalog mirrored from the Junction sandbox (`GET /v3/lab_test`). */
70
+ type CatalogMarker = {
71
+ id: number;
72
+ name: string;
73
+ slug: string;
74
+ description: string | null;
75
+ lab_id: number | null;
76
+ provider_id: string | null;
77
+ type: string | null;
78
+ unit: string | null;
79
+ price: string | null;
80
+ aoe: unknown;
81
+ a_la_carte_enabled: boolean;
82
+ common_tat_days: number | null;
83
+ worst_case_tat_days: number | null;
84
+ is_orderable: boolean | null;
85
+ };
86
+ type ExpectedResultLoinc = {
87
+ id: number;
88
+ name: string;
89
+ slug: string;
90
+ code: string;
91
+ unit: string | null;
92
+ };
93
+ type ExpectedResult = {
94
+ id: number;
95
+ name: string;
96
+ slug: string;
97
+ lab_id: number | null;
98
+ provider_id: string | null;
99
+ required: boolean;
100
+ loinc: ExpectedResultLoinc | null;
101
+ };
102
+ type LabTestRecord = {
103
+ id: string;
104
+ slug: string;
105
+ name: string;
106
+ sample_type: string;
107
+ method: string;
108
+ price: number;
109
+ is_active: boolean;
110
+ status: string;
111
+ fasting: boolean;
112
+ lab: Record<string, unknown>;
113
+ markers: CatalogMarker[] | null;
114
+ is_delegated: boolean;
115
+ auto_generated: boolean;
116
+ has_collection_instructions: boolean | null;
117
+ common_tat_days: number | null;
118
+ worst_case_tat_days: number | null;
119
+ };
120
+
121
+ type GetCacheEntry = {
122
+ status: number;
123
+ headers: Record<string, string>;
124
+ body: unknown;
125
+ };
126
+ declare const observationCacheKey: (url: URL | string, method?: string, body?: unknown) => string;
127
+ type JunctionWebhookEvent = {
128
+ event_type: "labtest.order.created" | "labtest.order.updated" | "labtest.appointment.updated";
129
+ data: Record<string, unknown>;
130
+ team_id: string;
131
+ user_id: string;
132
+ client_user_id: string;
133
+ };
134
+ type WebhookDeliveryAttempt = {
135
+ message_id: string;
136
+ event: JunctionWebhookEvent;
137
+ attempt: number;
138
+ scheduled_at: string;
139
+ timeout_ms: number;
140
+ acknowledged: boolean;
141
+ };
142
+ type WebhookPublisher = (event: JunctionWebhookEvent) => void;
143
+ type JunctionWebhookOptions = {
144
+ seed?: number;
145
+ jitterRatio?: number;
146
+ timeoutMs?: number;
147
+ };
148
+
149
+ /**
150
+ * Anything that can answer a Fetch `Request` with a `Response`.
151
+ *
152
+ * Every Mockingbird service implements this, and every runtime adapter consumes it.
153
+ * It is the only contract shared across the whole graph.
154
+ */
155
+ interface FetchAPI {
156
+ fetch(request: Request): Promise<Response>;
157
+ }
158
+
159
+ /**
160
+ * Version of the sealed-corpus on-disk format. Bumped whenever the shape changes so a
161
+ * stale recording is rejected instead of half-applied.
162
+ */
163
+ declare const SEALED_CORPUS_VERSION = 1;
164
+ /**
165
+ * Exact sandbox recording of the provider-owned reads a drop-in consumer depends on:
166
+ * parameter-stable GET observations (area/PSC inventory), the lab catalog, team labs, and
167
+ * lab accounts. Availability is intentionally absent — its slot dates and single-use
168
+ * `booking_key`s can never match a live cache key, so it stays with the generator.
169
+ */
170
+ type SealedCorpus = {
171
+ version: typeof SEALED_CORPUS_VERSION;
172
+ recordedAt: string;
173
+ source: string;
174
+ observations: Record<string, GetCacheEntry>;
175
+ catalog: {
176
+ labTests: LabTestRecord[];
177
+ labs: Record<string, unknown>[];
178
+ expectedResults: Record<string, ExpectedResult[]>;
179
+ };
180
+ labAccounts: Record<string, unknown>[];
181
+ };
182
+ /** Throws on a non-object or an unrecognized `version`. */
183
+ declare const parseSealedCorpus: (value: unknown) => SealedCorpus;
184
+
185
+ type SeedSource = {
186
+ fetch: (request: Request) => Promise<Response>;
187
+ baseUrl: string;
188
+ headers: Record<string, string>;
189
+ };
190
+ type SeedObservations = {
191
+ getCache?: ReadonlyMap<string, GetCacheEntry>;
192
+ };
193
+ type SeedReport = {
194
+ users: number;
195
+ orders: number;
196
+ appointments: number;
197
+ catalogTests: number;
198
+ labs: number;
199
+ cacheEntries: number;
200
+ };
201
+
202
+ /** High-signal ZIPs for availability prefetch (full routing corpus still used for area/psc). */
203
+ declare const PSC_AVAILABILITY_ZIPS: readonly ["85004", "85234", "11050", "10006", "90012", "96101", "92101", "60601", "33130", "98104", "75034", "07030"];
204
+ /**
205
+ * Phlebotomy availability is only served for a narrow Vital sandbox set.
206
+ * Probed: 85004 works; broader scheduling zips often 400. Keep prefetch/reshape sealed.
207
+ */
208
+ declare const PHLEBOTOMY_AVAILABILITY_ZIPS: readonly ["85004"];
209
+ /**
210
+ * Curated real ZIPs used as this package's parity coverage corpus (one per US state plus DC,
211
+ * plus scheduling pins). Prefetched into the observation cache so area/PSC parity is sealed
212
+ * for those geos.
213
+ */
214
+ declare const COVERAGE_ZIPS: readonly ["02108", "02903", "03101", "04101", "05401", "06103", "07030", "11050", "17316", "19107", "19801", "20001", "21201", "23219", "25301", "28202", "29201", "30303", "33130", "35203", "37219", "39201", "40202", "43215", "46204", "47630", "48226", "50309", "53202", "54977", "55415", "57104", "58102", "59101", "60601", "64106", "67202", "68102", "70112", "72201", "73102", "75034", "77002", "80202", "82001", "83702", "84111", "85004", "85234", "87102", "89101", "90012", "96101", "96813", "97204", "98104", "99501"];
215
+ /** Lab ids exercised by walk-in / PSC parity flows (quest, labcorp, bioreference, sonora). */
216
+ declare const PSC_LAB_IDS: readonly [4, 6, 13, 25];
217
+
218
+ /**
219
+ * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
220
+ * Unknown keys (including `x-*` extensions) are preserved on every object.
221
+ */
222
+ type JsonPrimitive = string | number | boolean | null;
223
+ type JsonValue = JsonPrimitive | JsonValue[] | {
224
+ [key: string]: JsonValue;
225
+ };
226
+ type ReferenceObject = {
227
+ $ref: string;
228
+ description?: string;
229
+ summary?: string;
230
+ };
231
+ type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
232
+ type SchemaObject = {
233
+ $ref?: string;
234
+ type?: SchemaType | SchemaType[];
235
+ title?: string;
236
+ description?: string;
237
+ format?: string;
238
+ enum?: JsonValue[];
239
+ const?: JsonValue;
240
+ default?: JsonValue;
241
+ example?: JsonValue;
242
+ examples?: JsonValue[];
243
+ nullable?: boolean;
244
+ deprecated?: boolean;
245
+ readOnly?: boolean;
246
+ writeOnly?: boolean;
247
+ minimum?: number;
248
+ maximum?: number;
249
+ exclusiveMinimum?: number;
250
+ exclusiveMaximum?: number;
251
+ multipleOf?: number;
252
+ minLength?: number;
253
+ maxLength?: number;
254
+ pattern?: string;
255
+ minItems?: number;
256
+ maxItems?: number;
257
+ uniqueItems?: boolean;
258
+ items?: SchemaObject;
259
+ prefixItems?: SchemaObject[];
260
+ minProperties?: number;
261
+ maxProperties?: number;
262
+ required?: string[];
263
+ properties?: Record<string, SchemaObject>;
264
+ additionalProperties?: boolean | SchemaObject;
265
+ propertyNames?: SchemaObject;
266
+ oneOf?: SchemaObject[];
267
+ anyOf?: SchemaObject[];
268
+ allOf?: SchemaObject[];
269
+ not?: SchemaObject;
270
+ discriminator?: {
271
+ propertyName: string;
272
+ mapping?: Record<string, string>;
273
+ };
274
+ [extension: `x-${string}`]: unknown;
275
+ };
276
+ type ParameterLocation = "path" | "query" | "header" | "cookie";
277
+ type ParameterObject = {
278
+ name: string;
279
+ in: ParameterLocation;
280
+ description?: string;
281
+ required?: boolean;
282
+ deprecated?: boolean;
283
+ style?: string;
284
+ explode?: boolean;
285
+ schema?: SchemaObject;
286
+ content?: Record<string, MediaTypeObject>;
287
+ example?: JsonValue;
288
+ [extension: `x-${string}`]: unknown;
289
+ };
290
+ type MediaTypeObject = {
291
+ schema?: SchemaObject;
292
+ example?: JsonValue;
293
+ examples?: Record<string, unknown>;
294
+ encoding?: Record<string, unknown>;
295
+ [extension: `x-${string}`]: unknown;
296
+ };
297
+ type RequestBodyObject = {
298
+ description?: string;
299
+ required?: boolean;
300
+ content: Record<string, MediaTypeObject>;
301
+ [extension: `x-${string}`]: unknown;
302
+ };
303
+ type HeaderObject = {
304
+ description?: string;
305
+ required?: boolean;
306
+ schema?: SchemaObject;
307
+ [extension: `x-${string}`]: unknown;
308
+ };
309
+ type ResponseObject = {
310
+ description: string;
311
+ headers?: Record<string, HeaderObject | ReferenceObject>;
312
+ content?: Record<string, MediaTypeObject>;
313
+ [extension: `x-${string}`]: unknown;
314
+ };
315
+ type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
316
+ type SecurityRequirementObject = Record<string, string[]>;
317
+ type OperationObject = {
318
+ operationId?: string;
319
+ summary?: string;
320
+ description?: string;
321
+ tags?: string[];
322
+ deprecated?: boolean;
323
+ parameters?: Array<ParameterObject | ReferenceObject>;
324
+ requestBody?: RequestBodyObject | ReferenceObject;
325
+ responses: ResponsesObject;
326
+ security?: SecurityRequirementObject[];
327
+ [extension: `x-${string}`]: unknown;
328
+ };
329
+ declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
330
+ type HttpMethod = (typeof HTTP_METHODS)[number];
331
+ type PathItemObject = {
332
+ summary?: string;
333
+ description?: string;
334
+ parameters?: Array<ParameterObject | ReferenceObject>;
335
+ [extension: `x-${string}`]: unknown;
336
+ } & Partial<Record<HttpMethod, OperationObject>>;
337
+ type SecuritySchemeObject = {
338
+ type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
339
+ description?: string;
340
+ name?: string;
341
+ in?: ParameterLocation;
342
+ scheme?: string;
343
+ bearerFormat?: string;
344
+ flows?: Record<string, unknown>;
345
+ openIdConnectUrl?: string;
346
+ [extension: `x-${string}`]: unknown;
347
+ };
348
+ type ComponentsObject = {
349
+ schemas?: Record<string, SchemaObject>;
350
+ responses?: Record<string, ResponseObject>;
351
+ parameters?: Record<string, ParameterObject>;
352
+ requestBodies?: Record<string, RequestBodyObject>;
353
+ headers?: Record<string, HeaderObject>;
354
+ securitySchemes?: Record<string, SecuritySchemeObject>;
355
+ [extension: `x-${string}`]: unknown;
356
+ };
357
+ type ServerObject = {
358
+ url: string;
359
+ description?: string;
360
+ variables?: Record<string, unknown>;
361
+ [extension: `x-${string}`]: unknown;
362
+ };
363
+ type InfoObject = {
364
+ title: string;
365
+ version: string;
366
+ description?: string;
367
+ [extension: `x-${string}`]: unknown;
368
+ };
369
+ type OpenAPIDocument = {
370
+ openapi: string;
371
+ info: InfoObject;
372
+ servers?: ServerObject[];
373
+ paths: Record<string, PathItemObject>;
374
+ components?: ComponentsObject;
375
+ security?: SecurityRequirementObject[];
376
+ tags?: Array<{
377
+ name: string;
378
+ description?: string;
379
+ }>;
380
+ [extension: `x-${string}`]: unknown;
381
+ };
382
+
383
+ declare const document: OpenAPIDocument;
384
+ type OperationId = "get_teams_users_v2_user_get" | "create_user_v2_user_post" | "get_user_v2_user__user_id__get" | "delete_user_v2_user__user_id__delete" | "patch_user_v2_user__user_id__patch" | "get_user_by_client_user_id_v2_user_resolve__client_user_id__get" | "patch_user_info_v2_user__user_id__info_patch" | "get_latest_user_info_user_v2_user__user_id__info_latest_get" | "get_paginated_lab_tests_for_team_v3_lab_test_get" | "get_team_lab_accounts_v3_lab_test_lab_account_get" | "get_lab_test_for_team_v3_lab_tests__lab_test_id__get" | "get_labs_v3_lab_tests_labs_get" | "get_markers_for_lab_test_v3_lab_tests__lab_test_id__markers_get" | "list_order_set_markers_v3_lab_tests_list_order_set_markers_post" | "create_order_v3_order_post" | "get_area_info_v3_order_area_info_get" | "get_psc_info_v3_order_psc_info_get" | "get_phlebotomy_appointment_availability_v3_order_phlebotomy_appointment_availability_post" | "get_phlebotomy_appointment_cancellation_reason_v3_order_phlebotomy_appointment_cancellation_reasons_get" | "get_psc_appointment_availability_v3_order_psc_appointment_availability_post" | "get_psc_appointment_cancellation_reason_v3_order_psc_appointment_cancellation_reasons_get" | "get_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_get" | "book_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_book_post" | "reschedule_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_reschedule_patch" | "cancel_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_cancel_patch" | "get_psc_appointment_v3_order__order_id__psc_appointment_get" | "book_psc_appointment_v3_order__order_id__psc_appointment_book_post" | "reschedule_psc_appointment_v3_order__order_id__psc_appointment_reschedule_patch" | "cancel_psc_appointment_v3_order__order_id__psc_appointment_cancel_patch" | "get_order_v3_order__order_id__get" | "cancel_order_v3_order__order_id__cancel_post" | "simulate_order_v3_order__order_id__test_post" | "get_result_raw_v3_order__order_id__result_get" | "get_result_metadata_v3_order__order_id__result_metadata_get" | "get_result_pdf_v3_order__order_id__result_pdf_get" | "get_order_requisition_pdf_v3_order__order_id__requisition_pdf_get" | "get_orders_v3_orders_get" | "get_order_transaction_v3_order_transaction__transaction_id__get" | "get_order_transaction_result_v3_order_transaction__transaction_id__result_get";
385
+ type SupportedOperationId = "get_teams_users_v2_user_get" | "create_user_v2_user_post" | "get_user_v2_user__user_id__get" | "delete_user_v2_user__user_id__delete" | "patch_user_v2_user__user_id__patch" | "get_user_by_client_user_id_v2_user_resolve__client_user_id__get" | "patch_user_info_v2_user__user_id__info_patch" | "get_latest_user_info_user_v2_user__user_id__info_latest_get" | "get_paginated_lab_tests_for_team_v3_lab_test_get" | "get_team_lab_accounts_v3_lab_test_lab_account_get" | "get_lab_test_for_team_v3_lab_tests__lab_test_id__get" | "get_labs_v3_lab_tests_labs_get" | "get_markers_for_lab_test_v3_lab_tests__lab_test_id__markers_get" | "list_order_set_markers_v3_lab_tests_list_order_set_markers_post" | "create_order_v3_order_post" | "get_area_info_v3_order_area_info_get" | "get_psc_info_v3_order_psc_info_get" | "get_phlebotomy_appointment_availability_v3_order_phlebotomy_appointment_availability_post" | "get_phlebotomy_appointment_cancellation_reason_v3_order_phlebotomy_appointment_cancellation_reasons_get" | "get_psc_appointment_availability_v3_order_psc_appointment_availability_post" | "get_psc_appointment_cancellation_reason_v3_order_psc_appointment_cancellation_reasons_get" | "get_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_get" | "book_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_book_post" | "reschedule_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_reschedule_patch" | "cancel_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_cancel_patch" | "get_psc_appointment_v3_order__order_id__psc_appointment_get" | "book_psc_appointment_v3_order__order_id__psc_appointment_book_post" | "reschedule_psc_appointment_v3_order__order_id__psc_appointment_reschedule_patch" | "cancel_psc_appointment_v3_order__order_id__psc_appointment_cancel_patch" | "get_order_v3_order__order_id__get" | "cancel_order_v3_order__order_id__cancel_post" | "simulate_order_v3_order__order_id__test_post" | "get_result_raw_v3_order__order_id__result_get" | "get_result_metadata_v3_order__order_id__result_metadata_get" | "get_result_pdf_v3_order__order_id__result_pdf_get" | "get_order_requisition_pdf_v3_order__order_id__requisition_pdf_get" | "get_orders_v3_orders_get" | "get_order_transaction_v3_order_transaction__transaction_id__get" | "get_order_transaction_result_v3_order_transaction__transaction_id__result_get";
386
+ declare const operationIds: readonly ["get_teams_users_v2_user_get", "create_user_v2_user_post", "get_user_v2_user__user_id__get", "delete_user_v2_user__user_id__delete", "patch_user_v2_user__user_id__patch", "get_user_by_client_user_id_v2_user_resolve__client_user_id__get", "patch_user_info_v2_user__user_id__info_patch", "get_latest_user_info_user_v2_user__user_id__info_latest_get", "get_paginated_lab_tests_for_team_v3_lab_test_get", "get_team_lab_accounts_v3_lab_test_lab_account_get", "get_lab_test_for_team_v3_lab_tests__lab_test_id__get", "get_labs_v3_lab_tests_labs_get", "get_markers_for_lab_test_v3_lab_tests__lab_test_id__markers_get", "list_order_set_markers_v3_lab_tests_list_order_set_markers_post", "create_order_v3_order_post", "get_area_info_v3_order_area_info_get", "get_psc_info_v3_order_psc_info_get", "get_phlebotomy_appointment_availability_v3_order_phlebotomy_appointment_availability_post", "get_phlebotomy_appointment_cancellation_reason_v3_order_phlebotomy_appointment_cancellation_reasons_get", "get_psc_appointment_availability_v3_order_psc_appointment_availability_post", "get_psc_appointment_cancellation_reason_v3_order_psc_appointment_cancellation_reasons_get", "get_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_get", "book_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_book_post", "reschedule_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_reschedule_patch", "cancel_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_cancel_patch", "get_psc_appointment_v3_order__order_id__psc_appointment_get", "book_psc_appointment_v3_order__order_id__psc_appointment_book_post", "reschedule_psc_appointment_v3_order__order_id__psc_appointment_reschedule_patch", "cancel_psc_appointment_v3_order__order_id__psc_appointment_cancel_patch", "get_order_v3_order__order_id__get", "cancel_order_v3_order__order_id__cancel_post", "simulate_order_v3_order__order_id__test_post", "get_result_raw_v3_order__order_id__result_get", "get_result_metadata_v3_order__order_id__result_metadata_get", "get_result_pdf_v3_order__order_id__result_pdf_get", "get_order_requisition_pdf_v3_order__order_id__requisition_pdf_get", "get_orders_v3_orders_get", "get_order_transaction_v3_order_transaction__transaction_id__get", "get_order_transaction_result_v3_order_transaction__transaction_id__result_get"];
387
+ declare const supportedOperationIds: readonly ["get_teams_users_v2_user_get", "create_user_v2_user_post", "get_user_v2_user__user_id__get", "delete_user_v2_user__user_id__delete", "patch_user_v2_user__user_id__patch", "get_user_by_client_user_id_v2_user_resolve__client_user_id__get", "patch_user_info_v2_user__user_id__info_patch", "get_latest_user_info_user_v2_user__user_id__info_latest_get", "get_paginated_lab_tests_for_team_v3_lab_test_get", "get_team_lab_accounts_v3_lab_test_lab_account_get", "get_lab_test_for_team_v3_lab_tests__lab_test_id__get", "get_labs_v3_lab_tests_labs_get", "get_markers_for_lab_test_v3_lab_tests__lab_test_id__markers_get", "list_order_set_markers_v3_lab_tests_list_order_set_markers_post", "create_order_v3_order_post", "get_area_info_v3_order_area_info_get", "get_psc_info_v3_order_psc_info_get", "get_phlebotomy_appointment_availability_v3_order_phlebotomy_appointment_availability_post", "get_phlebotomy_appointment_cancellation_reason_v3_order_phlebotomy_appointment_cancellation_reasons_get", "get_psc_appointment_availability_v3_order_psc_appointment_availability_post", "get_psc_appointment_cancellation_reason_v3_order_psc_appointment_cancellation_reasons_get", "get_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_get", "book_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_book_post", "reschedule_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_reschedule_patch", "cancel_phlebotomy_appointment_v3_order__order_id__phlebotomy_appointment_cancel_patch", "get_psc_appointment_v3_order__order_id__psc_appointment_get", "book_psc_appointment_v3_order__order_id__psc_appointment_book_post", "reschedule_psc_appointment_v3_order__order_id__psc_appointment_reschedule_patch", "cancel_psc_appointment_v3_order__order_id__psc_appointment_cancel_patch", "get_order_v3_order__order_id__get", "cancel_order_v3_order__order_id__cancel_post", "simulate_order_v3_order__order_id__test_post", "get_result_raw_v3_order__order_id__result_get", "get_result_metadata_v3_order__order_id__result_metadata_get", "get_result_pdf_v3_order__order_id__result_pdf_get", "get_order_requisition_pdf_v3_order__order_id__requisition_pdf_get", "get_orders_v3_orders_get", "get_order_transaction_v3_order_transaction__transaction_id__get", "get_order_transaction_result_v3_order_transaction__transaction_id__result_get"];
388
+
389
+ type SeedCacheEntry = {
390
+ status: number;
391
+ headers: Record<string, string>;
392
+ body: unknown;
393
+ };
394
+
395
+ type PrefetchTarget = {
396
+ baseUrl: string;
397
+ fetch: (request: Request) => Promise<Response>;
398
+ headers: () => Promise<Record<string, string>> | Record<string, string>;
399
+ };
400
+ /**
401
+ * Seal coverage-corpus routing ZIPs + availability POSTs into the seed observation cache.
402
+ * Call after warmup, before `seedFrom`, so compare walks can forceInclude geo/scheduling reads.
403
+ */
404
+ declare const prefetchCoverageObservations: (args: {
405
+ real: PrefetchTarget;
406
+ getCache: Map<string, SeedCacheEntry>;
407
+ zips?: readonly string[];
408
+ /** ZIPs that also get PSC availability POST seals. Defaults to scheduling corpus. */
409
+ schedulingZips?: readonly string[];
410
+ /** ZIPs for phlebotomy availability (narrow served set). Defaults to PHLEBOTOMY_ZIPS. */
411
+ phlebotomyZips?: readonly string[];
412
+ labIds?: readonly number[];
413
+ /** Also prefetch phlebotomy + PSC availability. Default true. */
414
+ includeAvailability?: boolean;
415
+ sleep?: (ms: number) => Promise<void>;
416
+ minIntervalMs?: number;
417
+ }) => Promise<void>;
418
+
419
+ type Violation = "wrong-type" | "string-too-long" | "string-too-short" | "number-too-large" | "number-too-small" | "not-in-enum" | "missing-required" | "unexpected-property" | "array-too-long" | "array-too-short" | "bad-format";
420
+ type Mutation = {
421
+ /** Location of the mutated value in generated *values* (not schema keywords). */
422
+ valuePath: Array<string | number>;
423
+ violation: Violation;
424
+ detail: string;
425
+ };
426
+
427
+ /**
428
+ * One generated API call. Concrete ids never appear here: resource references are
429
+ * {@link Placeholder}s resolved per side at execution time, which is what lets the same command
430
+ * run against the real API and the mock.
431
+ */
432
+ type LogicalCommand = {
433
+ operationId: string;
434
+ /** Path, query and header parameter values by name. */
435
+ parameters: Record<string, unknown>;
436
+ body: unknown;
437
+ mediaType: string | undefined;
438
+ /** Set when the body was deliberately mutated to violate its schema. */
439
+ invalid: Mutation | undefined;
440
+ };
441
+
442
+ /** Mutable walk state consulted by {@link DynamicWeightFn}. */
443
+ type ExploreState = {
444
+ /** operationId → times exercised in this walk. */
445
+ coverage: Record<string, number>;
446
+ /** Recent operationIds (oldest → newest), typically capped. */
447
+ history: readonly string[];
448
+ /** Active resource counts by type (user, order, …). */
449
+ resourceCounts: Record<string, number>;
450
+ phase: "warmup" | "compare" | "walk";
451
+ step: number;
452
+ maxSteps: number;
453
+ /** Optional observed GET cache size — used to unlock geo/scheduling reads. */
454
+ observationCacheSize?: number;
455
+ };
456
+ /** Mulberry32 PRNG — deterministic from a 32-bit seed. */
457
+ declare const createExploreRng: (seed: number) => {
458
+ /** Uniform float in [0, 1). */
459
+ next: () => number;
460
+ /** Uniform int in [0, max] inclusive. */
461
+ nextInt: (max: number) => number;
462
+ };
463
+ type ExploreRng = ReturnType<typeof createExploreRng>;
464
+
465
+ /** Stable address fields so availability observation-cache keys match prefetch (85004). */
466
+ declare const AVAILABILITY_ADDRESS: {
467
+ readonly first_line: "1 N Central Ave";
468
+ readonly second_line: string | null;
469
+ readonly city: "Phoenix";
470
+ readonly state: "AZ";
471
+ readonly unit: string | null;
472
+ };
473
+ /** Far-future start date so slots are always generated relative to frozen test clocks. */
474
+ declare const AVAILABILITY_START_DATE = "2099-06-15";
475
+ /**
476
+ * Pin geo / availability params onto the coverage corpus so observation-cache hits stay
477
+ * sealed during seedParity compare walks.
478
+ */
479
+ declare const reshapeCoverageGeoCommand: (command: LogicalCommand, _state: ExploreState, rng: ExploreRng, options?: {
480
+ zips?: readonly string[];
481
+ schedulingZips?: readonly string[];
482
+ phlebotomyZips?: readonly string[];
483
+ labIds?: readonly number[];
484
+ }) => LogicalCommand;
485
+
486
+ declare const JUNCTION_NAMESPACE = "junction";
18
487
  /**
19
488
  * Stateful mock of the Junction (Vital) API user and lab-testing surfaces.
20
489
  *
21
490
  * Docs: https://docs.junction.com/
22
491
  * Auth: `x-vital-api-key` — https://docs.junction.com/api-details/junction-api
23
492
  */
24
- export type JunctionAPIOptions = APIOptions & {
493
+ type JunctionAPIOptions = APIOptions & {
25
494
  onWebhook?: WebhookPublisher;
26
495
  webhook?: JunctionWebhookOptions;
27
496
  };
28
- export declare class JunctionAPI implements FetchAPI {
497
+ declare class JunctionAPI implements FetchAPI {
29
498
  readonly app: Hono;
30
499
  readonly sqlite: SqliteClient;
31
500
  private readonly service;
@@ -44,6 +513,8 @@ export declare class JunctionAPI implements FetchAPI {
44
513
  ensureOrders(source: SeedSource, ids: readonly string[]): Promise<number>;
45
514
  markUserDeleted(userId: string): void;
46
515
  webhookEvents(): JunctionWebhookEvent[];
47
- webhookDeliveryAttempts(): import("./state.js").WebhookDeliveryAttempt[];
516
+ webhookDeliveryAttempts(): WebhookDeliveryAttempt[];
48
517
  }
49
- //# sourceMappingURL=index.d.ts.map
518
+
519
+ export { AVAILABILITY_ADDRESS, AVAILABILITY_START_DATE, COVERAGE_ZIPS, JUNCTION_NAMESPACE, JunctionAPI, PHLEBOTOMY_AVAILABILITY_ZIPS, PSC_AVAILABILITY_ZIPS, PSC_LAB_IDS, SEALED_CORPUS_VERSION, document, observationCacheKey, operationIds, parseSealedCorpus, prefetchCoverageObservations, reshapeCoverageGeoCommand, supportedOperationIds };
520
+ export type { FetchAPI, GetCacheEntry, JunctionAPIOptions, JunctionWebhookEvent, JunctionWebhookOptions, OperationId, SealedCorpus, SeedObservations, SeedReport, SeedSource, SqliteClient, SupportedOperationId, WebhookPublisher };