@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/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
- cProd: string;
133
- xProd: string;
134
- NCM: string;
135
- CFOP: string;
136
- uCom: string;
137
- qCom: number;
138
- vUnCom: number;
139
- vProd: number;
140
- cEAN?: string;
141
- cEANTrib?: string;
142
- uTrib?: string;
143
- qTrib?: number;
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
- vFrete?: number;
149
- vSeg?: number;
150
- vOutro?: number;
151
- CEST?: string;
152
- origem?: string;
153
- cst_icms?: string;
154
- csosn_icms?: string;
155
- pICMS?: number;
156
- cst_pis?: string;
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
- cpf_cnpj: string;
166
- xNome: string;
167
- indIEDest?: string;
168
- IE?: string;
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
- nome_municipio?: string;
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
- natureza_operacao: string;
185
+ cnpj_emitente: string;
181
186
  itens: EmissaoItemInput[];
182
- /** Desconto sobre o total da nota (R$), rateado proporcionalmente entre os itens pela API. */
183
- desconto_geral?: number;
184
- destinatario?: EmissaoDestinatarioInput;
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
- tipo_documento?: number;
188
- finalidade_emissao?: number;
189
- consumidor_final?: number;
190
- presenca_comprador?: number;
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
- interface DetalheAutocura {
201
- campo: string;
202
- valor_original: any;
203
- valor_corrigido: any;
204
- motivo: string;
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
- status: string;
208
- cStat: string;
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
- numero?: number;
212
- serie?: number;
213
- protocolo?: string;
214
- xml_autorizado?: string;
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
- detalhes_autocura?: DetalheAutocura[];
220
- simulacao?: boolean;
225
+ xml_autorizado_base64?: string | null;
226
+ danfe_pdf_base64?: string | null;
227
+ qrcode_url?: string | null;
221
228
  consumo_creditos?: number;
222
- avisos?: string[];
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
- protocolo?: string;
232
- chave_acesso?: string;
233
- data_evento?: string;
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
- modelo?: number;
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 DetalheAutocura, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, 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 };
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
- cProd: string;
133
- xProd: string;
134
- NCM: string;
135
- CFOP: string;
136
- uCom: string;
137
- qCom: number;
138
- vUnCom: number;
139
- vProd: number;
140
- cEAN?: string;
141
- cEANTrib?: string;
142
- uTrib?: string;
143
- qTrib?: number;
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
- vFrete?: number;
149
- vSeg?: number;
150
- vOutro?: number;
151
- CEST?: string;
152
- origem?: string;
153
- cst_icms?: string;
154
- csosn_icms?: string;
155
- pICMS?: number;
156
- cst_pis?: string;
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
- cpf_cnpj: string;
166
- xNome: string;
167
- indIEDest?: string;
168
- IE?: string;
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
- nome_municipio?: string;
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
- natureza_operacao: string;
185
+ cnpj_emitente: string;
181
186
  itens: EmissaoItemInput[];
182
- /** Desconto sobre o total da nota (R$), rateado proporcionalmente entre os itens pela API. */
183
- desconto_geral?: number;
184
- destinatario?: EmissaoDestinatarioInput;
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
- tipo_documento?: number;
188
- finalidade_emissao?: number;
189
- consumidor_final?: number;
190
- presenca_comprador?: number;
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
- interface DetalheAutocura {
201
- campo: string;
202
- valor_original: any;
203
- valor_corrigido: any;
204
- motivo: string;
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
- status: string;
208
- cStat: string;
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
- numero?: number;
212
- serie?: number;
213
- protocolo?: string;
214
- xml_autorizado?: string;
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
- detalhes_autocura?: DetalheAutocura[];
220
- simulacao?: boolean;
225
+ xml_autorizado_base64?: string | null;
226
+ danfe_pdf_base64?: string | null;
227
+ qrcode_url?: string | null;
221
228
  consumo_creditos?: number;
222
- avisos?: string[];
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
- protocolo?: string;
232
- chave_acesso?: string;
233
- data_evento?: string;
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
- modelo?: number;
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 DetalheAutocura, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, 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 };
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.4.0",
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
- if ([502, 503, 504].includes(response.status) && attempt < this.maxRetries - 1) {
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
  }