@decaf-ts/for-couchdb 0.14.0 → 0.14.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/dist/for-couchdb.cjs +1 -1
- package/dist/for-couchdb.cjs.map +1 -1
- package/dist/for-couchdb.js +1 -1
- package/dist/for-couchdb.js.map +1 -1
- package/lib/cjs/adapter.cjs +6 -12
- package/lib/cjs/adapter.cjs.map +1 -1
- package/lib/cjs/{errors.cjs → errors/IndexError.cjs} +2 -2
- package/lib/cjs/errors/IndexError.cjs.map +1 -0
- package/lib/cjs/errors/IndexPlanningError.cjs +15 -0
- package/lib/cjs/errors/IndexPlanningError.cjs.map +1 -0
- package/lib/cjs/errors/index.cjs +20 -0
- package/lib/cjs/errors/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +10 -6
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/indexes/generator.cjs +13 -9
- package/lib/cjs/indexes/generator.cjs.map +1 -1
- package/lib/cjs/query/Paginator.cjs +32 -16
- package/lib/cjs/query/Paginator.cjs.map +1 -1
- package/lib/cjs/query/Statement.cjs +13 -8
- package/lib/cjs/query/Statement.cjs.map +1 -1
- package/lib/cjs/query/index.cjs +1 -0
- package/lib/cjs/query/index.cjs.map +1 -1
- package/lib/cjs/query/planner.cjs +448 -0
- package/lib/cjs/query/planner.cjs.map +1 -0
- package/lib/esm/adapter.js +1 -7
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/{errors.js → errors/IndexError.js} +1 -1
- package/lib/esm/errors/IndexError.js.map +1 -0
- package/lib/esm/errors/IndexPlanningError.js +10 -0
- package/lib/esm/errors/IndexPlanningError.js.map +1 -0
- package/lib/esm/errors/index.js +3 -0
- package/lib/esm/errors/index.js.map +1 -0
- package/lib/esm/index.js +5 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/indexes/generator.js +12 -10
- package/lib/esm/indexes/generator.js.map +1 -1
- package/lib/esm/query/Paginator.js +32 -16
- package/lib/esm/query/Paginator.js.map +1 -1
- package/lib/esm/query/Statement.js +14 -9
- package/lib/esm/query/Statement.js.map +1 -1
- package/lib/esm/query/index.js +1 -0
- package/lib/esm/query/index.js.map +1 -1
- package/lib/esm/query/planner.js +430 -0
- package/lib/esm/query/planner.js.map +1 -0
- package/lib/types/adapter.d.cts +3 -3
- package/lib/types/adapter.d.mts +3 -3
- package/lib/types/errors/IndexPlanningError.d.cts +17 -0
- package/lib/types/errors/IndexPlanningError.d.mts +17 -0
- package/lib/types/errors/index.d.cts +2 -0
- package/lib/types/errors/index.d.mts +2 -0
- package/lib/types/index.d.cts +5 -5
- package/lib/types/index.d.mts +5 -5
- package/lib/types/indexes/generator.d.cts +13 -0
- package/lib/types/indexes/generator.d.mts +13 -0
- package/lib/types/query/Paginator.d.cts +3 -0
- package/lib/types/query/Paginator.d.mts +3 -0
- package/lib/types/query/Statement.d.cts +3 -2
- package/lib/types/query/Statement.d.mts +3 -2
- package/lib/types/query/index.d.cts +1 -0
- package/lib/types/query/index.d.mts +1 -0
- package/lib/types/query/planner.d.cts +64 -0
- package/lib/types/query/planner.d.mts +64 -0
- package/lib/types/types.d.cts +8 -0
- package/lib/types/types.d.mts +8 -0
- package/package.json +1 -1
- package/lib/cjs/errors.cjs.map +0 -1
- package/lib/esm/errors.js.map +0 -1
- /package/lib/types/{errors.d.cts → errors/IndexError.d.cts} +0 -0
- /package/lib/types/{errors.d.mts → errors/IndexError.d.mts} +0 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { OrderDirection } from "@decaf-ts/core";
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
import { CouchDBKeys } from "./../constants.js";
|
|
4
|
+
import { CouchDBGroupOperator, CouchDBOperator } from "./constants.js";
|
|
5
|
+
import { generateIndexName, generateModelIndexName, } from "./../indexes/generator.js";
|
|
6
|
+
import { IndexPlanningError } from "./../errors/IndexPlanningError.js";
|
|
7
|
+
const SCAN_PRONE_OPERATORS = new Set([
|
|
8
|
+
"$or",
|
|
9
|
+
"$in",
|
|
10
|
+
"$regex",
|
|
11
|
+
"$nin",
|
|
12
|
+
"$not",
|
|
13
|
+
"$ne",
|
|
14
|
+
"$nor",
|
|
15
|
+
]);
|
|
16
|
+
function isPlainObject(value) {
|
|
17
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function selectorContainsOperator(node, operator) {
|
|
20
|
+
if (!node || typeof node !== "object")
|
|
21
|
+
return false;
|
|
22
|
+
if (Array.isArray(node)) {
|
|
23
|
+
return node.some((child) => selectorContainsOperator(child, operator));
|
|
24
|
+
}
|
|
25
|
+
return Object.entries(node).some(([key, value]) => key === operator || selectorContainsOperator(value, operator));
|
|
26
|
+
}
|
|
27
|
+
export function normalizeSortField(entry) {
|
|
28
|
+
if (typeof entry === "string") {
|
|
29
|
+
return { field: entry };
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(entry)) {
|
|
32
|
+
return entry.length ? { field: String(entry[0]) } : undefined;
|
|
33
|
+
}
|
|
34
|
+
const [field, direction] = Object.entries(entry || {})[0] || [];
|
|
35
|
+
if (!field)
|
|
36
|
+
return undefined;
|
|
37
|
+
return {
|
|
38
|
+
field,
|
|
39
|
+
direction: String(direction || OrderDirection.ASC).toLowerCase(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function getSortFields(query) {
|
|
43
|
+
return (query.sort || [])
|
|
44
|
+
.map(normalizeSortField)
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.map((entry) => entry.field);
|
|
47
|
+
}
|
|
48
|
+
export function getSortDirection(query) {
|
|
49
|
+
return (query.sort || [])
|
|
50
|
+
.map(normalizeSortField)
|
|
51
|
+
.find(Boolean)?.direction;
|
|
52
|
+
}
|
|
53
|
+
export function getEqualitySelectorFields(selector = {}) {
|
|
54
|
+
const fields = new Set();
|
|
55
|
+
const visit = (node) => {
|
|
56
|
+
if (!node || typeof node !== "object")
|
|
57
|
+
return;
|
|
58
|
+
if (Array.isArray(node)) {
|
|
59
|
+
node.forEach(visit);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(node[CouchDBGroupOperator.AND])) {
|
|
63
|
+
node[CouchDBGroupOperator.AND].forEach(visit);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
for (const [key, value] of Object.entries(node)) {
|
|
67
|
+
if (key === CouchDBGroupOperator.OR || key === CouchDBGroupOperator.AND) {
|
|
68
|
+
visit(value);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (!isPlainObject(value)) {
|
|
72
|
+
fields.add(key);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(value, CouchDBOperator.EQUAL)) {
|
|
76
|
+
fields.add(key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
visit(selector);
|
|
81
|
+
return fields;
|
|
82
|
+
}
|
|
83
|
+
export function getRangeSelectorFields(selector = {}) {
|
|
84
|
+
const fields = new Set();
|
|
85
|
+
const visit = (node) => {
|
|
86
|
+
if (!node || typeof node !== "object")
|
|
87
|
+
return;
|
|
88
|
+
if (Array.isArray(node)) {
|
|
89
|
+
node.forEach(visit);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(node[CouchDBGroupOperator.AND])) {
|
|
93
|
+
node[CouchDBGroupOperator.AND].forEach(visit);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
for (const [key, value] of Object.entries(node)) {
|
|
97
|
+
if (key === CouchDBGroupOperator.OR || key === CouchDBGroupOperator.AND) {
|
|
98
|
+
visit(value);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!isPlainObject(value))
|
|
102
|
+
continue;
|
|
103
|
+
if (Object.prototype.hasOwnProperty.call(value, CouchDBOperator.BIGGER) ||
|
|
104
|
+
Object.prototype.hasOwnProperty.call(value, CouchDBOperator.BIGGER_EQ) ||
|
|
105
|
+
Object.prototype.hasOwnProperty.call(value, CouchDBOperator.SMALLER) ||
|
|
106
|
+
Object.prototype.hasOwnProperty.call(value, CouchDBOperator.SMALLER_EQ)) {
|
|
107
|
+
fields.add(key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
visit(selector);
|
|
112
|
+
return fields;
|
|
113
|
+
}
|
|
114
|
+
function collectGeneratedIndexEntries(clazz) {
|
|
115
|
+
const tableName = Model.tableName(clazz);
|
|
116
|
+
const candidates = [];
|
|
117
|
+
const tableIndexName = generateIndexName([CouchDBKeys.TABLE]);
|
|
118
|
+
candidates.push({
|
|
119
|
+
name: tableIndexName,
|
|
120
|
+
ddoc: tableIndexName,
|
|
121
|
+
fields: [CouchDBKeys.TABLE],
|
|
122
|
+
source: "table",
|
|
123
|
+
});
|
|
124
|
+
let defaultQueryAttrs = [];
|
|
125
|
+
try {
|
|
126
|
+
defaultQueryAttrs = Model.defaultQueryAttributes(clazz);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
defaultQueryAttrs = [];
|
|
130
|
+
}
|
|
131
|
+
for (const attr of defaultQueryAttrs) {
|
|
132
|
+
const baseName = generateIndexName([tableName, attr, "defaultQuery"]);
|
|
133
|
+
candidates.push({
|
|
134
|
+
name: baseName,
|
|
135
|
+
ddoc: baseName,
|
|
136
|
+
fields: [CouchDBKeys.TABLE, attr],
|
|
137
|
+
source: "defaultQuery",
|
|
138
|
+
});
|
|
139
|
+
for (const direction of [OrderDirection.ASC, OrderDirection.DSC]) {
|
|
140
|
+
const sortedName = generateIndexName([tableName, attr, "defaultQuery"], direction);
|
|
141
|
+
candidates.push({
|
|
142
|
+
name: sortedName,
|
|
143
|
+
ddoc: sortedName,
|
|
144
|
+
fields: [CouchDBKeys.TABLE, attr],
|
|
145
|
+
direction,
|
|
146
|
+
source: "defaultQuery",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const modelIndexes = Model.indexes(clazz);
|
|
151
|
+
Object.entries(modelIndexes || {}).forEach(([fieldKey, value]) => {
|
|
152
|
+
Object.values(value || {}).forEach((metadataValue) => {
|
|
153
|
+
if (!metadataValue || !isPlainObject(metadataValue))
|
|
154
|
+
return;
|
|
155
|
+
const meta = metadataValue;
|
|
156
|
+
const compositions = meta.compositions || [];
|
|
157
|
+
const directions = meta.directions || [OrderDirection.ASC];
|
|
158
|
+
const fields = [CouchDBKeys.TABLE, fieldKey, ...compositions];
|
|
159
|
+
const baseName = generateModelIndexName(tableName, fieldKey, compositions);
|
|
160
|
+
candidates.push({
|
|
161
|
+
name: baseName,
|
|
162
|
+
ddoc: baseName,
|
|
163
|
+
fields,
|
|
164
|
+
source: "index",
|
|
165
|
+
});
|
|
166
|
+
const validDirections = Array.from(new Set(directions.map((dir) => String(dir).toLowerCase()))).filter((dir) => dir === OrderDirection.ASC || dir === OrderDirection.DSC);
|
|
167
|
+
for (const direction of validDirections) {
|
|
168
|
+
const sortedName = generateModelIndexName(tableName, fieldKey, compositions, direction);
|
|
169
|
+
candidates.push({
|
|
170
|
+
name: sortedName,
|
|
171
|
+
ddoc: sortedName,
|
|
172
|
+
fields,
|
|
173
|
+
direction,
|
|
174
|
+
source: "index",
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
return candidates;
|
|
180
|
+
}
|
|
181
|
+
export function buildGeneratedIndexCandidates(clazz) {
|
|
182
|
+
return collectGeneratedIndexEntries(clazz);
|
|
183
|
+
}
|
|
184
|
+
export function findGeneratedIndexCandidateByName(clazz, expectedName) {
|
|
185
|
+
return collectGeneratedIndexEntries(clazz).find((candidate) => candidate.name === expectedName || candidate.ddoc === expectedName);
|
|
186
|
+
}
|
|
187
|
+
export function resolveGeneratedIndexForQuery(clazz, query, options = {}) {
|
|
188
|
+
if (query.use_index)
|
|
189
|
+
return undefined;
|
|
190
|
+
// A single named index cannot be proven valid for selectors combining
|
|
191
|
+
// branches via $or/$nor, since CouchDB only treats an index as usable when
|
|
192
|
+
// its leading fields constrain every branch of the selector. Forcing a
|
|
193
|
+
// use_index hint here causes CouchDB to reject it as "not a valid index for
|
|
194
|
+
// this query" - so let CouchDB pick (or fall back) on its own instead.
|
|
195
|
+
if (selectorContainsOperator(query.selector, CouchDBGroupOperator.OR) ||
|
|
196
|
+
selectorContainsOperator(query.selector, "$nor")) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
const preserveDefaultQuery = options.preserveDefaultQuery !== false;
|
|
200
|
+
const candidates = collectGeneratedIndexEntries(clazz);
|
|
201
|
+
const equalityFields = getEqualitySelectorFields(query.selector);
|
|
202
|
+
const rangeFields = getRangeSelectorFields(query.selector);
|
|
203
|
+
const sortFields = getSortFields(query);
|
|
204
|
+
const sortDirection = getSortDirection(query);
|
|
205
|
+
equalityFields.add(CouchDBKeys.TABLE);
|
|
206
|
+
const scored = candidates
|
|
207
|
+
.map((candidate) => {
|
|
208
|
+
if (candidate.direction &&
|
|
209
|
+
sortDirection &&
|
|
210
|
+
candidate.direction !== sortDirection) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
if (!candidate.fields.includes(CouchDBKeys.TABLE))
|
|
214
|
+
return undefined;
|
|
215
|
+
if (candidate.fields[0] !== CouchDBKeys.TABLE)
|
|
216
|
+
return undefined;
|
|
217
|
+
const candidateFields = candidate.fields.filter((field) => field !== CouchDBKeys.TABLE);
|
|
218
|
+
const coversAllSort = sortFields.length === 0 ||
|
|
219
|
+
sortFields.every((field) => candidateFields.includes(field));
|
|
220
|
+
const coversSomeSort = sortFields.some((field) => candidateFields.includes(field));
|
|
221
|
+
const coversAllRange = rangeFields.size === 0 ||
|
|
222
|
+
Array.from(rangeFields).every((field) => candidateFields.includes(field));
|
|
223
|
+
const coversSomeRange = Array.from(rangeFields).some((field) => candidateFields.includes(field));
|
|
224
|
+
if (options.requireSortCoverage && sortFields.length && !coversAllSort) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const equalityCoverage = candidateFields.filter((field) => equalityFields.has(field)).length;
|
|
228
|
+
const rangeCoverage = candidateFields.filter((field) => rangeFields.has(field)).length;
|
|
229
|
+
const sortCoverage = candidateFields.filter((field) => sortFields.includes(field)).length;
|
|
230
|
+
if (!equalityCoverage && !rangeCoverage && !sortCoverage) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
let score = 0;
|
|
234
|
+
if (candidate.source === "defaultQuery" && preserveDefaultQuery) {
|
|
235
|
+
score += 100;
|
|
236
|
+
}
|
|
237
|
+
if (candidate.source === "index")
|
|
238
|
+
score += 50;
|
|
239
|
+
score += equalityCoverage * 30;
|
|
240
|
+
score += rangeCoverage * 25;
|
|
241
|
+
score += sortCoverage * 20;
|
|
242
|
+
if (coversAllSort && sortFields.length)
|
|
243
|
+
score += 20;
|
|
244
|
+
if (coversAllRange && rangeFields.size)
|
|
245
|
+
score += 20;
|
|
246
|
+
if (coversSomeSort)
|
|
247
|
+
score += 5;
|
|
248
|
+
if (coversSomeRange)
|
|
249
|
+
score += 5;
|
|
250
|
+
if (candidate.direction && sortDirection)
|
|
251
|
+
score += 10;
|
|
252
|
+
return { candidate, score };
|
|
253
|
+
})
|
|
254
|
+
.filter(Boolean);
|
|
255
|
+
if (!scored.length)
|
|
256
|
+
return undefined;
|
|
257
|
+
scored.sort((a, b) => {
|
|
258
|
+
if (b.score !== a.score)
|
|
259
|
+
return b.score - a.score;
|
|
260
|
+
return a.candidate.fields.length - b.candidate.fields.length;
|
|
261
|
+
});
|
|
262
|
+
const best = scored[0].candidate;
|
|
263
|
+
return {
|
|
264
|
+
candidate: best,
|
|
265
|
+
use_index: [best.ddoc, best.name],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
export function getRequiredMangoIndexShape(clazz, query) {
|
|
269
|
+
const tableName = Model.tableName(clazz);
|
|
270
|
+
const modelName = clazz.name;
|
|
271
|
+
const equalityFields = Array.from(getEqualitySelectorFields(query.selector));
|
|
272
|
+
const rangeFields = Array.from(getRangeSelectorFields(query.selector));
|
|
273
|
+
const sortFields = getSortFields(query);
|
|
274
|
+
const sortDirection = getSortDirection(query);
|
|
275
|
+
const requiredFields = [CouchDBKeys.TABLE];
|
|
276
|
+
for (const field of equalityFields) {
|
|
277
|
+
if (field !== CouchDBKeys.TABLE && !requiredFields.includes(field)) {
|
|
278
|
+
requiredFields.push(field);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
for (const field of rangeFields) {
|
|
282
|
+
if (field !== CouchDBKeys.TABLE && !requiredFields.includes(field)) {
|
|
283
|
+
requiredFields.push(field);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
for (const field of sortFields) {
|
|
287
|
+
if (field !== CouchDBKeys.TABLE && !requiredFields.includes(field)) {
|
|
288
|
+
requiredFields.push(field);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
tableName,
|
|
293
|
+
modelName,
|
|
294
|
+
equalityFields,
|
|
295
|
+
rangeFields,
|
|
296
|
+
sortFields,
|
|
297
|
+
sortDirection,
|
|
298
|
+
requiredFields,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
export function reverseRequiredShapeToIndexDeclaration(clazz, query) {
|
|
302
|
+
const shape = getRequiredMangoIndexShape(clazz, query);
|
|
303
|
+
const nonTableFields = shape.requiredFields.filter((field) => field !== CouchDBKeys.TABLE);
|
|
304
|
+
if (!nonTableFields.length) {
|
|
305
|
+
throw new IndexPlanningError("Cannot infer @index declaration for query with no model fields.", {
|
|
306
|
+
modelName: shape.modelName,
|
|
307
|
+
tableName: shape.tableName,
|
|
308
|
+
attribute: "",
|
|
309
|
+
compositions: [],
|
|
310
|
+
directions: [],
|
|
311
|
+
expectedName: "",
|
|
312
|
+
expectedDdoc: "",
|
|
313
|
+
expectedFields: [CouchDBKeys.TABLE],
|
|
314
|
+
decorator: "",
|
|
315
|
+
}, query);
|
|
316
|
+
}
|
|
317
|
+
const attribute = nonTableFields[0];
|
|
318
|
+
const compositions = nonTableFields.slice(1);
|
|
319
|
+
const direction = shape.sortDirection || OrderDirection.ASC;
|
|
320
|
+
const name = generateModelIndexName(shape.tableName, attribute, compositions, direction);
|
|
321
|
+
const fields = [
|
|
322
|
+
{ [CouchDBKeys.TABLE]: direction },
|
|
323
|
+
{ [attribute]: direction },
|
|
324
|
+
...compositions.map((field) => ({ [field]: direction })),
|
|
325
|
+
];
|
|
326
|
+
const decorator = [
|
|
327
|
+
"@index({",
|
|
328
|
+
compositions.length
|
|
329
|
+
? ` compositions: ${JSON.stringify(compositions)},`
|
|
330
|
+
: undefined,
|
|
331
|
+
` directions: ${JSON.stringify([direction])}`,
|
|
332
|
+
"})",
|
|
333
|
+
`${attribute}!: <type>;`,
|
|
334
|
+
]
|
|
335
|
+
.filter(Boolean)
|
|
336
|
+
.join("\n");
|
|
337
|
+
return {
|
|
338
|
+
attribute,
|
|
339
|
+
compositions,
|
|
340
|
+
directions: [direction],
|
|
341
|
+
name,
|
|
342
|
+
ddoc: name,
|
|
343
|
+
fields,
|
|
344
|
+
decorator,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
export function attachGeneratedUseIndex(clazz, query, log, options = {}) {
|
|
348
|
+
if (!clazz || query.use_index)
|
|
349
|
+
return;
|
|
350
|
+
if (options.forceNamedIndexes === false && !options.requireIndex) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const resolved = resolveGeneratedIndexForQuery(clazz, query, {
|
|
354
|
+
preserveDefaultQuery: options.preserveDefaultQuery ?? true,
|
|
355
|
+
requireSortCoverage: options.requireSortCoverage ?? false,
|
|
356
|
+
});
|
|
357
|
+
if (resolved) {
|
|
358
|
+
query.use_index = resolved.use_index;
|
|
359
|
+
log?.debug?.(`Attached Mango use_index=${JSON.stringify(resolved.use_index)} from ${resolved.candidate.source} metadata`);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (!options.requireIndex)
|
|
363
|
+
return;
|
|
364
|
+
const reversed = reverseRequiredShapeToIndexDeclaration(clazz, query);
|
|
365
|
+
throw new IndexPlanningError([
|
|
366
|
+
"No generated CouchDB index can satisfy this Mango query.",
|
|
367
|
+
"",
|
|
368
|
+
`Model: ${clazz.name}`,
|
|
369
|
+
`Table: ${shapeTableName(clazz)}`,
|
|
370
|
+
"",
|
|
371
|
+
"To allow this query, declare the following index on the model attribute:",
|
|
372
|
+
"",
|
|
373
|
+
reversed.decorator,
|
|
374
|
+
"",
|
|
375
|
+
"Then regenerate/deploy indexes.",
|
|
376
|
+
"",
|
|
377
|
+
"Expected generated index:",
|
|
378
|
+
` ddoc: ${reversed.ddoc}`,
|
|
379
|
+
` name: ${reversed.name}`,
|
|
380
|
+
` fields: ${JSON.stringify(reversed.fields)}`,
|
|
381
|
+
].join("\n"), {
|
|
382
|
+
modelName: clazz.name,
|
|
383
|
+
tableName: shapeTableName(clazz),
|
|
384
|
+
attribute: reversed.attribute,
|
|
385
|
+
compositions: reversed.compositions,
|
|
386
|
+
directions: reversed.directions,
|
|
387
|
+
expectedName: reversed.name,
|
|
388
|
+
expectedDdoc: reversed.ddoc,
|
|
389
|
+
expectedFields: reversed.fields,
|
|
390
|
+
decorator: reversed.decorator,
|
|
391
|
+
}, query);
|
|
392
|
+
}
|
|
393
|
+
function shapeTableName(clazz) {
|
|
394
|
+
return Model.tableName(clazz);
|
|
395
|
+
}
|
|
396
|
+
export function requireGeneratedUseIndex(clazz, query, log, options = {}) {
|
|
397
|
+
attachGeneratedUseIndex(clazz, query, log, {
|
|
398
|
+
preserveDefaultQuery: true,
|
|
399
|
+
requireSortCoverage: options.requireSortCoverage ?? true,
|
|
400
|
+
requireIndex: true,
|
|
401
|
+
forceNamedIndexes: true,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
export function warnScanProneMangoOperators(selector, log, path = "selector") {
|
|
405
|
+
if (!selector || typeof selector !== "object")
|
|
406
|
+
return;
|
|
407
|
+
if (Array.isArray(selector)) {
|
|
408
|
+
selector.forEach((entry, index) => warnScanProneMangoOperators(entry, log, `${path}[${index}]`));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
for (const [key, value] of Object.entries(selector)) {
|
|
412
|
+
if (SCAN_PRONE_OPERATORS.has(key)) {
|
|
413
|
+
log?.warn?.(`Mango query contains scan-prone operator ${key} at ${path}. This may bypass or weaken index usage and can produce slow queries.`);
|
|
414
|
+
}
|
|
415
|
+
warnScanProneMangoOperators(value, log, `${path}.${key}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
export function ensureDeterministicSort(query, tieBreaker, direction) {
|
|
419
|
+
if (!query.sort?.length)
|
|
420
|
+
return;
|
|
421
|
+
const sortFields = getSortFields(query);
|
|
422
|
+
if (sortFields.includes(tieBreaker))
|
|
423
|
+
return;
|
|
424
|
+
const effectiveDirection = direction || getSortDirection(query) || OrderDirection.ASC;
|
|
425
|
+
query.sort = [...query.sort, { [tieBreaker]: effectiveDirection }];
|
|
426
|
+
}
|
|
427
|
+
export function enableMangoExecutionStats(query) {
|
|
428
|
+
query.execution_stats = true;
|
|
429
|
+
}
|
|
430
|
+
//# sourceMappingURL=planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../../../src/query/planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,0BAAqB;AAC3C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,uBAAoB;AAEpE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,kCAA6B;AAC9B,OAAO,EAAE,kBAAkB,EAAE,0CAAqC;AAwClE,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,KAAK;IAC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C;YAClC,GAAG,EAAE,IAAI,EAAE,CACT,4CAA4C,GAAG,OAAO,IAAI,uEAAuE,CAClI,CAAC;QACJ,CAAC;QACD,2BAA2B,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAiB,EACjB,UAAkB,EAClB,SAA0B;IAE1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM;QAAE,OAAO;IAEhC,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO;IAE5C,MAAM,kBAAkB,GACtB,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC;IAE7D,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAiB;IACzD,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC;AAC/B,CAAC"}
|
package/lib/types/adapter.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Adapter,
|
|
1
|
+
import { Adapter, Paginator, RawResult, ContextualArgs, PreparedModel } from "@decaf-ts/core";
|
|
2
2
|
import { BaseError, type PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { type MangoQuery, ViewResponse } from "./types.d.cts";
|
|
4
|
+
import { type CouchDBFlags, type MangoQuery, ViewResponse } from "./types.d.cts";
|
|
5
5
|
import { CouchDBStatement } from "./query/index.d.cts";
|
|
6
6
|
import { Context } from "@decaf-ts/core";
|
|
7
7
|
import { type Constructor } from "@decaf-ts/decoration";
|
|
@@ -57,7 +57,7 @@ export declare abstract class CouchDBAdapter<CONF, CONN, C extends Context<any>>
|
|
|
57
57
|
* @template M - The model type
|
|
58
58
|
* @return {CouchDBStatement<M, any>} A new CouchDBStatement instance
|
|
59
59
|
*/
|
|
60
|
-
Statement<M extends Model>(overrides?: Partial<
|
|
60
|
+
Statement<M extends Model>(overrides?: Partial<CouchDBFlags>): CouchDBStatement<M, Adapter<CONF, CONN, MangoQuery, C>, any>;
|
|
61
61
|
Paginator<M extends Model>(query: MangoQuery, size: number, clazz: Constructor<M>): Paginator<M, any, MangoQuery>;
|
|
62
62
|
/**
|
|
63
63
|
* @description Initializes the adapter by creating indexes for all managed models
|
package/lib/types/adapter.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Adapter,
|
|
1
|
+
import { Adapter, Paginator, RawResult, ContextualArgs, PreparedModel } from "@decaf-ts/core";
|
|
2
2
|
import { BaseError, type PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { type MangoQuery, ViewResponse } from "./types.d.mts";
|
|
4
|
+
import { type CouchDBFlags, type MangoQuery, ViewResponse } from "./types.d.mts";
|
|
5
5
|
import { CouchDBStatement } from "./query/index.d.mts";
|
|
6
6
|
import { Context } from "@decaf-ts/core";
|
|
7
7
|
import { type Constructor } from "@decaf-ts/decoration";
|
|
@@ -57,7 +57,7 @@ export declare abstract class CouchDBAdapter<CONF, CONN, C extends Context<any>>
|
|
|
57
57
|
* @template M - The model type
|
|
58
58
|
* @return {CouchDBStatement<M, any>} A new CouchDBStatement instance
|
|
59
59
|
*/
|
|
60
|
-
Statement<M extends Model>(overrides?: Partial<
|
|
60
|
+
Statement<M extends Model>(overrides?: Partial<CouchDBFlags>): CouchDBStatement<M, Adapter<CONF, CONN, MangoQuery, C>, any>;
|
|
61
61
|
Paginator<M extends Model>(query: MangoQuery, size: number, clazz: Constructor<M>): Paginator<M, any, MangoQuery>;
|
|
62
62
|
/**
|
|
63
63
|
* @description Initializes the adapter by creating indexes for all managed models
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IndexError } from "./IndexError.d.cts";
|
|
2
|
+
export type IndexPlanningSuggestion = {
|
|
3
|
+
modelName: string;
|
|
4
|
+
tableName: string;
|
|
5
|
+
attribute: string;
|
|
6
|
+
compositions: string[];
|
|
7
|
+
directions: string[];
|
|
8
|
+
expectedName: string;
|
|
9
|
+
expectedDdoc: string;
|
|
10
|
+
expectedFields: Array<string | Record<string, string>>;
|
|
11
|
+
decorator: string;
|
|
12
|
+
};
|
|
13
|
+
export declare class IndexPlanningError extends IndexError {
|
|
14
|
+
readonly suggestion: IndexPlanningSuggestion;
|
|
15
|
+
readonly query: unknown;
|
|
16
|
+
constructor(message: string, suggestion: IndexPlanningSuggestion, query: unknown);
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IndexError } from "./IndexError.d.mts";
|
|
2
|
+
export type IndexPlanningSuggestion = {
|
|
3
|
+
modelName: string;
|
|
4
|
+
tableName: string;
|
|
5
|
+
attribute: string;
|
|
6
|
+
compositions: string[];
|
|
7
|
+
directions: string[];
|
|
8
|
+
expectedName: string;
|
|
9
|
+
expectedDdoc: string;
|
|
10
|
+
expectedFields: Array<string | Record<string, string>>;
|
|
11
|
+
decorator: string;
|
|
12
|
+
};
|
|
13
|
+
export declare class IndexPlanningError extends IndexError {
|
|
14
|
+
readonly suggestion: IndexPlanningSuggestion;
|
|
15
|
+
readonly query: unknown;
|
|
16
|
+
constructor(message: string, suggestion: IndexPlanningSuggestion, query: unknown);
|
|
17
|
+
}
|
package/lib/types/index.d.cts
CHANGED
|
@@ -2,11 +2,11 @@ export * from "./indexes/index.d.cts";
|
|
|
2
2
|
export * from "./repository.d.cts";
|
|
3
3
|
export * from "./adapter.d.cts";
|
|
4
4
|
export * from "./constants.d.cts";
|
|
5
|
-
export * from "./errors.d.cts";
|
|
5
|
+
export * from "./errors/index.d.cts";
|
|
6
6
|
export * from "./metadata.d.cts";
|
|
7
7
|
export * from "./decorators.d.cts";
|
|
8
8
|
export * from "./types.d.cts";
|
|
9
|
-
export
|
|
9
|
+
export { reAuth, wrapDocumentScope, testReservedAttributes, generateIndexDoc } from "./utils.d.cts";
|
|
10
10
|
export * from "./query/index.d.cts";
|
|
11
11
|
export * from "./views/index.d.cts";
|
|
12
12
|
/**
|
|
@@ -19,21 +19,21 @@ export * from "./views/index.d.cts";
|
|
|
19
19
|
* @summary The version string of the for-couchdb package
|
|
20
20
|
* @const VERSION
|
|
21
21
|
*/
|
|
22
|
-
export declare const VERSION = "0.
|
|
22
|
+
export declare const VERSION = "0.14.1";
|
|
23
23
|
/**
|
|
24
24
|
* @description Represents the current commit hash of the module build.
|
|
25
25
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
26
26
|
* the placeholder with the actual commit hash at publish time.
|
|
27
27
|
* @const COMMIT
|
|
28
28
|
*/
|
|
29
|
-
export declare const COMMIT = "
|
|
29
|
+
export declare const COMMIT = "8d4d67a";
|
|
30
30
|
/**
|
|
31
31
|
* @description Represents the full version string of the module.
|
|
32
32
|
* @summary Stores the semver version and commit hash for the package.
|
|
33
33
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
34
34
|
* @const FULL_VERSION
|
|
35
35
|
*/
|
|
36
|
-
export declare const FULL_VERSION = "0.
|
|
36
|
+
export declare const FULL_VERSION = "0.14.1-8d4d67a";
|
|
37
37
|
/**
|
|
38
38
|
* @description Stores the current package name
|
|
39
39
|
* @summary The version string of the for-couchdb package
|
package/lib/types/index.d.mts
CHANGED
|
@@ -2,11 +2,11 @@ export * from "./indexes/index.d.mts";
|
|
|
2
2
|
export * from "./repository.d.mts";
|
|
3
3
|
export * from "./adapter.d.mts";
|
|
4
4
|
export * from "./constants.d.mts";
|
|
5
|
-
export * from "./errors.d.mts";
|
|
5
|
+
export * from "./errors/index.d.mts";
|
|
6
6
|
export * from "./metadata.d.mts";
|
|
7
7
|
export * from "./decorators.d.mts";
|
|
8
8
|
export * from "./types.d.mts";
|
|
9
|
-
export
|
|
9
|
+
export { reAuth, wrapDocumentScope, testReservedAttributes, generateIndexDoc } from "./utils.d.mts";
|
|
10
10
|
export * from "./query/index.d.mts";
|
|
11
11
|
export * from "./views/index.d.mts";
|
|
12
12
|
/**
|
|
@@ -19,21 +19,21 @@ export * from "./views/index.d.mts";
|
|
|
19
19
|
* @summary The version string of the for-couchdb package
|
|
20
20
|
* @const VERSION
|
|
21
21
|
*/
|
|
22
|
-
export declare const VERSION = "0.
|
|
22
|
+
export declare const VERSION = "0.14.1";
|
|
23
23
|
/**
|
|
24
24
|
* @description Represents the current commit hash of the module build.
|
|
25
25
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
26
26
|
* the placeholder with the actual commit hash at publish time.
|
|
27
27
|
* @const COMMIT
|
|
28
28
|
*/
|
|
29
|
-
export declare const COMMIT = "
|
|
29
|
+
export declare const COMMIT = "8d4d67a";
|
|
30
30
|
/**
|
|
31
31
|
* @description Represents the full version string of the module.
|
|
32
32
|
* @summary Stores the semver version and commit hash for the package.
|
|
33
33
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
34
34
|
* @const FULL_VERSION
|
|
35
35
|
*/
|
|
36
|
-
export declare const FULL_VERSION = "0.
|
|
36
|
+
export declare const FULL_VERSION = "0.14.1-8d4d67a";
|
|
37
37
|
/**
|
|
38
38
|
* @description Stores the current package name
|
|
39
39
|
* @summary The version string of the for-couchdb package
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { OrderDirection } from "@decaf-ts/core";
|
|
1
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
3
|
import { CreateIndexRequest } from "../types.d.cts";
|
|
3
4
|
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
/**
|
|
6
|
+
* @description Generates a name for a CouchDB index
|
|
7
|
+
* @summary Creates a standardized name for a CouchDB index by combining name parts, compositions, and direction
|
|
8
|
+
* @param {string[]} name - Array of name parts for the index
|
|
9
|
+
* @param {OrderDirection} [direction] - Optional sort direction for the index
|
|
10
|
+
* @param {string[]} [compositions] - Optional additional attributes to include in the index name
|
|
11
|
+
* @param {string} [separator=DefaultSeparator] - The separator to use between parts of the index name
|
|
12
|
+
* @return {string} The generated index name
|
|
13
|
+
* @memberOf module:for-couchdb
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateIndexName(name: string[], direction?: OrderDirection, compositions?: string[], separator?: string): string;
|
|
16
|
+
export declare function generateModelIndexName(tableName: string, fieldKey: string, compositions?: string[], direction?: OrderDirection, separator?: string): string;
|
|
4
17
|
/**
|
|
5
18
|
* @description Generates CouchDB index configurations for models
|
|
6
19
|
* @summary Creates a set of CouchDB index configurations based on the metadata of the provided models
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { OrderDirection } from "@decaf-ts/core";
|
|
1
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
3
|
import { CreateIndexRequest } from "../types.d.mts";
|
|
3
4
|
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
/**
|
|
6
|
+
* @description Generates a name for a CouchDB index
|
|
7
|
+
* @summary Creates a standardized name for a CouchDB index by combining name parts, compositions, and direction
|
|
8
|
+
* @param {string[]} name - Array of name parts for the index
|
|
9
|
+
* @param {OrderDirection} [direction] - Optional sort direction for the index
|
|
10
|
+
* @param {string[]} [compositions] - Optional additional attributes to include in the index name
|
|
11
|
+
* @param {string} [separator=DefaultSeparator] - The separator to use between parts of the index name
|
|
12
|
+
* @return {string} The generated index name
|
|
13
|
+
* @memberOf module:for-couchdb
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateIndexName(name: string[], direction?: OrderDirection, compositions?: string[], separator?: string): string;
|
|
16
|
+
export declare function generateModelIndexName(tableName: string, fieldKey: string, compositions?: string[], direction?: OrderDirection, separator?: string): string;
|
|
4
17
|
/**
|
|
5
18
|
* @description Generates CouchDB index configurations for models
|
|
6
19
|
* @summary Creates a set of CouchDB index configurations based on the metadata of the provided models
|