@things-factory/shell 7.0.0-alpha.1 → 7.0.0-alpha.21

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.
@@ -0,0 +1,2 @@
1
+ import { ValueTransformer } from 'typeorm';
2
+ export declare const json5Transformer: ValueTransformer;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.json5Transformer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const json5_1 = tslib_1.__importDefault(require("json5"));
6
+ exports.json5Transformer = {
7
+ /**
8
+ * Converts the entity's value to a JSON5 string before storing it in the database.
9
+ * @param {any} entityValue - The unencrypted entity field value.
10
+ * @returns {string} - The stringified JSON5 representation of the entityValue.
11
+ */
12
+ to(entityValue) {
13
+ return json5_1.default.stringify(entityValue);
14
+ },
15
+ /**
16
+ * Converts a JSON5 string from the database back into its original type when retrieving it.
17
+ * @param {string} databaseValue - The JSON5 string stored in the database.
18
+ * @returns {any} - The original type of the entityValue, parsed from the JSON5 string.
19
+ */
20
+ from(databaseValue) {
21
+ try {
22
+ return json5_1.default.parse(databaseValue);
23
+ }
24
+ finally {
25
+ return databaseValue;
26
+ }
27
+ }
28
+ };
29
+ //# sourceMappingURL=json5-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json5-transform.js","sourceRoot":"","sources":["../../server/typeorm/json5-transform.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEZ,QAAA,gBAAgB,GAAqB;IAChD;;;;OAIG;IACH,EAAE,CAAC,WAAgB;QACjB,OAAO,eAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,aAAqB;QACxB,IAAI;YACF,OAAO,eAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;SAClC;gBAAS;YACR,OAAO,aAAa,CAAA;SACrB;IACH,CAAC;CACF,CAAA","sourcesContent":["import { ValueTransformer } from 'typeorm'\nimport json5 from 'json5'\n\nexport const json5Transformer: ValueTransformer = {\n /**\n * Converts the entity's value to a JSON5 string before storing it in the database.\n * @param {any} entityValue - The unencrypted entity field value.\n * @returns {string} - The stringified JSON5 representation of the entityValue.\n */\n to(entityValue: any) {\n return json5.stringify(entityValue)\n },\n\n /**\n * Converts a JSON5 string from the database back into its original type when retrieving it.\n * @param {string} databaseValue - The JSON5 string stored in the database.\n * @returns {any} - The original type of the entityValue, parsed from the JSON5 string.\n */\n from(databaseValue: string) {\n try {\n return json5.parse(databaseValue)\n } finally {\n return databaseValue\n }\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { ValueTransformer } from 'typeorm';
2
+ /**
3
+ * ValueTransformer object for rounding floating point values.
4
+ */
5
+ export declare const roundTransformer: ValueTransformer;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.roundTransformer = void 0;
4
+ /**
5
+ * ValueTransformer object for rounding floating point values.
6
+ */
7
+ exports.roundTransformer = {
8
+ /**
9
+ * Rounds the entity field value before storing it in the database.
10
+ * @param {number | null} value - Floating point value to round or null
11
+ * @returns {number | null} - Rounded number or null
12
+ */
13
+ to: (value) => (value !== null && !isNaN(value) ? Math.round(value * 100) / 100 : null),
14
+ /**
15
+ * Returns the entity field value as it is without any transformation when reading from the database.
16
+ * @param {number} value - Number value read from the database
17
+ * @returns {number} - The number value as is
18
+ */
19
+ from: (value) => value
20
+ };
21
+ //# sourceMappingURL=round-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round-transform.js","sourceRoot":"","sources":["../../server/typeorm/round-transform.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,gBAAgB,GAAqB;IAChD;;;;OAIG;IACH,EAAE,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAEtG;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK;CAC/B,CAAA","sourcesContent":["import { ValueTransformer } from 'typeorm'\n\n/**\n * ValueTransformer object for rounding floating point values.\n */\nexport const roundTransformer: ValueTransformer = {\n /**\n * Rounds the entity field value before storing it in the database.\n * @param {number | null} value - Floating point value to round or null\n * @returns {number | null} - Rounded number or null\n */\n to: (value: number | null) => (value !== null && !isNaN(value) ? Math.round(value * 100) / 100 : null),\n\n /**\n * Returns the entity field value as it is without any transformation when reading from the database.\n * @param {number} value - Number value read from the database\n * @returns {number} - The number value as is\n */\n from: (value: number) => value\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.21",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -41,9 +41,9 @@
41
41
  "@graphql-tools/merge": "^8.3.0",
42
42
  "@graphql-tools/schema": "^8.5.0",
43
43
  "@graphql-tools/utils": "^8.8.0",
44
- "@hatiolab/koa-webpack": "^7.0.0",
44
+ "@hatiolab/koa-webpack": "^6.0.0",
45
45
  "@hatiolab/things-scene": "^3.2.0",
46
- "@koa/cors": "^3.3.0",
46
+ "@koa/cors": "^5.0.0",
47
47
  "@material-design-icons/font": "^0.14.9",
48
48
  "@material/mwc-button": "^0.27.0",
49
49
  "@material/mwc-fab": "^0.27.0",
@@ -128,11 +128,11 @@
128
128
  },
129
129
  "optionalDependencies": {
130
130
  "better-sqlite3": "^7.5.3",
131
- "mssql": "^8.1.2",
131
+ "mssql": "^10.0.2",
132
132
  "mysql2": "^2.3.3",
133
133
  "oracledb": "^5.4.0",
134
134
  "pg": "^8.7.3",
135
135
  "sqlite3": "^5.0.8"
136
136
  },
137
- "gitHead": "778315d165d7f15e147583a45d5079c3d7cbce38"
137
+ "gitHead": "6dff39aa0d60f0fcf760cca9b8453626f222fa57"
138
138
  }
@@ -19,10 +19,6 @@ const defaultOptions: any = {
19
19
  }
20
20
  }
21
21
 
22
- const cache = new InMemoryCache({
23
- addTypename: false
24
- })
25
-
26
22
  /**
27
23
  * GraphqlLocalClient is a utility class for initializing an Apollo Client for a local GraphQL schema.
28
24
  * It provides a static `init` method for setting up the client with a schema and an app context.
@@ -42,6 +38,10 @@ export class GraphqlLocalClient {
42
38
  * @param {object} app - The application context to be passed in as part of the execution context.
43
39
  */
44
40
  static init(schema, app) {
41
+ const cache = new InMemoryCache({
42
+ addTypename: false
43
+ })
44
+
45
45
  GraphqlLocalClient.client = new ApolloClient({
46
46
  defaultOptions,
47
47
  cache,
package/server/index.ts CHANGED
@@ -7,4 +7,7 @@ export * from './pubsub-log-transport'
7
7
  export * from './middlewares'
8
8
  export * from './graphql-local-client'
9
9
  export * from './service'
10
+
10
11
  export * from './typeorm/encrypt-transform'
12
+ export * from './typeorm/json5-transform'
13
+ export * from './typeorm/round-transform'
@@ -1,6 +1,11 @@
1
1
  // ts-import-sorter: disable
2
2
 
3
- /* following 2 lines should be located in top of the file */
3
+ /* following 7 lines should be located in top of the file */
4
+ const OS = require('os')
5
+ process.env.UV_THREADPOOL_SIZE = OS.cpus().length
6
+
7
+ console.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE)
8
+
4
9
  process.env.NODE_ENV = 'development'
5
10
  process.setMaxListeners(0)
6
11
 
@@ -29,13 +34,7 @@ import { initLicense, checkValidity } from '@things-factory/operato-license-chec
29
34
 
30
35
  import { GraphqlLocalClient } from './graphql-local-client'
31
36
  import { databaseInitializer } from './initializers/database'
32
- import {
33
- domainPrivateRouter,
34
- domainPublicRouter,
35
- globalPrivateRouter,
36
- globalPublicRouter,
37
- graphqlRouter
38
- } from './routers'
37
+ import { domainPrivateRouter, domainPublicRouter, globalPrivateRouter, globalPublicRouter, graphqlRouter } from './routers'
39
38
  import { schema } from './schema'
40
39
  import { Domain } from './service'
41
40
  import { EntityManager } from 'typeorm'
package/server/server.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  // ts-import-sorter: disable
2
2
 
3
- /* following 2 lines should be located in top of the file */
3
+ /* following 5 lines should be located in top of the file */
4
+ const OS = require('os')
5
+ process.env.UV_THREADPOOL_SIZE = OS.cpus().length
6
+
7
+ console.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE)
8
+
4
9
  process.env.NODE_ENV = 'production'
5
10
  process.setMaxListeners(0)
6
11
 
@@ -28,13 +33,7 @@ import { initLicense, checkValidity } from '@things-factory/operato-license-chec
28
33
 
29
34
  import { GraphqlLocalClient } from './graphql-local-client'
30
35
  import { databaseInitializer } from './initializers/database'
31
- import {
32
- domainPrivateRouter,
33
- domainPublicRouter,
34
- globalPrivateRouter,
35
- globalPublicRouter,
36
- graphqlRouter
37
- } from './routers'
36
+ import { domainPrivateRouter, domainPublicRouter, globalPrivateRouter, globalPublicRouter, graphqlRouter } from './routers'
38
37
  import { schema } from './schema'
39
38
  import { domainMiddleware } from './middlewares'
40
39
 
@@ -0,0 +1,26 @@
1
+ import { ValueTransformer } from 'typeorm'
2
+ import json5 from 'json5'
3
+
4
+ export const json5Transformer: ValueTransformer = {
5
+ /**
6
+ * Converts the entity's value to a JSON5 string before storing it in the database.
7
+ * @param {any} entityValue - The unencrypted entity field value.
8
+ * @returns {string} - The stringified JSON5 representation of the entityValue.
9
+ */
10
+ to(entityValue: any) {
11
+ return json5.stringify(entityValue)
12
+ },
13
+
14
+ /**
15
+ * Converts a JSON5 string from the database back into its original type when retrieving it.
16
+ * @param {string} databaseValue - The JSON5 string stored in the database.
17
+ * @returns {any} - The original type of the entityValue, parsed from the JSON5 string.
18
+ */
19
+ from(databaseValue: string) {
20
+ try {
21
+ return json5.parse(databaseValue)
22
+ } finally {
23
+ return databaseValue
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,20 @@
1
+ import { ValueTransformer } from 'typeorm'
2
+
3
+ /**
4
+ * ValueTransformer object for rounding floating point values.
5
+ */
6
+ export const roundTransformer: ValueTransformer = {
7
+ /**
8
+ * Rounds the entity field value before storing it in the database.
9
+ * @param {number | null} value - Floating point value to round or null
10
+ * @returns {number | null} - Rounded number or null
11
+ */
12
+ to: (value: number | null) => (value !== null && !isNaN(value) ? Math.round(value * 100) / 100 : null),
13
+
14
+ /**
15
+ * Returns the entity field value as it is without any transformation when reading from the database.
16
+ * @param {number} value - Number value read from the database
17
+ * @returns {number} - The number value as is
18
+ */
19
+ from: (value: number) => value
20
+ }