@arkyn/shared 3.0.1-beta.99 → 3.0.3

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 (151) hide show
  1. package/LICENSE.txt +184 -1
  2. package/README.md +196 -306
  3. package/dist/formats/formatDate.d.ts +18 -26
  4. package/dist/formats/formatDate.d.ts.map +1 -1
  5. package/dist/formats/formatJsonObject.d.ts +5 -7
  6. package/dist/formats/formatJsonObject.d.ts.map +1 -1
  7. package/dist/formats/formatJsonString.d.ts +5 -21
  8. package/dist/formats/formatJsonString.d.ts.map +1 -1
  9. package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts +5 -24
  10. package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts.map +1 -1
  11. package/dist/formats/formatToCep.d.ts +3 -11
  12. package/dist/formats/formatToCep.d.ts.map +1 -1
  13. package/dist/formats/formatToCnpj.d.ts +3 -14
  14. package/dist/formats/formatToCnpj.d.ts.map +1 -1
  15. package/dist/formats/formatToCpf.d.ts +4 -13
  16. package/dist/formats/formatToCpf.d.ts.map +1 -1
  17. package/dist/formats/formatToCurrency.d.ts +10 -23
  18. package/dist/formats/formatToCurrency.d.ts.map +1 -1
  19. package/dist/formats/formatToEllipsis.d.ts +5 -5
  20. package/dist/formats/formatToEllipsis.d.ts.map +1 -1
  21. package/dist/formats/formatToHiddenDigits.d.ts +15 -26
  22. package/dist/formats/formatToHiddenDigits.d.ts.map +1 -1
  23. package/dist/formats/formatToPhone.d.ts +11 -23
  24. package/dist/formats/formatToPhone.d.ts.map +1 -1
  25. package/dist/generators/generateColorByString.d.ts +6 -4
  26. package/dist/generators/generateColorByString.d.ts.map +1 -1
  27. package/dist/generators/generateId.d.ts +8 -19
  28. package/dist/generators/generateId.d.ts.map +1 -1
  29. package/dist/generators/generateSlug.d.ts +8 -2
  30. package/dist/generators/generateSlug.d.ts.map +1 -1
  31. package/dist/index.d.ts +11 -10
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +373 -27
  34. package/dist/index.js.map +1 -0
  35. package/dist/modules/formats/formatDate.js +37 -0
  36. package/dist/modules/formats/formatDate.js.map +1 -0
  37. package/dist/modules/formats/formatJsonObject.js +25 -0
  38. package/dist/modules/formats/formatJsonObject.js.map +1 -0
  39. package/dist/modules/formats/formatJsonString.js +13 -0
  40. package/dist/modules/formats/formatJsonString.js.map +1 -0
  41. package/dist/modules/formats/formatToCapitalizeFirstWordLetter.js +8 -0
  42. package/dist/modules/formats/formatToCapitalizeFirstWordLetter.js.map +1 -0
  43. package/dist/modules/formats/formatToCep.js +11 -0
  44. package/dist/modules/formats/formatToCep.js.map +1 -0
  45. package/dist/modules/formats/formatToCnpj.js +11 -0
  46. package/dist/modules/formats/formatToCnpj.js.map +1 -0
  47. package/dist/modules/formats/formatToCpf.js +11 -0
  48. package/dist/modules/formats/formatToCpf.js.map +1 -0
  49. package/dist/modules/formats/formatToCurrency.js +15 -0
  50. package/dist/modules/formats/formatToCurrency.js.map +1 -0
  51. package/dist/modules/formats/formatToEllipsis.js +12 -0
  52. package/dist/modules/formats/formatToEllipsis.js.map +1 -0
  53. package/dist/modules/formats/formatToHiddenDigits.js +24 -0
  54. package/dist/modules/formats/formatToHiddenDigits.js.map +1 -0
  55. package/dist/modules/formats/formatToPhone.js +16 -0
  56. package/dist/modules/formats/formatToPhone.js.map +1 -0
  57. package/dist/modules/generators/generateColorByString.js +11 -0
  58. package/dist/modules/generators/generateColorByString.js.map +1 -0
  59. package/dist/modules/generators/generateId.js +34 -0
  60. package/dist/modules/generators/generateId.js.map +1 -0
  61. package/dist/modules/generators/generateSlug.js +9 -0
  62. package/dist/modules/generators/generateSlug.js.map +1 -0
  63. package/dist/modules/parsers/parseLargeFields.js +19 -0
  64. package/dist/modules/parsers/parseLargeFields.js.map +1 -0
  65. package/dist/modules/parsers/parseSensitiveData.js +30 -0
  66. package/dist/modules/parsers/parseSensitiveData.js.map +1 -0
  67. package/dist/modules/parsers/parseToDate.js +25 -0
  68. package/dist/modules/parsers/parseToDate.js.map +1 -0
  69. package/dist/modules/services/validateDateService.js +63 -0
  70. package/dist/modules/services/validateDateService.js.map +1 -0
  71. package/dist/modules/utilities/calculateCardInstallment.js +19 -0
  72. package/dist/modules/utilities/calculateCardInstallment.js.map +1 -0
  73. package/dist/modules/utilities/ensureQuotes.js +9 -0
  74. package/dist/modules/utilities/ensureQuotes.js.map +1 -0
  75. package/dist/modules/utilities/findCountryMask.js +25 -0
  76. package/dist/modules/utilities/findCountryMask.js.map +1 -0
  77. package/dist/modules/utilities/isHtml.js +8 -0
  78. package/dist/modules/utilities/isHtml.js.map +1 -0
  79. package/dist/modules/utilities/removeCurrencySymbols.js +8 -0
  80. package/dist/modules/utilities/removeCurrencySymbols.js.map +1 -0
  81. package/dist/modules/utilities/removeNonNumeric.js +8 -0
  82. package/dist/modules/utilities/removeNonNumeric.js.map +1 -0
  83. package/dist/modules/utilities/stripHtmlTags.js +8 -0
  84. package/dist/modules/utilities/stripHtmlTags.js.map +1 -0
  85. package/dist/{services/truncateLargeFields.d.ts → parsers/parseLargeFields.d.ts} +5 -8
  86. package/dist/parsers/parseLargeFields.d.ts.map +1 -0
  87. package/dist/parsers/parseSensitiveData.d.ts +22 -0
  88. package/dist/parsers/parseSensitiveData.d.ts.map +1 -0
  89. package/dist/parsers/parseToDate.d.ts +25 -0
  90. package/dist/parsers/parseToDate.d.ts.map +1 -0
  91. package/dist/services/validateDateService.d.ts +34 -0
  92. package/dist/services/validateDateService.d.ts.map +1 -0
  93. package/dist/utilities/calculateCardInstallment.d.ts +25 -0
  94. package/dist/utilities/calculateCardInstallment.d.ts.map +1 -0
  95. package/dist/utilities/ensureQuotes.d.ts +20 -0
  96. package/dist/utilities/ensureQuotes.d.ts.map +1 -0
  97. package/dist/utilities/findCountryMask.d.ts +21 -0
  98. package/dist/utilities/findCountryMask.d.ts.map +1 -0
  99. package/dist/utilities/isHtml.d.ts +21 -0
  100. package/dist/utilities/isHtml.d.ts.map +1 -0
  101. package/dist/{services/removeCurrencySymbols.js → utilities/removeCurrencySymbols.d.ts} +6 -7
  102. package/dist/utilities/removeCurrencySymbols.d.ts.map +1 -0
  103. package/dist/utilities/removeNonNumeric.d.ts +15 -0
  104. package/dist/utilities/removeNonNumeric.d.ts.map +1 -0
  105. package/dist/utilities/stripHtmlTags.d.ts +18 -0
  106. package/dist/utilities/stripHtmlTags.d.ts.map +1 -0
  107. package/package.json +255 -16
  108. package/dist/bundle.js +0 -2337
  109. package/dist/bundle.umd.cjs +0 -6
  110. package/dist/formats/formatDate.js +0 -66
  111. package/dist/formats/formatJsonObject.js +0 -90
  112. package/dist/formats/formatJsonString.js +0 -46
  113. package/dist/formats/formatToCapitalizeFirstWordLetter.js +0 -42
  114. package/dist/formats/formatToCep.js +0 -34
  115. package/dist/formats/formatToCnpj.js +0 -35
  116. package/dist/formats/formatToCpf.js +0 -35
  117. package/dist/formats/formatToCpfCnpj.d.ts +0 -24
  118. package/dist/formats/formatToCpfCnpj.d.ts.map +0 -1
  119. package/dist/formats/formatToCpfCnpj.js +0 -33
  120. package/dist/formats/formatToCurrency.js +0 -41
  121. package/dist/formats/formatToDate.d.ts +0 -32
  122. package/dist/formats/formatToDate.d.ts.map +0 -1
  123. package/dist/formats/formatToDate.js +0 -50
  124. package/dist/formats/formatToEllipsis.js +0 -21
  125. package/dist/formats/formatToHiddenDigits.js +0 -60
  126. package/dist/formats/formatToPhone.js +0 -131
  127. package/dist/generators/generateColorByString.js +0 -25
  128. package/dist/generators/generateId.js +0 -29
  129. package/dist/generators/generateSlug.js +0 -25
  130. package/dist/services/calculateCardInstallment.d.ts +0 -40
  131. package/dist/services/calculateCardInstallment.d.ts.map +0 -1
  132. package/dist/services/calculateCardInstallment.js +0 -55
  133. package/dist/services/ensureQuotes.d.ts +0 -14
  134. package/dist/services/ensureQuotes.d.ts.map +0 -1
  135. package/dist/services/ensureQuotes.js +0 -19
  136. package/dist/services/isHtml.d.ts +0 -22
  137. package/dist/services/isHtml.d.ts.map +0 -1
  138. package/dist/services/isHtml.js +0 -24
  139. package/dist/services/maskSensitiveData.d.ts +0 -26
  140. package/dist/services/maskSensitiveData.d.ts.map +0 -1
  141. package/dist/services/maskSensitiveData.js +0 -60
  142. package/dist/services/removeCurrencySymbols.d.ts +0 -21
  143. package/dist/services/removeCurrencySymbols.d.ts.map +0 -1
  144. package/dist/services/removeNonNumeric.d.ts +0 -16
  145. package/dist/services/removeNonNumeric.d.ts.map +0 -1
  146. package/dist/services/removeNonNumeric.js +0 -16
  147. package/dist/services/stripHtmlTags.d.ts +0 -16
  148. package/dist/services/stripHtmlTags.d.ts.map +0 -1
  149. package/dist/services/stripHtmlTags.js +0 -16
  150. package/dist/services/truncateLargeFields.d.ts.map +0 -1
  151. package/dist/services/truncateLargeFields.js +0 -57
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripHtmlTags.js","names":[],"sources":["../../../src/utilities/stripHtmlTags.ts"],"sourcesContent":["/**\n * Strips HTML tags from a string.\n *\n * This function removes all HTML tags from the provided string by replacing any content\n * that matches the HTML tag pattern with an empty string.\n *\n * @param rawHtml - The HTML string to strip tags from.\n * @returns The plain text with all HTML tags (including `<script>`, `<style>`, and comments) removed.\n *\n * @example\n * ```typescript\n * const strippedHtml = stripHtmlTags(\"<p>Hello <strong>World</strong></p>\");\n * console.log(strippedHtml); // \"Hello World\"\n * ```\n */\n\nfunction stripHtmlTags(rawHtml: string): string {\n\treturn rawHtml\n\t\t.replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, \"\")\n\t\t.replace(/<style\\b[^<]*(?:(?!<\\/style>)<[^<]*)*<\\/style>/gi, \"\")\n\t\t.replace(/<!--[\\s\\S]*?-->/g, \"\")\n\t\t.replace(/<\\/?[a-z][a-z0-9]*[^>]*>/gi, \"\");\n}\n\nexport { stripHtmlTags };\n"],"mappings":";AAgBA,SAAS,EAAc,GAAyB;CAC/C,OAAO,EACL,QAAQ,uDAAuD,EAAE,CAAC,CAClE,QAAQ,oDAAoD,EAAE,CAAC,CAC/D,QAAQ,oBAAoB,EAAE,CAAC,CAC/B,QAAQ,8BAA8B,EAAE;AAC3C"}
@@ -1,4 +1,3 @@
1
- type TruncateLargeFieldsFunction = (jsonString: string, maxLength?: number) => string;
2
1
  /**
3
2
  * Truncates large string fields in a JSON string to a specified maximum length.
4
3
  *
@@ -17,16 +16,14 @@ type TruncateLargeFieldsFunction = (jsonString: string, maxLength?: number) => s
17
16
  * const json = JSON.stringify({
18
17
  * name: "John",
19
18
  * description: "A very long description that exceeds the maximum length...",
20
- * nested: {
21
- * details: "Another long string that needs truncation."
22
- * }
19
+ * nested: { details: "Another long string that needs truncation." }
23
20
  * });
24
21
  *
25
- * const result = truncateLargeFields(json, 50);
22
+ * const result = parseLargeFields(json, 50);
26
23
  * console.log(result);
27
24
  * // Output: '{"name":"John","description":"To large information: field as 57 characters","nested":{"details":"To large information: field as 43 characters"}}'
28
25
  * ```
29
26
  */
30
- declare const truncateLargeFields: TruncateLargeFieldsFunction;
31
- export { truncateLargeFields };
32
- //# sourceMappingURL=truncateLargeFields.d.ts.map
27
+ declare function parseLargeFields(jsonString: string, maxLength?: number): string;
28
+ export { parseLargeFields };
29
+ //# sourceMappingURL=parseLargeFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseLargeFields.d.ts","sourceRoot":"","sources":["../../src/parsers/parseLargeFields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,iBAAS,gBAAgB,CACxB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAa,GACtB,MAAM,CA+BR;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Masks sensitive data in a JSON string by replacing the values of specified keys with "****".
3
+ *
4
+ * @param jsonString - The JSON string to be processed.
5
+ * @param sensitiveKeys - Keys whose values will be replaced with `"****"`. Defaults to `["password", "confirmPassword", "creditCard"]`.
6
+ * @returns A JSON string with sensitive values masked. Returns the original string if it is not valid JSON.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const jsonString = JSON.stringify({
11
+ * username: "user123",
12
+ * password: "secret",
13
+ * profile: { creditCard: "1234-5678-9012-3456" },
14
+ * });
15
+ *
16
+ * const result = parseSensitiveData(jsonString, ["password", "creditCard"]);
17
+ * console.log(result); // Output: '{"username":"user123","password":"****","profile":{"creditCard":"****"}}'
18
+ * ```
19
+ */
20
+ declare function parseSensitiveData(jsonString: string, sensitiveKeys?: string[]): string;
21
+ export { parseSensitiveData };
22
+ //# sourceMappingURL=parseSensitiveData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSensitiveData.d.ts","sourceRoot":"","sources":["../../src/parsers/parseSensitiveData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iBAAS,kBAAkB,CAC1B,UAAU,EAAE,MAAM,EAClB,aAAa,GAAE,MAAM,EAAkD,GACrE,MAAM,CAuCR;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Parses a date (and optional time) string into a JavaScript `Date` object.
3
+ * All calculations are in UTC+0; use `timezone` to shift the result.
4
+ *
5
+ * @param date - Date string in the format determined by `inputFormat`.
6
+ * @param time - Optional time string `"HH:mm:ss"` (defaults to `"00:00:00"`).
7
+ * @param inputFormat - Parsing format:
8
+ * - `"brazilianDate"`: DD/MM/YYYY
9
+ * - `"isoDate"`: MM-DD-YYYY
10
+ * - `"timestamp"`: YYYY-MM-DD
11
+ * @param timezone - UTC offset in hours (e.g. `-3` for UTC-3). Defaults to `0`.
12
+ * @returns A `Date` object representing the parsed date and time.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * parseToDate(["25/12/2023", "15:30:00"], "brazilianDate", -3);
17
+ * // Date: 2023-12-25T12:30:00.000Z
18
+ *
19
+ * parseToDate(["2023-12-25"], "timestamp");
20
+ * // Date: 2023-12-25T00:00:00.000Z
21
+ * ```
22
+ */
23
+ declare function parseToDate([date, time]: string[], inputFormat: "brazilianDate" | "isoDate" | "timestamp", timezone?: number): Date;
24
+ export { parseToDate };
25
+ //# sourceMappingURL=parseToDate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseToDate.d.ts","sourceRoot":"","sources":["../../src/parsers/parseToDate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,iBAAS,WAAW,CACnB,CAAC,IAAI,EAAE,IAAiB,CAAC,EAAE,MAAM,EAAE,EACnC,WAAW,EAAE,eAAe,GAAG,SAAS,GAAG,WAAW,EACtD,QAAQ,GAAE,MAAU,GAClB,IAAI,CAkCN;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Validates date components and input format strings for date-parsing utilities.
3
+ * Enforces 4-digit years, month/day ranges, month-specific day counts, and leap year rules.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const service = new ValidateDateService();
8
+ * service.validateDateParts(2024, 2, 29); // OK — leap year
9
+ * service.validateDateParts(2023, 2, 29); // throws — not a leap year
10
+ * service.validateInputFormat("brazilianDate"); // OK
11
+ * service.validateInputFormat("custom"); // throws
12
+ * ```
13
+ */
14
+ declare class ValidateDateService {
15
+ private isLeapYear;
16
+ private getDaysInMonth;
17
+ private validateDayInMonth;
18
+ /**
19
+ * Throws if year, month, or day are out of valid range or inconsistent with the calendar.
20
+ *
21
+ * @param year - 4-digit year (1000–9999).
22
+ * @param month - Month number (1–12).
23
+ * @param day - Day number (1–31, validated against the specific month).
24
+ */
25
+ validateDateParts(year: number, month: number, day: number): void;
26
+ /**
27
+ * Throws if `format` is not one of `"brazilianDate"`, `"isoDate"`, or `"timestamp"`.
28
+ *
29
+ * @param format - The format string to check.
30
+ */
31
+ validateInputFormat(format: string): void;
32
+ }
33
+ export { ValidateDateService };
34
+ //# sourceMappingURL=validateDateService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateDateService.d.ts","sourceRoot":"","sources":["../../src/services/validateDateService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAM,mBAAmB;IACxB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,kBAAkB;IA2B1B;;;;;;OAMG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAcjE;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAMzC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Calculates the per-installment and total price for a card payment plan with compound interest.
3
+ * No interest is applied when `fees` is `0` or `numberInstallments` is `1`.
4
+ *
5
+ * @param props.cashPrice - The base price of the item.
6
+ * @param props.numberInstallments - Number of installments (must be > 0).
7
+ * @param props.fees - Monthly interest rate (defaults to `0.0349`).
8
+ * @returns `{ totalPrice, installmentPrice }` — both rounded to 2 decimal places.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * calculateCardInstallment({ cashPrice: 1000, numberInstallments: 12, fees: 0.02 });
13
+ * // { totalPrice: 1124.62, installmentPrice: 93.72 }
14
+ * ```
15
+ */
16
+ declare function calculateCardInstallment(props: {
17
+ cashPrice: number;
18
+ numberInstallments: number;
19
+ fees?: number;
20
+ }): {
21
+ totalPrice: number;
22
+ installmentPrice: number;
23
+ };
24
+ export { calculateCardInstallment };
25
+ //# sourceMappingURL=calculateCardInstallment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateCardInstallment.d.ts","sourceRoot":"","sources":["../../src/utilities/calculateCardInstallment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,iBAAS,wBAAwB,CAAC,KAAK,EAAE;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CA4BnD;AAED,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Ensures that a given rawValue string is enclosed in quotes.
3
+ *
4
+ * This function checks if the input string is already enclosed in either single
5
+ * quotes (`'`) or double quotes (`"`). If the string is already quoted, it is
6
+ * returned as-is. Otherwise, the function wraps the string in double quotes.
7
+ *
8
+ * @param rawValue - The string to be checked and potentially quoted.
9
+ * @returns The original string if already quoted, otherwise the string wrapped in double quotes.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * ensureQuotes('example'); // Returns: '"example"'
14
+ * ensureQuotes('"already quoted"'); // Returns: '"already quoted"'
15
+ * ensureQuotes("'single quoted'"); // Returns: "'single quoted'"
16
+ * ```
17
+ */
18
+ declare function ensureQuotes(rawValue: string): string;
19
+ export { ensureQuotes };
20
+ //# sourceMappingURL=ensureQuotes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureQuotes.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureQuotes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type CountryType } from "@arkyn/templates";
2
+ /**
3
+ * Resolves the matching phone mask and country metadata for a given phone number.
4
+ * Masks use `"_"` as digit placeholders. For countries with multiple mask lengths
5
+ * (e.g. Brazil with and without the ninth digit), the mask matching the number's
6
+ * digit count is returned.
7
+ *
8
+ * @param phoneNumber - Phone number in E.164 format (e.g. `"+5511999999999"`).
9
+ * @returns A tuple of `[maskString, CountryType]`.
10
+ * @throws If the number is invalid or no mask is found for the parsed country.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const [mask, country] = findCountryMask("+5511999999999");
15
+ * // mask: "(__) _____-____"
16
+ * // country.name: "Brazil"
17
+ * ```
18
+ */
19
+ declare function findCountryMask(phoneNumber: string): [string, CountryType];
20
+ export { findCountryMask };
21
+ //# sourceMappingURL=findCountryMask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findCountryMask.d.ts","sourceRoot":"","sources":["../../src/utilities/findCountryMask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,kBAAkB,CAAC;AAI/D;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CA+BnE;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Check if a string contains HTML markup.
3
+ *
4
+ * This function uses a regular expression to detect the presence of HTML tags
5
+ * in a string. The check is case-insensitive and detects both opening
6
+ * and closing tags.
7
+ *
8
+ * @param rawString - The string to check.
9
+ * @returns `true` if the string contains HTML markup, `false` otherwise.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * isHtml('<p>Hello world</p>'); // true
14
+ * isHtml('<div>Content</div>'); // true
15
+ * isHtml('Plain text'); // false
16
+ * isHtml(''); // false
17
+ * ```
18
+ */
19
+ declare function isHtml(rawString: string): boolean;
20
+ export { isHtml };
21
+ //# sourceMappingURL=isHtml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isHtml.d.ts","sourceRoot":"","sources":["../../src/utilities/isHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAG1C;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -5,19 +5,18 @@
5
5
  * and removes them using a regular expression. The resulting string
6
6
  * is also trimmed of any leading or trailing whitespace.
7
7
  *
8
- * @param formattedValue - The input string containing currency symbols.
9
- * @returns A string with all currency symbols removed and trimmed of whitespace.
8
+ * @param rawString - The formatted string that may contain currency symbols.
9
+ * @returns The string with all currency symbols removed and trimmed of whitespace.
10
10
  *
11
11
  * @example
12
+ * ```typescript
12
13
  * removeCurrencySymbols("R$13,45"); // "13,45"
13
14
  * removeCurrencySymbols("$123.45"); // "123.45"
14
15
  * removeCurrencySymbols("€99.99"); // "99.99"
15
16
  * removeCurrencySymbols("¥1,000"); // "1,000"
16
17
  * removeCurrencySymbols("123.45"); // "123.45" (no symbols to remove)
18
+ * ```
17
19
  */
18
- const removeCurrencySymbols = (formattedValue) => {
19
- return formattedValue
20
- .replace(/(?:R\$|\p{Sc}|[$€¥£])/gu, "") // Inclui "R$" e outros símbolos comuns
21
- .trim();
22
- };
20
+ declare function removeCurrencySymbols(rawString: string): string;
23
21
  export { removeCurrencySymbols };
22
+ //# sourceMappingURL=removeCurrencySymbols.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeCurrencySymbols.d.ts","sourceRoot":"","sources":["../../src/utilities/removeCurrencySymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iBAAS,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Removes all non-numeric characters from a given string.
3
+ *
4
+ * @param rawString - The input string to strip non-numeric characters from.
5
+ * @returns A new string containing only the numeric characters from the input.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const result = removeNonNumeric("abc123def456");
10
+ * console.log(result); // Output: "123456"
11
+ * ```
12
+ */
13
+ declare function removeNonNumeric(rawString: string): string;
14
+ export { removeNonNumeric };
15
+ //# sourceMappingURL=removeNonNumeric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeNonNumeric.d.ts","sourceRoot":"","sources":["../../src/utilities/removeNonNumeric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iBAAS,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Strips HTML tags from a string.
3
+ *
4
+ * This function removes all HTML tags from the provided string by replacing any content
5
+ * that matches the HTML tag pattern with an empty string.
6
+ *
7
+ * @param rawHtml - The HTML string to strip tags from.
8
+ * @returns The plain text with all HTML tags (including `<script>`, `<style>`, and comments) removed.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const strippedHtml = stripHtmlTags("<p>Hello <strong>World</strong></p>");
13
+ * console.log(strippedHtml); // "Hello World"
14
+ * ```
15
+ */
16
+ declare function stripHtmlTags(rawHtml: string): string;
17
+ export { stripHtmlTags };
18
+ //# sourceMappingURL=stripHtmlTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripHtmlTags.d.ts","sourceRoot":"","sources":["../../src/utilities/stripHtmlTags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@arkyn/shared",
3
- "version": "3.0.1-beta.99",
4
- "main": "./dist/bundle.js",
5
- "module": "./dist/bundle.js",
3
+ "version": "3.0.3",
4
+ "main": "./dist/index.js",
5
+ "module": "./dist/index.js",
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
8
8
  "license": "Apache-2.0",
@@ -11,7 +11,6 @@
11
11
  "keywords": [
12
12
  "utilities",
13
13
  "formatting",
14
- "validation",
15
14
  "brazilian-documents",
16
15
  "cpf",
17
16
  "cnpj",
@@ -20,27 +19,267 @@
20
19
  "typescript",
21
20
  "generators"
22
21
  ],
23
- "homepage": "https://docs.arkyn.dev/en/shared/introduction",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "engines": {
26
+ "node": ">=18.0.0",
27
+ "bun": ">=1.0.0"
28
+ },
29
+ "homepage": "https://docs.arkyn.dev/docs/shared/introduction",
24
30
  "repository": {
25
31
  "type": "git",
26
- "url": "git+https://github.com/Lucas-Eduardo-Goncalves/arkyn.git",
32
+ "url": "git+https://github.com/Lucas-Eduardo-Goncalves/arkyn-library.git",
27
33
  "directory": "packages/shared"
28
34
  },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE.txt"
39
+ ],
40
+ "sideEffects": false,
29
41
  "scripts": {
30
- "clean": "rm -rf dist",
31
- "build": "bunx vite build && tsc",
32
- "test": "vitest --config vitest.config.ts",
42
+ "audit": "bun audit --workspace packages/shared",
43
+ "build": "bunx vite build && bunx tsc --project tsconfig.json --emitDeclarationOnly && bun ./generate-exports.ts && rm -f dist/modules/index.js dist/modules/style.css",
44
+ "prebuild": "rm -rf dist",
45
+ "publish:beta": "npm publish --tag beta",
46
+ "publish:latest": "npm publish --tag latest",
47
+ "release:beta": "bun ./generate-version.ts beta",
48
+ "release:patch": "bun ./generate-version.ts patch",
49
+ "release:minor": "bun ./generate-version.ts minor",
50
+ "release:major": "bun ./generate-version.ts major",
51
+ "test": "bunx vitest --config vitest.config.ts --run",
52
+ "test:watch": "bunx vitest --config vitest.config.ts --watch",
33
53
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
34
54
  },
35
55
  "dependencies": {
36
- "util": "^0.12.5",
37
- "uuid": "^10.0.0"
56
+ "@arkyn/templates": ">=3.0.2"
57
+ },
58
+ "peerDependencies": {
59
+ "libphonenumber-js": ">=1.13.7"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "libphonenumber-js": {
63
+ "optional": true
64
+ }
38
65
  },
39
66
  "devDependencies": {
40
- "@types/uuid": "^10.0.0",
41
- "bun-types": "latest",
42
- "vitest": "^3.2.4",
43
- "typescript": "^5.9.2",
44
- "vite": "^5.4.19"
67
+ "@types/bun": "catalog:",
68
+ "@types/node": "catalog:",
69
+ "libphonenumber-js": "catalog:",
70
+ "typescript": "catalog:",
71
+ "vite": "catalog:",
72
+ "vitest": "catalog:"
73
+ },
74
+ "exports": {
75
+ ".": {
76
+ "import": "./dist/index.js",
77
+ "types": "./dist/index.d.ts",
78
+ "default": "./dist/index.js"
79
+ },
80
+ "./calculateCardInstallment": {
81
+ "import": "./dist/modules/utilities/calculateCardInstallment.js",
82
+ "types": "./dist/utilities/calculateCardInstallment.d.ts",
83
+ "default": "./dist/modules/utilities/calculateCardInstallment.js"
84
+ },
85
+ "./ensureQuotes": {
86
+ "import": "./dist/modules/utilities/ensureQuotes.js",
87
+ "types": "./dist/utilities/ensureQuotes.d.ts",
88
+ "default": "./dist/modules/utilities/ensureQuotes.js"
89
+ },
90
+ "./findCountryMask": {
91
+ "import": "./dist/modules/utilities/findCountryMask.js",
92
+ "types": "./dist/utilities/findCountryMask.d.ts",
93
+ "default": "./dist/modules/utilities/findCountryMask.js"
94
+ },
95
+ "./formatDate": {
96
+ "import": "./dist/modules/formats/formatDate.js",
97
+ "types": "./dist/formats/formatDate.d.ts",
98
+ "default": "./dist/modules/formats/formatDate.js"
99
+ },
100
+ "./formatJsonObject": {
101
+ "import": "./dist/modules/formats/formatJsonObject.js",
102
+ "types": "./dist/formats/formatJsonObject.d.ts",
103
+ "default": "./dist/modules/formats/formatJsonObject.js"
104
+ },
105
+ "./formatJsonString": {
106
+ "import": "./dist/modules/formats/formatJsonString.js",
107
+ "types": "./dist/formats/formatJsonString.d.ts",
108
+ "default": "./dist/modules/formats/formatJsonString.js"
109
+ },
110
+ "./formatToCapitalizeFirstWordLetter": {
111
+ "import": "./dist/modules/formats/formatToCapitalizeFirstWordLetter.js",
112
+ "types": "./dist/formats/formatToCapitalizeFirstWordLetter.d.ts",
113
+ "default": "./dist/modules/formats/formatToCapitalizeFirstWordLetter.js"
114
+ },
115
+ "./formatToCep": {
116
+ "import": "./dist/modules/formats/formatToCep.js",
117
+ "types": "./dist/formats/formatToCep.d.ts",
118
+ "default": "./dist/modules/formats/formatToCep.js"
119
+ },
120
+ "./formatToCnpj": {
121
+ "import": "./dist/modules/formats/formatToCnpj.js",
122
+ "types": "./dist/formats/formatToCnpj.d.ts",
123
+ "default": "./dist/modules/formats/formatToCnpj.js"
124
+ },
125
+ "./formatToCpf": {
126
+ "import": "./dist/modules/formats/formatToCpf.js",
127
+ "types": "./dist/formats/formatToCpf.d.ts",
128
+ "default": "./dist/modules/formats/formatToCpf.js"
129
+ },
130
+ "./formatToCurrency": {
131
+ "import": "./dist/modules/formats/formatToCurrency.js",
132
+ "types": "./dist/formats/formatToCurrency.d.ts",
133
+ "default": "./dist/modules/formats/formatToCurrency.js"
134
+ },
135
+ "./formatToEllipsis": {
136
+ "import": "./dist/modules/formats/formatToEllipsis.js",
137
+ "types": "./dist/formats/formatToEllipsis.d.ts",
138
+ "default": "./dist/modules/formats/formatToEllipsis.js"
139
+ },
140
+ "./formatToHiddenDigits": {
141
+ "import": "./dist/modules/formats/formatToHiddenDigits.js",
142
+ "types": "./dist/formats/formatToHiddenDigits.d.ts",
143
+ "default": "./dist/modules/formats/formatToHiddenDigits.js"
144
+ },
145
+ "./formatToPhone": {
146
+ "import": "./dist/modules/formats/formatToPhone.js",
147
+ "types": "./dist/formats/formatToPhone.d.ts",
148
+ "default": "./dist/modules/formats/formatToPhone.js"
149
+ },
150
+ "./generateColorByString": {
151
+ "import": "./dist/modules/generators/generateColorByString.js",
152
+ "types": "./dist/generators/generateColorByString.d.ts",
153
+ "default": "./dist/modules/generators/generateColorByString.js"
154
+ },
155
+ "./generateId": {
156
+ "import": "./dist/modules/generators/generateId.js",
157
+ "types": "./dist/generators/generateId.d.ts",
158
+ "default": "./dist/modules/generators/generateId.js"
159
+ },
160
+ "./generateSlug": {
161
+ "import": "./dist/modules/generators/generateSlug.js",
162
+ "types": "./dist/generators/generateSlug.d.ts",
163
+ "default": "./dist/modules/generators/generateSlug.js"
164
+ },
165
+ "./isHtml": {
166
+ "import": "./dist/modules/utilities/isHtml.js",
167
+ "types": "./dist/utilities/isHtml.d.ts",
168
+ "default": "./dist/modules/utilities/isHtml.js"
169
+ },
170
+ "./parseLargeFields": {
171
+ "import": "./dist/modules/parsers/parseLargeFields.js",
172
+ "types": "./dist/parsers/parseLargeFields.d.ts",
173
+ "default": "./dist/modules/parsers/parseLargeFields.js"
174
+ },
175
+ "./parseSensitiveData": {
176
+ "import": "./dist/modules/parsers/parseSensitiveData.js",
177
+ "types": "./dist/parsers/parseSensitiveData.d.ts",
178
+ "default": "./dist/modules/parsers/parseSensitiveData.js"
179
+ },
180
+ "./parseToDate": {
181
+ "import": "./dist/modules/parsers/parseToDate.js",
182
+ "types": "./dist/parsers/parseToDate.d.ts",
183
+ "default": "./dist/modules/parsers/parseToDate.js"
184
+ },
185
+ "./removeCurrencySymbols": {
186
+ "import": "./dist/modules/utilities/removeCurrencySymbols.js",
187
+ "types": "./dist/utilities/removeCurrencySymbols.d.ts",
188
+ "default": "./dist/modules/utilities/removeCurrencySymbols.js"
189
+ },
190
+ "./removeNonNumeric": {
191
+ "import": "./dist/modules/utilities/removeNonNumeric.js",
192
+ "types": "./dist/utilities/removeNonNumeric.d.ts",
193
+ "default": "./dist/modules/utilities/removeNonNumeric.js"
194
+ },
195
+ "./stripHtmlTags": {
196
+ "import": "./dist/modules/utilities/stripHtmlTags.js",
197
+ "types": "./dist/utilities/stripHtmlTags.d.ts",
198
+ "default": "./dist/modules/utilities/stripHtmlTags.js"
199
+ },
200
+ "./validateDateService": {
201
+ "import": "./dist/modules/services/validateDateService.js",
202
+ "types": "./dist/services/validateDateService.d.ts",
203
+ "default": "./dist/modules/services/validateDateService.js"
204
+ }
205
+ },
206
+ "typesVersions": {
207
+ "*": {
208
+ "calculateCardInstallment": [
209
+ "./dist/utilities/calculateCardInstallment.d.ts"
210
+ ],
211
+ "ensureQuotes": [
212
+ "./dist/utilities/ensureQuotes.d.ts"
213
+ ],
214
+ "findCountryMask": [
215
+ "./dist/utilities/findCountryMask.d.ts"
216
+ ],
217
+ "formatDate": [
218
+ "./dist/formats/formatDate.d.ts"
219
+ ],
220
+ "formatJsonObject": [
221
+ "./dist/formats/formatJsonObject.d.ts"
222
+ ],
223
+ "formatJsonString": [
224
+ "./dist/formats/formatJsonString.d.ts"
225
+ ],
226
+ "formatToCapitalizeFirstWordLetter": [
227
+ "./dist/formats/formatToCapitalizeFirstWordLetter.d.ts"
228
+ ],
229
+ "formatToCep": [
230
+ "./dist/formats/formatToCep.d.ts"
231
+ ],
232
+ "formatToCnpj": [
233
+ "./dist/formats/formatToCnpj.d.ts"
234
+ ],
235
+ "formatToCpf": [
236
+ "./dist/formats/formatToCpf.d.ts"
237
+ ],
238
+ "formatToCurrency": [
239
+ "./dist/formats/formatToCurrency.d.ts"
240
+ ],
241
+ "formatToEllipsis": [
242
+ "./dist/formats/formatToEllipsis.d.ts"
243
+ ],
244
+ "formatToHiddenDigits": [
245
+ "./dist/formats/formatToHiddenDigits.d.ts"
246
+ ],
247
+ "formatToPhone": [
248
+ "./dist/formats/formatToPhone.d.ts"
249
+ ],
250
+ "generateColorByString": [
251
+ "./dist/generators/generateColorByString.d.ts"
252
+ ],
253
+ "generateId": [
254
+ "./dist/generators/generateId.d.ts"
255
+ ],
256
+ "generateSlug": [
257
+ "./dist/generators/generateSlug.d.ts"
258
+ ],
259
+ "isHtml": [
260
+ "./dist/utilities/isHtml.d.ts"
261
+ ],
262
+ "parseLargeFields": [
263
+ "./dist/parsers/parseLargeFields.d.ts"
264
+ ],
265
+ "parseSensitiveData": [
266
+ "./dist/parsers/parseSensitiveData.d.ts"
267
+ ],
268
+ "parseToDate": [
269
+ "./dist/parsers/parseToDate.d.ts"
270
+ ],
271
+ "removeCurrencySymbols": [
272
+ "./dist/utilities/removeCurrencySymbols.d.ts"
273
+ ],
274
+ "removeNonNumeric": [
275
+ "./dist/utilities/removeNonNumeric.d.ts"
276
+ ],
277
+ "stripHtmlTags": [
278
+ "./dist/utilities/stripHtmlTags.d.ts"
279
+ ],
280
+ "validateDateService": [
281
+ "./dist/services/validateDateService.d.ts"
282
+ ]
283
+ }
45
284
  }
46
285
  }