pakdatakit 1.1.0 → 2.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.
Files changed (127) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +907 -666
  3. package/dist/address.cjs +17 -0
  4. package/dist/address.d.cts +36 -0
  5. package/dist/address.d.ts +36 -0
  6. package/dist/address.js +4 -0
  7. package/dist/chunk-3COX5FSL.cjs +1650 -0
  8. package/dist/chunk-422X6FEZ.cjs +220 -0
  9. package/dist/chunk-432ZYMYV.js +31 -0
  10. package/dist/chunk-4VVFS6FN.cjs +715 -0
  11. package/dist/chunk-6TSKA2PH.js +38 -0
  12. package/dist/chunk-APXP7OK7.cjs +226 -0
  13. package/dist/chunk-AUATLZA5.cjs +168 -0
  14. package/dist/chunk-BSS4Z7NI.cjs +422 -0
  15. package/dist/chunk-CEPNSHIC.js +33 -0
  16. package/dist/chunk-CQKK3S7A.js +217 -0
  17. package/dist/chunk-CYJJ7KGC.cjs +108 -0
  18. package/dist/chunk-EEVNLTB4.js +32 -0
  19. package/dist/chunk-ENQ7O7VW.js +32 -0
  20. package/dist/chunk-H4DVWUYH.js +231 -0
  21. package/dist/chunk-H6M6L26S.cjs +37 -0
  22. package/dist/chunk-HBOZIITD.js +351 -0
  23. package/dist/chunk-HTCSHHOR.cjs +35 -0
  24. package/dist/chunk-JKE4AMSZ.js +47 -0
  25. package/dist/chunk-K6CZFCX6.js +1642 -0
  26. package/dist/chunk-KEHCTYLO.cjs +52 -0
  27. package/dist/chunk-KQKW2ZEK.cjs +18 -0
  28. package/dist/chunk-L2BDDM2W.js +165 -0
  29. package/dist/chunk-L45UXUWX.js +21 -0
  30. package/dist/chunk-LIYNKIKS.js +709 -0
  31. package/dist/chunk-LVHTH4P7.cjs +41 -0
  32. package/dist/chunk-OVUR47QH.cjs +22 -0
  33. package/dist/chunk-P4CGOJEM.js +16 -0
  34. package/dist/chunk-PHHKIMO2.cjs +35 -0
  35. package/dist/chunk-QQQKISXT.js +223 -0
  36. package/dist/chunk-T3E4B5MJ.js +417 -0
  37. package/dist/chunk-VPBMIYO2.cjs +38 -0
  38. package/dist/chunk-WPKV5JT3.cjs +235 -0
  39. package/dist/chunk-XCXFGTHW.cjs +355 -0
  40. package/dist/chunk-XT4ZNXRC.js +20 -0
  41. package/dist/chunk-Y6BUGLXU.js +95 -0
  42. package/dist/chunk-YLWZGSFY.cjs +99 -0
  43. package/dist/chunk-YS7MOLK2.cjs +23 -0
  44. package/dist/chunk-Z5JEIQVW.js +102 -0
  45. package/dist/cli.js +78 -2654
  46. package/dist/cnic.cjs +15 -0
  47. package/dist/cnic.d.cts +35 -0
  48. package/dist/cnic.d.ts +35 -0
  49. package/dist/cnic.js +2 -0
  50. package/dist/format.cjs +14 -0
  51. package/dist/format.d.cts +27 -0
  52. package/dist/format.d.ts +27 -0
  53. package/dist/format.js +1 -0
  54. package/dist/geo.cjs +27 -0
  55. package/dist/geo.d.cts +43 -0
  56. package/dist/geo.d.ts +43 -0
  57. package/dist/geo.js +2 -0
  58. package/dist/hijri.cjs +26 -0
  59. package/dist/hijri.d.cts +62 -0
  60. package/dist/hijri.d.ts +62 -0
  61. package/dist/hijri.js +1 -0
  62. package/dist/holidays.cjs +19 -0
  63. package/dist/holidays.d.cts +72 -0
  64. package/dist/holidays.d.ts +72 -0
  65. package/dist/holidays.js +2 -0
  66. package/dist/iban.cjs +15 -0
  67. package/dist/iban.d.cts +21 -0
  68. package/dist/iban.d.ts +21 -0
  69. package/dist/iban.js +2 -0
  70. package/dist/index.cjs +211 -0
  71. package/dist/index.d.cts +16 -0
  72. package/dist/index.d.ts +16 -300
  73. package/dist/index.js +18 -2764
  74. package/dist/networks.cjs +12 -0
  75. package/dist/networks.d.cts +20 -0
  76. package/dist/networks.d.ts +20 -0
  77. package/dist/networks.js +3 -0
  78. package/dist/numbers.cjs +24 -0
  79. package/dist/numbers.d.cts +53 -0
  80. package/dist/numbers.d.ts +53 -0
  81. package/dist/numbers.js +3 -0
  82. package/dist/phone.cjs +29 -0
  83. package/dist/phone.d.cts +56 -0
  84. package/dist/phone.d.ts +56 -0
  85. package/dist/phone.js +4 -0
  86. package/dist/postal.cjs +27 -0
  87. package/dist/postal.d.cts +40 -0
  88. package/dist/postal.d.ts +40 -0
  89. package/dist/postal.js +2 -0
  90. package/dist/raast.cjs +20 -0
  91. package/dist/raast.d.cts +119 -0
  92. package/dist/raast.d.ts +119 -0
  93. package/dist/raast.js +3 -0
  94. package/dist/rules-GxgPiVws.d.cts +7 -0
  95. package/dist/rules-GxgPiVws.d.ts +7 -0
  96. package/dist/tax.cjs +20 -0
  97. package/dist/tax.d.cts +47 -0
  98. package/dist/tax.d.ts +47 -0
  99. package/dist/tax.js +3 -0
  100. package/dist/text.cjs +23 -0
  101. package/dist/text.d.cts +34 -0
  102. package/dist/text.d.ts +34 -0
  103. package/dist/text.js +2 -0
  104. package/dist/valibot.cjs +47 -0
  105. package/dist/valibot.d.cts +22 -0
  106. package/dist/valibot.d.ts +22 -0
  107. package/dist/valibot.js +25 -0
  108. package/dist/whatsapp.cjs +12 -0
  109. package/dist/whatsapp.d.cts +12 -0
  110. package/dist/whatsapp.d.ts +12 -0
  111. package/dist/whatsapp.js +3 -0
  112. package/dist/words.cjs +14 -0
  113. package/dist/words.d.cts +49 -0
  114. package/dist/words.d.ts +49 -0
  115. package/dist/words.js +1 -0
  116. package/dist/yup.cjs +32 -0
  117. package/dist/yup.d.cts +22 -0
  118. package/dist/yup.d.ts +22 -0
  119. package/dist/yup.js +30 -0
  120. package/dist/zod.cjs +27 -0
  121. package/dist/zod.d.cts +22 -0
  122. package/dist/zod.d.ts +22 -0
  123. package/dist/zod.js +25 -0
  124. package/package.json +309 -77
  125. package/dist/cli.d.ts +0 -1
  126. package/dist/cli.js.map +0 -1
  127. package/dist/index.js.map +0 -1
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var chunkYS7MOLK2_cjs = require('./chunk-YS7MOLK2.cjs');
4
+ require('./chunk-YLWZGSFY.cjs');
5
+ require('./chunk-VPBMIYO2.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "getNetwork", {
10
+ enumerable: true,
11
+ get: function () { return chunkYS7MOLK2_cjs.getNetwork; }
12
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Original issuing operator for a mobile prefix.
3
+ *
4
+ * `Telenor` is the operator the 034x range was originally allocated to; Telenor
5
+ * Pakistan was merged into PTML (Ufone) in 2026. `SCO` is the Special
6
+ * Communications Organization (0355, serving AJK and Gilgit-Baltistan).
7
+ */
8
+ type NetworkName = 'Jazz' | 'Zong' | 'Telenor' | 'Ufone' | 'SCO' | 'Unknown';
9
+ /**
10
+ * Detects the mobile network for a Pakistani phone number based on its prefix.
11
+ *
12
+ * Returns the network the prefix was originally allocated to. Due to Mobile
13
+ * Number Portability (MNP) and operator mergers, the current carrier may differ.
14
+ *
15
+ * @param phone - The phone number to look up
16
+ * @returns Network name or `"Unknown"` if the number is not a valid Pakistani mobile number
17
+ */
18
+ declare function getNetwork(phone: string): NetworkName;
19
+
20
+ export { type NetworkName, getNetwork };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Original issuing operator for a mobile prefix.
3
+ *
4
+ * `Telenor` is the operator the 034x range was originally allocated to; Telenor
5
+ * Pakistan was merged into PTML (Ufone) in 2026. `SCO` is the Special
6
+ * Communications Organization (0355, serving AJK and Gilgit-Baltistan).
7
+ */
8
+ type NetworkName = 'Jazz' | 'Zong' | 'Telenor' | 'Ufone' | 'SCO' | 'Unknown';
9
+ /**
10
+ * Detects the mobile network for a Pakistani phone number based on its prefix.
11
+ *
12
+ * Returns the network the prefix was originally allocated to. Due to Mobile
13
+ * Number Portability (MNP) and operator mergers, the current carrier may differ.
14
+ *
15
+ * @param phone - The phone number to look up
16
+ * @returns Network name or `"Unknown"` if the number is not a valid Pakistani mobile number
17
+ */
18
+ declare function getNetwork(phone: string): NetworkName;
19
+
20
+ export { type NetworkName, getNetwork };
@@ -0,0 +1,3 @@
1
+ export { getNetwork } from './chunk-L45UXUWX.js';
2
+ import './chunk-Y6BUGLXU.js';
3
+ import './chunk-ENQ7O7VW.js';
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var chunkBSS4Z7NI_cjs = require('./chunk-BSS4Z7NI.cjs');
4
+ require('./chunk-YLWZGSFY.cjs');
5
+ require('./chunk-VPBMIYO2.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "analyzeNumber", {
10
+ enumerable: true,
11
+ get: function () { return chunkBSS4Z7NI_cjs.analyzeNumber; }
12
+ });
13
+ Object.defineProperty(exports, "getAreaCode", {
14
+ enumerable: true,
15
+ get: function () { return chunkBSS4Z7NI_cjs.getAreaCode; }
16
+ });
17
+ Object.defineProperty(exports, "getNumberType", {
18
+ enumerable: true,
19
+ get: function () { return chunkBSS4Z7NI_cjs.getNumberType; }
20
+ });
21
+ Object.defineProperty(exports, "validateLandline", {
22
+ enumerable: true,
23
+ get: function () { return chunkBSS4Z7NI_cjs.validateLandline; }
24
+ });
@@ -0,0 +1,53 @@
1
+ /** Kind of Pakistani telephone number. */
2
+ type NumberType = 'mobile' | 'landline' | 'uan' | 'toll-free' | 'premium' | 'personal';
3
+ /** Result of {@link analyzeNumber}. */
4
+ interface NumberInfo {
5
+ type: NumberType;
6
+ /** National format with trunk prefix and separators, e.g. `021-111-825-888`. */
7
+ formatted: string;
8
+ /** E.164 format, e.g. `+9221111825888`. `null` for a UAN dialled without an area code. */
9
+ e164: string | null;
10
+ /** Area code with trunk prefix (e.g. `021`) for landlines and UANs. */
11
+ areaCode: string | null;
12
+ /** Cities served by the area code, when known. */
13
+ cities: string[];
14
+ }
15
+ /**
16
+ * Identifies and formats any Pakistani telephone number: mobile, landline,
17
+ * UAN (`111`), toll-free (`0800`), premium-rate (`0900`) or personal (`0122`).
18
+ *
19
+ * @example
20
+ * analyzeNumber('021-111-825-888');
21
+ * // { type: 'uan', formatted: '021-111-825-888', e164: '+9221111825888',
22
+ * // areaCode: '021', cities: ['Karachi'] }
23
+ * analyzeNumber('042 35761234');
24
+ * // { type: 'landline', formatted: '042-35761234', e164: '+924235761234',
25
+ * // areaCode: '042', cities: ['Lahore'] }
26
+ *
27
+ * @param phone - Number in local or international format
28
+ * @returns Number details, or `null` if it is not a valid Pakistani number
29
+ */
30
+ declare function analyzeNumber(phone: string): NumberInfo | null;
31
+ /**
32
+ * Returns the type of a Pakistani telephone number. See {@link analyzeNumber}.
33
+ *
34
+ * @param phone - Number in local or international format
35
+ * @returns Number type, or `null` if it is not a valid Pakistani number
36
+ */
37
+ declare function getNumberType(phone: string): NumberType | null;
38
+ /**
39
+ * Validates a Pakistani landline (fixed-line) number such as `042-35761234`.
40
+ *
41
+ * @param phone - Number in local or international format
42
+ * @returns `true` for a valid landline number
43
+ */
44
+ declare function validateLandline(phone: string): boolean;
45
+ /**
46
+ * Returns the landline area code for a city, with trunk prefix (e.g. `"042"`).
47
+ *
48
+ * @param city - City name (case-insensitive)
49
+ * @returns Area code, or `null` if the city is not in the dataset
50
+ */
51
+ declare function getAreaCode(city: string): string | null;
52
+
53
+ export { type NumberInfo, type NumberType, analyzeNumber, getAreaCode, getNumberType, validateLandline };
@@ -0,0 +1,53 @@
1
+ /** Kind of Pakistani telephone number. */
2
+ type NumberType = 'mobile' | 'landline' | 'uan' | 'toll-free' | 'premium' | 'personal';
3
+ /** Result of {@link analyzeNumber}. */
4
+ interface NumberInfo {
5
+ type: NumberType;
6
+ /** National format with trunk prefix and separators, e.g. `021-111-825-888`. */
7
+ formatted: string;
8
+ /** E.164 format, e.g. `+9221111825888`. `null` for a UAN dialled without an area code. */
9
+ e164: string | null;
10
+ /** Area code with trunk prefix (e.g. `021`) for landlines and UANs. */
11
+ areaCode: string | null;
12
+ /** Cities served by the area code, when known. */
13
+ cities: string[];
14
+ }
15
+ /**
16
+ * Identifies and formats any Pakistani telephone number: mobile, landline,
17
+ * UAN (`111`), toll-free (`0800`), premium-rate (`0900`) or personal (`0122`).
18
+ *
19
+ * @example
20
+ * analyzeNumber('021-111-825-888');
21
+ * // { type: 'uan', formatted: '021-111-825-888', e164: '+9221111825888',
22
+ * // areaCode: '021', cities: ['Karachi'] }
23
+ * analyzeNumber('042 35761234');
24
+ * // { type: 'landline', formatted: '042-35761234', e164: '+924235761234',
25
+ * // areaCode: '042', cities: ['Lahore'] }
26
+ *
27
+ * @param phone - Number in local or international format
28
+ * @returns Number details, or `null` if it is not a valid Pakistani number
29
+ */
30
+ declare function analyzeNumber(phone: string): NumberInfo | null;
31
+ /**
32
+ * Returns the type of a Pakistani telephone number. See {@link analyzeNumber}.
33
+ *
34
+ * @param phone - Number in local or international format
35
+ * @returns Number type, or `null` if it is not a valid Pakistani number
36
+ */
37
+ declare function getNumberType(phone: string): NumberType | null;
38
+ /**
39
+ * Validates a Pakistani landline (fixed-line) number such as `042-35761234`.
40
+ *
41
+ * @param phone - Number in local or international format
42
+ * @returns `true` for a valid landline number
43
+ */
44
+ declare function validateLandline(phone: string): boolean;
45
+ /**
46
+ * Returns the landline area code for a city, with trunk prefix (e.g. `"042"`).
47
+ *
48
+ * @param city - City name (case-insensitive)
49
+ * @returns Area code, or `null` if the city is not in the dataset
50
+ */
51
+ declare function getAreaCode(city: string): string | null;
52
+
53
+ export { type NumberInfo, type NumberType, analyzeNumber, getAreaCode, getNumberType, validateLandline };
@@ -0,0 +1,3 @@
1
+ export { analyzeNumber, getAreaCode, getNumberType, validateLandline } from './chunk-T3E4B5MJ.js';
2
+ import './chunk-Y6BUGLXU.js';
3
+ import './chunk-ENQ7O7VW.js';
package/dist/phone.cjs ADDED
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var chunkPHHKIMO2_cjs = require('./chunk-PHHKIMO2.cjs');
4
+ require('./chunk-YS7MOLK2.cjs');
5
+ var chunkYLWZGSFY_cjs = require('./chunk-YLWZGSFY.cjs');
6
+ require('./chunk-VPBMIYO2.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "analyzePhone", {
11
+ enumerable: true,
12
+ get: function () { return chunkPHHKIMO2_cjs.analyzePhone; }
13
+ });
14
+ Object.defineProperty(exports, "formatPhone", {
15
+ enumerable: true,
16
+ get: function () { return chunkPHHKIMO2_cjs.formatPhone; }
17
+ });
18
+ Object.defineProperty(exports, "validatePhone", {
19
+ enumerable: true,
20
+ get: function () { return chunkPHHKIMO2_cjs.validatePhone; }
21
+ });
22
+ Object.defineProperty(exports, "getPhonePrefix", {
23
+ enumerable: true,
24
+ get: function () { return chunkYLWZGSFY_cjs.getPhonePrefix; }
25
+ });
26
+ Object.defineProperty(exports, "normalizePhoneDigits", {
27
+ enumerable: true,
28
+ get: function () { return chunkYLWZGSFY_cjs.normalizePhoneDigits; }
29
+ });
@@ -0,0 +1,56 @@
1
+ import { NetworkName } from './networks.cjs';
2
+
3
+ /**
4
+ * Normalizes a phone string to digits with country code (no leading plus).
5
+ *
6
+ * Accepts local (`0300…`), international (`+92300…`, `0092300…`), short
7
+ * (`300…`) and the common `+92 (0) 300…` / `+920300…` forms, with spaces,
8
+ * dashes, dots, slashes or parentheses, and Urdu or Arabic-Indic digits.
9
+ *
10
+ * Returns `null` when the input is not a Pakistani mobile number on an
11
+ * allocated `03XX` prefix.
12
+ */
13
+ declare function normalizePhoneDigits(phone: string): string | null;
14
+ /**
15
+ * Returns the local Pakistani mobile prefix (`0XXX`) from a phone number.
16
+ * Returns `null` when the phone cannot be normalized.
17
+ */
18
+ declare function getPhonePrefix(phone: string): string | null;
19
+
20
+ /** Combined phone validation, formatting, and network analysis result. */
21
+ interface PhoneAnalysis {
22
+ valid: boolean;
23
+ formatted: string | null;
24
+ network: NetworkName;
25
+ }
26
+ /**
27
+ * Validates a Pakistani mobile phone number.
28
+ *
29
+ * Accepts local (`03001234567`), international (`+923001234567`, `+92 (0) 300…`),
30
+ * and short (`3001234567`) formats, with common separators and Urdu digits.
31
+ * The `03XX` prefix must be allocated to a mobile operator.
32
+ *
33
+ * @param phone - The phone number string to validate
34
+ * @returns `true` if valid, otherwise `false`
35
+ */
36
+ declare function validatePhone(phone: string): boolean;
37
+ /**
38
+ * Formats a Pakistani mobile number to international E.164 style (`+923001234567`).
39
+ *
40
+ * @param phone - The phone number string to format
41
+ * @returns Formatted phone number, or `null` if invalid
42
+ */
43
+ declare function formatPhone(phone: string): string | null;
44
+
45
+ /**
46
+ * Analyzes a Pakistani mobile number in a single call.
47
+ *
48
+ * Combines validation, E.164 formatting, and network detection.
49
+ * Invalid numbers return `{ valid: false, formatted: null, network: "Unknown" }`.
50
+ *
51
+ * @param phone - Phone number in any supported format
52
+ * @returns Structured phone analysis result
53
+ */
54
+ declare function analyzePhone(phone: string): PhoneAnalysis;
55
+
56
+ export { NetworkName, type PhoneAnalysis, analyzePhone, formatPhone, getPhonePrefix, normalizePhoneDigits, validatePhone };
@@ -0,0 +1,56 @@
1
+ import { NetworkName } from './networks.js';
2
+
3
+ /**
4
+ * Normalizes a phone string to digits with country code (no leading plus).
5
+ *
6
+ * Accepts local (`0300…`), international (`+92300…`, `0092300…`), short
7
+ * (`300…`) and the common `+92 (0) 300…` / `+920300…` forms, with spaces,
8
+ * dashes, dots, slashes or parentheses, and Urdu or Arabic-Indic digits.
9
+ *
10
+ * Returns `null` when the input is not a Pakistani mobile number on an
11
+ * allocated `03XX` prefix.
12
+ */
13
+ declare function normalizePhoneDigits(phone: string): string | null;
14
+ /**
15
+ * Returns the local Pakistani mobile prefix (`0XXX`) from a phone number.
16
+ * Returns `null` when the phone cannot be normalized.
17
+ */
18
+ declare function getPhonePrefix(phone: string): string | null;
19
+
20
+ /** Combined phone validation, formatting, and network analysis result. */
21
+ interface PhoneAnalysis {
22
+ valid: boolean;
23
+ formatted: string | null;
24
+ network: NetworkName;
25
+ }
26
+ /**
27
+ * Validates a Pakistani mobile phone number.
28
+ *
29
+ * Accepts local (`03001234567`), international (`+923001234567`, `+92 (0) 300…`),
30
+ * and short (`3001234567`) formats, with common separators and Urdu digits.
31
+ * The `03XX` prefix must be allocated to a mobile operator.
32
+ *
33
+ * @param phone - The phone number string to validate
34
+ * @returns `true` if valid, otherwise `false`
35
+ */
36
+ declare function validatePhone(phone: string): boolean;
37
+ /**
38
+ * Formats a Pakistani mobile number to international E.164 style (`+923001234567`).
39
+ *
40
+ * @param phone - The phone number string to format
41
+ * @returns Formatted phone number, or `null` if invalid
42
+ */
43
+ declare function formatPhone(phone: string): string | null;
44
+
45
+ /**
46
+ * Analyzes a Pakistani mobile number in a single call.
47
+ *
48
+ * Combines validation, E.164 formatting, and network detection.
49
+ * Invalid numbers return `{ valid: false, formatted: null, network: "Unknown" }`.
50
+ *
51
+ * @param phone - Phone number in any supported format
52
+ * @returns Structured phone analysis result
53
+ */
54
+ declare function analyzePhone(phone: string): PhoneAnalysis;
55
+
56
+ export { NetworkName, type PhoneAnalysis, analyzePhone, formatPhone, getPhonePrefix, normalizePhoneDigits, validatePhone };
package/dist/phone.js ADDED
@@ -0,0 +1,4 @@
1
+ export { analyzePhone, formatPhone, validatePhone } from './chunk-432ZYMYV.js';
2
+ import './chunk-L45UXUWX.js';
3
+ export { getPhonePrefix, normalizePhoneDigits } from './chunk-Y6BUGLXU.js';
4
+ import './chunk-ENQ7O7VW.js';
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var chunk4VVFS6FN_cjs = require('./chunk-4VVFS6FN.cjs');
4
+ require('./chunk-VPBMIYO2.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "getCityByPostalCode", {
9
+ enumerable: true,
10
+ get: function () { return chunk4VVFS6FN_cjs.getCityByPostalCode; }
11
+ });
12
+ Object.defineProperty(exports, "getPostalAreas", {
13
+ enumerable: true,
14
+ get: function () { return chunk4VVFS6FN_cjs.getPostalAreas; }
15
+ });
16
+ Object.defineProperty(exports, "getPostalCode", {
17
+ enumerable: true,
18
+ get: function () { return chunk4VVFS6FN_cjs.getPostalCode; }
19
+ });
20
+ Object.defineProperty(exports, "getPostalCodes", {
21
+ enumerable: true,
22
+ get: function () { return chunk4VVFS6FN_cjs.getPostalCodes; }
23
+ });
24
+ Object.defineProperty(exports, "searchPostalCodes", {
25
+ enumerable: true,
26
+ get: function () { return chunk4VVFS6FN_cjs.searchPostalCodes; }
27
+ });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Returns the city name for a Pakistani postal code.
3
+ *
4
+ * @param postalCode - Postal code to look up (whitespace is ignored)
5
+ * @returns City name or `null` if not found
6
+ */
7
+ declare function getCityByPostalCode(postalCode: string): string | null;
8
+ /**
9
+ * Returns the primary postal code for a Pakistani city.
10
+ *
11
+ * Matching is case-insensitive and whitespace-tolerant.
12
+ * When multiple postal codes exist, returns the primary GPO code.
13
+ *
14
+ * @param city - City name to look up
15
+ * @returns Postal code or `null` if not found
16
+ */
17
+ declare function getPostalCode(city: string): string | null;
18
+ /**
19
+ * Returns all known postal codes for a city (case-insensitive).
20
+ *
21
+ * @param city - City name to look up
22
+ * @returns Alphabetically sorted postal codes
23
+ */
24
+ declare function getPostalCodes(city: string): string[];
25
+ /**
26
+ * Searches postal entries by city name, area, or postal code prefix.
27
+ *
28
+ * @param query - Partial search term
29
+ * @returns Matching postal code strings, sorted alphabetically
30
+ */
31
+ declare function searchPostalCodes(query: string): string[];
32
+ /**
33
+ * Returns known area names for a city's postal entries.
34
+ *
35
+ * @param city - City name to look up
36
+ * @returns Alphabetically sorted area names
37
+ */
38
+ declare function getPostalAreas(city: string): string[];
39
+
40
+ export { getCityByPostalCode, getPostalAreas, getPostalCode, getPostalCodes, searchPostalCodes };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Returns the city name for a Pakistani postal code.
3
+ *
4
+ * @param postalCode - Postal code to look up (whitespace is ignored)
5
+ * @returns City name or `null` if not found
6
+ */
7
+ declare function getCityByPostalCode(postalCode: string): string | null;
8
+ /**
9
+ * Returns the primary postal code for a Pakistani city.
10
+ *
11
+ * Matching is case-insensitive and whitespace-tolerant.
12
+ * When multiple postal codes exist, returns the primary GPO code.
13
+ *
14
+ * @param city - City name to look up
15
+ * @returns Postal code or `null` if not found
16
+ */
17
+ declare function getPostalCode(city: string): string | null;
18
+ /**
19
+ * Returns all known postal codes for a city (case-insensitive).
20
+ *
21
+ * @param city - City name to look up
22
+ * @returns Alphabetically sorted postal codes
23
+ */
24
+ declare function getPostalCodes(city: string): string[];
25
+ /**
26
+ * Searches postal entries by city name, area, or postal code prefix.
27
+ *
28
+ * @param query - Partial search term
29
+ * @returns Matching postal code strings, sorted alphabetically
30
+ */
31
+ declare function searchPostalCodes(query: string): string[];
32
+ /**
33
+ * Returns known area names for a city's postal entries.
34
+ *
35
+ * @param city - City name to look up
36
+ * @returns Alphabetically sorted area names
37
+ */
38
+ declare function getPostalAreas(city: string): string[];
39
+
40
+ export { getCityByPostalCode, getPostalAreas, getPostalCode, getPostalCodes, searchPostalCodes };
package/dist/postal.js ADDED
@@ -0,0 +1,2 @@
1
+ export { getCityByPostalCode, getPostalAreas, getPostalCode, getPostalCodes, searchPostalCodes } from './chunk-LIYNKIKS.js';
2
+ import './chunk-ENQ7O7VW.js';
package/dist/raast.cjs ADDED
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var chunkWPKV5JT3_cjs = require('./chunk-WPKV5JT3.cjs');
4
+ require('./chunk-422X6FEZ.cjs');
5
+ require('./chunk-VPBMIYO2.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "createMerchantQr", {
10
+ enumerable: true,
11
+ get: function () { return chunkWPKV5JT3_cjs.createMerchantQr; }
12
+ });
13
+ Object.defineProperty(exports, "createRaastP2PQr", {
14
+ enumerable: true,
15
+ get: function () { return chunkWPKV5JT3_cjs.createRaastP2PQr; }
16
+ });
17
+ Object.defineProperty(exports, "parseRaastQr", {
18
+ enumerable: true,
19
+ get: function () { return chunkWPKV5JT3_cjs.parseRaastQr; }
20
+ });
@@ -0,0 +1,119 @@
1
+ /**
2
+ * EMVCo Merchant-Presented QR (MPM) encoding: a flat list of
3
+ * `ID (2 digits) + length (2 digits) + value` fields, some of which are
4
+ * templates containing nested fields, ending with a CRC in field 63.
5
+ */
6
+ /** A parsed EMV field. `children` is set for template fields. */
7
+ interface EmvField {
8
+ id: string;
9
+ value: string;
10
+ children?: EmvField[];
11
+ }
12
+
13
+ /** Options for {@link createRaastP2PQr}. */
14
+ interface RaastP2PQrOptions {
15
+ /** Payee's Pakistani IBAN. */
16
+ iban: string;
17
+ /** Amount in PKR. When set, the QR is dynamic (point of initiation 12). */
18
+ amount?: number;
19
+ /** Payee's bank name (up to 25 characters). */
20
+ bankName?: string;
21
+ /** Payment description (up to 30 characters). */
22
+ particulars?: string;
23
+ }
24
+ /** Account details for a merchant QR, as issued by the merchant's bank. */
25
+ interface MerchantAccountInfo {
26
+ /** Template tag. SBP reserves `28`–`30` for Raast. Defaults to `28`. */
27
+ tag?: string;
28
+ /** Sub-fields of the template, keyed by 2-digit ID, in the order given. */
29
+ fields: Record<string, string>;
30
+ }
31
+ /** Options for {@link createMerchantQr}. */
32
+ interface MerchantQrOptions {
33
+ /** Raast merchant account template. Its sub-fields are defined by the bank. */
34
+ merchantAccount: MerchantAccountInfo;
35
+ /** Merchant name (up to 25 characters). */
36
+ merchantName: string;
37
+ /** Merchant city (up to 15 characters). */
38
+ city: string;
39
+ /** ISO 18245 merchant category code. Defaults to `0000`. */
40
+ mcc?: string;
41
+ /** Amount in PKR. When set, the QR is dynamic unless `dynamic` is `false`. */
42
+ amount?: number;
43
+ /** Overrides the point of initiation (static `11` / dynamic `12`). */
44
+ dynamic?: boolean;
45
+ /** Bill or invoice number (tag 62-01, up to 25 characters). */
46
+ billNumber?: string;
47
+ /** Customer mobile number (tag 62-02, up to 15 characters). */
48
+ mobileNumber?: string;
49
+ /** Reference label (tag 62-05, up to 25 characters). */
50
+ reference?: string;
51
+ /** Payment due date (Pakistan-specific tag 62-50). Requires `amountAfterDueDate`. */
52
+ dueDate?: Date;
53
+ /** Amount payable after the due date (Pakistan-specific tag 62-51). */
54
+ amountAfterDueDate?: number;
55
+ }
56
+ /** Result of {@link parseRaastQr}. */
57
+ interface ParsedRaastQr {
58
+ /** `p2p` for person-to-person QR codes, `merchant` for EMVCo merchant QR codes. */
59
+ kind: 'p2p' | 'merchant';
60
+ /** Whether the QR carries a fixed amount (point of initiation 12). */
61
+ dynamic: boolean;
62
+ /** Whether the CRC checksum matches. */
63
+ crcValid: boolean;
64
+ /** Payee IBAN, if one is present. */
65
+ iban: string | null;
66
+ /** Whether `iban` passes the IBAN checksum. */
67
+ ibanValid: boolean;
68
+ amount: number | null;
69
+ /** P2P: bank name. */
70
+ bankName: string | null;
71
+ /** P2P: payment description. */
72
+ particulars: string | null;
73
+ merchantName: string | null;
74
+ city: string | null;
75
+ mcc: string | null;
76
+ billNumber: string | null;
77
+ /** Due date as `YYYY-MM-DD`. */
78
+ dueDate: string | null;
79
+ amountAfterDueDate: number | null;
80
+ /** All top-level fields, with template fields parsed into `children`. */
81
+ fields: EmvField[];
82
+ }
83
+ /**
84
+ * Creates a Raast person-to-person QR payload, following SBP's P2P QR format
85
+ * (payload format `02`, scheme `30`). Encode the string as a QR code with any
86
+ * QR library.
87
+ *
88
+ * @example
89
+ * createRaastP2PQr({ iban: 'PK36SCBL0000001123456702', amount: 1500 });
90
+ *
91
+ * @param options - Payee IBAN and optional amount, bank name and description
92
+ * @returns QR payload string
93
+ * @throws {RangeError} If the IBAN is invalid or a field is too long
94
+ */
95
+ declare function createRaastP2PQr(options: RaastP2PQrOptions): string;
96
+ /**
97
+ * Creates an EMVCo merchant-presented QR payload following SBP's Pakistan QR
98
+ * standard (currency `586`, country `PK`, CRC in tag 63), including the
99
+ * Pakistan-specific due-date fields.
100
+ *
101
+ * SBP leaves the layout of the Raast merchant account template to the scheme
102
+ * and has shared it only with banks, so pass the template sub-fields your bank
103
+ * gives you in `merchantAccount`.
104
+ *
105
+ * @param options - Merchant account template, name, city and payment details
106
+ * @returns QR payload string
107
+ * @throws {RangeError} If a field is missing, too long, or out of range
108
+ */
109
+ declare function createMerchantQr(options: MerchantQrOptions): string;
110
+ /**
111
+ * Parses a Raast QR payload: either a person-to-person QR (payload format
112
+ * `02`) or an EMVCo merchant QR (payload format `01`), and verifies its CRC.
113
+ *
114
+ * @param payload - Text decoded from the QR code
115
+ * @returns Parsed details, or `null` if the payload is not a well-formed Pakistani QR code
116
+ */
117
+ declare function parseRaastQr(payload: string): ParsedRaastQr | null;
118
+
119
+ export { type MerchantAccountInfo, type MerchantQrOptions, type ParsedRaastQr, type RaastP2PQrOptions, createMerchantQr, createRaastP2PQr, parseRaastQr };