@node-c/core 1.0.0-alpha8 → 1.0.0-beta0
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/coverage/src/app.ts.html +349 -0
- package/coverage/src/common/configProvider/configProvider.module.ts.html +160 -0
- package/coverage/src/common/configProvider/configProvider.service.ts.html +658 -0
- package/coverage/src/common/configProvider/index.html +146 -0
- package/coverage/src/common/configProvider/index.ts.html +94 -0
- package/coverage/src/common/definitions/common.constants.ts.html +160 -0
- package/coverage/src/common/definitions/common.errors.ts.html +124 -0
- package/coverage/src/common/definitions/index.html +146 -0
- package/coverage/src/common/definitions/index.ts.html +94 -0
- package/coverage/src/common/utils/index.html +131 -0
- package/coverage/src/common/utils/index.ts.html +88 -0
- package/coverage/src/common/utils/utils.loadDynamicModules.ts.html +265 -0
- package/coverage/src/domain/entityService/domain.entity.service.ts.html +784 -0
- package/coverage/src/domain/entityService/index.html +131 -0
- package/coverage/src/domain/entityService/index.ts.html +91 -0
- package/coverage/src/index.html +116 -0
- package/coverage/src/persistance/entityService/index.html +131 -0
- package/coverage/src/persistance/entityService/index.ts.html +91 -0
- package/coverage/src/persistance/entityService/persistance.entity.service.ts.html +268 -0
- package/dist/app.d.ts +2 -2
- package/dist/app.js +27 -15
- package/dist/app.js.map +1 -1
- package/dist/common/configProvider/configProvider.definitions.d.ts +156 -20
- package/dist/common/configProvider/configProvider.definitions.js +21 -7
- package/dist/common/configProvider/configProvider.definitions.js.map +1 -1
- package/dist/common/configProvider/configProvider.module.js +13 -2
- package/dist/common/configProvider/configProvider.module.js.map +1 -1
- package/dist/common/configProvider/configProvider.service.js +21 -18
- package/dist/common/configProvider/configProvider.service.js.map +1 -1
- package/dist/common/definitions/common.constants.d.ts +2 -1
- package/dist/common/definitions/common.constants.js +1 -0
- package/dist/common/definitions/common.constants.js.map +1 -1
- package/dist/common/utils/base64UrlEncode/base64UrlEncode.method.d.ts +1 -0
- package/dist/common/utils/base64UrlEncode/base64UrlEncode.method.js +9 -0
- package/dist/common/utils/base64UrlEncode/base64UrlEncode.method.js.map +1 -0
- package/dist/common/utils/base64UrlEncode/index.d.ts +1 -0
- package/dist/{persistance/common/entityService → common/utils/base64UrlEncode}/index.js +1 -2
- package/dist/common/utils/base64UrlEncode/index.js.map +1 -0
- package/dist/common/utils/getNested/getNested.definitions.d.ts +4 -0
- package/dist/common/utils/getNested/getNested.definitions.js +3 -0
- package/dist/common/utils/getNested/getNested.definitions.js.map +1 -0
- package/dist/common/utils/getNested/getNested.method.d.ts +6 -0
- package/dist/common/utils/getNested/getNested.method.js +88 -0
- package/dist/common/utils/getNested/getNested.method.js.map +1 -0
- package/dist/common/utils/getNested/index.d.ts +2 -0
- package/dist/common/utils/getNested/index.js +19 -0
- package/dist/common/utils/getNested/index.js.map +1 -0
- package/dist/common/utils/httpRequest/httpRequest.definitions.d.ts +19 -0
- package/dist/common/utils/httpRequest/httpRequest.definitions.js +3 -0
- package/dist/common/utils/httpRequest/httpRequest.definitions.js.map +1 -0
- package/dist/common/utils/httpRequest/httpRequest.method.d.ts +2 -0
- package/dist/common/utils/httpRequest/httpRequest.method.js +56 -0
- package/dist/common/utils/httpRequest/httpRequest.method.js.map +1 -0
- package/dist/common/utils/httpRequest/index.d.ts +2 -0
- package/dist/common/utils/httpRequest/index.js +19 -0
- package/dist/common/utils/httpRequest/index.js.map +1 -0
- package/dist/common/utils/index.d.ts +5 -1
- package/dist/common/utils/index.js +5 -1
- package/dist/common/utils/index.js.map +1 -1
- package/dist/common/utils/loadDynamicModules/index.d.ts +1 -0
- package/dist/common/utils/loadDynamicModules/index.js +18 -0
- package/dist/common/utils/loadDynamicModules/index.js.map +1 -0
- package/dist/common/utils/{utils.loadDynamicModules.d.ts → loadDynamicModules/utils.loadDynamicModules.d.ts} +1 -1
- package/dist/common/utils/loadDynamicModules/utils.loadDynamicModules.js.map +1 -0
- package/dist/common/utils/setNested/index.d.ts +2 -0
- package/dist/common/utils/setNested/index.js +19 -0
- package/dist/common/utils/setNested/index.js.map +1 -0
- package/dist/common/utils/setNested/setNested.definitions.d.ts +4 -0
- package/dist/common/utils/setNested/setNested.definitions.js +3 -0
- package/dist/common/utils/setNested/setNested.definitions.js.map +1 -0
- package/dist/common/utils/setNested/setNested.method.d.ts +2 -0
- package/dist/common/utils/setNested/setNested.method.js +70 -0
- package/dist/common/utils/setNested/setNested.method.js.map +1 -0
- package/dist/data/entityService/data.entity.service.d.ts +17 -0
- package/dist/data/entityService/data.entity.service.definitions.d.ts +117 -0
- package/dist/data/entityService/data.entity.service.definitions.js +28 -0
- package/dist/data/entityService/data.entity.service.definitions.js.map +1 -0
- package/dist/{persistance/common/entityService/persistance.entity.service.js → data/entityService/data.entity.service.js} +42 -10
- package/dist/data/entityService/data.entity.service.js.map +1 -0
- package/dist/data/entityService/index.d.ts +2 -0
- package/dist/data/entityService/index.js +19 -0
- package/dist/data/entityService/index.js.map +1 -0
- package/dist/domain/entityService/domain.entity.service.d.ts +28 -13
- package/dist/domain/entityService/domain.entity.service.definitions.d.ts +26 -17
- package/dist/domain/entityService/domain.entity.service.definitions.js +6 -6
- package/dist/domain/entityService/domain.entity.service.definitions.js.map +1 -1
- package/dist/domain/entityService/domain.entity.service.js +97 -56
- package/dist/domain/entityService/domain.entity.service.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
- package/src/app.spec.ts +138 -0
- package/src/app.ts +115 -0
- package/src/common/configProvider/configProvider.definitions.ts +445 -0
- package/src/common/configProvider/configProvider.module.spec.ts +90 -0
- package/src/common/configProvider/configProvider.module.ts +25 -0
- package/src/common/configProvider/configProvider.service.spec.ts +206 -0
- package/src/common/configProvider/configProvider.service.ts +204 -0
- package/src/common/configProvider/index.ts +3 -0
- package/src/common/definitions/common.constants.ts +27 -0
- package/src/common/definitions/common.definitions.ts +13 -0
- package/src/common/definitions/common.errors.ts +13 -0
- package/src/common/definitions/index.ts +3 -0
- package/src/common/utils/base64UrlEncode/base64UrlEncode.method.ts +4 -0
- package/src/common/utils/base64UrlEncode/index.ts +1 -0
- package/src/common/utils/getNested/getNested.definitions.ts +4 -0
- package/src/common/utils/getNested/getNested.method.ts +108 -0
- package/src/common/utils/getNested/getNested.spec.ts +151 -0
- package/src/common/utils/getNested/index.ts +2 -0
- package/src/common/utils/httpRequest/httpRequest.definitions.ts +22 -0
- package/src/common/utils/httpRequest/httpRequest.method.ts +46 -0
- package/src/common/utils/httpRequest/index.ts +2 -0
- package/src/common/utils/index.ts +5 -0
- package/src/common/utils/loadDynamicModules/index.ts +1 -0
- package/src/common/utils/loadDynamicModules/utils.loadDynamicModules.spec.ts +111 -0
- package/src/common/utils/loadDynamicModules/utils.loadDynamicModules.ts +69 -0
- package/src/common/utils/setNested/index.ts +2 -0
- package/src/common/utils/setNested/setNested.definitions.ts +4 -0
- package/src/common/utils/setNested/setNested.method.ts +83 -0
- package/src/common/utils/setNested/setNested.spec.ts +184 -0
- package/src/data/entityService/data.entity.service.definitions.ts +154 -0
- package/src/data/entityService/data.entity.service.spec.ts +112 -0
- package/src/data/entityService/data.entity.service.ts +144 -0
- package/src/data/entityService/index.ts +2 -0
- package/src/domain/entityService/domain.entity.service.definitions.ts +142 -0
- package/src/domain/entityService/domain.entity.service.spec.ts +126 -0
- package/src/domain/entityService/domain.entity.service.ts +421 -0
- package/src/domain/entityService/index.ts +2 -0
- package/src/index.ts +6 -0
- package/src/vitest.config.ts +9 -0
- package/dist/common/utils/utils.loadDynamicModules.js.map +0 -1
- package/dist/persistance/common/entityService/index.d.ts +0 -2
- package/dist/persistance/common/entityService/index.js.map +0 -1
- package/dist/persistance/common/entityService/persistance.entity.service.d.ts +0 -11
- package/dist/persistance/common/entityService/persistance.entity.service.definitions.d.ts +0 -70
- package/dist/persistance/common/entityService/persistance.entity.service.definitions.js +0 -23
- package/dist/persistance/common/entityService/persistance.entity.service.definitions.js.map +0 -1
- package/dist/persistance/common/entityService/persistance.entity.service.js.map +0 -1
- /package/dist/common/utils/{utils.loadDynamicModules.js → loadDynamicModules/utils.loadDynamicModules.js} +0 -0
|
@@ -9,22 +9,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
const definitions_1 = require("
|
|
14
|
-
class
|
|
12
|
+
exports.DataEntityService = void 0;
|
|
13
|
+
const definitions_1 = require("../../common/definitions");
|
|
14
|
+
class DataEntityService {
|
|
15
|
+
constructor(configProvider, dataModuleName) {
|
|
16
|
+
this.configProvider = configProvider;
|
|
17
|
+
this.dataModuleName = dataModuleName;
|
|
18
|
+
const { settingsPerEntity } = configProvider.config.data[dataModuleName];
|
|
19
|
+
this.settings = settingsPerEntity || {};
|
|
20
|
+
}
|
|
15
21
|
bulkCreate(_data, _options, _privateOptions) {
|
|
16
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
23
|
throw new definitions_1.ApplicationError(`Method bulkCreate not implemented for class ${typeof this}.`);
|
|
18
24
|
});
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
count(_options, _privateOptions) {
|
|
21
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
throw new definitions_1.ApplicationError(`Method
|
|
28
|
+
throw new definitions_1.ApplicationError(`Method count not implemented for class ${typeof this}.`);
|
|
23
29
|
});
|
|
24
30
|
}
|
|
25
|
-
|
|
31
|
+
create(_data, _options, _privateOptions) {
|
|
26
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
throw new definitions_1.ApplicationError(`Method
|
|
33
|
+
throw new definitions_1.ApplicationError(`Method create not implemented for class ${typeof this}.`);
|
|
28
34
|
});
|
|
29
35
|
}
|
|
30
36
|
delete(_options, _privateOptions) {
|
|
@@ -36,14 +42,40 @@ class PersistanceEntityService {
|
|
|
36
42
|
findOne(_options, _privateOptions) {
|
|
37
43
|
throw new definitions_1.ApplicationError(`Method findOne not implemented for class ${typeof this}.`);
|
|
38
44
|
}
|
|
39
|
-
getEntityName() {
|
|
45
|
+
getEntityName(noError) {
|
|
46
|
+
if (noError) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
40
49
|
throw new definitions_1.ApplicationError(`Method getEntityName not implemented for class ${typeof this}.`);
|
|
41
50
|
}
|
|
51
|
+
processObjectAllowedFields(data, options) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const { settings } = this;
|
|
54
|
+
const { allowedFields, isEnabled, objectType } = options;
|
|
55
|
+
if (isEnabled === false || (typeof isEnabled === 'undefined' && !settings[objectType])) {
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
const actualData = data instanceof Array ? data : [data];
|
|
59
|
+
const processedData = [];
|
|
60
|
+
actualData.forEach(dataItem => {
|
|
61
|
+
const processedDataItem = {};
|
|
62
|
+
allowedFields.forEach(fieldName => {
|
|
63
|
+
const typedFieldName = fieldName;
|
|
64
|
+
const value = dataItem[typedFieldName];
|
|
65
|
+
if (typeof value !== 'undefined') {
|
|
66
|
+
processedDataItem[typedFieldName] = value;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
processedData.push(processedDataItem);
|
|
70
|
+
});
|
|
71
|
+
return processedData.length === 1 ? processedData[0] : processedData;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
42
74
|
update(_data, _options, _privateOptions) {
|
|
43
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
76
|
throw new definitions_1.ApplicationError(`Method update not implemented for class ${typeof this}.`);
|
|
45
77
|
});
|
|
46
78
|
}
|
|
47
79
|
}
|
|
48
|
-
exports.
|
|
49
|
-
//# sourceMappingURL=
|
|
80
|
+
exports.DataEntityService = DataEntityService;
|
|
81
|
+
//# sourceMappingURL=data.entity.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.entity.service.js","sourceRoot":"","sources":["../../../src/data/entityService/data.entity.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./data.entity.service"), exports);
|
|
18
|
+
__exportStar(require("./data.entity.service.definitions"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data/entityService/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,oEAAkD"}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import { DomainBulkCreateOptions, DomainBulkCreateResult, DomainCreateOptions, DomainCreateResult, DomainDeleteOptions, DomainDeleteResult, DomainEntityServiceDefaultData, DomainFindOneOptions, DomainFindOneResult, DomainFindOptions,
|
|
1
|
+
import { DomainBaseAdditionalServiceOptionsOverrides, DomainBulkCreateOptions, DomainBulkCreatePrivateOptions, DomainBulkCreateResult, DomainCreateOptions, DomainCreatePrivateOptions, DomainCreateResult, DomainDataEntityServiceType, DomainDeleteOptions, DomainDeletePrivateOptions, DomainDeleteResult, DomainEntityServiceDefaultData, DomainFindOneOptions, DomainFindOnePrivateOptions, DomainFindOneResult, DomainFindOptions, DomainFindPrivateOptions, DomainFindResult, DomainRunMethodInAdditionalServicesOptions, DomainUpdateOptions, DomainUpdatePrivateOptions, DomainUpdateResult } from './domain.entity.service.definitions';
|
|
2
2
|
import { GenericObject } from '../../common/definitions';
|
|
3
|
-
import {
|
|
4
|
-
export declare class DomainEntityService<Entity, EntityService extends
|
|
5
|
-
protected
|
|
3
|
+
import { DataDefaultData, DataEntityService } from '../../data/entityService';
|
|
4
|
+
export declare class DomainEntityService<Entity, EntityService extends DataEntityService<Entity, DataEntityServiceData>, Data extends DomainEntityServiceDefaultData<Entity> = DomainEntityServiceDefaultData<Entity>, AdditionalEntityServices extends Record<string, DataEntityService<Partial<Entity>, DataDefaultData<object>>> | undefined = undefined, DataEntityServiceData extends DataDefaultData<Entity> = DataDefaultData<Entity>> {
|
|
5
|
+
protected dataEntityService: EntityService;
|
|
6
6
|
protected defaultMethods: string[];
|
|
7
|
-
protected
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
protected additionalDataEntityServices?: AdditionalEntityServices | undefined;
|
|
8
|
+
protected defaultAdditionalDataEntityServicesOptions?: {
|
|
9
|
+
[methodName: string]: {
|
|
10
|
+
[serviceName: string]: {
|
|
11
|
+
allowIncoming?: boolean;
|
|
12
|
+
serviceOptions?: DomainBaseAdditionalServiceOptionsOverrides & GenericObject<unknown>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | undefined;
|
|
16
|
+
constructor(dataEntityService: EntityService, defaultMethods?: string[], additionalDataEntityServices?: AdditionalEntityServices | undefined, defaultAdditionalDataEntityServicesOptions?: {
|
|
17
|
+
[methodName: string]: {
|
|
18
|
+
[serviceName: string]: {
|
|
19
|
+
allowIncoming?: boolean;
|
|
20
|
+
serviceOptions?: DomainBaseAdditionalServiceOptionsOverrides & GenericObject<unknown>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
} | undefined);
|
|
24
|
+
bulkCreate(data: Data['BulkCreate'], options?: DomainBulkCreateOptions, privateOptions?: DomainBulkCreatePrivateOptions): Promise<DomainBulkCreateResult<Entity>>;
|
|
25
|
+
create(data: Data['Create'], options?: DomainCreateOptions, privateOptions?: DomainCreatePrivateOptions): Promise<DomainCreateResult<Entity>>;
|
|
26
|
+
delete(options: DomainDeleteOptions, privateOptions?: DomainDeletePrivateOptions): Promise<DomainDeleteResult<Entity>>;
|
|
27
|
+
find(options: DomainFindOptions, privateOptions?: DomainFindOnePrivateOptions): Promise<DomainFindResult<Entity>>;
|
|
28
|
+
findOne(options: DomainFindOneOptions, privateOptions?: DomainFindPrivateOptions): Promise<DomainFindOneResult<Entity>>;
|
|
29
|
+
protected getDataService(serviceName: DomainDataEntityServiceType.Main | string): DataEntityService<Entity>;
|
|
15
30
|
protected runMethodInAdditionalServices<ServiceReturnData>(serviceNames: string[], options: DomainRunMethodInAdditionalServicesOptions<unknown>): Promise<GenericObject<ServiceReturnData> | undefined>;
|
|
16
|
-
update(data: Data['Update'], options: DomainUpdateOptions, privateOptions?:
|
|
31
|
+
update(data: Data['Update'], options: DomainUpdateOptions, privateOptions?: DomainUpdatePrivateOptions): Promise<DomainUpdateResult<Entity>>;
|
|
17
32
|
}
|
|
@@ -1,42 +1,49 @@
|
|
|
1
1
|
import { GenericObject } from '../../common/definitions';
|
|
2
|
-
import {
|
|
2
|
+
import { DataBulkCreatePrivateOptions, DataCreatePrivateOptions, DataDeleteOptions, DataDeletePrivateOptions, DataDeleteResult, DataFindOneOptions, DataFindOnePrivateOptions, DataFindOptions, DataFindPrivateOptions, DataFindResults, DataUpdateOptions, DataUpdatePrivateOptions, DataUpdateResult } from '../../data/entityService';
|
|
3
3
|
export interface DomainBaseAdditionalServiceOptionsOverrides {
|
|
4
|
-
|
|
4
|
+
filterByFirstServiceResultFields?: GenericObject<string>;
|
|
5
|
+
returnData?: boolean;
|
|
6
|
+
runOnNoFirstServiceResultOnly?: boolean | string;
|
|
5
7
|
}
|
|
6
8
|
export type DomainBaseOptions<Options> = Options & DomainBaseOptionsForAdditionalServices<Options>;
|
|
7
9
|
export interface DomainBaseOptionsForAdditionalServices<Options> {
|
|
8
10
|
optionsOverridesByService?: GenericObject<Partial<Options> & DomainBaseAdditionalServiceOptionsOverrides>;
|
|
9
|
-
|
|
11
|
+
dataServices?: DomainDataServicesKey[];
|
|
10
12
|
}
|
|
11
|
-
export type DomainBaseOptionsForAdditionalServicesFull<Options extends object | undefined = undefined, SaveAdditionalResultsOptions extends object | undefined = undefined> = DomainBaseOptionsForAdditionalServices<Options> &
|
|
12
|
-
export interface
|
|
13
|
-
|
|
13
|
+
export type DomainBaseOptionsForAdditionalServicesFull<Options extends object | undefined = undefined, SaveAdditionalResultsOptions extends object | undefined = undefined> = DomainBaseOptionsForAdditionalServices<Options> & DomainBaseOptionsWithSearchData<SaveAdditionalResultsOptions>;
|
|
14
|
+
export interface DomainBaseOptionsWithSearchData<SaveAdditionalResultsOptions extends object | undefined = undefined> {
|
|
15
|
+
saveAdditionalResultsInFirstService?: {
|
|
14
16
|
saveOptions?: SaveAdditionalResultsOptions;
|
|
15
17
|
serviceName: string;
|
|
16
|
-
|
|
18
|
+
useResultsForFirstService?: boolean;
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
21
|
export interface DomainBaseResult<Result> {
|
|
20
22
|
result: Result;
|
|
21
23
|
resultsByService?: GenericObject<Result>;
|
|
22
24
|
}
|
|
25
|
+
export type DomainBulkCreatePrivateOptions = DataBulkCreatePrivateOptions;
|
|
23
26
|
export type DomainBulkCreateData<Entity> = Partial<Entity>[];
|
|
24
27
|
export type DomainBulkCreateOptions<Options = object> = DomainBaseOptions<Options>;
|
|
25
28
|
export type DomainBulkCreateResult<Entity> = DomainBaseResult<Entity[]>;
|
|
26
29
|
export type DomainCreateData<Entity> = Partial<Entity>;
|
|
27
30
|
export type DomainCreateOptions<Options = object> = DomainBaseOptions<Options>;
|
|
31
|
+
export type DomainCreatePrivateOptions = DataCreatePrivateOptions;
|
|
28
32
|
export type DomainCreateResult<Entity> = DomainBaseResult<Entity>;
|
|
29
|
-
export type DomainDeleteOptions<Options = object> = Options & DomainBaseOptions<
|
|
30
|
-
export type
|
|
33
|
+
export type DomainDeleteOptions<Options = object> = Options & DomainBaseOptions<DataDeleteOptions>;
|
|
34
|
+
export type DomainDeletePrivateOptions = DataDeletePrivateOptions;
|
|
35
|
+
export type DomainDeleteResult<Entity> = DomainBaseResult<DataDeleteResult<Entity>>;
|
|
31
36
|
export interface DomainEntityServiceDefaultData<Entity> {
|
|
32
37
|
BulkCreate: DomainBulkCreateData<Entity>;
|
|
33
38
|
Create: DomainCreateData<Entity>;
|
|
34
39
|
Update: DomainUpdateData<Entity>;
|
|
35
40
|
}
|
|
36
|
-
export type DomainFindOneOptions<Options = object> = Options & DomainBaseOptions<
|
|
41
|
+
export type DomainFindOneOptions<Options = object> = Options & DomainBaseOptions<DataFindOneOptions> & DomainBaseOptionsWithSearchData<DomainCreateOptions>;
|
|
42
|
+
export type DomainFindOnePrivateOptions = DataFindOnePrivateOptions;
|
|
37
43
|
export type DomainFindOneResult<Entity> = DomainBaseResult<Entity | null>;
|
|
38
|
-
export type DomainFindOptions<Options = object> = Options & DomainBaseOptions<
|
|
39
|
-
export type
|
|
44
|
+
export type DomainFindOptions<Options = object> = Options & DomainBaseOptions<DataFindOptions> & DomainBaseOptionsWithSearchData<DomainBulkCreateOptions>;
|
|
45
|
+
export type DomainFindPrivateOptions = DataFindPrivateOptions;
|
|
46
|
+
export type DomainFindResult<Entity> = DomainBaseResult<DataFindResults<Entity>>;
|
|
40
47
|
export declare enum DomainMethod {
|
|
41
48
|
BulkCreate = "bulkCreate",
|
|
42
49
|
Create = "create",
|
|
@@ -46,18 +53,20 @@ export declare enum DomainMethod {
|
|
|
46
53
|
Update = "update"
|
|
47
54
|
}
|
|
48
55
|
export declare const DOMAIN_ENTITY_SERVICE_DEFAULT_METHODS: DomainMethod[];
|
|
49
|
-
export declare enum
|
|
56
|
+
export declare enum DomainDataEntityServiceType {
|
|
50
57
|
All = "all",
|
|
51
58
|
Main = "main"
|
|
52
59
|
}
|
|
53
|
-
export type
|
|
60
|
+
export type DomainDataServicesKey = DomainDataEntityServiceType | string;
|
|
54
61
|
export type DomainRunMethodInAdditionalServicesOptions<Options> = {
|
|
55
|
-
|
|
62
|
+
firstServiceResult?: unknown;
|
|
63
|
+
hasFirstServiceResult: boolean;
|
|
56
64
|
methodArgs?: unknown[];
|
|
57
65
|
methodName: string;
|
|
58
66
|
optionsArgIndex?: number;
|
|
59
67
|
optionsOverridesByService?: GenericObject<Partial<Options> & DomainBaseAdditionalServiceOptionsOverrides>;
|
|
60
68
|
};
|
|
61
69
|
export type DomainUpdateData<Entity> = Partial<Entity>;
|
|
62
|
-
export type DomainUpdateOptions<Options = object> = Options & DomainBaseOptions<
|
|
63
|
-
export type
|
|
70
|
+
export type DomainUpdateOptions<Options = object> = Options & DomainBaseOptions<DataUpdateOptions>;
|
|
71
|
+
export type DomainUpdatePrivateOptions = DataUpdatePrivateOptions;
|
|
72
|
+
export type DomainUpdateResult<Entity> = DomainBaseResult<DataUpdateResult<Entity>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DomainDataEntityServiceType = exports.DOMAIN_ENTITY_SERVICE_DEFAULT_METHODS = exports.DomainMethod = void 0;
|
|
4
4
|
var DomainMethod;
|
|
5
5
|
(function (DomainMethod) {
|
|
6
6
|
DomainMethod["BulkCreate"] = "bulkCreate";
|
|
@@ -18,9 +18,9 @@ exports.DOMAIN_ENTITY_SERVICE_DEFAULT_METHODS = [
|
|
|
18
18
|
DomainMethod.FindOne,
|
|
19
19
|
DomainMethod.Update
|
|
20
20
|
];
|
|
21
|
-
var
|
|
22
|
-
(function (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})(
|
|
21
|
+
var DomainDataEntityServiceType;
|
|
22
|
+
(function (DomainDataEntityServiceType) {
|
|
23
|
+
DomainDataEntityServiceType["All"] = "all";
|
|
24
|
+
DomainDataEntityServiceType["Main"] = "main";
|
|
25
|
+
})(DomainDataEntityServiceType || (exports.DomainDataEntityServiceType = DomainDataEntityServiceType = {}));
|
|
26
26
|
//# sourceMappingURL=domain.entity.service.definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.entity.service.definitions.js","sourceRoot":"","sources":["../../../src/domain/entityService/domain.entity.service.definitions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"domain.entity.service.definitions.js","sourceRoot":"","sources":["../../../src/domain/entityService/domain.entity.service.definitions.ts"],"names":[],"mappings":";;;AA6FA,IAAY,YAaX;AAbD,WAAY,YAAY;IAEtB,yCAAyB,CAAA;IAEzB,iCAAiB,CAAA;IAEjB,iCAAiB,CAAA;IAEjB,6BAAa,CAAA;IAEb,mCAAmB,CAAA;IAEnB,iCAAiB,CAAA;AACnB,CAAC,EAbW,YAAY,4BAAZ,YAAY,QAavB;AAEY,QAAA,qCAAqC,GAAG;IACnD,YAAY,CAAC,UAAU;IACvB,YAAY,CAAC,MAAM;IACnB,YAAY,CAAC,MAAM;IACnB,YAAY,CAAC,IAAI;IACjB,YAAY,CAAC,OAAO;IACpB,YAAY,CAAC,MAAM;CACpB,CAAC;AAEF,IAAY,2BAKX;AALD,WAAY,2BAA2B;IAErC,0CAAW,CAAA;IAEX,4CAAa,CAAA;AACf,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC"}
|
|
@@ -24,14 +24,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.DomainEntityService = void 0;
|
|
27
|
-
const
|
|
27
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
28
28
|
const domain_entity_service_definitions_1 = require("./domain.entity.service.definitions");
|
|
29
29
|
const definitions_1 = require("../../common/definitions");
|
|
30
30
|
class DomainEntityService {
|
|
31
|
-
constructor(
|
|
32
|
-
this.
|
|
31
|
+
constructor(dataEntityService, defaultMethods = domain_entity_service_definitions_1.DOMAIN_ENTITY_SERVICE_DEFAULT_METHODS, additionalDataEntityServices, defaultAdditionalDataEntityServicesOptions) {
|
|
32
|
+
this.dataEntityService = dataEntityService;
|
|
33
33
|
this.defaultMethods = defaultMethods;
|
|
34
|
-
this.
|
|
34
|
+
this.additionalDataEntityServices = additionalDataEntityServices;
|
|
35
|
+
this.defaultAdditionalDataEntityServicesOptions = defaultAdditionalDataEntityServicesOptions;
|
|
35
36
|
}
|
|
36
37
|
bulkCreate(data, options, privateOptions) {
|
|
37
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -39,17 +40,22 @@ class DomainEntityService {
|
|
|
39
40
|
if (!((_a = this.defaultMethods) === null || _a === void 0 ? void 0 : _a.includes(domain_entity_service_definitions_1.DomainMethod.BulkCreate))) {
|
|
40
41
|
throw new definitions_1.ApplicationError(`Method bulkCreate not implemented for class ${typeof this}.`);
|
|
41
42
|
}
|
|
42
|
-
const { optionsOverridesByService,
|
|
43
|
-
const [firstServiceName, ...otherServiceNames] =
|
|
44
|
-
const result = yield this.
|
|
43
|
+
const { optionsOverridesByService, dataServices = [domain_entity_service_definitions_1.DomainDataEntityServiceType.Main] } = options || {};
|
|
44
|
+
const [firstServiceName, ...otherServiceNames] = dataServices;
|
|
45
|
+
const result = yield this.getDataService(firstServiceName).bulkCreate(data, privateOptions);
|
|
46
|
+
let actualOtherServiceNames = [];
|
|
47
|
+
let actualOptionsOverridesByService = {};
|
|
48
|
+
actualOtherServiceNames = otherServiceNames || [];
|
|
49
|
+
actualOptionsOverridesByService = optionsOverridesByService;
|
|
45
50
|
return {
|
|
46
51
|
result,
|
|
47
|
-
resultsByService: yield this.runMethodInAdditionalServices(
|
|
48
|
-
|
|
52
|
+
resultsByService: yield this.runMethodInAdditionalServices(actualOtherServiceNames, {
|
|
53
|
+
firstServiceResult: result,
|
|
54
|
+
hasFirstServiceResult: result.length > 0,
|
|
49
55
|
methodArgs: [result, privateOptions],
|
|
50
56
|
methodName: 'bulkCreate',
|
|
51
57
|
optionsArgIndex: 1,
|
|
52
|
-
optionsOverridesByService
|
|
58
|
+
optionsOverridesByService: actualOptionsOverridesByService
|
|
53
59
|
})
|
|
54
60
|
};
|
|
55
61
|
});
|
|
@@ -60,13 +66,14 @@ class DomainEntityService {
|
|
|
60
66
|
if (!((_a = this.defaultMethods) === null || _a === void 0 ? void 0 : _a.includes(domain_entity_service_definitions_1.DomainMethod.Create))) {
|
|
61
67
|
throw new definitions_1.ApplicationError(`Method create not implemented for class ${typeof this}.`);
|
|
62
68
|
}
|
|
63
|
-
const { optionsOverridesByService,
|
|
64
|
-
const [firstServiceName, ...otherServiceNames] =
|
|
65
|
-
const result = yield this.
|
|
69
|
+
const { optionsOverridesByService, dataServices = [domain_entity_service_definitions_1.DomainDataEntityServiceType.Main] } = options || {};
|
|
70
|
+
const [firstServiceName, ...otherServiceNames] = dataServices;
|
|
71
|
+
const result = yield this.getDataService(firstServiceName).create(data, privateOptions);
|
|
66
72
|
return {
|
|
67
73
|
result,
|
|
68
74
|
resultsByService: yield this.runMethodInAdditionalServices(otherServiceNames || [], {
|
|
69
|
-
|
|
75
|
+
firstServiceResult: result,
|
|
76
|
+
hasFirstServiceResult: typeof result !== 'undefined' && result !== null,
|
|
70
77
|
methodArgs: [result, privateOptions],
|
|
71
78
|
methodName: 'create',
|
|
72
79
|
optionsArgIndex: 1,
|
|
@@ -81,13 +88,14 @@ class DomainEntityService {
|
|
|
81
88
|
if (!((_a = this.defaultMethods) === null || _a === void 0 ? void 0 : _a.includes(domain_entity_service_definitions_1.DomainMethod.Delete))) {
|
|
82
89
|
throw new definitions_1.ApplicationError(`Method delete not implemented for class ${typeof this}.`);
|
|
83
90
|
}
|
|
84
|
-
const _b = options || {}, { optionsOverridesByService,
|
|
85
|
-
const [firstServiceName, ...otherServiceNames] =
|
|
86
|
-
const result = yield this.
|
|
91
|
+
const _b = options || {}, { optionsOverridesByService, dataServices = [domain_entity_service_definitions_1.DomainDataEntityServiceType.Main] } = _b, otherOptions = __rest(_b, ["optionsOverridesByService", "dataServices"]);
|
|
92
|
+
const [firstServiceName, ...otherServiceNames] = dataServices;
|
|
93
|
+
const result = yield this.getDataService(firstServiceName).delete(otherOptions, privateOptions);
|
|
87
94
|
return {
|
|
88
95
|
result,
|
|
89
96
|
resultsByService: yield this.runMethodInAdditionalServices(otherServiceNames || [], {
|
|
90
|
-
|
|
97
|
+
firstServiceResult: Object.assign(Object.assign({}, result), { items: result.originalItems || [] }),
|
|
98
|
+
hasFirstServiceResult: !!result.count,
|
|
91
99
|
methodArgs: [otherOptions, privateOptions],
|
|
92
100
|
methodName: 'delete',
|
|
93
101
|
optionsArgIndex: 0,
|
|
@@ -98,27 +106,28 @@ class DomainEntityService {
|
|
|
98
106
|
}
|
|
99
107
|
find(options, privateOptions) {
|
|
100
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
var _a;
|
|
109
|
+
var _a, _b;
|
|
102
110
|
if (!((_a = this.defaultMethods) === null || _a === void 0 ? void 0 : _a.includes(domain_entity_service_definitions_1.DomainMethod.Find))) {
|
|
103
111
|
throw new definitions_1.ApplicationError(`Method find not implemented for class ${typeof this}.`);
|
|
104
112
|
}
|
|
105
|
-
const
|
|
106
|
-
const [firstServiceName, ...otherServiceNames] =
|
|
107
|
-
let result = yield this.
|
|
108
|
-
const
|
|
113
|
+
const _c = options || {}, { optionsOverridesByService, dataServices = [domain_entity_service_definitions_1.DomainDataEntityServiceType.Main], saveAdditionalResultsInFirstService } = _c, otherOptions = __rest(_c, ["optionsOverridesByService", "dataServices", "saveAdditionalResultsInFirstService"]);
|
|
114
|
+
const [firstServiceName, ...otherServiceNames] = dataServices;
|
|
115
|
+
let result = yield this.getDataService(firstServiceName).find(otherOptions, privateOptions);
|
|
116
|
+
const hasFirstServiceResult = result.items.length > 0;
|
|
109
117
|
const resultsByService = yield this.runMethodInAdditionalServices(otherServiceNames || [], {
|
|
110
|
-
|
|
118
|
+
firstServiceResult: result,
|
|
119
|
+
hasFirstServiceResult,
|
|
111
120
|
methodArgs: [otherOptions, privateOptions],
|
|
112
121
|
methodName: 'find',
|
|
113
122
|
optionsArgIndex: 0,
|
|
114
123
|
optionsOverridesByService
|
|
115
124
|
});
|
|
116
|
-
if (
|
|
117
|
-
const { saveOptions, serviceName,
|
|
125
|
+
if (saveAdditionalResultsInFirstService && resultsByService) {
|
|
126
|
+
const { saveOptions, serviceName, useResultsForFirstService } = saveAdditionalResultsInFirstService;
|
|
118
127
|
const dataFromAdditionalService = resultsByService[serviceName];
|
|
119
|
-
if (dataFromAdditionalService.items.length) {
|
|
120
|
-
yield this.
|
|
121
|
-
if (
|
|
128
|
+
if ((_b = dataFromAdditionalService === null || dataFromAdditionalService === void 0 ? void 0 : dataFromAdditionalService.items) === null || _b === void 0 ? void 0 : _b.length) {
|
|
129
|
+
yield this.dataEntityService.bulkCreate(dataFromAdditionalService.items, saveOptions);
|
|
130
|
+
if (useResultsForFirstService && !hasFirstServiceResult) {
|
|
122
131
|
result = dataFromAdditionalService;
|
|
123
132
|
}
|
|
124
133
|
}
|
|
@@ -135,23 +144,24 @@ class DomainEntityService {
|
|
|
135
144
|
if (!((_a = this.defaultMethods) === null || _a === void 0 ? void 0 : _a.includes(domain_entity_service_definitions_1.DomainMethod.FindOne))) {
|
|
136
145
|
throw new definitions_1.ApplicationError(`Method findOne not implemented for class ${typeof this}.`);
|
|
137
146
|
}
|
|
138
|
-
const _b = options || {}, { optionsOverridesByService,
|
|
139
|
-
const [firstServiceName, ...otherServiceNames] =
|
|
140
|
-
let result = yield this.
|
|
141
|
-
const
|
|
147
|
+
const _b = options || {}, { optionsOverridesByService, dataServices = [domain_entity_service_definitions_1.DomainDataEntityServiceType.Main], saveAdditionalResultsInFirstService } = _b, otherOptions = __rest(_b, ["optionsOverridesByService", "dataServices", "saveAdditionalResultsInFirstService"]);
|
|
148
|
+
const [firstServiceName, ...otherServiceNames] = dataServices;
|
|
149
|
+
let result = yield this.getDataService(firstServiceName).findOne(otherOptions, privateOptions);
|
|
150
|
+
const hasFirstServiceResult = typeof result !== 'undefined' && result !== null;
|
|
142
151
|
const resultsByService = yield this.runMethodInAdditionalServices(otherServiceNames || [], {
|
|
143
|
-
|
|
152
|
+
firstServiceResult: result,
|
|
153
|
+
hasFirstServiceResult,
|
|
144
154
|
methodArgs: [otherOptions, privateOptions],
|
|
145
155
|
methodName: 'findOne',
|
|
146
156
|
optionsArgIndex: 0,
|
|
147
157
|
optionsOverridesByService
|
|
148
158
|
});
|
|
149
|
-
if (
|
|
150
|
-
const { saveOptions, serviceName,
|
|
159
|
+
if (saveAdditionalResultsInFirstService && resultsByService) {
|
|
160
|
+
const { saveOptions, serviceName, useResultsForFirstService } = saveAdditionalResultsInFirstService;
|
|
151
161
|
const dataFromAdditionalService = resultsByService[serviceName];
|
|
152
162
|
if (dataFromAdditionalService) {
|
|
153
|
-
yield this.
|
|
154
|
-
if (
|
|
163
|
+
yield this.dataEntityService.create(dataFromAdditionalService, saveOptions);
|
|
164
|
+
if (useResultsForFirstService && !hasFirstServiceResult) {
|
|
155
165
|
result = dataFromAdditionalService;
|
|
156
166
|
}
|
|
157
167
|
}
|
|
@@ -162,14 +172,14 @@ class DomainEntityService {
|
|
|
162
172
|
};
|
|
163
173
|
});
|
|
164
174
|
}
|
|
165
|
-
|
|
175
|
+
getDataService(serviceName) {
|
|
166
176
|
var _a;
|
|
167
|
-
if (serviceName === domain_entity_service_definitions_1.
|
|
168
|
-
return this.
|
|
177
|
+
if (serviceName === domain_entity_service_definitions_1.DomainDataEntityServiceType.Main) {
|
|
178
|
+
return this.dataEntityService;
|
|
169
179
|
}
|
|
170
|
-
const service = (_a = this.
|
|
180
|
+
const service = (_a = this.additionalDataEntityServices) === null || _a === void 0 ? void 0 : _a[serviceName];
|
|
171
181
|
if (!service) {
|
|
172
|
-
throw new definitions_1.ApplicationError(`
|
|
182
|
+
throw new definitions_1.ApplicationError(`DataEntityService ${serviceName} does not exist for DomainEntityService ${this.dataEntityService.getEntityName(true) || '(no entity name)'}.`);
|
|
173
183
|
}
|
|
174
184
|
return service;
|
|
175
185
|
}
|
|
@@ -178,27 +188,28 @@ class DomainEntityService {
|
|
|
178
188
|
if (!serviceNames.length) {
|
|
179
189
|
return undefined;
|
|
180
190
|
}
|
|
181
|
-
const {
|
|
191
|
+
const { firstServiceResult, hasFirstServiceResult, methodArgs = [], methodName, optionsArgIndex, optionsOverridesByService = {} } = options;
|
|
182
192
|
const returnDataByService = {};
|
|
183
|
-
if (!this.
|
|
184
|
-
throw new definitions_1.ApplicationError(`No additional
|
|
193
|
+
if (!this.additionalDataEntityServices) {
|
|
194
|
+
throw new definitions_1.ApplicationError(`No additional DataEntityServices exist for DomainEntityService ${this.dataEntityService.getEntityName(true) || '(no entity name)'}.`);
|
|
185
195
|
}
|
|
186
196
|
if (Object.keys(optionsOverridesByService).length &&
|
|
187
197
|
(typeof optionsArgIndex === 'undefined' || optionsArgIndex < 0 || optionsArgIndex > methodArgs.length - 1)) {
|
|
188
|
-
throw new definitions_1.ApplicationError(`Invalid optionsArgIndex value ${optionsArgIndex} provided for DomainEntityService ${this.
|
|
198
|
+
throw new definitions_1.ApplicationError(`Invalid optionsArgIndex value ${optionsArgIndex} provided for DomainEntityService ${this.dataEntityService.getEntityName(true) || '(no entity name)'}.}.`);
|
|
189
199
|
}
|
|
190
200
|
for (const i in serviceNames) {
|
|
191
201
|
const serviceName = serviceNames[i];
|
|
192
|
-
const service = this.
|
|
202
|
+
const service = this.getDataService(serviceName);
|
|
193
203
|
if (!service) {
|
|
194
|
-
throw new definitions_1.ApplicationError(`
|
|
204
|
+
throw new definitions_1.ApplicationError(`DataEntityService ${serviceName} does not exist for DomainEntityService ${this.dataEntityService.getEntityName(true) || '(no entity name)'}.`);
|
|
195
205
|
}
|
|
196
206
|
const serviceMethodOptionsOverrides = optionsOverridesByService[serviceName] || {};
|
|
197
|
-
const {
|
|
198
|
-
if (
|
|
207
|
+
const { filterByFirstServiceResultFields, runOnNoFirstServiceResultOnly = true } = serviceMethodOptionsOverrides, actualMethodOptionsOverrides = __rest(serviceMethodOptionsOverrides, ["filterByFirstServiceResultFields", "runOnNoFirstServiceResultOnly"]);
|
|
208
|
+
if ((runOnNoFirstServiceResultOnly === true || runOnNoFirstServiceResultOnly === 'true') &&
|
|
209
|
+
hasFirstServiceResult) {
|
|
199
210
|
continue;
|
|
200
211
|
}
|
|
201
|
-
const serviceMethodArgs =
|
|
212
|
+
const serviceMethodArgs = lodash_1.default.cloneDeep(methodArgs);
|
|
202
213
|
if (typeof serviceMethodArgs[optionsArgIndex] === 'undefined') {
|
|
203
214
|
if (optionsArgIndex > serviceMethodArgs.length - 1) {
|
|
204
215
|
serviceMethodArgs.push(actualMethodOptionsOverrides);
|
|
@@ -210,6 +221,35 @@ class DomainEntityService {
|
|
|
210
221
|
else {
|
|
211
222
|
serviceMethodArgs[optionsArgIndex] = Object.assign(Object.assign({}, serviceMethodArgs[optionsArgIndex]), actualMethodOptionsOverrides);
|
|
212
223
|
}
|
|
224
|
+
if (filterByFirstServiceResultFields && Object.keys(filterByFirstServiceResultFields).length) {
|
|
225
|
+
if (!hasFirstServiceResult) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
const filters = {};
|
|
229
|
+
const resultItems = firstServiceResult.items || [
|
|
230
|
+
firstServiceResult
|
|
231
|
+
];
|
|
232
|
+
resultItems.forEach(resultItem => {
|
|
233
|
+
if (!resultItem) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
for (const sourceFieldName in filterByFirstServiceResultFields) {
|
|
237
|
+
const fieldValue = resultItem[sourceFieldName];
|
|
238
|
+
const targetFieldName = filterByFirstServiceResultFields[sourceFieldName];
|
|
239
|
+
if (typeof fieldValue === 'undefined') {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!filters[targetFieldName]) {
|
|
243
|
+
filters[targetFieldName] = [];
|
|
244
|
+
}
|
|
245
|
+
filters[targetFieldName].push(fieldValue);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
if (Object.keys(filters).length) {
|
|
249
|
+
const serviceMethodOptions = serviceMethodArgs[optionsArgIndex];
|
|
250
|
+
serviceMethodArgs[optionsArgIndex] = Object.assign(Object.assign({}, serviceMethodOptions), { filters: Object.assign(Object.assign({}, lodash_1.default.omit(serviceMethodOptions.filters || {}, ['page', 'perPage'])), filters), findAll: true });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
213
253
|
returnDataByService[serviceName] = (yield service[methodName].apply(service, serviceMethodArgs));
|
|
214
254
|
}
|
|
215
255
|
return returnDataByService;
|
|
@@ -221,13 +261,14 @@ class DomainEntityService {
|
|
|
221
261
|
if (!((_a = this.defaultMethods) === null || _a === void 0 ? void 0 : _a.includes(domain_entity_service_definitions_1.DomainMethod.Update))) {
|
|
222
262
|
throw new definitions_1.ApplicationError(`Method update not implemented for class ${typeof this}.`);
|
|
223
263
|
}
|
|
224
|
-
const { optionsOverridesByService,
|
|
225
|
-
const [firstServiceName, ...otherServiceNames] =
|
|
226
|
-
const result = yield this.
|
|
264
|
+
const { optionsOverridesByService, dataServices = [domain_entity_service_definitions_1.DomainDataEntityServiceType.Main] } = options, otherOptions = __rest(options, ["optionsOverridesByService", "dataServices"]);
|
|
265
|
+
const [firstServiceName, ...otherServiceNames] = dataServices;
|
|
266
|
+
const result = yield this.getDataService(firstServiceName).update(data, otherOptions, privateOptions);
|
|
227
267
|
return {
|
|
228
268
|
result,
|
|
229
269
|
resultsByService: yield this.runMethodInAdditionalServices(otherServiceNames || [], {
|
|
230
|
-
|
|
270
|
+
firstServiceResult: result,
|
|
271
|
+
hasFirstServiceResult: !!result.count,
|
|
231
272
|
methodArgs: [data, otherOptions, privateOptions],
|
|
232
273
|
methodName: 'update',
|
|
233
274
|
optionsArgIndex: 1,
|