@smartsoft001/domain-core 2.30.0 → 2.39.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/.eslintrc.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": ["../../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
+ "rules": {}
8
+ },
9
+ {
10
+ "files": ["*.ts", "*.tsx"],
11
+ "rules": {}
12
+ },
13
+ {
14
+ "files": ["*.js", "*.jsx"],
15
+ "rules": {}
16
+ },
17
+ {
18
+ "files": ["*.json"],
19
+ "parser": "jsonc-eslint-parser",
20
+ "rules": {
21
+ "@nx/dependency-checks": [
22
+ "error",
23
+ {
24
+ "ignoredFiles": ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"]
25
+ }
26
+ ]
27
+ }
28
+ }
29
+ ]
30
+ }
package/jest.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ displayName: 'domain-core',
4
+ preset: '../../../jest.preset.js',
5
+ testEnvironment: 'node',
6
+ transform: {
7
+ '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8
+ },
9
+ moduleFileExtensions: ['ts', 'js', 'html'],
10
+ coverageDirectory: '../../../coverage/packages/shared/domain-core',
11
+ };
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@smartsoft001/domain-core",
3
- "version": "2.30.0",
3
+ "type": "commonjs",
4
4
  "dependencies": {
5
- "tslib": "^2.3.0",
6
- "@smartsoft001/models": "2.30.0",
7
5
  "rxjs": "^7.8.1",
8
- "@smartsoft001/users": "2.30.0"
6
+ "@smartsoft001/models": "^2.39.0",
7
+ "@smartsoft001/users": "^2.39.0"
9
8
  },
10
- "type": "commonjs",
9
+ "version": "2.39.0",
11
10
  "main": "./src/index.js",
12
- "typings": "./src/index.d.ts",
13
- "types": "./src/index.d.ts"
14
- }
11
+ "typings": "./src/index.d.ts"
12
+ }
package/project.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "domain-core",
3
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/shared/domain-core/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "build": {
9
+ "executor": "@nx/esbuild:esbuild",
10
+ "outputs": ["{options.outputPath}"],
11
+ "options": {
12
+ "outputPath": "dist/packages/shared/domain-core",
13
+ "main": "packages/shared/domain-core/src/index.ts",
14
+ "tsConfig": "packages/shared/domain-core/tsconfig.lib.json",
15
+ "assets": ["packages/shared/domain-core/*.md"],
16
+ "generatePackageJson": true,
17
+ "format": ["cjs"]
18
+ }
19
+ },
20
+ "deploy": {
21
+ "executor": "ngx-deploy-npm:deploy",
22
+ "options": {
23
+ "access": "public",
24
+ "distFolderPath": "dist/packages/shared/domain-core"
25
+ },
26
+ "dependsOn": ["build"]
27
+ },
28
+ "lint": {
29
+ "executor": "@nx/eslint:lint"
30
+ },
31
+ "test": {
32
+ "executor": "@nx/jest:jest",
33
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
34
+ "options": {
35
+ "jestConfig": "packages/shared/domain-core/jest.config.ts"
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,15 @@
1
+ export class DomainValidationError extends Error {
2
+ type = DomainValidationError;
3
+
4
+ constructor(msg: string) {
5
+ super(msg);
6
+ }
7
+ }
8
+
9
+ export class DomainForbiddenError extends Error {
10
+ type = DomainForbiddenError;
11
+
12
+ constructor(msg: string) {
13
+ super(msg);
14
+ }
15
+ }
@@ -1,6 +1,13 @@
1
+ /*
2
+ * Interface for entities
3
+ */
1
4
  export interface IEntity<T> {
2
5
  id: T;
3
6
  }
7
+
8
+ /*
9
+ * Address interface
10
+ */
4
11
  export interface IAddress {
5
12
  city: string;
6
13
  street: string;
@@ -8,11 +15,26 @@ export interface IAddress {
8
15
  flatNumber?: string;
9
16
  zipCode: string;
10
17
  }
18
+
19
+ /*
20
+ * Date range interface
21
+ */
11
22
  export interface IDateRange {
23
+ /*
24
+ * YYYY-MM-DD
25
+ */
12
26
  start: `${string}-${string}-${string}`;
27
+ /*
28
+ * YYYY-MM-DD
29
+ */
13
30
  end: `${string}-${string}-${string}`;
14
31
  }
32
+
33
+ /*
34
+ * Factory interface
35
+ */
15
36
  export interface IFactory<T, TConfig> {
16
37
  create(config: NonNullable<TConfig>): Promise<T>;
17
38
  }
39
+
18
40
  export { ISpecification } from "@smartsoft001/models";
@@ -0,0 +1,339 @@
1
+ import { Observable } from "rxjs";
2
+
3
+ import { IUser } from "@smartsoft001/users";
4
+
5
+ import { IEntity, ISpecification } from "./interfaces";
6
+
7
+ /**
8
+ * ITransaction defines the structure of a transaction context that can be used to
9
+ * perform a series of database operations as a single atomic unit of work.
10
+ *
11
+ * @interface ITransaction
12
+ */
13
+ export interface ITransaction {
14
+ /**
15
+ * The connection object that provides access to the database.
16
+ *
17
+ * This property typically represents the active database connection that is used
18
+ * to execute operations within the transaction. The exact type of the connection
19
+ * may vary depending on the database being used (e.g., MongoDB, SQL, etc.).
20
+ *
21
+ * @type {any}
22
+ */
23
+ connection: any;
24
+ }
25
+
26
+ /**
27
+ * IUnitOfWork is an abstract class that defines the contract for managing transactional operations
28
+ * across multiple repositories or services. This pattern ensures that a set of operations either
29
+ * all succeed or all fail, maintaining data consistency.
30
+ *
31
+ * @interface IUnitOfWork
32
+ */
33
+ export abstract class IUnitOfWork {
34
+ /**
35
+ * Executes a set of operations within a transactional scope.
36
+ *
37
+ * @param {function(ITransaction): Promise<void>} definition - A function that contains the operations to be executed within the transaction.
38
+ * The function receives an `ITransaction` object that provides the necessary context for the transaction.
39
+ *
40
+ * @returns {Promise<void>} - A promise that resolves when the transactional operations are completed successfully.
41
+ *
42
+ * @throws {Error} - Throws an error if the transaction fails, in which case all operations are rolled back.
43
+ *
44
+ * @example
45
+ * await this.unitOfWork.scope(async (tx) => {
46
+ * await this.itemRepository.updatePartial(
47
+ * {
48
+ * id: id1,
49
+ * status: "finished",
50
+ * },
51
+ * user,
52
+ * { transaction: tx }
53
+ * );
54
+ *
55
+ * await this.itemRepository.updatePartial(
56
+ * {
57
+ * id: id2,
58
+ * status: "finished",
59
+ * },
60
+ * user,
61
+ * { transaction: tx }
62
+ * );
63
+ * });
64
+ */
65
+ abstract scope(definition: (transaction: ITransaction) => Promise<void>): Promise<void>;
66
+ }
67
+
68
+ /**
69
+ *
70
+ * @interface IItemRepositoryOptions
71
+ */
72
+ export interface IItemRepositoryOptions {
73
+ transaction: ITransaction;
74
+ }
75
+
76
+ /**
77
+ * IItemRepository is an abstract class that defines the contract for a repository
78
+ * responsible for managing entities of type `T` in a storage system. This repository
79
+ * interface provides a set of methods for creating, updating, deleting, and querying
80
+ * entities, with support for transactional operations and various query criteria.
81
+ *
82
+ * @template T - The type of entity that this repository will manage. The entity should extend `IEntity<string>`.
83
+ *
84
+ * @interface IItemRepository
85
+ */
86
+ export abstract class IItemRepository<T extends IEntity<string>> {
87
+ /**
88
+ * Creates a new entity in the storage system.
89
+ *
90
+ * @param {T} item - The entity to be created.
91
+ * @param {IUser} user - The user performing the operation.
92
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
93
+ *
94
+ * @returns {Promise<void>} - A promise that resolves when the entity is successfully created.
95
+ */
96
+ abstract create(item: T, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
97
+
98
+ /**
99
+ * Creates multiple entities in the storage system.
100
+ *
101
+ * @param {T[]} list - The list of entities to be created.
102
+ * @param {IUser} user - The user performing the operation.
103
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
104
+ *
105
+ * @returns {Promise<void>} - A promise that resolves when all entities are successfully created.
106
+ */
107
+ abstract createMany(list: T[], user: IUser, options?: IItemRepositoryOptions): Promise<void>;
108
+
109
+ /**
110
+ * Updates an existing entity in the storage system.
111
+ *
112
+ * @param {T} item - The entity to be updated.
113
+ * @param {IUser} user - The user performing the operation.
114
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
115
+ *
116
+ * @returns {Promise<void>} - A promise that resolves when the entity is successfully updated.
117
+ */
118
+ abstract update(item: T, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
119
+
120
+ /**
121
+ * Partially updates an existing entity in the storage system.
122
+ *
123
+ * @param {Partial<T> & { id: string }} item - The partial entity data to be updated along with the entity's ID.
124
+ * @param {IUser} user - The user performing the operation.
125
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
126
+ *
127
+ * @returns {Promise<void>} - A promise that resolves when the entity is successfully updated.
128
+ */
129
+ abstract updatePartial(
130
+ item: Partial<T> & { id: string },
131
+ user: IUser
132
+ , options?: IItemRepositoryOptions
133
+ ): Promise<void>;
134
+
135
+ /**
136
+ * Partially updates multiple entities that match the specified criteria.
137
+ *
138
+ * @param {any} criteria - The criteria used to select the entities to be updated.
139
+ * @param {Partial<T>} set - The partial data to be set on the matching entities.
140
+ * @param {IUser} user - The user performing the operation.
141
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
142
+ *
143
+ * @returns {Promise<void>} - A promise that resolves when the entities are successfully updated.
144
+ */
145
+ abstract updatePartialManyByCriteria(
146
+ criteria: any,
147
+ set: Partial<T>,
148
+ user: IUser, options?: IItemRepositoryOptions
149
+ ): Promise<void>;
150
+
151
+ /**
152
+ * Partially updates multiple entities that match the specified specification.
153
+ *
154
+ * @param {ISpecification} spec - The specification used to select the entities to be updated.
155
+ * @param {Partial<T>} set - The partial data to be set on the matching entities.
156
+ * @param {IUser} user - The user performing the operation.
157
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
158
+ *
159
+ * @returns {Promise<void>} - A promise that resolves when the entities are successfully updated.
160
+ */
161
+ abstract updatePartialManyBySpecification(
162
+ spec: ISpecification,
163
+ set: Partial<T>,
164
+ user: IUser, options?: IItemRepositoryOptions
165
+ ): Promise<void>;
166
+
167
+ /**
168
+ * Deletes an entity from the storage system by its ID.
169
+ *
170
+ * @param {string} id - The ID of the entity to be deleted.
171
+ * @param {IUser} user - The user performing the operation.
172
+ * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
173
+ *
174
+ * @returns {Promise<void>} - A promise that resolves when the entity is successfully deleted.
175
+ */
176
+ abstract delete(id: string, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
177
+
178
+ /**
179
+ * Retrieves an entity from the storage system by its ID.
180
+ *
181
+ * @param {string} id - The ID of the entity to be retrieved.
182
+ * @param {IItemRepositoryOptions} [repoOptions] - Optional parameters for the operation, including transaction context.
183
+ *
184
+ * @returns {Promise<T>} - A promise that resolves to the retrieved entity.
185
+ */
186
+ abstract getById(id: string, repoOptions?: IItemRepositoryOptions): Promise<T>;
187
+
188
+ /**
189
+ * Retrieves entities from the storage system that match the specified criteria.
190
+ *
191
+ * @param {any} criteria - The criteria used to select the entities.
192
+ * @param {any} [options] - Optional parameters for the operation, such as pagination or sorting.
193
+ *
194
+ * @returns {Promise<{ data: T[]; totalCount: number }>} - A promise that resolves to an object containing the matching entities and the total count.
195
+ */
196
+ abstract getByCriteria(
197
+ criteria: any,
198
+ options?: any
199
+ ): Promise<{ data: T[]; totalCount: number }>;
200
+
201
+ /**
202
+ * Retrieves entities from the storage system that match the specified specification.
203
+ *
204
+ * @param {ISpecification} spec - The specification used to select the entities.
205
+ * @param {any} [options] - Optional parameters for the operation, such as pagination or sorting.
206
+ *
207
+ * @returns {Promise<{ data: T[]; totalCount: number }>} - A promise that resolves to an object containing the matching entities and the total count.
208
+ */
209
+ abstract getBySpecification(
210
+ spec: ISpecification,
211
+ options?: any
212
+ ): Promise<{ data: T[]; totalCount: number }>;
213
+
214
+ /**
215
+ * Counts the number of entities in the storage system that match the specified criteria.
216
+ *
217
+ * @param {any} criteria - The criteria used to count the entities.
218
+ *
219
+ * @returns {Promise<number>} - A promise that resolves to the count of matching entities.
220
+ */
221
+ abstract countByCriteria(criteria: any): Promise<number>;
222
+
223
+ /**
224
+ * Counts the number of entities in the storage system that match the specified specification.
225
+ *
226
+ * @param {ISpecification} spec - The specification used to count the entities.
227
+ *
228
+ * @returns {Promise<number>} - A promise that resolves to the count of matching entities.
229
+ */
230
+ abstract countBySpecification(spec: ISpecification): Promise<number>;
231
+
232
+ /**
233
+ * Clears all entities from the storage system.
234
+ *
235
+ * @param user
236
+ *
237
+ * @returns {Promise<void>} - A promise that resolves when the storage system is cleared.
238
+ */
239
+ abstract clear(user: IUser | IItemRepositoryOptions): Promise<void>;
240
+
241
+ /**
242
+ * Returns an observable that emits changes to entities that match the specified criteria.
243
+ *
244
+ * @param {any} criteria - The criteria used to select the entities to observe.
245
+ *
246
+ * @returns {Observable<any>} - An observable that emits changes to the matching entities.
247
+ */
248
+ abstract changesByCriteria(criteria: { id?: string }): Observable<any>;
249
+ }
250
+
251
+ /**
252
+ * IAttachmentRepository is an abstract class that defines the contract for managing file attachments
253
+ * in a storage system. This interface can be implemented to work with various storage backends, such as
254
+ * MongoDB GridFS, Amazon S3, Google Cloud Storage, or any other file storage solution.
255
+ *
256
+ * @template T - The type of the entity that this repository will manage. The entity should extend `IEntity<string>`.
257
+ *
258
+ * @interface IAttachmentRepository
259
+ */
260
+ export abstract class IAttachmentRepository<T extends IEntity<string>> {
261
+ /**
262
+ * Uploads a file to the storage system.
263
+ *
264
+ * @param {Object} data - The data required to upload the file.
265
+ * @param {string} data.id - A unique identifier for the file.
266
+ * @param {string} data.fileName - The name of the file to be uploaded.
267
+ * @param {Stream} data.stream - The stream of the file to be uploaded.
268
+ * @param {string} data.mimeType - The MIME type of the file.
269
+ * @param {string} data.encoding - The encoding of the file.
270
+ *
271
+ * @param {Object} [options] - Optional parameters for the upload.
272
+ * @param {Function} [options.streamCallback] - A callback function that gets invoked with the upload stream.
273
+ *
274
+ * @returns {Promise<void>} - A promise that resolves when the upload is complete.
275
+ *
276
+ * @throws {Error} - Throws an error if the upload fails.
277
+ *
278
+ * @example
279
+ * // Example usage with MongoDB implementation:
280
+ * const repository = new MongoAttachmentRepository(config);
281
+ *
282
+ * const fileStream = fs.createReadStream('/path/to/file');
283
+ *
284
+ * await repository.upload({
285
+ * id: 'unique-file-id',
286
+ * fileName: 'example.txt',
287
+ * stream: fileStream,
288
+ * mimeType: 'text/plain',
289
+ * encoding: 'utf-8'
290
+ * }, {
291
+ * streamCallback: (writeStream) => {
292
+ * console.log('Upload started');
293
+ * }
294
+ * });
295
+ *
296
+ * console.log('File uploaded successfully');
297
+ */
298
+ abstract upload(
299
+ data: { id: string, fileName: string; stream: any; mimeType: string; encoding: string },
300
+ options?: { streamCallback?: (r: any) => void }
301
+ ): Promise<void>;
302
+
303
+ /**
304
+ * Retrieves metadata information about a file stored in the storage system.
305
+ *
306
+ * @param {string} id - The unique identifier of the file.
307
+ *
308
+ * @returns {Promise<{ fileName: string, contentType: string, length: number } | null>}
309
+ * - A promise that resolves to an object containing file metadata, or `null` if the file is not found.
310
+ *
311
+ * @throws {Error} - Throws an error if retrieving the file information fails.
312
+ */
313
+ abstract getInfo(id: string): Promise<{ fileName: string, contentType: string, length: number }>;
314
+
315
+ /**
316
+ * Retrieves a stream for downloading a file from the storage system.
317
+ *
318
+ * @param {string} id - The unique identifier of the file.
319
+ * @param {Object} [options] - Optional parameters for retrieving a specific range of the file.
320
+ * @param {number} [options.start] - The starting byte position for the stream.
321
+ * @param {number} [options.end] - The ending byte position for the stream.
322
+ *
323
+ * @returns {Promise<any>} - A promise that resolves to a readable stream of the file.
324
+ *
325
+ * @throws {Error} - Throws an error if retrieving the file stream fails.
326
+ */
327
+ abstract getStream(id: string, options?: { start: number; end: number }): Promise<any>;
328
+
329
+ /**
330
+ * Deletes a file from the storage system.
331
+ *
332
+ * @param {string} id - The unique identifier of the file to be deleted.
333
+ *
334
+ * @returns {Promise<void>} - A promise that resolves when the file has been successfully deleted.
335
+ *
336
+ * @throws {Error} - Throws an error if the deletion fails.
337
+ */
338
+ abstract delete(id: string): Promise<void>;
339
+ }
@@ -0,0 +1,69 @@
1
+ import { BasicSpecification, MergeSpecification, OrSpecification, AndSpecification } from './specifications';
2
+ import { ISpecification } from './interfaces';
3
+
4
+ describe('shared-domain-core: BasicSpecification', () => {
5
+ it('should create a BasicSpecification with the given criteria', () => {
6
+ const criteria = { key: 'value' };
7
+
8
+ const spec = new BasicSpecification(criteria);
9
+
10
+ expect(spec.criteria).toEqual(criteria);
11
+ });
12
+ });
13
+
14
+ describe('shared-domain-core: MergeSpecification', () => {
15
+ it('should merge multiple specifications into one', () => {
16
+ const spec1: ISpecification = { criteria: { key1: 'value1' } };
17
+ const spec2: ISpecification = { criteria: { key2: 'value2' } };
18
+
19
+ const spec = new MergeSpecification(spec1, spec2);
20
+
21
+ expect(spec.criteria).toEqual({
22
+ key1: 'value1',
23
+ key2: 'value2'
24
+ });
25
+ });
26
+
27
+ it('should override criteria with the same key', () => {
28
+ const spec1: ISpecification = { criteria: { key: 'value1' } };
29
+ const spec2: ISpecification = { criteria: { key: 'value2' } };
30
+
31
+ const spec = new MergeSpecification(spec1, spec2);
32
+
33
+ expect(spec.criteria).toEqual({
34
+ key: 'value2'
35
+ });
36
+ });
37
+ });
38
+
39
+ describe('shared-domain-core: OrSpecification', () => {
40
+ it('should combine multiple specifications using logical OR', () => {
41
+ const spec1: ISpecification = { criteria: { key1: 'value1' } };
42
+ const spec2: ISpecification = { criteria: { key2: 'value2' } };
43
+
44
+ const spec = new OrSpecification(spec1, spec2);
45
+
46
+ expect(spec.criteria).toEqual({
47
+ $or: [
48
+ { key1: 'value1' },
49
+ { key2: 'value2' }
50
+ ]
51
+ });
52
+ });
53
+ });
54
+
55
+ describe('shared-domain-core: AndSpecification', () => {
56
+ it('should combine multiple specifications using logical AND', () => {
57
+ const spec1: ISpecification = { criteria: { key1: 'value1' } };
58
+ const spec2: ISpecification = { criteria: { key2: 'value2' } };
59
+
60
+ const spec = new AndSpecification(spec1, spec2);
61
+
62
+ expect(spec.criteria).toEqual({
63
+ $and: [
64
+ { key1: 'value1' },
65
+ { key2: 'value2' }
66
+ ]
67
+ });
68
+ });
69
+ });
@@ -1,6 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AndSpecification = exports.OrSpecification = exports.MergeSpecification = exports.BasicSpecification = void 0;
1
+ import {ISpecification} from "./interfaces";
2
+
4
3
  /**
5
4
  * BasicSpecification is a class that implements the `ISpecification` interface and serves as a base
6
5
  * class for defining basic query criteria. It holds a single set of criteria that can be used to
@@ -12,17 +11,16 @@ exports.AndSpecification = exports.OrSpecification = exports.MergeSpecification
12
11
  * @class BasicSpecification
13
12
  * @implements {ISpecification}
14
13
  */
15
- class BasicSpecification {
14
+ export class BasicSpecification implements ISpecification {
15
+
16
16
  /**
17
17
  * Creates an instance of BasicSpecification.
18
18
  *
19
19
  * @param {any} criteria - The criteria used to filter entities.
20
20
  */
21
- constructor(criteria) {
22
- this.criteria = criteria;
23
- }
21
+ constructor(public readonly criteria: any) { }
24
22
  }
25
- exports.BasicSpecification = BasicSpecification;
23
+
26
24
  /**
27
25
  * MergeSpecification is a class that extends `BasicSpecification` and allows for the merging of multiple
28
26
  * specifications into a single specification. The resulting specification combines the criteria of all provided
@@ -33,21 +31,27 @@ exports.BasicSpecification = BasicSpecification;
33
31
  * @class MergeSpecification
34
32
  * @extends {BasicSpecification}
35
33
  */
36
- class MergeSpecification extends BasicSpecification {
34
+ export class MergeSpecification extends BasicSpecification {
35
+
37
36
  /**
38
37
  * Creates an instance of MergeSpecification.
39
38
  *
40
39
  * @param {...ISpecification[]} specs - An array of specifications to be merged.
41
40
  */
42
- constructor(...specs) {
41
+ constructor(...specs: Array<ISpecification>) {
43
42
  let criteria = {};
43
+
44
44
  specs.forEach(spec => {
45
- criteria = Object.assign(Object.assign({}, criteria), spec.criteria);
45
+ criteria = {
46
+ ...criteria,
47
+ ...spec.criteria
48
+ }
46
49
  });
50
+
47
51
  super(criteria);
48
52
  }
49
53
  }
50
- exports.MergeSpecification = MergeSpecification;
54
+
51
55
  /**
52
56
  * OrSpecification is a class that extends `BasicSpecification` and allows for the combination of
53
57
  * multiple specifications using a logical OR operation. The resulting specification matches entities that satisfy
@@ -59,19 +63,20 @@ exports.MergeSpecification = MergeSpecification;
59
63
  * @class OrSpecification
60
64
  * @extends {BasicSpecification}
61
65
  */
62
- class OrSpecification extends BasicSpecification {
66
+ export class OrSpecification extends BasicSpecification {
67
+
63
68
  /**
64
69
  * Creates an instance of OrSpecification.
65
70
  *
66
71
  * @param {...ISpecification[]} spec - An array of specifications to be combined using a logical OR.
67
72
  */
68
- constructor(...spec) {
73
+ constructor(...spec: Array<ISpecification>) {
69
74
  super({
70
75
  $or: spec.map(c => c.criteria)
71
76
  });
72
77
  }
73
78
  }
74
- exports.OrSpecification = OrSpecification;
79
+
75
80
  /**
76
81
  * AndSpecification is a class that extends `BasicSpecification` and allows for the combination of
77
82
  * multiple specifications using a logical AND operation. The resulting specification matches entities that satisfy
@@ -83,17 +88,16 @@ exports.OrSpecification = OrSpecification;
83
88
  * @class AndSpecification
84
89
  * @extends {BasicSpecification}
85
90
  */
86
- class AndSpecification extends BasicSpecification {
91
+ export class AndSpecification extends BasicSpecification {
92
+
87
93
  /**
88
94
  * Creates an instance of AndSpecification.
89
95
  *
90
96
  * @param {...ISpecification[]} spec - An array of specifications to be combined using a logical AND.
91
97
  */
92
- constructor(...spec) {
98
+ constructor(...spec: Array<ISpecification>) {
93
99
  super({
94
100
  $and: spec.map(c => c.criteria)
95
101
  });
96
102
  }
97
103
  }
98
- exports.AndSpecification = AndSpecification;
99
- //# sourceMappingURL=specifications.js.map
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "forceConsistentCasingInFileNames": true,
6
+ "strict": true,
7
+ "noImplicitOverride": true,
8
+ "noPropertyAccessFromIndexSignature": true,
9
+ "noImplicitReturns": true,
10
+ "noFallthroughCasesInSwitch": true
11
+ },
12
+ "files": [],
13
+ "include": [],
14
+ "references": [
15
+ {
16
+ "path": "./tsconfig.lib.json"
17
+ },
18
+ {
19
+ "path": "./tsconfig.spec.json"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"]
7
+ },
8
+ "include": ["src/**/*.ts"],
9
+ "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"]
7
+ },
8
+ "include": [
9
+ "jest.config.ts",
10
+ "src/**/*.test.ts",
11
+ "src/**/*.spec.ts",
12
+ "src/**/*.d.ts"
13
+ ]
14
+ }
package/src/index.js DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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"}
@@ -1,8 +0,0 @@
1
- export declare class DomainValidationError extends Error {
2
- type: typeof DomainValidationError;
3
- constructor(msg: string);
4
- }
5
- export declare class DomainForbiddenError extends Error {
6
- type: typeof DomainForbiddenError;
7
- constructor(msg: string);
8
- }
package/src/lib/errors.js DELETED
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAG5C,YAAY,GAAW;QACnB,KAAK,CAAC,GAAG,CAAC,CAAC;QAHf,SAAI,GAAG,qBAAqB,CAAC;IAI7B,CAAC;CACJ;AAND,sDAMC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAG3C,YAAY,GAAW;QACnB,KAAK,CAAC,GAAG,CAAC,CAAC;QAHf,SAAI,GAAG,oBAAoB,CAAC;IAI5B,CAAC;CACJ;AAND,oDAMC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/interfaces.ts"],"names":[],"mappings":""}
@@ -1,320 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { IUser } from "@smartsoft001/users";
3
- import { IEntity, ISpecification } from "./interfaces";
4
- /**
5
- * ITransaction defines the structure of a transaction context that can be used to
6
- * perform a series of database operations as a single atomic unit of work.
7
- *
8
- * @interface ITransaction
9
- */
10
- export interface ITransaction {
11
- /**
12
- * The connection object that provides access to the database.
13
- *
14
- * This property typically represents the active database connection that is used
15
- * to execute operations within the transaction. The exact type of the connection
16
- * may vary depending on the database being used (e.g., MongoDB, SQL, etc.).
17
- *
18
- * @type {any}
19
- */
20
- connection: any;
21
- }
22
- /**
23
- * IUnitOfWork is an abstract class that defines the contract for managing transactional operations
24
- * across multiple repositories or services. This pattern ensures that a set of operations either
25
- * all succeed or all fail, maintaining data consistency.
26
- *
27
- * @interface IUnitOfWork
28
- */
29
- export declare abstract class IUnitOfWork {
30
- /**
31
- * Executes a set of operations within a transactional scope.
32
- *
33
- * @param {function(ITransaction): Promise<void>} definition - A function that contains the operations to be executed within the transaction.
34
- * The function receives an `ITransaction` object that provides the necessary context for the transaction.
35
- *
36
- * @returns {Promise<void>} - A promise that resolves when the transactional operations are completed successfully.
37
- *
38
- * @throws {Error} - Throws an error if the transaction fails, in which case all operations are rolled back.
39
- *
40
- * @example
41
- * await this.unitOfWork.scope(async (tx) => {
42
- * await this.itemRepository.updatePartial(
43
- * {
44
- * id: id1,
45
- * status: "finished",
46
- * },
47
- * user,
48
- * { transaction: tx }
49
- * );
50
- *
51
- * await this.itemRepository.updatePartial(
52
- * {
53
- * id: id2,
54
- * status: "finished",
55
- * },
56
- * user,
57
- * { transaction: tx }
58
- * );
59
- * });
60
- */
61
- abstract scope(definition: (transaction: ITransaction) => Promise<void>): Promise<void>;
62
- }
63
- /**
64
- *
65
- * @interface IItemRepositoryOptions
66
- */
67
- export interface IItemRepositoryOptions {
68
- transaction: ITransaction;
69
- }
70
- /**
71
- * IItemRepository is an abstract class that defines the contract for a repository
72
- * responsible for managing entities of type `T` in a storage system. This repository
73
- * interface provides a set of methods for creating, updating, deleting, and querying
74
- * entities, with support for transactional operations and various query criteria.
75
- *
76
- * @template T - The type of entity that this repository will manage. The entity should extend `IEntity<string>`.
77
- *
78
- * @interface IItemRepository
79
- */
80
- export declare abstract class IItemRepository<T extends IEntity<string>> {
81
- /**
82
- * Creates a new entity in the storage system.
83
- *
84
- * @param {T} item - The entity to be created.
85
- * @param {IUser} user - The user performing the operation.
86
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
87
- *
88
- * @returns {Promise<void>} - A promise that resolves when the entity is successfully created.
89
- */
90
- abstract create(item: T, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
91
- /**
92
- * Creates multiple entities in the storage system.
93
- *
94
- * @param {T[]} list - The list of entities to be created.
95
- * @param {IUser} user - The user performing the operation.
96
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
97
- *
98
- * @returns {Promise<void>} - A promise that resolves when all entities are successfully created.
99
- */
100
- abstract createMany(list: T[], user: IUser, options?: IItemRepositoryOptions): Promise<void>;
101
- /**
102
- * Updates an existing entity in the storage system.
103
- *
104
- * @param {T} item - The entity to be updated.
105
- * @param {IUser} user - The user performing the operation.
106
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
107
- *
108
- * @returns {Promise<void>} - A promise that resolves when the entity is successfully updated.
109
- */
110
- abstract update(item: T, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
111
- /**
112
- * Partially updates an existing entity in the storage system.
113
- *
114
- * @param {Partial<T> & { id: string }} item - The partial entity data to be updated along with the entity's ID.
115
- * @param {IUser} user - The user performing the operation.
116
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
117
- *
118
- * @returns {Promise<void>} - A promise that resolves when the entity is successfully updated.
119
- */
120
- abstract updatePartial(item: Partial<T> & {
121
- id: string;
122
- }, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
123
- /**
124
- * Partially updates multiple entities that match the specified criteria.
125
- *
126
- * @param {any} criteria - The criteria used to select the entities to be updated.
127
- * @param {Partial<T>} set - The partial data to be set on the matching entities.
128
- * @param {IUser} user - The user performing the operation.
129
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
130
- *
131
- * @returns {Promise<void>} - A promise that resolves when the entities are successfully updated.
132
- */
133
- abstract updatePartialManyByCriteria(criteria: any, set: Partial<T>, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
134
- /**
135
- * Partially updates multiple entities that match the specified specification.
136
- *
137
- * @param {ISpecification} spec - The specification used to select the entities to be updated.
138
- * @param {Partial<T>} set - The partial data to be set on the matching entities.
139
- * @param {IUser} user - The user performing the operation.
140
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
141
- *
142
- * @returns {Promise<void>} - A promise that resolves when the entities are successfully updated.
143
- */
144
- abstract updatePartialManyBySpecification(spec: ISpecification, set: Partial<T>, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
145
- /**
146
- * Deletes an entity from the storage system by its ID.
147
- *
148
- * @param {string} id - The ID of the entity to be deleted.
149
- * @param {IUser} user - The user performing the operation.
150
- * @param {IItemRepositoryOptions} [options] - Optional parameters for the operation, including transaction context.
151
- *
152
- * @returns {Promise<void>} - A promise that resolves when the entity is successfully deleted.
153
- */
154
- abstract delete(id: string, user: IUser, options?: IItemRepositoryOptions): Promise<void>;
155
- /**
156
- * Retrieves an entity from the storage system by its ID.
157
- *
158
- * @param {string} id - The ID of the entity to be retrieved.
159
- * @param {IItemRepositoryOptions} [repoOptions] - Optional parameters for the operation, including transaction context.
160
- *
161
- * @returns {Promise<T>} - A promise that resolves to the retrieved entity.
162
- */
163
- abstract getById(id: string, repoOptions?: IItemRepositoryOptions): Promise<T>;
164
- /**
165
- * Retrieves entities from the storage system that match the specified criteria.
166
- *
167
- * @param {any} criteria - The criteria used to select the entities.
168
- * @param {any} [options] - Optional parameters for the operation, such as pagination or sorting.
169
- *
170
- * @returns {Promise<{ data: T[]; totalCount: number }>} - A promise that resolves to an object containing the matching entities and the total count.
171
- */
172
- abstract getByCriteria(criteria: any, options?: any): Promise<{
173
- data: T[];
174
- totalCount: number;
175
- }>;
176
- /**
177
- * Retrieves entities from the storage system that match the specified specification.
178
- *
179
- * @param {ISpecification} spec - The specification used to select the entities.
180
- * @param {any} [options] - Optional parameters for the operation, such as pagination or sorting.
181
- *
182
- * @returns {Promise<{ data: T[]; totalCount: number }>} - A promise that resolves to an object containing the matching entities and the total count.
183
- */
184
- abstract getBySpecification(spec: ISpecification, options?: any): Promise<{
185
- data: T[];
186
- totalCount: number;
187
- }>;
188
- /**
189
- * Counts the number of entities in the storage system that match the specified criteria.
190
- *
191
- * @param {any} criteria - The criteria used to count the entities.
192
- *
193
- * @returns {Promise<number>} - A promise that resolves to the count of matching entities.
194
- */
195
- abstract countByCriteria(criteria: any): Promise<number>;
196
- /**
197
- * Counts the number of entities in the storage system that match the specified specification.
198
- *
199
- * @param {ISpecification} spec - The specification used to count the entities.
200
- *
201
- * @returns {Promise<number>} - A promise that resolves to the count of matching entities.
202
- */
203
- abstract countBySpecification(spec: ISpecification): Promise<number>;
204
- /**
205
- * Clears all entities from the storage system.
206
- *
207
- * @param user
208
- *
209
- * @returns {Promise<void>} - A promise that resolves when the storage system is cleared.
210
- */
211
- abstract clear(user: IUser | IItemRepositoryOptions): Promise<void>;
212
- /**
213
- * Returns an observable that emits changes to entities that match the specified criteria.
214
- *
215
- * @param {any} criteria - The criteria used to select the entities to observe.
216
- *
217
- * @returns {Observable<any>} - An observable that emits changes to the matching entities.
218
- */
219
- abstract changesByCriteria(criteria: {
220
- id?: string;
221
- }): Observable<any>;
222
- }
223
- /**
224
- * IAttachmentRepository is an abstract class that defines the contract for managing file attachments
225
- * in a storage system. This interface can be implemented to work with various storage backends, such as
226
- * MongoDB GridFS, Amazon S3, Google Cloud Storage, or any other file storage solution.
227
- *
228
- * @template T - The type of the entity that this repository will manage. The entity should extend `IEntity<string>`.
229
- *
230
- * @interface IAttachmentRepository
231
- */
232
- export declare abstract class IAttachmentRepository<T extends IEntity<string>> {
233
- /**
234
- * Uploads a file to the storage system.
235
- *
236
- * @param {Object} data - The data required to upload the file.
237
- * @param {string} data.id - A unique identifier for the file.
238
- * @param {string} data.fileName - The name of the file to be uploaded.
239
- * @param {Stream} data.stream - The stream of the file to be uploaded.
240
- * @param {string} data.mimeType - The MIME type of the file.
241
- * @param {string} data.encoding - The encoding of the file.
242
- *
243
- * @param {Object} [options] - Optional parameters for the upload.
244
- * @param {Function} [options.streamCallback] - A callback function that gets invoked with the upload stream.
245
- *
246
- * @returns {Promise<void>} - A promise that resolves when the upload is complete.
247
- *
248
- * @throws {Error} - Throws an error if the upload fails.
249
- *
250
- * @example
251
- * // Example usage with MongoDB implementation:
252
- * const repository = new MongoAttachmentRepository(config);
253
- *
254
- * const fileStream = fs.createReadStream('/path/to/file');
255
- *
256
- * await repository.upload({
257
- * id: 'unique-file-id',
258
- * fileName: 'example.txt',
259
- * stream: fileStream,
260
- * mimeType: 'text/plain',
261
- * encoding: 'utf-8'
262
- * }, {
263
- * streamCallback: (writeStream) => {
264
- * console.log('Upload started');
265
- * }
266
- * });
267
- *
268
- * console.log('File uploaded successfully');
269
- */
270
- abstract upload(data: {
271
- id: string;
272
- fileName: string;
273
- stream: any;
274
- mimeType: string;
275
- encoding: string;
276
- }, options?: {
277
- streamCallback?: (r: any) => void;
278
- }): Promise<void>;
279
- /**
280
- * Retrieves metadata information about a file stored in the storage system.
281
- *
282
- * @param {string} id - The unique identifier of the file.
283
- *
284
- * @returns {Promise<{ fileName: string, contentType: string, length: number } | null>}
285
- * - A promise that resolves to an object containing file metadata, or `null` if the file is not found.
286
- *
287
- * @throws {Error} - Throws an error if retrieving the file information fails.
288
- */
289
- abstract getInfo(id: string): Promise<{
290
- fileName: string;
291
- contentType: string;
292
- length: number;
293
- }>;
294
- /**
295
- * Retrieves a stream for downloading a file from the storage system.
296
- *
297
- * @param {string} id - The unique identifier of the file.
298
- * @param {Object} [options] - Optional parameters for retrieving a specific range of the file.
299
- * @param {number} [options.start] - The starting byte position for the stream.
300
- * @param {number} [options.end] - The ending byte position for the stream.
301
- *
302
- * @returns {Promise<any>} - A promise that resolves to a readable stream of the file.
303
- *
304
- * @throws {Error} - Throws an error if retrieving the file stream fails.
305
- */
306
- abstract getStream(id: string, options?: {
307
- start: number;
308
- end: number;
309
- }): Promise<any>;
310
- /**
311
- * Deletes a file from the storage system.
312
- *
313
- * @param {string} id - The unique identifier of the file to be deleted.
314
- *
315
- * @returns {Promise<void>} - A promise that resolves when the file has been successfully deleted.
316
- *
317
- * @throws {Error} - Throws an error if the deletion fails.
318
- */
319
- abstract delete(id: string): Promise<void>;
320
- }
@@ -1,39 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"repositories.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/repositories.ts"],"names":[],"mappings":";;;AAyBA;;;;;;GAMG;AACH,MAAsB,WAAW;CAiChC;AAjCD,kCAiCC;AAUD;;;;;;;;;GASG;AACH,MAAsB,eAAe;CAmKpC;AAnKD,0CAmKC;AAED;;;;;;;;GAQG;AACH,MAAsB,qBAAqB;CA+E1C;AA/ED,sDA+EC"}
@@ -1,77 +0,0 @@
1
- import { ISpecification } from "./interfaces";
2
- /**
3
- * BasicSpecification is a class that implements the `ISpecification` interface and serves as a base
4
- * class for defining basic query criteria. It holds a single set of criteria that can be used to
5
- * filter entities in a repository or database.
6
- *
7
- * This class can be extended to create more complex specifications by combining or modifying the
8
- * base criteria.
9
- *
10
- * @class BasicSpecification
11
- * @implements {ISpecification}
12
- */
13
- export declare class BasicSpecification implements ISpecification {
14
- readonly criteria: any;
15
- /**
16
- * Creates an instance of BasicSpecification.
17
- *
18
- * @param {any} criteria - The criteria used to filter entities.
19
- */
20
- constructor(criteria: any);
21
- }
22
- /**
23
- * MergeSpecification is a class that extends `BasicSpecification` and allows for the merging of multiple
24
- * specifications into a single specification. The resulting specification combines the criteria of all provided
25
- * specifications using a shallow merge.
26
- *
27
- * This class is useful when you need to apply multiple specifications to a query in a way that combines their criteria.
28
- *
29
- * @class MergeSpecification
30
- * @extends {BasicSpecification}
31
- */
32
- export declare class MergeSpecification extends BasicSpecification {
33
- /**
34
- * Creates an instance of MergeSpecification.
35
- *
36
- * @param {...ISpecification[]} specs - An array of specifications to be merged.
37
- */
38
- constructor(...specs: Array<ISpecification>);
39
- }
40
- /**
41
- * OrSpecification is a class that extends `BasicSpecification` and allows for the combination of
42
- * multiple specifications using a logical OR operation. The resulting specification matches entities that satisfy
43
- * at least one of the provided specifications.
44
- *
45
- * This class is useful when you need to apply multiple specifications to a query in a way that matches entities
46
- * that meet any of the specified criteria.
47
- *
48
- * @class OrSpecification
49
- * @extends {BasicSpecification}
50
- */
51
- export declare class OrSpecification extends BasicSpecification {
52
- /**
53
- * Creates an instance of OrSpecification.
54
- *
55
- * @param {...ISpecification[]} spec - An array of specifications to be combined using a logical OR.
56
- */
57
- constructor(...spec: Array<ISpecification>);
58
- }
59
- /**
60
- * AndSpecification is a class that extends `BasicSpecification` and allows for the combination of
61
- * multiple specifications using a logical AND operation. The resulting specification matches entities that satisfy
62
- * all the provided specifications.
63
- *
64
- * This class is useful when you need to apply multiple specifications to a query in a way that matches entities
65
- * that meet all the specified criteria.
66
- *
67
- * @class AndSpecification
68
- * @extends {BasicSpecification}
69
- */
70
- export declare class AndSpecification extends BasicSpecification {
71
- /**
72
- * Creates an instance of AndSpecification.
73
- *
74
- * @param {...ISpecification[]} spec - An array of specifications to be combined using a logical AND.
75
- */
76
- constructor(...spec: Array<ISpecification>);
77
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"specifications.js","sourceRoot":"","sources":["../../../../../../packages/shared/domain-core/src/lib/specifications.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,MAAa,kBAAkB;IAE3B;;;;OAIG;IACH,YAA4B,QAAa;QAAb,aAAQ,GAAR,QAAQ,CAAK;IAAI,CAAC;CACjD;AARD,gDAQC;AAED;;;;;;;;;GASG;AACH,MAAa,kBAAmB,SAAQ,kBAAkB;IAEtD;;;;OAIG;IACH,YAAY,GAAG,KAA4B;QACvC,IAAI,QAAQ,GAAG,EAAE,CAAC;QAElB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAClB,QAAQ,mCACD,QAAQ,GACR,IAAI,CAAC,QAAQ,CACnB,CAAA;QACJ,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;CACJ;AAnBD,gDAmBC;AAED;;;;;;;;;;GAUG;AACH,MAAa,eAAgB,SAAQ,kBAAkB;IAEnD;;;;OAIG;IACH,YAAY,GAAG,IAA2B;QACtC,KAAK,CAAC;YACF,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;SACjC,CAAC,CAAC;IACP,CAAC;CACJ;AAZD,0CAYC;AAED;;;;;;;;;;GAUG;AACH,MAAa,gBAAiB,SAAQ,kBAAkB;IAEpD;;;;OAIG;IACH,YAAY,GAAG,IAA2B;QACtC,KAAK,CAAC;YACF,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;SAClC,CAAC,CAAC;IACP,CAAC;CACJ;AAZD,4CAYC"}
File without changes