@sampuli/data 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.
@@ -0,0 +1,71 @@
1
+ // Type definitions for @sampuli/data
2
+
3
+ export interface FieldInfo {
4
+ key: string
5
+ label: string
6
+ num: boolean
7
+ money: boolean
8
+ img: boolean
9
+ }
10
+
11
+ export interface PresetInfo {
12
+ key: string
13
+ name: string
14
+ desc: string
15
+ }
16
+
17
+ export interface GenerateSettings {
18
+ /** Any string/number makes output reproducible. */
19
+ seed?: string | number
20
+ /**
21
+ * Which fields a `.person` record includes. Omit for the default-on set;
22
+ * pass an array of field keys to pick exactly which (e.g.
23
+ * ['name','phone','email','gps','dob']); pass 'all' for every field the
24
+ * pack offers, including the optional PII columns.
25
+ */
26
+ fields?: string[] | 'all'
27
+ /** 'symbol' → "KES 1,200.00"; 'number' → 1200. Default 'symbol'. */
28
+ amountStyle?: 'symbol' | 'number'
29
+ /** Kenya: mobile network for phone numbers. */
30
+ network?: 'any' | 'safaricom' | 'airtel' | 'telkom'
31
+ /** Kenya: phone format. */
32
+ phoneFmt?: 'local' | 'plus' | 'intl'
33
+ /** Kenya: KRA PIN class — Individual (A) or Company (P). */
34
+ pinType?: 'A' | 'P'
35
+ [key: string]: unknown
36
+ }
37
+
38
+ /** One synthetic record: field key → generated value. */
39
+ export type SampuliRecord = Record<string, string | number>
40
+
41
+ /** A preset's output: ordered [label, value] rows (with section separators). */
42
+ export type PresetRows = Array<[string, string | number]>
43
+
44
+ /** ISO codes of available packs (['KE'] out of the box). */
45
+ export function listPacks(): string[]
46
+
47
+ /** The generatable fields for a pack. */
48
+ export function listFields(code: string): FieldInfo[]
49
+
50
+ /** The scenario presets for a pack. */
51
+ export function listPresets(code: string): PresetInfo[]
52
+
53
+ /** Register an extra country pack at runtime. */
54
+ export function registerPack(pack: unknown): void
55
+
56
+ /**
57
+ * Generate one value. The spec is `pack.selector`:
58
+ * a field key ('ke.phone'), 'ke.person' (a full record),
59
+ * 'ke.preset:kyc' (preset rows), or just 'ke' (a record).
60
+ */
61
+ export function generate(
62
+ spec: string,
63
+ settings?: GenerateSettings,
64
+ ): string | number | SampuliRecord | PresetRows
65
+
66
+ /** Generate an array of `count` values (records, single fields, or presets). */
67
+ export function generateMany(
68
+ spec: string,
69
+ count: number,
70
+ settings?: GenerateSettings,
71
+ ): Array<string | number | SampuliRecord | PresetRows>