@futdevpro/nts-dynamo 1.9.44 → 1.9.45
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/build/_collections/global-settings.const.d.ts.map +1 -1
- package/build/_collections/global-settings.const.js +1 -0
- package/build/_collections/global-settings.const.js.map +1 -1
- package/build/_models/interfaces/global-settings.interface.d.ts +4 -0
- package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/build/_services/base/archive-data.service.d.ts +1 -1
- package/build/_services/base/archive-data.service.d.ts.map +1 -1
- package/build/_services/base/archive-data.service.js +1 -1
- package/build/_services/base/archive-data.service.js.map +1 -1
- package/build/_services/base/data.service.d.ts +5 -5
- package/build/_services/base/data.service.d.ts.map +1 -1
- package/build/_services/base/data.service.js +59 -11
- package/build/_services/base/data.service.js.map +1 -1
- package/build/_services/base/db.service.d.ts +7 -8
- package/build/_services/base/db.service.d.ts.map +1 -1
- package/build/_services/base/db.service.js +15 -4
- package/build/_services/base/db.service.js.map +1 -1
- package/build/index.d.ts +3 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -5
- package/build/index.js.map +1 -1
- package/package.json +3 -3
- package/src/_collections/global-settings.const.ts +2 -1
- package/src/_models/interfaces/global-settings.interface.ts +5 -0
- package/src/_services/base/archive-data.service.ts +7 -5
- package/src/_services/base/data.service.ts +119 -48
- package/src/_services/base/db.service.ts +35 -15
- package/src/index.ts +3 -5
- package/build/_models/types/db-filter.type.d.ts +0 -97
- package/build/_models/types/db-filter.type.d.ts.map +0 -1
- package/build/_models/types/db-filter.type.js +0 -3
- package/build/_models/types/db-filter.type.js.map +0 -1
- package/src/_models/types/db-filter.type.ts +0 -108
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,sCAAsC,CAAC;AAIrD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,sCAAsC,CAAC;AAIrD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAG7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AAKtD,cAAc,uDAAuD,CAAC;AACtE,cAAc,wDAAwD,CAAC;AACvE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wDAAwD,CAAC;AAGvE,cAAc,wDAAwD,CAAC;AACvE,cAAc,mDAAmD,CAAC;AAClE,cAAc,wDAAwD,CAAC;AACvE,cAAc,sDAAsD,CAAC;AAGrE,cAAc,gCAAgC,CAAC;AAK/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6CAA6C,CAAC;AAG5D,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AAGnD,cAAc,+BAA+B,CAAC;AAG9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,0CAA0C,CAAC;AAGzD,cAAc,mCAAmC,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -6,24 +6,23 @@ tslib_1.__exportStar(require("./_collections/global-settings.const"), exports);
|
|
|
6
6
|
// ENUMS
|
|
7
7
|
tslib_1.__exportStar(require("./_enums/data-model-type.enum"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./_enums/data-service-function.enum"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./_enums/route-security.enum"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./_enums/predefined-data-types.enum"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./_enums/route-security.enum"), exports);
|
|
11
11
|
// enums/HTTP
|
|
12
12
|
tslib_1.__exportStar(require("./_enums/http/http-call-type.enum"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./_enums/http/http-response-type.enum"), exports);
|
|
14
14
|
// MODELS (CONTROL-MODELS, INTERFACES, TYPES)
|
|
15
15
|
// models/INTERFACES
|
|
16
|
-
tslib_1.__exportStar(require("./_models/interfaces/global-service-settings.interface"), exports);
|
|
17
16
|
tslib_1.__exportStar(require("./_models/interfaces/certification-settings.interface"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./_models/interfaces/global-service-settings.interface"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./_models/interfaces/global-settings.interface"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./_models/interfaces/routing-module-settings.interface"), exports);
|
|
20
20
|
// models/CONTROL MODELS
|
|
21
21
|
tslib_1.__exportStar(require("./_models/control-models/api-call-params.control-model"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./_models/control-models/app-params.control-model"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./_models/control-models/http-settings.control-model"), exports);
|
|
24
23
|
tslib_1.__exportStar(require("./_models/control-models/endpoint-params.control-model"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./_models/control-models/http-settings.control-model"), exports);
|
|
25
25
|
// models/TYPES
|
|
26
|
-
tslib_1.__exportStar(require("./_models/types/db-filter.type"), exports);
|
|
27
26
|
tslib_1.__exportStar(require("./_models/types/db-update.type"), exports);
|
|
28
27
|
// SERVICES
|
|
29
28
|
// services/CORE
|
|
@@ -41,7 +40,6 @@ tslib_1.__exportStar(require("./_services/base/singleton.service"), exports);
|
|
|
41
40
|
tslib_1.__exportStar(require("./_services/server/app.server"), exports);
|
|
42
41
|
// services/ROUTE
|
|
43
42
|
tslib_1.__exportStar(require("./_services/route/controller.service"), exports);
|
|
44
|
-
tslib_1.__exportStar(require("./_services/route/controller.service"), exports);
|
|
45
43
|
tslib_1.__exportStar(require("./_services/route/routing-module.service"), exports);
|
|
46
44
|
// services/SHARED
|
|
47
45
|
tslib_1.__exportStar(require("./_services/shared.static-service"), exports);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,cAAc;AACd,+EAAqD;AAGrD,QAAQ;AACR,wEAA8C;AAC9C,8EAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,cAAc;AACd,+EAAqD;AAGrD,QAAQ;AACR,wEAA8C;AAC9C,8EAAoD;AACpD,8EAAoD;AACpD,uEAA6C;AAE7C,aAAa;AACb,4EAAkD;AAClD,gFAAsD;AAGtD,6CAA6C;AAC7C,oBAAoB;AACpB,gGAAsE;AACtE,iGAAuE;AACvE,yFAA+D;AAC/D,iGAAuE;AAEvE,wBAAwB;AACxB,iGAAuE;AACvE,4FAAkE;AAClE,iGAAuE;AACvE,+FAAqE;AAErE,eAAe;AACf,yEAA+C;AAG/C,WAAW;AACX,gBAAgB;AAChB,uEAA6C;AAC7C,wEAA8C;AAC9C,yEAA+C;AAC/C,0EAAgD;AAChD,sFAA4D;AAE5D,gBAAgB;AAChB,gFAAsD;AACtD,wEAA8C;AAC9C,sEAA4C;AAC5C,6EAAmD;AAEnD,kBAAkB;AAClB,wEAA8C;AAE9C,iBAAiB;AACjB,+EAAqD;AACrD,mFAAyD;AAEzD,kBAAkB;AAClB,4EAAkD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/nts-dynamo",
|
|
3
|
-
"version": "01.09.
|
|
3
|
+
"version": "01.09.45",
|
|
4
4
|
"description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prep": "npm i rimraf nodemon -g",
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
},
|
|
91
91
|
"homepage": "https:/futdevpro.hu/projects/dynamo",
|
|
92
92
|
"DISABLED": {
|
|
93
|
-
"@futdevpro/fsm-dynamo": "file:../tgz-collection/dynamo-fsm/futdevpro-fsm-dynamo-01.09.
|
|
93
|
+
"@futdevpro/fsm-dynamo": "file:../tgz-collection/dynamo-fsm/futdevpro-fsm-dynamo-01.09.43.tgz",
|
|
94
94
|
"empty": ""
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@futdevpro/fsm-dynamo": "~1.9.
|
|
97
|
+
"@futdevpro/fsm-dynamo": "~1.9.43",
|
|
98
98
|
|
|
99
99
|
"@types/express": "~4.17.17",
|
|
100
100
|
"@types/geoip-lite": "~1.4.1",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import { DyNTS_RouteSecurity } from '../_enums/route-security.enum';
|
|
3
|
-
import { DyNTS_SocketSecurity } from '../_modules/socket/_enums/socket-security.enum';
|
|
4
3
|
import { DyNTS_Global_Settings } from '../_models/interfaces/global-settings.interface';
|
|
4
|
+
import { DyNTS_SocketSecurity } from '../_modules/socket/_enums/socket-security.enum';
|
|
5
5
|
|
|
6
6
|
export const DyNTS_global_settings: DyNTS_Global_Settings = {
|
|
7
7
|
baseUrl: '/api',
|
|
8
8
|
defaultRouteSecurity: DyNTS_RouteSecurity.open,
|
|
9
9
|
defaultSocketSecurity: DyNTS_SocketSecurity.open,
|
|
10
|
+
defaultPageSize: 10,
|
|
10
11
|
autoResolveEndpointCirculationErrors: true,
|
|
11
12
|
|
|
12
13
|
log_settings: {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
DyFM_DataModel_Params,
|
|
4
|
+
DyFM_DBFilterSimple,
|
|
5
|
+
DyFM_Error,
|
|
6
|
+
DyFM_Metadata,
|
|
4
7
|
} from '@futdevpro/fsm-dynamo';
|
|
5
8
|
|
|
6
|
-
import { DyNTS_DataService } from './data.service';
|
|
7
9
|
import { DyNTS_getArchivedDBName } from '../../_collections/archive.util';
|
|
8
10
|
import { DyNTS_GlobalService } from '../core/global.service';
|
|
11
|
+
import { DyNTS_DataService } from './data.service';
|
|
9
12
|
import { DyNTS_DBService } from './db.service';
|
|
10
|
-
import { DyNTS_DBFilterSimple } from '../../_models/types/db-filter.type';
|
|
11
13
|
|
|
12
14
|
// TODO: 3 type of archiving service system:
|
|
13
15
|
// 1.: within list (data have a list that have elements to archive)
|
|
@@ -95,7 +97,7 @@ export class DyNTS_ArchiveDataService<T extends DyFM_Metadata> extends DyNTS_Dat
|
|
|
95
97
|
return await this.findData(
|
|
96
98
|
{
|
|
97
99
|
_originalId: originalId,
|
|
98
|
-
} as
|
|
100
|
+
} as DyFM_DBFilterSimple<T>,
|
|
99
101
|
dontSetToService
|
|
100
102
|
);
|
|
101
103
|
} catch (error) {
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
DyFM_AnyError,
|
|
4
4
|
DyFM_Array,
|
|
5
|
-
DyFM_DataModel_Params, DyFM_DataProperty_Params,
|
|
5
|
+
DyFM_DataModel_Params, DyFM_DataProperty_Params,
|
|
6
|
+
DyFM_DBFilter,
|
|
7
|
+
DyFM_Error,
|
|
6
8
|
DyFM_Error_Settings, DyFM_ErrorLevel,
|
|
7
9
|
DyFM_Log,
|
|
8
|
-
DyFM_Metadata
|
|
10
|
+
DyFM_Metadata,
|
|
11
|
+
DyFM_SearchQuery
|
|
9
12
|
} from '@futdevpro/fsm-dynamo';
|
|
10
13
|
|
|
11
14
|
import { DyNTS_getArchivedDBName } from '../../_collections/archive.util';
|
|
12
15
|
import { DyNTS_global_settings } from '../../_collections/global-settings.const';
|
|
13
|
-
import { DyNTS_DBFilter } from '../../_models/types/db-filter.type';
|
|
14
16
|
import { DyNTS_DBUpdate } from '../../_models/types/db-update.type';
|
|
15
17
|
import { DyNTS_GlobalService } from '../core/global.service';
|
|
16
18
|
import { DyNTS_ArchiveDataService } from './archive-data.service';
|
|
@@ -254,37 +256,41 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
254
256
|
});
|
|
255
257
|
}
|
|
256
258
|
|
|
257
|
-
if (!dependencyId
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
259
|
+
if (!dependencyId) {
|
|
260
|
+
dependencyId = this.data?.[this.depKey];
|
|
261
|
+
|
|
262
|
+
if (!dependencyId) {
|
|
263
|
+
throw new DyFM_Error({
|
|
264
|
+
...this._getDefaultErrorSettings(
|
|
265
|
+
'getDataByDependencyId',
|
|
266
|
+
new Error(
|
|
267
|
+
`getDataByDependencyId failed, "${this.depKey}" is missing! ` +
|
|
268
|
+
`(${this.dataParams.dataName})`
|
|
269
|
+
)
|
|
270
|
+
),
|
|
271
|
+
|
|
272
|
+
errorCode: 'NTS-DS0-GD2',
|
|
273
|
+
additionalContent: {
|
|
274
|
+
data: this.data,
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
}
|
|
272
278
|
}
|
|
273
279
|
|
|
274
|
-
const dataExists: T = await this.dataDBService.getDataByDependencyId(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
);
|
|
280
|
+
const dataExists: T = await this.dataDBService.getDataByDependencyId(dependencyId).catch(
|
|
281
|
+
(error): null => {
|
|
282
|
+
if (error?.errorCode === 'NTS-DBS-GD2') {
|
|
283
|
+
DyFM_Log.warn(
|
|
284
|
+
`getDataByDependencyId failed; "${this.dataParams.dataName}" ` +
|
|
285
|
+
`(${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`
|
|
286
|
+
);
|
|
282
287
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
288
|
+
return null;
|
|
289
|
+
} else {
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
286
292
|
}
|
|
287
|
-
|
|
293
|
+
);
|
|
288
294
|
|
|
289
295
|
if (!dontSetToService) {
|
|
290
296
|
this.data = dataExists;
|
|
@@ -462,7 +468,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
462
468
|
* //
|
|
463
469
|
* @returns {T} data: T
|
|
464
470
|
*/
|
|
465
|
-
async findData(filterBy:
|
|
471
|
+
async findData(filterBy: DyFM_DBFilter<T>, dontSetToService?: boolean): Promise<T> {
|
|
466
472
|
try {
|
|
467
473
|
const dataExists: T = await this.dataDBService.findOne(filterBy).catch((error): null => {
|
|
468
474
|
if (error?.errorCode === 'NTS-DBS-FO1') {
|
|
@@ -518,7 +524,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
518
524
|
* //
|
|
519
525
|
* @returns {T[]} dataList: T[]
|
|
520
526
|
*/
|
|
521
|
-
async findDataList(filterBy:
|
|
527
|
+
async findDataList(filterBy: DyFM_DBFilter<T>, dontSetToService?: boolean): Promise<T[]> {
|
|
522
528
|
try {
|
|
523
529
|
const dataListExists: T[] = await this.dataDBService.find(filterBy).catch((error): T[] => {
|
|
524
530
|
if (error?.errorCode === 'NTS-DBS-F1') {
|
|
@@ -601,7 +607,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
601
607
|
* //
|
|
602
608
|
*/
|
|
603
609
|
async updateData(
|
|
604
|
-
set: { filterBy?:
|
|
610
|
+
set: { filterBy?: DyFM_DBFilter<T>, update: DyNTS_DBUpdate<T> },
|
|
605
611
|
dontUpdateModified?: boolean
|
|
606
612
|
): Promise<void> {
|
|
607
613
|
try {
|
|
@@ -615,7 +621,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
615
621
|
|
|
616
622
|
} else if (this.data._id) {
|
|
617
623
|
await this.dataDBService.updateOne(
|
|
618
|
-
{ _id: this.data._id } as
|
|
624
|
+
{ _id: this.data._id } as DyFM_DBFilter<T>,
|
|
619
625
|
set.update,
|
|
620
626
|
this.issuer,
|
|
621
627
|
dontUpdateModified
|
|
@@ -623,7 +629,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
623
629
|
|
|
624
630
|
} else if (this.depKey && this.data[this.depKey]) {
|
|
625
631
|
await this.dataDBService.updateOne(
|
|
626
|
-
{ [this.depKey]: this.data[this.depKey] } as
|
|
632
|
+
{ [this.depKey]: this.data[this.depKey] } as DyFM_DBFilter<T>,
|
|
627
633
|
set.update,
|
|
628
634
|
this.issuer,
|
|
629
635
|
dontUpdateModified
|
|
@@ -679,15 +685,15 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
679
685
|
}
|
|
680
686
|
|
|
681
687
|
/**
|
|
682
|
-
* modifies data if the data have ID and already exists in the DB,
|
|
683
|
-
* creates new if the ID is not present or cant find in DB,
|
|
684
|
-
* and if dependency data setted up, will check before creation,
|
|
685
|
-
*
|
|
686
|
-
* @warning
|
|
687
|
-
* but the proper way to update data, if you use update method instead,
|
|
688
|
-
* this way, you can avoid data override errors
|
|
689
|
-
* (when you simultaneously trying to change the same data's
|
|
690
|
-
* different values from different flows)
|
|
688
|
+
* modifies data if the data have ID and already exists in the DB,
|
|
689
|
+
* creates new if the ID is not present or cant find in DB,
|
|
690
|
+
* and if dependency data setted up, will check before creation,
|
|
691
|
+
*
|
|
692
|
+
* @warning
|
|
693
|
+
* but the proper way to update data, if you use update method instead,
|
|
694
|
+
* this way, you can avoid data override errors
|
|
695
|
+
* (when you simultaneously trying to change the same data's
|
|
696
|
+
* different values from different flows)
|
|
691
697
|
*/
|
|
692
698
|
async saveData(data?: T, dontSetToService?: boolean, dontUpdateModified?: boolean): Promise<T> {
|
|
693
699
|
try {
|
|
@@ -797,6 +803,23 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
797
803
|
// if data not exists create new data
|
|
798
804
|
data = await this.dataDBService.createData(data, this.issuer);
|
|
799
805
|
|
|
806
|
+
if (!data._id) {
|
|
807
|
+
throw new DyFM_Error({
|
|
808
|
+
...this._getDefaultErrorSettings(
|
|
809
|
+
'saveData',
|
|
810
|
+
new Error(
|
|
811
|
+
`saveData was unsuccessful: data creation failed ` +
|
|
812
|
+
`(${this.dataParams.dataName})`
|
|
813
|
+
)
|
|
814
|
+
),
|
|
815
|
+
|
|
816
|
+
errorCode: 'NTS-DS0-SD4',
|
|
817
|
+
additionalContent: {
|
|
818
|
+
data: data,
|
|
819
|
+
},
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
|
|
800
823
|
if (!dontSetToService) {
|
|
801
824
|
this.data = data;
|
|
802
825
|
}
|
|
@@ -804,7 +827,12 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
804
827
|
return data;
|
|
805
828
|
|
|
806
829
|
} catch (error) {
|
|
807
|
-
if ([
|
|
830
|
+
if ([
|
|
831
|
+
'NTS-DS0-SD1',
|
|
832
|
+
'NTS-DS0-SD2',
|
|
833
|
+
'NTS-DS0-SD3',
|
|
834
|
+
'NTS-DS0-SD4',
|
|
835
|
+
].includes(error?.errorCode)) {
|
|
808
836
|
throw error;
|
|
809
837
|
|
|
810
838
|
} else {
|
|
@@ -818,8 +846,8 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
818
846
|
}
|
|
819
847
|
|
|
820
848
|
/**
|
|
821
|
-
* markes data as deleted, if can be archived, will be archived as well
|
|
822
|
-
* if absolute is true, permanently deletes data from database by data._id
|
|
849
|
+
* markes data as deleted, if can be archived, will be archived as well
|
|
850
|
+
* if absolute is true, permanently deletes data from database by data._id
|
|
823
851
|
*/
|
|
824
852
|
async deleteData(id?: string, absolute?: boolean): Promise<void> {
|
|
825
853
|
try {
|
|
@@ -971,7 +999,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
971
999
|
}
|
|
972
1000
|
|
|
973
1001
|
/**
|
|
974
|
-
* validation of data, for modify and create, by the ModelParams
|
|
1002
|
+
* validation of data, for modify and create, by the ModelParams
|
|
975
1003
|
*/
|
|
976
1004
|
async validateForSave(data?: T): Promise<void> {
|
|
977
1005
|
try {
|
|
@@ -1051,6 +1079,49 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
1051
1079
|
}
|
|
1052
1080
|
}
|
|
1053
1081
|
|
|
1082
|
+
async searchData(query?: DyFM_SearchQuery<T>): Promise<T[]> {
|
|
1083
|
+
try {
|
|
1084
|
+
if (!query || Object.keys(query).length === 0) {
|
|
1085
|
+
return await this.getAll();
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (!query.filterBy) {
|
|
1089
|
+
query.filterBy = {};
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
if (!query.page && !query.pageSize && !query.sortBy) {
|
|
1093
|
+
return await this.dataDBService.find(query.filterBy);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
if (!query.page) {
|
|
1097
|
+
query.page = 1;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
if (!query.pageSize) {
|
|
1101
|
+
DyFM_Log.warn('searchData pageSize is not setted, setting to 10.');
|
|
1102
|
+
query.pageSize = DyNTS_global_settings.defaultPageSize;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
if (!query.sortBy) {
|
|
1106
|
+
query.sortBy = { __lastModified: -1 };
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
return await this.dataDBService.findWithPaging(
|
|
1110
|
+
query.filterBy,
|
|
1111
|
+
query.page,
|
|
1112
|
+
query.pageSize,
|
|
1113
|
+
query.sortBy
|
|
1114
|
+
);
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
throw new DyFM_Error({
|
|
1117
|
+
...this._getDefaultErrorSettings('searchData', error),
|
|
1118
|
+
|
|
1119
|
+
errorCode: 'NTS-DS0-SD0',
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
|
|
1054
1125
|
/**
|
|
1055
1126
|
* setting up dependency dataHook by DynamoBEDataModelParams
|
|
1056
1127
|
*/
|
|
@@ -4,13 +4,14 @@ import { Schema } from 'mongoose';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
DyFM_AnyError,
|
|
7
|
-
DyFM_DataModel_Params, DyFM_DataProperty_Params,
|
|
7
|
+
DyFM_DataModel_Params, DyFM_DataProperty_Params,
|
|
8
|
+
DyFM_DBFilter, DyFM_DBFilterSimple, DyFM_DBSort,
|
|
9
|
+
DyFM_Error,
|
|
8
10
|
DyFM_Error_Settings, DyFM_ErrorLevel,
|
|
9
11
|
DyFM_Log,
|
|
10
12
|
DyFM_Metadata
|
|
11
13
|
} from '@futdevpro/fsm-dynamo';
|
|
12
14
|
import { DyNTS_archiveSuffix } from '../../_collections/archive.util';
|
|
13
|
-
import { DyNTS_DBFilter, DyNTS_DBFilterSimple } from '../../_models/types/db-filter.type';
|
|
14
15
|
import { DyNTS_DBUpdate } from '../../_models/types/db-update.type';
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -508,7 +509,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
508
509
|
* @returns dataList
|
|
509
510
|
*/
|
|
510
511
|
async searchData(
|
|
511
|
-
filterBy:
|
|
512
|
+
filterBy: DyFM_DBFilter<T>,
|
|
512
513
|
narrowByDependencyIds?: string[]
|
|
513
514
|
): Promise<T[]> {
|
|
514
515
|
const filter = {};
|
|
@@ -592,7 +593,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
592
593
|
});
|
|
593
594
|
});
|
|
594
595
|
|
|
595
|
-
if ((filterBy as
|
|
596
|
+
if ((filterBy as DyFM_DBFilterSimple<T>)._deleted === undefined) {
|
|
596
597
|
dataList = dataList.filter((data: T): boolean => !data._deleted);
|
|
597
598
|
}
|
|
598
599
|
|
|
@@ -630,7 +631,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
630
631
|
* //
|
|
631
632
|
* @returns {T} data: T
|
|
632
633
|
*/
|
|
633
|
-
async findOne(filterBy:
|
|
634
|
+
async findOne(filterBy: DyFM_DBFilter<T>): Promise<T> {
|
|
634
635
|
const data: T = await this.dataModel
|
|
635
636
|
.findOne(filterBy)
|
|
636
637
|
.then((res): T => res as T ?? null)
|
|
@@ -673,8 +674,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
673
674
|
* //
|
|
674
675
|
* @returns {T[]} dataList: T[]
|
|
675
676
|
*/
|
|
676
|
-
async find(filterBy:
|
|
677
|
-
|
|
677
|
+
async find(filterBy: DyFM_DBFilter<T>): Promise<T[]> {
|
|
678
678
|
let dataList: T[] = await this.dataModel
|
|
679
679
|
.find(filterBy)
|
|
680
680
|
.then((res): T[] => res as T[] ?? [])
|
|
@@ -687,7 +687,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
687
687
|
});
|
|
688
688
|
});
|
|
689
689
|
|
|
690
|
-
if ((filterBy as
|
|
690
|
+
if ((filterBy as DyFM_DBFilterSimple<T>)._deleted === undefined) {
|
|
691
691
|
dataList = dataList.filter((data: T): boolean => !data._deleted);
|
|
692
692
|
}
|
|
693
693
|
|
|
@@ -728,12 +728,16 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
728
728
|
* @returns {T[]} dataList: T[]
|
|
729
729
|
*/
|
|
730
730
|
async findWithPaging(
|
|
731
|
-
filterBy:
|
|
731
|
+
filterBy: DyFM_DBFilter<T>,
|
|
732
732
|
page: number,
|
|
733
733
|
pageSize: number,
|
|
734
|
-
sort?:
|
|
734
|
+
sort?: DyFM_DBSort<T>
|
|
735
735
|
): Promise<T[]> {
|
|
736
|
-
|
|
736
|
+
if (filterBy['_deleted'] === undefined) {
|
|
737
|
+
filterBy['_deleted'] = null;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const dataList: T[] = await this.dataModel
|
|
737
741
|
.find(filterBy)
|
|
738
742
|
.sort(sort)
|
|
739
743
|
.skip(page * pageSize)
|
|
@@ -748,9 +752,9 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
748
752
|
});
|
|
749
753
|
});
|
|
750
754
|
|
|
751
|
-
if ((filterBy as
|
|
755
|
+
/* if ((filterBy as DyFM_DBFilterSimple<T>)._deleted === undefined) {
|
|
752
756
|
dataList = dataList.filter((data: T): boolean => !data._deleted);
|
|
753
|
-
}
|
|
757
|
+
} */
|
|
754
758
|
|
|
755
759
|
return dataList.map((data: T): T => this.stringifyDataId(data, 'find'));
|
|
756
760
|
}
|
|
@@ -843,7 +847,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
843
847
|
* //
|
|
844
848
|
*/
|
|
845
849
|
async updateOne(
|
|
846
|
-
filterBy:
|
|
850
|
+
filterBy: DyFM_DBFilter<T>,
|
|
847
851
|
update: DyNTS_DBUpdate<T>,
|
|
848
852
|
issuer: string,
|
|
849
853
|
dontUpdateModified?: boolean
|
|
@@ -918,7 +922,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
918
922
|
* //
|
|
919
923
|
*/
|
|
920
924
|
async updateMany(
|
|
921
|
-
filterBy:
|
|
925
|
+
filterBy: DyFM_DBFilter<T>,
|
|
922
926
|
update: DyNTS_DBUpdate<T>,
|
|
923
927
|
issuer: string,
|
|
924
928
|
dontUpdateModified?: boolean
|
|
@@ -1123,6 +1127,22 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
|
|
|
1123
1127
|
(modelParams: DyFM_DataProperty_Params): boolean => modelParams.isDependencyHook
|
|
1124
1128
|
);
|
|
1125
1129
|
|
|
1130
|
+
if (this.dataParams.properties.filter(
|
|
1131
|
+
(modelParams: DyFM_DataProperty_Params): boolean => modelParams.isDependencyHook).length > 1
|
|
1132
|
+
) {
|
|
1133
|
+
throw new DyFM_Error({
|
|
1134
|
+
...this._getDefaultErrorSettings(
|
|
1135
|
+
'lookForDependencyDataSettings',
|
|
1136
|
+
new Error(
|
|
1137
|
+
`Multiple "isDependencyHook" found for this dataModel (${this.dataParams.dbName}) ` +
|
|
1138
|
+
`(NTS DB)` +
|
|
1139
|
+
`\nSorry, but this is not supported yet! (Donate to Dynamo to get this feature!)`
|
|
1140
|
+
)
|
|
1141
|
+
),
|
|
1142
|
+
errorCode: 'NTS-DBS-LFDD0',
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1126
1146
|
if (dependencyParam) {
|
|
1127
1147
|
this.depDataName = dependencyParam.key;
|
|
1128
1148
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,8 +6,8 @@ export * from './_collections/global-settings.const';
|
|
|
6
6
|
// ENUMS
|
|
7
7
|
export * from './_enums/data-model-type.enum';
|
|
8
8
|
export * from './_enums/data-service-function.enum';
|
|
9
|
-
export * from './_enums/route-security.enum';
|
|
10
9
|
export * from './_enums/predefined-data-types.enum';
|
|
10
|
+
export * from './_enums/route-security.enum';
|
|
11
11
|
|
|
12
12
|
// enums/HTTP
|
|
13
13
|
export * from './_enums/http/http-call-type.enum';
|
|
@@ -16,19 +16,18 @@ export * from './_enums/http/http-response-type.enum';
|
|
|
16
16
|
|
|
17
17
|
// MODELS (CONTROL-MODELS, INTERFACES, TYPES)
|
|
18
18
|
// models/INTERFACES
|
|
19
|
-
export * from './_models/interfaces/global-service-settings.interface';
|
|
20
19
|
export * from './_models/interfaces/certification-settings.interface';
|
|
20
|
+
export * from './_models/interfaces/global-service-settings.interface';
|
|
21
21
|
export * from './_models/interfaces/global-settings.interface';
|
|
22
22
|
export * from './_models/interfaces/routing-module-settings.interface';
|
|
23
23
|
|
|
24
24
|
// models/CONTROL MODELS
|
|
25
25
|
export * from './_models/control-models/api-call-params.control-model';
|
|
26
26
|
export * from './_models/control-models/app-params.control-model';
|
|
27
|
-
export * from './_models/control-models/http-settings.control-model';
|
|
28
27
|
export * from './_models/control-models/endpoint-params.control-model';
|
|
28
|
+
export * from './_models/control-models/http-settings.control-model';
|
|
29
29
|
|
|
30
30
|
// models/TYPES
|
|
31
|
-
export * from './_models/types/db-filter.type';
|
|
32
31
|
export * from './_models/types/db-update.type';
|
|
33
32
|
|
|
34
33
|
|
|
@@ -51,7 +50,6 @@ export * from './_services/server/app.server';
|
|
|
51
50
|
|
|
52
51
|
// services/ROUTE
|
|
53
52
|
export * from './_services/route/controller.service';
|
|
54
|
-
export * from './_services/route/controller.service';
|
|
55
53
|
export * from './_services/route/routing-module.service';
|
|
56
54
|
|
|
57
55
|
// services/SHARED
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @example
|
|
3
|
-
* // by email:
|
|
4
|
-
* { email: email }
|
|
5
|
-
* //
|
|
6
|
-
* @example
|
|
7
|
-
* // or by id that is in list:
|
|
8
|
-
* { userIds: { $in: this.userId } }
|
|
9
|
-
* //
|
|
10
|
-
* @example
|
|
11
|
-
* // or by number or Date that is Greater Than AND Less Than:
|
|
12
|
-
* { points: { $gt: 2, $lt: 14 } }
|
|
13
|
-
* // further tools (syntax matches with $gt):
|
|
14
|
-
* $eq: // Matches values that are EQual to a specified value.
|
|
15
|
-
* $gte: // Matches values that are Greater Than OR Equal to a specified value.
|
|
16
|
-
* $lte: // Matches values that are Less Than or Equal to a specified value.
|
|
17
|
-
* $ne: // Matches all values that are Not Equal to a specified value.
|
|
18
|
-
* $nin: // Matches None of the values specified IN an array.
|
|
19
|
-
* //
|
|
20
|
-
* @returns {T} data: T
|
|
21
|
-
*/
|
|
22
|
-
export type DyNTS_DBFilter<T> = DyNTS_DBFilterSimple<T> | DyNTS_DBFilterOR<T> | DyNTS_DBFilterNOR<T>;
|
|
23
|
-
/**
|
|
24
|
-
* A simple filter for a DynamoDB query.
|
|
25
|
-
*/
|
|
26
|
-
export type DyNTS_DBFilterSimple<T> = {
|
|
27
|
-
[K in keyof T]?: T[K] | DyNTS_DBFilterExpressions<T[K] | boolean>;
|
|
28
|
-
} & {
|
|
29
|
-
[path: string]: any;
|
|
30
|
-
};
|
|
31
|
-
export type DyNTS_DBFilterExpressions<T> = {
|
|
32
|
-
/**
|
|
33
|
-
* Matches values that are includes the value; This works only when T[K] is an array!
|
|
34
|
-
*/
|
|
35
|
-
$in?: any;
|
|
36
|
-
/**
|
|
37
|
-
* Matches values that are EQual to a specified value.
|
|
38
|
-
*/
|
|
39
|
-
$eq?: T;
|
|
40
|
-
/**
|
|
41
|
-
* Matches values that are Greater Than a specified value.
|
|
42
|
-
*/
|
|
43
|
-
$gt?: number | Date;
|
|
44
|
-
/**
|
|
45
|
-
* Matches values that are Greater Than OR Equal to a specified value.
|
|
46
|
-
*/
|
|
47
|
-
$gte?: number | Date;
|
|
48
|
-
/**
|
|
49
|
-
* Matches values that are Less Than a specified value.
|
|
50
|
-
*/
|
|
51
|
-
$lt?: number | Date;
|
|
52
|
-
/**
|
|
53
|
-
* Matches values that are Less Than or Equal to a specified value.
|
|
54
|
-
*/
|
|
55
|
-
$lte?: number | Date;
|
|
56
|
-
/**
|
|
57
|
-
* Matches all values that are Not Equal to a specified value.
|
|
58
|
-
*/
|
|
59
|
-
$ne?: T;
|
|
60
|
-
/**
|
|
61
|
-
* Matches None of the values specified IN an array.
|
|
62
|
-
*/
|
|
63
|
-
$nin?: T;
|
|
64
|
-
/**
|
|
65
|
-
* Inverts the effect of a query expression and returns documents that do not match the query expression.
|
|
66
|
-
*/
|
|
67
|
-
$not?: T | {
|
|
68
|
-
$regex?: RegExp | string;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Performs a regular expression on the field's value, and selects documents that match the regular expression.
|
|
72
|
-
*/
|
|
73
|
-
$exists?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Selects documents if a field is of the specified type.
|
|
76
|
-
*/
|
|
77
|
-
$type?: string;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
|
|
81
|
-
*/
|
|
82
|
-
export type DyNTS_DBFilterNOR<T> = {
|
|
83
|
-
/**
|
|
84
|
-
* Joins query clauses with a logical NOR returns all documents that fail to match both clauses.
|
|
85
|
-
*/
|
|
86
|
-
$nor: DyNTS_DBFilterSimple<T>[];
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
|
|
90
|
-
*/
|
|
91
|
-
export type DyNTS_DBFilterOR<T> = {
|
|
92
|
-
/**
|
|
93
|
-
* Joins query clauses with a logical OR returns all documents that match the conditions of either clause.
|
|
94
|
-
*/
|
|
95
|
-
$or: DyNTS_DBFilterSimple<T>[];
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=db-filter.type.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db-filter.type.d.ts","sourceRoot":"","sources":["../../../src/_models/types/db-filter.type.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAC1B,oBAAoB,CAAC,CAAC,CAAC,GACvB,gBAAgB,CAAC,CAAC,CAAC,GACnB,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;KACnC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CAClE,GAAG;IACF,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI;IACzC;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC;IACV;;OAEG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC;IACR;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC;IACR;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,CAAC;IACT;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,GAAG;QACT,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC1B,CAAC;IACF;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC;;OAEG;IACH,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;CACjC,CAAA;AAGD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC;;OAEG;IACH,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;CAChC,CAAA"}
|