@ibiz-template/model-helper 0.5.1 → 0.5.2

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/index.esm.js CHANGED
@@ -4451,8 +4451,8 @@ function deepUpdateAppId(appId, model) {
4451
4451
  });
4452
4452
  } else {
4453
4453
  model.appId = appId;
4454
- const keys = Object.keys(model);
4455
- keys.forEach((key) => {
4454
+ const keys4 = Object.keys(model);
4455
+ keys4.forEach((key) => {
4456
4456
  const val = model[key];
4457
4457
  deepUpdateAppId(appId, val);
4458
4458
  });
@@ -15114,15 +15114,6 @@ var DSLHelper = class {
15114
15114
  }
15115
15115
  };
15116
15116
 
15117
- // src/utils/format-path/format-path.ts
15118
- function formatPath(path) {
15119
- if ((path == null ? void 0 : path.indexOf("PSSYSAPPS/")) === 0) {
15120
- const pos = path.indexOf("/");
15121
- return path.substring(path.indexOf("/", pos + 1));
15122
- }
15123
- return path;
15124
- }
15125
-
15126
15117
  // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isPlaceholder.js
15127
15118
  function _isPlaceholder(a) {
15128
15119
  return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
@@ -15195,16 +15186,266 @@ function _curry3(fn) {
15195
15186
  };
15196
15187
  }
15197
15188
 
15189
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isArray.js
15190
+ var isArray_default = Array.isArray || function _isArray(val) {
15191
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
15192
+ };
15193
+
15194
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_arrayFromIterator.js
15195
+ function _arrayFromIterator(iter) {
15196
+ var list = [];
15197
+ var next;
15198
+ while (!(next = iter.next()).done) {
15199
+ list.push(next.value);
15200
+ }
15201
+ return list;
15202
+ }
15203
+
15204
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_includesWith.js
15205
+ function _includesWith(pred, x, list) {
15206
+ var idx = 0;
15207
+ var len = list.length;
15208
+ while (idx < len) {
15209
+ if (pred(x, list[idx])) {
15210
+ return true;
15211
+ }
15212
+ idx += 1;
15213
+ }
15214
+ return false;
15215
+ }
15216
+
15217
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_functionName.js
15218
+ function _functionName(f) {
15219
+ var match = String(f).match(/^function (\w*)/);
15220
+ return match == null ? "" : match[1];
15221
+ }
15222
+
15198
15223
  // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_has.js
15199
15224
  function _has(prop, obj) {
15200
15225
  return Object.prototype.hasOwnProperty.call(obj, prop);
15201
15226
  }
15202
15227
 
15228
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_objectIs.js
15229
+ function _objectIs(a, b) {
15230
+ if (a === b) {
15231
+ return a !== 0 || 1 / a === 1 / b;
15232
+ } else {
15233
+ return a !== a && b !== b;
15234
+ }
15235
+ }
15236
+ var objectIs_default = typeof Object.is === "function" ? Object.is : _objectIs;
15237
+
15238
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isArguments.js
15239
+ var toString = Object.prototype.toString;
15240
+ var _isArguments = /* @__PURE__ */ function() {
15241
+ return toString.call(arguments) === "[object Arguments]" ? function _isArguments2(x) {
15242
+ return toString.call(x) === "[object Arguments]";
15243
+ } : function _isArguments2(x) {
15244
+ return _has("callee", x);
15245
+ };
15246
+ }();
15247
+ var isArguments_default = _isArguments;
15248
+
15249
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/keys.js
15250
+ var hasEnumBug = !/* @__PURE__ */ {
15251
+ toString: null
15252
+ }.propertyIsEnumerable("toString");
15253
+ var nonEnumerableProps = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"];
15254
+ var hasArgsEnumBug = /* @__PURE__ */ function() {
15255
+ "use strict";
15256
+ return arguments.propertyIsEnumerable("length");
15257
+ }();
15258
+ var contains = function contains2(list, item) {
15259
+ var idx = 0;
15260
+ while (idx < list.length) {
15261
+ if (list[idx] === item) {
15262
+ return true;
15263
+ }
15264
+ idx += 1;
15265
+ }
15266
+ return false;
15267
+ };
15268
+ var keys = typeof Object.keys === "function" && !hasArgsEnumBug ? /* @__PURE__ */ _curry1(function keys2(obj) {
15269
+ return Object(obj) !== obj ? [] : Object.keys(obj);
15270
+ }) : /* @__PURE__ */ _curry1(function keys3(obj) {
15271
+ if (Object(obj) !== obj) {
15272
+ return [];
15273
+ }
15274
+ var prop, nIdx;
15275
+ var ks = [];
15276
+ var checkArgsLength = hasArgsEnumBug && isArguments_default(obj);
15277
+ for (prop in obj) {
15278
+ if (_has(prop, obj) && (!checkArgsLength || prop !== "length")) {
15279
+ ks[ks.length] = prop;
15280
+ }
15281
+ }
15282
+ if (hasEnumBug) {
15283
+ nIdx = nonEnumerableProps.length - 1;
15284
+ while (nIdx >= 0) {
15285
+ prop = nonEnumerableProps[nIdx];
15286
+ if (_has(prop, obj) && !contains(ks, prop)) {
15287
+ ks[ks.length] = prop;
15288
+ }
15289
+ nIdx -= 1;
15290
+ }
15291
+ }
15292
+ return ks;
15293
+ });
15294
+ var keys_default = keys;
15295
+
15296
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/type.js
15297
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
15298
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
15299
+ });
15300
+ var type_default = type;
15301
+
15302
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_equals.js
15303
+ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
15304
+ var a = _arrayFromIterator(aIterator);
15305
+ var b = _arrayFromIterator(bIterator);
15306
+ function eq(_a, _b) {
15307
+ return _equals(_a, _b, stackA.slice(), stackB.slice());
15308
+ }
15309
+ return !_includesWith(function(b2, aItem) {
15310
+ return !_includesWith(eq, aItem, b2);
15311
+ }, b, a);
15312
+ }
15313
+ function _equals(a, b, stackA, stackB) {
15314
+ if (objectIs_default(a, b)) {
15315
+ return true;
15316
+ }
15317
+ var typeA = type_default(a);
15318
+ if (typeA !== type_default(b)) {
15319
+ return false;
15320
+ }
15321
+ if (typeof a["fantasy-land/equals"] === "function" || typeof b["fantasy-land/equals"] === "function") {
15322
+ return typeof a["fantasy-land/equals"] === "function" && a["fantasy-land/equals"](b) && typeof b["fantasy-land/equals"] === "function" && b["fantasy-land/equals"](a);
15323
+ }
15324
+ if (typeof a.equals === "function" || typeof b.equals === "function") {
15325
+ return typeof a.equals === "function" && a.equals(b) && typeof b.equals === "function" && b.equals(a);
15326
+ }
15327
+ switch (typeA) {
15328
+ case "Arguments":
15329
+ case "Array":
15330
+ case "Object":
15331
+ if (typeof a.constructor === "function" && _functionName(a.constructor) === "Promise") {
15332
+ return a === b;
15333
+ }
15334
+ break;
15335
+ case "Boolean":
15336
+ case "Number":
15337
+ case "String":
15338
+ if (!(typeof a === typeof b && objectIs_default(a.valueOf(), b.valueOf()))) {
15339
+ return false;
15340
+ }
15341
+ break;
15342
+ case "Date":
15343
+ if (!objectIs_default(a.valueOf(), b.valueOf())) {
15344
+ return false;
15345
+ }
15346
+ break;
15347
+ case "Error":
15348
+ return a.name === b.name && a.message === b.message;
15349
+ case "RegExp":
15350
+ if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
15351
+ return false;
15352
+ }
15353
+ break;
15354
+ }
15355
+ var idx = stackA.length - 1;
15356
+ while (idx >= 0) {
15357
+ if (stackA[idx] === a) {
15358
+ return stackB[idx] === b;
15359
+ }
15360
+ idx -= 1;
15361
+ }
15362
+ switch (typeA) {
15363
+ case "Map":
15364
+ if (a.size !== b.size) {
15365
+ return false;
15366
+ }
15367
+ return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
15368
+ case "Set":
15369
+ if (a.size !== b.size) {
15370
+ return false;
15371
+ }
15372
+ return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
15373
+ case "Arguments":
15374
+ case "Array":
15375
+ case "Object":
15376
+ case "Boolean":
15377
+ case "Number":
15378
+ case "String":
15379
+ case "Date":
15380
+ case "Error":
15381
+ case "RegExp":
15382
+ case "Int8Array":
15383
+ case "Uint8Array":
15384
+ case "Uint8ClampedArray":
15385
+ case "Int16Array":
15386
+ case "Uint16Array":
15387
+ case "Int32Array":
15388
+ case "Uint32Array":
15389
+ case "Float32Array":
15390
+ case "Float64Array":
15391
+ case "ArrayBuffer":
15392
+ break;
15393
+ default:
15394
+ return false;
15395
+ }
15396
+ var keysA = keys_default(a);
15397
+ if (keysA.length !== keys_default(b).length) {
15398
+ return false;
15399
+ }
15400
+ var extendedStackA = stackA.concat([a]);
15401
+ var extendedStackB = stackB.concat([b]);
15402
+ idx = keysA.length - 1;
15403
+ while (idx >= 0) {
15404
+ var key = keysA[idx];
15405
+ if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
15406
+ return false;
15407
+ }
15408
+ idx -= 1;
15409
+ }
15410
+ return true;
15411
+ }
15412
+
15413
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/equals.js
15414
+ var equals = /* @__PURE__ */ _curry2(function equals2(a, b) {
15415
+ return _equals(a, b, [], []);
15416
+ });
15417
+ var equals_default = equals;
15418
+
15203
15419
  // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isObject.js
15204
15420
  function _isObject(x) {
15205
15421
  return Object.prototype.toString.call(x) === "[object Object]";
15206
15422
  }
15207
15423
 
15424
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isString.js
15425
+ function _isString(x) {
15426
+ return Object.prototype.toString.call(x) === "[object String]";
15427
+ }
15428
+
15429
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isTypedArray.js
15430
+ function _isTypedArray(val) {
15431
+ var type3 = Object.prototype.toString.call(val);
15432
+ return type3 === "[object Uint8ClampedArray]" || type3 === "[object Int8Array]" || type3 === "[object Uint8Array]" || type3 === "[object Int16Array]" || type3 === "[object Uint16Array]" || type3 === "[object Int32Array]" || type3 === "[object Uint32Array]" || type3 === "[object Float32Array]" || type3 === "[object Float64Array]" || type3 === "[object BigInt64Array]" || type3 === "[object BigUint64Array]";
15433
+ }
15434
+
15435
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/empty.js
15436
+ var empty = /* @__PURE__ */ _curry1(function empty2(x) {
15437
+ return x != null && typeof x["fantasy-land/empty"] === "function" ? x["fantasy-land/empty"]() : x != null && x.constructor != null && typeof x.constructor["fantasy-land/empty"] === "function" ? x.constructor["fantasy-land/empty"]() : x != null && typeof x.empty === "function" ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === "function" ? x.constructor.empty() : isArray_default(x) ? [] : _isString(x) ? "" : _isObject(x) ? {} : isArguments_default(x) ? /* @__PURE__ */ function() {
15438
+ return arguments;
15439
+ }() : _isTypedArray(x) ? x.constructor.from("") : void 0;
15440
+ });
15441
+ var empty_default = empty;
15442
+
15443
+ // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/isEmpty.js
15444
+ var isEmpty = /* @__PURE__ */ _curry1(function isEmpty2(x) {
15445
+ return x != null && equals_default(x, empty_default(x));
15446
+ });
15447
+ var isEmpty_default = isEmpty;
15448
+
15208
15449
  // ../../node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/mergeWithKey.js
15209
15450
  var mergeWithKey = /* @__PURE__ */ _curry3(function mergeWithKey2(fn, l, r) {
15210
15451
  var result = {};
@@ -15245,6 +15486,15 @@ var mergeDeepLeft = /* @__PURE__ */ _curry2(function mergeDeepLeft2(lObj, rObj)
15245
15486
  });
15246
15487
  var mergeDeepLeft_default = mergeDeepLeft;
15247
15488
 
15489
+ // src/utils/format-path/format-path.ts
15490
+ function formatPath(path) {
15491
+ if ((path == null ? void 0 : path.indexOf("PSSYSAPPS/")) === 0) {
15492
+ const pos = path.indexOf("/");
15493
+ return path.substring(path.indexOf("/", pos + 1));
15494
+ }
15495
+ return path;
15496
+ }
15497
+
15248
15498
  // src/utils/merge-model/merge-model.ts
15249
15499
  function mergeModel(models, m, tag) {
15250
15500
  models.forEach((model) => {
@@ -15531,7 +15781,7 @@ var ModelUtil = class {
15531
15781
  * @date 2023-04-13 21:04:21
15532
15782
  * @param {string}appId 应用标识
15533
15783
  * @param {string} modelTag
15534
- * @param {(url: string) => Promise<IModel>} get 模型加载方法
15784
+ * @param {(url: string, params?: IParams) => Promise<IModel>} get 模型加载方法
15535
15785
  * @param {boolean} hub 是否为 hub 应用基座
15536
15786
  */
15537
15787
  constructor(appId, modelTag, get, hub, permission = true) {
@@ -15704,15 +15954,15 @@ var ModelUtil = class {
15704
15954
  throw new Error("\u5E94\u7528[".concat(this.appId, "]\u672A\u627E\u5230\u6570\u636E\u5B9E\u4F53[").concat(tag, "]"));
15705
15955
  }
15706
15956
  /**
15707
- * 根据应用视图 codeName 获取应用视图模型
15957
+ * 根据应用视图 id 获取应用视图模型,如果给了 params 则每次都会重新加载模型
15708
15958
  *
15709
15959
  * @author chitanda
15710
- * @date 2023-04-16 18:04:00
15960
+ * @date 2024-01-08 11:01:39
15711
15961
  * @param {string} tag
15712
- * @param {boolean} [ignoreCase=false]
15962
+ * @param {IParams} [params]
15713
15963
  * @return {*} {Promise<IModel>}
15714
15964
  */
15715
- async getAppViewModel(tag) {
15965
+ async getAppViewModel(tag, params) {
15716
15966
  const allViews = this.appModel.getAllPSAppViews;
15717
15967
  if (allViews && allViews.length > 0) {
15718
15968
  const lowerTag = tag.toLowerCase();
@@ -15721,7 +15971,7 @@ var ModelUtil = class {
15721
15971
  (v) => v.id.endsWith(exTag) || v.id === lowerTag
15722
15972
  );
15723
15973
  if (view) {
15724
- return this.getModel(view.path);
15974
+ return this.getModel(view.path, params);
15725
15975
  }
15726
15976
  }
15727
15977
  throw new Error("\u5E94\u7528[".concat(this.appId, "]\u672A\u627E\u5230\u89C6\u56FE[").concat(tag, "]"));
@@ -15764,25 +16014,29 @@ var ModelUtil = class {
15764
16014
  return this.get(url);
15765
16015
  }
15766
16016
  /**
15767
- * 获取模型
16017
+ * 加载模型,如果给了 params 则不会缓存模型
15768
16018
  *
15769
16019
  * @author chitanda
15770
- * @date 2023-04-16 16:04:10
16020
+ * @date 2024-01-08 11:01:41
15771
16021
  * @param {string} modelPath
16022
+ * @param {IParams} [params]
15772
16023
  * @return {*} {Promise<IModel>}
15773
16024
  */
15774
- async getModel(modelPath) {
16025
+ async getModel(modelPath, params) {
15775
16026
  let url;
15776
16027
  if (this.hub) {
15777
16028
  url = this.calcAppPath(modelPath);
15778
16029
  } else {
15779
16030
  url = this.calcSubAppPath(modelPath);
15780
16031
  }
15781
- if (this.modelCache.has(url)) {
16032
+ const isParams = params && !isEmpty_default(params);
16033
+ if (this.modelCache.has(url) && !isParams) {
15782
16034
  return this.modelCache.get(url);
15783
16035
  }
15784
- const model = await this.get(url);
15785
- this.modelCache.set(url, model);
16036
+ const model = await this.get(url, params);
16037
+ if (!isParams) {
16038
+ this.modelCache.set(url, model);
16039
+ }
15786
16040
  this.deepFillAppId(model);
15787
16041
  return model;
15788
16042
  }
@@ -15796,8 +16050,8 @@ var ModelUtil = class {
15796
16050
  */
15797
16051
  deepFillAppId(model) {
15798
16052
  model.appId = this.appId;
15799
- const keys = Object.keys(model);
15800
- keys.forEach((key) => {
16053
+ const keys4 = Object.keys(model);
16054
+ keys4.forEach((key) => {
15801
16055
  const value = model[key];
15802
16056
  if (value && typeof value === "object") {
15803
16057
  if (Array.isArray(value)) {
@@ -15861,6 +16115,9 @@ var ModelLoader = class {
15861
16115
  getAppStyle(appId) {
15862
16116
  return this.helper.getAppStyle(appId);
15863
16117
  }
16118
+ loadAppView(appId, viewId, params) {
16119
+ return this.helper.loadAppViewModel(viewId, params, appId);
16120
+ }
15864
16121
  };
15865
16122
 
15866
16123
  // src/model-helper.ts
@@ -15868,8 +16125,8 @@ var ModelHelper = class {
15868
16125
  /**
15869
16126
  * Creates an instance of ModelHelper.
15870
16127
  * @author chitanda
15871
- * @date 2023-04-16 17:04:01
15872
- * @param {(url: string) => Promise<IModel>} getModel 模型加载方法
16128
+ * @date 2024-01-08 10:01:20
16129
+ * @param {(url: string, params?: IParams) => Promise<IModel>} getModel 模型加载方法
15873
16130
  * @param {string} defaultAppId 默认应用标识
15874
16131
  * @param {boolean} [permission=true] 是否启用权限
15875
16132
  */
@@ -16086,6 +16343,24 @@ var ModelHelper = class {
16086
16343
  this.calcAppViewSubAppModel(dsl);
16087
16344
  return dsl;
16088
16345
  }
16346
+ /**
16347
+ * 根据路径和参数加载应用视图模型,主要用于后台根据运行时参数重新计算视图模型
16348
+ *
16349
+ * @author chitanda
16350
+ * @date 2024-01-08 10:01:43
16351
+ * @param {string} viewId
16352
+ * @param {IParams} [params]
16353
+ * @param {string} [appId]
16354
+ * @return {*} {Promise<IAppView>}
16355
+ */
16356
+ async loadAppViewModel(viewId, params, appId) {
16357
+ const model = await this.getModelUtil(appId).getAppViewModel(
16358
+ viewId,
16359
+ params
16360
+ );
16361
+ const dsl = this.dsl.appView(model);
16362
+ return dsl;
16363
+ }
16089
16364
  /**
16090
16365
  * 获取应用多语言模型
16091
16366
  *