@indodev/toolkit 0.3.0 → 0.3.2

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 (41) hide show
  1. package/dist/{compare-BIodyGn7.d.cts → compare-CZadJMGl.d.cts} +1 -1
  2. package/dist/{compare-BIodyGn7.d.ts → compare-CZadJMGl.d.ts} +1 -1
  3. package/dist/email-validator/index.cjs +83 -0
  4. package/dist/email-validator/index.cjs.map +1 -0
  5. package/dist/email-validator/index.d.cts +13 -0
  6. package/dist/email-validator/index.d.ts +13 -0
  7. package/dist/email-validator/index.js +76 -0
  8. package/dist/email-validator/index.js.map +1 -0
  9. package/dist/email-validator-R9L5unIw.d.cts +120 -0
  10. package/dist/email-validator-R9L5unIw.d.ts +120 -0
  11. package/dist/index.cjs +148 -0
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +5 -107
  14. package/dist/index.d.ts +5 -107
  15. package/dist/index.js +144 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/npwp/index.cjs +95 -0
  18. package/dist/npwp/index.cjs.map +1 -0
  19. package/dist/npwp/index.d.cts +76 -0
  20. package/dist/npwp/index.d.ts +76 -0
  21. package/dist/npwp/index.js +90 -0
  22. package/dist/npwp/index.js.map +1 -0
  23. package/dist/plate/index.cjs +99 -0
  24. package/dist/plate/index.cjs.map +1 -0
  25. package/dist/plate/index.d.cts +8 -0
  26. package/dist/plate/index.d.ts +8 -0
  27. package/dist/plate/index.js +94 -0
  28. package/dist/plate/index.js.map +1 -0
  29. package/dist/text/index.d.cts +1 -1
  30. package/dist/text/index.d.ts +1 -1
  31. package/dist/types-i5e6R0AS.d.cts +39 -0
  32. package/dist/types-i5e6R0AS.d.ts +39 -0
  33. package/dist/utils-DDVlOusI.d.cts +30 -0
  34. package/dist/utils-DDVlOusI.d.ts +30 -0
  35. package/dist/vin/index.cjs +84 -0
  36. package/dist/vin/index.cjs.map +1 -0
  37. package/dist/vin/index.d.cts +39 -0
  38. package/dist/vin/index.d.ts +39 -0
  39. package/dist/vin/index.js +74 -0
  40. package/dist/vin/index.js.map +1 -0
  41. package/package.json +21 -1
package/dist/index.d.cts CHANGED
@@ -1,110 +1,8 @@
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';
6
+ export { c as EmailInfo, b as EmailMaskOptions, E as EmailValidationOptions, a as EmailValidationResult, g as getEmailInfo, m as maskEmail, n as normalizeEmail, v as validateEmail } from './email-validator-R9L5unIw.cjs';
3
7
  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 };
8
+ 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,8 @@
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';
6
+ export { c as EmailInfo, b as EmailMaskOptions, E as EmailValidationOptions, a as EmailValidationResult, g as getEmailInfo, m as maskEmail, n as normalizeEmail, v as validateEmail } from './email-validator-R9L5unIw.js';
3
7
  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 };
8
+ 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,149 @@ 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
+
1252
+ // src/email-validator/constants.ts
1253
+ var EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$/;
1254
+ var DISPOSABLE_DOMAINS = [
1255
+ "mailinator.com",
1256
+ "10minutemail.com",
1257
+ "temp-mail.org",
1258
+ "guerrillamail.com"
1259
+ ];
1260
+
1261
+ // src/email-validator/email-validator.ts
1262
+ var COMMON_PROVIDERS = ["gmail.com", "yahoo.com", "outlook.com", "hotmail.com", "icloud.com"];
1263
+ var MAX_EMAIL_LENGTH = 254;
1264
+ function validateEmail(email, options) {
1265
+ if (!email || typeof email !== "string") {
1266
+ return false;
1267
+ }
1268
+ const trimmedEmail = email.trim().toLowerCase();
1269
+ if (trimmedEmail.length > MAX_EMAIL_LENGTH) {
1270
+ return false;
1271
+ }
1272
+ const parts = trimmedEmail.split("@");
1273
+ if (parts.length !== 2) {
1274
+ return false;
1275
+ }
1276
+ const [username, domain] = parts;
1277
+ if (!username || !domain) {
1278
+ return false;
1279
+ }
1280
+ if (username.length > 64) {
1281
+ return false;
1282
+ }
1283
+ if (username.includes("..") || username.startsWith(".") || username.endsWith(".") || domain.startsWith(".") || domain.endsWith(".") || domain.includes("..")) {
1284
+ return false;
1285
+ }
1286
+ if (!EMAIL_REGEX.test(trimmedEmail)) {
1287
+ return false;
1288
+ }
1289
+ if (options?.blockDisposable) {
1290
+ if (DISPOSABLE_DOMAINS.includes(domain)) {
1291
+ return false;
1292
+ }
1293
+ }
1294
+ return true;
1295
+ }
1296
+ function getEmailInfo(email) {
1297
+ if (!validateEmail(email)) return null;
1298
+ const [username, domain] = email.trim().toLowerCase().split("@");
1299
+ return {
1300
+ username,
1301
+ domain,
1302
+ isCommonProvider: COMMON_PROVIDERS.includes(domain),
1303
+ isDisposable: DISPOSABLE_DOMAINS.includes(domain)
1304
+ };
1305
+ }
1306
+ function maskEmail(email, options) {
1307
+ if (!validateEmail(email)) return email;
1308
+ const { visibleStart = 1, visibleEnd = 1, maskChar = "*" } = options || {};
1309
+ const [username, domain] = email.split("@");
1310
+ if (username.length <= 3) {
1311
+ return `${username[0]}${maskChar.repeat(3)}@${domain}`;
1312
+ }
1313
+ const maskedLength = username.length - (visibleStart + visibleEnd);
1314
+ if (maskedLength <= 0) {
1315
+ return `${username[0]}${maskChar.repeat(3)}@${domain}`;
1316
+ }
1317
+ const start = username.slice(0, visibleStart);
1318
+ const end = username.slice(username.length - visibleEnd);
1319
+ return `${start}${maskChar.repeat(maskedLength)}${end}@${domain}`;
1320
+ }
1321
+ function normalizeEmail(email) {
1322
+ return email.trim().toLowerCase();
1323
+ }
1324
+
1182
1325
  // src/currency/format.ts
1183
1326
  function formatRupiah(amount, options) {
1184
1327
  const {
@@ -3137,6 +3280,6 @@ function similarity(str1, str2) {
3137
3280
  return 1 - distance / maxLength;
3138
3281
  }
3139
3282
 
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 };
3283
+ export { addRupiahSymbol, calculateTax, capitalize2 as capitalize, cleanPhoneNumber, compareStrings, contractAbbreviation, expandAbbreviation, extractWords, formatAccounting, formatBirthDate, formatCompact, formatNIK, formatNPWP, formatPhoneNumber, formatPlate, formatRupiah, generateSmsLink, generateTelLink, generateWALink, getAge, getEmailInfo, getOperator, getRegionFromPlate, isAlay, isLandlineNumber, isMobileNumber, isProvider, isValidForBirthDate, isValidForGender, maskEmail, maskNIK, maskNPWP, maskPhoneNumber, normalizeEmail, normalizeWhitespace, parseNIK, parseNPWP, parsePhoneNumber, parseRupiah, profanityFilter, removeAccents, removeStopwords, roundToClean, sanitize, similarity, slugify, toE164, toFormal, toInternational, toNational, toSentenceCase, toTitleCase, toWords, truncate, validateEmail, validateNIK, validateNPWP, validatePhoneNumber, validatePlate, validateVIN };
3141
3284
  //# sourceMappingURL=index.js.map
3142
3285
  //# sourceMappingURL=index.js.map