xml-model 0.2.3 → 0.2.6
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/models.js +2 -2
- package/build/main/model/index.js +34 -31
- package/build/main/model/property.js +13 -10
- package/build/main/model/types.js +10 -10
- package/build/main/model.spec.d.ts +2 -0
- package/build/main/model.spec.js +234 -0
- package/build/module/defaults/models.js +2 -2
- package/build/module/model/index.js +34 -31
- package/build/module/model/property.js +13 -10
- package/build/module/model/types.js +10 -10
- package/build/module/model.spec.d.ts +2 -0
- package/build/module/model.spec.js +229 -0
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metada
|
|
|
15
15
|
__RΦ.t[id] = t = l;
|
|
16
16
|
}
|
|
17
17
|
return t;
|
|
18
|
-
}, t: { [4]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [13]: { LΦ: t => String }, [14]: { LΦ: t => Number }, [
|
|
18
|
+
}, t: { [4]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [13]: { LΦ: t => String }, [14]: { LΦ: t => Number }, [1698]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(3125) }] }) }, [3125]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(3123) }) }, [3123]: { RΦ: t => ({ TΦ: "O", m: [{ n: "type", f: "", t: __RΦ.a(13) }, { n: "name", f: "", t: __RΦ.a(13) }] }) }, [20]: { LΦ: t => Boolean } } };
|
|
19
19
|
const model_1 = require("../model");
|
|
20
20
|
const xml_1 = require("../xml");
|
|
21
21
|
// string is <string>value</string>
|
|
@@ -48,7 +48,7 @@ const xml_1 = require("../xml");
|
|
|
48
48
|
Object.assign({ type: "element", name: "boolean" }, (0, xml_1.fromContent)(String(ctx.object))),
|
|
49
49
|
],
|
|
50
50
|
};
|
|
51
|
-
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
51
|
+
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1698))], "toXML"),
|
|
52
52
|
fromXML: __RΦ.f((ctx) => {
|
|
53
53
|
return Boolean((0, xml_1.getContent)(ctx.xml.elements[0]));
|
|
54
54
|
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(20))], "fromXML"),
|
|
@@ -19,7 +19,7 @@ const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metada
|
|
|
19
19
|
__RΦ.t[id] = t = l;
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
|
-
}, t: { [532]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(503)] }) }, [202]: { LΦ: t => require("typescript-rtti/dist").IΦConstructor }, [503]: { LΦ: t => Object }, [
|
|
22
|
+
}, t: { [532]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(503)] }) }, [202]: { LΦ: t => require("typescript-rtti/dist").IΦConstructor }, [503]: { LΦ: t => Object }, [1716]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(8)] }) }, [8]: { RΦ: t => ({ TΦ: "U" }) }, [1719]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(140), p: [__RΦ.a(1716), __RΦ.a(22), __RΦ.a(8)] }) }, [140]: { LΦ: t => Object }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [505]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1)] }) }, [502]: { TΦ: "5", name: "XMLModel" }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [1742]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(505)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [1751]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(503)] }) }, [1622]: { LΦ: t => require("./types").IΦCreateXMLModelOptions }, [525]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(522), p: [__RΦ.a(503)] }) }, [522]: { LΦ: t => require("./types").IΦXMLModelOptions }, [1775]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1328)] }) }, [1328]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(422), __RΦ.a(1326)] }) }, [602]: { LΦ: t => require("./types").IΦConversionOptions }, [422]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(423), p: [__RΦ.a(421), __RΦ.a(384)] }) }, [423]: { LΦ: t => Object }, [421]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(380), p: [__RΦ.a(1)] }) }, [380]: { LΦ: t => require("./types").IΦfromXMLContext }, [384]: { LΦ: t => "properties" }, [1326]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1327), p: [__RΦ.a(1)] }) }, [1327]: { LΦ: t => Object }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [658]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(659), p: [__RΦ.a(503)] }) }, [659]: { LΦ: t => Object }, [1785]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1783)] }) }, [1783]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(1360), __RΦ.a(1781)] }) }, [1360]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1361), p: [__RΦ.a(1359), __RΦ.a(384)] }) }, [1361]: { LΦ: t => Object }, [1359]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(860), p: [__RΦ.a(1)] }) }, [860]: { LΦ: t => require("./types").IΦtoXMLContext }, [1781]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1782), p: [__RΦ.a(1)] }) }, [1782]: { LΦ: t => Object }, [890]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(891), p: [__RΦ.a(503)] }) }, [891]: { LΦ: t => Object }, [20]: { LΦ: t => Boolean }, [661]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(667) }, { n: "toXML", f: "", t: __RΦ.a(898) }, { n: "options", f: "", t: __RΦ.a(1074) }] }) }, [667]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(663), __RΦ.a(665)] }) }, [663]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(664), p: [__RΦ.a(606), __RΦ.a(384)] }) }, [664]: { LΦ: t => Object }, [606]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(380), p: [__RΦ.a(523)] }) }, [523]: { LΦ: t => Object }, [665]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(666), p: [__RΦ.a(523)] }) }, [666]: { LΦ: t => Object }, [898]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(894), __RΦ.a(896)] }) }, [894]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(895), p: [__RΦ.a(863), __RΦ.a(384)] }) }, [895]: { LΦ: t => Object }, [863]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(860), p: [__RΦ.a(523)] }) }, [896]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(897), p: [__RΦ.a(523)] }) }, [897]: { LΦ: t => Object }, [1074]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1064), p: [__RΦ.a(1072), __RΦ.a(1073)] }) }, [1064]: { LΦ: t => Map }, [1072]: { LΦ: t => Object }, [1073]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(523)] }) }, [214]: { LΦ: t => require("./types").IΦXMLModelPropertyOptions }, [1801]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1799)] }) }, [1799]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(421), __RΦ.a(1)] }) }, [1806]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1804)] }) }, [1804]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(1359), __RΦ.a(111)] }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [13]: { LΦ: t => String }, [541]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(111)] }) }, [28]: { LΦ: t => Object }, [948]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(944), p: [__RΦ.a(532)] }) }, [944]: { LΦ: t => require("typescript-rtti/dist").ReflectedClass }, [1069]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1064), p: [__RΦ.a(13), __RΦ.a(1063)] }) }, [1063]: { RΦ: t => ({ TΦ: "&", t: [__RΦ.a(1061), __RΦ.a(1062)] }) }, [1061]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1)] }) }, [1062]: { RΦ: t => ({ TΦ: "O", m: [{ n: "model", f: "", t: __RΦ.a(1) }] }) }, [1626]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), 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(502), p: [__RΦ.a(1621)] }) }, [1724]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), 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(502), p: [__RΦ.a(1721)] }) }, [1882]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1881)] }) }, [1881]: { LΦ: t => Object }, [1885]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1881)] }) }, [1888]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(1887)] }) }, [1887]: { LΦ: t => Object }, [1890]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "constructor", t: () => __RΦ.a(1891), v: null }], f: "" }) }, [1891]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1887)] }) } } };
|
|
23
23
|
const typescript_rtti_1 = require("typescript-rtti");
|
|
24
24
|
const middleware_1 = require("../middleware");
|
|
25
25
|
const property_1 = require("./property");
|
|
@@ -40,9 +40,9 @@ function* ParentChain(constructor) {
|
|
|
40
40
|
}
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
43
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1716), v: null }])(ParentChain);
|
|
44
44
|
__RΦ.m("rt:f", "F")(ParentChain);
|
|
45
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
45
|
+
__RΦ.m("rt:t", () => __RΦ.a(1719))(ParentChain);
|
|
46
46
|
function getParentModel(model) {
|
|
47
47
|
if (model.options.parent)
|
|
48
48
|
return model.options.parent;
|
|
@@ -56,7 +56,7 @@ function getParentModel(model) {
|
|
|
56
56
|
}
|
|
57
57
|
__RΦ.m("rt:p", [{ n: "model", t: () => __RΦ.a(505), v: null }])(getParentModel);
|
|
58
58
|
__RΦ.m("rt:f", "F")(getParentModel);
|
|
59
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
59
|
+
__RΦ.m("rt:t", () => __RΦ.a(1742))(getParentModel);
|
|
60
60
|
class XMLModel {
|
|
61
61
|
constructor(type, options) {
|
|
62
62
|
this.type = type;
|
|
@@ -67,7 +67,7 @@ class XMLModel {
|
|
|
67
67
|
if (typeof parent === "undefined")
|
|
68
68
|
parent = getParentModel(this);
|
|
69
69
|
return parent;
|
|
70
|
-
}, [__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");
|
|
71
71
|
let propertiesLoaded = false;
|
|
72
72
|
const properties = {
|
|
73
73
|
options: new Map(),
|
|
@@ -129,7 +129,7 @@ class XMLModel {
|
|
|
129
129
|
},
|
|
130
130
|
};
|
|
131
131
|
const loadProperties = __RΦ.f(() => {
|
|
132
|
-
const props =
|
|
132
|
+
const props = this.reflectedClass.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
|
|
133
133
|
props.forEach(__RΦ.f((property) => {
|
|
134
134
|
const options = (0, property_1.getPropertyConversionOptions)(this.type, property.name);
|
|
135
135
|
if (!options.ignored) {
|
|
@@ -221,17 +221,20 @@ class XMLModel {
|
|
|
221
221
|
const properties = new Map();
|
|
222
222
|
const parent = getParentModel(this);
|
|
223
223
|
if (parent)
|
|
224
|
-
parent
|
|
225
|
-
.
|
|
226
|
-
|
|
227
|
-
this.options.properties.options.forEach(__RΦ.f((options, key) =>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
224
|
+
parent.resolveAllProperties().forEach(__RΦ.f((prop, key) => {
|
|
225
|
+
properties.set(key, prop);
|
|
226
|
+
}, [__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(22))], ""));
|
|
227
|
+
this.options.properties.options.forEach(__RΦ.f((options, key) => {
|
|
228
|
+
properties.delete(key); // delete prop if already present to make sure it overrides parent's prop
|
|
229
|
+
properties.set(key, new Proxy(options, {
|
|
230
|
+
get: __RΦ.f((target, p, reciever) => {
|
|
231
|
+
if (p === "model")
|
|
232
|
+
return this;
|
|
233
|
+
else
|
|
234
|
+
return Reflect.get(target, p, reciever);
|
|
235
|
+
}, [__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"),
|
|
236
|
+
}));
|
|
237
|
+
}, [__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(22))], ""));
|
|
235
238
|
return properties;
|
|
236
239
|
}
|
|
237
240
|
}
|
|
@@ -241,19 +244,19 @@ __RΦ.m("rt:SP", [])(XMLModel);
|
|
|
241
244
|
__RΦ.m("rt:P", ["options", "type", "reflectedClass"])(XMLModel);
|
|
242
245
|
__RΦ.m("rt:Sm", [])(XMLModel);
|
|
243
246
|
__RΦ.m("rt:m", ["fromXML", "toXML", "resolveAllProperties"])(XMLModel);
|
|
244
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(532), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(
|
|
247
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(532), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(1751), v: null }])(XMLModel);
|
|
245
248
|
__RΦ.m("rt:f", "Ce")(XMLModel);
|
|
246
249
|
__RΦ.m("rt:t", () => __RΦ.a(525))(XMLModel.prototype, "options");
|
|
247
250
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "options");
|
|
248
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
251
|
+
__RΦ.m("rt:t", () => __RΦ.a(1775))(XMLModel.prototype, "parent");
|
|
249
252
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
250
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
253
|
+
__RΦ.m("rt:t", () => __RΦ.a(1785))(XMLModel.prototype, "parent");
|
|
251
254
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
252
255
|
__RΦ.m("rt:t", () => __RΦ.a(661))(XMLModel.prototype, "properties");
|
|
253
256
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
254
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
257
|
+
__RΦ.m("rt:t", () => __RΦ.a(1801))(XMLModel.prototype, "parent");
|
|
255
258
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
256
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
259
|
+
__RΦ.m("rt:t", () => __RΦ.a(1806))(XMLModel.prototype, "parent");
|
|
257
260
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
258
261
|
__RΦ.m("rt:t", () => __RΦ.a(13))(XMLModel.prototype, "tagname");
|
|
259
262
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "tagname");
|
|
@@ -287,17 +290,17 @@ function createModel(type, options) {
|
|
|
287
290
|
return model;
|
|
288
291
|
}
|
|
289
292
|
exports.createModel = createModel;
|
|
290
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
293
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(1626), v: null }, { n: "options", t: () => __RΦ.a(1625), v: null }])(createModel);
|
|
291
294
|
__RΦ.m("rt:f", "F")(createModel);
|
|
292
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
295
|
+
__RΦ.m("rt:t", () => __RΦ.a(1659))(createModel);
|
|
293
296
|
exports.Models = new Map();
|
|
294
297
|
function findModel(id) {
|
|
295
298
|
return exports.Models.get(id);
|
|
296
299
|
}
|
|
297
300
|
exports.findModel = findModel;
|
|
298
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
301
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1724), v: null }])(findModel);
|
|
299
302
|
__RΦ.m("rt:f", "F")(findModel);
|
|
300
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
303
|
+
__RΦ.m("rt:t", () => __RΦ.a(1737))(findModel);
|
|
301
304
|
function getModel(id) {
|
|
302
305
|
const model = findModel(id);
|
|
303
306
|
if (model)
|
|
@@ -306,19 +309,19 @@ function getModel(id) {
|
|
|
306
309
|
throw new TypeError(`couln't find model for type ${id.name}`);
|
|
307
310
|
}
|
|
308
311
|
exports.getModel = getModel;
|
|
309
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
312
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1882), v: null }])(getModel);
|
|
310
313
|
__RΦ.m("rt:f", "F")(getModel);
|
|
311
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
314
|
+
__RΦ.m("rt:t", () => __RΦ.a(1885))(getModel);
|
|
312
315
|
// Model decorator
|
|
313
316
|
function ModelDecoratorFactory(options) {
|
|
314
317
|
return __RΦ.f(function (constructor) {
|
|
315
318
|
findModel(constructor) || createModel(constructor, options || {});
|
|
316
|
-
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
319
|
+
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1891), v: null }]), __RΦ.m("rt:f", "M"), __RΦ.m("rt:t", () => __RΦ.a(22))], "");
|
|
317
320
|
}
|
|
318
321
|
exports.Model = ModelDecoratorFactory;
|
|
319
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
322
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1888), v: null, f: "?" }])(ModelDecoratorFactory);
|
|
320
323
|
__RΦ.m("rt:f", "F")(ModelDecoratorFactory);
|
|
321
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
324
|
+
__RΦ.m("rt:t", () => __RΦ.a(1890))(ModelDecoratorFactory);
|
|
322
325
|
var property_2 = require("./property");
|
|
323
326
|
Object.defineProperty(exports, "Prop", { enumerable: true, get: function () { return property_2.Prop; } });
|
|
324
327
|
require("../defaults/models");
|
|
@@ -16,14 +16,17 @@ const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metada
|
|
|
16
16
|
__RΦ.t[id] = t = l;
|
|
17
17
|
}
|
|
18
18
|
return t;
|
|
19
|
-
}, t: { [205]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(197)] }) }, [202]: { LΦ: t => require("typescript-rtti/dist").IΦConstructor }, [197]: { LΦ: t => Object }, [201]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(198), p: [__RΦ.a(197)] }) }, [198]: { LΦ: t => require("./types").IΦCreateXMLModelPropertyOptions }, [213]: { LΦ: t => Object }, [217]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(197)] }) }, [214]: { LΦ: t => require("./types").IΦXMLModelPropertyOptions }, [497]: { LΦ: t => require("typescript-rtti/dist").ReflectedProperty }, [13]: { LΦ: t => String }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [20]: { LΦ: t => Boolean }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [
|
|
19
|
+
}, t: { [205]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(197)] }) }, [202]: { LΦ: t => require("typescript-rtti/dist").IΦConstructor }, [197]: { LΦ: t => Object }, [201]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(198), p: [__RΦ.a(197)] }) }, [198]: { LΦ: t => require("./types").IΦCreateXMLModelPropertyOptions }, [213]: { LΦ: t => Object }, [217]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(197)] }) }, [214]: { LΦ: t => require("./types").IΦXMLModelPropertyOptions }, [497]: { LΦ: t => require("typescript-rtti/dist").ReflectedProperty }, [13]: { LΦ: t => String }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [20]: { LΦ: t => Boolean }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [1409]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1408)] }) }, [1408]: { LΦ: t => Object }, [1411]: { LΦ: t => Object }, [1412]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1408)] }) }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [1424]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), 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(214), p: [__RΦ.a(1423)] }) }, [1441]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1440)] }) }, [1440]: { LΦ: t => Object }, [1443]: { LΦ: t => Object }, [1467]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1440)] }) }, [1474]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(198), 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 } } };
|
|
20
20
|
const typescript_rtti_1 = require("typescript-rtti");
|
|
21
21
|
const defaults_1 = require("../defaults");
|
|
22
22
|
function resolvePropertyConversionOptions(options, constructor, property) {
|
|
23
23
|
const _options = {
|
|
24
24
|
name: property,
|
|
25
25
|
get reflected() {
|
|
26
|
-
|
|
26
|
+
const reflectedClass = (0, typescript_rtti_1.reflect)(constructor, { TΦ: "c", t: void 0, p: [__RΦ.a(205)], r: void 0, tp: [] });
|
|
27
|
+
return (reflectedClass.getOwnProperty(property) ||
|
|
28
|
+
reflectedClass.getProperty(property)); // patch bug in typescript-rtti
|
|
29
|
+
// TODO: remove when typescript-rtti is patched
|
|
27
30
|
},
|
|
28
31
|
get tagname() {
|
|
29
32
|
return options.tagname || defaults_1.defaults.tagnameFromProperty(this);
|
|
@@ -65,7 +68,7 @@ function storePropertyConversionOptions(constructor, property, options) {
|
|
|
65
68
|
}
|
|
66
69
|
map.set(property, options);
|
|
67
70
|
}
|
|
68
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
71
|
+
__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);
|
|
69
72
|
__RΦ.m("rt:f", "F")(storePropertyConversionOptions);
|
|
70
73
|
__RΦ.m("rt:t", () => __RΦ.a(22))(storePropertyConversionOptions);
|
|
71
74
|
function findPropertyConversionOptions(constructor, property) {
|
|
@@ -74,24 +77,24 @@ function findPropertyConversionOptions(constructor, property) {
|
|
|
74
77
|
return options.get(property);
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
80
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1424), v: null }, { n: "property", t: () => __RΦ.a(1426), v: null }])(findPropertyConversionOptions);
|
|
78
81
|
__RΦ.m("rt:f", "F")(findPropertyConversionOptions);
|
|
79
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
82
|
+
__RΦ.m("rt:t", () => __RΦ.a(1435))(findPropertyConversionOptions);
|
|
80
83
|
function getPropertyConversionOptions(constructor, property) {
|
|
81
84
|
const options = findPropertyConversionOptions(constructor, property);
|
|
82
85
|
return options || resolvePropertyConversionOptions({}, constructor, property);
|
|
83
86
|
}
|
|
84
87
|
exports.getPropertyConversionOptions = getPropertyConversionOptions;
|
|
85
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
88
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1441), v: null }, { n: "property", t: () => __RΦ.a(1443), v: null }])(getPropertyConversionOptions);
|
|
86
89
|
__RΦ.m("rt:f", "F")(getPropertyConversionOptions);
|
|
87
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
90
|
+
__RΦ.m("rt:t", () => __RΦ.a(1467))(getPropertyConversionOptions);
|
|
88
91
|
function PropDecoratorFactory(options) {
|
|
89
92
|
return __RΦ.f(function (prototype, property) {
|
|
90
93
|
const _options = resolvePropertyConversionOptions(options || {}, prototype.constructor, property);
|
|
91
94
|
storePropertyConversionOptions(prototype.constructor, property, _options);
|
|
92
|
-
}, [__RΦ.m("rt:p", [{ n: "prototype", t: () => __RΦ.a(1), v: null }, { n: "property", t: () => __RΦ.a(
|
|
95
|
+
}, [__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))], "");
|
|
93
96
|
}
|
|
94
97
|
exports.Prop = PropDecoratorFactory;
|
|
95
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
98
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1474), v: null, f: "?" }])(PropDecoratorFactory);
|
|
96
99
|
__RΦ.m("rt:f", "F")(PropDecoratorFactory);
|
|
97
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
100
|
+
__RΦ.m("rt:t", () => __RΦ.a(1476))(PropDecoratorFactory);
|
|
@@ -16,7 +16,7 @@ const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metada
|
|
|
16
16
|
__RΦ.t[id] = t = l;
|
|
17
17
|
}
|
|
18
18
|
return t;
|
|
19
|
-
}, t: { [1370]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1341)] }) }, [214]: { TΦ: "5", name: "XMLModelPropertyOptions" }, [1341]: { LΦ: t => Object }, [1374]: { LΦ: t => Object }, [493]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(375)] }) }, [375]: { LΦ: t => Object }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [496]: { LΦ: t => Object }, [497]: { LΦ: t => require("typescript-rtti").ReflectedProperty }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [505]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1)] }) }, [502]: { LΦ: t => require("../model").XMLModel }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [357]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(20), p: [{ n: "element", t: () => __RΦ.a(105), v: null }, { n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [399]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(400), p: [__RΦ.a(377), __RΦ.a(378)] }) }, [400]: { LΦ: t => Object }, [377]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(374), p: [__RΦ.a(215)] }) }, [374]: { TΦ: "5", name: "PropertyFromXMLContext" }, [215]: { LΦ: t => Object }, [378]: { LΦ: t => "elements" }, [1221]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(107), p: [{ n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [1223]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(1336), p: [{ n: "context", t: () => __RΦ.a(377), v: null }], f: "" }) }, [1336]: { LΦ: t => Object }, [1225]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(111), p: [{ n: "context", t: () => __RΦ.a(1343), v: null }], f: "" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [1343]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1340), p: [__RΦ.a(215)] }) }, [1340]: { TΦ: "5", name: "PropertyToXMLContext" }, [
|
|
19
|
+
}, t: { [1370]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1341)] }) }, [214]: { TΦ: "5", name: "XMLModelPropertyOptions" }, [1341]: { LΦ: t => Object }, [1374]: { LΦ: t => Object }, [493]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(375)] }) }, [375]: { LΦ: t => Object }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => require("../types").IΦXMLElement }, [496]: { LΦ: t => Object }, [497]: { LΦ: t => require("typescript-rtti").ReflectedProperty }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [505]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1)] }) }, [502]: { LΦ: t => require("../model").XMLModel }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [357]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(20), p: [{ n: "element", t: () => __RΦ.a(105), v: null }, { n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [399]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(400), p: [__RΦ.a(377), __RΦ.a(378)] }) }, [400]: { LΦ: t => Object }, [377]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(374), p: [__RΦ.a(215)] }) }, [374]: { TΦ: "5", name: "PropertyFromXMLContext" }, [215]: { LΦ: t => Object }, [378]: { LΦ: t => "elements" }, [1221]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(107), p: [{ n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [1223]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(1336), p: [{ n: "context", t: () => __RΦ.a(377), v: null }], f: "" }) }, [1336]: { LΦ: t => Object }, [1225]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(111), p: [{ n: "context", t: () => __RΦ.a(1343), v: null }], f: "" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [1343]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1340), p: [__RΦ.a(215)] }) }, [1340]: { TΦ: "5", name: "PropertyToXMLContext" }, [1386]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(74), __RΦ.a(1385)] }) }, [74]: { LΦ: t => RegExp }, [1385]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [1277]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1346]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1299]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [506]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(505)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [610]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(602)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [602]: { TΦ: "5", name: "ConversionOptions" }, [613]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(612) }) }, [612]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [656]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(657), p: [__RΦ.a(381)] }) }, [657]: { LΦ: t => Object }, [381]: { LΦ: t => Object }, [519]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(381)] }) }, [861]: { LΦ: t => Object }, [888]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(889), p: [__RΦ.a(861)] }) }, [889]: { LΦ: t => Object }, [926]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(861)] }) }, [528]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(523)] }) }, [523]: { LΦ: t => Object }, [660]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(667) }, { n: "toXML", f: "", t: __RΦ.a(898) }, { n: "options", f: "", t: __RΦ.a(1074) }] }) }, [667]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(663), __RΦ.a(665)] }) }, [663]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(664), p: [__RΦ.a(606), __RΦ.a(384)] }) }, [664]: { LΦ: t => Object }, [606]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(380), p: [__RΦ.a(523)] }) }, [380]: { TΦ: "5", name: "fromXMLContext" }, [384]: { LΦ: t => "properties" }, [665]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(666), p: [__RΦ.a(523)] }) }, [666]: { LΦ: t => Object }, [898]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(894), __RΦ.a(896)] }) }, [894]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(895), p: [__RΦ.a(863), __RΦ.a(384)] }) }, [895]: { LΦ: t => Object }, [863]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(860), p: [__RΦ.a(523)] }) }, [860]: { TΦ: "5", name: "toXMLContext" }, [896]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(897), p: [__RΦ.a(523)] }) }, [897]: { LΦ: t => Object }, [1074]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1064), p: [__RΦ.a(1072), __RΦ.a(1073)] }) }, [1064]: { LΦ: t => Map }, [1072]: { LΦ: t => Object }, [1073]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(523)] }) }, [607]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(606), __RΦ.a(523)] }) }, [864]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(863), __RΦ.a(111)] }) }, [1817]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1816)] }) }, [1816]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1623)] }) }, [1623]: { LΦ: t => Object }, [1644]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1634]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) } } };
|
|
20
20
|
var IΦPropertyToXMLContext = { name: "PropertyToXMLContext", prototype: {}, identity: Symbol("PropertyToXMLContext (interface)") };
|
|
21
21
|
exports.IΦPropertyToXMLContext = IΦPropertyToXMLContext;
|
|
22
22
|
(t => __RΦ.t[1340] = t)(IΦPropertyToXMLContext);
|
|
@@ -101,7 +101,7 @@ __RΦ.m("rt:m", [])(IΦCreateXMLModelPropertyOptions);
|
|
|
101
101
|
__RΦ.m("rt:f", "Ie")(IΦCreateXMLModelPropertyOptions);
|
|
102
102
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
103
103
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
104
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
104
|
+
__RΦ.m("rt:t", () => __RΦ.a(1386))(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
105
105
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
106
106
|
__RΦ.m("rt:t", () => __RΦ.a(1277))(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
107
107
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
@@ -117,7 +117,7 @@ __RΦ.m("rt:t", () => __RΦ.a(506))(IΦCreateXMLModelPropertyOptions.prototype,
|
|
|
117
117
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "model");
|
|
118
118
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
119
119
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
120
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
120
|
+
__RΦ.m("rt:t", () => __RΦ.a(1386))(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
121
121
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
122
122
|
__RΦ.m("rt:t", () => __RΦ.a(1277))(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
123
123
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
@@ -208,23 +208,23 @@ __RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelOptions.prototype, "tagname");
|
|
|
208
208
|
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "tagname");
|
|
209
209
|
var IΦCreateXMLModelOptions = { name: "CreateXMLModelOptions", prototype: {}, identity: Symbol("CreateXMLModelOptions (interface)") };
|
|
210
210
|
exports.IΦCreateXMLModelOptions = IΦCreateXMLModelOptions;
|
|
211
|
-
(t => __RΦ.t[
|
|
211
|
+
(t => __RΦ.t[1622] = t)(IΦCreateXMLModelOptions);
|
|
212
212
|
__RΦ.m("rt:P", ["parent", "fromXML", "toXML", "tagname"])(IΦCreateXMLModelOptions);
|
|
213
213
|
__RΦ.m("rt:m", [])(IΦCreateXMLModelOptions);
|
|
214
214
|
__RΦ.m("rt:f", "Ie")(IΦCreateXMLModelOptions);
|
|
215
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
215
|
+
__RΦ.m("rt:t", () => __RΦ.a(1817))(IΦCreateXMLModelOptions.prototype, "parent");
|
|
216
216
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "parent");
|
|
217
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
217
|
+
__RΦ.m("rt:t", () => __RΦ.a(1644))(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
218
218
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
219
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
219
|
+
__RΦ.m("rt:t", () => __RΦ.a(1634))(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
220
220
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
221
221
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
222
222
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
223
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
223
|
+
__RΦ.m("rt:t", () => __RΦ.a(1817))(IΦCreateXMLModelOptions.prototype, "parent");
|
|
224
224
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "parent");
|
|
225
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
225
|
+
__RΦ.m("rt:t", () => __RΦ.a(1644))(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
226
226
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
227
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
227
|
+
__RΦ.m("rt:t", () => __RΦ.a(1634))(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
228
228
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
229
229
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
230
230
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metadata(k, v)(t, ...a) : void 0, f: (f, d, n) => (d.forEach(d => d(f)), Object.defineProperty(f, "name", { value: n, writable: false }), f), c: (c, d, dp, dsp, n) => (d.forEach(d => d(c)), dp.forEach(([p, d]) => d(c.prototype, p)), dsp.forEach(([p, d]) => d(c, p)), n ? Object.defineProperty(c, "name", { value: n, writable: false }) : undefined, c), r: (o, a) => (Object.assign(o, a)), a: id => {
|
|
13
|
+
let t = __RΦ.t[id];
|
|
14
|
+
if (t === void 0)
|
|
15
|
+
return void 0;
|
|
16
|
+
if (t.RΦ) {
|
|
17
|
+
let r = t.RΦ;
|
|
18
|
+
delete t.RΦ;
|
|
19
|
+
__RΦ.r(t, r(t));
|
|
20
|
+
}
|
|
21
|
+
else if (t.LΦ) {
|
|
22
|
+
let l = t.LΦ();
|
|
23
|
+
delete t.LΦ;
|
|
24
|
+
__RΦ.t[id] = t = l;
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
}, t: { [2702]: { RΦ: t => ({ TΦ: "O", m: [{ n: "propA", f: "", t: __RΦ.a(13) }, { n: "propB", f: "", t: __RΦ.a(20) }, { n: "propC", f: "", t: __RΦ.a(2718) }, { n: "propD", f: "", t: __RΦ.a(705) }, { n: "__constructor", f: "", t: __RΦ.a(4) }] }) }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [2718]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(2716) }) }, [2716]: { TΦ: "5", name: "B" }, [705]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(47), __RΦ.a(135)] }) }, [47]: { LΦ: t => 0 }, [135]: { LΦ: t => 1 }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [2654]: { RΦ: t => ({ TΦ: "O", m: [{ n: "name", f: "", t: __RΦ.a(13) }, { n: "nbPages", f: "", t: __RΦ.a(14) }] }) }, [14]: { LΦ: t => Number }, [2673]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(2617) }) }, [2617]: { TΦ: "5", name: "Book" }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [101]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(102), p: [] }) }, [102]: { LΦ: t => Object } } };
|
|
28
|
+
require("mocha");
|
|
29
|
+
const chai_1 = require("chai");
|
|
30
|
+
require("reflect-metadata");
|
|
31
|
+
const model_1 = require("./model");
|
|
32
|
+
const xml_1 = __importDefault(require("./xml"));
|
|
33
|
+
const typescript_rtti_1 = require("typescript-rtti");
|
|
34
|
+
let Book = class Book {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.name = options.name;
|
|
37
|
+
this.nbPages = options.nbPages;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
Book = __decorate([
|
|
41
|
+
(0, model_1.Model)({
|
|
42
|
+
fromXML({ model, properties }) {
|
|
43
|
+
return new model.type(properties);
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
], Book);
|
|
47
|
+
(t => __RΦ.t[2617] = t)(Book);
|
|
48
|
+
__RΦ.m("rt:SP", [])(Book);
|
|
49
|
+
__RΦ.m("rt:P", ["name", "nbPages"])(Book);
|
|
50
|
+
__RΦ.m("rt:Sm", [])(Book);
|
|
51
|
+
__RΦ.m("rt:m", ["fromXML"])(Book);
|
|
52
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(2654), v: null }])(Book);
|
|
53
|
+
__RΦ.m("rt:f", "C")(Book);
|
|
54
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(Book.prototype, "name");
|
|
55
|
+
__RΦ.m("rt:f", "P")(Book.prototype, "name");
|
|
56
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(Book.prototype, "nbPages");
|
|
57
|
+
__RΦ.m("rt:f", "P")(Book.prototype, "nbPages");
|
|
58
|
+
let Library = class Library {
|
|
59
|
+
constructor(name, ...books) {
|
|
60
|
+
this.books = [];
|
|
61
|
+
this.name = name;
|
|
62
|
+
this.books.push(...books);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
Library = __decorate([
|
|
66
|
+
(0, model_1.Model)({
|
|
67
|
+
fromXML({ model, properties }) {
|
|
68
|
+
return new model.type(properties.name, ...properties.books);
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
], Library);
|
|
72
|
+
(t => __RΦ.t[2657] = t)(Library);
|
|
73
|
+
__RΦ.m("rt:SP", [])(Library);
|
|
74
|
+
__RΦ.m("rt:P", ["name", "books"])(Library);
|
|
75
|
+
__RΦ.m("rt:Sm", [])(Library);
|
|
76
|
+
__RΦ.m("rt:m", ["fromXML"])(Library);
|
|
77
|
+
__RΦ.m("rt:p", [{ n: "name", t: () => __RΦ.a(13), v: null }, { n: "books", t: () => __RΦ.a(2673), v: null, f: "3" }])(Library);
|
|
78
|
+
__RΦ.m("rt:f", "C")(Library);
|
|
79
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(Library.prototype, "name");
|
|
80
|
+
__RΦ.m("rt:f", "P")(Library.prototype, "name");
|
|
81
|
+
__RΦ.m("rt:t", () => __RΦ.a(2673))(Library.prototype, "books");
|
|
82
|
+
__RΦ.m("rt:f", "P")(Library.prototype, "books");
|
|
83
|
+
describe("Library Example", __RΦ.f(() => {
|
|
84
|
+
const library = new Library("test");
|
|
85
|
+
for (let i = 1; i <= 4; i++) {
|
|
86
|
+
const book = new Book({ name: `Book #${i}`, nbPages: Math.pow(10, i) });
|
|
87
|
+
library.books.push(book);
|
|
88
|
+
}
|
|
89
|
+
const libraryXMLString = xml_1.default.stringify(xml_1.default.parse(`<library>
|
|
90
|
+
<name>${library.name}</name>
|
|
91
|
+
<books>
|
|
92
|
+
${library.books
|
|
93
|
+
.map(__RΦ.f((book) => ` <book>
|
|
94
|
+
<name>${book.name}</name>
|
|
95
|
+
<nb-pages>${book.nbPages}</nb-pages>
|
|
96
|
+
</book>`, [__RΦ.m("rt:p", [{ n: "book", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(13))], ""))
|
|
97
|
+
.join("")}
|
|
98
|
+
</books>
|
|
99
|
+
</library>`));
|
|
100
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
101
|
+
const xml = (0, model_1.getModel)(Library).toXML(library);
|
|
102
|
+
(0, chai_1.expect)(xml_1.default.stringify(xml)).to.equal(libraryXMLString);
|
|
103
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
104
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
105
|
+
const parsedLibrary = (0, model_1.getModel)(Library).fromXML(libraryXMLString);
|
|
106
|
+
(0, chai_1.expect)(parsedLibrary instanceof Library).to.be.true;
|
|
107
|
+
(0, chai_1.expect)(parsedLibrary).to.deep.equal(library);
|
|
108
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
109
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
110
|
+
let A = class A {
|
|
111
|
+
constructor(record) {
|
|
112
|
+
this.propA = "";
|
|
113
|
+
this.propB = true;
|
|
114
|
+
this.propC = [];
|
|
115
|
+
this.propD = 0;
|
|
116
|
+
if (record)
|
|
117
|
+
Object.entries(record).forEach(__RΦ.f(([key, val]) => {
|
|
118
|
+
this[key] = val;
|
|
119
|
+
}, [__RΦ.m("rt:p", [{ n: "[key, val]", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, model_1.Prop)({ tagname: "b", inline: true })
|
|
124
|
+
], A.prototype, "propC", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, model_1.Prop)({ tagname: "propd" })
|
|
127
|
+
], A.prototype, "propD", void 0);
|
|
128
|
+
A = __decorate([
|
|
129
|
+
(0, model_1.Model)({
|
|
130
|
+
fromXML({ model, properties }) {
|
|
131
|
+
return new model.type(properties);
|
|
132
|
+
},
|
|
133
|
+
})
|
|
134
|
+
], A);
|
|
135
|
+
(t => __RΦ.t[2703] = t)(A);
|
|
136
|
+
__RΦ.m("rt:SP", [])(A);
|
|
137
|
+
__RΦ.m("rt:P", ["propA", "propB", "propC", "propD"])(A);
|
|
138
|
+
__RΦ.m("rt:Sm", [])(A);
|
|
139
|
+
__RΦ.m("rt:m", ["fromXML"])(A);
|
|
140
|
+
__RΦ.m("rt:p", [{ n: "record", t: () => __RΦ.a(101), v: null, f: "?" }])(A);
|
|
141
|
+
__RΦ.m("rt:f", "C")(A);
|
|
142
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(A.prototype, "propA");
|
|
143
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propA");
|
|
144
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(A.prototype, "propB");
|
|
145
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propB");
|
|
146
|
+
__RΦ.m("rt:t", () => __RΦ.a(2718))(A.prototype, "propC");
|
|
147
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propC");
|
|
148
|
+
__RΦ.m("rt:t", () => __RΦ.a(705))(A.prototype, "propD");
|
|
149
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propD");
|
|
150
|
+
let B = class B {
|
|
151
|
+
constructor(record) {
|
|
152
|
+
this.propA = 0;
|
|
153
|
+
if (record)
|
|
154
|
+
Object.entries(record).forEach(__RΦ.f(([key, val]) => {
|
|
155
|
+
this[key] = val;
|
|
156
|
+
}, [__RΦ.m("rt:p", [{ n: "[key, val]", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
B = __decorate([
|
|
160
|
+
(0, model_1.Model)({
|
|
161
|
+
fromXML({ model, properties }) {
|
|
162
|
+
return new model.type(properties);
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
], B);
|
|
166
|
+
(t => __RΦ.t[2716] = t)(B);
|
|
167
|
+
__RΦ.m("rt:SP", [])(B);
|
|
168
|
+
__RΦ.m("rt:P", ["propA"])(B);
|
|
169
|
+
__RΦ.m("rt:Sm", [])(B);
|
|
170
|
+
__RΦ.m("rt:m", ["fromXML"])(B);
|
|
171
|
+
__RΦ.m("rt:p", [{ n: "record", t: () => __RΦ.a(101), v: null, f: "?" }])(B);
|
|
172
|
+
__RΦ.m("rt:f", "C")(B);
|
|
173
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(B.prototype, "propA");
|
|
174
|
+
__RΦ.m("rt:f", "P")(B.prototype, "propA");
|
|
175
|
+
describe("Edgy Cases", __RΦ.f(() => {
|
|
176
|
+
const instance = new A();
|
|
177
|
+
for (let i = 0; i < 8; i++) {
|
|
178
|
+
const b = new B();
|
|
179
|
+
b.propA = i;
|
|
180
|
+
instance.propC.push(b);
|
|
181
|
+
}
|
|
182
|
+
const instanceXMLString = xml_1.default.stringify(xml_1.default.parse(`<a>
|
|
183
|
+
<prop-a>${instance.propA}</prop-a>
|
|
184
|
+
<prop-b>${instance.propB}</prop-b>
|
|
185
|
+
${instance.propC.map(__RΦ.f((b) => `<b><prop-a>${b.propA}</prop-a></b>`, [__RΦ.m("rt:p", [{ n: "b", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(13))], "")).join("")}
|
|
186
|
+
<propd>${instance.propD}</propd>
|
|
187
|
+
</a>`));
|
|
188
|
+
it("should give right type infos", __RΦ.f(() => {
|
|
189
|
+
const reflectedA = (0, typescript_rtti_1.reflect)(A, { TΦ: "c", t: void 0, p: [__RΦ.a(2702)], r: void 0, tp: [] });
|
|
190
|
+
(0, chai_1.assert)(reflectedA === (0, typescript_rtti_1.reflect)(A, { TΦ: "c", t: void 0, p: [__RΦ.a(2702)], r: void 0, tp: [] }));
|
|
191
|
+
(0, chai_1.expect)(reflectedA.getProperty("propA").type.isClass(String)).to.be.true;
|
|
192
|
+
(0, chai_1.expect)(reflectedA.getProperty("propB").type.isClass(Boolean)).to.be.true;
|
|
193
|
+
const ModelAPropCType = reflectedA.getProperty("propC").type;
|
|
194
|
+
(0, chai_1.expect)(ModelAPropCType.is("array") && ModelAPropCType.elementType.isClass(B)).to.be.true;
|
|
195
|
+
const ModelAPropDType = reflectedA.getProperty("propD").type;
|
|
196
|
+
(0, chai_1.expect)(ModelAPropDType.is("union")).to.be.true;
|
|
197
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
198
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
199
|
+
const parsed = (0, model_1.getModel)(A).fromXML(instanceXMLString);
|
|
200
|
+
(0, chai_1.expect)(parsed instanceof A).to.be.true;
|
|
201
|
+
(0, chai_1.expect)(parsed).to.deep.equal(instance);
|
|
202
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
203
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
204
|
+
const xml = (0, model_1.getModel)(A).toXML(instance);
|
|
205
|
+
(0, chai_1.expect)(xml_1.default.stringify(xml)).to.equal(instanceXMLString);
|
|
206
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
207
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
208
|
+
let C = class C extends B {
|
|
209
|
+
constructor() {
|
|
210
|
+
super(...arguments);
|
|
211
|
+
this.propB = 3;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
C = __decorate([
|
|
215
|
+
(0, model_1.Model)()
|
|
216
|
+
], C);
|
|
217
|
+
(t => __RΦ.t[2766] = t)(C);
|
|
218
|
+
__RΦ.m("rt:SP", [])(C);
|
|
219
|
+
__RΦ.m("rt:P", ["propB"])(C);
|
|
220
|
+
__RΦ.m("rt:Sm", [])(C);
|
|
221
|
+
__RΦ.m("rt:m", [])(C);
|
|
222
|
+
__RΦ.m("rt:f", "C")(C);
|
|
223
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(C.prototype, "propB");
|
|
224
|
+
__RΦ.m("rt:f", "P")(C.prototype, "propB");
|
|
225
|
+
describe("Inheritance", __RΦ.f(() => {
|
|
226
|
+
const cInstance = new C();
|
|
227
|
+
const cInstanceXMLString = `<c><prop-a>${cInstance.propA}</prop-a><prop-b>${cInstance.propB}</prop-b></c>`;
|
|
228
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
229
|
+
(0, chai_1.expect)((0, model_1.getModel)(C).fromXML(cInstanceXMLString)).to.deep.equal(cInstance);
|
|
230
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
231
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
232
|
+
(0, chai_1.expect)(xml_1.default.stringify((0, model_1.getModel)(C).toXML(cInstance))).to.equal(cInstanceXMLString);
|
|
233
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
234
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
@@ -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: { [4]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_0.IΦXMLElement }, [13]: { LΦ: t => String }, [14]: { LΦ: t => Number }, [
|
|
16
|
+
}, t: { [4]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_0.IΦXMLElement }, [13]: { LΦ: t => String }, [14]: { LΦ: t => Number }, [1698]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(3125) }] }) }, [3125]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(3123) }) }, [3123]: { RΦ: t => ({ TΦ: "O", m: [{ n: "type", f: "", t: __RΦ.a(13) }, { n: "name", f: "", t: __RΦ.a(13) }] }) }, [20]: { LΦ: t => Boolean } } };
|
|
17
17
|
import { createModel } from "../model";
|
|
18
18
|
import { getContent, fromContent } from "../xml";
|
|
19
19
|
import * as LΦ_0 from "../types";
|
|
@@ -47,7 +47,7 @@ createModel(Boolean, {
|
|
|
47
47
|
Object.assign({ type: "element", name: "boolean" }, fromContent(String(ctx.object))),
|
|
48
48
|
],
|
|
49
49
|
};
|
|
50
|
-
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
50
|
+
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1698))], "toXML"),
|
|
51
51
|
fromXML: __RΦ.f((ctx) => {
|
|
52
52
|
return Boolean(getContent(ctx.xml.elements[0]));
|
|
53
53
|
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(20))], "fromXML"),
|
|
@@ -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: { [532]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(503)] }) }, [202]: { LΦ: t => LΦ_0.IΦConstructor }, [503]: { LΦ: t => Object }, [
|
|
16
|
+
}, t: { [532]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(503)] }) }, [202]: { LΦ: t => LΦ_0.IΦConstructor }, [503]: { LΦ: t => Object }, [1716]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(8)] }) }, [8]: { RΦ: t => ({ TΦ: "U" }) }, [1719]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(140), p: [__RΦ.a(1716), __RΦ.a(22), __RΦ.a(8)] }) }, [140]: { LΦ: t => Object }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [505]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1)] }) }, [502]: { TΦ: "5", name: "XMLModel" }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [1742]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(505)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [1751]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(503)] }) }, [1622]: { LΦ: t => LΦ_1.IΦCreateXMLModelOptions }, [525]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(522), p: [__RΦ.a(503)] }) }, [522]: { LΦ: t => LΦ_1.IΦXMLModelOptions }, [1775]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1328)] }) }, [1328]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(422), __RΦ.a(1326)] }) }, [602]: { LΦ: t => LΦ_1.IΦConversionOptions }, [422]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(423), p: [__RΦ.a(421), __RΦ.a(384)] }) }, [423]: { LΦ: t => Object }, [421]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(380), p: [__RΦ.a(1)] }) }, [380]: { LΦ: t => LΦ_1.IΦfromXMLContext }, [384]: { LΦ: t => "properties" }, [1326]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1327), p: [__RΦ.a(1)] }) }, [1327]: { LΦ: t => Object }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [658]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(659), p: [__RΦ.a(503)] }) }, [659]: { LΦ: t => Object }, [1785]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1783)] }) }, [1783]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(1360), __RΦ.a(1781)] }) }, [1360]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1361), p: [__RΦ.a(1359), __RΦ.a(384)] }) }, [1361]: { LΦ: t => Object }, [1359]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(860), p: [__RΦ.a(1)] }) }, [860]: { LΦ: t => LΦ_1.IΦtoXMLContext }, [1781]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1782), p: [__RΦ.a(1)] }) }, [1782]: { LΦ: t => Object }, [890]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(891), p: [__RΦ.a(503)] }) }, [891]: { LΦ: t => Object }, [20]: { LΦ: t => Boolean }, [661]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(667) }, { n: "toXML", f: "", t: __RΦ.a(898) }, { n: "options", f: "", t: __RΦ.a(1074) }] }) }, [667]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(663), __RΦ.a(665)] }) }, [663]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(664), p: [__RΦ.a(606), __RΦ.a(384)] }) }, [664]: { LΦ: t => Object }, [606]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(380), p: [__RΦ.a(523)] }) }, [523]: { LΦ: t => Object }, [665]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(666), p: [__RΦ.a(523)] }) }, [666]: { LΦ: t => Object }, [898]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(894), __RΦ.a(896)] }) }, [894]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(895), p: [__RΦ.a(863), __RΦ.a(384)] }) }, [895]: { LΦ: t => Object }, [863]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(860), p: [__RΦ.a(523)] }) }, [896]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(897), p: [__RΦ.a(523)] }) }, [897]: { LΦ: t => Object }, [1074]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1064), p: [__RΦ.a(1072), __RΦ.a(1073)] }) }, [1064]: { LΦ: t => Map }, [1072]: { LΦ: t => Object }, [1073]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(523)] }) }, [214]: { 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(602), p: [__RΦ.a(421), __RΦ.a(1)] }) }, [1806]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1804)] }) }, [1804]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(1359), __RΦ.a(111)] }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_2.IΦXMLElement }, [13]: { LΦ: t => String }, [541]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(111)] }) }, [28]: { LΦ: t => Object }, [948]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(944), p: [__RΦ.a(532)] }) }, [944]: { LΦ: t => LΦ_0.ReflectedClass }, [1069]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1064), p: [__RΦ.a(13), __RΦ.a(1063)] }) }, [1063]: { RΦ: t => ({ TΦ: "&", t: [__RΦ.a(1061), __RΦ.a(1062)] }) }, [1061]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1)] }) }, [1062]: { RΦ: t => ({ TΦ: "O", m: [{ n: "model", f: "", t: __RΦ.a(1) }] }) }, [1626]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), 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(502), p: [__RΦ.a(1621)] }) }, [1724]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), 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(502), p: [__RΦ.a(1721)] }) }, [1882]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1881)] }) }, [1881]: { LΦ: t => Object }, [1885]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1881)] }) }, [1888]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1622), p: [__RΦ.a(1887)] }) }, [1887]: { LΦ: t => Object }, [1890]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "constructor", t: () => __RΦ.a(1891), v: null }], f: "" }) }, [1891]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1887)] }) } } };
|
|
17
17
|
import { reflect } from "typescript-rtti";
|
|
18
18
|
import { MiddlewareChain, resolve } from "../middleware";
|
|
19
19
|
import { getPropertyConversionOptions } from "./property";
|
|
@@ -34,9 +34,9 @@ function* ParentChain(constructor) {
|
|
|
34
34
|
}
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
37
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1716), v: null }])(ParentChain);
|
|
38
38
|
__RΦ.m("rt:f", "F")(ParentChain);
|
|
39
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
39
|
+
__RΦ.m("rt:t", () => __RΦ.a(1719))(ParentChain);
|
|
40
40
|
import * as LΦ_1 from "./types";
|
|
41
41
|
import * as LΦ_2 from "../types";
|
|
42
42
|
function getParentModel(model) {
|
|
@@ -52,7 +52,7 @@ function getParentModel(model) {
|
|
|
52
52
|
}
|
|
53
53
|
__RΦ.m("rt:p", [{ n: "model", t: () => __RΦ.a(505), v: null }])(getParentModel);
|
|
54
54
|
__RΦ.m("rt:f", "F")(getParentModel);
|
|
55
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
55
|
+
__RΦ.m("rt:t", () => __RΦ.a(1742))(getParentModel);
|
|
56
56
|
import * as LΦ_0 from "typescript-rtti/dist";
|
|
57
57
|
export class XMLModel {
|
|
58
58
|
constructor(type, options) {
|
|
@@ -64,7 +64,7 @@ export class XMLModel {
|
|
|
64
64
|
if (typeof parent === "undefined")
|
|
65
65
|
parent = getParentModel(this);
|
|
66
66
|
return parent;
|
|
67
|
-
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
67
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1742))], "getParent");
|
|
68
68
|
let propertiesLoaded = false;
|
|
69
69
|
const properties = {
|
|
70
70
|
options: new Map(),
|
|
@@ -126,7 +126,7 @@ export class XMLModel {
|
|
|
126
126
|
},
|
|
127
127
|
};
|
|
128
128
|
const loadProperties = __RΦ.f(() => {
|
|
129
|
-
const props =
|
|
129
|
+
const props = this.reflectedClass.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
|
|
130
130
|
props.forEach(__RΦ.f((property) => {
|
|
131
131
|
const options = getPropertyConversionOptions(this.type, property.name);
|
|
132
132
|
if (!options.ignored) {
|
|
@@ -218,17 +218,20 @@ export class XMLModel {
|
|
|
218
218
|
const properties = new Map();
|
|
219
219
|
const parent = getParentModel(this);
|
|
220
220
|
if (parent)
|
|
221
|
-
parent
|
|
222
|
-
.
|
|
223
|
-
|
|
224
|
-
this.options.properties.options.forEach(__RΦ.f((options, key) =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
221
|
+
parent.resolveAllProperties().forEach(__RΦ.f((prop, key) => {
|
|
222
|
+
properties.set(key, prop);
|
|
223
|
+
}, [__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(22))], ""));
|
|
224
|
+
this.options.properties.options.forEach(__RΦ.f((options, key) => {
|
|
225
|
+
properties.delete(key); // delete prop if already present to make sure it overrides parent's prop
|
|
226
|
+
properties.set(key, new Proxy(options, {
|
|
227
|
+
get: __RΦ.f((target, p, reciever) => {
|
|
228
|
+
if (p === "model")
|
|
229
|
+
return this;
|
|
230
|
+
else
|
|
231
|
+
return Reflect.get(target, p, reciever);
|
|
232
|
+
}, [__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"),
|
|
233
|
+
}));
|
|
234
|
+
}, [__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(22))], ""));
|
|
232
235
|
return properties;
|
|
233
236
|
}
|
|
234
237
|
}
|
|
@@ -237,19 +240,19 @@ __RΦ.m("rt:SP", [])(XMLModel);
|
|
|
237
240
|
__RΦ.m("rt:P", ["options", "type", "reflectedClass"])(XMLModel);
|
|
238
241
|
__RΦ.m("rt:Sm", [])(XMLModel);
|
|
239
242
|
__RΦ.m("rt:m", ["fromXML", "toXML", "resolveAllProperties"])(XMLModel);
|
|
240
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(532), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(
|
|
243
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(532), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(1751), v: null }])(XMLModel);
|
|
241
244
|
__RΦ.m("rt:f", "Ce")(XMLModel);
|
|
242
245
|
__RΦ.m("rt:t", () => __RΦ.a(525))(XMLModel.prototype, "options");
|
|
243
246
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "options");
|
|
244
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
247
|
+
__RΦ.m("rt:t", () => __RΦ.a(1775))(XMLModel.prototype, "parent");
|
|
245
248
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
246
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
249
|
+
__RΦ.m("rt:t", () => __RΦ.a(1785))(XMLModel.prototype, "parent");
|
|
247
250
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
248
251
|
__RΦ.m("rt:t", () => __RΦ.a(661))(XMLModel.prototype, "properties");
|
|
249
252
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
250
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
253
|
+
__RΦ.m("rt:t", () => __RΦ.a(1801))(XMLModel.prototype, "parent");
|
|
251
254
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
252
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
255
|
+
__RΦ.m("rt:t", () => __RΦ.a(1806))(XMLModel.prototype, "parent");
|
|
253
256
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
254
257
|
__RΦ.m("rt:t", () => __RΦ.a(13))(XMLModel.prototype, "tagname");
|
|
255
258
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "tagname");
|
|
@@ -282,16 +285,16 @@ export function createModel(type, options) {
|
|
|
282
285
|
Models.set(type, model);
|
|
283
286
|
return model;
|
|
284
287
|
}
|
|
285
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
288
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(1626), v: null }, { n: "options", t: () => __RΦ.a(1625), v: null }])(createModel);
|
|
286
289
|
__RΦ.m("rt:f", "F")(createModel);
|
|
287
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
290
|
+
__RΦ.m("rt:t", () => __RΦ.a(1659))(createModel);
|
|
288
291
|
export const Models = new Map();
|
|
289
292
|
export function findModel(id) {
|
|
290
293
|
return Models.get(id);
|
|
291
294
|
}
|
|
292
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
295
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1724), v: null }])(findModel);
|
|
293
296
|
__RΦ.m("rt:f", "F")(findModel);
|
|
294
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
297
|
+
__RΦ.m("rt:t", () => __RΦ.a(1737))(findModel);
|
|
295
298
|
export function getModel(id) {
|
|
296
299
|
const model = findModel(id);
|
|
297
300
|
if (model)
|
|
@@ -299,18 +302,18 @@ export function getModel(id) {
|
|
|
299
302
|
else
|
|
300
303
|
throw new TypeError(`couln't find model for type ${id.name}`);
|
|
301
304
|
}
|
|
302
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
305
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1882), v: null }])(getModel);
|
|
303
306
|
__RΦ.m("rt:f", "F")(getModel);
|
|
304
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
307
|
+
__RΦ.m("rt:t", () => __RΦ.a(1885))(getModel);
|
|
305
308
|
// Model decorator
|
|
306
309
|
function ModelDecoratorFactory(options) {
|
|
307
310
|
return __RΦ.f(function (constructor) {
|
|
308
311
|
findModel(constructor) || createModel(constructor, options || {});
|
|
309
|
-
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
312
|
+
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1891), v: null }]), __RΦ.m("rt:f", "M"), __RΦ.m("rt:t", () => __RΦ.a(22))], "");
|
|
310
313
|
}
|
|
311
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
314
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1888), v: null, f: "?" }])(ModelDecoratorFactory);
|
|
312
315
|
__RΦ.m("rt:f", "F")(ModelDecoratorFactory);
|
|
313
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
316
|
+
__RΦ.m("rt:t", () => __RΦ.a(1890))(ModelDecoratorFactory);
|
|
314
317
|
export { ModelDecoratorFactory as Model };
|
|
315
318
|
export { Prop } from "./property";
|
|
316
319
|
import "../defaults/models";
|
|
@@ -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: { [205]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(197)] }) }, [202]: { LΦ: t => LΦ_0.IΦConstructor }, [197]: { LΦ: t => Object }, [201]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(198), p: [__RΦ.a(197)] }) }, [198]: { LΦ: t => LΦ_1.IΦCreateXMLModelPropertyOptions }, [213]: { LΦ: t => Object }, [217]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(197)] }) }, [214]: { LΦ: t => LΦ_1.IΦXMLModelPropertyOptions }, [497]: { LΦ: t => LΦ_0.ReflectedProperty }, [13]: { LΦ: t => String }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [20]: { LΦ: t => Boolean }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_2.IΦXMLElement }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [
|
|
16
|
+
}, t: { [205]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(197)] }) }, [202]: { LΦ: t => LΦ_0.IΦConstructor }, [197]: { LΦ: t => Object }, [201]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(198), p: [__RΦ.a(197)] }) }, [198]: { LΦ: t => LΦ_1.IΦCreateXMLModelPropertyOptions }, [213]: { LΦ: t => Object }, [217]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(197)] }) }, [214]: { LΦ: t => LΦ_1.IΦXMLModelPropertyOptions }, [497]: { LΦ: t => LΦ_0.ReflectedProperty }, [13]: { LΦ: t => String }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [20]: { LΦ: t => Boolean }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_2.IΦXMLElement }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [1409]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1408)] }) }, [1408]: { LΦ: t => Object }, [1411]: { LΦ: t => Object }, [1412]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1408)] }) }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [1424]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), 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(214), p: [__RΦ.a(1423)] }) }, [1441]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(202), p: [__RΦ.a(1440)] }) }, [1440]: { LΦ: t => Object }, [1443]: { LΦ: t => Object }, [1467]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1440)] }) }, [1474]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(198), 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
19
|
import * as LΦ_2 from "../types";
|
|
@@ -23,7 +23,10 @@ function resolvePropertyConversionOptions(options, constructor, property) {
|
|
|
23
23
|
const _options = {
|
|
24
24
|
name: property,
|
|
25
25
|
get reflected() {
|
|
26
|
-
|
|
26
|
+
const reflectedClass = reflect(constructor, { TΦ: "c", t: void 0, p: [__RΦ.a(205)], r: void 0, tp: [] });
|
|
27
|
+
return (reflectedClass.getOwnProperty(property) ||
|
|
28
|
+
reflectedClass.getProperty(property)); // patch bug in typescript-rtti
|
|
29
|
+
// TODO: remove when typescript-rtti is patched
|
|
27
30
|
},
|
|
28
31
|
get tagname() {
|
|
29
32
|
return options.tagname || defaults.tagnameFromProperty(this);
|
|
@@ -65,7 +68,7 @@ function storePropertyConversionOptions(constructor, property, options) {
|
|
|
65
68
|
}
|
|
66
69
|
map.set(property, options);
|
|
67
70
|
}
|
|
68
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
71
|
+
__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);
|
|
69
72
|
__RΦ.m("rt:f", "F")(storePropertyConversionOptions);
|
|
70
73
|
__RΦ.m("rt:t", () => __RΦ.a(22))(storePropertyConversionOptions);
|
|
71
74
|
function findPropertyConversionOptions(constructor, property) {
|
|
@@ -74,23 +77,23 @@ function findPropertyConversionOptions(constructor, property) {
|
|
|
74
77
|
return options.get(property);
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
80
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1424), v: null }, { n: "property", t: () => __RΦ.a(1426), v: null }])(findPropertyConversionOptions);
|
|
78
81
|
__RΦ.m("rt:f", "F")(findPropertyConversionOptions);
|
|
79
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
82
|
+
__RΦ.m("rt:t", () => __RΦ.a(1435))(findPropertyConversionOptions);
|
|
80
83
|
export function getPropertyConversionOptions(constructor, property) {
|
|
81
84
|
const options = findPropertyConversionOptions(constructor, property);
|
|
82
85
|
return options || resolvePropertyConversionOptions({}, constructor, property);
|
|
83
86
|
}
|
|
84
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
87
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1441), v: null }, { n: "property", t: () => __RΦ.a(1443), v: null }])(getPropertyConversionOptions);
|
|
85
88
|
__RΦ.m("rt:f", "F")(getPropertyConversionOptions);
|
|
86
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
89
|
+
__RΦ.m("rt:t", () => __RΦ.a(1467))(getPropertyConversionOptions);
|
|
87
90
|
function PropDecoratorFactory(options) {
|
|
88
91
|
return __RΦ.f(function (prototype, property) {
|
|
89
92
|
const _options = resolvePropertyConversionOptions(options || {}, prototype.constructor, property);
|
|
90
93
|
storePropertyConversionOptions(prototype.constructor, property, _options);
|
|
91
|
-
}, [__RΦ.m("rt:p", [{ n: "prototype", t: () => __RΦ.a(1), v: null }, { n: "property", t: () => __RΦ.a(
|
|
94
|
+
}, [__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))], "");
|
|
92
95
|
}
|
|
93
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
96
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1474), v: null, f: "?" }])(PropDecoratorFactory);
|
|
94
97
|
__RΦ.m("rt:f", "F")(PropDecoratorFactory);
|
|
95
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
98
|
+
__RΦ.m("rt:t", () => __RΦ.a(1476))(PropDecoratorFactory);
|
|
96
99
|
export { PropDecoratorFactory as Prop };
|
|
@@ -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: { [1370]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1341)] }) }, [214]: { TΦ: "5", name: "XMLModelPropertyOptions" }, [1341]: { LΦ: t => Object }, [1374]: { LΦ: t => Object }, [493]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(375)] }) }, [375]: { LΦ: t => Object }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_0.IΦXMLElement }, [496]: { LΦ: t => Object }, [497]: { LΦ: t => LΦ_1.ReflectedProperty }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [505]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1)] }) }, [502]: { LΦ: t => LΦ_2.XMLModel }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [357]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(20), p: [{ n: "element", t: () => __RΦ.a(105), v: null }, { n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [399]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(400), p: [__RΦ.a(377), __RΦ.a(378)] }) }, [400]: { LΦ: t => Object }, [377]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(374), p: [__RΦ.a(215)] }) }, [374]: { TΦ: "5", name: "PropertyFromXMLContext" }, [215]: { LΦ: t => Object }, [378]: { LΦ: t => "elements" }, [1221]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(107), p: [{ n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [1223]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(1336), p: [{ n: "context", t: () => __RΦ.a(377), v: null }], f: "" }) }, [1336]: { LΦ: t => Object }, [1225]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(111), p: [{ n: "context", t: () => __RΦ.a(1343), v: null }], f: "" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [1343]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1340), p: [__RΦ.a(215)] }) }, [1340]: { TΦ: "5", name: "PropertyToXMLContext" }, [
|
|
16
|
+
}, t: { [1370]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(1341)] }) }, [214]: { TΦ: "5", name: "XMLModelPropertyOptions" }, [1341]: { LΦ: t => Object }, [1374]: { LΦ: t => Object }, [493]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(375)] }) }, [375]: { LΦ: t => Object }, [107]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(105) }) }, [105]: { LΦ: t => LΦ_0.IΦXMLElement }, [496]: { LΦ: t => Object }, [497]: { LΦ: t => LΦ_1.ReflectedProperty }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [505]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1)] }) }, [502]: { LΦ: t => LΦ_2.XMLModel }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [357]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(20), p: [{ n: "element", t: () => __RΦ.a(105), v: null }, { n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [399]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(400), p: [__RΦ.a(377), __RΦ.a(378)] }) }, [400]: { LΦ: t => Object }, [377]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(374), p: [__RΦ.a(215)] }) }, [374]: { TΦ: "5", name: "PropertyFromXMLContext" }, [215]: { LΦ: t => Object }, [378]: { LΦ: t => "elements" }, [1221]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(107), p: [{ n: "context", t: () => __RΦ.a(399), v: null }], f: "" }) }, [1223]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(1336), p: [{ n: "context", t: () => __RΦ.a(377), v: null }], f: "" }) }, [1336]: { LΦ: t => Object }, [1225]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(111), p: [{ n: "context", t: () => __RΦ.a(1343), v: null }], f: "" }) }, [111]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(107) }] }) }, [1343]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1340), p: [__RΦ.a(215)] }) }, [1340]: { TΦ: "5", name: "PropertyToXMLContext" }, [1386]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(74), __RΦ.a(1385)] }) }, [74]: { LΦ: t => RegExp }, [1385]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [1277]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1346]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1299]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [506]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(505)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [610]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(602)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [602]: { TΦ: "5", name: "ConversionOptions" }, [613]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(612) }) }, [612]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [656]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(657), p: [__RΦ.a(381)] }) }, [657]: { LΦ: t => Object }, [381]: { LΦ: t => Object }, [519]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(381)] }) }, [861]: { LΦ: t => Object }, [888]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(889), p: [__RΦ.a(861)] }) }, [889]: { LΦ: t => Object }, [926]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(861)] }) }, [528]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(523)] }) }, [523]: { LΦ: t => Object }, [660]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(667) }, { n: "toXML", f: "", t: __RΦ.a(898) }, { n: "options", f: "", t: __RΦ.a(1074) }] }) }, [667]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(663), __RΦ.a(665)] }) }, [663]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(664), p: [__RΦ.a(606), __RΦ.a(384)] }) }, [664]: { LΦ: t => Object }, [606]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(380), p: [__RΦ.a(523)] }) }, [380]: { TΦ: "5", name: "fromXMLContext" }, [384]: { LΦ: t => "properties" }, [665]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(666), p: [__RΦ.a(523)] }) }, [666]: { LΦ: t => Object }, [898]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(894), __RΦ.a(896)] }) }, [894]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(895), p: [__RΦ.a(863), __RΦ.a(384)] }) }, [895]: { LΦ: t => Object }, [863]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(860), p: [__RΦ.a(523)] }) }, [860]: { TΦ: "5", name: "toXMLContext" }, [896]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(897), p: [__RΦ.a(523)] }) }, [897]: { LΦ: t => Object }, [1074]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1064), p: [__RΦ.a(1072), __RΦ.a(1073)] }) }, [1064]: { LΦ: t => Map }, [1072]: { LΦ: t => Object }, [1073]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(214), p: [__RΦ.a(523)] }) }, [607]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(606), __RΦ.a(523)] }) }, [864]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(602), p: [__RΦ.a(863), __RΦ.a(111)] }) }, [1817]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1816)] }) }, [1816]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(502), p: [__RΦ.a(1623)] }) }, [1623]: { LΦ: t => Object }, [1644]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1634]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) } } };
|
|
17
17
|
var IΦPropertyToXMLContext = { name: "PropertyToXMLContext", prototype: {}, identity: Symbol("PropertyToXMLContext (interface)") };
|
|
18
18
|
export { IΦPropertyToXMLContext };
|
|
19
19
|
(t => __RΦ.t[1340] = t)(IΦPropertyToXMLContext);
|
|
@@ -101,7 +101,7 @@ __RΦ.m("rt:m", [])(IΦCreateXMLModelPropertyOptions);
|
|
|
101
101
|
__RΦ.m("rt:f", "Ie")(IΦCreateXMLModelPropertyOptions);
|
|
102
102
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
103
103
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
104
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
104
|
+
__RΦ.m("rt:t", () => __RΦ.a(1386))(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
105
105
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
106
106
|
__RΦ.m("rt:t", () => __RΦ.a(1277))(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
107
107
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
@@ -117,7 +117,7 @@ __RΦ.m("rt:t", () => __RΦ.a(506))(IΦCreateXMLModelPropertyOptions.prototype,
|
|
|
117
117
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "model");
|
|
118
118
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
119
119
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
120
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
120
|
+
__RΦ.m("rt:t", () => __RΦ.a(1386))(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
121
121
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
122
122
|
__RΦ.m("rt:t", () => __RΦ.a(1277))(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
123
123
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
@@ -208,23 +208,23 @@ __RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelOptions.prototype, "tagname");
|
|
|
208
208
|
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "tagname");
|
|
209
209
|
var IΦCreateXMLModelOptions = { name: "CreateXMLModelOptions", prototype: {}, identity: Symbol("CreateXMLModelOptions (interface)") };
|
|
210
210
|
export { IΦCreateXMLModelOptions };
|
|
211
|
-
(t => __RΦ.t[
|
|
211
|
+
(t => __RΦ.t[1622] = t)(IΦCreateXMLModelOptions);
|
|
212
212
|
__RΦ.m("rt:P", ["parent", "fromXML", "toXML", "tagname"])(IΦCreateXMLModelOptions);
|
|
213
213
|
__RΦ.m("rt:m", [])(IΦCreateXMLModelOptions);
|
|
214
214
|
__RΦ.m("rt:f", "Ie")(IΦCreateXMLModelOptions);
|
|
215
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
215
|
+
__RΦ.m("rt:t", () => __RΦ.a(1817))(IΦCreateXMLModelOptions.prototype, "parent");
|
|
216
216
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "parent");
|
|
217
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
217
|
+
__RΦ.m("rt:t", () => __RΦ.a(1644))(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
218
218
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
219
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
219
|
+
__RΦ.m("rt:t", () => __RΦ.a(1634))(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
220
220
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
221
221
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
222
222
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
223
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
223
|
+
__RΦ.m("rt:t", () => __RΦ.a(1817))(IΦCreateXMLModelOptions.prototype, "parent");
|
|
224
224
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "parent");
|
|
225
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
225
|
+
__RΦ.m("rt:t", () => __RΦ.a(1644))(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
226
226
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
227
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
227
|
+
__RΦ.m("rt:t", () => __RΦ.a(1634))(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
228
228
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
229
229
|
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
230
230
|
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
const __RΦ = { m: (k, v) => (t, ...a) => t && Reflect.metadata ? Reflect.metadata(k, v)(t, ...a) : void 0, f: (f, d, n) => (d.forEach(d => d(f)), Object.defineProperty(f, "name", { value: n, writable: false }), f), c: (c, d, dp, dsp, n) => (d.forEach(d => d(c)), dp.forEach(([p, d]) => d(c.prototype, p)), dsp.forEach(([p, d]) => d(c, p)), n ? Object.defineProperty(c, "name", { value: n, writable: false }) : undefined, c), r: (o, a) => (Object.assign(o, a)), a: id => {
|
|
8
|
+
let t = __RΦ.t[id];
|
|
9
|
+
if (t === void 0)
|
|
10
|
+
return void 0;
|
|
11
|
+
if (t.RΦ) {
|
|
12
|
+
let r = t.RΦ;
|
|
13
|
+
delete t.RΦ;
|
|
14
|
+
__RΦ.r(t, r(t));
|
|
15
|
+
}
|
|
16
|
+
else if (t.LΦ) {
|
|
17
|
+
let l = t.LΦ();
|
|
18
|
+
delete t.LΦ;
|
|
19
|
+
__RΦ.t[id] = t = l;
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
}, t: { [2702]: { RΦ: t => ({ TΦ: "O", m: [{ n: "propA", f: "", t: __RΦ.a(13) }, { n: "propB", f: "", t: __RΦ.a(20) }, { n: "propC", f: "", t: __RΦ.a(2718) }, { n: "propD", f: "", t: __RΦ.a(705) }, { n: "__constructor", f: "", t: __RΦ.a(4) }] }) }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [2718]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(2716) }) }, [2716]: { TΦ: "5", name: "B" }, [705]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(47), __RΦ.a(135)] }) }, [47]: { LΦ: t => 0 }, [135]: { LΦ: t => 1 }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [2654]: { RΦ: t => ({ TΦ: "O", m: [{ n: "name", f: "", t: __RΦ.a(13) }, { n: "nbPages", f: "", t: __RΦ.a(14) }] }) }, [14]: { LΦ: t => Number }, [2673]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(2617) }) }, [2617]: { TΦ: "5", name: "Book" }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [101]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(102), p: [] }) }, [102]: { LΦ: t => Object } } };
|
|
23
|
+
import "mocha";
|
|
24
|
+
import { expect, assert } from "chai";
|
|
25
|
+
import "reflect-metadata";
|
|
26
|
+
import { Model, Prop, getModel } from "./model";
|
|
27
|
+
import XML from "./xml";
|
|
28
|
+
import { reflect } from "typescript-rtti";
|
|
29
|
+
let Book = class Book {
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.name = options.name;
|
|
32
|
+
this.nbPages = options.nbPages;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
Book = __decorate([
|
|
36
|
+
Model({
|
|
37
|
+
fromXML({ model, properties }) {
|
|
38
|
+
return new model.type(properties);
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
], Book);
|
|
42
|
+
(t => __RΦ.t[2617] = t)(Book);
|
|
43
|
+
__RΦ.m("rt:SP", [])(Book);
|
|
44
|
+
__RΦ.m("rt:P", ["name", "nbPages"])(Book);
|
|
45
|
+
__RΦ.m("rt:Sm", [])(Book);
|
|
46
|
+
__RΦ.m("rt:m", ["fromXML"])(Book);
|
|
47
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(2654), v: null }])(Book);
|
|
48
|
+
__RΦ.m("rt:f", "C")(Book);
|
|
49
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(Book.prototype, "name");
|
|
50
|
+
__RΦ.m("rt:f", "P")(Book.prototype, "name");
|
|
51
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(Book.prototype, "nbPages");
|
|
52
|
+
__RΦ.m("rt:f", "P")(Book.prototype, "nbPages");
|
|
53
|
+
let Library = class Library {
|
|
54
|
+
constructor(name, ...books) {
|
|
55
|
+
this.books = [];
|
|
56
|
+
this.name = name;
|
|
57
|
+
this.books.push(...books);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
Library = __decorate([
|
|
61
|
+
Model({
|
|
62
|
+
fromXML({ model, properties }) {
|
|
63
|
+
return new model.type(properties.name, ...properties.books);
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
], Library);
|
|
67
|
+
(t => __RΦ.t[2657] = t)(Library);
|
|
68
|
+
__RΦ.m("rt:SP", [])(Library);
|
|
69
|
+
__RΦ.m("rt:P", ["name", "books"])(Library);
|
|
70
|
+
__RΦ.m("rt:Sm", [])(Library);
|
|
71
|
+
__RΦ.m("rt:m", ["fromXML"])(Library);
|
|
72
|
+
__RΦ.m("rt:p", [{ n: "name", t: () => __RΦ.a(13), v: null }, { n: "books", t: () => __RΦ.a(2673), v: null, f: "3" }])(Library);
|
|
73
|
+
__RΦ.m("rt:f", "C")(Library);
|
|
74
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(Library.prototype, "name");
|
|
75
|
+
__RΦ.m("rt:f", "P")(Library.prototype, "name");
|
|
76
|
+
__RΦ.m("rt:t", () => __RΦ.a(2673))(Library.prototype, "books");
|
|
77
|
+
__RΦ.m("rt:f", "P")(Library.prototype, "books");
|
|
78
|
+
describe("Library Example", __RΦ.f(() => {
|
|
79
|
+
const library = new Library("test");
|
|
80
|
+
for (let i = 1; i <= 4; i++) {
|
|
81
|
+
const book = new Book({ name: `Book #${i}`, nbPages: Math.pow(10, i) });
|
|
82
|
+
library.books.push(book);
|
|
83
|
+
}
|
|
84
|
+
const libraryXMLString = XML.stringify(XML.parse(`<library>
|
|
85
|
+
<name>${library.name}</name>
|
|
86
|
+
<books>
|
|
87
|
+
${library.books
|
|
88
|
+
.map(__RΦ.f((book) => ` <book>
|
|
89
|
+
<name>${book.name}</name>
|
|
90
|
+
<nb-pages>${book.nbPages}</nb-pages>
|
|
91
|
+
</book>`, [__RΦ.m("rt:p", [{ n: "book", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(13))], ""))
|
|
92
|
+
.join("")}
|
|
93
|
+
</books>
|
|
94
|
+
</library>`));
|
|
95
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
96
|
+
const xml = getModel(Library).toXML(library);
|
|
97
|
+
expect(XML.stringify(xml)).to.equal(libraryXMLString);
|
|
98
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
99
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
100
|
+
const parsedLibrary = getModel(Library).fromXML(libraryXMLString);
|
|
101
|
+
expect(parsedLibrary instanceof Library).to.be.true;
|
|
102
|
+
expect(parsedLibrary).to.deep.equal(library);
|
|
103
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
104
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
105
|
+
let A = class A {
|
|
106
|
+
constructor(record) {
|
|
107
|
+
this.propA = "";
|
|
108
|
+
this.propB = true;
|
|
109
|
+
this.propC = [];
|
|
110
|
+
this.propD = 0;
|
|
111
|
+
if (record)
|
|
112
|
+
Object.entries(record).forEach(__RΦ.f(([key, val]) => {
|
|
113
|
+
this[key] = val;
|
|
114
|
+
}, [__RΦ.m("rt:p", [{ n: "[key, val]", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
__decorate([
|
|
118
|
+
Prop({ tagname: "b", inline: true })
|
|
119
|
+
], A.prototype, "propC", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
Prop({ tagname: "propd" })
|
|
122
|
+
], A.prototype, "propD", void 0);
|
|
123
|
+
A = __decorate([
|
|
124
|
+
Model({
|
|
125
|
+
fromXML({ model, properties }) {
|
|
126
|
+
return new model.type(properties);
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
], A);
|
|
130
|
+
(t => __RΦ.t[2703] = t)(A);
|
|
131
|
+
__RΦ.m("rt:SP", [])(A);
|
|
132
|
+
__RΦ.m("rt:P", ["propA", "propB", "propC", "propD"])(A);
|
|
133
|
+
__RΦ.m("rt:Sm", [])(A);
|
|
134
|
+
__RΦ.m("rt:m", ["fromXML"])(A);
|
|
135
|
+
__RΦ.m("rt:p", [{ n: "record", t: () => __RΦ.a(101), v: null, f: "?" }])(A);
|
|
136
|
+
__RΦ.m("rt:f", "C")(A);
|
|
137
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(A.prototype, "propA");
|
|
138
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propA");
|
|
139
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(A.prototype, "propB");
|
|
140
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propB");
|
|
141
|
+
__RΦ.m("rt:t", () => __RΦ.a(2718))(A.prototype, "propC");
|
|
142
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propC");
|
|
143
|
+
__RΦ.m("rt:t", () => __RΦ.a(705))(A.prototype, "propD");
|
|
144
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propD");
|
|
145
|
+
let B = class B {
|
|
146
|
+
constructor(record) {
|
|
147
|
+
this.propA = 0;
|
|
148
|
+
if (record)
|
|
149
|
+
Object.entries(record).forEach(__RΦ.f(([key, val]) => {
|
|
150
|
+
this[key] = val;
|
|
151
|
+
}, [__RΦ.m("rt:p", [{ n: "[key, val]", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
B = __decorate([
|
|
155
|
+
Model({
|
|
156
|
+
fromXML({ model, properties }) {
|
|
157
|
+
return new model.type(properties);
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
], B);
|
|
161
|
+
(t => __RΦ.t[2716] = t)(B);
|
|
162
|
+
__RΦ.m("rt:SP", [])(B);
|
|
163
|
+
__RΦ.m("rt:P", ["propA"])(B);
|
|
164
|
+
__RΦ.m("rt:Sm", [])(B);
|
|
165
|
+
__RΦ.m("rt:m", ["fromXML"])(B);
|
|
166
|
+
__RΦ.m("rt:p", [{ n: "record", t: () => __RΦ.a(101), v: null, f: "?" }])(B);
|
|
167
|
+
__RΦ.m("rt:f", "C")(B);
|
|
168
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(B.prototype, "propA");
|
|
169
|
+
__RΦ.m("rt:f", "P")(B.prototype, "propA");
|
|
170
|
+
describe("Edgy Cases", __RΦ.f(() => {
|
|
171
|
+
const instance = new A();
|
|
172
|
+
for (let i = 0; i < 8; i++) {
|
|
173
|
+
const b = new B();
|
|
174
|
+
b.propA = i;
|
|
175
|
+
instance.propC.push(b);
|
|
176
|
+
}
|
|
177
|
+
const instanceXMLString = XML.stringify(XML.parse(`<a>
|
|
178
|
+
<prop-a>${instance.propA}</prop-a>
|
|
179
|
+
<prop-b>${instance.propB}</prop-b>
|
|
180
|
+
${instance.propC.map(__RΦ.f((b) => `<b><prop-a>${b.propA}</prop-a></b>`, [__RΦ.m("rt:p", [{ n: "b", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(13))], "")).join("")}
|
|
181
|
+
<propd>${instance.propD}</propd>
|
|
182
|
+
</a>`));
|
|
183
|
+
it("should give right type infos", __RΦ.f(() => {
|
|
184
|
+
const reflectedA = reflect(A, { TΦ: "c", t: void 0, p: [__RΦ.a(2702)], r: void 0, tp: [] });
|
|
185
|
+
assert(reflectedA === reflect(A, { TΦ: "c", t: void 0, p: [__RΦ.a(2702)], r: void 0, tp: [] }));
|
|
186
|
+
expect(reflectedA.getProperty("propA").type.isClass(String)).to.be.true;
|
|
187
|
+
expect(reflectedA.getProperty("propB").type.isClass(Boolean)).to.be.true;
|
|
188
|
+
const ModelAPropCType = reflectedA.getProperty("propC").type;
|
|
189
|
+
expect(ModelAPropCType.is("array") && ModelAPropCType.elementType.isClass(B)).to.be.true;
|
|
190
|
+
const ModelAPropDType = reflectedA.getProperty("propD").type;
|
|
191
|
+
expect(ModelAPropDType.is("union")).to.be.true;
|
|
192
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
193
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
194
|
+
const parsed = getModel(A).fromXML(instanceXMLString);
|
|
195
|
+
expect(parsed instanceof A).to.be.true;
|
|
196
|
+
expect(parsed).to.deep.equal(instance);
|
|
197
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
198
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
199
|
+
const xml = getModel(A).toXML(instance);
|
|
200
|
+
expect(XML.stringify(xml)).to.equal(instanceXMLString);
|
|
201
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
202
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
203
|
+
let C = class C extends B {
|
|
204
|
+
constructor() {
|
|
205
|
+
super(...arguments);
|
|
206
|
+
this.propB = 3;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
C = __decorate([
|
|
210
|
+
Model()
|
|
211
|
+
], C);
|
|
212
|
+
(t => __RΦ.t[2766] = t)(C);
|
|
213
|
+
__RΦ.m("rt:SP", [])(C);
|
|
214
|
+
__RΦ.m("rt:P", ["propB"])(C);
|
|
215
|
+
__RΦ.m("rt:Sm", [])(C);
|
|
216
|
+
__RΦ.m("rt:m", [])(C);
|
|
217
|
+
__RΦ.m("rt:f", "C")(C);
|
|
218
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(C.prototype, "propB");
|
|
219
|
+
__RΦ.m("rt:f", "P")(C.prototype, "propB");
|
|
220
|
+
describe("Inheritance", __RΦ.f(() => {
|
|
221
|
+
const cInstance = new C();
|
|
222
|
+
const cInstanceXMLString = `<c><prop-a>${cInstance.propA}</prop-a><prop-b>${cInstance.propB}</prop-b></c>`;
|
|
223
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
224
|
+
expect(getModel(C).fromXML(cInstanceXMLString)).to.deep.equal(cInstance);
|
|
225
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
226
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
227
|
+
expect(XML.stringify(getModel(C).toXML(cInstance))).to.equal(cInstanceXMLString);
|
|
228
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
229
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|