@arkyn/shared 2.2.15 → 3.0.1-beta.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.
- package/dist/formats/formatDate.d.ts +3 -1
- package/dist/formats/formatDate.d.ts.map +1 -1
- package/dist/formats/formatJsonObject.d.ts +1 -1
- package/dist/formats/formatJsonObject.d.ts.map +1 -1
- package/dist/formats/formatJsonString.d.ts +1 -1
- package/dist/formats/formatJsonString.d.ts.map +1 -1
- package/dist/formats/formatToCep.d.ts +1 -1
- package/dist/formats/formatToCep.d.ts.map +1 -1
- package/dist/formats/formatToCnpj.d.ts +1 -1
- package/dist/formats/formatToCnpj.d.ts.map +1 -1
- package/dist/formats/formatToCpf.d.ts +1 -1
- package/dist/formats/formatToCpf.d.ts.map +1 -1
- package/dist/formats/formatToCpfCnpj.d.ts +1 -1
- package/dist/formats/formatToCpfCnpj.d.ts.map +1 -1
- package/dist/formats/formatToCurrency.d.ts +6 -1
- package/dist/formats/formatToCurrency.d.ts.map +1 -1
- package/dist/formats/formatToDate.d.ts +3 -1
- package/dist/formats/formatToDate.d.ts.map +1 -1
- package/dist/formats/formatToDate.js +26 -0
- package/dist/formats/formatToEllipsis.d.ts +1 -1
- package/dist/formats/formatToEllipsis.d.ts.map +1 -1
- package/dist/formats/formatToHiddenDigits.d.ts +4 -1
- package/dist/formats/formatToHiddenDigits.d.ts.map +1 -1
- package/dist/formats/formatToPhone.d.ts +1 -1
- package/dist/formats/formatToPhone.d.ts.map +1 -1
- package/dist/generators/generateColorByString.d.ts +1 -1
- package/dist/generators/generateColorByString.d.ts.map +1 -1
- package/dist/services/calculateCardInstallment.d.ts +8 -1
- package/dist/services/calculateCardInstallment.d.ts.map +1 -1
- package/dist/services/ensureQuotes.d.ts +1 -1
- package/dist/services/ensureQuotes.d.ts.map +1 -1
- package/dist/services/maskSensitiveData.d.ts +1 -1
- package/dist/services/maskSensitiveData.d.ts.map +1 -1
- package/dist/services/removeCurrencySymbols.d.ts +2 -1
- package/dist/services/removeCurrencySymbols.d.ts.map +1 -1
- package/dist/services/removeNonNumeric.d.ts +2 -1
- package/dist/services/removeNonNumeric.d.ts.map +1 -1
- package/dist/services/removeNonNumeric.js +2 -2
- package/dist/services/stripHtmlTags.d.ts +1 -1
- package/dist/services/stripHtmlTags.d.ts.map +1 -1
- package/dist/services/truncateLargeFields.d.ts +1 -1
- package/dist/services/truncateLargeFields.d.ts.map +1 -1
- package/dist/validations/validateCep.d.ts +1 -1
- package/dist/validations/validateCep.d.ts.map +1 -1
- package/dist/validations/validateCnpj.d.ts +1 -1
- package/dist/validations/validateCnpj.d.ts.map +1 -1
- package/dist/validations/validateCpf.d.ts +1 -1
- package/dist/validations/validateCpf.d.ts.map +1 -1
- package/dist/validations/validateDate.d.ts +6 -1
- package/dist/validations/validateDate.d.ts.map +1 -1
- package/dist/validations/validatePassword.d.ts +1 -1
- package/dist/validations/validatePassword.d.ts.map +1 -1
- package/dist/validations/validatePhone.d.ts +1 -1
- package/dist/validations/validatePhone.d.ts.map +1 -1
- package/dist/validations/validateRg.d.ts +1 -1
- package/dist/validations/validateRg.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/formats/formatDate.ts +8 -1
- package/src/formats/formatJsonObject.ts +1 -1
- package/src/formats/formatJsonString.ts +2 -1
- package/src/formats/formatToCep.ts +2 -1
- package/src/formats/formatToCnpj.ts +2 -1
- package/src/formats/formatToCpf.ts +2 -1
- package/src/formats/formatToCpfCnpj.ts +2 -2
- package/src/formats/formatToCurrency.ts +12 -2
- package/src/formats/formatToDate.ts +8 -1
- package/src/formats/formatToEllipsis.ts +1 -1
- package/src/formats/formatToHiddenDigits.ts +5 -2
- package/src/formats/formatToPhone.ts +11 -1
- package/src/generators/generateColorByString.ts +1 -1
- package/src/services/calculateCardInstallment.ts +8 -1
- package/src/services/ensureQuotes.ts +1 -1
- package/src/services/maskSensitiveData.ts +4 -1
- package/src/services/removeCurrencySymbols.ts +5 -1
- package/src/services/removeNonNumeric.ts +4 -2
- package/src/services/stripHtmlTags.ts +1 -1
- package/src/services/truncateLargeFields.ts +4 -1
- package/src/validations/validateCep.ts +2 -1
- package/src/validations/validateCnpj.ts +2 -1
- package/src/validations/validateCpf.ts +2 -1
- package/src/validations/validateDate.ts +10 -1
- package/src/validations/validatePassword.ts +1 -1
- package/src/validations/validatePhone.ts +2 -1
- package/src/validations/validateRg.ts +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type InputFormatTypes = "brazilianDate" | "isoDate" | "timestamp";
|
|
2
|
+
type FormatDateFunction = (date: string[], // [date: string, time?: string]
|
|
3
|
+
inputFormat: InputFormatTypes, outputFormat: string, timezone?: number) => string;
|
|
2
4
|
/**
|
|
3
5
|
* Formats a date and time string based on the provided input and output formats.
|
|
4
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../../src/formats/formatDate.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../../src/formats/formatDate.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG,eAAe,GAAG,SAAS,GAAG,WAAW,CAAC;AAElE,KAAK,kBAAkB,GAAG,CACxB,IAAI,EAAE,MAAM,EAAE,EAAE,gCAAgC;AAChD,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,KACd,MAAM,CAAC;AAqBZ;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,QAAA,MAAM,UAAU,EAAE,kBAgCjB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatJsonObject.d.ts","sourceRoot":"","sources":["../../src/formats/formatJsonObject.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"formatJsonObject.d.ts","sourceRoot":"","sources":["../../src/formats/formatJsonObject.ts"],"names":[],"mappings":"AAAA,KAAK,wBAAwB,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,QAAA,MAAM,gBAAgB,EAAE,wBAuDvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatJsonString.d.ts","sourceRoot":"","sources":["../../src/formats/formatJsonString.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatJsonString.d.ts","sourceRoot":"","sources":["../../src/formats/formatJsonString.ts"],"names":[],"mappings":"AAEA,KAAK,wBAAwB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,QAAA,MAAM,gBAAgB,EAAE,wBAOvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCep.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCep.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToCep.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCep.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,QAAA,MAAM,WAAW,EAAE,mBAMlB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCnpj.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCnpj.ts"],"names":[],"mappings":"AAEA,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,QAAA,MAAM,YAAY,EAAE,oBAMnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCpf.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToCpf.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpf.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,QAAA,MAAM,WAAW,EAAE,mBAMlB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCpfCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpfCnpj.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToCpfCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpfCnpj.ts"],"names":[],"mappings":"AAGA,KAAK,uBAAuB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,QAAA,MAAM,eAAe,EAAE,uBAStB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { countryCurrencies } from "@arkyn/templates";
|
|
2
|
+
type Currencies = keyof typeof countryCurrencies;
|
|
3
|
+
type Config = {
|
|
4
|
+
showPrefix?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type FormatToCurrency = (value: number, currency: Currencies, config?: Config) => string;
|
|
2
7
|
/**
|
|
3
8
|
* Formats a numeric value into a currency string based on the specified currency and configuration.
|
|
4
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCurrency.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCurrency.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToCurrency.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,KAAK,UAAU,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEjD,KAAK,MAAM,GAAG;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,gBAAgB,GAAG,CACtB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,UAAU,EACpB,MAAM,CAAC,EAAE,MAAM,KACZ,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,QAAA,MAAM,gBAAgB,EAAE,gBAmBvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
type InputFormatTypes = "brazilianDate" | "timestamp" | "isoDate";
|
|
2
|
+
type FormatToDateFunction = (date: string[], // [date: string, time?: string]
|
|
3
|
+
inputFormat: InputFormatTypes, timezone?: number) => Date;
|
|
1
4
|
/**
|
|
2
5
|
* Converts a date and time input into a JavaScript `Date` object, formatted according to the specified input format and timezone.
|
|
3
6
|
*
|
|
@@ -24,7 +27,6 @@
|
|
|
24
27
|
* console.log(date); // Outputs a Date object for "2023-12-25T18:30:00.000Z" (UTC)
|
|
25
28
|
* ```
|
|
26
29
|
*/
|
|
27
|
-
import type { FormatToDateFunction } from "@arkyn/types";
|
|
28
30
|
declare const formatToDate: FormatToDateFunction;
|
|
29
31
|
export { formatToDate };
|
|
30
32
|
//# sourceMappingURL=formatToDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToDate.d.ts","sourceRoot":"","sources":["../../src/formats/formatToDate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"formatToDate.d.ts","sourceRoot":"","sources":["../../src/formats/formatToDate.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG,eAAe,GAAG,WAAW,GAAG,SAAS,CAAC;AAElE,KAAK,oBAAoB,GAAG,CAC1B,IAAI,EAAE,MAAM,EAAE,EAAE,gCAAgC;AAChD,WAAW,EAAE,gBAAgB,EAC7B,QAAQ,CAAC,EAAE,MAAM,KACd,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,QAAA,MAAM,YAAY,EAAE,oBAgCnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a date and time input into a JavaScript `Date` object, formatted according to the specified input format and timezone.
|
|
3
|
+
*
|
|
4
|
+
* @param param0 - A tuple containing the date string and an optional time string.
|
|
5
|
+
* The date string format depends on the `inputFormat` parameter.
|
|
6
|
+
* The time string defaults to "00:00:00" if not provided.
|
|
7
|
+
* @param inputFormat - The format of the input date string.
|
|
8
|
+
* Supported formats are:
|
|
9
|
+
* - `"brazilianDate"`: Expects the date in `DD/MM/YYYY` format.
|
|
10
|
+
* - `"isoDate"`: Expects the date in `YYYY-MM-DD` format.
|
|
11
|
+
* - `"timestamp"`: Expects the date in `YYYY-MM-DD` format (similar to `isoDate`).
|
|
12
|
+
* @param timezone - An optional timezone offset in hours. Defaults to `0` (UTC).
|
|
13
|
+
*
|
|
14
|
+
* @returns A `Date` object representing the parsed date and time, adjusted for the specified timezone.
|
|
15
|
+
*
|
|
16
|
+
* @throws {Error} If the `inputFormat` is invalid.
|
|
17
|
+
* @throws {Error} If the provided date or time is invalid.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { formatToDate } from "./formatToIsoDate";
|
|
22
|
+
*
|
|
23
|
+
* const date = formatToDate(["25/12/2023", "15:30:00"], "brazilianDate", -3);
|
|
24
|
+
* console.log(date); // Outputs a Date object for "2023-12-25T18:30:00.000Z" (UTC)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
1
27
|
const formatToDate = ([date, time = "00:00:00"], inputFormat, timezone = 0) => {
|
|
2
28
|
const dateParts = date.split(/[-/]/).map(Number);
|
|
3
29
|
const timeParts = time.split(".")[0].split(":").map(Number);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type FormatToEllipsisFunction = (value: string, maxLength: number) => string;
|
|
2
2
|
/**
|
|
3
3
|
* Truncates a given text to a specified maximum length and appends an ellipsis ("...")
|
|
4
4
|
* if the text exceeds the maximum length.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToEllipsis.d.ts","sourceRoot":"","sources":["../../src/formats/formatToEllipsis.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"formatToEllipsis.d.ts","sourceRoot":"","sources":["../../src/formats/formatToEllipsis.ts"],"names":[],"mappings":"AAAA,KAAK,wBAAwB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;AAE7E;;;;;;;;;;;GAWG;AAEH,QAAA,MAAM,gBAAgB,EAAE,wBAOvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type FormatToHiddenDigitsFunction = (value: string, options: {
|
|
2
|
+
range?: number | [number, number];
|
|
3
|
+
hider?: string;
|
|
4
|
+
}) => string;
|
|
2
5
|
/**
|
|
3
6
|
* Formats a string by hiding specific digits within a given range.
|
|
4
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToHiddenDigits.d.ts","sourceRoot":"","sources":["../../src/formats/formatToHiddenDigits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToHiddenDigits.d.ts","sourceRoot":"","sources":["../../src/formats/formatToHiddenDigits.ts"],"names":[],"mappings":"AAmBA,KAAK,4BAA4B,GAAG,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3D,MAAM,CAAC;AA4BZ;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,QAAA,MAAM,oBAAoB,EAAE,4BAU3B,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToPhone.d.ts","sourceRoot":"","sources":["../../src/formats/formatToPhone.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToPhone.d.ts","sourceRoot":"","sources":["../../src/formats/formatToPhone.ts"],"names":[],"mappings":"AAaA,KAAK,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAmGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,QAAA,MAAM,aAAa,EAAE,qBAwBpB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type GenerateColorByStringFunction = (prop: string) => string;
|
|
2
2
|
/**
|
|
3
3
|
* Generates a hexadecimal color code based on the input string.
|
|
4
4
|
* The function creates a hash from the string and uses it to calculate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateColorByString.d.ts","sourceRoot":"","sources":["../../src/generators/generateColorByString.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"generateColorByString.d.ts","sourceRoot":"","sources":["../../src/generators/generateColorByString.ts"],"names":[],"mappings":"AAAA,KAAK,6BAA6B,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAE9D;;;;;;;;;;GAUG;AAEH,QAAA,MAAM,qBAAqB,EAAE,6BAgB5B,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type CalculateCardInstallmentFunction = (props: {
|
|
2
|
+
cashPrice: number;
|
|
3
|
+
numberInstallments: number;
|
|
4
|
+
fees?: number;
|
|
5
|
+
}) => {
|
|
6
|
+
totalPrice: number;
|
|
7
|
+
installmentPrice: number;
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* Calculates the installment price and total price for a card payment plan.
|
|
4
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateCardInstallment.d.ts","sourceRoot":"","sources":["../../src/services/calculateCardInstallment.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"calculateCardInstallment.d.ts","sourceRoot":"","sources":["../../src/services/calculateCardInstallment.ts"],"names":[],"mappings":"AAAA,KAAK,gCAAgC,GAAG,CAAC,KAAK,EAAE;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,KAAK;IACJ,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,QAAA,MAAM,wBAAwB,EAAE,gCA+B/B,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureQuotes.d.ts","sourceRoot":"","sources":["../../src/services/ensureQuotes.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ensureQuotes.d.ts","sourceRoot":"","sources":["../../src/services/ensureQuotes.ts"],"names":[],"mappings":"AAAA,KAAK,oBAAoB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzD;;;;;;;;;GASG;AAEH,QAAA,MAAM,YAAY,EAAE,oBASnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maskSensitiveData.d.ts","sourceRoot":"","sources":["../../src/services/maskSensitiveData.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"maskSensitiveData.d.ts","sourceRoot":"","sources":["../../src/services/maskSensitiveData.ts"],"names":[],"mappings":"AAAA,KAAK,yBAAyB,GAAG,CAC/B,UAAU,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,EAAE,KACrB,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,QAAA,MAAM,iBAAiB,EAAE,yBAqCxB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type RemoveCurrencySymbolsFunction = (formattedValue: string) => string;
|
|
1
2
|
/**
|
|
2
3
|
* Removes currency symbols from a given formatted string.
|
|
3
4
|
*
|
|
@@ -15,6 +16,6 @@
|
|
|
15
16
|
* removeCurrencySymbols("¥1,000"); // "1,000"
|
|
16
17
|
* removeCurrencySymbols("123.45"); // "123.45" (no symbols to remove)
|
|
17
18
|
*/
|
|
18
|
-
declare const removeCurrencySymbols:
|
|
19
|
+
declare const removeCurrencySymbols: RemoveCurrencySymbolsFunction;
|
|
19
20
|
export { removeCurrencySymbols };
|
|
20
21
|
//# sourceMappingURL=removeCurrencySymbols.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeCurrencySymbols.d.ts","sourceRoot":"","sources":["../../src/services/removeCurrencySymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,QAAA,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"removeCurrencySymbols.d.ts","sourceRoot":"","sources":["../../src/services/removeCurrencySymbols.ts"],"names":[],"mappings":"AAAA,KAAK,6BAA6B,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;AAExE;;;;;;;;;;;;;;;;GAgBG;AAEH,QAAA,MAAM,qBAAqB,EAAE,6BAM5B,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type RemoveNonNumericFunction = (formattedValue: string) => string;
|
|
1
2
|
/**
|
|
2
3
|
* Removes all non-numeric characters from a given string.
|
|
3
4
|
*
|
|
@@ -10,6 +11,6 @@
|
|
|
10
11
|
* console.log(result); // Output: "123456"
|
|
11
12
|
* ```
|
|
12
13
|
*/
|
|
13
|
-
declare
|
|
14
|
+
declare const removeNonNumeric: RemoveNonNumericFunction;
|
|
14
15
|
export { removeNonNumeric };
|
|
15
16
|
//# sourceMappingURL=removeNonNumeric.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeNonNumeric.d.ts","sourceRoot":"","sources":["../../src/services/removeNonNumeric.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"removeNonNumeric.d.ts","sourceRoot":"","sources":["../../src/services/removeNonNumeric.ts"],"names":[],"mappings":"AAAA,KAAK,wBAAwB,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnE;;;;;;;;;;;GAWG;AAEH,QAAA,MAAM,gBAAgB,EAAE,wBAEvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripHtmlTags.d.ts","sourceRoot":"","sources":["../../src/services/stripHtmlTags.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"stripHtmlTags.d.ts","sourceRoot":"","sources":["../../src/services/stripHtmlTags.ts"],"names":[],"mappings":"AAAA,KAAK,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzD;;;;;;;;;;;GAWG;AAEH,QAAA,MAAM,aAAa,EAAE,qBAEpB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truncateLargeFields.d.ts","sourceRoot":"","sources":["../../src/services/truncateLargeFields.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"truncateLargeFields.d.ts","sourceRoot":"","sources":["../../src/services/truncateLargeFields.ts"],"names":[],"mappings":"AAAA,KAAK,2BAA2B,GAAG,CACjC,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,KACf,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,QAAA,MAAM,mBAAmB,EAAE,2BAgC1B,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCep.d.ts","sourceRoot":"","sources":["../../src/validations/validateCep.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCep.d.ts","sourceRoot":"","sources":["../../src/validations/validateCep.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvD;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,QAAA,MAAM,WAAW,EAAE,mBAYlB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCnpj.d.ts","sourceRoot":"","sources":["../../src/validations/validateCnpj.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCnpj.d.ts","sourceRoot":"","sources":["../../src/validations/validateCnpj.ts"],"names":[],"mappings":"AAEA,KAAK,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;AAyBzD;;;;;;;;;;;;;;;;;GAiBG;AAEH,QAAA,MAAM,YAAY,EAAE,oBAgBnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCpf.d.ts","sourceRoot":"","sources":["../../src/validations/validateCpf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCpf.d.ts","sourceRoot":"","sources":["../../src/validations/validateCpf.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;AAyBvD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,QAAA,MAAM,WAAW,EAAE,mBAWlB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type ValidateDateConfig = {
|
|
2
|
+
inputFormat?: "DD/MM/YYYY" | "MM-DD-YYYY" | "YYYY-MM-DD";
|
|
3
|
+
minYear?: number;
|
|
4
|
+
maxYear?: number;
|
|
5
|
+
};
|
|
6
|
+
type ValidateDateFunction = (rawDate: string, config?: ValidateDateConfig) => boolean;
|
|
2
7
|
/**
|
|
3
8
|
* Validates a date string based on the provided format and configuration.
|
|
4
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateDate.d.ts","sourceRoot":"","sources":["../../src/validations/validateDate.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validateDate.d.ts","sourceRoot":"","sources":["../../src/validations/validateDate.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG;IACxB,WAAW,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,oBAAoB,GAAG,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,QAAA,MAAM,YAAY,EAAE,oBA8CnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePassword.d.ts","sourceRoot":"","sources":["../../src/validations/validatePassword.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"validatePassword.d.ts","sourceRoot":"","sources":["../../src/validations/validatePassword.ts"],"names":[],"mappings":"AAAA,KAAK,wBAAwB,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;AAEjE;;;;;;;;;;;;;;;;GAgBG;AAEH,QAAA,MAAM,gBAAgB,EAAE,wBAkBvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,QAAA,MAAM,aAAa,EAAE,qBAiBpB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateRg.d.ts","sourceRoot":"","sources":["../../src/validations/validateRg.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"validateRg.d.ts","sourceRoot":"","sources":["../../src/validations/validateRg.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAErD;;;;;;;;;;;;;;;;;GAiBG;AAEH,QAAA,MAAM,UAAU,EAAE,kBAajB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type InputFormatTypes = "brazilianDate" | "isoDate" | "timestamp";
|
|
2
|
+
|
|
3
|
+
type FormatDateFunction = (
|
|
4
|
+
date: string[], // [date: string, time?: string]
|
|
5
|
+
inputFormat: InputFormatTypes,
|
|
6
|
+
outputFormat: string,
|
|
7
|
+
timezone?: number
|
|
8
|
+
) => string;
|
|
2
9
|
|
|
3
10
|
function formatDateString(date: Date, format: string): string {
|
|
4
11
|
const pad = (num: number) => num.toString().padStart(2, "0");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FormatToCnpjFunction } from "@arkyn/types";
|
|
2
1
|
import { removeNonNumeric } from "../services/removeNonNumeric";
|
|
3
2
|
|
|
3
|
+
type FormatToCnpjFunction = (value: string) => string;
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Formats a given string or number into a CNPJ (Cadastro Nacional da Pessoa Jurídica) format.
|
|
6
7
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FormatToCpfFunction } from "@arkyn/types";
|
|
2
1
|
import { removeNonNumeric } from "../services/removeNonNumeric";
|
|
3
2
|
|
|
3
|
+
type FormatToCpfFunction = (value: string) => string;
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Formats a given string into a CPF (Cadastro de Pessoas Físicas) format.
|
|
6
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FormatToCpfCnpjFunction } from "@arkyn/types";
|
|
2
|
-
|
|
3
1
|
import { formatToCnpj } from "./formatToCnpj";
|
|
4
2
|
import { formatToCpf } from "./formatToCpf";
|
|
5
3
|
|
|
4
|
+
type FormatToCpfCnpjFunction = (value: string) => string;
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* Formats a given string value into either a CPF or CNPJ format based on its length.
|
|
8
8
|
*
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { countryCurrencies } from "@arkyn/templates";
|
|
2
|
-
import type { FormatToCurrency } from "@arkyn/types";
|
|
3
|
-
|
|
4
2
|
import { removeCurrencySymbols } from "../services/removeCurrencySymbols";
|
|
5
3
|
|
|
4
|
+
type Currencies = keyof typeof countryCurrencies;
|
|
5
|
+
|
|
6
|
+
type Config = {
|
|
7
|
+
showPrefix?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type FormatToCurrency = (
|
|
11
|
+
value: number,
|
|
12
|
+
currency: Currencies,
|
|
13
|
+
config?: Config
|
|
14
|
+
) => string;
|
|
15
|
+
|
|
6
16
|
/**
|
|
7
17
|
* Formats a numeric value into a currency string based on the specified currency and configuration.
|
|
8
18
|
*
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
type InputFormatTypes = "brazilianDate" | "timestamp" | "isoDate";
|
|
2
|
+
|
|
3
|
+
type FormatToDateFunction = (
|
|
4
|
+
date: string[], // [date: string, time?: string]
|
|
5
|
+
inputFormat: InputFormatTypes,
|
|
6
|
+
timezone?: number
|
|
7
|
+
) => Date;
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* Converts a date and time input into a JavaScript `Date` object, formatted according to the specified input format and timezone.
|
|
3
11
|
*
|
|
@@ -24,7 +32,6 @@
|
|
|
24
32
|
* console.log(date); // Outputs a Date object for "2023-12-25T18:30:00.000Z" (UTC)
|
|
25
33
|
* ```
|
|
26
34
|
*/
|
|
27
|
-
import type { FormatToDateFunction } from "@arkyn/types";
|
|
28
35
|
|
|
29
36
|
const formatToDate: FormatToDateFunction = (
|
|
30
37
|
[date, time = "00:00:00"],
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { FormatToHiddenDigitsFunction } from "@arkyn/types";
|
|
2
|
-
|
|
3
1
|
const DIGIT = /^\d$/;
|
|
4
2
|
|
|
5
3
|
type DigitCharacterNode = {
|
|
@@ -19,6 +17,11 @@ type RootCharacterNode = {
|
|
|
19
17
|
children: (DigitCharacterNode | OtherCharacterNode)[];
|
|
20
18
|
};
|
|
21
19
|
|
|
20
|
+
type FormatToHiddenDigitsFunction = (
|
|
21
|
+
value: string,
|
|
22
|
+
options: { range?: number | [number, number]; hider?: string }
|
|
23
|
+
) => string;
|
|
24
|
+
|
|
22
25
|
const parseToCharacters = (value: string): RootCharacterNode => {
|
|
23
26
|
let digits = 0;
|
|
24
27
|
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { countries } from "@arkyn/templates";
|
|
2
|
-
import type { CountryType, FormatToPhoneFunction } from "@arkyn/types";
|
|
3
2
|
|
|
4
3
|
import { removeNonNumeric } from "../services/removeNonNumeric";
|
|
5
4
|
|
|
5
|
+
type CountryType = {
|
|
6
|
+
name: string;
|
|
7
|
+
code: string;
|
|
8
|
+
iso: string;
|
|
9
|
+
prefix: null | string;
|
|
10
|
+
flag: string;
|
|
11
|
+
mask: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type FormatToPhoneFunction = (prop: string) => string;
|
|
15
|
+
|
|
6
16
|
function getMask(value: string): "NINE" | "EIGTH" {
|
|
7
17
|
const mask = value.length > 10 ? "NINE" : "EIGTH";
|
|
8
18
|
return mask;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type CalculateCardInstallmentFunction = (props: {
|
|
2
|
+
cashPrice: number;
|
|
3
|
+
numberInstallments: number;
|
|
4
|
+
fees?: number;
|
|
5
|
+
}) => {
|
|
6
|
+
totalPrice: number;
|
|
7
|
+
installmentPrice: number;
|
|
8
|
+
};
|
|
2
9
|
|
|
3
10
|
/**
|
|
4
11
|
* Calculates the installment price and total price for a card payment plan.
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type MaskSensitiveDataFunction = (
|
|
2
|
+
jsonString: string,
|
|
3
|
+
sensitiveKeys?: string[]
|
|
4
|
+
) => string;
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Masks sensitive data in a JSON string by replacing the values of specified keys with "****".
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
type RemoveCurrencySymbolsFunction = (formattedValue: string) => string;
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Removes currency symbols from a given formatted string.
|
|
3
5
|
*
|
|
@@ -16,7 +18,9 @@
|
|
|
16
18
|
* removeCurrencySymbols("123.45"); // "123.45" (no symbols to remove)
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
|
-
const removeCurrencySymbols = (
|
|
21
|
+
const removeCurrencySymbols: RemoveCurrencySymbolsFunction = (
|
|
22
|
+
formattedValue
|
|
23
|
+
) => {
|
|
20
24
|
return formattedValue
|
|
21
25
|
.replace(/(?:R\$|\p{Sc}|[$€¥£])/gu, "") // Inclui "R$" e outros símbolos comuns
|
|
22
26
|
.trim();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
type RemoveNonNumericFunction = (formattedValue: string) => string;
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Removes all non-numeric characters from a given string.
|
|
3
5
|
*
|
|
@@ -11,8 +13,8 @@
|
|
|
11
13
|
* ```
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
const removeNonNumeric: RemoveNonNumericFunction = (prop) => {
|
|
15
17
|
return prop.replace(/[^0-9]/g, "");
|
|
16
|
-
}
|
|
18
|
+
};
|
|
17
19
|
|
|
18
20
|
export { removeNonNumeric };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ValidateCepFunction } from "@arkyn/types";
|
|
2
1
|
import { removeNonNumeric } from "../services/removeNonNumeric";
|
|
3
2
|
|
|
3
|
+
type ValidateCepFunction = (rawCep: string) => boolean;
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Removes all non-digit characters from the CEP.
|
|
6
7
|
* @param cep - Raw CEP string.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ValidateCnpjFunction } from "@arkyn/types";
|
|
2
1
|
import { removeNonNumeric } from "../services/removeNonNumeric";
|
|
3
2
|
|
|
3
|
+
type ValidateCnpjFunction = (rawCnpj: string) => boolean;
|
|
4
|
+
|
|
4
5
|
function isInvalidLength(cnpj: string) {
|
|
5
6
|
const CNPJ_LENGTH = 14;
|
|
6
7
|
return cnpj.length !== CNPJ_LENGTH;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ValidateCpfFunction } from "@arkyn/types";
|
|
2
1
|
import { removeNonNumeric } from "../services/removeNonNumeric";
|
|
3
2
|
|
|
3
|
+
type ValidateCpfFunction = (rawCpf: string) => boolean;
|
|
4
|
+
|
|
4
5
|
function isInvalidLength(cpf: string) {
|
|
5
6
|
const CPF_LENGTH = 11;
|
|
6
7
|
return cpf.length !== CPF_LENGTH;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
type ValidateDateConfig = {
|
|
2
|
+
inputFormat?: "DD/MM/YYYY" | "MM-DD-YYYY" | "YYYY-MM-DD";
|
|
3
|
+
minYear?: number;
|
|
4
|
+
maxYear?: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type ValidateDateFunction = (
|
|
8
|
+
rawDate: string,
|
|
9
|
+
config?: ValidateDateConfig
|
|
10
|
+
) => boolean;
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* Validates a date string based on the provided format and configuration.
|