@kosdev-code/kos-ui-sdk 3.0.21 → 3.0.22

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.
Files changed (54) hide show
  1. package/core/core/kosCore.d.ts +1 -0
  2. package/core/core/kosCore.d.ts.map +1 -1
  3. package/core/core/kosModel.d.ts +11 -0
  4. package/core/core/kosModel.d.ts.map +1 -1
  5. package/core/core/kosModelManager.d.ts +8 -0
  6. package/core/core/kosModelManager.d.ts.map +1 -1
  7. package/core/core/lifecycle/constants.d.ts +1 -1
  8. package/core/core/lifecycle/constants.d.ts.map +1 -1
  9. package/core/core/model/kos-subscription-manager.d.ts +1 -0
  10. package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
  11. package/core/core/registration/index.d.ts +1 -1
  12. package/core/core/registration/index.d.ts.map +1 -1
  13. package/core/core/registration/model-registration.d.ts +11 -0
  14. package/core/core/registration/model-registration.d.ts.map +1 -1
  15. package/core/index.d.ts +1 -1
  16. package/core/index.d.ts.map +1 -1
  17. package/core/util/kos-model-utils.d.ts +13 -0
  18. package/core/util/kos-model-utils.d.ts.map +1 -1
  19. package/{index-DUoSahlA.cjs → index-CRb8ucfF.cjs} +115 -48
  20. package/index-CRb8ucfF.cjs.map +1 -0
  21. package/{index-BUwbSjst.js → index-YzHb2lnB.js} +116 -49
  22. package/index-YzHb2lnB.js.map +1 -0
  23. package/index.cjs +113 -26
  24. package/index.cjs.map +1 -1
  25. package/index.js +114 -27
  26. package/index.js.map +1 -1
  27. package/models/decorators/kos-config-bean-prop.d.ts +5 -0
  28. package/models/decorators/kos-config-bean-prop.d.ts.map +1 -1
  29. package/models/decorators/kos-config-bean.d.ts +7 -1
  30. package/models/decorators/kos-config-bean.d.ts.map +1 -1
  31. package/models/models/config-bean/config-bean-model.d.ts +9 -0
  32. package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
  33. package/models/models/config-bean/config-bean-types.d.ts +2 -0
  34. package/models/models/config-bean/config-bean-types.d.ts.map +1 -1
  35. package/models/models/config-bean-prop/config-bean-prop-model.d.ts +3 -0
  36. package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
  37. package/models/models/config-bean-prop/types/index.d.ts +10 -0
  38. package/models/models/region-info/region-info-model.d.ts +12 -1
  39. package/models/models/region-info/region-info-model.d.ts.map +1 -1
  40. package/models/models/region-info/services/region-info-services.d.ts +2 -2
  41. package/models/models/region-info/services/region-info-services.d.ts.map +1 -1
  42. package/models/models/region-info/types/index.d.ts +7 -0
  43. package/models/models/region-info/types/index.d.ts.map +1 -1
  44. package/models/services/config-bean/index.d.ts +2 -2
  45. package/models/services/config-bean/index.d.ts.map +1 -1
  46. package/package.json +2 -2
  47. package/testing/index.d.ts +51 -9
  48. package/testing/index.d.ts.map +1 -1
  49. package/testing.cjs +57 -3
  50. package/testing.cjs.map +1 -1
  51. package/testing.js +57 -3
  52. package/testing.js.map +1 -1
  53. package/index-BUwbSjst.js.map +0 -1
  54. package/index-DUoSahlA.cjs.map +0 -1
package/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const service$8 = require("./index-DUoSahlA.cjs");
3
+ const service$8 = require("./index-CRb8ucfF.cjs");
4
4
  const mobx = require("mobx");
5
5
  const log$s = require("loglevel");
6
6
  const dateFns = require("date-fns");
@@ -1318,18 +1318,20 @@ const { postModel: postModel$5, getOne: getOne$6 } = service$8.ServiceFactory.bu
1318
1318
  destinationAddress: "",
1319
1319
  basePath: `${URL$d}/kos/config/`
1320
1320
  });
1321
- const modifyConfigBean = async (id, model, path = `/api/kos/config`) => {
1321
+ const modifyConfigBean = async (id, model, path = `/api/kos/config`, destinationAddress = "") => {
1322
1322
  log$r.debug(`sending modify request for ConfigBean: ${id}`);
1323
1323
  const response = postModel$5({
1324
1324
  model,
1325
- urlOverride: `${URL$d}${path}/${id}`
1325
+ urlOverride: `${URL$d}${path}/${id}`,
1326
+ destinationAddress
1326
1327
  });
1327
1328
  return response;
1328
1329
  };
1329
- const getConfigBean = async (id, path = `/api/kos/config`) => {
1330
+ const getConfigBean = async (id, path = `/api/kos/config`, destinationAddress = "") => {
1330
1331
  log$r.debug(`sending get request for ConfigBean: ${id}`);
1331
1332
  const response = await getOne$6({
1332
- urlOverride: `${URL$d}${path}/details/${id}/15`
1333
+ urlOverride: `${URL$d}${path}/details/${id}/15`,
1334
+ destinationAddress
1333
1335
  });
1334
1336
  return response;
1335
1337
  };
@@ -1441,6 +1443,10 @@ function matchValue(patterns, value) {
1441
1443
  const CONFIG_BEAN_MODEL_TYPE = "config-bean-model";
1442
1444
  const log$q = service$8.KosLog.getLogger(CONFIG_BEAN_MODEL_TYPE);
1443
1445
  const PATH_PROP$3 = createPropKey("path");
1446
+ const DESTINATION_PROP$2 = createPropKey("destinationAddress");
1447
+ function configBeanModelId(path, destinationAddress) {
1448
+ return destinationAddress ? `${CONFIG_BEAN_MODEL_TYPE}-${destinationAddress}-${path}` : `${CONFIG_BEAN_MODEL_TYPE}-${path}`;
1449
+ }
1444
1450
  function servicePathMapper$1(configBeanModel) {
1445
1451
  const hasMapper = service$8.ExtensionManager.propertyMapper.hasMapper(
1446
1452
  KosCoreModelPropertyMapper.ConfigServicePath
@@ -1470,6 +1476,8 @@ let ConfigBeanModelImpl = class {
1470
1476
  prevProps;
1471
1477
  /** Optional custom base path for configuration service endpoints */
1472
1478
  serviceBasePath;
1479
+ /** Connection the bean's requests and topic subscription are routed to */
1480
+ destinationAddress;
1473
1481
  /**
1474
1482
  * @category Constructor
1475
1483
  *
@@ -1484,6 +1492,7 @@ let ConfigBeanModelImpl = class {
1484
1492
  this.id = modelId;
1485
1493
  this.path = options.path;
1486
1494
  this.serviceBasePath = options.serviceBasePath || servicePathMapper$1(this);
1495
+ this.destinationAddress = options.destinationAddress;
1487
1496
  const {
1488
1497
  modifyConfigBean: modifyConfigBean$1 = modifyConfigBean,
1489
1498
  getConfigBean: getConfigBean$1 = getConfigBean
@@ -1525,7 +1534,11 @@ let ConfigBeanModelImpl = class {
1525
1534
  */
1526
1535
  async load() {
1527
1536
  log$q.debug(`loading config bean ${this.path}`);
1528
- const response = await this._getConfigBean(this.path, this.serviceBasePath);
1537
+ const response = await this._getConfigBean(
1538
+ this.path,
1539
+ this.serviceBasePath,
1540
+ this.destinationAddress
1541
+ );
1529
1542
  if (response?.data) {
1530
1543
  const data = response.data;
1531
1544
  mapDtoToConfigBeanModel(data, this);
@@ -1603,7 +1616,12 @@ let ConfigBeanModelImpl = class {
1603
1616
  */
1604
1617
  async updateConfigBean() {
1605
1618
  const request = mapConfigBeanModelToDto(this);
1606
- await this._modifyConfigBean(this.path, request, this.serviceBasePath);
1619
+ await this._modifyConfigBean(
1620
+ this.path,
1621
+ request,
1622
+ this.serviceBasePath,
1623
+ this.destinationAddress
1624
+ );
1607
1625
  }
1608
1626
  handleConfigBeanUpdated(configBean) {
1609
1627
  mapUpdateDtoToConfigBeanModel(configBean, this);
@@ -1612,7 +1630,9 @@ let ConfigBeanModelImpl = class {
1612
1630
  __decorateClass$A([
1613
1631
  service$8.kosTopicHandler({
1614
1632
  topic: `/kos/config/${PATH_PROP$3}`,
1615
- websocket: true
1633
+ websocket: true,
1634
+ destinationAddress: DESTINATION_PROP$2,
1635
+ explicitDestination: true
1616
1636
  })
1617
1637
  ], ConfigBeanModelImpl.prototype, "handleConfigBeanUpdated", 1);
1618
1638
  ConfigBeanModelImpl = __decorateClass$A([
@@ -1622,14 +1642,15 @@ const ConfigBean = new service$8.KosModelRegistrationFactory({
1622
1642
  class: ConfigBeanModelImpl,
1623
1643
  type: CONFIG_BEAN_MODEL_TYPE
1624
1644
  });
1625
- const kosConfigBean = ({ path, lazy, serviceBasePath }) => (target, name) => {
1645
+ const kosConfigBean = ({ path, lazy, serviceBasePath, destinationAddress }) => (target, name) => {
1626
1646
  target[service$8.DependencyModels] = target[service$8.DependencyModels] || {};
1627
1647
  target[service$8.DependencyModels][name] = {
1628
1648
  modelType: ConfigBean.type,
1629
- id: `${ConfigBean.type}-${path}`,
1649
+ id: configBeanModelId(path, destinationAddress),
1630
1650
  options: {
1631
1651
  path,
1632
- serviceBasePath
1652
+ serviceBasePath,
1653
+ destinationAddress
1633
1654
  },
1634
1655
  lifecycle: service$8.DependencyLifecycle.INIT,
1635
1656
  lazy
@@ -1639,20 +1660,22 @@ const { URL: URL$c } = service$8.resolveServiceUrl();
1639
1660
  const { getOne: getOne$5, getAll: getAll$7 } = service$8.ServiceFactory.build({
1640
1661
  basePath: `${URL$c}/api/kos/regions/info`
1641
1662
  });
1642
- const getRegionInfo = async (baseServicePath) => {
1663
+ const getRegionInfo = async (baseServicePath, destinationAddress = "") => {
1643
1664
  try {
1644
1665
  const response = await getOne$5({
1645
- urlOverride: `${URL$c}${baseServicePath}/info`
1666
+ urlOverride: `${URL$c}${baseServicePath}/info`,
1667
+ destinationAddress
1646
1668
  });
1647
1669
  return response;
1648
1670
  } catch (error) {
1649
1671
  return void 0;
1650
1672
  }
1651
1673
  };
1652
- const getRegions = async (baseServicePath) => {
1674
+ const getRegions = async (baseServicePath, destinationAddress = "") => {
1653
1675
  try {
1654
1676
  const response = await getAll$7({
1655
- urlOverride: `${URL$c}${baseServicePath}`
1677
+ urlOverride: `${URL$c}${baseServicePath}`,
1678
+ destinationAddress
1656
1679
  });
1657
1680
  return response;
1658
1681
  } catch (error) {
@@ -1807,12 +1830,28 @@ function servicePathMapper(regionInfoModel) {
1807
1830
  }
1808
1831
  return "/api/kos/regions";
1809
1832
  }
1833
+ const REGION_SETTINGS_PATH$2 = "kos:service:region:settings";
1834
+ const REGION_PATH$2 = "kos:service:region";
1835
+ const DESTINATION_PROP$1 = createPropKey("destinationAddress");
1836
+ const REGION_SETTINGS_BEAN_ID_PROP = createPropKey(
1837
+ "regionSettingsBeanId"
1838
+ );
1839
+ const REGION_BEAN_ID_PROP = createPropKey("regionBeanId");
1840
+ function regionInfoModelId(destinationAddress) {
1841
+ return destinationAddress ? `${MODEL_TYPE$w}-${destinationAddress}` : MODEL_TYPE$w;
1842
+ }
1810
1843
  let RegionInfoModelImpl = class {
1811
1844
  id;
1812
1845
  unitSystemMap;
1813
1846
  measureMap;
1814
1847
  defaultMeasureMap;
1815
1848
  serviceBasePath;
1849
+ /** Connection the region services and beans are routed to */
1850
+ destinationAddress;
1851
+ // An unset destination must keep the legacy bean ids, and a dependency id
1852
+ // template cannot drop a segment, so the bean ids are computed per instance.
1853
+ regionSettingsBeanId;
1854
+ regionBeanId;
1816
1855
  regionMap;
1817
1856
  timeFormats;
1818
1857
  dateFormats;
@@ -1821,8 +1860,14 @@ let RegionInfoModelImpl = class {
1821
1860
  region;
1822
1861
  regions = [];
1823
1862
  timeZoneMap = {};
1824
- constructor(modelId) {
1863
+ constructor(modelId, options) {
1825
1864
  this.id = modelId;
1865
+ this.destinationAddress = options?.destinationAddress;
1866
+ this.regionSettingsBeanId = configBeanModelId(
1867
+ REGION_SETTINGS_PATH$2,
1868
+ this.destinationAddress
1869
+ );
1870
+ this.regionBeanId = configBeanModelId(REGION_PATH$2, this.destinationAddress);
1826
1871
  this.serviceBasePath = servicePathMapper(this);
1827
1872
  this.unitSystems = {};
1828
1873
  this.unitSystemMap = {};
@@ -2123,7 +2168,10 @@ let RegionInfoModelImpl = class {
2123
2168
  */
2124
2169
  async load() {
2125
2170
  log$p.debug("loading region info");
2126
- const regions = await getRegions(this.serviceBasePath);
2171
+ const regions = await getRegions(
2172
+ this.serviceBasePath,
2173
+ this.destinationAddress
2174
+ );
2127
2175
  if (regions) {
2128
2176
  this.regions = regions.data.map((region) => region.id);
2129
2177
  this.timeZoneMap = regions.data.reduce((acc, region) => {
@@ -2133,7 +2181,10 @@ let RegionInfoModelImpl = class {
2133
2181
  return { ...acc, [region.id]: region };
2134
2182
  }, {});
2135
2183
  }
2136
- const regionInfo = await getRegionInfo(this.serviceBasePath);
2184
+ const regionInfo = await getRegionInfo(
2185
+ this.serviceBasePath,
2186
+ this.destinationAddress
2187
+ );
2137
2188
  if (regionInfo) {
2138
2189
  this.unitSystems = regionInfo.data.unitSystems.reduce((acc, curr) => {
2139
2190
  const unitSystem = {
@@ -2177,10 +2228,21 @@ let RegionInfoModelImpl = class {
2177
2228
  }
2178
2229
  };
2179
2230
  __decorateClass$z([
2180
- kosConfigBean({ path: "kos:service:region:settings" })
2231
+ kosDependency({
2232
+ modelType: ConfigBean.type,
2233
+ id: REGION_SETTINGS_BEAN_ID_PROP,
2234
+ options: {
2235
+ path: REGION_SETTINGS_PATH$2,
2236
+ destinationAddress: DESTINATION_PROP$1
2237
+ }
2238
+ })
2181
2239
  ], RegionInfoModelImpl.prototype, "regionSource", 2);
2182
2240
  __decorateClass$z([
2183
- kosConfigBean({ path: "kos:service:region" })
2241
+ kosDependency({
2242
+ modelType: ConfigBean.type,
2243
+ id: REGION_BEAN_ID_PROP,
2244
+ options: { path: REGION_PATH$2, destinationAddress: DESTINATION_PROP$1 }
2245
+ })
2184
2246
  ], RegionInfoModelImpl.prototype, "region", 2);
2185
2247
  RegionInfoModelImpl = __decorateClass$z([
2186
2248
  service$8.kosModel(MODEL_TYPE$w)
@@ -2189,7 +2251,7 @@ const Registration$1 = {
2189
2251
  registration: {
2190
2252
  [MODEL_TYPE$w]: {
2191
2253
  class: RegionInfoModelImpl,
2192
- singleton: true
2254
+ singleton: false
2193
2255
  }
2194
2256
  },
2195
2257
  type: MODEL_TYPE$w,
@@ -2445,6 +2507,9 @@ const MODEL_TYPE$v = "config-bean-prop-model";
2445
2507
  const log$o = service$8.KosLog.createLogger({ name: "config-bean-prop-model" });
2446
2508
  const PATH_PROP$2 = createPropKey("path");
2447
2509
  const SERVICE_PATH_PROP = createPropKey("serviceBasePath");
2510
+ const DESTINATION_PROP = createPropKey("destinationAddress");
2511
+ const BEAN_ID_PROP = createPropKey("configBeanId");
2512
+ const REGION_INFO_ID_PROP = createPropKey("regionInfoId");
2448
2513
  let KosConfigPropertyImpl = class {
2449
2514
  id;
2450
2515
  path;
@@ -2453,6 +2518,11 @@ let KosConfigPropertyImpl = class {
2453
2518
  formatter;
2454
2519
  optionsExpander;
2455
2520
  serviceBasePath;
2521
+ destinationAddress;
2522
+ // An unset destination must keep the legacy bean id, and a dependency id
2523
+ // template cannot drop a segment, so the bean id is computed per instance.
2524
+ configBeanId;
2525
+ regionInfoId;
2456
2526
  regionInfo;
2457
2527
  bean;
2458
2528
  constructor(modelId, options) {
@@ -2462,7 +2532,10 @@ let KosConfigPropertyImpl = class {
2462
2532
  this.converter = options.converter;
2463
2533
  this.formatter = options.formatter;
2464
2534
  this.serviceBasePath = options.serviceBasePath;
2535
+ this.destinationAddress = options.destinationAddress;
2465
2536
  this.optionsExpander = options.optionsExpander;
2537
+ this.configBeanId = configBeanModelId(this.path, this.destinationAddress);
2538
+ this.regionInfoId = regionInfoModelId(this.destinationAddress);
2466
2539
  }
2467
2540
  // -------------------LIFECYCLE----------------------------
2468
2541
  /**
@@ -2895,10 +2968,22 @@ let KosConfigPropertyImpl = class {
2895
2968
  }
2896
2969
  };
2897
2970
  __decorateClass$y([
2898
- kosDependency({ modelType: Registration$1.type })
2971
+ kosDependency({
2972
+ modelType: Registration$1.type,
2973
+ id: REGION_INFO_ID_PROP,
2974
+ options: { destinationAddress: DESTINATION_PROP }
2975
+ })
2899
2976
  ], KosConfigPropertyImpl.prototype, "regionInfo", 2);
2900
2977
  __decorateClass$y([
2901
- kosConfigBean({ path: PATH_PROP$2, serviceBasePath: SERVICE_PATH_PROP })
2978
+ kosDependency({
2979
+ modelType: ConfigBean.type,
2980
+ id: BEAN_ID_PROP,
2981
+ options: {
2982
+ path: PATH_PROP$2,
2983
+ serviceBasePath: SERVICE_PATH_PROP,
2984
+ destinationAddress: DESTINATION_PROP
2985
+ }
2986
+ })
2902
2987
  ], KosConfigPropertyImpl.prototype, "bean", 2);
2903
2988
  KosConfigPropertyImpl = __decorateClass$y([
2904
2989
  service$8.kosModel(MODEL_TYPE$v)
@@ -2923,7 +3008,8 @@ function kosConfigProperty(params2) {
2923
3008
  formatter: formatter2,
2924
3009
  lazy,
2925
3010
  optionsExpander,
2926
- serviceBasePath
3011
+ serviceBasePath,
3012
+ destinationAddress
2927
3013
  } = params2;
2928
3014
  const _converter = converter;
2929
3015
  if (_converter) {
@@ -2938,11 +3024,12 @@ function kosConfigProperty(params2) {
2938
3024
  target[service$8.DependencyModels] = target[service$8.DependencyModels] || {};
2939
3025
  target[service$8.DependencyModels][name] = {
2940
3026
  modelType: Registration.type,
2941
- id: `${path}-${attribute}`,
3027
+ id: destinationAddress ? `${destinationAddress}-${path}-${attribute}` : `${path}-${attribute}`,
2942
3028
  options: {
2943
3029
  path,
2944
3030
  attribute,
2945
3031
  serviceBasePath,
3032
+ destinationAddress,
2946
3033
  converter: _converter,
2947
3034
  formatter: formatter2,
2948
3035
  optionsExpander
@@ -12180,7 +12267,7 @@ const updateRegion = async (region) => {
12180
12267
  regionInfo.updateProperty(region);
12181
12268
  };
12182
12269
  async function getKosServiceApi() {
12183
- const { default: API } = await Promise.resolve().then(() => require("./index-DUoSahlA.cjs")).then((n) => n.service);
12270
+ const { default: API } = await Promise.resolve().then(() => require("./index-CRb8ucfF.cjs")).then((n) => n.service);
12184
12271
  return API;
12185
12272
  }
12186
12273
  function kosServiceRequest$7(params2) {