@bitize/bitmde 0.19.0 → 0.20.0
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/CHANGELOG.md +25 -0
- package/README.md +252 -2
- package/dist/apis/distribuicaoNFSe-api.d.ts +176 -0
- package/dist/apis/manifestacaoNFSe-api.d.ts +130 -0
- package/dist/controllers/distribuicaoNFSe-controller.d.ts +50 -0
- package/dist/controllers/index.d.ts +76 -0
- package/dist/controllers/manifestacaoNFSe-controller.d.ts +38 -0
- package/dist/env/index.d.ts +4 -1
- package/dist/env/nfse.d.ts +32 -0
- package/dist/helpers/distribuicaoNFSe-helper.d.ts +107 -0
- package/dist/helpers/index.d.ts +146 -0
- package/dist/helpers/manifestacaoNFSe-helper.d.ts +80 -0
- package/dist/helpers/retornoNfse-helper.d.ts +44 -0
- package/dist/index.d.ts +7 -1
- package/dist/schemas/index.d.ts +17 -0
- package/dist/schemas/manifestacaoNFSe-schema.d.ts +33 -0
- package/dist/util/assinatura.d.ts +3 -1
- package/dist/util/gzip.d.ts +7 -0
- package/dist/util/index.d.ts +2 -1
- package/dist/validators/chaveNfse-validator.d.ts +14 -0
- package/dist/validators/cnpj-validator.d.ts +19 -0
- package/dist/validators/index.d.ts +50 -0
- package/dist/validators/motivoRejeicao-validator.d.ts +23 -0
- package/dist/validators/nsuNfse-validator.d.ts +20 -0
- package/lib/apis/distribuicaoNFSe-api.js +59 -0
- package/lib/apis/manifestacaoNFSe-api.js +69 -0
- package/lib/controllers/distribuicaoNFSe-controller.js +16 -0
- package/lib/controllers/index.js +3 -1
- package/lib/controllers/manifestacaoNFSe-controller.js +25 -0
- package/lib/env/index.js +8 -1
- package/lib/env/nfse.js +24 -0
- package/lib/env/version.js +1 -1
- package/lib/helpers/distribuicaoNFSe-helper.js +128 -0
- package/lib/helpers/index.js +5 -2
- package/lib/helpers/manifestacaoNFSe-helper.js +105 -0
- package/lib/helpers/retornoNfse-helper.js +31 -0
- package/lib/index.js +7 -1
- package/lib/schemas/index.js +2 -1
- package/lib/schemas/manifestacaoNFSe-schema.js +19 -0
- package/lib/util/assinatura.js +2 -2
- package/lib/util/gzip.js +8 -0
- package/lib/validators/chaveNfse-validator.js +16 -0
- package/lib/validators/cnpj-validator.js +21 -0
- package/lib/validators/index.js +5 -1
- package/lib/validators/motivoRejeicao-validator.js +28 -0
- package/lib/validators/nsuNfse-validator.js +18 -0
- package/package.json +6 -3
|
@@ -33,6 +33,82 @@ declare const controller: Readonly<{
|
|
|
33
33
|
status: number;
|
|
34
34
|
}>;
|
|
35
35
|
};
|
|
36
|
+
DistribuicaoNFSeController: {
|
|
37
|
+
new (): {};
|
|
38
|
+
enviar(opts: any): Promise<{
|
|
39
|
+
data: {
|
|
40
|
+
statusProcessamento: string;
|
|
41
|
+
tipoAmbiente: string;
|
|
42
|
+
versaoAplicativo: string;
|
|
43
|
+
dataHoraProcessamento: string;
|
|
44
|
+
alertas: Array<{
|
|
45
|
+
codigo: string;
|
|
46
|
+
descricao: string;
|
|
47
|
+
complemento: string;
|
|
48
|
+
}>;
|
|
49
|
+
erros: Array<{
|
|
50
|
+
codigo: string;
|
|
51
|
+
descricao: string;
|
|
52
|
+
complemento: string;
|
|
53
|
+
}>;
|
|
54
|
+
documentos: Array<{
|
|
55
|
+
nsu: string;
|
|
56
|
+
chaveAcesso: string;
|
|
57
|
+
tipoDocumento: string;
|
|
58
|
+
tipoEvento: string;
|
|
59
|
+
dataHoraGeracao: string;
|
|
60
|
+
papel: "" | "tomador" | "prestador" | "intermediario";
|
|
61
|
+
xml: string;
|
|
62
|
+
json: any;
|
|
63
|
+
}>;
|
|
64
|
+
documentosErros: Array<{
|
|
65
|
+
nsu: string;
|
|
66
|
+
chaveAcesso: string;
|
|
67
|
+
tipoDocumento: string;
|
|
68
|
+
error: string;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
error?: string;
|
|
72
|
+
transportError?: {
|
|
73
|
+
code: string;
|
|
74
|
+
message: string;
|
|
75
|
+
};
|
|
76
|
+
resBody: string;
|
|
77
|
+
status: number;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
ManifestacaoNFSeController: {
|
|
81
|
+
new (): {};
|
|
82
|
+
enviar(opts: any): Promise<{
|
|
83
|
+
data: {
|
|
84
|
+
tipoAmbiente: string;
|
|
85
|
+
versaoAplicativo: string;
|
|
86
|
+
dataHoraProcessamento: string;
|
|
87
|
+
alertas: Array<{
|
|
88
|
+
codigo: string;
|
|
89
|
+
descricao: string;
|
|
90
|
+
complemento: string;
|
|
91
|
+
}>;
|
|
92
|
+
erros: Array<{
|
|
93
|
+
codigo: string;
|
|
94
|
+
descricao: string;
|
|
95
|
+
complemento: string;
|
|
96
|
+
}>;
|
|
97
|
+
evento: {
|
|
98
|
+
xml?: string;
|
|
99
|
+
json?: any;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
error?: string;
|
|
103
|
+
transportError?: {
|
|
104
|
+
code: string;
|
|
105
|
+
message: string;
|
|
106
|
+
};
|
|
107
|
+
reqXml: string;
|
|
108
|
+
resBody: string;
|
|
109
|
+
status: number;
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
36
112
|
RecepcaoController: {
|
|
37
113
|
new (): {};
|
|
38
114
|
enviar(opts: any): Promise<{
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare const _exports: typeof ManifestacaoNFSeController;
|
|
2
|
+
export = _exports;
|
|
3
|
+
declare class ManifestacaoNFSeController {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} opts
|
|
7
|
+
* @returns {Promise<{data:{tipoAmbiente: string,versaoAplicativo: string,dataHoraProcessamento: string, alertas: Array<{codigo: string,descricao: string,complemento: string}>, erros: Array<{codigo: string,descricao: string,complemento: string}>, evento: {xml?: string, json?: Object}}, error?: string, transportError?: {code: string, message: string}, reqXml: string, resBody: string, status: number}>}
|
|
8
|
+
*/
|
|
9
|
+
static enviar(opts: any): Promise<{
|
|
10
|
+
data: {
|
|
11
|
+
tipoAmbiente: string;
|
|
12
|
+
versaoAplicativo: string;
|
|
13
|
+
dataHoraProcessamento: string;
|
|
14
|
+
alertas: Array<{
|
|
15
|
+
codigo: string;
|
|
16
|
+
descricao: string;
|
|
17
|
+
complemento: string;
|
|
18
|
+
}>;
|
|
19
|
+
erros: Array<{
|
|
20
|
+
codigo: string;
|
|
21
|
+
descricao: string;
|
|
22
|
+
complemento: string;
|
|
23
|
+
}>;
|
|
24
|
+
evento: {
|
|
25
|
+
xml?: string;
|
|
26
|
+
json?: any;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
error?: string;
|
|
30
|
+
transportError?: {
|
|
31
|
+
code: string;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
reqXml: string;
|
|
35
|
+
resBody: string;
|
|
36
|
+
status: number;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
package/dist/env/index.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import { CA_PADRAO } from "./ca";
|
|
|
3
3
|
import { CODIGOS_UF } from "./uf";
|
|
4
4
|
import { DISTRIBUICAO } from "./distribuicao";
|
|
5
5
|
import { EVENTOS } from "./evento";
|
|
6
|
+
import { EVENTOS_NFSE } from "./nfse";
|
|
7
|
+
import { NFSE_ADN } from "./nfse";
|
|
8
|
+
import { NFSE_SEFIN } from "./nfse";
|
|
6
9
|
import { RECEPCAO } from "./recepcao";
|
|
7
10
|
import { VERSION } from "./version";
|
|
8
11
|
import { ZONES } from "./zone";
|
|
9
|
-
export { CA, CA_PADRAO, CODIGOS_UF, DISTRIBUICAO, EVENTOS, RECEPCAO, VERSION, ZONES };
|
|
12
|
+
export { CA, CA_PADRAO, CODIGOS_UF, DISTRIBUICAO, EVENTOS, EVENTOS_NFSE, NFSE_ADN, NFSE_SEFIN, RECEPCAO, VERSION, ZONES };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eventos de manifestação do tomador. O `xDesc` é literal do XSD
|
|
3
|
+
* (`enumeration`), com acento: alterar o texto rejeita o pedido por schema.
|
|
4
|
+
*/
|
|
5
|
+
export const EVENTOS_NFSE: {
|
|
6
|
+
203202: {
|
|
7
|
+
codigo: string;
|
|
8
|
+
elemento: string;
|
|
9
|
+
xDesc: string;
|
|
10
|
+
};
|
|
11
|
+
203206: {
|
|
12
|
+
codigo: string;
|
|
13
|
+
elemento: string;
|
|
14
|
+
xDesc: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* URL base da API de distribuição para contribuintes da NFS-e Nacional
|
|
19
|
+
* Ambiente de Dados Nacional (ADN) — Manual dos Contribuintes, APIs do ADN v1.0
|
|
20
|
+
*/
|
|
21
|
+
export const NFSE_ADN: {
|
|
22
|
+
1: string;
|
|
23
|
+
2: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* URL base da API da SEFIN Nacional, que recebe o pedido de registro de evento
|
|
27
|
+
* (manifestação do tomador) — Swagger SEFIN Nacional v1
|
|
28
|
+
*/
|
|
29
|
+
export const NFSE_SEFIN: {
|
|
30
|
+
1: string;
|
|
31
|
+
2: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
declare const _exports: typeof DistribuicaoNFSeHelper;
|
|
2
|
+
export = _exports;
|
|
3
|
+
declare class DistribuicaoNFSeHelper {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} config
|
|
7
|
+
* @param {Object} opts
|
|
8
|
+
* @returns {Promise<{status: number, data: string, transportError?: {code: string, message: string}}>}
|
|
9
|
+
*/
|
|
10
|
+
static enviarConsulta(config: any, opts: any): Promise<{
|
|
11
|
+
status: number;
|
|
12
|
+
data: string;
|
|
13
|
+
transportError?: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Config da requisição ao axios. Os headers vão na requisição, e não na
|
|
20
|
+
* instância, para o axios mesclá-los com o User-Agent.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} opts
|
|
23
|
+
* @returns {{method: string, url: string, params?: {lote: boolean, cnpjConsulta: string}, headers: Object, responseType: string}}
|
|
24
|
+
*/
|
|
25
|
+
static montarRequest(opts: any): {
|
|
26
|
+
method: string;
|
|
27
|
+
url: string;
|
|
28
|
+
params?: {
|
|
29
|
+
lote: boolean;
|
|
30
|
+
cnpjConsulta: string;
|
|
31
|
+
};
|
|
32
|
+
headers: any;
|
|
33
|
+
responseType: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Interpreta o corpo cru do ADN. Nunca lança: corpo que não é JSON, ou
|
|
37
|
+
* JSON sem `StatusProcessamento`, devolve `null`.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} corpo
|
|
40
|
+
* @param {string} cnpj CNPJ consultado, para o `papel` de cada NFS-e
|
|
41
|
+
* @returns {Promise<{statusProcessamento: string, tipoAmbiente: string, versaoAplicativo: string, dataHoraProcessamento: string, alertas: {codigo: string, descricao: string, complemento: string}[], erros: {codigo: string, descricao: string, complemento: string}[], documentos: {nsu: string, chaveAcesso: string, tipoDocumento: string, tipoEvento: string, dataHoraGeracao: string, papel: string, xml: string, json: Object}[], documentosErros: {nsu: string, chaveAcesso: string, tipoDocumento: string, error: string}[]} | null>}
|
|
42
|
+
*/
|
|
43
|
+
static montarResponse(corpo: string, cnpj: string): Promise<{
|
|
44
|
+
statusProcessamento: string;
|
|
45
|
+
tipoAmbiente: string;
|
|
46
|
+
versaoAplicativo: string;
|
|
47
|
+
dataHoraProcessamento: string;
|
|
48
|
+
alertas: {
|
|
49
|
+
codigo: string;
|
|
50
|
+
descricao: string;
|
|
51
|
+
complemento: string;
|
|
52
|
+
}[];
|
|
53
|
+
erros: {
|
|
54
|
+
codigo: string;
|
|
55
|
+
descricao: string;
|
|
56
|
+
complemento: string;
|
|
57
|
+
}[];
|
|
58
|
+
documentos: {
|
|
59
|
+
nsu: string;
|
|
60
|
+
chaveAcesso: string;
|
|
61
|
+
tipoDocumento: string;
|
|
62
|
+
tipoEvento: string;
|
|
63
|
+
dataHoraGeracao: string;
|
|
64
|
+
papel: string;
|
|
65
|
+
xml: string;
|
|
66
|
+
json: any;
|
|
67
|
+
}[];
|
|
68
|
+
documentosErros: {
|
|
69
|
+
nsu: string;
|
|
70
|
+
chaveAcesso: string;
|
|
71
|
+
tipoDocumento: string;
|
|
72
|
+
error: string;
|
|
73
|
+
}[];
|
|
74
|
+
} | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Descompacta e interpreta um item do `LoteDFe` sem nunca rejeitar: a
|
|
77
|
+
* falha vira um item com `error`, para não derrubar o restante do lote.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} item
|
|
80
|
+
* @param {string} cnpj
|
|
81
|
+
* @returns {Promise<{nsu: string, chaveAcesso: string, tipoDocumento: string, tipoEvento: string, dataHoraGeracao: string, papel: string, xml: string, json: Object} | {nsu: string, chaveAcesso: string, tipoDocumento: string, error: string}>}
|
|
82
|
+
*/
|
|
83
|
+
static abrirArquivoXml(item: any, cnpj: string): Promise<{
|
|
84
|
+
nsu: string;
|
|
85
|
+
chaveAcesso: string;
|
|
86
|
+
tipoDocumento: string;
|
|
87
|
+
tipoEvento: string;
|
|
88
|
+
dataHoraGeracao: string;
|
|
89
|
+
papel: string;
|
|
90
|
+
xml: string;
|
|
91
|
+
json: any;
|
|
92
|
+
} | {
|
|
93
|
+
nsu: string;
|
|
94
|
+
chaveAcesso: string;
|
|
95
|
+
tipoDocumento: string;
|
|
96
|
+
error: string;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Papel do CNPJ consultado na NFS-e. Evento não traz as partes da nota.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} tipoDocumento
|
|
102
|
+
* @param {Object} json
|
|
103
|
+
* @param {string} cnpj
|
|
104
|
+
* @returns {'' | 'tomador' | 'prestador' | 'intermediario'}
|
|
105
|
+
*/
|
|
106
|
+
static calcularPapel(tipoDocumento: string, json: any, cnpj: string): "" | "tomador" | "prestador" | "intermediario";
|
|
107
|
+
}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -43,6 +43,125 @@ declare const helper: Readonly<{
|
|
|
43
43
|
error: string;
|
|
44
44
|
}>;
|
|
45
45
|
};
|
|
46
|
+
DistribuicaoNFSeHelper: {
|
|
47
|
+
new (): {};
|
|
48
|
+
enviarConsulta(config: any, opts: any): Promise<{
|
|
49
|
+
status: number;
|
|
50
|
+
data: string;
|
|
51
|
+
transportError?: {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
montarRequest(opts: any): {
|
|
57
|
+
method: string;
|
|
58
|
+
url: string;
|
|
59
|
+
params?: {
|
|
60
|
+
lote: boolean;
|
|
61
|
+
cnpjConsulta: string;
|
|
62
|
+
};
|
|
63
|
+
headers: any;
|
|
64
|
+
responseType: string;
|
|
65
|
+
};
|
|
66
|
+
montarResponse(corpo: string, cnpj: string): Promise<{
|
|
67
|
+
statusProcessamento: string;
|
|
68
|
+
tipoAmbiente: string;
|
|
69
|
+
versaoAplicativo: string;
|
|
70
|
+
dataHoraProcessamento: string;
|
|
71
|
+
alertas: {
|
|
72
|
+
codigo: string;
|
|
73
|
+
descricao: string;
|
|
74
|
+
complemento: string;
|
|
75
|
+
}[];
|
|
76
|
+
erros: {
|
|
77
|
+
codigo: string;
|
|
78
|
+
descricao: string;
|
|
79
|
+
complemento: string;
|
|
80
|
+
}[];
|
|
81
|
+
documentos: {
|
|
82
|
+
nsu: string;
|
|
83
|
+
chaveAcesso: string;
|
|
84
|
+
tipoDocumento: string;
|
|
85
|
+
tipoEvento: string;
|
|
86
|
+
dataHoraGeracao: string;
|
|
87
|
+
papel: string;
|
|
88
|
+
xml: string;
|
|
89
|
+
json: any;
|
|
90
|
+
}[];
|
|
91
|
+
documentosErros: {
|
|
92
|
+
nsu: string;
|
|
93
|
+
chaveAcesso: string;
|
|
94
|
+
tipoDocumento: string;
|
|
95
|
+
error: string;
|
|
96
|
+
}[];
|
|
97
|
+
} | null>;
|
|
98
|
+
abrirArquivoXml(item: any, cnpj: string): Promise<{
|
|
99
|
+
nsu: string;
|
|
100
|
+
chaveAcesso: string;
|
|
101
|
+
tipoDocumento: string;
|
|
102
|
+
tipoEvento: string;
|
|
103
|
+
dataHoraGeracao: string;
|
|
104
|
+
papel: string;
|
|
105
|
+
xml: string;
|
|
106
|
+
json: any;
|
|
107
|
+
} | {
|
|
108
|
+
nsu: string;
|
|
109
|
+
chaveAcesso: string;
|
|
110
|
+
tipoDocumento: string;
|
|
111
|
+
error: string;
|
|
112
|
+
}>;
|
|
113
|
+
calcularPapel(tipoDocumento: string, json: any, cnpj: string): "" | "tomador" | "prestador" | "intermediario";
|
|
114
|
+
};
|
|
115
|
+
ManifestacaoNFSeHelper: {
|
|
116
|
+
new (): {};
|
|
117
|
+
enviarEvento(config: any, opts: any): Promise<{
|
|
118
|
+
status: number;
|
|
119
|
+
data: string;
|
|
120
|
+
transportError?: {
|
|
121
|
+
code: string;
|
|
122
|
+
message: string;
|
|
123
|
+
};
|
|
124
|
+
}>;
|
|
125
|
+
montarRequest(opts: any): Promise<{
|
|
126
|
+
reqXml: string;
|
|
127
|
+
config: {
|
|
128
|
+
method: string;
|
|
129
|
+
url: string;
|
|
130
|
+
data: string;
|
|
131
|
+
headers: any;
|
|
132
|
+
responseType: string;
|
|
133
|
+
};
|
|
134
|
+
}>;
|
|
135
|
+
montarResponse(corpo: string): Promise<{
|
|
136
|
+
json: {
|
|
137
|
+
tipoAmbiente: string;
|
|
138
|
+
versaoAplicativo: string;
|
|
139
|
+
dataHoraProcessamento: string;
|
|
140
|
+
alertas: {
|
|
141
|
+
codigo: string;
|
|
142
|
+
descricao: string;
|
|
143
|
+
complemento: string;
|
|
144
|
+
}[];
|
|
145
|
+
erros: {
|
|
146
|
+
codigo: string;
|
|
147
|
+
descricao: string;
|
|
148
|
+
complemento: string;
|
|
149
|
+
}[];
|
|
150
|
+
evento: {
|
|
151
|
+
xml?: string;
|
|
152
|
+
json?: any;
|
|
153
|
+
};
|
|
154
|
+
} | null;
|
|
155
|
+
falha?: string;
|
|
156
|
+
}>;
|
|
157
|
+
abrirEvento(eventoXmlGZipB64: string): Promise<{
|
|
158
|
+
evento: {
|
|
159
|
+
xml?: string;
|
|
160
|
+
json?: any;
|
|
161
|
+
};
|
|
162
|
+
falha?: string;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
46
165
|
RecepcaoHelper: {
|
|
47
166
|
new (): {};
|
|
48
167
|
enviarEvento(data: string, opts: any): Promise<{
|
|
@@ -98,4 +217,31 @@ declare const helper: Readonly<{
|
|
|
98
217
|
status: number;
|
|
99
218
|
};
|
|
100
219
|
};
|
|
220
|
+
RetornoNfseHelper: {
|
|
221
|
+
new (): {};
|
|
222
|
+
montarRetorno(options: {
|
|
223
|
+
json: any | null;
|
|
224
|
+
retorno: {
|
|
225
|
+
data: string;
|
|
226
|
+
status: number;
|
|
227
|
+
transportError?: {
|
|
228
|
+
code: string;
|
|
229
|
+
message: string;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
servico?: "ADN" | "SEFIN";
|
|
233
|
+
reqXml?: string;
|
|
234
|
+
falha?: string;
|
|
235
|
+
}): {
|
|
236
|
+
data: any;
|
|
237
|
+
reqXml?: string;
|
|
238
|
+
resBody: string;
|
|
239
|
+
status: number;
|
|
240
|
+
error?: string;
|
|
241
|
+
transportError?: {
|
|
242
|
+
code: string;
|
|
243
|
+
message: string;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
101
247
|
}>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
declare const _exports: typeof ManifestacaoNFSeHelper;
|
|
2
|
+
export = _exports;
|
|
3
|
+
declare class ManifestacaoNFSeHelper {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} config
|
|
7
|
+
* @param {Object} opts
|
|
8
|
+
* @returns {Promise<{status: number, data: string, transportError?: {code: string, message: string}}>}
|
|
9
|
+
*/
|
|
10
|
+
static enviarEvento(config: any, opts: any): Promise<{
|
|
11
|
+
status: number;
|
|
12
|
+
data: string;
|
|
13
|
+
transportError?: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Monta e assina o `pedRegEvento`, e a config do `POST` ao axios. Os
|
|
20
|
+
* headers vão na requisição, e não na instância, para o axios mesclá-los
|
|
21
|
+
* com o User-Agent.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} opts
|
|
24
|
+
* @returns {Promise<{reqXml: string, config: {method: string, url: string, data: string, headers: Object, responseType: string}}>}
|
|
25
|
+
*/
|
|
26
|
+
static montarRequest(opts: any): Promise<{
|
|
27
|
+
reqXml: string;
|
|
28
|
+
config: {
|
|
29
|
+
method: string;
|
|
30
|
+
url: string;
|
|
31
|
+
data: string;
|
|
32
|
+
headers: any;
|
|
33
|
+
responseType: string;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Interpreta o corpo cru da SEFIN. Nunca lança: corpo que não é JSON, ou
|
|
38
|
+
* JSON sem `eventoXmlGZipB64` nem `erro`, devolve `json: null`. Evento
|
|
39
|
+
* retornado que não abre devolve `falha`, que o retorno transforma em
|
|
40
|
+
* `error`.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} corpo
|
|
43
|
+
* @returns {Promise<{json: {tipoAmbiente: string, versaoAplicativo: string, dataHoraProcessamento: string, alertas: {codigo: string, descricao: string, complemento: string}[], erros: {codigo: string, descricao: string, complemento: string}[], evento: {xml?: string, json?: Object}} | null, falha?: string}>}
|
|
44
|
+
*/
|
|
45
|
+
static montarResponse(corpo: string): Promise<{
|
|
46
|
+
json: {
|
|
47
|
+
tipoAmbiente: string;
|
|
48
|
+
versaoAplicativo: string;
|
|
49
|
+
dataHoraProcessamento: string;
|
|
50
|
+
alertas: {
|
|
51
|
+
codigo: string;
|
|
52
|
+
descricao: string;
|
|
53
|
+
complemento: string;
|
|
54
|
+
}[];
|
|
55
|
+
erros: {
|
|
56
|
+
codigo: string;
|
|
57
|
+
descricao: string;
|
|
58
|
+
complemento: string;
|
|
59
|
+
}[];
|
|
60
|
+
evento: {
|
|
61
|
+
xml?: string;
|
|
62
|
+
json?: any;
|
|
63
|
+
};
|
|
64
|
+
} | null;
|
|
65
|
+
falha?: string;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Descompacta e interpreta o evento registrado, sem nunca rejeitar.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} eventoXmlGZipB64
|
|
71
|
+
* @returns {Promise<{evento: {xml?: string, json?: Object}, falha?: string}>}
|
|
72
|
+
*/
|
|
73
|
+
static abrirEvento(eventoXmlGZipB64: string): Promise<{
|
|
74
|
+
evento: {
|
|
75
|
+
xml?: string;
|
|
76
|
+
json?: any;
|
|
77
|
+
};
|
|
78
|
+
falha?: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare const _exports: typeof RetornoNfseHelper;
|
|
2
|
+
export = _exports;
|
|
3
|
+
declare class RetornoNfseHelper {
|
|
4
|
+
/**
|
|
5
|
+
* Formato de retorno das APIs da NFS-e. `status`, `error` e
|
|
6
|
+
* `transportError` têm o mesmo significado das APIs de NF-e; o corpo cru
|
|
7
|
+
* vai em `resBody`.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} options
|
|
10
|
+
* @param {Object | null} options.json `null` quando o corpo não é uma resposta do serviço
|
|
11
|
+
* @param {Object} options.retorno
|
|
12
|
+
* @param {string} options.retorno.data
|
|
13
|
+
* @param {number} options.retorno.status
|
|
14
|
+
* @param {{code: string, message: string}} [options.retorno.transportError]
|
|
15
|
+
* @param {'ADN' | 'SEFIN'} [options.servico = 'ADN'] Nomeia o serviço na mensagem de resposta inesperada
|
|
16
|
+
* @param {string} [options.reqXml] XML de domínio enviado; só existe na manifestação
|
|
17
|
+
* @param {string} [options.falha] Falha do helper ao ler uma resposta bem-sucedida
|
|
18
|
+
* @returns {{data: Object, reqXml?: string, resBody: string, status: number, error?: string, transportError?: {code: string, message: string}}}
|
|
19
|
+
*/
|
|
20
|
+
static montarRetorno(options: {
|
|
21
|
+
json: any | null;
|
|
22
|
+
retorno: {
|
|
23
|
+
data: string;
|
|
24
|
+
status: number;
|
|
25
|
+
transportError?: {
|
|
26
|
+
code: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
servico?: "ADN" | "SEFIN";
|
|
31
|
+
reqXml?: string;
|
|
32
|
+
falha?: string;
|
|
33
|
+
}): {
|
|
34
|
+
data: any;
|
|
35
|
+
reqXml?: string;
|
|
36
|
+
resBody: string;
|
|
37
|
+
status: number;
|
|
38
|
+
error?: string;
|
|
39
|
+
transportError?: {
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
export const CA_ICP_BRASIL: readonly string[];
|
|
2
2
|
export const CA_PADRAO: readonly string[];
|
|
3
3
|
import DistribuicaoDFe = require("./apis/distribuicaoDFe-api");
|
|
4
|
+
import DistribuicaoNFSe = require("./apis/distribuicaoNFSe-api");
|
|
5
|
+
import ManifestacaoNFSe = require("./apis/manifestacaoNFSe-api");
|
|
4
6
|
import RecepcaoEvento = require("./apis/recepcaoEvento-api");
|
|
5
7
|
declare namespace _default {
|
|
6
8
|
export { CA_ICP_BRASIL };
|
|
7
9
|
export { CA_PADRAO };
|
|
8
10
|
export { DistribuicaoDFe };
|
|
11
|
+
export { DistribuicaoNFSe };
|
|
12
|
+
export { ManifestacaoNFSe };
|
|
9
13
|
export { RecepcaoEvento };
|
|
10
14
|
}
|
|
11
15
|
export declare namespace mde {
|
|
12
16
|
export { CA_ICP_BRASIL };
|
|
13
17
|
export { CA_PADRAO };
|
|
14
18
|
export { DistribuicaoDFe };
|
|
19
|
+
export { DistribuicaoNFSe };
|
|
20
|
+
export { ManifestacaoNFSe };
|
|
15
21
|
export { RecepcaoEvento };
|
|
16
22
|
}
|
|
17
|
-
export { DistribuicaoDFe, RecepcaoEvento, _default as default };
|
|
23
|
+
export { DistribuicaoDFe, DistribuicaoNFSe, ManifestacaoNFSe, RecepcaoEvento, _default as default };
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -14,6 +14,23 @@ declare const schema: Readonly<{
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
+
ManifestacaoNFSeSchema: {
|
|
18
|
+
new (): {};
|
|
19
|
+
montarSchema(options: {
|
|
20
|
+
tpAmb: string;
|
|
21
|
+
verAplic: string;
|
|
22
|
+
dhEvento: string;
|
|
23
|
+
cnpj: string;
|
|
24
|
+
chNFSe: string;
|
|
25
|
+
evento: {
|
|
26
|
+
codigo: string;
|
|
27
|
+
elemento: string;
|
|
28
|
+
xDesc: string;
|
|
29
|
+
};
|
|
30
|
+
cMotivo?: string;
|
|
31
|
+
xMotivo?: string;
|
|
32
|
+
}): any;
|
|
33
|
+
};
|
|
17
34
|
RecepcaoSchema: {
|
|
18
35
|
new (): {};
|
|
19
36
|
montarSchema(options: any): {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const _exports: typeof ManifestacaoNFSeSchema;
|
|
2
|
+
export = _exports;
|
|
3
|
+
declare class ManifestacaoNFSeSchema {
|
|
4
|
+
/**
|
|
5
|
+
* `pedRegEvento` v1.01 de um evento do tomador. A ordem das chaves é a do
|
|
6
|
+
* `TCInfPedReg` do XSD.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} options
|
|
9
|
+
* @param {string} options.tpAmb
|
|
10
|
+
* @param {string} options.verAplic
|
|
11
|
+
* @param {string} options.dhEvento
|
|
12
|
+
* @param {string} options.cnpj
|
|
13
|
+
* @param {string} options.chNFSe
|
|
14
|
+
* @param {{codigo: string, elemento: string, xDesc: string}} options.evento
|
|
15
|
+
* @param {string} [options.cMotivo]
|
|
16
|
+
* @param {string} [options.xMotivo]
|
|
17
|
+
* @returns {Object}
|
|
18
|
+
*/
|
|
19
|
+
static montarSchema(options: {
|
|
20
|
+
tpAmb: string;
|
|
21
|
+
verAplic: string;
|
|
22
|
+
dhEvento: string;
|
|
23
|
+
cnpj: string;
|
|
24
|
+
chNFSe: string;
|
|
25
|
+
evento: {
|
|
26
|
+
codigo: string;
|
|
27
|
+
elemento: string;
|
|
28
|
+
xDesc: string;
|
|
29
|
+
};
|
|
30
|
+
cMotivo?: string;
|
|
31
|
+
xMotivo?: string;
|
|
32
|
+
}): any;
|
|
33
|
+
}
|
|
@@ -2,11 +2,13 @@ declare const _exports: typeof Assinatura;
|
|
|
2
2
|
export = _exports;
|
|
3
3
|
declare class Assinatura {
|
|
4
4
|
/**
|
|
5
|
+
* Assina o elemento referenciado e insere a `Signature` logo depois dele.
|
|
5
6
|
*
|
|
6
7
|
* @param {string} cert
|
|
7
8
|
* @param {string} key
|
|
8
9
|
* @param {string} xml
|
|
10
|
+
* @param {string} [elemento = 'infEvento'] `infEvento` na NF-e, `infPedReg` no pedido de evento da NFS-e
|
|
9
11
|
* @returns {string}
|
|
10
12
|
*/
|
|
11
|
-
static assinarXml(cert: string, key: string, xml: string): string;
|
|
13
|
+
static assinarXml(cert: string, key: string, xml: string, elemento?: string): string;
|
|
12
14
|
}
|
package/dist/util/gzip.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
declare const _exports: typeof Gzip;
|
|
2
2
|
export = _exports;
|
|
3
3
|
declare class Gzip {
|
|
4
|
+
/**
|
|
5
|
+
* Inverso do `unzip`: gzip do texto em UTF-8, em base64.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} str
|
|
8
|
+
* @returns {Promise<string>}
|
|
9
|
+
*/
|
|
10
|
+
static zip(str: string): Promise<string>;
|
|
4
11
|
/**
|
|
5
12
|
*
|
|
6
13
|
* @param {string} str
|
package/dist/util/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export = util;
|
|
|
2
2
|
declare const util: Readonly<{
|
|
3
3
|
Assinatura: {
|
|
4
4
|
new (): {};
|
|
5
|
-
assinarXml(cert: string, key: string, xml: string): string;
|
|
5
|
+
assinarXml(cert: string, key: string, xml: string, elemento?: string): string;
|
|
6
6
|
};
|
|
7
7
|
Certificado: {
|
|
8
8
|
new (): {};
|
|
@@ -17,6 +17,7 @@ declare const util: Readonly<{
|
|
|
17
17
|
};
|
|
18
18
|
Gzip: {
|
|
19
19
|
new (): {};
|
|
20
|
+
zip(str: string): Promise<string>;
|
|
20
21
|
unzip(str: string): Promise<string>;
|
|
21
22
|
};
|
|
22
23
|
Xml: {
|