@azrico/webobject 1.4.6 → 1.4.8
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.
|
@@ -90,12 +90,13 @@ export declare class SimpleObject extends MapableObject {
|
|
|
90
90
|
notifyChanged<MKey extends PropOf<this>>(type: string, key: MKey | string, value: any, subvalue?: any): Promise<void>;
|
|
91
91
|
/**
|
|
92
92
|
* check if a key can be changed on an object
|
|
93
|
-
* @param object
|
|
94
|
-
* @param key
|
|
95
|
-
* @param useExtraProps
|
|
93
|
+
* @param object the object we are checking
|
|
94
|
+
* @param key key of the object
|
|
95
|
+
* @param useExtraProps should we check extra props?
|
|
96
96
|
* @returns
|
|
97
97
|
*/
|
|
98
|
-
static canChangeKey(object: SimpleObject, key: string, useExtraProps: boolean):
|
|
98
|
+
static canChangeKey(object: SimpleObject, key: string, useExtraProps: boolean): boolean;
|
|
99
|
+
static hasIllegalChanges(referenceObject: any, changesObject: any, userObject: any): boolean;
|
|
99
100
|
/**
|
|
100
101
|
* Apply the changes and empty the delta object
|
|
101
102
|
*/
|
|
@@ -163,7 +164,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
163
164
|
* and its type
|
|
164
165
|
* @param toObj
|
|
165
166
|
*/
|
|
166
|
-
setSaveResult(toObj: any, type
|
|
167
|
+
setSaveResult(toObj: any, type?: saveResultType | "auto"): void;
|
|
167
168
|
getSaveResult(original?: boolean): any;
|
|
168
169
|
getSaveResultType(): saveResultType;
|
|
169
170
|
static factoryClear(obj: SimpleObject): void;
|
|
@@ -458,9 +458,9 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
458
458
|
}()
|
|
459
459
|
/**
|
|
460
460
|
* check if a key can be changed on an object
|
|
461
|
-
* @param object
|
|
462
|
-
* @param key
|
|
463
|
-
* @param useExtraProps
|
|
461
|
+
* @param object the object we are checking
|
|
462
|
+
* @param key key of the object
|
|
463
|
+
* @param useExtraProps should we check extra props?
|
|
464
464
|
* @returns
|
|
465
465
|
*/
|
|
466
466
|
}, {
|
|
@@ -775,7 +775,8 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
775
775
|
* and its type
|
|
776
776
|
* @param toObj
|
|
777
777
|
*/
|
|
778
|
-
function setSaveResult(toObj
|
|
778
|
+
function setSaveResult(toObj) {
|
|
779
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "auto";
|
|
779
780
|
if (toObj != null) {
|
|
780
781
|
_classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
|
|
781
782
|
} else {
|
|
@@ -853,10 +854,24 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
853
854
|
if (__changeables != null && !__changeables.includes(key)) return false;
|
|
854
855
|
if (__unchangeables != null && __unchangeables.includes(key)) return false;
|
|
855
856
|
//protected keys can only be changed by the creator of this object
|
|
857
|
+
//make sure you set the is_current_user function correctly
|
|
856
858
|
if (__protectedProperties != null && __protectedProperties.includes(key)) {
|
|
857
859
|
if (object.isNew) return true;
|
|
858
860
|
var creatorOfObject = object.get("_creator");
|
|
859
|
-
return _global.gfunc.run_action_sync("is_current_user", creatorOfObject);
|
|
861
|
+
return Boolean(_global.gfunc.run_action_sync("is_current_user", creatorOfObject));
|
|
862
|
+
}
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
}, {
|
|
866
|
+
key: "hasIllegalChanges",
|
|
867
|
+
value: function hasIllegalChanges(referenceObject, changesObject, userObject) {
|
|
868
|
+
var __protectedProperties = (0, _object.object_getStatic)(referenceObject, "__protectedProperties");
|
|
869
|
+
if (__protectedProperties == null) return false;
|
|
870
|
+
if (Boolean(_global.gfunc.run_action_sync("is_current_user", userObject || changesObject.__user || changesObject._creator))) return false;
|
|
871
|
+
for (var key in changesObject) {
|
|
872
|
+
if (__protectedProperties.includes(key)) {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
860
875
|
}
|
|
861
876
|
return true;
|
|
862
877
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/webobject",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"description": "Stateful object",
|
|
5
5
|
"author": "Azrideus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"lodash.clonedeep": "*"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@azrico/event": "^1",
|
|
73
|
-
"@azrico/global": "^1",
|
|
74
|
-
"@azrico/object": "^1.4.
|
|
75
|
-
"@azrico/string": "^1",
|
|
76
|
-
"@azrico/uid": "^1"
|
|
72
|
+
"@azrico/event": "^1.2.15",
|
|
73
|
+
"@azrico/global": "^1.3.17",
|
|
74
|
+
"@azrico/object": "^1.4.33",
|
|
75
|
+
"@azrico/string": "^1.2.30",
|
|
76
|
+
"@azrico/uid": "^1.0.5"
|
|
77
77
|
}
|
|
78
78
|
}
|