@azrico/webobject 1.4.77 → 1.4.79
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/src/WebObjects/WebObject.d.ts +2 -9
- package/dist/src/WebObjects/WebObject.js +43 -32
- package/dist/src/WebObjects/WebObjectManager.d.ts +0 -2
- package/dist/src/WebObjects/WebObjectManager.js +2 -4
- package/dist/src/structs/ObjectManager.d.ts +4 -2
- package/dist/src/structs/ObjectManager.js +6 -0
- package/dist/src/structs/SimpleObject.d.ts +5 -0
- package/dist/src/structs/SimpleObject.js +19 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import SimpleObject,
|
|
1
|
+
import { SimpleObject, sendChangesType } from "../index";
|
|
2
2
|
import { WebObjectManager } from "../index";
|
|
3
3
|
export type deltaParams = {
|
|
4
4
|
type?: string;
|
|
@@ -10,8 +10,6 @@ export type deltaParams = {
|
|
|
10
10
|
applyFilter?: boolean;
|
|
11
11
|
};
|
|
12
12
|
export declare class WebObject extends SimpleObject {
|
|
13
|
-
static readonly __web_path: string;
|
|
14
|
-
static readonly __web_type: string;
|
|
15
13
|
static readonly __protectedProperties: string[];
|
|
16
14
|
static readonly __requiredProperties: never[];
|
|
17
15
|
meta_data: {
|
|
@@ -60,7 +58,7 @@ export declare class WebObject extends SimpleObject {
|
|
|
60
58
|
static saveList(itemList: WebObject[], extraOptions?: {
|
|
61
59
|
[key: string]: any;
|
|
62
60
|
}): Promise<boolean>;
|
|
63
|
-
Save(): Promise<
|
|
61
|
+
Save(): Promise<any>;
|
|
64
62
|
Delete(): Promise<boolean>;
|
|
65
63
|
canSave(deltaObj?: any): true | string;
|
|
66
64
|
deltaIsValid(d: any): true | string;
|
|
@@ -70,11 +68,6 @@ export declare class WebObject extends SimpleObject {
|
|
|
70
68
|
* @returns
|
|
71
69
|
*/
|
|
72
70
|
get_deltaObject(p?: deltaParams): Promise<any>;
|
|
73
|
-
get __web_path(): string;
|
|
74
|
-
get __web_type(): string;
|
|
75
|
-
get_webtype: () => string;
|
|
76
|
-
get_webpath: () => string;
|
|
77
|
-
static get_webname(): string | undefined;
|
|
78
71
|
get manager(): WebObjectManager<any> | undefined;
|
|
79
72
|
onDelete(...p: any): Promise<any>;
|
|
80
73
|
onLoad(...p: any): Promise<any>;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.WebObject = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _index3 = require("../index");
|
|
8
8
|
var _object = require("@azrico/object");
|
|
9
9
|
var _string = require("@azrico/string");
|
|
10
10
|
var _global = require("@azrico/global");
|
|
@@ -49,12 +49,6 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
49
49
|
_defineProperty(_assertThisInitialized(_this), "_creator", void 0);
|
|
50
50
|
//multiple users can work on one object
|
|
51
51
|
_defineProperty(_assertThisInitialized(_this), "_users", void 0);
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "get_webtype", function () {
|
|
53
|
-
return _this.__web_type || _this.get_webpath();
|
|
54
|
-
});
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "get_webpath", function () {
|
|
56
|
-
return _this.__web_path;
|
|
57
|
-
});
|
|
58
52
|
_this.meta_data = {};
|
|
59
53
|
return _this;
|
|
60
54
|
}
|
|
@@ -168,19 +162,53 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
168
162
|
key: "Save",
|
|
169
163
|
value: function Save() {
|
|
170
164
|
return (_Save = _Save || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
165
|
+
var deltaObject, putAction, putAddress, canSaveResult, resultObject;
|
|
171
166
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
172
167
|
while (1) switch (_context2.prev = _context2.next) {
|
|
173
168
|
case 0:
|
|
174
|
-
|
|
175
|
-
|
|
169
|
+
_context2.next = 2;
|
|
170
|
+
return this.get_deltaObject();
|
|
171
|
+
case 2:
|
|
172
|
+
deltaObject = _context2.sent;
|
|
173
|
+
putAction = "post";
|
|
174
|
+
putAddress = this.isNew ? "".concat(this.__web_path) : "".concat(this.__web_path, "/").concat(this.getID()); //save
|
|
175
|
+
if ((0, _object.object_isEmpty)(deltaObject)) {
|
|
176
|
+
_context2.next = 18;
|
|
176
177
|
break;
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
canSaveResult = this.canSave(deltaObject);
|
|
180
|
+
if (!(canSaveResult !== true)) {
|
|
181
|
+
_context2.next = 11;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
WebObject.addError(this, "Save not allowed", String(canSaveResult), true);
|
|
181
185
|
this.setSaveResult(false, "canceled");
|
|
182
186
|
return _context2.abrupt("return", false);
|
|
183
|
-
case
|
|
187
|
+
case 11:
|
|
188
|
+
_context2.next = 13;
|
|
189
|
+
return _global.gfunc.run_action(putAction, putAddress, deltaObject);
|
|
190
|
+
case 13:
|
|
191
|
+
resultObject = _context2.sent;
|
|
192
|
+
this.setSaveResult(resultObject, "auto");
|
|
193
|
+
if (!this.__saveResultIsSuccess) {
|
|
194
|
+
console.error("bad save result : ", resultObject);
|
|
195
|
+
WebObject.addError(this, "Save result is not valid", "the response from server was not a valid saveresult object !", true);
|
|
196
|
+
}
|
|
197
|
+
_context2.next = 19;
|
|
198
|
+
break;
|
|
199
|
+
case 18:
|
|
200
|
+
/* nothing to save */
|
|
201
|
+
this.setSaveResult(null, "nothing");
|
|
202
|
+
case 19:
|
|
203
|
+
if (!this.isSaved) {
|
|
204
|
+
_context2.next = 23;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
_context2.next = 22;
|
|
208
|
+
return this.onSave();
|
|
209
|
+
case 22:
|
|
210
|
+
return _context2.abrupt("return", this.getSaveResult());
|
|
211
|
+
case 23:
|
|
184
212
|
case "end":
|
|
185
213
|
return _context2.stop();
|
|
186
214
|
}
|
|
@@ -311,7 +339,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
311
339
|
dlt = allProperties || !useDelta && isChild && chkChangables ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
|
|
312
340
|
allkeys = Object.keys(dlt);
|
|
313
341
|
changableKeys = chkChangables ? allkeys.filter(function (s) {
|
|
314
|
-
return
|
|
342
|
+
return _index3.SimpleObject.canChangeKey(_this2, s, {
|
|
315
343
|
useExtraProps: useExtraProps,
|
|
316
344
|
ignoreProtected: allProperties
|
|
317
345
|
});
|
|
@@ -393,16 +421,6 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
393
421
|
}, _callee6, this, [[17, 28, 31, 34]]);
|
|
394
422
|
}))).apply(this, arguments);
|
|
395
423
|
} /* --------------------------------- Getters -------------------------------- */
|
|
396
|
-
}, {
|
|
397
|
-
key: "__web_path",
|
|
398
|
-
get: function get() {
|
|
399
|
-
return this.constructor["__web_path"];
|
|
400
|
-
}
|
|
401
|
-
}, {
|
|
402
|
-
key: "__web_type",
|
|
403
|
-
get: function get() {
|
|
404
|
-
return this.constructor["__web_type"];
|
|
405
|
-
}
|
|
406
424
|
}, {
|
|
407
425
|
key: "manager",
|
|
408
426
|
get: function get() {
|
|
@@ -734,11 +752,6 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
734
752
|
}, _callee12, this);
|
|
735
753
|
}))).apply(this, arguments);
|
|
736
754
|
}
|
|
737
|
-
}, {
|
|
738
|
-
key: "get_webname",
|
|
739
|
-
value: function get_webname() {
|
|
740
|
-
return this.__web_path || this.__web_type || this.__cache_name;
|
|
741
|
-
}
|
|
742
755
|
}, {
|
|
743
756
|
key: "saveResultHasID",
|
|
744
757
|
value: function saveResultHasID(s) {
|
|
@@ -884,10 +897,8 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
884
897
|
}
|
|
885
898
|
}]);
|
|
886
899
|
return WebObject;
|
|
887
|
-
}(
|
|
900
|
+
}(_index3.SimpleObject);
|
|
888
901
|
exports.WebObject = WebObject;
|
|
889
|
-
_defineProperty(WebObject, "__web_path", "");
|
|
890
|
-
_defineProperty(WebObject, "__web_type", "");
|
|
891
902
|
_defineProperty(WebObject, "__protectedProperties", ["_users"]);
|
|
892
903
|
//you cant create a new weboject without these properties
|
|
893
904
|
_defineProperty(WebObject, "__requiredProperties", []);
|
|
@@ -5,8 +5,6 @@ import WebObject from "./WebObject";
|
|
|
5
5
|
* This class manages the events of an Simple Object
|
|
6
6
|
*/
|
|
7
7
|
export declare class WebObjectManager<T extends WebObject> extends ObjectManager<T> {
|
|
8
|
-
static readonly __web_path: string;
|
|
9
|
-
static readonly __web_type: string;
|
|
10
8
|
static readonly __save_message: boolean;
|
|
11
9
|
constructor();
|
|
12
10
|
/**
|
|
@@ -191,13 +191,13 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
|
|
|
191
191
|
key: "__web_path",
|
|
192
192
|
get: function get() {
|
|
193
193
|
var _this$obj5;
|
|
194
|
-
return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.__web_path) || this.
|
|
194
|
+
return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.__web_path) || this.__last_web_path || this.__web_type;
|
|
195
195
|
}
|
|
196
196
|
}, {
|
|
197
197
|
key: "__web_type",
|
|
198
198
|
get: function get() {
|
|
199
199
|
var _this$obj6;
|
|
200
|
-
return ((_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.__web_type) || this.
|
|
200
|
+
return ((_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.__web_type) || this.__last_web_type || "";
|
|
201
201
|
}
|
|
202
202
|
}, {
|
|
203
203
|
key: "get_webname",
|
|
@@ -372,8 +372,6 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
|
|
|
372
372
|
}(_ObjectManager2["default"]);
|
|
373
373
|
exports.WebObjectManager = WebObjectManager;
|
|
374
374
|
//we use this as backup
|
|
375
|
-
_defineProperty(WebObjectManager, "__web_path", "");
|
|
376
|
-
_defineProperty(WebObjectManager, "__web_type", "");
|
|
377
375
|
_defineProperty(WebObjectManager, "__save_message", true);
|
|
378
376
|
var _default = WebObjectManager;
|
|
379
377
|
exports["default"] = _default;
|
|
@@ -8,9 +8,11 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
8
8
|
__eventList: any;
|
|
9
9
|
__eventPrefix?: string;
|
|
10
10
|
__stopEvents?: boolean;
|
|
11
|
-
__currentObject
|
|
12
|
-
__options
|
|
11
|
+
private __currentObject?;
|
|
12
|
+
private __options?;
|
|
13
13
|
__object_nullable: boolean;
|
|
14
|
+
__last_web_path: string;
|
|
15
|
+
__last_web_type: string;
|
|
14
16
|
notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[] | undefined>;
|
|
15
17
|
get obj(): ObjType | undefined;
|
|
16
18
|
/**
|
|
@@ -33,6 +33,8 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
|
|
|
33
33
|
_defineProperty(this, "__options", void 0);
|
|
34
34
|
//can the current object be set to null safely?
|
|
35
35
|
_defineProperty(this, "__object_nullable", false);
|
|
36
|
+
_defineProperty(this, "__last_web_path", "");
|
|
37
|
+
_defineProperty(this, "__last_web_type", "");
|
|
36
38
|
_defineProperty(this, "get", this.getValue);
|
|
37
39
|
}
|
|
38
40
|
_createClass(ObjectManager, [{
|
|
@@ -90,6 +92,10 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
|
|
|
90
92
|
if (this.__currentObject) {
|
|
91
93
|
this.__currentObject.set_managerClass(this);
|
|
92
94
|
}
|
|
95
|
+
if (this.__currentObject instanceof _SimpleObject["default"]) {
|
|
96
|
+
this.__last_web_path == this.__currentObject.__web_path || this.__last_web_path;
|
|
97
|
+
this.__last_web_type == this.__currentObject.__web_type || this.__last_web_type;
|
|
98
|
+
}
|
|
93
99
|
if (toObj == null && !this.__object_nullable) {
|
|
94
100
|
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
95
101
|
}
|
|
@@ -9,6 +9,8 @@ export type WriteablePropOf<obj> = keyof obj;
|
|
|
9
9
|
export type PropType<obj, prop extends keyof obj> = obj[prop];
|
|
10
10
|
export declare class SimpleObject extends MapableObject {
|
|
11
11
|
#private;
|
|
12
|
+
static readonly __web_path: string;
|
|
13
|
+
static readonly __web_type: string;
|
|
12
14
|
static readonly __cache_name?: string;
|
|
13
15
|
static readonly __unchangeables?: string[];
|
|
14
16
|
static readonly __changeables?: string[];
|
|
@@ -38,6 +40,9 @@ export declare class SimpleObject extends MapableObject {
|
|
|
38
40
|
_index_key: string;
|
|
39
41
|
_index_value: number;
|
|
40
42
|
constructor(is_readonly?: boolean);
|
|
43
|
+
get __web_path(): string;
|
|
44
|
+
get __web_type(): string;
|
|
45
|
+
static get_webname(): string | undefined;
|
|
41
46
|
loadValues(initObject: any, fullUpdate?: boolean): boolean;
|
|
42
47
|
static loadValues(obj: SimpleObject, initObject: any, fullUpdate?: boolean): boolean;
|
|
43
48
|
static getValue<T extends SimpleObject, MKey extends PropOf<T>>(o: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
|
|
@@ -65,6 +65,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
|
|
|
65
65
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setDefaultProperty);
|
|
66
66
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setProperty);
|
|
67
67
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _getSubProperty);
|
|
68
|
+
/* -------------------------------------------------------------------------- */
|
|
68
69
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setSubProperty);
|
|
69
70
|
//an exact copy of this object is stored here
|
|
70
71
|
_defineProperty(_assertThisInitialized(_this), "__originalobject", void 0);
|
|
@@ -112,11 +113,22 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
|
|
|
112
113
|
_this.clear_changes();
|
|
113
114
|
return _this;
|
|
114
115
|
}
|
|
116
|
+
/* -------------------------------------------------------------------------- */
|
|
115
117
|
_createClass(SimpleObject, [{
|
|
116
118
|
key: "_static",
|
|
117
119
|
value: function _static() {
|
|
118
120
|
return this.constructor;
|
|
119
121
|
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "__web_path",
|
|
124
|
+
get: function get() {
|
|
125
|
+
return this.constructor["__web_path"] || this.__web_type;
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "__web_type",
|
|
129
|
+
get: function get() {
|
|
130
|
+
return this.constructor["__web_type"];
|
|
131
|
+
}
|
|
120
132
|
}, {
|
|
121
133
|
key: "loadValues",
|
|
122
134
|
value: /* -------------------------------------------------------------------------- */
|
|
@@ -880,6 +892,11 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
|
|
|
880
892
|
/* statics */
|
|
881
893
|
/* -------------------------------------------------------------------------- */
|
|
882
894
|
}], [{
|
|
895
|
+
key: "get_webname",
|
|
896
|
+
value: function get_webname() {
|
|
897
|
+
return this.__web_path || this.__web_type || this.__cache_name;
|
|
898
|
+
}
|
|
899
|
+
}, {
|
|
883
900
|
key: "loadValues",
|
|
884
901
|
value: function loadValues(obj, initObject) {
|
|
885
902
|
var fullUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -1248,6 +1265,8 @@ function _setSaveResultObject2(toObj) {
|
|
|
1248
1265
|
if (toObj == null) toObj = null; //null or undefined
|
|
1249
1266
|
this.__saveResultObject = toObj;
|
|
1250
1267
|
}
|
|
1268
|
+
_defineProperty(SimpleObject, "__web_path", "");
|
|
1269
|
+
_defineProperty(SimpleObject, "__web_type", "");
|
|
1251
1270
|
_defineProperty(SimpleObject, "__cache_name", void 0);
|
|
1252
1271
|
//these properties should not be changed and are usually set by server
|
|
1253
1272
|
_defineProperty(SimpleObject, "__unchangeables", void 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/webobject",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.79",
|
|
4
4
|
"description": "Stateful object",
|
|
5
5
|
"author": "Azrideus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@azrico/event": "^1.2.17",
|
|
76
76
|
"@azrico/global": "^1.3.50",
|
|
77
77
|
"@azrico/math": "^1.0.3",
|
|
78
|
-
"@azrico/object": "^1.4.
|
|
78
|
+
"@azrico/object": "^1.4.87",
|
|
79
79
|
"@azrico/string": "^1.2.84",
|
|
80
80
|
"@azrico/types": "^1.0.4",
|
|
81
81
|
"@azrico/uid": "^1.0.5"
|