@pairus/product-data 1.5.0 → 1.6.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 CHANGED
@@ -70,7 +70,7 @@ console.log(enriched.palavras_chave); // Otimizadas para e-commerce
70
70
  ```typescript
71
71
  const resultado = await client.products.search('refrigerante zero açucar lata');
72
72
  for (const item of resultado.produtos) {
73
- console.log(`[Score: ${item.score}] ${item.gtin} - ${item.xProd}`);
73
+ console.log(`[Score: ${item.score}] ${item.gtin} - ${item.xProd} (${item.marca})`);
74
74
  }
75
75
  ```
76
76
 
@@ -100,19 +100,22 @@ const predicao = await client.fiscal.predict({
100
100
  });
101
101
 
102
102
  const trib = predicao.dados_tributarios!;
103
- console.log(`CFOP: ${trib.cfop} | CST/CSOSN: ${trib.icms_cst_csosn}`);
103
+ // CFOP interno (mesma UF) e externo (interestadual): use o que corresponde à operação
104
+ console.log(`CFOP: ${trib.cfop_interno} / ${trib.cfop_externo} | CST/CSOSN: ${trib.icms_cst_csosn}`);
104
105
  console.log(`IBS Efetivo: ${trib.ibscbs.ibs_aliquota_efetiva}% | CBS: ${trib.ibscbs.cbs_aliquota_efetiva}%`);
106
+ if (trib.is?.incidencia) console.log(`Imposto Seletivo: CST ${trib.is.CSTIS} (${trib.is.pIS}%)`);
107
+ console.log(trib.avisos_fiscais);
105
108
  ```
106
109
 
107
110
  #### Saneamento Fiscal em Lote
108
111
  ```typescript
109
112
  const lote = await client.fiscal.sanitize([
110
- { ncm: '22021000', descricao: 'Refrigerante Cola' },
111
- { ncm: '22030000', descricao: 'Cerveja Pilsen' },
113
+ { NCM: '22021000', xProd: 'Refrigerante Cola', id: 'SKU-001' },
114
+ { NCM: '22030000', CEST: '0302100', xProd: 'Cerveja Pilsen' },
112
115
  ]);
113
116
 
114
117
  for (const item of lote.itens) {
115
- console.log(`NCM: ${item.ncm} | CEST Sugerido: ${item.cest_sugerido}`);
118
+ console.log(`NCM: ${item.NCM_informado} | Vigente: ${item.auditoria_fiscal.ncm_vigente} | CEST: ${item.auditoria_fiscal.cest_sugerido}`);
116
119
  }
117
120
  ```
118
121
 
package/dist/index.d.mts CHANGED
@@ -46,6 +46,12 @@ interface DocumentoDFe {
46
46
  tipo_documento?: string;
47
47
  manifestacao_status?: string;
48
48
  tem_xml_completo?: boolean;
49
+ /** Protocolo de autorização da NF-e (resNFe). */
50
+ protocolo?: string;
51
+ cnpj_destinatario?: string;
52
+ ie_emitente?: string;
53
+ ambiente?: string;
54
+ [campo: string]: any;
49
55
  }
50
56
  interface SincronizarDFeInput {
51
57
  cnpj: string;
@@ -72,12 +78,15 @@ interface ListarDocumentosDFeResponse {
72
78
  total: number;
73
79
  ult_nsu: string;
74
80
  max_nsu: string;
81
+ /** Data e hora da última sincronização com a SEFAZ. */
82
+ ultima_sincronizacao?: string | null;
75
83
  documentos: DocumentoDFe[];
76
84
  }
77
85
  interface ManifestarDFeInput {
78
86
  cnpj: string;
79
87
  chave_acesso: string;
80
88
  tipo_evento: TipoManifestacaoDFe | string;
89
+ /** Obrigatória apenas no 210240 (15 a 255 caracteres); a API a descarta nos demais eventos. */
81
90
  justificativa?: string;
82
91
  ambiente?: 'producao' | 'homologacao';
83
92
  }
@@ -87,6 +96,9 @@ interface ManifestarDFeResponse {
87
96
  xmotivo: string;
88
97
  protocolo?: string;
89
98
  tipo_evento?: string;
99
+ chave_acesso?: string;
100
+ /** 'ciencia', 'confirmada', 'desconhecida' ou 'nao_realizada'. */
101
+ manifestacao_status?: string;
90
102
  detalhes?: Record<string, any>;
91
103
  }
92
104
 
@@ -289,6 +301,12 @@ declare class EmissaoResource extends BaseResource {
289
301
  inutilizar(params: InutilizacaoInput): Promise<EventoNFeResponse>;
290
302
  }
291
303
 
304
+ /**
305
+ * Tipos da predição fiscal (/v2/fiscal/predict) e do saneamento em lote (/v2/fiscal/sanitize).
306
+ *
307
+ * Espelham o contrato da API. Os nomes usados até a 1.5 (`cfop`, `avisos`, `imposto_seletivo` e
308
+ * `aliquota_efetiva_unificada` na raiz) continuam preenchidos pelo SDK a partir dos oficiais.
309
+ */
292
310
  interface IBSCBSData {
293
311
  cst: string;
294
312
  cClassTrib: string;
@@ -296,16 +314,29 @@ interface IBSCBSData {
296
314
  cbs_diferimento: number;
297
315
  cbs_reducao_aliquota: number;
298
316
  cbs_aliquota_efetiva: number;
317
+ aliquota_cbs_estimada?: number;
299
318
  ibs_aliquota_estadual: number;
300
319
  ibs_aliquota_municipal: number;
301
320
  ibs_diferimento: number;
302
321
  ibs_reducao_aliquota: number;
322
+ ibs_reducao_aliquota_estadual?: number;
323
+ ibs_reducao_aliquota_municipal?: number;
303
324
  ibs_aliquota_efetiva: number;
325
+ aliquota_ibs_estimada?: number;
326
+ aliquota_efetiva_unificada?: number;
327
+ vTotDFe_obrigatorio?: boolean;
304
328
  }
329
+ /** Imposto Seletivo: chega na chave `is` de `dados_tributarios`. */
305
330
  interface SelectiveTaxData {
306
- cst: string;
307
- cClassTribIS: string;
308
- aliquota: number;
331
+ incidencia?: boolean;
332
+ CSTIS?: string | null;
333
+ cClassTribIS?: string | null;
334
+ pIS?: number;
335
+ nota?: string | null;
336
+ /** @deprecated Use `CSTIS`. */
337
+ cst?: string | null;
338
+ /** @deprecated Use `pIS`. */
339
+ aliquota?: number;
309
340
  }
310
341
  interface FuelData {
311
342
  codigo_anp: string;
@@ -317,30 +348,55 @@ interface FuelData {
317
348
  }
318
349
  interface TaxPredictionData {
319
350
  ncm_sugerido: string;
320
- cest_sugerido?: string;
321
- cfop: string;
322
- cfop_devolucao?: string;
351
+ cest_sugerido?: string | null;
352
+ origem_mercadoria?: string;
353
+ origem_mercadoria_descricao?: string;
354
+ cfop_interno?: string;
355
+ cfop_externo?: string;
356
+ cfop_devolucao_interno?: string | null;
357
+ cfop_devolucao_externo?: string | null;
323
358
  icms_cst_csosn: string;
324
359
  icms_aliquota: number;
325
- icms_aliquota_st: number;
326
- icms_mva_st: number;
327
360
  icms_reducao_bc: number;
361
+ icms_sujeito_st?: boolean;
362
+ icms_mva_st: number;
363
+ icms_aliquota_st: number;
328
364
  icms_reducao_bc_st: number;
329
- icms_modalidade_bc: string;
330
- icms_modalidade_bc_st: string;
365
+ icms_modalidade_bc?: string | null;
366
+ icms_modalidade_bc_st?: string | null;
367
+ icms_credito_aliquota_sn?: number;
368
+ dados_desoneracao_suframa?: Record<string, any> | null;
331
369
  pis_cst: string;
332
370
  pis_aliquota: number;
333
371
  cofins_cst: string;
334
372
  cofins_aliquota: number;
335
- ipi_cst?: string;
373
+ ipi_cst?: string | null;
336
374
  ipi_aliquota?: number;
375
+ extipi?: string | null;
376
+ reforma_tributaria_nota?: string;
337
377
  ibscbs: IBSCBSData;
378
+ /** Imposto Seletivo (nome oficial da chave na API). */
379
+ is?: SelectiveTaxData;
380
+ combustivel_sujeito_anp?: boolean;
381
+ dados_combustivel?: FuelData | null;
382
+ diagnostico_anti_rejeicao?: Array<Record<string, string>>;
383
+ otimizacao_tributaria?: Record<string, any> | null;
384
+ difal?: Record<string, any> | null;
385
+ motor_ia: string;
386
+ avisos_fiscais?: string[];
387
+ disclaimer?: string;
388
+ /** @deprecated Use `cfop_interno` ou `cfop_externo` conforme a UF de destino (preenchido com `cfop_interno`). */
389
+ cfop?: string;
390
+ /** @deprecated Use `cfop_devolucao_interno` / `cfop_devolucao_externo`. */
391
+ cfop_devolucao?: string | null;
392
+ /** @deprecated Use `is`. */
338
393
  imposto_seletivo?: SelectiveTaxData;
339
- dados_combustivel?: FuelData;
394
+ /** @deprecated Use `ibscbs.aliquota_efetiva_unificada`. */
395
+ aliquota_efetiva_unificada?: number;
396
+ /** @deprecated Use `avisos_fiscais`. */
397
+ avisos?: string[];
398
+ /** @deprecated Não é devolvido pela API. */
340
399
  beneficio_fiscal?: string;
341
- aliquota_efetiva_unificada: number;
342
- motor_ia: string;
343
- avisos: string[];
344
400
  }
345
401
  interface TaxPredictionItemInput {
346
402
  xProd?: string;
@@ -354,6 +410,10 @@ interface TaxPredictionParams {
354
410
  ufDestino?: string;
355
411
  finalidade?: 'revenda' | 'consumo_final' | 'industrializacao' | string;
356
412
  destinatarioContribuinte?: boolean;
413
+ /** Alíquota de crédito de ICMS do Simples Nacional (pCredSN). */
414
+ aliquotaCreditoIcmsSn?: number;
415
+ destinatarioSuframa?: boolean;
416
+ inscricaoSuframa?: string;
357
417
  xProd?: string;
358
418
  gtin?: string;
359
419
  ncm?: string;
@@ -362,38 +422,49 @@ interface TaxPredictionParams {
362
422
  }
363
423
  interface TaxPredictionItemResult {
364
424
  item_index: number;
365
- xProd?: string;
425
+ xProd?: string | null;
366
426
  dados_tributarios: TaxPredictionData;
367
427
  }
368
428
  interface TaxPredictionResponse {
369
429
  status: string;
370
430
  provider: string;
371
- xProd?: string;
372
- dados_tributarios?: TaxPredictionData;
373
- resultados?: TaxPredictionItemResult[];
431
+ timestamp?: string;
432
+ motor_ia?: string | null;
433
+ xProd?: string | null;
434
+ dados_tributarios?: TaxPredictionData | null;
435
+ resultados?: TaxPredictionItemResult[] | null;
374
436
  }
437
+ /**
438
+ * Item do saneamento. A API exige `NCM`/`CEST` em maiúsculas; os nomes `ncm`, `cest`,
439
+ * `descricao` e `gtin` da 1.5 continuam aceitos e são convertidos pelo SDK.
440
+ */
375
441
  interface FiscalSanitizeItemInput {
376
- ncm: string;
442
+ NCM?: string;
443
+ CEST?: string;
444
+ xProd?: string;
445
+ id?: string;
446
+ /** @deprecated Use `NCM`. */
447
+ ncm?: string;
448
+ /** @deprecated Use `CEST`. */
377
449
  cest?: string;
450
+ /** @deprecated Use `xProd`. */
378
451
  descricao?: string;
452
+ /** @deprecated Use `id`. */
379
453
  gtin?: string;
380
454
  }
381
455
  interface FiscalSanitizeItemResult {
382
- ncm: string;
383
- ncm_valido: boolean;
384
- descricao_ncm?: string;
385
- cest_informado?: string;
386
- cest_sugerido?: string;
387
- sujeito_st: boolean;
388
- aliquotas_sugeridas?: Record<string, any>;
389
- avisos?: string[];
456
+ id?: string;
457
+ xProd?: string;
458
+ NCM_informado?: string;
459
+ CEST_informado?: string | null;
460
+ auditoria_fiscal: Record<string, any>;
390
461
  }
391
462
  interface FiscalSanitizeResponse {
392
463
  status: string;
393
464
  provider: string;
394
465
  timestamp?: string;
395
466
  total_itens: number;
396
- itens: Array<Record<string, any>>;
467
+ itens: FiscalSanitizeItemResult[];
397
468
  }
398
469
 
399
470
  declare class FiscalResource extends BaseResource {
@@ -403,8 +474,9 @@ declare class FiscalResource extends BaseResource {
403
474
  predict(params: TaxPredictionParams): Promise<TaxPredictionResponse>;
404
475
  /**
405
476
  * Audita e higieniza uma lista de produtos em lote perante as tabelas fiscais vigentes.
477
+ * Cada item precisa de `NCM` (aceita também `ncm`); `CEST`, `xProd` e `id` são opcionais.
406
478
  */
407
- sanitize(itens: Array<Record<string, any>>): Promise<any>;
479
+ sanitize(itens: FiscalSanitizeItemInput[]): Promise<FiscalSanitizeResponse>;
408
480
  }
409
481
 
410
482
  interface EnderecoNFSeInput {
@@ -450,6 +522,14 @@ interface RetencoesFederaisInput {
450
522
  aliquota_inss?: number;
451
523
  valor_inss?: number;
452
524
  }
525
+ /** Campos da Reforma Tributária (IBS e CBS) sobre serviços (LC 214/2025). */
526
+ interface ReformaTributariaServicoInput {
527
+ cst_ibs_cbs?: string;
528
+ cClassTrib?: string;
529
+ aliquota_ibs_estadual?: number;
530
+ aliquota_ibs_municipal?: number;
531
+ aliquota_cbs?: number;
532
+ }
453
533
  interface ServicoNFSeInput {
454
534
  item_lista_servico: string;
455
535
  discriminacao: string;
@@ -462,8 +542,10 @@ interface ServicoNFSeInput {
462
542
  valor_desconto_condicionado?: number;
463
543
  iss_retido?: boolean;
464
544
  aliquota_iss?: number;
545
+ /** '1' Exigível, '2' Não incidência, '3' Isenção, '4' Exportação, '5' Imunidade, '6'/'7' Suspensa. */
465
546
  exigibilidade_iss?: string;
466
547
  retencoes_federais?: RetencoesFederaisInput;
548
+ reforma_tributaria?: ReformaTributariaServicoInput;
467
549
  }
468
550
  interface NFSeEmissaoInput {
469
551
  prestador: PrestadorNFSeInput | Record<string, any>;
@@ -486,6 +568,8 @@ interface NFSeEmissaoResponse {
486
568
  data_emissao?: string;
487
569
  link_visualizacao?: string;
488
570
  danfse_pdf_base64?: string;
571
+ /** Alias de danfse_pdf_base64 devolvido pela API. */
572
+ danfse_base64?: string;
489
573
  xml_nfse?: string;
490
574
  valor_servicos: number;
491
575
  valor_iss: number;
@@ -494,7 +578,13 @@ interface NFSeEmissaoResponse {
494
578
  valor_liquido: number;
495
579
  erros?: string[];
496
580
  alertas?: string[];
497
- trilha_auditoria?: Record<string, any>[];
581
+ trilha_auditoria?: Array<{
582
+ autor: string;
583
+ acao: string;
584
+ justificativa_legal: string;
585
+ campos_alterados?: Record<string, any>;
586
+ timestamp: string;
587
+ }>;
498
588
  creditos_cobrados: number;
499
589
  tempo_processamento_ms: number;
500
590
  }
@@ -504,6 +594,7 @@ interface CancelamentoNFSeInput {
504
594
  inscricao_municipal: string;
505
595
  codigo_municipio_ibge: string;
506
596
  justificativa: string;
597
+ /** '1' Erro de emissão, '2' Serviço não prestado, '3' Duplicidade, '9' Outros. */
507
598
  motivo_codigo?: string;
508
599
  codigo_verificacao?: string;
509
600
  chave_acesso_nacional?: string;
@@ -535,6 +626,11 @@ declare class NFSeResource extends BaseResource {
535
626
  consultar(chaveOuNumero: string): Promise<Record<string, any>>;
536
627
  }
537
628
 
629
+ /**
630
+ * Tipos de produto do SDK. A API devolve o produto no layout da NF-e (`GTIN`, `NCM`, `CEST`) com
631
+ * marca, categoria, imagem e pesos em `infoAdicional` e a IA em `enriquecimentoIA`/`tributacaoIA`;
632
+ * o `ProductsResource` converte esse contrato para os tipos abaixo.
633
+ */
538
634
  interface ProductDetails {
539
635
  gtin: string;
540
636
  xProd: string;
@@ -549,10 +645,16 @@ interface ProductDetails {
549
645
  quantidadeEmbalagem?: number;
550
646
  dataCadastro?: string;
551
647
  dataAtualizacao?: string;
648
+ tpGTIN?: string;
649
+ fonte?: string;
650
+ /** Bloco `infoAdicional` original da API. */
651
+ infoAdicional?: Record<string, any>;
552
652
  }
553
653
  interface ProductResponse {
554
654
  status: string;
555
655
  provider: string;
656
+ cStat?: string;
657
+ xMotivo?: string;
556
658
  produto?: ProductDetails;
557
659
  raw_data?: Record<string, any>;
558
660
  }
@@ -562,6 +664,8 @@ interface ProductSearchResultItem {
562
664
  marca?: string;
563
665
  categoria?: string;
564
666
  score?: number;
667
+ /** Explicação da correspondência semântica. */
668
+ justificativa?: string;
565
669
  ncm?: string;
566
670
  cest?: string;
567
671
  imagem_url?: string;
@@ -571,12 +675,17 @@ interface ProductSearchResponse {
571
675
  provider: string;
572
676
  total_encontrados: number;
573
677
  termo_buscado: string;
678
+ motor_busca?: string;
574
679
  produtos: ProductSearchResultItem[];
575
680
  }
576
681
  interface ProductEnrichedDetails {
577
682
  gtin: string;
578
683
  xProd: string;
684
+ /** Nome saneado pela IA. */
685
+ xProd_higienizado?: string;
686
+ /** Descrição otimizada para SEO (`enriquecimentoIA.descricao_seo`). */
579
687
  descricao_completa?: string;
688
+ /** Atributos técnicos extraídos pela IA (`enriquecimentoIA.atributos`). */
580
689
  ficha_tecnica?: Record<string, any>;
581
690
  palavras_chave?: string[];
582
691
  ncm?: string;
@@ -586,7 +695,13 @@ interface ProductEnrichedDetails {
586
695
  imagem_url?: string;
587
696
  peso_bruto?: number;
588
697
  peso_liquido?: number;
698
+ /** Nó `tributacaoIA` da API. */
589
699
  dados_tributarios_sugeridos?: Record<string, any>;
700
+ tpGTIN?: string;
701
+ fonte?: string;
702
+ infoAdicional?: Record<string, any>;
703
+ enriquecimentoIA?: Record<string, any>;
704
+ tributacaoIA?: Record<string, any>;
590
705
  }
591
706
 
592
707
  declare class ProductsResource extends BaseResource {
@@ -672,4 +787,4 @@ declare class NetworkError extends PairusError {
672
787
  constructor(message: string);
673
788
  }
674
789
 
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 };
790
+ 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 ReformaTributariaServicoInput, 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 };