@almadar/core 10.36.0 → 10.38.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.
@@ -0,0 +1,119 @@
1
+ import { E as EntityPersistence, a as EntityField, F as FieldValue, b as EntityRow } from '../entity-CVylqnAf.js';
2
+ import 'zod';
3
+
4
+ /**
5
+ * Lightweight seeded pseudo-random generator for mock data.
6
+ *
7
+ * Replaces @faker-js/faker in browser-facing code so the client bundle does
8
+ * not pay the ~3.7 MB faker cost. The API surface is intentionally narrow:
9
+ * only the helpers actually used by MockPersistenceAdapter.
10
+ */
11
+ /** Re-seed the generator. Same signature as `faker.seed()`. */
12
+ declare function seedRandom(value: number | undefined): void;
13
+ /** Integer in [min, max]. */
14
+ declare function randomInt({ min, max }: {
15
+ min: number;
16
+ max: number;
17
+ }): number;
18
+ /** Float in [min, max] with fixed fraction digits. */
19
+ declare function randomFloat({ min, max, fractionDigits, }: {
20
+ min: number;
21
+ max: number;
22
+ fractionDigits?: number;
23
+ }): number;
24
+ /** True/false with 50% probability. */
25
+ declare function randomBoolean(): boolean;
26
+ /** Pick one element from an array. */
27
+ declare function randomArrayElement<T>(array: ReadonlyArray<T>): T;
28
+ /** Return a shallow-shuffled copy of the array (Fisher-Yates). */
29
+ declare function shuffleArray<T>(array: ReadonlyArray<T>): T[];
30
+ /** ISO-8601 date string roughly `years` in the past. */
31
+ declare function randomPastDate({ years }?: {
32
+ years?: number;
33
+ }): Date;
34
+ /** ISO-8601 date string within the last `days`. */
35
+ declare function randomRecentDate({ days }?: {
36
+ days?: number;
37
+ }): Date;
38
+ /** Any date in the last ~100 years. */
39
+ declare function randomAnytimeDate(): Date;
40
+ /** A few random words. */
41
+ declare function randomWords(count: number): string;
42
+ /** A short sentence. */
43
+ declare function randomSentence(): string;
44
+ /** UUID v4-like string (random, not strictly compliant). */
45
+ declare function randomUuid(): string;
46
+ /** Random hex color (#rrggbb). */
47
+ declare function randomColor(): string;
48
+ /** Random password of the given length. */
49
+ declare function randomPassword(length?: number): string;
50
+ /** Random email address. */
51
+ declare function randomEmail(): string;
52
+ /** Random URL. */
53
+ declare function randomUrl(): string;
54
+ /** Random phone number. */
55
+ declare function randomPhone(): string;
56
+
57
+ /**
58
+ * The one owner of mock-seed value synthesis.
59
+ *
60
+ * Five synthesizers used to hold four different policies on a field's declared
61
+ * `default`, so the same entity seeded differently depending on which path
62
+ * rendered it. This module is the single policy; callers supply only entropy.
63
+ *
64
+ * @packageDocumentation
65
+ */
66
+
67
+ /**
68
+ * Entropy source. `'seeded'` draws from the shared LCG — stateful and
69
+ * order-dependent, so a value depends on how many draws earlier rows consumed.
70
+ * `'index'` is a pure function of `(field, index)`, which is the only strategy
71
+ * Rust can reproduce and therefore the one parity is asserted on.
72
+ */
73
+ type SampleStrategy = 'seeded' | 'index';
74
+ interface SampleEntity {
75
+ readonly name: string;
76
+ readonly persistence?: EntityPersistence;
77
+ readonly fields: readonly EntityField[];
78
+ }
79
+ interface SampleContext {
80
+ readonly entityName: string;
81
+ /** 1-based row ordinal. Row 1 always yields `values[0]`. */
82
+ readonly index: number;
83
+ readonly strategy: SampleStrategy;
84
+ /** Declared persistence of the OWNING entity; undefined means persistent. */
85
+ readonly persistence?: EntityPersistence;
86
+ readonly depth?: number;
87
+ }
88
+ /**
89
+ * Image-bearing field names that still resolve to a real photo.
90
+ *
91
+ * A stopgap, kept verbatim from the two copies it replaces: no entity field in
92
+ * the corpus can express an image type yet, and 470 string fields are named
93
+ * this way, so deleting it would render broken `<img>` corpus-wide. Retire it
94
+ * once a real `image` type exists — not before.
95
+ */
96
+ declare const IMAGE_FIELD_NAMES: ReadonlySet<string>;
97
+ /** Deterministic stock-photo URL; the same entity+field renders the same image. */
98
+ declare function sampleImageUrl(entityName: string, fieldName: string, ctx: SampleContext, width?: number, height?: number): string;
99
+ /**
100
+ * Is `field.default` a value the synthesizer must return verbatim?
101
+ *
102
+ * Exported so codegen and tests share the one predicate rather than restating it.
103
+ */
104
+ declare function isDeclaredDefaultHonored(field: EntityField): boolean;
105
+ /** Rows to synthesize. A `[runtime]` entity is a per-orbital singleton. */
106
+ declare function sampleRowCount(entity: SampleEntity, requested: number): number;
107
+ /**
108
+ * One sample value for one field. `undefined` means OMIT the key.
109
+ *
110
+ * Order matters — see the three gates in the plan. Gates 1 and 2 read declared
111
+ * schema properties (`persistence`, `intrinsic`), never field names.
112
+ */
113
+ declare function sampleFieldValue(field: EntityField, ctx: SampleContext): FieldValue | undefined;
114
+ /** One row. Reserved keys are left to the caller. */
115
+ declare function sampleRow(entity: SampleEntity, ctx: Omit<SampleContext, 'entityName' | 'depth'>): EntityRow;
116
+ /** `count` rows, 1-based, honoring the runtime-singleton gate. */
117
+ declare function sampleRows(entity: SampleEntity, count: number, strategy: SampleStrategy): EntityRow[];
118
+
119
+ export { IMAGE_FIELD_NAMES, type SampleContext, type SampleEntity, type SampleStrategy, isDeclaredDefaultHonored, randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, sampleFieldValue, sampleImageUrl, sampleRow, sampleRowCount, sampleRows, seedRandom, shuffleArray };