@next-core/brick-kit 2.124.0 → 2.126.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,42 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.126.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.125.0...@next-core/brick-kit@2.126.0) (2022-08-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * make loose dependency on backend runtime api ([6474f53](https://github.com/easyops-cn/next-core/commit/6474f53687ae514e79c88780810d98e887045c32))
12
+
13
+
14
+ ### Features
15
+
16
+ * **runtime:** support runtime FLAGS and MISC on standalone mode ([131cdbc](https://github.com/easyops-cn/next-core/commit/131cdbc46eb609722719091a202c3364053bfc84))
17
+ * support userConfig & injectMenus in standalone mode ([cd890ed](https://github.com/easyops-cn/next-core/commit/cd890edf01b12c18a771d677106de74ca4e837be))
18
+
19
+
20
+
21
+
22
+
23
+ # [2.125.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.124.1...@next-core/brick-kit@2.125.0) (2022-08-08)
24
+
25
+
26
+ ### Features
27
+
28
+ * support INSTALLED_APPS in standalone mode ([c152053](https://github.com/easyops-cn/next-core/commit/c1520532597c88d1def251aafd44831c7a7fad56))
29
+
30
+
31
+
32
+
33
+
34
+ ## [2.124.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.124.0...@next-core/brick-kit@2.124.1) (2022-08-03)
35
+
36
+ **Note:** Version bump only for package @next-core/brick-kit
37
+
38
+
39
+
40
+
41
+
6
42
  # [2.124.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.123.8...@next-core/brick-kit@2.124.0) (2022-08-01)
7
43
 
8
44
 
@@ -2923,7 +2923,7 @@
2923
2923
  }
2924
2924
 
2925
2925
  var _excluded$6 = ["children"],
2926
- _excluded2$1 = ["items", "app"];
2926
+ _excluded2$2 = ["items", "app"];
2927
2927
  var symbolAppId = Symbol("appId");
2928
2928
  // Caching menu requests to avoid flicker.
2929
2929
  var menuCache = new Map();
@@ -3107,7 +3107,7 @@
3107
3107
  items,
3108
3108
  app
3109
3109
  } = _yield$fetchMenuById,
3110
- restMenuData = _objectWithoutProperties__default["default"](_yield$fetchMenuById, _excluded2$1);
3110
+ restMenuData = _objectWithoutProperties__default["default"](_yield$fetchMenuById, _excluded2$2);
3111
3111
 
3112
3112
  var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, yield computeRealValueWithOverrideApp(restMenuData, app[0].appId, context, kernel)), {}, {
3113
3113
  items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
@@ -3495,7 +3495,8 @@
3495
3495
  }
3496
3496
 
3497
3497
  hasInstalledApp(appId, matchVersion) {
3498
- return kernel.bootstrapData.microApps.some(app => {
3498
+ var allMicroApps = window.STANDALONE_MICRO_APPS ? kernel.bootstrapData.offSiteStandaloneApps : kernel.bootstrapData.microApps;
3499
+ return allMicroApps.some(app => {
3499
3500
  var foundApp = app.id === appId && app.installStatus !== "running";
3500
3501
 
3501
3502
  if (!matchVersion || !foundApp) {
@@ -5793,6 +5794,24 @@
5793
5794
  timeoutIdList.clear();
5794
5795
  }
5795
5796
 
5797
+ /**
5798
+ * @description 独立小产品Runtime接口
5799
+ * @endpoint GET /api/v1/runtime_standalone
5800
+ */
5801
+
5802
+
5803
+ var BootstrapStandaloneApi_runtimeStandalone = /*#__PURE__*/function () {
5804
+ var _ref = _asyncToGenerator__default["default"](function* (options) {
5805
+ return (
5806
+ /**! @contract easyops.api.api_gateway.bootstrap_standalone.RuntimeStandalone@1.0.1 */
5807
+ (yield brickHttp.http.get("api/v1/runtime_standalone", options)).data
5808
+ );
5809
+ });
5810
+
5811
+ return function BootstrapStandaloneApi_runtimeStandalone(_x) {
5812
+ return _ref.apply(this, arguments);
5813
+ };
5814
+ }();
5796
5815
  /**
5797
5816
  * @description 获取系统初始化信息
5798
5817
  * @endpoint GET /api/auth/v2/bootstrap
@@ -6885,6 +6904,43 @@
6885
6904
  };
6886
6905
  }();
6887
6906
 
6907
+ /**
6908
+ * @description 独立小产品Runtime接口
6909
+ * @endpoint GET /api/v1/micro_app_standalone/runtime/:appId
6910
+ */
6911
+
6912
+
6913
+ var RuntimeApi_runtimeMicroAppStandalone = /*#__PURE__*/function () {
6914
+ var _ref = _asyncToGenerator__default["default"](function* (appId, options) {
6915
+ return (
6916
+ /**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */
6917
+ (yield brickHttp.http.get("api/gateway/micro_app_standalone.runtime.RuntimeMicroAppStandalone/api/v1/micro_app_standalone/runtime/".concat(appId), options)).data
6918
+ );
6919
+ });
6920
+
6921
+ return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2) {
6922
+ return _ref.apply(this, arguments);
6923
+ };
6924
+ }();
6925
+ /**
6926
+ * @description 查询独立部署小产品
6927
+ * @endpoint POST /api/v1/micro_app_standalone/search
6928
+ */
6929
+
6930
+
6931
+ var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
6932
+ var _ref = _asyncToGenerator__default["default"](function* (data, options) {
6933
+ return (
6934
+ /**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */
6935
+ (yield brickHttp.http.post("api/gateway/micro_app_standalone.runtime.SearchMicroAppStandalone/api/v1/micro_app_standalone/search", data, options)).data
6936
+ );
6937
+ });
6938
+
6939
+ return function RuntimeApi_searchMicroAppStandalone(_x, _x2) {
6940
+ return _ref.apply(this, arguments);
6941
+ };
6942
+ }();
6943
+
6888
6944
  /**
6889
6945
  * Merge `app.defaultConfig` and `app.userConfig` to `app.config`.
6890
6946
  *
@@ -7077,15 +7133,21 @@
7077
7133
  }
7078
7134
  }
7079
7135
 
7080
- var _excluded$4 = ["feature_flags"];
7136
+ var _excluded$4 = ["feature_flags"],
7137
+ _excluded2$1 = ["featureFlags", "misc"];
7081
7138
  function standaloneBootstrap() {
7082
7139
  return _standaloneBootstrap.apply(this, arguments);
7083
7140
  }
7084
7141
 
7085
7142
  function _standaloneBootstrap() {
7086
7143
  _standaloneBootstrap = _asyncToGenerator__default["default"](function* () {
7087
- var [bootstrapResult, confString] = yield Promise.all([brickHttp.http.get(window.BOOTSTRAP_FILE), brickHttp.http.get("".concat(window.APP_ROOT, "conf.yaml"), {
7144
+ var [bootstrapResult, confString, runtimeData] = yield Promise.all([brickHttp.http.get(window.BOOTSTRAP_FILE), brickHttp.http.get("".concat(window.APP_ROOT, "conf.yaml"), {
7088
7145
  responseType: "text"
7146
+ }), yield BootstrapStandaloneApi_runtimeStandalone().catch(function (error) {
7147
+ // make it not crash when the backend service is not updated.
7148
+ // eslint-disable-next-line no-console
7149
+ console.warn("request runtime api from api-gateway failed: ", error, ", something might went wrong running standalone micro app");
7150
+ return undefined;
7089
7151
  })]);
7090
7152
  var conf;
7091
7153
 
@@ -7133,6 +7195,24 @@
7133
7195
  }
7134
7196
  }
7135
7197
 
7198
+ if (runtimeData) {
7199
+ var runtimeSetings = runtimeData.settings;
7200
+
7201
+ if (!_.isEmpty(runtimeSetings)) {
7202
+ // Merge Feature Flags
7203
+ if (!settings) {
7204
+ settings = runtimeSetings;
7205
+ } else {
7206
+ // Merge Feature Flags & Misc
7207
+ var rest = _objectWithoutProperties__default["default"](runtimeSetings, _excluded2$1);
7208
+
7209
+ settings.featureFlags = _objectSpread__default["default"](_objectSpread__default["default"]({}, settings.featureFlags), runtimeSetings.featureFlags);
7210
+ settings.misc = _objectSpread__default["default"](_objectSpread__default["default"]({}, settings.misc), runtimeSetings.misc);
7211
+ settings = Object.assign(settings, rest);
7212
+ }
7213
+ }
7214
+ }
7215
+
7136
7216
  return _objectSpread__default["default"](_objectSpread__default["default"]({}, bootstrapResult), {}, {
7137
7217
  settings
7138
7218
  });
@@ -8854,6 +8934,27 @@
8854
8934
  Object.assign(storyboard, {
8855
8935
  $$fulfilled: true
8856
8936
  });
8937
+
8938
+ if (!window.NO_AUTH_GUARD) {
8939
+ var appRuntimeData;
8940
+
8941
+ try {
8942
+ appRuntimeData = yield RuntimeApi_runtimeMicroAppStandalone(storyboard.app.id);
8943
+ } catch (error) {
8944
+ // make it not crash when the backend service is not updated.
8945
+ // eslint-disable-next-line no-console
8946
+ console.warn("request standalone runtime api from micro-app-standalone failed: ", error, ", something might went wrong running standalone micro app");
8947
+ }
8948
+
8949
+ if (appRuntimeData) {
8950
+ // merge user config
8951
+ storyboard.app.userConfig = _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard.app.userConfig), appRuntimeData.userConfig); // get inject menus (Actually, appRuntimeData contains both main and inject menus)
8952
+
8953
+ storyboard.meta = _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard.meta), {}, {
8954
+ injectMenus: appRuntimeData.injectMenus
8955
+ });
8956
+ }
8957
+ }
8857
8958
  } else {
8858
8959
  var {
8859
8960
  routes,
@@ -9368,15 +9469,20 @@
9368
9469
  }
9369
9470
 
9370
9471
  getStandaloneMenus(menuId) {
9371
- var _cloneDeep, _currentStoryboard$me;
9472
+ var _currentStoryboard$me, _currentStoryboard$me2;
9372
9473
 
9373
9474
  var currentAppId = this.currentApp.id;
9374
9475
  var currentStoryboard = this.bootstrapData.storyboards.find(storyboard => storyboard.app.id === currentAppId);
9375
- return ((_cloneDeep = _.cloneDeep((_currentStoryboard$me = currentStoryboard.meta) === null || _currentStoryboard$me === void 0 ? void 0 : _currentStoryboard$me.menus)) !== null && _cloneDeep !== void 0 ? _cloneDeep : []).filter(menu => menu.menuId === menuId).map(menu => _objectSpread__default["default"](_objectSpread__default["default"]({}, menu), {}, {
9376
- app: [{
9377
- appId: currentAppId
9378
- }]
9379
- }));
9476
+ var menus = (_currentStoryboard$me = currentStoryboard.meta) !== null && _currentStoryboard$me !== void 0 && _currentStoryboard$me.injectMenus ? _.cloneDeep(currentStoryboard.meta.injectMenus) : (_currentStoryboard$me2 = currentStoryboard.meta) !== null && _currentStoryboard$me2 !== void 0 && _currentStoryboard$me2.menus ? _.cloneDeep(currentStoryboard.meta.menus) : [];
9477
+ return menus.filter(menu => menu.menuId === menuId).map(menu => {
9478
+ var _menu$app;
9479
+
9480
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, menu), (_menu$app = menu.app) !== null && _menu$app !== void 0 && _menu$app.length && menu.app[0].appId ? {} : {
9481
+ app: [{
9482
+ appId: currentAppId
9483
+ }]
9484
+ });
9485
+ });
9380
9486
  }
9381
9487
 
9382
9488
  getProviderBrick(provider) {
@@ -9917,6 +10023,7 @@
9917
10023
  break;
9918
10024
 
9919
10025
  case "IP":
10026
+ /* eslint-disable */
9920
10027
  defaultValue = {
9921
10028
  brick: "forms.general-input",
9922
10029
  properties: {
@@ -9926,9 +10033,14 @@
9926
10033
  readOnly: field.limit.includes("READONLY"),
9927
10034
  required: field.limit.includes("REQUIRED"),
9928
10035
  placeholder: field.description,
9929
- pattern: /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9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|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$))",
10037
+ message: {
10038
+ pattern: "输入字符不匹配IP格式"
10039
+ }
9930
10040
  }
9931
10041
  };
10042
+ /* eslint-disable */
10043
+
9932
10044
  break;
9933
10045
 
9934
10046
  case "JSON":
@@ -11328,6 +11440,69 @@
11328
11440
  });
11329
11441
  }
11330
11442
 
11443
+ var standaloneApps = [];
11444
+ var appIdSet = new Set();
11445
+ function preFetchStandaloneInstalledApps(_x) {
11446
+ return _preFetchStandaloneInstalledApps.apply(this, arguments);
11447
+ }
11448
+
11449
+ function _preFetchStandaloneInstalledApps() {
11450
+ _preFetchStandaloneInstalledApps = _asyncToGenerator__default["default"](function* (storyboard) {
11451
+ var saIds = brickUtils.scanInstalledAppsInStoryboard(storyboard);
11452
+ yield fetchStandaloneApps(saIds);
11453
+ });
11454
+ return _preFetchStandaloneInstalledApps.apply(this, arguments);
11455
+ }
11456
+
11457
+ function fetchStandaloneApps(_x2) {
11458
+ return _fetchStandaloneApps.apply(this, arguments);
11459
+ }
11460
+
11461
+ function _fetchStandaloneApps() {
11462
+ _fetchStandaloneApps = _asyncToGenerator__default["default"](function* (saIds) {
11463
+ // ignore apps which are already searched
11464
+ var searchIds = _.difference(saIds, Array.from(appIdSet));
11465
+
11466
+ if (searchIds.length === 0) {
11467
+ return;
11468
+ }
11469
+
11470
+ try {
11471
+ var result = yield RuntimeApi_searchMicroAppStandalone({
11472
+ query: {
11473
+ isActiveVersion: true,
11474
+ appId: {
11475
+ $in: searchIds
11476
+ }
11477
+ },
11478
+ fields: ["appId", "version"]
11479
+ });
11480
+
11481
+ for (var item of result.list) {
11482
+ standaloneApps.push({
11483
+ id: item.appId,
11484
+ currentVersion: item.version,
11485
+ installStatus: "ok"
11486
+ });
11487
+ }
11488
+
11489
+ for (var id of searchIds) {
11490
+ appIdSet.add(id);
11491
+ }
11492
+ } catch (error) {
11493
+ // Allow search micro app to fail, and
11494
+ // make it not crash when the backend service is not updated.
11495
+ // eslint-disable-next-line no-console
11496
+ console.error("get off site standalone micro app failed", error);
11497
+ }
11498
+ });
11499
+ return _fetchStandaloneApps.apply(this, arguments);
11500
+ }
11501
+
11502
+ function getStandaloneInstalledApps() {
11503
+ return standaloneApps;
11504
+ }
11505
+
11331
11506
  class Router {
11332
11507
  constructor(kernel) {
11333
11508
  _defineProperty__default["default"](this, "defaultCollapsed", false);
@@ -11525,6 +11700,13 @@
11525
11700
 
11526
11701
  if (isLoggedIn() && !getAuth().isAdmin) {
11527
11702
  yield preCheckPermissions(storyboard);
11703
+ } // Standalone App 需要额外读取 Installed App 信息
11704
+
11705
+
11706
+ if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
11707
+ // TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
11708
+ yield preFetchStandaloneInstalledApps(storyboard);
11709
+ _this3.kernel.bootstrapData.offSiteStandaloneApps = getStandaloneInstalledApps();
11528
11710
  } // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
11529
11711
 
11530
11712