@next-core/brick-utils 2.28.7 → 2.28.11

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,41 @@
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.28.11](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.28.10...@next-core/brick-utils@2.28.11) (2021-10-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * dispose specific null fields ([0f50281](https://github.com/easyops-cn/next-core/commit/0f502815abf47faf4156bfbf91029125bbda01a4))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.28.10](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.28.9...@next-core/brick-utils@2.28.10) (2021-10-21)
18
+
19
+ **Note:** Version bump only for package @next-core/brick-utils
20
+
21
+
22
+
23
+
24
+
25
+ ## [2.28.9](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.28.8...@next-core/brick-utils@2.28.9) (2021-10-20)
26
+
27
+ **Note:** Version bump only for package @next-core/brick-utils
28
+
29
+
30
+
31
+
32
+
33
+ ## [2.28.8](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.28.7...@next-core/brick-utils@2.28.8) (2021-10-20)
34
+
35
+ **Note:** Version bump only for package @next-core/brick-utils
36
+
37
+
38
+
39
+
40
+
6
41
  ## [2.28.7](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.28.6...@next-core/brick-utils@2.28.7) (2021-10-13)
7
42
 
8
43
 
@@ -18589,7 +18589,11 @@
18589
18589
  }
18590
18590
 
18591
18591
  function preevaluate(raw, options) {
18592
- var source = raw.replace(/^\s*<%~?\s|\s%>\s*$/g, "");
18592
+ var fixes = [];
18593
+ var source = raw.replace(/^\s*<%~?\s|\s%>\s*$/g, m => {
18594
+ fixes.push(m);
18595
+ return "";
18596
+ });
18593
18597
  var expression = parseAsEstreeExpression(source);
18594
18598
  var attemptToVisitGlobals = precook(expression, _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
18595
18599
  expressionOnly: true
@@ -18597,7 +18601,9 @@
18597
18601
  return {
18598
18602
  expression,
18599
18603
  attemptToVisitGlobals,
18600
- source
18604
+ source,
18605
+ prefix: fixes[0],
18606
+ suffix: fixes[1]
18601
18607
  };
18602
18608
  }
18603
18609
  function isEvaluable(raw) {
@@ -20405,32 +20411,26 @@
20405
20411
 
20406
20412
  var yamlFieldsInBrick = ["permissionsPreCheck", "transformFrom"]; // Fields started with `_` will be removed by default.
20407
20413
 
20408
- var fieldsToRemoveInRoute = ["appId", "children", "creator", "ctime", "id", "instanceId", "graphInfo", "modifier", "mountPoint", "mtime", "org", "parent", "sort", "deleteAuthorizers", "readAuthorizers", "updateAuthorizers"];
20409
- var fieldsToRemoveInBrick = fieldsToRemoveInRoute.concat("type");
20414
+ var fieldsToRemoveInRoute = ["appId", "children", "creator", "ctime", "id", "instanceId", "graphInfo", "modifier", "mountPoint", "mtime", "org", "parent", "sort", "name", "providersBak", "providers_bak", "deleteAuthorizers", "readAuthorizers", "updateAuthorizers"];
20415
+ var fieldsToRemoveInBrick = fieldsToRemoveInRoute.concat("type", "alias"); // Those fields can be disposed if value is null.
20416
+
20417
+ var disposableNullFields = ["alias", "documentId", "hybrid", "bg", "context", "exports", "ref", "portal"];
20410
20418
  function normalizeBuilderNode(node) {
20411
20419
  if (isBrickNode(node)) {
20412
- return normalizeBuilderBrickNode(node);
20420
+ return normalize(node, fieldsToRemoveInBrick, jsonFieldsInBrick, yamlFieldsInBrick, false);
20413
20421
  }
20414
20422
 
20415
20423
  if (isRouteNode(node)) {
20416
- return normalizeBuilderRouteNode(node);
20424
+ return normalize(node, fieldsToRemoveInRoute, jsonFieldsInRoute, yamlFieldsInRoute, true);
20417
20425
  }
20418
20426
 
20419
20427
  return null;
20420
20428
  }
20421
20429
 
20422
- function normalizeBuilderBrickNode(node) {
20423
- return normalize(node, fieldsToRemoveInBrick, jsonFieldsInBrick, yamlFieldsInBrick);
20424
- }
20425
-
20426
- function normalizeBuilderRouteNode(node) {
20427
- return normalize(node, fieldsToRemoveInRoute, jsonFieldsInRoute, yamlFieldsInRoute, true);
20428
- }
20429
-
20430
20430
  function normalize(node, fieldsToRemove, jsonFields, yamlFields, cleanUpSegues) {
20431
20431
  return Object.fromEntries(Object.entries(node) // Remove unused fields from CMDB.
20432
20432
  // Consider fields started with `_` as unused.
20433
- .filter(([key]) => key[0] !== "_" && !fieldsToRemove.includes(key)) // Parse json fields.
20433
+ .filter(([key, value]) => !(key[0] === "_" || fieldsToRemove.includes(key) || value === null && disposableNullFields.includes(key))) // Parse specific fields.
20434
20434
  .map(([key, value]) => [key, cleanUpSegues && key === "segues" ? getCleanSegues(value) : jsonFields.includes(key) ? safeJsonParse(value) : yamlFields.includes(key) ? safeYamlParse(value) : lodash.cloneDeep(value)]));
20435
20435
  } // Clear `segue._view` which is for development only.
20436
20436