@rws-framework/db 2.3.2 → 2.4.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/.bin/add-v.sh +9 -9
- package/.bin/emerge.sh +10 -10
- package/.eslintrc.json +53 -53
- package/README.md +404 -367
- package/dist/decorators/InverseRelation.d.ts +12 -12
- package/dist/decorators/InverseRelation.js +24 -24
- package/dist/decorators/InverseTimeSeries.d.ts +8 -8
- package/dist/decorators/InverseTimeSeries.js +13 -13
- package/dist/decorators/RWSCollection.d.ts +12 -12
- package/dist/decorators/RWSCollection.js +16 -16
- package/dist/decorators/Relation.d.ts +19 -19
- package/dist/decorators/Relation.js +26 -26
- package/dist/decorators/TrackType.d.ts +20 -20
- package/dist/decorators/TrackType.js +41 -41
- package/dist/decorators/index.d.ts +5 -5
- package/dist/decorators/index.js +14 -14
- package/dist/helper/DbHelper.d.ts +8 -8
- package/dist/helper/DbHelper.js +141 -141
- package/dist/helper/FieldsHelper.d.ts +4 -4
- package/dist/helper/FieldsHelper.js +35 -35
- package/dist/index.d.ts +12 -12
- package/dist/index.js +19 -19
- package/dist/models/TimeSeriesModel.d.ts +7 -7
- package/dist/models/TimeSeriesModel.js +33 -33
- package/dist/models/_model.d.ts +6 -6
- package/dist/models/_model.js +9 -9
- package/dist/models/core/RWSModel.d.ts +66 -66
- package/dist/models/core/RWSModel.js +400 -400
- package/dist/models/core/TimeSeriesModel.d.ts +1 -1
- package/dist/models/core/TimeSeriesModel.js +14 -14
- package/dist/models/index.d.ts +7 -7
- package/dist/models/index.js +8 -8
- package/dist/models/interfaces/IModel.d.ts +11 -11
- package/dist/models/interfaces/IModel.js +2 -2
- package/dist/models/interfaces/IRWSModelServices.d.ts +6 -6
- package/dist/models/interfaces/IRWSModelServices.js +2 -2
- package/dist/models/interfaces/OpModelType.d.ts +31 -31
- package/dist/models/interfaces/OpModelType.js +2 -2
- package/dist/models/types/RelationTypes.d.ts +24 -24
- package/dist/models/types/RelationTypes.js +2 -2
- package/dist/models/utils/ModelUtils.d.ts +10 -10
- package/dist/models/utils/ModelUtils.js +56 -56
- package/dist/models/utils/PaginationUtils.d.ts +5 -5
- package/dist/models/utils/PaginationUtils.js +32 -32
- package/dist/models/utils/RelationUtils.d.ts +14 -14
- package/dist/models/utils/RelationUtils.js +65 -65
- package/dist/models/utils/TimeSeriesUtils.d.ts +11 -11
- package/dist/models/utils/TimeSeriesUtils.js +35 -35
- package/dist/services/DBService.d.ts +37 -37
- package/dist/services/DBService.js +198 -198
- package/dist/types/DbConfigHandler.d.ts +9 -9
- package/dist/types/DbConfigHandler.js +2 -2
- package/dist/types/FindParams.d.ts +14 -14
- package/dist/types/FindParams.js +2 -2
- package/dist/types/IRWSModel.d.ts +3 -3
- package/dist/types/IRWSModel.js +2 -2
- package/dist/types/ITimeSeries.d.ts +6 -6
- package/dist/types/ITimeSeries.js +2 -2
- package/exec/console.js +110 -110
- package/exec/db.rws.webpack.config.js +168 -168
- package/exec/src/cli.ts +74 -73
- package/exec/tsconfig.json +32 -32
- package/exec/webpackFilters.js +17 -17
- package/package.json +36 -36
- package/src/decorators/InverseRelation.ts +36 -36
- package/src/decorators/InverseTimeSeries.ts +21 -21
- package/src/decorators/RWSCollection.ts +27 -27
- package/src/decorators/Relation.ts +47 -47
- package/src/decorators/TrackType.ts +69 -69
- package/src/decorators/index.ts +7 -7
- package/src/empty.js +0 -0
- package/src/helper/DbHelper.ts +177 -177
- package/src/helper/FieldsHelper.ts +34 -34
- package/src/index.ts +36 -36
- package/src/models/_model.ts +29 -29
- package/src/models/core/RWSModel.ts +520 -520
- package/src/models/core/TimeSeriesModel.ts +19 -19
- package/src/models/index.ts +20 -20
- package/src/models/interfaces/IModel.ts +12 -12
- package/src/models/interfaces/IRWSModelServices.ts +7 -7
- package/src/models/interfaces/OpModelType.ts +49 -49
- package/src/models/types/RelationTypes.ts +25 -25
- package/src/models/utils/ModelUtils.ts +65 -65
- package/src/models/utils/PaginationUtils.ts +42 -42
- package/src/models/utils/RelationUtils.ts +76 -76
- package/src/models/utils/TimeSeriesUtils.ts +38 -38
- package/src/services/DBService.ts +277 -277
- package/src/types/DbConfigHandler.ts +12 -11
- package/src/types/FindParams.ts +13 -13
- package/src/types/IRWSModel.ts +2 -2
- package/src/types/ITimeSeries.ts +5 -5
- package/tsconfig.json +22 -22
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { RWSModel, OpModelType } from '../models/_model';
|
|
3
|
-
interface InverseRelationOpts {
|
|
4
|
-
key: string;
|
|
5
|
-
inversionModel: OpModelType<RWSModel<any>>;
|
|
6
|
-
foreignKey: string;
|
|
7
|
-
singular?: boolean;
|
|
8
|
-
relationName?: string;
|
|
9
|
-
}
|
|
10
|
-
declare function InverseRelation(inversionModel: () => OpModelType<RWSModel<any>>, sourceModel: () => OpModelType<RWSModel<any>>, relationOptions?: Partial<InverseRelationOpts>): (target: any, key: string) => void;
|
|
11
|
-
export default InverseRelation;
|
|
12
|
-
export { InverseRelationOpts };
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { RWSModel, OpModelType } from '../models/_model';
|
|
3
|
+
interface InverseRelationOpts {
|
|
4
|
+
key: string;
|
|
5
|
+
inversionModel: OpModelType<RWSModel<any>>;
|
|
6
|
+
foreignKey: string;
|
|
7
|
+
singular?: boolean;
|
|
8
|
+
relationName?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function InverseRelation(inversionModel: () => OpModelType<RWSModel<any>>, sourceModel: () => OpModelType<RWSModel<any>>, relationOptions?: Partial<InverseRelationOpts>): (target: any, key: string) => void;
|
|
11
|
+
export default InverseRelation;
|
|
12
|
+
export { InverseRelationOpts };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
function InverseRelation(inversionModel, sourceModel, relationOptions = null) {
|
|
5
|
-
return function (target, key) {
|
|
6
|
-
const metadataPromise = Promise.resolve().then(() => {
|
|
7
|
-
const model = inversionModel();
|
|
8
|
-
const source = sourceModel();
|
|
9
|
-
const metaOpts = {
|
|
10
|
-
...relationOptions,
|
|
11
|
-
key,
|
|
12
|
-
inversionModel: model,
|
|
13
|
-
foreignKey: relationOptions && relationOptions.foreignKey ? relationOptions.foreignKey : `${source._collection}_id`
|
|
14
|
-
};
|
|
15
|
-
return metaOpts;
|
|
16
|
-
});
|
|
17
|
-
// Store both the promise and the key information
|
|
18
|
-
Reflect.defineMetadata(`InverseRelation:${key}`, {
|
|
19
|
-
promise: metadataPromise,
|
|
20
|
-
key
|
|
21
|
-
}, target);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.default = InverseRelation;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
function InverseRelation(inversionModel, sourceModel, relationOptions = null) {
|
|
5
|
+
return function (target, key) {
|
|
6
|
+
const metadataPromise = Promise.resolve().then(() => {
|
|
7
|
+
const model = inversionModel();
|
|
8
|
+
const source = sourceModel();
|
|
9
|
+
const metaOpts = {
|
|
10
|
+
...relationOptions,
|
|
11
|
+
key,
|
|
12
|
+
inversionModel: model,
|
|
13
|
+
foreignKey: relationOptions && relationOptions.foreignKey ? relationOptions.foreignKey : `${source._collection}_id`
|
|
14
|
+
};
|
|
15
|
+
return metaOpts;
|
|
16
|
+
});
|
|
17
|
+
// Store both the promise and the key information
|
|
18
|
+
Reflect.defineMetadata(`InverseRelation:${key}`, {
|
|
19
|
+
promise: metadataPromise,
|
|
20
|
+
key
|
|
21
|
+
}, target);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.default = InverseRelation;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
interface InverseTimeSeriesOpts {
|
|
3
|
-
timeSeriesModel: string;
|
|
4
|
-
hydrationField: string;
|
|
5
|
-
}
|
|
6
|
-
declare function InverseTimeSeries(timeSeriesModel: string, hydrationField: string): (target: any, key: string) => void;
|
|
7
|
-
export default InverseTimeSeries;
|
|
8
|
-
export { InverseTimeSeriesOpts };
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
interface InverseTimeSeriesOpts {
|
|
3
|
+
timeSeriesModel: string;
|
|
4
|
+
hydrationField: string;
|
|
5
|
+
}
|
|
6
|
+
declare function InverseTimeSeries(timeSeriesModel: string, hydrationField: string): (target: any, key: string) => void;
|
|
7
|
+
export default InverseTimeSeries;
|
|
8
|
+
export { InverseTimeSeriesOpts };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
function InverseTimeSeries(timeSeriesModel, hydrationField) {
|
|
5
|
-
const metaOpts = {
|
|
6
|
-
timeSeriesModel: timeSeriesModel,
|
|
7
|
-
hydrationField: hydrationField
|
|
8
|
-
};
|
|
9
|
-
return function (target, key) {
|
|
10
|
-
Reflect.defineMetadata(`InverseTimeSeries:${key}`, metaOpts, target);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
exports.default = InverseTimeSeries;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
function InverseTimeSeries(timeSeriesModel, hydrationField) {
|
|
5
|
+
const metaOpts = {
|
|
6
|
+
timeSeriesModel: timeSeriesModel,
|
|
7
|
+
hydrationField: hydrationField
|
|
8
|
+
};
|
|
9
|
+
return function (target, key) {
|
|
10
|
+
Reflect.defineMetadata(`InverseTimeSeries:${key}`, metaOpts, target);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.default = InverseTimeSeries;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { OpModelType } from "../models/_model";
|
|
2
|
-
export interface IRWSCollectionOpts {
|
|
3
|
-
relations?: {
|
|
4
|
-
[key: string]: boolean;
|
|
5
|
-
};
|
|
6
|
-
ignored_keys?: string[];
|
|
7
|
-
}
|
|
8
|
-
export interface IRWSCollectionMeta {
|
|
9
|
-
collectionName: string;
|
|
10
|
-
options?: IRWSCollectionOpts;
|
|
11
|
-
}
|
|
12
|
-
export declare function RWSCollection(collectionName: string, options?: IRWSCollectionOpts): (target: OpModelType<any>) => void;
|
|
1
|
+
import { OpModelType } from "../models/_model";
|
|
2
|
+
export interface IRWSCollectionOpts {
|
|
3
|
+
relations?: {
|
|
4
|
+
[key: string]: boolean;
|
|
5
|
+
};
|
|
6
|
+
ignored_keys?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface IRWSCollectionMeta {
|
|
9
|
+
collectionName: string;
|
|
10
|
+
options?: IRWSCollectionOpts;
|
|
11
|
+
}
|
|
12
|
+
export declare function RWSCollection(collectionName: string, options?: IRWSCollectionOpts): (target: OpModelType<any>) => void;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RWSCollection = RWSCollection;
|
|
4
|
-
function RWSCollection(collectionName, options) {
|
|
5
|
-
const metaOpts = { collectionName, options };
|
|
6
|
-
return function (target) {
|
|
7
|
-
target._collection = collectionName;
|
|
8
|
-
if (options && options.relations) {
|
|
9
|
-
target._RELATIONS = options.relations;
|
|
10
|
-
}
|
|
11
|
-
if (options && options.ignored_keys) {
|
|
12
|
-
target._CUT_KEYS = options.ignored_keys;
|
|
13
|
-
}
|
|
14
|
-
Reflect.defineMetadata(`RWSCollection`, metaOpts, target);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RWSCollection = RWSCollection;
|
|
4
|
+
function RWSCollection(collectionName, options) {
|
|
5
|
+
const metaOpts = { collectionName, options };
|
|
6
|
+
return function (target) {
|
|
7
|
+
target._collection = collectionName;
|
|
8
|
+
if (options && options.relations) {
|
|
9
|
+
target._RELATIONS = options.relations;
|
|
10
|
+
}
|
|
11
|
+
if (options && options.ignored_keys) {
|
|
12
|
+
target._CUT_KEYS = options.ignored_keys;
|
|
13
|
+
}
|
|
14
|
+
Reflect.defineMetadata(`RWSCollection`, metaOpts, target);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { RWSModel, OpModelType } from '../models/_model';
|
|
3
|
-
type CascadingSetup = 'Cascade' | 'Restrict' | 'NoAction' | 'SetNull';
|
|
4
|
-
interface IRelationOpts {
|
|
5
|
-
required?: boolean;
|
|
6
|
-
key: string;
|
|
7
|
-
relationField: string;
|
|
8
|
-
relatedToField?: string;
|
|
9
|
-
relatedTo: OpModelType<RWSModel<any>>;
|
|
10
|
-
many?: boolean;
|
|
11
|
-
embed?: boolean;
|
|
12
|
-
cascade: {
|
|
13
|
-
onDelete: CascadingSetup;
|
|
14
|
-
onUpdate: CascadingSetup;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
declare function Relation(theModel: () => OpModelType<RWSModel<any>>, relationOptions?: Partial<IRelationOpts>): (target: any, key: string) => void;
|
|
18
|
-
export default Relation;
|
|
19
|
-
export { IRelationOpts };
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { RWSModel, OpModelType } from '../models/_model';
|
|
3
|
+
type CascadingSetup = 'Cascade' | 'Restrict' | 'NoAction' | 'SetNull';
|
|
4
|
+
interface IRelationOpts {
|
|
5
|
+
required?: boolean;
|
|
6
|
+
key: string;
|
|
7
|
+
relationField: string;
|
|
8
|
+
relatedToField?: string;
|
|
9
|
+
relatedTo: OpModelType<RWSModel<any>>;
|
|
10
|
+
many?: boolean;
|
|
11
|
+
embed?: boolean;
|
|
12
|
+
cascade: {
|
|
13
|
+
onDelete: CascadingSetup;
|
|
14
|
+
onUpdate: CascadingSetup;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
declare function Relation(theModel: () => OpModelType<RWSModel<any>>, relationOptions?: Partial<IRelationOpts>): (target: any, key: string) => void;
|
|
18
|
+
export default Relation;
|
|
19
|
+
export { IRelationOpts };
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const _DEFAULTS = { required: false, many: false, embed: false, cascade: { onDelete: 'SetNull', onUpdate: 'Cascade' } };
|
|
5
|
-
function Relation(theModel, relationOptions = _DEFAULTS) {
|
|
6
|
-
return function (target, key) {
|
|
7
|
-
// Store the promise in metadata immediately
|
|
8
|
-
const metadataPromise = Promise.resolve().then(() => {
|
|
9
|
-
const relatedTo = theModel();
|
|
10
|
-
const metaOpts = {
|
|
11
|
-
...relationOptions,
|
|
12
|
-
cascade: relationOptions.cascade || _DEFAULTS.cascade,
|
|
13
|
-
relatedTo,
|
|
14
|
-
relationField: relationOptions.relationField ? relationOptions.relationField : relatedTo._collection + '_id',
|
|
15
|
-
key
|
|
16
|
-
};
|
|
17
|
-
return metaOpts;
|
|
18
|
-
});
|
|
19
|
-
// Store both the promise and the key information
|
|
20
|
-
Reflect.defineMetadata(`Relation:${key}`, {
|
|
21
|
-
promise: metadataPromise,
|
|
22
|
-
key
|
|
23
|
-
}, target);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.default = Relation;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const _DEFAULTS = { required: false, many: false, embed: false, cascade: { onDelete: 'SetNull', onUpdate: 'Cascade' } };
|
|
5
|
+
function Relation(theModel, relationOptions = _DEFAULTS) {
|
|
6
|
+
return function (target, key) {
|
|
7
|
+
// Store the promise in metadata immediately
|
|
8
|
+
const metadataPromise = Promise.resolve().then(() => {
|
|
9
|
+
const relatedTo = theModel();
|
|
10
|
+
const metaOpts = {
|
|
11
|
+
...relationOptions,
|
|
12
|
+
cascade: relationOptions.cascade || _DEFAULTS.cascade,
|
|
13
|
+
relatedTo,
|
|
14
|
+
relationField: relationOptions.relationField ? relationOptions.relationField : relatedTo._collection + '_id',
|
|
15
|
+
key
|
|
16
|
+
};
|
|
17
|
+
return metaOpts;
|
|
18
|
+
});
|
|
19
|
+
// Store both the promise and the key information
|
|
20
|
+
Reflect.defineMetadata(`Relation:${key}`, {
|
|
21
|
+
promise: metadataPromise,
|
|
22
|
+
key
|
|
23
|
+
}, target);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.default = Relation;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { OpModelType } from '../models/interfaces/OpModelType';
|
|
3
|
-
interface ITrackerOpts {
|
|
4
|
-
required?: boolean;
|
|
5
|
-
isArray?: boolean;
|
|
6
|
-
relationField?: string;
|
|
7
|
-
relatedToField?: string;
|
|
8
|
-
relatedTo?: OpModelType<any>;
|
|
9
|
-
inversionModel?: OpModelType<any>;
|
|
10
|
-
relationName?: string;
|
|
11
|
-
}
|
|
12
|
-
interface IMetaOpts extends ITrackerOpts {
|
|
13
|
-
type: any;
|
|
14
|
-
tags: string[];
|
|
15
|
-
required: boolean;
|
|
16
|
-
isArray: boolean;
|
|
17
|
-
}
|
|
18
|
-
declare function TrackType(type: any, opts?: ITrackerOpts | null, tags?: string[]): (target: any, key: string) => void;
|
|
19
|
-
export default TrackType;
|
|
20
|
-
export { IMetaOpts, ITrackerOpts };
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { OpModelType } from '../models/interfaces/OpModelType';
|
|
3
|
+
interface ITrackerOpts {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
isArray?: boolean;
|
|
6
|
+
relationField?: string;
|
|
7
|
+
relatedToField?: string;
|
|
8
|
+
relatedTo?: OpModelType<any>;
|
|
9
|
+
inversionModel?: OpModelType<any>;
|
|
10
|
+
relationName?: string;
|
|
11
|
+
}
|
|
12
|
+
interface IMetaOpts extends ITrackerOpts {
|
|
13
|
+
type: any;
|
|
14
|
+
tags: string[];
|
|
15
|
+
required: boolean;
|
|
16
|
+
isArray: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare function TrackType(type: any, opts?: ITrackerOpts | null, tags?: string[]): (target: any, key: string) => void;
|
|
19
|
+
export default TrackType;
|
|
20
|
+
export { IMetaOpts, ITrackerOpts };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
function TrackType(type, opts = null, tags = []) {
|
|
5
|
-
if (!opts) {
|
|
6
|
-
opts = {
|
|
7
|
-
required: false,
|
|
8
|
-
isArray: false
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
if (!(opts === null || opts === void 0 ? void 0 : opts.required)) {
|
|
12
|
-
opts.required = false;
|
|
13
|
-
}
|
|
14
|
-
if (!(opts === null || opts === void 0 ? void 0 : opts.isArray)) {
|
|
15
|
-
opts.isArray = false;
|
|
16
|
-
}
|
|
17
|
-
const required = opts.required;
|
|
18
|
-
const isArray = opts.isArray;
|
|
19
|
-
const metaOpts = { type, tags, required, isArray };
|
|
20
|
-
if (opts.relatedToField && opts.relatedTo) {
|
|
21
|
-
metaOpts.relatedToField = opts.relatedToField;
|
|
22
|
-
metaOpts.relatedTo = opts.relatedTo;
|
|
23
|
-
if (!opts.relationField) {
|
|
24
|
-
metaOpts.relationField = opts.relatedTo + '_id';
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
metaOpts.relationField = opts.relationField;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (opts.inversionModel) {
|
|
31
|
-
metaOpts.inversionModel = opts.inversionModel;
|
|
32
|
-
}
|
|
33
|
-
//const resolvedType = typeof type === 'function' ? type() : type;
|
|
34
|
-
if (type._collection) {
|
|
35
|
-
metaOpts.type = type;
|
|
36
|
-
}
|
|
37
|
-
return function (target, key) {
|
|
38
|
-
Reflect.defineMetadata(`TrackType:${key}`, metaOpts, target);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
exports.default = TrackType;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
function TrackType(type, opts = null, tags = []) {
|
|
5
|
+
if (!opts) {
|
|
6
|
+
opts = {
|
|
7
|
+
required: false,
|
|
8
|
+
isArray: false
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.required)) {
|
|
12
|
+
opts.required = false;
|
|
13
|
+
}
|
|
14
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.isArray)) {
|
|
15
|
+
opts.isArray = false;
|
|
16
|
+
}
|
|
17
|
+
const required = opts.required;
|
|
18
|
+
const isArray = opts.isArray;
|
|
19
|
+
const metaOpts = { type, tags, required, isArray };
|
|
20
|
+
if (opts.relatedToField && opts.relatedTo) {
|
|
21
|
+
metaOpts.relatedToField = opts.relatedToField;
|
|
22
|
+
metaOpts.relatedTo = opts.relatedTo;
|
|
23
|
+
if (!opts.relationField) {
|
|
24
|
+
metaOpts.relationField = opts.relatedTo + '_id';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
metaOpts.relationField = opts.relationField;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (opts.inversionModel) {
|
|
31
|
+
metaOpts.inversionModel = opts.inversionModel;
|
|
32
|
+
}
|
|
33
|
+
//const resolvedType = typeof type === 'function' ? type() : type;
|
|
34
|
+
if (type._collection) {
|
|
35
|
+
metaOpts.type = type;
|
|
36
|
+
}
|
|
37
|
+
return function (target, key) {
|
|
38
|
+
Reflect.defineMetadata(`TrackType:${key}`, metaOpts, target);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.default = TrackType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import InverseRelation from './InverseRelation';
|
|
2
|
-
import Relation from './Relation';
|
|
3
|
-
import TrackType, { IMetaOpts } from './TrackType';
|
|
4
|
-
import InverseTimeSeries from './InverseTimeSeries';
|
|
5
|
-
export { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts };
|
|
1
|
+
import InverseRelation from './InverseRelation';
|
|
2
|
+
import Relation from './Relation';
|
|
3
|
+
import TrackType, { IMetaOpts } from './TrackType';
|
|
4
|
+
import InverseTimeSeries from './InverseTimeSeries';
|
|
5
|
+
export { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts };
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = void 0;
|
|
7
|
-
const InverseRelation_1 = __importDefault(require("./InverseRelation"));
|
|
8
|
-
exports.InverseRelation = InverseRelation_1.default;
|
|
9
|
-
const Relation_1 = __importDefault(require("./Relation"));
|
|
10
|
-
exports.Relation = Relation_1.default;
|
|
11
|
-
const TrackType_1 = __importDefault(require("./TrackType"));
|
|
12
|
-
exports.TrackType = TrackType_1.default;
|
|
13
|
-
const InverseTimeSeries_1 = __importDefault(require("./InverseTimeSeries"));
|
|
14
|
-
exports.InverseTimeSeries = InverseTimeSeries_1.default;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = void 0;
|
|
7
|
+
const InverseRelation_1 = __importDefault(require("./InverseRelation"));
|
|
8
|
+
exports.InverseRelation = InverseRelation_1.default;
|
|
9
|
+
const Relation_1 = __importDefault(require("./Relation"));
|
|
10
|
+
exports.Relation = Relation_1.default;
|
|
11
|
+
const TrackType_1 = __importDefault(require("./TrackType"));
|
|
12
|
+
exports.TrackType = TrackType_1.default;
|
|
13
|
+
const InverseTimeSeries_1 = __importDefault(require("./InverseTimeSeries"));
|
|
14
|
+
exports.InverseTimeSeries = InverseTimeSeries_1.default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IDbConfigHandler } from '../types/DbConfigHandler';
|
|
2
|
-
import { IMetaOpts, OpModelType } from '../models/_model';
|
|
3
|
-
import { DBService } from '../services/DBService';
|
|
4
|
-
export declare class DbHelper {
|
|
5
|
-
static installPrisma(configService: IDbConfigHandler, dbService: DBService, leaveFile?: boolean): Promise<void>;
|
|
6
|
-
static generateModelSections(model: OpModelType<any>): Promise<string>;
|
|
7
|
-
static toConfigCase(modelType: IMetaOpts): string;
|
|
8
|
-
}
|
|
1
|
+
import { IDbConfigHandler } from '../types/DbConfigHandler';
|
|
2
|
+
import { IMetaOpts, OpModelType } from '../models/_model';
|
|
3
|
+
import { DBService } from '../services/DBService';
|
|
4
|
+
export declare class DbHelper {
|
|
5
|
+
static installPrisma(configService: IDbConfigHandler, dbService: DBService, leaveFile?: boolean): Promise<void>;
|
|
6
|
+
static generateModelSections(model: OpModelType<any>): Promise<string>;
|
|
7
|
+
static toConfigCase(modelType: IMetaOpts): string;
|
|
8
|
+
}
|