@next-core/brick-kit 2.101.1 → 2.103.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,59 @@
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.103.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.102.1...@next-core/brick-kit@2.103.0) (2022-01-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * refine theme ([7d6480b](https://github.com/easyops-cn/next-core/commit/7d6480bffd738676a0c04865991c6cad796b7379))
12
+
13
+
14
+ ### Features
15
+
16
+ * add button style ([ebf1377](https://github.com/easyops-cn/next-core/commit/ebf1377805306600dbf96a6c05164f295d04f9af))
17
+ * chart style ([8d3f04b](https://github.com/easyops-cn/next-core/commit/8d3f04b342f79f62c65696ef82337b06d881aafd))
18
+
19
+
20
+
21
+
22
+
23
+ ## [2.102.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.102.0...@next-core/brick-kit@2.102.1) (2022-01-12)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * do not redirect to login page while NO_AUTH_GUARD is enabled ([02b69b1](https://github.com/easyops-cn/next-core/commit/02b69b19b98b1ba4aa4e0d2405d28444f3c05def))
29
+
30
+
31
+
32
+
33
+
34
+ # [2.102.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.101.2...@next-core/brick-kit@2.102.0) (2022-01-07)
35
+
36
+
37
+ ### Features
38
+
39
+ * **FlowApi:** update size-limit.js ([7b61a08](https://github.com/easyops-cn/next-core/commit/7b61a088ed6e0f2bd7ecd3bcb80fd2fa8b918bc7))
40
+ * **FlowApi:** update unit test ([059f6b6](https://github.com/easyops-cn/next-core/commit/059f6b612d5e90cb5facaa6285c8340f046ce4b0))
41
+ * **FlowApi:** update unit test ([a4bcc9d](https://github.com/easyops-cn/next-core/commit/a4bcc9d654039616a3889c142e5bd37c8ee987bc))
42
+ * **FlowApi:** useMock in flow api ([05a5751](https://github.com/easyops-cn/next-core/commit/05a5751e33aedfaae73c80a040081c2b4d2f2a73))
43
+
44
+
45
+
46
+
47
+
48
+ ## [2.101.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.101.1...@next-core/brick-kit@2.101.2) (2022-01-06)
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * dark theme refine ([db6d4e5](https://github.com/easyops-cn/next-core/commit/db6d4e58c98779329e9dad99ee0fcde22631e44b))
54
+
55
+
56
+
57
+
58
+
6
59
  ## [2.101.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.101.0...@next-core/brick-kit@2.101.1) (2022-01-05)
7
60
 
8
61
 
@@ -389,6 +389,10 @@
389
389
  }, []);
390
390
  return currentMode;
391
391
  }
392
+ function getCssPropertyValue(name) {
393
+ var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.documentElement;
394
+ return window.getComputedStyle(el).getPropertyValue(name);
395
+ }
392
396
 
393
397
  function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
394
398
  try {
@@ -512,6 +516,24 @@
512
516
  return _ref.apply(this, arguments);
513
517
  };
514
518
  }();
519
+ /**
520
+ * @description 搜索实例V3 (支持多属性排序)
521
+ * @endpoint POST /v3/object/:objectId/instance/_search
522
+ */
523
+
524
+
525
+ var InstanceApi_postSearchV3 = /*#__PURE__*/function () {
526
+ var _ref = _asyncToGenerator$3(function* (objectId, data, options) {
527
+ return (
528
+ /**! @contract easyops.api.cmdb.instance.PostSearchV3 */
529
+ (yield brickHttp.http.post("api/gateway/cmdb.instance.PostSearchV3/v3/object/".concat(objectId, "/instance/_search"), data, options)).data
530
+ );
531
+ });
532
+
533
+ return function InstanceApi_postSearchV3(_x, _x2, _x3) {
534
+ return _ref.apply(this, arguments);
535
+ };
536
+ }();
515
537
 
516
538
  function supply(attemptToVisitGlobals, providedGlobalVariables) {
517
539
  var globalVariables = _objectSpread__default["default"]({}, providedGlobalVariables); // Allow limited browser builtin values.
@@ -1527,6 +1549,11 @@
1527
1549
  return {
1528
1550
  check: collectCoverage ? fakeCheckPermissions : checkPermissions
1529
1551
  };
1552
+
1553
+ case "THEME":
1554
+ return {
1555
+ getTheme: collectCoverage ? () => "light" : getTheme
1556
+ };
1530
1557
  }
1531
1558
  }
1532
1559
 
@@ -1903,11 +1930,6 @@
1903
1930
  getUrl: getUrlBySegueFactory(app, segues)
1904
1931
  };
1905
1932
 
1906
- case "THEME":
1907
- return {
1908
- getTheme
1909
- };
1910
-
1911
1933
  case "SESSION_STORAGE":
1912
1934
  return {
1913
1935
  getItem: getItemFactory("session")
@@ -3192,7 +3214,7 @@
3192
3214
 
3193
3215
  function handleHttpError(error) {
3194
3216
  // Redirect to login page if not logged in.
3195
- if (isUnauthenticatedError(error)) {
3217
+ if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {
3196
3218
  // Do not show multiple confirm modals.
3197
3219
  if (unauthenticatedConfirmModal) {
3198
3220
  return;
@@ -5018,6 +5040,39 @@
5018
5040
  };
5019
5041
  }();
5020
5042
 
5043
+ var mocks = {
5044
+ mockId: null,
5045
+ mockList: []
5046
+ };
5047
+ function registerMock(useMocks) {
5048
+ var _useMocks$mockList;
5049
+
5050
+ if (useMocks) mocks = _objectSpread__default["default"](_objectSpread__default["default"]({}, useMocks), {}, {
5051
+ mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
5052
+ uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
5053
+ return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
5054
+ }).replace(/:\w+/g, "([^/]+)")
5055
+ }))
5056
+ });
5057
+ }
5058
+ function getMockList() {
5059
+ return mocks.mockList;
5060
+ }
5061
+ var getMockInfo = requestUrl => {
5062
+ var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
5063
+
5064
+ if (item) {
5065
+ return {
5066
+ url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
5067
+ return "".concat(p1, "/").concat(p3);
5068
+ }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
5069
+ mockId: mocks.mockId
5070
+ };
5071
+ }
5072
+
5073
+ return;
5074
+ };
5075
+
5021
5076
  var flowApiDefinitionPromiseMap = new Map(); // Legacy Custom API: `${namespace}@${name}`
5022
5077
  // Flow API: `${namespace}@${name}:${version}`
5023
5078
 
@@ -5137,25 +5192,59 @@
5137
5192
  _fetchFlowApiDefinition2 = _asyncToGenerator__default["default"](function* (provider) {
5138
5193
  var [namespaceName, nameWithVersion] = provider.split("@");
5139
5194
  var [name, version] = nameWithVersion.split(":");
5140
- var {
5141
- contractData
5142
- } = yield ContractApi_searchSingleContract({
5143
- contractName: "".concat(namespaceName, ".").concat(name),
5144
- version
5145
- }); // return undefined if don't found contract
5195
+ var isUseMock = getMockList().find(item => item.provider === "".concat(namespaceName, "@").concat(name));
5146
5196
 
5147
- if (contractData) {
5148
- var _contractData$namespa, _contractData$namespa2;
5197
+ if (isUseMock) {
5198
+ var _list$;
5149
5199
 
5150
- return {
5151
- name: contractData.name,
5152
- namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
5153
- version: contractData.version,
5154
- contract: {
5155
- endpoint: contractData.endpoint,
5156
- response: contractData.response
5200
+ var {
5201
+ list
5202
+ } = yield InstanceApi_postSearchV3("FLOW_BUILDER_API_CONTRACT@EASYOPS", {
5203
+ fields: ["name", "namespaceId", "endpoint", "response", "version"],
5204
+ query: {
5205
+ namespaceId: {
5206
+ $eq: namespaceName
5207
+ },
5208
+ name: {
5209
+ $eq: name
5210
+ }
5157
5211
  }
5158
- };
5212
+ });
5213
+
5214
+ if ((_list$ = list[0]) !== null && _list$ !== void 0 && _list$.instanceId) {
5215
+ var _list$2;
5216
+
5217
+ return {
5218
+ name: list[0].name,
5219
+ namespace: (_list$2 = list[0]) === null || _list$2 === void 0 ? void 0 : _list$2.namespaceId,
5220
+ version: list[0].version,
5221
+ contract: {
5222
+ endpoint: list[0].endpoint,
5223
+ response: list[0].response
5224
+ }
5225
+ };
5226
+ }
5227
+ } else {
5228
+ var {
5229
+ contractData
5230
+ } = yield ContractApi_searchSingleContract({
5231
+ contractName: "".concat(namespaceName, ".").concat(name),
5232
+ version
5233
+ }); // return undefined if don't found contract
5234
+
5235
+ if (contractData) {
5236
+ var _contractData$namespa, _contractData$namespa2;
5237
+
5238
+ return {
5239
+ name: contractData.name,
5240
+ namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
5241
+ version: contractData.version,
5242
+ contract: {
5243
+ endpoint: contractData.endpoint,
5244
+ response: contractData.response
5245
+ }
5246
+ };
5247
+ }
5159
5248
  }
5160
5249
  });
5161
5250
  return _fetchFlowApiDefinition2.apply(this, arguments);
@@ -10084,36 +10173,6 @@
10084
10173
  return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
10085
10174
  }
10086
10175
 
10087
- var mocks = {
10088
- mockId: null,
10089
- mockList: []
10090
- };
10091
- function registerMock(useMocks) {
10092
- var _useMocks$mockList;
10093
-
10094
- if (useMocks) mocks = _objectSpread__default["default"](_objectSpread__default["default"]({}, useMocks), {}, {
10095
- mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
10096
- uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
10097
- return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
10098
- }).replace(/:\w+/g, "([^/]+)")
10099
- }))
10100
- });
10101
- }
10102
- var getMockInfo = requestUrl => {
10103
- var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
10104
-
10105
- if (item) {
10106
- return {
10107
- url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
10108
- return "".concat(p1, "/").concat(p3);
10109
- }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
10110
- mockId: mocks.mockId
10111
- };
10112
- }
10113
-
10114
- return;
10115
- };
10116
-
10117
10176
  class Router {
10118
10177
  constructor(kernel) {
10119
10178
  _defineProperty__default["default"](this, "defaultCollapsed", false);
@@ -10330,6 +10389,8 @@
10330
10389
  var legacy = currentApp ? currentApp.legacy : undefined;
10331
10390
  _this3.kernel.nextApp = currentApp;
10332
10391
  var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
10392
+ setTheme((currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) || "light");
10393
+ setMode("default");
10333
10394
  devtoolsHookEmit("rendering");
10334
10395
  unmountTree(mountPoints.bg);
10335
10396
 
@@ -10340,7 +10401,7 @@
10340
10401
  };
10341
10402
 
10342
10403
  if (storyboard) {
10343
- var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$theme;
10404
+ var _currentApp$breadcrum, _currentApp$breadcrum2;
10344
10405
 
10345
10406
  if (appChanged && currentApp.id && isLoggedIn()) {
10346
10407
  var usedCustomApis = brickUtils.mapCustomApisToNameAndNamespace(brickUtils.scanCustomApisInStoryboard(storyboard));
@@ -10373,7 +10434,7 @@
10373
10434
  // eslint-disable-next-line no-console
10374
10435
  console.error(error); // Redirect to login page if not logged in.
10375
10436
 
10376
- if (isUnauthenticatedError(error)) {
10437
+ if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {
10377
10438
  mountRoutesResult.flags.unauthenticated = true;
10378
10439
  } else {
10379
10440
  yield _this3.kernel.layoutBootstrap(layoutType);
@@ -10437,10 +10498,8 @@
10437
10498
  _this3.kernel.unsetBars({
10438
10499
  appChanged,
10439
10500
  legacy: actualLegacy
10440
- });
10501
+ }); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
10441
10502
 
10442
- setTheme((_currentApp$theme = currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
10443
- setMode("default"); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
10444
10503
 
10445
10504
  _this3.locationContext.handleBeforePageLoad();
10446
10505
 
@@ -12612,6 +12671,7 @@
12612
12671
  exports.doTransform = doTransform;
12613
12672
  exports.event = event;
12614
12673
  exports.getAuth = getAuth;
12674
+ exports.getCssPropertyValue = getCssPropertyValue;
12615
12675
  exports.getHistory = getHistory;
12616
12676
  exports.getMockInfo = getMockInfo;
12617
12677
  exports.getRuntime = getRuntime;