@ibiz-template/model-helper 0.7.12-alpha.0 → 0.7.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.
package/dist/index.esm.js CHANGED
@@ -15823,15 +15823,13 @@ import_pluralize.default.addPluralRule(/(matr|vert|ind)ix|ex$/, "$1ices");
15823
15823
  function plural(key) {
15824
15824
  return (0, import_pluralize.default)(key);
15825
15825
  }
15826
- function pluralLower(key) {
15827
- return plural(key).toLowerCase();
15828
- }
15829
15826
 
15830
15827
  // src/utils/service-path-util/service-path-util.ts
15831
15828
  var ServicePathUtil = class {
15832
- constructor(appDataEntities, allDERss) {
15829
+ constructor(appDataEntities, allDERss, modelUtil) {
15833
15830
  this.appDataEntities = appDataEntities;
15834
15831
  this.allDERss = allDERss;
15832
+ this.modelUtil = modelUtil;
15835
15833
  /**
15836
15834
  * 应用实体关系
15837
15835
  *
@@ -15883,8 +15881,8 @@ var ServicePathUtil = class {
15883
15881
  * @param {string} id
15884
15882
  * @return {*} {string[]}
15885
15883
  */
15886
- calcRequestPaths(id) {
15887
- const paths = this.calcPaths(id);
15884
+ async calcRequestPaths(id) {
15885
+ const paths = await this.calcPaths(id);
15888
15886
  return paths.map((path) => {
15889
15887
  return path.map((item) => "".concat(item.plural, "/${").concat(item.lower, "}")).join("/");
15890
15888
  });
@@ -15898,7 +15896,7 @@ var ServicePathUtil = class {
15898
15896
  * @param {string} id
15899
15897
  * @return {*} {ServicePathItem[][]} 返回顺序为 [祖父实体,爷爷实体,父实体,当前实体]
15900
15898
  */
15901
- calcPaths(id) {
15899
+ async calcPaths(id) {
15902
15900
  const entityRef = this.appDataEntities.find((item) => item.id === id);
15903
15901
  if (!entityRef) {
15904
15902
  throw new Error("\u672A\u627E\u5230\u5B9E\u4F53 ".concat(id));
@@ -15911,7 +15909,7 @@ var ServicePathUtil = class {
15911
15909
  if (deRss) {
15912
15910
  const ids = [id];
15913
15911
  const arr = this.calcDeepPath(ids, deRss);
15914
- this.deepFillPath(codeName, [codeName], arr);
15912
+ await this.deepFillPath(codeName, [codeName], arr);
15915
15913
  let paths = this.entityRsPathMap.get(codeName);
15916
15914
  if (paths) {
15917
15915
  paths = this.sortPath(paths);
@@ -15966,11 +15964,12 @@ var ServicePathUtil = class {
15966
15964
  * @param {string[]} pathNames
15967
15965
  * @param {ServicePathDeep[]} items
15968
15966
  */
15969
- deepFillPath(deCodeName, pathNames, items) {
15970
- items.forEach((item) => {
15967
+ async deepFillPath(deCodeName, pathNames, items) {
15968
+ for (let i = 0; i < items.length; i++) {
15969
+ const item = items[i];
15971
15970
  const [rs, children] = item;
15972
15971
  if (children.length > 0) {
15973
- this.deepFillPath(
15972
+ await this.deepFillPath(
15974
15973
  deCodeName,
15975
15974
  [...pathNames, rs.majorDECodeName],
15976
15975
  children
@@ -15980,23 +15979,27 @@ var ServicePathUtil = class {
15980
15979
  this.entityRsPathMap.set(deCodeName, []);
15981
15980
  }
15982
15981
  const arr = this.entityRsPathMap.get(deCodeName);
15982
+ const serviceApiItems = await this.getServiceApiItems(pathNames);
15983
+ const rsServiceApiItems = await this.getServiceApiItems([
15984
+ rs.majorDECodeName
15985
+ ]);
15983
15986
  arr.push(
15984
15987
  [
15985
- ...pathNames.map((pathName) => {
15988
+ ...pathNames.map((pathName, index) => {
15986
15989
  return {
15987
15990
  codeName: pathName,
15988
15991
  lower: pathName.toLowerCase(),
15989
- plural: pluralLower(pathName)
15992
+ plural: serviceApiItems[index].deApiCodeName2
15990
15993
  };
15991
15994
  }),
15992
15995
  {
15993
15996
  codeName: rs.majorDECodeName,
15994
15997
  lower: rs.majorDECodeName.toLowerCase(),
15995
- plural: pluralLower(rs.majorDECodeName)
15998
+ plural: rsServiceApiItems[0].deApiCodeName2
15996
15999
  }
15997
16000
  ].reverse()
15998
16001
  );
15999
- });
16002
+ }
16000
16003
  }
16001
16004
  /**
16002
16005
  * 排序资源路径顺序
@@ -16012,6 +16015,40 @@ var ServicePathUtil = class {
16012
16015
  return b.length - a.length;
16013
16016
  });
16014
16017
  }
16018
+ /**
16019
+ * 通过codeName数据获取相关接口标识数据
16020
+ *
16021
+ * @author tony001
16022
+ * @date 2024-05-11 17:05:51
16023
+ * @protected
16024
+ * @param {string[]} codeNames
16025
+ * @return {*} {Promise<ServiceApiItem[]>}
16026
+ */
16027
+ async getServiceApiItems(codeNames) {
16028
+ const serviceApiItems = [];
16029
+ for (let i = 0; i < codeNames.length; i++) {
16030
+ const appEntity = await this.modelUtil.getAppDataEntityModel(
16031
+ codeNames[i],
16032
+ false
16033
+ );
16034
+ const serviceApiItem = {
16035
+ codeName: codeNames[i],
16036
+ deApiCodeName: appEntity.dEAPICodeName,
16037
+ deApiCodeName2: ""
16038
+ };
16039
+ if (appEntity.dEAPICodeName) {
16040
+ if (!appEntity.deapicodeName2) {
16041
+ serviceApiItem.deApiCodeName2 = plural(appEntity.dEAPICodeName);
16042
+ }
16043
+ const { engineVer } = await this.modelUtil.getAppModel();
16044
+ if (!engineVer || engineVer < 240) {
16045
+ serviceApiItem.deApiCodeName2 = appEntity.deapicodeName2.toLowerCase();
16046
+ }
16047
+ }
16048
+ serviceApiItems.push(serviceApiItem);
16049
+ }
16050
+ return serviceApiItems;
16051
+ }
16015
16052
  };
16016
16053
 
16017
16054
  // src/utils/merge-model/merge-app-menu.ts
@@ -16182,7 +16219,8 @@ var ModelUtil = class {
16182
16219
  });
16183
16220
  this.servicePathUtil = new ServicePathUtil(
16184
16221
  allDataEntities,
16185
- allAppDERSs
16222
+ allAppDERSs,
16223
+ this
16186
16224
  );
16187
16225
  if (this.appModel.getAllPSAppLans && this.appModel.getAllPSAppLans.length > 0) {
16188
16226
  ibiz.env.isEnableMultiLan = true;
@@ -16672,7 +16710,7 @@ var ModelHelper = class {
16672
16710
  const util = this.getModelUtil(appId);
16673
16711
  const model = await util.getAppDataEntityModel(name, isId, true);
16674
16712
  const dsl = this.dsl.appDataEntity(model);
16675
- const list = util.servicePathUtil.calcRequestPaths(dsl.id);
16713
+ const list = await util.servicePathUtil.calcRequestPaths(dsl.id);
16676
16714
  dsl.requestPaths = list;
16677
16715
  dsl.codeName2 = plural(dsl.codeName.toLowerCase());
16678
16716
  if (dsl.deapicodeName) {