@rws-framework/db 3.3.8 → 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 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
- git add .
6
- git commit -m "v$VERSION"
7
- git tag $VERSION
8
- git push
9
- git push origin $VERSION
10
- npm publish
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
  */
@@ -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
@@ -277,7 +282,9 @@ datasource db {
277
282
  static async installPrisma(configService, dbService, leaveFile = false) {
278
283
  const dbUrl = configService.get('db_url');
279
284
  const dbType = configService.get('db_type') || 'mongodb';
280
- let template = this.generateBaseSchema(dbType, dbUrl);
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);
281
288
  const dbModels = configService.get('db_models');
282
289
  if (dbModels) {
283
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);
@@ -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;