@devix-tecnologia/value-objects 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -24
- package/dist/cjs/cpf_cnpj/index.js +28 -9
- package/dist/cjs/imagem_base64/image-formats.js +86 -12
- package/dist/cjs/imagem_base64/index.js +20 -11
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/placa_veiculo/index.js +1 -1
- package/dist/cjs/telefone/index.js +25 -7
- package/dist/cjs/types/cpf_cnpj/index.d.ts +8 -0
- package/dist/cjs/types/cpf_cnpj/index.d.ts.map +1 -1
- package/dist/cjs/types/imagem_base64/image-formats.d.ts +13 -3
- package/dist/cjs/types/imagem_base64/image-formats.d.ts.map +1 -1
- package/dist/cjs/types/imagem_base64/index.d.ts.map +1 -1
- package/dist/cjs/types/placa_veiculo/index.d.ts.map +1 -1
- package/dist/cjs/types/telefone/index.d.ts +8 -0
- package/dist/cjs/types/telefone/index.d.ts.map +1 -1
- package/dist/cjs/types/types/base_class.d.ts +2 -0
- package/dist/cjs/types/types/base_class.d.ts.map +1 -1
- package/dist/esm/cpf_cnpj/index.js +27 -8
- package/dist/esm/imagem_base64/image-formats.js +85 -12
- package/dist/esm/imagem_base64/index.js +19 -10
- package/dist/esm/telefone/index.js +24 -6
- package/dist/esm/types/cpf_cnpj/index.d.ts +8 -0
- package/dist/esm/types/cpf_cnpj/index.d.ts.map +1 -1
- package/dist/esm/types/imagem_base64/image-formats.d.ts +13 -3
- package/dist/esm/types/imagem_base64/image-formats.d.ts.map +1 -1
- package/dist/esm/types/imagem_base64/index.d.ts.map +1 -1
- package/dist/esm/types/placa_veiculo/index.d.ts.map +1 -1
- package/dist/esm/types/telefone/index.d.ts +8 -0
- package/dist/esm/types/telefone/index.d.ts.map +1 -1
- package/dist/esm/types/types/base_class.d.ts +2 -0
- package/dist/esm/types/types/base_class.d.ts.map +1 -1
- package/package.json +37 -25
package/README.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@devix-tecnologia/value-objects)
|
|
4
|
+
[](https://www.npmjs.com/package/@devix-tecnologia/value-objects)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/devix-tecnologia/value-objects/actions/workflows/package_deploy.yml)
|
|
7
|
+
|
|
1
8
|
# @devix-tecnologia/value-objects
|
|
2
9
|
|
|
3
10
|
Robust library for manipulation and validation of value objects in JavaScript/TypeScript. Provides utility classes for common data such as phone numbers, documents, and base64 images, ensuring consistent validation and formatting.
|
|
4
11
|
|
|
12
|
+
Brazilian value objects, validated and formatted: CPF and CNPJ (including the alphanumeric CNPJ that the Receita Federal adopts in 2026), phone numbers, vehicle plates (old and Mercosul) and base64 images. No runtime dependencies; ESM and CommonJS, with types.
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @devix-tecnologia/value-objects # or: npm i @devix-tecnologia/value-objects
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { CpfCnpj, Telefone, PlacaVeiculo, ImagemBase64 } from '@devix-tecnologia/value-objects'
|
|
22
|
+
|
|
23
|
+
new CpfCnpj('52998224725').formatted // '529.982.247-25'
|
|
24
|
+
new CpfCnpj('12ABC34501DE35').isValid() // true (alphanumeric CNPJ)
|
|
25
|
+
new Telefone('27 97645-5555').formatted // '+55 27 97645-5555'
|
|
26
|
+
new PlacaVeiculo('abc1d23').formatted // 'ABC-1D23' (format: 'MERCOSUL')
|
|
27
|
+
new ImagemBase64(dataUri).format // 'PNG', 'JPEG', 'WEBP'…
|
|
28
|
+
```
|
|
29
|
+
|
|
5
30
|
## Table of Contents
|
|
31
|
+
- [Quick start](#quick-start)
|
|
6
32
|
- [Installation](#installation)
|
|
7
33
|
- [Requirements](#requirements)
|
|
8
34
|
- [Import](#import)
|
|
@@ -19,7 +45,7 @@ npm i @devix-tecnologia/value-objects
|
|
|
19
45
|
```
|
|
20
46
|
|
|
21
47
|
## Requirements
|
|
22
|
-
- Node.js >=
|
|
48
|
+
- Node.js >= 22 (Node.js 22 or higher recommended)
|
|
23
49
|
- TypeScript >= 4.5 (optional, for typing)
|
|
24
50
|
|
|
25
51
|
## Import
|
|
@@ -31,35 +57,39 @@ import { ClassName } from '@devix-tecnologia/value-objects'
|
|
|
31
57
|
## Available Value Objects
|
|
32
58
|
|
|
33
59
|
- [Phone](./src/telefone/README.md): Manipulates and validates phone numbers, supporting Brazilian DDD and country codes.
|
|
34
|
-
- [CPF/CNPJ](./src/cpf_cnpj/README.md): Validates and formats CPF and CNPJ documents.
|
|
60
|
+
- [CPF/CNPJ](./src/cpf_cnpj/README.md): Validates and formats CPF and CNPJ documents, including alphanumeric CNPJ (Receita Federal 2026).
|
|
35
61
|
- [Base64Image](./src/imagem_base64/README.md): Manages and validates base64-encoded images, with automatic format detection.
|
|
36
62
|
- [Vehicle Plate](./src/placa_veiculo/README.md): Validates and formats Brazilian vehicle plates, supporting both old (ABC1234) and Mercosul (ABC1D23) formats.
|
|
37
63
|
|
|
38
64
|
## Usage Examples
|
|
39
65
|
|
|
40
66
|
```typescript
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
const tel = new
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// CPF/CNPJ
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
import { Telefone, CpfCnpj, ImagemBase64, PlacaVeiculo } from '@devix-tecnologia/value-objects'
|
|
68
|
+
|
|
69
|
+
// Telefone
|
|
70
|
+
const tel = new Telefone('+55 11 91234-5678')
|
|
71
|
+
tel.isValid() // true
|
|
72
|
+
tel.formatted // '+55 11 91234-5678'
|
|
73
|
+
|
|
74
|
+
// CPF/CNPJ (inclusive o CNPJ alfanumérico da Receita Federal, 2026)
|
|
75
|
+
const cpf = new CpfCnpj('529.982.247-25')
|
|
76
|
+
cpf.isValid() // true
|
|
77
|
+
cpf.formatted // '529.982.247-25'
|
|
78
|
+
|
|
79
|
+
const cnpj = new CpfCnpj('12ABC34501DE35')
|
|
80
|
+
cnpj.isValid() // true
|
|
81
|
+
cnpj.formatted // '12.ABC.345/01DE-35'
|
|
82
|
+
|
|
83
|
+
// ImagemBase64 (detecta o formato pelos bytes do arquivo)
|
|
84
|
+
const img = new ImagemBase64(base64String)
|
|
85
|
+
img.isValid() // true
|
|
86
|
+
img.format // 'PNG', 'JPEG', 'WEBP'…
|
|
87
|
+
|
|
88
|
+
// PlacaVeiculo
|
|
89
|
+
const placa = new PlacaVeiculo('ABC1234')
|
|
90
|
+
placa.isValid() // true
|
|
91
|
+
placa.formatted // 'ABC-1234'
|
|
92
|
+
placa.format // 'ANTIGA' (ou 'MERCOSUL')
|
|
63
93
|
```
|
|
64
94
|
|
|
65
95
|
## To Do
|
|
@@ -4,7 +4,9 @@ exports.CpfCnpj = void 0;
|
|
|
4
4
|
class CpfCnpj {
|
|
5
5
|
constructor(numDoc) {
|
|
6
6
|
this._isValid = false;
|
|
7
|
-
const doc = String(numDoc)
|
|
7
|
+
const doc = String(numDoc)
|
|
8
|
+
.replace(/[^a-zA-Z0-9]+/g, '')
|
|
9
|
+
.toUpperCase();
|
|
8
10
|
this._docId = doc;
|
|
9
11
|
if (doc.length === 11 && this.isCpfValid()) {
|
|
10
12
|
this._docType = 'CPF';
|
|
@@ -34,16 +36,20 @@ class CpfCnpj {
|
|
|
34
36
|
if (this._docType === 'CPF') {
|
|
35
37
|
return this._docId.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/, '$1.$2.$3-$4');
|
|
36
38
|
}
|
|
37
|
-
return this._docId.replace(/^(\
|
|
39
|
+
return this._docId.replace(/^([\dA-Z]{2})([\dA-Z]{3})([\dA-Z]{3})([\dA-Z]{4})([\dA-Z]{2})$/, '$1.$2.$3/$4-$5');
|
|
38
40
|
}
|
|
39
|
-
get
|
|
41
|
+
get value() {
|
|
40
42
|
this.isValid({ raiseException: true });
|
|
41
43
|
return this._docId;
|
|
42
44
|
}
|
|
45
|
+
/** @deprecated Use `value` instead */
|
|
46
|
+
get onlyNumbers() {
|
|
47
|
+
return this.value;
|
|
48
|
+
}
|
|
43
49
|
toJSON() {
|
|
44
50
|
return {
|
|
45
51
|
type: this.type,
|
|
46
|
-
value: this.
|
|
52
|
+
value: this.value,
|
|
47
53
|
formatted: this.formatted,
|
|
48
54
|
isValid: this._isValid,
|
|
49
55
|
version: this.version,
|
|
@@ -63,9 +69,9 @@ class CpfCnpj {
|
|
|
63
69
|
return false;
|
|
64
70
|
try {
|
|
65
71
|
const otherDoc = other instanceof CpfCnpj ? other : new CpfCnpj(other);
|
|
66
|
-
return this.
|
|
72
|
+
return this.value === otherDoc.value;
|
|
67
73
|
}
|
|
68
|
-
catch
|
|
74
|
+
catch {
|
|
69
75
|
return false;
|
|
70
76
|
}
|
|
71
77
|
}
|
|
@@ -123,7 +129,12 @@ class CpfCnpj {
|
|
|
123
129
|
];
|
|
124
130
|
if (blocklist.includes(this._docId))
|
|
125
131
|
return false;
|
|
126
|
-
|
|
132
|
+
const base = this._docId.slice(0, 12);
|
|
133
|
+
const d1 = CpfCnpj.CnpjVerifierDigits(base);
|
|
134
|
+
const d2 = CpfCnpj.CnpjVerifierDigits(base + String(d1));
|
|
135
|
+
const expected = String(d1) + String(d2);
|
|
136
|
+
const actual = this._docId.slice(-2);
|
|
137
|
+
return expected === actual;
|
|
127
138
|
}
|
|
128
139
|
static CpfVerifierDigits(doc_ident) {
|
|
129
140
|
const numbers = doc_ident.split('').map((number) => parseInt(number, 10));
|
|
@@ -132,12 +143,20 @@ class CpfCnpj {
|
|
|
132
143
|
const mod = multiplied.reduce((buffer, number) => buffer + number) % 11;
|
|
133
144
|
return mod < 2 ? 0 : 11 - mod;
|
|
134
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Valor do caractere no cálculo do DV do CNPJ: código ASCII menos 48
|
|
148
|
+
* (0 = 0, 9 = 9, A = 17, Z = 42), segundo a Receita Federal (CNPJ alfanumérico,
|
|
149
|
+
* pergunta 14) e o Serpro (Cálculo dos dígitos verificadores de CNPJ alfanumérico).
|
|
150
|
+
*/
|
|
151
|
+
static charToValue(char) {
|
|
152
|
+
return char.charCodeAt(0) - 48;
|
|
153
|
+
}
|
|
135
154
|
static CnpjVerifierDigits(doc_ident) {
|
|
136
155
|
let index = 2;
|
|
137
156
|
const reverse = doc_ident
|
|
138
157
|
.split('')
|
|
139
|
-
.reduce((buffer,
|
|
140
|
-
return [
|
|
158
|
+
.reduce((buffer, char) => {
|
|
159
|
+
return [CpfCnpj.charToValue(char)].concat(buffer);
|
|
141
160
|
}, []);
|
|
142
161
|
const sum = reverse.reduce((buffer, number) => {
|
|
143
162
|
buffer += number * index;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.imageFormats = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.findFormatBySignature = findFormatBySignature;
|
|
5
|
+
exports.findFormatByMimeType = findFormatByMimeType;
|
|
5
6
|
const imageFormats = {
|
|
6
7
|
JPEG: {
|
|
7
8
|
name: 'JPEG Image',
|
|
@@ -19,13 +20,13 @@ const imageFormats = {
|
|
|
19
20
|
name: 'Graphics Interchange Format',
|
|
20
21
|
extension: 'gif',
|
|
21
22
|
mimeType: 'image/gif',
|
|
22
|
-
base64Prefix: ['R0lGODlh'],
|
|
23
|
+
base64Prefix: ['R0lGODdh', 'R0lGODlh'],
|
|
23
24
|
},
|
|
24
25
|
WEBP: {
|
|
25
26
|
name: 'WebP Image',
|
|
26
27
|
extension: 'webp',
|
|
27
28
|
mimeType: 'image/webp',
|
|
28
|
-
base64Prefix: ['
|
|
29
|
+
base64Prefix: ['UklGR'],
|
|
29
30
|
},
|
|
30
31
|
BMP: {
|
|
31
32
|
name: 'Bitmap Image File',
|
|
@@ -37,37 +38,37 @@ const imageFormats = {
|
|
|
37
38
|
name: 'Tagged Image File Format',
|
|
38
39
|
extension: 'tiff',
|
|
39
40
|
mimeType: 'image/tiff',
|
|
40
|
-
base64Prefix: ['
|
|
41
|
+
base64Prefix: ['SUkqA', 'TU0AK'],
|
|
41
42
|
},
|
|
42
43
|
ICO: {
|
|
43
44
|
name: 'Windows Icon',
|
|
44
45
|
extension: 'ico',
|
|
45
46
|
mimeType: 'image/x-icon',
|
|
46
|
-
base64Prefix: ['
|
|
47
|
+
base64Prefix: ['AAABA'],
|
|
47
48
|
},
|
|
48
49
|
SVG: {
|
|
49
50
|
name: 'Scalable Vector Graphics',
|
|
50
51
|
extension: 'svg',
|
|
51
52
|
mimeType: 'image/svg+xml',
|
|
52
|
-
base64Prefix: ['
|
|
53
|
+
base64Prefix: ['PHN2Z', 'PD94bW'],
|
|
53
54
|
},
|
|
54
55
|
HEIC: {
|
|
55
56
|
name: 'High Efficiency Image Format',
|
|
56
57
|
extension: 'heic',
|
|
57
58
|
mimeType: 'image/heic',
|
|
58
|
-
base64Prefix: [
|
|
59
|
+
base64Prefix: [],
|
|
59
60
|
},
|
|
60
61
|
AVIF: {
|
|
61
62
|
name: 'AV1 Image File Format',
|
|
62
63
|
extension: 'avif',
|
|
63
64
|
mimeType: 'image/avif',
|
|
64
|
-
base64Prefix: [
|
|
65
|
+
base64Prefix: [],
|
|
65
66
|
},
|
|
66
67
|
PSD: {
|
|
67
68
|
name: 'Adobe Photoshop Document',
|
|
68
69
|
extension: 'psd',
|
|
69
70
|
mimeType: 'image/vnd.adobe.photoshop',
|
|
70
|
-
base64Prefix: ['
|
|
71
|
+
base64Prefix: ['OEJQU'],
|
|
71
72
|
},
|
|
72
73
|
unknown: {
|
|
73
74
|
name: 'Unknown Format',
|
|
@@ -77,12 +78,85 @@ const imageFormats = {
|
|
|
77
78
|
},
|
|
78
79
|
};
|
|
79
80
|
exports.imageFormats = imageFormats;
|
|
81
|
+
/** Quantos caracteres de base64 decodificar para ler a assinatura (múltiplo de 4). */
|
|
82
|
+
const CARACTERES_PARA_ASSINATURA = 1024;
|
|
83
|
+
const temBytes = (bytes, esperado, inicio = 0) => esperado.every((byte, i) => bytes[inicio + i] === byte);
|
|
84
|
+
const ascii = (texto) => texto.split('').map((c) => c.charCodeAt(0));
|
|
85
|
+
const MARCAS_HEIC = [
|
|
86
|
+
'heic',
|
|
87
|
+
'heix',
|
|
88
|
+
'hevc',
|
|
89
|
+
'hevx',
|
|
90
|
+
'heim',
|
|
91
|
+
'heis',
|
|
92
|
+
'hevm',
|
|
93
|
+
'hevs',
|
|
94
|
+
];
|
|
95
|
+
const MARCAS_AVIF = ['avif', 'avis'];
|
|
96
|
+
const marcaIsoBmff = (bytes) => {
|
|
97
|
+
if (!temBytes(bytes, ascii('ftyp'), 4))
|
|
98
|
+
return null;
|
|
99
|
+
return String.fromCharCode(...bytes.slice(8, 12));
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Assinatura de cada formato, em bytes. Fontes: WHATWG MIME Sniffing Standard, "Matching an
|
|
103
|
+
* image type pattern" (ICO, BMP, GIF, WebP, PNG, JPEG); TIFF 6.0 (II*\0 e MM\0*); Adobe
|
|
104
|
+
* Photoshop File Formats Specification (8BPS); ISO/IEC 14496-12 e 23008-12 e AV1 Image File
|
|
105
|
+
* Format (caixa ftyp com a marca principal); SVG 1.1 (elemento raiz svg, documento XML).
|
|
106
|
+
*/
|
|
107
|
+
const assinaturas = {
|
|
108
|
+
JPEG: (b) => temBytes(b, [0xff, 0xd8, 0xff]),
|
|
109
|
+
PNG: (b) => temBytes(b, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
|
|
110
|
+
GIF: (b) => temBytes(b, ascii('GIF87a')) || temBytes(b, ascii('GIF89a')),
|
|
111
|
+
WEBP: (b) => temBytes(b, ascii('RIFF')) && temBytes(b, ascii('WEBPVP'), 8),
|
|
112
|
+
BMP: (b) => temBytes(b, ascii('BM')),
|
|
113
|
+
TIFF: (b) => temBytes(b, [0x49, 0x49, 0x2a, 0x00]) ||
|
|
114
|
+
temBytes(b, [0x4d, 0x4d, 0x00, 0x2a]),
|
|
115
|
+
ICO: (b) => temBytes(b, [0x00, 0x00, 0x01, 0x00]),
|
|
116
|
+
SVG: (_b, texto) => {
|
|
117
|
+
const inicio = texto.replace(/^/, '').trimStart();
|
|
118
|
+
return inicio.startsWith('<') && inicio.includes('<svg');
|
|
119
|
+
},
|
|
120
|
+
HEIC: (b) => MARCAS_HEIC.includes(marcaIsoBmff(b) ?? ''),
|
|
121
|
+
AVIF: (b) => MARCAS_AVIF.includes(marcaIsoBmff(b) ?? ''),
|
|
122
|
+
PSD: (b) => temBytes(b, ascii('8BPS')),
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Detecta o formato da imagem pela assinatura dos primeiros bytes do conteúdo base64.
|
|
126
|
+
*/
|
|
127
|
+
function findFormatBySignature(base64Str) {
|
|
128
|
+
const trecho = base64Str.length > CARACTERES_PARA_ASSINATURA
|
|
129
|
+
? base64Str.slice(0, CARACTERES_PARA_ASSINATURA)
|
|
130
|
+
: base64Str;
|
|
131
|
+
let texto;
|
|
132
|
+
try {
|
|
133
|
+
texto = atob(trecho);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return 'unknown';
|
|
137
|
+
}
|
|
138
|
+
const bytes = ascii(texto);
|
|
139
|
+
for (const [format, confere] of Object.entries(assinaturas)) {
|
|
140
|
+
if (confere(bytes, texto))
|
|
141
|
+
return format;
|
|
142
|
+
}
|
|
143
|
+
return 'unknown';
|
|
144
|
+
}
|
|
145
|
+
/** Tipos MIME aceitos em data URI que não são o tipo principal do formato. */
|
|
146
|
+
const MIME_ALTERNATIVOS = {
|
|
147
|
+
'image/jpg': 'JPEG',
|
|
148
|
+
'image/pjpeg': 'JPEG',
|
|
149
|
+
'image/vnd.microsoft.icon': 'ICO',
|
|
150
|
+
};
|
|
80
151
|
/**
|
|
81
|
-
*
|
|
152
|
+
* Formato a partir do tipo MIME de uma data URI, ou 'unknown' se não for um tipo conhecido.
|
|
82
153
|
*/
|
|
83
|
-
function
|
|
154
|
+
function findFormatByMimeType(mimeType) {
|
|
155
|
+
const tipo = mimeType.trim().toLowerCase();
|
|
156
|
+
if (MIME_ALTERNATIVOS[tipo])
|
|
157
|
+
return MIME_ALTERNATIVOS[tipo];
|
|
84
158
|
for (const [format, info] of Object.entries(imageFormats)) {
|
|
85
|
-
if (info.
|
|
159
|
+
if (format !== 'unknown' && info.mimeType === tipo) {
|
|
86
160
|
return format;
|
|
87
161
|
}
|
|
88
162
|
}
|
|
@@ -46,7 +46,7 @@ class ImagemBase64 {
|
|
|
46
46
|
if (this._isDataUri) {
|
|
47
47
|
return this._content;
|
|
48
48
|
}
|
|
49
|
-
return `data
|
|
49
|
+
return `data:${image_formats_js_1.imageFormats[this._format].mimeType};base64,${this._content}`;
|
|
50
50
|
}
|
|
51
51
|
toJSON() {
|
|
52
52
|
if (!this._isValid) {
|
|
@@ -62,7 +62,7 @@ class ImagemBase64 {
|
|
|
62
62
|
format: this._format,
|
|
63
63
|
isValid: true,
|
|
64
64
|
version: this.version,
|
|
65
|
-
mimeType:
|
|
65
|
+
mimeType: image_formats_js_1.imageFormats[this._format].mimeType,
|
|
66
66
|
isDataUri: this._isDataUri,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
@@ -88,7 +88,7 @@ class ImagemBase64 {
|
|
|
88
88
|
return false;
|
|
89
89
|
return this.content === otherImage.content;
|
|
90
90
|
}
|
|
91
|
-
catch
|
|
91
|
+
catch {
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -96,16 +96,25 @@ class ImagemBase64 {
|
|
|
96
96
|
if (!this._content || typeof this._content !== 'string') {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
// Verifica se é data URI
|
|
99
|
+
// Verifica se é data URI: data:image/<subtipo>[;parâmetros];base64,<conteúdo>
|
|
100
|
+
// (RFC 2397: sem ";base64" os dados são texto com codificação por cento)
|
|
100
101
|
if (this._content.startsWith('data:image/')) {
|
|
101
102
|
this._isDataUri = true;
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
103
|
+
const virgula = this._content.indexOf(',');
|
|
104
|
+
if (virgula < 0)
|
|
105
|
+
return;
|
|
106
|
+
const [mimeType, ...parametros] = this._content
|
|
107
|
+
.slice('data:'.length, virgula)
|
|
108
|
+
.split(';');
|
|
109
|
+
const base64Content = this._content.slice(virgula + 1);
|
|
110
|
+
if (!parametros.some((p) => p.trim().toLowerCase() === 'base64')) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!this.isBase64String(base64Content)) {
|
|
104
114
|
return;
|
|
105
115
|
}
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
this._isValid = true;
|
|
116
|
+
this._format = (0, image_formats_js_1.findFormatByMimeType)(mimeType);
|
|
117
|
+
this._isValid = this._format !== 'unknown';
|
|
109
118
|
return;
|
|
110
119
|
}
|
|
111
120
|
// Verifica se é base64 puro
|
|
@@ -113,7 +122,7 @@ class ImagemBase64 {
|
|
|
113
122
|
return;
|
|
114
123
|
}
|
|
115
124
|
// Detecta o formato
|
|
116
|
-
this._format = (0, image_formats_js_1.
|
|
125
|
+
this._format = (0, image_formats_js_1.findFormatBySignature)(this._content);
|
|
117
126
|
this._isValid = this._format !== 'unknown';
|
|
118
127
|
}
|
|
119
128
|
isBase64String(str) {
|
|
@@ -123,7 +132,7 @@ class ImagemBase64 {
|
|
|
123
132
|
const regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/;
|
|
124
133
|
return regex.test(str.trim());
|
|
125
134
|
}
|
|
126
|
-
catch
|
|
135
|
+
catch {
|
|
127
136
|
return false;
|
|
128
137
|
}
|
|
129
138
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -32,13 +32,16 @@ class Telefone {
|
|
|
32
32
|
this._countryCode = '55';
|
|
33
33
|
this._areaCode = tel.slice(0, 2);
|
|
34
34
|
this._phoneNum = tel.slice(2);
|
|
35
|
-
this._isValid = this.isDDDValid();
|
|
35
|
+
this._isValid = this.isDDDValid() && this.isSubscriberNumberValid();
|
|
36
36
|
}
|
|
37
37
|
else if (tel.length === 12 || tel.length === 13) {
|
|
38
38
|
this._countryCode = tel.slice(0, 2);
|
|
39
39
|
this._areaCode = tel.slice(2, 4);
|
|
40
40
|
this._phoneNum = tel.slice(4);
|
|
41
|
-
this._isValid =
|
|
41
|
+
this._isValid =
|
|
42
|
+
this._countryCode === '55' &&
|
|
43
|
+
this.isDDDValid() &&
|
|
44
|
+
this.isSubscriberNumberValid();
|
|
42
45
|
}
|
|
43
46
|
else {
|
|
44
47
|
throw new Error('Could not parse phone number from string. Try creating the record using an object { countryCode: string; areaCode: string; phoneNum: string }');
|
|
@@ -49,7 +52,10 @@ class Telefone {
|
|
|
49
52
|
this._areaCode = phone.areaCode.replace(/[^\d]+/g, '');
|
|
50
53
|
this._phoneNum = phone.phoneNum.replace(/[^\d]+/g, '');
|
|
51
54
|
if (this._countryCode === '55') {
|
|
52
|
-
this._isValid =
|
|
55
|
+
this._isValid =
|
|
56
|
+
this.isDDDValid() &&
|
|
57
|
+
this.isSubscriberNumberValid() &&
|
|
58
|
+
this.isCountryCodeValid();
|
|
53
59
|
}
|
|
54
60
|
else {
|
|
55
61
|
this._isValid = this.isCountryCodeValid();
|
|
@@ -73,10 +79,14 @@ class Telefone {
|
|
|
73
79
|
const lastDigits = num.splice(-4, 4);
|
|
74
80
|
return `+${this._countryCode} ${this._areaCode} ${num.join('')}-${lastDigits.join('')}`;
|
|
75
81
|
}
|
|
76
|
-
get
|
|
82
|
+
get value() {
|
|
77
83
|
this.isValid({ raiseException: true });
|
|
78
84
|
return `${this._countryCode}${this._areaCode}${this._phoneNum}`;
|
|
79
85
|
}
|
|
86
|
+
/** @deprecated Use `value` instead */
|
|
87
|
+
get onlyNumbers() {
|
|
88
|
+
return this.value;
|
|
89
|
+
}
|
|
80
90
|
get country() {
|
|
81
91
|
return country_codes_js_1.countryCodes[this._countryCode].code;
|
|
82
92
|
}
|
|
@@ -88,7 +98,7 @@ class Telefone {
|
|
|
88
98
|
toJSON() {
|
|
89
99
|
return {
|
|
90
100
|
type: this.type,
|
|
91
|
-
value: this.
|
|
101
|
+
value: this.value,
|
|
92
102
|
formatted: this.formatted,
|
|
93
103
|
isValid: this._isValid,
|
|
94
104
|
version: this.version,
|
|
@@ -110,15 +120,23 @@ class Telefone {
|
|
|
110
120
|
return false;
|
|
111
121
|
try {
|
|
112
122
|
const otherPhone = other instanceof Telefone ? other : new Telefone(other);
|
|
113
|
-
return this.
|
|
123
|
+
return this.value === otherPhone.value;
|
|
114
124
|
}
|
|
115
|
-
catch
|
|
125
|
+
catch {
|
|
116
126
|
return false;
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
isDDDValid() {
|
|
120
130
|
return ddd_js_1.DDD[this._areaCode] !== undefined;
|
|
121
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Número do assinante no plano de numeração brasileiro (Anatel): 8 dígitos (fixo) ou
|
|
134
|
+
* 9 dígitos (celular), e o nono dígito do celular é sempre 9, à esquerda
|
|
135
|
+
* (Resolução Anatel nº 553/2010; Regulamento Geral de Numeração, Resolução nº 749/2022).
|
|
136
|
+
*/
|
|
137
|
+
isSubscriberNumberValid() {
|
|
138
|
+
return /^(\d{8}|9\d{8})$/.test(this._phoneNum);
|
|
139
|
+
}
|
|
122
140
|
isCountryCodeValid() {
|
|
123
141
|
return country_codes_js_1.countryCodes[this._countryCode] !== undefined;
|
|
124
142
|
}
|
|
@@ -9,6 +9,8 @@ declare class CpfCnpj implements IBaseClassNumbers {
|
|
|
9
9
|
get version(): string;
|
|
10
10
|
get validation(): string;
|
|
11
11
|
get formatted(): string;
|
|
12
|
+
get value(): string;
|
|
13
|
+
/** @deprecated Use `value` instead */
|
|
12
14
|
get onlyNumbers(): string;
|
|
13
15
|
toJSON(): object;
|
|
14
16
|
toString(): string;
|
|
@@ -19,6 +21,12 @@ declare class CpfCnpj implements IBaseClassNumbers {
|
|
|
19
21
|
private isCpfValid;
|
|
20
22
|
private isCnpjValid;
|
|
21
23
|
private static CpfVerifierDigits;
|
|
24
|
+
/**
|
|
25
|
+
* Valor do caractere no cálculo do DV do CNPJ: código ASCII menos 48
|
|
26
|
+
* (0 = 0, 9 = 9, A = 17, Z = 42), segundo a Receita Federal (CNPJ alfanumérico,
|
|
27
|
+
* pergunta 14) e o Serpro (Cálculo dos dígitos verificadores de CNPJ alfanumérico).
|
|
28
|
+
*/
|
|
29
|
+
private static charToValue;
|
|
22
30
|
private static CnpjVerifierDigits;
|
|
23
31
|
}
|
|
24
32
|
export { CpfCnpj };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cpf_cnpj/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIvE,cAAM,OAAQ,YAAW,iBAAiB;IACxC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cpf_cnpj/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIvE,cAAM,OAAQ,YAAW,iBAAiB;IACxC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,MAAM,EAAE,MAAM,GAAG,MAAM,EAclC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAIvB;IAED,IAAI,SAAS,IAAI,MAAM,CAatB;IAED,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,sCAAsC;IACtC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,MAAM,IAAI,MAAM,CAQf;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAUxC;IAED,MAAM,CAAC,MAAM,IAAI,OAAO,CAQvB;IAED,MAAM,CAAC,OAAO,IAAI,OAAO,CAQxB;IAED,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAUhC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAiBlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -2,13 +2,23 @@ interface ImageFormatInfo {
|
|
|
2
2
|
name: string;
|
|
3
3
|
extension: string;
|
|
4
4
|
mimeType: string;
|
|
5
|
+
/**
|
|
6
|
+
* Início do base64 de todo arquivo do formato (informativo). A detecção não usa este
|
|
7
|
+
* campo: ela decodifica os primeiros bytes e compara com a assinatura do formato, porque
|
|
8
|
+
* em vários formatos a assinatura não começa no primeiro byte (WebP, HEIC, AVIF) ou
|
|
9
|
+
* não fecha um grupo de 3 bytes, e o base64 dela depende dos bytes seguintes.
|
|
10
|
+
*/
|
|
5
11
|
base64Prefix: string[];
|
|
6
12
|
}
|
|
7
13
|
declare const imageFormats: Record<string, ImageFormatInfo>;
|
|
8
14
|
type ImageFormat = keyof typeof imageFormats | 'unknown';
|
|
9
15
|
/**
|
|
10
|
-
* Detecta o formato da imagem
|
|
16
|
+
* Detecta o formato da imagem pela assinatura dos primeiros bytes do conteúdo base64.
|
|
11
17
|
*/
|
|
12
|
-
declare function
|
|
13
|
-
|
|
18
|
+
declare function findFormatBySignature(base64Str: string): ImageFormat;
|
|
19
|
+
/**
|
|
20
|
+
* Formato a partir do tipo MIME de uma data URI, ou 'unknown' se não for um tipo conhecido.
|
|
21
|
+
*/
|
|
22
|
+
declare function findFormatByMimeType(mimeType: string): ImageFormat;
|
|
23
|
+
export { imageFormats, type ImageFormat, type ImageFormatInfo, findFormatBySignature, findFormatByMimeType, };
|
|
14
24
|
//# sourceMappingURL=image-formats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-formats.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/image-formats.ts"],"names":[],"mappings":"AAAA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAyExC,CAAA;AAEV,KAAK,WAAW,GAAG,MAAM,OAAO,YAAY,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"image-formats.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/image-formats.ts"],"names":[],"mappings":"AAAA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAyExC,CAAA;AAEV,KAAK,WAAW,GAAG,MAAM,OAAO,YAAY,GAAG,SAAS,CAAA;AAsDxD;;GAEG;AACH,iBAAS,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAgB7D;AASD;;GAEG;AACH,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAS3D;AAED,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,oBAAoB,CAAA;AAE3B;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,OAAO,EAAE,MAAM,EAG1B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,MAAM,IAAI,WAAW,CAGxB;IAED,IAAI,OAAO,IAAI,MAAM,CAGpB;IAED,IAAI,UAAU,IAAI,eAAe,CAGhC;IAED,OAAO,KAAK,OAAO,GAMlB;IAED,MAAM,IAAI,MAAM,CAkBf;IAED,QAAQ,IAAI,MAAM,CAGjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,CAc7C;IAED,OAAO,CAAC,QAAQ;IAsChB,OAAO,CAAC,cAAc;CAUvB;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/placa_veiculo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpE,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/placa_veiculo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpE,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,KAAK,EAAE,MAAM,EAKxB;IAED,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY;IAiBpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,IAAI,SAAS,IAAI,MAAM,CAUtB;IAED,IAAI,WAAW,IAAI,MAAM,CAGxB;IAED,MAAM,IAAI,MAAM,CASf;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,CAY7C;IAED;;OAEG;IACH,UAAU,IAAI,OAAO,CAEpB;IAED;;OAEG;IACH,WAAW,IAAI,OAAO,CAErB;CACF;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,CAAA"}
|
|
@@ -24,6 +24,8 @@ declare class Telefone implements IBaseClassNumbers {
|
|
|
24
24
|
get version(): string;
|
|
25
25
|
get validation(): string;
|
|
26
26
|
get formatted(): string;
|
|
27
|
+
get value(): string;
|
|
28
|
+
/** @deprecated Use `value` instead */
|
|
27
29
|
get onlyNumbers(): string;
|
|
28
30
|
get country(): string;
|
|
29
31
|
get estate(): string | null;
|
|
@@ -32,6 +34,12 @@ declare class Telefone implements IBaseClassNumbers {
|
|
|
32
34
|
isValid(config?: ValidConfig): boolean;
|
|
33
35
|
equals(other: Telefone | unknown): boolean;
|
|
34
36
|
private isDDDValid;
|
|
37
|
+
/**
|
|
38
|
+
* Número do assinante no plano de numeração brasileiro (Anatel): 8 dígitos (fixo) ou
|
|
39
|
+
* 9 dígitos (celular), e o nono dígito do celular é sempre 9, à esquerda
|
|
40
|
+
* (Resolução Anatel nº 553/2010; Regulamento Geral de Numeração, Resolução nº 749/2022).
|
|
41
|
+
*/
|
|
42
|
+
private isSubscriberNumberValid;
|
|
35
43
|
private isCountryCodeValid;
|
|
36
44
|
}
|
|
37
45
|
export { Telefone, type PhoneInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/telefone/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEvE,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;GAMG;AACH,cAAM,QAAS,YAAW,iBAAiB;IACzC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/telefone/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEvE,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;GAMG;AACH,cAAM,QAAS,YAAW,iBAAiB;IACzC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,QAAQ,EAAE,MAAM,GAAG,UAAU,EAMxC;IAED,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,eAAe;IAevB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAKvB;IAED,IAAI,SAAS,IAAI,MAAM,CAKtB;IAED,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,sCAAsC;IACtC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,IAAI,CAG1B;IAED,MAAM,IAAI,MAAM,CAUf;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAUzC;IAED,OAAO,CAAC,UAAU;IAIlB;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,kBAAkB;CAG3B;AAED,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,CAAA"}
|
|
@@ -14,7 +14,9 @@ interface IBaseClass<T> extends IMetadata {
|
|
|
14
14
|
toString(): string;
|
|
15
15
|
}
|
|
16
16
|
interface IBaseClassNumbers extends IBaseClass<IBaseClassNumbers> {
|
|
17
|
+
/** @deprecated Use `value` instead — `onlyNumbers` pode conter letras (CNPJ alfanumérico) */
|
|
17
18
|
get onlyNumbers(): string;
|
|
19
|
+
get value(): string;
|
|
18
20
|
}
|
|
19
21
|
interface IBaseClassText extends IBaseClass<IBaseClassText> {
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_class.d.ts","sourceRoot":"","sources":["../../../../src/types/base_class.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,UAAU,SAAS;IACjB,IAAI,IAAI,IAAI,MAAM,CAAA;IAClB,IAAI,OAAO,IAAI,MAAM,CAAA;IACrB,IAAI,UAAU,IAAI,MAAM,CAAA;CACzB;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS;IACvC,IAAI,SAAS,IAAI,MAAM,CAAA;IACvB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAA;IACrC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,GAAG,OAAO,CAAA;IACnC,MAAM,IAAI,MAAM,CAAA;IAChB,QAAQ,IAAI,MAAM,CAAA;CACnB;AAED,UAAU,iBAAkB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,IAAI,WAAW,IAAI,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"base_class.d.ts","sourceRoot":"","sources":["../../../../src/types/base_class.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,UAAU,SAAS;IACjB,IAAI,IAAI,IAAI,MAAM,CAAA;IAClB,IAAI,OAAO,IAAI,MAAM,CAAA;IACrB,IAAI,UAAU,IAAI,MAAM,CAAA;CACzB;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS;IACvC,IAAI,SAAS,IAAI,MAAM,CAAA;IACvB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAA;IACrC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,GAAG,OAAO,CAAA;IACnC,MAAM,IAAI,MAAM,CAAA;IAChB,QAAQ,IAAI,MAAM,CAAA;CACnB;AAED,UAAU,iBAAkB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,6FAA6F;IAC7F,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,KAAK,IAAI,MAAM,CAAA;CACpB;AAED,UAAU,cAAe,SAAQ,UAAU,CAAC,cAAc,CAAC;CAAG;AAE9D,UAAU,OAAO,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAClD,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,OAAO,IAAI,MAAM,CAAA;CACtB;AAED,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -4,7 +4,9 @@ class CpfCnpj {
|
|
|
4
4
|
_isValid = false;
|
|
5
5
|
static VERSION = '1.0.0';
|
|
6
6
|
constructor(numDoc) {
|
|
7
|
-
const doc = String(numDoc)
|
|
7
|
+
const doc = String(numDoc)
|
|
8
|
+
.replace(/[^a-zA-Z0-9]+/g, '')
|
|
9
|
+
.toUpperCase();
|
|
8
10
|
this._docId = doc;
|
|
9
11
|
if (doc.length === 11 && this.isCpfValid()) {
|
|
10
12
|
this._docType = 'CPF';
|
|
@@ -34,16 +36,20 @@ class CpfCnpj {
|
|
|
34
36
|
if (this._docType === 'CPF') {
|
|
35
37
|
return this._docId.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/, '$1.$2.$3-$4');
|
|
36
38
|
}
|
|
37
|
-
return this._docId.replace(/^(\
|
|
39
|
+
return this._docId.replace(/^([\dA-Z]{2})([\dA-Z]{3})([\dA-Z]{3})([\dA-Z]{4})([\dA-Z]{2})$/, '$1.$2.$3/$4-$5');
|
|
38
40
|
}
|
|
39
|
-
get
|
|
41
|
+
get value() {
|
|
40
42
|
this.isValid({ raiseException: true });
|
|
41
43
|
return this._docId;
|
|
42
44
|
}
|
|
45
|
+
/** @deprecated Use `value` instead */
|
|
46
|
+
get onlyNumbers() {
|
|
47
|
+
return this.value;
|
|
48
|
+
}
|
|
43
49
|
toJSON() {
|
|
44
50
|
return {
|
|
45
51
|
type: this.type,
|
|
46
|
-
value: this.
|
|
52
|
+
value: this.value,
|
|
47
53
|
formatted: this.formatted,
|
|
48
54
|
isValid: this._isValid,
|
|
49
55
|
version: this.version,
|
|
@@ -63,7 +69,7 @@ class CpfCnpj {
|
|
|
63
69
|
return false;
|
|
64
70
|
try {
|
|
65
71
|
const otherDoc = other instanceof CpfCnpj ? other : new CpfCnpj(other);
|
|
66
|
-
return this.
|
|
72
|
+
return this.value === otherDoc.value;
|
|
67
73
|
}
|
|
68
74
|
catch {
|
|
69
75
|
return false;
|
|
@@ -123,7 +129,12 @@ class CpfCnpj {
|
|
|
123
129
|
];
|
|
124
130
|
if (blocklist.includes(this._docId))
|
|
125
131
|
return false;
|
|
126
|
-
|
|
132
|
+
const base = this._docId.slice(0, 12);
|
|
133
|
+
const d1 = CpfCnpj.CnpjVerifierDigits(base);
|
|
134
|
+
const d2 = CpfCnpj.CnpjVerifierDigits(base + String(d1));
|
|
135
|
+
const expected = String(d1) + String(d2);
|
|
136
|
+
const actual = this._docId.slice(-2);
|
|
137
|
+
return expected === actual;
|
|
127
138
|
}
|
|
128
139
|
static CpfVerifierDigits(doc_ident) {
|
|
129
140
|
const numbers = doc_ident.split('').map((number) => parseInt(number, 10));
|
|
@@ -132,12 +143,20 @@ class CpfCnpj {
|
|
|
132
143
|
const mod = multiplied.reduce((buffer, number) => buffer + number) % 11;
|
|
133
144
|
return mod < 2 ? 0 : 11 - mod;
|
|
134
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Valor do caractere no cálculo do DV do CNPJ: código ASCII menos 48
|
|
148
|
+
* (0 = 0, 9 = 9, A = 17, Z = 42), segundo a Receita Federal (CNPJ alfanumérico,
|
|
149
|
+
* pergunta 14) e o Serpro (Cálculo dos dígitos verificadores de CNPJ alfanumérico).
|
|
150
|
+
*/
|
|
151
|
+
static charToValue(char) {
|
|
152
|
+
return char.charCodeAt(0) - 48;
|
|
153
|
+
}
|
|
135
154
|
static CnpjVerifierDigits(doc_ident) {
|
|
136
155
|
let index = 2;
|
|
137
156
|
const reverse = doc_ident
|
|
138
157
|
.split('')
|
|
139
|
-
.reduce((buffer,
|
|
140
|
-
return [
|
|
158
|
+
.reduce((buffer, char) => {
|
|
159
|
+
return [CpfCnpj.charToValue(char)].concat(buffer);
|
|
141
160
|
}, []);
|
|
142
161
|
const sum = reverse.reduce((buffer, number) => {
|
|
143
162
|
buffer += number * index;
|
|
@@ -15,13 +15,13 @@ const imageFormats = {
|
|
|
15
15
|
name: 'Graphics Interchange Format',
|
|
16
16
|
extension: 'gif',
|
|
17
17
|
mimeType: 'image/gif',
|
|
18
|
-
base64Prefix: ['R0lGODlh'],
|
|
18
|
+
base64Prefix: ['R0lGODdh', 'R0lGODlh'],
|
|
19
19
|
},
|
|
20
20
|
WEBP: {
|
|
21
21
|
name: 'WebP Image',
|
|
22
22
|
extension: 'webp',
|
|
23
23
|
mimeType: 'image/webp',
|
|
24
|
-
base64Prefix: ['
|
|
24
|
+
base64Prefix: ['UklGR'],
|
|
25
25
|
},
|
|
26
26
|
BMP: {
|
|
27
27
|
name: 'Bitmap Image File',
|
|
@@ -33,37 +33,37 @@ const imageFormats = {
|
|
|
33
33
|
name: 'Tagged Image File Format',
|
|
34
34
|
extension: 'tiff',
|
|
35
35
|
mimeType: 'image/tiff',
|
|
36
|
-
base64Prefix: ['
|
|
36
|
+
base64Prefix: ['SUkqA', 'TU0AK'],
|
|
37
37
|
},
|
|
38
38
|
ICO: {
|
|
39
39
|
name: 'Windows Icon',
|
|
40
40
|
extension: 'ico',
|
|
41
41
|
mimeType: 'image/x-icon',
|
|
42
|
-
base64Prefix: ['
|
|
42
|
+
base64Prefix: ['AAABA'],
|
|
43
43
|
},
|
|
44
44
|
SVG: {
|
|
45
45
|
name: 'Scalable Vector Graphics',
|
|
46
46
|
extension: 'svg',
|
|
47
47
|
mimeType: 'image/svg+xml',
|
|
48
|
-
base64Prefix: ['
|
|
48
|
+
base64Prefix: ['PHN2Z', 'PD94bW'],
|
|
49
49
|
},
|
|
50
50
|
HEIC: {
|
|
51
51
|
name: 'High Efficiency Image Format',
|
|
52
52
|
extension: 'heic',
|
|
53
53
|
mimeType: 'image/heic',
|
|
54
|
-
base64Prefix: [
|
|
54
|
+
base64Prefix: [],
|
|
55
55
|
},
|
|
56
56
|
AVIF: {
|
|
57
57
|
name: 'AV1 Image File Format',
|
|
58
58
|
extension: 'avif',
|
|
59
59
|
mimeType: 'image/avif',
|
|
60
|
-
base64Prefix: [
|
|
60
|
+
base64Prefix: [],
|
|
61
61
|
},
|
|
62
62
|
PSD: {
|
|
63
63
|
name: 'Adobe Photoshop Document',
|
|
64
64
|
extension: 'psd',
|
|
65
65
|
mimeType: 'image/vnd.adobe.photoshop',
|
|
66
|
-
base64Prefix: ['
|
|
66
|
+
base64Prefix: ['OEJQU'],
|
|
67
67
|
},
|
|
68
68
|
unknown: {
|
|
69
69
|
name: 'Unknown Format',
|
|
@@ -72,15 +72,88 @@ const imageFormats = {
|
|
|
72
72
|
base64Prefix: [],
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
+
/** Quantos caracteres de base64 decodificar para ler a assinatura (múltiplo de 4). */
|
|
76
|
+
const CARACTERES_PARA_ASSINATURA = 1024;
|
|
77
|
+
const temBytes = (bytes, esperado, inicio = 0) => esperado.every((byte, i) => bytes[inicio + i] === byte);
|
|
78
|
+
const ascii = (texto) => texto.split('').map((c) => c.charCodeAt(0));
|
|
79
|
+
const MARCAS_HEIC = [
|
|
80
|
+
'heic',
|
|
81
|
+
'heix',
|
|
82
|
+
'hevc',
|
|
83
|
+
'hevx',
|
|
84
|
+
'heim',
|
|
85
|
+
'heis',
|
|
86
|
+
'hevm',
|
|
87
|
+
'hevs',
|
|
88
|
+
];
|
|
89
|
+
const MARCAS_AVIF = ['avif', 'avis'];
|
|
90
|
+
const marcaIsoBmff = (bytes) => {
|
|
91
|
+
if (!temBytes(bytes, ascii('ftyp'), 4))
|
|
92
|
+
return null;
|
|
93
|
+
return String.fromCharCode(...bytes.slice(8, 12));
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Assinatura de cada formato, em bytes. Fontes: WHATWG MIME Sniffing Standard, "Matching an
|
|
97
|
+
* image type pattern" (ICO, BMP, GIF, WebP, PNG, JPEG); TIFF 6.0 (II*\0 e MM\0*); Adobe
|
|
98
|
+
* Photoshop File Formats Specification (8BPS); ISO/IEC 14496-12 e 23008-12 e AV1 Image File
|
|
99
|
+
* Format (caixa ftyp com a marca principal); SVG 1.1 (elemento raiz svg, documento XML).
|
|
100
|
+
*/
|
|
101
|
+
const assinaturas = {
|
|
102
|
+
JPEG: (b) => temBytes(b, [0xff, 0xd8, 0xff]),
|
|
103
|
+
PNG: (b) => temBytes(b, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
|
|
104
|
+
GIF: (b) => temBytes(b, ascii('GIF87a')) || temBytes(b, ascii('GIF89a')),
|
|
105
|
+
WEBP: (b) => temBytes(b, ascii('RIFF')) && temBytes(b, ascii('WEBPVP'), 8),
|
|
106
|
+
BMP: (b) => temBytes(b, ascii('BM')),
|
|
107
|
+
TIFF: (b) => temBytes(b, [0x49, 0x49, 0x2a, 0x00]) ||
|
|
108
|
+
temBytes(b, [0x4d, 0x4d, 0x00, 0x2a]),
|
|
109
|
+
ICO: (b) => temBytes(b, [0x00, 0x00, 0x01, 0x00]),
|
|
110
|
+
SVG: (_b, texto) => {
|
|
111
|
+
const inicio = texto.replace(/^/, '').trimStart();
|
|
112
|
+
return inicio.startsWith('<') && inicio.includes('<svg');
|
|
113
|
+
},
|
|
114
|
+
HEIC: (b) => MARCAS_HEIC.includes(marcaIsoBmff(b) ?? ''),
|
|
115
|
+
AVIF: (b) => MARCAS_AVIF.includes(marcaIsoBmff(b) ?? ''),
|
|
116
|
+
PSD: (b) => temBytes(b, ascii('8BPS')),
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Detecta o formato da imagem pela assinatura dos primeiros bytes do conteúdo base64.
|
|
120
|
+
*/
|
|
121
|
+
function findFormatBySignature(base64Str) {
|
|
122
|
+
const trecho = base64Str.length > CARACTERES_PARA_ASSINATURA
|
|
123
|
+
? base64Str.slice(0, CARACTERES_PARA_ASSINATURA)
|
|
124
|
+
: base64Str;
|
|
125
|
+
let texto;
|
|
126
|
+
try {
|
|
127
|
+
texto = atob(trecho);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return 'unknown';
|
|
131
|
+
}
|
|
132
|
+
const bytes = ascii(texto);
|
|
133
|
+
for (const [format, confere] of Object.entries(assinaturas)) {
|
|
134
|
+
if (confere(bytes, texto))
|
|
135
|
+
return format;
|
|
136
|
+
}
|
|
137
|
+
return 'unknown';
|
|
138
|
+
}
|
|
139
|
+
/** Tipos MIME aceitos em data URI que não são o tipo principal do formato. */
|
|
140
|
+
const MIME_ALTERNATIVOS = {
|
|
141
|
+
'image/jpg': 'JPEG',
|
|
142
|
+
'image/pjpeg': 'JPEG',
|
|
143
|
+
'image/vnd.microsoft.icon': 'ICO',
|
|
144
|
+
};
|
|
75
145
|
/**
|
|
76
|
-
*
|
|
146
|
+
* Formato a partir do tipo MIME de uma data URI, ou 'unknown' se não for um tipo conhecido.
|
|
77
147
|
*/
|
|
78
|
-
function
|
|
148
|
+
function findFormatByMimeType(mimeType) {
|
|
149
|
+
const tipo = mimeType.trim().toLowerCase();
|
|
150
|
+
if (MIME_ALTERNATIVOS[tipo])
|
|
151
|
+
return MIME_ALTERNATIVOS[tipo];
|
|
79
152
|
for (const [format, info] of Object.entries(imageFormats)) {
|
|
80
|
-
if (info.
|
|
153
|
+
if (format !== 'unknown' && info.mimeType === tipo) {
|
|
81
154
|
return format;
|
|
82
155
|
}
|
|
83
156
|
}
|
|
84
157
|
return 'unknown';
|
|
85
158
|
}
|
|
86
|
-
export { imageFormats,
|
|
159
|
+
export { imageFormats, findFormatBySignature, findFormatByMimeType, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { imageFormats,
|
|
1
|
+
import { imageFormats, findFormatBySignature, findFormatByMimeType, } from './image-formats.js';
|
|
2
2
|
/**
|
|
3
3
|
* Cria objeto de valor para imagens em base64.
|
|
4
4
|
* Valida se a string fornecida é uma imagem base64 válida.
|
|
@@ -44,7 +44,7 @@ class ImagemBase64 {
|
|
|
44
44
|
if (this._isDataUri) {
|
|
45
45
|
return this._content;
|
|
46
46
|
}
|
|
47
|
-
return `data
|
|
47
|
+
return `data:${imageFormats[this._format].mimeType};base64,${this._content}`;
|
|
48
48
|
}
|
|
49
49
|
toJSON() {
|
|
50
50
|
if (!this._isValid) {
|
|
@@ -60,7 +60,7 @@ class ImagemBase64 {
|
|
|
60
60
|
format: this._format,
|
|
61
61
|
isValid: true,
|
|
62
62
|
version: this.version,
|
|
63
|
-
mimeType:
|
|
63
|
+
mimeType: imageFormats[this._format].mimeType,
|
|
64
64
|
isDataUri: this._isDataUri,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
@@ -94,16 +94,25 @@ class ImagemBase64 {
|
|
|
94
94
|
if (!this._content || typeof this._content !== 'string') {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
// Verifica se é data URI
|
|
97
|
+
// Verifica se é data URI: data:image/<subtipo>[;parâmetros];base64,<conteúdo>
|
|
98
|
+
// (RFC 2397: sem ";base64" os dados são texto com codificação por cento)
|
|
98
99
|
if (this._content.startsWith('data:image/')) {
|
|
99
100
|
this._isDataUri = true;
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
101
|
+
const virgula = this._content.indexOf(',');
|
|
102
|
+
if (virgula < 0)
|
|
103
|
+
return;
|
|
104
|
+
const [mimeType, ...parametros] = this._content
|
|
105
|
+
.slice('data:'.length, virgula)
|
|
106
|
+
.split(';');
|
|
107
|
+
const base64Content = this._content.slice(virgula + 1);
|
|
108
|
+
if (!parametros.some((p) => p.trim().toLowerCase() === 'base64')) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!this.isBase64String(base64Content)) {
|
|
102
112
|
return;
|
|
103
113
|
}
|
|
104
|
-
|
|
105
|
-
this.
|
|
106
|
-
this._isValid = true;
|
|
114
|
+
this._format = findFormatByMimeType(mimeType);
|
|
115
|
+
this._isValid = this._format !== 'unknown';
|
|
107
116
|
return;
|
|
108
117
|
}
|
|
109
118
|
// Verifica se é base64 puro
|
|
@@ -111,7 +120,7 @@ class ImagemBase64 {
|
|
|
111
120
|
return;
|
|
112
121
|
}
|
|
113
122
|
// Detecta o formato
|
|
114
|
-
this._format =
|
|
123
|
+
this._format = findFormatBySignature(this._content);
|
|
115
124
|
this._isValid = this._format !== 'unknown';
|
|
116
125
|
}
|
|
117
126
|
isBase64String(str) {
|
|
@@ -30,13 +30,16 @@ class Telefone {
|
|
|
30
30
|
this._countryCode = '55';
|
|
31
31
|
this._areaCode = tel.slice(0, 2);
|
|
32
32
|
this._phoneNum = tel.slice(2);
|
|
33
|
-
this._isValid = this.isDDDValid();
|
|
33
|
+
this._isValid = this.isDDDValid() && this.isSubscriberNumberValid();
|
|
34
34
|
}
|
|
35
35
|
else if (tel.length === 12 || tel.length === 13) {
|
|
36
36
|
this._countryCode = tel.slice(0, 2);
|
|
37
37
|
this._areaCode = tel.slice(2, 4);
|
|
38
38
|
this._phoneNum = tel.slice(4);
|
|
39
|
-
this._isValid =
|
|
39
|
+
this._isValid =
|
|
40
|
+
this._countryCode === '55' &&
|
|
41
|
+
this.isDDDValid() &&
|
|
42
|
+
this.isSubscriberNumberValid();
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
42
45
|
throw new Error('Could not parse phone number from string. Try creating the record using an object { countryCode: string; areaCode: string; phoneNum: string }');
|
|
@@ -47,7 +50,10 @@ class Telefone {
|
|
|
47
50
|
this._areaCode = phone.areaCode.replace(/[^\d]+/g, '');
|
|
48
51
|
this._phoneNum = phone.phoneNum.replace(/[^\d]+/g, '');
|
|
49
52
|
if (this._countryCode === '55') {
|
|
50
|
-
this._isValid =
|
|
53
|
+
this._isValid =
|
|
54
|
+
this.isDDDValid() &&
|
|
55
|
+
this.isSubscriberNumberValid() &&
|
|
56
|
+
this.isCountryCodeValid();
|
|
51
57
|
}
|
|
52
58
|
else {
|
|
53
59
|
this._isValid = this.isCountryCodeValid();
|
|
@@ -71,10 +77,14 @@ class Telefone {
|
|
|
71
77
|
const lastDigits = num.splice(-4, 4);
|
|
72
78
|
return `+${this._countryCode} ${this._areaCode} ${num.join('')}-${lastDigits.join('')}`;
|
|
73
79
|
}
|
|
74
|
-
get
|
|
80
|
+
get value() {
|
|
75
81
|
this.isValid({ raiseException: true });
|
|
76
82
|
return `${this._countryCode}${this._areaCode}${this._phoneNum}`;
|
|
77
83
|
}
|
|
84
|
+
/** @deprecated Use `value` instead */
|
|
85
|
+
get onlyNumbers() {
|
|
86
|
+
return this.value;
|
|
87
|
+
}
|
|
78
88
|
get country() {
|
|
79
89
|
return countryCodes[this._countryCode].code;
|
|
80
90
|
}
|
|
@@ -86,7 +96,7 @@ class Telefone {
|
|
|
86
96
|
toJSON() {
|
|
87
97
|
return {
|
|
88
98
|
type: this.type,
|
|
89
|
-
value: this.
|
|
99
|
+
value: this.value,
|
|
90
100
|
formatted: this.formatted,
|
|
91
101
|
isValid: this._isValid,
|
|
92
102
|
version: this.version,
|
|
@@ -108,7 +118,7 @@ class Telefone {
|
|
|
108
118
|
return false;
|
|
109
119
|
try {
|
|
110
120
|
const otherPhone = other instanceof Telefone ? other : new Telefone(other);
|
|
111
|
-
return this.
|
|
121
|
+
return this.value === otherPhone.value;
|
|
112
122
|
}
|
|
113
123
|
catch {
|
|
114
124
|
return false;
|
|
@@ -117,6 +127,14 @@ class Telefone {
|
|
|
117
127
|
isDDDValid() {
|
|
118
128
|
return DDD[this._areaCode] !== undefined;
|
|
119
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Número do assinante no plano de numeração brasileiro (Anatel): 8 dígitos (fixo) ou
|
|
132
|
+
* 9 dígitos (celular), e o nono dígito do celular é sempre 9, à esquerda
|
|
133
|
+
* (Resolução Anatel nº 553/2010; Regulamento Geral de Numeração, Resolução nº 749/2022).
|
|
134
|
+
*/
|
|
135
|
+
isSubscriberNumberValid() {
|
|
136
|
+
return /^(\d{8}|9\d{8})$/.test(this._phoneNum);
|
|
137
|
+
}
|
|
120
138
|
isCountryCodeValid() {
|
|
121
139
|
return countryCodes[this._countryCode] !== undefined;
|
|
122
140
|
}
|
|
@@ -9,6 +9,8 @@ declare class CpfCnpj implements IBaseClassNumbers {
|
|
|
9
9
|
get version(): string;
|
|
10
10
|
get validation(): string;
|
|
11
11
|
get formatted(): string;
|
|
12
|
+
get value(): string;
|
|
13
|
+
/** @deprecated Use `value` instead */
|
|
12
14
|
get onlyNumbers(): string;
|
|
13
15
|
toJSON(): object;
|
|
14
16
|
toString(): string;
|
|
@@ -19,6 +21,12 @@ declare class CpfCnpj implements IBaseClassNumbers {
|
|
|
19
21
|
private isCpfValid;
|
|
20
22
|
private isCnpjValid;
|
|
21
23
|
private static CpfVerifierDigits;
|
|
24
|
+
/**
|
|
25
|
+
* Valor do caractere no cálculo do DV do CNPJ: código ASCII menos 48
|
|
26
|
+
* (0 = 0, 9 = 9, A = 17, Z = 42), segundo a Receita Federal (CNPJ alfanumérico,
|
|
27
|
+
* pergunta 14) e o Serpro (Cálculo dos dígitos verificadores de CNPJ alfanumérico).
|
|
28
|
+
*/
|
|
29
|
+
private static charToValue;
|
|
22
30
|
private static CnpjVerifierDigits;
|
|
23
31
|
}
|
|
24
32
|
export { CpfCnpj };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cpf_cnpj/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIvE,cAAM,OAAQ,YAAW,iBAAiB;IACxC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cpf_cnpj/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIvE,cAAM,OAAQ,YAAW,iBAAiB;IACxC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,MAAM,EAAE,MAAM,GAAG,MAAM,EAclC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAIvB;IAED,IAAI,SAAS,IAAI,MAAM,CAatB;IAED,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,sCAAsC;IACtC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,MAAM,IAAI,MAAM,CAQf;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAUxC;IAED,MAAM,CAAC,MAAM,IAAI,OAAO,CAQvB;IAED,MAAM,CAAC,OAAO,IAAI,OAAO,CAQxB;IAED,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAUhC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAiBlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -2,13 +2,23 @@ interface ImageFormatInfo {
|
|
|
2
2
|
name: string;
|
|
3
3
|
extension: string;
|
|
4
4
|
mimeType: string;
|
|
5
|
+
/**
|
|
6
|
+
* Início do base64 de todo arquivo do formato (informativo). A detecção não usa este
|
|
7
|
+
* campo: ela decodifica os primeiros bytes e compara com a assinatura do formato, porque
|
|
8
|
+
* em vários formatos a assinatura não começa no primeiro byte (WebP, HEIC, AVIF) ou
|
|
9
|
+
* não fecha um grupo de 3 bytes, e o base64 dela depende dos bytes seguintes.
|
|
10
|
+
*/
|
|
5
11
|
base64Prefix: string[];
|
|
6
12
|
}
|
|
7
13
|
declare const imageFormats: Record<string, ImageFormatInfo>;
|
|
8
14
|
type ImageFormat = keyof typeof imageFormats | 'unknown';
|
|
9
15
|
/**
|
|
10
|
-
* Detecta o formato da imagem
|
|
16
|
+
* Detecta o formato da imagem pela assinatura dos primeiros bytes do conteúdo base64.
|
|
11
17
|
*/
|
|
12
|
-
declare function
|
|
13
|
-
|
|
18
|
+
declare function findFormatBySignature(base64Str: string): ImageFormat;
|
|
19
|
+
/**
|
|
20
|
+
* Formato a partir do tipo MIME de uma data URI, ou 'unknown' se não for um tipo conhecido.
|
|
21
|
+
*/
|
|
22
|
+
declare function findFormatByMimeType(mimeType: string): ImageFormat;
|
|
23
|
+
export { imageFormats, type ImageFormat, type ImageFormatInfo, findFormatBySignature, findFormatByMimeType, };
|
|
14
24
|
//# sourceMappingURL=image-formats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-formats.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/image-formats.ts"],"names":[],"mappings":"AAAA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAyExC,CAAA;AAEV,KAAK,WAAW,GAAG,MAAM,OAAO,YAAY,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"image-formats.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/image-formats.ts"],"names":[],"mappings":"AAAA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAyExC,CAAA;AAEV,KAAK,WAAW,GAAG,MAAM,OAAO,YAAY,GAAG,SAAS,CAAA;AAsDxD;;GAEG;AACH,iBAAS,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAgB7D;AASD;;GAEG;AACH,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAS3D;AAED,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/imagem_base64/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,oBAAoB,CAAA;AAE3B;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,OAAO,EAAE,MAAM,EAG1B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,MAAM,IAAI,WAAW,CAGxB;IAED,IAAI,OAAO,IAAI,MAAM,CAGpB;IAED,IAAI,UAAU,IAAI,eAAe,CAGhC;IAED,OAAO,KAAK,OAAO,GAMlB;IAED,MAAM,IAAI,MAAM,CAkBf;IAED,QAAQ,IAAI,MAAM,CAGjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,CAc7C;IAED,OAAO,CAAC,QAAQ;IAsChB,OAAO,CAAC,cAAc;CAUvB;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/placa_veiculo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpE,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/placa_veiculo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpE,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,KAAK,EAAE,MAAM,EAKxB;IAED,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY;IAiBpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,IAAI,SAAS,IAAI,MAAM,CAUtB;IAED,IAAI,WAAW,IAAI,MAAM,CAGxB;IAED,MAAM,IAAI,MAAM,CASf;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,CAY7C;IAED;;OAEG;IACH,UAAU,IAAI,OAAO,CAEpB;IAED;;OAEG;IACH,WAAW,IAAI,OAAO,CAErB;CACF;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,CAAA"}
|
|
@@ -24,6 +24,8 @@ declare class Telefone implements IBaseClassNumbers {
|
|
|
24
24
|
get version(): string;
|
|
25
25
|
get validation(): string;
|
|
26
26
|
get formatted(): string;
|
|
27
|
+
get value(): string;
|
|
28
|
+
/** @deprecated Use `value` instead */
|
|
27
29
|
get onlyNumbers(): string;
|
|
28
30
|
get country(): string;
|
|
29
31
|
get estate(): string | null;
|
|
@@ -32,6 +34,12 @@ declare class Telefone implements IBaseClassNumbers {
|
|
|
32
34
|
isValid(config?: ValidConfig): boolean;
|
|
33
35
|
equals(other: Telefone | unknown): boolean;
|
|
34
36
|
private isDDDValid;
|
|
37
|
+
/**
|
|
38
|
+
* Número do assinante no plano de numeração brasileiro (Anatel): 8 dígitos (fixo) ou
|
|
39
|
+
* 9 dígitos (celular), e o nono dígito do celular é sempre 9, à esquerda
|
|
40
|
+
* (Resolução Anatel nº 553/2010; Regulamento Geral de Numeração, Resolução nº 749/2022).
|
|
41
|
+
*/
|
|
42
|
+
private isSubscriberNumberValid;
|
|
35
43
|
private isCountryCodeValid;
|
|
36
44
|
}
|
|
37
45
|
export { Telefone, type PhoneInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/telefone/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEvE,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;GAMG;AACH,cAAM,QAAS,YAAW,iBAAiB;IACzC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/telefone/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEvE,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;GAMG;AACH,cAAM,QAAS,YAAW,iBAAiB;IACzC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAEzC,YAAY,QAAQ,EAAE,MAAM,GAAG,UAAU,EAMxC;IAED,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,eAAe;IAevB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAKvB;IAED,IAAI,SAAS,IAAI,MAAM,CAKtB;IAED,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,sCAAsC;IACtC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,IAAI,CAG1B;IAED,MAAM,IAAI,MAAM,CAUf;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO,CAKhE;IAED,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAUzC;IAED,OAAO,CAAC,UAAU;IAIlB;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,kBAAkB;CAG3B;AAED,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,CAAA"}
|
|
@@ -14,7 +14,9 @@ interface IBaseClass<T> extends IMetadata {
|
|
|
14
14
|
toString(): string;
|
|
15
15
|
}
|
|
16
16
|
interface IBaseClassNumbers extends IBaseClass<IBaseClassNumbers> {
|
|
17
|
+
/** @deprecated Use `value` instead — `onlyNumbers` pode conter letras (CNPJ alfanumérico) */
|
|
17
18
|
get onlyNumbers(): string;
|
|
19
|
+
get value(): string;
|
|
18
20
|
}
|
|
19
21
|
interface IBaseClassText extends IBaseClass<IBaseClassText> {
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_class.d.ts","sourceRoot":"","sources":["../../../../src/types/base_class.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,UAAU,SAAS;IACjB,IAAI,IAAI,IAAI,MAAM,CAAA;IAClB,IAAI,OAAO,IAAI,MAAM,CAAA;IACrB,IAAI,UAAU,IAAI,MAAM,CAAA;CACzB;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS;IACvC,IAAI,SAAS,IAAI,MAAM,CAAA;IACvB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAA;IACrC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,GAAG,OAAO,CAAA;IACnC,MAAM,IAAI,MAAM,CAAA;IAChB,QAAQ,IAAI,MAAM,CAAA;CACnB;AAED,UAAU,iBAAkB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,IAAI,WAAW,IAAI,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"base_class.d.ts","sourceRoot":"","sources":["../../../../src/types/base_class.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,UAAU,SAAS;IACjB,IAAI,IAAI,IAAI,MAAM,CAAA;IAClB,IAAI,OAAO,IAAI,MAAM,CAAA;IACrB,IAAI,UAAU,IAAI,MAAM,CAAA;CACzB;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS;IACvC,IAAI,SAAS,IAAI,MAAM,CAAA;IACvB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAA;IACrC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,GAAG,OAAO,CAAA;IACnC,MAAM,IAAI,MAAM,CAAA;IAChB,QAAQ,IAAI,MAAM,CAAA;CACnB;AAED,UAAU,iBAAkB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,6FAA6F;IAC7F,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,KAAK,IAAI,MAAM,CAAA;CACpB;AAED,UAAU,cAAe,SAAQ,UAAU,CAAC,cAAc,CAAC;CAAG;AAE9D,UAAU,OAAO,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAClD,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,OAAO,IAAI,MAAM,CAAA;CACtB;AAED,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devix-tecnologia/value-objects",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Coleção de objetos de valores para implementação em sistemas.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,37 +22,49 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "vitest run",
|
|
25
|
+
"test:pacote": "vitest run --config vitest.pacote.config.ts",
|
|
25
26
|
"clean": "rm -rf ./dist",
|
|
26
|
-
"build": "
|
|
27
|
-
"build:esm": "tsc -p ./tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs",
|
|
28
|
-
"build:cjs": "tsc -p ./tsconfig.cjs.json",
|
|
27
|
+
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
|
|
28
|
+
"build:esm": "node node_modules/typescript-native/bin/tsc -p ./tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs",
|
|
29
|
+
"build:cjs": "node node_modules/typescript-native/bin/tsc -p ./tsconfig.cjs.json",
|
|
29
30
|
"postbuild": "node ./scripts/prepare-package-json",
|
|
30
|
-
"prepack": "
|
|
31
|
+
"prepack": "pnpm build",
|
|
31
32
|
"semantic-release": "semantic-release",
|
|
32
33
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
34
|
+
"banner": "node scripts/gerar-banner.ts",
|
|
33
35
|
"lint": "eslint --fix --ext .ts,.tsx --no-error-on-unmatched-pattern --max-warnings=0 --config eslint.config.js src/"
|
|
34
36
|
},
|
|
35
|
-
"author": "
|
|
37
|
+
"author": "Devix Tecnologia Ltda",
|
|
38
|
+
"contributors": [
|
|
39
|
+
{
|
|
40
|
+
"name": "Roberto Seba",
|
|
41
|
+
"github": "https://github.com/robertoseba",
|
|
42
|
+
"linkedin": "https://www.linkedin.com/in/robertoseba"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "Sidarta Veloso",
|
|
46
|
+
"github": "https://github.com/sidartaveloso",
|
|
47
|
+
"linkedin": "https://www.linkedin.com/in/sidartaveloso"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
36
50
|
"license": "MIT",
|
|
37
51
|
"devDependencies": {
|
|
38
|
-
"@eslint/js": "^
|
|
39
|
-
"@semantic-release/
|
|
40
|
-
"@semantic-release/
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@typescript-eslint/
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^5.9.3",
|
|
55
|
-
"vitest": "^3.2.4"
|
|
52
|
+
"@eslint/js": "^10.0.1",
|
|
53
|
+
"@semantic-release/github": "^12.0.11",
|
|
54
|
+
"@semantic-release/npm": "^13.2.0",
|
|
55
|
+
"@types/node": "^26.6.11",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.74.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.74.0",
|
|
58
|
+
"@vitest/ui": "^5.1.2",
|
|
59
|
+
"eslint": "^10.16.0",
|
|
60
|
+
"eslint-config-prettier": "^10.1.9",
|
|
61
|
+
"playwright": "^1.65.1",
|
|
62
|
+
"prettier": "^3.10.1",
|
|
63
|
+
"semantic-release": "^26.0.1",
|
|
64
|
+
"taskin": "^5.3.2",
|
|
65
|
+
"typescript": "^6.0.3",
|
|
66
|
+
"typescript-native": "npm:typescript@^7.0.2",
|
|
67
|
+
"vitest": "^5.1.2"
|
|
56
68
|
},
|
|
57
69
|
"exports": {
|
|
58
70
|
".": {
|
|
@@ -67,6 +79,6 @@
|
|
|
67
79
|
}
|
|
68
80
|
},
|
|
69
81
|
"engines": {
|
|
70
|
-
"node": ">=
|
|
82
|
+
"node": ">=22.0.0"
|
|
71
83
|
}
|
|
72
84
|
}
|