@azrico/webobject 1.4.142 → 1.4.144

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.
@@ -1,5 +1,6 @@
1
+ import { AnyClassType } from "@azrico/types";
1
2
  import WebObject from "./WebObject";
2
- type PathFunction<T> = string | ((w: T) => string);
3
+ type PathFunction<T extends AnyClassType> = string | ((w: InstanceType<T>) => string);
3
4
  export declare class WebObjectPathHelper {
4
5
  static readonly defaultPaths: {
5
6
  lock: string;
@@ -23,6 +24,6 @@ export declare class WebObjectPathHelper {
23
24
  * @param override
24
25
  * @returns
25
26
  */
26
- static override_path<T>(obj: T | string, pn: string, override: PathFunction<T>): Promise<false | PathFunction<T>>;
27
+ static override_path<T extends AnyClassType>(obj: T | InstanceType<T> | string, pn: string, override: PathFunction<T>): Promise<false | PathFunction<T>>;
27
28
  }
28
29
  export default WebObjectPathHelper;
@@ -94,6 +94,7 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
94
94
  case 0:
95
95
  pn = String(pn).toLowerCase();
96
96
  wn = "";
97
+ /* ------------------------------ find webname ------------------------------ */
97
98
  if (typeof obj === "string") {
98
99
  wn = obj;
99
100
  } else if (typeof obj.get_webname === "function") {
@@ -109,6 +110,7 @@ var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function ()
109
110
  console.error("[override_path]", "bad webname");
110
111
  return _context3.abrupt("return", false);
111
112
  case 6:
113
+ /* --------------------------- apply the override --------------------------- */
112
114
  if (!WebObjectPathHelper.pathOverrides[wn]) WebObjectPathHelper.pathOverrides[wn] = {};
113
115
  WebObjectPathHelper.pathOverrides[wn][pn] = override;
114
116
  return _context3.abrupt("return", override);
@@ -1138,6 +1138,9 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
1138
1138
  }
1139
1139
  }
1140
1140
  }
1141
+ /* ---------------------- try to parse id from objectId --------------------- */
1142
+ if (obj["_id"] != null && _typeof(obj["_id"]) === "object" && obj["_id"]["$oid"]) obj["_id"] = obj["_id"]["$oid"];
1143
+ /* -------------------------------------------------------------------------- */
1141
1144
  return true;
1142
1145
  }
1143
1146
  /* -------------------------------------------------------------------------- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.142",
3
+ "version": "1.4.144",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",