xml-model 0.1.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main/defaults/index.js +22 -16
- package/build/main/defaults/models.js +4 -4
- package/build/main/errors.d.ts +4 -0
- package/build/main/errors.js +35 -0
- package/build/main/middleware.js +11 -11
- package/build/main/model/index.d.ts +7 -9
- package/build/main/model/index.js +88 -67
- package/build/main/model/property.js +16 -14
- package/build/main/model/types.d.ts +5 -1
- package/build/main/model/types.js +86 -70
- package/build/main/types.d.ts +10 -2
- package/build/main/types.js +34 -1
- package/build/{module/xml.d.ts → main/xml/index.d.ts} +5 -4
- package/build/main/{xml.js → xml/index.js} +29 -19
- package/build/main/xml/xml-js.d.ts +9 -0
- package/build/main/xml/xml-js.js +26 -0
- package/build/module/defaults/index.js +24 -17
- package/build/module/defaults/models.js +6 -10
- package/build/module/errors.d.ts +4 -0
- package/build/module/errors.js +31 -0
- package/build/module/middleware.js +11 -11
- package/build/module/model/index.d.ts +7 -9
- package/build/module/model/index.js +97 -74
- package/build/module/model/property.js +18 -16
- package/build/module/model/types.d.ts +5 -1
- package/build/module/model/types.js +88 -72
- package/build/module/types.d.ts +10 -2
- package/build/module/types.js +33 -2
- package/build/{main/xml.d.ts → module/xml/index.d.ts} +5 -4
- package/build/module/{xml.js → xml/index.js} +26 -18
- package/build/module/xml/xml-js.d.ts +9 -0
- package/build/module/xml/xml-js.js +24 -0
- package/package.json +2 -2
- package/build/main/model.spec.d.ts +0 -1
- package/build/main/model.spec.js +0 -261
- package/build/module/model.spec.d.ts +0 -1
- package/build/module/model.spec.js +0 -259
|
@@ -34,12 +34,15 @@ exports.defaults = {
|
|
|
34
34
|
return innerElements.filter((el) => context.property.isSourceElement(el, context));
|
|
35
35
|
},
|
|
36
36
|
propertySourceElementsFilter(element, context) {
|
|
37
|
-
return context.property.tagname
|
|
37
|
+
return context.property.tagname === element.name;
|
|
38
38
|
},
|
|
39
39
|
propertyFromXML(context) {
|
|
40
40
|
// TODO: handle inline
|
|
41
41
|
const prop = context.property;
|
|
42
42
|
const elements = context.elements;
|
|
43
|
+
if (prop.model) {
|
|
44
|
+
return prop.model.fromXML({ elements });
|
|
45
|
+
}
|
|
43
46
|
const type = context.property.reflected.type;
|
|
44
47
|
if (prop.reflected.isOptional && elements.length === 0) {
|
|
45
48
|
return undefined;
|
|
@@ -56,20 +59,18 @@ exports.defaults = {
|
|
|
56
59
|
// we assume our array is contained in a root tag
|
|
57
60
|
arrayEl = elements[0];
|
|
58
61
|
}
|
|
59
|
-
else if (prop.inline
|
|
60
|
-
elements.every((el) => el.name === prop.tagname)) {
|
|
62
|
+
else if (prop.inline) {
|
|
61
63
|
// we assume our array is contained in xml.elements
|
|
62
64
|
arrayEl = { elements };
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
66
|
+
const els = arrayEl.elements || [];
|
|
67
|
+
const elType = type.elementType;
|
|
68
|
+
if (elType.is("class")) {
|
|
69
|
+
const model = (0, model_1.getModel)(elType.class);
|
|
70
|
+
const xmlInstances = els.map((el) => ({
|
|
71
|
+
elements: [el],
|
|
72
|
+
}));
|
|
73
|
+
return xmlInstances.map((xml) => model.fromXML(xml));
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
else if (type.is("union") &&
|
|
@@ -91,14 +92,16 @@ exports.defaults = {
|
|
|
91
92
|
/* Object -> XML */
|
|
92
93
|
toXML({ properties, model }) {
|
|
93
94
|
const elements = [];
|
|
94
|
-
model.
|
|
95
|
+
model.resolveAllProperties().forEach((prop) => {
|
|
95
96
|
if (prop.name in properties && typeof prop.name !== "symbol") {
|
|
96
97
|
// FIXME: prop.name should never be a symbol anyway
|
|
97
98
|
const _xml = properties[prop.name];
|
|
98
|
-
// overwrite tagnames
|
|
99
99
|
_xml.elements.forEach((el) => {
|
|
100
|
-
(
|
|
101
|
-
|
|
100
|
+
if (!prop.inline) {
|
|
101
|
+
// overwrite tagnames
|
|
102
|
+
el.name = prop.tagname; // TODO: configurable ?
|
|
103
|
+
}
|
|
104
|
+
elements.push(el);
|
|
102
105
|
});
|
|
103
106
|
}
|
|
104
107
|
});
|
|
@@ -120,6 +123,9 @@ exports.defaults = {
|
|
|
120
123
|
},
|
|
121
124
|
propertyToXML(context) {
|
|
122
125
|
const property = context.property;
|
|
126
|
+
if (property.model) {
|
|
127
|
+
return property.model.toXML(context.value);
|
|
128
|
+
}
|
|
123
129
|
const type = property.reflected.type;
|
|
124
130
|
const value = context.value;
|
|
125
131
|
if (property.reflected.isOptional && typeof value === "undefined") {
|
|
@@ -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Φ: "~" }) }, [
|
|
18
|
+
}, t: { [4]: { RΦ: t => ({ TΦ: "~" }) }, [109]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(105) }] }) }, [105]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(103) }) }, [103]: { LΦ: t => require("../types").IΦXMLElement }, [13]: { LΦ: t => String }, [14]: { LΦ: t => Number }, [1694]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(3121) }] }) }, [3121]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(3119) }) }, [3119]: { 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>
|
|
@@ -24,7 +24,7 @@ const xml_1 = require("../xml");
|
|
|
24
24
|
return {
|
|
25
25
|
elements: [(0, xml_1.fromContent)(ctx.object, "string")],
|
|
26
26
|
};
|
|
27
|
-
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
27
|
+
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(109))], "toXML"),
|
|
28
28
|
fromXML: __RΦ.f((ctx) => {
|
|
29
29
|
return String((0, xml_1.getContent)(ctx.xml.elements[0]));
|
|
30
30
|
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(13))], "fromXML"),
|
|
@@ -35,7 +35,7 @@ const xml_1 = require("../xml");
|
|
|
35
35
|
return {
|
|
36
36
|
elements: [(0, xml_1.fromContent)(String(ctx.object), "number")],
|
|
37
37
|
};
|
|
38
|
-
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
38
|
+
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(109))], "toXML"),
|
|
39
39
|
fromXML: __RΦ.f((ctx) => {
|
|
40
40
|
return Number((0, xml_1.getContent)(ctx.xml.elements[0]));
|
|
41
41
|
}, [__RΦ.m("rt:p", [{ n: "ctx", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(14))], "fromXML"),
|
|
@@ -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(1694))], "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"),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XMLConversionError = 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: { [13]: { LΦ: t => String }, [8]: { RΦ: t => ({ TΦ: "U" }) } } };
|
|
20
|
+
class XMLConversionError extends Error {
|
|
21
|
+
constructor(message, origin) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.origin = origin;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.XMLConversionError = XMLConversionError;
|
|
27
|
+
(t => __RΦ.t[85] = t)(XMLConversionError);
|
|
28
|
+
__RΦ.m("rt:SP", [])(XMLConversionError);
|
|
29
|
+
__RΦ.m("rt:P", ["origin"])(XMLConversionError);
|
|
30
|
+
__RΦ.m("rt:Sm", [])(XMLConversionError);
|
|
31
|
+
__RΦ.m("rt:m", [])(XMLConversionError);
|
|
32
|
+
__RΦ.m("rt:p", [{ n: "message", t: () => __RΦ.a(13), v: null }, { n: "origin", t: () => __RΦ.a(8), v: null, f: "?" }])(XMLConversionError);
|
|
33
|
+
__RΦ.m("rt:f", "Ce")(XMLConversionError);
|
|
34
|
+
__RΦ.m("rt:t", () => __RΦ.a(8))(XMLConversionError.prototype, "origin");
|
|
35
|
+
__RΦ.m("rt:f", "P")(XMLConversionError.prototype, "origin");
|
package/build/main/middleware.js
CHANGED
|
@@ -16,19 +16,19 @@ 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: { [
|
|
19
|
+
}, t: { [118]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(115)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [115]: { TΦ: "5", name: "ChainableOptions" }, [121]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(120) }) }, [120]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [124]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(115), p: [__RΦ.a(122), __RΦ.a(123)] }) }, [122]: { LΦ: t => Object }, [123]: { LΦ: t => Object }, [143]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(138), p: [__RΦ.a(125), __RΦ.a(22), __RΦ.a(8)] }) }, [138]: { LΦ: t => Object }, [125]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [8]: { RΦ: t => ({ TΦ: "U" }) }, [155]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(147), p: [__RΦ.a(158), __RΦ.a(1), __RΦ.a(10)] }) }, [147]: { LΦ: t => Object }, [158]: { RΦ: t => ({ TΦ: "O", m: [{ n: "__call", f: "", t: __RΦ.a(4) }] }) }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [153]: { LΦ: t => Object }, [154]: { LΦ: t => Object } } };
|
|
20
20
|
var IΦChainableOptions = { name: "ChainableOptions", prototype: {}, identity: Symbol("ChainableOptions (interface)") };
|
|
21
|
-
(t => __RΦ.t[
|
|
21
|
+
(t => __RΦ.t[115] = t)(IΦChainableOptions);
|
|
22
22
|
__RΦ.m("rt:P", ["parent", "middlewares"])(IΦChainableOptions);
|
|
23
23
|
__RΦ.m("rt:m", [])(IΦChainableOptions);
|
|
24
24
|
__RΦ.m("rt:f", "I")(IΦChainableOptions);
|
|
25
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
25
|
+
__RΦ.m("rt:t", () => __RΦ.a(118))(IΦChainableOptions.prototype, "parent");
|
|
26
26
|
__RΦ.m("rt:f", "P")(IΦChainableOptions.prototype, "parent");
|
|
27
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
27
|
+
__RΦ.m("rt:t", () => __RΦ.a(121))(IΦChainableOptions.prototype, "middlewares");
|
|
28
28
|
__RΦ.m("rt:f", "P")(IΦChainableOptions.prototype, "middlewares");
|
|
29
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
29
|
+
__RΦ.m("rt:t", () => __RΦ.a(118))(IΦChainableOptions.prototype, "parent");
|
|
30
30
|
__RΦ.m("rt:f", "P")(IΦChainableOptions.prototype, "parent");
|
|
31
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
31
|
+
__RΦ.m("rt:t", () => __RΦ.a(121))(IΦChainableOptions.prototype, "middlewares");
|
|
32
32
|
__RΦ.m("rt:f", "P")(IΦChainableOptions.prototype, "middlewares");
|
|
33
33
|
function* MiddlewareChain(options) {
|
|
34
34
|
do {
|
|
@@ -42,9 +42,9 @@ function* MiddlewareChain(options) {
|
|
|
42
42
|
} while (true);
|
|
43
43
|
}
|
|
44
44
|
exports.MiddlewareChain = MiddlewareChain;
|
|
45
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
45
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(124), v: null }])(MiddlewareChain);
|
|
46
46
|
__RΦ.m("rt:f", "F")(MiddlewareChain);
|
|
47
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
47
|
+
__RΦ.m("rt:t", () => __RΦ.a(143))(MiddlewareChain);
|
|
48
48
|
function resolve(middlewares, context) {
|
|
49
49
|
const next = __RΦ.f(() => {
|
|
50
50
|
const { value: nextMiddleware, done } = middlewares.next();
|
|
@@ -56,10 +56,10 @@ function resolve(middlewares, context) {
|
|
|
56
56
|
else {
|
|
57
57
|
return nextMiddleware(context, next);
|
|
58
58
|
}
|
|
59
|
-
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
59
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(154))], "next");
|
|
60
60
|
return next();
|
|
61
61
|
}
|
|
62
62
|
exports.resolve = resolve;
|
|
63
|
-
__RΦ.m("rt:p", [{ n: "middlewares", t: () => __RΦ.a(
|
|
63
|
+
__RΦ.m("rt:p", [{ n: "middlewares", t: () => __RΦ.a(155), v: null }, { n: "context", t: () => __RΦ.a(153), v: null }])(resolve);
|
|
64
64
|
__RΦ.m("rt:f", "F")(resolve);
|
|
65
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
65
|
+
__RΦ.m("rt:t", () => __RΦ.a(154))(resolve);
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import type { Constructor } from "typescript-rtti";
|
|
3
|
-
import { XMLModelOptions } from "./types";
|
|
3
|
+
import { XMLModelOptions, XMLModelPropertyOptions, CreateXMLModelOptions } from "./types";
|
|
4
4
|
import { XMLRoot } from "../types";
|
|
5
|
-
export interface XMLModelConversionOptions<T> {
|
|
6
|
-
fromXML?: XMLModelOptions<T>["fromXML"]["middlewares"][number];
|
|
7
|
-
tagname?: string;
|
|
8
|
-
toXML?: XMLModelOptions<T>["toXML"]["middlewares"][number];
|
|
9
|
-
}
|
|
10
5
|
export declare class XMLModel<T = any> {
|
|
11
6
|
readonly type: Constructor<T>;
|
|
12
7
|
options: XMLModelOptions<T>;
|
|
13
|
-
constructor(type: Constructor<T>, options:
|
|
8
|
+
constructor(type: Constructor<T>, options: CreateXMLModelOptions<T>);
|
|
14
9
|
fromXML(xml: XMLRoot | string): T;
|
|
15
10
|
toXML(instance: object): XMLRoot;
|
|
16
11
|
get reflectedClass(): import("typescript-rtti").ReflectedClass<Constructor<T>>;
|
|
12
|
+
resolveAllProperties(): Map<string, XMLModelPropertyOptions<any> & {
|
|
13
|
+
model: any;
|
|
14
|
+
}>;
|
|
17
15
|
}
|
|
18
|
-
export declare function createModel<T>(type: Constructor<T>, options:
|
|
16
|
+
export declare function createModel<T>(type: Constructor<T>, options: CreateXMLModelOptions<T>): XMLModel<T>;
|
|
19
17
|
declare type ModelID<T> = Constructor<T>;
|
|
20
18
|
export declare const Models: Map<ModelID<unknown>, XMLModel<unknown>>;
|
|
21
19
|
export declare function findModel<T>(id: ModelID<T>): XMLModel<T> | undefined;
|
|
22
20
|
export declare function getModel<T>(id: ModelID<T>): XMLModel<T>;
|
|
23
|
-
declare function ModelDecoratorFactory<T>(options?:
|
|
21
|
+
declare function ModelDecoratorFactory<T>(options?: CreateXMLModelOptions<T>): (constructor: Constructor<T>) => void;
|
|
24
22
|
export { ModelDecoratorFactory as Model };
|
|
25
23
|
export { Prop } from "./property";
|
|
26
24
|
import "../defaults/models";
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Prop = exports.Model = exports.getModel = exports.findModel = exports.Models = exports.createModel = exports.XMLModel =
|
|
6
|
+
exports.Prop = exports.Model = exports.getModel = exports.findModel = exports.Models = exports.createModel = exports.XMLModel = void 0;
|
|
7
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
8
|
let t = __RΦ.t[id];
|
|
9
9
|
if (t === void 0)
|
|
@@ -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: { [
|
|
22
|
+
}, t: { [530]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(501)] }) }, [200]: { LΦ: t => require("typescript-rtti/dist").IΦConstructor }, [501]: { LΦ: t => Object }, [1712]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(8)] }) }, [8]: { RΦ: t => ({ TΦ: "U" }) }, [1715]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(138), p: [__RΦ.a(1712), __RΦ.a(22), __RΦ.a(8)] }) }, [138]: { LΦ: t => Object }, [22]: { RΦ: t => ({ TΦ: "V" }) }, [503]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1)] }) }, [500]: { TΦ: "5", name: "XMLModel" }, [1]: { RΦ: t => ({ TΦ: "~" }) }, [1738]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(503)] }) }, [12]: { RΦ: t => ({ TΦ: "n" }) }, [1747]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1618), p: [__RΦ.a(501)] }) }, [1618]: { LΦ: t => require("./types").IΦCreateXMLModelOptions }, [523]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(520), p: [__RΦ.a(501)] }) }, [520]: { LΦ: t => require("./types").IΦXMLModelOptions }, [1771]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1326)] }) }, [1326]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(420), __RΦ.a(1324)] }) }, [600]: { LΦ: t => require("./types").IΦConversionOptions }, [420]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(421), p: [__RΦ.a(419), __RΦ.a(382)] }) }, [421]: { LΦ: t => Object }, [419]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(378), p: [__RΦ.a(1)] }) }, [378]: { LΦ: t => require("./types").IΦfromXMLContext }, [382]: { LΦ: t => "properties" }, [1324]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1325), p: [__RΦ.a(1)] }) }, [1325]: { LΦ: t => Object }, [4]: { RΦ: t => ({ TΦ: "~" }) }, [656]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(657), p: [__RΦ.a(501)] }) }, [657]: { LΦ: t => Object }, [1781]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1779)] }) }, [1779]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(1358), __RΦ.a(1777)] }) }, [1358]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1359), p: [__RΦ.a(1357), __RΦ.a(382)] }) }, [1359]: { LΦ: t => Object }, [1357]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(858), p: [__RΦ.a(1)] }) }, [858]: { LΦ: t => require("./types").IΦtoXMLContext }, [1777]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(1778), p: [__RΦ.a(1)] }) }, [1778]: { LΦ: t => Object }, [888]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(889), p: [__RΦ.a(501)] }) }, [889]: { LΦ: t => Object }, [20]: { LΦ: t => Boolean }, [659]: { RΦ: t => ({ TΦ: "O", m: [{ n: "fromXML", f: "", t: __RΦ.a(665) }, { n: "toXML", f: "", t: __RΦ.a(896) }, { n: "options", f: "", t: __RΦ.a(1072) }] }) }, [665]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(661), __RΦ.a(663)] }) }, [661]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(662), p: [__RΦ.a(604), __RΦ.a(382)] }) }, [662]: { LΦ: t => Object }, [604]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(378), p: [__RΦ.a(521)] }) }, [521]: { LΦ: t => Object }, [663]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(664), p: [__RΦ.a(521)] }) }, [664]: { LΦ: t => Object }, [896]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(892), __RΦ.a(894)] }) }, [892]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(893), p: [__RΦ.a(861), __RΦ.a(382)] }) }, [893]: { LΦ: t => Object }, [861]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(858), p: [__RΦ.a(521)] }) }, [894]: { RΦ: t => ({ TΦ: "m", t: __RΦ.a(895), p: [__RΦ.a(521)] }) }, [895]: { LΦ: t => Object }, [1072]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1062), p: [__RΦ.a(1070), __RΦ.a(1071)] }) }, [1062]: { LΦ: t => Map }, [1070]: { LΦ: t => Object }, [1071]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(521)] }) }, [212]: { LΦ: t => require("./types").IΦXMLModelPropertyOptions }, [1797]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1795)] }) }, [1795]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(419), __RΦ.a(1)] }) }, [1802]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(12), __RΦ.a(1800)] }) }, [1800]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(600), p: [__RΦ.a(1357), __RΦ.a(109)] }) }, [109]: { RΦ: t => ({ TΦ: "O", m: [{ n: "elements", f: "", t: __RΦ.a(105) }] }) }, [105]: { RΦ: t => ({ TΦ: "[", e: __RΦ.a(103) }) }, [103]: { LΦ: t => require("../types").IΦXMLElement }, [13]: { LΦ: t => String }, [539]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(13), __RΦ.a(109)] }) }, [28]: { LΦ: t => Object }, [946]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(942), p: [__RΦ.a(530)] }) }, [942]: { LΦ: t => require("typescript-rtti/dist").ReflectedClass }, [1067]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1062), p: [__RΦ.a(13), __RΦ.a(1061)] }) }, [1061]: { RΦ: t => ({ TΦ: "&", t: [__RΦ.a(1059), __RΦ.a(1060)] }) }, [1059]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(212), p: [__RΦ.a(1)] }) }, [1060]: { RΦ: t => ({ TΦ: "O", m: [{ n: "model", f: "", t: __RΦ.a(1) }] }) }, [1622]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1617)] }) }, [1617]: { LΦ: t => Object }, [1621]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1618), p: [__RΦ.a(1617)] }) }, [1655]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1617)] }) }, [1720]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1717)] }) }, [1717]: { LΦ: t => Object }, [1733]: { RΦ: t => ({ TΦ: "|", t: [__RΦ.a(10), __RΦ.a(1732)] }) }, [10]: { RΦ: t => ({ TΦ: "u" }) }, [1732]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1717)] }) }, [1934]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1933)] }) }, [1933]: { LΦ: t => Object }, [1937]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(500), p: [__RΦ.a(1933)] }) }, [1940]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(1618), p: [__RΦ.a(1939)] }) }, [1939]: { LΦ: t => Object }, [1942]: { RΦ: t => ({ TΦ: "F", r: __RΦ.a(22), p: [{ n: "constructor", t: () => __RΦ.a(1943), v: null }], f: "" }) }, [1943]: { RΦ: t => ({ TΦ: "g", t: __RΦ.a(200), p: [__RΦ.a(1939)] }) } } };
|
|
23
23
|
require("reflect-metadata");
|
|
24
24
|
const typescript_rtti_1 = require("typescript-rtti");
|
|
25
25
|
const middleware_1 = require("../middleware");
|
|
@@ -41,10 +41,12 @@ function* ParentChain(constructor) {
|
|
|
41
41
|
}
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
44
|
+
__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1712), v: null }])(ParentChain);
|
|
45
45
|
__RΦ.m("rt:f", "F")(ParentChain);
|
|
46
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
46
|
+
__RΦ.m("rt:t", () => __RΦ.a(1715))(ParentChain);
|
|
47
47
|
function getParentModel(model) {
|
|
48
|
+
if (model.options.parent)
|
|
49
|
+
return model.options.parent;
|
|
48
50
|
for (const constructor of ParentChain(model.type)) {
|
|
49
51
|
const model = findModel(constructor);
|
|
50
52
|
if (model) {
|
|
@@ -53,27 +55,9 @@ function getParentModel(model) {
|
|
|
53
55
|
}
|
|
54
56
|
return null;
|
|
55
57
|
}
|
|
56
|
-
__RΦ.m("rt:p", [{ n: "model", t: () => __RΦ.a(
|
|
58
|
+
__RΦ.m("rt:p", [{ n: "model", t: () => __RΦ.a(503), v: null }])(getParentModel);
|
|
57
59
|
__RΦ.m("rt:f", "F")(getParentModel);
|
|
58
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
59
|
-
var IΦXMLModelConversionOptions = { name: "XMLModelConversionOptions", prototype: {}, identity: Symbol("XMLModelConversionOptions (interface)") };
|
|
60
|
-
exports.IΦXMLModelConversionOptions = IΦXMLModelConversionOptions;
|
|
61
|
-
(t => __RΦ.t[1205] = t)(IΦXMLModelConversionOptions);
|
|
62
|
-
__RΦ.m("rt:P", ["fromXML", "tagname", "toXML"])(IΦXMLModelConversionOptions);
|
|
63
|
-
__RΦ.m("rt:m", [])(IΦXMLModelConversionOptions);
|
|
64
|
-
__RΦ.m("rt:f", "Ie")(IΦXMLModelConversionOptions);
|
|
65
|
-
__RΦ.m("rt:t", () => __RΦ.a(1230))(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
66
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
67
|
-
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
68
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
69
|
-
__RΦ.m("rt:t", () => __RΦ.a(1219))(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
70
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
71
|
-
__RΦ.m("rt:t", () => __RΦ.a(1230))(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
72
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "fromXML");
|
|
73
|
-
__RΦ.m("rt:t", () => __RΦ.a(13))(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
74
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "tagname");
|
|
75
|
-
__RΦ.m("rt:t", () => __RΦ.a(1219))(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
76
|
-
__RΦ.m("rt:f", "P?")(IΦXMLModelConversionOptions.prototype, "toXML");
|
|
60
|
+
__RΦ.m("rt:t", () => __RΦ.a(1738))(getParentModel);
|
|
77
61
|
class XMLModel {
|
|
78
62
|
constructor(type, options) {
|
|
79
63
|
this.type = type;
|
|
@@ -84,7 +68,7 @@ class XMLModel {
|
|
|
84
68
|
if (typeof parent === "undefined")
|
|
85
69
|
parent = getParentModel(this);
|
|
86
70
|
return parent;
|
|
87
|
-
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
71
|
+
}, [__RΦ.m("rt:p", []), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1738))], "getParent");
|
|
88
72
|
let propertiesLoaded = false;
|
|
89
73
|
const properties = {
|
|
90
74
|
options: new Map(),
|
|
@@ -103,15 +87,20 @@ class XMLModel {
|
|
|
103
87
|
xml,
|
|
104
88
|
property,
|
|
105
89
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
try {
|
|
91
|
+
record[property.name] = property.fromXML({
|
|
92
|
+
model,
|
|
93
|
+
xml: context.xml,
|
|
94
|
+
property,
|
|
95
|
+
elements,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new errors_1.XMLConversionError(`[Model: ${context.model.type.name}] failed to convert prop <${String(property.name)}> from XML`, error);
|
|
100
|
+
}
|
|
112
101
|
}, [__RΦ.m("rt:p", [{ n: "property", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
113
102
|
return record;
|
|
114
|
-
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
103
|
+
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(656))], ""),
|
|
115
104
|
],
|
|
116
105
|
},
|
|
117
106
|
toXML: {
|
|
@@ -123,20 +112,25 @@ class XMLModel {
|
|
|
123
112
|
__RΦ.f((context, next) => {
|
|
124
113
|
const record = getParent() ? next() : {};
|
|
125
114
|
properties.options.forEach(__RΦ.f((options) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
115
|
+
try {
|
|
116
|
+
record[options.name] = options.toXML({
|
|
117
|
+
model,
|
|
118
|
+
object: context.object,
|
|
119
|
+
property: options,
|
|
120
|
+
value: context.object[options.name],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw new errors_1.XMLConversionError(`[Model: ${context.model.type.name}] failed to convert prop <${String(options.name)}> to XML`, error);
|
|
125
|
+
}
|
|
132
126
|
}, [__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(22))], ""));
|
|
133
127
|
return record;
|
|
134
|
-
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
128
|
+
}, [__RΦ.m("rt:p", [{ n: "context", t: () => __RΦ.a(4), v: null }, { n: "next", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(888))], ""),
|
|
135
129
|
],
|
|
136
130
|
},
|
|
137
131
|
};
|
|
138
132
|
const loadProperties = __RΦ.f(() => {
|
|
139
|
-
const props = (0, typescript_rtti_1.reflect)(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(
|
|
133
|
+
const props = (0, typescript_rtti_1.reflect)(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(530)], r: void 0, tp: [] }).ownProperties.filter(__RΦ.f((prop) => typeof prop.host.constructor.prototype[prop.name] !== "function", [__RΦ.m("rt:p", [{ n: "prop", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(20))], "")); // filter out methods like String.prototype.concat etc... that are seen as properties
|
|
140
134
|
props.forEach(__RΦ.f((property) => {
|
|
141
135
|
const options = (0, property_1.getPropertyConversionOptions)(this.type, property.name);
|
|
142
136
|
if (!options.ignored) {
|
|
@@ -169,9 +163,11 @@ class XMLModel {
|
|
|
169
163
|
return options.tagname || defaults_1.defaults.tagnameFromModel(model);
|
|
170
164
|
},
|
|
171
165
|
};
|
|
166
|
+
if (options.parent)
|
|
167
|
+
this.options.parent = options.parent;
|
|
172
168
|
if (!getParent()) {
|
|
173
169
|
this.options.fromXML.middlewares.push(__RΦ.f((...args) => defaults_1.defaults.fromXML(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1))], ""));
|
|
174
|
-
this.options.toXML.middlewares.push(__RΦ.f((...args) => defaults_1.defaults.toXML(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(
|
|
170
|
+
this.options.toXML.middlewares.push(__RΦ.f((...args) => defaults_1.defaults.toXML(...args), [__RΦ.m("rt:p", [{ n: "args", t: () => __RΦ.a(4), v: null, f: "3" }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(109))], ""));
|
|
175
171
|
}
|
|
176
172
|
if (options.fromXML)
|
|
177
173
|
this.options.fromXML.middlewares.push(options.fromXML);
|
|
@@ -198,7 +194,9 @@ class XMLModel {
|
|
|
198
194
|
toXML(instance) {
|
|
199
195
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
200
196
|
const model = this;
|
|
201
|
-
if (instance instanceof this.type ||
|
|
197
|
+
if (instance instanceof this.type ||
|
|
198
|
+
(typeof instance !== "undefined" && instance.constructor === this.type) // FIXME: allow instance to be Undefined ?
|
|
199
|
+
) {
|
|
202
200
|
// intanceof won't work with type "String" for example
|
|
203
201
|
const context = {
|
|
204
202
|
object: instance,
|
|
@@ -218,47 +216,69 @@ class XMLModel {
|
|
|
218
216
|
}
|
|
219
217
|
}
|
|
220
218
|
get reflectedClass() {
|
|
221
|
-
return (0, typescript_rtti_1.reflect)(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(
|
|
219
|
+
return (0, typescript_rtti_1.reflect)(this.type, { TΦ: "c", t: void 0, p: [__RΦ.a(530)], r: void 0, tp: [] });
|
|
220
|
+
}
|
|
221
|
+
resolveAllProperties() {
|
|
222
|
+
const properties = new Map();
|
|
223
|
+
const parent = getParentModel(this);
|
|
224
|
+
if (parent)
|
|
225
|
+
parent
|
|
226
|
+
.resolveAllProperties()
|
|
227
|
+
.forEach(__RΦ.f((prop, key) => properties.set(key, prop), [__RΦ.m("rt:p", [{ n: "prop", t: () => __RΦ.a(4), v: null }, { n: "key", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1067))], ""));
|
|
228
|
+
this.options.properties.options.forEach(__RΦ.f((options, key) => properties.set(key, new Proxy(options, {
|
|
229
|
+
get: __RΦ.f((target, p, reciever) => {
|
|
230
|
+
if (p === "model")
|
|
231
|
+
return this;
|
|
232
|
+
else
|
|
233
|
+
return Reflect.get(target, p, reciever);
|
|
234
|
+
}, [__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"),
|
|
235
|
+
})), [__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(4), v: null }, { n: "key", t: () => __RΦ.a(4), v: null }]), __RΦ.m("rt:f", "F>"), __RΦ.m("rt:t", () => __RΦ.a(1067))], ""));
|
|
236
|
+
return properties;
|
|
222
237
|
}
|
|
223
238
|
}
|
|
224
239
|
exports.XMLModel = XMLModel;
|
|
225
|
-
(t => __RΦ.t[
|
|
240
|
+
(t => __RΦ.t[500] = t)(XMLModel);
|
|
226
241
|
__RΦ.m("rt:SP", [])(XMLModel);
|
|
227
242
|
__RΦ.m("rt:P", ["options", "type", "reflectedClass"])(XMLModel);
|
|
228
243
|
__RΦ.m("rt:Sm", [])(XMLModel);
|
|
229
|
-
__RΦ.m("rt:m", ["fromXML", "toXML"])(XMLModel);
|
|
230
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
244
|
+
__RΦ.m("rt:m", ["fromXML", "toXML", "resolveAllProperties"])(XMLModel);
|
|
245
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(530), v: null, f: "R" }, { n: "options", t: () => __RΦ.a(1747), v: null }])(XMLModel);
|
|
231
246
|
__RΦ.m("rt:f", "Ce")(XMLModel);
|
|
232
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
247
|
+
__RΦ.m("rt:t", () => __RΦ.a(523))(XMLModel.prototype, "options");
|
|
233
248
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "options");
|
|
234
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
249
|
+
__RΦ.m("rt:t", () => __RΦ.a(1771))(XMLModel.prototype, "parent");
|
|
235
250
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
236
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
251
|
+
__RΦ.m("rt:t", () => __RΦ.a(1781))(XMLModel.prototype, "parent");
|
|
237
252
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
238
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
253
|
+
__RΦ.m("rt:t", () => __RΦ.a(659))(XMLModel.prototype, "properties");
|
|
239
254
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
240
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
255
|
+
__RΦ.m("rt:t", () => __RΦ.a(1797))(XMLModel.prototype, "parent");
|
|
241
256
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
242
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
257
|
+
__RΦ.m("rt:t", () => __RΦ.a(1802))(XMLModel.prototype, "parent");
|
|
243
258
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "parent");
|
|
244
259
|
__RΦ.m("rt:t", () => __RΦ.a(13))(XMLModel.prototype, "tagname");
|
|
245
260
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "tagname");
|
|
246
261
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype["fromXML"]);
|
|
247
262
|
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "fromXML");
|
|
248
|
-
__RΦ.m("rt:p", [{ n: "xml", t: () => __RΦ.a(
|
|
263
|
+
__RΦ.m("rt:p", [{ n: "xml", t: () => __RΦ.a(539), v: null }])(XMLModel.prototype, "fromXML");
|
|
249
264
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "fromXML");
|
|
250
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
251
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
265
|
+
__RΦ.m("rt:t", () => __RΦ.a(501))(XMLModel.prototype, "fromXML");
|
|
266
|
+
__RΦ.m("rt:t", () => __RΦ.a(656))(XMLModel.prototype, "properties");
|
|
252
267
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
253
268
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype["toXML"]);
|
|
254
269
|
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "toXML");
|
|
255
270
|
__RΦ.m("rt:p", [{ n: "instance", t: () => __RΦ.a(28), v: null }])(XMLModel.prototype, "toXML");
|
|
256
271
|
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "toXML");
|
|
257
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
258
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
272
|
+
__RΦ.m("rt:t", () => __RΦ.a(109))(XMLModel.prototype, "toXML");
|
|
273
|
+
__RΦ.m("rt:t", () => __RΦ.a(888))(XMLModel.prototype, "properties");
|
|
259
274
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "properties");
|
|
260
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
275
|
+
__RΦ.m("rt:t", () => __RΦ.a(946))(XMLModel.prototype, "reflectedClass");
|
|
261
276
|
__RΦ.m("rt:f", "P")(XMLModel.prototype, "reflectedClass");
|
|
277
|
+
__RΦ.m("rt:f", "M.")(XMLModel.prototype["resolveAllProperties"]);
|
|
278
|
+
((t, p) => __RΦ.m("rt:h", () => typeof t === "object" ? t.constructor : t)(t[p]))(XMLModel.prototype, "resolveAllProperties");
|
|
279
|
+
__RΦ.m("rt:p", [])(XMLModel.prototype, "resolveAllProperties");
|
|
280
|
+
__RΦ.m("rt:f", "M.")(XMLModel.prototype, "resolveAllProperties");
|
|
281
|
+
__RΦ.m("rt:t", () => __RΦ.a(1067))(XMLModel.prototype, "resolveAllProperties");
|
|
262
282
|
function createModel(type, options) {
|
|
263
283
|
if (findModel(type)) {
|
|
264
284
|
throw new TypeError(`a model for type ${type.name} already exists`);
|
|
@@ -268,17 +288,17 @@ function createModel(type, options) {
|
|
|
268
288
|
return model;
|
|
269
289
|
}
|
|
270
290
|
exports.createModel = createModel;
|
|
271
|
-
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(
|
|
291
|
+
__RΦ.m("rt:p", [{ n: "type", t: () => __RΦ.a(1622), v: null }, { n: "options", t: () => __RΦ.a(1621), v: null }])(createModel);
|
|
272
292
|
__RΦ.m("rt:f", "F")(createModel);
|
|
273
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
293
|
+
__RΦ.m("rt:t", () => __RΦ.a(1655))(createModel);
|
|
274
294
|
exports.Models = new Map();
|
|
275
295
|
function findModel(id) {
|
|
276
296
|
return exports.Models.get(id);
|
|
277
297
|
}
|
|
278
298
|
exports.findModel = findModel;
|
|
279
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
299
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1720), v: null }])(findModel);
|
|
280
300
|
__RΦ.m("rt:f", "F")(findModel);
|
|
281
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
301
|
+
__RΦ.m("rt:t", () => __RΦ.a(1733))(findModel);
|
|
282
302
|
function getModel(id) {
|
|
283
303
|
const model = findModel(id);
|
|
284
304
|
if (model)
|
|
@@ -287,19 +307,20 @@ function getModel(id) {
|
|
|
287
307
|
throw new TypeError(`couln't find model for type ${id.name}`);
|
|
288
308
|
}
|
|
289
309
|
exports.getModel = getModel;
|
|
290
|
-
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(
|
|
310
|
+
__RΦ.m("rt:p", [{ n: "id", t: () => __RΦ.a(1934), v: null }])(getModel);
|
|
291
311
|
__RΦ.m("rt:f", "F")(getModel);
|
|
292
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
312
|
+
__RΦ.m("rt:t", () => __RΦ.a(1937))(getModel);
|
|
293
313
|
// Model decorator
|
|
294
314
|
function ModelDecoratorFactory(options) {
|
|
295
315
|
return __RΦ.f(function (constructor) {
|
|
296
316
|
findModel(constructor) || createModel(constructor, options || {});
|
|
297
|
-
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(
|
|
317
|
+
}, [__RΦ.m("rt:p", [{ n: "constructor", t: () => __RΦ.a(1943), v: null }]), __RΦ.m("rt:f", "M"), __RΦ.m("rt:t", () => __RΦ.a(22))], "");
|
|
298
318
|
}
|
|
299
319
|
exports.Model = ModelDecoratorFactory;
|
|
300
|
-
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(
|
|
320
|
+
__RΦ.m("rt:p", [{ n: "options", t: () => __RΦ.a(1940), v: null, f: "?" }])(ModelDecoratorFactory);
|
|
301
321
|
__RΦ.m("rt:f", "F")(ModelDecoratorFactory);
|
|
302
|
-
__RΦ.m("rt:t", () => __RΦ.a(
|
|
322
|
+
__RΦ.m("rt:t", () => __RΦ.a(1942))(ModelDecoratorFactory);
|
|
303
323
|
var property_2 = require("./property");
|
|
304
324
|
Object.defineProperty(exports, "Prop", { enumerable: true, get: function () { return property_2.Prop; } });
|
|
305
325
|
require("../defaults/models");
|
|
326
|
+
const errors_1 = require("../errors");
|