@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.
- package/LICENSE +21 -0
- package/README.md +58 -2
- package/data/LICENSE-kodepos.txt +21 -0
- package/data/LICENSE-wilayah.txt +21 -0
- package/data/README.md +14 -0
- package/data/desa.json +1 -0
- package/data/kodepos.json +1 -0
- package/data/wilayah.json +1 -0
- package/dist/holidays.d.ts +33 -0
- package/dist/holidays.js +130 -0
- package/dist/holidays.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/nik.d.ts +41 -0
- package/dist/nik.js +78 -0
- package/dist/nik.js.map +1 -0
- package/dist/npwp.d.ts +22 -0
- package/dist/npwp.js +40 -0
- package/dist/npwp.js.map +1 -0
- package/dist/phone.d.ts +31 -0
- package/dist/phone.js +107 -0
- package/dist/phone.js.map +1 -0
- package/dist/provinces.d.ts +1 -0
- package/dist/provinces.js +42 -0
- package/dist/provinces.js.map +1 -0
- package/dist/rupiah.d.ts +23 -0
- package/dist/rupiah.js +219 -0
- package/dist/rupiah.js.map +1 -0
- package/dist/samaran/detectors.d.ts +9 -0
- package/dist/samaran/detectors.js +508 -0
- package/dist/samaran/detectors.js.map +1 -0
- package/dist/samaran/fields.d.ts +8 -0
- package/dist/samaran/fields.js +123 -0
- package/dist/samaran/fields.js.map +1 -0
- package/dist/samaran/index.d.ts +53 -0
- package/dist/samaran/index.js +162 -0
- package/dist/samaran/index.js.map +1 -0
- package/dist/samaran/types.d.ts +16 -0
- package/dist/samaran/types.js +15 -0
- package/dist/samaran/types.js.map +1 -0
- package/dist/terbilang.d.ts +11 -0
- package/dist/terbilang.js +78 -0
- package/dist/terbilang.js.map +1 -0
- package/dist/wilayah.d.ts +40 -0
- package/dist/wilayah.js +154 -0
- package/dist/wilayah.js.map +1 -0
- 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
|
-
#
|
|
1
|
+
# @lokal-id/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@lokal-id/core)
|
|
4
|
+
[](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
|
+
```
|