@crvouga/mockingbird-service-junction 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +448 -133
- package/dist/chunk-4C6VYRJN.js +18 -0
- package/dist/chunk-4C6VYRJN.js.map +7 -0
- package/dist/chunk-KKNULV7X.js +406 -0
- package/dist/chunk-KKNULV7X.js.map +7 -0
- package/dist/chunk-MA3HSUVD.js +7771 -0
- package/dist/chunk-MA3HSUVD.js.map +7 -0
- package/dist/chunk-MD4KYEIM.js +145758 -0
- package/dist/chunk-MD4KYEIM.js.map +7 -0
- package/dist/cli.js +214 -0
- package/dist/cli.js.map +7 -0
- package/dist/corpus.d.ts +97 -0
- package/dist/corpus.js +8 -0
- package/dist/corpus.js.map +7 -0
- package/dist/index.d.ts +1131 -21
- package/dist/index.js +82 -120
- package/dist/index.js.map +7 -1
- package/dist/server.d.ts +978 -0
- package/dist/server.js +16 -0
- package/dist/server.js.map +7 -0
- package/package.json +32 -12
- package/dist/catalog.d.ts +0 -63
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js +0 -736
- package/dist/catalog.js.map +0 -1
- package/dist/coverage-corpus.d.ts +0 -76
- package/dist/coverage-corpus.d.ts.map +0 -1
- package/dist/coverage-corpus.js +0 -166
- package/dist/coverage-corpus.js.map +0 -1
- package/dist/generated/openapi.d.ts +0 -7
- package/dist/generated/openapi.d.ts.map +0 -1
- package/dist/generated/openapi.js +0 -5
- package/dist/generated/openapi.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lab-accounts.d.ts +0 -38
- package/dist/lab-accounts.d.ts.map +0 -1
- package/dist/lab-accounts.js +0 -213
- package/dist/lab-accounts.js.map +0 -1
- package/dist/orders.d.ts +0 -18
- package/dist/orders.d.ts.map +0 -1
- package/dist/orders.js +0 -1247
- package/dist/orders.js.map +0 -1
- package/dist/prefetch.d.ts +0 -43
- package/dist/prefetch.d.ts.map +0 -1
- package/dist/prefetch.js +0 -131
- package/dist/prefetch.js.map +0 -1
- package/dist/reshape.d.ts +0 -22
- package/dist/reshape.d.ts.map +0 -1
- package/dist/reshape.js +0 -190
- package/dist/reshape.js.map +0 -1
- package/dist/results.d.ts +0 -19
- package/dist/results.d.ts.map +0 -1
- package/dist/results.js +0 -221
- package/dist/results.js.map +0 -1
- package/dist/scheduling.d.ts +0 -113
- package/dist/scheduling.d.ts.map +0 -1
- package/dist/scheduling.js +0 -1508
- package/dist/scheduling.js.map +0 -1
- package/dist/sealed-corpus.d.ts +0 -28
- package/dist/sealed-corpus.d.ts.map +0 -1
- package/dist/sealed-corpus.js +0 -17
- package/dist/sealed-corpus.js.map +0 -1
- package/dist/seed-from.d.ts +0 -27
- package/dist/seed-from.d.ts.map +0 -1
- package/dist/seed-from.js +0 -523
- package/dist/seed-from.js.map +0 -1
- package/dist/seeds.d.ts +0 -9
- package/dist/seeds.d.ts.map +0 -1
- package/dist/seeds.js +0 -9
- package/dist/seeds.js.map +0 -1
- package/dist/state.d.ts +0 -270
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -448
- package/dist/state.js.map +0 -1
- package/dist/users.d.ts +0 -13
- package/dist/users.d.ts.map +0 -1
- package/dist/users.js +0 -669
- package/dist/users.js.map +0 -1
package/dist/cli.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
loadCorpus,
|
|
4
|
+
runCli,
|
|
5
|
+
serveCommand,
|
|
6
|
+
serveTarget
|
|
7
|
+
} from "./chunk-KKNULV7X.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_JUNCTION_BASE_URL,
|
|
10
|
+
createRuntime,
|
|
11
|
+
diffCorpus,
|
|
12
|
+
isSandboxKey,
|
|
13
|
+
pullCorpus,
|
|
14
|
+
verifyAgainstReal
|
|
15
|
+
} from "./chunk-MA3HSUVD.js";
|
|
16
|
+
import {
|
|
17
|
+
defaultCorpus
|
|
18
|
+
} from "./chunk-MD4KYEIM.js";
|
|
19
|
+
import {
|
|
20
|
+
parseSealedCorpus
|
|
21
|
+
} from "./chunk-4C6VYRJN.js";
|
|
22
|
+
|
|
23
|
+
// src/cli.ts
|
|
24
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
25
|
+
var asString = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
26
|
+
var realKeyOf = (values) => asString(values["real-key"]) ?? process.env.MOCKINGBIRD_JUNCTION_API_KEY ?? process.env.JUNCTION_API_KEY;
|
|
27
|
+
var readCorpus = async (source) => source === "default" ? defaultCorpus : parseSealedCorpus(JSON.parse(await readFile(source, "utf8")));
|
|
28
|
+
var guardKey = (key, values) => {
|
|
29
|
+
if (key === void 0) {
|
|
30
|
+
console.error("missing --real-key (or env MOCKINGBIRD_JUNCTION_API_KEY)");
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
if (!isSandboxKey(key) && values["allow-any-key"] !== true) {
|
|
34
|
+
console.error(
|
|
35
|
+
"refusing a key that is not a sandbox team key (sk_us_\u2026 / sk_eu_\u2026); pass --allow-any-key to override"
|
|
36
|
+
);
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
return key;
|
|
40
|
+
};
|
|
41
|
+
var REAL_OPTIONS = {
|
|
42
|
+
"real-key": {
|
|
43
|
+
type: "string",
|
|
44
|
+
value: "<key>",
|
|
45
|
+
description: "Junction API key (env MOCKINGBIRD_JUNCTION_API_KEY)"
|
|
46
|
+
},
|
|
47
|
+
"real-url": {
|
|
48
|
+
type: "string",
|
|
49
|
+
value: "<url>",
|
|
50
|
+
description: "Junction API base URL",
|
|
51
|
+
default: DEFAULT_JUNCTION_BASE_URL
|
|
52
|
+
},
|
|
53
|
+
"allow-any-key": {
|
|
54
|
+
type: "boolean",
|
|
55
|
+
description: "Allow a key that is not a sandbox team key"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var code = await runCli(
|
|
59
|
+
{
|
|
60
|
+
bin: "mockingbird-junction",
|
|
61
|
+
description: "stateful Junction (Vital) API mock",
|
|
62
|
+
commands: {
|
|
63
|
+
serve: serveCommand(serveTarget),
|
|
64
|
+
"corpus pull": {
|
|
65
|
+
summary: "Record a corpus from a real Junction team (read-only GETs)",
|
|
66
|
+
usage: "mockingbird-junction corpus pull --out <file> [--zip 10001,94105] [--base <file>]",
|
|
67
|
+
options: {
|
|
68
|
+
...REAL_OPTIONS,
|
|
69
|
+
out: { type: "string", value: "<file>", description: "Where to write the corpus" },
|
|
70
|
+
zip: {
|
|
71
|
+
type: "string",
|
|
72
|
+
value: "<zip,zip,\u2026>",
|
|
73
|
+
description: "ZIPs to record coverage for (default: the shipped set)"
|
|
74
|
+
},
|
|
75
|
+
base: {
|
|
76
|
+
type: "string",
|
|
77
|
+
value: "<file|default>",
|
|
78
|
+
description: "Only refresh --zip on top of this corpus"
|
|
79
|
+
},
|
|
80
|
+
"coverage-only": {
|
|
81
|
+
type: "boolean",
|
|
82
|
+
description: "Skip the team's catalog and lab accounts"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async run(values) {
|
|
86
|
+
const key = guardKey(realKeyOf(values), values);
|
|
87
|
+
if (key === void 0) return 2;
|
|
88
|
+
const out = asString(values.out);
|
|
89
|
+
if (out === void 0) {
|
|
90
|
+
console.error("missing --out <file>");
|
|
91
|
+
return 2;
|
|
92
|
+
}
|
|
93
|
+
const zips = asString(values.zip)?.split(",").map((zip) => zip.trim()).filter(Boolean);
|
|
94
|
+
if (zips?.some((zip) => !/^\d{5}$/.test(zip))) {
|
|
95
|
+
console.error("--zip takes comma-separated 5-digit ZIPs");
|
|
96
|
+
return 2;
|
|
97
|
+
}
|
|
98
|
+
const baseSource = asString(values.base);
|
|
99
|
+
const corpus = await pullCorpus({
|
|
100
|
+
apiKey: key,
|
|
101
|
+
baseUrl: asString(values["real-url"]) ?? DEFAULT_JUNCTION_BASE_URL,
|
|
102
|
+
...zips ? { zips } : {},
|
|
103
|
+
...baseSource ? { base: await readCorpus(baseSource) } : {},
|
|
104
|
+
coverageOnly: values["coverage-only"] === true,
|
|
105
|
+
onProgress: (message) => console.log(`corpus pull: ${message}`)
|
|
106
|
+
});
|
|
107
|
+
await writeFile(out, `${JSON.stringify(corpus, null, 2)}
|
|
108
|
+
`);
|
|
109
|
+
console.log(
|
|
110
|
+
`corpus pull: wrote ${out} \u2014 ${Object.keys(corpus.observations).length} observations, ${corpus.catalog.labTests.length} lab tests, ${corpus.labAccounts.length} lab accounts, fingerprint ${corpus.fingerprint?.slice(0, 12)}`
|
|
111
|
+
);
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"corpus diff": {
|
|
116
|
+
summary: "Show what changed between two corpora (exit 1 when they differ)",
|
|
117
|
+
usage: "mockingbird-junction corpus diff <before|default> <after|default> [--json]",
|
|
118
|
+
options: { json: { type: "boolean", description: "Print the diff as JSON" } },
|
|
119
|
+
async run(values, positionals) {
|
|
120
|
+
const [beforePath, afterPath] = positionals;
|
|
121
|
+
if (beforePath === void 0 || afterPath === void 0) {
|
|
122
|
+
console.error("usage: mockingbird-junction corpus diff <before> <after>");
|
|
123
|
+
return 2;
|
|
124
|
+
}
|
|
125
|
+
const diff = diffCorpus(await readCorpus(beforePath), await readCorpus(afterPath));
|
|
126
|
+
if (values.json === true) {
|
|
127
|
+
console.log(JSON.stringify(diff, null, 2));
|
|
128
|
+
return diff.identical ? 0 : 1;
|
|
129
|
+
}
|
|
130
|
+
if (diff.identical) {
|
|
131
|
+
console.log("corpora are identical");
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
const section = (title, d) => {
|
|
135
|
+
const total = d.added.length + d.removed.length + (d.changed?.length ?? 0);
|
|
136
|
+
if (total === 0) return;
|
|
137
|
+
console.log(`${title}:`);
|
|
138
|
+
for (const id of d.added) console.log(` + ${id}`);
|
|
139
|
+
for (const id of d.removed) console.log(` - ${id}`);
|
|
140
|
+
for (const id of d.changed ?? []) console.log(` ~ ${id}`);
|
|
141
|
+
};
|
|
142
|
+
section("ZIPs", diff.zips);
|
|
143
|
+
section("lab tests", diff.labTests);
|
|
144
|
+
section("lab accounts", diff.labAccounts);
|
|
145
|
+
const o = diff.observations;
|
|
146
|
+
console.log(
|
|
147
|
+
`observations: +${o.added.length} -${o.removed.length} ~${o.changed.length} (--json lists them)`
|
|
148
|
+
);
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
verify: {
|
|
153
|
+
summary: "Replay the corpus and a stateful scenario against real Junction and the mock",
|
|
154
|
+
usage: "mockingbird-junction verify --real-key <sk_us_\u2026> [--corpus <file>] [--orders]",
|
|
155
|
+
options: {
|
|
156
|
+
...REAL_OPTIONS,
|
|
157
|
+
corpus: {
|
|
158
|
+
type: "string",
|
|
159
|
+
value: "<default|file>",
|
|
160
|
+
description: "Corpus the mock serves and drift is checked against",
|
|
161
|
+
default: "default"
|
|
162
|
+
},
|
|
163
|
+
sample: {
|
|
164
|
+
type: "string",
|
|
165
|
+
value: "<n>",
|
|
166
|
+
description: "Re-fetch at most n recorded observations (default: all)"
|
|
167
|
+
},
|
|
168
|
+
"skip-drift": { type: "boolean", description: "Only run the stateful scenario" },
|
|
169
|
+
orders: {
|
|
170
|
+
type: "boolean",
|
|
171
|
+
description: "Also place and cancel an order on the real team"
|
|
172
|
+
},
|
|
173
|
+
json: { type: "boolean", description: "Print the report as JSON" }
|
|
174
|
+
},
|
|
175
|
+
async run(values) {
|
|
176
|
+
const key = guardKey(realKeyOf(values), values);
|
|
177
|
+
if (key === void 0) return 2;
|
|
178
|
+
const corpus = await loadCorpus(asString(values.corpus) ?? "default");
|
|
179
|
+
if (!corpus) {
|
|
180
|
+
console.error("verify needs a corpus (--corpus default or a file)");
|
|
181
|
+
return 2;
|
|
182
|
+
}
|
|
183
|
+
const sample = asString(values.sample);
|
|
184
|
+
const report = await verifyAgainstReal({
|
|
185
|
+
realKey: key,
|
|
186
|
+
realUrl: asString(values["real-url"]) ?? DEFAULT_JUNCTION_BASE_URL,
|
|
187
|
+
mock: createRuntime({ corpus }),
|
|
188
|
+
corpus,
|
|
189
|
+
...sample !== void 0 ? { sample: Number.parseInt(sample, 10) } : {},
|
|
190
|
+
skipDrift: values["skip-drift"] === true,
|
|
191
|
+
orders: values.orders === true,
|
|
192
|
+
...values.json === true ? {} : { onProgress: (message) => console.log(`verify: ${message}`) }
|
|
193
|
+
});
|
|
194
|
+
if (values.json === true) {
|
|
195
|
+
console.log(JSON.stringify(report, null, 2));
|
|
196
|
+
} else {
|
|
197
|
+
for (const d of report.divergences) {
|
|
198
|
+
console.log(`DIVERGED ${d.check} (${d.kind}${d.at ? ` at ${d.at}` : ""})`);
|
|
199
|
+
console.log(` real: ${JSON.stringify(d.real)?.slice(0, 400)}`);
|
|
200
|
+
console.log(` mock: ${JSON.stringify(d.mock)?.slice(0, 400)}`);
|
|
201
|
+
}
|
|
202
|
+
console.log(
|
|
203
|
+
`verify: drift ${report.drift.stale}/${report.drift.checked} stale; scenario ${report.scenario.divergent}/${report.scenario.steps} divergent \u2014 ${report.ok ? "OK" : "DIVERGED"}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return report.ok ? 0 : 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
process.argv.slice(2)
|
|
212
|
+
);
|
|
213
|
+
if (code !== 0) process.exitCode = code;
|
|
214
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n/// <reference types=\"node\" />\nimport { readFile, writeFile } from \"node:fs/promises\"\nimport { type CliValues, runCli, serveCommand } from \"@crvouga/mockingbird-adapter-node\"\nimport { defaultCorpus } from \"./corpus.js\"\nimport { DEFAULT_JUNCTION_BASE_URL, diffCorpus, isSandboxKey, pullCorpus } from \"./corpus-tools.js\"\nimport { createRuntime } from \"./runtime.js\"\nimport { parseSealedCorpus, type SealedCorpus } from \"./sealed-corpus.js\"\nimport { loadCorpus, serveTarget } from \"./server.js\"\nimport { verifyAgainstReal } from \"./verify.js\"\n\nconst asString = (value: string | boolean | undefined): string | undefined =>\n typeof value === \"string\" && value !== \"\" ? value : undefined\n\nconst realKeyOf = (values: CliValues): string | undefined =>\n asString(values[\"real-key\"]) ??\n process.env.MOCKINGBIRD_JUNCTION_API_KEY ??\n process.env.JUNCTION_API_KEY\n\nconst readCorpus = async (source: string): Promise<SealedCorpus> =>\n source === \"default\"\n ? defaultCorpus\n : parseSealedCorpus(JSON.parse(await readFile(source, \"utf8\")))\n\nconst guardKey = (key: string | undefined, values: CliValues): string | undefined => {\n if (key === undefined) {\n console.error(\"missing --real-key (or env MOCKINGBIRD_JUNCTION_API_KEY)\")\n return undefined\n }\n if (!isSandboxKey(key) && values[\"allow-any-key\"] !== true) {\n console.error(\n \"refusing a key that is not a sandbox team key (sk_us_\u2026 / sk_eu_\u2026); pass --allow-any-key to override\",\n )\n return undefined\n }\n return key\n}\n\nconst REAL_OPTIONS = {\n \"real-key\": {\n type: \"string\",\n value: \"<key>\",\n description: \"Junction API key (env MOCKINGBIRD_JUNCTION_API_KEY)\",\n },\n \"real-url\": {\n type: \"string\",\n value: \"<url>\",\n description: \"Junction API base URL\",\n default: DEFAULT_JUNCTION_BASE_URL,\n },\n \"allow-any-key\": {\n type: \"boolean\",\n description: \"Allow a key that is not a sandbox team key\",\n },\n} as const\n\nconst code = await runCli(\n {\n bin: \"mockingbird-junction\",\n description: \"stateful Junction (Vital) API mock\",\n commands: {\n serve: serveCommand(serveTarget),\n\n \"corpus pull\": {\n summary: \"Record a corpus from a real Junction team (read-only GETs)\",\n usage: \"mockingbird-junction corpus pull --out <file> [--zip 10001,94105] [--base <file>]\",\n options: {\n ...REAL_OPTIONS,\n out: { type: \"string\", value: \"<file>\", description: \"Where to write the corpus\" },\n zip: {\n type: \"string\",\n value: \"<zip,zip,\u2026>\",\n description: \"ZIPs to record coverage for (default: the shipped set)\",\n },\n base: {\n type: \"string\",\n value: \"<file|default>\",\n description: \"Only refresh --zip on top of this corpus\",\n },\n \"coverage-only\": {\n type: \"boolean\",\n description: \"Skip the team's catalog and lab accounts\",\n },\n },\n async run(values) {\n const key = guardKey(realKeyOf(values), values)\n if (key === undefined) return 2\n const out = asString(values.out)\n if (out === undefined) {\n console.error(\"missing --out <file>\")\n return 2\n }\n const zips = asString(values.zip)\n ?.split(\",\")\n .map((zip) => zip.trim())\n .filter(Boolean)\n if (zips?.some((zip) => !/^\\d{5}$/.test(zip))) {\n console.error(\"--zip takes comma-separated 5-digit ZIPs\")\n return 2\n }\n const baseSource = asString(values.base)\n const corpus = await pullCorpus({\n apiKey: key,\n baseUrl: asString(values[\"real-url\"]) ?? DEFAULT_JUNCTION_BASE_URL,\n ...(zips ? { zips } : {}),\n ...(baseSource ? { base: await readCorpus(baseSource) } : {}),\n coverageOnly: values[\"coverage-only\"] === true,\n onProgress: (message) => console.log(`corpus pull: ${message}`),\n })\n await writeFile(out, `${JSON.stringify(corpus, null, 2)}\\n`)\n console.log(\n `corpus pull: wrote ${out} \u2014 ${Object.keys(corpus.observations).length} observations, ${corpus.catalog.labTests.length} lab tests, ${corpus.labAccounts.length} lab accounts, fingerprint ${corpus.fingerprint?.slice(0, 12)}`,\n )\n return 0\n },\n },\n\n \"corpus diff\": {\n summary: \"Show what changed between two corpora (exit 1 when they differ)\",\n usage: \"mockingbird-junction corpus diff <before|default> <after|default> [--json]\",\n options: { json: { type: \"boolean\", description: \"Print the diff as JSON\" } },\n async run(values, positionals) {\n const [beforePath, afterPath] = positionals\n if (beforePath === undefined || afterPath === undefined) {\n console.error(\"usage: mockingbird-junction corpus diff <before> <after>\")\n return 2\n }\n const diff = diffCorpus(await readCorpus(beforePath), await readCorpus(afterPath))\n if (values.json === true) {\n console.log(JSON.stringify(diff, null, 2))\n return diff.identical ? 0 : 1\n }\n if (diff.identical) {\n console.log(\"corpora are identical\")\n return 0\n }\n const section = (\n title: string,\n d: { added: string[]; removed: string[]; changed?: string[] },\n ) => {\n const total = d.added.length + d.removed.length + (d.changed?.length ?? 0)\n if (total === 0) return\n console.log(`${title}:`)\n for (const id of d.added) console.log(` + ${id}`)\n for (const id of d.removed) console.log(` - ${id}`)\n for (const id of d.changed ?? []) console.log(` ~ ${id}`)\n }\n section(\"ZIPs\", diff.zips)\n section(\"lab tests\", diff.labTests)\n section(\"lab accounts\", diff.labAccounts)\n const o = diff.observations\n console.log(\n `observations: +${o.added.length} -${o.removed.length} ~${o.changed.length} (--json lists them)`,\n )\n return 1\n },\n },\n\n verify: {\n summary: \"Replay the corpus and a stateful scenario against real Junction and the mock\",\n usage: \"mockingbird-junction verify --real-key <sk_us_\u2026> [--corpus <file>] [--orders]\",\n options: {\n ...REAL_OPTIONS,\n corpus: {\n type: \"string\",\n value: \"<default|file>\",\n description: \"Corpus the mock serves and drift is checked against\",\n default: \"default\",\n },\n sample: {\n type: \"string\",\n value: \"<n>\",\n description: \"Re-fetch at most n recorded observations (default: all)\",\n },\n \"skip-drift\": { type: \"boolean\", description: \"Only run the stateful scenario\" },\n orders: {\n type: \"boolean\",\n description: \"Also place and cancel an order on the real team\",\n },\n json: { type: \"boolean\", description: \"Print the report as JSON\" },\n },\n async run(values) {\n const key = guardKey(realKeyOf(values), values)\n if (key === undefined) return 2\n const corpus = await loadCorpus(asString(values.corpus) ?? \"default\")\n if (!corpus) {\n console.error(\"verify needs a corpus (--corpus default or a file)\")\n return 2\n }\n const sample = asString(values.sample)\n const report = await verifyAgainstReal({\n realKey: key,\n realUrl: asString(values[\"real-url\"]) ?? DEFAULT_JUNCTION_BASE_URL,\n mock: createRuntime({ corpus }),\n corpus,\n ...(sample !== undefined ? { sample: Number.parseInt(sample, 10) } : {}),\n skipDrift: values[\"skip-drift\"] === true,\n orders: values.orders === true,\n ...(values.json === true\n ? {}\n : { onProgress: (message: string) => console.log(`verify: ${message}`) }),\n })\n if (values.json === true) {\n console.log(JSON.stringify(report, null, 2))\n } else {\n for (const d of report.divergences) {\n console.log(`DIVERGED ${d.check} (${d.kind}${d.at ? ` at ${d.at}` : \"\"})`)\n console.log(` real: ${JSON.stringify(d.real)?.slice(0, 400)}`)\n console.log(` mock: ${JSON.stringify(d.mock)?.slice(0, 400)}`)\n }\n console.log(\n `verify: drift ${report.drift.stale}/${report.drift.checked} stale; scenario ${report.scenario.divergent}/${report.scenario.steps} divergent \u2014 ${report.ok ? \"OK\" : \"DIVERGED\"}`,\n )\n }\n return report.ok ? 0 : 1\n },\n },\n },\n },\n process.argv.slice(2),\n)\nif (code !== 0) process.exitCode = code\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,UAAU,iBAAiB;AASpC,IAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ;AAEtD,IAAM,YAAY,CAAC,WACjB,SAAS,OAAO,UAAU,CAAC,KAC3B,QAAQ,IAAI,gCACZ,QAAQ,IAAI;AAEd,IAAM,aAAa,OAAO,WACxB,WAAW,YACP,gBACA,kBAAkB,KAAK,MAAM,MAAM,SAAS,QAAQ,MAAM,CAAC,CAAC;AAElE,IAAM,WAAW,CAAC,KAAyB,WAA0C;AACnF,MAAI,QAAQ,QAAW;AACrB,YAAQ,MAAM,0DAA0D;AACxE,WAAO;AAAA,EACT;AACA,MAAI,CAAC,aAAa,GAAG,KAAK,OAAO,eAAe,MAAM,MAAM;AAC1D,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,eAAe;AAAA,EACnB,YAAY;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,YAAY;AAAA,IACV,MAAM;AAAA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AAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/corpus.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Lab-test catalog mirrored from the Junction sandbox (`GET /v3/lab_test`). */
|
|
2
|
+
type CatalogMarker = {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
lab_id: number | null;
|
|
8
|
+
provider_id: string | null;
|
|
9
|
+
type: string | null;
|
|
10
|
+
unit: string | null;
|
|
11
|
+
price: string | null;
|
|
12
|
+
aoe: unknown;
|
|
13
|
+
a_la_carte_enabled: boolean;
|
|
14
|
+
common_tat_days: number | null;
|
|
15
|
+
worst_case_tat_days: number | null;
|
|
16
|
+
is_orderable: boolean | null;
|
|
17
|
+
};
|
|
18
|
+
type ExpectedResultLoinc = {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
code: string;
|
|
23
|
+
unit: string | null;
|
|
24
|
+
};
|
|
25
|
+
type ExpectedResult = {
|
|
26
|
+
id: number;
|
|
27
|
+
name: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
lab_id: number | null;
|
|
30
|
+
provider_id: string | null;
|
|
31
|
+
required: boolean;
|
|
32
|
+
loinc: ExpectedResultLoinc | null;
|
|
33
|
+
};
|
|
34
|
+
type LabTestRecord = {
|
|
35
|
+
id: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
name: string;
|
|
38
|
+
sample_type: string;
|
|
39
|
+
method: string;
|
|
40
|
+
price: number;
|
|
41
|
+
is_active: boolean;
|
|
42
|
+
status: string;
|
|
43
|
+
fasting: boolean;
|
|
44
|
+
lab: Record<string, unknown>;
|
|
45
|
+
markers: CatalogMarker[] | null;
|
|
46
|
+
is_delegated: boolean;
|
|
47
|
+
auto_generated: boolean;
|
|
48
|
+
has_collection_instructions: boolean | null;
|
|
49
|
+
common_tat_days: number | null;
|
|
50
|
+
worst_case_tat_days: number | null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type GetCacheEntry = {
|
|
54
|
+
status: number;
|
|
55
|
+
headers: Record<string, string>;
|
|
56
|
+
body: unknown;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Version of the sealed-corpus on-disk format. Bumped whenever the shape changes so a
|
|
61
|
+
* stale recording is rejected instead of half-applied.
|
|
62
|
+
*/
|
|
63
|
+
declare const SEALED_CORPUS_VERSION = 1;
|
|
64
|
+
/**
|
|
65
|
+
* Exact sandbox recording of the provider-owned reads a drop-in consumer depends on:
|
|
66
|
+
* parameter-stable GET observations (area/PSC inventory), the lab catalog, team labs, and
|
|
67
|
+
* lab accounts. Availability is intentionally absent — its slot dates and single-use
|
|
68
|
+
* `booking_key`s can never match a live cache key, so it stays with the generator.
|
|
69
|
+
*/
|
|
70
|
+
type SealedCorpus = {
|
|
71
|
+
version: typeof SEALED_CORPUS_VERSION;
|
|
72
|
+
recordedAt: string;
|
|
73
|
+
source: string;
|
|
74
|
+
/** SHA-256 of the recording's content, written by `corpus pull`. Identifies it in logs. */
|
|
75
|
+
fingerprint?: string;
|
|
76
|
+
observations: Record<string, GetCacheEntry>;
|
|
77
|
+
catalog: {
|
|
78
|
+
labTests: LabTestRecord[];
|
|
79
|
+
labs: Record<string, unknown>[];
|
|
80
|
+
expectedResults: Record<string, ExpectedResult[]>;
|
|
81
|
+
};
|
|
82
|
+
labAccounts: Record<string, unknown>[];
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The corpus shipped with this package, recorded from the Junction sandbox: area and
|
|
87
|
+
* PSC serviceability for a fixed ZIP set, plus the recording team's lab catalog.
|
|
88
|
+
*
|
|
89
|
+
* Its catalog is the recording team's, not yours — lab-test ids differ per team. To
|
|
90
|
+
* serve your own catalog and lab accounts, record your team with
|
|
91
|
+
* `mockingbird-junction corpus pull` and load that file instead.
|
|
92
|
+
*
|
|
93
|
+
* A separate entry point, so importing the mock does not parse megabytes of JSON.
|
|
94
|
+
*/
|
|
95
|
+
declare const defaultCorpus: SealedCorpus;
|
|
96
|
+
|
|
97
|
+
export { defaultCorpus };
|
package/dist/corpus.js
ADDED