@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.
- package/README.md +134 -0
- package/dist/index.cjs +9965 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +9934 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# @sampuli/data
|
|
2
|
+
|
|
3
|
+
**Format-true synthetic test data — 27 countries, Kenya first.** Valid KRA
|
|
4
|
+
PINs and M-Pesa numbers, Nigerian BVNs, South African IDs, real bank SWIFT/BIC
|
|
5
|
+
codes, and ready-made KYC / transfer / payment / merchant scenarios per
|
|
6
|
+
country — generated on the spot, never real people.
|
|
7
|
+
|
|
8
|
+
Built for QA and dev teams at African banks and fintechs (and beyond) who need
|
|
9
|
+
test data that *passes their own format validation*. Free, no volume caps.
|
|
10
|
+
The engine behind [Sampuli](https://sampuli.site).
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @sampuli/data
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { generate, generateMany, listPacks } from '@sampuli/data'
|
|
20
|
+
|
|
21
|
+
listPacks() // ['KE','DZ','AO', … 'FR','NL','BR', …] — every Sampuli country
|
|
22
|
+
|
|
23
|
+
generate('ke.phone') // → '0712345678' (a real Safaricom/Airtel/Telkom prefix)
|
|
24
|
+
generate('ke.kra_pin') // → 'A123456789Z' (valid KRA PIN format)
|
|
25
|
+
generate('ng.person') // → a coherent Nigerian record
|
|
26
|
+
generate('za.person') // → a coherent South African record
|
|
27
|
+
|
|
28
|
+
generate('ke.person')
|
|
29
|
+
// → {
|
|
30
|
+
// name: 'Mercy Achieng', phone: '0748163920', id: '27380011',
|
|
31
|
+
// kra: 'A661044820Q', bank: 'Equity Bank', swift: 'EQBLKENA',
|
|
32
|
+
// account: '830155120774', amount: 'KES 12,400.00'
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
generateMany('ke.person', 200) // → 200 coherent records
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Every pack uses the same spec shape — swap the country code. A pack's fields
|
|
39
|
+
and presets vary by country; discover them with `listFields(code)` /
|
|
40
|
+
`listPresets(code)`. (Kenya's tax id field is `kra`; most other packs use `tax`.)
|
|
41
|
+
|
|
42
|
+
CommonJS works too:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const { generate } = require('@sampuli/data')
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## What you can generate
|
|
49
|
+
|
|
50
|
+
`generate(spec, settings?)` — the `spec` is `pack.selector`:
|
|
51
|
+
|
|
52
|
+
| Spec | Returns |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `'ke.phone'`, `'ke.kra_pin'`, `'ke.national_id'`, … | a single field value |
|
|
55
|
+
| `'ke.person'` (or just `'ke'`) | a full coherent record (object) |
|
|
56
|
+
| `'ke.preset:kyc'` | ordered `[label, value]` rows for a scenario |
|
|
57
|
+
|
|
58
|
+
Discover what a pack offers:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { listFields, listPresets } from '@sampuli/data'
|
|
62
|
+
|
|
63
|
+
listFields('ke') // [{ key: 'phone', label: 'Phone', num: false, ... }, ...]
|
|
64
|
+
listPresets('ke') // [{ key: 'kyc', name: 'KYC customer profile', ... }, ...]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Kenya's field keys, for example: `name`, `phone`, `id`, `kra`, `bank`,
|
|
68
|
+
`swift`, `account`, `amount`, `gender`, `dob`, `marital`, `occupation`,
|
|
69
|
+
`town`, `county`, `gps`, `address`, `business`, `paybill`, `till`, `plate`,
|
|
70
|
+
`email`, `avatar`, `ref`. Presets: `kyc`, `pesalink`, `schoolfees`, `fx`,
|
|
71
|
+
`merchant`. Other countries share the common core (name/phone/id/tax/bank/
|
|
72
|
+
swift/account/amount) with locale-specific extras and presets — always check
|
|
73
|
+
`listFields(code)`.
|
|
74
|
+
|
|
75
|
+
## Choosing which fields a record has
|
|
76
|
+
|
|
77
|
+
`generate('ke.person')` returns the on-by-default columns. To include the
|
|
78
|
+
optional PII — email, GPS, date of birth, address, occupation, avatar, plate,
|
|
79
|
+
and the rest — pass `fields` (the package equivalent of the app's column
|
|
80
|
+
toggles):
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
generate('ke.person', { fields: 'all' })
|
|
84
|
+
// → every field the pack has: name, phone, id, kra, …, gender, dob, gps,
|
|
85
|
+
// address, email, avatar, ref
|
|
86
|
+
|
|
87
|
+
generate('ke.person', { fields: ['name', 'phone', 'email', 'gps', 'dob'] })
|
|
88
|
+
// → { name, phone, email, gps, dob } — exactly those, in that order
|
|
89
|
+
|
|
90
|
+
generateMany('za.person', 500, { fields: ['name', 'said', 'phone', 'email'] })
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Records stay coherent whichever fields you pick (e.g. `email` derives from the
|
|
94
|
+
generated `name`).
|
|
95
|
+
|
|
96
|
+
## Settings
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
generate('ke.phone', { phoneFmt: 'plus' }) // '+254712345678'
|
|
100
|
+
generate('ke.phone', { network: 'safaricom' }) // Safaricom prefixes only
|
|
101
|
+
generate('ke.kra_pin', { pinType: 'P' }) // company PIN (P…)
|
|
102
|
+
generate('ke.amount', { amountStyle: 'number' }) // 12400 (number, not 'KES 12,400.00')
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Records stay internally coherent: `bank` and `swift` describe the same bank,
|
|
106
|
+
`gender` matches the first name, `county` matches the `town`.
|
|
107
|
+
|
|
108
|
+
## Reproducible output
|
|
109
|
+
|
|
110
|
+
Pass a `seed` and you get the same data every time — ideal for CI snapshots:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
generate('ke.person', { seed: 'test-42' }) // identical on every run
|
|
114
|
+
generateMany('ke.person', 100, { seed: 'batch' }) // identical batch every run
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Scope
|
|
118
|
+
|
|
119
|
+
Ships **all 27 Sampuli country packs**, free, with no volume caps — Africa
|
|
120
|
+
(Kenya, Nigeria, South Africa, Egypt, Ghana, Tanzania, Uganda, Rwanda,
|
|
121
|
+
Algeria, Angola, Morocco, Ethiopia, Côte d'Ivoire, DR Congo, Tunisia,
|
|
122
|
+
Cameroon, Mauritius), plus Germany, Switzerland, UK, Canada, US, UAE,
|
|
123
|
+
Australia, China, India, Japan. Try them at [sampuli.site](https://sampuli.site).
|
|
124
|
+
Additional packs can be plugged in at runtime via `registerPack(pack)`.
|
|
125
|
+
|
|
126
|
+
## Accuracy
|
|
127
|
+
|
|
128
|
+
Every value is *format-valid*: it matches the real shape and passes standard
|
|
129
|
+
format checks. It is entirely synthetic — invented at call time, corresponding
|
|
130
|
+
to no real person, account, or business.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT.
|