xml-model 0.1.2 → 0.2.2
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/build/main/defaults/index.js +22 -16
- package/build/main/defaults/models.js +4 -4
- package/build/main/errors.d.ts +4 -0
- package/build/main/errors.js +35 -0
- package/build/main/middleware.js +11 -11
- package/build/main/model/index.d.ts +7 -9
- package/build/main/model/index.js +88 -67
- package/build/main/model/property.js +16 -14
- package/build/main/model/types.d.ts +5 -1
- package/build/main/model/types.js +86 -70
- package/build/main/types.d.ts +10 -2
- package/build/main/types.js +34 -1
- package/build/{module/xml.d.ts → main/xml/index.d.ts} +5 -4
- package/build/main/{xml.js → xml/index.js} +29 -19
- package/build/main/xml/xml-js.d.ts +9 -0
- package/build/main/xml/xml-js.js +26 -0
- package/build/module/defaults/index.js +24 -17
- package/build/module/defaults/models.js +6 -10
- package/build/module/errors.d.ts +4 -0
- package/build/module/errors.js +31 -0
- package/build/module/middleware.js +11 -11
- package/build/module/model/index.d.ts +7 -9
- package/build/module/model/index.js +97 -74
- package/build/module/model/property.js +18 -16
- package/build/module/model/types.d.ts +5 -1
- package/build/module/model/types.js +88 -72
- package/build/module/types.d.ts +10 -2
- package/build/module/types.js +33 -2
- package/build/{main/xml.d.ts → module/xml/index.d.ts} +5 -4
- package/build/module/{xml.js → xml/index.js} +26 -18
- package/build/module/xml/xml-js.d.ts +9 -0
- package/build/module/xml/xml-js.js +24 -0
- package/package.json +2 -2
- package/build/main/model.spec.d.ts +0 -1
- package/build/main/model.spec.js +0 -261
- package/build/module/model.spec.d.ts +0 -1
- package/build/module/model.spec.js +0 -259
|
@@ -13,7 +13,7 @@ const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metada
|
|
|
13
13
|
__RΦ.t[id] = t = l;
|
|
14
14
|
}
|
|
15
15
|
return t;
|
|
16
|
-
}, t: { [
|
|
16
|
+
}, t: { [530]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(501)] }) }, [200]: { LΦ: t => LΦ_0.IΦConstructor }, [501]: { LΦ: t => Object }, [1712]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(8)] }) }, [8]: { RΦ: t => ({ TΦ: "U" }) }, [1715]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(138), p: [__RΦ.a(1712), __RΦ.a(22), __RΦ.a(8)] }) }, [138]: { LΦ: t => Object }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [503]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1)] }) }, [500]: { TΦ: "5", name: "XMLModel" }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [1738]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(503)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [1747]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1618), p: [__RΦ.a(501)] }) }, [1618]: { LΦ: t => LΦ_1.IΦCreateXMLModelOptions }, [523]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(520), p: [__RΦ.a(501)] }) }, [520]: { LΦ: t => LΦ_1.IΦXMLModelOptions }, [1771]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1326)] }) }, [1326]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(420), __RΦ.a(1324)] }) }, [600]: { LΦ: t => LΦ_1.IΦConversionOptions }, [420]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(421), p: [__RΦ.a(419), __RΦ.a(382)] }) }, [421]: { LΦ: t => Object }, [419]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(378), p: [__RΦ.a(1)] }) }, [378]: { LΦ: t => LΦ_1.IΦfromXMLContext }, [382]: { LΦ: t => "properties" }, [1324]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1325), p: [__RΦ.a(1)] }) }, [1325]: { LΦ: t => Object }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [656]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(657), p: [__RΦ.a(501)] }) }, [657]: { LΦ: t => Object }, [1781]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1779)] }) }, [1779]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(1358), __RΦ.a(1777)] }) }, [1358]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1359), p: [__RΦ.a(1357), __RΦ.a(382)] }) }, [1359]: { LΦ: t => Object }, [1357]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(858), p: [__RΦ.a(1)] }) }, [858]: { LΦ: t => LΦ_1.IΦtoXMLContext }, [1777]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1778), p: [__RΦ.a(1)] }) }, [1778]: { LΦ: t => Object }, [888]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(889), p: [__RΦ.a(501)] }) }, [889]: { LΦ: t => Object }, [20]: { LΦ: t => Boolean }, [659]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(665) }, { n: "toXML", f: "", t: __RΦ.a(896) }, { n: "options", f: "", t: __RΦ.a(1072) }] }) }, [665]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(661), __RΦ.a(663)] }) }, [661]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(662), p: [__RΦ.a(604), __RΦ.a(382)] }) }, [662]: { LΦ: t => Object }, [604]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(378), p: [__RΦ.a(521)] }) }, [521]: { LΦ: t => Object }, [663]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(664), p: [__RΦ.a(521)] }) }, [664]: { LΦ: t => Object }, [896]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(892), __RΦ.a(894)] }) }, [892]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(893), p: [__RΦ.a(861), __RΦ.a(382)] }) }, [893]: { LΦ: t => Object }, [861]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(858), p: [__RΦ.a(521)] }) }, [894]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(895), p: [__RΦ.a(521)] }) }, [895]: { LΦ: t => Object }, [1072]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1062), p: [__RΦ.a(1070), __RΦ.a(1071)] }) }, [1062]: { LΦ: t => Map }, [1070]: { LΦ: t => Object }, [1071]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(521)] }) }, [212]: { LΦ: t => LΦ_1.IΦXMLModelPropertyOptions }, [1797]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1795)] }) }, [1795]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(419), __RΦ.a(1)] }) }, [1802]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1800)] }) }, [1800]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(1357), __RΦ.a(109)] }) }, [109]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(105) }] }) }, [105]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(103) }) }, [103]: { LΦ: t => LΦ_2.IΦXMLElement }, [13]: { LΦ: t => String }, [539]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(109)] }) }, [28]: { LΦ: t => Object }, [946]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(942), p: [__RΦ.a(530)] }) }, [942]: { LΦ: t => LΦ_0.ReflectedClass }, [1067]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1062), p: [__RΦ.a(13), __RΦ.a(1061)] }) }, [1061]: { RΦ: t => ({ TΦ: "&", t: [__RΦ.a(1059), __RΦ.a(1060)] }) }, [1059]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1)] }) }, [1060]: { RΦ: t => ({ TΦ: "O", m: [{ n: "model", f: "", t: __RΦ.a(1) }] }) }, [1622]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1617)] }) }, [1617]: { LΦ: t => Object }, [1621]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1618), p: [__RΦ.a(1617)] }) }, [1655]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1617)] }) }, [1720]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1717)] }) }, [1717]: { LΦ: t => Object }, [1733]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1732)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [1732]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1717)] }) }, [1934]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1933)] }) }, [1933]: { LΦ: t => Object }, [1937]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1933)] }) }, [1940]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1618), p: [__RΦ.a(1939)] }) }, [1939]: { LΦ: t => Object }, [1942]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "constructor", t: () => __RΦ.a(1943), v: null }], f: "" }) }, [1943]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1939)] }) } } };
|
|
17
17
|
import "reflect-metadata";
|
|
18
18
|
import { reflect } from "typescript-rtti";
|
|
19
19
|
import { MiddlewareChain, resolve } from "../middleware";
|
|
@@ -35,10 +35,14 @@ function* ParentChain(constructor) {
|
|
|
35
35
|
}
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
38
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1712), v: null }])(ParentChain);
|
|
39
39
|
__RΦ.m("rt:f", "F")(ParentChain);
|
|
40
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
40
|
+
__RΦ.m("rt:t", () => __RΦ.a(1715))(ParentChain);
|
|
41
|
+
import * as LΦ_1 from "./types";
|
|
42
|
+
import * as LΦ_2 from "../types";
|
|
41
43
|
function getParentModel(model) {
|
|
44
|
+
if (model.options.parent)
|
|
45
|
+
return model.options.parent;
|
|
42
46
|
for (const constructor of ParentChain(model.type)) {
|
|
43
47
|
const model = findModel(constructor);
|
|
44
48
|
if (model) {
|
|
@@ -47,33 +51,11 @@ function getParentModel(model) {
|
|
|
47
51
|
}
|
|
48
52
|
return null;
|
|
49
53
|
}
|
|
50
|
-
__RΦ.m("rt:p", [{ n: "model", t: () => __RΦ.a(
|
|
54
|
+
__RΦ.m("rt:p", [{ n: "model", t: () => __RΦ.a(503), v: null }])(getParentModel);
|
|
51
55
|
__RΦ.m("rt:f", "F")(getParentModel);
|
|
52
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
53
|
-
import * as LΦ_1 from "./types";
|
|
54
|
-
import * as LΦ_2 from "xml-js/types";
|
|
55
|
-
var IΦXMLModelConversionOptions = { name: "XMLModelConversionOptions", prototype: {}, identity: Symbol("XMLModelConversionOptions (interface)") };
|
|
56
|
-
export { IΦXMLModelConversionOptions };
|
|
57
|
-
(t => __RΦ.t[1209] = t)(IΦXMLModelConversionOptions);
|
|
58
|
-
__RΦ.m("rt:P", ["fromXML", "tagname", "toXML"])(IΦXMLModelConversionOptions);
|
|
59
|
-
__RΦ.m("rt:m", [])(IΦXMLModelConversionOptions);
|
|
60
|
-
__RΦ.m("rt:f", "Ie")(IΦXMLModelConversionOptions);
|
|
61
|
-
__RΦ.m("rt:t", () => __RΦ.a(1234))(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
62
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
63
|
-
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
64
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
65
|
-
__RΦ.m("rt:t", () => __RΦ.a(1223))(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
66
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
67
|
-
__RΦ.m("rt:t", () => __RΦ.a(1234))(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
68
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
69
|
-
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
70
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
71
|
-
__RΦ.m("rt:t", () => __RΦ.a(1223))(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
72
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
56
|
+
__RΦ.m("rt:t", () => __RΦ.a(1738))(getParentModel);
|
|
73
57
|
import * as LΦ_0 from "typescript-rtti/dist";
|
|
74
58
|
export class XMLModel {
|
|
75
|
-
type;
|
|
76
|
-
options;
|
|
77
59
|
constructor(type, options) {
|
|
78
60
|
this.type = type;
|
|
79
61
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
@@ -83,13 +65,14 @@ export class XMLModel {
|
|
|
83
65
|
if (typeof parent === "undefined")
|
|
84
66
|
parent = getParentModel(this);
|
|
85
67
|
return parent;
|
|
86
|
-
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
68
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1738))], "getParent");
|
|
87
69
|
let propertiesLoaded = false;
|
|
88
70
|
const properties = {
|
|
89
71
|
options: new Map(),
|
|
90
72
|
fromXML: {
|
|
91
73
|
get parent() {
|
|
92
|
-
|
|
74
|
+
var _a;
|
|
75
|
+
return ((_a = getParent()) === null || _a === void 0 ? void 0 : _a.options.properties.fromXML) || null;
|
|
93
76
|
},
|
|
94
77
|
middlewares: [
|
|
95
78
|
__RΦ.f((context, next) => {
|
|
@@ -101,39 +84,50 @@ export class XMLModel {
|
|
|
101
84
|
xml,
|
|
102
85
|
property,
|
|
103
86
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
87
|
+
try {
|
|
88
|
+
record[property.name] = property.fromXML({
|
|
89
|
+
model,
|
|
90
|
+
xml: context.xml,
|
|
91
|
+
property,
|
|
92
|
+
elements,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
throw new XMLConversionError(`[Model: ${context.model.type.name}] failed to convert prop <${String(property.name)}> from XML`, error);
|
|
97
|
+
}
|
|
110
98
|
}, [__RΦ.m("rt:p", [{ n: "property", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
111
99
|
return record;
|
|
112
|
-
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
100
|
+
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(656))], ""),
|
|
113
101
|
],
|
|
114
102
|
},
|
|
115
103
|
toXML: {
|
|
116
104
|
get parent() {
|
|
117
|
-
|
|
105
|
+
var _a;
|
|
106
|
+
return ((_a = getParent()) === null || _a === void 0 ? void 0 : _a.options.properties.toXML) || null;
|
|
118
107
|
},
|
|
119
108
|
middlewares: [
|
|
120
109
|
__RΦ.f((context, next) => {
|
|
121
110
|
const record = getParent() ? next() : {};
|
|
122
111
|
properties.options.forEach(__RΦ.f((options) => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
try {
|
|
113
|
+
record[options.name] = options.toXML({
|
|
114
|
+
model,
|
|
115
|
+
object: context.object,
|
|
116
|
+
property: options,
|
|
117
|
+
value: context.object[options.name],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
throw new XMLConversionError(`[Model: ${context.model.type.name}] failed to convert prop <${String(options.name)}> to XML`, error);
|
|
122
|
+
}
|
|
129
123
|
}, [__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
130
124
|
return record;
|
|
131
|
-
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
125
|
+
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(888))], ""),
|
|
132
126
|
],
|
|
133
127
|
},
|
|
134
128
|
};
|
|
135
129
|
const loadProperties = __RΦ.f(() => {
|
|
136
|
-
const props = reflect(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(
|
|
130
|
+
const props = reflect(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(530)], r: void 0, tp: [] }).ownProperties.filter(__RΦ.f((prop) => typeof prop.host.constructor.prototype[prop.name] !== "function", [__RΦ.m("rt:p", [{ n: "prop", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(20))], "")); // filter out methods like String.prototype.concat etc... that are seen as properties
|
|
137
131
|
props.forEach(__RΦ.f((property) => {
|
|
138
132
|
const options = getPropertyConversionOptions(this.type, property.name);
|
|
139
133
|
if (!options.ignored) {
|
|
@@ -151,22 +145,26 @@ export class XMLModel {
|
|
|
151
145
|
fromXML: {
|
|
152
146
|
middlewares: [],
|
|
153
147
|
get parent() {
|
|
154
|
-
|
|
148
|
+
var _a;
|
|
149
|
+
return ((_a = getParent()) === null || _a === void 0 ? void 0 : _a.options.fromXML) || null;
|
|
155
150
|
},
|
|
156
151
|
},
|
|
157
152
|
toXML: {
|
|
158
153
|
middlewares: [],
|
|
159
154
|
get parent() {
|
|
160
|
-
|
|
155
|
+
var _a;
|
|
156
|
+
return ((_a = getParent()) === null || _a === void 0 ? void 0 : _a.options.toXML) || null;
|
|
161
157
|
},
|
|
162
158
|
},
|
|
163
159
|
get tagname() {
|
|
164
160
|
return options.tagname || defaults.tagnameFromModel(model);
|
|
165
161
|
},
|
|
166
162
|
};
|
|
163
|
+
if (options.parent)
|
|
164
|
+
this.options.parent = options.parent;
|
|
167
165
|
if (!getParent()) {
|
|
168
166
|
this.options.fromXML.middlewares.push(__RΦ.f((...args) => defaults.fromXML(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1))], ""));
|
|
169
|
-
this.options.toXML.middlewares.push(__RΦ.f((...args) => defaults.toXML(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
167
|
+
this.options.toXML.middlewares.push(__RΦ.f((...args) => defaults.toXML(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(109))], ""));
|
|
170
168
|
}
|
|
171
169
|
if (options.fromXML)
|
|
172
170
|
this.options.fromXML.middlewares.push(options.fromXML);
|
|
@@ -193,7 +191,9 @@ export class XMLModel {
|
|
|
193
191
|
toXML(instance) {
|
|
194
192
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
195
193
|
const model = this;
|
|
196
|
-
if (instance instanceof this.type ||
|
|
194
|
+
if (instance instanceof this.type ||
|
|
195
|
+
(typeof instance !== "undefined" && instance.constructor === this.type) // FIXME: allow instance to be Undefined ?
|
|
196
|
+
) {
|
|
197
197
|
// intanceof won't work with type "String" for example
|
|
198
198
|
const context = {
|
|
199
199
|
object: instance,
|
|
@@ -213,46 +213,68 @@ export class XMLModel {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
get reflectedClass() {
|
|
216
|
-
return reflect(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(
|
|
216
|
+
return reflect(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(530)], r: void 0, tp: [] });
|
|
217
|
+
}
|
|
218
|
+
resolveAllProperties() {
|
|
219
|
+
const properties = new Map();
|
|
220
|
+
const parent = getParentModel(this);
|
|
221
|
+
if (parent)
|
|
222
|
+
parent
|
|
223
|
+
.resolveAllProperties()
|
|
224
|
+
.forEach(__RΦ.f((prop, key) => properties.set(key, prop), [__RΦ.m("rt:p", [{ n: "prop", t: () => __RΦ.a(4), v: null }, { n: "key", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1067))], ""));
|
|
225
|
+
this.options.properties.options.forEach(__RΦ.f((options, key) => properties.set(key, new Proxy(options, {
|
|
226
|
+
get: __RΦ.f((target, p, reciever) => {
|
|
227
|
+
if (p === "model")
|
|
228
|
+
return this;
|
|
229
|
+
else
|
|
230
|
+
return Reflect.get(target, p, reciever);
|
|
231
|
+
}, [__RΦ.m("rt:p", [{ n: "target", t: () => __RΦ.a(4), v: null }, { n: "p", t: () => __RΦ.a(4), v: null }, { n: "reciever", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1))], "get"),
|
|
232
|
+
})), [__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(4), v: null }, { n: "key", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1067))], ""));
|
|
233
|
+
return properties;
|
|
217
234
|
}
|
|
218
235
|
}
|
|
219
|
-
(t => __RΦ.t[
|
|
236
|
+
(t => __RΦ.t[500] = t)(XMLModel);
|
|
220
237
|
__RΦ.m("rt:SP", [])(XMLModel);
|
|
221
238
|
__RΦ.m("rt:P", ["options", "type", "reflectedClass"])(XMLModel);
|
|
222
239
|
__RΦ.m("rt:Sm", [])(XMLModel);
|
|
223
|
-
__RΦ.m("rt:m", ["fromXML", "toXML"])(XMLModel);
|
|
224
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
240
|
+
__RΦ.m("rt:m", ["fromXML", "toXML", "resolveAllProperties"])(XMLModel);
|
|
241
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(530), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(1747), v: null }])(XMLModel);
|
|
225
242
|
__RΦ.m("rt:f", "Ce")(XMLModel);
|
|
226
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
243
|
+
__RΦ.m("rt:t", () => __RΦ.a(523))(XMLModel.prototype, "options");
|
|
227
244
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "options");
|
|
228
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
245
|
+
__RΦ.m("rt:t", () => __RΦ.a(1771))(XMLModel.prototype, "parent");
|
|
229
246
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
230
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
247
|
+
__RΦ.m("rt:t", () => __RΦ.a(1781))(XMLModel.prototype, "parent");
|
|
231
248
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
232
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
249
|
+
__RΦ.m("rt:t", () => __RΦ.a(659))(XMLModel.prototype, "properties");
|
|
233
250
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
234
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
251
|
+
__RΦ.m("rt:t", () => __RΦ.a(1797))(XMLModel.prototype, "parent");
|
|
235
252
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
236
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
253
|
+
__RΦ.m("rt:t", () => __RΦ.a(1802))(XMLModel.prototype, "parent");
|
|
237
254
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
238
255
|
__RΦ.m("rt:t", () => __RΦ.a(13))(XMLModel.prototype, "tagname");
|
|
239
256
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "tagname");
|
|
240
257
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype["fromXML"]);
|
|
241
258
|
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "fromXML");
|
|
242
|
-
__RΦ.m("rt:p", [{ n: "xml", t: () => __RΦ.a(
|
|
259
|
+
__RΦ.m("rt:p", [{ n: "xml", t: () => __RΦ.a(539), v: null }])(XMLModel.prototype, "fromXML");
|
|
243
260
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "fromXML");
|
|
244
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
245
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
261
|
+
__RΦ.m("rt:t", () => __RΦ.a(501))(XMLModel.prototype, "fromXML");
|
|
262
|
+
__RΦ.m("rt:t", () => __RΦ.a(656))(XMLModel.prototype, "properties");
|
|
246
263
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
247
264
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype["toXML"]);
|
|
248
265
|
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "toXML");
|
|
249
266
|
__RΦ.m("rt:p", [{ n: "instance", t: () => __RΦ.a(28), v: null }])(XMLModel.prototype, "toXML");
|
|
250
267
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "toXML");
|
|
251
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
252
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
268
|
+
__RΦ.m("rt:t", () => __RΦ.a(109))(XMLModel.prototype, "toXML");
|
|
269
|
+
__RΦ.m("rt:t", () => __RΦ.a(888))(XMLModel.prototype, "properties");
|
|
253
270
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
254
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
271
|
+
__RΦ.m("rt:t", () => __RΦ.a(946))(XMLModel.prototype, "reflectedClass");
|
|
255
272
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "reflectedClass");
|
|
273
|
+
__RΦ.m("rt:f", "M.")(XMLModel.prototype["resolveAllProperties"]);
|
|
274
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "resolveAllProperties");
|
|
275
|
+
__RΦ.m("rt:p", [])(XMLModel.prototype, "resolveAllProperties");
|
|
276
|
+
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "resolveAllProperties");
|
|
277
|
+
__RΦ.m("rt:t", () => __RΦ.a(1067))(XMLModel.prototype, "resolveAllProperties");
|
|
256
278
|
export function createModel(type, options) {
|
|
257
279
|
if (findModel(type)) {
|
|
258
280
|
throw new TypeError(`a model for type ${type.name} already exists`);
|
|
@@ -261,16 +283,16 @@ export function createModel(type, options) {
|
|
|
261
283
|
Models.set(type, model);
|
|
262
284
|
return model;
|
|
263
285
|
}
|
|
264
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
286
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(1622), v: null }, { n: "options", t: () => __RΦ.a(1621), v: null }])(createModel);
|
|
265
287
|
__RΦ.m("rt:f", "F")(createModel);
|
|
266
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
288
|
+
__RΦ.m("rt:t", () => __RΦ.a(1655))(createModel);
|
|
267
289
|
export const Models = new Map();
|
|
268
290
|
export function findModel(id) {
|
|
269
291
|
return Models.get(id);
|
|
270
292
|
}
|
|
271
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
293
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1720), v: null }])(findModel);
|
|
272
294
|
__RΦ.m("rt:f", "F")(findModel);
|
|
273
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
295
|
+
__RΦ.m("rt:t", () => __RΦ.a(1733))(findModel);
|
|
274
296
|
export function getModel(id) {
|
|
275
297
|
const model = findModel(id);
|
|
276
298
|
if (model)
|
|
@@ -278,18 +300,19 @@ export function getModel(id) {
|
|
|
278
300
|
else
|
|
279
301
|
throw new TypeError(`couln't find model for type ${id.name}`);
|
|
280
302
|
}
|
|
281
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
303
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1934), v: null }])(getModel);
|
|
282
304
|
__RΦ.m("rt:f", "F")(getModel);
|
|
283
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
305
|
+
__RΦ.m("rt:t", () => __RΦ.a(1937))(getModel);
|
|
284
306
|
// Model decorator
|
|
285
307
|
function ModelDecoratorFactory(options) {
|
|
286
308
|
return __RΦ.f(function (constructor) {
|
|
287
309
|
findModel(constructor) || createModel(constructor, options || {});
|
|
288
|
-
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
310
|
+
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1943), v: null }]), __RΦ.m("rt:f", "M"), __RΦ.m("rt:t", () => __RΦ.a(22))], "");
|
|
289
311
|
}
|
|
290
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
312
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1940), v: null, f: "?" }])(ModelDecoratorFactory);
|
|
291
313
|
__RΦ.m("rt:f", "F")(ModelDecoratorFactory);
|
|
292
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
314
|
+
__RΦ.m("rt:t", () => __RΦ.a(1942))(ModelDecoratorFactory);
|
|
293
315
|
export { ModelDecoratorFactory as Model };
|
|
294
316
|
export { Prop } from "./property";
|
|
295
317
|
import "../defaults/models";
|
|
318
|
+
import { XMLConversionError } from "../errors";
|
|
@@ -13,17 +13,17 @@ const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metada
|
|
|
13
13
|
__RΦ.t[id] = t = l;
|
|
14
14
|
}
|
|
15
15
|
return t;
|
|
16
|
-
}, t: { [
|
|
16
|
+
}, t: { [203]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(195)] }) }, [200]: { LΦ: t => LΦ_0.IΦConstructor }, [195]: { LΦ: t => Object }, [199]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(196), p: [__RΦ.a(195)] }) }, [196]: { LΦ: t => LΦ_1.IΦCreateXMLModelPropertyOptions }, [211]: { LΦ: t => Object }, [215]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(195)] }) }, [212]: { LΦ: t => LΦ_1.IΦXMLModelPropertyOptions }, [495]: { LΦ: t => LΦ_0.ReflectedProperty }, [13]: { LΦ: t => String }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [20]: { LΦ: t => Boolean }, [105]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(103) }) }, [103]: { LΦ: t => LΦ_2.IΦXMLElement }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [109]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(105) }] }) }, [1405]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1404)] }) }, [1404]: { LΦ: t => Object }, [1407]: { LΦ: t => Object }, [1408]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1404)] }) }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [1420]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1419)] }) }, [1419]: { LΦ: t => Object }, [1422]: { LΦ: t => Object }, [1431]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1423)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [1423]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1419)] }) }, [1437]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1436)] }) }, [1436]: { LΦ: t => Object }, [1439]: { LΦ: t => Object }, [1463]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1436)] }) }, [1470]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(196), p: [__RΦ.a(1469)] }) }, [1469]: { LΦ: t => Object }, [1472]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "prototype", t: () => __RΦ.a(1), v: null }, { n: "property", t: () => __RΦ.a(1474), v: null }], f: "" }) }, [1474]: { LΦ: t => Object } } };
|
|
17
17
|
import { reflect } from "typescript-rtti";
|
|
18
18
|
import * as LΦ_1 from "./types";
|
|
19
|
-
import * as LΦ_2 from "
|
|
19
|
+
import * as LΦ_2 from "../types";
|
|
20
20
|
import { defaults } from "../defaults";
|
|
21
21
|
import * as LΦ_0 from "typescript-rtti/dist";
|
|
22
22
|
function resolvePropertyConversionOptions(options, constructor, property) {
|
|
23
23
|
const _options = {
|
|
24
24
|
name: property,
|
|
25
25
|
get reflected() {
|
|
26
|
-
return reflect(constructor, { TΦ: "c", t: void 0, p: [__RΦ.a(
|
|
26
|
+
return reflect(constructor, { TΦ: "c", t: void 0, p: [__RΦ.a(203)], r: void 0, tp: [] }).getProperty(property);
|
|
27
27
|
},
|
|
28
28
|
get tagname() {
|
|
29
29
|
return options.tagname || defaults.tagnameFromProperty(this);
|
|
@@ -33,11 +33,13 @@ function resolvePropertyConversionOptions(options, constructor, property) {
|
|
|
33
33
|
isSourceElement: __RΦ.f((...args) => defaults.propertySourceElementsFilter(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(20))], "isSourceElement"),
|
|
34
34
|
resolveElements: options.resolveElements
|
|
35
35
|
? options.resolveElements
|
|
36
|
-
: __RΦ.f((...args) => defaults.propertyResolveSourceElements(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
36
|
+
: __RΦ.f((...args) => defaults.propertyResolveSourceElements(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(105))], ""),
|
|
37
37
|
fromXML: __RΦ.f((context) => (options.fromXML || defaults.propertyFromXML)(context), [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1))], "fromXML"),
|
|
38
|
-
toXML: __RΦ.f((context) => (options.toXML || defaults.propertyToXML)(context), [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
38
|
+
toXML: __RΦ.f((context) => (options.toXML || defaults.propertyToXML)(context), [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(109))], "toXML"),
|
|
39
39
|
};
|
|
40
|
-
if (options
|
|
40
|
+
if (options === null || options === void 0 ? void 0 : options.model)
|
|
41
|
+
_options.model = options.model;
|
|
42
|
+
if (options === null || options === void 0 ? void 0 : options.sourceElements) {
|
|
41
43
|
const _sourceElements = options.sourceElements;
|
|
42
44
|
if (typeof _sourceElements === "string") {
|
|
43
45
|
_options.isSourceElement = __RΦ.f((element) => element.name === _sourceElements, [__RΦ.m("rt:p", [{ n: "element", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(20))], "");
|
|
@@ -51,9 +53,9 @@ function resolvePropertyConversionOptions(options, constructor, property) {
|
|
|
51
53
|
}
|
|
52
54
|
return _options;
|
|
53
55
|
}
|
|
54
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
56
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(199), v: null }, { n: "constructor", t: () => __RΦ.a(203), v: null }, { n: "property", t: () => __RΦ.a(211), v: null }])(resolvePropertyConversionOptions);
|
|
55
57
|
__RΦ.m("rt:f", "F")(resolvePropertyConversionOptions);
|
|
56
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
58
|
+
__RΦ.m("rt:t", () => __RΦ.a(215))(resolvePropertyConversionOptions);
|
|
57
59
|
const PropertyOptions = new Map();
|
|
58
60
|
function storePropertyConversionOptions(constructor, property, options) {
|
|
59
61
|
let map = PropertyOptions.get(constructor);
|
|
@@ -63,7 +65,7 @@ function storePropertyConversionOptions(constructor, property, options) {
|
|
|
63
65
|
}
|
|
64
66
|
map.set(property, options);
|
|
65
67
|
}
|
|
66
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
68
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1405), v: null }, { n: "property", t: () => __RΦ.a(1407), v: null }, { n: "options", t: () => __RΦ.a(1408), v: null }])(storePropertyConversionOptions);
|
|
67
69
|
__RΦ.m("rt:f", "F")(storePropertyConversionOptions);
|
|
68
70
|
__RΦ.m("rt:t", () => __RΦ.a(22))(storePropertyConversionOptions);
|
|
69
71
|
function findPropertyConversionOptions(constructor, property) {
|
|
@@ -72,23 +74,23 @@ function findPropertyConversionOptions(constructor, property) {
|
|
|
72
74
|
return options.get(property);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
77
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1420), v: null }, { n: "property", t: () => __RΦ.a(1422), v: null }])(findPropertyConversionOptions);
|
|
76
78
|
__RΦ.m("rt:f", "F")(findPropertyConversionOptions);
|
|
77
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
79
|
+
__RΦ.m("rt:t", () => __RΦ.a(1431))(findPropertyConversionOptions);
|
|
78
80
|
export function getPropertyConversionOptions(constructor, property) {
|
|
79
81
|
const options = findPropertyConversionOptions(constructor, property);
|
|
80
82
|
return options || resolvePropertyConversionOptions({}, constructor, property);
|
|
81
83
|
}
|
|
82
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
84
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1437), v: null }, { n: "property", t: () => __RΦ.a(1439), v: null }])(getPropertyConversionOptions);
|
|
83
85
|
__RΦ.m("rt:f", "F")(getPropertyConversionOptions);
|
|
84
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
86
|
+
__RΦ.m("rt:t", () => __RΦ.a(1463))(getPropertyConversionOptions);
|
|
85
87
|
function PropDecoratorFactory(options) {
|
|
86
88
|
return __RΦ.f(function (prototype, property) {
|
|
87
89
|
const _options = resolvePropertyConversionOptions(options || {}, prototype.constructor, property);
|
|
88
90
|
storePropertyConversionOptions(prototype.constructor, property, _options);
|
|
89
|
-
}, [__RΦ.m("rt:p", [{ n: "prototype", t: () => __RΦ.a(1), v: null }, { n: "property", t: () => __RΦ.a(
|
|
91
|
+
}, [__RΦ.m("rt:p", [{ n: "prototype", t: () => __RΦ.a(1), v: null }, { n: "property", t: () => __RΦ.a(1474), v: null }]), __RΦ.m("rt:f", "M."), __RΦ.m("rt:t", () => __RΦ.a(22))], "");
|
|
90
92
|
}
|
|
91
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
93
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1470), v: null, f: "?" }])(PropDecoratorFactory);
|
|
92
94
|
__RΦ.m("rt:f", "F")(PropDecoratorFactory);
|
|
93
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
95
|
+
__RΦ.m("rt:t", () => __RΦ.a(1472))(PropDecoratorFactory);
|
|
94
96
|
export { PropDecoratorFactory as Prop };
|
|
@@ -23,6 +23,7 @@ export interface XMLModelPropertyOptions<T> {
|
|
|
23
23
|
tagname: string;
|
|
24
24
|
ignored: boolean;
|
|
25
25
|
inline: boolean;
|
|
26
|
+
model?: XMLModel<any>;
|
|
26
27
|
isSourceElement: (element: XMLElement, context: Omit<PropertyFromXMLContext<T>, "elements">) => boolean;
|
|
27
28
|
resolveElements: (context: Omit<PropertyFromXMLContext<T>, "elements">) => XMLElement[];
|
|
28
29
|
fromXML: (context: PropertyFromXMLContext<T>) => T[keyof T];
|
|
@@ -36,6 +37,7 @@ export interface CreateXMLModelPropertyOptions<T> {
|
|
|
36
37
|
fromXML?: XMLModelPropertyOptions<T>["fromXML"];
|
|
37
38
|
inline?: boolean;
|
|
38
39
|
ignore?: boolean;
|
|
40
|
+
model?: XMLModelPropertyOptions<T>["model"];
|
|
39
41
|
}
|
|
40
42
|
interface ConversionOptions<C, T> {
|
|
41
43
|
parent: ConversionOptions<C, T> | null;
|
|
@@ -52,6 +54,7 @@ export interface toXMLContext<T> {
|
|
|
52
54
|
model: XMLModel<T>;
|
|
53
55
|
}
|
|
54
56
|
export interface XMLModelOptions<T> {
|
|
57
|
+
parent?: XMLModel<T>;
|
|
55
58
|
properties: {
|
|
56
59
|
fromXML: ConversionOptions<Omit<fromXMLContext<T>, "properties">, PropertiesRecord<T>>;
|
|
57
60
|
toXML: ConversionOptions<Omit<toXMLContext<T>, "properties">, XMLPropertiesRecord<T>>;
|
|
@@ -62,8 +65,9 @@ export interface XMLModelOptions<T> {
|
|
|
62
65
|
tagname: string;
|
|
63
66
|
}
|
|
64
67
|
export interface CreateXMLModelOptions<T> {
|
|
68
|
+
parent?: XMLModelOptions<T>["parent"];
|
|
65
69
|
fromXML?: XMLModelOptions<T>["fromXML"]["middlewares"][number];
|
|
66
|
-
tagname?: string;
|
|
67
70
|
toXML?: XMLModelOptions<T>["toXML"]["middlewares"][number];
|
|
71
|
+
tagname?: XMLModelOptions<T>["tagname"];
|
|
68
72
|
}
|
|
69
73
|
export { XMLModel };
|