@azrico/webobject 1.5.58 → 1.5.59

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.
Files changed (33) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +16 -0
  3. package/dist/src/WebObjects/ParentWebObject.d.ts +24 -0
  4. package/dist/src/WebObjects/ParentWebObject.js +121 -0
  5. package/dist/src/WebObjects/WebObject.d.ts +153 -0
  6. package/dist/src/WebObjects/WebObject.js +1624 -0
  7. package/dist/src/WebObjects/WebObjectHelper.d.ts +9 -0
  8. package/dist/src/WebObjects/WebObjectHelper.js +38 -0
  9. package/dist/src/WebObjects/WebObjectHelper.test.d.ts +1 -0
  10. package/dist/src/WebObjects/WebObjectHelper.test.js +67 -0
  11. package/dist/src/WebObjects/WebObjectManager.d.ts +68 -0
  12. package/dist/src/WebObjects/WebObjectManager.js +889 -0
  13. package/dist/src/WebObjects/WebObjectPathHelper.d.ts +36 -0
  14. package/dist/src/WebObjects/WebObjectPathHelper.js +155 -0
  15. package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -0
  16. package/dist/src/WebObjects/WebObjectPathHelper.test.js +122 -0
  17. package/dist/src/index.d.ts +10 -0
  18. package/dist/src/index.js +115 -0
  19. package/dist/src/structs/DummyObject.d.ts +5 -0
  20. package/dist/src/structs/DummyObject.js +32 -0
  21. package/dist/src/structs/MapableObject.d.ts +43 -0
  22. package/dist/src/structs/MapableObject.js +123 -0
  23. package/dist/src/structs/MetaObject.d.ts +15 -0
  24. package/dist/src/structs/MetaObject.js +121 -0
  25. package/dist/src/structs/ObjectArray.d.ts +10 -0
  26. package/dist/src/structs/ObjectArray.js +68 -0
  27. package/dist/src/structs/ObjectManager.d.ts +135 -0
  28. package/dist/src/structs/ObjectManager.js +790 -0
  29. package/dist/src/structs/ObjectWithTemp.d.ts +11 -0
  30. package/dist/src/structs/ObjectWithTemp.js +66 -0
  31. package/dist/src/structs/SimpleObject.d.ts +305 -0
  32. package/dist/src/structs/SimpleObject.js +1751 -0
  33. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
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
+ });
@@ -0,0 +1,24 @@
1
+ import WebObject from "./WebObject";
2
+ type mrow = {
3
+ __parent__table_id: any;
4
+ __table_id: any;
5
+ __children?: any[];
6
+ };
7
+ /**
8
+ * This web object contains some more webobjects
9
+ */
10
+ export declare class ParentWebObject extends WebObject {
11
+ constructor(is_readonly?: boolean);
12
+ __children: WebObject[] | undefined;
13
+ set_children(val: WebObject[] | undefined): void;
14
+ private static getParentTableId;
15
+ private static getTableId;
16
+ static fixChildParentRelations<T extends mrow>(rows: T[]): T[];
17
+ /**
18
+ * assign children of row based on all_rows
19
+ * @param row
20
+ * @param all_rows
21
+ */
22
+ private static assignChildren;
23
+ }
24
+ export default ParentWebObject;
@@ -0,0 +1,121 @@
1
+ "use strict";
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(e) { return e && e.__esModule ? e : { "default": e }; }
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(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
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); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
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(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); }
15
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
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(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
18
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
19
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
20
+ 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
+ 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); }
23
+ /**
24
+ * This web object contains some more webobjects
25
+ */
26
+ var ParentWebObject = exports.ParentWebObject = /*#__PURE__*/function (_WebObject) {
27
+ function ParentWebObject() {
28
+ var _this;
29
+ var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
30
+ _classCallCheck(this, ParentWebObject);
31
+ _this = _callSuper(this, ParentWebObject, [is_readonly]);
32
+ _defineProperty(_this, "__children", undefined);
33
+ return _this;
34
+ }
35
+ _inherits(ParentWebObject, _WebObject);
36
+ return _createClass(ParentWebObject, [{
37
+ key: "set_children",
38
+ value: function set_children(val) {
39
+ if (Array.isArray(val)) {
40
+ var selftableid = this.__table_id;
41
+ val.forEach(function (v) {
42
+ v.__parent__table_id = selftableid;
43
+ });
44
+ } else val = [];
45
+ this.__children = val;
46
+ }
47
+ }], [{
48
+ key: "getParentTableId",
49
+ value: function getParentTableId(obj) {
50
+ var _ref, _ref2, _obj$__parent__table_;
51
+ return (_ref = (_ref2 = (_obj$__parent__table_ = obj.__parent__table_id) !== null && _obj$__parent__table_ !== void 0 ? _obj$__parent__table_ : obj.parent_id) !== null && _ref2 !== void 0 ? _ref2 : obj.parent) !== null && _ref !== void 0 ? _ref : obj.parentid;
52
+ }
53
+ }, {
54
+ key: "getTableId",
55
+ value: function getTableId(obj) {
56
+ var _obj$__table_id;
57
+ return (_obj$__table_id = obj.__table_id) !== null && _obj$__table_id !== void 0 ? _obj$__table_id : obj._id;
58
+ }
59
+ }, {
60
+ key: "fixChildParentRelations",
61
+ value: function fixChildParentRelations(rows) {
62
+ var _this2 = this;
63
+ if (!Array.isArray(rows)) rows = [];
64
+ var anyparentid = rows.find(function (r) {
65
+ return _this2.getParentTableId(r);
66
+ });
67
+ var anyselfid = rows.find(function (r) {
68
+ return _this2.getTableId(r);
69
+ });
70
+ if (!anyparentid || !anyselfid) return rows;
71
+ var converted_rows = rows.filter(function (r) {
72
+ return r != null;
73
+ }).map(function (r) {
74
+ return {
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
+ }
97
+ /**
98
+ * assign children of row based on all_rows
99
+ * @param row
100
+ * @param all_rows
101
+ */
102
+ }, {
103
+ key: "assignChildren",
104
+ value: function assignChildren(row, all_rows) {
105
+ var my_children = all_rows.filter(function (s) {
106
+ return row.self == s.parent;
107
+ });
108
+ if (my_children.length > 0) {
109
+ //find children of my children:
110
+ for (var index = 0; index < my_children.length; index++) {
111
+ var child = my_children[index];
112
+ this.assignChildren(child, all_rows);
113
+ }
114
+ row.data.__children = my_children.map(function (r) {
115
+ return r.data;
116
+ });
117
+ } else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0) row.data.__children = undefined;
118
+ }
119
+ }]);
120
+ }(_WebObject2["default"]);
121
+ var _default = exports["default"] = ParentWebObject;
@@ -0,0 +1,153 @@
1
+ import { SimpleObject, deltaParams, sendChangesType } from "../index";
2
+ import { WebObjectManager } from "../index";
3
+ export type ObjectWithUsers = Partial<{
4
+ _creator: string;
5
+ _users: string[];
6
+ attentions: string[];
7
+ }>;
8
+ export declare class WebObject extends SimpleObject {
9
+ static readonly __web_path: string;
10
+ static readonly __protectedProperties: string[];
11
+ static readonly __requiredProperties: never[];
12
+ meta_data: {
13
+ [key: string]: any;
14
+ };
15
+ _created_date?: string | Date;
16
+ _creator?: string;
17
+ _users?: string[];
18
+ constructor(is_readonly?: boolean);
19
+ /**
20
+ * get a list of all user ids that work on the given object
21
+ * _creator + _users + attentions(old)
22
+ * removes duplicates
23
+ * @returns array of ids
24
+ */
25
+ getAllUsers(): string[];
26
+ /**
27
+ * get a unique list of all user ids that work on the given object
28
+ * `_creator + _users + attentions`
29
+ * @returns array of ids
30
+ */
31
+ static getAllUsers(obj: ObjectWithUsers): string[];
32
+ /**
33
+ * Update meta value of this object , meta data is stored in meta_data variable
34
+ * @param key
35
+ * @param value
36
+ * @param sendChange
37
+ * @returns
38
+ */
39
+ setMetaValue(key: string, value: any, sendChange?: sendChangesType): Promise<boolean>;
40
+ /**
41
+ * Get meta value by key
42
+ * @param key
43
+ * @returns value or undefined
44
+ */
45
+ getMetaValue(key: string): any;
46
+ /**
47
+ * Get meta value by key
48
+ * @param o
49
+ * @param key
50
+ * @returns value or undefined
51
+ */
52
+ static getMetaValue(o: WebObject | null | undefined, key: string): any | undefined;
53
+ static zipSaveList(svlist: any): string;
54
+ static unzipSaveList(svlist: any): any[];
55
+ static saveList(itemList: WebObject[], extraOptions?: {
56
+ [key: string]: any;
57
+ }): Promise<boolean>;
58
+ Save(): Promise<any>;
59
+ Delete(): Promise<any>;
60
+ Lock(): Promise<any>;
61
+ UnLock(): Promise<any>;
62
+ Archive(): Promise<any>;
63
+ UnArchive(): Promise<any>;
64
+ canSave(deltaObj?: any): true | string;
65
+ canDelete(): boolean;
66
+ canArchive(): boolean;
67
+ deltaIsValid(d: any): true | string;
68
+ /**
69
+ * converts this object to an basic object
70
+ * that can be passed into client components from server components
71
+ *
72
+ * uses `get_fullDeltaObject`
73
+ * @param p
74
+ * @returns
75
+ */
76
+ get_basicObject(): Promise<Partial<this>>;
77
+ /**
78
+ * calls the `get_deltaObject` with
79
+ * `allProperties` `extraProperties`
80
+ * set to true
81
+ *
82
+ * @returns
83
+ */
84
+ get_fullDeltaObject(p?: deltaParams): Promise<any>;
85
+ /**
86
+ * calls the `get_deltaObject` with
87
+ * `allProperties` `extraProperties` `tempProperties`
88
+ * set to true
89
+ *
90
+ * @returns
91
+ */
92
+ get_fullObject(p?: deltaParams): Promise<any>;
93
+ /**
94
+ * You will post this to the server for saving
95
+ * automatically removes unchangeable fields
96
+ * @returns
97
+ */
98
+ get_deltaObject(p?: deltaParams): Promise<any>;
99
+ get manager(): WebObjectManager<any> | undefined;
100
+ get __web_path(): string;
101
+ get_webpath(): string;
102
+ static get_webpath(): string;
103
+ static get_dbname(): string;
104
+ onDelete(...p: any): Promise<any>;
105
+ onArchive(...p: any): Promise<any>;
106
+ onUnArchive(...p: any): Promise<any>;
107
+ onLock(...p: any): Promise<any>;
108
+ onUnLock(...p: any): Promise<any>;
109
+ onLoad(...p: any): Promise<any>;
110
+ onSave(...p: any): Promise<any>;
111
+ onAfterSave(...p: any): Promise<any>;
112
+ getSaveResult(original?: boolean): any;
113
+ onNew(...p: any): Promise<any>;
114
+ saveResultHasID(s: any): any;
115
+ static saveResultHasID(s: any): any;
116
+ /**
117
+ * Load Id and _index_value from the given save result into our object
118
+ * @param o
119
+ * @param srObject
120
+ * @returns
121
+ */
122
+ static LoadIdsFromSaveResult(o: WebObject, srObject: any): void;
123
+ /**
124
+ * get a single web object
125
+ * default order of parameters : search,readonly,fetchID
126
+ */
127
+ static get_single(...p: any[]): Promise<WebObject | any | undefined>;
128
+ /**
129
+ * Get a list of web objects
130
+ * default order of parameters : search,readonly,fetchID
131
+ */
132
+ static get_list(...p: any[]): Promise<Array<WebObject | any>>;
133
+ /**
134
+ * uses `get_list` and then saves the result to `gcache`
135
+ * then uses the `equals` function to return matched results
136
+ * @param search
137
+ * @returns
138
+ */
139
+ static get_list_cache(search?: any): Promise<Array<WebObject>>;
140
+ /**
141
+ * uses `get_list_cache` then the `equals` function to return matched result
142
+ * @param search
143
+ * @returns
144
+ */
145
+ static get_single_cache(search: any): Promise<WebObject | undefined>;
146
+ /**
147
+ * Get a list of web objects and convert them to basic objects
148
+ * can be passed to client components
149
+ * default order of parameters : search,readonly,fetchID
150
+ */
151
+ static get_basicList(...p: any[]): Promise<any[]>;
152
+ }
153
+ export default WebObject;