querymongo 1.1.1 → 1.4.0
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 +6 -0
- package/README.md +641 -41
- package/dist/application/MongoConverter.js +1 -1
- package/dist/application/MongoConverter.js.map +1 -1
- package/dist/application/MongoConverter.spec.js +136 -4
- package/dist/application/MongoConverter.spec.js.map +1 -1
- package/dist/cli/main.js +2 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/converters/ConverterFactory.js +2 -0
- package/dist/infrastructure/converters/ConverterFactory.js.map +1 -1
- package/dist/infrastructure/converters/ConverterFactory.spec.js +51 -0
- package/dist/infrastructure/converters/ConverterFactory.spec.js.map +1 -0
- package/dist/infrastructure/converters/JoinConverter.js +49 -0
- package/dist/infrastructure/converters/JoinConverter.js.map +1 -0
- package/dist/infrastructure/converters/SelectConverter.js +7 -8
- package/dist/infrastructure/converters/SelectConverter.js.map +1 -1
- package/dist/infrastructure/utils/queryUtils.js +22 -6
- package/dist/infrastructure/utils/queryUtils.js.map +1 -1
- package/dist/infrastructure/utils/queryUtils.spec.js +261 -0
- package/dist/infrastructure/utils/queryUtils.spec.js.map +1 -0
- package/dist/types/application/MongoConverter.d.ts +2 -1
- package/dist/types/application/MongoConverter.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/infrastructure/converters/ConverterFactory.d.ts.map +1 -1
- package/dist/types/infrastructure/converters/ConverterFactory.spec.d.ts +2 -0
- package/dist/types/infrastructure/converters/ConverterFactory.spec.d.ts.map +1 -0
- package/dist/types/infrastructure/converters/JoinConverter.d.ts +7 -0
- package/dist/types/infrastructure/converters/JoinConverter.d.ts.map +1 -0
- package/dist/types/infrastructure/converters/SelectConverter.d.ts.map +1 -1
- package/dist/types/infrastructure/utils/queryUtils.d.ts +7 -2
- package/dist/types/infrastructure/utils/queryUtils.d.ts.map +1 -1
- package/dist/types/infrastructure/utils/queryUtils.spec.d.ts +2 -0
- package/dist/types/infrastructure/utils/queryUtils.spec.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests para Query Utilities
|
|
3
|
+
* Verifica las funciones auxiliares para construir filtros, proyecciones y operaciones
|
|
4
|
+
*/
|
|
5
|
+
import { test, describe } from "node:test";
|
|
6
|
+
import { equal, ok, deepEqual } from "node:assert";
|
|
7
|
+
import { buildFilter, buildProjection, removeUndefinedFields, extractSelectColumns, determineOperation, } from "../utils/queryUtils.js";
|
|
8
|
+
describe("Query Utilities - buildFilter", () => {
|
|
9
|
+
test("should handle simple equality filter", () => {
|
|
10
|
+
var _a;
|
|
11
|
+
const condition = {
|
|
12
|
+
operator: "=",
|
|
13
|
+
left: { column: "id" },
|
|
14
|
+
right: { value: 1 },
|
|
15
|
+
};
|
|
16
|
+
const filter = buildFilter(condition);
|
|
17
|
+
ok(((_a = filter.id) === null || _a === void 0 ? void 0 : _a.$eq) === 1 || filter.id === 1);
|
|
18
|
+
});
|
|
19
|
+
test("should handle inequality operators", () => {
|
|
20
|
+
const conditions = [
|
|
21
|
+
{ op: "!=", expected: "$ne" },
|
|
22
|
+
{ op: "<>", expected: "$ne" },
|
|
23
|
+
{ op: "<", expected: "$lt" },
|
|
24
|
+
{ op: ">", expected: "$gt" },
|
|
25
|
+
{ op: "<=", expected: "$lte" },
|
|
26
|
+
{ op: ">=", expected: "$gte" },
|
|
27
|
+
];
|
|
28
|
+
conditions.forEach(({ op, expected }) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const condition = {
|
|
31
|
+
operator: op,
|
|
32
|
+
left: { column: "age" },
|
|
33
|
+
right: { value: 18 },
|
|
34
|
+
};
|
|
35
|
+
const filter = buildFilter(condition);
|
|
36
|
+
ok(((_a = filter.age) === null || _a === void 0 ? void 0 : _a[expected]) !== undefined);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
test("should handle AND operator", () => {
|
|
40
|
+
const condition = {
|
|
41
|
+
operator: "AND",
|
|
42
|
+
left: { operator: "=", left: { column: "id" }, right: { value: 1 } },
|
|
43
|
+
right: {
|
|
44
|
+
operator: "=",
|
|
45
|
+
left: { column: "status" },
|
|
46
|
+
right: { value: "active" },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const filter = buildFilter(condition);
|
|
50
|
+
ok(filter.$and && Array.isArray(filter.$and));
|
|
51
|
+
equal(filter.$and.length, 2);
|
|
52
|
+
});
|
|
53
|
+
test("should handle OR operator", () => {
|
|
54
|
+
const condition = {
|
|
55
|
+
operator: "OR",
|
|
56
|
+
left: { operator: "=", left: { column: "id" }, right: { value: 1 } },
|
|
57
|
+
right: { operator: "=", left: { column: "id" }, right: { value: 2 } },
|
|
58
|
+
};
|
|
59
|
+
const filter = buildFilter(condition);
|
|
60
|
+
ok(filter.$or && Array.isArray(filter.$or));
|
|
61
|
+
equal(filter.$or.length, 2);
|
|
62
|
+
});
|
|
63
|
+
test("should handle IN operator", () => {
|
|
64
|
+
var _a;
|
|
65
|
+
const condition = {
|
|
66
|
+
operator: "in",
|
|
67
|
+
left: { column: "status" },
|
|
68
|
+
right: { value: [1, 2, 3] },
|
|
69
|
+
};
|
|
70
|
+
const filter = buildFilter(condition);
|
|
71
|
+
ok((_a = filter.status) === null || _a === void 0 ? void 0 : _a.$in);
|
|
72
|
+
});
|
|
73
|
+
test("should handle LIKE operator", () => {
|
|
74
|
+
var _a;
|
|
75
|
+
const condition = {
|
|
76
|
+
operator: "like",
|
|
77
|
+
left: { column: "name" },
|
|
78
|
+
right: { value: "%john%" },
|
|
79
|
+
};
|
|
80
|
+
const filter = buildFilter(condition);
|
|
81
|
+
ok((_a = filter.name) === null || _a === void 0 ? void 0 : _a.$regex);
|
|
82
|
+
});
|
|
83
|
+
test("should return empty filter for null condition", () => {
|
|
84
|
+
const filter = buildFilter(null);
|
|
85
|
+
deepEqual(filter, {});
|
|
86
|
+
});
|
|
87
|
+
test("should normalize field names (remove quotes)", () => {
|
|
88
|
+
const condition = {
|
|
89
|
+
operator: "=",
|
|
90
|
+
left: { column: '"email"' },
|
|
91
|
+
right: { value: "test@example.com" },
|
|
92
|
+
};
|
|
93
|
+
const filter = buildFilter(condition);
|
|
94
|
+
ok(filter.email !== undefined);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe("Query Utilities - buildProjection", () => {
|
|
98
|
+
test("should return empty object for wildcard", () => {
|
|
99
|
+
const projection = buildProjection("*");
|
|
100
|
+
deepEqual(projection, {});
|
|
101
|
+
});
|
|
102
|
+
test("should build projection for specific columns", () => {
|
|
103
|
+
const projection = buildProjection(["id", "name", "email"]);
|
|
104
|
+
ok(projection.id === 1);
|
|
105
|
+
ok(projection.name === 1);
|
|
106
|
+
ok(projection.email === 1);
|
|
107
|
+
});
|
|
108
|
+
test("should normalize field names in projection", () => {
|
|
109
|
+
const projection = buildProjection(["`id`", '"name"', "email"]);
|
|
110
|
+
ok(projection.id === 1 || projection["`id`"]);
|
|
111
|
+
ok(projection.email === 1);
|
|
112
|
+
});
|
|
113
|
+
test("should handle qualified field names", () => {
|
|
114
|
+
const projection = buildProjection(["users.id", "users.name"]);
|
|
115
|
+
// Should extract the field part after the dot
|
|
116
|
+
ok(projection.id === 1 || projection.name === 1);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe("Query Utilities - extractSelectColumns", () => {
|
|
120
|
+
test("should return wildcard if no columns provided", () => {
|
|
121
|
+
//@ts-expect-error null is not a valid argument for extractSelectColumns but is used here for testing purposes
|
|
122
|
+
const columns = extractSelectColumns(null);
|
|
123
|
+
deepEqual(columns, ["*"]);
|
|
124
|
+
});
|
|
125
|
+
test("should extract column names from array", () => {
|
|
126
|
+
const columns = [{ expr: { column: "id" } }, { expr: { column: "name" } }];
|
|
127
|
+
const result = extractSelectColumns(columns);
|
|
128
|
+
ok(result.includes("id"));
|
|
129
|
+
ok(result.includes("name"));
|
|
130
|
+
});
|
|
131
|
+
test("should handle object columns without expr property", () => {
|
|
132
|
+
const columns = ["id", "name", "email"];
|
|
133
|
+
const result = extractSelectColumns(columns);
|
|
134
|
+
equal(result.length, 3);
|
|
135
|
+
});
|
|
136
|
+
test("should handle mixed column formats", () => {
|
|
137
|
+
const columns = [
|
|
138
|
+
{ expr: { column: "id" } },
|
|
139
|
+
"name",
|
|
140
|
+
{ expr: { value: "email" } },
|
|
141
|
+
];
|
|
142
|
+
const result = extractSelectColumns(columns);
|
|
143
|
+
ok(result.length >= 2);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe("Query Utilities - determineOperation", () => {
|
|
147
|
+
test("should return One operation for unique fields with equality", () => {
|
|
148
|
+
const where = {
|
|
149
|
+
operator: "=",
|
|
150
|
+
left: { column: "id" },
|
|
151
|
+
right: { value: 1 },
|
|
152
|
+
};
|
|
153
|
+
const result = determineOperation(where, {
|
|
154
|
+
one: "deleteOne",
|
|
155
|
+
many: "deleteMany",
|
|
156
|
+
});
|
|
157
|
+
equal(result, "deleteOne");
|
|
158
|
+
});
|
|
159
|
+
test("should return One operation for email with equality", () => {
|
|
160
|
+
const where = {
|
|
161
|
+
operator: "=",
|
|
162
|
+
left: { column: "email" },
|
|
163
|
+
right: { value: "test@example.com" },
|
|
164
|
+
};
|
|
165
|
+
const result = determineOperation(where, {
|
|
166
|
+
one: "updateOne",
|
|
167
|
+
many: "updateMany",
|
|
168
|
+
});
|
|
169
|
+
equal(result, "updateOne");
|
|
170
|
+
});
|
|
171
|
+
test("should return Many operation for non-unique fields with equality", () => {
|
|
172
|
+
const where = {
|
|
173
|
+
operator: "=",
|
|
174
|
+
left: { column: "status" },
|
|
175
|
+
right: { value: "active" },
|
|
176
|
+
};
|
|
177
|
+
const result = determineOperation(where, {
|
|
178
|
+
one: "deleteOne",
|
|
179
|
+
many: "deleteMany",
|
|
180
|
+
});
|
|
181
|
+
equal(result, "deleteMany");
|
|
182
|
+
});
|
|
183
|
+
test("should return Many operation for AND conditions", () => {
|
|
184
|
+
const where = {
|
|
185
|
+
operator: "AND",
|
|
186
|
+
left: { operator: "=", left: { column: "id" }, right: { value: 1 } },
|
|
187
|
+
right: {
|
|
188
|
+
operator: "=",
|
|
189
|
+
left: { column: "status" },
|
|
190
|
+
right: { value: "active" },
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
const result = determineOperation(where, {
|
|
194
|
+
one: "deleteOne",
|
|
195
|
+
many: "deleteMany",
|
|
196
|
+
});
|
|
197
|
+
equal(result, "deleteMany");
|
|
198
|
+
});
|
|
199
|
+
test("should return Many operation for comparison operators", () => {
|
|
200
|
+
const operators = [">", "<", ">=", "<=", "!=", "<>", "like"];
|
|
201
|
+
operators.forEach((op) => {
|
|
202
|
+
const where = {
|
|
203
|
+
operator: op,
|
|
204
|
+
left: { column: "age" },
|
|
205
|
+
right: { value: 18 },
|
|
206
|
+
};
|
|
207
|
+
const result = determineOperation(where, {
|
|
208
|
+
one: "updateOne",
|
|
209
|
+
many: "updateMany",
|
|
210
|
+
});
|
|
211
|
+
equal(result, "updateMany");
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
test("should return Many for null/no WHERE clause", () => {
|
|
215
|
+
const result1 = determineOperation(null, {
|
|
216
|
+
one: "deleteOne",
|
|
217
|
+
many: "deleteMany",
|
|
218
|
+
});
|
|
219
|
+
const result2 = determineOperation(undefined, {
|
|
220
|
+
one: "updateOne",
|
|
221
|
+
many: "updateMany",
|
|
222
|
+
});
|
|
223
|
+
equal(result1, "deleteMany");
|
|
224
|
+
equal(result2, "updateMany");
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
describe("Query Utilities - removeUndefinedFields", () => {
|
|
228
|
+
test("should remove undefined fields from object", () => {
|
|
229
|
+
const obj = {
|
|
230
|
+
name: "John",
|
|
231
|
+
email: undefined,
|
|
232
|
+
age: 30,
|
|
233
|
+
status: undefined,
|
|
234
|
+
};
|
|
235
|
+
const result = removeUndefinedFields(obj);
|
|
236
|
+
ok(result.name);
|
|
237
|
+
ok(result.age);
|
|
238
|
+
ok(!result.email);
|
|
239
|
+
ok(!result.status);
|
|
240
|
+
});
|
|
241
|
+
test("should preserve null and falsy values", () => {
|
|
242
|
+
const obj = {
|
|
243
|
+
name: "John",
|
|
244
|
+
verified: false,
|
|
245
|
+
count: 0,
|
|
246
|
+
notes: null,
|
|
247
|
+
empty: undefined,
|
|
248
|
+
};
|
|
249
|
+
const result = removeUndefinedFields(obj);
|
|
250
|
+
ok(result.verified === false);
|
|
251
|
+
ok(result.count === 0);
|
|
252
|
+
ok(result.notes === null);
|
|
253
|
+
ok(!result.empty);
|
|
254
|
+
});
|
|
255
|
+
test("should return empty object if all fields undefined", () => {
|
|
256
|
+
const obj = { a: undefined, b: undefined };
|
|
257
|
+
const result = removeUndefinedFields(obj);
|
|
258
|
+
deepEqual(result, {});
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
//# sourceMappingURL=queryUtils.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryUtils.spec.js","sourceRoot":"","sources":["../../../src/infrastructure/utils/queryUtils.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE;;QAChD,MAAM,SAAS,GAAG;YAChB,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YACtB,KAAK,EAAE,EAAE,KA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M,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;QACvB,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;QAC1B,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC9D,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAE1C,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoConverter.d.ts","sourceRoot":"","sources":["../../../src/application/MongoConverter.ts"],"names":[],"mappings":"AAUA,
|
|
1
|
+
{"version":3,"file":"MongoConverter.d.ts","sourceRoot":"","sources":["../../../src/application/MongoConverter.ts"],"names":[],"mappings":"AAUA,cAAM,cAAc;IAClB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAcxC;CACF;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* API pública del módulo
|
|
3
3
|
* Exporta las funcionalidades principales para uso como librería
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { mongoConverter } from "./application/MongoConverter.ts";
|
|
6
6
|
export type { IConverter } from "./domain/interfaces/Converter.ts";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConverterFactory.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/converters/ConverterFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"ConverterFactory.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/converters/ConverterFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAevE,eAAO,MAAM,YAAY,cAAe,MAAM,KAAG,UAAU,GAAG,IAE7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConverterFactory.spec.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/converters/ConverterFactory.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversor para queries SELECT con JOIN
|
|
3
|
+
* Convierte queries SELECT con JOIN a aggregation pipeline de MongoDB
|
|
4
|
+
*/
|
|
5
|
+
import type { IConverter } from "../../domain/interfaces/Converter.ts";
|
|
6
|
+
export declare const JoinConverter: IConverter;
|
|
7
|
+
//# sourceMappingURL=JoinConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JoinConverter.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/converters/JoinConverter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAQvE,eAAO,MAAM,aAAa,EAAE,UAoD3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectConverter.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/converters/SelectConverter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectConverter.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/converters/SelectConverter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAQvE,eAAO,MAAM,eAAe,EAAE,UAuB7B,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Utilidades para conversión de queries SQL a MongoDB
|
|
3
|
+
* Centraliza lógica reutilizable siguiendo principio DRY
|
|
4
|
+
*/
|
|
5
|
+
import _ from "lodash";
|
|
6
|
+
export declare const removeUndefinedFields: (obj: _.Dictionary<any>) => _.Dictionary<any>;
|
|
7
|
+
export declare const extractSelectColumns: (columns: any[]) => string[];
|
|
3
8
|
export declare const buildProjection: (fields: string[] | "*") => Record<string, 1 | 0>;
|
|
4
9
|
export declare const buildFilter: (condition: any) => Record<string, any>;
|
|
5
10
|
export declare function determineOperation(where: any, operations: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryUtils.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/utils/queryUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queryUtils.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/utils/queryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,eAAO,MAAM,qBAAqB,QAC3B,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,KACrB,CAAC,CAAC,UAAU,CAAC,GAAG,CAElB,CAAC;AAeF,eAAO,MAAM,oBAAoB,YAAa,GAAG,EAAE,KAAG,MAAM,EAS3D,CAAC;AAEF,eAAO,MAAM,eAAe,WAClB,MAAM,EAAE,GAAG,GAAG,KACrB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAStB,CAAC;AAEF,eAAO,MAAM,WAAW,cAAe,GAAG,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAsC9D,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,GAAG,EACV,UAAU,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxC,MAAM,CAmBR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryUtils.spec.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/utils/queryUtils.spec.ts"],"names":[],"mappings":""}
|