adminforth 1.0.40 → 1.0.41

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.
@@ -126,12 +126,23 @@ class MongoConnector {
126
126
 
127
127
  for (const filter of filters) {
128
128
  if (!this.OperatorsMap[filter.operator]) {
129
- throw new Error(`Operator ${filter.operator} is not allowed`);
129
+ throw new Error(`Operator ${filter.operator} is not allowed`);
130
130
  }
131
131
 
132
- if (!resource.dataSourceColumns.some((col) => col.name == filter.field)) {
132
+ if (!resource.dataSourceColumns.some((col) => col.name === filter.field)) {
133
133
  throw new Error(`Field ${filter.field} is not in resource ${resource.resourceId}. Available fields: ${resource.dataSourceColumns.map((col) => col.name).join(', ')}`);
134
134
  }
135
+
136
+ if (filter.operator === AdminForthFilterOperators.IN || filter.operator === AdminForthFilterOperators.NIN) {
137
+ if (!Array.isArray(filter.value)) {
138
+ throw new Error(`Value for operator ${filter.operator} should be an array`);
139
+ }
140
+ }
141
+
142
+ if (filter.operator === AdminForthFilterOperators.IN && filter.value.length === 0) {
143
+ // nonsense
144
+ return { data: [], total: 0 };
145
+ }
135
146
  }
136
147
 
137
148
  const collection = this.db.db().collection(tableName);
@@ -134,9 +134,18 @@ class MongoConnector {
134
134
  if (!this.OperatorsMap[filter.operator]) {
135
135
  throw new Error(`Operator ${filter.operator} is not allowed`);
136
136
  }
137
- if (!resource.dataSourceColumns.some((col) => col.name == filter.field)) {
137
+ if (!resource.dataSourceColumns.some((col) => col.name === filter.field)) {
138
138
  throw new Error(`Field ${filter.field} is not in resource ${resource.resourceId}. Available fields: ${resource.dataSourceColumns.map((col) => col.name).join(', ')}`);
139
139
  }
140
+ if (filter.operator === AdminForthFilterOperators.IN || filter.operator === AdminForthFilterOperators.NIN) {
141
+ if (!Array.isArray(filter.value)) {
142
+ throw new Error(`Value for operator ${filter.operator} should be an array`);
143
+ }
144
+ }
145
+ if (filter.operator === AdminForthFilterOperators.IN && filter.value.length === 0) {
146
+ // nonsense
147
+ return { data: [], total: 0 };
148
+ }
140
149
  }
141
150
  const collection = this.db.db().collection(tableName);
142
151
  const query = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",