@pairus/product-data 1.4.0 → 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 +80 -73
- package/dist/index.d.ts +80 -73
- 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,110 +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
|
-
vUnTrib?: number;
|
|
145
|
-
vDesc?: number;
|
|
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;
|
|
146
147
|
/** Desconto concedido no item (R$). */
|
|
147
148
|
desconto?: number;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
pPIS?: number;
|
|
158
|
-
cst_cofins?: string;
|
|
159
|
-
pCOFINS?: number;
|
|
160
|
-
cst_ibscbs?: string;
|
|
161
|
-
cClassTrib?: string;
|
|
162
|
-
infAdProd?: string;
|
|
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;
|
|
163
158
|
}
|
|
164
159
|
interface EmissaoDestinatarioInput {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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;
|
|
169
167
|
email?: string;
|
|
170
|
-
telefone?: string;
|
|
171
168
|
logradouro?: string;
|
|
172
169
|
numero?: string;
|
|
170
|
+
complemento?: string;
|
|
173
171
|
bairro?: string;
|
|
174
172
|
codigo_municipio?: string;
|
|
175
|
-
|
|
173
|
+
municipio?: string;
|
|
176
174
|
uf?: string;
|
|
177
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;
|
|
178
183
|
}
|
|
179
184
|
interface EmissaoNFeInput {
|
|
180
|
-
|
|
185
|
+
cnpj_emitente: string;
|
|
181
186
|
itens: EmissaoItemInput[];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
tipo_documento?: 'NFE' | 'NFCE';
|
|
188
|
+
modo_emissao?: 'direto' | 'assistido' | 'simulacao';
|
|
189
|
+
ambiente?: 'producao' | 'homologacao';
|
|
190
|
+
natureza_operacao?: string;
|
|
185
191
|
serie?: number;
|
|
192
|
+
/** Omitido: a API reserva o próximo número de forma atômica. */
|
|
186
193
|
numero?: number;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
forma_pagamento?: string;
|
|
192
|
-
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[];
|
|
193
198
|
informacoes_complementares?: string;
|
|
194
|
-
autocura?: boolean;
|
|
195
|
-
modo_emissao?: 'producao' | 'homologacao' | 'simulacao';
|
|
196
199
|
id_token_csc?: string;
|
|
197
200
|
codigo_csc?: string;
|
|
198
201
|
[key: string]: any;
|
|
199
202
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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;
|
|
205
210
|
}
|
|
206
211
|
interface EmissaoNFeResponse {
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
sucesso: boolean;
|
|
213
|
+
/** 'AUTORIZADA', 'REJEITADA', 'PENDENTE_RETORNO', 'DENEGADA' ou 'SIMULADA'. */
|
|
214
|
+
status_sefaz: string;
|
|
215
|
+
cStat: number;
|
|
209
216
|
xMotivo: string;
|
|
210
|
-
chave_acesso?: string;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
danfe_url?: string;
|
|
216
|
-
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;
|
|
217
222
|
ambiente?: string;
|
|
223
|
+
tipo_documento?: string;
|
|
218
224
|
autocura_aplicada?: boolean;
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
xml_autorizado_base64?: string | null;
|
|
226
|
+
danfe_pdf_base64?: string | null;
|
|
227
|
+
qrcode_url?: string | null;
|
|
221
228
|
consumo_creditos?: number;
|
|
222
|
-
|
|
229
|
+
/** true quando é a repetição de uma emissão já processada com a mesma Idempotency-Key. */
|
|
230
|
+
repeticao_idempotente?: boolean;
|
|
223
231
|
[key: string]: any;
|
|
224
232
|
}
|
|
225
233
|
interface EventoNFeResponse {
|
|
226
|
-
status: string;
|
|
227
234
|
sucesso: boolean;
|
|
228
235
|
cStat: string | number;
|
|
229
236
|
xMotivo: string;
|
|
230
237
|
tipo_evento: string;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
xml_evento_base64?: string;
|
|
238
|
+
protocolo_evento?: string | null;
|
|
239
|
+
data_registro?: string | null;
|
|
240
|
+
xml_evento_base64?: string | null;
|
|
235
241
|
consumo_creditos?: number;
|
|
236
242
|
[key: string]: any;
|
|
237
243
|
}
|
|
@@ -252,18 +258,19 @@ interface InutilizacaoInput {
|
|
|
252
258
|
numero_final: number;
|
|
253
259
|
justificativa: string;
|
|
254
260
|
ano?: number;
|
|
255
|
-
|
|
261
|
+
/** '55' (NF-e) ou '65' (NFC-e). */
|
|
262
|
+
modelo?: '55' | '65' | 55 | 65;
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
declare class EmissaoResource extends BaseResource {
|
|
259
266
|
/**
|
|
260
267
|
* Emite uma Nota Fiscal Eletrônica (NF-e Modelo 55) perante a SEFAZ.
|
|
261
268
|
*/
|
|
262
|
-
emitirNFe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
269
|
+
emitirNFe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
263
270
|
/**
|
|
264
271
|
* Emite uma Nota Fiscal de Consumidor Eletrônica (NFC-e Modelo 65) perante a SEFAZ.
|
|
265
272
|
*/
|
|
266
|
-
emitirNFCe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
273
|
+
emitirNFCe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
267
274
|
/**
|
|
268
275
|
* Simula uma emissão fiscal sem transmitir à SEFAZ (custo ZERO de créditos).
|
|
269
276
|
*/
|
|
@@ -665,4 +672,4 @@ declare class NetworkError extends PairusError {
|
|
|
665
672
|
constructor(message: string);
|
|
666
673
|
}
|
|
667
674
|
|
|
668
|
-
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,110 +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
|
-
vUnTrib?: number;
|
|
145
|
-
vDesc?: number;
|
|
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;
|
|
146
147
|
/** Desconto concedido no item (R$). */
|
|
147
148
|
desconto?: number;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
pPIS?: number;
|
|
158
|
-
cst_cofins?: string;
|
|
159
|
-
pCOFINS?: number;
|
|
160
|
-
cst_ibscbs?: string;
|
|
161
|
-
cClassTrib?: string;
|
|
162
|
-
infAdProd?: string;
|
|
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;
|
|
163
158
|
}
|
|
164
159
|
interface EmissaoDestinatarioInput {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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;
|
|
169
167
|
email?: string;
|
|
170
|
-
telefone?: string;
|
|
171
168
|
logradouro?: string;
|
|
172
169
|
numero?: string;
|
|
170
|
+
complemento?: string;
|
|
173
171
|
bairro?: string;
|
|
174
172
|
codigo_municipio?: string;
|
|
175
|
-
|
|
173
|
+
municipio?: string;
|
|
176
174
|
uf?: string;
|
|
177
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;
|
|
178
183
|
}
|
|
179
184
|
interface EmissaoNFeInput {
|
|
180
|
-
|
|
185
|
+
cnpj_emitente: string;
|
|
181
186
|
itens: EmissaoItemInput[];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
tipo_documento?: 'NFE' | 'NFCE';
|
|
188
|
+
modo_emissao?: 'direto' | 'assistido' | 'simulacao';
|
|
189
|
+
ambiente?: 'producao' | 'homologacao';
|
|
190
|
+
natureza_operacao?: string;
|
|
185
191
|
serie?: number;
|
|
192
|
+
/** Omitido: a API reserva o próximo número de forma atômica. */
|
|
186
193
|
numero?: number;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
forma_pagamento?: string;
|
|
192
|
-
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[];
|
|
193
198
|
informacoes_complementares?: string;
|
|
194
|
-
autocura?: boolean;
|
|
195
|
-
modo_emissao?: 'producao' | 'homologacao' | 'simulacao';
|
|
196
199
|
id_token_csc?: string;
|
|
197
200
|
codigo_csc?: string;
|
|
198
201
|
[key: string]: any;
|
|
199
202
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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;
|
|
205
210
|
}
|
|
206
211
|
interface EmissaoNFeResponse {
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
sucesso: boolean;
|
|
213
|
+
/** 'AUTORIZADA', 'REJEITADA', 'PENDENTE_RETORNO', 'DENEGADA' ou 'SIMULADA'. */
|
|
214
|
+
status_sefaz: string;
|
|
215
|
+
cStat: number;
|
|
209
216
|
xMotivo: string;
|
|
210
|
-
chave_acesso?: string;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
danfe_url?: string;
|
|
216
|
-
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;
|
|
217
222
|
ambiente?: string;
|
|
223
|
+
tipo_documento?: string;
|
|
218
224
|
autocura_aplicada?: boolean;
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
xml_autorizado_base64?: string | null;
|
|
226
|
+
danfe_pdf_base64?: string | null;
|
|
227
|
+
qrcode_url?: string | null;
|
|
221
228
|
consumo_creditos?: number;
|
|
222
|
-
|
|
229
|
+
/** true quando é a repetição de uma emissão já processada com a mesma Idempotency-Key. */
|
|
230
|
+
repeticao_idempotente?: boolean;
|
|
223
231
|
[key: string]: any;
|
|
224
232
|
}
|
|
225
233
|
interface EventoNFeResponse {
|
|
226
|
-
status: string;
|
|
227
234
|
sucesso: boolean;
|
|
228
235
|
cStat: string | number;
|
|
229
236
|
xMotivo: string;
|
|
230
237
|
tipo_evento: string;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
xml_evento_base64?: string;
|
|
238
|
+
protocolo_evento?: string | null;
|
|
239
|
+
data_registro?: string | null;
|
|
240
|
+
xml_evento_base64?: string | null;
|
|
235
241
|
consumo_creditos?: number;
|
|
236
242
|
[key: string]: any;
|
|
237
243
|
}
|
|
@@ -252,18 +258,19 @@ interface InutilizacaoInput {
|
|
|
252
258
|
numero_final: number;
|
|
253
259
|
justificativa: string;
|
|
254
260
|
ano?: number;
|
|
255
|
-
|
|
261
|
+
/** '55' (NF-e) ou '65' (NFC-e). */
|
|
262
|
+
modelo?: '55' | '65' | 55 | 65;
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
declare class EmissaoResource extends BaseResource {
|
|
259
266
|
/**
|
|
260
267
|
* Emite uma Nota Fiscal Eletrônica (NF-e Modelo 55) perante a SEFAZ.
|
|
261
268
|
*/
|
|
262
|
-
emitirNFe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
269
|
+
emitirNFe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
263
270
|
/**
|
|
264
271
|
* Emite uma Nota Fiscal de Consumidor Eletrônica (NFC-e Modelo 65) perante a SEFAZ.
|
|
265
272
|
*/
|
|
266
|
-
emitirNFCe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
|
|
273
|
+
emitirNFCe(payload: EmissaoNFeInput, options?: EmissaoOptions): Promise<EmissaoNFeResponse>;
|
|
267
274
|
/**
|
|
268
275
|
* Simula uma emissão fiscal sem transmitir à SEFAZ (custo ZERO de créditos).
|
|
269
276
|
*/
|
|
@@ -665,4 +672,4 @@ declare class NetworkError extends PairusError {
|
|
|
665
672
|
constructor(message: string);
|
|
666
673
|
}
|
|
667
674
|
|
|
668
|
-
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
|
}
|