@smartsoft001/trans-shell-nestjs 2.127.0 → 2.128.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/index.js +105 -104
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
5
5
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
6
|
if (decorator = decorators[i])
|
|
7
7
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
9
|
return result;
|
|
11
10
|
};
|
|
12
11
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
@@ -29,8 +28,8 @@ import { Guid as Guid2 } from "guid-typescript";
|
|
|
29
28
|
import { Memoize } from "lodash-decorators";
|
|
30
29
|
|
|
31
30
|
// packages/shared/models/src/lib/symbols.ts
|
|
32
|
-
var SYMBOL_MODEL = Symbol.for("smartsoft:model");
|
|
33
|
-
var SYMBOL_FIELD = Symbol.for("smartsoft:field");
|
|
31
|
+
var SYMBOL_MODEL = /* @__PURE__ */ Symbol.for("smartsoft:model");
|
|
32
|
+
var SYMBOL_FIELD = /* @__PURE__ */ Symbol.for("smartsoft:field");
|
|
34
33
|
|
|
35
34
|
// packages/shared/models/src/lib/decorators/model/model.decorator.ts
|
|
36
35
|
import "reflect-metadata";
|
|
@@ -62,11 +61,9 @@ var ObjectService = class {
|
|
|
62
61
|
* @return - new type object
|
|
63
62
|
*/
|
|
64
63
|
static createByType(data, type) {
|
|
65
|
-
if (!data)
|
|
66
|
-
return data;
|
|
64
|
+
if (!data) return data;
|
|
67
65
|
try {
|
|
68
|
-
if (data instanceof type)
|
|
69
|
-
return data;
|
|
66
|
+
if (data instanceof type) return data;
|
|
70
67
|
} catch (e) {
|
|
71
68
|
console.warn(e);
|
|
72
69
|
}
|
|
@@ -82,8 +79,7 @@ var ObjectService = class {
|
|
|
82
79
|
* @return - object without type
|
|
83
80
|
*/
|
|
84
81
|
static removeTypes(obj) {
|
|
85
|
-
if (!obj)
|
|
86
|
-
return obj;
|
|
82
|
+
if (!obj) return obj;
|
|
87
83
|
const result = {};
|
|
88
84
|
Object.keys(obj).forEach((key) => {
|
|
89
85
|
if (obj[key] && obj[key].constructor && !(obj[key] instanceof Date)) {
|
|
@@ -127,8 +123,7 @@ var PasswordService = class _PasswordService {
|
|
|
127
123
|
|
|
128
124
|
// packages/shared/models/src/lib/utils.ts
|
|
129
125
|
function getModelFieldKeys(type) {
|
|
130
|
-
if (!type["__fields"])
|
|
131
|
-
return [];
|
|
126
|
+
if (!type["__fields"]) return [];
|
|
132
127
|
return Object.keys(type["__fields"]);
|
|
133
128
|
}
|
|
134
129
|
function getModelFieldOptions(instance, fieldKey) {
|
|
@@ -144,8 +139,7 @@ function getModelFieldsWithOptions(instance) {
|
|
|
144
139
|
});
|
|
145
140
|
}
|
|
146
141
|
function isModel(instance) {
|
|
147
|
-
if (!instance || !instance.constructor)
|
|
148
|
-
return false;
|
|
142
|
+
if (!instance || !instance.constructor) return false;
|
|
149
143
|
return Reflect.hasMetadata(SYMBOL_MODEL, instance.constructor);
|
|
150
144
|
}
|
|
151
145
|
function getInvalidFields(instance, mode, permissions) {
|
|
@@ -166,8 +160,7 @@ function getInvalidFields(instance, mode, permissions) {
|
|
|
166
160
|
return result;
|
|
167
161
|
}
|
|
168
162
|
function castModel(instance, mode, permissions) {
|
|
169
|
-
if (!isModel(instance))
|
|
170
|
-
return;
|
|
163
|
+
if (!isModel(instance)) return;
|
|
171
164
|
const fieldsWithOptions = getModelFieldsWithOptions(instance);
|
|
172
165
|
Object.keys(instance).filter((key) => key !== "id").forEach((key) => {
|
|
173
166
|
const fieldWidthOptions = fieldsWithOptions.find((f) => f.key === key);
|
|
@@ -214,6 +207,9 @@ var CrudService = class {
|
|
|
214
207
|
this.repository = repository;
|
|
215
208
|
this.attachmentRepository = attachmentRepository;
|
|
216
209
|
}
|
|
210
|
+
permissionService;
|
|
211
|
+
repository;
|
|
212
|
+
attachmentRepository;
|
|
217
213
|
_logger = new Logger(CrudService.name, { timestamp: true });
|
|
218
214
|
async create(data, user) {
|
|
219
215
|
data.id = Guid2.raw();
|
|
@@ -351,8 +347,7 @@ var CrudService = class {
|
|
|
351
347
|
data.id = GuidService.create();
|
|
352
348
|
}
|
|
353
349
|
this.attachmentRepository.upload(data, options);
|
|
354
|
-
if (oldId)
|
|
355
|
-
await this.attachmentRepository.delete(data.id);
|
|
350
|
+
if (oldId) await this.attachmentRepository.delete(data.id);
|
|
356
351
|
return data.id;
|
|
357
352
|
}
|
|
358
353
|
getAttachmentInfo(id) {
|
|
@@ -380,8 +375,7 @@ var CrudService = class {
|
|
|
380
375
|
}
|
|
381
376
|
}
|
|
382
377
|
checkValidUpdatePartial(item, permissions) {
|
|
383
|
-
if (!isModel(item))
|
|
384
|
-
return;
|
|
378
|
+
if (!isModel(item)) return;
|
|
385
379
|
const keys = Object.keys(item);
|
|
386
380
|
const array = getInvalidFields(item, "update", permissions)?.filter(
|
|
387
381
|
(invalidField) => keys.some((key) => key === invalidField)
|
|
@@ -422,8 +416,7 @@ function getMongoUrl(config) {
|
|
|
422
416
|
let url;
|
|
423
417
|
if (config.username && config.password)
|
|
424
418
|
url = `mongodb://${config.username}:${config.password}@${config.host}:${config.port}`;
|
|
425
|
-
else
|
|
426
|
-
url = `mongodb://${config.host}:${config.port}`;
|
|
419
|
+
else url = `mongodb://${config.host}:${config.port}`;
|
|
427
420
|
url = url + "?authSource=" + config.database;
|
|
428
421
|
if (config.host.indexOf("ondigitalocean.com") > -1) {
|
|
429
422
|
url = url.replace("mongodb://", "mongodb+srv://");
|
|
@@ -438,6 +431,7 @@ var MongoUnitOfWork = class extends IUnitOfWork {
|
|
|
438
431
|
super();
|
|
439
432
|
this.config = config;
|
|
440
433
|
}
|
|
434
|
+
config;
|
|
441
435
|
async scope(definition) {
|
|
442
436
|
const client = await MongoClient.connect(this.getUrl());
|
|
443
437
|
const session = client.startSession();
|
|
@@ -460,8 +454,7 @@ var MongoUnitOfWork = class extends IUnitOfWork {
|
|
|
460
454
|
await session.endSession();
|
|
461
455
|
await client.close();
|
|
462
456
|
}
|
|
463
|
-
if (error)
|
|
464
|
-
throw error;
|
|
457
|
+
if (error) throw error;
|
|
465
458
|
}
|
|
466
459
|
getUrl() {
|
|
467
460
|
return getMongoUrl(this.config);
|
|
@@ -480,6 +473,7 @@ var MongoAttachmentRepository = class extends IAttachmentRepository {
|
|
|
480
473
|
super();
|
|
481
474
|
this.config = config;
|
|
482
475
|
}
|
|
476
|
+
config;
|
|
483
477
|
async upload(data, options) {
|
|
484
478
|
const client = await MongoClient2.connect(this.getUrl());
|
|
485
479
|
return await new Promise((res, rej) => {
|
|
@@ -491,11 +485,10 @@ var MongoAttachmentRepository = class extends IAttachmentRepository {
|
|
|
491
485
|
data.id,
|
|
492
486
|
data.fileName,
|
|
493
487
|
{
|
|
494
|
-
contentType: data.mimeType
|
|
488
|
+
metadata: { contentType: data.mimeType }
|
|
495
489
|
}
|
|
496
490
|
);
|
|
497
|
-
if (options?.streamCallback)
|
|
498
|
-
options.streamCallback(writeStream);
|
|
491
|
+
if (options?.streamCallback) options.streamCallback(writeStream);
|
|
499
492
|
data.stream.pipe(writeStream);
|
|
500
493
|
writeStream.on("error", (error) => {
|
|
501
494
|
rej(error);
|
|
@@ -514,11 +507,12 @@ var MongoAttachmentRepository = class extends IAttachmentRepository {
|
|
|
514
507
|
const items = await bucket.find({
|
|
515
508
|
_id: id
|
|
516
509
|
}).toArray();
|
|
517
|
-
if (!items || items.length === 0)
|
|
518
|
-
return null;
|
|
510
|
+
if (!items || items.length === 0) return null;
|
|
519
511
|
return {
|
|
520
512
|
fileName: items[0].filename,
|
|
521
|
-
contentType
|
|
513
|
+
// mongodb 7 removed the deprecated top-level contentType - files written
|
|
514
|
+
// by older driver versions still carry it, so fall back to it
|
|
515
|
+
contentType: items[0].metadata?.["contentType"] ?? items[0].contentType,
|
|
522
516
|
length: items[0].length
|
|
523
517
|
};
|
|
524
518
|
}
|
|
@@ -559,6 +553,7 @@ var MongoItemRepository = class extends IItemRepository {
|
|
|
559
553
|
super();
|
|
560
554
|
this.config = config;
|
|
561
555
|
}
|
|
556
|
+
config;
|
|
562
557
|
async create(item, user, repoOptions) {
|
|
563
558
|
await this.collectionContext(async (collection) => {
|
|
564
559
|
try {
|
|
@@ -874,8 +869,7 @@ var MongoItemRepository = class extends IItemRepository {
|
|
|
874
869
|
return result;
|
|
875
870
|
}
|
|
876
871
|
getModelToResult(item) {
|
|
877
|
-
if (!item)
|
|
878
|
-
return null;
|
|
872
|
+
if (!item) return null;
|
|
879
873
|
const result = ObjectService.removeTypes(item);
|
|
880
874
|
result["id"] = result._id;
|
|
881
875
|
delete result._id;
|
|
@@ -905,8 +899,7 @@ var MongoItemRepository = class extends IItemRepository {
|
|
|
905
899
|
}
|
|
906
900
|
}
|
|
907
901
|
generateSearch(criteria) {
|
|
908
|
-
if (!criteria["$search"])
|
|
909
|
-
return;
|
|
902
|
+
if (!criteria["$search"]) return;
|
|
910
903
|
if (this.config.type) {
|
|
911
904
|
const modelFields = getModelFieldsWithOptions(
|
|
912
905
|
new this.config.type()
|
|
@@ -921,8 +914,7 @@ var MongoItemRepository = class extends IItemRepository {
|
|
|
921
914
|
};
|
|
922
915
|
searchArray.push(res);
|
|
923
916
|
});
|
|
924
|
-
if (!criteria["$or"])
|
|
925
|
-
criteria["$or"] = searchArray;
|
|
917
|
+
if (!criteria["$or"]) criteria["$or"] = searchArray;
|
|
926
918
|
else if (criteria["$or"] && !criteria["$and"]) {
|
|
927
919
|
criteria["$and"] = [{ $or: criteria["$or"] }, { $or: searchArray }];
|
|
928
920
|
delete criteria["$or"];
|
|
@@ -1009,6 +1001,7 @@ var JwtStrategy = class extends PassportStrategy(Strategy) {
|
|
|
1009
1001
|
});
|
|
1010
1002
|
this.config = config;
|
|
1011
1003
|
}
|
|
1004
|
+
config;
|
|
1012
1005
|
async validate(payload) {
|
|
1013
1006
|
return {
|
|
1014
1007
|
...payload,
|
|
@@ -1027,6 +1020,7 @@ var PermissionService = class {
|
|
|
1027
1020
|
constructor(config) {
|
|
1028
1021
|
this.config = config;
|
|
1029
1022
|
}
|
|
1023
|
+
config;
|
|
1030
1024
|
/**
|
|
1031
1025
|
* Validates if the user has the required permissions for a given type.
|
|
1032
1026
|
* @param {PermissionType} type - The type of permission to validate.
|
|
@@ -1034,13 +1028,10 @@ var PermissionService = class {
|
|
|
1034
1028
|
* @throws {DomainForbiddenError} If the user does not have the required permissions.
|
|
1035
1029
|
*/
|
|
1036
1030
|
valid(type, user) {
|
|
1037
|
-
if (!this.config.permissions)
|
|
1038
|
-
return;
|
|
1031
|
+
if (!this.config.permissions) return;
|
|
1039
1032
|
const typeConfig = this.config.permissions[type];
|
|
1040
|
-
if (!typeConfig)
|
|
1041
|
-
|
|
1042
|
-
if (!user.permissions)
|
|
1043
|
-
throw new DomainForbiddenError(`Context forbidden`);
|
|
1033
|
+
if (!typeConfig) return;
|
|
1034
|
+
if (!user.permissions) throw new DomainForbiddenError(`Context forbidden`);
|
|
1044
1035
|
if (!typeConfig.some((tc) => user.permissions.some((up) => tc === up)))
|
|
1045
1036
|
throw new DomainForbiddenError(`Context forbidden`);
|
|
1046
1037
|
}
|
|
@@ -1178,8 +1169,7 @@ import { Readable } from "stream";
|
|
|
1178
1169
|
import * as querystring from "querystring";
|
|
1179
1170
|
var iso8601 = /^\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?(T([01][0-9]|2[0-3]):[0-5]\d(:[0-5]\d(\.\d+)?)?(Z|[+-]\d{2}:\d{2}))?$/;
|
|
1180
1171
|
function fieldsToMongo(fields) {
|
|
1181
|
-
if (!fields)
|
|
1182
|
-
return null;
|
|
1172
|
+
if (!fields) return null;
|
|
1183
1173
|
const hash = {};
|
|
1184
1174
|
fields.split(",").forEach(function(field) {
|
|
1185
1175
|
hash[field.trim()] = 1;
|
|
@@ -1190,8 +1180,7 @@ function convertRegex(val) {
|
|
|
1190
1180
|
return val.toString().replace(/\*/g, "[*]");
|
|
1191
1181
|
}
|
|
1192
1182
|
function omitFieldsToMongo(omitFields) {
|
|
1193
|
-
if (!omitFields)
|
|
1194
|
-
return null;
|
|
1183
|
+
if (!omitFields) return null;
|
|
1195
1184
|
const hash = {};
|
|
1196
1185
|
omitFields.split(",").forEach(function(omitField) {
|
|
1197
1186
|
hash[omitField.trim()] = 0;
|
|
@@ -1199,21 +1188,18 @@ function omitFieldsToMongo(omitFields) {
|
|
|
1199
1188
|
return hash;
|
|
1200
1189
|
}
|
|
1201
1190
|
function sortToMongo(sort) {
|
|
1202
|
-
if (!sort)
|
|
1203
|
-
return null;
|
|
1191
|
+
if (!sort) return null;
|
|
1204
1192
|
const hash = {};
|
|
1205
1193
|
let c;
|
|
1206
1194
|
sort.split(",").forEach(function(field) {
|
|
1207
1195
|
c = field.charAt(0);
|
|
1208
|
-
if (c === "-")
|
|
1209
|
-
field = field.substr(1);
|
|
1196
|
+
if (c === "-") field = field.substr(1);
|
|
1210
1197
|
hash[field.trim()] = c === "-" ? -1 : 1;
|
|
1211
1198
|
});
|
|
1212
1199
|
return hash;
|
|
1213
1200
|
}
|
|
1214
1201
|
function typedValue(value) {
|
|
1215
|
-
if (value[0] === "!")
|
|
1216
|
-
value = value.substr(1);
|
|
1202
|
+
if (value[0] === "!") value = value.substr(1);
|
|
1217
1203
|
const regex = value.match(/^\/(.*)\/(i?)$/);
|
|
1218
1204
|
const quotedString = value.match(/(["'])(?:\\\1|.)*?\1/);
|
|
1219
1205
|
if (regex) {
|
|
@@ -1244,13 +1230,11 @@ function comparisonToMongo(key, value) {
|
|
|
1244
1230
|
const parts = join.match(/^(!?[^><~!=:]+)(?:=?([><]=?|~?=|!?=|:.+=)(.+))?$/);
|
|
1245
1231
|
let op;
|
|
1246
1232
|
const hash = {};
|
|
1247
|
-
if (!parts)
|
|
1248
|
-
return null;
|
|
1233
|
+
if (!parts) return null;
|
|
1249
1234
|
key = parts[1];
|
|
1250
1235
|
op = parts[2];
|
|
1251
1236
|
if (!op) {
|
|
1252
|
-
if (key[0] !== "!")
|
|
1253
|
-
value = { $exists: true };
|
|
1237
|
+
if (key[0] !== "!") value = { $exists: true };
|
|
1254
1238
|
else {
|
|
1255
1239
|
key = key.substr(1);
|
|
1256
1240
|
value = { $exists: false };
|
|
@@ -1258,8 +1242,7 @@ function comparisonToMongo(key, value) {
|
|
|
1258
1242
|
} else if (op === "=" && parts[3] === "!") {
|
|
1259
1243
|
value = { $exists: false };
|
|
1260
1244
|
} else if (op === "=" || op === "!=") {
|
|
1261
|
-
if (op === "=" && parts[3][0] === "!")
|
|
1262
|
-
op = "!=";
|
|
1245
|
+
if (op === "=" && parts[3][0] === "!") op = "!=";
|
|
1263
1246
|
const array = typedValues(parts[3]);
|
|
1264
1247
|
if (array.length > 1) {
|
|
1265
1248
|
value = {};
|
|
@@ -1284,14 +1267,10 @@ function comparisonToMongo(key, value) {
|
|
|
1284
1267
|
value[op] = array.length === 1 ? array[0] : array;
|
|
1285
1268
|
} else {
|
|
1286
1269
|
value = typedValue(parts[3]);
|
|
1287
|
-
if (op === ">")
|
|
1288
|
-
|
|
1289
|
-
else if (op === "
|
|
1290
|
-
|
|
1291
|
-
else if (op === "<")
|
|
1292
|
-
value = { $lt: value };
|
|
1293
|
-
else if (op === "<=")
|
|
1294
|
-
value = { $lte: value };
|
|
1270
|
+
if (op === ">") value = { $gt: value };
|
|
1271
|
+
else if (op === ">=") value = { $gte: value };
|
|
1272
|
+
else if (op === "<") value = { $lt: value };
|
|
1273
|
+
else if (op === "<=") value = { $lte: value };
|
|
1295
1274
|
else if (op === "~=")
|
|
1296
1275
|
value = {
|
|
1297
1276
|
$regex: value ? convertRegex(value) : "",
|
|
@@ -1305,8 +1284,7 @@ function comparisonToMongo(key, value) {
|
|
|
1305
1284
|
function hasOrdinalKeys(obj) {
|
|
1306
1285
|
let c = 0;
|
|
1307
1286
|
for (const key in obj) {
|
|
1308
|
-
if (Number(key) !== c++)
|
|
1309
|
-
return false;
|
|
1287
|
+
if (Number(key) !== c++) return false;
|
|
1310
1288
|
}
|
|
1311
1289
|
return true;
|
|
1312
1290
|
}
|
|
@@ -1343,12 +1321,9 @@ function queryCriteriaToMongo(query, options = null) {
|
|
|
1343
1321
|
function queryOptionsToMongo(query, options) {
|
|
1344
1322
|
const hash = {}, fields = fieldsToMongo(query[options.keywords.fields]), omitFields = omitFieldsToMongo(query[options.keywords.omit]), sort = sortToMongo(query[options.keywords.sort]), maxLimit = options.maxLimit || 9007199254740992;
|
|
1345
1323
|
let limit = options.maxLimit || 0;
|
|
1346
|
-
if (fields)
|
|
1347
|
-
|
|
1348
|
-
if (
|
|
1349
|
-
hash.fields = omitFields;
|
|
1350
|
-
if (sort)
|
|
1351
|
-
hash.sort = sort;
|
|
1324
|
+
if (fields) hash.fields = fields;
|
|
1325
|
+
if (omitFields) hash.fields = omitFields;
|
|
1326
|
+
if (sort) hash.sort = sort;
|
|
1352
1327
|
if (query[options.keywords.offset])
|
|
1353
1328
|
hash.skip = Number(query[options.keywords.offset]);
|
|
1354
1329
|
if (query[options.keywords.limit])
|
|
@@ -1385,10 +1360,8 @@ function q2m(query = null, options = null) {
|
|
|
1385
1360
|
options.ignore = typeof options.ignore === "string" ? [options.ignore] : options.ignore;
|
|
1386
1361
|
}
|
|
1387
1362
|
options.ignore = options.ignore.concat(ignoreKeywords);
|
|
1388
|
-
if (!options.parser)
|
|
1389
|
-
|
|
1390
|
-
if (typeof query === "string")
|
|
1391
|
-
query = options.parser.parse(query);
|
|
1363
|
+
if (!options.parser) options.parser = querystring;
|
|
1364
|
+
if (typeof query === "string") query = options.parser.parse(query);
|
|
1392
1365
|
return {
|
|
1393
1366
|
criteria: queryCriteriaToMongo(query, options),
|
|
1394
1367
|
options: queryOptionsToMongo(query, options),
|
|
@@ -1397,8 +1370,7 @@ function q2m(query = null, options = null) {
|
|
|
1397
1370
|
const limit = Math.min(this.options.limit || 0, totalCount);
|
|
1398
1371
|
const links = {};
|
|
1399
1372
|
const last = {};
|
|
1400
|
-
if (!limit)
|
|
1401
|
-
return null;
|
|
1373
|
+
if (!limit) return null;
|
|
1402
1374
|
options = options || {};
|
|
1403
1375
|
if (offset > 0) {
|
|
1404
1376
|
query[options.keywords.offset] = Math.max(offset - limit, 0);
|
|
@@ -1449,6 +1421,7 @@ var CrudController = class {
|
|
|
1449
1421
|
constructor(service) {
|
|
1450
1422
|
this.service = service;
|
|
1451
1423
|
}
|
|
1424
|
+
service;
|
|
1452
1425
|
static getLink(req) {
|
|
1453
1426
|
return req.protocol + "://" + req.headers.host + req.url;
|
|
1454
1427
|
}
|
|
@@ -1635,8 +1608,7 @@ var CrudController = class {
|
|
|
1635
1608
|
if (!fields.some((f) => f === baseKey + key))
|
|
1636
1609
|
fields.push(baseKey + key);
|
|
1637
1610
|
} else {
|
|
1638
|
-
if (!fields.some((f) => f === key))
|
|
1639
|
-
fields.push(key);
|
|
1611
|
+
if (!fields.some((f) => f === key)) fields.push(key);
|
|
1640
1612
|
}
|
|
1641
1613
|
});
|
|
1642
1614
|
};
|
|
@@ -1736,6 +1708,7 @@ var CrudGateway = class {
|
|
|
1736
1708
|
constructor(service) {
|
|
1737
1709
|
this.service = service;
|
|
1738
1710
|
}
|
|
1711
|
+
service;
|
|
1739
1712
|
_clientsSubscriptions;
|
|
1740
1713
|
handleFilter(data, client) {
|
|
1741
1714
|
const event = "changes";
|
|
@@ -1864,6 +1837,9 @@ var PaynowService = class {
|
|
|
1864
1837
|
this.config = config;
|
|
1865
1838
|
this.moduleRef = moduleRef;
|
|
1866
1839
|
}
|
|
1840
|
+
httpService;
|
|
1841
|
+
config;
|
|
1842
|
+
moduleRef;
|
|
1867
1843
|
async create(obj) {
|
|
1868
1844
|
const config = await this.getConfig(obj.data);
|
|
1869
1845
|
const data = {
|
|
@@ -1955,8 +1931,7 @@ var PaynowService = class {
|
|
|
1955
1931
|
return this.config;
|
|
1956
1932
|
}
|
|
1957
1933
|
getBaseUrl(config) {
|
|
1958
|
-
if (config.test)
|
|
1959
|
-
return "https://api.sandbox.paynow.pl";
|
|
1934
|
+
if (config.test) return "https://api.sandbox.paynow.pl";
|
|
1960
1935
|
return "https://api.paynow.pl";
|
|
1961
1936
|
}
|
|
1962
1937
|
getStatusFromExternal(status) {
|
|
@@ -1992,6 +1967,13 @@ var PaypalConfig = class {
|
|
|
1992
1967
|
this.cancelUrl = cancelUrl;
|
|
1993
1968
|
this.test = test;
|
|
1994
1969
|
}
|
|
1970
|
+
clientId;
|
|
1971
|
+
clientSecret;
|
|
1972
|
+
currencyCode;
|
|
1973
|
+
returnUrl;
|
|
1974
|
+
apiUrl;
|
|
1975
|
+
cancelUrl;
|
|
1976
|
+
test;
|
|
1995
1977
|
};
|
|
1996
1978
|
var PAYPAL_CONFIG_PROVIDER = "PAYPAL_CONFIG_PROVIDER";
|
|
1997
1979
|
|
|
@@ -2004,6 +1986,9 @@ var PaypalService = class {
|
|
|
2004
1986
|
this.config = config;
|
|
2005
1987
|
this.moduleRef = moduleRef;
|
|
2006
1988
|
}
|
|
1989
|
+
httpService;
|
|
1990
|
+
config;
|
|
1991
|
+
moduleRef;
|
|
2007
1992
|
async create(obj) {
|
|
2008
1993
|
const config = await this.getConfig(obj.data);
|
|
2009
1994
|
const data = {
|
|
@@ -2213,6 +2198,9 @@ var PayuService = class {
|
|
|
2213
2198
|
this.config = config;
|
|
2214
2199
|
this.moduleRef = moduleRef;
|
|
2215
2200
|
}
|
|
2201
|
+
httpService;
|
|
2202
|
+
config;
|
|
2203
|
+
moduleRef;
|
|
2216
2204
|
async create(obj) {
|
|
2217
2205
|
const config = await this.getConfig(obj.data);
|
|
2218
2206
|
const token = await this.getToken(config);
|
|
@@ -2279,8 +2267,7 @@ var PayuService = class {
|
|
|
2279
2267
|
},
|
|
2280
2268
|
maxRedirects: 0
|
|
2281
2269
|
}).toPromise();
|
|
2282
|
-
if (!response.data.orders)
|
|
2283
|
-
return null;
|
|
2270
|
+
if (!response.data.orders) return null;
|
|
2284
2271
|
const order = response.data.orders[0];
|
|
2285
2272
|
return {
|
|
2286
2273
|
status: this.getStatusFromExternal(order.status),
|
|
@@ -2346,8 +2333,7 @@ var PayuService = class {
|
|
|
2346
2333
|
return this.config;
|
|
2347
2334
|
}
|
|
2348
2335
|
getBaseUrl(config) {
|
|
2349
|
-
if (config.test)
|
|
2350
|
-
return "https://secure.snd.payu.com";
|
|
2336
|
+
if (config.test) return "https://secure.snd.payu.com";
|
|
2351
2337
|
return "https://secure.payu.com";
|
|
2352
2338
|
}
|
|
2353
2339
|
getStatusFromExternal(status) {
|
|
@@ -2383,6 +2369,9 @@ var RevolutService = class {
|
|
|
2383
2369
|
this.moduleRef = moduleRef;
|
|
2384
2370
|
this.config = config;
|
|
2385
2371
|
}
|
|
2372
|
+
httpService;
|
|
2373
|
+
moduleRef;
|
|
2374
|
+
config;
|
|
2386
2375
|
async create(obj) {
|
|
2387
2376
|
const config = await this.getConfig(obj.data);
|
|
2388
2377
|
const data = {
|
|
@@ -2429,8 +2418,7 @@ var RevolutService = class {
|
|
|
2429
2418
|
return Promise.reject("Revolut does not support refund");
|
|
2430
2419
|
}
|
|
2431
2420
|
getBaseUrl(config) {
|
|
2432
|
-
if (config.test)
|
|
2433
|
-
return "https://sandbox-merchant.revolut.com";
|
|
2421
|
+
if (config.test) return "https://sandbox-merchant.revolut.com";
|
|
2434
2422
|
return "https://merchant.revolut.com";
|
|
2435
2423
|
}
|
|
2436
2424
|
getHeaders(config) {
|
|
@@ -2577,6 +2565,7 @@ var TransBaseService = class {
|
|
|
2577
2565
|
constructor(repository) {
|
|
2578
2566
|
this.repository = repository;
|
|
2579
2567
|
}
|
|
2568
|
+
repository;
|
|
2580
2569
|
addHistory(trans, data) {
|
|
2581
2570
|
const historyItem = new TransHistory();
|
|
2582
2571
|
historyItem.amount = trans.amount;
|
|
@@ -2584,8 +2573,7 @@ var TransBaseService = class {
|
|
|
2584
2573
|
historyItem.data = ObjectService.removeTypes(data);
|
|
2585
2574
|
historyItem.system = trans.system;
|
|
2586
2575
|
historyItem.status = trans.status;
|
|
2587
|
-
if (!trans.history)
|
|
2588
|
-
trans.history = [];
|
|
2576
|
+
if (!trans.history) trans.history = [];
|
|
2589
2577
|
trans.history.push(historyItem);
|
|
2590
2578
|
}
|
|
2591
2579
|
async setError(trans, error) {
|
|
@@ -2660,16 +2648,12 @@ var CreatorService = class extends TransBaseService {
|
|
|
2660
2648
|
return trans;
|
|
2661
2649
|
}
|
|
2662
2650
|
valid(req) {
|
|
2663
|
-
if (!req)
|
|
2664
|
-
|
|
2665
|
-
if (!req.
|
|
2666
|
-
throw new DomainValidationError("name is empty");
|
|
2667
|
-
if (!req.clientIp)
|
|
2668
|
-
throw new DomainValidationError("client ip is empty");
|
|
2651
|
+
if (!req) throw new DomainValidationError("config is empty");
|
|
2652
|
+
if (!req.name) throw new DomainValidationError("name is empty");
|
|
2653
|
+
if (!req.clientIp) throw new DomainValidationError("client ip is empty");
|
|
2669
2654
|
if (!req.amount || req.amount < 1)
|
|
2670
2655
|
throw new DomainValidationError("amount is empty");
|
|
2671
|
-
if (!req.data)
|
|
2672
|
-
throw new DomainValidationError("data is empty");
|
|
2656
|
+
if (!req.data) throw new DomainValidationError("data is empty");
|
|
2673
2657
|
if (!req.system || !TRANS_SYSTEMS.some((s) => s === req.system))
|
|
2674
2658
|
throw new DomainValidationError("system is empty");
|
|
2675
2659
|
}
|
|
@@ -2693,15 +2677,13 @@ var RefresherService = class extends TransBaseService {
|
|
|
2693
2677
|
}
|
|
2694
2678
|
try {
|
|
2695
2679
|
const { status, data } = await paymentService[trans.system].getStatus(trans);
|
|
2696
|
-
if (status === trans.status)
|
|
2697
|
-
return;
|
|
2680
|
+
if (status === trans.status) return;
|
|
2698
2681
|
trans.modifyDate = /* @__PURE__ */ new Date();
|
|
2699
2682
|
trans.status = status;
|
|
2700
2683
|
data["customData"] = customData;
|
|
2701
2684
|
this.addHistory(trans, data);
|
|
2702
2685
|
const internalRes = await internalService.refresh(trans);
|
|
2703
|
-
if (!internalRes)
|
|
2704
|
-
return;
|
|
2686
|
+
if (!internalRes) return;
|
|
2705
2687
|
this.addHistory(trans, internalRes);
|
|
2706
2688
|
await this.repository.updatePartial(
|
|
2707
2689
|
{
|
|
@@ -2765,6 +2747,8 @@ var TransConfig = class {
|
|
|
2765
2747
|
this.internalApiUrl = internalApiUrl;
|
|
2766
2748
|
this.tokenConfig = tokenConfig;
|
|
2767
2749
|
}
|
|
2750
|
+
internalApiUrl;
|
|
2751
|
+
tokenConfig;
|
|
2768
2752
|
};
|
|
2769
2753
|
|
|
2770
2754
|
// packages/trans/domain/src/index.ts
|
|
@@ -2795,6 +2779,17 @@ var TransService = class {
|
|
|
2795
2779
|
this.paypalService = paypalService;
|
|
2796
2780
|
this.revolutService = revolutService;
|
|
2797
2781
|
}
|
|
2782
|
+
moduleRef;
|
|
2783
|
+
creatorService;
|
|
2784
|
+
refresherService;
|
|
2785
|
+
refundService;
|
|
2786
|
+
httpService;
|
|
2787
|
+
config;
|
|
2788
|
+
repository;
|
|
2789
|
+
payuService;
|
|
2790
|
+
paynowService;
|
|
2791
|
+
paypalService;
|
|
2792
|
+
revolutService;
|
|
2798
2793
|
get _paymentService() {
|
|
2799
2794
|
return {
|
|
2800
2795
|
payu: this.payuService,
|
|
@@ -2875,6 +2870,7 @@ var PaynowController = class {
|
|
|
2875
2870
|
constructor(service) {
|
|
2876
2871
|
this.service = service;
|
|
2877
2872
|
}
|
|
2873
|
+
service;
|
|
2878
2874
|
async refreshStatus(obj) {
|
|
2879
2875
|
try {
|
|
2880
2876
|
await this.service.refresh(obj.paymentId, obj);
|
|
@@ -2913,6 +2909,9 @@ var PaypalController = class {
|
|
|
2913
2909
|
this.config = config;
|
|
2914
2910
|
this.paypalService = paypalService;
|
|
2915
2911
|
}
|
|
2912
|
+
service;
|
|
2913
|
+
config;
|
|
2914
|
+
paypalService;
|
|
2916
2915
|
async refreshStatus(obj) {
|
|
2917
2916
|
try {
|
|
2918
2917
|
const trans = await this.service.getById(obj.item_number1);
|
|
@@ -2968,6 +2967,7 @@ var PayUController = class {
|
|
|
2968
2967
|
constructor(service) {
|
|
2969
2968
|
this.service = service;
|
|
2970
2969
|
}
|
|
2970
|
+
service;
|
|
2971
2971
|
async refreshStatus(obj) {
|
|
2972
2972
|
try {
|
|
2973
2973
|
await this.service.refresh(obj.order.orderId, obj);
|
|
@@ -2993,6 +2993,7 @@ var TransController = class {
|
|
|
2993
2993
|
constructor(service) {
|
|
2994
2994
|
this.service = service;
|
|
2995
2995
|
}
|
|
2996
|
+
service;
|
|
2996
2997
|
async create(obj, req) {
|
|
2997
2998
|
obj.clientIp = req.connection.remoteAddress.indexOf("::") === 0 ? "10.0.0.1" : req.connection.remoteAddress;
|
|
2998
2999
|
const { redirectUrl, orderId } = await this.service.create(obj);
|