@azrico/webobject 1.5.10 → 1.5.12

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.
@@ -7,23 +7,31 @@ export type saveType = "normal" | "quick";
7
7
  export type sendChangesType = boolean | "auto";
8
8
  export type WithManager<T extends SimpleObject> = Ensure<T, "manager">;
9
9
  export type WithManagerOrNot<T extends SimpleObject> = T | WithManager<T>;
10
- type getKeysProps = {
11
- useExtraProps?: boolean;
12
- ignoreProtected?: boolean;
10
+ export type deltaParams = {
11
+ type?: string;
12
+ useDelta?: boolean;
13
+ isChild?: boolean;
14
+ allProperties?: boolean;
15
+ extraProperties?: boolean;
16
+ tempProperties?: boolean;
17
+ bypassProtected?: boolean;
18
+ needId?: boolean;
19
+ applyFilter?: boolean;
13
20
  };
14
21
  export declare class SimpleObject extends MapableObject {
15
22
  #private;
16
23
  static readonly __db_name: string;
17
24
  static readonly __object_name: string;
18
- static readonly __unchangeables?: string[];
19
- static readonly __changeables?: string[];
20
- static readonly __protectedProperties?: string[];
21
- static readonly __functionProperties?: string[];
25
+ static readonly __unchangeables: string[];
26
+ static readonly __changeables: string[];
27
+ static readonly __extraProperties: string[];
28
+ static readonly __tempProperties: string[];
29
+ static readonly __protectedProperties: string[];
30
+ static readonly __functionProperties: string[];
22
31
  static readonly __formatList?: formatObject;
23
- static readonly __extraProperties?: string[];
24
32
  static readonly __childTypes?: any[];
25
33
  static readonly __importColumns?: string[];
26
- static readonly __checkProperties?: string[];
34
+ static readonly __checkProperties: string[];
27
35
  static readonly __use_delta: boolean;
28
36
  _static(): Function;
29
37
  protected __originalobject?: this;
@@ -158,7 +166,13 @@ export declare class SimpleObject extends MapableObject {
158
166
  * @returns true if manager was notified. false otherwise
159
167
  */
160
168
  notifyChanged<MKey extends PropOf<this>>(type: string, key: MKey | string, value: any, subvalue?: any): Promise<false | any[] | undefined>;
161
- static getChangeableKeys(object: SimpleObject, options: getKeysProps): any[];
169
+ /**
170
+ * get a list of all keys that can be changed in given objcet
171
+ * @param object
172
+ * @param options
173
+ * @returns
174
+ */
175
+ static getChangeableKeys(object: SimpleObject, options: deltaParams): any[];
162
176
  /**
163
177
  * check if a key can be changed on an object
164
178
  * @param object the object we are checking
@@ -166,7 +180,7 @@ export declare class SimpleObject extends MapableObject {
166
180
  * @param useExtraProps should we check extra props?
167
181
  * @returns
168
182
  */
169
- static canChangeKey(object: SimpleObject, key: string, options: getKeysProps): boolean;
183
+ static canChangeKey(object: SimpleObject, key: string, options: deltaParams): boolean;
170
184
  static hasIllegalChanges(referenceObject: any, changesObject: any, updaterUser: any): boolean;
171
185
  /**
172
186
  * Apply all the changes and empty the delta object
@@ -707,7 +707,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
707
707
  return _notifyChanged.apply(this, arguments);
708
708
  }
709
709
  return notifyChanged;
710
- }())
710
+ }()
711
+ /**
712
+ * get a list of all keys that can be changed in given objcet
713
+ * @param object
714
+ * @param options
715
+ * @returns
716
+ */
717
+ )
711
718
  }, {
712
719
  key: "apply_changes",
713
720
  value: /* -------------------------------------------------------------------------- */
@@ -1270,26 +1277,26 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
1270
1277
  }, {
1271
1278
  key: "getChangeableKeys",
1272
1279
  value: function getChangeableKeys(object, options) {
1273
- var _key_list2;
1280
+ var _key_list;
1274
1281
  if (!object) return [];
1275
- var useExtraProps = options.useExtraProps,
1276
- ignoreProtected = options.ignoreProtected;
1277
1282
  var key_list = [];
1278
- if (useExtraProps) {
1279
- var _key_list;
1280
- var __extraProperties = object.constructor["__extraProperties"];
1281
- if (!(0, _object.array_isEmpty)(__extraProperties)) (_key_list = key_list).push.apply(_key_list, _toConsumableArray(__extraProperties));
1282
- }
1283
- /* -------------------------------------------------------------------------- */
1284
- var __changeables = object.constructor["__changeables"];
1285
- if (!(0, _object.array_isEmpty)(__changeables)) (_key_list2 = key_list).push.apply(_key_list2, _toConsumableArray(__changeables));
1283
+ (_key_list = key_list).push.apply(_key_list, _toConsumableArray(object.constructor["__changeables"]));
1286
1284
  var __unchangeables = object.constructor["__unchangeables"];
1287
1285
  if (!(0, _object.array_isEmpty)(__unchangeables)) {
1288
1286
  key_list = key_list.filter(function (s) {
1289
1287
  return !__unchangeables.includes(s);
1290
1288
  });
1291
1289
  }
1292
- if (ignoreProtected !== true) {
1290
+ /* -------------------------------------------------------------------------- */
1291
+ if (options.extraProperties) {
1292
+ var _key_list2;
1293
+ (_key_list2 = key_list).push.apply(_key_list2, _toConsumableArray(object.constructor["__extraProperties"]));
1294
+ }
1295
+ if (options.tempProperties) {
1296
+ var _key_list3;
1297
+ (_key_list3 = key_list).push.apply(_key_list3, _toConsumableArray(object.constructor["__tempProperties"]));
1298
+ }
1299
+ if (options.bypassProtected !== true && !options.allProperties) {
1293
1300
  var __protectedProperties = object.constructor["__protectedProperties"];
1294
1301
  //protected keys can only be changed by the creator of this object
1295
1302
  //make sure you set the is_current_user function correctly
@@ -1314,36 +1321,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
1314
1321
  if (!object || !key) return false;
1315
1322
  var keys = this.getChangeableKeys(object, options);
1316
1323
  return keys.includes(key);
1317
- // const {useExtraProps, ignoreProtected} = options;
1318
- // if (useExtraProps) {
1319
- // const __extraProperties = object.constructor["__extraProperties"];
1320
- // if (__extraProperties != null && __extraProperties.includes(key))
1321
- // return true;
1322
- // }
1323
- // /* -------------------------------------------------------------------------- */
1324
- // const __changeables = object.constructor["__changeables"];
1325
- // const __unchangeables = object.constructor["__unchangeables"];
1326
- // /* -------------------------------------------------------------------------- */
1327
- // if (__changeables != null && !__changeables.includes(key)) return false;
1328
- // if (__unchangeables != null && __unchangeables.includes(key))
1329
- // return false;
1330
- // if (ignoreProtected !== true) {
1331
- // const __protectedProperties =
1332
- // object.constructor["__protectedProperties"];
1333
- // if (
1334
- // __protectedProperties != null &&
1335
- // __protectedProperties.includes(key)
1336
- // ) {
1337
- // //protected keys can only be changed by the creator of this object
1338
- // //make sure you set the is_current_user function correctly
1339
- // if (object.isNew) return true;
1340
- // const creatorOfObject = (object as any).get("_creator");
1341
- // return Boolean(
1342
- // gfunc.run_action_sync("is_current_user", creatorOfObject),
1343
- // );
1344
- // }
1345
- // }
1346
- // return true;
1347
1324
  }
1348
1325
  }, {
1349
1326
  key: "hasIllegalChanges",
@@ -1690,22 +1667,24 @@ function _setSaveResultObject(toObj) {
1690
1667
  _defineProperty(SimpleObject, "__db_name", "");
1691
1668
  _defineProperty(SimpleObject, "__object_name", "");
1692
1669
  //these properties should not be changed and are usually set by server
1693
- _defineProperty(SimpleObject, "__unchangeables", void 0);
1670
+ _defineProperty(SimpleObject, "__unchangeables", []);
1694
1671
  //these properties can be directly changed and are included in deltaObject
1695
- _defineProperty(SimpleObject, "__changeables", void 0);
1672
+ _defineProperty(SimpleObject, "__changeables", []);
1673
+ //these properties usually are not directly changed and sometimes are included in deltaObject
1674
+ _defineProperty(SimpleObject, "__extraProperties", []);
1675
+ //these properties are never sent to database but may be sent to client
1676
+ _defineProperty(SimpleObject, "__tempProperties", []);
1696
1677
  //these properties can only be changed by the _creator
1697
- _defineProperty(SimpleObject, "__protectedProperties", void 0);
1678
+ _defineProperty(SimpleObject, "__protectedProperties", []);
1698
1679
  //these properties will be evaluated when needed
1699
- _defineProperty(SimpleObject, "__functionProperties", void 0);
1680
+ _defineProperty(SimpleObject, "__functionProperties", []);
1700
1681
  //apply these string formats
1701
1682
  _defineProperty(SimpleObject, "__formatList", void 0);
1702
- //these properties usually are not directly changed and sometimes are included in deltaObject
1703
- _defineProperty(SimpleObject, "__extraProperties", void 0);
1704
1683
  //types for children can be used when importing children
1705
1684
  _defineProperty(SimpleObject, "__childTypes", void 0);
1706
1685
  //these fields are used when importing
1707
1686
  _defineProperty(SimpleObject, "__importColumns", void 0);
1708
1687
  //these fields can be used when importing and checking if an item exists
1709
- _defineProperty(SimpleObject, "__checkProperties", void 0);
1688
+ _defineProperty(SimpleObject, "__checkProperties", []);
1710
1689
  _defineProperty(SimpleObject, "__use_delta", true);
1711
1690
  var _default = exports["default"] = SimpleObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",