@indodev/toolkit 0.3.0 → 0.3.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/dist/index.d.cts CHANGED
@@ -1,110 +1,7 @@
1
1
  export { NIKInfo, MaskOptions as NIKMaskOptions, formatBirthDate, formatNIK, getAge, isValidForBirthDate, isValidForGender, maskNIK, parseNIK, validateNIK } from './nik/index.cjs';
2
2
  export { PhoneFormat, PhoneInfo, MaskOptions as PhoneMaskOptions, cleanPhoneNumber, formatPhoneNumber, generateSmsLink, generateTelLink, generateWALink, getOperator, isLandlineNumber, isMobileNumber, isProvider, maskPhoneNumber, parsePhoneNumber, toE164, toInternational, toNational, validatePhoneNumber } from './phone/index.cjs';
3
+ export { NPWPInfo, MaskOptions as NPWPMaskOptions, formatNPWP, maskNPWP, parseNPWP, validateNPWP } from './npwp/index.cjs';
4
+ export { f as formatPlate, g as getRegionFromPlate, v as validatePlate } from './utils-DDVlOusI.cjs';
5
+ export { V as VINOptions, a as VINValidationResult, v as validateVIN } from './types-i5e6R0AS.cjs';
3
6
  export { RupiahOptions, WordOptions, addRupiahSymbol, calculateTax, formatAccounting, formatCompact, formatRupiah, parseRupiah, roundToClean, toWords } from './currency/index.cjs';
4
- export { C as CompareOptions, E as ExtractOptions, m as SanitizeOptions, S as SlugifyOptions, T as TitleCaseOptions, o as TruncateOptions, c as capitalize, k as compareStrings, d as contractAbbreviation, e as expandAbbreviation, j as extractWords, i as isAlay, n as normalizeWhitespace, p as profanityFilter, r as removeAccents, f as removeStopwords, b as sanitize, l as similarity, s as slugify, g as toFormal, a as toSentenceCase, t as toTitleCase, h as truncate } from './compare-BIodyGn7.cjs';
5
-
6
- /**
7
- * Validates an Indonesian NPWP (Nomor Pokok Wajib Pajak).
8
- *
9
- * Supports both 15-digit (standard) and 16-digit (new NIK-based) formats.
10
- *
11
- * @param npwp - The NPWP string to validate
12
- * @returns `true` if valid, `false` otherwise
13
- *
14
- * @example
15
- * ```typescript
16
- * validateNPWP('01.234.567.8-012.000'); // true
17
- * validateNPWP('012345678012000'); // true
18
- * ```
19
- */
20
- declare function validateNPWP(npwp: string): boolean;
21
-
22
- /**
23
- * Information extracted from an NPWP string.
24
- */
25
- interface NPWPInfo {
26
- /** The full 15 or 16 digit numeric string */
27
- npwp: string;
28
- /** Taxpayer type (e.g., 01-03 for individual, etc.) */
29
- type: string;
30
- /** Serial number */
31
- serial: string;
32
- /** Checksum digit */
33
- checksum: string;
34
- /** Tax office code */
35
- taxOfficeCode: string;
36
- /** Branch code (usually 000 for head office) */
37
- branchCode: string;
38
- /** Whether the NPWP is a 16-digit (NIK-based) NPWP */
39
- isNikBased: boolean;
40
- }
41
- /**
42
- * Options for NPWP masking.
43
- */
44
- interface MaskOptions {
45
- /** Number of characters to keep visible at the start (default: 2) */
46
- visibleStart?: number;
47
- /** Number of characters to keep visible at the end (default: 3) */
48
- visibleEnd?: number;
49
- /** Character to use for masking (default: '*') */
50
- maskChar?: string;
51
- }
52
-
53
- /**
54
- * Formats an NPWP string into standard Indonesian format (99.999.999.9-999.999).
55
- *
56
- * @param npwp - The NPWP string to format
57
- * @returns Formatted NPWP string, or original if invalid
58
- *
59
- * @example
60
- * ```typescript
61
- * formatNPWP('012345678012000'); // '01.234.567.8-012.000'
62
- * ```
63
- */
64
- declare function formatNPWP(npwp: string): string;
65
- /**
66
- * Parses an NPWP string into its components.
67
- *
68
- * @param npwp - The NPWP string to parse
69
- * @returns NPWPInfo object, or null if invalid
70
- */
71
- declare function parseNPWP(npwp: string): NPWPInfo | null;
72
- /**
73
- * Masks an NPWP string for privacy.
74
- *
75
- * @param npwp - The NPWP string to mask
76
- * @param options - Masking options
77
- * @returns Masked NPWP string
78
- */
79
- declare function maskNPWP(npwp: string, options?: MaskOptions): string;
80
-
81
- /**
82
- * Validates an Indonesian license plate number format.
83
- * Format: [1-2 letters] [1-4 digits] [1-3 letters]
84
- *
85
- * @param plate - The plate number string to validate
86
- * @returns `true` if valid, `false` otherwise
87
- *
88
- * @example
89
- * ```typescript
90
- * validatePlate('B 1234 ABC'); // true
91
- * validatePlate('AB 1 CD'); // true
92
- * ```
93
- */
94
- declare function validatePlate(plate: string): boolean;
95
- /**
96
- * Gets the region name from a license plate number.
97
- *
98
- * @param plate - The plate number
99
- * @returns Region name or null if not found
100
- */
101
- declare function getRegionFromPlate(plate: string): string | null;
102
- /**
103
- * Formats a license plate number with spaces (e.g., B 1234 ABC).
104
- *
105
- * @param plate - The plate number
106
- * @returns Formatted plate string
107
- */
108
- declare function formatPlate(plate: string): string;
109
-
110
- export { type NPWPInfo, type MaskOptions as NPWPMaskOptions, formatNPWP, formatPlate, getRegionFromPlate, maskNPWP, parseNPWP, validateNPWP, validatePlate };
7
+ export { C as CompareOptions, E as ExtractOptions, m as SanitizeOptions, S as SlugifyOptions, T as TitleCaseOptions, o as TruncateOptions, c as capitalize, k as compareStrings, d as contractAbbreviation, e as expandAbbreviation, g as extractWords, j as isAlay, n as normalizeWhitespace, p as profanityFilter, r as removeAccents, h as removeStopwords, b as sanitize, l as similarity, s as slugify, i as toFormal, a as toSentenceCase, t as toTitleCase, f as truncate } from './compare-CZadJMGl.cjs';
package/dist/index.d.ts CHANGED
@@ -1,110 +1,7 @@
1
1
  export { NIKInfo, MaskOptions as NIKMaskOptions, formatBirthDate, formatNIK, getAge, isValidForBirthDate, isValidForGender, maskNIK, parseNIK, validateNIK } from './nik/index.js';
2
2
  export { PhoneFormat, PhoneInfo, MaskOptions as PhoneMaskOptions, cleanPhoneNumber, formatPhoneNumber, generateSmsLink, generateTelLink, generateWALink, getOperator, isLandlineNumber, isMobileNumber, isProvider, maskPhoneNumber, parsePhoneNumber, toE164, toInternational, toNational, validatePhoneNumber } from './phone/index.js';
3
+ export { NPWPInfo, MaskOptions as NPWPMaskOptions, formatNPWP, maskNPWP, parseNPWP, validateNPWP } from './npwp/index.js';
4
+ export { f as formatPlate, g as getRegionFromPlate, v as validatePlate } from './utils-DDVlOusI.js';
5
+ export { V as VINOptions, a as VINValidationResult, v as validateVIN } from './types-i5e6R0AS.js';
3
6
  export { RupiahOptions, WordOptions, addRupiahSymbol, calculateTax, formatAccounting, formatCompact, formatRupiah, parseRupiah, roundToClean, toWords } from './currency/index.js';
4
- export { C as CompareOptions, E as ExtractOptions, m as SanitizeOptions, S as SlugifyOptions, T as TitleCaseOptions, o as TruncateOptions, c as capitalize, k as compareStrings, d as contractAbbreviation, e as expandAbbreviation, j as extractWords, i as isAlay, n as normalizeWhitespace, p as profanityFilter, r as removeAccents, f as removeStopwords, b as sanitize, l as similarity, s as slugify, g as toFormal, a as toSentenceCase, t as toTitleCase, h as truncate } from './compare-BIodyGn7.js';
5
-
6
- /**
7
- * Validates an Indonesian NPWP (Nomor Pokok Wajib Pajak).
8
- *
9
- * Supports both 15-digit (standard) and 16-digit (new NIK-based) formats.
10
- *
11
- * @param npwp - The NPWP string to validate
12
- * @returns `true` if valid, `false` otherwise
13
- *
14
- * @example
15
- * ```typescript
16
- * validateNPWP('01.234.567.8-012.000'); // true
17
- * validateNPWP('012345678012000'); // true
18
- * ```
19
- */
20
- declare function validateNPWP(npwp: string): boolean;
21
-
22
- /**
23
- * Information extracted from an NPWP string.
24
- */
25
- interface NPWPInfo {
26
- /** The full 15 or 16 digit numeric string */
27
- npwp: string;
28
- /** Taxpayer type (e.g., 01-03 for individual, etc.) */
29
- type: string;
30
- /** Serial number */
31
- serial: string;
32
- /** Checksum digit */
33
- checksum: string;
34
- /** Tax office code */
35
- taxOfficeCode: string;
36
- /** Branch code (usually 000 for head office) */
37
- branchCode: string;
38
- /** Whether the NPWP is a 16-digit (NIK-based) NPWP */
39
- isNikBased: boolean;
40
- }
41
- /**
42
- * Options for NPWP masking.
43
- */
44
- interface MaskOptions {
45
- /** Number of characters to keep visible at the start (default: 2) */
46
- visibleStart?: number;
47
- /** Number of characters to keep visible at the end (default: 3) */
48
- visibleEnd?: number;
49
- /** Character to use for masking (default: '*') */
50
- maskChar?: string;
51
- }
52
-
53
- /**
54
- * Formats an NPWP string into standard Indonesian format (99.999.999.9-999.999).
55
- *
56
- * @param npwp - The NPWP string to format
57
- * @returns Formatted NPWP string, or original if invalid
58
- *
59
- * @example
60
- * ```typescript
61
- * formatNPWP('012345678012000'); // '01.234.567.8-012.000'
62
- * ```
63
- */
64
- declare function formatNPWP(npwp: string): string;
65
- /**
66
- * Parses an NPWP string into its components.
67
- *
68
- * @param npwp - The NPWP string to parse
69
- * @returns NPWPInfo object, or null if invalid
70
- */
71
- declare function parseNPWP(npwp: string): NPWPInfo | null;
72
- /**
73
- * Masks an NPWP string for privacy.
74
- *
75
- * @param npwp - The NPWP string to mask
76
- * @param options - Masking options
77
- * @returns Masked NPWP string
78
- */
79
- declare function maskNPWP(npwp: string, options?: MaskOptions): string;
80
-
81
- /**
82
- * Validates an Indonesian license plate number format.
83
- * Format: [1-2 letters] [1-4 digits] [1-3 letters]
84
- *
85
- * @param plate - The plate number string to validate
86
- * @returns `true` if valid, `false` otherwise
87
- *
88
- * @example
89
- * ```typescript
90
- * validatePlate('B 1234 ABC'); // true
91
- * validatePlate('AB 1 CD'); // true
92
- * ```
93
- */
94
- declare function validatePlate(plate: string): boolean;
95
- /**
96
- * Gets the region name from a license plate number.
97
- *
98
- * @param plate - The plate number
99
- * @returns Region name or null if not found
100
- */
101
- declare function getRegionFromPlate(plate: string): string | null;
102
- /**
103
- * Formats a license plate number with spaces (e.g., B 1234 ABC).
104
- *
105
- * @param plate - The plate number
106
- * @returns Formatted plate string
107
- */
108
- declare function formatPlate(plate: string): string;
109
-
110
- export { type NPWPInfo, type MaskOptions as NPWPMaskOptions, formatNPWP, formatPlate, getRegionFromPlate, maskNPWP, parseNPWP, validateNPWP, validatePlate };
7
+ export { C as CompareOptions, E as ExtractOptions, m as SanitizeOptions, S as SlugifyOptions, T as TitleCaseOptions, o as TruncateOptions, c as capitalize, k as compareStrings, d as contractAbbreviation, e as expandAbbreviation, g as extractWords, j as isAlay, n as normalizeWhitespace, p as profanityFilter, r as removeAccents, h as removeStopwords, b as sanitize, l as similarity, s as slugify, i as toFormal, a as toSentenceCase, t as toTitleCase, f as truncate } from './compare-CZadJMGl.js';
package/dist/index.js CHANGED
@@ -1179,6 +1179,76 @@ function formatPlate(plate) {
1179
1179
  return `${match[1]} ${match[2]} ${match[3]}`;
1180
1180
  }
1181
1181
 
1182
+ // src/vin/constants.ts
1183
+ var VIN_LENGTH = 17;
1184
+ var VIN_CHECK_DIGIT_INDEX = 8;
1185
+ var VIN_MODULUS = 11;
1186
+ var VIN_CHECK_DIGIT_X = "X";
1187
+ var VIN_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];
1188
+ var VIN_CHAR_VALUES = {
1189
+ "0": 0,
1190
+ "1": 1,
1191
+ "2": 2,
1192
+ "3": 3,
1193
+ "4": 4,
1194
+ "5": 5,
1195
+ "6": 6,
1196
+ "7": 7,
1197
+ "8": 8,
1198
+ "9": 9,
1199
+ "A": 1,
1200
+ "B": 2,
1201
+ "C": 3,
1202
+ "D": 4,
1203
+ "E": 5,
1204
+ "F": 6,
1205
+ "G": 7,
1206
+ "H": 8,
1207
+ "J": 1,
1208
+ "K": 2,
1209
+ "L": 3,
1210
+ "M": 4,
1211
+ "N": 5,
1212
+ "P": 7,
1213
+ "R": 9,
1214
+ "S": 2,
1215
+ "T": 3,
1216
+ "U": 4,
1217
+ "V": 5,
1218
+ "W": 6,
1219
+ "X": 7,
1220
+ "Y": 8,
1221
+ "Z": 9
1222
+ };
1223
+ var EXCLUDED_VIN_CHARS = ["I", "O", "Q"];
1224
+
1225
+ // src/vin/validate.ts
1226
+ function validateVIN(vin) {
1227
+ if (!vin || vin.length !== VIN_LENGTH) {
1228
+ return false;
1229
+ }
1230
+ const normalizedVIN = vin.toUpperCase();
1231
+ for (const char of EXCLUDED_VIN_CHARS) {
1232
+ if (normalizedVIN.includes(char)) {
1233
+ return false;
1234
+ }
1235
+ }
1236
+ let sum = 0;
1237
+ for (let i = 0; i < VIN_LENGTH; i++) {
1238
+ const char = normalizedVIN[i];
1239
+ const weight = VIN_WEIGHTS[i];
1240
+ const val = VIN_CHAR_VALUES[char];
1241
+ if (val === void 0) {
1242
+ return false;
1243
+ }
1244
+ sum += val * weight;
1245
+ }
1246
+ const checkDigitValue = sum % VIN_MODULUS;
1247
+ const expectedCheckDigit = checkDigitValue === 10 ? VIN_CHECK_DIGIT_X : checkDigitValue.toString();
1248
+ const actualCheckDigit = normalizedVIN[VIN_CHECK_DIGIT_INDEX];
1249
+ return actualCheckDigit === expectedCheckDigit;
1250
+ }
1251
+
1182
1252
  // src/currency/format.ts
1183
1253
  function formatRupiah(amount, options) {
1184
1254
  const {
@@ -3137,6 +3207,6 @@ function similarity(str1, str2) {
3137
3207
  return 1 - distance / maxLength;
3138
3208
  }
3139
3209
 
3140
- export { addRupiahSymbol, calculateTax, capitalize2 as capitalize, cleanPhoneNumber, compareStrings, contractAbbreviation, expandAbbreviation, extractWords, formatAccounting, formatBirthDate, formatCompact, formatNIK, formatNPWP, formatPhoneNumber, formatPlate, formatRupiah, generateSmsLink, generateTelLink, generateWALink, getAge, getOperator, getRegionFromPlate, isAlay, isLandlineNumber, isMobileNumber, isProvider, isValidForBirthDate, isValidForGender, maskNIK, maskNPWP, maskPhoneNumber, normalizeWhitespace, parseNIK, parseNPWP, parsePhoneNumber, parseRupiah, profanityFilter, removeAccents, removeStopwords, roundToClean, sanitize, similarity, slugify, toE164, toFormal, toInternational, toNational, toSentenceCase, toTitleCase, toWords, truncate, validateNIK, validateNPWP, validatePhoneNumber, validatePlate };
3210
+ export { addRupiahSymbol, calculateTax, capitalize2 as capitalize, cleanPhoneNumber, compareStrings, contractAbbreviation, expandAbbreviation, extractWords, formatAccounting, formatBirthDate, formatCompact, formatNIK, formatNPWP, formatPhoneNumber, formatPlate, formatRupiah, generateSmsLink, generateTelLink, generateWALink, getAge, getOperator, getRegionFromPlate, isAlay, isLandlineNumber, isMobileNumber, isProvider, isValidForBirthDate, isValidForGender, maskNIK, maskNPWP, maskPhoneNumber, normalizeWhitespace, parseNIK, parseNPWP, parsePhoneNumber, parseRupiah, profanityFilter, removeAccents, removeStopwords, roundToClean, sanitize, similarity, slugify, toE164, toFormal, toInternational, toNational, toSentenceCase, toTitleCase, toWords, truncate, validateNIK, validateNPWP, validatePhoneNumber, validatePlate, validateVIN };
3141
3211
  //# sourceMappingURL=index.js.map
3142
3212
  //# sourceMappingURL=index.js.map