@objectql/driver-mongo 1.7.1 → 1.7.3

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
@@ -1,5 +1,21 @@
1
1
  # @objectql/driver-mongo
2
2
 
3
+ ## 1.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Release patch version 1.7.3 with latest improvements and bug fixes
8
+ - Updated dependencies
9
+ - @objectql/types@1.7.3
10
+
11
+ ## 1.7.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Release patch version 1.7.2
16
+ - Updated dependencies
17
+ - @objectql/types@1.7.2
18
+
3
19
  ## 1.7.1
4
20
 
5
21
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,21 +1,118 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ObjectQL Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ # PolyForm Shield License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/shield/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree
8
+ to them as both strict obligations and conditions to all
9
+ your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the
14
+ software to do everything you might do with the software
15
+ that would otherwise infringe the licensor's copyright
16
+ in it for any permitted purpose. However, you may
17
+ only distribute the software according to [Distribution
18
+ License](#distribution-license) and make changes or new works
19
+ based on the software according to [Changes and New Works
20
+ License](#changes-and-new-works-license).
21
+
22
+ ## Distribution License
23
+
24
+ The licensor grants you an additional copyright license
25
+ to distribute copies of the software. Your license
26
+ to distribute covers distributing the software with
27
+ changes and new works permitted by [Changes and New Works
28
+ License](#changes-and-new-works-license).
29
+
30
+ ## Notices
31
+
32
+ You must ensure that anyone who gets a copy of any part of
33
+ the software from you also gets a copy of these terms or the
34
+ URL for them above, as well as copies of any plain-text lines
35
+ beginning with `Required Notice:` that the licensor provided
36
+ with the software. For example:
37
+
38
+ > Required Notice: Copyright ObjectQL Contributors (https://github.com/objectql)
39
+
40
+ ## Changes and New Works License
41
+
42
+ The licensor grants you an additional copyright license to
43
+ make changes and new works based on the software for any
44
+ permitted purpose.
45
+
46
+ ## Patent License
47
+
48
+ The licensor grants you a patent license for the software that
49
+ covers patent claims the licensor can license, or becomes able
50
+ to license, that you would infringe by using the software.
51
+
52
+ ## Fair Use
53
+
54
+ You may have "fair use" rights for the software under the
55
+ law. These terms do not limit them.
56
+
57
+ ## No Other Rights
58
+
59
+ These terms do not allow you to sublicense or transfer any of
60
+ your licenses to anyone else, or prevent the licensor from
61
+ granting licenses to anyone else. These terms do not imply
62
+ any other licenses.
63
+
64
+ ## Patent Defense
65
+
66
+ If you make any written claim that the software infringes or
67
+ contributes to infringement of any patent, your patent license
68
+ for the software granted under these terms ends immediately. If
69
+ your company makes such a claim, your patent license ends
70
+ immediately for work on behalf of your company.
71
+
72
+ ## Violations
73
+
74
+ The first time you are notified in writing that you have
75
+ violated any of these terms, or done anything with the software
76
+ not covered by your licenses, your licenses can nonetheless
77
+ continue if you come into full compliance with these terms,
78
+ and take practical steps to correct past violations, within
79
+ 32 days of receiving notice. Otherwise, all your licenses
80
+ end immediately.
81
+
82
+ ## No Liability
83
+
84
+ ***As far as the law allows, the software comes as is, without
85
+ any warranty or condition, and the licensor will not be liable
86
+ to you for any damages arising out of these terms or the use
87
+ or nature of the software, under any kind of legal claim.***
88
+
89
+ ## Definitions
90
+
91
+ The **licensor** is the individual or entity offering these
92
+ terms, and the **software** is the software the licensor makes
93
+ available under these terms.
94
+
95
+ **You** refers to the individual or entity agreeing to these
96
+ terms.
97
+
98
+ **Your company** is any legal entity, sole proprietorship,
99
+ or other kind of organization that you work for, plus all
100
+ organizations that have control over, are under the control of,
101
+ or are under common control with that organization. **Control**
102
+ means ownership of substantially all the assets of an entity,
103
+ or the power to direct its management and policies by vote,
104
+ contract, or otherwise. Control can be direct or indirect.
105
+
106
+ **Your licenses** are all the licenses granted to you for the
107
+ software under these terms.
108
+
109
+ **Use** means anything you do with the software requiring one
110
+ of your licenses.
111
+
112
+ **Permitted purpose** means any purpose other than competing
113
+ with the licensor or any product the licensor or its affiliates
114
+ provides using the software.
115
+
116
+ ---
117
+
118
+ Required Notice: Copyright (c) 2026 ObjectQL Contributors (https://github.com/objectql)
package/dist/index.d.ts CHANGED
@@ -24,6 +24,15 @@ export declare class MongoDriver implements Driver {
24
24
  */
25
25
  private mapFromMongoArray;
26
26
  private mapFilters;
27
+ /**
28
+ * Build MongoDB filter conditions from ObjectQL filter array.
29
+ * Supports nested filter groups and logical operators (AND/OR).
30
+ */
31
+ private buildFilterConditions;
32
+ /**
33
+ * Build a single MongoDB condition from field, operator, and value.
34
+ */
35
+ private buildSingleCondition;
27
36
  find(objectName: string, query: any, options?: any): Promise<any[]>;
28
37
  findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
29
38
  create(objectName: string, data: any, options?: any): Promise<any>;
package/dist/index.js CHANGED
@@ -56,79 +56,113 @@ class MongoDriver {
56
56
  mapFilters(filters) {
57
57
  if (!filters || filters.length === 0)
58
58
  return {};
59
- // Simple case: Array of arrays [['a','=','1'], ['b','=','2']] (Implicit AND)
60
- // or Mixed: [['a','=','1'], 'and', ['b','=','2']]
59
+ const result = this.buildFilterConditions(filters);
60
+ return result;
61
+ }
62
+ /**
63
+ * Build MongoDB filter conditions from ObjectQL filter array.
64
+ * Supports nested filter groups and logical operators (AND/OR).
65
+ */
66
+ buildFilterConditions(filters) {
61
67
  const conditions = [];
62
- let currentLogic = '$and'; // Default implicit logic
68
+ let nextJoin = '$and'; // Default logic operator for next condition
63
69
  for (const item of filters) {
70
+ if (typeof item === 'string') {
71
+ // Update the logic operator for the next condition
72
+ if (item.toLowerCase() === 'or') {
73
+ nextJoin = '$or';
74
+ }
75
+ else if (item.toLowerCase() === 'and') {
76
+ nextJoin = '$and';
77
+ }
78
+ continue;
79
+ }
64
80
  if (Array.isArray(item)) {
65
- const [field, op, value] = item;
66
- let mongoCondition = {};
67
- // Map both 'id' and '_id' to '_id' for MongoDB compatibility
68
- // This ensures backward compatibility for queries using '_id'
69
- const dbField = (field === 'id' || field === '_id') ? '_id' : field;
70
- if (dbField === '_id') {
71
- mongoCondition[dbField] = this.normalizeId(value);
81
+ // Heuristic to detect if it is a criterion [field, op, value] or a nested group
82
+ const [fieldRaw, op, value] = item;
83
+ const isCriterion = typeof fieldRaw === 'string' && typeof op === 'string';
84
+ let condition;
85
+ if (isCriterion) {
86
+ // This is a single criterion [field, op, value]
87
+ condition = this.buildSingleCondition(fieldRaw, op, value);
72
88
  }
73
89
  else {
74
- switch (op) {
75
- case '=':
76
- mongoCondition[dbField] = { $eq: value };
77
- break;
78
- case '!=':
79
- mongoCondition[dbField] = { $ne: value };
80
- break;
81
- case '>':
82
- mongoCondition[dbField] = { $gt: value };
83
- break;
84
- case '>=':
85
- mongoCondition[dbField] = { $gte: value };
86
- break;
87
- case '<':
88
- mongoCondition[dbField] = { $lt: value };
89
- break;
90
- case '<=':
91
- mongoCondition[dbField] = { $lte: value };
92
- break;
93
- case 'in':
94
- mongoCondition[dbField] = { $in: value };
95
- break;
96
- case 'nin':
97
- mongoCondition[dbField] = { $nin: value };
98
- break;
99
- case 'contains':
100
- // Basic regex escape should be added for safety
101
- mongoCondition[dbField] = { $regex: value, $options: 'i' };
102
- break;
103
- default: mongoCondition[dbField] = { $eq: value };
104
- }
90
+ // This is a nested group - recursively process it
91
+ condition = this.buildFilterConditions(item);
105
92
  }
106
- conditions.push(mongoCondition);
107
- }
108
- else if (typeof item === 'string') {
109
- if (item.toLowerCase() === 'or') {
110
- // If we encounter an OR, we might need to restructure.
111
- // For simplicity in this v1, let's assume simple ANDs usually,
112
- // OR handling requires more complex tree parsing if mixed.
113
- // But if it's strictly [A, 'or', B], we can do strict mapping.
114
- // This is a simplified parser:
115
- currentLogic = '$or';
93
+ // Apply the join logic
94
+ if (conditions.length > 0 && nextJoin === '$or') {
95
+ // Collect all OR conditions together
96
+ const lastItem = conditions[conditions.length - 1];
97
+ if (lastItem && lastItem.$or) {
98
+ // Extend existing $or array
99
+ lastItem.$or.push(condition);
100
+ }
101
+ else {
102
+ // Create new $or with previous and current condition
103
+ const previous = conditions.pop();
104
+ conditions.push({ $or: [previous, condition] });
105
+ }
116
106
  }
117
- else if (item.toLowerCase() === 'and') {
118
- currentLogic = '$and';
107
+ else {
108
+ // Default AND - just add to conditions array
109
+ conditions.push(condition);
119
110
  }
111
+ // Reset to default AND logic after processing each item
112
+ nextJoin = '$and';
120
113
  }
121
114
  }
122
115
  if (conditions.length === 0)
123
116
  return {};
124
117
  if (conditions.length === 1)
125
118
  return conditions[0];
126
- // If 'or' was detected, wrap all in $or (very naive implementation)
127
- if (currentLogic === '$or') {
128
- return { $or: conditions };
129
- }
119
+ // Multiple conditions - wrap in AND
130
120
  return { $and: conditions };
131
121
  }
122
+ /**
123
+ * Build a single MongoDB condition from field, operator, and value.
124
+ */
125
+ buildSingleCondition(fieldRaw, op, value) {
126
+ const mongoCondition = {};
127
+ // Map both 'id' and '_id' to '_id' for MongoDB compatibility
128
+ const dbField = (fieldRaw === 'id' || fieldRaw === '_id') ? '_id' : fieldRaw;
129
+ if (dbField === '_id') {
130
+ mongoCondition[dbField] = this.normalizeId(value);
131
+ }
132
+ else {
133
+ switch (op) {
134
+ case '=':
135
+ mongoCondition[dbField] = { $eq: value };
136
+ break;
137
+ case '!=':
138
+ mongoCondition[dbField] = { $ne: value };
139
+ break;
140
+ case '>':
141
+ mongoCondition[dbField] = { $gt: value };
142
+ break;
143
+ case '>=':
144
+ mongoCondition[dbField] = { $gte: value };
145
+ break;
146
+ case '<':
147
+ mongoCondition[dbField] = { $lt: value };
148
+ break;
149
+ case '<=':
150
+ mongoCondition[dbField] = { $lte: value };
151
+ break;
152
+ case 'in':
153
+ mongoCondition[dbField] = { $in: value };
154
+ break;
155
+ case 'nin':
156
+ mongoCondition[dbField] = { $nin: value };
157
+ break;
158
+ case 'contains':
159
+ mongoCondition[dbField] = { $regex: value, $options: 'i' };
160
+ break;
161
+ default: mongoCondition[dbField] = { $eq: value };
162
+ }
163
+ }
164
+ return mongoCondition;
165
+ }
132
166
  async find(objectName, query, options) {
133
167
  const collection = await this.getCollection(objectName);
134
168
  const filter = this.mapFilters(query.filters);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,qCAAyE;AAEzE,MAAa,WAAW;IAMpB,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAEO,KAAK,CAAC,OAAO;QACjB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,EAAE,GAAG,IAAI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C,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAE5D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,aAAa,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAkB,EAAE,OAAY,EAAE,OAAa;QAC5D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO,MAAM,CAAC,YAAY,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,UAAkB,EAAE,QAAe,EAAE,OAAa;QAC9D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/D,0DAA0D;QAC1D,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,UAAU;QACZ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ;AA1SD,kCA0SC"}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@objectql/driver-mongo",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
+ "license": "PolyForm-Shield-1.0.0",
4
5
  "main": "dist/index.js",
5
6
  "types": "dist/index.d.ts",
6
7
  "dependencies": {
7
8
  "mongodb": "^5.9.2",
8
- "@objectql/types": "1.7.1"
9
+ "@objectql/types": "1.7.3"
9
10
  },
10
11
  "devDependencies": {
11
12
  "mongodb-memory-server": "^11.0.1"
package/src/index.ts CHANGED
@@ -64,65 +64,102 @@ export class MongoDriver implements Driver {
64
64
  private mapFilters(filters: any): Filter<any> {
65
65
  if (!filters || filters.length === 0) return {};
66
66
 
67
- // Simple case: Array of arrays [['a','=','1'], ['b','=','2']] (Implicit AND)
68
- // or Mixed: [['a','=','1'], 'and', ['b','=','2']]
69
-
67
+ const result = this.buildFilterConditions(filters);
68
+ return result;
69
+ }
70
+
71
+ /**
72
+ * Build MongoDB filter conditions from ObjectQL filter array.
73
+ * Supports nested filter groups and logical operators (AND/OR).
74
+ */
75
+ private buildFilterConditions(filters: any[]): Filter<any> {
70
76
  const conditions: any[] = [];
71
- let currentLogic = '$and'; // Default implicit logic
77
+ let nextJoin = '$and'; // Default logic operator for next condition
72
78
 
73
79
  for (const item of filters) {
74
- if (Array.isArray(item)) {
75
- const [field, op, value] = item;
76
- let mongoCondition: any = {};
77
-
78
- // Map both 'id' and '_id' to '_id' for MongoDB compatibility
79
- // This ensures backward compatibility for queries using '_id'
80
- const dbField = (field === 'id' || field === '_id') ? '_id' : field;
81
-
82
- if (dbField === '_id') {
83
- mongoCondition[dbField] = this.normalizeId(value);
84
- } else {
85
- switch (op) {
86
- case '=': mongoCondition[dbField] = { $eq: value }; break;
87
- case '!=': mongoCondition[dbField] = { $ne: value }; break;
88
- case '>': mongoCondition[dbField] = { $gt: value }; break;
89
- case '>=': mongoCondition[dbField] = { $gte: value }; break;
90
- case '<': mongoCondition[dbField] = { $lt: value }; break;
91
- case '<=': mongoCondition[dbField] = { $lte: value }; break;
92
- case 'in': mongoCondition[dbField] = { $in: value }; break;
93
- case 'nin': mongoCondition[dbField] = { $nin: value }; break;
94
- case 'contains':
95
- // Basic regex escape should be added for safety
96
- mongoCondition[dbField] = { $regex: value, $options: 'i' };
97
- break;
98
- default: mongoCondition[dbField] = { $eq: value };
99
- }
100
- }
101
- conditions.push(mongoCondition);
80
+ if (typeof item === 'string') {
81
+ // Update the logic operator for the next condition
82
+ if (item.toLowerCase() === 'or') {
83
+ nextJoin = '$or';
84
+ } else if (item.toLowerCase() === 'and') {
85
+ nextJoin = '$and';
86
+ }
87
+ continue;
88
+ }
89
+
90
+ if (Array.isArray(item)) {
91
+ // Heuristic to detect if it is a criterion [field, op, value] or a nested group
92
+ const [fieldRaw, op, value] = item;
93
+ const isCriterion = typeof fieldRaw === 'string' && typeof op === 'string';
102
94
 
103
- } else if (typeof item === 'string') {
104
- if (item.toLowerCase() === 'or') {
105
- // If we encounter an OR, we might need to restructure.
106
- // For simplicity in this v1, let's assume simple ANDs usually,
107
- // OR handling requires more complex tree parsing if mixed.
108
- // But if it's strictly [A, 'or', B], we can do strict mapping.
109
- // This is a simplified parser:
110
- currentLogic = '$or';
111
- } else if (item.toLowerCase() === 'and') {
112
- currentLogic = '$and';
113
- }
114
- }
95
+ let condition: any;
96
+
97
+ if (isCriterion) {
98
+ // This is a single criterion [field, op, value]
99
+ condition = this.buildSingleCondition(fieldRaw, op, value);
100
+ } else {
101
+ // This is a nested group - recursively process it
102
+ condition = this.buildFilterConditions(item);
103
+ }
104
+
105
+ // Apply the join logic
106
+ if (conditions.length > 0 && nextJoin === '$or') {
107
+ // Collect all OR conditions together
108
+ const lastItem = conditions[conditions.length - 1];
109
+ if (lastItem && lastItem.$or) {
110
+ // Extend existing $or array
111
+ lastItem.$or.push(condition);
112
+ } else {
113
+ // Create new $or with previous and current condition
114
+ const previous = conditions.pop();
115
+ conditions.push({ $or: [previous, condition] });
116
+ }
117
+ } else {
118
+ // Default AND - just add to conditions array
119
+ conditions.push(condition);
120
+ }
121
+
122
+ // Reset to default AND logic after processing each item
123
+ nextJoin = '$and';
124
+ }
115
125
  }
116
126
 
117
127
  if (conditions.length === 0) return {};
118
128
  if (conditions.length === 1) return conditions[0];
119
129
 
120
- // If 'or' was detected, wrap all in $or (very naive implementation)
121
- if (currentLogic === '$or') {
122
- return { $or: conditions };
130
+ // Multiple conditions - wrap in AND
131
+ return { $and: conditions };
132
+ }
133
+
134
+ /**
135
+ * Build a single MongoDB condition from field, operator, and value.
136
+ */
137
+ private buildSingleCondition(fieldRaw: string, op: string, value: any): any {
138
+ const mongoCondition: any = {};
139
+
140
+ // Map both 'id' and '_id' to '_id' for MongoDB compatibility
141
+ const dbField = (fieldRaw === 'id' || fieldRaw === '_id') ? '_id' : fieldRaw;
142
+
143
+ if (dbField === '_id') {
144
+ mongoCondition[dbField] = this.normalizeId(value);
145
+ } else {
146
+ switch (op) {
147
+ case '=': mongoCondition[dbField] = { $eq: value }; break;
148
+ case '!=': mongoCondition[dbField] = { $ne: value }; break;
149
+ case '>': mongoCondition[dbField] = { $gt: value }; break;
150
+ case '>=': mongoCondition[dbField] = { $gte: value }; break;
151
+ case '<': mongoCondition[dbField] = { $lt: value }; break;
152
+ case '<=': mongoCondition[dbField] = { $lte: value }; break;
153
+ case 'in': mongoCondition[dbField] = { $in: value }; break;
154
+ case 'nin': mongoCondition[dbField] = { $nin: value }; break;
155
+ case 'contains':
156
+ mongoCondition[dbField] = { $regex: value, $options: 'i' };
157
+ break;
158
+ default: mongoCondition[dbField] = { $eq: value };
159
+ }
123
160
  }
124
161
 
125
- return { $and: conditions };
162
+ return mongoCondition;
126
163
  }
127
164
 
128
165
  async find(objectName: string, query: any, options?: any): Promise<any[]> {