@rws-framework/db 2.4.0 → 2.4.2
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 +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 +12 -8
- package/dist/helper/DbHelper.js +185 -137
- 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/_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 +14 -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/src/cli.ts +1 -0
- package/package.json +1 -1
- package/src/helper/DbHelper.ts +77 -12
- package/src/index.ts +2 -1
- package/src/models/core/RWSModel.ts +3 -3
- package/src/models/interfaces/IModel.ts +1 -1
- package/src/models/utils/RelationUtils.ts +1 -1
- package/src/types/DbConfigHandler.ts +6 -1
package/dist/helper/DbHelper.js
CHANGED
|
@@ -1,141 +1,189 @@
|
|
|
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.DbHelper = void 0;
|
|
7
|
-
const console_1 = require("@rws-framework/console");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const _model_1 = require("../models/_model");
|
|
12
|
-
const log = console.log;
|
|
13
|
-
const workspaceRoot = console_1.rwsPath.findRootWorkspacePath();
|
|
14
|
-
const moduleDir = path_1.default.resolve(workspaceRoot, 'node_modules', '@rws-framework', 'db');
|
|
15
|
-
class DbHelper {
|
|
16
|
-
static async installPrisma(configService, dbService, leaveFile = false) {
|
|
17
|
-
const dbUrl = configService.get('
|
|
18
|
-
const dbType = 'mongodb';
|
|
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.DbHelper = void 0;
|
|
7
|
+
const console_1 = require("@rws-framework/console");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const _model_1 = require("../models/_model");
|
|
12
|
+
const log = console.log;
|
|
13
|
+
const workspaceRoot = console_1.rwsPath.findRootWorkspacePath();
|
|
14
|
+
const moduleDir = path_1.default.resolve(workspaceRoot, 'node_modules', '@rws-framework', 'db');
|
|
15
|
+
class DbHelper {
|
|
16
|
+
static async installPrisma(configService, dbService, leaveFile = false) {
|
|
17
|
+
const dbUrl = configService.get('db_url');
|
|
18
|
+
const dbType = configService.get('db_type') || 'mongodb';
|
|
19
19
|
let template = `generator client {\n
|
|
20
20
|
provider = "prisma-client-js"\n
|
|
21
|
-
}\n\n`;
|
|
21
|
+
}\n\n`;
|
|
22
22
|
template += `\ndatasource db {\n
|
|
23
23
|
provider = "${dbType}"\n
|
|
24
|
-
url = env("
|
|
25
|
-
}\n\n`;
|
|
26
|
-
const dbModels = configService.get('db_models');
|
|
27
|
-
if (dbModels) {
|
|
28
|
-
for (const model of dbModels) {
|
|
29
|
-
const modelSection = await DbHelper.generateModelSections(model);
|
|
30
|
-
template += '\n\n' + modelSection;
|
|
31
|
-
log(chalk_1.default.green('[RWS]'), chalk_1.default.blue('Building DB Model'), model.name);
|
|
32
|
-
// if(RWSModel.isSubclass(model as any, TimeSeriesModel)){
|
|
33
|
-
// dbService.collectionExists(model._collection).then((exists: boolean) => {
|
|
34
|
-
// if (exists){
|
|
35
|
-
// return;
|
|
36
|
-
// }
|
|
37
|
-
// log(chalk.green('[RWS Init]') + ` creating TimeSeries type collection from ${model} model`);
|
|
38
|
-
// dbService.createTimeSeriesCollection(model._collection);
|
|
39
|
-
// });
|
|
40
|
-
// }
|
|
41
|
-
}
|
|
42
|
-
const schemaDir = path_1.default.join(moduleDir, 'prisma');
|
|
43
|
-
const schemaPath = path_1.default.join(schemaDir, 'schema.prisma');
|
|
44
|
-
if (!fs_1.default.existsSync(schemaDir)) {
|
|
45
|
-
fs_1.default.mkdirSync(schemaDir);
|
|
46
|
-
}
|
|
47
|
-
if (fs_1.default.existsSync(schemaPath)) {
|
|
48
|
-
fs_1.default.unlinkSync(schemaPath);
|
|
49
|
-
}
|
|
50
|
-
fs_1.default.writeFileSync(schemaPath, template);
|
|
51
|
-
process.env
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
24
|
+
url = env("${this.dbUrlVarName}")\n
|
|
25
|
+
}\n\n`;
|
|
26
|
+
const dbModels = configService.get('db_models');
|
|
27
|
+
if (dbModels) {
|
|
28
|
+
for (const model of dbModels) {
|
|
29
|
+
const modelSection = await DbHelper.generateModelSections(model, configService);
|
|
30
|
+
template += '\n\n' + modelSection;
|
|
31
|
+
log(chalk_1.default.green('[RWS]'), chalk_1.default.blue('Building DB Model'), model.name);
|
|
32
|
+
// if(RWSModel.isSubclass(model as any, TimeSeriesModel)){
|
|
33
|
+
// dbService.collectionExists(model._collection).then((exists: boolean) => {
|
|
34
|
+
// if (exists){
|
|
35
|
+
// return;
|
|
36
|
+
// }
|
|
37
|
+
// log(chalk.green('[RWS Init]') + ` creating TimeSeries type collection from ${model} model`);
|
|
38
|
+
// dbService.createTimeSeriesCollection(model._collection);
|
|
39
|
+
// });
|
|
40
|
+
// }
|
|
41
|
+
}
|
|
42
|
+
const schemaDir = path_1.default.join(moduleDir, 'prisma');
|
|
43
|
+
const schemaPath = path_1.default.join(schemaDir, 'schema.prisma');
|
|
44
|
+
if (!fs_1.default.existsSync(schemaDir)) {
|
|
45
|
+
fs_1.default.mkdirSync(schemaDir);
|
|
46
|
+
}
|
|
47
|
+
if (fs_1.default.existsSync(schemaPath)) {
|
|
48
|
+
fs_1.default.unlinkSync(schemaPath);
|
|
49
|
+
}
|
|
50
|
+
fs_1.default.writeFileSync(schemaPath, template);
|
|
51
|
+
process.env = { ...process.env, [this.dbUrlVarName]: dbUrl };
|
|
52
|
+
// Use npx directly with the full path to prisma
|
|
53
|
+
const npxPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'npx');
|
|
54
|
+
const prismaPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'prisma');
|
|
55
|
+
try {
|
|
56
|
+
// Try using npx with the full path
|
|
57
|
+
await console_1.rwsShell.runCommand(`"${npxPath}" prisma generate --schema="${schemaPath}"`, process.cwd());
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
// If that fails, try using the prisma binary directly
|
|
61
|
+
try {
|
|
62
|
+
await console_1.rwsShell.runCommand(`"${prismaPath}" generate --schema="${schemaPath}"`, process.cwd());
|
|
63
|
+
}
|
|
64
|
+
catch (innerError) {
|
|
65
|
+
// If both fail, try using node to run prisma
|
|
66
|
+
const nodePrismaPath = path_1.default.join(workspaceRoot, 'node_modules', 'prisma', 'build', 'index.js');
|
|
67
|
+
await console_1.rwsShell.runCommand(`node "${nodePrismaPath}" generate --schema="${schemaPath}"`, process.cwd());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
leaveFile = false;
|
|
71
|
+
log(chalk_1.default.green('[RWS Init]') + ' prisma schema generated from ', schemaPath);
|
|
72
|
+
if (!leaveFile) {
|
|
73
|
+
fs_1.default.unlinkSync(schemaPath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
static generateId(dbType, options = {}) {
|
|
78
|
+
const { useUuid = false, customType } = options;
|
|
79
|
+
if (customType) {
|
|
80
|
+
return `id ${customType} @id`;
|
|
81
|
+
}
|
|
82
|
+
switch (dbType) {
|
|
83
|
+
case 'mongodb':
|
|
84
|
+
return 'id String @id @default(auto()) @map("_id") @db.ObjectId';
|
|
85
|
+
case 'mysql':
|
|
86
|
+
return useUuid
|
|
87
|
+
? 'id String @id @default(uuid())'
|
|
88
|
+
: 'id Int @id @default(autoincrement())';
|
|
89
|
+
case 'sqlite':
|
|
90
|
+
return 'id Int @id @default(autoincrement())';
|
|
91
|
+
default:
|
|
92
|
+
throw new Error('Kurwa, nieobsługiwany typ bazy danych!');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
static detectInstaller() {
|
|
96
|
+
if (fs_1.default.existsSync(path_1.default.join(workspaceRoot, 'yarn.lock'))) {
|
|
97
|
+
return 'yarn';
|
|
98
|
+
}
|
|
99
|
+
return 'npx';
|
|
100
|
+
}
|
|
101
|
+
static async pushDBModels(configService, dbService, leaveFile = false) {
|
|
102
|
+
process.env = { ...process.env, [this.dbUrlVarName]: configService.get('db_url') };
|
|
103
|
+
const schemaDir = path_1.default.join(moduleDir, 'prisma');
|
|
104
|
+
const schemaPath = path_1.default.join(schemaDir, 'schema.prisma');
|
|
105
|
+
// Use npx directly with the full path to prisma
|
|
106
|
+
const execCmdPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'yarn.cmd');
|
|
107
|
+
const execPrismaPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'yarn.cmd');
|
|
108
|
+
await console_1.rwsShell.runCommand(`${this.detectInstaller()} prisma db push --schema="${schemaPath}"`, process.cwd());
|
|
109
|
+
}
|
|
110
|
+
static async generateModelSections(model, configService) {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
let section = '';
|
|
113
|
+
const modelMetadatas = await _model_1.RWSModel.getModelAnnotations(model);
|
|
114
|
+
const modelName = model._collection;
|
|
115
|
+
section += `model ${modelName} {\n`;
|
|
116
|
+
section += `\t${this.generateId(configService.get('db_type'))}\n`;
|
|
117
|
+
for (const key in modelMetadatas) {
|
|
118
|
+
const modelMetadata = modelMetadatas[key].metadata;
|
|
119
|
+
let requiredString = modelMetadata.required ? '' : '?';
|
|
120
|
+
const annotationType = modelMetadatas[key].annotationType;
|
|
121
|
+
if (key === 'id') {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (annotationType === 'Relation') {
|
|
125
|
+
const relationMeta = modelMetadata;
|
|
126
|
+
const relatedModel = relationMeta.relatedTo;
|
|
127
|
+
const isMany = relationMeta.many;
|
|
128
|
+
const cascadeOpts = [];
|
|
129
|
+
if ((_a = relationMeta.cascade) === null || _a === void 0 ? void 0 : _a.onDelete) {
|
|
130
|
+
cascadeOpts.push(`onDelete: ${relationMeta.cascade.onDelete}`);
|
|
131
|
+
}
|
|
132
|
+
if ((_b = relationMeta.cascade) === null || _b === void 0 ? void 0 : _b.onUpdate) {
|
|
133
|
+
cascadeOpts.push(`onUpdate: ${relationMeta.cascade.onUpdate}`);
|
|
134
|
+
}
|
|
135
|
+
if (isMany) {
|
|
136
|
+
// Handle many-to-many or one-to-many relation
|
|
137
|
+
section += `\t${key} ${relatedModel._collection}[] @relation("${modelName}_${relatedModel._collection}")\n`;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Handle one-to-one or many-to-one relation
|
|
141
|
+
section += `\t${key} ${relatedModel._collection}${requiredString} @relation("${modelName}_${relatedModel._collection}", fields: [${modelMetadata.relationField}], references: [${modelMetadata.relatedToField || 'id'}], ${cascadeOpts.join(', ')})\n`;
|
|
142
|
+
section += `\t${modelMetadata.relationField} String${requiredString} @db.ObjectId\n`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (annotationType === 'InverseRelation') {
|
|
146
|
+
const relationMeta = modelMetadata;
|
|
147
|
+
// Handle inverse relation (one-to-many or one-to-one)
|
|
148
|
+
section += `\t${key} ${relationMeta.inversionModel._collection}[] @relation("${relationMeta.relationName ? relationMeta.relationName : `${relationMeta.inversionModel._collection}_${modelName}`}")\n`;
|
|
149
|
+
}
|
|
150
|
+
else if (annotationType === 'InverseTimeSeries') {
|
|
151
|
+
section += `\t${key} String[] @db.ObjectId\n`;
|
|
152
|
+
}
|
|
153
|
+
else if (annotationType === 'TrackType') {
|
|
154
|
+
const tags = modelMetadata.tags.map((item) => '@' + item);
|
|
155
|
+
if (modelMetadata.isArray || modelMetadata.type.name === 'Array') {
|
|
156
|
+
requiredString = '';
|
|
157
|
+
}
|
|
158
|
+
section += `\t${key} ${DbHelper.toConfigCase(modelMetadata)}${requiredString} ${tags.join(' ')}\n`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
section += '}\n';
|
|
162
|
+
return section;
|
|
163
|
+
}
|
|
164
|
+
static toConfigCase(modelType) {
|
|
165
|
+
const type = modelType.type;
|
|
166
|
+
let input = type.name;
|
|
167
|
+
if (input == 'Number') {
|
|
168
|
+
input = 'Int';
|
|
169
|
+
}
|
|
170
|
+
if (input == 'Object') {
|
|
171
|
+
input = 'Json';
|
|
172
|
+
}
|
|
173
|
+
if (input == 'Date') {
|
|
174
|
+
input = 'DateTime';
|
|
175
|
+
}
|
|
176
|
+
if (input == 'Array') {
|
|
177
|
+
input = 'Json[]';
|
|
178
|
+
}
|
|
179
|
+
const firstChar = input.charAt(0).toUpperCase();
|
|
180
|
+
const restOfString = input.slice(1);
|
|
181
|
+
let resultField = firstChar + restOfString;
|
|
182
|
+
if (modelType.isArray) {
|
|
183
|
+
resultField += '[]';
|
|
184
|
+
}
|
|
185
|
+
return resultField;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.DbHelper = DbHelper;
|
|
189
|
+
DbHelper.dbUrlVarName = 'PRISMA_DB_URL';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare class FieldsHelper {
|
|
2
|
-
private constructor();
|
|
3
|
-
static getAllClassFields(target: any): string[];
|
|
4
|
-
}
|
|
1
|
+
export declare class FieldsHelper {
|
|
2
|
+
private constructor();
|
|
3
|
+
static getAllClassFields(target: any): string[];
|
|
4
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FieldsHelper = void 0;
|
|
4
|
-
class FieldsHelper {
|
|
5
|
-
constructor() {
|
|
6
|
-
throw new Error(`Class ${this.constructor.name} cannot be instanced.`);
|
|
7
|
-
}
|
|
8
|
-
static getAllClassFields(target) {
|
|
9
|
-
// Get instance properties
|
|
10
|
-
const instanceFields = Object.getOwnPropertyNames(target.prototype);
|
|
11
|
-
// Get static properties
|
|
12
|
-
const staticFields = Object.getOwnPropertyNames(target);
|
|
13
|
-
// Get decorated properties using Reflect metadata if available
|
|
14
|
-
const decoratedFields = Reflect.getMetadataKeys(target.prototype) || [];
|
|
15
|
-
// Combine all fields and remove duplicates and methods
|
|
16
|
-
const allFields = new Set([
|
|
17
|
-
...instanceFields,
|
|
18
|
-
...staticFields,
|
|
19
|
-
...decoratedFields
|
|
20
|
-
]);
|
|
21
|
-
// Filter out constructor and methods
|
|
22
|
-
return Array.from(allFields).filter(field => {
|
|
23
|
-
// Remove constructor
|
|
24
|
-
if (field === 'constructor')
|
|
25
|
-
return false;
|
|
26
|
-
// Remove methods
|
|
27
|
-
const descriptor = Object.getOwnPropertyDescriptor(target.prototype, field);
|
|
28
|
-
if (descriptor && typeof descriptor.value === 'function')
|
|
29
|
-
return false;
|
|
30
|
-
return true;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
;
|
|
34
|
-
}
|
|
35
|
-
exports.FieldsHelper = FieldsHelper;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldsHelper = void 0;
|
|
4
|
+
class FieldsHelper {
|
|
5
|
+
constructor() {
|
|
6
|
+
throw new Error(`Class ${this.constructor.name} cannot be instanced.`);
|
|
7
|
+
}
|
|
8
|
+
static getAllClassFields(target) {
|
|
9
|
+
// Get instance properties
|
|
10
|
+
const instanceFields = Object.getOwnPropertyNames(target.prototype);
|
|
11
|
+
// Get static properties
|
|
12
|
+
const staticFields = Object.getOwnPropertyNames(target);
|
|
13
|
+
// Get decorated properties using Reflect metadata if available
|
|
14
|
+
const decoratedFields = Reflect.getMetadataKeys(target.prototype) || [];
|
|
15
|
+
// Combine all fields and remove duplicates and methods
|
|
16
|
+
const allFields = new Set([
|
|
17
|
+
...instanceFields,
|
|
18
|
+
...staticFields,
|
|
19
|
+
...decoratedFields
|
|
20
|
+
]);
|
|
21
|
+
// Filter out constructor and methods
|
|
22
|
+
return Array.from(allFields).filter(field => {
|
|
23
|
+
// Remove constructor
|
|
24
|
+
if (field === 'constructor')
|
|
25
|
+
return false;
|
|
26
|
+
// Remove methods
|
|
27
|
+
const descriptor = Object.getOwnPropertyDescriptor(target.prototype, field);
|
|
28
|
+
if (descriptor && typeof descriptor.value === 'function')
|
|
29
|
+
return false;
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
;
|
|
34
|
+
}
|
|
35
|
+
exports.FieldsHelper = FieldsHelper;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DBService } from "./services/DBService";
|
|
2
|
-
import { RWSModel, OpModelType } from "./models/_model";
|
|
3
|
-
import { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts } from './decorators';
|
|
4
|
-
import { DbHelper } from './helper/DbHelper';
|
|
5
|
-
import { FieldsHelper } from './helper/FieldsHelper';
|
|
6
|
-
import type { FindByType } from './types/FindParams';
|
|
7
|
-
import type { ITimeSeries } from './types/ITimeSeries';
|
|
8
|
-
import type { IDbConfigHandler } from './types/DbConfigHandler';
|
|
9
|
-
import type { IRWSModel } from './types/IRWSModel';
|
|
10
|
-
import { RWSCollection, IRWSCollectionMeta, IRWSCollectionOpts } from "./decorators/RWSCollection";
|
|
11
|
-
export type { IRWSCollectionMeta, IRWSCollectionOpts, IRWSModel, IMetaOpts, OpModelType, IDbConfigHandler, ITimeSeries, };
|
|
12
|
-
export { RWSModel, RWSCollection, DBService, FindByType, InverseRelation, Relation, TrackType, InverseTimeSeries, DbHelper, FieldsHelper };
|
|
1
|
+
import { DBService } from "./services/DBService";
|
|
2
|
+
import { RWSModel, OpModelType } from "./models/_model";
|
|
3
|
+
import { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts } from './decorators';
|
|
4
|
+
import { DbHelper } from './helper/DbHelper';
|
|
5
|
+
import { FieldsHelper } from './helper/FieldsHelper';
|
|
6
|
+
import type { FindByType } from './types/FindParams';
|
|
7
|
+
import type { ITimeSeries } from './types/ITimeSeries';
|
|
8
|
+
import type { IDbConfigHandler, IDbConfigParams } from './types/DbConfigHandler';
|
|
9
|
+
import type { IRWSModel } from './types/IRWSModel';
|
|
10
|
+
import { RWSCollection, IRWSCollectionMeta, IRWSCollectionOpts } from "./decorators/RWSCollection";
|
|
11
|
+
export type { IRWSCollectionMeta, IRWSCollectionOpts, IRWSModel, IMetaOpts, OpModelType, IDbConfigHandler, IDbConfigParams, ITimeSeries, };
|
|
12
|
+
export { RWSModel, RWSCollection, DBService, FindByType, InverseRelation, Relation, TrackType, InverseTimeSeries, DbHelper, FieldsHelper };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FieldsHelper = exports.DbHelper = exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = exports.DBService = exports.RWSCollection = exports.RWSModel = void 0;
|
|
4
|
-
const DBService_1 = require("./services/DBService");
|
|
5
|
-
Object.defineProperty(exports, "DBService", { enumerable: true, get: function () { return DBService_1.DBService; } });
|
|
6
|
-
const _model_1 = require("./models/_model");
|
|
7
|
-
Object.defineProperty(exports, "RWSModel", { enumerable: true, get: function () { return _model_1.RWSModel; } });
|
|
8
|
-
// import TimeSeriesModel from './models/core/TimeSeriesModel';
|
|
9
|
-
const decorators_1 = require("./decorators");
|
|
10
|
-
Object.defineProperty(exports, "InverseRelation", { enumerable: true, get: function () { return decorators_1.InverseRelation; } });
|
|
11
|
-
Object.defineProperty(exports, "Relation", { enumerable: true, get: function () { return decorators_1.Relation; } });
|
|
12
|
-
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return decorators_1.TrackType; } });
|
|
13
|
-
Object.defineProperty(exports, "InverseTimeSeries", { enumerable: true, get: function () { return decorators_1.InverseTimeSeries; } });
|
|
14
|
-
const DbHelper_1 = require("./helper/DbHelper");
|
|
15
|
-
Object.defineProperty(exports, "DbHelper", { enumerable: true, get: function () { return DbHelper_1.DbHelper; } });
|
|
16
|
-
const FieldsHelper_1 = require("./helper/FieldsHelper");
|
|
17
|
-
Object.defineProperty(exports, "FieldsHelper", { enumerable: true, get: function () { return FieldsHelper_1.FieldsHelper; } });
|
|
18
|
-
const RWSCollection_1 = require("./decorators/RWSCollection");
|
|
19
|
-
Object.defineProperty(exports, "RWSCollection", { enumerable: true, get: function () { return RWSCollection_1.RWSCollection; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldsHelper = exports.DbHelper = exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = exports.DBService = exports.RWSCollection = exports.RWSModel = void 0;
|
|
4
|
+
const DBService_1 = require("./services/DBService");
|
|
5
|
+
Object.defineProperty(exports, "DBService", { enumerable: true, get: function () { return DBService_1.DBService; } });
|
|
6
|
+
const _model_1 = require("./models/_model");
|
|
7
|
+
Object.defineProperty(exports, "RWSModel", { enumerable: true, get: function () { return _model_1.RWSModel; } });
|
|
8
|
+
// import TimeSeriesModel from './models/core/TimeSeriesModel';
|
|
9
|
+
const decorators_1 = require("./decorators");
|
|
10
|
+
Object.defineProperty(exports, "InverseRelation", { enumerable: true, get: function () { return decorators_1.InverseRelation; } });
|
|
11
|
+
Object.defineProperty(exports, "Relation", { enumerable: true, get: function () { return decorators_1.Relation; } });
|
|
12
|
+
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return decorators_1.TrackType; } });
|
|
13
|
+
Object.defineProperty(exports, "InverseTimeSeries", { enumerable: true, get: function () { return decorators_1.InverseTimeSeries; } });
|
|
14
|
+
const DbHelper_1 = require("./helper/DbHelper");
|
|
15
|
+
Object.defineProperty(exports, "DbHelper", { enumerable: true, get: function () { return DbHelper_1.DbHelper; } });
|
|
16
|
+
const FieldsHelper_1 = require("./helper/FieldsHelper");
|
|
17
|
+
Object.defineProperty(exports, "FieldsHelper", { enumerable: true, get: function () { return FieldsHelper_1.FieldsHelper; } });
|
|
18
|
+
const RWSCollection_1 = require("./decorators/RWSCollection");
|
|
19
|
+
Object.defineProperty(exports, "RWSCollection", { enumerable: true, get: function () { return RWSCollection_1.RWSCollection; } });
|
package/dist/models/_model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 { RWSModel, TrackType };
|
|
6
|
-
export type { IModel, IRWSModelServices, OpModelType, RelationBindType, RelOneMetaType, RelManyMetaType, IMetaOpts };
|
|
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 { RWSModel, TrackType };
|
|
6
|
+
export type { IModel, IRWSModelServices, OpModelType, RelationBindType, RelOneMetaType, RelManyMetaType, IMetaOpts };
|
package/dist/models/_model.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated This file is deprecated. Import from 'models' directory instead.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TrackType = exports.RWSModel = void 0;
|
|
7
|
-
const index_1 = require("./index");
|
|
8
|
-
Object.defineProperty(exports, "RWSModel", { enumerable: true, get: function () { return index_1.RWSModel; } });
|
|
9
|
-
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return index_1.TrackType; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated This file is deprecated. Import from 'models' directory instead.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TrackType = exports.RWSModel = void 0;
|
|
7
|
+
const index_1 = require("./index");
|
|
8
|
+
Object.defineProperty(exports, "RWSModel", { enumerable: true, get: function () { return index_1.RWSModel; } });
|
|
9
|
+
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return index_1.TrackType; } });
|