@azrico/webobject 1.4.176 → 1.4.179
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.js +1 -16
- package/dist/src/WebObjects/ParentWebObject.js +68 -115
- package/dist/src/WebObjects/WebObject.d.ts +2 -2
- package/dist/src/WebObjects/WebObject.js +498 -1303
- package/dist/src/WebObjects/WebObjectManager.js +257 -831
- package/dist/src/WebObjects/WebObjectPathHelper.js +71 -142
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +31 -122
- package/dist/src/index.js +10 -115
- package/dist/src/structs/DummyObject.js +8 -32
- package/dist/src/structs/MapableObject.js +75 -121
- package/dist/src/structs/MetaObject.js +35 -121
- package/dist/src/structs/ObjectArray.js +43 -68
- package/dist/src/structs/ObjectManager.js +277 -721
- package/dist/src/structs/ObjectWithTemp.js +25 -64
- package/dist/src/structs/SimpleObject.js +954 -1535
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _index = require("./src/index");
|
|
7
|
-
Object.keys(_index).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _index[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _index[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
export * from "./src/index";
|
|
@@ -1,121 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.ParentWebObject = void 0;
|
|
7
|
-
var _WebObject2 = _interopRequireDefault(require("./WebObject"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
|
+
import WebObject from "./WebObject";
|
|
23
2
|
/**
|
|
24
3
|
* This web object contains some more webobjects
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
parent: _this2.getParentTableId(r),
|
|
76
|
-
self: _this2.getTableId(r),
|
|
77
|
-
data: r
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
var top_level_rows = converted_rows.filter(function (r) {
|
|
81
|
-
return !r.parent;
|
|
82
|
-
});
|
|
83
|
-
var any_child = converted_rows.find(function (r) {
|
|
84
|
-
return Boolean(r.parent);
|
|
85
|
-
});
|
|
86
|
-
if (any_child) {
|
|
87
|
-
//find children of top-level parents:
|
|
88
|
-
for (var index = 0; index < top_level_rows.length; index++) {
|
|
89
|
-
var mrow = top_level_rows[index];
|
|
90
|
-
this.assignChildren(mrow, converted_rows);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return top_level_rows.map(function (r) {
|
|
94
|
-
return r.data;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
4
|
+
*/
|
|
5
|
+
export class ParentWebObject extends WebObject {
|
|
6
|
+
constructor(is_readonly = false) {
|
|
7
|
+
super(is_readonly);
|
|
8
|
+
}
|
|
9
|
+
__children = undefined;
|
|
10
|
+
set_children(val) {
|
|
11
|
+
if (Array.isArray(val)) {
|
|
12
|
+
const selftableid = this.__table_id;
|
|
13
|
+
val.forEach((v) => {
|
|
14
|
+
v.__parent__table_id = selftableid;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else
|
|
18
|
+
val = [];
|
|
19
|
+
this.__children = val;
|
|
20
|
+
}
|
|
21
|
+
static getParentTableId(obj) {
|
|
22
|
+
return obj.__parent__table_id ?? obj.parentid ?? obj.parent;
|
|
23
|
+
}
|
|
24
|
+
static getTableId(obj) {
|
|
25
|
+
return obj.__table_id ?? obj._id;
|
|
26
|
+
}
|
|
27
|
+
static fixChildParentRelations(rows) {
|
|
28
|
+
if (!Array.isArray(rows))
|
|
29
|
+
rows = [];
|
|
30
|
+
const anyparentid = rows.find((r) => this.getParentTableId(r));
|
|
31
|
+
const anyselfid = rows.find((r) => this.getTableId(r));
|
|
32
|
+
if (!anyparentid || !anyselfid)
|
|
33
|
+
return rows;
|
|
34
|
+
const converted_rows = rows
|
|
35
|
+
.filter((r) => r != null)
|
|
36
|
+
.map((r) => {
|
|
37
|
+
return {
|
|
38
|
+
parent: this.getParentTableId(r),
|
|
39
|
+
self: this.getTableId(r),
|
|
40
|
+
data: r,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const top_level_rows = converted_rows.filter((r) => !r.parent);
|
|
44
|
+
const any_child = converted_rows.find((r) => Boolean(r.parent));
|
|
45
|
+
if (any_child) {
|
|
46
|
+
//find children of top-level parents:
|
|
47
|
+
for (let index = 0; index < top_level_rows.length; index++) {
|
|
48
|
+
const mrow = top_level_rows[index];
|
|
49
|
+
this.assignChildren(mrow, converted_rows);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return top_level_rows.map((r) => r.data);
|
|
53
|
+
}
|
|
97
54
|
/**
|
|
98
55
|
* assign children of row based on all_rows
|
|
99
56
|
* @param row
|
|
100
57
|
* @param all_rows
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}]);
|
|
120
|
-
}(_WebObject2["default"]);
|
|
121
|
-
var _default = exports["default"] = ParentWebObject;
|
|
58
|
+
*/
|
|
59
|
+
static assignChildren(row, all_rows) {
|
|
60
|
+
const my_children = all_rows.filter((s) => row.self == s.parent);
|
|
61
|
+
if (my_children.length > 0) {
|
|
62
|
+
//find children of my children:
|
|
63
|
+
for (let index = 0; index < my_children.length; index++) {
|
|
64
|
+
const child = my_children[index];
|
|
65
|
+
this.assignChildren(child, all_rows);
|
|
66
|
+
}
|
|
67
|
+
row.data.__children = my_children.map((r) => r.data);
|
|
68
|
+
}
|
|
69
|
+
else if (!Array.isArray(row.data.__children) ||
|
|
70
|
+
row.data.__children.length == 0)
|
|
71
|
+
row.data.__children = undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export default ParentWebObject;
|
|
@@ -110,11 +110,11 @@ export declare class WebObject extends SimpleObject {
|
|
|
110
110
|
* get a single web object
|
|
111
111
|
* default order of parameters : search,readonly,fetchID
|
|
112
112
|
*/
|
|
113
|
-
static get_single<T extends WebObject>(...p: any[]): Promise<T |
|
|
113
|
+
static get_single<T extends WebObject>(...p: any[]): Promise<T | undefined>;
|
|
114
114
|
/**
|
|
115
115
|
* Get a list of web objects
|
|
116
116
|
* default order of parameters : search,readonly,fetchID
|
|
117
117
|
*/
|
|
118
|
-
static get_list(...p: any[]): Promise<WebObject
|
|
118
|
+
static get_list(...p: any[]): Promise<Array<WebObject>>;
|
|
119
119
|
}
|
|
120
120
|
export default WebObject;
|