@things-factory/shell 6.2.115 → 6.2.120
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-server/index.d.ts +1 -0
- package/dist-server/index.js +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/typeorm/json5-transform.d.ts +2 -0
- package/dist-server/typeorm/json5-transform.js +29 -0
- package/dist-server/typeorm/json5-transform.js.map +1 -0
- package/package.json +2 -2
- package/server/index.ts +1 -0
- package/server/typeorm/json5-transform.ts +26 -0
@@ -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"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/shell",
|
3
|
-
"version": "6.2.
|
3
|
+
"version": "6.2.120",
|
4
4
|
"description": "Core module for framework",
|
5
5
|
"bin": {
|
6
6
|
"things-factory": "bin/things-factory",
|
@@ -134,5 +134,5 @@
|
|
134
134
|
"pg": "^8.7.3",
|
135
135
|
"sqlite3": "^5.0.8"
|
136
136
|
},
|
137
|
-
"gitHead": "
|
137
|
+
"gitHead": "6b3b329144401effb7cd8ea0cf1aa4cb5f179dca"
|
138
138
|
}
|
package/server/index.ts
CHANGED
@@ -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
|
+
}
|