@bitize/bitmde 0.18.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +309 -4
  3. package/dist/apis/distribuicaoDFe-api.d.ts +13 -1
  4. package/dist/apis/distribuicaoNFSe-api.d.ts +176 -0
  5. package/dist/apis/manifestacaoNFSe-api.d.ts +130 -0
  6. package/dist/apis/recepcaoEvento-api.d.ts +5 -1
  7. package/dist/controllers/distribuicaoDFe-controller.d.ts +5 -1
  8. package/dist/controllers/distribuicaoNFSe-controller.d.ts +50 -0
  9. package/dist/controllers/index.d.ts +84 -0
  10. package/dist/controllers/manifestacaoNFSe-controller.d.ts +38 -0
  11. package/dist/controllers/recepcaoEvento-controller.d.ts +5 -1
  12. package/dist/env/ca.d.ts +8 -2
  13. package/dist/env/index.d.ts +5 -1
  14. package/dist/env/nfse.d.ts +32 -0
  15. package/dist/helpers/distribuicaoDFe-helper.d.ts +4 -0
  16. package/dist/helpers/distribuicaoNFSe-helper.d.ts +107 -0
  17. package/dist/helpers/index.d.ts +158 -0
  18. package/dist/helpers/manifestacaoNFSe-helper.d.ts +80 -0
  19. package/dist/helpers/recepcaoEvento-helper.d.ts +4 -0
  20. package/dist/helpers/retorno-helper.d.ts +5 -0
  21. package/dist/helpers/retornoNfse-helper.d.ts +44 -0
  22. package/dist/index.d.ts +13 -1
  23. package/dist/schemas/index.d.ts +17 -0
  24. package/dist/schemas/manifestacaoNFSe-schema.d.ts +33 -0
  25. package/dist/services/sefaz-service.d.ts +8 -1
  26. package/dist/util/assinatura.d.ts +3 -1
  27. package/dist/util/gzip.d.ts +7 -0
  28. package/dist/util/index.d.ts +2 -1
  29. package/dist/validators/chaveNfse-validator.d.ts +14 -0
  30. package/dist/validators/cnpj-validator.d.ts +19 -0
  31. package/dist/validators/index.d.ts +50 -0
  32. package/dist/validators/motivoRejeicao-validator.d.ts +23 -0
  33. package/dist/validators/nsuNfse-validator.d.ts +20 -0
  34. package/lib/apis/distribuicaoNFSe-api.js +59 -0
  35. package/lib/apis/manifestacaoNFSe-api.js +69 -0
  36. package/lib/controllers/distribuicaoNFSe-controller.js +16 -0
  37. package/lib/controllers/index.js +3 -1
  38. package/lib/controllers/manifestacaoNFSe-controller.js +25 -0
  39. package/lib/env/ca.js +3 -2
  40. package/lib/env/index.js +12 -1
  41. package/lib/env/nfse.js +24 -0
  42. package/lib/env/version.js +1 -1
  43. package/lib/helpers/distribuicaoDFe-helper.js +2 -2
  44. package/lib/helpers/distribuicaoNFSe-helper.js +128 -0
  45. package/lib/helpers/index.js +5 -2
  46. package/lib/helpers/manifestacaoNFSe-helper.js +105 -0
  47. package/lib/helpers/recepcaoEvento-helper.js +2 -2
  48. package/lib/helpers/retorno-helper.js +16 -9
  49. package/lib/helpers/retornoNfse-helper.js +31 -0
  50. package/lib/index.js +13 -1
  51. package/lib/schemas/index.js +2 -1
  52. package/lib/schemas/manifestacaoNFSe-schema.js +19 -0
  53. package/lib/services/sefaz-service.js +15 -14
  54. package/lib/util/assinatura.js +2 -2
  55. package/lib/util/gzip.js +8 -0
  56. package/lib/validators/chaveNfse-validator.js +16 -0
  57. package/lib/validators/cnpj-validator.js +21 -0
  58. package/lib/validators/index.js +5 -1
  59. package/lib/validators/motivoRejeicao-validator.js +28 -0
  60. package/lib/validators/nsuNfse-validator.js +18 -0
  61. package/package.json +10 -4
@@ -0,0 +1,130 @@
1
+ export = ManifestacaoNFSe;
2
+ declare class ManifestacaoNFSe {
3
+ /**
4
+ * Manifestação do tomador da NFS-e Nacional (Confirmação e Rejeição), na
5
+ * SEFIN Nacional. Cada chamada registra um evento fiscal: em produção
6
+ * (`tpAmb` `'1'`), ele não se desfaz.
7
+ *
8
+ * @param {Object} config
9
+ * @param {Buffer} [config.pfx]
10
+ * @param {string} [config.passphrase]
11
+ * @param {Buffer | string} [config.cert]
12
+ * @param {Buffer | string} [config.key]
13
+ * @param {string} config.cnpj CNPJ do tomador, enviado como `CNPJAutor`. Precisa ter a mesma raiz do CNPJ do certificado.
14
+ * @param {'1' | '2'} config.tpAmb `'1'` produção, `'2'` produção restrita.
15
+ * @param {'America/Araguaina' | 'America/Bahia' | 'America/Belem' | 'America/Boa_Vista' | 'America/Campo_Grande' | 'America/Cuiaba' | 'America/Fortaleza' | 'America/Maceio' | 'America/Manaus' | 'America/Noronha' | 'America/Porto_Velho' | 'America/Recife' | 'America/Rio_Branco' | 'America/Sao_Paulo'} [config.timezone = 'America/Sao_Paulo']
16
+ * @param {Object} [config.options]
17
+ * @param {import('axios').AxiosRequestConfig} [config.options.requestOptions]
18
+ * @param {import('https').AgentOptions} [config.options.httpsOptions] Mesclado por cima do padrão `{ ca: CA_PADRAO, rejectUnauthorized: true }`. Informar `ca` substitui a cadeia inteira; para somar uma AC, use `[...CA_PADRAO, minhaCa]`.
19
+ */
20
+ constructor(config: {
21
+ pfx?: Buffer;
22
+ passphrase?: string;
23
+ cert?: Buffer | string;
24
+ key?: Buffer | string;
25
+ cnpj: string;
26
+ tpAmb: "1" | "2";
27
+ timezone?: "America/Araguaina" | "America/Bahia" | "America/Belem" | "America/Boa_Vista" | "America/Campo_Grande" | "America/Cuiaba" | "America/Fortaleza" | "America/Maceio" | "America/Manaus" | "America/Noronha" | "America/Porto_Velho" | "America/Recife" | "America/Rio_Branco" | "America/Sao_Paulo";
28
+ options?: {
29
+ requestOptions?: import("axios").AxiosRequestConfig;
30
+ httpsOptions?: import("https").AgentOptions;
31
+ };
32
+ });
33
+ config: Readonly<{
34
+ cnpj: string;
35
+ tpAmb: "1" | "2";
36
+ timezone: "America/Araguaina" | "America/Bahia" | "America/Belem" | "America/Boa_Vista" | "America/Campo_Grande" | "America/Cuiaba" | "America/Fortaleza" | "America/Maceio" | "America/Manaus" | "America/Noronha" | "America/Porto_Velho" | "America/Recife" | "America/Rio_Branco" | "America/Sao_Paulo";
37
+ cert: string;
38
+ key: string;
39
+ requestOptions: Readonly<import("axios").AxiosRequestConfig<any, any>>;
40
+ httpsOptions: Readonly<import("node:https").AgentOptions>;
41
+ }>;
42
+ /**
43
+ * Confirmação do tomador (`e203202`). Depois dela, o prestador não
44
+ * consegue mais cancelar a NFS-e, só substituí-la.
45
+ *
46
+ * @param {string} chNFSe Chave de acesso de 50 dígitos.
47
+ */
48
+ confirmar(chNFSe: string): Promise<{
49
+ data: {
50
+ tipoAmbiente: string;
51
+ versaoAplicativo: string;
52
+ dataHoraProcessamento: string;
53
+ alertas: Array<{
54
+ codigo: string;
55
+ descricao: string;
56
+ complemento: string;
57
+ }>;
58
+ erros: Array<{
59
+ codigo: string;
60
+ descricao: string;
61
+ complemento: string;
62
+ }>;
63
+ evento: {
64
+ xml?: string;
65
+ json?: any;
66
+ };
67
+ };
68
+ error?: string;
69
+ transportError?: {
70
+ code: string;
71
+ message: string;
72
+ };
73
+ reqXml: string;
74
+ resBody: string;
75
+ status: number;
76
+ }>;
77
+ /**
78
+ * Rejeição do tomador (`e203206`).
79
+ *
80
+ * @param {string} chNFSe Chave de acesso de 50 dígitos.
81
+ * @param {Object} motivo
82
+ * @param {MotivoRejeicaoNFSe} motivo.cMotivo
83
+ * @param {string} [motivo.xMotivo] De 15 a 255 caracteres; obrigatório com `cMotivo` `'9'`.
84
+ */
85
+ rejeitar(chNFSe: string, motivo: {
86
+ cMotivo: MotivoRejeicaoNFSe;
87
+ xMotivo?: string;
88
+ }): Promise<{
89
+ data: {
90
+ tipoAmbiente: string;
91
+ versaoAplicativo: string;
92
+ dataHoraProcessamento: string;
93
+ alertas: Array<{
94
+ codigo: string;
95
+ descricao: string;
96
+ complemento: string;
97
+ }>;
98
+ erros: Array<{
99
+ codigo: string;
100
+ descricao: string;
101
+ complemento: string;
102
+ }>;
103
+ evento: {
104
+ xml?: string;
105
+ json?: any;
106
+ };
107
+ };
108
+ error?: string;
109
+ transportError?: {
110
+ code: string;
111
+ message: string;
112
+ };
113
+ reqXml: string;
114
+ resBody: string;
115
+ status: number;
116
+ }>;
117
+ }
118
+ declare namespace ManifestacaoNFSe {
119
+ export { MotivoRejeicaoNFSe };
120
+ }
121
+ /**
122
+ * Motivo da Rejeição do tomador (`cMotivo`):
123
+ * - `'1'` NFS-e em duplicidade;
124
+ * - `'2'` NFS-e já emitida pelo tomador;
125
+ * - `'3'` não ocorrência do fato gerador;
126
+ * - `'4'` erro quanto à responsabilidade tributária;
127
+ * - `'5'` erro quanto ao valor do serviço, valor das deduções, serviço prestado ou data do fato gerador;
128
+ * - `'9'` outros — exige `xMotivo`.
129
+ */
130
+ type MotivoRejeicaoNFSe = "1" | "2" | "3" | "4" | "5" | "9";
@@ -12,7 +12,7 @@ declare class RecepcaoEvento {
12
12
  * @param {'America/Araguaina' | 'America/Bahia' | 'America/Belem' | 'America/Boa_Vista' | 'America/Campo_Grande' | 'America/Cuiaba' | 'America/Fortaleza' | 'America/Maceio' | 'America/Manaus' | 'America/Noronha' | 'America/Porto_Velho' | 'America/Recife' | 'America/Rio_Branco' | 'America/Sao_Paulo'} [config.timezone = 'America/Sao_Paulo']
13
13
  * @param {Object} [config.options]
14
14
  * @param {import('axios').AxiosRequestConfig} [config.options.requestOptions]
15
- * @param {import('https').AgentOptions} [config.options.httpsOptions]
15
+ * @param {import('https').AgentOptions} [config.options.httpsOptions] Mesclado por cima do padrão `{ ca: CA_PADRAO, rejectUnauthorized: true }`. Informar `ca` substitui a cadeia inteira; para somar uma AC, use `[...CA_PADRAO, minhaCa]`.
16
16
  */
17
17
  constructor(config: {
18
18
  pfx?: Buffer;
@@ -74,6 +74,10 @@ declare class RecepcaoEvento {
74
74
  }];
75
75
  };
76
76
  error: string;
77
+ transportError?: {
78
+ code: string;
79
+ message: string;
80
+ };
77
81
  reqXml: string;
78
82
  resXml: string;
79
83
  status: number;
@@ -4,7 +4,7 @@ declare class DistribuicaoController {
4
4
  /**
5
5
  *
6
6
  * @param {Object} opts
7
- * @returns {Promise<{data:{tpAmb: string,verAplic: string,cStat: string,xMotivo: string,dhResp: string,ultNSU: string,maxNSU: string, docZip:[{xml: string,json: Object,nsu: string,schema: string}], docZipErrors:[{nsu: string,schema: string,error: string}]}, error: string, reqXml: string, resXml: string, status: number}>}
7
+ * @returns {Promise<{data:{tpAmb: string,verAplic: string,cStat: string,xMotivo: string,dhResp: string,ultNSU: string,maxNSU: string, docZip:[{xml: string,json: Object,nsu: string,schema: string}], docZipErrors:[{nsu: string,schema: string,error: string}]}, error: string, transportError?: {code: string, message: string}, reqXml: string, resXml: string, status: number}>}
8
8
  */
9
9
  static enviar(opts: any): Promise<{
10
10
  data: {
@@ -28,6 +28,10 @@ declare class DistribuicaoController {
28
28
  }];
29
29
  };
30
30
  error: string;
31
+ transportError?: {
32
+ code: string;
33
+ message: string;
34
+ };
31
35
  reqXml: string;
32
36
  resXml: string;
33
37
  status: number;
@@ -0,0 +1,50 @@
1
+ declare const _exports: typeof DistribuicaoNFSeController;
2
+ export = _exports;
3
+ declare class DistribuicaoNFSeController {
4
+ /**
5
+ *
6
+ * @param {Object} opts
7
+ * @returns {Promise<{data:{statusProcessamento: string,tipoAmbiente: string,versaoAplicativo: string,dataHoraProcessamento: string, alertas: Array<{codigo: string,descricao: string,complemento: string}>, erros: Array<{codigo: string,descricao: string,complemento: string}>, documentos: Array<{nsu: string,chaveAcesso: string,tipoDocumento: string,tipoEvento: string,dataHoraGeracao: string,papel: '' | 'tomador' | 'prestador' | 'intermediario',xml: string,json: Object}>, documentosErros: Array<{nsu: string,chaveAcesso: string,tipoDocumento: string,error: string}>}, error?: string, transportError?: {code: string, message: string}, resBody: string, status: number}>}
8
+ */
9
+ static enviar(opts: any): Promise<{
10
+ data: {
11
+ statusProcessamento: string;
12
+ tipoAmbiente: string;
13
+ versaoAplicativo: string;
14
+ dataHoraProcessamento: string;
15
+ alertas: Array<{
16
+ codigo: string;
17
+ descricao: string;
18
+ complemento: string;
19
+ }>;
20
+ erros: Array<{
21
+ codigo: string;
22
+ descricao: string;
23
+ complemento: string;
24
+ }>;
25
+ documentos: Array<{
26
+ nsu: string;
27
+ chaveAcesso: string;
28
+ tipoDocumento: string;
29
+ tipoEvento: string;
30
+ dataHoraGeracao: string;
31
+ papel: "" | "tomador" | "prestador" | "intermediario";
32
+ xml: string;
33
+ json: any;
34
+ }>;
35
+ documentosErros: Array<{
36
+ nsu: string;
37
+ chaveAcesso: string;
38
+ tipoDocumento: string;
39
+ error: string;
40
+ }>;
41
+ };
42
+ error?: string;
43
+ transportError?: {
44
+ code: string;
45
+ message: string;
46
+ };
47
+ resBody: string;
48
+ status: number;
49
+ }>;
50
+ }
@@ -24,11 +24,91 @@ declare const controller: Readonly<{
24
24
  }];
25
25
  };
26
26
  error: string;
27
+ transportError?: {
28
+ code: string;
29
+ message: string;
30
+ };
27
31
  reqXml: string;
28
32
  resXml: string;
29
33
  status: number;
30
34
  }>;
31
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
+ };
32
112
  RecepcaoController: {
33
113
  new (): {};
34
114
  enviar(opts: any): Promise<{
@@ -55,6 +135,10 @@ declare const controller: Readonly<{
55
135
  }];
56
136
  };
57
137
  error: string;
138
+ transportError?: {
139
+ code: string;
140
+ message: string;
141
+ };
58
142
  reqXml: string;
59
143
  resXml: string;
60
144
  status: number;
@@ -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
+ }
@@ -4,7 +4,7 @@ declare class RecepcaoController {
4
4
  /**
5
5
  *
6
6
  * @param {Object} opts
7
- * @returns {Promise<{data:{idLote: string,tpAmb: string,verAplic: string,cOrgao: string,cStat: string,xMotivo: string, infEvento:[{tpAmb: string,verAplic: string,cOrgao: string,cStat: string,xMotivo: string,chNFe: string,tpEvento: string,xEvento: string,nSeqEvento: string,CNPJDest: string,dhRegEvento: string,nProt: string}]}, error: string, reqXml: string, resXml: string, status: number}>}
7
+ * @returns {Promise<{data:{idLote: string,tpAmb: string,verAplic: string,cOrgao: string,cStat: string,xMotivo: string, infEvento:[{tpAmb: string,verAplic: string,cOrgao: string,cStat: string,xMotivo: string,chNFe: string,tpEvento: string,xEvento: string,nSeqEvento: string,CNPJDest: string,dhRegEvento: string,nProt: string}]}, error: string, transportError?: {code: string, message: string}, reqXml: string, resXml: string, status: number}>}
8
8
  */
9
9
  static enviar(opts: any): Promise<{
10
10
  data: {
@@ -30,6 +30,10 @@ declare class RecepcaoController {
30
30
  }];
31
31
  };
32
32
  error: string;
33
+ transportError?: {
34
+ code: string;
35
+ message: string;
36
+ };
33
37
  reqXml: string;
34
38
  resXml: string;
35
39
  status: number;
package/dist/env/ca.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  /**
2
- * Cadeia de Certificados da NF-e (www1.nfe.fazenda.gov.br)
3
- * Página Principal > Documentos > Diversos > Cadeia de Certificados do www1 (atualizada em 04/08/2021)
2
+ * Cadeia ICP-Brasil: AC Raiz Brasileira v10 e AC SERPRO SSLv1.
3
+ *
4
+ * Veio do portal da NF-e como "Cadeia de Certificados do www1 (atualizada em
5
+ * 04/08/2021)", mas deixou de ser a cadeia do www1/hom1: desde então o
6
+ * Ambiente Nacional serve AC SERPRO AR46 OV TLS CA 2025 ← GlobalSign Root R46,
7
+ * que só fecha com as raízes padrão do Node. Continua embarcada para quem
8
+ * fala com endpoint ICP-Brasil.
4
9
  * https://www.nfe.fazenda.gov.br/portal/exibirArquivo.aspx?conteudo=JuhROOiTOPA=
5
10
  */
6
11
  export const CA: string[];
12
+ export const CA_PADRAO: string[];
@@ -1,8 +1,12 @@
1
1
  import { CA } from "./ca";
2
+ import { CA_PADRAO } from "./ca";
2
3
  import { CODIGOS_UF } from "./uf";
3
4
  import { DISTRIBUICAO } from "./distribuicao";
4
5
  import { EVENTOS } from "./evento";
6
+ import { EVENTOS_NFSE } from "./nfse";
7
+ import { NFSE_ADN } from "./nfse";
8
+ import { NFSE_SEFIN } from "./nfse";
5
9
  import { RECEPCAO } from "./recepcao";
6
10
  import { VERSION } from "./version";
7
11
  import { ZONES } from "./zone";
8
- export { CA, 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
+ };
@@ -10,6 +10,10 @@ declare class DistribuicaoHelper {
10
10
  static enviarConsulta(data: string, opts: any): Promise<{
11
11
  status: number;
12
12
  data: string;
13
+ transportError?: {
14
+ code: string;
15
+ message: string;
16
+ };
13
17
  }>;
14
18
  /**
15
19
  *
@@ -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
+ }