@crvouga/mockingbird 0.1.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/README.md ADDED
@@ -0,0 +1,218 @@
1
+ # @crvouga/mockingbird
2
+
3
+ Stateful, contract-checked mocks of third-party HTTP APIs (Stripe, Junction/Vital, GeneByGene,
4
+ Medplum) and in-memory SQL engines (PostgreSQL, SQLite) for your test process. Each HTTP mock is a
5
+ plain Fetch handler — `mock.fetch(request) → Promise<Response>` — that speaks the provider's real
6
+ surface, keeps state, and is verified against the real sandbox by differential property tests.
7
+
8
+ This package is the umbrella: it re-exports every mock plus the `mockingbird` CLI. It is also the
9
+ **integration guide for coding agents** — read this file, then the README of each provider package
10
+ you use (`node_modules/@crvouga/mockingbird-service-<provider>/README.md`).
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -D @crvouga/mockingbird
16
+ # or only what you need, e.g.
17
+ npm install -D @crvouga/mockingbird-service-stripe
18
+ ```
19
+
20
+ Requirements: Node.js >= 22 or Bun >= 1.2, ESM only (`import`, not `require`). TypeScript types
21
+ ship with every package.
22
+
23
+ ## Usage
24
+
25
+ ### Scaffold with the CLI
26
+
27
+ ```bash
28
+ npx mockingbird init --providers stripe,junction --dry-run # preview
29
+ npx mockingbird init --providers stripe,junction # writes tests/mocks/mockingbird.ts
30
+ npx mockingbird init --providers stripe --json # machine-readable plan
31
+ ```
32
+
33
+ `init` writes `tests/mocks/mockingbird.ts` (a `createMockProviders()` factory) and prints the
34
+ install command for your package manager; it does not install anything itself. Providers:
35
+ `stripe`, `junction`, `genebygene`, `medplum`.
36
+
37
+ ### In-process (preferred)
38
+
39
+ Pass the mock's `fetch` wherever your code accepts one. No network, no ports, fully isolated.
40
+
41
+ ```ts
42
+ import { createDefaultSqlite, JunctionAPI, StripeAPI } from "@crvouga/mockingbird"
43
+
44
+ const sqlite = createDefaultSqlite() // one in-memory DB; each service keeps its own namespace
45
+ const stripe = new StripeAPI({ sqlite, now: () => Date.UTC(2025, 0, 1) })
46
+ const junction = new JunctionAPI({ sqlite })
47
+
48
+ const created = await stripe.fetch(
49
+ new Request("https://api.stripe.com/v1/customers", {
50
+ method: "POST",
51
+ headers: {
52
+ authorization: "Bearer sk_test_mockingbird",
53
+ "content-type": "application/x-www-form-urlencoded",
54
+ },
55
+ body: new URLSearchParams({ email: "qa@example.com" }),
56
+ }),
57
+ )
58
+ const customer = (await created.json()) as { id: string }
59
+
60
+ await stripe.reset() // clears only Stripe's records; Junction's survive
61
+ ```
62
+
63
+ - **Any host works.** The mock routes on method + path, so keep your production base URL.
64
+ - **Auth is enforced like the real API.** Send the provider's header (Stripe
65
+ `authorization: Bearer sk_test_…`, Junction `x-vital-api-key`, GeneByGene a bearer token from
66
+ its `/connect/token` endpoint) or you get the provider's own `401`.
67
+ - **State persists per instance** until `reset()`. Use a fresh instance (or `reset()`) per test.
68
+ - **Deterministic time:** pass `now` to freeze `created`-style timestamps.
69
+
70
+ ### Route a whole app's `fetch`
71
+
72
+ When the code under test calls `fetch` directly, route by hostname and fall through to the
73
+ network for everything else:
74
+
75
+ ```ts
76
+ import { GeneByGeneAPI, JunctionAPI, StripeAPI } from "@crvouga/mockingbird"
77
+ import type { FetchAPI } from "@crvouga/mockingbird"
78
+
79
+ const mocks: Record<string, FetchAPI> = {
80
+ "api.stripe.com": new StripeAPI(),
81
+ "api.sandbox.us.junction.com": new JunctionAPI(),
82
+ "api.genebygene.com": new GeneByGeneAPI(),
83
+ }
84
+
85
+ const realFetch = globalThis.fetch
86
+ export const mockFetch = (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
87
+ const request = new Request(input, init)
88
+ const mock = mocks[new URL(request.url).hostname]
89
+ return mock ? mock.fetch(request) : realFetch(request)
90
+ }
91
+ // Inject mockFetch into your HTTP client, or assign it to globalThis.fetch in test setup.
92
+ ```
93
+
94
+ ### Over HTTP
95
+
96
+ When something needs a real URL (an official SDK without a custom-fetch hook, another process, a
97
+ browser), serve the mock with an adapter:
98
+
99
+ ```ts
100
+ import type { AddressInfo } from "node:net"
101
+ import { serve } from "@crvouga/mockingbird-adapter-node"
102
+ import { StripeAPI } from "@crvouga/mockingbird-service-stripe"
103
+
104
+ const server = await serve(new StripeAPI()) // node:http Server on an ephemeral port
105
+ const { port } = server.address() as AddressInfo
106
+ const baseUrl = `http://127.0.0.1:${port}` // point the SDK / app at this
107
+ // ... run tests ...
108
+ server.close()
109
+ ```
110
+
111
+ On Bun use `serve` from `@crvouga/mockingbird-adapter-bun` (returns a `Bun.serve` server). Each
112
+ provider README shows how to point that provider's official SDK at the mock.
113
+
114
+ ### Medplum is different
115
+
116
+ `MedplumAPI` runs the real Medplum server as a child process on embedded Postgres + Redis. Call
117
+ `await medplum.start()` before use and `await medplum.stop()` after; the first start clones and
118
+ builds Medplum (slow, cached afterwards). See `@crvouga/mockingbird-service-medplum`.
119
+
120
+ ## Choosing a package
121
+
122
+ | You need | Install |
123
+ | --- | --- |
124
+ | Everything, one dependency | `@crvouga/mockingbird` |
125
+ | Stripe (customers, payment intents, subscriptions, invoices, webhooks, …) | `@crvouga/mockingbird-service-stripe` |
126
+ | Junction / Vital (users, lab tests, orders) | `@crvouga/mockingbird-service-junction` |
127
+ | GeneByGene (OAuth token, products, orders) | `@crvouga/mockingbird-service-genebygene` |
128
+ | Medplum (real FHIR server, self-hosted) | `@crvouga/mockingbird-service-medplum` |
129
+ | In-memory PostgreSQL / SQLite engine, pure TypeScript | `@crvouga/mockingbird-service-postgres` / `@crvouga/mockingbird-service-sqlite` |
130
+ | Serve any mock over HTTP | `@crvouga/mockingbird-adapter-node` / `@crvouga/mockingbird-adapter-bun` |
131
+ | Prove your own mock matches a real API (differential property tests) | `@crvouga/mockingbird-parity` |
132
+ | Build a new mock from an OpenAPI spec | `@crvouga/mockingbird-service`, `@crvouga/mockingbird-openapi` |
133
+
134
+ Granular packages are the source of truth; this package only re-exports them. Coverage per
135
+ provider (which operations are implemented) is in each package's `SUPPORT.md` on GitHub.
136
+
137
+ ## For coding agents
138
+
139
+ Rules for integrating Mockingbird into a project:
140
+
141
+ 1. Install as a **devDependency**. Never import mocks from production code paths.
142
+ 2. Prefer in-process injection of `mock.fetch`; fall back to `serve()` only when a URL is required.
143
+ 3. Create mocks in test setup, `reset()` (or recreate) between tests, and never share one instance
144
+ across parallel test files.
145
+ 4. Send the provider's real auth header and body encoding (Stripe is
146
+ `application/x-www-form-urlencoded`; Junction and GeneByGene are JSON). A `401`/`400` from the
147
+ mock usually means the request would fail against the real API too.
148
+ 5. If an operation returns `404`/`501` unexpectedly, check that provider's `SUPPORT.md` — it may
149
+ not be implemented yet. Do not work around it by stubbing responses by hand.
150
+ 6. Every package ships types; rely on the TypeScript signatures (`dist/*.d.ts`) over guesses.
151
+
152
+ Paste this into your project's `AGENTS.md` / `CLAUDE.md` so future agents find these docs:
153
+
154
+ ```md
155
+ ## Third-party API mocks (Mockingbird)
156
+ Tests use Mockingbird mocks instead of real Stripe/Junction/GeneByGene/Medplum APIs.
157
+ Read node_modules/@crvouga/mockingbird/README.md first, then
158
+ node_modules/@crvouga/mockingbird-service-<provider>/README.md. Mock setup: tests/mocks/mockingbird.ts.
159
+ ```
160
+
161
+ A machine-readable index of every package's docs: https://github.com/crvouga/mockingbird/blob/main/llms.txt
162
+
163
+ ## API
164
+
165
+ Core contract
166
+
167
+ - `FetchAPI` (type) — `{ fetch(request: Request): Promise<Response> }`, implemented by every mock.
168
+ - `FetchHandler` (type) — `(request: Request) => Promise<Response>`.
169
+ - `toFetchHandler(api)` — `FetchAPI` → bare handler (for `Bun.serve`, workers, Deno).
170
+ - `fromFetchHandler(handler)` — bare handler → `FetchAPI`.
171
+ - `APIOptions` (type) — `{ sqlite?: SqliteClient; now?: () => number }`, accepted by the SQLite-backed mocks.
172
+
173
+ Storage (`@crvouga/mockingbird-sqlite`)
174
+
175
+ - `createDefaultSqlite()` — fresh in-memory SQLite client (pure TypeScript engine).
176
+ - `resolveSqlite(client?)` — the given client, or a new default one.
177
+ - `migrateCore(sqlite)` — create Mockingbird's core tables (mocks do this on boot).
178
+ - Types: `SqliteClient`, `SqliteStatement`, `SqliteValue`.
179
+
180
+ Stripe (`@crvouga/mockingbird-service-stripe`)
181
+
182
+ - `StripeAPI` — the mock (`new StripeAPI(options?)`, `fetch`, `reset`).
183
+ - `stripeDocument` — the vendored OpenAPI document.
184
+ - `QA_SURFACE_OPS`, `QA_TEST_CARD_TOKENS`, `QA_TEST_PAYMENT_METHODS`, `reshapeQaCommand` — QA-surface parity helpers.
185
+
186
+ Junction (`@crvouga/mockingbird-service-junction`)
187
+
188
+ - `JunctionAPI` — the mock; options add `onWebhook` / `webhook` (types `JunctionAPIOptions`, `JunctionWebhookEvent`, `JunctionWebhookOptions`, `WebhookPublisher`).
189
+ - `junctionDocument`, `junctionOperationIds`, `junctionSupportedOperationIds` — spec and operation coverage (types `JunctionOperationId`, `JunctionSupportedOperationId`).
190
+ - `JUNCTION_NAMESPACE` — SQLite namespace used by the mock.
191
+ - `AVAILABILITY_ADDRESS`, `AVAILABILITY_START_DATE`, `COVERAGE_ZIPS`, `PHLEBOTOMY_AVAILABILITY_ZIPS`, `PSC_AVAILABILITY_ZIPS`, `PSC_LAB_IDS` — fixture data the lab-testing endpoints recognise.
192
+ - `observationCacheKey`, `prefetchCoverageObservations`, `reshapeCoverageGeoCommand` — sealed-corpus / seed helpers (types `GetCacheEntry`, `SealedCorpus`, `SeedObservations`, `SeedReport`, `SeedSource`).
193
+
194
+ GeneByGene (`@crvouga/mockingbird-service-genebygene`)
195
+
196
+ - `GeneByGeneAPI` — the mock. `geneByGeneDocument` — its OpenAPI document.
197
+
198
+ Medplum (`@crvouga/mockingbird-service-medplum`)
199
+
200
+ - `MedplumAPI` — self-hosted real Medplum (`start`, `stop`, `reset`, `getBaseUrl`, `getAccessToken`); options type `MedplumAPIOptions`.
201
+ - `createMedplumAPI(options?)` — construct and start in one call.
202
+
203
+ PostgreSQL engine (`@crvouga/mockingbird-service-postgres`)
204
+
205
+ - `PostgresDatabase`, `PostgresStatement`, `PostgresSnapshot`, `PostgresError` — aliases of `Database`, `Statement`, `Snapshot`, `PostgresError`.
206
+ - Types: `PostgresBindValue`, `PostgresDatabaseOptions`, `PostgresErrorCategory`, `PostgresJsValue`, `PostgresQueryRow`, `PostgresRegisterFunctionOptions`, `PostgresResultSet`, `PostgresRunResult`.
207
+
208
+ SQLite engine (`@crvouga/mockingbird-service-sqlite`)
209
+
210
+ - `SqliteDatabase`, `SqliteDatabaseStatement`, `SqliteSnapshot`, `SqliteError` — aliases of `Database`, `Statement`, `Snapshot`, `SqliteError`.
211
+ - Types: `SqliteBindValue`, `SqliteDatabaseOptions`, `SqliteErrorCategory`, `SqliteQueryRow`, `SqliteQueryValue`, `SqliteDatabaseResultSet`, `SqliteDatabaseRunResult`.
212
+
213
+ CLI
214
+
215
+ - `mockingbird init [--providers <list>] [--dir <path>] [--package-manager bun|npm|pnpm|yarn] [--dry-run] [--json]`
216
+ - `mockingbird --help`, `mockingbird --version`
217
+
218
+ Part of [mockingbird](https://github.com/crvouga/mockingbird).
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Mockingbird CLI — `mockingbird init` for agent-friendly project setup.
4
+ *
5
+ * Usage:
6
+ * mockingbird --help
7
+ * mockingbird --version
8
+ * mockingbird init [--providers stripe,junction] [--dir .] [--package-manager bun] [--dry-run] [--json]
9
+ */
10
+ import { readFileSync } from "node:fs";
11
+ import { initProject, printInitResult } from "./init.js";
12
+ const VERSION = "0.0.0-development";
13
+ function readVersion() {
14
+ try {
15
+ // dist/cli/index.js → package root; the release job stamps the real version there.
16
+ const pkgPath = new URL("../../package.json", import.meta.url).pathname;
17
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
18
+ return pkg.version ?? VERSION;
19
+ }
20
+ catch {
21
+ return VERSION;
22
+ }
23
+ }
24
+ function showHelp() {
25
+ console.log(`mockingbird ${readVersion()}
26
+
27
+ Usage: mockingbird <command> [options]
28
+
29
+ Commands:
30
+ init Scaffold Mockingbird into a consuming project
31
+ --help, -h Show this help
32
+ --version, -v Print version
33
+
34
+ Options for init:
35
+ --providers Comma-separated provider list (stripe,junction,genebygene,medplum)
36
+ --dir Target project directory (default: current directory)
37
+ --package-manager Package manager to use (bun, npm, pnpm, yarn; default: auto-detect)
38
+ --dry-run Preview changes without applying
39
+ --json Output structured JSON for programmatic consumption
40
+ --help Show init help
41
+
42
+ Examples:
43
+ mockingbird init --providers stripe --dir ./my-app
44
+ mockingbird init --providers stripe,junction --dry-run --json
45
+ mockingbird init --help`);
46
+ }
47
+ function showInitHelp() {
48
+ console.log(`mockingbird init — scaffold Mockingbird into a consuming project
49
+
50
+ This command installs @crvouga/mockingbird and optionally provider-specific
51
+ service packages, then creates a boilerplate test setup file.
52
+
53
+ Designed for agent-friendly use: all options are flag-driven, and --json
54
+ output is machine-parseable.
55
+
56
+ Options:
57
+ --providers <list> Comma-separated provider names: stripe, junction, genebygene, medplum
58
+ --dir <path> Target project directory (default: .)
59
+ --package-manager <pm> Force a package manager: bun, npm, pnpm, yarn
60
+ --dry-run Print planned actions without making changes
61
+ --json Output structured JSON
62
+ --help Show this help
63
+
64
+ Examples:
65
+ mockingbird init --providers stripe --dir ./my-app
66
+ mockingbird init --providers stripe,junction --dry-run --json
67
+ mockingbird init --help`);
68
+ }
69
+ function parseArgs() {
70
+ const args = process.argv.slice(2);
71
+ const command = args[0] ?? "";
72
+ const options = {};
73
+ if (command === "init") {
74
+ for (let i = 1; i < args.length; i++) {
75
+ const arg = args[i];
76
+ if (!arg)
77
+ continue;
78
+ switch (arg) {
79
+ case "--dir":
80
+ case "-d":
81
+ options.dir = args[++i] ?? ".";
82
+ break;
83
+ case "--package-manager":
84
+ case "-p":
85
+ options.packageManager = args[++i] ?? "";
86
+ break;
87
+ case "--providers":
88
+ case "-P": {
89
+ const list = args[++i] ?? "";
90
+ options.providers = list.split(",").filter(Boolean);
91
+ break;
92
+ }
93
+ case "--dry-run":
94
+ options.dryRun = true;
95
+ break;
96
+ case "--json":
97
+ options.json = true;
98
+ break;
99
+ case "--help":
100
+ case "-h":
101
+ options.help = true;
102
+ break;
103
+ default:
104
+ if (arg.startsWith("--")) {
105
+ console.error(`mockingbird: unknown option ${arg}`);
106
+ process.exit(1);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ if (command === "--help" || command === "-h") {
112
+ options.help = true;
113
+ }
114
+ if (command === "--version" || command === "-v") {
115
+ console.log(readVersion());
116
+ process.exit(0);
117
+ }
118
+ return { command, options };
119
+ }
120
+ // ── Main ───────────────────────────────────────────────────────────
121
+ const { command, options } = parseArgs();
122
+ if (options.help) {
123
+ if (command === "init") {
124
+ showInitHelp();
125
+ }
126
+ else {
127
+ showHelp();
128
+ }
129
+ process.exit(0);
130
+ }
131
+ switch (command) {
132
+ case "init": {
133
+ const packageManager = options.packageManager;
134
+ const opts = {
135
+ providers: options.providers ?? [],
136
+ dir: options.dir ?? process.cwd(),
137
+ dryRun: Boolean(options.dryRun),
138
+ json: Boolean(options.json),
139
+ };
140
+ if (typeof packageManager === "string") {
141
+ if (!["npm", "bun", "pnpm", "yarn"].includes(packageManager)) {
142
+ console.error(`mockingbird init: unknown package manager "${packageManager}"`);
143
+ console.error(" Valid: npm, bun, pnpm, yarn");
144
+ process.exit(1);
145
+ }
146
+ opts.packageManager = packageManager;
147
+ }
148
+ const result = await initProject(opts);
149
+ printInitResult(result, Boolean(options.json), Boolean(options.dryRun));
150
+ break;
151
+ }
152
+ case "":
153
+ console.log("mockingbird: missing command. Use --help for usage.");
154
+ process.exit(1);
155
+ break;
156
+ default:
157
+ console.error(`mockingbird: unknown command "${command}". Use --help for usage.`);
158
+ process.exit(1);
159
+ }
160
+ //# sour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AO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACjB,CAAC;YACD,IAAI,CAAC,cAAc,GAAG,cAAgC,CAAA;QACxD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAA;QACtC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACvE,MAAK;IACP,CAAC;IAED,KAAK,EAAE;QACL,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAA;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACf,MAAK;IAEP;QACE,OAAO,CAAC,KAAK,CAAC,iCAAiC,OAAO,0BAA0B,CAAC,CAAA;QACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type PackageManager } from "./project.js";
2
+ export type InitOptions = {
3
+ providers: string[];
4
+ dir: string;
5
+ packageManager?: PackageManager;
6
+ dryRun: boolean;
7
+ json: boolean;
8
+ };
9
+ export type InitAction = {
10
+ type: "install" | "create_file" | "add_readme_section" | "info";
11
+ description: string;
12
+ details?: string;
13
+ };
14
+ export type InitResult = {
15
+ actions: InitAction[];
16
+ files: string[];
17
+ installCommands: string[];
18
+ skipReason?: string;
19
+ };
20
+ export declare function initProject(opts: InitOptions): Promise<InitResult>;
21
+ export declare function printInitResult(result: InitResult, json: boolean, dryRun: boolean): void;
22
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAA;AAGrB,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM,CAAA;IAC/D,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAiGxE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CA6CxF"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * `mockingbird init` — scaffold Mockingbird into a consuming project.
3
+ *
4
+ * mockingbird init [--providers stripe,junction] [--dir .]
5
+ * [--package-manager bun] [--dry-run] [--json] [--help]
6
+ */
7
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
8
+ import { join, relative } from "node:path";
9
+ import { detectPackageManager, installCommand, KNOWN_PROVIDERS, readProjectInfo, } from "./project.js";
10
+ import { generateSetupContent } from "./templates/init.js";
11
+ export async function initProject(opts) {
12
+ const project = await readProjectInfo(opts.dir);
13
+ const actions = [];
14
+ const files = [];
15
+ const installCmds = [];
16
+ // Validate providers
17
+ const validProviders = [];
18
+ const invalidProviders = [];
19
+ for (const p of opts.providers) {
20
+ const key = p.toLowerCase();
21
+ if (KNOWN_PROVIDERS[key]) {
22
+ validProviders.push(key);
23
+ }
24
+ else {
25
+ invalidProviders.push(p);
26
+ }
27
+ }
28
+ if (invalidProviders.length > 0) {
29
+ return {
30
+ actions: [
31
+ {
32
+ type: "info",
33
+ description: `Unknown providers: ${invalidProviders.join(", ")}. Known: ${Object.keys(KNOWN_PROVIDERS).join(", ")}`,
34
+ },
35
+ ],
36
+ files: [],
37
+ installCommands: [],
38
+ skipReason: `Unknown providers: ${invalidProviders.join(", ")}`,
39
+ };
40
+ }
41
+ // Check project has a package.json
42
+ if (!project.pkg) {
43
+ return {
44
+ actions: [
45
+ {
46
+ type: "info",
47
+ description: `No package.json found at ${opts.dir}. Run mockingbird init in a Node/Bun project directory.`,
48
+ },
49
+ ],
50
+ files: [],
51
+ installCommands: [],
52
+ skipReason: "No package.json found",
53
+ };
54
+ }
55
+ const pm = opts.packageManager ?? detectPackageManager(opts.dir);
56
+ // 1. Install @crvouga/mockingbird (and service packages if providers specified)
57
+ const deps = ["@crvouga/mockingbird"];
58
+ for (const p of validProviders) {
59
+ const dependency = KNOWN_PROVIDERS[p];
60
+ if (dependency)
61
+ deps.push(dependency);
62
+ }
63
+ const cmd = installCommand(pm, deps, true);
64
+ installCmds.push(cmd);
65
+ actions.push({
66
+ type: "install",
67
+ description: `Install ${deps.join(", ")} as devDependencies`,
68
+ details: cmd,
69
+ });
70
+ // 2. Create test setup file
71
+ const mocksDir = join(opts.dir, "tests", "mocks");
72
+ const setupPath = join(mocksDir, "mockingbird.ts");
73
+ const relPath = relative(opts.dir, setupPath);
74
+ const content = generateSetupContent(validProviders, project.typescript);
75
+ files.push(setupPath);
76
+ actions.push({
77
+ type: "create_file",
78
+ description: `Create ${relPath} with boilerplate mock setup`,
79
+ details: `${content.substring(0, 200)}...`,
80
+ });
81
+ if (!opts.dryRun) {
82
+ mkdirSync(mocksDir, { recursive: true });
83
+ writeFileSync(setupPath, content, "utf8");
84
+ }
85
+ // 3. Add README section (optional, only if README.md exists)
86
+ const readmePath = join(opts.dir, "README.md");
87
+ if (existsSync(readmePath)) {
88
+ actions.push({
89
+ type: "info",
90
+ description: "README.md found — document the mocks for your team (see node_modules/@crvouga/mockingbird/README.md)",
91
+ });
92
+ }
93
+ return {
94
+ actions,
95
+ files,
96
+ installCommands: installCmds,
97
+ };
98
+ }
99
+ export function printInitResult(result, json, dryRun) {
100
+ if (json) {
101
+ console.log(JSON.stringify(result, null, 2));
102
+ return;
103
+ }
104
+ if (result.skipReason) {
105
+ console.log(`mockingbird init: ${result.skipReason}`);
106
+ process.exit(1);
107
+ }
108
+ console.log(`mockingbird init — ${dryRun ? "planned actions" : "done"}:\n`);
109
+ for (const action of result.actions) {
110
+ switch (action.type) {
111
+ case "install":
112
+ console.log(` 📦 ${action.description}`);
113
+ if (action.details)
114
+ console.log(` ${action.details}`);
115
+ break;
116
+ case "create_file":
117
+ console.log(` 📝 ${action.description}`);
118
+ break;
119
+ case "add_readme_section":
120
+ console.log(` 📖 ${action.description}`);
121
+ break;
122
+ case "info":
123
+ console.log(` ℹ️ ${action.description}`);
124
+ break;
125
+ }
126
+ }
127
+ if (result.files.length > 0) {
128
+ console.log(dryRun ? "\nFiles to create:" : "\nFiles created:");
129
+ for (const f of result.files) {
130
+ console.log(` - ${f}`);
131
+ }
132
+ }
133
+ if (result.installCommands.length > 0) {
134
+ console.log("\nInstall the packages (not run for you):");
135
+ for (const cmd of result.installCommands) {
136
+ console.log(` ${cmd}`);
137
+ }
138
+ }
139
+ if (dryRun)
140
+ console.log("\nRun without --dry-run to apply.");
141
+ }
142
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,eAAe,EAEf,eAAe,GAChB,MAAM,cAAc,CAAA;AACrB,OAAO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26 @@
1
+ export type PackageManager = "npm" | "bun" | "pnpm" | "yarn";
2
+ export type TestFramework = "vitest" | "jest" | "bun-test" | "mocha" | "node-test" | null;
3
+ export type ProjectType = "app" | "lib";
4
+ export type ProjectInfo = {
5
+ /** Absolute path to the project root */
6
+ dir: string;
7
+ /** Whether the project is ESM */
8
+ esm: boolean;
9
+ /** Whether the project uses TypeScript */
10
+ typescript: boolean;
11
+ /** Detected or explicit package manager */
12
+ packageManager: PackageManager;
13
+ /** Detected test framework */
14
+ testFramework: TestFramework;
15
+ /** Project type */
16
+ type: ProjectType;
17
+ /** Parsed package.json, or null */
18
+ pkg: Record<string, unknown> | null;
19
+ };
20
+ export declare const KNOWN_PROVIDERS: Record<string, string>;
21
+ export declare function detectPackageManager(dir: string): PackageManager;
22
+ export declare function detectTestFramework(pkg: Record<string, unknown> | null): TestFramework;
23
+ export declare function detectProjectType(pkg: Record<string, unknown> | null): ProjectType;
24
+ export declare function readProjectInfo(dir: string): Promise<ProjectInfo>;
25
+ export declare function installCommand(pm: PackageManager, deps: string[], dev: boolean): string;
26
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/cli/project.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAC5D,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,IAAI,CAAA;AACzF,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,CAAA;AAEvC,MAAM,MAAM,WAAW,GAAG;IACxB,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,iCAAiC;IACjC,GAAG,EAAE,OAAO,CAAA;IACZ,0CAA0C;IAC1C,UAAU,EAAE,OAAO,CAAA;IACnB,2CAA2C;IAC3C,cAAc,EAAE,cAAc,CAAA;IAC9B,8BAA8B;IAC9B,aAAa,EAAE,aAAa,CAAA;IAC5B,mBAAmB;IACnB,IAAI,EAAE,WAAW,CAAA;IACjB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKlD,CAAA;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAOhE;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,aAAa,CAWtF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,WAAW,CAMlF;AAED,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmBvE;AACD,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAYvF"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Project detection helpers for the mockingbird CLI.
3
+ *
4
+ * Detects package manager, test framework, and project type from a target directory.
5
+ */
6
+ import { existsSync, readFileSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ export const KNOWN_PROVIDERS = {
9
+ stripe: "@crvouga/mockingbird-service-stripe",
10
+ junction: "@crvouga/mockingbird-service-junction",
11
+ genebygene: "@crvouga/mockingbird-service-genebygene",
12
+ medplum: "@crvouga/mockingbird-service-medplum",
13
+ };
14
+ export function detectPackageManager(dir) {
15
+ if (existsSync(join(dir, "bun.lock")) || existsSync(join(dir, "bun.lockb")))
16
+ return "bun";
17
+ if (existsSync(join(dir, "pnpm-lock.yaml")))
18
+ return "pnpm";
19
+ if (existsSync(join(dir, "yarn.lock")))
20
+ return "yarn";
21
+ if (existsSync(join(dir, "package-lock.json")))
22
+ return "npm";
23
+ // Default to bun if available
24
+ return "bun";
25
+ }
26
+ export function detectTestFramework(pkg) {
27
+ if (!pkg)
28
+ return null;
29
+ const deps = {
30
+ ...pkg.dependencies,
31
+ ...pkg.devDependencies,
32
+ };
33
+ if (deps.vitest)
34
+ return "vitest";
35
+ if (deps.jest)
36
+ return "jest";
37
+ if (deps.mocha)
38
+ return "mocha";
39
+ if (pkg.engines && pkg.engines.bun)
40
+ return "bun-test";
41
+ return null;
42
+ }
43
+ export function detectProjectType(pkg) {
44
+ if (!pkg)
45
+ return "app";
46
+ const bin = pkg.bin;
47
+ if (bin && typeof bin === "object" && Object.keys(bin).length > 0)
48
+ return "lib";
49
+ if (bin && typeof bin === "string")
50
+ return "lib";
51
+ return "app";
52
+ }
53
+ export async function readProjectInfo(dir) {
54
+ const pkgPath = join(dir, "package.json");
55
+ let pkg = null;
56
+ if (existsSync(pkgPath)) {
57
+ pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
58
+ }
59
+ const typescript = existsSync(join(dir, "tsconfig.json"));
60
+ const esm = pkg?.type === "module" || false;
61
+ return {
62
+ dir,
63
+ esm,
64
+ typescript,
65
+ packageManager: detectPackageManager(dir),
66
+ testFramework: detectTestFramework(pkg),
67
+ type: detectProjectType(pkg),
68
+ pkg,
69
+ };
70
+ }
71
+ export function installCommand(pm, deps, dev) {
72
+ const flag = dev ? "--dev" : "";
73
+ switch (pm) {
74
+ case "bun":
75
+ return `bun add ${deps.join(" ")} ${flag}`.trim();
76
+ case "pnpm":
77
+ return `pnpm add ${deps.join(" ")} ${dev ? "--save-dev" : ""}`.trim();
78
+ case "yarn":
79
+ return `yarn add ${deps.join(" ")} ${dev ? "--dev" : ""}`.trim();
80
+ case "npm":
81
+ return `npm install ${deps.join(" ")} ${dev ? "--save-dev" : ""}`.trim();
82
+ }
83
+ }
84
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version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AAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/B,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,KAAK;YACR,OAAO,WAAW,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;QACnD,KAAK,MAAM;YACT,OAAO,YAAY,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;QACvE,KAAK,MAAM;YACT,OAAO,YAAY,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;QAClE,KAAK,KAAK;YACR,OAAO,eAAe,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5E,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Boilerplate templates for the mockingbird init command.
3
+ */
4
+ export type ProviderTemplate = {
5
+ /** Short name, e.g. "stripe" */
6
+ name: string;
7
+ /** npm package name */
8
+ pkg: string;
9
+ /** Class/type name for TypeScript return annotations */
10
+ typeName: string;
11
+ /** Import statement */
12
+ importStatement: string;
13
+ /** Instance creation line */
14
+ instanceLine: string;
15
+ /** Return field name */
16
+ field: string;
17
+ };
18
+ export declare function getProviderTemplate(name: string): ProviderTemplate | undefined;
19
+ export declare function generateSetupContent(providers: string[], typescript: boolean): string;
20
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAA;IAChB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAsCD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAG9E;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,CA4DrF"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Boilerplate templates for the mockingbird init command.
3
+ */
4
+ const PROVIDER_TEMPLATES = {
5
+ stripe: () => ({
6
+ name: "stripe",
7
+ pkg: "@crvouga/mockingbird-service-stripe",
8
+ typeName: "StripeAPI",
9
+ importStatement: `import { StripeAPI } from "@crvouga/mockingbird-service-stripe"`,
10
+ instanceLine: `const stripe = new StripeAPI({ sqlite })`,
11
+ field: "stripe",
12
+ }),
13
+ junction: () => ({
14
+ name: "junction",
15
+ pkg: "@crvouga/mockingbird-service-junction",
16
+ typeName: "JunctionAPI",
17
+ importStatement: `import { JunctionAPI } from "@crvouga/mockingbird-service-junction"`,
18
+ instanceLine: `const junction = new JunctionAPI({ sqlite })`,
19
+ field: "junction",
20
+ }),
21
+ genebygene: () => ({
22
+ name: "genebygene",
23
+ pkg: "@crvouga/mockingbird-service-genebygene",
24
+ typeName: "GeneByGeneAPI",
25
+ importStatement: `import { GeneByGeneAPI } from "@crvouga/mockingbird-service-genebygene"`,
26
+ instanceLine: `const genebygene = new GeneByGeneAPI({ sqlite })`,
27
+ field: "genebygene",
28
+ }),
29
+ medplum: () => ({
30
+ name: "medplum",
31
+ pkg: "@crvouga/mockingbird-service-medplum",
32
+ typeName: "MedplumAPI",
33
+ importStatement: `import { MedplumAPI } from "@crvouga/mockingbird-service-medplum"`,
34
+ // Self-hosts the real Medplum server: `await medplum.start()` before use, `stop()` after.
35
+ instanceLine: `const medplum = new MedplumAPI()`,
36
+ field: "medplum",
37
+ }),
38
+ };
39
+ export function getProviderTemplate(name) {
40
+ const factory = PROVIDER_TEMPLATES[name];
41
+ return factory?.(name);
42
+ }
43
+ export function generateSetupContent(providers, typescript) {
44
+ const ts = typescript;
45
+ const templates = providers
46
+ .map((p) => getProviderTemplate(p))
47
+ .filter(Boolean);
48
+ const sqliteBacked = templates.filter((t) => t.name !== "medplum");
49
+ const imports = [
50
+ ...(sqliteBacked.length > 0
51
+ ? [`import { createDefaultSqlite } from "@crvouga/mockingbird"`]
52
+ : []),
53
+ ...templates.map((t) => t.importStatement),
54
+ ].join("\n");
55
+ const instances = [
56
+ ...(sqliteBacked.length > 0
57
+ ? [" // One in-memory SQLite database; each service keeps its own namespace in it."]
58
+ : []),
59
+ ...(sqliteBacked.length > 0 ? [" const sqlite = createDefaultSqlite()"] : []),
60
+ ...templates.map((t) => t.name === "medplum"
61
+ ? ` // Medplum self-hosts the real server: await medplum.start() before use, medplum.stop() after.\n ${t.instanceLine}`
62
+ : ` ${t.instanceLine}`),
63
+ ].join("\n");
64
+ const returnFields = templates.map((t) => ` ${t.field},`).join("\n");
65
+ const returnType = ts
66
+ ? `: { ${templates.map((t) => `${t.field}: ${t.typeName}`).join("; ")} }`
67
+ : "";
68
+ const example = templates[0]?.field ?? "stripe";
69
+ return `// Generated by \`mockingbird init\`. Edit freely.
70
+ // Docs for agents and humans: node_modules/@crvouga/mockingbird/README.md
71
+ ${imports}
72
+
73
+ /** Fresh, isolated mock providers. Create one set per test file (or reset() between tests). */
74
+ export function createMockProviders()${returnType} {
75
+ ${instances}
76
+
77
+ return {
78
+ ${returnFields}
79
+ }
80
+ }
81
+
82
+ /*
83
+ * Each mock is a Fetch handler: \`mock.fetch(request) → Promise<Response>\`.
84
+ *
85
+ * In-process (fastest) — hand the mock's fetch to your API client:
86
+ *
87
+ * const mocks = createMockProviders()
88
+ * const res = await mocks.${example}.fetch(new Request("https://mock.local/...", { headers }))
89
+ *
90
+ * Over HTTP — when the code under test needs a base URL (official SDKs, other processes):
91
+ *
92
+ * import { serve } from "@crvouga/mockingbird-adapter-node"
93
+ * const server = await serve(mocks.${example}) // node:http Server on an ephemeral port
94
+ * const { port } = server.address() as import("node:net").AddressInfo
95
+ * // point the SDK at http://127.0.0.1:\${port}, then server.close() after the tests
96
+ */
97
+ `;
98
+ }
99
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/templates/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH,MAAM,kBAAkB,GAAuD;IAC7E,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACb,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,qCAAqC;QAC1C,QAAQ,EAAE,WAAW;QACrB,eAAe,EAAE,iEAAiE;QAClF,YAAY,EAAE,0CAA0C;QACxD,KAAK,EAAE,QAAQ;KAChB,CAAC;IACF,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;QACf,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,uCAAuC;QAC5C,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,qEAAqE;QACtF,YAAY,EAAE,8CAA8C;QAC5D,KAAK,EAAE,UAAU;KAClB,CAAC;IACF,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,yCAAyC;QAC9C,QAAQ,EAAE,eAAe;QACzB,eAAe,EAAE,yEAAyE;QAC1F,YAAY,EAAE,kDAAkD;QAChE,KAAK,EAAE,YAAY;KACpB,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,IAAI,EAAE,SAAS;QACf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AAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACrB,CAAC,CAAC,IAAI,KAAK,SAAS;YAClB,CAAC,CAAC,uGAAuG,CAAC,CAAC,YAAY,EAAE;YACzH,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAC1B;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACZ,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvE,MAAM,UAAU,GAAG,EAAE;QACnB,CAAC,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QACzE,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,QAAQ,CAAA;IAE/C,OAAO;;EAEP,OAAO;;;uCAG8B,UAAU;EAC/C,SAAS;;;EAGT,YAAY;;;;;;;;;;+BAUiB,OAAO;;;;;wCAKE,OAAO;;;;CAI9C,CAAA;AACD,CAAC"}
@@ -0,0 +1,16 @@
1
+ export type { FetchAPI, FetchHandler } from "@crvouga/mockingbird-core";
2
+ export { fromFetchHandler, toFetchHandler } from "@crvouga/mockingbird-core";
3
+ export type { APIOptions } from "@crvouga/mockingbird-service";
4
+ export { document as geneByGeneDocument, GeneByGeneAPI, } from "@crvouga/mockingbird-service-genebygene";
5
+ export type { GetCacheEntry, JunctionAPIOptions, JunctionWebhookEvent, JunctionWebhookOptions, OperationId as JunctionOperationId, SealedCorpus, SeedObservations, SeedReport, SeedSource, SupportedOperationId as JunctionSupportedOperationId, WebhookPublisher, } from "@crvouga/mockingbird-service-junction";
6
+ export { AVAILABILITY_ADDRESS, AVAILABILITY_START_DATE, COVERAGE_ZIPS, document as junctionDocument, JUNCTION_NAMESPACE, JunctionAPI, observationCacheKey, operationIds as junctionOperationIds, PHLEBOTOMY_AVAILABILITY_ZIPS, PSC_AVAILABILITY_ZIPS, PSC_LAB_IDS, prefetchCoverageObservations, reshapeCoverageGeoCommand, supportedOperationIds as junctionSupportedOperationIds, } from "@crvouga/mockingbird-service-junction";
7
+ export type { MedplumAPIOptions } from "@crvouga/mockingbird-service-medplum";
8
+ export { createMedplumAPI, MedplumAPI, } from "@crvouga/mockingbird-service-medplum";
9
+ export type { BindValue as PostgresBindValue, DatabaseOptions as PostgresDatabaseOptions, ErrorCategory as PostgresErrorCategory, JsValue as PostgresJsValue, QueryRow as PostgresQueryRow, RegisterFunctionOptions as PostgresRegisterFunctionOptions, ResultSet as PostgresResultSet, RunResult as PostgresRunResult, } from "@crvouga/mockingbird-service-postgres";
10
+ export { Database as PostgresDatabase, PostgresError, Snapshot as PostgresSnapshot, Statement as PostgresStatement, } from "@crvouga/mockingbird-service-postgres";
11
+ export type { BindValue as SqliteBindValue, DatabaseOptions as SqliteDatabaseOptions, ErrorCategory as SqliteErrorCategory, QueryRow as SqliteQueryRow, QueryValue as SqliteQueryValue, ResultSet as SqliteDatabaseResultSet, RunResult as SqliteDatabaseRunResult, } from "@crvouga/mockingbird-service-sqlite";
12
+ export { Database as SqliteDatabase, Snapshot as SqliteSnapshot, SqliteError, Statement as SqliteDatabaseStatement, } from "@crvouga/mockingbird-service-sqlite";
13
+ export { document as stripeDocument, QA_SURFACE_OPS, QA_TEST_CARD_TOKENS, QA_TEST_PAYMENT_METHODS, reshapeQaCommand, StripeAPI, } from "@crvouga/mockingbird-service-stripe";
14
+ export type { SqliteClient, SqliteStatement, SqliteValue } from "@crvouga/mockingbird-sqlite";
15
+ export { createDefaultSqlite, migrateCore, resolveSqlite, } from "@crvouga/mockingbird-sqlite";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+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EACb,QAAQ,IAAI,gBAAgB,EAC5B,SAAS,IAAI,iBAAiB,GAC/B,MAAM,uCAAuC,CAAA;AAC9C,YAAY,EACV,SAAS,IAAI,eAAe,EAC5B,eAAe,IAAI,qBAAqB,EACxC,aAAa,IAAI,mBAAmB,EACpC,QAAQ,IAAI,cAAc,EAC1B,UAAU,IAAI,gBAAgB,EAC9B,SAAS,IAAI,uBAAuB,EACpC,SAAS,IAAI,uBAAuB,GACrC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,QAAQ,IAAI,cAAc,EAC1B,WAAW,EACX,SAAS,IAAI,uBAAuB,GACrC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,GACV,MAAM,qCAAqC,CAAA;AAC5C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC7F,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,6BAA6B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { fromFetchHandler, toFetchHandler } from "@crvouga/mockingbird-core";
2
+ export { document as geneByGeneDocument, GeneByGeneAPI, } from "@crvouga/mockingbird-service-genebygene";
3
+ export { AVAILABILITY_ADDRESS, AVAILABILITY_START_DATE, COVERAGE_ZIPS, document as junctionDocument, JUNCTION_NAMESPACE, JunctionAPI, observationCacheKey, operationIds as junctionOperationIds, PHLEBOTOMY_AVAILABILITY_ZIPS, PSC_AVAILABILITY_ZIPS, PSC_LAB_IDS, prefetchCoverageObservations, reshapeCoverageGeoCommand, supportedOperationIds as junctionSupportedOperationIds, } from "@crvouga/mockingbird-service-junction";
4
+ export { createMedplumAPI, MedplumAPI, } from "@crvouga/mockingbird-service-medplum";
5
+ export { Database as PostgresDatabase, PostgresError, Snapshot as PostgresSnapshot, Statement as PostgresStatement, } from "@crvouga/mockingbird-service-postgres";
6
+ export { Database as SqliteDatabase, Snapshot as SqliteSnapshot, SqliteError, Statement as SqliteDatabaseStatement, } from "@crvouga/mockingbird-service-sqlite";
7
+ export { document as stripeDocument, QA_SURFACE_OPS, QA_TEST_CARD_TOKENS, QA_TEST_PAYMENT_METHODS, reshapeQaCommand, StripeAPI, } from "@crvouga/mockingbird-service-stripe";
8
+ export { createDefaultSqlite, migrateCore, resolveSqlite, } from "@crvouga/mockingbird-sqlite";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE5E,OAAO,EACL,QAAQ,IAAI,kBAAkB,EAC9B,aAAa,GACd,MAAM,yCAAyC,CAAA;AAchD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,QAAQ,IAAI,gBAAgB,EAC5B,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,YAAY,IAAI,oBAAoB,EACpC,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,4BAA4B,EAC5B,yBAAyB,EACzB,qBAAqB,IAAI,6BAA6B,GACvD,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACL,gBAAgB,EAChB,UAAU,GACX,MAAM,sCAAsC,CAAA;AAW7C,OAAO,EACL,QAAQ,IAAI,gBAAgB,EAC5B,aAAa,EACb,QAAQ,IAAI,gBAAgB,EAC5B,SAAS,IAAI,iBAAiB,GAC/B,MAAM,uCAAuC,CAAA;AAU9C,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,QAAQ,IAAI,cAAc,EAC1B,WAAW,EACX,SAAS,IAAI,uBAAuB,GACrC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,GACV,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,6BAA6B,CAAA"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@crvouga/mockingbird",
3
+ "version": "0.1.0",
4
+ "description": "Realistic, stateful mock third-party HTTP APIs for your test process. Thin facade over the granular @crvouga/mockingbird-* packages.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "bin": {
19
+ "mockingbird": "./dist/cli/index.js"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "provenance": true
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/crvouga/mockingbird.git",
28
+ "directory": "packages/facade"
29
+ },
30
+ "homepage": "https://github.com/crvouga/mockingbird/tree/main/packages/facade#readme",
31
+ "keywords": [
32
+ "mockingbird",
33
+ "facade"
34
+ ],
35
+ "mockingbird": {
36
+ "runtime": "node",
37
+ "layer": "facade"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.build.json",
41
+ "typecheck": "tsc -p tsconfig.json --noEmit",
42
+ "lint": "biome check .",
43
+ "test": "bun test",
44
+ "portability": "bun ../../scripts/portability.ts",
45
+ "pack:check": "bun ../../scripts/pack-check.ts"
46
+ },
47
+ "dependencies": {
48
+ "@crvouga/mockingbird-core": "0.0.0-development",
49
+ "@crvouga/mockingbird-sqlite": "0.0.0-development",
50
+ "@crvouga/mockingbird-service": "0.0.0-development",
51
+ "@crvouga/mockingbird-service-stripe": "0.0.0-development",
52
+ "@crvouga/mockingbird-service-junction": "0.0.0-development",
53
+ "@crvouga/mockingbird-service-genebygene": "0.0.0-development",
54
+ "@crvouga/mockingbird-service-medplum": "0.0.0-development",
55
+ "@crvouga/mockingbird-service-postgres": "0.0.0-development",
56
+ "@crvouga/mockingbird-service-sqlite": "0.0.0-development",
57
+ "@crvouga/mockingbird-adapter-node": "0.0.0-development",
58
+ "@crvouga/mockingbird-adapter-bun": "0.0.0-development"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "22.20.1",
62
+ "fast-check": "4.9.0"
63
+ }
64
+ }