@rws-framework/db 3.3.7 → 3.4.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/.bin/add-v.sh +88 -6
- package/.bin/emerge.sh +10 -10
- package/.eslintrc.json +53 -53
- package/dist/helper/DbHelper.d.ts +1 -1
- package/dist/helper/DbHelper.js +2 -2
- package/dist/helper/db/schema-generator.d.ts +2 -1
- package/dist/helper/db/schema-generator.js +29 -11
- package/dist/models/TimeSeriesModel.d.ts +7 -7
- package/dist/models/TimeSeriesModel.js +33 -33
- package/dist/models/interfaces/ITrackerOpts.d.ts +2 -0
- package/dist/models/types/RelationTypes.d.ts +1 -0
- package/dist/models/utils/HydrateUtils.js +16 -6
- package/dist/models/utils/RelationUtils.js +2 -1
- package/dist/types/DbConfigHandler.d.ts +2 -0
- package/exec/db.rws.webpack.config.js +168 -168
- package/exec/tsconfig.json +32 -32
- package/exec/webpackFilters.js +17 -17
- package/package.json +2 -3
- package/src/decorators/InverseRelation.ts +1 -1
- package/src/decorators/InverseTimeSeries.ts +21 -21
- package/src/helper/DbHelper.ts +2 -2
- package/src/helper/FieldsHelper.ts +34 -34
- package/src/helper/db/schema-generator.ts +36 -12
- package/src/models/core/TimeSeriesModel.ts +19 -19
- package/src/models/interfaces/IModel.ts +12 -12
- package/src/models/interfaces/IRWSModelServices.ts +7 -7
- package/src/models/interfaces/ITrackerOpts.ts +3 -1
- package/src/models/types/RelationTypes.ts +2 -1
- package/src/models/utils/HydrateUtils.ts +16 -7
- package/src/models/utils/PaginationUtils.ts +42 -42
- package/src/models/utils/RelationUtils.ts +2 -1
- package/src/models/utils/TimeSeriesUtils.ts +38 -38
- package/src/types/DbConfigHandler.ts +3 -1
- package/src/types/FindParams.ts +13 -13
- package/src/types/ITimeSeries.ts +5 -5
package/.bin/add-v.sh
CHANGED
|
@@ -1,10 +1,92 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
# Check if version argument is provided
|
|
4
|
+
if [ -z "$1" ]; then
|
|
5
|
+
echo "Error: Version argument is required"
|
|
6
|
+
echo "Usage: $0 <version>"
|
|
7
|
+
echo "Example: $0 1.2.4"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
3
11
|
export VERSION=$1
|
|
4
12
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
# Validate version format (basic semver check)
|
|
14
|
+
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
15
|
+
echo "Error: Version must be in semver format (e.g., 1.2.3)"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Check if we're in a git repository
|
|
20
|
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then
|
|
21
|
+
echo "Error: Not in a git repository"
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# Get list of changed files for commit message
|
|
26
|
+
CHANGED_FILES=$(git diff --name-only HEAD 2>/dev/null || echo "")
|
|
27
|
+
STAGED_FILES=$(git diff --cached --name-only 2>/dev/null || echo "")
|
|
28
|
+
|
|
29
|
+
# Combine changed and staged files
|
|
30
|
+
ALL_CHANGED_FILES="$CHANGED_FILES $STAGED_FILES"
|
|
31
|
+
ALL_CHANGED_FILES=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
|
32
|
+
|
|
33
|
+
# Update package.json version
|
|
34
|
+
echo "Updating package.json version to $VERSION..."
|
|
35
|
+
npm version "$VERSION" --no-git-tag-version || {
|
|
36
|
+
echo "Error: Failed to update package.json version"
|
|
37
|
+
exit 1
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Add all changes
|
|
41
|
+
echo "Adding changes to git..."
|
|
42
|
+
git add . || {
|
|
43
|
+
echo "Error: Failed to add changes to git"
|
|
44
|
+
exit 1
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Create detailed commit message
|
|
48
|
+
if [ -n "$ALL_CHANGED_FILES" ]; then
|
|
49
|
+
COMMIT_MSG="v$VERSION
|
|
50
|
+
|
|
51
|
+
Changed files:
|
|
52
|
+
$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | sed 's/^/- /' | grep -v '^- $')"
|
|
53
|
+
else
|
|
54
|
+
COMMIT_MSG="v$VERSION"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# Commit with version and file list
|
|
58
|
+
echo "Committing version $VERSION..."
|
|
59
|
+
git commit -m "$COMMIT_MSG" || {
|
|
60
|
+
echo "Error: Failed to commit changes"
|
|
61
|
+
exit 1
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Create git tag
|
|
65
|
+
echo "Creating git tag $VERSION..."
|
|
66
|
+
git tag "$VERSION" || {
|
|
67
|
+
echo "Error: Failed to create git tag"
|
|
68
|
+
exit 1
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Push commits
|
|
72
|
+
echo "Pushing commits..."
|
|
73
|
+
git push || {
|
|
74
|
+
echo "Error: Failed to push commits"
|
|
75
|
+
exit 1
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Push tags
|
|
79
|
+
echo "Pushing tags..."
|
|
80
|
+
git push origin "$VERSION" || {
|
|
81
|
+
echo "Error: Failed to push tags"
|
|
82
|
+
exit 1
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Publish to npm
|
|
86
|
+
echo "Publishing to npm..."
|
|
87
|
+
npm publish || {
|
|
88
|
+
echo "Error: Failed to publish to npm"
|
|
89
|
+
exit 1
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
echo "Successfully published version $VERSION!"
|
package/.bin/emerge.sh
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
if ! command -v emerge >/dev/null 2>&1; then
|
|
4
|
-
echo "emerge command does not exist. Installing."
|
|
5
|
-
apt-get install graphviz graphviz-dev
|
|
6
|
-
pip install emerge-viz
|
|
7
|
-
fi
|
|
8
|
-
|
|
9
|
-
mkdir -p ./.emerge-vis-output/rws-server
|
|
10
|
-
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if ! command -v emerge >/dev/null 2>&1; then
|
|
4
|
+
echo "emerge command does not exist. Installing."
|
|
5
|
+
apt-get install graphviz graphviz-dev
|
|
6
|
+
pip install emerge-viz
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
mkdir -p ./.emerge-vis-output/rws-server
|
|
10
|
+
|
|
11
11
|
emerge -c ./.emerge-typescript-template.yaml
|
package/.eslintrc.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": false,
|
|
4
|
-
"es2021": true
|
|
5
|
-
},
|
|
6
|
-
"plugins": ["@typescript-eslint", "unused-imports"],
|
|
7
|
-
"extends": [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:@typescript-eslint/recommended"
|
|
10
|
-
],
|
|
11
|
-
"parser": "@typescript-eslint/parser",
|
|
12
|
-
"parserOptions": {
|
|
13
|
-
"ecmaVersion": "latest",
|
|
14
|
-
"sourceType": "module",
|
|
15
|
-
"project": "./tsconfig.json"
|
|
16
|
-
},
|
|
17
|
-
"ignorePatterns": ["*.js"],
|
|
18
|
-
"rules": {
|
|
19
|
-
"no-unused-vars": "off",
|
|
20
|
-
"no-case-declarations": "off",
|
|
21
|
-
"no-prototype-builtins": "off",
|
|
22
|
-
"unused-imports/no-unused-imports": "error",
|
|
23
|
-
"unused-imports/no-unused-vars": ["warn", { "vars": "all", "args": "none"}],
|
|
24
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
25
|
-
"@typescript-eslint/semi": ["error", "always"],
|
|
26
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
27
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
28
|
-
"@typescript-eslint/no-this-alias": "off",
|
|
29
|
-
"@typescript-eslint/type-annotation-spacing": ["error", {
|
|
30
|
-
"before": false,
|
|
31
|
-
"after": true,
|
|
32
|
-
"overrides": {
|
|
33
|
-
"arrow": {
|
|
34
|
-
"before": true, // Space before the arrow function's arrow
|
|
35
|
-
"after": true // Space after the arrow function's arrow
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}],
|
|
39
|
-
"indent": [
|
|
40
|
-
"error",
|
|
41
|
-
4
|
|
42
|
-
],
|
|
43
|
-
"linebreak-style": [
|
|
44
|
-
"error",
|
|
45
|
-
"unix"
|
|
46
|
-
],
|
|
47
|
-
"quotes": [
|
|
48
|
-
"error",
|
|
49
|
-
"single"
|
|
50
|
-
],
|
|
51
|
-
"semi": "off"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": false,
|
|
4
|
+
"es2021": true
|
|
5
|
+
},
|
|
6
|
+
"plugins": ["@typescript-eslint", "unused-imports"],
|
|
7
|
+
"extends": [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended"
|
|
10
|
+
],
|
|
11
|
+
"parser": "@typescript-eslint/parser",
|
|
12
|
+
"parserOptions": {
|
|
13
|
+
"ecmaVersion": "latest",
|
|
14
|
+
"sourceType": "module",
|
|
15
|
+
"project": "./tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
"ignorePatterns": ["*.js"],
|
|
18
|
+
"rules": {
|
|
19
|
+
"no-unused-vars": "off",
|
|
20
|
+
"no-case-declarations": "off",
|
|
21
|
+
"no-prototype-builtins": "off",
|
|
22
|
+
"unused-imports/no-unused-imports": "error",
|
|
23
|
+
"unused-imports/no-unused-vars": ["warn", { "vars": "all", "args": "none"}],
|
|
24
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
25
|
+
"@typescript-eslint/semi": ["error", "always"],
|
|
26
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
27
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
28
|
+
"@typescript-eslint/no-this-alias": "off",
|
|
29
|
+
"@typescript-eslint/type-annotation-spacing": ["error", {
|
|
30
|
+
"before": false,
|
|
31
|
+
"after": true,
|
|
32
|
+
"overrides": {
|
|
33
|
+
"arrow": {
|
|
34
|
+
"before": true, // Space before the arrow function's arrow
|
|
35
|
+
"after": true // Space after the arrow function's arrow
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}],
|
|
39
|
+
"indent": [
|
|
40
|
+
"error",
|
|
41
|
+
4
|
|
42
|
+
],
|
|
43
|
+
"linebreak-style": [
|
|
44
|
+
"error",
|
|
45
|
+
"unix"
|
|
46
|
+
],
|
|
47
|
+
"quotes": [
|
|
48
|
+
"error",
|
|
49
|
+
"single"
|
|
50
|
+
],
|
|
51
|
+
"semi": "off"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -41,7 +41,7 @@ export declare class DbHelper {
|
|
|
41
41
|
* @param dbUrl The database URL
|
|
42
42
|
* @returns The base schema
|
|
43
43
|
*/
|
|
44
|
-
static generateBaseSchema(dbType: string, dbUrl: string): string;
|
|
44
|
+
static generateBaseSchema(dbType: string, dbUrl: string, output?: string, binaryTargets?: string[]): string;
|
|
45
45
|
/**
|
|
46
46
|
* Get the directory and path for the Prisma schema file
|
|
47
47
|
*/
|
package/dist/helper/DbHelper.js
CHANGED
|
@@ -52,8 +52,8 @@ class DbHelper {
|
|
|
52
52
|
* @param dbUrl The database URL
|
|
53
53
|
* @returns The base schema
|
|
54
54
|
*/
|
|
55
|
-
static generateBaseSchema(dbType, dbUrl) {
|
|
56
|
-
return db_1.SchemaGenerator.generateBaseSchema(dbType, dbUrl);
|
|
55
|
+
static generateBaseSchema(dbType, dbUrl, output, binaryTargets) {
|
|
56
|
+
return db_1.SchemaGenerator.generateBaseSchema(dbType, dbUrl, output, binaryTargets);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Get the directory and path for the Prisma schema file
|
|
@@ -12,7 +12,8 @@ export declare class SchemaGenerator {
|
|
|
12
12
|
* @param dbUrl The database URL
|
|
13
13
|
* @returns The base schema
|
|
14
14
|
*/
|
|
15
|
-
static generateBaseSchema(dbType: string, dbUrl: string): string;
|
|
15
|
+
static generateBaseSchema(dbType: string, dbUrl: string, output?: string, binaryTargets?: string[]): string;
|
|
16
|
+
private static ospath;
|
|
16
17
|
/**
|
|
17
18
|
* Generate model sections for the schema
|
|
18
19
|
* @param model The model to generate a section for
|
|
@@ -24,17 +24,22 @@ class SchemaGenerator {
|
|
|
24
24
|
* @param dbUrl The database URL
|
|
25
25
|
* @returns The base schema
|
|
26
26
|
*/
|
|
27
|
-
static generateBaseSchema(dbType, dbUrl) {
|
|
27
|
+
static generateBaseSchema(dbType, dbUrl, output, binaryTargets) {
|
|
28
28
|
process.env = { ...process.env, [this.dbUrlVarName]: dbUrl };
|
|
29
29
|
return `generator client {
|
|
30
30
|
provider = "prisma-client-js"
|
|
31
|
+
${output ? `output = "${this.ospath(output)}"` : ''}
|
|
32
|
+
${binaryTargets ? `binaryTargets = ${JSON.stringify(binaryTargets)}` : ''}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
datasource db {
|
|
34
36
|
provider = "${dbType}"
|
|
35
|
-
url = env("${this.dbUrlVarName}")
|
|
37
|
+
url = env("${this.dbUrlVarName}")
|
|
36
38
|
}`;
|
|
37
39
|
}
|
|
40
|
+
static ospath(outPath) {
|
|
41
|
+
return outPath.split('')[1] === ':' ? outPath.replace(/\\/g, '\\\\') : outPath;
|
|
42
|
+
}
|
|
38
43
|
/**
|
|
39
44
|
* Generate model sections for the schema
|
|
40
45
|
* @param model The model to generate a section for
|
|
@@ -93,10 +98,16 @@ datasource db {
|
|
|
93
98
|
const relationFieldName = modelMetadata.relationField ? modelMetadata.relationField : key.toLowerCase() + '_' + modelMetadata.relationField.toLowerCase();
|
|
94
99
|
const relatedToField = modelMetadata.relatedToField || 'id';
|
|
95
100
|
const bindingFieldExists = !!modelMetadatas[relationFieldName];
|
|
101
|
+
const relatedFieldMeta = relatedModelMetadatas[relatedToField];
|
|
102
|
+
const foundInverseRelation = Object.values(relatedModelMetadatas).find(item => item.metadata.foreignKey === relationFieldName && item.metadata.inversionModel._collection === modelName);
|
|
96
103
|
if (modelMetadata.required === false) {
|
|
97
104
|
requiredString = '?';
|
|
98
105
|
}
|
|
99
|
-
|
|
106
|
+
let cascadeStr = cascadeOpts.length ? `, ${cascadeOpts.join(', ')}` : '';
|
|
107
|
+
if (foundInverseRelation && foundInverseRelation.metadata.singular) {
|
|
108
|
+
cascadeStr = '';
|
|
109
|
+
requiredString = '?';
|
|
110
|
+
}
|
|
100
111
|
if (isMany) {
|
|
101
112
|
// Add an inverse field to the related model if it doesn't exist
|
|
102
113
|
section += `\t${key} ${relatedModel._collection}[] @relation(${relationName ? `"${relationName}", ` : ''}fields: [${relationFieldName}], references: [${relatedToField}]${mapName ? `, map: "${mapName}"` : ''}${cascadeStr})\n`;
|
|
@@ -104,7 +115,6 @@ datasource db {
|
|
|
104
115
|
else {
|
|
105
116
|
section += `\t${key} ${relatedModel._collection}${requiredString} @relation(${relationName ? `"${relationName}", ` : ''}fields: [${relationFieldName}], references: [${relatedToField}]${mapName ? `, map: "${mapName}"` : ''}${cascadeStr})\n`;
|
|
106
117
|
if (!bindingFieldExists) {
|
|
107
|
-
const relatedFieldMeta = relatedModelMetadatas[relatedToField];
|
|
108
118
|
if (!relatedFieldMeta.metadata.required) {
|
|
109
119
|
requiredString = '';
|
|
110
120
|
}
|
|
@@ -113,24 +123,29 @@ datasource db {
|
|
|
113
123
|
if (relationMeta.required === false) {
|
|
114
124
|
requiredString = '?';
|
|
115
125
|
}
|
|
126
|
+
let appendix = '';
|
|
127
|
+
if (foundInverseRelation && foundInverseRelation.metadata.singular) {
|
|
128
|
+
appendix = ' @unique';
|
|
129
|
+
requiredString = '?';
|
|
130
|
+
}
|
|
116
131
|
// Add relation field with appropriate type based on database
|
|
117
132
|
if (dbType === 'mongodb') {
|
|
118
|
-
section += `\t${relationFieldName} String${requiredString} @db.ObjectId\n`;
|
|
133
|
+
section += `\t${relationFieldName} String${requiredString} @db.ObjectId${appendix}\n`;
|
|
119
134
|
}
|
|
120
135
|
else if (dbType === 'mysql') {
|
|
121
136
|
// For MySQL, determine the type based on the related model's ID type
|
|
122
|
-
section += `\t${relationFieldName} ${relatedFieldType}${requiredString}\n`;
|
|
137
|
+
section += `\t${relationFieldName} ${relatedFieldType}${requiredString}${appendix}\n`;
|
|
123
138
|
}
|
|
124
139
|
else if (dbType === 'postgresql' || dbType === 'postgres') {
|
|
125
140
|
if (relatedFieldType === 'String') {
|
|
126
|
-
section += `\t${relationFieldName} ${relatedFieldType}${requiredString} @db.Uuid\n`;
|
|
141
|
+
section += `\t${relationFieldName} ${relatedFieldType}${requiredString} @db.Uuid${appendix}\n`;
|
|
127
142
|
}
|
|
128
143
|
else {
|
|
129
|
-
section += `\t${relationFieldName} ${relatedFieldType}${requiredString}\n`;
|
|
144
|
+
section += `\t${relationFieldName} ${relatedFieldType}${requiredString}${appendix}\n`;
|
|
130
145
|
}
|
|
131
146
|
}
|
|
132
147
|
else {
|
|
133
|
-
section += `\t${relationFieldName} String${requiredString}\n`;
|
|
148
|
+
section += `\t${relationFieldName} String${requiredString}${appendix}\n`;
|
|
134
149
|
}
|
|
135
150
|
}
|
|
136
151
|
}
|
|
@@ -145,11 +160,12 @@ datasource db {
|
|
|
145
160
|
const relationKey = [relatedModelName, modelName].join('_');
|
|
146
161
|
const relationIndex = relation_manager_1.RelationManager.getRelationCounter(relationKey, true);
|
|
147
162
|
const relationName = relation_manager_1.RelationManager.getShortenedRelationName(relatedModelName, modelName, relationIndex);
|
|
163
|
+
const singular = relationMeta.singular;
|
|
148
164
|
let relationTag = '';
|
|
149
165
|
if (relationMeta.relationName) {
|
|
150
166
|
relationTag = ` @relation("${relationMeta.relationName}")`;
|
|
151
167
|
}
|
|
152
|
-
section += `\t${key} ${relationMeta.inversionModel._collection}[]${relationTag}\n`;
|
|
168
|
+
section += `\t${key} ${relationMeta.inversionModel._collection}${singular ? '?' : '[]'}${relationTag}\n`;
|
|
153
169
|
relation_manager_1.RelationManager.completeRelation(relationKey, relationIndex, true);
|
|
154
170
|
}
|
|
155
171
|
else if (annotationType === 'InverseTimeSeries') {
|
|
@@ -266,7 +282,9 @@ datasource db {
|
|
|
266
282
|
static async installPrisma(configService, dbService, leaveFile = false) {
|
|
267
283
|
const dbUrl = configService.get('db_url');
|
|
268
284
|
const dbType = configService.get('db_type') || 'mongodb';
|
|
269
|
-
|
|
285
|
+
const dbPrismaOutput = configService.get('db_prisma_output');
|
|
286
|
+
const dbPrismaBinaryTargets = configService.get('db_prisma_binary_targets');
|
|
287
|
+
let template = this.generateBaseSchema(dbType, dbUrl, dbPrismaOutput, dbPrismaBinaryTargets);
|
|
270
288
|
const dbModels = configService.get('db_models');
|
|
271
289
|
if (dbModels) {
|
|
272
290
|
for (const model of dbModels) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RWSModel } from './_model';
|
|
2
|
-
export default class TimeSeriesModel<ChildClass> extends RWSModel<TimeSeriesModel<ChildClass>> {
|
|
3
|
-
value: number;
|
|
4
|
-
timestamp: Date;
|
|
5
|
-
params: any;
|
|
6
|
-
constructor(data?: any);
|
|
7
|
-
}
|
|
1
|
+
import { RWSModel } from './_model';
|
|
2
|
+
export default class TimeSeriesModel<ChildClass> extends RWSModel<TimeSeriesModel<ChildClass>> {
|
|
3
|
+
value: number;
|
|
4
|
+
timestamp: Date;
|
|
5
|
+
params: any;
|
|
6
|
+
constructor(data?: any);
|
|
7
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const _model_1 = require("./_model");
|
|
13
|
-
class TimeSeriesModel extends _model_1.RWSModel {
|
|
14
|
-
constructor(data) {
|
|
15
|
-
super(data);
|
|
16
|
-
if (!this.timestamp) {
|
|
17
|
-
this.timestamp = new Date();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = TimeSeriesModel;
|
|
22
|
-
__decorate([
|
|
23
|
-
(0, _model_1.TrackType)(Number),
|
|
24
|
-
__metadata("design:type", Number)
|
|
25
|
-
], TimeSeriesModel.prototype, "value", void 0);
|
|
26
|
-
__decorate([
|
|
27
|
-
(0, _model_1.TrackType)(Date),
|
|
28
|
-
__metadata("design:type", Date)
|
|
29
|
-
], TimeSeriesModel.prototype, "timestamp", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
(0, _model_1.TrackType)(Object),
|
|
32
|
-
__metadata("design:type", Object)
|
|
33
|
-
], TimeSeriesModel.prototype, "params", void 0);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const _model_1 = require("./_model");
|
|
13
|
+
class TimeSeriesModel extends _model_1.RWSModel {
|
|
14
|
+
constructor(data) {
|
|
15
|
+
super(data);
|
|
16
|
+
if (!this.timestamp) {
|
|
17
|
+
this.timestamp = new Date();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = TimeSeriesModel;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, _model_1.TrackType)(Number),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], TimeSeriesModel.prototype, "value", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, _model_1.TrackType)(Date),
|
|
28
|
+
__metadata("design:type", Date)
|
|
29
|
+
], TimeSeriesModel.prototype, "timestamp", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, _model_1.TrackType)(Object),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], TimeSeriesModel.prototype, "params", void 0);
|
|
@@ -48,12 +48,22 @@ class HydrateUtils {
|
|
|
48
48
|
const relationEnabled = !RelationUtils_1.RelationUtils.checkRelDisabled(model, relMeta.key);
|
|
49
49
|
if (relationEnabled) {
|
|
50
50
|
const pk = ModelUtils_1.ModelUtils.findPrimaryKeyFields(model.constructor);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if (relMeta.singular) {
|
|
52
|
+
model[relMeta.key] = await relMeta.inversionModel.findOneBy({
|
|
53
|
+
conditions: {
|
|
54
|
+
[relMeta.foreignKey]: data[pk]
|
|
55
|
+
},
|
|
56
|
+
allowRelations: false
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
model[relMeta.key] = await relMeta.inversionModel.findBy({
|
|
61
|
+
conditions: {
|
|
62
|
+
[relMeta.foreignKey]: data[pk]
|
|
63
|
+
},
|
|
64
|
+
allowRelations: false
|
|
65
|
+
});
|
|
66
|
+
}
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
// Handle one-to-one relations
|
|
@@ -39,7 +39,8 @@ class RelationUtils {
|
|
|
39
39
|
relIds[key] = {
|
|
40
40
|
key: resolvedMetadata.key,
|
|
41
41
|
inversionModel: resolvedMetadata.inversionModel,
|
|
42
|
-
foreignKey: resolvedMetadata.foreignKey
|
|
42
|
+
foreignKey: resolvedMetadata.foreignKey,
|
|
43
|
+
singular: resolvedMetadata?.singular || false
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
}
|
|
@@ -4,6 +4,8 @@ export interface IDbConfigParams {
|
|
|
4
4
|
db_name?: string;
|
|
5
5
|
db_type?: 'mongodb' | 'mysql' | 'sqlite' | 'postgresql' | 'postgres';
|
|
6
6
|
db_models?: OpModelType<any>[];
|
|
7
|
+
db_prisma_output?: string;
|
|
8
|
+
db_prisma_binary_targets?: string[];
|
|
7
9
|
}
|
|
8
10
|
export interface IdGeneratorOptions {
|
|
9
11
|
useUuid?: boolean;
|