@rws-framework/db 2.1.11 → 2.2.1
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/dist/decorators/InverseRelation.d.ts +0 -0
- package/dist/decorators/InverseRelation.js +0 -0
- package/dist/decorators/InverseTimeSeries.d.ts +0 -0
- package/dist/decorators/InverseTimeSeries.js +0 -0
- package/dist/decorators/RWSCollection.d.ts +0 -0
- package/dist/decorators/RWSCollection.js +0 -0
- package/dist/decorators/Relation.d.ts +0 -0
- package/dist/decorators/Relation.js +0 -0
- package/dist/decorators/TrackType.d.ts +1 -1
- package/dist/decorators/TrackType.js +0 -0
- package/dist/decorators/index.d.ts +0 -0
- package/dist/decorators/index.js +0 -0
- package/dist/helper/DbHelper.d.ts +0 -0
- package/dist/helper/DbHelper.js +0 -0
- package/dist/helper/FieldsHelper.d.ts +0 -0
- package/dist/helper/FieldsHelper.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/models/TimeSeriesModel.d.ts +0 -0
- package/dist/models/TimeSeriesModel.js +0 -0
- package/dist/models/_model.d.ts +5 -116
- package/dist/models/_model.js +10 -42
- package/dist/models/core/RWSModel.d.ts +65 -0
- package/dist/models/core/RWSModel.js +375 -0
- package/dist/models/core/TimeSeriesModel.d.ts +7 -0
- package/dist/models/core/TimeSeriesModel.js +34 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +12 -0
- package/dist/models/interfaces/IModel.d.ts +10 -0
- package/dist/models/interfaces/IModel.js +2 -0
- package/dist/models/interfaces/IRWSModelServices.d.ts +6 -0
- package/dist/models/interfaces/IRWSModelServices.js +2 -0
- package/dist/models/interfaces/OpModelType.d.ts +32 -0
- package/dist/models/interfaces/OpModelType.js +2 -0
- package/dist/models/types/RelationTypes.d.ts +24 -0
- package/dist/models/types/RelationTypes.js +2 -0
- package/dist/models/utils/ModelUtils.d.ts +10 -0
- package/dist/models/utils/ModelUtils.js +56 -0
- package/dist/models/utils/PaginationUtils.d.ts +5 -0
- package/dist/models/utils/PaginationUtils.js +32 -0
- package/dist/models/utils/RelationUtils.d.ts +14 -0
- package/dist/models/utils/RelationUtils.js +65 -0
- package/dist/models/utils/TimeSeriesUtils.d.ts +11 -0
- package/dist/models/utils/TimeSeriesUtils.js +35 -0
- package/dist/services/DBService.d.ts +3 -2
- package/dist/services/DBService.js +5 -1
- package/dist/types/DbConfigHandler.d.ts +1 -1
- package/dist/types/DbConfigHandler.js +0 -0
- package/dist/types/FindParams.d.ts +5 -0
- package/dist/types/FindParams.js +0 -0
- package/dist/types/IRWSModel.d.ts +0 -0
- package/dist/types/IRWSModel.js +0 -0
- package/dist/types/ITimeSeries.d.ts +0 -0
- package/dist/types/ITimeSeries.js +0 -0
- package/package.json +1 -1
- package/src/decorators/TrackType.ts +2 -2
- package/src/models/_model.ts +29 -24
- package/src/models/core/RWSModel.ts +482 -0
- package/src/models/core/TimeSeriesModel.ts +19 -0
- package/src/models/index.ts +20 -0
- package/src/models/interfaces/IModel.ts +11 -0
- package/src/models/interfaces/IRWSModelServices.ts +7 -0
- package/src/models/interfaces/OpModelType.ts +49 -0
- package/src/models/types/RelationTypes.ts +25 -0
- package/src/models/utils/ModelUtils.ts +65 -0
- package/src/models/utils/PaginationUtils.ts +42 -0
- package/src/models/utils/RelationUtils.ts +76 -0
- package/src/models/utils/TimeSeriesUtils.ts +38 -0
- package/src/services/DBService.ts +14 -3
- package/src/types/DbConfigHandler.ts +2 -2
- package/src/types/FindParams.ts +10 -4
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/decorators/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/helper/DbHelper.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/models/_model.d.ts
CHANGED
|
@@ -1,116 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { TrackType, IMetaOpts } from '
|
|
5
|
-
|
|
6
|
-
interface IModel {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
id: string | null;
|
|
9
|
-
save: () => void;
|
|
10
|
-
getCollection: () => string | null;
|
|
11
|
-
configService?: IDbConfigHandler;
|
|
12
|
-
dbService?: DBService;
|
|
13
|
-
}
|
|
14
|
-
interface IRWSModelServices {
|
|
15
|
-
configService?: IDbConfigHandler;
|
|
16
|
-
dbService?: DBService;
|
|
17
|
-
}
|
|
18
|
-
type RelationBindType = {
|
|
19
|
-
connect: {
|
|
20
|
-
id: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
type RelOneMetaType<T extends IRWSModel> = {
|
|
24
|
-
[key: string]: {
|
|
25
|
-
required: boolean;
|
|
26
|
-
key?: string;
|
|
27
|
-
model: OpModelType<T>;
|
|
28
|
-
hydrationField: string;
|
|
29
|
-
foreignKey: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
type RelManyMetaType<T extends IRWSModel> = {
|
|
33
|
-
[key: string]: {
|
|
34
|
-
key: string;
|
|
35
|
-
inversionModel: OpModelType<T>;
|
|
36
|
-
foreignKey: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export interface OpModelType<ChildClass> {
|
|
40
|
-
new (data?: any | null): ChildClass;
|
|
41
|
-
services: IRWSModelServices;
|
|
42
|
-
name: string;
|
|
43
|
-
_collection: string;
|
|
44
|
-
_RELATIONS: {
|
|
45
|
-
[key: string]: boolean;
|
|
46
|
-
};
|
|
47
|
-
_CUT_KEYS: string[];
|
|
48
|
-
allModels: OpModelType<any>[];
|
|
49
|
-
loadModels: () => OpModelType<any>[];
|
|
50
|
-
checkForInclusionWithThrow: (className: string) => void;
|
|
51
|
-
checkForInclusion: (className: string) => boolean;
|
|
52
|
-
findOneBy<T extends RWSModel<T>>(this: OpModelType<T>, findParams: FindByType): Promise<T | null>;
|
|
53
|
-
find<T extends RWSModel<T>>(this: OpModelType<T>, id: string, findParams?: Omit<FindByType, 'conditions'>): Promise<T | null>;
|
|
54
|
-
findBy<T extends RWSModel<T>>(this: OpModelType<T>, findParams: FindByType): Promise<T[]>;
|
|
55
|
-
delete<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, conditions: any): Promise<void>;
|
|
56
|
-
create<T extends RWSModel<T>>(this: OpModelType<T>, data: T): Promise<T>;
|
|
57
|
-
getRelationOneMeta(model: any, classFields: string[]): Promise<RelOneMetaType<IRWSModel>>;
|
|
58
|
-
getRelationManyMeta(model: any, classFields: string[]): Promise<RelManyMetaType<IRWSModel>>;
|
|
59
|
-
getCollection(): string;
|
|
60
|
-
setServices(services: IRWSModelServices): void;
|
|
61
|
-
}
|
|
62
|
-
declare class RWSModel<ChildClass> implements IModel {
|
|
63
|
-
static services: IRWSModelServices;
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
id: string;
|
|
66
|
-
static _collection: string;
|
|
67
|
-
static _RELATIONS: {};
|
|
68
|
-
static _BANNED_KEYS: string[];
|
|
69
|
-
static allModels: OpModelType<any>[];
|
|
70
|
-
static _CUT_KEYS: string[];
|
|
71
|
-
constructor(data: any);
|
|
72
|
-
checkForInclusionWithThrow(): void;
|
|
73
|
-
static checkForInclusionWithThrow(this: OpModelType<any>, checkModelType: string): void;
|
|
74
|
-
checkForInclusion(): boolean;
|
|
75
|
-
static checkForInclusion(this: OpModelType<any>, checkModelType: string): boolean;
|
|
76
|
-
_fill(data: any): RWSModel<ChildClass>;
|
|
77
|
-
protected hasRelation(key: string): boolean;
|
|
78
|
-
protected bindRelation(key: string, relatedModel: RWSModel<any>): RelationBindType;
|
|
79
|
-
_asyncFill(data: any, fullDataMode?: boolean, allowRelations?: boolean): Promise<ChildClass>;
|
|
80
|
-
private getModelScalarFields;
|
|
81
|
-
private getTimeSeriesModelFields;
|
|
82
|
-
private getRelationOneMeta;
|
|
83
|
-
static getRelationOneMeta(model: any, classFields: string[]): Promise<RelOneMetaType<RWSModel<any>>>;
|
|
84
|
-
private getRelationManyMeta;
|
|
85
|
-
static getRelationManyMeta(model: any, classFields: string[]): Promise<RelManyMetaType<RWSModel<any>>>;
|
|
86
|
-
toMongo(): Promise<any>;
|
|
87
|
-
getCollection(): string | null;
|
|
88
|
-
static getCollection(): string | null;
|
|
89
|
-
save(): Promise<this>;
|
|
90
|
-
static getModelAnnotations<T extends unknown>(constructor: new () => T): Promise<Record<string, {
|
|
91
|
-
annotationType: string;
|
|
92
|
-
metadata: any;
|
|
93
|
-
}>>;
|
|
94
|
-
preUpdate(): void;
|
|
95
|
-
postUpdate(): void;
|
|
96
|
-
preCreate(): void;
|
|
97
|
-
postCreate(): void;
|
|
98
|
-
static isSubclass<T extends RWSModel<T>, C extends new () => T>(constructor: C, baseClass: new () => T): boolean;
|
|
99
|
-
hasTimeSeries(): boolean;
|
|
100
|
-
static checkTimeSeries(constructor: any): boolean;
|
|
101
|
-
isDbVariable(variable: string): Promise<boolean>;
|
|
102
|
-
static checkDbVariable(constructor: any, variable: string): Promise<boolean>;
|
|
103
|
-
sanitizeDBData(data: any): any;
|
|
104
|
-
static watchCollection<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, preRun: () => void): Promise<any>;
|
|
105
|
-
static findOneBy<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, findParams?: FindByType): Promise<ChildClass | null>;
|
|
106
|
-
static find<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, id: string, findParams?: Omit<FindByType, 'conditions'>): Promise<ChildClass | null>;
|
|
107
|
-
static findBy<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, findParams?: FindByType): Promise<ChildClass[]>;
|
|
108
|
-
static delete<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, conditions: any): Promise<void>;
|
|
109
|
-
delete<ChildClass extends RWSModel<ChildClass>>(): Promise<void>;
|
|
110
|
-
static create<T extends RWSModel<T>>(this: new () => T, data: any): Promise<T>;
|
|
111
|
-
static loadModels(): OpModelType<any>[];
|
|
112
|
-
loadModels(): OpModelType<any>[];
|
|
113
|
-
private checkRelEnabled;
|
|
114
|
-
static setServices(services: IRWSModelServices): void;
|
|
115
|
-
}
|
|
116
|
-
export { IModel, TrackType, IMetaOpts, RWSModel };
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated This file is deprecated. Import from 'models' directory instead.
|
|
3
|
+
*/
|
|
4
|
+
import { IModel, IRWSModelServices, OpModelType, RelationBindType, RelOneMetaType, RelManyMetaType, RWSModel, TrackType, IMetaOpts } from './index';
|
|
5
|
+
export { IModel, IRWSModelServices, OpModelType, RelationBindType, RelOneMetaType, RelManyMetaType, RWSModel, TrackType, IMetaOpts };
|
package/dist/models/_model.js
CHANGED
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated This file is deprecated. Import from 'models' directory instead.
|
|
4
|
+
*/
|
|
44
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
<<<<<<< HEAD
|
|
45
7
|
exports.RWSModel = exports.TrackType = void 0;
|
|
46
8
|
const decorators_1 = require("../decorators");
|
|
47
9
|
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return decorators_1.TrackType; } });
|
|
@@ -497,3 +459,9 @@ __decorate([
|
|
|
497
459
|
(0, decorators_1.TrackType)(String),
|
|
498
460
|
__metadata("design:type", String)
|
|
499
461
|
], RWSModel.prototype, "id", void 0);
|
|
462
|
+
=======
|
|
463
|
+
exports.TrackType = exports.RWSModel = void 0;
|
|
464
|
+
const index_1 = require("./index");
|
|
465
|
+
Object.defineProperty(exports, "RWSModel", { enumerable: true, get: function () { return index_1.RWSModel; } });
|
|
466
|
+
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return index_1.TrackType; } });
|
|
467
|
+
>>>>>>> 7c50786 (v2.2.0)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IModel } from '../interfaces/IModel';
|
|
2
|
+
import { IRWSModelServices } from '../interfaces/IRWSModelServices';
|
|
3
|
+
import { OpModelType } from '../interfaces/OpModelType';
|
|
4
|
+
import { FindByType, IPaginationParams } from '../../types/FindParams';
|
|
5
|
+
import { DBService } from '../../services/DBService';
|
|
6
|
+
declare class RWSModel<ChildClass> implements IModel {
|
|
7
|
+
static services: IRWSModelServices;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
id: string;
|
|
10
|
+
static _collection: string;
|
|
11
|
+
static _RELATIONS: {};
|
|
12
|
+
static _BANNED_KEYS: string[];
|
|
13
|
+
static allModels: OpModelType<any>[];
|
|
14
|
+
static _CUT_KEYS: string[];
|
|
15
|
+
constructor(data: any);
|
|
16
|
+
checkForInclusionWithThrow(): void;
|
|
17
|
+
static checkForInclusionWithThrow(this: OpModelType<any>, checkModelType: string): void;
|
|
18
|
+
checkForInclusion(): boolean;
|
|
19
|
+
static checkForInclusion(this: OpModelType<any>, checkModelType: string): boolean;
|
|
20
|
+
protected _fill(data: any): RWSModel<ChildClass>;
|
|
21
|
+
protected hasRelation(key: string): boolean;
|
|
22
|
+
protected bindRelation(key: string, relatedModel: RWSModel<any>): {
|
|
23
|
+
connect: {
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
_asyncFill(data: any, fullDataMode?: boolean, allowRelations?: boolean): Promise<ChildClass>;
|
|
28
|
+
private getModelScalarFields;
|
|
29
|
+
private getRelationOneMeta;
|
|
30
|
+
static getRelationOneMeta(model: any, classFields: string[]): Promise<import("..").RelOneMetaType<import("../..").IRWSModel>>;
|
|
31
|
+
private getRelationManyMeta;
|
|
32
|
+
static getRelationManyMeta(model: any, classFields: string[]): Promise<import("..").RelManyMetaType<import("../..").IRWSModel>>;
|
|
33
|
+
static paginate<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<any>, pageParams: IPaginationParams, findParams?: FindByType): Promise<RWSModel<ChildClass>[]>;
|
|
34
|
+
toMongo(): Promise<any>;
|
|
35
|
+
getCollection(): string | null;
|
|
36
|
+
static getCollection(): string | null;
|
|
37
|
+
save(): Promise<this>;
|
|
38
|
+
static getModelAnnotations<T extends unknown>(constructor: new () => T): Promise<Record<string, {
|
|
39
|
+
annotationType: string;
|
|
40
|
+
metadata: any;
|
|
41
|
+
}>>;
|
|
42
|
+
preUpdate(): void;
|
|
43
|
+
postUpdate(): void;
|
|
44
|
+
preCreate(): void;
|
|
45
|
+
postCreate(): void;
|
|
46
|
+
static isSubclass<T extends RWSModel<T>, C extends new () => T>(constructor: C, baseClass: new () => T): boolean;
|
|
47
|
+
hasTimeSeries(): boolean;
|
|
48
|
+
static checkTimeSeries(constructor: any): boolean;
|
|
49
|
+
isDbVariable(variable: string): Promise<boolean>;
|
|
50
|
+
static checkDbVariable(constructor: any, variable: string): Promise<boolean>;
|
|
51
|
+
sanitizeDBData(data: any): any;
|
|
52
|
+
static watchCollection<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, preRun: () => void): Promise<any>;
|
|
53
|
+
static findOneBy<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, findParams?: FindByType): Promise<ChildClass | null>;
|
|
54
|
+
static find<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, id: string, findParams?: Omit<FindByType, 'conditions'>): Promise<ChildClass | null>;
|
|
55
|
+
static findBy<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, findParams?: FindByType): Promise<ChildClass[]>;
|
|
56
|
+
static delete<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, conditions: any): Promise<void>;
|
|
57
|
+
delete<ChildClass extends RWSModel<ChildClass>>(): Promise<void>;
|
|
58
|
+
static create<T extends RWSModel<T>>(this: new () => T, data: any): Promise<T>;
|
|
59
|
+
static loadModels(): OpModelType<any>[];
|
|
60
|
+
loadModels(): OpModelType<any>[];
|
|
61
|
+
private checkRelEnabled;
|
|
62
|
+
static setServices(services: IRWSModelServices): void;
|
|
63
|
+
getDb(): DBService;
|
|
64
|
+
}
|
|
65
|
+
export { RWSModel };
|