@crvouga/mockingbird-service-junction 0.8.0 → 1.0.1

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/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  runCli,
5
5
  serveCommand,
6
6
  serveTarget
7
- } from "./chunk-TG2EOH3J.js";
7
+ } from "./chunk-2YNUCD2S.js";
8
8
  import {
9
9
  DEFAULT_JUNCTION_BASE_URL,
10
10
  createRuntime,
@@ -12,7 +12,7 @@ import {
12
12
  isSandboxKey,
13
13
  pullCorpus,
14
14
  verifyAgainstReal
15
- } from "./chunk-MS774AJA.js";
15
+ } from "./chunk-KEP42KKR.js";
16
16
  import {
17
17
  defaultCorpus
18
18
  } from "./chunk-C2UGIPPM.js";
package/dist/index.d.ts CHANGED
@@ -741,8 +741,6 @@ type OrderRecord = {
741
741
  notes: null;
742
742
  clinical_notes: string | null;
743
743
  passthrough: string | null;
744
- /** Echoed from the request's opaque provider account id; absent when the order had none. */
745
- lab_account_id?: string;
746
744
  created_at: string;
747
745
  updated_at: string;
748
746
  events: OrderEventRecord[];
@@ -842,6 +840,9 @@ type LabAccountRecord = {
842
840
  };
843
841
  /** The 50 `USState` values from the docs, alphabetical by state name. */
844
842
  declare const US_STATES: readonly string[];
843
+ /** `billing_type` values the vendored create-order body accepts. */
844
+ declare const BILLING_TYPES: readonly ["client_bill", "commercial_insurance", "patient_bill_passthrough", "patient_bill", "upfront_payment"];
845
+ type BillingType = (typeof BILLING_TYPES)[number];
845
846
  /** A team the mock is not, for fixtures that model another team's account. */
846
847
  declare const OTHER_TEAM_ID: string;
847
848
  declare const TEAM_LAB_ACCOUNTS: readonly LabAccountRecord[];
@@ -887,7 +888,11 @@ declare const labAccountFromInput: (input: LabAccountInput, teamId?: string) =>
887
888
  *
888
889
  * Where a preset copies a recorded account, its states and billing types are the
889
890
  * recording's. `bioreference_ny_nj_delegated` is not a recorded account: it is the
890
- * NY/NJ client-bill shape a consumer asked for, kept because suites depend on it.
891
+ * NY/NJ client-bill shape a consumer asked for, kept because suites depend on it, and
892
+ * listed in `SYNTHETIC_LAB_ACCOUNT_PRESETS`.
893
+ *
894
+ * `*_platform` presets are Junction's own accounts (`org_id: null`, allowlist `[]`); every
895
+ * other active preset is customer-owned (it belongs to an Org and is linked to the team).
891
896
  */
892
897
 
893
898
  /** Junction's own Quest, Labcorp and BioReference accounts client-bill in these 47 states. */
@@ -900,6 +905,13 @@ type Preset = Omit<LabAccountInput, "id">;
900
905
  * configured team; the platform presets carry `[]`, as Junction's own accounts do.
901
906
  */
902
907
  declare const LAB_ACCOUNT_PRESETS: Readonly<Record<string, Preset>>;
908
+ /**
909
+ * Deprecated preset names and the preset each stands for. An alias keeps its own default id,
910
+ * so a suite that pinned `presetAccountId(alias)` still finds its account.
911
+ */
912
+ declare const LAB_ACCOUNT_PRESET_ALIASES: Readonly<Record<string, string>>;
913
+ /** Presets that model a shape consumers asked for, not an account recorded from a real team. */
914
+ declare const SYNTHETIC_LAB_ACCOUNT_PRESETS: readonly string[];
903
915
  /** A preset's id when none is given: stable across runs and namespaces. */
904
916
  declare const presetAccountId: (name: string) => string;
905
917
  /**
@@ -1431,6 +1443,11 @@ type JunctionRuntimeOptions = {
1431
1443
  limits?: JunctionLimitsInput;
1432
1444
  /** `adopt-users` creates unknown user ids on first use. Default `strict`. */
1433
1445
  identity?: IdentityMode;
1446
+ /**
1447
+ * Lab slug → `billing_type` for orders that omit it; see
1448
+ * {@link JunctionAPIOptions.defaultBillingTypes}. Per namespace via `PUT /__admin/default-billing-types`.
1449
+ */
1450
+ defaultBillingTypes?: Partial<Record<string, BillingType>>;
1434
1451
  /** Users and orders every namespace starts with, re-applied on each reset. */
1435
1452
  fixtures?: JunctionFixtures;
1436
1453
  /** Requests each namespace's journal keeps (`GET /__admin/requests`). Default 1000. */
@@ -1483,7 +1500,9 @@ declare const UNKNOWN_ZIP_ERROR_TYPE = "MOCKINGBIRD_UNKNOWN_ZIP";
1483
1500
  *
1484
1501
  * The scenario also replays every order-scoped operation against a random unknown order
1485
1502
  * (each 404 body compared exactly) and, with `orders` and a corpus holding an account whose
1486
- * `team_id_allowlist` is empty, orders through that account with and without its id.
1503
+ * `team_id_allowlist` is empty, orders through that account with and without its id. With
1504
+ * `orders`, it also orders through every other active account by id with `billing_type`
1505
+ * omitted, which shows the billing type the team defaults to.
1487
1506
  *
1488
1507
  * Only a sandbox team should be used: the scenario creates, and always deletes, one
1489
1508
  * user (and, with `orders`, places and cancels its orders).
@@ -1560,6 +1579,12 @@ type JunctionAPIOptions = APIOptions & {
1560
1579
  limits?: JunctionLimitsInput;
1561
1580
  /** `adopt-users` creates an unknown (well-formed) `user_id` on first use. Default `strict`. */
1562
1581
  identity?: IdentityMode;
1582
+ /**
1583
+ * Lab slug → the `billing_type` `create_order` uses when the request omits it, e.g.
1584
+ * `{ bioreference: "patient_bill_passthrough" }`. Unlisted labs use Junction's documented
1585
+ * default, `client_bill`.
1586
+ */
1587
+ defaultBillingTypes?: Partial<Record<string, BillingType>>;
1563
1588
  /** Users and orders to load into every namespace, re-applied on every `reset()`. */
1564
1589
  fixtures?: JunctionFixtures;
1565
1590
  };
@@ -1623,6 +1648,10 @@ declare class JunctionAPI implements FetchAPI {
1623
1648
  get limits(): JunctionLimits;
1624
1649
  /** Change some limits (`null` lifts a numeric one); kept across `reset()`. */
1625
1650
  configureLimits(input: JunctionLimitsInput): JunctionLimits;
1651
+ /** Lab slug → the `billing_type` an order gets when it omits one. Kept across `reset()`. */
1652
+ get defaultBillingTypes(): Record<string, BillingType>;
1653
+ /** Replace the per-lab default billing types (`{}` restores `client_bill` everywhere). */
1654
+ set defaultBillingTypes(input: Partial<Record<string, BillingType>>);
1626
1655
  get identity(): IdentityMode;
1627
1656
  set identity(mode: IdentityMode);
1628
1657
  /** Insert users with chosen ids, all or none. Throws `FixtureError` (400/404/409). */
@@ -1641,6 +1670,12 @@ declare class JunctionAPI implements FetchAPI {
1641
1670
  set geoMode(mode: GeoMode);
1642
1671
  order(id: string): OrderRecord | undefined;
1643
1672
  orders(): OrderRecord[];
1673
+ /**
1674
+ * The lab account an order was placed with: its id, `null` for Junction's platform account,
1675
+ * or `undefined` for an unknown order. Junction's order has no such field, so this is the
1676
+ * only place the mock reports it.
1677
+ */
1678
+ orderLabAccount(id: string): string | null | undefined;
1644
1679
  /**
1645
1680
  * Put an order straight into a status (a full `<status>.<method>.<event>` value) and
1646
1681
  * publish the webhook a real transition would. `flags` takes the same keys as
@@ -1666,5 +1701,5 @@ declare class LabAccountConflict extends Error {
1666
1701
  constructor(id: string);
1667
1702
  }
1668
1703
 
1669
- export { AVAILABILITY_ADDRESS, AVAILABILITY_START_DATE, COVERAGE_ZIPS, DEFAULT_JUNCTION_BASE_URL, DEFAULT_LIMITS, DELEGATED_ACCOUNT_STATES, FAULT_PRESETS, FixtureError, IDENTITY_MODES, JUNCTION_NAMESPACE, JunctionAPI, KNOWN_HEADER, LAB_ACCOUNT_PRESETS, LabAccountConflict, MISS_HEADER, MOCK_TEAM_ID, ORDER_NOT_FOUND, ORDER_STATUSES_BY_METHOD, OTHER_TEAM_ID, PHLEBOTOMY_AVAILABILITY_ZIPS, PLATFORM_ACCOUNT_STATES, PSC_AVAILABILITY_ZIPS, PSC_LAB_IDS, RESULT_FIXTURES, SANDBOX_KEY_PREFIXES, SEALED_CORPUS_VERSION, SUPPORTED_SEALED_CORPUS_VERSIONS, TEAM_LAB_ACCOUNTS, TRANSITION_ALIASES, UNKNOWN_ZIP_ERROR_TYPE, UNKNOWN_ZIP_STATUS, US_STATES, corpusLabel, createRuntime, createWebhookDispatcher, diffCorpus, document, fingerprintCorpus, isLinkedToTeam, isSandboxKey, labAccountFromInput, observationCacheKey, operationIds, parseSealedCorpus, prefetchCoverageObservations, presetAccountId, pullCorpus, reshapeCoverageGeoCommand, resolveTransition, sandboxUserQuotaBody, signSvix, supportedOperationIds, verifyAgainstReal, verifySvix };
1670
- export type { CorpusDiff, CorpusInfo, Divergence, FetchAPI, GeoMode, GetCacheEntry, IdentityMode, InsertOptions, JunctionAPIOptions, JunctionAdminOptions, JunctionFixtures, JunctionLimits, JunctionLimitsInput, JunctionRuntime, JunctionRuntimeOptions, JunctionWebhookEvent, JunctionWebhookOptions, LabAccountDelegatedFlow, LabAccountInput, LabAccountLayout, LabAccountRecord, LabAccountStatus, OperationId, OrderFixture, OrderRecord, PullCorpusOptions, ResultFixture, SealedCorpus, SeedObservations, SeedReport, SeedSource, SetDiff, SqliteClient, StoredLabAccount, SupportedOperationId, UserFixture, UserRecord, VerifyOptions, VerifyReport, WebhookAttempt, WebhookDelivery, WebhookDispatcher, WebhookEndpoint, WebhookPublisher };
1704
+ export { AVAILABILITY_ADDRESS, AVAILABILITY_START_DATE, BILLING_TYPES, COVERAGE_ZIPS, DEFAULT_JUNCTION_BASE_URL, DEFAULT_LIMITS, DELEGATED_ACCOUNT_STATES, FAULT_PRESETS, FixtureError, IDENTITY_MODES, JUNCTION_NAMESPACE, JunctionAPI, KNOWN_HEADER, LAB_ACCOUNT_PRESETS, LAB_ACCOUNT_PRESET_ALIASES, LabAccountConflict, MISS_HEADER, MOCK_TEAM_ID, ORDER_NOT_FOUND, ORDER_STATUSES_BY_METHOD, OTHER_TEAM_ID, PHLEBOTOMY_AVAILABILITY_ZIPS, PLATFORM_ACCOUNT_STATES, PSC_AVAILABILITY_ZIPS, PSC_LAB_IDS, RESULT_FIXTURES, SANDBOX_KEY_PREFIXES, SEALED_CORPUS_VERSION, SUPPORTED_SEALED_CORPUS_VERSIONS, SYNTHETIC_LAB_ACCOUNT_PRESETS, TEAM_LAB_ACCOUNTS, TRANSITION_ALIASES, UNKNOWN_ZIP_ERROR_TYPE, UNKNOWN_ZIP_STATUS, US_STATES, corpusLabel, createRuntime, createWebhookDispatcher, diffCorpus, document, fingerprintCorpus, isLinkedToTeam, isSandboxKey, labAccountFromInput, observationCacheKey, operationIds, parseSealedCorpus, prefetchCoverageObservations, presetAccountId, pullCorpus, reshapeCoverageGeoCommand, resolveTransition, sandboxUserQuotaBody, signSvix, supportedOperationIds, verifyAgainstReal, verifySvix };
1705
+ export type { BillingType, CorpusDiff, CorpusInfo, Divergence, FetchAPI, GeoMode, GetCacheEntry, IdentityMode, InsertOptions, JunctionAPIOptions, JunctionAdminOptions, JunctionFixtures, JunctionLimits, JunctionLimitsInput, JunctionRuntime, JunctionRuntimeOptions, JunctionWebhookEvent, JunctionWebhookOptions, LabAccountDelegatedFlow, LabAccountInput, LabAccountLayout, LabAccountRecord, LabAccountStatus, OperationId, OrderFixture, OrderRecord, PullCorpusOptions, ResultFixture, SealedCorpus, SeedObservations, SeedReport, SeedSource, SetDiff, SqliteClient, StoredLabAccount, SupportedOperationId, UserFixture, UserRecord, VerifyOptions, VerifyReport, WebhookAttempt, WebhookDelivery, WebhookDispatcher, WebhookEndpoint, WebhookPublisher };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AVAILABILITY_ADDRESS,
3
3
  AVAILABILITY_START_DATE,
4
+ BILLING_TYPES,
4
5
  COVERAGE_ZIPS,
5
6
  DEFAULT_JUNCTION_BASE_URL,
6
7
  DEFAULT_LIMITS,
@@ -12,6 +13,7 @@ import {
12
13
  JunctionAPI,
13
14
  KNOWN_HEADER,
14
15
  LAB_ACCOUNT_PRESETS,
16
+ LAB_ACCOUNT_PRESET_ALIASES,
15
17
  LabAccountConflict,
16
18
  MISS_HEADER,
17
19
  MOCK_TEAM_ID,
@@ -24,6 +26,7 @@ import {
24
26
  PSC_LAB_IDS,
25
27
  RESULT_FIXTURES,
26
28
  SANDBOX_KEY_PREFIXES,
29
+ SYNTHETIC_LAB_ACCOUNT_PRESETS,
27
30
  TEAM_LAB_ACCOUNTS,
28
31
  TRANSITION_ALIASES,
29
32
  UNKNOWN_ZIP_ERROR_TYPE,
@@ -50,7 +53,7 @@ import {
50
53
  supportedOperationIds,
51
54
  verifyAgainstReal,
52
55
  verifySvix
53
- } from "./chunk-MS774AJA.js";
56
+ } from "./chunk-KEP42KKR.js";
54
57
  import {
55
58
  SEALED_CORPUS_VERSION,
56
59
  SUPPORTED_SEALED_CORPUS_VERSIONS,
@@ -59,6 +62,7 @@ import {
59
62
  export {
60
63
  AVAILABILITY_ADDRESS,
61
64
  AVAILABILITY_START_DATE,
65
+ BILLING_TYPES,
62
66
  COVERAGE_ZIPS,
63
67
  DEFAULT_JUNCTION_BASE_URL,
64
68
  DEFAULT_LIMITS,
@@ -70,6 +74,7 @@ export {
70
74
  JunctionAPI,
71
75
  KNOWN_HEADER,
72
76
  LAB_ACCOUNT_PRESETS,
77
+ LAB_ACCOUNT_PRESET_ALIASES,
73
78
  LabAccountConflict,
74
79
  MISS_HEADER,
75
80
  MOCK_TEAM_ID,
@@ -84,6 +89,7 @@ export {
84
89
  SANDBOX_KEY_PREFIXES,
85
90
  SEALED_CORPUS_VERSION,
86
91
  SUPPORTED_SEALED_CORPUS_VERSIONS,
92
+ SYNTHETIC_LAB_ACCOUNT_PRESETS,
87
93
  TEAM_LAB_ACCOUNTS,
88
94
  TRANSITION_ALIASES,
89
95
  UNKNOWN_ZIP_ERROR_TYPE,
package/dist/server.d.ts CHANGED
@@ -1187,8 +1187,6 @@ type OrderRecord = {
1187
1187
  notes: null;
1188
1188
  clinical_notes: string | null;
1189
1189
  passthrough: string | null;
1190
- /** Echoed from the request's opaque provider account id; absent when the order had none. */
1191
- lab_account_id?: string;
1192
1190
  created_at: string;
1193
1191
  updated_at: string;
1194
1192
  events: OrderEventRecord[];
@@ -1329,6 +1327,9 @@ interface FetchAPI {
1329
1327
 
1330
1328
  type LabAccountStatus = "active" | "pending" | "suspended" | "ready_to_launch";
1331
1329
  type LabAccountDelegatedFlow = "order_delegated" | "result_delegated" | "fully_delegated" | "not_delegated";
1330
+ /** `billing_type` values the vendored create-order body accepts. */
1331
+ declare const BILLING_TYPES: readonly ["client_bill", "commercial_insurance", "patient_bill_passthrough", "patient_bill", "upfront_payment"];
1332
+ type BillingType = (typeof BILLING_TYPES)[number];
1332
1333
  /**
1333
1334
  * A lab account as a consumer configures it. Mirrors `ClientFacingLabAccount`, with
1334
1335
  * every field but `id` and `lab` optional, plus a `states` shorthand for the common
@@ -1359,7 +1360,11 @@ type LabAccountInput = {
1359
1360
  *
1360
1361
  * Where a preset copies a recorded account, its states and billing types are the
1361
1362
  * recording's. `bioreference_ny_nj_delegated` is not a recorded account: it is the
1362
- * NY/NJ client-bill shape a consumer asked for, kept because suites depend on it.
1363
+ * NY/NJ client-bill shape a consumer asked for, kept because suites depend on it, and
1364
+ * listed in `SYNTHETIC_LAB_ACCOUNT_PRESETS`.
1365
+ *
1366
+ * `*_platform` presets are Junction's own accounts (`org_id: null`, allowlist `[]`); every
1367
+ * other active preset is customer-owned (it belongs to an Org and is linked to the team).
1363
1368
  */
1364
1369
 
1365
1370
  /**
@@ -1514,6 +1519,12 @@ type JunctionAPIOptions = APIOptions & {
1514
1519
  limits?: JunctionLimitsInput;
1515
1520
  /** `adopt-users` creates an unknown (well-formed) `user_id` on first use. Default `strict`. */
1516
1521
  identity?: IdentityMode;
1522
+ /**
1523
+ * Lab slug → the `billing_type` `create_order` uses when the request omits it, e.g.
1524
+ * `{ bioreference: "patient_bill_passthrough" }`. Unlisted labs use Junction's documented
1525
+ * default, `client_bill`.
1526
+ */
1527
+ defaultBillingTypes?: Partial<Record<string, BillingType>>;
1517
1528
  /** Users and orders to load into every namespace, re-applied on every `reset()`. */
1518
1529
  fixtures?: JunctionFixtures;
1519
1530
  };
@@ -1575,6 +1586,10 @@ declare class JunctionAPI implements FetchAPI {
1575
1586
  get limits(): JunctionLimits;
1576
1587
  /** Change some limits (`null` lifts a numeric one); kept across `reset()`. */
1577
1588
  configureLimits(input: JunctionLimitsInput): JunctionLimits;
1589
+ /** Lab slug → the `billing_type` an order gets when it omits one. Kept across `reset()`. */
1590
+ get defaultBillingTypes(): Record<string, BillingType>;
1591
+ /** Replace the per-lab default billing types (`{}` restores `client_bill` everywhere). */
1592
+ set defaultBillingTypes(input: Partial<Record<string, BillingType>>);
1578
1593
  get identity(): IdentityMode;
1579
1594
  set identity(mode: IdentityMode);
1580
1595
  /** Insert users with chosen ids, all or none. Throws `FixtureError` (400/404/409). */
@@ -1593,6 +1608,12 @@ declare class JunctionAPI implements FetchAPI {
1593
1608
  set geoMode(mode: GeoMode);
1594
1609
  order(id: string): OrderRecord | undefined;
1595
1610
  orders(): OrderRecord[];
1611
+ /**
1612
+ * The lab account an order was placed with: its id, `null` for Junction's platform account,
1613
+ * or `undefined` for an unknown order. Junction's order has no such field, so this is the
1614
+ * only place the mock reports it.
1615
+ */
1616
+ orderLabAccount(id: string): string | null | undefined;
1596
1617
  /**
1597
1618
  * Put an order straight into a status (a full `<status>.<method>.<event>` value) and
1598
1619
  * publish the webhook a real transition would. `flags` takes the same keys as
@@ -1629,6 +1650,11 @@ type JunctionRuntimeOptions = {
1629
1650
  limits?: JunctionLimitsInput;
1630
1651
  /** `adopt-users` creates unknown user ids on first use. Default `strict`. */
1631
1652
  identity?: IdentityMode;
1653
+ /**
1654
+ * Lab slug → `billing_type` for orders that omit it; see
1655
+ * {@link JunctionAPIOptions.defaultBillingTypes}. Per namespace via `PUT /__admin/default-billing-types`.
1656
+ */
1657
+ defaultBillingTypes?: Partial<Record<string, BillingType>>;
1632
1658
  /** Users and orders every namespace starts with, re-applied on each reset. */
1633
1659
  fixtures?: JunctionFixtures;
1634
1660
  /** Requests each namespace's journal keeps (`GET /__admin/requests`). Default 1000. */
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createServer,
4
4
  loadCorpus,
5
5
  serveTarget
6
- } from "./chunk-TG2EOH3J.js";
7
- import "./chunk-MS774AJA.js";
6
+ } from "./chunk-2YNUCD2S.js";
7
+ import "./chunk-KEP42KKR.js";
8
8
  import "./chunk-C2UGIPPM.js";
9
9
  import "./chunk-ISDNA2TU.js";
10
10
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-junction",
3
- "version": "0.8.0",
3
+ "version": "1.0.1",
4
4
  "description": "Stateful mock of the Junction (Vital) user API driven by its OpenAPI contract and verified by differential property tests against the Junction sandbox.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -54,6 +54,10 @@
54
54
  "layer": "service",
55
55
  "category": "health",
56
56
  "displayName": "Junction",
57
+ "vendor": {
58
+ "website": "https://www.junction.com",
59
+ "docs": "https://docs.junction.com"
60
+ },
57
61
  "status": "ready"
58
62
  },
59
63
  "scripts": {
@@ -78,7 +82,7 @@
78
82
  "verify": "bun src/cli.ts verify"
79
83
  },
80
84
  "dependencies": {
81
- "@crvouga/mockingbird-service-sqlite": "0.3.0",
85
+ "@crvouga/mockingbird-service-sqlite": "1.0.0",
82
86
  "hono": "4.11.9"
83
87
  },
84
88
  "devDependencies": {