@lokal-id/core 0.0.0-stage → 0.2.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -2
  3. package/data/LICENSE-kodepos.txt +21 -0
  4. package/data/LICENSE-wilayah.txt +21 -0
  5. package/data/README.md +14 -0
  6. package/data/desa.json +1 -0
  7. package/data/kodepos.json +1 -0
  8. package/data/wilayah.json +1 -0
  9. package/dist/holidays.d.ts +33 -0
  10. package/dist/holidays.js +130 -0
  11. package/dist/holidays.js.map +1 -0
  12. package/dist/index.d.ts +8 -0
  13. package/dist/index.js +9 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/nik.d.ts +41 -0
  16. package/dist/nik.js +78 -0
  17. package/dist/nik.js.map +1 -0
  18. package/dist/npwp.d.ts +22 -0
  19. package/dist/npwp.js +40 -0
  20. package/dist/npwp.js.map +1 -0
  21. package/dist/phone.d.ts +31 -0
  22. package/dist/phone.js +107 -0
  23. package/dist/phone.js.map +1 -0
  24. package/dist/provinces.d.ts +1 -0
  25. package/dist/provinces.js +42 -0
  26. package/dist/provinces.js.map +1 -0
  27. package/dist/rupiah.d.ts +23 -0
  28. package/dist/rupiah.js +219 -0
  29. package/dist/rupiah.js.map +1 -0
  30. package/dist/samaran/detectors.d.ts +9 -0
  31. package/dist/samaran/detectors.js +508 -0
  32. package/dist/samaran/detectors.js.map +1 -0
  33. package/dist/samaran/fields.d.ts +8 -0
  34. package/dist/samaran/fields.js +123 -0
  35. package/dist/samaran/fields.js.map +1 -0
  36. package/dist/samaran/index.d.ts +53 -0
  37. package/dist/samaran/index.js +162 -0
  38. package/dist/samaran/index.js.map +1 -0
  39. package/dist/samaran/types.d.ts +16 -0
  40. package/dist/samaran/types.js +15 -0
  41. package/dist/samaran/types.js.map +1 -0
  42. package/dist/terbilang.d.ts +11 -0
  43. package/dist/terbilang.js +78 -0
  44. package/dist/terbilang.js.map +1 -0
  45. package/dist/wilayah.d.ts +40 -0
  46. package/dist/wilayah.js +154 -0
  47. package/dist/wilayah.js.map +1 -0
  48. package/package.json +49 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lokal contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # @lokal-id/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@lokal-id/core?color=cb3837)](https://www.npmjs.com/package/@lokal-id/core)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lokal-id/lokal/blob/HEAD/LICENSE)
5
+
6
+ Indonesian data primitives for apps and AI agents: NIK, NPWP, phone numbers, Rupiah, *terbilang*, holidays and working days, Kemendagri regions with postal codes, and **Samaran**, which masks Indonesian personal data before it reaches an LLM and restores it afterwards.
7
+
8
+ No dependencies. Part of [Lokal](https://github.com/lokal-id/lokal) · [Bahasa Indonesia](https://github.com/lokal-id/lokal/blob/HEAD/README.id.md)
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install @lokal-id/core
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import { parseNik, parsePhone, formatRupiah, parseRupiah, terbilang, addWorkingDays, Samaran } from '@lokal-id/core';
20
+ import { listWilayah, searchWilayah, wilayahName, findByPostalCode } from '@lokal-id/core/wilayah';
21
+
22
+ parseNik('3201011508950001', { lookupWilayah: wilayahName });
23
+ // { valid: true, province: 'Jawa Barat', regency: 'Kabupaten Bogor', gender: 'L', birthDate: '1995-08-15', … }
24
+ parsePhone('0812 3456 7890'); // { e164: '+6281234567890', operator: 'Telkomsel', … }
25
+ formatRupiah(1500000); // 'Rp1.500.000'
26
+ parseRupiah('sejuta setengah'); // { amount: 1500000, approximate: false }
27
+ terbilang(1500000, { currency: true }); // 'satu juta lima ratus ribu rupiah'
28
+ addWorkingDays('2026-03-17', 1); // '2026-03-25', skipping Nyepi and Lebaran
29
+ listWilayah('32.76'); // districts of Kota Depok
30
+ findByPostalCode('16431'); // villages that use this postal code
31
+ ```
32
+
33
+ ### Samaran
34
+
35
+ ```ts
36
+ const samaran = new Samaran();
37
+ const { text } = samaran.mask('nama saya budi santoso, NIK 3201011508950001, HP 0812-3456-7890');
38
+ // 'nama saya [NAME_1], NIK [NIK_1], HP [PHONE_1]'
39
+
40
+ samaran.unmask(await llm(text)); // placeholders are replaced with the original values
41
+ ```
42
+
43
+ The same value always gets the same placeholder, so the model can still deduplicate and join. Use `mode: 'partial'` for logs and admin screens (`3201********0001`).
44
+
45
+ `@lokal-id/core/wilayah` loads about 4.4 MB of region data and runs on Node only. The main entry point does not load it and is safe for browsers.
46
+
47
+ ## Data
48
+
49
+ | Data | Source |
50
+ |---|---|
51
+ | Regions: 38 provinces, 416 regencies, 98 cities, 7,285 districts, 8,496 *kelurahan*, 75,266 villages | [cahyadsn/wilayah](https://github.com/cahyadsn/wilayah) (MIT), following Kepmendagri 300.2.2-2138/2025 |
52
+ | Postal codes for all 83,762 villages | [cahyadsn/wilayah_kodepos](https://github.com/cahyadsn/wilayah_kodepos) (MIT) |
53
+ | Holidays and *cuti bersama* for 2026 and 2027 | SKB 3 Menteri. Other years return an error, not a guess |
54
+
55
+ Detection limits and full documentation are in the [Lokal README](https://github.com/lokal-id/lokal#limitations).
56
+
57
+ ## License
58
+
59
+ [MIT](https://github.com/lokal-id/lokal/blob/HEAD/LICENSE)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Cahya DSN
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-2025 Cahya DSN
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Data wilayah
2
+
3
+ `wilayah.json` (provinsi, kabupaten/kota, kecamatan) and `desa.json` (kelurahan/desa) are generated from
4
+ [cahyadsn/wilayah](https://github.com/cahyadsn/wilayah) `db/wilayah.sql`, which follows
5
+ Kepmendagri No 300.2.2-2138 Tahun 2025 (as amended by 300.2.2-2430 Tahun 2025, which only reassigns four islands). The
6
+ totals match the decree exactly: 38 provinsi, 416 kabupaten, 98 kota, 7,285 kecamatan, 8,496 kelurahan, 75,266 desa.
7
+ That data is MIT-licensed; see `LICENSE-wilayah.txt`.
8
+
9
+ Regenerate after a new Kepmendagri decree:
10
+
11
+ ```sh
12
+ curl -L -o wilayah.sql https://raw.githubusercontent.com/cahyadsn/wilayah/master/db/wilayah.sql
13
+ npm run data:wilayah -w @lokal-id/core -- path/to/wilayah.sql
14
+ ```