ts-serializable 3.7.2 → 4.0.0
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.
|
@@ -15,6 +15,14 @@ import { getPropertyName } from "../utils/GetProperyName.js";
|
|
|
15
15
|
* @class Serializable
|
|
16
16
|
*/
|
|
17
17
|
export class Serializable {
|
|
18
|
+
/**
|
|
19
|
+
* Global setting for serialization and deserialization
|
|
20
|
+
*
|
|
21
|
+
* @static
|
|
22
|
+
* @type {SerializationSettings}
|
|
23
|
+
* @memberof Serializable
|
|
24
|
+
*/
|
|
25
|
+
static defaultSettings = new SerializationSettings();
|
|
18
26
|
/**
|
|
19
27
|
* Deserialize object from static method.
|
|
20
28
|
*
|
|
@@ -260,11 +268,3 @@ export class Serializable {
|
|
|
260
268
|
return getPropertyName(this, property, settings);
|
|
261
269
|
}
|
|
262
270
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Global setting for serialization and deserialization
|
|
265
|
-
*
|
|
266
|
-
* @static
|
|
267
|
-
* @type {SerializationSettings}
|
|
268
|
-
* @memberof Serializable
|
|
269
|
-
*/
|
|
270
|
-
Serializable.defaultSettings = new SerializationSettings();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SerializationSettings } from "../models/SerializationSettings.js";
|
|
2
|
-
export declare const jsonObject: (settings?: Partial<SerializationSettings
|
|
2
|
+
export declare const jsonObject: (settings?: Partial<SerializationSettings>) => ClassDecorator;
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Serializable } from "../classes/Serializable.js";
|
|
3
|
-
export const jsonObject = (settings, extend) => (target) => {
|
|
4
|
-
if (extend === true) {
|
|
5
|
-
Reflect.set(target, "defaultSettings", Serializable.defaultSettings);
|
|
6
|
-
Reflect.set(target, "fromJSON", Serializable.fromJSON);
|
|
7
|
-
Reflect.set(target.prototype, "fromJSON", Serializable.prototype.fromJSON);
|
|
8
|
-
Reflect.set(target.prototype, "deserializeProperty", Serializable.prototype.deserializeProperty);
|
|
9
|
-
Reflect.set(target.prototype, "getJsonPropertyName", Serializable.prototype.getJsonPropertyName);
|
|
10
|
-
Reflect.set(target.prototype, "onWrongType", Serializable.prototype.onWrongType);
|
|
11
|
-
Reflect.set(target.prototype, "toJSON", Serializable.prototype.toJSON);
|
|
12
|
-
Reflect.defineMetadata("ts-serializable:jsonObjectExtended", true, target);
|
|
13
|
-
}
|
|
1
|
+
export const jsonObject = (settings) => (target) => {
|
|
14
2
|
if (settings) {
|
|
15
3
|
Reflect.defineMetadata("ts-serializable:jsonObject", settings, target);
|
|
16
4
|
}
|
|
@@ -6,13 +6,11 @@ import { MissingMemberHandling } from "../enums/MissingMemberHandling.js";
|
|
|
6
6
|
import { DateFormatHandling } from "../enums/DateFormatHandling.js";
|
|
7
7
|
// From newtonsoft https://www.newtonsoft.com/json/help/html/SerializationSettings.htm
|
|
8
8
|
export class SerializationSettings {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.logLevel = LogLevels.Warning;
|
|
17
|
-
}
|
|
9
|
+
dateFormatHandling = DateFormatHandling.IsoDateFormat;
|
|
10
|
+
missingMemberHandling = MissingMemberHandling.Ignore;
|
|
11
|
+
referenceLoopHandling = ReferenceLoopHandling.Serialize;
|
|
12
|
+
nullValueHandling = NullValueHandling.Include;
|
|
13
|
+
defaultValueHandling = DefaultValueHandling.Ignore;
|
|
14
|
+
namingStrategy = null;
|
|
15
|
+
logLevel = LogLevels.Warning;
|
|
18
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-serializable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"author": "Eugene Labutin",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/LabEG/Serializable#readme",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test-watch": "node --watch --import ./ts-loader.js --test --test-reporter=spec --test-reporter-destination=stdout \"tests/**/*.spec.ts\"",
|
|
27
27
|
"coverage": "node --import ./ts-loader.js --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info \"tests/**/*.spec.ts\"",
|
|
28
28
|
"build": "tsc --project tsconfig.build.json && node ./dist/index.js",
|
|
29
|
-
"prepublishOnly": "npm run lint && npm run build && npm run test
|
|
29
|
+
"prepublishOnly": "npm run lint && npm run build && npm run test",
|
|
30
30
|
"release": "cliff-jumper --name 'ts-serializable' --package-path '.' --no-skip-changelog --no-skip-tag",
|
|
31
31
|
"prepare": "husky install"
|
|
32
32
|
},
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"reflect-metadata": ">=0.1.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@commitlint/cli": "^19.
|
|
38
|
-
"@commitlint/config-conventional": "^19.
|
|
39
|
-
"@favware/cliff-jumper": "^
|
|
40
|
-
"@labeg/code-style": "^
|
|
41
|
-
"@swc-node/register": "^1.10.
|
|
42
|
-
"@types/chai": "^5.
|
|
43
|
-
"chai": "^5.
|
|
37
|
+
"@commitlint/cli": "^19.8.0",
|
|
38
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
39
|
+
"@favware/cliff-jumper": "^6.0.0",
|
|
40
|
+
"@labeg/code-style": "^6.2.0",
|
|
41
|
+
"@swc-node/register": "^1.10.10",
|
|
42
|
+
"@types/chai": "^5.2.1",
|
|
43
|
+
"chai": "^5.2.0",
|
|
44
44
|
"husky": "^9.1.7",
|
|
45
|
-
"lint-staged": "^15.
|
|
45
|
+
"lint-staged": "^15.5.0",
|
|
46
46
|
"reflect-metadata": "^0.2.2",
|
|
47
|
-
"typescript": "^5.
|
|
47
|
+
"typescript": "^5.8.2"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"serialization",
|