@arkyn/shared 1.3.21 → 1.3.23

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.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { calculateCardInstallment } from "./calculateCardInstallment";
2
+ export { currencyFormat } from "./currencyFormat";
2
3
  export { generateColorByString } from "./generateColorByString";
3
4
  export { generateSlug } from "./generateSlug";
4
- export { currencyFormat } from "./currencyFormat";
5
5
  export { regex } from "./regex";
6
+ export { uuidV4, uuidV7 } from "./uuid";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { calculateCardInstallment } from "./calculateCardInstallment";
2
+ export { currencyFormat } from "./currencyFormat";
2
3
  export { generateColorByString } from "./generateColorByString";
3
4
  export { generateSlug } from "./generateSlug";
4
- export { currencyFormat } from "./currencyFormat";
5
5
  export { regex } from "./regex";
6
+ export { uuidV4, uuidV7 } from "./uuid";
package/dist/regex.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export declare const regex: {
2
2
  URL: RegExp;
3
+ HOUR: RegExp;
3
4
  RG: RegExp;
4
5
  PHONE: RegExp;
5
6
  PASSWORD: RegExp;
7
+ DATEHOUR: RegExp;
6
8
  CPF: RegExp;
7
9
  CNPJ: RegExp;
8
10
  CEP: RegExp;
9
11
  CPFCNPJ: RegExp;
12
+ DATE: RegExp;
10
13
  };
11
14
  //# sourceMappingURL=regex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../src/regex.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,KAAK;;;;;;;;;CAAwD,CAAC"}
1
+ {"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../src/regex.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,KAAK;;;;;;;;;;;;CAYjB,CAAC"}
package/dist/regex.js CHANGED
@@ -1,9 +1,24 @@
1
1
  const CEP = /(^[0-9]{5})-?([0-9]{3}$)/;
2
2
  const CNPJ = /(^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$)/;
3
3
  const CPF = /(^\d{3}\.\d{3}\.\d{3}\-\d{2}$)/;
4
+ const DATE = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}$/;
5
+ const DATEHOUR = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}\s(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/;
6
+ const HOUR = /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/;
4
7
  const PASSWORD = /(?=^.{8,}$)((?=.*\w)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[|!"$%&\/\(\)\?\^\'\\\+\-\*]))^.*/;
5
8
  const PHONE = /([0-9]{2})?(\s|-)?(9?[0-9]{4})-?([0-9]{4}$)/;
6
9
  const RG = /(^\d{1,2}).?(\d{3}).?(\d{3})-?(\d{1}|X|x$)/;
7
10
  const URL = /^(((https?|ftp):\/\/)?([\w\-\.])+(\.)([\w]){2,4}([\w\/+=%&_\.~?\-]*))*$/;
8
11
  const CPFCNPJ = /^(?:(\d{3}\.\d{3}\.\d{3}-\d{2})|(\d{11})|(\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2})|(\d{14}))$/;
9
- export const regex = { URL, RG, PHONE, PASSWORD, CPF, CNPJ, CEP, CPFCNPJ };
12
+ export const regex = {
13
+ URL,
14
+ HOUR,
15
+ RG,
16
+ PHONE,
17
+ PASSWORD,
18
+ DATEHOUR,
19
+ CPF,
20
+ CNPJ,
21
+ CEP,
22
+ CPFCNPJ,
23
+ DATE,
24
+ };
package/dist/uuid.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ declare function uuidV4(): {
2
+ text: string;
3
+ binary: Uint8Array;
4
+ };
5
+ declare function uuidV7(): {
6
+ text: string;
7
+ binary: Uint8Array;
8
+ };
9
+ export { uuidV4, uuidV7 };
10
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAYA,iBAAS,MAAM;;;EAMd;AAED,iBAAS,MAAM;;;EAOd;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
package/dist/uuid.js ADDED
@@ -0,0 +1,23 @@
1
+ import { v4, v7 } from "uuid";
2
+ function hexToBin(hex) {
3
+ const buffer = new Uint8Array(hex.length / 2);
4
+ for (let i = 0; i < hex.length; i += 2) {
5
+ buffer[i / 2] = parseInt(hex.substring(i, i + 2), 16);
6
+ }
7
+ return buffer;
8
+ }
9
+ function uuidV4() {
10
+ const uuid = v4();
11
+ return {
12
+ text: uuid,
13
+ binary: hexToBin(uuid),
14
+ };
15
+ }
16
+ function uuidV7() {
17
+ const uuid = v7();
18
+ return {
19
+ text: uuid,
20
+ binary: hexToBin(uuid),
21
+ };
22
+ }
23
+ export { uuidV4, uuidV7 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/shared",
3
- "version": "1.3.21",
3
+ "version": "1.3.23",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -9,7 +9,11 @@
9
9
  "build": "bunx tsc --project tsconfig.json",
10
10
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
11
11
  },
12
+ "dependencies": {
13
+ "uuid": "^10.0.0"
14
+ },
12
15
  "devDependencies": {
16
+ "@types/uuid": "^10.0.0",
13
17
  "bun-types": "latest",
14
18
  "typescript": ">=5.5.2"
15
19
  }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { calculateCardInstallment } from "./calculateCardInstallment";
2
+ export { currencyFormat } from "./currencyFormat";
2
3
  export { generateColorByString } from "./generateColorByString";
3
4
  export { generateSlug } from "./generateSlug";
4
- export { currencyFormat } from "./currencyFormat";
5
5
  export { regex } from "./regex";
6
+ export { uuidV4, uuidV7 } from "./uuid";
package/src/regex.ts CHANGED
@@ -4,6 +4,13 @@ const CNPJ = /(^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$)/;
4
4
 
5
5
  const CPF = /(^\d{3}\.\d{3}\.\d{3}\-\d{2}$)/;
6
6
 
7
+ const DATE = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}$/;
8
+
9
+ const DATEHOUR =
10
+ /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}\s(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/;
11
+
12
+ const HOUR = /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/;
13
+
7
14
  const PASSWORD =
8
15
  /(?=^.{8,}$)((?=.*\w)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[|!"$%&\/\(\)\?\^\'\\\+\-\*]))^.*/;
9
16
 
@@ -17,4 +24,16 @@ const URL =
17
24
  const CPFCNPJ =
18
25
  /^(?:(\d{3}\.\d{3}\.\d{3}-\d{2})|(\d{11})|(\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2})|(\d{14}))$/;
19
26
 
20
- export const regex = { URL, RG, PHONE, PASSWORD, CPF, CNPJ, CEP, CPFCNPJ };
27
+ export const regex = {
28
+ URL,
29
+ HOUR,
30
+ RG,
31
+ PHONE,
32
+ PASSWORD,
33
+ DATEHOUR,
34
+ CPF,
35
+ CNPJ,
36
+ CEP,
37
+ CPFCNPJ,
38
+ DATE,
39
+ };
package/src/uuid.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { v4, v7 } from "uuid";
2
+
3
+ function hexToBin(hex: string) {
4
+ const buffer = new Uint8Array(hex.length / 2);
5
+
6
+ for (let i = 0; i < hex.length; i += 2) {
7
+ buffer[i / 2] = parseInt(hex.substring(i, i + 2), 16);
8
+ }
9
+
10
+ return buffer;
11
+ }
12
+
13
+ function uuidV4() {
14
+ const uuid = v4();
15
+ return {
16
+ text: uuid,
17
+ binary: hexToBin(uuid),
18
+ };
19
+ }
20
+
21
+ function uuidV7() {
22
+ const uuid = v7();
23
+
24
+ return {
25
+ text: uuid,
26
+ binary: hexToBin(uuid),
27
+ };
28
+ }
29
+
30
+ export { uuidV4, uuidV7 };