xml-model 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.eslintrc.js +6 -0
- package/.gitignore +2 -0
- package/.vscode/launch.json +21 -0
- package/.vscode/settings.json +3 -0
- package/README.md +7 -0
- package/build/main/defaults/index.d.ts +14 -0
- package/build/main/defaults/index.js +165 -0
- package/build/main/defaults/models.d.ts +1 -0
- package/build/main/defaults/models.js +55 -0
- package/build/main/index.d.ts +5 -0
- package/build/main/index.js +31 -0
- package/build/main/middleware.d.ts +9 -0
- package/build/main/middleware.js +65 -0
- package/build/main/model/index.d.ts +26 -0
- package/build/main/model/index.js +304 -0
- package/build/main/model/property.d.ts +5 -0
- package/build/main/model/property.js +95 -0
- package/build/main/model/types.d.ts +69 -0
- package/build/main/model/types.js +214 -0
- package/build/main/model.spec.d.ts +1 -0
- package/build/main/model.spec.js +261 -0
- package/build/main/types.d.ts +8 -0
- package/build/main/types.js +18 -0
- package/build/main/xml.d.ts +31 -0
- package/build/main/xml.js +95 -0
- package/build/module/defaults/index.d.ts +13 -0
- package/build/module/defaults/index.js +71 -0
- package/build/module/defaults/models.d.ts +1 -0
- package/build/module/defaults/models.js +27 -0
- package/build/module/errors.d.ts +3 -0
- package/build/module/errors.js +37 -0
- package/build/module/index.d.ts +4 -0
- package/build/module/index.js +19 -0
- package/build/module/middleware.d.ts +9 -0
- package/build/module/middleware.js +60 -0
- package/build/module/model.d.ts +71 -0
- package/build/module/model.js +466 -0
- package/build/module/model.spec.d.ts +1 -0
- package/build/module/model.spec.js +76 -0
- package/build/module/types.d.ts +13 -0
- package/build/module/types.js +40 -0
- package/build/module/xml-from-object.d.ts +11 -0
- package/build/module/xml-from-object.js +58 -0
- package/build/module/xml-from-object.spec.d.ts +1 -0
- package/build/module/xml-from-object.spec.js +104 -0
- package/build/module/xml-to-object.d.ts +11 -0
- package/build/module/xml-to-object.js +55 -0
- package/build/module/xml.d.ts +15 -0
- package/build/module/xml.js +74 -0
- package/package.json +50 -0
- package/register-ts-node.js +9 -0
- package/src/defaults/index.ts +181 -0
- package/src/defaults/models.ts +45 -0
- package/src/index.ts +6 -0
- package/src/middleware.ts +34 -0
- package/src/model/index.ts +245 -0
- package/src/model/property.ts +104 -0
- package/src/model/types.ts +99 -0
- package/src/model.spec.ts +178 -0
- package/src/types.ts +8 -0
- package/src/xml.ts +80 -0
- package/tsconfig.json +106 -0
- package/tsconfig.module.json +9 -0
- package/yarn.lock +2217 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IΦCreateXMLModelOptions = exports.IΦXMLModelOptions = exports.IΦtoXMLContext = exports.IΦfromXMLContext = exports.IΦCreateXMLModelPropertyOptions = exports.IΦXMLModelPropertyOptions = exports.IΦPropertyFromXMLContext = exports.IΦPropertyToXMLContext = void 0;
|
|
4
|
+
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 => {
|
|
5
|
+
let t = __RΦ.t[id];
|
|
6
|
+
if (t === void 0)
|
|
7
|
+
return void 0;
|
|
8
|
+
if (t.RΦ) {
|
|
9
|
+
let r = t.RΦ;
|
|
10
|
+
delete t.RΦ;
|
|
11
|
+
__RΦ.r(t, r(t));
|
|
12
|
+
}
|
|
13
|
+
else if (t.LΦ) {
|
|
14
|
+
let l = t.LΦ();
|
|
15
|
+
delete t.LΦ;
|
|
16
|
+
__RΦ.t[id] = t = l;
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
}, t: { [676]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(199), p: [__RΦ.a(648)] }) }, [199]: { TΦ: "5", name: "XMLModelPropertyOptions" }, [648]: { LΦ: t => Object }, [1802]: { LΦ: t => Object }, [478]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(199), p: [__RΦ.a(360)] }) }, [360]: { LΦ: t => Object }, [92]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(91) }) }, [91]: { LΦ: t => require("xml-js/types").IΦElement }, [481]: { LΦ: t => Object }, [482]: { LΦ: t => require("typescript-rtti").ReflectedProperty }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [342]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(20), p: [{ n: "element", t: () => __RΦ.a(91), v: null }, { n: "context", t: () => __RΦ.a(384), v: null }], f: "" }) }, [384]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(385), p: [__RΦ.a(362), __RΦ.a(363)] }) }, [385]: { LΦ: t => Object }, [362]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(359), p: [__RΦ.a(200)] }) }, [359]: { TΦ: "5", name: "PropertyFromXMLContext" }, [200]: { LΦ: t => Object }, [363]: { LΦ: t => "elements" }, [592]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(92), p: [{ n: "context", t: () => __RΦ.a(384), v: null }], f: "" }) }, [614]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(621), p: [{ n: "context", t: () => __RΦ.a(362), v: null }], f: "" }) }, [621]: { LΦ: t => Object }, [641]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(93), p: [{ n: "context", t: () => __RΦ.a(650), v: null }], f: "" }) }, [93]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(92) }] }) }, [650]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(647), p: [__RΦ.a(200)] }) }, [647]: { TΦ: "5", name: "PropertyToXMLContext" }, [706]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(74), __RΦ.a(705)] }) }, [74]: { LΦ: t => RegExp }, [705]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [593]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [642]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [615]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [537]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(514)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [514]: { TΦ: "5", name: "ConversionOptions" }, [541]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(540) }) }, [540]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [572]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(573), p: [__RΦ.a(366)] }) }, [573]: { LΦ: t => Object }, [366]: { LΦ: t => Object }, [502]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(499), p: [__RΦ.a(366)] }) }, [499]: { LΦ: t => require("../model").XMLModel }, [658]: { LΦ: t => Object }, [1414]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1415), p: [__RΦ.a(658)] }) }, [1415]: { LΦ: t => Object }, [1421]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(499), p: [__RΦ.a(658)] }) }, [511]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(528) }, { n: "toXML", f: "", t: __RΦ.a(1374) }, { n: "options", f: "", t: __RΦ.a(1348) }] }) }, [528]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(514), p: [__RΦ.a(520), __RΦ.a(526)] }) }, [520]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(521), p: [__RΦ.a(518), __RΦ.a(369)] }) }, [521]: { LΦ: t => Object }, [518]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(365), p: [__RΦ.a(506)] }) }, [365]: { TΦ: "5", name: "fromXMLContext" }, [506]: { LΦ: t => Object }, [369]: { LΦ: t => "properties" }, [526]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(527), p: [__RΦ.a(506)] }) }, [527]: { LΦ: t => Object }, [1374]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(514), p: [__RΦ.a(1366), __RΦ.a(1372)] }) }, [1366]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1367), p: [__RΦ.a(1194), __RΦ.a(369)] }) }, [1367]: { LΦ: t => Object }, [1194]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(657), p: [__RΦ.a(506)] }) }, [657]: { TΦ: "5", name: "toXMLContext" }, [1372]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1373), p: [__RΦ.a(506)] }) }, [1373]: { LΦ: t => Object }, [1348]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(734), p: [__RΦ.a(1346), __RΦ.a(1347)] }) }, [734]: { LΦ: t => Map }, [1346]: { LΦ: t => Object }, [1347]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(199), p: [__RΦ.a(506)] }) }, [1208]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(514), p: [__RΦ.a(518), __RΦ.a(506)] }) }, [1195]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(514), p: [__RΦ.a(1194), __RΦ.a(93)] }) }, [1825]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1832]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) } } };
|
|
20
|
+
var IΦPropertyToXMLContext = { name: "PropertyToXMLContext", prototype: {}, identity: Symbol("PropertyToXMLContext (interface)") };
|
|
21
|
+
exports.IΦPropertyToXMLContext = IΦPropertyToXMLContext;
|
|
22
|
+
(t => __RΦ.t[647] = t)(IΦPropertyToXMLContext);
|
|
23
|
+
__RΦ.m("rt:P", ["property", "value"])(IΦPropertyToXMLContext);
|
|
24
|
+
__RΦ.m("rt:m", [])(IΦPropertyToXMLContext);
|
|
25
|
+
__RΦ.m("rt:i", [() => IΦOmit])(IΦPropertyToXMLContext);
|
|
26
|
+
__RΦ.m("rt:f", "Ie")(IΦPropertyToXMLContext);
|
|
27
|
+
__RΦ.m("rt:t", () => __RΦ.a(676))(IΦPropertyToXMLContext.prototype, "property");
|
|
28
|
+
__RΦ.m("rt:f", "P")(IΦPropertyToXMLContext.prototype, "property");
|
|
29
|
+
__RΦ.m("rt:t", () => __RΦ.a(1802))(IΦPropertyToXMLContext.prototype, "value");
|
|
30
|
+
__RΦ.m("rt:f", "P")(IΦPropertyToXMLContext.prototype, "value");
|
|
31
|
+
__RΦ.m("rt:t", () => __RΦ.a(676))(IΦPropertyToXMLContext.prototype, "property");
|
|
32
|
+
__RΦ.m("rt:f", "P")(IΦPropertyToXMLContext.prototype, "property");
|
|
33
|
+
__RΦ.m("rt:t", () => __RΦ.a(1802))(IΦPropertyToXMLContext.prototype, "value");
|
|
34
|
+
__RΦ.m("rt:f", "P")(IΦPropertyToXMLContext.prototype, "value");
|
|
35
|
+
var IΦPropertyFromXMLContext = { name: "PropertyFromXMLContext", prototype: {}, identity: Symbol("PropertyFromXMLContext (interface)") };
|
|
36
|
+
exports.IΦPropertyFromXMLContext = IΦPropertyFromXMLContext;
|
|
37
|
+
(t => __RΦ.t[359] = t)(IΦPropertyFromXMLContext);
|
|
38
|
+
__RΦ.m("rt:P", ["property", "elements"])(IΦPropertyFromXMLContext);
|
|
39
|
+
__RΦ.m("rt:m", [])(IΦPropertyFromXMLContext);
|
|
40
|
+
__RΦ.m("rt:i", [() => IΦOmit])(IΦPropertyFromXMLContext);
|
|
41
|
+
__RΦ.m("rt:f", "Ie")(IΦPropertyFromXMLContext);
|
|
42
|
+
__RΦ.m("rt:t", () => __RΦ.a(478))(IΦPropertyFromXMLContext.prototype, "property");
|
|
43
|
+
__RΦ.m("rt:f", "P")(IΦPropertyFromXMLContext.prototype, "property");
|
|
44
|
+
__RΦ.m("rt:t", () => __RΦ.a(92))(IΦPropertyFromXMLContext.prototype, "elements");
|
|
45
|
+
__RΦ.m("rt:f", "P")(IΦPropertyFromXMLContext.prototype, "elements");
|
|
46
|
+
__RΦ.m("rt:t", () => __RΦ.a(478))(IΦPropertyFromXMLContext.prototype, "property");
|
|
47
|
+
__RΦ.m("rt:f", "P")(IΦPropertyFromXMLContext.prototype, "property");
|
|
48
|
+
__RΦ.m("rt:t", () => __RΦ.a(92))(IΦPropertyFromXMLContext.prototype, "elements");
|
|
49
|
+
__RΦ.m("rt:f", "P")(IΦPropertyFromXMLContext.prototype, "elements");
|
|
50
|
+
var IΦXMLModelPropertyOptions = { name: "XMLModelPropertyOptions", prototype: {}, identity: Symbol("XMLModelPropertyOptions (interface)") };
|
|
51
|
+
exports.IΦXMLModelPropertyOptions = IΦXMLModelPropertyOptions;
|
|
52
|
+
(t => __RΦ.t[199] = t)(IΦXMLModelPropertyOptions);
|
|
53
|
+
__RΦ.m("rt:P", ["name", "reflected", "tagname", "ignored", "inline", "isSourceElement", "resolveElements", "fromXML", "toXML"])(IΦXMLModelPropertyOptions);
|
|
54
|
+
__RΦ.m("rt:m", [])(IΦXMLModelPropertyOptions);
|
|
55
|
+
__RΦ.m("rt:f", "Ie")(IΦXMLModelPropertyOptions);
|
|
56
|
+
__RΦ.m("rt:t", () => __RΦ.a(481))(IΦXMLModelPropertyOptions.prototype, "name");
|
|
57
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "name");
|
|
58
|
+
__RΦ.m("rt:t", () => __RΦ.a(482))(IΦXMLModelPropertyOptions.prototype, "reflected");
|
|
59
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "reflected");
|
|
60
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelPropertyOptions.prototype, "tagname");
|
|
61
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "tagname");
|
|
62
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦXMLModelPropertyOptions.prototype, "ignored");
|
|
63
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "ignored");
|
|
64
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦXMLModelPropertyOptions.prototype, "inline");
|
|
65
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "inline");
|
|
66
|
+
__RΦ.m("rt:t", () => __RΦ.a(342))(IΦXMLModelPropertyOptions.prototype, "isSourceElement");
|
|
67
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "isSourceElement");
|
|
68
|
+
__RΦ.m("rt:t", () => __RΦ.a(592))(IΦXMLModelPropertyOptions.prototype, "resolveElements");
|
|
69
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "resolveElements");
|
|
70
|
+
__RΦ.m("rt:t", () => __RΦ.a(614))(IΦXMLModelPropertyOptions.prototype, "fromXML");
|
|
71
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "fromXML");
|
|
72
|
+
__RΦ.m("rt:t", () => __RΦ.a(641))(IΦXMLModelPropertyOptions.prototype, "toXML");
|
|
73
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "toXML");
|
|
74
|
+
__RΦ.m("rt:t", () => __RΦ.a(481))(IΦXMLModelPropertyOptions.prototype, "name");
|
|
75
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "name");
|
|
76
|
+
__RΦ.m("rt:t", () => __RΦ.a(482))(IΦXMLModelPropertyOptions.prototype, "reflected");
|
|
77
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "reflected");
|
|
78
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelPropertyOptions.prototype, "tagname");
|
|
79
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "tagname");
|
|
80
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦXMLModelPropertyOptions.prototype, "ignored");
|
|
81
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "ignored");
|
|
82
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦXMLModelPropertyOptions.prototype, "inline");
|
|
83
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "inline");
|
|
84
|
+
__RΦ.m("rt:t", () => __RΦ.a(342))(IΦXMLModelPropertyOptions.prototype, "isSourceElement");
|
|
85
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "isSourceElement");
|
|
86
|
+
__RΦ.m("rt:t", () => __RΦ.a(592))(IΦXMLModelPropertyOptions.prototype, "resolveElements");
|
|
87
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "resolveElements");
|
|
88
|
+
__RΦ.m("rt:t", () => __RΦ.a(614))(IΦXMLModelPropertyOptions.prototype, "fromXML");
|
|
89
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "fromXML");
|
|
90
|
+
__RΦ.m("rt:t", () => __RΦ.a(641))(IΦXMLModelPropertyOptions.prototype, "toXML");
|
|
91
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelPropertyOptions.prototype, "toXML");
|
|
92
|
+
var IΦCreateXMLModelPropertyOptions = { name: "CreateXMLModelPropertyOptions", prototype: {}, identity: Symbol("CreateXMLModelPropertyOptions (interface)") };
|
|
93
|
+
exports.IΦCreateXMLModelPropertyOptions = IΦCreateXMLModelPropertyOptions;
|
|
94
|
+
(t => __RΦ.t[183] = t)(IΦCreateXMLModelPropertyOptions);
|
|
95
|
+
__RΦ.m("rt:P", ["tagname", "sourceElements", "resolveElements", "toXML", "fromXML", "inline", "ignore"])(IΦCreateXMLModelPropertyOptions);
|
|
96
|
+
__RΦ.m("rt:m", [])(IΦCreateXMLModelPropertyOptions);
|
|
97
|
+
__RΦ.m("rt:f", "Ie")(IΦCreateXMLModelPropertyOptions);
|
|
98
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
99
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
100
|
+
__RΦ.m("rt:t", () => __RΦ.a(706))(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
101
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
102
|
+
__RΦ.m("rt:t", () => __RΦ.a(593))(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
103
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
104
|
+
__RΦ.m("rt:t", () => __RΦ.a(642))(IΦCreateXMLModelPropertyOptions.prototype, "toXML");
|
|
105
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "toXML");
|
|
106
|
+
__RΦ.m("rt:t", () => __RΦ.a(615))(IΦCreateXMLModelPropertyOptions.prototype, "fromXML");
|
|
107
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "fromXML");
|
|
108
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦCreateXMLModelPropertyOptions.prototype, "inline");
|
|
109
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "inline");
|
|
110
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦCreateXMLModelPropertyOptions.prototype, "ignore");
|
|
111
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "ignore");
|
|
112
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
113
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "tagname");
|
|
114
|
+
__RΦ.m("rt:t", () => __RΦ.a(706))(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
115
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "sourceElements");
|
|
116
|
+
__RΦ.m("rt:t", () => __RΦ.a(593))(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
117
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "resolveElements");
|
|
118
|
+
__RΦ.m("rt:t", () => __RΦ.a(642))(IΦCreateXMLModelPropertyOptions.prototype, "toXML");
|
|
119
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "toXML");
|
|
120
|
+
__RΦ.m("rt:t", () => __RΦ.a(615))(IΦCreateXMLModelPropertyOptions.prototype, "fromXML");
|
|
121
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "fromXML");
|
|
122
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦCreateXMLModelPropertyOptions.prototype, "inline");
|
|
123
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "inline");
|
|
124
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(IΦCreateXMLModelPropertyOptions.prototype, "ignore");
|
|
125
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelPropertyOptions.prototype, "ignore");
|
|
126
|
+
var IΦConversionOptions = { name: "ConversionOptions", prototype: {}, identity: Symbol("ConversionOptions (interface)") };
|
|
127
|
+
(t => __RΦ.t[514] = t)(IΦConversionOptions);
|
|
128
|
+
__RΦ.m("rt:P", ["parent", "middlewares"])(IΦConversionOptions);
|
|
129
|
+
__RΦ.m("rt:m", [])(IΦConversionOptions);
|
|
130
|
+
__RΦ.m("rt:f", "I")(IΦConversionOptions);
|
|
131
|
+
__RΦ.m("rt:t", () => __RΦ.a(537))(IΦConversionOptions.prototype, "parent");
|
|
132
|
+
__RΦ.m("rt:f", "P")(IΦConversionOptions.prototype, "parent");
|
|
133
|
+
__RΦ.m("rt:t", () => __RΦ.a(541))(IΦConversionOptions.prototype, "middlewares");
|
|
134
|
+
__RΦ.m("rt:f", "P")(IΦConversionOptions.prototype, "middlewares");
|
|
135
|
+
__RΦ.m("rt:t", () => __RΦ.a(537))(IΦConversionOptions.prototype, "parent");
|
|
136
|
+
__RΦ.m("rt:f", "P")(IΦConversionOptions.prototype, "parent");
|
|
137
|
+
__RΦ.m("rt:t", () => __RΦ.a(541))(IΦConversionOptions.prototype, "middlewares");
|
|
138
|
+
__RΦ.m("rt:f", "P")(IΦConversionOptions.prototype, "middlewares");
|
|
139
|
+
var IΦfromXMLContext = { name: "fromXMLContext", prototype: {}, identity: Symbol("fromXMLContext (interface)") };
|
|
140
|
+
exports.IΦfromXMLContext = IΦfromXMLContext;
|
|
141
|
+
(t => __RΦ.t[365] = t)(IΦfromXMLContext);
|
|
142
|
+
__RΦ.m("rt:P", ["xml", "properties", "model"])(IΦfromXMLContext);
|
|
143
|
+
__RΦ.m("rt:m", [])(IΦfromXMLContext);
|
|
144
|
+
__RΦ.m("rt:f", "Ie")(IΦfromXMLContext);
|
|
145
|
+
__RΦ.m("rt:t", () => __RΦ.a(93))(IΦfromXMLContext.prototype, "xml");
|
|
146
|
+
__RΦ.m("rt:f", "P")(IΦfromXMLContext.prototype, "xml");
|
|
147
|
+
__RΦ.m("rt:t", () => __RΦ.a(572))(IΦfromXMLContext.prototype, "properties");
|
|
148
|
+
__RΦ.m("rt:f", "P")(IΦfromXMLContext.prototype, "properties");
|
|
149
|
+
__RΦ.m("rt:t", () => __RΦ.a(502))(IΦfromXMLContext.prototype, "model");
|
|
150
|
+
__RΦ.m("rt:f", "P")(IΦfromXMLContext.prototype, "model");
|
|
151
|
+
__RΦ.m("rt:t", () => __RΦ.a(93))(IΦfromXMLContext.prototype, "xml");
|
|
152
|
+
__RΦ.m("rt:f", "P")(IΦfromXMLContext.prototype, "xml");
|
|
153
|
+
__RΦ.m("rt:t", () => __RΦ.a(572))(IΦfromXMLContext.prototype, "properties");
|
|
154
|
+
__RΦ.m("rt:f", "P")(IΦfromXMLContext.prototype, "properties");
|
|
155
|
+
__RΦ.m("rt:t", () => __RΦ.a(502))(IΦfromXMLContext.prototype, "model");
|
|
156
|
+
__RΦ.m("rt:f", "P")(IΦfromXMLContext.prototype, "model");
|
|
157
|
+
var IΦtoXMLContext = { name: "toXMLContext", prototype: {}, identity: Symbol("toXMLContext (interface)") };
|
|
158
|
+
exports.IΦtoXMLContext = IΦtoXMLContext;
|
|
159
|
+
(t => __RΦ.t[657] = t)(IΦtoXMLContext);
|
|
160
|
+
__RΦ.m("rt:P", ["object", "properties", "model"])(IΦtoXMLContext);
|
|
161
|
+
__RΦ.m("rt:m", [])(IΦtoXMLContext);
|
|
162
|
+
__RΦ.m("rt:f", "Ie")(IΦtoXMLContext);
|
|
163
|
+
__RΦ.m("rt:t", () => __RΦ.a(658))(IΦtoXMLContext.prototype, "object");
|
|
164
|
+
__RΦ.m("rt:f", "P")(IΦtoXMLContext.prototype, "object");
|
|
165
|
+
__RΦ.m("rt:t", () => __RΦ.a(1414))(IΦtoXMLContext.prototype, "properties");
|
|
166
|
+
__RΦ.m("rt:f", "P")(IΦtoXMLContext.prototype, "properties");
|
|
167
|
+
__RΦ.m("rt:t", () => __RΦ.a(1421))(IΦtoXMLContext.prototype, "model");
|
|
168
|
+
__RΦ.m("rt:f", "P")(IΦtoXMLContext.prototype, "model");
|
|
169
|
+
__RΦ.m("rt:t", () => __RΦ.a(658))(IΦtoXMLContext.prototype, "object");
|
|
170
|
+
__RΦ.m("rt:f", "P")(IΦtoXMLContext.prototype, "object");
|
|
171
|
+
__RΦ.m("rt:t", () => __RΦ.a(1414))(IΦtoXMLContext.prototype, "properties");
|
|
172
|
+
__RΦ.m("rt:f", "P")(IΦtoXMLContext.prototype, "properties");
|
|
173
|
+
__RΦ.m("rt:t", () => __RΦ.a(1421))(IΦtoXMLContext.prototype, "model");
|
|
174
|
+
__RΦ.m("rt:f", "P")(IΦtoXMLContext.prototype, "model");
|
|
175
|
+
var IΦXMLModelOptions = { name: "XMLModelOptions", prototype: {}, identity: Symbol("XMLModelOptions (interface)") };
|
|
176
|
+
exports.IΦXMLModelOptions = IΦXMLModelOptions;
|
|
177
|
+
(t => __RΦ.t[505] = t)(IΦXMLModelOptions);
|
|
178
|
+
__RΦ.m("rt:P", ["properties", "fromXML", "toXML", "tagname"])(IΦXMLModelOptions);
|
|
179
|
+
__RΦ.m("rt:m", [])(IΦXMLModelOptions);
|
|
180
|
+
__RΦ.m("rt:f", "Ie")(IΦXMLModelOptions);
|
|
181
|
+
__RΦ.m("rt:t", () => __RΦ.a(511))(IΦXMLModelOptions.prototype, "properties");
|
|
182
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "properties");
|
|
183
|
+
__RΦ.m("rt:t", () => __RΦ.a(1208))(IΦXMLModelOptions.prototype, "fromXML");
|
|
184
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "fromXML");
|
|
185
|
+
__RΦ.m("rt:t", () => __RΦ.a(1195))(IΦXMLModelOptions.prototype, "toXML");
|
|
186
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "toXML");
|
|
187
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelOptions.prototype, "tagname");
|
|
188
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "tagname");
|
|
189
|
+
__RΦ.m("rt:t", () => __RΦ.a(511))(IΦXMLModelOptions.prototype, "properties");
|
|
190
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "properties");
|
|
191
|
+
__RΦ.m("rt:t", () => __RΦ.a(1208))(IΦXMLModelOptions.prototype, "fromXML");
|
|
192
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "fromXML");
|
|
193
|
+
__RΦ.m("rt:t", () => __RΦ.a(1195))(IΦXMLModelOptions.prototype, "toXML");
|
|
194
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "toXML");
|
|
195
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelOptions.prototype, "tagname");
|
|
196
|
+
__RΦ.m("rt:f", "P")(IΦXMLModelOptions.prototype, "tagname");
|
|
197
|
+
var IΦCreateXMLModelOptions = { name: "CreateXMLModelOptions", prototype: {}, identity: Symbol("CreateXMLModelOptions (interface)") };
|
|
198
|
+
exports.IΦCreateXMLModelOptions = IΦCreateXMLModelOptions;
|
|
199
|
+
(t => __RΦ.t[1819] = t)(IΦCreateXMLModelOptions);
|
|
200
|
+
__RΦ.m("rt:P", ["fromXML", "tagname", "toXML"])(IΦCreateXMLModelOptions);
|
|
201
|
+
__RΦ.m("rt:m", [])(IΦCreateXMLModelOptions);
|
|
202
|
+
__RΦ.m("rt:f", "Ie")(IΦCreateXMLModelOptions);
|
|
203
|
+
__RΦ.m("rt:t", () => __RΦ.a(1825))(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
204
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
205
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
206
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
207
|
+
__RΦ.m("rt:t", () => __RΦ.a(1832))(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
208
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
209
|
+
__RΦ.m("rt:t", () => __RΦ.a(1825))(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
210
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "fromXML");
|
|
211
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
212
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "tagname");
|
|
213
|
+
__RΦ.m("rt:t", () => __RΦ.a(1832))(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
214
|
+
__RΦ.m("rt:f", "P?")(IΦCreateXMLModelOptions.prototype, "toXML");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "mocha";
|
|
@@ -0,0 +1,261 @@
|
|
|
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: { [2574]: { 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(2590) }, { n: "propD", f: "", t: __RΦ.a(1562) }, { n: "equals", f: "", t: __RΦ.a(2671) }, { n: "__constructor", f: "", t: __RΦ.a(4) }] }) }, [13]: { LΦ: t => String }, [20]: { LΦ: t => Boolean }, [2590]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(2588) }) }, [2588]: { TΦ: "5", name: "B" }, [1562]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(47), __RΦ.a(117)] }) }, [47]: { LΦ: t => 0 }, [117]: { LΦ: t => 1 }, [2671]: { RΦ: t => ({ TΦ: "O", m: [] }) }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [2522]: { RΦ: t => ({ TΦ: "O", m: [{ n: "name", f: "", t: __RΦ.a(13) }, { n: "nbPages", f: "", t: __RΦ.a(14) }] }) }, [14]: { LΦ: t => Number }, [2482]: { TΦ: "5", name: "Book" }, [2525]: { LΦ: t => Boolean }, [2543]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(2482) }) }, [2526]: { TΦ: "5", name: "Library" }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [89]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(90), p: [] }) }, [90]: { LΦ: t => Object }, [2575]: { TΦ: "5", name: "A" } } };
|
|
28
|
+
require("mocha");
|
|
29
|
+
const chai_1 = require("chai");
|
|
30
|
+
const model_1 = require("./model");
|
|
31
|
+
const xml_1 = __importDefault(require("./xml"));
|
|
32
|
+
const typescript_rtti_1 = require("typescript-rtti");
|
|
33
|
+
let Book = class Book {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.name = options.name;
|
|
36
|
+
this.nbPages = options.nbPages;
|
|
37
|
+
}
|
|
38
|
+
equals(book) {
|
|
39
|
+
if (this.name !== book.name)
|
|
40
|
+
return false;
|
|
41
|
+
if (this.nbPages !== book.nbPages)
|
|
42
|
+
return false;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
Book = __decorate([
|
|
47
|
+
(0, model_1.Model)({
|
|
48
|
+
fromXML({ model, properties }) {
|
|
49
|
+
return new model.type(properties);
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
], Book);
|
|
53
|
+
(t => __RΦ.t[2482] = t)(Book);
|
|
54
|
+
__RΦ.m("rt:SP", [])(Book);
|
|
55
|
+
__RΦ.m("rt:P", ["name", "nbPages"])(Book);
|
|
56
|
+
__RΦ.m("rt:Sm", [])(Book);
|
|
57
|
+
__RΦ.m("rt:m", ["fromXML", "equals"])(Book);
|
|
58
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(2522), v: null }])(Book);
|
|
59
|
+
__RΦ.m("rt:f", "C")(Book);
|
|
60
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(Book.prototype, "name");
|
|
61
|
+
__RΦ.m("rt:f", "P")(Book.prototype, "name");
|
|
62
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(Book.prototype, "nbPages");
|
|
63
|
+
__RΦ.m("rt:f", "P")(Book.prototype, "nbPages");
|
|
64
|
+
__RΦ.m("rt:f", "M.")(Book.prototype["equals"]);
|
|
65
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(Book.prototype, "equals");
|
|
66
|
+
__RΦ.m("rt:p", [{ n: "book", t: () => __RΦ.a(2482), v: null }])(Book.prototype, "equals");
|
|
67
|
+
__RΦ.m("rt:f", "M.")(Book.prototype, "equals");
|
|
68
|
+
__RΦ.m("rt:t", () => __RΦ.a(2525))(Book.prototype, "equals");
|
|
69
|
+
let Library = class Library {
|
|
70
|
+
constructor(name, ...books) {
|
|
71
|
+
this.books = [];
|
|
72
|
+
this.name = name;
|
|
73
|
+
this.books.push(...books);
|
|
74
|
+
}
|
|
75
|
+
equals(library) {
|
|
76
|
+
if (this.name !== library.name)
|
|
77
|
+
return false;
|
|
78
|
+
if (this.books.length !== library.books.length)
|
|
79
|
+
return false;
|
|
80
|
+
for (let index = 0; index < this.books.length; index++) {
|
|
81
|
+
if (!this.books[index].equals(library.books[index]))
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
Library = __decorate([
|
|
88
|
+
(0, model_1.Model)({
|
|
89
|
+
fromXML({ model, properties }) {
|
|
90
|
+
return new model.type(properties.name, ...properties.books);
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
], Library);
|
|
94
|
+
(t => __RΦ.t[2526] = t)(Library);
|
|
95
|
+
__RΦ.m("rt:SP", [])(Library);
|
|
96
|
+
__RΦ.m("rt:P", ["name", "books"])(Library);
|
|
97
|
+
__RΦ.m("rt:Sm", [])(Library);
|
|
98
|
+
__RΦ.m("rt:m", ["fromXML", "equals"])(Library);
|
|
99
|
+
__RΦ.m("rt:p", [{ n: "name", t: () => __RΦ.a(13), v: null }, { n: "books", t: () => __RΦ.a(2543), v: null }])(Library);
|
|
100
|
+
__RΦ.m("rt:f", "C")(Library);
|
|
101
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(Library.prototype, "name");
|
|
102
|
+
__RΦ.m("rt:f", "P")(Library.prototype, "name");
|
|
103
|
+
__RΦ.m("rt:t", () => __RΦ.a(2543))(Library.prototype, "books");
|
|
104
|
+
__RΦ.m("rt:f", "P")(Library.prototype, "books");
|
|
105
|
+
__RΦ.m("rt:f", "M.")(Library.prototype["equals"]);
|
|
106
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(Library.prototype, "equals");
|
|
107
|
+
__RΦ.m("rt:p", [{ n: "library", t: () => __RΦ.a(2526), v: null }])(Library.prototype, "equals");
|
|
108
|
+
__RΦ.m("rt:f", "M.")(Library.prototype, "equals");
|
|
109
|
+
__RΦ.m("rt:t", () => __RΦ.a(2525))(Library.prototype, "equals");
|
|
110
|
+
describe("Library Example", __RΦ.f(() => {
|
|
111
|
+
const library = new Library("test");
|
|
112
|
+
for (let i = 1; i <= 4; i++) {
|
|
113
|
+
const book = new Book({ name: `Book #${i}`, nbPages: Math.pow(10, i) });
|
|
114
|
+
library.books.push(book);
|
|
115
|
+
}
|
|
116
|
+
const libraryXMLString = xml_1.default.stringify(xml_1.default.parse(`<library>
|
|
117
|
+
<name>${library.name}</name>
|
|
118
|
+
<books>
|
|
119
|
+
${library.books
|
|
120
|
+
.map(__RΦ.f((book) => ` <book>
|
|
121
|
+
<name>${book.name}</name>
|
|
122
|
+
<nb-pages>${book.nbPages}</nb-pages>
|
|
123
|
+
</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))], ""))
|
|
124
|
+
.join("")}
|
|
125
|
+
</books>
|
|
126
|
+
</library>`));
|
|
127
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
128
|
+
const xml = (0, model_1.getModel)(Library).toXML(library);
|
|
129
|
+
(0, chai_1.expect)(xml_1.default.stringify(xml)).to.equal(libraryXMLString);
|
|
130
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
131
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
132
|
+
const parsedLibrary = (0, model_1.getModel)(Library).fromXML(libraryXMLString);
|
|
133
|
+
(0, chai_1.expect)(parsedLibrary instanceof Library).to.be.true;
|
|
134
|
+
(0, chai_1.expect)(library.equals(parsedLibrary)).to.be.true;
|
|
135
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
136
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
137
|
+
let A = class A {
|
|
138
|
+
constructor(record) {
|
|
139
|
+
this.propA = "";
|
|
140
|
+
this.propB = true;
|
|
141
|
+
this.propC = [];
|
|
142
|
+
this.propD = 0;
|
|
143
|
+
if (record)
|
|
144
|
+
Object.entries(record).forEach(__RΦ.f(([key, val]) => {
|
|
145
|
+
this[key] = val;
|
|
146
|
+
}, [__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))], ""));
|
|
147
|
+
}
|
|
148
|
+
equals(a) {
|
|
149
|
+
//
|
|
150
|
+
if (this.propA !== a.propA ||
|
|
151
|
+
this.propB !== a.propB ||
|
|
152
|
+
this.propC.length !== a.propC.length ||
|
|
153
|
+
this.propD !== a.propD)
|
|
154
|
+
return false;
|
|
155
|
+
for (let i = 0; i < this.propC.length; i++) {
|
|
156
|
+
if (!this.propC[i].equals(a.propC[i]))
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, model_1.Prop)({ tagname: "b", inline: true })
|
|
164
|
+
], A.prototype, "propC", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, model_1.Prop)({ tagname: "propd" })
|
|
167
|
+
], A.prototype, "propD", void 0);
|
|
168
|
+
A = __decorate([
|
|
169
|
+
(0, model_1.Model)({
|
|
170
|
+
fromXML({ model, properties }) {
|
|
171
|
+
return new model.type(properties);
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
], A);
|
|
175
|
+
(t => __RΦ.t[2575] = t)(A);
|
|
176
|
+
__RΦ.m("rt:SP", [])(A);
|
|
177
|
+
__RΦ.m("rt:P", ["propA", "propB", "propC", "propD"])(A);
|
|
178
|
+
__RΦ.m("rt:Sm", [])(A);
|
|
179
|
+
__RΦ.m("rt:m", ["fromXML", "equals"])(A);
|
|
180
|
+
__RΦ.m("rt:p", [{ n: "record", t: () => __RΦ.a(89), v: null, f: "?" }])(A);
|
|
181
|
+
__RΦ.m("rt:f", "C")(A);
|
|
182
|
+
__RΦ.m("rt:t", () => __RΦ.a(13))(A.prototype, "propA");
|
|
183
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propA");
|
|
184
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(A.prototype, "propB");
|
|
185
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propB");
|
|
186
|
+
__RΦ.m("rt:t", () => __RΦ.a(2590))(A.prototype, "propC");
|
|
187
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propC");
|
|
188
|
+
__RΦ.m("rt:t", () => __RΦ.a(1562))(A.prototype, "propD");
|
|
189
|
+
__RΦ.m("rt:f", "P")(A.prototype, "propD");
|
|
190
|
+
__RΦ.m("rt:f", "M.")(A.prototype["equals"]);
|
|
191
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(A.prototype, "equals");
|
|
192
|
+
__RΦ.m("rt:p", [{ n: "a", t: () => __RΦ.a(2575), v: null }])(A.prototype, "equals");
|
|
193
|
+
__RΦ.m("rt:f", "M.")(A.prototype, "equals");
|
|
194
|
+
__RΦ.m("rt:t", () => __RΦ.a(2525))(A.prototype, "equals");
|
|
195
|
+
let B = class B {
|
|
196
|
+
constructor(record) {
|
|
197
|
+
this.propA = 0;
|
|
198
|
+
if (record)
|
|
199
|
+
Object.entries(record).forEach(__RΦ.f(([key, val]) => {
|
|
200
|
+
this[key] = val;
|
|
201
|
+
}, [__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))], ""));
|
|
202
|
+
}
|
|
203
|
+
equals(b) {
|
|
204
|
+
return this.propA === b.propA;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
B = __decorate([
|
|
208
|
+
(0, model_1.Model)({
|
|
209
|
+
fromXML({ model, properties }) {
|
|
210
|
+
return new model.type(properties);
|
|
211
|
+
},
|
|
212
|
+
})
|
|
213
|
+
], B);
|
|
214
|
+
(t => __RΦ.t[2588] = t)(B);
|
|
215
|
+
__RΦ.m("rt:SP", [])(B);
|
|
216
|
+
__RΦ.m("rt:P", ["propA"])(B);
|
|
217
|
+
__RΦ.m("rt:Sm", [])(B);
|
|
218
|
+
__RΦ.m("rt:m", ["fromXML", "equals"])(B);
|
|
219
|
+
__RΦ.m("rt:p", [{ n: "record", t: () => __RΦ.a(89), v: null, f: "?" }])(B);
|
|
220
|
+
__RΦ.m("rt:f", "C")(B);
|
|
221
|
+
__RΦ.m("rt:t", () => __RΦ.a(14))(B.prototype, "propA");
|
|
222
|
+
__RΦ.m("rt:f", "P")(B.prototype, "propA");
|
|
223
|
+
__RΦ.m("rt:f", "M.")(B.prototype["equals"]);
|
|
224
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(B.prototype, "equals");
|
|
225
|
+
__RΦ.m("rt:p", [{ n: "b", t: () => __RΦ.a(2588), v: null }])(B.prototype, "equals");
|
|
226
|
+
__RΦ.m("rt:f", "M.")(B.prototype, "equals");
|
|
227
|
+
__RΦ.m("rt:t", () => __RΦ.a(20))(B.prototype, "equals");
|
|
228
|
+
describe("Edgy Cases", __RΦ.f(() => {
|
|
229
|
+
const instance = new A();
|
|
230
|
+
for (let i = 0; i < 8; i++) {
|
|
231
|
+
const b = new B();
|
|
232
|
+
b.propA = i;
|
|
233
|
+
instance.propC.push(b);
|
|
234
|
+
}
|
|
235
|
+
const instanceXMLString = xml_1.default.stringify(xml_1.default.parse(`<a>
|
|
236
|
+
<prop-a>${instance.propA}</prop-a>
|
|
237
|
+
<prop-b>${instance.propB}</prop-b>
|
|
238
|
+
${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("")}
|
|
239
|
+
<propd>${instance.propD}</propd>
|
|
240
|
+
</a>`));
|
|
241
|
+
it("should give right type infos", __RΦ.f(() => {
|
|
242
|
+
const reflectedA = (0, typescript_rtti_1.reflect)(A, { TΦ: "c", t: void 0, p: [__RΦ.a(2574)], r: void 0, tp: [] });
|
|
243
|
+
(0, chai_1.assert)(reflectedA === (0, typescript_rtti_1.reflect)(A, { TΦ: "c", t: void 0, p: [__RΦ.a(2574)], r: void 0, tp: [] }));
|
|
244
|
+
(0, chai_1.expect)(reflectedA.getProperty("propA").type.isClass(String)).to.be.true;
|
|
245
|
+
(0, chai_1.expect)(reflectedA.getProperty("propB").type.isClass(Boolean)).to.be.true;
|
|
246
|
+
const ModelAPropCType = reflectedA.getProperty("propC").type;
|
|
247
|
+
(0, chai_1.expect)(ModelAPropCType.is("array") && ModelAPropCType.elementType.isClass(B)).to.be.true;
|
|
248
|
+
const ModelAPropDType = reflectedA.getProperty("propD").type;
|
|
249
|
+
(0, chai_1.expect)(ModelAPropDType.is("union")).to.be.true;
|
|
250
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
251
|
+
it("XML -> Object", __RΦ.f(() => {
|
|
252
|
+
const parsed = (0, model_1.getModel)(A).fromXML(instanceXMLString);
|
|
253
|
+
(0, chai_1.expect)(parsed instanceof A).to.be.true;
|
|
254
|
+
const equals = instance.equals(parsed);
|
|
255
|
+
(0, chai_1.expect)(equals).to.be.true;
|
|
256
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
257
|
+
it("Object -> XML", __RΦ.f(() => {
|
|
258
|
+
const xml = (0, model_1.getModel)(A).toXML(instance);
|
|
259
|
+
(0, chai_1.expect)(xml_1.default.stringify(xml)).to.equal(instanceXMLString);
|
|
260
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
261
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Constructor } from "typescript-rtti";
|
|
2
|
+
export declare type UnknownRecord = Record<string | number | symbol, unknown>;
|
|
3
|
+
export declare type UnknownObject = object;
|
|
4
|
+
import type { Element as _XMLElement } from "xml-js";
|
|
5
|
+
export declare type XMLElement = _XMLElement;
|
|
6
|
+
export declare type XMLRoot = {
|
|
7
|
+
elements: XMLElement[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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 => {
|
|
4
|
+
let t = __RΦ.t[id];
|
|
5
|
+
if (t === void 0)
|
|
6
|
+
return void 0;
|
|
7
|
+
if (t.RΦ) {
|
|
8
|
+
let r = t.RΦ;
|
|
9
|
+
delete t.RΦ;
|
|
10
|
+
__RΦ.r(t, r(t));
|
|
11
|
+
}
|
|
12
|
+
else if (t.LΦ) {
|
|
13
|
+
let l = t.LΦ();
|
|
14
|
+
delete t.LΦ;
|
|
15
|
+
__RΦ.t[id] = t = l;
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
}, t: {} };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { js2xml } from "xml-js";
|
|
2
|
+
import { XMLElement, XMLRoot } from "./types";
|
|
3
|
+
export declare function parse(string: string): XMLRoot;
|
|
4
|
+
export declare function stringify(xml: XMLRoot, options?: Parameters<typeof js2xml>[1]): string;
|
|
5
|
+
export declare function getContent(xml: XMLElement): string | number | boolean | undefined;
|
|
6
|
+
export declare function fromContent(content: string): {
|
|
7
|
+
elements: [{
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
}] | [];
|
|
11
|
+
};
|
|
12
|
+
export declare function fromContent(content: string, tag: string, attributes?: XMLElement["attributes"]): {
|
|
13
|
+
type: "element";
|
|
14
|
+
name: string;
|
|
15
|
+
attributes?: XMLElement["attributes"];
|
|
16
|
+
elements: [{
|
|
17
|
+
type: "text";
|
|
18
|
+
text: string;
|
|
19
|
+
}] | [];
|
|
20
|
+
};
|
|
21
|
+
export declare function addElement(xml: XMLElement, element: XMLElement): void;
|
|
22
|
+
export declare function setAttribute(xml: XMLElement, attribute: string, value: string): void;
|
|
23
|
+
declare const XML: {
|
|
24
|
+
parse: typeof parse;
|
|
25
|
+
stringify: typeof stringify;
|
|
26
|
+
fromContent: typeof fromContent;
|
|
27
|
+
getContent: typeof getContent;
|
|
28
|
+
addElement: typeof addElement;
|
|
29
|
+
setAttribute: typeof setAttribute;
|
|
30
|
+
};
|
|
31
|
+
export default XML;
|