@azrico/webobject 1.5.69 → 1.5.71
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/dist/index.d.ts +1 -1
- package/dist/src/WebObjects/ParentWebObject.d.ts +24 -24
- package/dist/src/WebObjects/ParentWebObject.js +7 -7
- package/dist/src/WebObjects/WebObject.d.ts +153 -153
- package/dist/src/WebObjects/WebObject.js +476 -561
- package/dist/src/WebObjects/WebObjectHelper.d.ts +9 -9
- package/dist/src/WebObjects/WebObjectHelper.js +4 -4
- package/dist/src/WebObjects/WebObjectHelper.test.d.ts +1 -1
- package/dist/src/WebObjects/WebObjectHelper.test.js +1 -1
- package/dist/src/WebObjects/WebObjectManager.d.ts +68 -68
- package/dist/src/WebObjects/WebObjectManager.js +303 -350
- package/dist/src/WebObjects/WebObjectPathHelper.d.ts +36 -36
- package/dist/src/WebObjects/WebObjectPathHelper.js +31 -39
- package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -1
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +55 -61
- package/dist/src/index.d.ts +10 -10
- package/dist/src/structs/DummyObject.d.ts +5 -5
- package/dist/src/structs/DummyObject.js +1 -1
- package/dist/src/structs/MapableObject.d.ts +43 -43
- package/dist/src/structs/MapableObject.js +3 -3
- package/dist/src/structs/MetaObject.d.ts +15 -15
- package/dist/src/structs/MetaObject.js +19 -25
- package/dist/src/structs/ObjectArray.d.ts +10 -10
- package/dist/src/structs/ObjectArray.js +1 -1
- package/dist/src/structs/ObjectManager.d.ts +140 -140
- package/dist/src/structs/ObjectManager.js +202 -223
- package/dist/src/structs/ObjectWithTemp.d.ts +17 -17
- package/dist/src/structs/ObjectWithTemp.js +13 -17
- package/dist/src/structs/SimpleObject.d.ts +318 -303
- package/dist/src/structs/SimpleObject.js +423 -467
- package/package.json +63 -82
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { AnyClassType } from "@azrico/types";
|
|
2
|
-
import WebObject from "./WebObject";
|
|
3
|
-
type PathFunction<T extends AnyClassType> = string | ((w: InstanceType<T>) => string);
|
|
4
|
-
export declare class WebObjectPathHelper {
|
|
5
|
-
static readonly defaultPaths: {
|
|
6
|
-
lock: string;
|
|
7
|
-
unlock: string;
|
|
8
|
-
archive: string;
|
|
9
|
-
unarchive: string;
|
|
10
|
-
delete: string;
|
|
11
|
-
new: string;
|
|
12
|
-
save: string;
|
|
13
|
-
get: string;
|
|
14
|
-
};
|
|
15
|
-
static readonly pathOverrides: {};
|
|
16
|
-
/**
|
|
17
|
-
* get path that we use for `action` for the `obj`
|
|
18
|
-
* @param obj
|
|
19
|
-
* @param action
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
static get_path<T extends WebObject | typeof WebObject>(obj: T, action: string): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* clear all paths that are override by `override_path`
|
|
25
|
-
*/
|
|
26
|
-
static clear_overrides(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* override a save path for the gievn webobject
|
|
29
|
-
* @param obj
|
|
30
|
-
* @param pn
|
|
31
|
-
* @param override
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
static override_path<T extends AnyClassType>(obj: T | InstanceType<T> | string, pn: string, override: PathFunction<T>): Promise<false | PathFunction<T>>;
|
|
35
|
-
}
|
|
36
|
-
export default WebObjectPathHelper;
|
|
1
|
+
import { AnyClassType } from "@azrico/types";
|
|
2
|
+
import WebObject from "./WebObject";
|
|
3
|
+
type PathFunction<T extends AnyClassType> = string | ((w: InstanceType<T>) => string);
|
|
4
|
+
export declare class WebObjectPathHelper {
|
|
5
|
+
static readonly defaultPaths: {
|
|
6
|
+
lock: string;
|
|
7
|
+
unlock: string;
|
|
8
|
+
archive: string;
|
|
9
|
+
unarchive: string;
|
|
10
|
+
delete: string;
|
|
11
|
+
new: string;
|
|
12
|
+
save: string;
|
|
13
|
+
get: string;
|
|
14
|
+
};
|
|
15
|
+
static readonly pathOverrides: {};
|
|
16
|
+
/**
|
|
17
|
+
* get path that we use for `action` for the `obj`
|
|
18
|
+
* @param obj
|
|
19
|
+
* @param action
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
static get_path<T extends WebObject | typeof WebObject>(obj: T, action: string): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* clear all paths that are override by `override_path`
|
|
25
|
+
*/
|
|
26
|
+
static clear_overrides(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* override a save path for the gievn webobject
|
|
29
|
+
* @param obj
|
|
30
|
+
* @param pn
|
|
31
|
+
* @param override
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
static override_path<T extends AnyClassType>(obj: T | InstanceType<T> | string, pn: string, override: PathFunction<T>): Promise<false | PathFunction<T>>;
|
|
35
|
+
}
|
|
36
|
+
export default WebObjectPathHelper;
|
|
@@ -7,7 +7,8 @@ exports["default"] = exports.WebObjectPathHelper = void 0;
|
|
|
7
7
|
var _WebObject = _interopRequireDefault(require("./WebObject"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
9
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
-
function
|
|
10
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
11
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
11
12
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
13
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
13
14
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -15,7 +16,7 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
|
|
|
15
16
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
17
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
-
function _toPrimitive(t,
|
|
19
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
19
20
|
var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function () {
|
|
20
21
|
function WebObjectPathHelper() {
|
|
21
22
|
_classCallCheck(this, WebObjectPathHelper);
|
|
@@ -23,22 +24,21 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
|
|
|
23
24
|
return _createClass(WebObjectPathHelper, null, [{
|
|
24
25
|
key: "get_path",
|
|
25
26
|
value: (
|
|
26
|
-
/**
|
|
27
|
-
* get path that we use for `action` for the `obj`
|
|
28
|
-
* @param obj
|
|
29
|
-
* @param action
|
|
30
|
-
* @returns
|
|
27
|
+
/**
|
|
28
|
+
* get path that we use for `action` for the `obj`
|
|
29
|
+
* @param obj
|
|
30
|
+
* @param action
|
|
31
|
+
* @returns
|
|
31
32
|
*/
|
|
32
33
|
function () {
|
|
33
|
-
var _get_path = _asyncToGenerator(/*#__PURE__*/
|
|
34
|
+
var _get_path = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(obj, action) {
|
|
34
35
|
var wn, wp, usepath;
|
|
35
|
-
return
|
|
36
|
-
while (1) switch (_context.
|
|
36
|
+
return _regenerator().w(function (_context) {
|
|
37
|
+
while (1) switch (_context.n) {
|
|
37
38
|
case 0:
|
|
38
39
|
action = String(action).toLowerCase();
|
|
39
40
|
wn = obj.get_webpath();
|
|
40
41
|
wp = obj.__web_path;
|
|
41
|
-
usepath = "";
|
|
42
42
|
if (WebObjectPathHelper.pathOverrides[wn] && WebObjectPathHelper.pathOverrides[wn][action]) {
|
|
43
43
|
usepath = WebObjectPathHelper.pathOverrides[wn][action];
|
|
44
44
|
} else {
|
|
@@ -52,10 +52,7 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
|
|
|
52
52
|
usepath = usepath.replaceAll("{id}", obj.getID());
|
|
53
53
|
}
|
|
54
54
|
/* -------------------------------------------------------------------------- */
|
|
55
|
-
return _context.
|
|
56
|
-
case 10:
|
|
57
|
-
case "end":
|
|
58
|
-
return _context.stop();
|
|
55
|
+
return _context.a(2, usepath);
|
|
59
56
|
}
|
|
60
57
|
}, _callee);
|
|
61
58
|
}));
|
|
@@ -64,24 +61,23 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
|
|
|
64
61
|
}
|
|
65
62
|
return get_path;
|
|
66
63
|
}()
|
|
67
|
-
/**
|
|
68
|
-
* clear all paths that are override by `override_path`
|
|
64
|
+
/**
|
|
65
|
+
* clear all paths that are override by `override_path`
|
|
69
66
|
*/
|
|
70
67
|
)
|
|
71
68
|
}, {
|
|
72
69
|
key: "clear_overrides",
|
|
73
70
|
value: (function () {
|
|
74
|
-
var _clear_overrides = _asyncToGenerator(/*#__PURE__*/
|
|
71
|
+
var _clear_overrides = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
75
72
|
var key;
|
|
76
|
-
return
|
|
77
|
-
while (1) switch (_context2.
|
|
73
|
+
return _regenerator().w(function (_context2) {
|
|
74
|
+
while (1) switch (_context2.n) {
|
|
78
75
|
case 0:
|
|
79
76
|
for (key in this.pathOverrides) {
|
|
80
77
|
this.pathOverrides[key] = {};
|
|
81
78
|
}
|
|
82
79
|
case 1:
|
|
83
|
-
|
|
84
|
-
return _context2.stop();
|
|
80
|
+
return _context2.a(2);
|
|
85
81
|
}
|
|
86
82
|
}, _callee2, this);
|
|
87
83
|
}));
|
|
@@ -90,24 +86,23 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
|
|
|
90
86
|
}
|
|
91
87
|
return clear_overrides;
|
|
92
88
|
}()
|
|
93
|
-
/**
|
|
94
|
-
* override a save path for the gievn webobject
|
|
95
|
-
* @param obj
|
|
96
|
-
* @param pn
|
|
97
|
-
* @param override
|
|
98
|
-
* @returns
|
|
89
|
+
/**
|
|
90
|
+
* override a save path for the gievn webobject
|
|
91
|
+
* @param obj
|
|
92
|
+
* @param pn
|
|
93
|
+
* @param override
|
|
94
|
+
* @returns
|
|
99
95
|
*/
|
|
100
96
|
)
|
|
101
97
|
}, {
|
|
102
98
|
key: "override_path",
|
|
103
99
|
value: (function () {
|
|
104
|
-
var _override_path = _asyncToGenerator(/*#__PURE__*/
|
|
100
|
+
var _override_path = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(obj, pn, override) {
|
|
105
101
|
var wn;
|
|
106
|
-
return
|
|
107
|
-
while (1) switch (_context3.
|
|
102
|
+
return _regenerator().w(function (_context3) {
|
|
103
|
+
while (1) switch (_context3.n) {
|
|
108
104
|
case 0:
|
|
109
105
|
pn = String(pn).toLowerCase();
|
|
110
|
-
wn = "";
|
|
111
106
|
/* ------------------------------ find webname ------------------------------ */
|
|
112
107
|
if (typeof obj === "string") {
|
|
113
108
|
wn = obj;
|
|
@@ -118,19 +113,16 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
|
|
|
118
113
|
wn = obj.__web_path || obj.__web_type;
|
|
119
114
|
}
|
|
120
115
|
if (wn) {
|
|
121
|
-
_context3.
|
|
116
|
+
_context3.n = 1;
|
|
122
117
|
break;
|
|
123
118
|
}
|
|
124
119
|
console.error("[override_path]", "bad webname");
|
|
125
|
-
return _context3.
|
|
126
|
-
case
|
|
120
|
+
return _context3.a(2, false);
|
|
121
|
+
case 1:
|
|
127
122
|
/* --------------------------- apply the override --------------------------- */
|
|
128
123
|
if (!WebObjectPathHelper.pathOverrides[wn]) WebObjectPathHelper.pathOverrides[wn] = {};
|
|
129
124
|
WebObjectPathHelper.pathOverrides[wn][pn] = override;
|
|
130
|
-
return _context3.
|
|
131
|
-
case 9:
|
|
132
|
-
case "end":
|
|
133
|
-
return _context3.stop();
|
|
125
|
+
return _context3.a(2, override);
|
|
134
126
|
}
|
|
135
127
|
}, _callee3);
|
|
136
128
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,8 @@ var _index = require("../index");
|
|
|
4
4
|
var _WebObjectPathHelper = _interopRequireDefault(require("./WebObjectPathHelper"));
|
|
5
5
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
6
6
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
-
function
|
|
7
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
8
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
8
9
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
9
10
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
10
11
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
@@ -19,7 +20,7 @@ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new T
|
|
|
19
20
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
20
21
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
-
function _toPrimitive(t,
|
|
23
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
23
24
|
var TestWebObject = /*#__PURE__*/function (_WebObject) {
|
|
24
25
|
function TestWebObject() {
|
|
25
26
|
_classCallCheck(this, TestWebObject);
|
|
@@ -36,86 +37,79 @@ describe("WebObjectPathHelper", function () {
|
|
|
36
37
|
wobj = new TestWebObject();
|
|
37
38
|
wobj._id = "test";
|
|
38
39
|
});
|
|
39
|
-
it("get_path", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
it("get_path", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
41
|
+
var _t, _t2, _t3;
|
|
42
|
+
return _regenerator().w(function (_context) {
|
|
43
|
+
while (1) switch (_context.n) {
|
|
42
44
|
case 0:
|
|
43
|
-
|
|
44
|
-
_context.
|
|
45
|
+
_t = expect;
|
|
46
|
+
_context.n = 1;
|
|
45
47
|
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
46
|
-
case
|
|
47
|
-
_context.
|
|
48
|
-
|
|
49
|
-
_context.
|
|
50
|
-
_context.next = 8;
|
|
48
|
+
case 1:
|
|
49
|
+
_t(_context.v).toBe(wobj.get_webpath() + "/" + wobj.getID());
|
|
50
|
+
_t2 = expect;
|
|
51
|
+
_context.n = 2;
|
|
51
52
|
return _WebObjectPathHelper["default"].get_path(wobj, "new");
|
|
52
|
-
case
|
|
53
|
-
_context.
|
|
54
|
-
|
|
55
|
-
_context.
|
|
56
|
-
_context.next = 13;
|
|
53
|
+
case 2:
|
|
54
|
+
_t2(_context.v).toBe(wobj.get_webpath());
|
|
55
|
+
_t3 = expect;
|
|
56
|
+
_context.n = 3;
|
|
57
57
|
return _WebObjectPathHelper["default"].get_path(wobj, "lock");
|
|
58
|
-
case
|
|
59
|
-
_context.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
case "end":
|
|
63
|
-
return _context.stop();
|
|
58
|
+
case 3:
|
|
59
|
+
_t3(_context.v).toBe("".concat(wobj.get_webpath(), "/").concat(wobj.getID(), "/lock"));
|
|
60
|
+
case 4:
|
|
61
|
+
return _context.a(2);
|
|
64
62
|
}
|
|
65
63
|
}, _callee);
|
|
66
64
|
})));
|
|
67
|
-
it("override_path", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
it("override_path", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
66
|
+
var _t4, _t5, _t6;
|
|
67
|
+
return _regenerator().w(function (_context2) {
|
|
68
|
+
while (1) switch (_context2.n) {
|
|
70
69
|
case 0:
|
|
71
|
-
_context2.
|
|
70
|
+
_context2.n = 1;
|
|
72
71
|
return _WebObjectPathHelper["default"].override_path(wobj.get_webpath(), "save", "blah");
|
|
73
|
-
case
|
|
74
|
-
|
|
75
|
-
_context2.
|
|
72
|
+
case 1:
|
|
73
|
+
_t4 = expect;
|
|
74
|
+
_context2.n = 2;
|
|
76
75
|
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
77
|
-
case
|
|
78
|
-
_context2.
|
|
79
|
-
|
|
80
|
-
_context2.next = 9;
|
|
76
|
+
case 2:
|
|
77
|
+
_t4(_context2.v).toBe("blah");
|
|
78
|
+
_context2.n = 3;
|
|
81
79
|
return _WebObjectPathHelper["default"].override_path(wobj.get_webpath(), "save", "{id}");
|
|
82
|
-
case
|
|
83
|
-
|
|
84
|
-
_context2.
|
|
80
|
+
case 3:
|
|
81
|
+
_t5 = expect;
|
|
82
|
+
_context2.n = 4;
|
|
85
83
|
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
86
|
-
case
|
|
87
|
-
_context2.
|
|
88
|
-
|
|
89
|
-
_context2.
|
|
90
|
-
_context2.next = 17;
|
|
84
|
+
case 4:
|
|
85
|
+
_t5(_context2.v).toBe(wobj.getID());
|
|
86
|
+
_t6 = expect;
|
|
87
|
+
_context2.n = 5;
|
|
91
88
|
return _WebObjectPathHelper["default"].get_path(wobj, "new");
|
|
92
|
-
case
|
|
93
|
-
_context2.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case "end":
|
|
97
|
-
return _context2.stop();
|
|
89
|
+
case 5:
|
|
90
|
+
_t6(_context2.v).toBe(wobj.get_webpath());
|
|
91
|
+
case 6:
|
|
92
|
+
return _context2.a(2);
|
|
98
93
|
}
|
|
99
94
|
}, _callee2);
|
|
100
95
|
})));
|
|
101
|
-
it("override_path with function", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
it("override_path with function", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
97
|
+
var _t7;
|
|
98
|
+
return _regenerator().w(function (_context3) {
|
|
99
|
+
while (1) switch (_context3.n) {
|
|
104
100
|
case 0:
|
|
105
|
-
_context3.
|
|
101
|
+
_context3.n = 1;
|
|
106
102
|
return _WebObjectPathHelper["default"].override_path(wobj, "save", function (s) {
|
|
107
103
|
return s._id;
|
|
108
104
|
});
|
|
109
|
-
case
|
|
110
|
-
|
|
111
|
-
_context3.
|
|
105
|
+
case 1:
|
|
106
|
+
_t7 = expect;
|
|
107
|
+
_context3.n = 2;
|
|
112
108
|
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
113
|
-
case
|
|
114
|
-
_context3.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
case "end":
|
|
118
|
-
return _context3.stop();
|
|
109
|
+
case 2:
|
|
110
|
+
_t7(_context3.v).toBe(wobj.getID());
|
|
111
|
+
case 3:
|
|
112
|
+
return _context3.a(2);
|
|
119
113
|
}
|
|
120
114
|
}, _callee3);
|
|
121
115
|
})));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./structs/SimpleObject";
|
|
2
|
-
export * from "./structs/ObjectArray";
|
|
3
|
-
export * from "./structs/MapableObject";
|
|
4
|
-
export * from "./structs/MetaObject";
|
|
5
|
-
export * from "./structs/DummyObject";
|
|
6
|
-
export * from "./structs/ObjectManager";
|
|
7
|
-
export * from "./WebObjects/WebObjectManager";
|
|
8
|
-
export * from "./WebObjects/WebObject";
|
|
9
|
-
export * from "./WebObjects/WebObjectPathHelper";
|
|
10
|
-
export * from "./WebObjects/ParentWebObject";
|
|
1
|
+
export * from "./structs/SimpleObject";
|
|
2
|
+
export * from "./structs/ObjectArray";
|
|
3
|
+
export * from "./structs/MapableObject";
|
|
4
|
+
export * from "./structs/MetaObject";
|
|
5
|
+
export * from "./structs/DummyObject";
|
|
6
|
+
export * from "./structs/ObjectManager";
|
|
7
|
+
export * from "./WebObjects/WebObjectManager";
|
|
8
|
+
export * from "./WebObjects/WebObject";
|
|
9
|
+
export * from "./WebObjects/WebObjectPathHelper";
|
|
10
|
+
export * from "./WebObjects/ParentWebObject";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SimpleObject } from "./SimpleObject";
|
|
2
|
-
export declare class DummyObject extends SimpleObject {
|
|
3
|
-
constructor(initObject: Partial<DummyObject> | null | undefined);
|
|
4
|
-
}
|
|
5
|
-
export default DummyObject;
|
|
1
|
+
import { SimpleObject } from "./SimpleObject";
|
|
2
|
+
export declare class DummyObject extends SimpleObject {
|
|
3
|
+
constructor(initObject: Partial<DummyObject> | null | undefined);
|
|
4
|
+
}
|
|
5
|
+
export default DummyObject;
|
|
@@ -9,7 +9,7 @@ var _SimpleObject2 = require("./SimpleObject");
|
|
|
9
9
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
10
10
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
-
function _toPrimitive(t,
|
|
12
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
13
13
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
14
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
15
15
|
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import ObjectWithTemp from "./ObjectWithTemp";
|
|
2
|
-
declare type FirstInTuple<T extends any[]> = ((...args: T) => any) extends (arg: infer R, ...rest: infer U) => any ? R : T;
|
|
3
|
-
/**
|
|
4
|
-
* This object can be mapped and converted
|
|
5
|
-
*/
|
|
6
|
-
export declare class MapableObject extends ObjectWithTemp {
|
|
7
|
-
readonly __uid: string;
|
|
8
|
-
__table_id?: string;
|
|
9
|
-
__parent__table_id?: string;
|
|
10
|
-
__row_number?: number;
|
|
11
|
-
constructor();
|
|
12
|
-
getUID(): string;
|
|
13
|
-
static getUID(o: MapableObject): string;
|
|
14
|
-
static mapto<T>(maptoType: {
|
|
15
|
-
new (...p: any): T;
|
|
16
|
-
}, objectlist: any[] | null | undefined, is_readonly?: boolean, ...p: any[]): T[];
|
|
17
|
-
static mapto<T extends typeof MapableObject>(objectlist: any[] | null | undefined, is_readonly?: boolean, ...p: any[]): InstanceType<T>[];
|
|
18
|
-
/**
|
|
19
|
-
* construct a new class from the given first parameter
|
|
20
|
-
* @param maptoType class
|
|
21
|
-
* @param first_param first parameter
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
static ensure<ClassType extends new (...args: any) => any>(maptoType: ClassType, first_param: FirstInTuple<ConstructorParameters<ClassType>>): InstanceType<ClassType>;
|
|
25
|
-
/**
|
|
26
|
-
* construct a new class from the given parameters
|
|
27
|
-
* @param maptoType class
|
|
28
|
-
* @param first_param first parameter
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
static ensure<ClassType extends new (...args: any) => any>(maptoType: ClassType, ...rest_params: ConstructorParameters<ClassType>): InstanceType<ClassType>;
|
|
32
|
-
/**
|
|
33
|
-
* make sure the object is instance of class
|
|
34
|
-
* @param maptoType class
|
|
35
|
-
* @param obj
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
static ensure<ClassType extends new (...args: any) => any>(maptoType: ClassType, obj: InstanceType<ClassType>): InstanceType<ClassType>;
|
|
39
|
-
static map_rowindex<T extends MapableObject>(objectlist: T[] | null | undefined): T[];
|
|
40
|
-
static map_tableid<T extends MapableObject>(objectlist: T[] | null | undefined): T[];
|
|
41
|
-
static equals(a?: MapableObject | any, b?: MapableObject | any): boolean;
|
|
42
|
-
}
|
|
43
|
-
export default MapableObject;
|
|
1
|
+
import ObjectWithTemp from "./ObjectWithTemp";
|
|
2
|
+
declare type FirstInTuple<T extends any[]> = ((...args: T) => any) extends (arg: infer R, ...rest: infer U) => any ? R : T;
|
|
3
|
+
/**
|
|
4
|
+
* This object can be mapped and converted
|
|
5
|
+
*/
|
|
6
|
+
export declare class MapableObject extends ObjectWithTemp {
|
|
7
|
+
readonly __uid: string;
|
|
8
|
+
__table_id?: string;
|
|
9
|
+
__parent__table_id?: string;
|
|
10
|
+
__row_number?: number;
|
|
11
|
+
constructor();
|
|
12
|
+
getUID(): string;
|
|
13
|
+
static getUID(o: MapableObject): string;
|
|
14
|
+
static mapto<T>(maptoType: {
|
|
15
|
+
new (...p: any): T;
|
|
16
|
+
}, objectlist: any[] | null | undefined, is_readonly?: boolean, ...p: any[]): T[];
|
|
17
|
+
static mapto<T extends typeof MapableObject>(objectlist: any[] | null | undefined, is_readonly?: boolean, ...p: any[]): InstanceType<T>[];
|
|
18
|
+
/**
|
|
19
|
+
* construct a new class from the given first parameter
|
|
20
|
+
* @param maptoType class
|
|
21
|
+
* @param first_param first parameter
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
static ensure<ClassType extends new (...args: any) => any>(maptoType: ClassType, first_param: FirstInTuple<ConstructorParameters<ClassType>>): InstanceType<ClassType>;
|
|
25
|
+
/**
|
|
26
|
+
* construct a new class from the given parameters
|
|
27
|
+
* @param maptoType class
|
|
28
|
+
* @param first_param first parameter
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
static ensure<ClassType extends new (...args: any) => any>(maptoType: ClassType, ...rest_params: ConstructorParameters<ClassType>): InstanceType<ClassType>;
|
|
32
|
+
/**
|
|
33
|
+
* make sure the object is instance of class
|
|
34
|
+
* @param maptoType class
|
|
35
|
+
* @param obj
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
static ensure<ClassType extends new (...args: any) => any>(maptoType: ClassType, obj: InstanceType<ClassType>): InstanceType<ClassType>;
|
|
39
|
+
static map_rowindex<T extends MapableObject>(objectlist: T[] | null | undefined): T[];
|
|
40
|
+
static map_tableid<T extends MapableObject>(objectlist: T[] | null | undefined): T[];
|
|
41
|
+
static equals(a?: MapableObject | any, b?: MapableObject | any): boolean;
|
|
42
|
+
}
|
|
43
|
+
export default MapableObject;
|