@cosyte/synth 0.1.9 → 0.1.11
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 +39 -0
- package/README.md +39 -19
- package/dist/animal-code-Bdl_9Jma.d.cts +30 -0
- package/dist/animal-code-Bdl_9Jma.d.ts +30 -0
- package/dist/astm/index.cjs +147 -17
- package/dist/astm/index.cjs.map +1 -1
- package/dist/astm/index.d.cts +22 -9
- package/dist/astm/index.d.ts +22 -9
- package/dist/astm/index.mjs +147 -17
- package/dist/astm/index.mjs.map +1 -1
- package/dist/ccda/index.cjs +147 -17
- package/dist/ccda/index.cjs.map +1 -1
- package/dist/ccda/index.d.cts +12 -3
- package/dist/ccda/index.d.ts +12 -3
- package/dist/ccda/index.mjs +147 -17
- package/dist/ccda/index.mjs.map +1 -1
- package/dist/deid/index.cjs +537 -30
- package/dist/deid/index.cjs.map +1 -1
- package/dist/deid/index.d.cts +2 -1
- package/dist/deid/index.d.ts +2 -1
- package/dist/deid/index.mjs +537 -30
- package/dist/deid/index.mjs.map +1 -1
- package/dist/fhir/index.cjs +142 -14
- package/dist/fhir/index.cjs.map +1 -1
- package/dist/fhir/index.d.cts +4 -1
- package/dist/fhir/index.d.ts +4 -1
- package/dist/fhir/index.mjs +142 -14
- package/dist/fhir/index.mjs.map +1 -1
- package/dist/hl7/index.cjs +566 -39
- package/dist/hl7/index.cjs.map +1 -1
- package/dist/hl7/index.d.cts +416 -116
- package/dist/hl7/index.d.ts +416 -116
- package/dist/hl7/index.mjs +557 -40
- package/dist/hl7/index.mjs.map +1 -1
- package/dist/index.cjs +124 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +183 -10
- package/dist/index.d.ts +183 -10
- package/dist/index.mjs +115 -14
- package/dist/index.mjs.map +1 -1
- package/dist/ncpdp/index.cjs +142 -14
- package/dist/ncpdp/index.cjs.map +1 -1
- package/dist/ncpdp/index.d.cts +4 -1
- package/dist/ncpdp/index.d.ts +4 -1
- package/dist/ncpdp/index.mjs +142 -14
- package/dist/ncpdp/index.mjs.map +1 -1
- package/dist/{quirk-BfObsiWV.d.ts → quirk-CzknuYUo.d.ts} +16 -5
- package/dist/{quirk-BCSs1jPt.d.cts → quirk-Q5AxzHSC.d.cts} +16 -5
- package/dist/x12/index.cjs +142 -14
- package/dist/x12/index.cjs.map +1 -1
- package/dist/x12/index.d.cts +4 -1
- package/dist/x12/index.d.ts +4 -1
- package/dist/x12/index.mjs +142 -14
- package/dist/x12/index.mjs.map +1 -1
- package/package.json +9 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,117 @@
|
|
|
1
|
-
import { s as ssn, p as phone, n as name, e as email, i as ipv4, c as ipv6, u as uuid, d as identifier, f as address, g as dateYmd, h as npi, j as dea } from './providers-B48qUwHU.cjs';
|
|
2
|
-
export { A as Artifact, C as Corpus, k as CorpusManifest,
|
|
3
|
-
|
|
1
|
+
import { R as Rng, s as ssn, p as phone, n as name, e as email, i as ipv4, c as ipv6, u as uuid, d as identifier, f as address, g as dateYmd, h as npi, j as dea } from './providers-B48qUwHU.cjs';
|
|
2
|
+
export { A as Artifact, C as Corpus, k as CorpusManifest, l as SsnBlock, m as SynthFormat, b as SyntheticAddress, a as SyntheticIdentifier, S as SyntheticName, o as createRng, q as makeCorpus } from './providers-B48qUwHU.cjs';
|
|
3
|
+
import { A as AnimalCode, a as AnimalSpecies } from './animal-code-Bdl_9Jma.cjs';
|
|
4
|
+
export { b as ANIMAL_CODE_SYSTEM } from './animal-code-Bdl_9Jma.cjs';
|
|
5
|
+
export { P as PROFILE_QUIRK_APPLIED, a as QuirkArtifact, Q as QuirkDescriptor, c as QuirkProfileDisposition, d as QuirkProfiledVerdict, b as QuirkRoundTripResult, S as SynthProfile, e as SynthProfileSpec, f as assertIntendedWarnings, g as defineSynthProfile, p as profileTolerated, r as resolveQuirk, s as sameCodeSet, v as validateProfileQuirks } from './quirk-Q5AxzHSC.cjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The synthetic **animal** providers: a pet's name, its species and breed, its microchip, and its
|
|
9
|
+
* birth date. Like every provider in `../safe`, each is a pure function of an explicit seeded
|
|
10
|
+
* generator and draws only from a source this module ships or a range we chose for synthetic values.
|
|
11
|
+
*
|
|
12
|
+
* - **Species and breed** come from a short list of our own: plain text, with codes in a local
|
|
13
|
+
* code system ({@link ANIMAL_CODE_SYSTEM}). No SNOMED CT, VetSCT or VeNom content is used.
|
|
14
|
+
* - **Pet names** come from a clearly invented pool, like the person-name pool.
|
|
15
|
+
* - **Microchips** are 15 digits that begin with `999` (see {@link MICROCHIP_TEST_PREFIX}). We
|
|
16
|
+
* take `999` to be outside the country and manufacturer codes a real chip carries, but we have
|
|
17
|
+
* not verified that against ISO 11784 or any registry.
|
|
18
|
+
*
|
|
19
|
+
* `# synthetic: true`
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** A species and one of its breeds, as {@link animalBreed} draws them. */
|
|
25
|
+
interface AnimalBreedDraw {
|
|
26
|
+
/** The species. */
|
|
27
|
+
readonly species: AnimalCode;
|
|
28
|
+
/** A breed of that species. */
|
|
29
|
+
readonly breed: AnimalCode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The species and breeds the animal subject draws from: our own short list, in plain text, under
|
|
33
|
+
* {@link ANIMAL_CODE_SYSTEM}. Small on purpose: structural coverage, not a breed registry.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { SYNTHETIC_ANIMAL_SPECIES } from "@cosyte/synth";
|
|
38
|
+
* SYNTHETIC_ANIMAL_SPECIES.map((s) => s.text); // ["Dog", "Cat", "Horse", "Cattle"]
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare const SYNTHETIC_ANIMAL_SPECIES: readonly AnimalSpecies[];
|
|
42
|
+
/** Clearly invented pet names. None is a name a reader would take for a real animal's record. */
|
|
43
|
+
declare const SYNTHETIC_PET_NAMES: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* The three digits every synthetic microchip begins with: `999`. We chose it as a range we believe
|
|
46
|
+
* no implanted chip uses, but we have not verified that against ISO 11784 or any manufacturer code
|
|
47
|
+
* list. Not verified.
|
|
48
|
+
*/
|
|
49
|
+
declare const MICROCHIP_TEST_PREFIX = "999";
|
|
50
|
+
/**
|
|
51
|
+
* A **synthetic pet name** from {@link SYNTHETIC_PET_NAMES}.
|
|
52
|
+
*
|
|
53
|
+
* @param rng - The seeded generator.
|
|
54
|
+
* @returns A clearly invented pet name.
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { createRng, petName } from "@cosyte/synth";
|
|
58
|
+
* petName(createRng(1)); // e.g. "Stubtail", synthetic
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function petName(rng: Rng): string;
|
|
62
|
+
/**
|
|
63
|
+
* A **species and breed** from {@link SYNTHETIC_ANIMAL_SPECIES}: the species first, then one of its
|
|
64
|
+
* breeds.
|
|
65
|
+
*
|
|
66
|
+
* @param rng - The seeded generator.
|
|
67
|
+
* @returns An {@link AnimalBreedDraw}.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { animalBreed, createRng } from "@cosyte/synth";
|
|
71
|
+
* const { species, breed } = animalBreed(createRng(1));
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function animalBreed(rng: Rng): AnimalBreedDraw;
|
|
75
|
+
/**
|
|
76
|
+
* A **synthetic microchip**: 15 digits, {@link MICROCHIP_TEST_PREFIX} then twelve seeded digits.
|
|
77
|
+
*
|
|
78
|
+
* @param rng - The seeded generator.
|
|
79
|
+
* @returns A 15-digit string beginning `999`.
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { createRng, isSyntheticMicrochip, microchip } from "@cosyte/synth";
|
|
83
|
+
* isSyntheticMicrochip(microchip(createRng(1))); // true
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function microchip(rng: Rng): string;
|
|
87
|
+
/**
|
|
88
|
+
* Whether a value is a synthetic microchip: exactly 15 digits beginning with
|
|
89
|
+
* {@link MICROCHIP_TEST_PREFIX}.
|
|
90
|
+
*
|
|
91
|
+
* @param value - The value to test.
|
|
92
|
+
* @returns `true` when the value is 15 digits beginning {@link MICROCHIP_TEST_PREFIX}.
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { isSyntheticMicrochip } from "@cosyte/synth";
|
|
96
|
+
* isSyntheticMicrochip("999000000000001"); // true
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function isSyntheticMicrochip(value: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* A **synthetic animal birth date** in `YYYYMMDD` form, from 0 to 20 years before `onDate`, both
|
|
102
|
+
* ends included. `onDate` is a date the caller supplies (the generators pass the message date), never
|
|
103
|
+
* the clock, so the same seed and date give the same birth date.
|
|
104
|
+
*
|
|
105
|
+
* @param rng - The seeded generator.
|
|
106
|
+
* @param onDate - The reference date, `YYYYMMDD` (only its first eight digits are read).
|
|
107
|
+
* @returns A `YYYYMMDD` date no later than `onDate` and no more than 20 years before it.
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { animalBirthDate, createRng } from "@cosyte/synth";
|
|
111
|
+
* animalBirthDate(createRng(1), "20250101"); // between "20050101" and "20250101"
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function animalBirthDate(rng: Rng, onDate: string): string;
|
|
4
115
|
|
|
5
116
|
/**
|
|
6
117
|
* The reserved / never-collide identifier facts that make a `@cosyte/synth` value **provably
|
|
@@ -357,6 +468,7 @@ declare const SYNTHETIC_CITY_NAMES: readonly string[];
|
|
|
357
468
|
* const rng = createRng(42);
|
|
358
469
|
* safe.ssn(rng); // never-issued SSN
|
|
359
470
|
* safe.phone(rng); // reserved 555-01NN number
|
|
471
|
+
* safe.microchip(rng); // 15 digits beginning 999
|
|
360
472
|
* ```
|
|
361
473
|
*/
|
|
362
474
|
declare const safe: Readonly<{
|
|
@@ -372,6 +484,10 @@ declare const safe: Readonly<{
|
|
|
372
484
|
dateYmd: typeof dateYmd;
|
|
373
485
|
npi: typeof npi;
|
|
374
486
|
dea: typeof dea;
|
|
487
|
+
petName: typeof petName;
|
|
488
|
+
animalBreed: typeof animalBreed;
|
|
489
|
+
microchip: typeof microchip;
|
|
490
|
+
animalBirthDate: typeof animalBirthDate;
|
|
375
491
|
}>;
|
|
376
492
|
|
|
377
493
|
/**
|
|
@@ -504,7 +620,11 @@ declare const SYNTH_FATAL_CODES: Readonly<{
|
|
|
504
620
|
readonly SYNTH_INVALID_DECIMAL: "SYNTH_INVALID_DECIMAL";
|
|
505
621
|
/** An integer range was requested with its maximum below its minimum. Fatal. */
|
|
506
622
|
readonly SYNTH_INVALID_RANGE: "SYNTH_INVALID_RANGE";
|
|
507
|
-
/**
|
|
623
|
+
/**
|
|
624
|
+
* A value was drawn from an empty pool. Fatal, never a fabricated substitute. A corpus given an
|
|
625
|
+
* empty `mix`, `triggers` or `quirks` list (or a profile whose `quirks` is an empty list) raises it
|
|
626
|
+
* too: there is no kind to cycle through, and an empty list is never read as the default.
|
|
627
|
+
*/
|
|
508
628
|
readonly SYNTH_EMPTY_POOL: "SYNTH_EMPTY_POOL";
|
|
509
629
|
/** A `defineSynthProfile` spec was not usable (a missing or blank `name`). Fatal. */
|
|
510
630
|
readonly SYNTH_INVALID_PROFILE: "SYNTH_INVALID_PROFILE";
|
|
@@ -524,6 +644,20 @@ declare const SYNTH_FATAL_CODES: Readonly<{
|
|
|
524
644
|
* mislabelled artifact is worse than no artifact.
|
|
525
645
|
*/
|
|
526
646
|
readonly SYNTH_PROFILE_NOT_GENERATED: "SYNTH_PROFILE_NOT_GENERATED";
|
|
647
|
+
/**
|
|
648
|
+
* The sibling parser a generator builds through is not installed. Raised on the first call that
|
|
649
|
+
* needs it, by both builds, only when the missing package is the parser itself: a missing
|
|
650
|
+
* dependency of an installed parser is thrown as Node.js raised it. The error carries the parser's
|
|
651
|
+
* package name on `peer`, a message from {@link SYNTH_PEER_MESSAGES} that names its install
|
|
652
|
+
* command, and the error Node.js raised on `cause`.
|
|
653
|
+
*/
|
|
654
|
+
readonly SYNTH_PEER_NOT_INSTALLED: "SYNTH_PEER_NOT_INSTALLED";
|
|
655
|
+
/**
|
|
656
|
+
* An HL7 v2 `ACK` was asked for an inbound message that carries no MSH-10 message control id.
|
|
657
|
+
* MSA-2 must echo that id, and an acknowledgment that cannot be matched to the message it answers
|
|
658
|
+
* is not a fixture worth having, so nothing is generated.
|
|
659
|
+
*/
|
|
660
|
+
readonly SYNTH_ACK_UNCORRELATED: "SYNTH_ACK_UNCORRELATED";
|
|
527
661
|
}>;
|
|
528
662
|
/**
|
|
529
663
|
* A value from {@link SYNTH_FATAL_CODES}: the type carried by a thrown {@link SynthError}.
|
|
@@ -549,13 +683,48 @@ type SynthFatalCode = (typeof SYNTH_FATAL_CODES)[keyof typeof SYNTH_FATAL_CODES]
|
|
|
549
683
|
* ```
|
|
550
684
|
*/
|
|
551
685
|
declare const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>>;
|
|
686
|
+
/**
|
|
687
|
+
* The message a {@link SYNTH_FATAL_CODES.SYNTH_PEER_NOT_INSTALLED} error carries for each sibling
|
|
688
|
+
* parser: which package is missing, and the command that installs it. Keyed by the closed set of
|
|
689
|
+
* parser packages this package builds through, so like {@link SYNTH_FATAL_MESSAGES} it is a table
|
|
690
|
+
* of fixed strings, and no caller value can reach it.
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* ```ts
|
|
694
|
+
* import { SYNTH_PEER_MESSAGES } from "@cosyte/synth";
|
|
695
|
+
* SYNTH_PEER_MESSAGES["@cosyte/hl7"]; // => "@cosyte/hl7 is not installed, and this generator builds through it. Install it beside @cosyte/synth: npm install @cosyte/hl7"
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
declare const SYNTH_PEER_MESSAGES: Readonly<{
|
|
699
|
+
readonly "@cosyte/hl7": string;
|
|
700
|
+
readonly "@cosyte/fhir": string;
|
|
701
|
+
readonly "@cosyte/ccda": string;
|
|
702
|
+
readonly "@cosyte/x12": string;
|
|
703
|
+
readonly "@cosyte/ncpdp": string;
|
|
704
|
+
readonly "@cosyte/astm": string;
|
|
705
|
+
readonly "@cosyte/deid": string;
|
|
706
|
+
}>;
|
|
707
|
+
/** A sibling parser package: a key of {@link SYNTH_PEER_MESSAGES}. */
|
|
708
|
+
type SynthPeer = keyof typeof SYNTH_PEER_MESSAGES;
|
|
709
|
+
/** What a {@link SynthError} may carry beside its code. */
|
|
710
|
+
interface SynthErrorOptions {
|
|
711
|
+
/** The error that caused this one, kept on `cause`. */
|
|
712
|
+
readonly cause?: unknown;
|
|
713
|
+
/**
|
|
714
|
+
* For {@link SYNTH_FATAL_CODES.SYNTH_PEER_NOT_INSTALLED}: the parser package that is missing. Its
|
|
715
|
+
* message then comes from {@link SYNTH_PEER_MESSAGES}.
|
|
716
|
+
*/
|
|
717
|
+
readonly peer?: SynthPeer;
|
|
718
|
+
}
|
|
552
719
|
/**
|
|
553
720
|
* The typed error every fatal `@cosyte/synth` condition throws. Carries a stable
|
|
554
721
|
* {@link SynthFatalCode} so callers branch on `err.code` without matching message text.
|
|
555
722
|
*
|
|
556
723
|
* It takes **no value parameter**. The message is whatever {@link SYNTH_FATAL_MESSAGES} holds for the
|
|
557
|
-
* code,
|
|
558
|
-
*
|
|
724
|
+
* code, or for a missing parser whatever {@link SYNTH_PEER_MESSAGES} holds for that package, so no
|
|
725
|
+
* caller-supplied string can reach a diagnostic surface by any route, not `message`, not `stack`,
|
|
726
|
+
* not a field on the thrown object. The options carry only an error this package caught (`cause`)
|
|
727
|
+
* and a package name from that closed set (`peer`).
|
|
559
728
|
*
|
|
560
729
|
* @example
|
|
561
730
|
* ```ts
|
|
@@ -566,10 +735,13 @@ declare const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>>;
|
|
|
566
735
|
declare class SynthError extends Error {
|
|
567
736
|
/** The stable fatal code. */
|
|
568
737
|
readonly code: SynthFatalCode;
|
|
738
|
+
/** The missing parser package, on a {@link SYNTH_FATAL_CODES.SYNTH_PEER_NOT_INSTALLED} error only. */
|
|
739
|
+
readonly peer?: SynthPeer;
|
|
569
740
|
/**
|
|
570
741
|
* @param code - The stable {@link SynthFatalCode}. The message comes from the frozen registry.
|
|
742
|
+
* @param options - The error that caused this one, and for a missing parser its package.
|
|
571
743
|
*/
|
|
572
|
-
constructor(code: SynthFatalCode);
|
|
744
|
+
constructor(code: SynthFatalCode, options?: SynthErrorOptions);
|
|
573
745
|
}
|
|
574
746
|
|
|
575
747
|
/**
|
|
@@ -620,7 +792,8 @@ declare function resolveKind<T extends string>(allowed: readonly T[], requested:
|
|
|
620
792
|
* of this function also treated `[]` as "nothing supplied", on the stated grounds that it matched the
|
|
621
793
|
* previous behaviour; it did not: `??` fires on `undefined` and never on `[]`, and it changed the
|
|
622
794
|
* result of six published entry points, turning an explicit empty selection into "generate one of
|
|
623
|
-
* everything". A convenience that fails open is not a convenience.
|
|
795
|
+
* everything". A convenience that fails open is not a convenience. Every corpus then refuses the empty
|
|
796
|
+
* mix with `SYNTH_EMPTY_POOL`, before it generates anything.
|
|
624
797
|
*
|
|
625
798
|
* @param allowed - Every kind the corpus may generate.
|
|
626
799
|
* @param requested - The mix the caller supplied, or `undefined` for the default.
|
|
@@ -669,5 +842,5 @@ declare function resolveMix<T extends string>(allowed: readonly T[], requested:
|
|
|
669
842
|
*/
|
|
670
843
|
declare const VERSION: string;
|
|
671
844
|
|
|
672
|
-
export { DEA_REGISTRANT_TYPES, DOC_V6_PREFIX, ITIN_GROUP_RANGES, NPI_LUHN_PREFIX, RESERVED_EMAIL_DOMAINS, SYNTHETIC_ASSIGNING_AUTHORITY, SYNTHETIC_CITY_NAMES, SYNTHETIC_FAMILY_NAMES, SYNTHETIC_GIVEN_NAMES, SYNTHETIC_STREET_NAMES, SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES, SynthError, TEST_NET_V4_PREFIXES, VERSION, address, dateYmd, dea, deaCheckDigit, email, identifier, ipv4, ipv6, isItinFormatted, isSyntheticDea, isSyntheticEmail, isSyntheticIp, isSyntheticNpi, isSyntheticPhone, isSyntheticSsn, luhnMod10, name, npi, npiCheckDigit, phone, resolveKind, resolveMix, safe, sfc32Next, splitmix32, ssn, uuid };
|
|
673
|
-
export type { Sfc32State, SynthFatalCode };
|
|
845
|
+
export { AnimalCode, AnimalSpecies, DEA_REGISTRANT_TYPES, DOC_V6_PREFIX, ITIN_GROUP_RANGES, MICROCHIP_TEST_PREFIX, NPI_LUHN_PREFIX, RESERVED_EMAIL_DOMAINS, Rng, SYNTHETIC_ANIMAL_SPECIES, SYNTHETIC_ASSIGNING_AUTHORITY, SYNTHETIC_CITY_NAMES, SYNTHETIC_FAMILY_NAMES, SYNTHETIC_GIVEN_NAMES, SYNTHETIC_PET_NAMES, SYNTHETIC_STREET_NAMES, SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES, SYNTH_PEER_MESSAGES, SynthError, TEST_NET_V4_PREFIXES, VERSION, address, animalBirthDate, animalBreed, dateYmd, dea, deaCheckDigit, email, identifier, ipv4, ipv6, isItinFormatted, isSyntheticDea, isSyntheticEmail, isSyntheticIp, isSyntheticMicrochip, isSyntheticNpi, isSyntheticPhone, isSyntheticSsn, luhnMod10, microchip, name, npi, npiCheckDigit, petName, phone, resolveKind, resolveMix, safe, sfc32Next, splitmix32, ssn, uuid };
|
|
846
|
+
export type { AnimalBreedDraw, Sfc32State, SynthErrorOptions, SynthFatalCode, SynthPeer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,117 @@
|
|
|
1
|
-
import { s as ssn, p as phone, n as name, e as email, i as ipv4, c as ipv6, u as uuid, d as identifier, f as address, g as dateYmd, h as npi, j as dea } from './providers-B48qUwHU.js';
|
|
2
|
-
export { A as Artifact, C as Corpus, k as CorpusManifest,
|
|
3
|
-
|
|
1
|
+
import { R as Rng, s as ssn, p as phone, n as name, e as email, i as ipv4, c as ipv6, u as uuid, d as identifier, f as address, g as dateYmd, h as npi, j as dea } from './providers-B48qUwHU.js';
|
|
2
|
+
export { A as Artifact, C as Corpus, k as CorpusManifest, l as SsnBlock, m as SynthFormat, b as SyntheticAddress, a as SyntheticIdentifier, S as SyntheticName, o as createRng, q as makeCorpus } from './providers-B48qUwHU.js';
|
|
3
|
+
import { A as AnimalCode, a as AnimalSpecies } from './animal-code-Bdl_9Jma.js';
|
|
4
|
+
export { b as ANIMAL_CODE_SYSTEM } from './animal-code-Bdl_9Jma.js';
|
|
5
|
+
export { P as PROFILE_QUIRK_APPLIED, a as QuirkArtifact, Q as QuirkDescriptor, c as QuirkProfileDisposition, d as QuirkProfiledVerdict, b as QuirkRoundTripResult, S as SynthProfile, e as SynthProfileSpec, f as assertIntendedWarnings, g as defineSynthProfile, p as profileTolerated, r as resolveQuirk, s as sameCodeSet, v as validateProfileQuirks } from './quirk-CzknuYUo.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The synthetic **animal** providers: a pet's name, its species and breed, its microchip, and its
|
|
9
|
+
* birth date. Like every provider in `../safe`, each is a pure function of an explicit seeded
|
|
10
|
+
* generator and draws only from a source this module ships or a range we chose for synthetic values.
|
|
11
|
+
*
|
|
12
|
+
* - **Species and breed** come from a short list of our own: plain text, with codes in a local
|
|
13
|
+
* code system ({@link ANIMAL_CODE_SYSTEM}). No SNOMED CT, VetSCT or VeNom content is used.
|
|
14
|
+
* - **Pet names** come from a clearly invented pool, like the person-name pool.
|
|
15
|
+
* - **Microchips** are 15 digits that begin with `999` (see {@link MICROCHIP_TEST_PREFIX}). We
|
|
16
|
+
* take `999` to be outside the country and manufacturer codes a real chip carries, but we have
|
|
17
|
+
* not verified that against ISO 11784 or any registry.
|
|
18
|
+
*
|
|
19
|
+
* `# synthetic: true`
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** A species and one of its breeds, as {@link animalBreed} draws them. */
|
|
25
|
+
interface AnimalBreedDraw {
|
|
26
|
+
/** The species. */
|
|
27
|
+
readonly species: AnimalCode;
|
|
28
|
+
/** A breed of that species. */
|
|
29
|
+
readonly breed: AnimalCode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The species and breeds the animal subject draws from: our own short list, in plain text, under
|
|
33
|
+
* {@link ANIMAL_CODE_SYSTEM}. Small on purpose: structural coverage, not a breed registry.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { SYNTHETIC_ANIMAL_SPECIES } from "@cosyte/synth";
|
|
38
|
+
* SYNTHETIC_ANIMAL_SPECIES.map((s) => s.text); // ["Dog", "Cat", "Horse", "Cattle"]
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare const SYNTHETIC_ANIMAL_SPECIES: readonly AnimalSpecies[];
|
|
42
|
+
/** Clearly invented pet names. None is a name a reader would take for a real animal's record. */
|
|
43
|
+
declare const SYNTHETIC_PET_NAMES: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* The three digits every synthetic microchip begins with: `999`. We chose it as a range we believe
|
|
46
|
+
* no implanted chip uses, but we have not verified that against ISO 11784 or any manufacturer code
|
|
47
|
+
* list. Not verified.
|
|
48
|
+
*/
|
|
49
|
+
declare const MICROCHIP_TEST_PREFIX = "999";
|
|
50
|
+
/**
|
|
51
|
+
* A **synthetic pet name** from {@link SYNTHETIC_PET_NAMES}.
|
|
52
|
+
*
|
|
53
|
+
* @param rng - The seeded generator.
|
|
54
|
+
* @returns A clearly invented pet name.
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { createRng, petName } from "@cosyte/synth";
|
|
58
|
+
* petName(createRng(1)); // e.g. "Stubtail", synthetic
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function petName(rng: Rng): string;
|
|
62
|
+
/**
|
|
63
|
+
* A **species and breed** from {@link SYNTHETIC_ANIMAL_SPECIES}: the species first, then one of its
|
|
64
|
+
* breeds.
|
|
65
|
+
*
|
|
66
|
+
* @param rng - The seeded generator.
|
|
67
|
+
* @returns An {@link AnimalBreedDraw}.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { animalBreed, createRng } from "@cosyte/synth";
|
|
71
|
+
* const { species, breed } = animalBreed(createRng(1));
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function animalBreed(rng: Rng): AnimalBreedDraw;
|
|
75
|
+
/**
|
|
76
|
+
* A **synthetic microchip**: 15 digits, {@link MICROCHIP_TEST_PREFIX} then twelve seeded digits.
|
|
77
|
+
*
|
|
78
|
+
* @param rng - The seeded generator.
|
|
79
|
+
* @returns A 15-digit string beginning `999`.
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { createRng, isSyntheticMicrochip, microchip } from "@cosyte/synth";
|
|
83
|
+
* isSyntheticMicrochip(microchip(createRng(1))); // true
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function microchip(rng: Rng): string;
|
|
87
|
+
/**
|
|
88
|
+
* Whether a value is a synthetic microchip: exactly 15 digits beginning with
|
|
89
|
+
* {@link MICROCHIP_TEST_PREFIX}.
|
|
90
|
+
*
|
|
91
|
+
* @param value - The value to test.
|
|
92
|
+
* @returns `true` when the value is 15 digits beginning {@link MICROCHIP_TEST_PREFIX}.
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { isSyntheticMicrochip } from "@cosyte/synth";
|
|
96
|
+
* isSyntheticMicrochip("999000000000001"); // true
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function isSyntheticMicrochip(value: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* A **synthetic animal birth date** in `YYYYMMDD` form, from 0 to 20 years before `onDate`, both
|
|
102
|
+
* ends included. `onDate` is a date the caller supplies (the generators pass the message date), never
|
|
103
|
+
* the clock, so the same seed and date give the same birth date.
|
|
104
|
+
*
|
|
105
|
+
* @param rng - The seeded generator.
|
|
106
|
+
* @param onDate - The reference date, `YYYYMMDD` (only its first eight digits are read).
|
|
107
|
+
* @returns A `YYYYMMDD` date no later than `onDate` and no more than 20 years before it.
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { animalBirthDate, createRng } from "@cosyte/synth";
|
|
111
|
+
* animalBirthDate(createRng(1), "20250101"); // between "20050101" and "20250101"
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function animalBirthDate(rng: Rng, onDate: string): string;
|
|
4
115
|
|
|
5
116
|
/**
|
|
6
117
|
* The reserved / never-collide identifier facts that make a `@cosyte/synth` value **provably
|
|
@@ -357,6 +468,7 @@ declare const SYNTHETIC_CITY_NAMES: readonly string[];
|
|
|
357
468
|
* const rng = createRng(42);
|
|
358
469
|
* safe.ssn(rng); // never-issued SSN
|
|
359
470
|
* safe.phone(rng); // reserved 555-01NN number
|
|
471
|
+
* safe.microchip(rng); // 15 digits beginning 999
|
|
360
472
|
* ```
|
|
361
473
|
*/
|
|
362
474
|
declare const safe: Readonly<{
|
|
@@ -372,6 +484,10 @@ declare const safe: Readonly<{
|
|
|
372
484
|
dateYmd: typeof dateYmd;
|
|
373
485
|
npi: typeof npi;
|
|
374
486
|
dea: typeof dea;
|
|
487
|
+
petName: typeof petName;
|
|
488
|
+
animalBreed: typeof animalBreed;
|
|
489
|
+
microchip: typeof microchip;
|
|
490
|
+
animalBirthDate: typeof animalBirthDate;
|
|
375
491
|
}>;
|
|
376
492
|
|
|
377
493
|
/**
|
|
@@ -504,7 +620,11 @@ declare const SYNTH_FATAL_CODES: Readonly<{
|
|
|
504
620
|
readonly SYNTH_INVALID_DECIMAL: "SYNTH_INVALID_DECIMAL";
|
|
505
621
|
/** An integer range was requested with its maximum below its minimum. Fatal. */
|
|
506
622
|
readonly SYNTH_INVALID_RANGE: "SYNTH_INVALID_RANGE";
|
|
507
|
-
/**
|
|
623
|
+
/**
|
|
624
|
+
* A value was drawn from an empty pool. Fatal, never a fabricated substitute. A corpus given an
|
|
625
|
+
* empty `mix`, `triggers` or `quirks` list (or a profile whose `quirks` is an empty list) raises it
|
|
626
|
+
* too: there is no kind to cycle through, and an empty list is never read as the default.
|
|
627
|
+
*/
|
|
508
628
|
readonly SYNTH_EMPTY_POOL: "SYNTH_EMPTY_POOL";
|
|
509
629
|
/** A `defineSynthProfile` spec was not usable (a missing or blank `name`). Fatal. */
|
|
510
630
|
readonly SYNTH_INVALID_PROFILE: "SYNTH_INVALID_PROFILE";
|
|
@@ -524,6 +644,20 @@ declare const SYNTH_FATAL_CODES: Readonly<{
|
|
|
524
644
|
* mislabelled artifact is worse than no artifact.
|
|
525
645
|
*/
|
|
526
646
|
readonly SYNTH_PROFILE_NOT_GENERATED: "SYNTH_PROFILE_NOT_GENERATED";
|
|
647
|
+
/**
|
|
648
|
+
* The sibling parser a generator builds through is not installed. Raised on the first call that
|
|
649
|
+
* needs it, by both builds, only when the missing package is the parser itself: a missing
|
|
650
|
+
* dependency of an installed parser is thrown as Node.js raised it. The error carries the parser's
|
|
651
|
+
* package name on `peer`, a message from {@link SYNTH_PEER_MESSAGES} that names its install
|
|
652
|
+
* command, and the error Node.js raised on `cause`.
|
|
653
|
+
*/
|
|
654
|
+
readonly SYNTH_PEER_NOT_INSTALLED: "SYNTH_PEER_NOT_INSTALLED";
|
|
655
|
+
/**
|
|
656
|
+
* An HL7 v2 `ACK` was asked for an inbound message that carries no MSH-10 message control id.
|
|
657
|
+
* MSA-2 must echo that id, and an acknowledgment that cannot be matched to the message it answers
|
|
658
|
+
* is not a fixture worth having, so nothing is generated.
|
|
659
|
+
*/
|
|
660
|
+
readonly SYNTH_ACK_UNCORRELATED: "SYNTH_ACK_UNCORRELATED";
|
|
527
661
|
}>;
|
|
528
662
|
/**
|
|
529
663
|
* A value from {@link SYNTH_FATAL_CODES}: the type carried by a thrown {@link SynthError}.
|
|
@@ -549,13 +683,48 @@ type SynthFatalCode = (typeof SYNTH_FATAL_CODES)[keyof typeof SYNTH_FATAL_CODES]
|
|
|
549
683
|
* ```
|
|
550
684
|
*/
|
|
551
685
|
declare const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>>;
|
|
686
|
+
/**
|
|
687
|
+
* The message a {@link SYNTH_FATAL_CODES.SYNTH_PEER_NOT_INSTALLED} error carries for each sibling
|
|
688
|
+
* parser: which package is missing, and the command that installs it. Keyed by the closed set of
|
|
689
|
+
* parser packages this package builds through, so like {@link SYNTH_FATAL_MESSAGES} it is a table
|
|
690
|
+
* of fixed strings, and no caller value can reach it.
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* ```ts
|
|
694
|
+
* import { SYNTH_PEER_MESSAGES } from "@cosyte/synth";
|
|
695
|
+
* SYNTH_PEER_MESSAGES["@cosyte/hl7"]; // => "@cosyte/hl7 is not installed, and this generator builds through it. Install it beside @cosyte/synth: npm install @cosyte/hl7"
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
declare const SYNTH_PEER_MESSAGES: Readonly<{
|
|
699
|
+
readonly "@cosyte/hl7": string;
|
|
700
|
+
readonly "@cosyte/fhir": string;
|
|
701
|
+
readonly "@cosyte/ccda": string;
|
|
702
|
+
readonly "@cosyte/x12": string;
|
|
703
|
+
readonly "@cosyte/ncpdp": string;
|
|
704
|
+
readonly "@cosyte/astm": string;
|
|
705
|
+
readonly "@cosyte/deid": string;
|
|
706
|
+
}>;
|
|
707
|
+
/** A sibling parser package: a key of {@link SYNTH_PEER_MESSAGES}. */
|
|
708
|
+
type SynthPeer = keyof typeof SYNTH_PEER_MESSAGES;
|
|
709
|
+
/** What a {@link SynthError} may carry beside its code. */
|
|
710
|
+
interface SynthErrorOptions {
|
|
711
|
+
/** The error that caused this one, kept on `cause`. */
|
|
712
|
+
readonly cause?: unknown;
|
|
713
|
+
/**
|
|
714
|
+
* For {@link SYNTH_FATAL_CODES.SYNTH_PEER_NOT_INSTALLED}: the parser package that is missing. Its
|
|
715
|
+
* message then comes from {@link SYNTH_PEER_MESSAGES}.
|
|
716
|
+
*/
|
|
717
|
+
readonly peer?: SynthPeer;
|
|
718
|
+
}
|
|
552
719
|
/**
|
|
553
720
|
* The typed error every fatal `@cosyte/synth` condition throws. Carries a stable
|
|
554
721
|
* {@link SynthFatalCode} so callers branch on `err.code` without matching message text.
|
|
555
722
|
*
|
|
556
723
|
* It takes **no value parameter**. The message is whatever {@link SYNTH_FATAL_MESSAGES} holds for the
|
|
557
|
-
* code,
|
|
558
|
-
*
|
|
724
|
+
* code, or for a missing parser whatever {@link SYNTH_PEER_MESSAGES} holds for that package, so no
|
|
725
|
+
* caller-supplied string can reach a diagnostic surface by any route, not `message`, not `stack`,
|
|
726
|
+
* not a field on the thrown object. The options carry only an error this package caught (`cause`)
|
|
727
|
+
* and a package name from that closed set (`peer`).
|
|
559
728
|
*
|
|
560
729
|
* @example
|
|
561
730
|
* ```ts
|
|
@@ -566,10 +735,13 @@ declare const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>>;
|
|
|
566
735
|
declare class SynthError extends Error {
|
|
567
736
|
/** The stable fatal code. */
|
|
568
737
|
readonly code: SynthFatalCode;
|
|
738
|
+
/** The missing parser package, on a {@link SYNTH_FATAL_CODES.SYNTH_PEER_NOT_INSTALLED} error only. */
|
|
739
|
+
readonly peer?: SynthPeer;
|
|
569
740
|
/**
|
|
570
741
|
* @param code - The stable {@link SynthFatalCode}. The message comes from the frozen registry.
|
|
742
|
+
* @param options - The error that caused this one, and for a missing parser its package.
|
|
571
743
|
*/
|
|
572
|
-
constructor(code: SynthFatalCode);
|
|
744
|
+
constructor(code: SynthFatalCode, options?: SynthErrorOptions);
|
|
573
745
|
}
|
|
574
746
|
|
|
575
747
|
/**
|
|
@@ -620,7 +792,8 @@ declare function resolveKind<T extends string>(allowed: readonly T[], requested:
|
|
|
620
792
|
* of this function also treated `[]` as "nothing supplied", on the stated grounds that it matched the
|
|
621
793
|
* previous behaviour; it did not: `??` fires on `undefined` and never on `[]`, and it changed the
|
|
622
794
|
* result of six published entry points, turning an explicit empty selection into "generate one of
|
|
623
|
-
* everything". A convenience that fails open is not a convenience.
|
|
795
|
+
* everything". A convenience that fails open is not a convenience. Every corpus then refuses the empty
|
|
796
|
+
* mix with `SYNTH_EMPTY_POOL`, before it generates anything.
|
|
624
797
|
*
|
|
625
798
|
* @param allowed - Every kind the corpus may generate.
|
|
626
799
|
* @param requested - The mix the caller supplied, or `undefined` for the default.
|
|
@@ -669,5 +842,5 @@ declare function resolveMix<T extends string>(allowed: readonly T[], requested:
|
|
|
669
842
|
*/
|
|
670
843
|
declare const VERSION: string;
|
|
671
844
|
|
|
672
|
-
export { DEA_REGISTRANT_TYPES, DOC_V6_PREFIX, ITIN_GROUP_RANGES, NPI_LUHN_PREFIX, RESERVED_EMAIL_DOMAINS, SYNTHETIC_ASSIGNING_AUTHORITY, SYNTHETIC_CITY_NAMES, SYNTHETIC_FAMILY_NAMES, SYNTHETIC_GIVEN_NAMES, SYNTHETIC_STREET_NAMES, SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES, SynthError, TEST_NET_V4_PREFIXES, VERSION, address, dateYmd, dea, deaCheckDigit, email, identifier, ipv4, ipv6, isItinFormatted, isSyntheticDea, isSyntheticEmail, isSyntheticIp, isSyntheticNpi, isSyntheticPhone, isSyntheticSsn, luhnMod10, name, npi, npiCheckDigit, phone, resolveKind, resolveMix, safe, sfc32Next, splitmix32, ssn, uuid };
|
|
673
|
-
export type { Sfc32State, SynthFatalCode };
|
|
845
|
+
export { AnimalCode, AnimalSpecies, DEA_REGISTRANT_TYPES, DOC_V6_PREFIX, ITIN_GROUP_RANGES, MICROCHIP_TEST_PREFIX, NPI_LUHN_PREFIX, RESERVED_EMAIL_DOMAINS, Rng, SYNTHETIC_ANIMAL_SPECIES, SYNTHETIC_ASSIGNING_AUTHORITY, SYNTHETIC_CITY_NAMES, SYNTHETIC_FAMILY_NAMES, SYNTHETIC_GIVEN_NAMES, SYNTHETIC_PET_NAMES, SYNTHETIC_STREET_NAMES, SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES, SYNTH_PEER_MESSAGES, SynthError, TEST_NET_V4_PREFIXES, VERSION, address, animalBirthDate, animalBreed, dateYmd, dea, deaCheckDigit, email, identifier, ipv4, ipv6, isItinFormatted, isSyntheticDea, isSyntheticEmail, isSyntheticIp, isSyntheticMicrochip, isSyntheticNpi, isSyntheticPhone, isSyntheticSsn, luhnMod10, microchip, name, npi, npiCheckDigit, petName, phone, resolveKind, resolveMix, safe, sfc32Next, splitmix32, ssn, uuid };
|
|
846
|
+
export type { AnimalBreedDraw, Sfc32State, SynthErrorOptions, SynthFatalCode, SynthPeer };
|