@smartsoft001/trans-shell-app-services 2.148.0 → 2.149.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/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@smartsoft001/trans-shell-app-services",
3
- "version": "2.148.0",
3
+ "version": "2.149.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "typings": "./src/index.d.ts",
7
+ "description": "TransService: the application service that picks a payment provider by name, resolves the internal service and delegates to the three trans domain services.",
4
8
  "publishConfig": {
5
9
  "access": "public"
6
10
  },
7
- "description": "This library was generated with [Nx](https://nx.dev).",
8
11
  "repository": {
9
12
  "type": "git",
10
13
  "url": "git+https://github.com/emiljuchnikowski/smartsoft.git"
@@ -14,5 +17,14 @@
14
17
  "bugs": {
15
18
  "url": "https://github.com/emiljuchnikowski/smartsoft/issues"
16
19
  },
17
- "homepage": "https://github.com/emiljuchnikowski/smartsoft#readme"
20
+ "homepage": "https://github.com/emiljuchnikowski/smartsoft#readme",
21
+ "peerDependencies": {
22
+ "@smartsoft001/domain-core": "2.149.0",
23
+ "@smartsoft001/paynow": "2.149.0",
24
+ "@smartsoft001/paypal": "2.149.0",
25
+ "@smartsoft001/payu": "2.149.0",
26
+ "@smartsoft001/revolut": "2.149.0",
27
+ "@smartsoft001/trans-domain": "2.149.0"
28
+ },
29
+ "types": "./src/index.d.ts"
18
30
  }
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/services"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/trans/shell/app-services/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERVICES = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const trans_service_1 = require("./trans/trans.service");
6
+ tslib_1.__exportStar(require("./trans/trans.service"), exports);
7
+ tslib_1.__exportStar(require("./internal/internal.service"), exports);
8
+ exports.SERVICES = [trans_service_1.TransService];
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/trans/shell/app-services/src/lib/services/index.ts"],"names":[],"mappings":";;;;AAAA,yDAAqD;AAErD,gEAAsC;AACtC,sEAA4C;AAE/B,QAAA,QAAQ,GAAG,CAAC,4BAAY,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRANS_TOKEN_INTERNAL_SERVICE = void 0;
4
+ exports.TRANS_TOKEN_INTERNAL_SERVICE = 'TRANS_TOKEN_INTERNAL_SERVICE';
5
+ //# sourceMappingURL=internal.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.service.js","sourceRoot":"","sources":["../../../../../../../../../packages/trans/shell/app-services/src/lib/services/internal/internal.service.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GAAG,8BAA8B,CAAC"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = require("@nestjs/axios");
6
+ const common_1 = require("@nestjs/common");
7
+ const core_1 = require("@nestjs/core");
8
+ const domain_core_1 = require("@smartsoft001/domain-core");
9
+ const paynow_1 = require("@smartsoft001/paynow");
10
+ const paypal_1 = require("@smartsoft001/paypal");
11
+ const payu_1 = require("@smartsoft001/payu");
12
+ const revolut_1 = require("@smartsoft001/revolut");
13
+ const trans_domain_1 = require("@smartsoft001/trans-domain");
14
+ const internal_service_1 = require("../internal/internal.service");
15
+ let TransService = class TransService {
16
+ moduleRef;
17
+ creatorService;
18
+ refresherService;
19
+ refundService;
20
+ httpService;
21
+ config;
22
+ repository;
23
+ payuService;
24
+ paynowService;
25
+ paypalService;
26
+ revolutService;
27
+ get _paymentService() {
28
+ return {
29
+ payu: this.payuService,
30
+ paypal: this.paypalService,
31
+ paynow: this.paynowService,
32
+ revolut: this.revolutService,
33
+ };
34
+ }
35
+ _internalService = {
36
+ create: (trans) => {
37
+ if (!this.config.internalApiUrl)
38
+ return Promise.resolve({
39
+ date: new Date(),
40
+ req: trans,
41
+ });
42
+ return this.httpService
43
+ .post(this.config.internalApiUrl, trans)
44
+ .toPromise()
45
+ .then((res) => res.data);
46
+ },
47
+ refresh: (trans) => {
48
+ if (!this.config.internalApiUrl)
49
+ return Promise.resolve({
50
+ date: new Date(),
51
+ req: trans,
52
+ id: trans.id,
53
+ });
54
+ return this.httpService
55
+ .put(this.config.internalApiUrl + '/' + trans.id, trans)
56
+ .toPromise()
57
+ .then((res) => res.data);
58
+ },
59
+ };
60
+ constructor(moduleRef, creatorService, refresherService, refundService, httpService, config, repository, payuService, paynowService, paypalService, revolutService) {
61
+ this.moduleRef = moduleRef;
62
+ this.creatorService = creatorService;
63
+ this.refresherService = refresherService;
64
+ this.refundService = refundService;
65
+ this.httpService = httpService;
66
+ this.config = config;
67
+ this.repository = repository;
68
+ this.payuService = payuService;
69
+ this.paynowService = paynowService;
70
+ this.paypalService = paypalService;
71
+ this.revolutService = revolutService;
72
+ }
73
+ create(ops) {
74
+ return this.creatorService.create(ops, this.getInternalService(), this._paymentService);
75
+ }
76
+ async refresh(transId, data = {}) {
77
+ await this.refresherService.refresh(transId, this.getInternalService(), this._paymentService, data);
78
+ }
79
+ async refund(transId, comment = 'Refund') {
80
+ await this.refundService.refund(transId, this.getInternalService(), this._paymentService, comment);
81
+ }
82
+ async getById(id) {
83
+ return await this.repository.getById(id);
84
+ }
85
+ getInternalService() {
86
+ try {
87
+ return this.moduleRef.get(internal_service_1.TRANS_TOKEN_INTERNAL_SERVICE, {
88
+ strict: false,
89
+ });
90
+ }
91
+ catch (e) {
92
+ return this._internalService;
93
+ }
94
+ }
95
+ };
96
+ exports.TransService = TransService;
97
+ exports.TransService = TransService = tslib_1.__decorate([
98
+ (0, common_1.Injectable)(),
99
+ tslib_1.__param(7, (0, common_1.Optional)()),
100
+ tslib_1.__param(8, (0, common_1.Optional)()),
101
+ tslib_1.__param(9, (0, common_1.Optional)()),
102
+ tslib_1.__param(10, (0, common_1.Optional)()),
103
+ tslib_1.__metadata("design:paramtypes", [core_1.ModuleRef,
104
+ trans_domain_1.CreatorService,
105
+ trans_domain_1.RefresherService,
106
+ trans_domain_1.RefundService,
107
+ axios_1.HttpService,
108
+ trans_domain_1.TransConfig,
109
+ domain_core_1.IItemRepository,
110
+ payu_1.PayuService,
111
+ paynow_1.PaynowService,
112
+ paypal_1.PaypalService,
113
+ revolut_1.RevolutService])
114
+ ], TransService);
115
+ //# sourceMappingURL=trans.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trans.service.js","sourceRoot":"","sources":["../../../../../../../../../packages/trans/shell/app-services/src/lib/services/trans/trans.service.ts"],"names":[],"mappings":";;;;AAAA,yCAA4C;AAC5C,2CAAsD;AACtD,uCAAyC;AAEzC,2DAA4D;AAC5D,iDAAqD;AACrD,iDAAqD;AACrD,6CAAiD;AACjD,mDAAuD;AACvD,6DASoC;AAEpC,mEAA4E;AAGrE,IAAM,YAAY,GAAlB,MAAM,YAAY;IA0Cb;IACA;IACA;IACA;IACA;IACA;IACA;IACY;IACA;IACA;IACA;IAnDtB,IAAY,eAAe;QAGzB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,MAAM,EAAE,IAAI,CAAC,aAAa;YAC1B,MAAM,EAAE,IAAI,CAAC,aAAa;YAC1B,OAAO,EAAE,IAAI,CAAC,cAAc;SAC7B,CAAC;IACJ,CAAC;IAEO,gBAAgB,GAAG;QACzB,MAAM,EAAE,CAAC,KAAiB,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,IAAA,iBAAQ,GAAE,CAAA;IACV,mBAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,oBAAA,IAAA,iBAAQ,GAAE,CAAA;6CAVQ,gBAAS;QACJ,6BAAc;QACZ,+BAAgB;QACnB,4BAAa;QACf,mBAAW;QAChB,0BAAW;QACP,6BAAe;QACF,kBAAW;QACT,sBAAa;QACb,sBAAa;QACZ,wBAAc;GApDzC,YAAY,CAgGxB"}
package/test-setup.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=test-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../../../../packages/trans/shell/app-services/test-setup.ts"],"names":[],"mappings":""}
package/index.js DELETED
@@ -1,122 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
9
- return result;
10
- };
11
- var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
12
-
13
- // packages/trans/shell/app-services/src/lib/services/trans/trans.service.ts
14
- import { Injectable, Optional } from "@nestjs/common";
15
-
16
- // packages/trans/shell/app-services/src/lib/services/internal/internal.service.ts
17
- var TRANS_TOKEN_INTERNAL_SERVICE = "TRANS_TOKEN_INTERNAL_SERVICE";
18
-
19
- // packages/trans/shell/app-services/src/lib/services/trans/trans.service.ts
20
- var TransService = class {
21
- constructor(moduleRef, creatorService, refresherService, refundService, httpService, config, repository, payuService, paynowService, paypalService, revolutService) {
22
- this.moduleRef = moduleRef;
23
- this.creatorService = creatorService;
24
- this.refresherService = refresherService;
25
- this.refundService = refundService;
26
- this.httpService = httpService;
27
- this.config = config;
28
- this.repository = repository;
29
- this.payuService = payuService;
30
- this.paynowService = paynowService;
31
- this.paypalService = paypalService;
32
- this.revolutService = revolutService;
33
- }
34
- moduleRef;
35
- creatorService;
36
- refresherService;
37
- refundService;
38
- httpService;
39
- config;
40
- repository;
41
- payuService;
42
- paynowService;
43
- paypalService;
44
- revolutService;
45
- get _paymentService() {
46
- return {
47
- payu: this.payuService,
48
- paypal: this.paypalService,
49
- paynow: this.paynowService,
50
- revolut: this.revolutService
51
- };
52
- }
53
- _internalService = {
54
- create: (trans) => {
55
- if (!this.config.internalApiUrl)
56
- return Promise.resolve({
57
- date: /* @__PURE__ */ new Date(),
58
- req: trans
59
- });
60
- return this.httpService.post(this.config.internalApiUrl, trans).toPromise().then((res) => res.data);
61
- },
62
- refresh: (trans) => {
63
- if (!this.config.internalApiUrl)
64
- return Promise.resolve({
65
- date: /* @__PURE__ */ new Date(),
66
- req: trans,
67
- id: trans.id
68
- });
69
- return this.httpService.put(this.config.internalApiUrl + "/" + trans.id, trans).toPromise().then((res) => res.data);
70
- }
71
- };
72
- create(ops) {
73
- return this.creatorService.create(
74
- ops,
75
- this.getInternalService(),
76
- this._paymentService
77
- );
78
- }
79
- async refresh(transId, data = {}) {
80
- await this.refresherService.refresh(
81
- transId,
82
- this.getInternalService(),
83
- this._paymentService,
84
- data
85
- );
86
- }
87
- async refund(transId, comment = "Refund") {
88
- await this.refundService.refund(
89
- transId,
90
- this.getInternalService(),
91
- this._paymentService,
92
- comment
93
- );
94
- }
95
- async getById(id) {
96
- return await this.repository.getById(id);
97
- }
98
- getInternalService() {
99
- try {
100
- return this.moduleRef.get(TRANS_TOKEN_INTERNAL_SERVICE, {
101
- strict: false
102
- });
103
- } catch (e) {
104
- return this._internalService;
105
- }
106
- }
107
- };
108
- TransService = __decorateClass([
109
- Injectable(),
110
- __decorateParam(7, Optional()),
111
- __decorateParam(8, Optional()),
112
- __decorateParam(9, Optional()),
113
- __decorateParam(10, Optional())
114
- ], TransService);
115
-
116
- // packages/trans/shell/app-services/src/lib/services/index.ts
117
- var SERVICES = [TransService];
118
- export {
119
- SERVICES,
120
- TRANS_TOKEN_INTERNAL_SERVICE,
121
- TransService
122
- };