pakdatakit 1.0.2 → 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.
- package/LICENSE +21 -21
- package/README.md +907 -597
- 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-422X6FEZ.cjs +220 -0
- package/dist/chunk-432ZYMYV.js +31 -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-CQKK3S7A.js +217 -0
- package/dist/chunk-CYJJ7KGC.cjs +108 -0
- package/dist/chunk-EEVNLTB4.js +32 -0
- package/dist/chunk-ENQ7O7VW.js +32 -0
- package/dist/chunk-H4DVWUYH.js +231 -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-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-OVUR47QH.cjs +22 -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-WPKV5JT3.cjs +235 -0
- package/dist/chunk-XCXFGTHW.cjs +355 -0
- package/dist/chunk-XT4ZNXRC.js +20 -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 +129 -0
- 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 -190
- package/dist/index.js +18 -2465
- 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 +119 -0
- package/dist/raast.d.ts +119 -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 -69
- package/dist/index.js.map +0 -1
package/dist/raast.d.ts
ADDED
|
@@ -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 };
|
package/dist/raast.js
ADDED
package/dist/tax.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkH6M6L26S_cjs = require('./chunk-H6M6L26S.cjs');
|
|
4
|
+
require('./chunk-HTCSHHOR.cjs');
|
|
5
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "analyzeNTN", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkH6M6L26S_cjs.analyzeNTN; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "validateNTN", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkH6M6L26S_cjs.validateNTN; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "validateSTRN", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkH6M6L26S_cjs.validateSTRN; }
|
|
20
|
+
});
|
package/dist/tax.d.cts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Kind of taxpayer an NTN belongs to. */
|
|
2
|
+
type NTNType = 'individual' | 'business';
|
|
3
|
+
/** Result of {@link analyzeNTN}. */
|
|
4
|
+
interface NTNInfo {
|
|
5
|
+
/** `individual` when the NTN is a CNIC; `business` for a 7-digit company/AOP NTN. */
|
|
6
|
+
type: NTNType;
|
|
7
|
+
/** Digits without separators (7, 8 or 13 digits). */
|
|
8
|
+
digits: string;
|
|
9
|
+
/** Display form: `1234567-8` for business NTNs with a check digit, `#####-#######-#` for CNICs. */
|
|
10
|
+
formatted: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Analyzes a Pakistani National Tax Number (NTN).
|
|
14
|
+
*
|
|
15
|
+
* - Individuals use their 13-digit CNIC as their NTN (since the Finance Act 2015).
|
|
16
|
+
* - Companies and associations of persons have a 7-digit NTN, often written
|
|
17
|
+
* with an 8th check digit as `1234567-8`.
|
|
18
|
+
*
|
|
19
|
+
* FBR does not publish the check-digit algorithm, so the check digit is not
|
|
20
|
+
* verified; this validates the format only.
|
|
21
|
+
*
|
|
22
|
+
* @param ntn - NTN in any common format
|
|
23
|
+
* @returns NTN details, or `null` if the format is invalid
|
|
24
|
+
*/
|
|
25
|
+
declare function analyzeNTN(ntn: string): NTNInfo | null;
|
|
26
|
+
/**
|
|
27
|
+
* Validates the format of a Pakistani National Tax Number (NTN): a CNIC for
|
|
28
|
+
* individuals, or 7 digits (optionally followed by a check digit) for
|
|
29
|
+
* businesses. See {@link analyzeNTN}.
|
|
30
|
+
*
|
|
31
|
+
* @param ntn - NTN to validate
|
|
32
|
+
* @returns `true` if the format is valid
|
|
33
|
+
*/
|
|
34
|
+
declare function validateNTN(ntn: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Validates the format of a Sales Tax Registration Number (STRN): 13 digits,
|
|
37
|
+
* with optional spaces or dashes.
|
|
38
|
+
*
|
|
39
|
+
* FBR does not publish a check-digit algorithm or the meaning of the digit
|
|
40
|
+
* groups, so this validates the format only.
|
|
41
|
+
*
|
|
42
|
+
* @param strn - STRN to validate
|
|
43
|
+
* @returns `true` if the format is valid
|
|
44
|
+
*/
|
|
45
|
+
declare function validateSTRN(strn: string): boolean;
|
|
46
|
+
|
|
47
|
+
export { type NTNInfo, type NTNType, analyzeNTN, validateNTN, validateSTRN };
|
package/dist/tax.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Kind of taxpayer an NTN belongs to. */
|
|
2
|
+
type NTNType = 'individual' | 'business';
|
|
3
|
+
/** Result of {@link analyzeNTN}. */
|
|
4
|
+
interface NTNInfo {
|
|
5
|
+
/** `individual` when the NTN is a CNIC; `business` for a 7-digit company/AOP NTN. */
|
|
6
|
+
type: NTNType;
|
|
7
|
+
/** Digits without separators (7, 8 or 13 digits). */
|
|
8
|
+
digits: string;
|
|
9
|
+
/** Display form: `1234567-8` for business NTNs with a check digit, `#####-#######-#` for CNICs. */
|
|
10
|
+
formatted: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Analyzes a Pakistani National Tax Number (NTN).
|
|
14
|
+
*
|
|
15
|
+
* - Individuals use their 13-digit CNIC as their NTN (since the Finance Act 2015).
|
|
16
|
+
* - Companies and associations of persons have a 7-digit NTN, often written
|
|
17
|
+
* with an 8th check digit as `1234567-8`.
|
|
18
|
+
*
|
|
19
|
+
* FBR does not publish the check-digit algorithm, so the check digit is not
|
|
20
|
+
* verified; this validates the format only.
|
|
21
|
+
*
|
|
22
|
+
* @param ntn - NTN in any common format
|
|
23
|
+
* @returns NTN details, or `null` if the format is invalid
|
|
24
|
+
*/
|
|
25
|
+
declare function analyzeNTN(ntn: string): NTNInfo | null;
|
|
26
|
+
/**
|
|
27
|
+
* Validates the format of a Pakistani National Tax Number (NTN): a CNIC for
|
|
28
|
+
* individuals, or 7 digits (optionally followed by a check digit) for
|
|
29
|
+
* businesses. See {@link analyzeNTN}.
|
|
30
|
+
*
|
|
31
|
+
* @param ntn - NTN to validate
|
|
32
|
+
* @returns `true` if the format is valid
|
|
33
|
+
*/
|
|
34
|
+
declare function validateNTN(ntn: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Validates the format of a Sales Tax Registration Number (STRN): 13 digits,
|
|
37
|
+
* with optional spaces or dashes.
|
|
38
|
+
*
|
|
39
|
+
* FBR does not publish a check-digit algorithm or the meaning of the digit
|
|
40
|
+
* groups, so this validates the format only.
|
|
41
|
+
*
|
|
42
|
+
* @param strn - STRN to validate
|
|
43
|
+
* @returns `true` if the format is valid
|
|
44
|
+
*/
|
|
45
|
+
declare function validateSTRN(strn: string): boolean;
|
|
46
|
+
|
|
47
|
+
export { type NTNInfo, type NTNType, analyzeNTN, validateNTN, validateSTRN };
|
package/dist/tax.js
ADDED
package/dist/text.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKEHCTYLO_cjs = require('./chunk-KEHCTYLO.cjs');
|
|
4
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "normalizeRomanUrdu", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkKEHCTYLO_cjs.normalizeRomanUrdu; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "normalizeText", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkKEHCTYLO_cjs.normalizeText; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "toEnglishDigits", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkKEHCTYLO_cjs.toEnglishDigits; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "toUrduDigits", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkKEHCTYLO_cjs.toUrduDigits; }
|
|
23
|
+
});
|
package/dist/text.d.cts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes general text: trims, collapses whitespace, and applies Unicode NFC.
|
|
3
|
+
*
|
|
4
|
+
* @param text - Input text
|
|
5
|
+
* @returns Normalized text
|
|
6
|
+
*/
|
|
7
|
+
declare function normalizeText(text: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes informal Roman Urdu spellings to common canonical forms.
|
|
10
|
+
*
|
|
11
|
+
* Also applies {@link normalizeText} and converts Urdu/Arabic digits to English.
|
|
12
|
+
* A capitalized word keeps its capital; all-caps words (acronyms such as "AP")
|
|
13
|
+
* are left unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @param text - Roman Urdu input
|
|
16
|
+
* @returns Normalized Roman Urdu string
|
|
17
|
+
*/
|
|
18
|
+
declare function normalizeRomanUrdu(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts English/Arabic-Indic digits in a string to Urdu digits (۰–۹).
|
|
21
|
+
*
|
|
22
|
+
* @param text - Input text
|
|
23
|
+
* @returns Text with Urdu digits
|
|
24
|
+
*/
|
|
25
|
+
declare function toUrduDigits(text: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Converts Urdu/Arabic-Indic digits in a string to English digits (0–9).
|
|
28
|
+
*
|
|
29
|
+
* @param text - Input text
|
|
30
|
+
* @returns Text with English digits
|
|
31
|
+
*/
|
|
32
|
+
declare function toEnglishDigits(text: string): string;
|
|
33
|
+
|
|
34
|
+
export { normalizeRomanUrdu, normalizeText, toEnglishDigits, toUrduDigits };
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes general text: trims, collapses whitespace, and applies Unicode NFC.
|
|
3
|
+
*
|
|
4
|
+
* @param text - Input text
|
|
5
|
+
* @returns Normalized text
|
|
6
|
+
*/
|
|
7
|
+
declare function normalizeText(text: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes informal Roman Urdu spellings to common canonical forms.
|
|
10
|
+
*
|
|
11
|
+
* Also applies {@link normalizeText} and converts Urdu/Arabic digits to English.
|
|
12
|
+
* A capitalized word keeps its capital; all-caps words (acronyms such as "AP")
|
|
13
|
+
* are left unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @param text - Roman Urdu input
|
|
16
|
+
* @returns Normalized Roman Urdu string
|
|
17
|
+
*/
|
|
18
|
+
declare function normalizeRomanUrdu(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts English/Arabic-Indic digits in a string to Urdu digits (۰–۹).
|
|
21
|
+
*
|
|
22
|
+
* @param text - Input text
|
|
23
|
+
* @returns Text with Urdu digits
|
|
24
|
+
*/
|
|
25
|
+
declare function toUrduDigits(text: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Converts Urdu/Arabic-Indic digits in a string to English digits (0–9).
|
|
28
|
+
*
|
|
29
|
+
* @param text - Input text
|
|
30
|
+
* @returns Text with English digits
|
|
31
|
+
*/
|
|
32
|
+
declare function toEnglishDigits(text: string): string;
|
|
33
|
+
|
|
34
|
+
export { normalizeRomanUrdu, normalizeText, toEnglishDigits, toUrduDigits };
|
package/dist/text.js
ADDED
package/dist/valibot.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkOVUR47QH_cjs = require('./chunk-OVUR47QH.cjs');
|
|
4
|
+
require('./chunk-BSS4Z7NI.cjs');
|
|
5
|
+
require('./chunk-PHHKIMO2.cjs');
|
|
6
|
+
require('./chunk-YS7MOLK2.cjs');
|
|
7
|
+
require('./chunk-H6M6L26S.cjs');
|
|
8
|
+
require('./chunk-YLWZGSFY.cjs');
|
|
9
|
+
require('./chunk-HTCSHHOR.cjs');
|
|
10
|
+
require('./chunk-422X6FEZ.cjs');
|
|
11
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
12
|
+
var v = require('valibot');
|
|
13
|
+
|
|
14
|
+
function _interopNamespace(e) {
|
|
15
|
+
if (e && e.__esModule) return e;
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var v__namespace = /*#__PURE__*/_interopNamespace(v);
|
|
33
|
+
|
|
34
|
+
function schema(name) {
|
|
35
|
+
const rule = chunkOVUR47QH_cjs.RULES[name];
|
|
36
|
+
return (options = {}) => v__namespace.pipe(v__namespace.string(), v__namespace.check(rule.test, options.message ?? rule.message));
|
|
37
|
+
}
|
|
38
|
+
var pk = {
|
|
39
|
+
cnic: schema("cnic"),
|
|
40
|
+
phone: schema("phone"),
|
|
41
|
+
iban: schema("iban"),
|
|
42
|
+
ntn: schema("ntn"),
|
|
43
|
+
strn: schema("strn"),
|
|
44
|
+
landline: schema("landline")
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.pk = pk;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { A as AdapterOptions } from './rules-GxgPiVws.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Valibot schemas for Pakistani identifiers.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import * as v from 'valibot';
|
|
9
|
+
* import { pk } from 'pakdatakit/valibot';
|
|
10
|
+
*
|
|
11
|
+
* const form = v.object({ cnic: pk.cnic(), phone: pk.phone() });
|
|
12
|
+
*/
|
|
13
|
+
declare const pk: {
|
|
14
|
+
cnic: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
15
|
+
phone: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
16
|
+
iban: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
17
|
+
ntn: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
18
|
+
strn: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
19
|
+
landline: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { AdapterOptions, pk };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { A as AdapterOptions } from './rules-GxgPiVws.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Valibot schemas for Pakistani identifiers.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import * as v from 'valibot';
|
|
9
|
+
* import { pk } from 'pakdatakit/valibot';
|
|
10
|
+
*
|
|
11
|
+
* const form = v.object({ cnic: pk.cnic(), phone: pk.phone() });
|
|
12
|
+
*/
|
|
13
|
+
declare const pk: {
|
|
14
|
+
cnic: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
15
|
+
phone: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
16
|
+
iban: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
17
|
+
ntn: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
18
|
+
strn: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
19
|
+
landline: (options?: AdapterOptions) => v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, string>]>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { AdapterOptions, pk };
|
package/dist/valibot.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RULES } from './chunk-XT4ZNXRC.js';
|
|
2
|
+
import './chunk-T3E4B5MJ.js';
|
|
3
|
+
import './chunk-432ZYMYV.js';
|
|
4
|
+
import './chunk-L45UXUWX.js';
|
|
5
|
+
import './chunk-CEPNSHIC.js';
|
|
6
|
+
import './chunk-Y6BUGLXU.js';
|
|
7
|
+
import './chunk-EEVNLTB4.js';
|
|
8
|
+
import './chunk-CQKK3S7A.js';
|
|
9
|
+
import './chunk-ENQ7O7VW.js';
|
|
10
|
+
import * as v from 'valibot';
|
|
11
|
+
|
|
12
|
+
function schema(name) {
|
|
13
|
+
const rule = RULES[name];
|
|
14
|
+
return (options = {}) => v.pipe(v.string(), v.check(rule.test, options.message ?? rule.message));
|
|
15
|
+
}
|
|
16
|
+
var pk = {
|
|
17
|
+
cnic: schema("cnic"),
|
|
18
|
+
phone: schema("phone"),
|
|
19
|
+
iban: schema("iban"),
|
|
20
|
+
ntn: schema("ntn"),
|
|
21
|
+
strn: schema("strn"),
|
|
22
|
+
landline: schema("landline")
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { pk };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKQKW2ZEK_cjs = require('./chunk-KQKW2ZEK.cjs');
|
|
4
|
+
require('./chunk-YLWZGSFY.cjs');
|
|
5
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "createWhatsAppLink", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkKQKW2ZEK_cjs.createWhatsAppLink; }
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a WhatsApp click-to-chat link for a Pakistani mobile number.
|
|
3
|
+
*
|
|
4
|
+
* Accepts local, international, and short phone formats.
|
|
5
|
+
*
|
|
6
|
+
* @param phone - Pakistani mobile number in any supported format
|
|
7
|
+
* @param message - Optional pre-filled message (URL-encoded)
|
|
8
|
+
* @returns WhatsApp wa.me link, or `null` if the phone number is invalid
|
|
9
|
+
*/
|
|
10
|
+
declare function createWhatsAppLink(phone: string, message?: string): string | null;
|
|
11
|
+
|
|
12
|
+
export { createWhatsAppLink };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a WhatsApp click-to-chat link for a Pakistani mobile number.
|
|
3
|
+
*
|
|
4
|
+
* Accepts local, international, and short phone formats.
|
|
5
|
+
*
|
|
6
|
+
* @param phone - Pakistani mobile number in any supported format
|
|
7
|
+
* @param message - Optional pre-filled message (URL-encoded)
|
|
8
|
+
* @returns WhatsApp wa.me link, or `null` if the phone number is invalid
|
|
9
|
+
*/
|
|
10
|
+
declare function createWhatsAppLink(phone: string, message?: string): string | null;
|
|
11
|
+
|
|
12
|
+
export { createWhatsAppLink };
|
package/dist/whatsapp.js
ADDED
package/dist/words.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkAPXP7OK7_cjs = require('./chunk-APXP7OK7.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "amountInWords", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkAPXP7OK7_cjs.amountInWords; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "numberToWords", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkAPXP7OK7_cjs.numberToWords; }
|
|
14
|
+
});
|
package/dist/words.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Language for number words. */
|
|
2
|
+
type WordsLanguage = 'en' | 'ur';
|
|
3
|
+
/** Options for {@link numberToWords}. */
|
|
4
|
+
interface NumberToWordsOptions {
|
|
5
|
+
/** `'en'` (default) or `'ur'`. */
|
|
6
|
+
language?: WordsLanguage;
|
|
7
|
+
}
|
|
8
|
+
/** Options for {@link amountInWords}. */
|
|
9
|
+
interface AmountInWordsOptions extends NumberToWordsOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Cheque style: `"Rupees One Lakh Twenty-Five Thousand Only"` in English,
|
|
12
|
+
* or the words followed by `"روپے صرف"` in Urdu.
|
|
13
|
+
*/
|
|
14
|
+
cheque?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts a whole number to words using the Pakistani numbering system
|
|
18
|
+
* (hundred, thousand, lakh, crore, arab, kharab).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* numberToWords(125000); // "one lakh twenty-five thousand"
|
|
22
|
+
* numberToWords(125000, { language: 'ur' }); // "ایک لاکھ پچیس ہزار"
|
|
23
|
+
*
|
|
24
|
+
* @param n - A safe integer
|
|
25
|
+
* @param options - Output language
|
|
26
|
+
* @returns The number in words
|
|
27
|
+
* @throws {RangeError} If `n` is not a safe integer
|
|
28
|
+
*/
|
|
29
|
+
declare function numberToWords(n: number, options?: NumberToWordsOptions): string;
|
|
30
|
+
/**
|
|
31
|
+
* Writes a rupee amount in words, with paisa, as used on Pakistani cheques
|
|
32
|
+
* and invoices. Amounts are rounded to the nearest paisa.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* amountInWords(125000.5);
|
|
36
|
+
* // "one lakh twenty-five thousand rupees and fifty paisa"
|
|
37
|
+
* amountInWords(125000, { cheque: true });
|
|
38
|
+
* // "Rupees One Lakh Twenty-Five Thousand Only"
|
|
39
|
+
* amountInWords(125000, { language: 'ur' });
|
|
40
|
+
* // "ایک لاکھ پچیس ہزار روپے"
|
|
41
|
+
*
|
|
42
|
+
* @param amount - Amount in PKR (must be zero or more)
|
|
43
|
+
* @param options - Output language and cheque style
|
|
44
|
+
* @returns The amount in words
|
|
45
|
+
* @throws {RangeError} If `amount` is negative, not finite, or too large
|
|
46
|
+
*/
|
|
47
|
+
declare function amountInWords(amount: number, options?: AmountInWordsOptions): string;
|
|
48
|
+
|
|
49
|
+
export { type AmountInWordsOptions, type NumberToWordsOptions, type WordsLanguage, amountInWords, numberToWords };
|
package/dist/words.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Language for number words. */
|
|
2
|
+
type WordsLanguage = 'en' | 'ur';
|
|
3
|
+
/** Options for {@link numberToWords}. */
|
|
4
|
+
interface NumberToWordsOptions {
|
|
5
|
+
/** `'en'` (default) or `'ur'`. */
|
|
6
|
+
language?: WordsLanguage;
|
|
7
|
+
}
|
|
8
|
+
/** Options for {@link amountInWords}. */
|
|
9
|
+
interface AmountInWordsOptions extends NumberToWordsOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Cheque style: `"Rupees One Lakh Twenty-Five Thousand Only"` in English,
|
|
12
|
+
* or the words followed by `"روپے صرف"` in Urdu.
|
|
13
|
+
*/
|
|
14
|
+
cheque?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts a whole number to words using the Pakistani numbering system
|
|
18
|
+
* (hundred, thousand, lakh, crore, arab, kharab).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* numberToWords(125000); // "one lakh twenty-five thousand"
|
|
22
|
+
* numberToWords(125000, { language: 'ur' }); // "ایک لاکھ پچیس ہزار"
|
|
23
|
+
*
|
|
24
|
+
* @param n - A safe integer
|
|
25
|
+
* @param options - Output language
|
|
26
|
+
* @returns The number in words
|
|
27
|
+
* @throws {RangeError} If `n` is not a safe integer
|
|
28
|
+
*/
|
|
29
|
+
declare function numberToWords(n: number, options?: NumberToWordsOptions): string;
|
|
30
|
+
/**
|
|
31
|
+
* Writes a rupee amount in words, with paisa, as used on Pakistani cheques
|
|
32
|
+
* and invoices. Amounts are rounded to the nearest paisa.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* amountInWords(125000.5);
|
|
36
|
+
* // "one lakh twenty-five thousand rupees and fifty paisa"
|
|
37
|
+
* amountInWords(125000, { cheque: true });
|
|
38
|
+
* // "Rupees One Lakh Twenty-Five Thousand Only"
|
|
39
|
+
* amountInWords(125000, { language: 'ur' });
|
|
40
|
+
* // "ایک لاکھ پچیس ہزار روپے"
|
|
41
|
+
*
|
|
42
|
+
* @param amount - Amount in PKR (must be zero or more)
|
|
43
|
+
* @param options - Output language and cheque style
|
|
44
|
+
* @returns The amount in words
|
|
45
|
+
* @throws {RangeError} If `amount` is negative, not finite, or too large
|
|
46
|
+
*/
|
|
47
|
+
declare function amountInWords(amount: number, options?: AmountInWordsOptions): string;
|
|
48
|
+
|
|
49
|
+
export { type AmountInWordsOptions, type NumberToWordsOptions, type WordsLanguage, amountInWords, numberToWords };
|
package/dist/words.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { amountInWords, numberToWords } from './chunk-QQQKISXT.js';
|