@pairus/product-data 1.3.1 → 1.5.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/README.md +431 -407
- package/dist/index.d.mts +82 -71
- package/dist/index.d.ts +82 -71
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -128,106 +128,116 @@ declare class DFeResource extends BaseResource {
|
|
|
128
128
|
baixarDanfe(chaveAcesso: string): Promise<ArrayBuffer>;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Item da nota fiscal. Os nomes espelham o contrato da API (/v1/nfe/emitir e /v1/nfce/emitir).
|
|
133
|
+
*/
|
|
131
134
|
interface EmissaoItemInput {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
pPIS?: number;
|
|
156
|
-
cst_cofins?: string;
|
|
157
|
-
pCOFINS?: number;
|
|
158
|
-
cst_ibscbs?: string;
|
|
159
|
-
cClassTrib?: string;
|
|
160
|
-
infAdProd?: string;
|
|
135
|
+
descricao: string;
|
|
136
|
+
valor_unitario: number;
|
|
137
|
+
quantidade?: number;
|
|
138
|
+
codigo_produto?: string;
|
|
139
|
+
/** Código de barras GTIN/EAN ou 'SEM GTIN'. */
|
|
140
|
+
gtin?: string;
|
|
141
|
+
ncm?: string;
|
|
142
|
+
cest?: string;
|
|
143
|
+
cfop?: string;
|
|
144
|
+
/** '0' Nacional, '1' Importada, etc. */
|
|
145
|
+
origem_mercadoria?: string;
|
|
146
|
+
unidade_comercial?: string;
|
|
147
|
+
/** Desconto concedido no item (R$). */
|
|
148
|
+
desconto?: number;
|
|
149
|
+
/** CST (Regime Normal) ou CSOSN (Simples Nacional) do ICMS. */
|
|
150
|
+
icms_cst_csosn?: string;
|
|
151
|
+
icms_aliquota?: number;
|
|
152
|
+
pis_cst?: string;
|
|
153
|
+
pis_aliquota?: number;
|
|
154
|
+
cofins_cst?: string;
|
|
155
|
+
cofins_aliquota?: number;
|
|
156
|
+
informacoes_adicionais?: string;
|
|
157
|
+
[key: string]: any;
|
|
161
158
|
}
|
|
162
159
|
interface EmissaoDestinatarioInput {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
/** CPF (11 dígitos) ou CNPJ (14 dígitos). Obrigatório na NF-e; opcional na NFC-e. */
|
|
161
|
+
cpf_cnpj?: string;
|
|
162
|
+
razao_social?: string;
|
|
163
|
+
/** '1' Contribuinte, '2' Isento, '9' Não Contribuinte. */
|
|
164
|
+
indicador_ie?: string;
|
|
165
|
+
inscricao_estadual?: string;
|
|
166
|
+
consumidor_final?: boolean;
|
|
167
167
|
email?: string;
|
|
168
|
-
telefone?: string;
|
|
169
168
|
logradouro?: string;
|
|
170
169
|
numero?: string;
|
|
170
|
+
complemento?: string;
|
|
171
171
|
bairro?: string;
|
|
172
172
|
codigo_municipio?: string;
|
|
173
|
-
|
|
173
|
+
municipio?: string;
|
|
174
174
|
uf?: string;
|
|
175
175
|
cep?: string;
|
|
176
|
+
[key: string]: any;
|
|
177
|
+
}
|
|
178
|
+
/** Forma de pagamento; acima do total da nota, a API gera o troco (vTroco). */
|
|
179
|
+
interface EmissaoPagamentoInput {
|
|
180
|
+
/** Código SEFAZ: '01' Dinheiro, '03' Crédito, '04' Débito, '17' PIX... */
|
|
181
|
+
forma_pagamento?: string;
|
|
182
|
+
valor: number;
|
|
176
183
|
}
|
|
177
184
|
interface EmissaoNFeInput {
|
|
178
|
-
|
|
185
|
+
cnpj_emitente: string;
|
|
179
186
|
itens: EmissaoItemInput[];
|
|
180
|
-
|
|
187
|
+
tipo_documento?: 'NFE' | 'NFCE';
|
|
188
|
+
modo_emissao?: 'direto' | 'assistido' | 'simulacao';
|
|
189
|
+
ambiente?: 'producao' | 'homologacao';
|
|
190
|
+
natureza_operacao?: string;
|
|
181
191
|
serie?: number;
|
|
192
|
+
/** Omitido: a API reserva o próximo número de forma atômica. */
|
|
182
193
|
numero?: number;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
forma_pagamento?: string;
|
|
188
|
-
valor_pagamento?: number;
|
|
194
|
+
destinatario?: EmissaoDestinatarioInput;
|
|
195
|
+
/** Desconto sobre o total da nota (R$), rateado proporcionalmente entre os itens pela API. */
|
|
196
|
+
desconto_geral?: number;
|
|
197
|
+
pagamentos?: EmissaoPagamentoInput[];
|
|
189
198
|
informacoes_complementares?: string;
|
|
190
|
-
autocura?: boolean;
|
|
191
|
-
modo_emissao?: 'producao' | 'homologacao' | 'simulacao';
|
|
192
199
|
id_token_csc?: string;
|
|
193
200
|
codigo_csc?: string;
|
|
194
201
|
[key: string]: any;
|
|
195
202
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
/** Opções de envio da emissão. */
|
|
204
|
+
interface EmissaoOptions {
|
|
205
|
+
/**
|
|
206
|
+
* Identificador único da venda (8 a 128 caracteres). Se omitido, o SDK gera um UUID e o reutiliza
|
|
207
|
+
* nas retentativas automáticas, impedindo que um timeout emita a mesma venda duas vezes.
|
|
208
|
+
*/
|
|
209
|
+
idempotencyKey?: string;
|
|
201
210
|
}
|
|
202
211
|
interface EmissaoNFeResponse {
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
sucesso: boolean;
|
|
213
|
+
/** 'AUTORIZADA', 'REJEITADA', 'PENDENTE_RETORNO', 'DENEGADA' ou 'SIMULADA'. */
|
|
214
|
+
status_sefaz: string;
|
|
215
|
+
cStat: number;
|
|
205
216
|
xMotivo: string;
|
|
206
|
-
chave_acesso?: string;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
danfe_url?: string;
|
|
212
|
-
qrcode_url?: string;
|
|
217
|
+
chave_acesso?: string | null;
|
|
218
|
+
protocolo?: string | null;
|
|
219
|
+
numero?: number | null;
|
|
220
|
+
serie?: number | null;
|
|
221
|
+
data_emissao?: string | null;
|
|
213
222
|
ambiente?: string;
|
|
223
|
+
tipo_documento?: string;
|
|
214
224
|
autocura_aplicada?: boolean;
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
xml_autorizado_base64?: string | null;
|
|
226
|
+
danfe_pdf_base64?: string | null;
|
|
227
|
+
qrcode_url?: string | null;
|
|
217
228
|
consumo_creditos?: number;
|
|
218
|
-
|
|
229
|
+
/** true quando é a repetição de uma emissão já processada com a mesma Idempotency-Key. */
|
|
230
|
+
repeticao_idempotente?: boolean;
|
|
219
231
|
[key: string]: any;
|
|
220
232
|
}
|
|
221
233
|
interface EventoNFeResponse {
|
|
222
|
-
status: string;
|
|
223
234
|
sucesso: boolean;
|
|
224
235
|
cStat: string | number;
|
|
225
236
|
xMotivo: string;
|
|
226
237
|
tipo_evento: string;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
xml_evento_base64?: string;
|
|
238
|
+
protocolo_evento?: string | null;
|
|
239
|
+
data_registro?: string | null;
|
|
240
|
+
xml_evento_base64?: string | null;
|
|
231
241
|
consumo_creditos?: number;
|
|
232
242
|
[key: string]: any;
|
|
233
243
|
}
|
|
@@ -248,18 +258,19 @@ interface InutilizacaoInput {
|
|
|
248
258
|
numero_final: number;
|
|
249
259
|
justificativa: string;
|
|
250
260
|
ano?: number;
|
|
251
|
-
|
|
261
|
+
/** '55' (NF-e) ou '65' (NFC-e). */
|
|
262
|
+
modelo?: '55' | '65' | 55 | 65;
|
|
252
263
|
}
|
|
253
264
|
|
|
254
265
|
declare class EmissaoResource extends BaseResource {
|
|
255
266
|
/**
|
|
256
267
|
* Emite uma Nota Fiscal Eletrônica (NF-e Modelo 55) perante a SEFAZ.
|
|
257
268
|
*/
|
|
258
|
-
emitirNFe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
269
|
+
emitirNFe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
259
270
|
/**
|
|
260
271
|
* Emite uma Nota Fiscal de Consumidor Eletrônica (NFC-e Modelo 65) perante a SEFAZ.
|
|
261
272
|
*/
|
|
262
|
-
emitirNFCe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
273
|
+
emitirNFCe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
263
274
|
/**
|
|
264
275
|
* Simula uma emissão fiscal sem transmitir à SEFAZ (custo ZERO de créditos).
|
|
265
276
|
*/
|
|
@@ -661,4 +672,4 @@ declare class NetworkError extends PairusError {
|
|
|
661
672
|
constructor(message: string);
|
|
662
673
|
}
|
|
663
674
|
|
|
664
|
-
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type
|
|
675
|
+
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, type EmissaoOptions, type EmissaoPagamentoInput, EmissaoResource, type EnderecoNFSeInput, type EventoNFeResponse, FiscalResource, type FiscalSanitizeItemInput, type FiscalSanitizeItemResult, type FiscalSanitizeResponse, type FuelData, type IBSCBSData, type InutilizacaoInput, InvalidSignatureError, type ListarDocumentosDFeParams, type ListarDocumentosDFeResponse, type ManifestarDFeInput, type ManifestarDFeResponse, type NFSeEmissaoInput, type NFSeEmissaoResponse, NFSeResource, NetworkError, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type PrestadorNFSeInput, type ProductDetails, type ProductEnrichedDetails, type ProductResponse, type ProductSearchResponse, type ProductSearchResultItem, ProductsResource, RateLimitError, type RetencoesFederaisInput, type SelectiveTaxData, type ServicoNFSeInput, type SincronizarDFeInput, type SincronizarDFeResponse, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TipoManifestacaoDFe, type TomadorNFSeInput, type WebhookEvent, Webhooks };
|
package/dist/index.d.ts
CHANGED
|
@@ -128,106 +128,116 @@ declare class DFeResource extends BaseResource {
|
|
|
128
128
|
baixarDanfe(chaveAcesso: string): Promise<ArrayBuffer>;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Item da nota fiscal. Os nomes espelham o contrato da API (/v1/nfe/emitir e /v1/nfce/emitir).
|
|
133
|
+
*/
|
|
131
134
|
interface EmissaoItemInput {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
pPIS?: number;
|
|
156
|
-
cst_cofins?: string;
|
|
157
|
-
pCOFINS?: number;
|
|
158
|
-
cst_ibscbs?: string;
|
|
159
|
-
cClassTrib?: string;
|
|
160
|
-
infAdProd?: string;
|
|
135
|
+
descricao: string;
|
|
136
|
+
valor_unitario: number;
|
|
137
|
+
quantidade?: number;
|
|
138
|
+
codigo_produto?: string;
|
|
139
|
+
/** Código de barras GTIN/EAN ou 'SEM GTIN'. */
|
|
140
|
+
gtin?: string;
|
|
141
|
+
ncm?: string;
|
|
142
|
+
cest?: string;
|
|
143
|
+
cfop?: string;
|
|
144
|
+
/** '0' Nacional, '1' Importada, etc. */
|
|
145
|
+
origem_mercadoria?: string;
|
|
146
|
+
unidade_comercial?: string;
|
|
147
|
+
/** Desconto concedido no item (R$). */
|
|
148
|
+
desconto?: number;
|
|
149
|
+
/** CST (Regime Normal) ou CSOSN (Simples Nacional) do ICMS. */
|
|
150
|
+
icms_cst_csosn?: string;
|
|
151
|
+
icms_aliquota?: number;
|
|
152
|
+
pis_cst?: string;
|
|
153
|
+
pis_aliquota?: number;
|
|
154
|
+
cofins_cst?: string;
|
|
155
|
+
cofins_aliquota?: number;
|
|
156
|
+
informacoes_adicionais?: string;
|
|
157
|
+
[key: string]: any;
|
|
161
158
|
}
|
|
162
159
|
interface EmissaoDestinatarioInput {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
/** CPF (11 dígitos) ou CNPJ (14 dígitos). Obrigatório na NF-e; opcional na NFC-e. */
|
|
161
|
+
cpf_cnpj?: string;
|
|
162
|
+
razao_social?: string;
|
|
163
|
+
/** '1' Contribuinte, '2' Isento, '9' Não Contribuinte. */
|
|
164
|
+
indicador_ie?: string;
|
|
165
|
+
inscricao_estadual?: string;
|
|
166
|
+
consumidor_final?: boolean;
|
|
167
167
|
email?: string;
|
|
168
|
-
telefone?: string;
|
|
169
168
|
logradouro?: string;
|
|
170
169
|
numero?: string;
|
|
170
|
+
complemento?: string;
|
|
171
171
|
bairro?: string;
|
|
172
172
|
codigo_municipio?: string;
|
|
173
|
-
|
|
173
|
+
municipio?: string;
|
|
174
174
|
uf?: string;
|
|
175
175
|
cep?: string;
|
|
176
|
+
[key: string]: any;
|
|
177
|
+
}
|
|
178
|
+
/** Forma de pagamento; acima do total da nota, a API gera o troco (vTroco). */
|
|
179
|
+
interface EmissaoPagamentoInput {
|
|
180
|
+
/** Código SEFAZ: '01' Dinheiro, '03' Crédito, '04' Débito, '17' PIX... */
|
|
181
|
+
forma_pagamento?: string;
|
|
182
|
+
valor: number;
|
|
176
183
|
}
|
|
177
184
|
interface EmissaoNFeInput {
|
|
178
|
-
|
|
185
|
+
cnpj_emitente: string;
|
|
179
186
|
itens: EmissaoItemInput[];
|
|
180
|
-
|
|
187
|
+
tipo_documento?: 'NFE' | 'NFCE';
|
|
188
|
+
modo_emissao?: 'direto' | 'assistido' | 'simulacao';
|
|
189
|
+
ambiente?: 'producao' | 'homologacao';
|
|
190
|
+
natureza_operacao?: string;
|
|
181
191
|
serie?: number;
|
|
192
|
+
/** Omitido: a API reserva o próximo número de forma atômica. */
|
|
182
193
|
numero?: number;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
forma_pagamento?: string;
|
|
188
|
-
valor_pagamento?: number;
|
|
194
|
+
destinatario?: EmissaoDestinatarioInput;
|
|
195
|
+
/** Desconto sobre o total da nota (R$), rateado proporcionalmente entre os itens pela API. */
|
|
196
|
+
desconto_geral?: number;
|
|
197
|
+
pagamentos?: EmissaoPagamentoInput[];
|
|
189
198
|
informacoes_complementares?: string;
|
|
190
|
-
autocura?: boolean;
|
|
191
|
-
modo_emissao?: 'producao' | 'homologacao' | 'simulacao';
|
|
192
199
|
id_token_csc?: string;
|
|
193
200
|
codigo_csc?: string;
|
|
194
201
|
[key: string]: any;
|
|
195
202
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
/** Opções de envio da emissão. */
|
|
204
|
+
interface EmissaoOptions {
|
|
205
|
+
/**
|
|
206
|
+
* Identificador único da venda (8 a 128 caracteres). Se omitido, o SDK gera um UUID e o reutiliza
|
|
207
|
+
* nas retentativas automáticas, impedindo que um timeout emita a mesma venda duas vezes.
|
|
208
|
+
*/
|
|
209
|
+
idempotencyKey?: string;
|
|
201
210
|
}
|
|
202
211
|
interface EmissaoNFeResponse {
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
sucesso: boolean;
|
|
213
|
+
/** 'AUTORIZADA', 'REJEITADA', 'PENDENTE_RETORNO', 'DENEGADA' ou 'SIMULADA'. */
|
|
214
|
+
status_sefaz: string;
|
|
215
|
+
cStat: number;
|
|
205
216
|
xMotivo: string;
|
|
206
|
-
chave_acesso?: string;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
danfe_url?: string;
|
|
212
|
-
qrcode_url?: string;
|
|
217
|
+
chave_acesso?: string | null;
|
|
218
|
+
protocolo?: string | null;
|
|
219
|
+
numero?: number | null;
|
|
220
|
+
serie?: number | null;
|
|
221
|
+
data_emissao?: string | null;
|
|
213
222
|
ambiente?: string;
|
|
223
|
+
tipo_documento?: string;
|
|
214
224
|
autocura_aplicada?: boolean;
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
xml_autorizado_base64?: string | null;
|
|
226
|
+
danfe_pdf_base64?: string | null;
|
|
227
|
+
qrcode_url?: string | null;
|
|
217
228
|
consumo_creditos?: number;
|
|
218
|
-
|
|
229
|
+
/** true quando é a repetição de uma emissão já processada com a mesma Idempotency-Key. */
|
|
230
|
+
repeticao_idempotente?: boolean;
|
|
219
231
|
[key: string]: any;
|
|
220
232
|
}
|
|
221
233
|
interface EventoNFeResponse {
|
|
222
|
-
status: string;
|
|
223
234
|
sucesso: boolean;
|
|
224
235
|
cStat: string | number;
|
|
225
236
|
xMotivo: string;
|
|
226
237
|
tipo_evento: string;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
xml_evento_base64?: string;
|
|
238
|
+
protocolo_evento?: string | null;
|
|
239
|
+
data_registro?: string | null;
|
|
240
|
+
xml_evento_base64?: string | null;
|
|
231
241
|
consumo_creditos?: number;
|
|
232
242
|
[key: string]: any;
|
|
233
243
|
}
|
|
@@ -248,18 +258,19 @@ interface InutilizacaoInput {
|
|
|
248
258
|
numero_final: number;
|
|
249
259
|
justificativa: string;
|
|
250
260
|
ano?: number;
|
|
251
|
-
|
|
261
|
+
/** '55' (NF-e) ou '65' (NFC-e). */
|
|
262
|
+
modelo?: '55' | '65' | 55 | 65;
|
|
252
263
|
}
|
|
253
264
|
|
|
254
265
|
declare class EmissaoResource extends BaseResource {
|
|
255
266
|
/**
|
|
256
267
|
* Emite uma Nota Fiscal Eletrônica (NF-e Modelo 55) perante a SEFAZ.
|
|
257
268
|
*/
|
|
258
|
-
emitirNFe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
269
|
+
emitirNFe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
259
270
|
/**
|
|
260
271
|
* Emite uma Nota Fiscal de Consumidor Eletrônica (NFC-e Modelo 65) perante a SEFAZ.
|
|
261
272
|
*/
|
|
262
|
-
emitirNFCe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
273
|
+
emitirNFCe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
263
274
|
/**
|
|
264
275
|
* Simula uma emissão fiscal sem transmitir à SEFAZ (custo ZERO de créditos).
|
|
265
276
|
*/
|
|
@@ -661,4 +672,4 @@ declare class NetworkError extends PairusError {
|
|
|
661
672
|
constructor(message: string);
|
|
662
673
|
}
|
|
663
674
|
|
|
664
|
-
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type
|
|
675
|
+
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, type EmissaoOptions, type EmissaoPagamentoInput, EmissaoResource, type EnderecoNFSeInput, type EventoNFeResponse, FiscalResource, type FiscalSanitizeItemInput, type FiscalSanitizeItemResult, type FiscalSanitizeResponse, type FuelData, type IBSCBSData, type InutilizacaoInput, InvalidSignatureError, type ListarDocumentosDFeParams, type ListarDocumentosDFeResponse, type ManifestarDFeInput, type ManifestarDFeResponse, type NFSeEmissaoInput, type NFSeEmissaoResponse, NFSeResource, NetworkError, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type PrestadorNFSeInput, type ProductDetails, type ProductEnrichedDetails, type ProductResponse, type ProductSearchResponse, type ProductSearchResultItem, ProductsResource, RateLimitError, type RetencoesFederaisInput, type SelectiveTaxData, type ServicoNFSeInput, type SincronizarDFeInput, type SincronizarDFeResponse, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TipoManifestacaoDFe, type TomadorNFSeInput, type WebhookEvent, Webhooks };
|
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ var BaseResource = class {
|
|
|
125
125
|
const reqHeaders = {
|
|
126
126
|
"Accept": "application/json",
|
|
127
127
|
"X-API-Key": this.apiKey,
|
|
128
|
-
"User-Agent": "Pairus-NodeJS-SDK/1.
|
|
128
|
+
"User-Agent": "Pairus-NodeJS-SDK/1.5.0",
|
|
129
129
|
...options.headers || {}
|
|
130
130
|
};
|
|
131
131
|
const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
|
|
@@ -165,7 +165,8 @@ var BaseResource = class {
|
|
|
165
165
|
}
|
|
166
166
|
throw new RateLimitError(retryAfterSec, errData.cStat, errData.xMotivo, errData);
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
const vendaEmProcessamento = response.status === 409 && "Idempotency-Key" in reqHeaders;
|
|
169
|
+
if (([502, 503, 504].includes(response.status) || vendaEmProcessamento) && attempt < this.maxRetries - 1) {
|
|
169
170
|
const delay = Math.pow(2, attempt) * 1e3 + Math.random() * 500;
|
|
170
171
|
await new Promise((res) => setTimeout(res, delay));
|
|
171
172
|
continue;
|
|
@@ -390,25 +391,31 @@ var DFeResource = class extends BaseResource {
|
|
|
390
391
|
};
|
|
391
392
|
|
|
392
393
|
// src/resources/emissao.ts
|
|
394
|
+
var import_node_crypto = require("crypto");
|
|
395
|
+
function cabecalhoIdempotencia(options) {
|
|
396
|
+
return { "Idempotency-Key": options?.idempotencyKey || (0, import_node_crypto.randomUUID)() };
|
|
397
|
+
}
|
|
393
398
|
var EmissaoResource = class extends BaseResource {
|
|
394
399
|
/**
|
|
395
400
|
* Emite uma Nota Fiscal Eletrônica (NF-e Modelo 55) perante a SEFAZ.
|
|
396
401
|
*/
|
|
397
|
-
async emitirNFe(payload) {
|
|
402
|
+
async emitirNFe(payload, options) {
|
|
398
403
|
return this.request({
|
|
399
404
|
method: "POST",
|
|
400
405
|
path: "/v1/nfe/emitir",
|
|
401
|
-
body: payload
|
|
406
|
+
body: payload,
|
|
407
|
+
headers: cabecalhoIdempotencia(options)
|
|
402
408
|
});
|
|
403
409
|
}
|
|
404
410
|
/**
|
|
405
411
|
* Emite uma Nota Fiscal de Consumidor Eletrônica (NFC-e Modelo 65) perante a SEFAZ.
|
|
406
412
|
*/
|
|
407
|
-
async emitirNFCe(payload) {
|
|
413
|
+
async emitirNFCe(payload, options) {
|
|
408
414
|
return this.request({
|
|
409
415
|
method: "POST",
|
|
410
416
|
path: "/v1/nfce/emitir",
|
|
411
|
-
body: payload
|
|
417
|
+
body: payload,
|
|
418
|
+
headers: cabecalhoIdempotencia(options)
|
|
412
419
|
});
|
|
413
420
|
}
|
|
414
421
|
/**
|
|
@@ -463,7 +470,7 @@ var EmissaoResource = class extends BaseResource {
|
|
|
463
470
|
numero_final: params.numero_final,
|
|
464
471
|
justificativa: params.justificativa,
|
|
465
472
|
ano: params.ano,
|
|
466
|
-
modelo: params.modelo ?? 55
|
|
473
|
+
modelo: String(params.modelo ?? "55")
|
|
467
474
|
}
|
|
468
475
|
});
|
|
469
476
|
}
|