facturas 0.5.0 → 0.5.1

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
@@ -31,6 +31,8 @@ The package exports:
31
31
 
32
32
  `facturas` also exports `createMemoryWsaaSessionStore()` for tests/local single-process coordination and the small `ArcaWsaaSessionStore` interface for applications that need to share WSAA tickets across workers through their own durable store.
33
33
 
34
+ Authenticated WSFE and WSMTXCA methods accept `forceRefresh: true` when callers need to discard the cached WSAA TA and request a fresh Token Authorization for the same service.
35
+
34
36
  ## WSFE associated periods
35
37
 
36
38
  `client.wsfe.createNextVoucher({ data })` supports `associatedPeriod` for credit/debit notes that use `PeriodoAsoc` instead of `CbtesAsoc`:
package/dist/index.js CHANGED
@@ -435,7 +435,7 @@ function createWsfeService(options) {
435
435
  async function executeWsfeAuthenticatedOperation(operation, input, body = {}) {
436
436
  const auth = await options.auth.login("wsfe", {
437
437
  representedTaxId: input.representedTaxId,
438
- forceRefresh: input.forceAuthRefresh
438
+ forceRefresh: input.forceRefresh
439
439
  });
440
440
  const response = await options.soap.execute({
441
441
  service: "wsfe",
@@ -463,13 +463,13 @@ function createWsfeService(options) {
463
463
  representedTaxId,
464
464
  salesPoint,
465
465
  voucherType,
466
- forceAuthRefresh
466
+ forceRefresh
467
467
  }) {
468
468
  const result = await executeWsfeAuthenticatedOperation(
469
469
  "FECompUltimoAutorizado",
470
470
  {
471
471
  representedTaxId,
472
- forceAuthRefresh
472
+ forceRefresh
473
473
  },
474
474
  {
475
475
  PtoVta: salesPoint,
@@ -481,29 +481,35 @@ function createWsfeService(options) {
481
481
  async function getWsfeCatalog(operation, resultKey, input) {
482
482
  const result = await executeWsfeAuthenticatedOperation(operation, {
483
483
  representedTaxId: input.representedTaxId,
484
- forceAuthRefresh: input.forceAuthRefresh
484
+ forceRefresh: input.forceRefresh
485
485
  });
486
486
  return getWsfeResultEntries(result, resultKey).map(mapWsfeCatalogEntry);
487
487
  }
488
488
  function authorizeVoucher({
489
489
  representedTaxId,
490
490
  data,
491
- voucherNumber
491
+ voucherNumber,
492
+ forceRefresh
492
493
  }) {
493
494
  const normalizedInput = normalizeWsfeVoucherInput(data);
494
495
  return authorizeNormalizedVoucher({
495
496
  representedTaxId,
496
497
  data: normalizedInput,
497
- voucherNumber
498
+ voucherNumber,
499
+ forceRefresh
498
500
  });
499
501
  }
500
502
  async function authorizeNormalizedVoucher({
501
503
  representedTaxId,
502
504
  data: normalizedInput,
503
- voucherNumber
505
+ voucherNumber,
506
+ forceRefresh
504
507
  }) {
505
508
  const requestData = mapWsfeVoucherInput(normalizedInput, voucherNumber);
506
- const auth = await options.auth.login("wsfe", { representedTaxId });
509
+ const auth = await options.auth.login("wsfe", {
510
+ representedTaxId,
511
+ forceRefresh
512
+ });
507
513
  const response = await options.soap.execute({
508
514
  service: "wsfe",
509
515
  operation: "FECAESolicitar",
@@ -543,12 +549,13 @@ function createWsfeService(options) {
543
549
  }
544
550
  return {
545
551
  authorizeVoucher,
546
- async createNextVoucher({ representedTaxId, data }) {
552
+ async createNextVoucher({ representedTaxId, data, forceRefresh }) {
547
553
  const normalizedInput = normalizeWsfeVoucherInput(data);
548
554
  const voucherNumber = await getNextVoucherNumber({
549
555
  representedTaxId,
550
556
  salesPoint: normalizedInput.salesPoint,
551
- voucherType: normalizedInput.voucherType
557
+ voucherType: normalizedInput.voucherType,
558
+ forceRefresh
552
559
  });
553
560
  return authorizeNormalizedVoucher({
554
561
  representedTaxId,
@@ -560,12 +567,12 @@ function createWsfeService(options) {
560
567
  getLastVoucher(input) {
561
568
  return getNextVoucherNumber(input);
562
569
  },
563
- async getSalesPoints({ representedTaxId, forceAuthRefresh }) {
570
+ async getSalesPoints({ representedTaxId, forceRefresh }) {
564
571
  const result = await executeWsfeAuthenticatedOperation(
565
572
  "FEParamGetPtosVenta",
566
573
  {
567
574
  representedTaxId,
568
- forceAuthRefresh
575
+ forceRefresh
569
576
  }
570
577
  );
571
578
  const rawPoints = result.ResultGet?.PtoVenta;
@@ -584,12 +591,12 @@ function createWsfeService(options) {
584
591
  getConceptTypes(input) {
585
592
  return getWsfeCatalog("FEParamGetTiposConcepto", "ConceptoTipo", input);
586
593
  },
587
- async getCurrencyTypes({ representedTaxId, forceAuthRefresh }) {
594
+ async getCurrencyTypes({ representedTaxId, forceRefresh }) {
588
595
  const result = await executeWsfeAuthenticatedOperation(
589
596
  "FEParamGetTiposMonedas",
590
597
  {
591
598
  representedTaxId,
592
- forceAuthRefresh
599
+ forceRefresh
593
600
  }
594
601
  );
595
602
  return getWsfeResultEntries(result, "Moneda").map(mapWsfeCurrencyType);
@@ -603,12 +610,12 @@ function createWsfeService(options) {
603
610
  getOptionalTypes(input) {
604
611
  return getWsfeCatalog("FEParamGetTiposOpcional", "OpcionalTipo", input);
605
612
  },
606
- async getActivities({ representedTaxId, forceAuthRefresh }) {
613
+ async getActivities({ representedTaxId, forceRefresh }) {
607
614
  const result = await executeWsfeAuthenticatedOperation(
608
615
  "FEParamGetActividades",
609
616
  {
610
617
  representedTaxId,
611
- forceAuthRefresh
618
+ forceRefresh
612
619
  }
613
620
  );
614
621
  return getWsfeResultEntries(result, "ActividadesTipo").map(
@@ -618,13 +625,13 @@ function createWsfeService(options) {
618
625
  async getReceiverVatConditions({
619
626
  representedTaxId,
620
627
  voucherClass,
621
- forceAuthRefresh
628
+ forceRefresh
622
629
  }) {
623
630
  const result = await executeWsfeAuthenticatedOperation(
624
631
  "FEParamGetCondicionIvaReceptor",
625
632
  {
626
633
  representedTaxId,
627
- forceAuthRefresh
634
+ forceRefresh
628
635
  },
629
636
  {
630
637
  ...voucherClass === void 0 ? {} : { ClaseCmp: voucherClass }
@@ -638,12 +645,12 @@ function createWsfeService(options) {
638
645
  const result = await executeWsfeOperation("FEDummy");
639
646
  return mapWsfeServerStatus(result);
640
647
  },
641
- async getQuotation({ currencyId, representedTaxId, forceAuthRefresh }) {
648
+ async getQuotation({ currencyId, representedTaxId, forceRefresh }) {
642
649
  const result = await executeWsfeAuthenticatedOperation(
643
650
  "FEParamGetCotizacion",
644
651
  {
645
652
  representedTaxId,
646
- forceAuthRefresh
653
+ forceRefresh
647
654
  },
648
655
  {
649
656
  MonId: currencyId
@@ -656,12 +663,14 @@ function createWsfeService(options) {
656
663
  representedTaxId,
657
664
  number,
658
665
  salesPoint,
659
- voucherType
666
+ voucherType,
667
+ forceRefresh
660
668
  }) {
661
669
  const result = await executeWsfeAuthenticatedOperation(
662
670
  "FECompConsultar",
663
671
  {
664
- representedTaxId
672
+ representedTaxId,
673
+ forceRefresh
665
674
  },
666
675
  {
667
676
  FeCompConsReq: {
@@ -1035,8 +1044,11 @@ function getWsfeResultEntries(result, key) {
1035
1044
  // src/services/wsmtxca.ts
1036
1045
  function createWsmtxcaService(options) {
1037
1046
  return {
1038
- async authorizeVoucher({ representedTaxId, data }) {
1039
- const auth = await options.auth.login("wsmtxca", { representedTaxId });
1047
+ async authorizeVoucher({ representedTaxId, data, forceRefresh }) {
1048
+ const auth = await options.auth.login("wsmtxca", {
1049
+ representedTaxId,
1050
+ forceRefresh
1051
+ });
1040
1052
  const response = await options.soap.execute({
1041
1053
  service: "wsmtxca",
1042
1054
  operation: "autorizarComprobante",
@@ -1082,9 +1094,13 @@ function createWsmtxcaService(options) {
1082
1094
  async getLastAuthorizedVoucher({
1083
1095
  representedTaxId,
1084
1096
  voucherType,
1085
- salesPoint
1097
+ salesPoint,
1098
+ forceRefresh
1086
1099
  }) {
1087
- const auth = await options.auth.login("wsmtxca", { representedTaxId });
1100
+ const auth = await options.auth.login("wsmtxca", {
1101
+ representedTaxId,
1102
+ forceRefresh
1103
+ });
1088
1104
  const response = await options.soap.execute({
1089
1105
  service: "wsmtxca",
1090
1106
  operation: "consultarUltimoComprobanteAutorizado",
@@ -1119,9 +1135,13 @@ function createWsmtxcaService(options) {
1119
1135
  representedTaxId,
1120
1136
  voucherType,
1121
1137
  salesPoint,
1122
- voucherNumber
1138
+ voucherNumber,
1139
+ forceRefresh
1123
1140
  }) {
1124
- const auth = await options.auth.login("wsmtxca", { representedTaxId });
1141
+ const auth = await options.auth.login("wsmtxca", {
1142
+ representedTaxId,
1143
+ forceRefresh
1144
+ });
1125
1145
  const response = await options.soap.execute({
1126
1146
  service: "wsmtxca",
1127
1147
  operation: "consultarComprobante",