@dyrected/core 2.5.29 → 2.5.32

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.
@@ -0,0 +1,54 @@
1
+ // src/utils/where-sanitizer.ts
2
+ var NEVER_FILTERABLE_TYPES = [
3
+ "password",
4
+ "richText",
5
+ "json",
6
+ "file",
7
+ "image",
8
+ "join",
9
+ "collapsible"
10
+ ];
11
+ function sanitizeWhereClause(where, fields) {
12
+ const fieldMap = /* @__PURE__ */ new Map();
13
+ function addFieldsToMap(fList, prefix = "") {
14
+ for (const f of fList) {
15
+ if ("name" in f && f.name) {
16
+ fieldMap.set(prefix + f.name, f);
17
+ }
18
+ if (f.type === "object" || f.type === "row" || f.type === "array") {
19
+ if ("fields" in f && Array.isArray(f.fields)) {
20
+ addFieldsToMap(f.fields, f.type === "object" || f.type === "array" ? `${prefix}${f.name}.` : prefix);
21
+ }
22
+ }
23
+ }
24
+ }
25
+ addFieldsToMap(fields);
26
+ function walk(node) {
27
+ const result = {};
28
+ for (const [key, value] of Object.entries(node)) {
29
+ if (key === "AND" || key === "OR") {
30
+ if (Array.isArray(value)) {
31
+ const processed = value.map((v) => walk(v)).filter((v) => Object.keys(v).length > 0);
32
+ if (processed.length > 0) {
33
+ result[key] = processed;
34
+ }
35
+ }
36
+ continue;
37
+ }
38
+ if (key === "id") {
39
+ result[key] = value;
40
+ continue;
41
+ }
42
+ const fieldDef = fieldMap.get(key);
43
+ if (!fieldDef) continue;
44
+ if (fieldDef.admin?.filterable === false) continue;
45
+ if (NEVER_FILTERABLE_TYPES.includes(fieldDef.type)) continue;
46
+ result[key] = value;
47
+ }
48
+ return result;
49
+ }
50
+ return walk(where);
51
+ }
52
+ export {
53
+ sanitizeWhereClause
54
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/core",
3
- "version": "2.5.29",
3
+ "version": "2.5.32",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -25,6 +25,7 @@
25
25
  "hono": "^4.0.0",
26
26
  "jexl": "^2.3.0",
27
27
  "jose": "^6.2.3",
28
+ "lucide-react": "^1.14.0",
28
29
  "nodemailer": "^6.10.1",
29
30
  "zod": "^3.22.0"
30
31
  },