xml-model 0.1.1 → 0.2.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/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 +22 -16
- package/build/module/defaults/models.js +5 -5
- package/build/module/errors.d.ts +4 -0
- package/build/module/errors.js +32 -0
- package/build/module/middleware.js +11 -11
- package/build/module/model/index.d.ts +7 -9
- package/build/module/model/index.js +89 -68
- package/build/module/model/property.js +17 -15
- 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} +24 -17
- package/build/module/xml/xml-js.d.ts +9 -0
- package/build/module/xml/xml-js.js +24 -0
- package/package.json +3 -4
- 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: { [533]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(504)] }) }, [200]: { LΦ: t => LΦ_0.IΦConstructor }, [504]: { LΦ: t => Object }, [1716]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(8)] }) }, [8]: { RΦ: t => ({ TΦ: "U" }) }, [1719]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(138), p: [__RΦ.a(1716), __RΦ.a(22), __RΦ.a(8)] }) }, [138]: { LΦ: t => Object }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [506]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(503), p: [__RΦ.a(1)] }) }, [503]: { TΦ: "5", name: "XMLModel" }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [1742]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(506)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [1751]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(504)] }) }, [1622]: { LΦ: t => LΦ_1.IΦCreateXMLModelOptions }, [526]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(523), p: [__RΦ.a(504)] }) }, [523]: { LΦ: t => LΦ_1.IΦXMLModelOptions }, [1775]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1330)] }) }, [1330]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(603), p: [__RΦ.a(423), __RΦ.a(1328)] }) }, [603]: { LΦ: t => LΦ_1.IΦConversionOptions }, [423]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(424), p: [__RΦ.a(422), __RΦ.a(385)] }) }, [424]: { LΦ: t => Object }, [422]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(381), p: [__RΦ.a(1)] }) }, [381]: { LΦ: t => LΦ_1.IΦfromXMLContext }, [385]: { LΦ: t => "properties" }, [1328]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1329), p: [__RΦ.a(1)] }) }, [1329]: { LΦ: t => Object }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [659]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(660), p: [__RΦ.a(504)] }) }, [660]: { LΦ: t => Object }, [1785]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1783)] }) }, [1783]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(603), p: [__RΦ.a(1362), __RΦ.a(1781)] }) }, [1362]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1363), p: [__RΦ.a(1361), __RΦ.a(385)] }) }, [1363]: { LΦ: t => Object }, [1361]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(862), p: [__RΦ.a(1)] }) }, [862]: { LΦ: t => LΦ_1.IΦtoXMLContext }, [1781]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1782), p: [__RΦ.a(1)] }) }, [1782]: { LΦ: t => Object }, [892]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(893), p: [__RΦ.a(504)] }) }, [893]: { LΦ: t => Object }, [20]: { LΦ: t => Boolean }, [662]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(668) }, { n: "toXML", f: "", t: __RΦ.a(900) }, { n: "options", f: "", t: __RΦ.a(1076) }] }) }, [668]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(603), p: [__RΦ.a(664), __RΦ.a(666)] }) }, [664]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(665), p: [__RΦ.a(607), __RΦ.a(385)] }) }, [665]: { LΦ: t => Object }, [607]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(381), p: [__RΦ.a(524)] }) }, [524]: { LΦ: t => Object }, [666]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(667), p: [__RΦ.a(524)] }) }, [667]: { LΦ: t => Object }, [900]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(603), p: [__RΦ.a(896), __RΦ.a(898)] }) }, [896]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(897), p: [__RΦ.a(865), __RΦ.a(385)] }) }, [897]: { LΦ: t => Object }, [865]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(862), p: [__RΦ.a(524)] }) }, [898]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(899), p: [__RΦ.a(524)] }) }, [899]: { LΦ: t => Object }, [1076]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1066), p: [__RΦ.a(1074), __RΦ.a(1075)] }) }, [1066]: { LΦ: t => Map }, [1074]: { LΦ: t => Object }, [1075]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(524)] }) }, [212]: { LΦ: t => LΦ_1.IΦXMLModelPropertyOptions }, [1801]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1799)] }) }, [1799]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(603), p: [__RΦ.a(422), __RΦ.a(1)] }) }, [1806]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1804)] }) }, [1804]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(603), p: [__RΦ.a(1361), __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 }, [542]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(109)] }) }, [28]: { LΦ: t => Object }, [950]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(946), p: [__RΦ.a(533)] }) }, [946]: { LΦ: t => LΦ_0.ReflectedClass }, [1071]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1066), p: [__RΦ.a(13), __RΦ.a(1065)] }) }, [1065]: { RΦ: t => ({ TΦ: "&", t: [__RΦ.a(1063), __RΦ.a(1064)] }) }, [1063]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1)] }) }, [1064]: { RΦ: t => ({ TΦ: "O", m: [{ n: "model", f: "", t: __RΦ.a(1) }] }) }, [1626]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1621)] }) }, [1621]: { LΦ: t => Object }, [1625]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(1621)] }) }, [1659]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(503), p: [__RΦ.a(1621)] }) }, [1724]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1721)] }) }, [1721]: { LΦ: t => Object }, [1737]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1736)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [1736]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(503), p: [__RΦ.a(1721)] }) }, [1938]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1937)] }) }, [1937]: { LΦ: t => Object }, [1941]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(503), p: [__RΦ.a(1937)] }) }, [1944]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(1943)] }) }, [1943]: { LΦ: t => Object }, [1946]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "constructor", t: () => __RΦ.a(1947), v: null }], f: "" }) }, [1947]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1943)] }) } } };
|
|
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(1716), 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(1719))(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,29 +51,9 @@ 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(506), 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(1742))(getParentModel);
|
|
73
57
|
import * as LΦ_0 from "typescript-rtti/dist";
|
|
74
58
|
export class XMLModel {
|
|
75
59
|
type;
|
|
@@ -83,7 +67,7 @@ export class XMLModel {
|
|
|
83
67
|
if (typeof parent === "undefined")
|
|
84
68
|
parent = getParentModel(this);
|
|
85
69
|
return parent;
|
|
86
|
-
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
70
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1742))], "getParent");
|
|
87
71
|
let propertiesLoaded = false;
|
|
88
72
|
const properties = {
|
|
89
73
|
options: new Map(),
|
|
@@ -101,15 +85,20 @@ export class XMLModel {
|
|
|
101
85
|
xml,
|
|
102
86
|
property,
|
|
103
87
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
try {
|
|
89
|
+
record[property.name] = property.fromXML({
|
|
90
|
+
model,
|
|
91
|
+
xml: context.xml,
|
|
92
|
+
property,
|
|
93
|
+
elements,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new XMLConversionError(`[Model: ${context.model.type.name}] failed to convert prop <${String(property.name)}> from XML`, error);
|
|
98
|
+
}
|
|
110
99
|
}, [__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
100
|
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(
|
|
101
|
+
}, [__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(659))], ""),
|
|
113
102
|
],
|
|
114
103
|
},
|
|
115
104
|
toXML: {
|
|
@@ -120,20 +109,25 @@ export class XMLModel {
|
|
|
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(892))], ""),
|
|
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(533)], 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) {
|
|
@@ -164,9 +158,11 @@ export class XMLModel {
|
|
|
164
158
|
return options.tagname || defaults.tagnameFromModel(model);
|
|
165
159
|
},
|
|
166
160
|
};
|
|
161
|
+
if (options.parent)
|
|
162
|
+
this.options.parent = options.parent;
|
|
167
163
|
if (!getParent()) {
|
|
168
164
|
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(
|
|
165
|
+
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
166
|
}
|
|
171
167
|
if (options.fromXML)
|
|
172
168
|
this.options.fromXML.middlewares.push(options.fromXML);
|
|
@@ -193,7 +189,9 @@ export class XMLModel {
|
|
|
193
189
|
toXML(instance) {
|
|
194
190
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
195
191
|
const model = this;
|
|
196
|
-
if (instance instanceof this.type ||
|
|
192
|
+
if (instance instanceof this.type ||
|
|
193
|
+
(typeof instance !== "undefined" && instance.constructor === this.type) // FIXME: allow instance to be Undefined ?
|
|
194
|
+
) {
|
|
197
195
|
// intanceof won't work with type "String" for example
|
|
198
196
|
const context = {
|
|
199
197
|
object: instance,
|
|
@@ -213,46 +211,68 @@ export class XMLModel {
|
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
get reflectedClass() {
|
|
216
|
-
return reflect(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(
|
|
214
|
+
return reflect(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(533)], r: void 0, tp: [] });
|
|
215
|
+
}
|
|
216
|
+
resolveAllProperties() {
|
|
217
|
+
const properties = new Map();
|
|
218
|
+
const parent = getParentModel(this);
|
|
219
|
+
if (parent)
|
|
220
|
+
parent
|
|
221
|
+
.resolveAllProperties()
|
|
222
|
+
.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(1071))], ""));
|
|
223
|
+
this.options.properties.options.forEach(__RΦ.f((options, key) => properties.set(key, new Proxy(options, {
|
|
224
|
+
get: __RΦ.f((target, p, reciever) => {
|
|
225
|
+
if (p === "model")
|
|
226
|
+
return this;
|
|
227
|
+
else
|
|
228
|
+
return Reflect.get(target, p, reciever);
|
|
229
|
+
}, [__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"),
|
|
230
|
+
})), [__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(1071))], ""));
|
|
231
|
+
return properties;
|
|
217
232
|
}
|
|
218
233
|
}
|
|
219
|
-
(t => __RΦ.t[
|
|
234
|
+
(t => __RΦ.t[503] = t)(XMLModel);
|
|
220
235
|
__RΦ.m("rt:SP", [])(XMLModel);
|
|
221
236
|
__RΦ.m("rt:P", ["options", "type", "reflectedClass"])(XMLModel);
|
|
222
237
|
__RΦ.m("rt:Sm", [])(XMLModel);
|
|
223
|
-
__RΦ.m("rt:m", ["fromXML", "toXML"])(XMLModel);
|
|
224
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
238
|
+
__RΦ.m("rt:m", ["fromXML", "toXML", "resolveAllProperties"])(XMLModel);
|
|
239
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(533), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(1751), v: null }])(XMLModel);
|
|
225
240
|
__RΦ.m("rt:f", "Ce")(XMLModel);
|
|
226
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
241
|
+
__RΦ.m("rt:t", () => __RΦ.a(526))(XMLModel.prototype, "options");
|
|
227
242
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "options");
|
|
228
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
243
|
+
__RΦ.m("rt:t", () => __RΦ.a(1775))(XMLModel.prototype, "parent");
|
|
229
244
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
230
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
245
|
+
__RΦ.m("rt:t", () => __RΦ.a(1785))(XMLModel.prototype, "parent");
|
|
231
246
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
232
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
247
|
+
__RΦ.m("rt:t", () => __RΦ.a(662))(XMLModel.prototype, "properties");
|
|
233
248
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
234
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
249
|
+
__RΦ.m("rt:t", () => __RΦ.a(1801))(XMLModel.prototype, "parent");
|
|
235
250
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
236
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
251
|
+
__RΦ.m("rt:t", () => __RΦ.a(1806))(XMLModel.prototype, "parent");
|
|
237
252
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
238
253
|
__RΦ.m("rt:t", () => __RΦ.a(13))(XMLModel.prototype, "tagname");
|
|
239
254
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "tagname");
|
|
240
255
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype["fromXML"]);
|
|
241
256
|
((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(
|
|
257
|
+
__RΦ.m("rt:p", [{ n: "xml", t: () => __RΦ.a(542), v: null }])(XMLModel.prototype, "fromXML");
|
|
243
258
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "fromXML");
|
|
244
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
245
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
259
|
+
__RΦ.m("rt:t", () => __RΦ.a(504))(XMLModel.prototype, "fromXML");
|
|
260
|
+
__RΦ.m("rt:t", () => __RΦ.a(659))(XMLModel.prototype, "properties");
|
|
246
261
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
247
262
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype["toXML"]);
|
|
248
263
|
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "toXML");
|
|
249
264
|
__RΦ.m("rt:p", [{ n: "instance", t: () => __RΦ.a(28), v: null }])(XMLModel.prototype, "toXML");
|
|
250
265
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "toXML");
|
|
251
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
252
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
266
|
+
__RΦ.m("rt:t", () => __RΦ.a(109))(XMLModel.prototype, "toXML");
|
|
267
|
+
__RΦ.m("rt:t", () => __RΦ.a(892))(XMLModel.prototype, "properties");
|
|
253
268
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
254
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
269
|
+
__RΦ.m("rt:t", () => __RΦ.a(950))(XMLModel.prototype, "reflectedClass");
|
|
255
270
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "reflectedClass");
|
|
271
|
+
__RΦ.m("rt:f", "M.")(XMLModel.prototype["resolveAllProperties"]);
|
|
272
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "resolveAllProperties");
|
|
273
|
+
__RΦ.m("rt:p", [])(XMLModel.prototype, "resolveAllProperties");
|
|
274
|
+
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "resolveAllProperties");
|
|
275
|
+
__RΦ.m("rt:t", () => __RΦ.a(1071))(XMLModel.prototype, "resolveAllProperties");
|
|
256
276
|
export function createModel(type, options) {
|
|
257
277
|
if (findModel(type)) {
|
|
258
278
|
throw new TypeError(`a model for type ${type.name} already exists`);
|
|
@@ -261,16 +281,16 @@ export function createModel(type, options) {
|
|
|
261
281
|
Models.set(type, model);
|
|
262
282
|
return model;
|
|
263
283
|
}
|
|
264
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
284
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(1626), v: null }, { n: "options", t: () => __RΦ.a(1625), v: null }])(createModel);
|
|
265
285
|
__RΦ.m("rt:f", "F")(createModel);
|
|
266
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
286
|
+
__RΦ.m("rt:t", () => __RΦ.a(1659))(createModel);
|
|
267
287
|
export const Models = new Map();
|
|
268
288
|
export function findModel(id) {
|
|
269
289
|
return Models.get(id);
|
|
270
290
|
}
|
|
271
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
291
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1724), v: null }])(findModel);
|
|
272
292
|
__RΦ.m("rt:f", "F")(findModel);
|
|
273
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
293
|
+
__RΦ.m("rt:t", () => __RΦ.a(1737))(findModel);
|
|
274
294
|
export function getModel(id) {
|
|
275
295
|
const model = findModel(id);
|
|
276
296
|
if (model)
|
|
@@ -278,18 +298,19 @@ export function getModel(id) {
|
|
|
278
298
|
else
|
|
279
299
|
throw new TypeError(`couln't find model for type ${id.name}`);
|
|
280
300
|
}
|
|
281
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
301
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1938), v: null }])(getModel);
|
|
282
302
|
__RΦ.m("rt:f", "F")(getModel);
|
|
283
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
303
|
+
__RΦ.m("rt:t", () => __RΦ.a(1941))(getModel);
|
|
284
304
|
// Model decorator
|
|
285
305
|
function ModelDecoratorFactory(options) {
|
|
286
306
|
return __RΦ.f(function (constructor) {
|
|
287
307
|
findModel(constructor) || createModel(constructor, options || {});
|
|
288
|
-
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
308
|
+
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1947), v: null }]), __RΦ.m("rt:f", "M"), __RΦ.m("rt:t", () => __RΦ.a(22))], "");
|
|
289
309
|
}
|
|
290
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
310
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1944), v: null, f: "?" }])(ModelDecoratorFactory);
|
|
291
311
|
__RΦ.m("rt:f", "F")(ModelDecoratorFactory);
|
|
292
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
312
|
+
__RΦ.m("rt:t", () => __RΦ.a(1946))(ModelDecoratorFactory);
|
|
293
313
|
export { ModelDecoratorFactory as Model };
|
|
294
314
|
export { Prop } from "./property";
|
|
295
315
|
import "../defaults/models";
|
|
316
|
+
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 }, [498]: { 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) }] }) }, [1409]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1408)] }) }, [1408]: { LΦ: t => Object }, [1411]: { LΦ: t => Object }, [1412]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1408)] }) }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [1424]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1423)] }) }, [1423]: { LΦ: t => Object }, [1426]: { LΦ: t => Object }, [1435]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1427)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [1427]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1423)] }) }, [1441]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1440)] }) }, [1440]: { LΦ: t => Object }, [1443]: { LΦ: t => Object }, [1467]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1440)] }) }, [1474]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(196), p: [__RΦ.a(1473)] }) }, [1473]: { LΦ: t => Object }, [1476]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "prototype", t: () => __RΦ.a(1), v: null }, { n: "property", t: () => __RΦ.a(1478), v: null }], f: "" }) }, [1478]: { 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,10 +33,12 @@ 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?.model)
|
|
41
|
+
_options.model = options.model;
|
|
40
42
|
if (options?.sourceElements) {
|
|
41
43
|
const _sourceElements = options.sourceElements;
|
|
42
44
|
if (typeof _sourceElements === "string") {
|
|
@@ -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(1409), v: null }, { n: "property", t: () => __RΦ.a(1411), v: null }, { n: "options", t: () => __RΦ.a(1412), 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(1424), v: null }, { n: "property", t: () => __RΦ.a(1426), 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(1435))(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(1441), v: null }, { n: "property", t: () => __RΦ.a(1443), 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(1467))(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(1478), 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(1474), 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(1476))(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 };
|