@pairus/product-data 1.0.0 → 1.2.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.ts CHANGED
@@ -27,6 +27,154 @@ declare class BaseResource {
27
27
  protected request<T>(options: RequestOptions): Promise<T>;
28
28
  }
29
29
 
30
+ interface EmissaoItemInput {
31
+ cProd: string;
32
+ xProd: string;
33
+ NCM: string;
34
+ CFOP: string;
35
+ uCom: string;
36
+ qCom: number;
37
+ vUnCom: number;
38
+ vProd: number;
39
+ cEAN?: string;
40
+ cEANTrib?: string;
41
+ uTrib?: string;
42
+ qTrib?: number;
43
+ vUnTrib?: number;
44
+ vDesc?: number;
45
+ vFrete?: number;
46
+ vSeg?: number;
47
+ vOutro?: number;
48
+ CEST?: string;
49
+ origem?: string;
50
+ cst_icms?: string;
51
+ csosn_icms?: string;
52
+ pICMS?: number;
53
+ cst_pis?: string;
54
+ pPIS?: number;
55
+ cst_cofins?: string;
56
+ pCOFINS?: number;
57
+ cst_ibscbs?: string;
58
+ cClassTrib?: string;
59
+ infAdProd?: string;
60
+ }
61
+ interface EmissaoDestinatarioInput {
62
+ cpf_cnpj: string;
63
+ xNome: string;
64
+ indIEDest?: string;
65
+ IE?: string;
66
+ email?: string;
67
+ telefone?: string;
68
+ logradouro?: string;
69
+ numero?: string;
70
+ bairro?: string;
71
+ codigo_municipio?: string;
72
+ nome_municipio?: string;
73
+ uf?: string;
74
+ cep?: string;
75
+ }
76
+ interface EmissaoNFeInput {
77
+ natureza_operacao: string;
78
+ itens: EmissaoItemInput[];
79
+ destinatario?: EmissaoDestinatarioInput;
80
+ serie?: number;
81
+ numero?: number;
82
+ tipo_documento?: number;
83
+ finalidade_emissao?: number;
84
+ consumidor_final?: number;
85
+ presenca_comprador?: number;
86
+ forma_pagamento?: string;
87
+ valor_pagamento?: number;
88
+ informacoes_complementares?: string;
89
+ autocura?: boolean;
90
+ modo_emissao?: 'producao' | 'homologacao' | 'simulacao';
91
+ [key: string]: any;
92
+ }
93
+ interface DetalheAutocura {
94
+ campo: string;
95
+ valor_original: any;
96
+ valor_corrigido: any;
97
+ motivo: string;
98
+ }
99
+ interface EmissaoNFeResponse {
100
+ status: string;
101
+ cStat: string;
102
+ xMotivo: string;
103
+ chave_acesso?: string;
104
+ numero?: number;
105
+ serie?: number;
106
+ protocolo?: string;
107
+ xml_autorizado?: string;
108
+ danfe_url?: string;
109
+ qrcode_url?: string;
110
+ ambiente?: string;
111
+ autocura_aplicada?: boolean;
112
+ detalhes_autocura?: DetalheAutocura[];
113
+ simulacao?: boolean;
114
+ consumo_creditos?: number;
115
+ avisos?: string[];
116
+ [key: string]: any;
117
+ }
118
+ interface EventoNFeResponse {
119
+ status: string;
120
+ sucesso: boolean;
121
+ cStat: string | number;
122
+ xMotivo: string;
123
+ tipo_evento: string;
124
+ protocolo?: string;
125
+ chave_acesso?: string;
126
+ data_evento?: string;
127
+ xml_evento_base64?: string;
128
+ consumo_creditos?: number;
129
+ [key: string]: any;
130
+ }
131
+ interface CancelamentoInput {
132
+ chave_acesso: string;
133
+ justificativa: string;
134
+ protocolo_autorizacao?: string;
135
+ }
136
+ interface CartaCorrecaoInput {
137
+ chave_acesso: string;
138
+ correcao: string;
139
+ sequencia_evento?: number;
140
+ }
141
+ interface InutilizacaoInput {
142
+ cnpj_emitente: string;
143
+ serie: number;
144
+ numero_inicial: number;
145
+ numero_final: number;
146
+ justificativa: string;
147
+ ano?: number;
148
+ modelo?: number;
149
+ }
150
+
151
+ declare class EmissaoResource extends BaseResource {
152
+ /**
153
+ * Emite uma Nota Fiscal Eletrônica (NF-e Modelo 55) perante a SEFAZ.
154
+ */
155
+ emitirNFe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
156
+ /**
157
+ * Emite uma Nota Fiscal de Consumidor Eletrônica (NFC-e Modelo 65) perante a SEFAZ.
158
+ */
159
+ emitirNFCe(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
160
+ /**
161
+ * Simula uma emissão fiscal sem transmitir à SEFAZ (custo ZERO de créditos).
162
+ */
163
+ simular(payload: EmissaoNFeInput): Promise<EmissaoNFeResponse>;
164
+ /**
165
+ * Homologa o cancelamento oficial de uma NF-e ou NFC-e perante a SEFAZ.
166
+ */
167
+ cancelar(params: CancelamentoInput): Promise<EventoNFeResponse>;
168
+ /**
169
+ * Emite uma Carta de Correção Eletrônica (CC-e) perante a SEFAZ.
170
+ */
171
+ cartaCorrecao(params: CartaCorrecaoInput): Promise<EventoNFeResponse>;
172
+ /**
173
+ * Inutiliza uma faixa de numeração quebrada na SEFAZ (Ajuste SINIEF 07/05).
174
+ */
175
+ inutilizar(params: InutilizacaoInput): Promise<EventoNFeResponse>;
176
+ }
177
+
30
178
  interface IBSCBSData {
31
179
  cst: string;
32
180
  cClassTrib: string;
@@ -110,12 +258,167 @@ interface TaxPredictionResponse {
110
258
  dados_tributarios?: TaxPredictionData;
111
259
  resultados?: TaxPredictionItemResult[];
112
260
  }
261
+ interface FiscalSanitizeItemInput {
262
+ ncm: string;
263
+ cest?: string;
264
+ descricao?: string;
265
+ gtin?: string;
266
+ }
267
+ interface FiscalSanitizeItemResult {
268
+ ncm: string;
269
+ ncm_valido: boolean;
270
+ descricao_ncm?: string;
271
+ cest_informado?: string;
272
+ cest_sugerido?: string;
273
+ sujeito_st: boolean;
274
+ aliquotas_sugeridas?: Record<string, any>;
275
+ avisos?: string[];
276
+ }
277
+ interface FiscalSanitizeResponse {
278
+ status: string;
279
+ provider: string;
280
+ timestamp?: string;
281
+ total_itens: number;
282
+ itens: Array<Record<string, any>>;
283
+ }
113
284
 
114
285
  declare class FiscalResource extends BaseResource {
115
286
  /**
116
287
  * Executa a predição fiscal completa da Reforma Tributária (IBS/CBS/IS) e NF-e.
117
288
  */
118
289
  predict(params: TaxPredictionParams): Promise<TaxPredictionResponse>;
290
+ /**
291
+ * Audita e higieniza uma lista de produtos em lote perante as tabelas fiscais vigentes.
292
+ */
293
+ sanitize(itens: Array<Record<string, any>>): Promise<any>;
294
+ }
295
+
296
+ interface EnderecoNFSeInput {
297
+ logradouro: string;
298
+ numero: string;
299
+ complemento?: string;
300
+ bairro: string;
301
+ codigo_municipio_ibge: string;
302
+ uf: string;
303
+ cep: string;
304
+ }
305
+ interface PrestadorNFSeInput {
306
+ cnpj: string;
307
+ inscricao_municipal: string;
308
+ razao_social: string;
309
+ nome_fantasia?: string;
310
+ optante_simples_nacional?: boolean;
311
+ regime_especial_tributacao?: string;
312
+ endereco?: EnderecoNFSeInput;
313
+ }
314
+ interface TomadorNFSeInput {
315
+ cpf_cnpj: string;
316
+ razao_social: string;
317
+ inscricao_municipal?: string;
318
+ email?: string;
319
+ telefone?: string;
320
+ endereco?: EnderecoNFSeInput;
321
+ }
322
+ interface RetencoesFederaisInput {
323
+ pis_retido?: boolean;
324
+ aliquota_pis?: number;
325
+ valor_pis?: number;
326
+ cofins_retido?: boolean;
327
+ aliquota_cofins?: number;
328
+ valor_cofins?: number;
329
+ csll_retida?: boolean;
330
+ aliquota_csll?: number;
331
+ valor_csll?: number;
332
+ irrf_retido?: boolean;
333
+ aliquota_irrf?: number;
334
+ valor_irrf?: number;
335
+ inss_retido?: boolean;
336
+ aliquota_inss?: number;
337
+ valor_inss?: number;
338
+ }
339
+ interface ServicoNFSeInput {
340
+ item_lista_servico: string;
341
+ discriminacao: string;
342
+ municipio_prestacao_ibge: string;
343
+ valor_servicos: number;
344
+ codigo_cnae?: string;
345
+ codigo_tributacao_municipio?: string;
346
+ valor_deducoes?: number;
347
+ valor_desconto_incondicionado?: number;
348
+ valor_desconto_condicionado?: number;
349
+ iss_retido?: boolean;
350
+ aliquota_iss?: number;
351
+ exigibilidade_iss?: string;
352
+ retencoes_federais?: RetencoesFederaisInput;
353
+ }
354
+ interface NFSeEmissaoInput {
355
+ prestador: PrestadorNFSeInput | Record<string, any>;
356
+ tomador: TomadorNFSeInput | Record<string, any>;
357
+ servico: ServicoNFSeInput | Record<string, any>;
358
+ serie_dps?: string;
359
+ numero_dps?: number;
360
+ modo?: 'direto' | 'assistido' | 'simulacao';
361
+ politica_rejeicao?: 'autocura_silenciosa' | 'autocura_assistida' | 'nenhuma';
362
+ ambiente?: 'producao' | 'homologacao';
363
+ informacoes_complementares?: string;
364
+ webhook_url?: string;
365
+ }
366
+ interface NFSeEmissaoResponse {
367
+ sucesso: boolean;
368
+ status: 'autorizada' | 'rejeitada' | 'cancelada' | 'simulada';
369
+ numero_nfse?: string;
370
+ codigo_verificacao?: string;
371
+ chave_acesso_nacional?: string;
372
+ data_emissao?: string;
373
+ link_visualizacao?: string;
374
+ danfse_pdf_base64?: string;
375
+ xml_nfse?: string;
376
+ valor_servicos: number;
377
+ valor_iss: number;
378
+ valor_iss_retido: number;
379
+ total_retencoes_federais: number;
380
+ valor_liquido: number;
381
+ erros?: string[];
382
+ alertas?: string[];
383
+ trilha_auditoria?: Record<string, any>[];
384
+ creditos_cobrados: number;
385
+ tempo_processamento_ms: number;
386
+ }
387
+ interface CancelamentoNFSeInput {
388
+ numero_nfse: string;
389
+ cnpj_prestador: string;
390
+ inscricao_municipal: string;
391
+ codigo_municipio_ibge: string;
392
+ justificativa: string;
393
+ motivo_codigo?: string;
394
+ codigo_verificacao?: string;
395
+ chave_acesso_nacional?: string;
396
+ }
397
+ interface CancelamentoNFSeResponse {
398
+ sucesso: boolean;
399
+ numero_nfse: string;
400
+ data_cancelamento?: string;
401
+ mensagem: string;
402
+ erros?: string[];
403
+ }
404
+
405
+ declare class NFSeResource extends BaseResource {
406
+ /**
407
+ * Emite uma Nota Fiscal de Serviços Eletrônica (NFS-e) perante o SND ou prefeitura.
408
+ */
409
+ emitir(payload: NFSeEmissaoInput | Record<string, any>): Promise<NFSeEmissaoResponse>;
410
+ /**
411
+ * Simula o cálculo de NFS-e com retenções e apuração tributária (custo ZERO de créditos).
412
+ */
413
+ simular(payload: NFSeEmissaoInput | Record<string, any>): Promise<NFSeEmissaoResponse>;
414
+ /**
415
+ * Homologa o cancelamento oficial de uma NFS-e perante o SND ou prefeitura.
416
+ */
417
+ cancelar(payload: CancelamentoNFSeInput): Promise<CancelamentoNFSeResponse>;
418
+ /**
419
+ * Consulta os dados, status e DANFSE de uma NFS-e pelo número ou chave de 50 dígitos.
420
+ */
421
+ consultar(chaveOuNumero: string): Promise<Record<string, any>>;
119
422
  }
120
423
 
121
424
  interface ProductDetails {
@@ -139,13 +442,60 @@ interface ProductResponse {
139
442
  produto?: ProductDetails;
140
443
  raw_data?: Record<string, any>;
141
444
  }
445
+ interface ProductSearchResultItem {
446
+ gtin: string;
447
+ xProd: string;
448
+ marca?: string;
449
+ categoria?: string;
450
+ score?: number;
451
+ ncm?: string;
452
+ cest?: string;
453
+ imagem_url?: string;
454
+ }
455
+ interface ProductSearchResponse {
456
+ status: string;
457
+ provider: string;
458
+ total_encontrados: number;
459
+ termo_buscado: string;
460
+ produtos: ProductSearchResultItem[];
461
+ }
462
+ interface ProductEnrichedDetails {
463
+ gtin: string;
464
+ xProd: string;
465
+ descricao_completa?: string;
466
+ ficha_tecnica?: Record<string, any>;
467
+ palavras_chave?: string[];
468
+ ncm?: string;
469
+ cest?: string;
470
+ marca?: string;
471
+ categoria?: string;
472
+ imagem_url?: string;
473
+ peso_bruto?: number;
474
+ peso_liquido?: number;
475
+ dados_tributarios_sugeridos?: Record<string, any>;
476
+ }
142
477
 
143
478
  declare class ProductsResource extends BaseResource {
144
479
  /**
145
- * Consulta um produto por código de barras GTIN/EAN.
480
+ * Consulta dados oficiais de um produto por código de barras GTIN/EAN (V1).
146
481
  * @param gtin Código numérico de 8 a 14 dígitos.
147
482
  */
148
483
  get(gtin: string): Promise<ProductDetails>;
484
+ /**
485
+ * Consulta dados enriquecidos por IA, com SEO e ficha técnica estruturada (V2).
486
+ * @param gtin Código numérico do produto.
487
+ */
488
+ getEnriched(gtin: string): Promise<ProductEnrichedDetails>;
489
+ /**
490
+ * Executa busca semântica por intenção/linguagem natural (V2).
491
+ * @param query Termo livre de busca (ex: 'refrigerante zero lata').
492
+ */
493
+ search(query: string): Promise<ProductSearchResponse>;
494
+ /**
495
+ * Reconhece código de barras por visão computacional a partir de foto JPEG (OCR V2).
496
+ * @param file Blob, Buffer ou FormData com a imagem JPEG.
497
+ */
498
+ scan(file: Blob | Buffer | FormData): Promise<ProductEnrichedDetails>;
149
499
  }
150
500
 
151
501
  interface WebhookEvent<T = Record<string, any>> {
@@ -175,6 +525,8 @@ declare class PairusProductData {
175
525
  readonly webhooks: typeof Webhooks;
176
526
  readonly products: ProductsResource;
177
527
  readonly fiscal: FiscalResource;
528
+ readonly emissao: EmissaoResource;
529
+ readonly nfse: NFSeResource;
178
530
  constructor(options?: PairusClientOptions);
179
531
  }
180
532
 
@@ -205,4 +557,4 @@ declare class NetworkError extends PairusError {
205
557
  constructor(message: string);
206
558
  }
207
559
 
208
- export { AuthenticationError, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, type FuelData, type IBSCBSData, InvalidSignatureError, NetworkError, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type ProductDetails, type ProductResponse, RateLimitError, type SelectiveTaxData, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type WebhookEvent, Webhooks };
560
+ export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, type DetalheAutocura, 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 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 TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TomadorNFSeInput, type WebhookEvent, Webhooks };