@nocobase/utils 0.21.0-alpha.1 → 0.21.0-alpha.2

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/lib/client.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './common';
5
5
  export * from './date';
6
6
  export * from './forEach';
7
7
  export * from './getValuesByPath';
8
+ export * from './isValidFilter';
8
9
  export * from './json-templates';
9
10
  export * from './log';
10
11
  export * from './merge';
package/lib/client.js CHANGED
@@ -39,6 +39,7 @@ __reExport(client_exports, require("./common"), module.exports);
39
39
  __reExport(client_exports, require("./date"), module.exports);
40
40
  __reExport(client_exports, require("./forEach"), module.exports);
41
41
  __reExport(client_exports, require("./getValuesByPath"), module.exports);
42
+ __reExport(client_exports, require("./isValidFilter"), module.exports);
42
43
  __reExport(client_exports, require("./json-templates"), module.exports);
43
44
  __reExport(client_exports, require("./log"), module.exports);
44
45
  __reExport(client_exports, require("./merge"), module.exports);
@@ -59,6 +60,7 @@ __reExport(client_exports, require("./parseHTML"), module.exports);
59
60
  ...require("./date"),
60
61
  ...require("./forEach"),
61
62
  ...require("./getValuesByPath"),
63
+ ...require("./isValidFilter"),
62
64
  ...require("./json-templates"),
63
65
  ...require("./log"),
64
66
  ...require("./merge"),
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './date';
7
7
  export * from './dayjs';
8
8
  export * from './forEach';
9
9
  export * from './fs-exists';
10
+ export * from './isValidFilter';
10
11
  export * from './json-templates';
11
12
  export * from './koa-multer';
12
13
  export * from './measure-execution-time';
package/lib/index.js CHANGED
@@ -41,6 +41,7 @@ __reExport(src_exports, require("./date"), module.exports);
41
41
  __reExport(src_exports, require("./dayjs"), module.exports);
42
42
  __reExport(src_exports, require("./forEach"), module.exports);
43
43
  __reExport(src_exports, require("./fs-exists"), module.exports);
44
+ __reExport(src_exports, require("./isValidFilter"), module.exports);
44
45
  __reExport(src_exports, require("./json-templates"), module.exports);
45
46
  __reExport(src_exports, require("./koa-multer"), module.exports);
46
47
  __reExport(src_exports, require("./measure-execution-time"), module.exports);
@@ -67,6 +68,7 @@ __reExport(src_exports, require("./url"), module.exports);
67
68
  ...require("./dayjs"),
68
69
  ...require("./forEach"),
69
70
  ...require("./fs-exists"),
71
+ ...require("./isValidFilter"),
70
72
  ...require("./json-templates"),
71
73
  ...require("./koa-multer"),
72
74
  ...require("./measure-execution-time"),
@@ -0,0 +1 @@
1
+ export declare function isValidFilter(condition: any): any;
@@ -0,0 +1,54 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var isValidFilter_exports = {};
20
+ __export(isValidFilter_exports, {
21
+ isValidFilter: () => isValidFilter
22
+ });
23
+ module.exports = __toCommonJS(isValidFilter_exports);
24
+ function isValidFilter(condition) {
25
+ if (!condition) {
26
+ return false;
27
+ }
28
+ const groups = [condition.$and, condition.$or].filter(Boolean);
29
+ if (groups.length == 0) {
30
+ return Object.keys(condition).length > 0;
31
+ }
32
+ return groups.some((item) => {
33
+ if (Array.isArray(item)) {
34
+ return item.some(isValidFilter);
35
+ }
36
+ if (item.$and || item.$or) {
37
+ return isValidFilter(item);
38
+ }
39
+ const [name] = Object.keys(item);
40
+ if (!name || !item[name]) {
41
+ return false;
42
+ }
43
+ const [op] = Object.keys(item[name]);
44
+ if (!op || typeof item[name][op] === "undefined") {
45
+ return false;
46
+ }
47
+ return true;
48
+ });
49
+ }
50
+ __name(isValidFilter, "isValidFilter");
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ isValidFilter
54
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/utils",
3
- "version": "0.21.0-alpha.1",
3
+ "version": "0.21.0-alpha.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -15,5 +15,5 @@
15
15
  "multer": "^1.4.5-lts.1",
16
16
  "object-path": "^0.11.8"
17
17
  },
18
- "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
18
+ "gitHead": "90628f2e2da846208fb2d7966ddb4e467d187ffb"
19
19
  }