sunat-engine-nest 1.0.9 → 1.1.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
@@ -4,6 +4,7 @@ export { SunatEngineService } from './sunat-engine.service';
4
4
  export { XmlSignerService } from './signer/xml-signer.service';
5
5
  export { SunatSoapClient } from './soap/sunat-soap.client';
6
6
  export type { SoapSendResult, SunatEndpointType } from './soap/sunat-soap.client';
7
+ export { FakeSunatSoapClient } from './soap/fake-sunat-soap.client';
7
8
  export { SunatGreClient } from './gre/sunat-gre.client';
8
9
  export { OseClient } from './ose/ose.client';
9
10
  export type { OseClientOptions } from './ose/ose.client';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildVoidedXml = exports.buildSummaryXml = exports.buildDespatchXml = exports.buildNoteXml = exports.buildInvoiceXml = exports.DocumentPdfService = exports.CdrParserService = exports.OseClient = exports.SunatGreClient = exports.SunatSoapClient = exports.XmlSignerService = exports.SunatEngineService = exports.SUNAT_ENGINE_OPTIONS = exports.SunatEngineModule = void 0;
3
+ exports.buildVoidedXml = exports.buildSummaryXml = exports.buildDespatchXml = exports.buildNoteXml = exports.buildInvoiceXml = exports.DocumentPdfService = exports.CdrParserService = exports.OseClient = exports.SunatGreClient = exports.FakeSunatSoapClient = exports.SunatSoapClient = exports.XmlSignerService = exports.SunatEngineService = exports.SUNAT_ENGINE_OPTIONS = exports.SunatEngineModule = void 0;
4
4
  var sunat_engine_module_1 = require("./sunat-engine.module");
5
5
  Object.defineProperty(exports, "SunatEngineModule", { enumerable: true, get: function () { return sunat_engine_module_1.SunatEngineModule; } });
6
6
  Object.defineProperty(exports, "SUNAT_ENGINE_OPTIONS", { enumerable: true, get: function () { return sunat_engine_module_1.SUNAT_ENGINE_OPTIONS; } });
@@ -10,6 +10,8 @@ var xml_signer_service_1 = require("./signer/xml-signer.service");
10
10
  Object.defineProperty(exports, "XmlSignerService", { enumerable: true, get: function () { return xml_signer_service_1.XmlSignerService; } });
11
11
  var sunat_soap_client_1 = require("./soap/sunat-soap.client");
12
12
  Object.defineProperty(exports, "SunatSoapClient", { enumerable: true, get: function () { return sunat_soap_client_1.SunatSoapClient; } });
13
+ var fake_sunat_soap_client_1 = require("./soap/fake-sunat-soap.client");
14
+ Object.defineProperty(exports, "FakeSunatSoapClient", { enumerable: true, get: function () { return fake_sunat_soap_client_1.FakeSunatSoapClient; } });
13
15
  var sunat_gre_client_1 = require("./gre/sunat-gre.client");
14
16
  Object.defineProperty(exports, "SunatGreClient", { enumerable: true, get: function () { return sunat_gre_client_1.SunatGreClient; } });
15
17
  var ose_client_1 = require("./ose/ose.client");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,6DAAgF;AAAvE,wHAAA,iBAAiB,OAAA;AAAE,2HAAA,oBAAoB,OAAA;AAIhD,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAG3B,kEAA+D;AAAtD,sHAAA,gBAAgB,OAAA;AACzB,8DAA2D;AAAlD,oHAAA,eAAe,OAAA;AAExB,2DAAwD;AAA/C,kHAAA,cAAc,OAAA;AACvB,+CAA6C;AAApC,uGAAA,SAAS,OAAA;AAElB,+DAA4D;AAAnD,sHAAA,gBAAgB,OAAA;AACzB,mEAAgE;AAAvD,0HAAA,kBAAkB,OAAA;AAI3B,yDAAwD;AAA/C,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,4GAAA,YAAY,OAAA;AACrB,2DAA0D;AAAjD,oHAAA,gBAAgB,OAAA;AACzB,yDAAwD;AAA/C,kHAAA,eAAe,OAAA;AACxB,uDAAsD;AAA7C,gHAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,6DAAgF;AAAvE,wHAAA,iBAAiB,OAAA;AAAE,2HAAA,oBAAoB,OAAA;AAIhD,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAG3B,kEAA+D;AAAtD,sHAAA,gBAAgB,OAAA;AACzB,8DAA2D;AAAlD,oHAAA,eAAe,OAAA;AAExB,wEAAoE;AAA3D,6HAAA,mBAAmB,OAAA;AAC5B,2DAAwD;AAA/C,kHAAA,cAAc,OAAA;AACvB,+CAA6C;AAApC,uGAAA,SAAS,OAAA;AAElB,+DAA4D;AAAnD,sHAAA,gBAAgB,OAAA;AACzB,mEAAgE;AAAvD,0HAAA,kBAAkB,OAAA;AAI3B,yDAAwD;AAA/C,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,4GAAA,YAAY,OAAA;AACrB,2DAA0D;AAAjD,oHAAA,gBAAgB,OAAA;AACzB,yDAAwD;AAA/C,kHAAA,eAAe,OAAA;AACxB,uDAAsD;AAA7C,gHAAA,cAAc,OAAA"}
@@ -0,0 +1,8 @@
1
+ import { SunatSoapClient, SoapSendResult } from './sunat-soap.client';
2
+ export declare class FakeSunatSoapClient extends SunatSoapClient {
3
+ private ticketCounter;
4
+ sendBill(params: Parameters<SunatSoapClient['sendBill']>[0]): Promise<SoapSendResult>;
5
+ sendSummary(params: Parameters<SunatSoapClient['sendSummary']>[0]): Promise<SoapSendResult>;
6
+ getStatus(params: Parameters<SunatSoapClient['getStatus']>[0]): Promise<SoapSendResult>;
7
+ private buildFakeCdrZip;
8
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FakeSunatSoapClient = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const sunat_soap_client_1 = require("./sunat-soap.client");
12
+ let FakeSunatSoapClient = class FakeSunatSoapClient extends sunat_soap_client_1.SunatSoapClient {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.ticketCounter = 1_000_000_000;
16
+ }
17
+ async sendBill(params) {
18
+ const cdrZipBase64 = await this.buildFakeCdrZip(params.fileName);
19
+ return { success: true, cdrZipBase64 };
20
+ }
21
+ async sendSummary(params) {
22
+ return { success: true, ticket: String(++this.ticketCounter) };
23
+ }
24
+ async getStatus(params) {
25
+ const cdrZipBase64 = await this.buildFakeCdrZip(`TICKET-${params.ticket}`);
26
+ return { success: true, cdrZipBase64 };
27
+ }
28
+ async buildFakeCdrZip(refFileName) {
29
+ const baseName = refFileName.replace(/\.zip$/i, '');
30
+ const today = new Date().toISOString().slice(0, 10);
31
+ const cdrXml = `<?xml version="1.0" encoding="UTF-8"?>
32
+ <ApplicationResponse xmlns="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2"
33
+ xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
34
+ xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
35
+ <cbc:ID>1</cbc:ID>
36
+ <cbc:ResponseDate>${today}</cbc:ResponseDate>
37
+ <cac:DocumentResponse>
38
+ <cac:Response>
39
+ <cbc:ResponseCode>0</cbc:ResponseCode>
40
+ <cbc:Description>El Comprobante ha sido aceptado [FakeSunatSoapClient]</cbc:Description>
41
+ </cac:Response>
42
+ </cac:DocumentResponse>
43
+ </ApplicationResponse>`;
44
+ return this.createZip(`R-${baseName}.zip`, cdrXml);
45
+ }
46
+ };
47
+ exports.FakeSunatSoapClient = FakeSunatSoapClient;
48
+ exports.FakeSunatSoapClient = FakeSunatSoapClient = __decorate([
49
+ (0, common_1.Injectable)()
50
+ ], FakeSunatSoapClient);
51
+ //# sourceMappingURL=fake-sunat-soap.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-sunat-soap.client.js","sourceRoot":"","sources":["../../src/soap/fake-sunat-soap.client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,2DAAsE;AAmB/D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,mCAAe;IAAjD;;QACG,kBAAa,GAAG,aAAa,CAAC;IAmCxC,CAAC;IAjCU,KAAK,CAAC,QAAQ,CAAC,MAAkD;QACxE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACzC,CAAC;IAEQ,KAAK,CAAC,WAAW,CAAC,MAAqD;QAC9E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACjE,CAAC;IAEQ,KAAK,CAAC,SAAS,CAAC,MAAmD;QAC1E,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACzC,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,WAAmB;QAC/C,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG;;;;;sBAKG,KAAK;;;;;;;uBAOJ,CAAC;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,QAAQ,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AApCY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAoC/B"}