@smartsoft001/domain-core 2.82.0 → 2.84.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 +4 -15
- package/src/index.js +8 -0
- package/src/index.js.map +1 -0
- package/src/lib/errors.js +18 -0
- package/src/lib/errors.js.map +1 -0
- package/src/lib/interfaces.js +3 -0
- package/src/lib/interfaces.js.map +1 -0
- package/src/lib/repositories.js +39 -0
- package/src/lib/repositories.js.map +1 -0
- package/src/lib/specifications.js +99 -0
- package/src/lib/specifications.js.map +1 -0
- package/index.cjs +0 -152
package/package.json
CHANGED
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
"name": "@smartsoft001/domain-core",
|
|
3
3
|
"type": "commonjs",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@angular/core": "20.1.0",
|
|
6
|
-
"@smartsoft001/models": "^2.82.0",
|
|
7
|
-
"@smartsoft001/users": "^2.82.0",
|
|
8
|
-
"flatted": "3.3.3",
|
|
9
|
-
"guid-typescript": "^1.0.9",
|
|
10
|
-
"lodash": "4.17.21",
|
|
11
|
-
"md5": "^2.3.0",
|
|
12
|
-
"reflect-metadata": "^0.2.1",
|
|
13
5
|
"rxjs": "^7.8.1",
|
|
14
|
-
"
|
|
6
|
+
"@smartsoft001/models": "^2.84.0",
|
|
7
|
+
"@smartsoft001/users": "^2.84.0"
|
|
15
8
|
},
|
|
16
|
-
"version": "2.
|
|
9
|
+
"version": "2.84.0",
|
|
17
10
|
"main": "./src/index.js",
|
|
18
11
|
"typings": "./src/index.d.ts",
|
|
19
|
-
"
|
|
20
|
-
"paypal-rest-sdk": "1.8.1",
|
|
21
|
-
"tslib": "^2.3.0",
|
|
22
|
-
"zone.js": "~0.15.0"
|
|
23
|
-
}
|
|
12
|
+
"types": "./src/index.d.ts"
|
|
24
13
|
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/interfaces"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/errors"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/repositories"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/specifications"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/shared/domain-core/src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,uDAA6B;AAC7B,6DAAmC;AACnC,+DAAqC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainForbiddenError = exports.DomainValidationError = void 0;
|
|
4
|
+
class DomainValidationError extends Error {
|
|
5
|
+
constructor(msg) {
|
|
6
|
+
super(msg);
|
|
7
|
+
this.type = DomainValidationError;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DomainValidationError = DomainValidationError;
|
|
11
|
+
class DomainForbiddenError extends Error {
|
|
12
|
+
constructor(msg) {
|
|
13
|
+
super(msg);
|
|
14
|
+
this.type = DomainForbiddenError;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.DomainForbiddenError = DomainForbiddenError;
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAG9C,YAAY,GAAW;QACrB,KAAK,CAAC,GAAG,CAAC,CAAC;QAHb,SAAI,GAAG,qBAAqB,CAAC;IAI7B,CAAC;CACF;AAND,sDAMC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAG7C,YAAY,GAAW;QACrB,KAAK,CAAC,GAAG,CAAC,CAAC;QAHb,SAAI,GAAG,oBAAoB,CAAC;IAI5B,CAAC;CACF;AAND,oDAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IAttachmentRepository = exports.IItemRepository = exports.IUnitOfWork = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* IUnitOfWork is an abstract class that defines the contract for managing transactional operations
|
|
6
|
+
* across multiple repositories or services. This pattern ensures that a set of operations either
|
|
7
|
+
* all succeed or all fail, maintaining data consistency.
|
|
8
|
+
*
|
|
9
|
+
* @interface IUnitOfWork
|
|
10
|
+
*/
|
|
11
|
+
class IUnitOfWork {
|
|
12
|
+
}
|
|
13
|
+
exports.IUnitOfWork = IUnitOfWork;
|
|
14
|
+
/**
|
|
15
|
+
* IItemRepository is an abstract class that defines the contract for a repository
|
|
16
|
+
* responsible for managing entities of type `T` in a storage system. This repository
|
|
17
|
+
* interface provides a set of methods for creating, updating, deleting, and querying
|
|
18
|
+
* entities, with support for transactional operations and various query criteria.
|
|
19
|
+
*
|
|
20
|
+
* @template T - The type of entity that this repository will manage. The entity should extend `IEntity<string>`.
|
|
21
|
+
*
|
|
22
|
+
* @interface IItemRepository
|
|
23
|
+
*/
|
|
24
|
+
class IItemRepository {
|
|
25
|
+
}
|
|
26
|
+
exports.IItemRepository = IItemRepository;
|
|
27
|
+
/**
|
|
28
|
+
* IAttachmentRepository is an abstract class that defines the contract for managing file attachments
|
|
29
|
+
* in a storage system. This interface can be implemented to work with various storage backends, such as
|
|
30
|
+
* MongoDB GridFS, Amazon S3, Google Cloud Storage, or any other file storage solution.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The type of the entity that this repository will manage. The entity should extend `IEntity<string>`.
|
|
33
|
+
*
|
|
34
|
+
* @interface IAttachmentRepository
|
|
35
|
+
*/
|
|
36
|
+
class IAttachmentRepository {
|
|
37
|
+
}
|
|
38
|
+
exports.IAttachmentRepository = IAttachmentRepository;
|
|
39
|
+
//# sourceMappingURL=repositories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repositories.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/repositories.ts"],"names":[],"mappings":";;;AAyBA;;;;;;GAMG;AACH,MAAsB,WAAW;CAmChC;AAnCD,kCAmCC;AAUD;;;;;;;;;GASG;AACH,MAAsB,eAAe;CAwLpC;AAxLD,0CAwLC;AAED;;;;;;;;GAQG;AACH,MAAsB,qBAAqB;CA0F1C;AA1FD,sDA0FC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AndSpecification = exports.OrSpecification = exports.MergeSpecification = exports.BasicSpecification = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* BasicSpecification is a class that implements the `ISpecification` interface and serves as a base
|
|
6
|
+
* class for defining basic query criteria. It holds a single set of criteria that can be used to
|
|
7
|
+
* filter entities in a repository or database.
|
|
8
|
+
*
|
|
9
|
+
* This class can be extended to create more complex specifications by combining or modifying the
|
|
10
|
+
* base criteria.
|
|
11
|
+
*
|
|
12
|
+
* @class BasicSpecification
|
|
13
|
+
* @implements {ISpecification}
|
|
14
|
+
*/
|
|
15
|
+
class BasicSpecification {
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of BasicSpecification.
|
|
18
|
+
*
|
|
19
|
+
* @param {any} criteria - The criteria used to filter entities.
|
|
20
|
+
*/
|
|
21
|
+
constructor(criteria) {
|
|
22
|
+
this.criteria = criteria;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.BasicSpecification = BasicSpecification;
|
|
26
|
+
/**
|
|
27
|
+
* MergeSpecification is a class that extends `BasicSpecification` and allows for the merging of multiple
|
|
28
|
+
* specifications into a single specification. The resulting specification combines the criteria of all provided
|
|
29
|
+
* specifications using a shallow merge.
|
|
30
|
+
*
|
|
31
|
+
* This class is useful when you need to apply multiple specifications to a query in a way that combines their criteria.
|
|
32
|
+
*
|
|
33
|
+
* @class MergeSpecification
|
|
34
|
+
* @extends {BasicSpecification}
|
|
35
|
+
*/
|
|
36
|
+
class MergeSpecification extends BasicSpecification {
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of MergeSpecification.
|
|
39
|
+
*
|
|
40
|
+
* @param {...ISpecification[]} specs - An array of specifications to be merged.
|
|
41
|
+
*/
|
|
42
|
+
constructor(...specs) {
|
|
43
|
+
let criteria = {};
|
|
44
|
+
specs.forEach((spec) => {
|
|
45
|
+
criteria = Object.assign(Object.assign({}, criteria), spec.criteria);
|
|
46
|
+
});
|
|
47
|
+
super(criteria);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MergeSpecification = MergeSpecification;
|
|
51
|
+
/**
|
|
52
|
+
* OrSpecification is a class that extends `BasicSpecification` and allows for the combination of
|
|
53
|
+
* multiple specifications using a logical OR operation. The resulting specification matches entities that satisfy
|
|
54
|
+
* at least one of the provided specifications.
|
|
55
|
+
*
|
|
56
|
+
* This class is useful when you need to apply multiple specifications to a query in a way that matches entities
|
|
57
|
+
* that meet any of the specified criteria.
|
|
58
|
+
*
|
|
59
|
+
* @class OrSpecification
|
|
60
|
+
* @extends {BasicSpecification}
|
|
61
|
+
*/
|
|
62
|
+
class OrSpecification extends BasicSpecification {
|
|
63
|
+
/**
|
|
64
|
+
* Creates an instance of OrSpecification.
|
|
65
|
+
*
|
|
66
|
+
* @param {...ISpecification[]} spec - An array of specifications to be combined using a logical OR.
|
|
67
|
+
*/
|
|
68
|
+
constructor(...spec) {
|
|
69
|
+
super({
|
|
70
|
+
$or: spec.map((c) => c.criteria),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.OrSpecification = OrSpecification;
|
|
75
|
+
/**
|
|
76
|
+
* AndSpecification is a class that extends `BasicSpecification` and allows for the combination of
|
|
77
|
+
* multiple specifications using a logical AND operation. The resulting specification matches entities that satisfy
|
|
78
|
+
* all the provided specifications.
|
|
79
|
+
*
|
|
80
|
+
* This class is useful when you need to apply multiple specifications to a query in a way that matches entities
|
|
81
|
+
* that meet all the specified criteria.
|
|
82
|
+
*
|
|
83
|
+
* @class AndSpecification
|
|
84
|
+
* @extends {BasicSpecification}
|
|
85
|
+
*/
|
|
86
|
+
class AndSpecification extends BasicSpecification {
|
|
87
|
+
/**
|
|
88
|
+
* Creates an instance of AndSpecification.
|
|
89
|
+
*
|
|
90
|
+
* @param {...ISpecification[]} spec - An array of specifications to be combined using a logical AND.
|
|
91
|
+
*/
|
|
92
|
+
constructor(...spec) {
|
|
93
|
+
super({
|
|
94
|
+
$and: spec.map((c) => c.criteria),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.AndSpecification = AndSpecification;
|
|
99
|
+
//# sourceMappingURL=specifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specifications.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/specifications.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,MAAa,kBAAkB;IAC7B;;;;OAIG;IACH,YAA4B,QAAa;QAAb,aAAQ,GAAR,QAAQ,CAAK;IAAG,CAAC;CAC9C;AAPD,gDAOC;AAED;;;;;;;;;GASG;AACH,MAAa,kBAAmB,SAAQ,kBAAkB;IACxD;;;;OAIG;IACH,YAAY,GAAG,KAA4B;QACzC,IAAI,QAAQ,GAAG,EAAE,CAAC;QAElB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,QAAQ,mCACH,QAAQ,GACR,IAAI,CAAC,QAAQ,CACjB,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;CACF;AAlBD,gDAkBC;AAED;;;;;;;;;;GAUG;AACH,MAAa,eAAgB,SAAQ,kBAAkB;IACrD;;;;OAIG;IACH,YAAY,GAAG,IAA2B;QACxC,KAAK,CAAC;YACJ,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAXD,0CAWC;AAED;;;;;;;;;;GAUG;AACH,MAAa,gBAAiB,SAAQ,kBAAkB;IACtD;;;;OAIG;IACH,YAAY,GAAG,IAA2B;QACxC,KAAK,CAAC;YACJ,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;CACF;AAXD,4CAWC"}
|
package/index.cjs
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/shared/domain-core/src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
AndSpecification: () => AndSpecification,
|
|
34
|
-
BasicSpecification: () => BasicSpecification,
|
|
35
|
-
DomainForbiddenError: () => DomainForbiddenError,
|
|
36
|
-
DomainValidationError: () => DomainValidationError,
|
|
37
|
-
IAttachmentRepository: () => IAttachmentRepository,
|
|
38
|
-
IItemRepository: () => IItemRepository,
|
|
39
|
-
IUnitOfWork: () => IUnitOfWork,
|
|
40
|
-
MergeSpecification: () => MergeSpecification,
|
|
41
|
-
OrSpecification: () => OrSpecification
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(src_exports);
|
|
44
|
-
|
|
45
|
-
// packages/shared/models/src/lib/symbols.ts
|
|
46
|
-
var SYMBOL_MODEL = Symbol.for("smartsoft:model");
|
|
47
|
-
var SYMBOL_FIELD = Symbol.for("smartsoft:field");
|
|
48
|
-
|
|
49
|
-
// packages/shared/models/src/lib/decorators/model/model.decorator.ts
|
|
50
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
51
|
-
|
|
52
|
-
// packages/shared/models/src/lib/decorators/field/field.decorator.ts
|
|
53
|
-
var import_reflect_metadata2 = require("reflect-metadata");
|
|
54
|
-
|
|
55
|
-
// packages/shared/utils/src/lib/services/password/password.service.ts
|
|
56
|
-
var md5_ = __toESM(require("md5"));
|
|
57
|
-
|
|
58
|
-
// packages/shared/utils/src/lib/services/object/object.service.ts
|
|
59
|
-
var import_flatted = require("flatted");
|
|
60
|
-
|
|
61
|
-
// packages/shared/utils/src/lib/services/guid/guid.service.ts
|
|
62
|
-
var import_guid_typescript = require("guid-typescript");
|
|
63
|
-
|
|
64
|
-
// packages/shared/utils/src/lib/services/array/array.service.ts
|
|
65
|
-
var _ = __toESM(require("lodash"));
|
|
66
|
-
|
|
67
|
-
// packages/shared/domain-core/src/lib/errors.ts
|
|
68
|
-
var DomainValidationError = class _DomainValidationError extends Error {
|
|
69
|
-
constructor(msg) {
|
|
70
|
-
super(msg);
|
|
71
|
-
this.type = _DomainValidationError;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var DomainForbiddenError = class _DomainForbiddenError extends Error {
|
|
75
|
-
constructor(msg) {
|
|
76
|
-
super(msg);
|
|
77
|
-
this.type = _DomainForbiddenError;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// packages/shared/domain-core/src/lib/repositories.ts
|
|
82
|
-
var IUnitOfWork = class {
|
|
83
|
-
};
|
|
84
|
-
var IItemRepository = class {
|
|
85
|
-
};
|
|
86
|
-
var IAttachmentRepository = class {
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// packages/shared/domain-core/src/lib/specifications.ts
|
|
90
|
-
var BasicSpecification = class {
|
|
91
|
-
/**
|
|
92
|
-
* Creates an instance of BasicSpecification.
|
|
93
|
-
*
|
|
94
|
-
* @param {any} criteria - The criteria used to filter entities.
|
|
95
|
-
*/
|
|
96
|
-
constructor(criteria) {
|
|
97
|
-
this.criteria = criteria;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
var MergeSpecification = class extends BasicSpecification {
|
|
101
|
-
/**
|
|
102
|
-
* Creates an instance of MergeSpecification.
|
|
103
|
-
*
|
|
104
|
-
* @param {...ISpecification[]} specs - An array of specifications to be merged.
|
|
105
|
-
*/
|
|
106
|
-
constructor(...specs) {
|
|
107
|
-
let criteria = {};
|
|
108
|
-
specs.forEach((spec) => {
|
|
109
|
-
criteria = {
|
|
110
|
-
...criteria,
|
|
111
|
-
...spec.criteria
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
super(criteria);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
var OrSpecification = class extends BasicSpecification {
|
|
118
|
-
/**
|
|
119
|
-
* Creates an instance of OrSpecification.
|
|
120
|
-
*
|
|
121
|
-
* @param {...ISpecification[]} spec - An array of specifications to be combined using a logical OR.
|
|
122
|
-
*/
|
|
123
|
-
constructor(...spec) {
|
|
124
|
-
super({
|
|
125
|
-
$or: spec.map((c) => c.criteria)
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var AndSpecification = class extends BasicSpecification {
|
|
130
|
-
/**
|
|
131
|
-
* Creates an instance of AndSpecification.
|
|
132
|
-
*
|
|
133
|
-
* @param {...ISpecification[]} spec - An array of specifications to be combined using a logical AND.
|
|
134
|
-
*/
|
|
135
|
-
constructor(...spec) {
|
|
136
|
-
super({
|
|
137
|
-
$and: spec.map((c) => c.criteria)
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
-
0 && (module.exports = {
|
|
143
|
-
AndSpecification,
|
|
144
|
-
BasicSpecification,
|
|
145
|
-
DomainForbiddenError,
|
|
146
|
-
DomainValidationError,
|
|
147
|
-
IAttachmentRepository,
|
|
148
|
-
IItemRepository,
|
|
149
|
-
IUnitOfWork,
|
|
150
|
-
MergeSpecification,
|
|
151
|
-
OrSpecification
|
|
152
|
-
});
|