pakdatakit 1.1.0 → 2.1.1
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 -21
- package/README.md +909 -666
- package/dist/address.cjs +17 -0
- package/dist/address.d.cts +36 -0
- package/dist/address.d.ts +36 -0
- package/dist/address.js +4 -0
- package/dist/chunk-3COX5FSL.cjs +1650 -0
- package/dist/chunk-432ZYMYV.js +31 -0
- package/dist/chunk-43ULDYUP.cjs +235 -0
- package/dist/chunk-44YRK7WO.js +231 -0
- package/dist/chunk-4EUKCSLW.js +221 -0
- package/dist/chunk-4VVFS6FN.cjs +715 -0
- package/dist/chunk-6TSKA2PH.js +38 -0
- package/dist/chunk-APXP7OK7.cjs +226 -0
- package/dist/chunk-AUATLZA5.cjs +168 -0
- package/dist/chunk-BSS4Z7NI.cjs +422 -0
- package/dist/chunk-CEPNSHIC.js +33 -0
- package/dist/chunk-CYJJ7KGC.cjs +108 -0
- package/dist/chunk-E47SNBWQ.cjs +224 -0
- package/dist/chunk-E7GAK72W.js +20 -0
- package/dist/chunk-EEVNLTB4.js +32 -0
- package/dist/chunk-ENQ7O7VW.js +32 -0
- package/dist/chunk-H6M6L26S.cjs +37 -0
- package/dist/chunk-HBOZIITD.js +351 -0
- package/dist/chunk-HTCSHHOR.cjs +35 -0
- package/dist/chunk-JKE4AMSZ.js +47 -0
- package/dist/chunk-JNP27XW2.cjs +22 -0
- package/dist/chunk-K6CZFCX6.js +1642 -0
- package/dist/chunk-KEHCTYLO.cjs +52 -0
- package/dist/chunk-KQKW2ZEK.cjs +18 -0
- package/dist/chunk-L2BDDM2W.js +165 -0
- package/dist/chunk-L45UXUWX.js +21 -0
- package/dist/chunk-LIYNKIKS.js +709 -0
- package/dist/chunk-LVHTH4P7.cjs +41 -0
- package/dist/chunk-P4CGOJEM.js +16 -0
- package/dist/chunk-PHHKIMO2.cjs +35 -0
- package/dist/chunk-QQQKISXT.js +223 -0
- package/dist/chunk-T3E4B5MJ.js +417 -0
- package/dist/chunk-VPBMIYO2.cjs +38 -0
- package/dist/chunk-XCXFGTHW.cjs +355 -0
- package/dist/chunk-Y6BUGLXU.js +95 -0
- package/dist/chunk-YLWZGSFY.cjs +99 -0
- package/dist/chunk-YS7MOLK2.cjs +23 -0
- package/dist/chunk-Z5JEIQVW.js +102 -0
- package/dist/cli.js +78 -2654
- package/dist/cnic.cjs +15 -0
- package/dist/cnic.d.cts +35 -0
- package/dist/cnic.d.ts +35 -0
- package/dist/cnic.js +2 -0
- package/dist/format.cjs +14 -0
- package/dist/format.d.cts +27 -0
- package/dist/format.d.ts +27 -0
- package/dist/format.js +1 -0
- package/dist/geo.cjs +27 -0
- package/dist/geo.d.cts +43 -0
- package/dist/geo.d.ts +43 -0
- package/dist/geo.js +2 -0
- package/dist/hijri.cjs +26 -0
- package/dist/hijri.d.cts +62 -0
- package/dist/hijri.d.ts +62 -0
- package/dist/hijri.js +1 -0
- package/dist/holidays.cjs +19 -0
- package/dist/holidays.d.cts +72 -0
- package/dist/holidays.d.ts +72 -0
- package/dist/holidays.js +2 -0
- package/dist/iban.cjs +15 -0
- package/dist/iban.d.cts +21 -0
- package/dist/iban.d.ts +21 -0
- package/dist/iban.js +2 -0
- package/dist/index.cjs +211 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -300
- package/dist/index.js +18 -2764
- package/dist/networks.cjs +12 -0
- package/dist/networks.d.cts +20 -0
- package/dist/networks.d.ts +20 -0
- package/dist/networks.js +3 -0
- package/dist/numbers.cjs +24 -0
- package/dist/numbers.d.cts +53 -0
- package/dist/numbers.d.ts +53 -0
- package/dist/numbers.js +3 -0
- package/dist/phone.cjs +29 -0
- package/dist/phone.d.cts +56 -0
- package/dist/phone.d.ts +56 -0
- package/dist/phone.js +4 -0
- package/dist/postal.cjs +27 -0
- package/dist/postal.d.cts +40 -0
- package/dist/postal.d.ts +40 -0
- package/dist/postal.js +2 -0
- package/dist/raast.cjs +20 -0
- package/dist/raast.d.cts +125 -0
- package/dist/raast.d.ts +125 -0
- package/dist/raast.js +3 -0
- package/dist/rules-GxgPiVws.d.cts +7 -0
- package/dist/rules-GxgPiVws.d.ts +7 -0
- package/dist/tax.cjs +20 -0
- package/dist/tax.d.cts +47 -0
- package/dist/tax.d.ts +47 -0
- package/dist/tax.js +3 -0
- package/dist/text.cjs +23 -0
- package/dist/text.d.cts +34 -0
- package/dist/text.d.ts +34 -0
- package/dist/text.js +2 -0
- package/dist/valibot.cjs +47 -0
- package/dist/valibot.d.cts +22 -0
- package/dist/valibot.d.ts +22 -0
- package/dist/valibot.js +25 -0
- package/dist/whatsapp.cjs +12 -0
- package/dist/whatsapp.d.cts +12 -0
- package/dist/whatsapp.d.ts +12 -0
- package/dist/whatsapp.js +3 -0
- package/dist/words.cjs +14 -0
- package/dist/words.d.cts +49 -0
- package/dist/words.d.ts +49 -0
- package/dist/words.js +1 -0
- package/dist/yup.cjs +32 -0
- package/dist/yup.d.cts +22 -0
- package/dist/yup.d.ts +22 -0
- package/dist/yup.js +30 -0
- package/dist/zod.cjs +27 -0
- package/dist/zod.d.cts +22 -0
- package/dist/zod.d.ts +22 -0
- package/dist/zod.js +25 -0
- package/package.json +309 -77
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js.map +0 -1
- 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 };
|
package/dist/networks.js
ADDED
package/dist/numbers.cjs
ADDED
|
@@ -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 };
|
package/dist/numbers.js
ADDED
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
|
+
});
|
package/dist/phone.d.cts
ADDED
|
@@ -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 };
|
package/dist/phone.d.ts
ADDED
|
@@ -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
package/dist/postal.cjs
ADDED
|
@@ -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 };
|
package/dist/postal.d.ts
ADDED
|
@@ -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
package/dist/raast.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk43ULDYUP_cjs = require('./chunk-43ULDYUP.cjs');
|
|
4
|
+
require('./chunk-E47SNBWQ.cjs');
|
|
5
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "createMerchantQr", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunk43ULDYUP_cjs.createMerchantQr; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "createRaastP2PQr", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunk43ULDYUP_cjs.createRaastP2PQr; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "parseRaastQr", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunk43ULDYUP_cjs.parseRaastQr; }
|
|
20
|
+
});
|
package/dist/raast.d.cts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Scheme identifier (tag 02). Defaults to `'00'`, as used by banking apps.
|
|
19
|
+
* `'30'` is the value listed for Raast in SBP's QR standard.
|
|
20
|
+
*/
|
|
21
|
+
scheme?: '00' | '30';
|
|
22
|
+
/** Amount in PKR. When set, the QR is dynamic (point of initiation 12). */
|
|
23
|
+
amount?: number;
|
|
24
|
+
/** Payee's bank name (up to 25 characters). */
|
|
25
|
+
bankName?: string;
|
|
26
|
+
/** Payment description (up to 30 characters). */
|
|
27
|
+
particulars?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Account details for a merchant QR, as issued by the merchant's bank. */
|
|
30
|
+
interface MerchantAccountInfo {
|
|
31
|
+
/** Template tag. SBP reserves `28`–`30` for Raast. Defaults to `28`. */
|
|
32
|
+
tag?: string;
|
|
33
|
+
/** Sub-fields of the template, keyed by 2-digit ID, in the order given. */
|
|
34
|
+
fields: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
/** Options for {@link createMerchantQr}. */
|
|
37
|
+
interface MerchantQrOptions {
|
|
38
|
+
/** Raast merchant account template. Its sub-fields are defined by the bank. */
|
|
39
|
+
merchantAccount: MerchantAccountInfo;
|
|
40
|
+
/** Merchant name (up to 25 characters). */
|
|
41
|
+
merchantName: string;
|
|
42
|
+
/** Merchant city (up to 15 characters). */
|
|
43
|
+
city: string;
|
|
44
|
+
/** ISO 18245 merchant category code. Defaults to `0000`. */
|
|
45
|
+
mcc?: string;
|
|
46
|
+
/** Amount in PKR. When set, the QR is dynamic unless `dynamic` is `false`. */
|
|
47
|
+
amount?: number;
|
|
48
|
+
/** Overrides the point of initiation (static `11` / dynamic `12`). */
|
|
49
|
+
dynamic?: boolean;
|
|
50
|
+
/** Bill or invoice number (tag 62-01, up to 25 characters). */
|
|
51
|
+
billNumber?: string;
|
|
52
|
+
/** Customer mobile number (tag 62-02, up to 15 characters). */
|
|
53
|
+
mobileNumber?: string;
|
|
54
|
+
/** Reference label (tag 62-05, up to 25 characters). */
|
|
55
|
+
reference?: string;
|
|
56
|
+
/** Payment due date (Pakistan-specific tag 62-50). Requires `amountAfterDueDate`. */
|
|
57
|
+
dueDate?: Date;
|
|
58
|
+
/** Amount payable after the due date (Pakistan-specific tag 62-51). */
|
|
59
|
+
amountAfterDueDate?: number;
|
|
60
|
+
}
|
|
61
|
+
/** Result of {@link parseRaastQr}. */
|
|
62
|
+
interface ParsedRaastQr {
|
|
63
|
+
/** `p2p` for person-to-person QR codes, `merchant` for EMVCo merchant QR codes. */
|
|
64
|
+
kind: 'p2p' | 'merchant';
|
|
65
|
+
/** Whether the QR carries a fixed amount (point of initiation 12). */
|
|
66
|
+
dynamic: boolean;
|
|
67
|
+
/** Whether the CRC checksum matches. */
|
|
68
|
+
crcValid: boolean;
|
|
69
|
+
/** Payee IBAN, if one is present. */
|
|
70
|
+
iban: string | null;
|
|
71
|
+
/** Whether `iban` passes the IBAN checksum. */
|
|
72
|
+
ibanValid: boolean;
|
|
73
|
+
amount: number | null;
|
|
74
|
+
/** P2P: bank name. */
|
|
75
|
+
bankName: string | null;
|
|
76
|
+
/** P2P: payment description. */
|
|
77
|
+
particulars: string | null;
|
|
78
|
+
merchantName: string | null;
|
|
79
|
+
city: string | null;
|
|
80
|
+
mcc: string | null;
|
|
81
|
+
billNumber: string | null;
|
|
82
|
+
/** Due date as `YYYY-MM-DD`. */
|
|
83
|
+
dueDate: string | null;
|
|
84
|
+
amountAfterDueDate: number | null;
|
|
85
|
+
/** All top-level fields, with template fields parsed into `children`. */
|
|
86
|
+
fields: EmvField[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates a Raast person-to-person QR payload in SBP's P2P QR format (payload
|
|
90
|
+
* format `02`), matching the QR codes banking apps generate, so it can be
|
|
91
|
+
* scanned by apps such as Easypaisa and JazzCash. Encode the string as a QR
|
|
92
|
+
* code with any QR library.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* createRaastP2PQr({ iban: 'PK36SCBL0000001123456702', amount: 1500 });
|
|
96
|
+
*
|
|
97
|
+
* @param options - Payee IBAN and optional amount, bank name and description
|
|
98
|
+
* @returns QR payload string
|
|
99
|
+
* @throws {RangeError} If the IBAN is invalid or a field is too long
|
|
100
|
+
*/
|
|
101
|
+
declare function createRaastP2PQr(options: RaastP2PQrOptions): string;
|
|
102
|
+
/**
|
|
103
|
+
* Creates an EMVCo merchant-presented QR payload following SBP's Pakistan QR
|
|
104
|
+
* standard (currency `586`, country `PK`, CRC in tag 63), including the
|
|
105
|
+
* Pakistan-specific due-date fields.
|
|
106
|
+
*
|
|
107
|
+
* SBP leaves the layout of the Raast merchant account template to the scheme
|
|
108
|
+
* and has shared it only with banks, so pass the template sub-fields your bank
|
|
109
|
+
* gives you in `merchantAccount`.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Merchant account template, name, city and payment details
|
|
112
|
+
* @returns QR payload string
|
|
113
|
+
* @throws {RangeError} If a field is missing, too long, or out of range
|
|
114
|
+
*/
|
|
115
|
+
declare function createMerchantQr(options: MerchantQrOptions): string;
|
|
116
|
+
/**
|
|
117
|
+
* Parses a Raast QR payload: either a person-to-person QR (payload format
|
|
118
|
+
* `02`) or an EMVCo merchant QR (payload format `01`), and verifies its CRC.
|
|
119
|
+
*
|
|
120
|
+
* @param payload - Text decoded from the QR code
|
|
121
|
+
* @returns Parsed details, or `null` if the payload is not a well-formed Pakistani QR code
|
|
122
|
+
*/
|
|
123
|
+
declare function parseRaastQr(payload: string): ParsedRaastQr | null;
|
|
124
|
+
|
|
125
|
+
export { type MerchantAccountInfo, type MerchantQrOptions, type ParsedRaastQr, type RaastP2PQrOptions, createMerchantQr, createRaastP2PQr, parseRaastQr };
|