@dereekb/firebase 13.11.15 → 13.11.16

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,2290 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Returns the outermost statement node for a FunctionDeclaration — its `ExportNamedDeclaration`
5
+ * or `ExportDefaultDeclaration` parent if exported, otherwise the declaration itself. This is the
6
+ * node ESLint attaches leading comments to.
7
+ *
8
+ * @param node - The FunctionDeclaration AST node.
9
+ * @returns The statement node ESLint attaches leading comments to.
10
+ */ function getStatementAnchor(node) {
11
+ return node.parent && (node.parent.type === 'ExportNamedDeclaration' || node.parent.type === 'ExportDefaultDeclaration') ? node.parent : node;
12
+ }
13
+ /**
14
+ * Returns the JSDoc Block comment immediately preceding `anchor`, or `null` when
15
+ * the anchor has no JSDoc leader. Used by the `@dbx<Family>` companion-tag rules
16
+ * to locate the tagged declaration's documentation.
17
+ *
18
+ * @param sourceCode - The ESLint `SourceCode` object.
19
+ * @param anchor - The statement-level node ESLint attaches leading comments to.
20
+ * @returns The JSDoc block comment, or null when none is present.
21
+ */ function leadingJsdocFor(sourceCode, anchor) {
22
+ var comments = sourceCode.getCommentsBefore(anchor) || [];
23
+ var result = null;
24
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
25
+ try {
26
+ for(var _iterator = comments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
27
+ var comment = _step.value;
28
+ if (comment.type === 'Block' && typeof comment.value === 'string' && comment.value.startsWith('*')) {
29
+ result = comment;
30
+ }
31
+ }
32
+ } catch (err) {
33
+ _didIteratorError = true;
34
+ _iteratorError = err;
35
+ } finally{
36
+ try {
37
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
38
+ _iterator.return();
39
+ }
40
+ } finally{
41
+ if (_didIteratorError) {
42
+ throw _iteratorError;
43
+ }
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+
49
+ function _array_like_to_array$3(arr, len) {
50
+ if (len == null || len > arr.length) len = arr.length;
51
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
52
+ return arr2;
53
+ }
54
+ function _array_with_holes$1(arr) {
55
+ if (Array.isArray(arr)) return arr;
56
+ }
57
+ function _iterable_to_array_limit$1(arr, i) {
58
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
59
+ if (_i == null) return;
60
+ var _arr = [];
61
+ var _n = true;
62
+ var _d = false;
63
+ var _s, _e;
64
+ try {
65
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
66
+ _arr.push(_s.value);
67
+ if (i && _arr.length === i) break;
68
+ }
69
+ } catch (err) {
70
+ _d = true;
71
+ _e = err;
72
+ } finally{
73
+ try {
74
+ if (!_n && _i["return"] != null) _i["return"]();
75
+ } finally{
76
+ if (_d) throw _e;
77
+ }
78
+ }
79
+ return _arr;
80
+ }
81
+ function _non_iterable_rest$1() {
82
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
83
+ }
84
+ function _sliced_to_array$1(arr, i) {
85
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$1();
86
+ }
87
+ function _unsupported_iterable_to_array$3(o, minLen) {
88
+ if (!o) return;
89
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
90
+ var n = Object.prototype.toString.call(o).slice(8, -1);
91
+ if (n === "Object" && o.constructor) n = o.constructor.name;
92
+ if (n === "Map" || n === "Set") return Array.from(n);
93
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
94
+ }
95
+ var TAG_LINE_REGEX = /^@([A-Za-z_]\w*)\s*(.*)$/;
96
+ var TYPE_ANNOTATION_REGEX = /^\{([^}]*)\}\s*(.*)$/;
97
+ var PARAM_NAME_REGEX = /^([A-Za-z_$][A-Za-z0-9_$.[\]]*)\s*(.*)$/;
98
+ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
99
+ /**
100
+ * Strips the leading whitespace + `*` + optional space prefix from a JSDoc body line and reports the length stripped.
101
+ *
102
+ * @param raw - The raw line as it appears in `comment.value`.
103
+ * @returns A `{ text, prefixLength }` pair.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * stripPrefix(' * @param x - desc'); // { text: '@param x - desc', prefixLength: 3 }
108
+ * stripPrefix(' *'); // { text: '', prefixLength: 2 }
109
+ * stripPrefix('* hello'); // { text: 'hello', prefixLength: 2 }
110
+ * ```
111
+ */ function stripPrefix(raw) {
112
+ var match = LINE_PREFIX_REGEX.exec(raw);
113
+ var result = {
114
+ text: raw,
115
+ prefixLength: 0
116
+ };
117
+ if (match) {
118
+ result.text = match[2];
119
+ result.prefixLength = match[1].length;
120
+ }
121
+ return result;
122
+ }
123
+ /**
124
+ * Splits the raw comment value into per-line views with prefix/offset metadata.
125
+ *
126
+ * @param commentValue - The `value` of an ESLint Block comment.
127
+ * @returns Array of parsed line records in source order.
128
+ */ function buildParsedLines(commentValue) {
129
+ var rawLines = commentValue.split('\n');
130
+ var runningOffset = 0;
131
+ return rawLines.map(function(raw, index) {
132
+ var _stripPrefix = stripPrefix(raw), stripped = _stripPrefix.text, prefixLength = _stripPrefix.prefixLength;
133
+ var text = stripped.trimEnd();
134
+ var blank = text.length === 0;
135
+ var valueOffsetStart = runningOffset;
136
+ var textOffsetStart = runningOffset + prefixLength;
137
+ runningOffset += raw.length + 1; // +1 for the consumed `\n` (overshoots on last line, harmless)
138
+ return {
139
+ raw: raw,
140
+ text: text,
141
+ blank: blank,
142
+ index: index,
143
+ valueOffsetStart: valueOffsetStart,
144
+ textOffsetStart: textOffsetStart
145
+ };
146
+ });
147
+ }
148
+ /**
149
+ * Returns the index of the first line that begins with a JSDoc `@tag`, or `-1` when none exists.
150
+ *
151
+ * @param lines - Parsed lines in source order.
152
+ * @returns Zero-based line index of the first tag, or `-1` when no tag is present.
153
+ */ function findFirstTagIndex(lines) {
154
+ var firstTagIndex = -1;
155
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
156
+ try {
157
+ for(var _iterator = lines.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
158
+ var _step_value = _sliced_to_array$1(_step.value, 2), i = _step_value[0], line = _step_value[1];
159
+ if (TAG_LINE_REGEX.test(line.text)) {
160
+ firstTagIndex = i;
161
+ break;
162
+ }
163
+ }
164
+ } catch (err) {
165
+ _didIteratorError = true;
166
+ _iteratorError = err;
167
+ } finally{
168
+ try {
169
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
170
+ _iterator.return();
171
+ }
172
+ } finally{
173
+ if (_didIteratorError) {
174
+ throw _iteratorError;
175
+ }
176
+ }
177
+ }
178
+ return firstTagIndex;
179
+ }
180
+ /**
181
+ * Trims leading and trailing blank lines from a contiguous run of description lines.
182
+ *
183
+ * @param descriptionLines - Description-section lines before any tag.
184
+ * @returns Sub-array with surrounding blank lines stripped.
185
+ */ function trimBlankBoundaries(descriptionLines) {
186
+ var descStart = 0;
187
+ var descEnd = descriptionLines.length;
188
+ while(descStart < descEnd && descriptionLines[descStart].blank)descStart += 1;
189
+ while(descEnd > descStart && descriptionLines[descEnd - 1].blank)descEnd -= 1;
190
+ return descriptionLines.slice(descStart, descEnd);
191
+ }
192
+ /**
193
+ * Splits the trimmed description lines into paragraphs separated by blank-line runs.
194
+ *
195
+ * @param trimmedDescription - Description lines with surrounding blank lines removed.
196
+ * @returns Paragraph strings joined by `\n`.
197
+ */ function buildDescriptionParagraphs(trimmedDescription) {
198
+ var descriptionParagraphs = [];
199
+ var paragraphBuffer = [];
200
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
201
+ try {
202
+ for(var _iterator = trimmedDescription[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
203
+ var line = _step.value;
204
+ if (line.blank) {
205
+ if (paragraphBuffer.length > 0) {
206
+ descriptionParagraphs.push(paragraphBuffer.join('\n'));
207
+ paragraphBuffer = [];
208
+ }
209
+ } else {
210
+ paragraphBuffer.push(line.text);
211
+ }
212
+ }
213
+ } catch (err) {
214
+ _didIteratorError = true;
215
+ _iteratorError = err;
216
+ } finally{
217
+ try {
218
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
219
+ _iterator.return();
220
+ }
221
+ } finally{
222
+ if (_didIteratorError) {
223
+ throw _iteratorError;
224
+ }
225
+ }
226
+ }
227
+ if (paragraphBuffer.length > 0) {
228
+ descriptionParagraphs.push(paragraphBuffer.join('\n'));
229
+ }
230
+ return descriptionParagraphs;
231
+ }
232
+ /**
233
+ * Pulls an optional `{Type}` annotation off the front of a tag remainder.
234
+ *
235
+ * @param remainder - The tag-line text after the `@tagName` prefix.
236
+ * @returns The annotation (or `undefined`) plus the remaining text.
237
+ */ function extractTypeAnnotation(remainder) {
238
+ var type;
239
+ var rest = remainder;
240
+ var typeMatch = TYPE_ANNOTATION_REGEX.exec(remainder);
241
+ if (typeMatch) {
242
+ type = typeMatch[1];
243
+ rest = typeMatch[2];
244
+ }
245
+ return {
246
+ type: type,
247
+ rest: rest
248
+ };
249
+ }
250
+ /**
251
+ * Pulls an optional parameter name off the front of a `@param` tag remainder.
252
+ *
253
+ * @param tagName - Tag name (only `'param'` extracts a name; other tags pass through).
254
+ * @param remainder - The tag-line text after the optional `{Type}` annotation.
255
+ * @returns The parameter name (or `undefined`) plus the remaining text.
256
+ */ function extractParamName(tagName, remainder) {
257
+ var name;
258
+ var rest = remainder;
259
+ if (tagName === 'param') {
260
+ var nameMatch = PARAM_NAME_REGEX.exec(remainder);
261
+ if (nameMatch) {
262
+ name = nameMatch[1];
263
+ rest = nameMatch[2];
264
+ }
265
+ }
266
+ return {
267
+ name: name,
268
+ rest: rest
269
+ };
270
+ }
271
+ /**
272
+ * Collects the tag line at `startIndex` plus every following non-tag continuation line.
273
+ *
274
+ * @param lines - All parsed lines in the comment.
275
+ * @param startIndex - Index of the `@tag` opening line.
276
+ * @returns The collected tag lines and the index of the next unconsumed line.
277
+ */ function collectTagLines(lines, startIndex) {
278
+ var tagLines = [
279
+ lines[startIndex]
280
+ ];
281
+ var j = startIndex + 1;
282
+ while(j < lines.length){
283
+ if (TAG_LINE_REGEX.test(lines[j].text)) break;
284
+ tagLines.push(lines[j]);
285
+ j += 1;
286
+ }
287
+ return {
288
+ tagLines: tagLines,
289
+ nextIndex: j
290
+ };
291
+ }
292
+ /**
293
+ * Joins the on-line remainder and continuation-line text into a tag description, dropping trailing
294
+ * blank lines while preserving interior blanks.
295
+ *
296
+ * @param remainder - The on-line remainder after stripping `@tagName {Type} name`.
297
+ * @param tagLines - All lines that belong to the tag (including the header line at index 0).
298
+ * @returns Description text joined by `\n`.
299
+ */ function buildTagDescription(remainder, tagLines) {
300
+ var descriptionParts = [];
301
+ if (remainder.length > 0) descriptionParts.push(remainder);
302
+ for(var k = 1; k < tagLines.length; k += 1){
303
+ descriptionParts.push(tagLines[k].text);
304
+ }
305
+ while(descriptionParts.length > 0 && descriptionParts.at(-1).trim().length === 0){
306
+ descriptionParts.pop();
307
+ }
308
+ return descriptionParts.join('\n');
309
+ }
310
+ /**
311
+ * Builds a single parsed-tag record starting at `startIndex` in the line array.
312
+ *
313
+ * @param lines - All parsed lines in the comment.
314
+ * @param startIndex - Index of the `@tag` opening line.
315
+ * @returns The parsed tag and the next unconsumed line index.
316
+ */ function parseTagAt(lines, startIndex) {
317
+ var line = lines[startIndex];
318
+ var match = TAG_LINE_REGEX.exec(line.text);
319
+ var tagName = match[1];
320
+ var _extractTypeAnnotation = extractTypeAnnotation(match[2]), type = _extractTypeAnnotation.type, afterType = _extractTypeAnnotation.rest;
321
+ var _extractParamName = extractParamName(tagName, afterType), name = _extractParamName.name, afterName = _extractParamName.rest;
322
+ var _collectTagLines = collectTagLines(lines, startIndex), tagLines = _collectTagLines.tagLines, nextIndex = _collectTagLines.nextIndex;
323
+ var description = buildTagDescription(afterName, tagLines);
324
+ return {
325
+ tag: {
326
+ tag: tagName,
327
+ name: name,
328
+ type: type,
329
+ description: description,
330
+ lines: tagLines,
331
+ startLineIndex: startIndex,
332
+ endLineIndex: nextIndex - 1
333
+ },
334
+ nextIndex: nextIndex
335
+ };
336
+ }
337
+ /**
338
+ * Parses every `@tag` block starting from `firstTagIndex` to the end of the line array.
339
+ *
340
+ * @param lines - All parsed lines in the comment.
341
+ * @param firstTagIndex - Index where tag parsing should begin (`-1` skips entirely).
342
+ * @returns All parsed tags in source order.
343
+ */ function parseTags(lines, firstTagIndex) {
344
+ var tags = [];
345
+ if (firstTagIndex !== -1) {
346
+ var i = firstTagIndex;
347
+ while(i < lines.length){
348
+ if (!TAG_LINE_REGEX.test(lines[i].text)) {
349
+ i += 1;
350
+ continue;
351
+ }
352
+ var _parseTagAt = parseTagAt(lines, i), tag = _parseTagAt.tag, nextIndex = _parseTagAt.nextIndex;
353
+ tags.push(tag);
354
+ i = nextIndex;
355
+ }
356
+ }
357
+ return tags;
358
+ }
359
+ /**
360
+ * Parses the value of an ESLint Block comment that represents a JSDoc into a structured form.
361
+ *
362
+ * @param commentValue - The `value` of an ESLint Block comment (text between `/*` and `*\/`, including the leading `*`).
363
+ * @returns A structured view of the JSDoc with description, paragraphs, and tags.
364
+ *
365
+ * @example
366
+ * ```ts
367
+ * const parsed = parseJsdocComment('*\n * Hello.\n *\n * @param x - The value.\n ');
368
+ * // parsed.description === 'Hello.'
369
+ * // parsed.tags[0].tag === 'param'
370
+ * // parsed.tags[0].name === 'x'
371
+ * // parsed.tags[0].description === 'The value.'
372
+ * ```
373
+ */ function parseJsdocComment(commentValue) {
374
+ var singleLine = !commentValue.includes('\n');
375
+ var lines = buildParsedLines(commentValue);
376
+ var firstTagIndex = findFirstTagIndex(lines);
377
+ var descriptionLines = firstTagIndex === -1 ? lines.slice() : lines.slice(0, firstTagIndex);
378
+ var trimmedDescription = trimBlankBoundaries(descriptionLines);
379
+ var description = trimmedDescription.map(function(l) {
380
+ return l.text;
381
+ }).join('\n');
382
+ var descriptionParagraphs = buildDescriptionParagraphs(trimmedDescription);
383
+ var tags = parseTags(lines, firstTagIndex);
384
+ return {
385
+ lines: lines,
386
+ descriptionLines: descriptionLines,
387
+ description: description,
388
+ descriptionParagraphs: descriptionParagraphs,
389
+ tags: tags,
390
+ singleLine: singleLine
391
+ };
392
+ }
393
+
394
+ function _array_like_to_array$2(arr, len) {
395
+ if (len == null || len > arr.length) len = arr.length;
396
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
397
+ return arr2;
398
+ }
399
+ function _array_without_holes$1(arr) {
400
+ if (Array.isArray(arr)) return _array_like_to_array$2(arr);
401
+ }
402
+ function _iterable_to_array$1(iter) {
403
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
404
+ }
405
+ function _non_iterable_spread$1() {
406
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
407
+ }
408
+ function _to_consumable_array$1(arr) {
409
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$1();
410
+ }
411
+ function _unsupported_iterable_to_array$2(o, minLen) {
412
+ if (!o) return;
413
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
414
+ var n = Object.prototype.toString.call(o).slice(8, -1);
415
+ if (n === "Object" && o.constructor) n = o.constructor.name;
416
+ if (n === "Map" || n === "Set") return Array.from(n);
417
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
418
+ }
419
+ /**
420
+ * Module that publishes the `@dereekb/firebase` Firestore constraint factories (`where`, `orderBy`, etc.).
421
+ */ var FIREBASE_MODULE = '@dereekb/firebase';
422
+ /**
423
+ * JSDoc tag name that marks an exported query factory whose body should be scanned by
424
+ * `dbx-components-mcp`'s index extractor (`packages/dbx-components-mcp/src/scan/model-firebase-index-extract.ts`).
425
+ */ var DBX_MODEL_FIREBASE_INDEX_MARKER = 'dbxModelFirebaseIndex';
426
+ /**
427
+ * The canonical suffix expected on every `@dbxModelFirebaseIndex`-tagged factory name.
428
+ */ var QUERY_SUFFIX = 'Query';
429
+ /**
430
+ * Index-affecting Firestore constraint factory identifiers exported from `@dereekb/firebase`
431
+ * (see `packages/firebase/src/lib/common/firestore/query/constraint.ts`). These shape the
432
+ * composite index Firestore needs to satisfy the query — calls to them must originate inside
433
+ * a `@dbxModelFirebaseIndex`-tagged function so the dbx-components-mcp index extractor can
434
+ * collect them.
435
+ *
436
+ * `where` and `orderBy` are the only constraint factories that influence composite indexes;
437
+ * pagination/cursor factories (`limit`, `limitToLast`, `whereDocumentId`, `startAt`/`After`,
438
+ * `endAt`/`Before`) only narrow the cursor/window of an already-indexed query and may be
439
+ * composed freely outside tagged factories — see {@link DEFAULT_PAGINATION_CONSTRAINT_NAMES}.
440
+ */ var DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES = [
441
+ 'where',
442
+ 'orderBy'
443
+ ];
444
+ /**
445
+ * Pagination/cursor Firestore constraint factory identifiers exported from `@dereekb/firebase`.
446
+ * These do not influence composite indexes and may be composed externally — e.g. a generic
447
+ * pagination helper that appends `limit` + `startAfter` onto a caller-supplied tagged-query
448
+ * constraint array. The "tagged-firestore-constraints" rule does not flag calls to these by
449
+ * default.
450
+ */ var DEFAULT_PAGINATION_CONSTRAINT_NAMES = [
451
+ 'limit',
452
+ 'limitToLast',
453
+ 'whereDocumentId',
454
+ 'startAt',
455
+ 'startAfter',
456
+ 'endAt',
457
+ 'endBefore'
458
+ ];
459
+ /**
460
+ * Combined list of every Firestore constraint factory exported from `@dereekb/firebase`. Used
461
+ * by the body-coherence rule to ensure a tagged factory body contains at least one constraint
462
+ * call of any kind (index-affecting or pagination) before warning that the marker is orphaned.
463
+ */ var DEFAULT_CONSTRAINT_FACTORY_NAMES = _to_consumable_array$1(DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES).concat(_to_consumable_array$1(DEFAULT_PAGINATION_CONSTRAINT_NAMES));
464
+ /**
465
+ * Creates an empty {@link ImportRegistry}.
466
+ *
467
+ * @returns A fresh empty registry.
468
+ */ function createImportRegistry() {
469
+ return {
470
+ bySource: new Map(),
471
+ localToSource: new Map(),
472
+ localToImported: new Map()
473
+ };
474
+ }
475
+ /**
476
+ * Records an `ImportDeclaration` node in the registry.
477
+ *
478
+ * @param registry - The registry to mutate.
479
+ * @param node - The ImportDeclaration AST node.
480
+ */ function trackImportDeclaration(registry, node) {
481
+ var _node_source;
482
+ var source = (_node_source = node.source) === null || _node_source === void 0 ? void 0 : _node_source.value;
483
+ if (source) {
484
+ var _registry_bySource_get, _node_specifiers;
485
+ var localNames = (_registry_bySource_get = registry.bySource.get(source)) !== null && _registry_bySource_get !== void 0 ? _registry_bySource_get : new Set();
486
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
487
+ try {
488
+ for(var _iterator = ((_node_specifiers = node.specifiers) !== null && _node_specifiers !== void 0 ? _node_specifiers : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
489
+ var specifier = _step.value;
490
+ if (specifier.type === 'ImportSpecifier' || specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportNamespaceSpecifier') {
491
+ var _specifier_local;
492
+ var localName = (_specifier_local = specifier.local) === null || _specifier_local === void 0 ? void 0 : _specifier_local.name;
493
+ if (localName) {
494
+ var _ref;
495
+ var _specifier_imported;
496
+ localNames.add(localName);
497
+ registry.localToSource.set(localName, source);
498
+ var importedName = specifier.type === 'ImportSpecifier' ? (_ref = (_specifier_imported = specifier.imported) === null || _specifier_imported === void 0 ? void 0 : _specifier_imported.name) !== null && _ref !== void 0 ? _ref : localName : localName;
499
+ registry.localToImported.set(localName, importedName);
500
+ }
501
+ }
502
+ }
503
+ } catch (err) {
504
+ _didIteratorError = true;
505
+ _iteratorError = err;
506
+ } finally{
507
+ try {
508
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
509
+ _iterator.return();
510
+ }
511
+ } finally{
512
+ if (_didIteratorError) {
513
+ throw _iteratorError;
514
+ }
515
+ }
516
+ }
517
+ registry.bySource.set(source, localNames);
518
+ }
519
+ }
520
+ /**
521
+ * Returns true when the given local identifier name was imported from the given module.
522
+ *
523
+ * @param registry - The import registry built from the file's import declarations.
524
+ * @param localName - The local identifier (as it appears in code).
525
+ * @param fromSource - The expected source-module string.
526
+ * @returns True when the local name maps to the given source.
527
+ */ function isImportedFrom(registry, localName, fromSource) {
528
+ return registry.localToSource.get(localName) === fromSource;
529
+ }
530
+ /**
531
+ * Returns the statement-level anchor node that ESLint attaches leading comments to for the
532
+ * given function-like node. For function declarations this is the declaration (or its
533
+ * `Export*Declaration` wrapper); for arrow/function expressions assigned to a variable, it
534
+ * is the variable declaration (or its `Export*Declaration` wrapper); otherwise `null`.
535
+ *
536
+ * @param node - The function-like AST node (FunctionDeclaration / FunctionExpression / ArrowFunctionExpression).
537
+ * @returns The anchor statement node, or null when the function has no JSDoc-anchorable container.
538
+ */ function getFunctionJsdocAnchor(node) {
539
+ var result = null;
540
+ if (node.type === 'FunctionDeclaration') {
541
+ result = node.parent && (node.parent.type === 'ExportNamedDeclaration' || node.parent.type === 'ExportDefaultDeclaration') ? node.parent : node;
542
+ } else if (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') {
543
+ var declarator = node.parent;
544
+ if ((declarator === null || declarator === void 0 ? void 0 : declarator.type) === 'VariableDeclarator') {
545
+ var declaration = declarator.parent;
546
+ if ((declaration === null || declaration === void 0 ? void 0 : declaration.type) === 'VariableDeclaration') {
547
+ var _declaration_parent, _declaration_parent1;
548
+ result = ((_declaration_parent = declaration.parent) === null || _declaration_parent === void 0 ? void 0 : _declaration_parent.type) === 'ExportNamedDeclaration' || ((_declaration_parent1 = declaration.parent) === null || _declaration_parent1 === void 0 ? void 0 : _declaration_parent1.type) === 'ExportDefaultDeclaration' ? declaration.parent : declaration;
549
+ }
550
+ }
551
+ }
552
+ return result;
553
+ }
554
+ /**
555
+ * Returns the function name when resolvable: `node.id.name` for declarations, or the
556
+ * containing `VariableDeclarator.id.name` for arrow/function expressions. Returns `null`
557
+ * when the function is anonymous in an unrecognized context.
558
+ *
559
+ * @param node - The function-like AST node.
560
+ * @returns The function name, or null when anonymous.
561
+ */ function getFunctionName(node) {
562
+ var _node_id;
563
+ var result = null;
564
+ if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && ((_node_id = node.id) === null || _node_id === void 0 ? void 0 : _node_id.type) === 'Identifier') {
565
+ result = node.id.name;
566
+ } else if (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') {
567
+ var _declarator_id;
568
+ var declarator = node.parent;
569
+ if ((declarator === null || declarator === void 0 ? void 0 : declarator.type) === 'VariableDeclarator' && ((_declarator_id = declarator.id) === null || _declarator_id === void 0 ? void 0 : _declarator_id.type) === 'Identifier') {
570
+ result = declarator.id.name;
571
+ }
572
+ }
573
+ return result;
574
+ }
575
+ /**
576
+ * Returns the name-bearing AST node for reporting on a function: the `id` for a
577
+ * declaration, the `VariableDeclarator.id` for an arrow assignment, or the function node
578
+ * itself as a last resort.
579
+ *
580
+ * @param node - The function-like AST node.
581
+ * @returns The node to attach a `context.report` location to.
582
+ */ function getFunctionNameNode(node) {
583
+ var result = node;
584
+ if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.id) {
585
+ result = node.id;
586
+ } else if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') {
587
+ var declarator = node.parent;
588
+ if ((declarator === null || declarator === void 0 ? void 0 : declarator.type) === 'VariableDeclarator' && declarator.id) {
589
+ result = declarator.id;
590
+ }
591
+ }
592
+ return result;
593
+ }
594
+
595
+ function _array_like_to_array$1(arr, len) {
596
+ if (len == null || len > arr.length) len = arr.length;
597
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
598
+ return arr2;
599
+ }
600
+ function _array_without_holes(arr) {
601
+ if (Array.isArray(arr)) return _array_like_to_array$1(arr);
602
+ }
603
+ function _iterable_to_array(iter) {
604
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
605
+ }
606
+ function _non_iterable_spread() {
607
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
608
+ }
609
+ function _to_consumable_array(arr) {
610
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
611
+ }
612
+ function _unsupported_iterable_to_array$1(o, minLen) {
613
+ if (!o) return;
614
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
615
+ var n = Object.prototype.toString.call(o).slice(8, -1);
616
+ if (n === "Object" && o.constructor) n = o.constructor.name;
617
+ if (n === "Map" || n === "Set") return Array.from(n);
618
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
619
+ }
620
+ /**
621
+ * ESLint rule that forbids inline `@dereekb/firebase` Firestore constraint factory calls
622
+ * (`where`, `orderBy`, `limit`, ...) outside a function whose leading JSDoc carries the
623
+ * `@dbxModelFirebaseIndex` marker. The dbx-components-mcp index extractor only sees
624
+ * constraints inside tagged factories — anything else is invisible to index generation
625
+ * and must be extracted into a dedicated `*Query` factory.
626
+ *
627
+ * Not auto-fixable: extracting an inline constraint into a new function requires choosing
628
+ * a name, signature, and call-site replacement that are outside the safe scope of an ESLint
629
+ * autofix.
630
+ */ var FIREBASE_REQUIRE_TAGGED_FIRESTORE_CONSTRAINTS_RULE = {
631
+ meta: {
632
+ type: 'problem',
633
+ fixable: undefined,
634
+ docs: {
635
+ description: 'Disallow `@dereekb/firebase` index-affecting Firestore constraint factory calls (`where`, `orderBy`) outside a `@dbxModelFirebaseIndex`-tagged query factory. Pagination/cursor factories (`limit`, `limitToLast`, `whereDocumentId`, `startAt`/`After`, `endAt`/`Before`) do not affect composite indexes and are not flagged.',
636
+ recommended: true
637
+ },
638
+ messages: {
639
+ inlineConstraintOutsideTaggedQuery: '`{{name}}(...)` from `@dereekb/firebase` must be called inside a `@dbxModelFirebaseIndex`-tagged query factory. Extract this constraint into a dedicated `*Query` function tagged with `@dbxModelFirebaseIndex` so dbx-components-mcp can index it, then run `dbx-cli-generate-firestore-indexes --component <dir>` to regenerate `firestore.indexes.json`.'
640
+ },
641
+ schema: [
642
+ {
643
+ type: 'object',
644
+ additionalProperties: false,
645
+ properties: {
646
+ constraintNames: {
647
+ type: 'array',
648
+ items: {
649
+ type: 'string'
650
+ }
651
+ },
652
+ additionalConstraintNames: {
653
+ type: 'array',
654
+ items: {
655
+ type: 'string'
656
+ }
657
+ },
658
+ allowedImportSources: {
659
+ type: 'array',
660
+ items: {
661
+ type: 'string'
662
+ }
663
+ },
664
+ markerTag: {
665
+ type: 'string'
666
+ }
667
+ }
668
+ }
669
+ ]
670
+ },
671
+ create: function create(context) {
672
+ var _context_options_, _options_constraintNames, _options_additionalConstraintNames, _options_allowedImportSources, _options_markerTag;
673
+ var options = (_context_options_ = context.options[0]) !== null && _context_options_ !== void 0 ? _context_options_ : {};
674
+ var sourceCode = context.sourceCode;
675
+ var baseNames = (_options_constraintNames = options.constraintNames) !== null && _options_constraintNames !== void 0 ? _options_constraintNames : DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES;
676
+ var constraintNames = new Set(_to_consumable_array(baseNames).concat(_to_consumable_array((_options_additionalConstraintNames = options.additionalConstraintNames) !== null && _options_additionalConstraintNames !== void 0 ? _options_additionalConstraintNames : [])));
677
+ var allowedSources = new Set((_options_allowedImportSources = options.allowedImportSources) !== null && _options_allowedImportSources !== void 0 ? _options_allowedImportSources : [
678
+ FIREBASE_MODULE
679
+ ]);
680
+ var markerTag = (_options_markerTag = options.markerTag) !== null && _options_markerTag !== void 0 ? _options_markerTag : DBX_MODEL_FIREBASE_INDEX_MARKER;
681
+ var registry = createImportRegistry();
682
+ var stack = [];
683
+ function jsdocHasMarker(anchor) {
684
+ var jsdoc = leadingJsdocFor(sourceCode, anchor);
685
+ var result = false;
686
+ if (jsdoc) {
687
+ var parsed = parseJsdocComment(jsdoc.value);
688
+ result = parsed.tags.some(function(t) {
689
+ return t.tag === markerTag;
690
+ });
691
+ }
692
+ return result;
693
+ }
694
+ function pushFrame(node) {
695
+ var _ref;
696
+ var anchor = getFunctionJsdocAnchor(node);
697
+ var tagged = anchor ? jsdocHasMarker(anchor) : false;
698
+ var parent = stack.length > 0 ? stack[stack.length - 1] : null;
699
+ var taggedDeep = tagged || ((_ref = parent === null || parent === void 0 ? void 0 : parent.taggedDeep) !== null && _ref !== void 0 ? _ref : false);
700
+ stack.push({
701
+ node: node,
702
+ tagged: tagged,
703
+ taggedDeep: taggedDeep
704
+ });
705
+ }
706
+ function popFrame(node) {
707
+ if (stack.length > 0 && stack[stack.length - 1].node === node) {
708
+ stack.pop();
709
+ }
710
+ }
711
+ function isTrackedConstraintCall(node) {
712
+ var _node_callee;
713
+ var result = null;
714
+ if (((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === 'Identifier') {
715
+ var localName = node.callee.name;
716
+ var source = registry.localToSource.get(localName);
717
+ if (source && allowedSources.has(source) && isImportedFrom(registry, localName, source)) {
718
+ var _registry_localToImported_get;
719
+ var importedName = (_registry_localToImported_get = registry.localToImported.get(localName)) !== null && _registry_localToImported_get !== void 0 ? _registry_localToImported_get : localName;
720
+ if (constraintNames.has(importedName)) {
721
+ result = importedName;
722
+ }
723
+ }
724
+ }
725
+ return result;
726
+ }
727
+ return {
728
+ ImportDeclaration: function ImportDeclaration(node) {
729
+ return trackImportDeclaration(registry, node);
730
+ },
731
+ FunctionDeclaration: function FunctionDeclaration(node) {
732
+ return pushFrame(node);
733
+ },
734
+ 'FunctionDeclaration:exit': function(node) {
735
+ return popFrame(node);
736
+ },
737
+ FunctionExpression: function FunctionExpression(node) {
738
+ return pushFrame(node);
739
+ },
740
+ 'FunctionExpression:exit': function(node) {
741
+ return popFrame(node);
742
+ },
743
+ ArrowFunctionExpression: function ArrowFunctionExpression(node) {
744
+ return pushFrame(node);
745
+ },
746
+ 'ArrowFunctionExpression:exit': function(node) {
747
+ return popFrame(node);
748
+ },
749
+ CallExpression: function CallExpression(node) {
750
+ var name = isTrackedConstraintCall(node);
751
+ if (name) {
752
+ var taggedAncestor = stack.some(function(frame) {
753
+ return frame.tagged;
754
+ });
755
+ if (!taggedAncestor) {
756
+ context.report({
757
+ node: node,
758
+ messageId: 'inlineConstraintOutsideTaggedQuery',
759
+ data: {
760
+ name: name
761
+ }
762
+ });
763
+ }
764
+ }
765
+ }
766
+ };
767
+ }
768
+ };
769
+
770
+ var DEFAULT_STRIPPABLE_SUFFIXES = [
771
+ 'Filter',
772
+ 'Constraints',
773
+ 'Builder'
774
+ ];
775
+ /**
776
+ * Builds a rename suggestion: strips a recognized non-canonical suffix and appends the canonical
777
+ * `Query` suffix; otherwise appends `Query` directly.
778
+ *
779
+ * @param name - The current function name.
780
+ * @param suffix - The canonical suffix (default `'Query'`).
781
+ * @param strippable - Suffixes to strip before appending (default `['Filter', 'Constraints', 'Builder']`).
782
+ * @returns The suggested renamed identifier.
783
+ */ function buildRenameSuggestion(name, suffix, strippable) {
784
+ var result = "".concat(name).concat(suffix);
785
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
786
+ try {
787
+ for(var _iterator = strippable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
788
+ var s = _step.value;
789
+ if (name.endsWith(s) && name.length > s.length) {
790
+ result = "".concat(name.slice(0, -s.length)).concat(suffix);
791
+ break;
792
+ }
793
+ }
794
+ } catch (err) {
795
+ _didIteratorError = true;
796
+ _iteratorError = err;
797
+ } finally{
798
+ try {
799
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
800
+ _iterator.return();
801
+ }
802
+ } finally{
803
+ if (_didIteratorError) {
804
+ throw _iteratorError;
805
+ }
806
+ }
807
+ }
808
+ return result;
809
+ }
810
+ /**
811
+ * ESLint rule that enforces the canonical `Query` suffix on every `@dbxModelFirebaseIndex`-tagged
812
+ * function. Mirrors the naming used by the canonical fixtures in
813
+ * `packages/dbx-components-mcp/src/scan/model-firebase-index-extract.spec.ts` and production
814
+ * factories in `packages/firebase/src/lib/model/**\/*.query.ts`.
815
+ *
816
+ * Not auto-fixable: renaming across files (call sites + tests) is outside the safe scope of an
817
+ * ESLint autofix.
818
+ */ var FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_QUERY_SUFFIX_RULE = {
819
+ meta: {
820
+ type: 'suggestion',
821
+ fixable: undefined,
822
+ docs: {
823
+ description: 'Require the canonical `Query` suffix on `@dbxModelFirebaseIndex`-tagged factories.',
824
+ recommended: true
825
+ },
826
+ messages: {
827
+ queryFactoryNameMustEndWithQuery: '`@dbxModelFirebaseIndex`-tagged factory `{{name}}` must end with `{{suffix}}`. Rename to e.g. `{{suggestion}}` so dbx-components-mcp can identify it consistently.',
828
+ anonymousQueryFactory: '`@dbxModelFirebaseIndex`-tagged factories must be named (must end with `{{suffix}}`); anonymous functions are not allowed.'
829
+ },
830
+ schema: [
831
+ {
832
+ type: 'object',
833
+ additionalProperties: false,
834
+ properties: {
835
+ suffix: {
836
+ type: 'string'
837
+ },
838
+ markerTag: {
839
+ type: 'string'
840
+ },
841
+ allowedSuffixes: {
842
+ type: 'array',
843
+ items: {
844
+ type: 'string'
845
+ }
846
+ },
847
+ strippableSuffixes: {
848
+ type: 'array',
849
+ items: {
850
+ type: 'string'
851
+ }
852
+ }
853
+ }
854
+ }
855
+ ]
856
+ },
857
+ create: function create(context) {
858
+ var _context_options_, _options_suffix, _options_markerTag, _options_allowedSuffixes, _options_strippableSuffixes;
859
+ var options = (_context_options_ = context.options[0]) !== null && _context_options_ !== void 0 ? _context_options_ : {};
860
+ var sourceCode = context.sourceCode;
861
+ var suffix = (_options_suffix = options.suffix) !== null && _options_suffix !== void 0 ? _options_suffix : QUERY_SUFFIX;
862
+ var markerTag = (_options_markerTag = options.markerTag) !== null && _options_markerTag !== void 0 ? _options_markerTag : DBX_MODEL_FIREBASE_INDEX_MARKER;
863
+ var allowedSuffixes = (_options_allowedSuffixes = options.allowedSuffixes) !== null && _options_allowedSuffixes !== void 0 ? _options_allowedSuffixes : [];
864
+ var strippableSuffixes = (_options_strippableSuffixes = options.strippableSuffixes) !== null && _options_strippableSuffixes !== void 0 ? _options_strippableSuffixes : DEFAULT_STRIPPABLE_SUFFIXES;
865
+ function isTagged(anchor) {
866
+ var jsdoc = leadingJsdocFor(sourceCode, anchor);
867
+ var result = false;
868
+ if (jsdoc) {
869
+ var parsed = parseJsdocComment(jsdoc.value);
870
+ result = parsed.tags.some(function(t) {
871
+ return t.tag === markerTag;
872
+ });
873
+ }
874
+ return result;
875
+ }
876
+ function nameMatchesSuffix(name) {
877
+ var matches = name.endsWith(suffix);
878
+ if (!matches) {
879
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
880
+ try {
881
+ for(var _iterator = allowedSuffixes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
882
+ var allowed = _step.value;
883
+ if (name.endsWith(allowed)) {
884
+ matches = true;
885
+ break;
886
+ }
887
+ }
888
+ } catch (err) {
889
+ _didIteratorError = true;
890
+ _iteratorError = err;
891
+ } finally{
892
+ try {
893
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
894
+ _iterator.return();
895
+ }
896
+ } finally{
897
+ if (_didIteratorError) {
898
+ throw _iteratorError;
899
+ }
900
+ }
901
+ }
902
+ }
903
+ return matches;
904
+ }
905
+ function check(node) {
906
+ var anchor = getFunctionJsdocAnchor(node);
907
+ if (!anchor || !isTagged(anchor)) return;
908
+ var name = getFunctionName(node);
909
+ if (!name) {
910
+ context.report({
911
+ node: getFunctionNameNode(node),
912
+ messageId: 'anonymousQueryFactory',
913
+ data: {
914
+ suffix: suffix
915
+ }
916
+ });
917
+ return;
918
+ }
919
+ if (!nameMatchesSuffix(name)) {
920
+ var suggestion = buildRenameSuggestion(name, suffix, strippableSuffixes);
921
+ context.report({
922
+ node: getFunctionNameNode(node),
923
+ messageId: 'queryFactoryNameMustEndWithQuery',
924
+ data: {
925
+ name: name,
926
+ suffix: suffix,
927
+ suggestion: suggestion
928
+ }
929
+ });
930
+ }
931
+ }
932
+ return {
933
+ FunctionDeclaration: function FunctionDeclaration(node) {
934
+ return check(node);
935
+ },
936
+ FunctionExpression: function FunctionExpression(node) {
937
+ return check(node);
938
+ },
939
+ ArrowFunctionExpression: function ArrowFunctionExpression(node) {
940
+ return check(node);
941
+ }
942
+ };
943
+ }
944
+ };
945
+
946
+ function _array_like_to_array(arr, len) {
947
+ if (len == null || len > arr.length) len = arr.length;
948
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
949
+ return arr2;
950
+ }
951
+ function _array_with_holes(arr) {
952
+ if (Array.isArray(arr)) return arr;
953
+ }
954
+ function _iterable_to_array_limit(arr, i) {
955
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
956
+ if (_i == null) return;
957
+ var _arr = [];
958
+ var _n = true;
959
+ var _d = false;
960
+ var _s, _e;
961
+ try {
962
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
963
+ _arr.push(_s.value);
964
+ if (i && _arr.length === i) break;
965
+ }
966
+ } catch (err) {
967
+ _d = true;
968
+ _e = err;
969
+ } finally{
970
+ try {
971
+ if (!_n && _i["return"] != null) _i["return"]();
972
+ } finally{
973
+ if (_d) throw _e;
974
+ }
975
+ }
976
+ return _arr;
977
+ }
978
+ function _non_iterable_rest() {
979
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
980
+ }
981
+ function _sliced_to_array(arr, i) {
982
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
983
+ }
984
+ function _unsupported_iterable_to_array(o, minLen) {
985
+ if (!o) return;
986
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
987
+ var n = Object.prototype.toString.call(o).slice(8, -1);
988
+ if (n === "Object" && o.constructor) n = o.constructor.name;
989
+ if (n === "Map" || n === "Set") return Array.from(n);
990
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
991
+ }
992
+ /**
993
+ * Shared helpers for the `@dbx<Family>` companion-tag ESLint rules. Mirrors the
994
+ * scanner schemas in `packages/dbx-components-mcp/src/scan/*-extract.ts` so
995
+ * violations surface at lint time instead of at manifest-regeneration time.
996
+ *
997
+ * Each per-family rule supplies a {@link DbxTagFamilySpec} describing which
998
+ * companions are required/optional, what value format each accepts, and which
999
+ * messageId to emit when a check fails. The rule body itself only wires the
1000
+ * visitors and message map; all value-format validation lives here.
1001
+ */ /**
1002
+ * Kebab-case slug pattern: lowercase letters/digits, words separated by single hyphens,
1003
+ * starts with a letter. Used to validate slug/related/skill-ref values.
1004
+ */ var KEBAB_SLUG_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
1005
+ /**
1006
+ * Pascal-case TypeScript identifier pattern (starts uppercase). Used for model
1007
+ * identifiers and other `<ModelName>` style tag values.
1008
+ */ var PASCAL_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9_$]*$/;
1009
+ /**
1010
+ * Boolean tag-value vocabulary (case-insensitive). `''` and `true|yes` map to
1011
+ * true; `false|no` map to false. Anything else is flagged as invalid.
1012
+ */ var TRUE_TAG_VALUES = new Set([
1013
+ '',
1014
+ 'true',
1015
+ 'yes'
1016
+ ]);
1017
+ var FALSE_TAG_VALUES = new Set([
1018
+ 'false',
1019
+ 'no'
1020
+ ]);
1021
+ /**
1022
+ * Splits a comma-separated tag-value string into trimmed items, preserving order.
1023
+ *
1024
+ * @param value - Raw text following the tag name on a single line.
1025
+ * @returns Non-empty trimmed segments in declaration order.
1026
+ */ function splitCommaSeparated(value) {
1027
+ return value.split(',').map(function(item) {
1028
+ return item.trim();
1029
+ }).filter(function(item) {
1030
+ return item.length > 0;
1031
+ });
1032
+ }
1033
+ /**
1034
+ * Parses a boolean tag value using the workspace vocabulary
1035
+ * (`''`/`true`/`yes` → true; `false`/`no` → false). Other inputs return `undefined`.
1036
+ *
1037
+ * @param text - The trimmed tag value text.
1038
+ * @returns The parsed boolean, or `undefined` when the text is not in the vocabulary.
1039
+ */ function parseBooleanTagValue(text) {
1040
+ var lowered = text.trim().toLowerCase();
1041
+ var result;
1042
+ if (TRUE_TAG_VALUES.has(lowered)) {
1043
+ result = true;
1044
+ } else if (FALSE_TAG_VALUES.has(lowered)) {
1045
+ result = false;
1046
+ }
1047
+ return result;
1048
+ }
1049
+ /**
1050
+ * Returns the source-text offset of an offset-within-comment-value, given a Block comment node.
1051
+ *
1052
+ * @param commentNode - The ESLint Block comment AST node.
1053
+ * @param valueOffset - The character offset within `comment.value`.
1054
+ * @returns The character offset in the source file.
1055
+ */ function commentValueToSourceOffset(commentNode, valueOffset) {
1056
+ return commentNode.range[0] + 2 + valueOffset;
1057
+ }
1058
+ /**
1059
+ * Returns the family marker + companion tag list for the given parsed JSDoc.
1060
+ * Family membership is determined by tag-name prefix.
1061
+ *
1062
+ * @param parsed - The parsed JSDoc.
1063
+ * @param marker - The bare family marker (e.g. `'dbxPipe'`).
1064
+ * @returns The marker tag (if present), and all companion tags in source order.
1065
+ */ function findFamilyTags(parsed, marker) {
1066
+ var familyTags = parsed.tags.filter(function(t) {
1067
+ return t.tag === marker || t.tag.startsWith(marker);
1068
+ });
1069
+ var markerTag = parsed.tags.find(function(t) {
1070
+ return t.tag === marker;
1071
+ });
1072
+ return {
1073
+ markerTag: markerTag,
1074
+ familyTags: familyTags
1075
+ };
1076
+ }
1077
+ /**
1078
+ * Groups companion tags (those after the marker) by suffix. Marker entries are excluded.
1079
+ *
1080
+ * @param familyTags - The family tag list from {@link findFamilyTags}.
1081
+ * @param marker - The bare family marker.
1082
+ * @returns Lookup keyed by companion-suffix listing matching tags in declaration order.
1083
+ */ function groupCompanionsBySuffix(familyTags, marker) {
1084
+ var result = new Map();
1085
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1086
+ try {
1087
+ for(var _iterator = familyTags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1088
+ var tag = _step.value;
1089
+ var _result_get;
1090
+ if (tag.tag === marker) continue;
1091
+ var suffix = tag.tag.slice(marker.length);
1092
+ var list = (_result_get = result.get(suffix)) !== null && _result_get !== void 0 ? _result_get : [];
1093
+ list.push(tag);
1094
+ result.set(suffix, list);
1095
+ }
1096
+ } catch (err) {
1097
+ _didIteratorError = true;
1098
+ _iteratorError = err;
1099
+ } finally{
1100
+ try {
1101
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1102
+ _iterator.return();
1103
+ }
1104
+ } finally{
1105
+ if (_didIteratorError) {
1106
+ throw _iteratorError;
1107
+ }
1108
+ }
1109
+ }
1110
+ return result;
1111
+ }
1112
+ /**
1113
+ * Per-format validators dispatched from {@link validateCompanionValue}. Each entry validates
1114
+ * a single non-empty tag value and emits zero or more violations.
1115
+ */ var VALUE_VALIDATORS = {
1116
+ marker: function marker() {
1117
+ return undefined;
1118
+ },
1119
+ 'free-text': function() {
1120
+ return undefined;
1121
+ },
1122
+ 'comma-list-free-text': function() {
1123
+ return undefined;
1124
+ },
1125
+ 'kebab-slug': function(param) {
1126
+ var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
1127
+ if (!KEBAB_SLUG_PATTERN.test(value)) emit({
1128
+ kind: 'invalid-kebab',
1129
+ suffix: spec.suffix,
1130
+ value: value,
1131
+ lineIndex: lineIndex
1132
+ });
1133
+ },
1134
+ enum: function _enum(param) {
1135
+ var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
1136
+ var format = spec.format;
1137
+ if (!format.values.includes(value)) emit({
1138
+ kind: 'invalid-enum',
1139
+ suffix: spec.suffix,
1140
+ value: value,
1141
+ allowed: format.values,
1142
+ lineIndex: lineIndex
1143
+ });
1144
+ },
1145
+ 'pascal-identifier': function(param) {
1146
+ var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
1147
+ if (!PASCAL_IDENTIFIER_PATTERN.test(value)) emit({
1148
+ kind: 'invalid-pascal',
1149
+ suffix: spec.suffix,
1150
+ value: value,
1151
+ lineIndex: lineIndex
1152
+ });
1153
+ },
1154
+ 'comma-list-kebab-slug': function(param) {
1155
+ var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
1156
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1157
+ try {
1158
+ for(var _iterator = splitCommaSeparated(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1159
+ var item = _step.value;
1160
+ if (!KEBAB_SLUG_PATTERN.test(item)) emit({
1161
+ kind: 'comma-item-not-kebab',
1162
+ suffix: spec.suffix,
1163
+ value: item,
1164
+ lineIndex: lineIndex
1165
+ });
1166
+ }
1167
+ } catch (err) {
1168
+ _didIteratorError = true;
1169
+ _iteratorError = err;
1170
+ } finally{
1171
+ try {
1172
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1173
+ _iterator.return();
1174
+ }
1175
+ } finally{
1176
+ if (_didIteratorError) {
1177
+ throw _iteratorError;
1178
+ }
1179
+ }
1180
+ }
1181
+ },
1182
+ 'comma-list-lowercase': function(param) {
1183
+ var spec = param.spec, tag = param.tag, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
1184
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1185
+ try {
1186
+ for(var _iterator = splitCommaSeparated(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1187
+ var item = _step.value;
1188
+ if (/[A-Z]/.test(item)) emit({
1189
+ kind: 'tags-not-lowercase',
1190
+ suffix: spec.suffix,
1191
+ value: item,
1192
+ lineIndex: lineIndex,
1193
+ raw: tag
1194
+ });
1195
+ }
1196
+ } catch (err) {
1197
+ _didIteratorError = true;
1198
+ _iteratorError = err;
1199
+ } finally{
1200
+ try {
1201
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1202
+ _iterator.return();
1203
+ }
1204
+ } finally{
1205
+ if (_didIteratorError) {
1206
+ throw _iteratorError;
1207
+ }
1208
+ }
1209
+ }
1210
+ },
1211
+ boolean: function boolean(param) {
1212
+ var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
1213
+ if (parseBooleanTagValue(value) === undefined) emit({
1214
+ kind: 'invalid-boolean',
1215
+ suffix: spec.suffix,
1216
+ value: value,
1217
+ lineIndex: lineIndex
1218
+ });
1219
+ }
1220
+ };
1221
+ /**
1222
+ * Validates one companion tag's value against the configured {@link DbxTagFormat}
1223
+ * and emits zero-or-more violations. Used by {@link checkDbxTagFamily} to keep
1224
+ * each rule's body small.
1225
+ *
1226
+ * @param spec - The companion spec being validated.
1227
+ * @param tags - All occurrences of the companion in source order.
1228
+ * @param emit - Callback for each violation.
1229
+ */ function validateCompanionValue(spec, tags, emit) {
1230
+ if (spec.format.kind === 'marker') return;
1231
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1232
+ try {
1233
+ for(var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1234
+ var tag = _step.value;
1235
+ var value = tag.description.trim();
1236
+ var lineIndex = tag.startLineIndex;
1237
+ if (value.length === 0) {
1238
+ if (spec.format.kind !== 'boolean') emit({
1239
+ kind: 'empty',
1240
+ suffix: spec.suffix,
1241
+ lineIndex: lineIndex
1242
+ });
1243
+ continue;
1244
+ }
1245
+ var validator = VALUE_VALIDATORS[spec.format.kind];
1246
+ if (validator) validator({
1247
+ spec: spec,
1248
+ tag: tag,
1249
+ value: value,
1250
+ lineIndex: lineIndex,
1251
+ emit: emit
1252
+ });
1253
+ }
1254
+ } catch (err) {
1255
+ _didIteratorError = true;
1256
+ _iteratorError = err;
1257
+ } finally{
1258
+ try {
1259
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1260
+ _iterator.return();
1261
+ }
1262
+ } finally{
1263
+ if (_didIteratorError) {
1264
+ throw _iteratorError;
1265
+ }
1266
+ }
1267
+ }
1268
+ }
1269
+ function emitUnknownCompanions(groups, knownSuffixes, emit) {
1270
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1271
+ try {
1272
+ for(var _iterator = groups.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1273
+ var _step_value = _sliced_to_array(_step.value, 2), suffix = _step_value[0], instances = _step_value[1];
1274
+ if (knownSuffixes.has(suffix)) continue;
1275
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1276
+ try {
1277
+ for(var _iterator1 = instances[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1278
+ var tag = _step1.value;
1279
+ emit({
1280
+ kind: 'unknown',
1281
+ suffix: suffix,
1282
+ lineIndex: tag.startLineIndex
1283
+ });
1284
+ }
1285
+ } catch (err) {
1286
+ _didIteratorError1 = true;
1287
+ _iteratorError1 = err;
1288
+ } finally{
1289
+ try {
1290
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1291
+ _iterator1.return();
1292
+ }
1293
+ } finally{
1294
+ if (_didIteratorError1) {
1295
+ throw _iteratorError1;
1296
+ }
1297
+ }
1298
+ }
1299
+ }
1300
+ } catch (err) {
1301
+ _didIteratorError = true;
1302
+ _iteratorError = err;
1303
+ } finally{
1304
+ try {
1305
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1306
+ _iterator.return();
1307
+ }
1308
+ } finally{
1309
+ if (_didIteratorError) {
1310
+ throw _iteratorError;
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ function emitDuplicateCompanions(companion, instances, emit) {
1316
+ for(var i = 1; i < instances.length; i += 1){
1317
+ emit({
1318
+ kind: 'duplicate',
1319
+ suffix: companion.suffix,
1320
+ lineIndex: instances[i].startLineIndex
1321
+ });
1322
+ }
1323
+ }
1324
+ function checkCompanion(input) {
1325
+ var companion = input.companion, instances = input.instances, markerLineIndex = input.markerLineIndex, emit = input.emit;
1326
+ if (instances.length === 0) {
1327
+ if (companion.required) emit({
1328
+ kind: 'missing',
1329
+ suffix: companion.suffix,
1330
+ lineIndex: markerLineIndex
1331
+ });
1332
+ return;
1333
+ }
1334
+ if (!companion.multiple && instances.length > 1) emitDuplicateCompanions(companion, instances, emit);
1335
+ validateCompanionValue(companion, instances, emit);
1336
+ }
1337
+ /**
1338
+ * Validates a `@dbx<Family>` marker plus its companion tags against the supplied spec.
1339
+ * Reports unknown companions, missing required companions, duplicates, and per-companion
1340
+ * value violations through `input.emit`.
1341
+ *
1342
+ * @param input - Parsed JSDoc, family spec, resolved marker/companion tags, and emit sink.
1343
+ *
1344
+ * @example
1345
+ * ```ts
1346
+ * checkDbxTagFamily({ parsed, spec, markerTag, familyTags, emit });
1347
+ * ```
1348
+ */ function checkDbxTagFamily(input) {
1349
+ var spec = input.spec, markerTag = input.markerTag, familyTags = input.familyTags, emit = input.emit;
1350
+ var knownSuffixes = new Set(spec.companions.map(function(c) {
1351
+ return c.suffix;
1352
+ }));
1353
+ var groups = groupCompanionsBySuffix(familyTags, spec.marker);
1354
+ emitUnknownCompanions(groups, knownSuffixes, emit);
1355
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1356
+ try {
1357
+ for(var _iterator = spec.companions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1358
+ var companion = _step.value;
1359
+ var _groups_get;
1360
+ var instances = (_groups_get = groups.get(companion.suffix)) !== null && _groups_get !== void 0 ? _groups_get : [];
1361
+ checkCompanion({
1362
+ companion: companion,
1363
+ instances: instances,
1364
+ markerLineIndex: markerTag.startLineIndex,
1365
+ emit: emit
1366
+ });
1367
+ }
1368
+ } catch (err) {
1369
+ _didIteratorError = true;
1370
+ _iteratorError = err;
1371
+ } finally{
1372
+ try {
1373
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1374
+ _iterator.return();
1375
+ }
1376
+ } finally{
1377
+ if (_didIteratorError) {
1378
+ throw _iteratorError;
1379
+ }
1380
+ }
1381
+ }
1382
+ }
1383
+ /**
1384
+ * Translates a JSDoc-line violation into an ESLint `context.report()` call by computing the
1385
+ * source range of the offending line and attaching the supplied message + optional fixer.
1386
+ *
1387
+ * @param input - Reporting context (comment node, parsed JSDoc, source code, line index, message id, optional data + fixer, report sink).
1388
+ *
1389
+ * @example
1390
+ * ```ts
1391
+ * reportOnJsdocLine({ commentNode, parsed, sourceCode, lineIndex: tag.startLineIndex, messageId: 'unknown', report: context.report });
1392
+ * ```
1393
+ */ function reportOnJsdocLine(input) {
1394
+ var _ref, _ref1;
1395
+ var _line_text;
1396
+ var commentNode = input.commentNode, parsed = input.parsed, sourceCode = input.sourceCode, lineIndex = input.lineIndex, messageId = input.messageId, data = input.data, report = input.report, fix = input.fix;
1397
+ var line = parsed.lines[lineIndex];
1398
+ var startInValue = (_ref = line === null || line === void 0 ? void 0 : line.textOffsetStart) !== null && _ref !== void 0 ? _ref : 0;
1399
+ var endInValue = startInValue + ((_ref1 = line === null || line === void 0 ? void 0 : (_line_text = line.text) === null || _line_text === void 0 ? void 0 : _line_text.length) !== null && _ref1 !== void 0 ? _ref1 : 0);
1400
+ var start = commentValueToSourceOffset(commentNode, startInValue);
1401
+ var end = commentValueToSourceOffset(commentNode, endInValue);
1402
+ report({
1403
+ loc: {
1404
+ type: 'SourceLocation',
1405
+ start: sourceCode.getLocFromIndex(start),
1406
+ end: sourceCode.getLocFromIndex(end)
1407
+ },
1408
+ messageId: messageId,
1409
+ data: data,
1410
+ fix: fix
1411
+ });
1412
+ }
1413
+ /**
1414
+ * Computes an auto-fix descriptor that lowercases every token after a `@dbx<Family>Tags` tag
1415
+ * name. Returns `undefined` when the line is already canonical so the caller can short-circuit.
1416
+ *
1417
+ * @param input - Fix context (comment node, parsed JSDoc, source code, target tag).
1418
+ * @returns Replacement range + text when a rewrite is needed; otherwise `undefined`.
1419
+ *
1420
+ * @example
1421
+ * ```ts
1422
+ * const fix = buildLowercaseTagsFix({ commentNode, parsed, sourceCode, tag });
1423
+ * ```
1424
+ */ function buildLowercaseTagsFix(input) {
1425
+ var commentNode = input.commentNode, parsed = input.parsed, sourceCode = input.sourceCode, tag = input.tag;
1426
+ var tagLine = parsed.lines[tag.startLineIndex];
1427
+ var result;
1428
+ if (tagLine) {
1429
+ var tagLineSourceStart = commentValueToSourceOffset(commentNode, tagLine.textOffsetStart);
1430
+ var tagLineSourceEnd = tagLineSourceStart + tagLine.text.length;
1431
+ var sourceText = sourceCode.getText();
1432
+ var lineSource = sourceText.slice(tagLineSourceStart, tagLineSourceEnd);
1433
+ var lowered = lineSource.replace(/^(@[A-Za-z]+\s+)(.*)$/, function(_match, prefix, body) {
1434
+ return "".concat(prefix).concat(body.toLowerCase());
1435
+ });
1436
+ if (lowered !== lineSource) {
1437
+ result = {
1438
+ startOffset: tagLineSourceStart,
1439
+ endOffset: tagLineSourceEnd,
1440
+ replacement: lowered
1441
+ };
1442
+ }
1443
+ }
1444
+ return result;
1445
+ }
1446
+
1447
+ function _type_of$1(obj) {
1448
+ "@swc/helpers - typeof";
1449
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1450
+ }
1451
+ var DEFAULT_ALLOWED_SCOPES = [
1452
+ 'COLLECTION',
1453
+ 'COLLECTION_GROUP'
1454
+ ];
1455
+ var DEFAULT_KNOWN_COMPANIONS = [
1456
+ 'Slug',
1457
+ 'Model',
1458
+ 'Scope',
1459
+ 'Dispatcher',
1460
+ 'Manual',
1461
+ 'Skip',
1462
+ 'AllowArrayContainsAny',
1463
+ 'Category',
1464
+ 'Tags',
1465
+ 'Related',
1466
+ 'SkillRefs',
1467
+ 'Path',
1468
+ 'Helper'
1469
+ ];
1470
+ /**
1471
+ * ESLint rule enforcing `@dbxModelFirebaseIndex` companion tags and body coherence.
1472
+ * Mirrors the scanner schema at
1473
+ * `packages/dbx-components-mcp/src/scan/model-firebase-index-extract.ts` (companion tag
1474
+ * validation) and additionally cross-checks the function body so the tag stays in sync
1475
+ * with the constraint calls it advertises.
1476
+ */ var FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_COMPANION_TAGS_RULE = {
1477
+ meta: {
1478
+ type: 'suggestion',
1479
+ fixable: 'code',
1480
+ docs: {
1481
+ description: 'Require the canonical `@dbxModelFirebaseIndex*` companion tags on `@dbxModelFirebaseIndex`-tagged factories and verify the body matches the declared model.',
1482
+ recommended: true
1483
+ },
1484
+ messages: {
1485
+ missingModel: '`@dbxModelFirebaseIndex`-tagged factory is missing the required `@dbxModelFirebaseIndexModel <ModelName>` companion tag.',
1486
+ invalidModelIdentifier: '`@dbxModelFirebaseIndexModel` value `{{value}}` is not a valid PascalCase identifier.',
1487
+ invalidScope: '`@dbxModelFirebaseIndexScope` value `{{value}}` is not allowed. Use one of: {{allowed}}.',
1488
+ invalidBooleanValue: '`@dbxModelFirebaseIndex{{name}}` value `{{value}}` is not a recognized boolean.',
1489
+ slugNotKebab: '`@dbxModelFirebaseIndexSlug` value `{{value}}` is not a valid kebab-case slug.',
1490
+ tagsNotLowercase: '`@dbxModelFirebaseIndexTags` token `{{value}}` contains uppercase characters; tokens should be lowercase.',
1491
+ relatedNotKebab: '`@dbxModelFirebaseIndexRelated` item `{{value}}` is not a kebab-case slug.',
1492
+ skillRefsNotKebab: '`@dbxModelFirebaseIndexSkillRefs` item `{{value}}` is not a kebab-case slug.',
1493
+ unknownDbxModelFirebaseIndexTag: '`@dbxModelFirebaseIndex{{name}}` is not a recognized companion tag. Known companions: {{known}}.',
1494
+ duplicateCompanionTag: '`@dbxModelFirebaseIndex{{name}}` is declared more than once.',
1495
+ taggedFactoryHasNoConstraints: '`@dbxModelFirebaseIndex`-tagged factory `{{name}}` contains no `@dereekb/firebase` constraint calls. Add at least one (`where`/`orderBy`/...) or mark it `@dbxModelFirebaseIndexSkip true`.',
1496
+ modelTagMismatchesGenericArg: '`@dbxModelFirebaseIndexModel` is `{{tagValue}}` but the body uses `{{constraint}}<{{generic}}>(...)`. They should match.',
1497
+ nonLiteralFieldPathInTaggedQuery: 'Field path passed to `{{constraint}}(...)` in a `@dbxModelFirebaseIndex`-tagged factory must be a string literal so dbx-components-mcp can extract it.'
1498
+ },
1499
+ schema: [
1500
+ {
1501
+ type: 'object',
1502
+ additionalProperties: false,
1503
+ properties: {
1504
+ allowedScopes: {
1505
+ type: 'array',
1506
+ items: {
1507
+ type: 'string'
1508
+ }
1509
+ },
1510
+ knownCompanions: {
1511
+ type: 'array',
1512
+ items: {
1513
+ type: 'string'
1514
+ }
1515
+ },
1516
+ requireBareMarker: {
1517
+ type: 'boolean'
1518
+ },
1519
+ constraintNames: {
1520
+ type: 'array',
1521
+ items: {
1522
+ type: 'string'
1523
+ }
1524
+ },
1525
+ allowDynamicFieldPaths: {
1526
+ type: 'boolean'
1527
+ },
1528
+ checkBodyCoherence: {
1529
+ type: 'boolean'
1530
+ }
1531
+ }
1532
+ }
1533
+ ]
1534
+ },
1535
+ create: function create(context) {
1536
+ var _context_options_, _options_allowedScopes, _options_knownCompanions, _options_constraintNames;
1537
+ var options = (_context_options_ = context.options[0]) !== null && _context_options_ !== void 0 ? _context_options_ : {};
1538
+ var sourceCode = context.sourceCode;
1539
+ var allowedScopes = (_options_allowedScopes = options.allowedScopes) !== null && _options_allowedScopes !== void 0 ? _options_allowedScopes : DEFAULT_ALLOWED_SCOPES;
1540
+ var knownCompanions = (_options_knownCompanions = options.knownCompanions) !== null && _options_knownCompanions !== void 0 ? _options_knownCompanions : DEFAULT_KNOWN_COMPANIONS;
1541
+ var requireBareMarker = options.requireBareMarker !== false;
1542
+ var constraintNames = new Set((_options_constraintNames = options.constraintNames) !== null && _options_constraintNames !== void 0 ? _options_constraintNames : DEFAULT_CONSTRAINT_FACTORY_NAMES);
1543
+ var allowDynamicFieldPaths = options.allowDynamicFieldPaths === true;
1544
+ var checkBodyCoherence = options.checkBodyCoherence !== false;
1545
+ var allCompanions = [
1546
+ {
1547
+ suffix: 'Slug',
1548
+ format: {
1549
+ kind: 'kebab-slug'
1550
+ }
1551
+ },
1552
+ {
1553
+ suffix: 'Model',
1554
+ required: true,
1555
+ format: {
1556
+ kind: 'pascal-identifier'
1557
+ }
1558
+ },
1559
+ {
1560
+ suffix: 'Scope',
1561
+ format: {
1562
+ kind: 'enum',
1563
+ values: allowedScopes
1564
+ }
1565
+ },
1566
+ {
1567
+ suffix: 'Dispatcher',
1568
+ format: {
1569
+ kind: 'boolean'
1570
+ }
1571
+ },
1572
+ {
1573
+ suffix: 'Manual',
1574
+ format: {
1575
+ kind: 'boolean'
1576
+ }
1577
+ },
1578
+ {
1579
+ suffix: 'Skip',
1580
+ format: {
1581
+ kind: 'boolean'
1582
+ }
1583
+ },
1584
+ {
1585
+ suffix: 'AllowArrayContainsAny',
1586
+ format: {
1587
+ kind: 'boolean'
1588
+ }
1589
+ },
1590
+ {
1591
+ suffix: 'Category',
1592
+ format: {
1593
+ kind: 'free-text'
1594
+ }
1595
+ },
1596
+ {
1597
+ suffix: 'Tags',
1598
+ format: {
1599
+ kind: 'comma-list-lowercase'
1600
+ }
1601
+ },
1602
+ {
1603
+ suffix: 'Related',
1604
+ format: {
1605
+ kind: 'comma-list-kebab-slug'
1606
+ }
1607
+ },
1608
+ {
1609
+ suffix: 'SkillRefs',
1610
+ format: {
1611
+ kind: 'comma-list-kebab-slug'
1612
+ }
1613
+ },
1614
+ {
1615
+ suffix: 'Path',
1616
+ multiple: true,
1617
+ format: {
1618
+ kind: 'comma-list-free-text'
1619
+ }
1620
+ },
1621
+ {
1622
+ suffix: 'Helper',
1623
+ format: {
1624
+ kind: 'free-text'
1625
+ }
1626
+ }
1627
+ ];
1628
+ var spec = {
1629
+ marker: DBX_MODEL_FIREBASE_INDEX_MARKER,
1630
+ companions: allCompanions.filter(function(c) {
1631
+ return knownCompanions.includes(c.suffix);
1632
+ })
1633
+ };
1634
+ function handleCommaItem(input) {
1635
+ var commentNode = input.commentNode, parsed = input.parsed, suffix = input.suffix, value = input.value, lineIndex = input.lineIndex;
1636
+ if (suffix === 'Related') reportOnJsdocLine({
1637
+ commentNode: commentNode,
1638
+ parsed: parsed,
1639
+ sourceCode: sourceCode,
1640
+ lineIndex: lineIndex,
1641
+ messageId: 'relatedNotKebab',
1642
+ data: {
1643
+ value: value
1644
+ },
1645
+ report: context.report
1646
+ });
1647
+ else if (suffix === 'SkillRefs') reportOnJsdocLine({
1648
+ commentNode: commentNode,
1649
+ parsed: parsed,
1650
+ sourceCode: sourceCode,
1651
+ lineIndex: lineIndex,
1652
+ messageId: 'skillRefsNotKebab',
1653
+ data: {
1654
+ value: value
1655
+ },
1656
+ report: context.report
1657
+ });
1658
+ }
1659
+ function handleTagsNotLowercase(commentNode, parsed, v) {
1660
+ if (v.suffix !== 'Tags') return;
1661
+ var fix = buildLowercaseTagsFix({
1662
+ commentNode: commentNode,
1663
+ parsed: parsed,
1664
+ sourceCode: sourceCode,
1665
+ tag: v.raw
1666
+ });
1667
+ var fixer = fix ? function(fixer2) {
1668
+ return fixer2.replaceTextRange([
1669
+ fix.startOffset,
1670
+ fix.endOffset
1671
+ ], fix.replacement);
1672
+ } : undefined;
1673
+ reportOnJsdocLine({
1674
+ commentNode: commentNode,
1675
+ parsed: parsed,
1676
+ sourceCode: sourceCode,
1677
+ lineIndex: v.lineIndex,
1678
+ messageId: 'tagsNotLowercase',
1679
+ data: {
1680
+ value: v.value
1681
+ },
1682
+ report: context.report,
1683
+ fix: fixer
1684
+ });
1685
+ }
1686
+ function handleViolation(commentNode, parsed, v) {
1687
+ switch(v.kind){
1688
+ case 'missing':
1689
+ case 'empty':
1690
+ if (v.suffix === 'Model') reportOnJsdocLine({
1691
+ commentNode: commentNode,
1692
+ parsed: parsed,
1693
+ sourceCode: sourceCode,
1694
+ lineIndex: v.lineIndex,
1695
+ messageId: 'missingModel',
1696
+ report: context.report
1697
+ });
1698
+ break;
1699
+ case 'invalid-kebab':
1700
+ if (v.suffix === 'Slug') reportOnJsdocLine({
1701
+ commentNode: commentNode,
1702
+ parsed: parsed,
1703
+ sourceCode: sourceCode,
1704
+ lineIndex: v.lineIndex,
1705
+ messageId: 'slugNotKebab',
1706
+ data: {
1707
+ value: v.value
1708
+ },
1709
+ report: context.report
1710
+ });
1711
+ break;
1712
+ case 'invalid-pascal':
1713
+ if (v.suffix === 'Model') reportOnJsdocLine({
1714
+ commentNode: commentNode,
1715
+ parsed: parsed,
1716
+ sourceCode: sourceCode,
1717
+ lineIndex: v.lineIndex,
1718
+ messageId: 'invalidModelIdentifier',
1719
+ data: {
1720
+ value: v.value
1721
+ },
1722
+ report: context.report
1723
+ });
1724
+ break;
1725
+ case 'invalid-enum':
1726
+ if (v.suffix === 'Scope') reportOnJsdocLine({
1727
+ commentNode: commentNode,
1728
+ parsed: parsed,
1729
+ sourceCode: sourceCode,
1730
+ lineIndex: v.lineIndex,
1731
+ messageId: 'invalidScope',
1732
+ data: {
1733
+ value: v.value,
1734
+ allowed: v.allowed.join(', ')
1735
+ },
1736
+ report: context.report
1737
+ });
1738
+ break;
1739
+ case 'invalid-boolean':
1740
+ reportOnJsdocLine({
1741
+ commentNode: commentNode,
1742
+ parsed: parsed,
1743
+ sourceCode: sourceCode,
1744
+ lineIndex: v.lineIndex,
1745
+ messageId: 'invalidBooleanValue',
1746
+ data: {
1747
+ name: v.suffix,
1748
+ value: v.value
1749
+ },
1750
+ report: context.report
1751
+ });
1752
+ break;
1753
+ case 'comma-item-not-kebab':
1754
+ handleCommaItem({
1755
+ commentNode: commentNode,
1756
+ parsed: parsed,
1757
+ suffix: v.suffix,
1758
+ value: v.value,
1759
+ lineIndex: v.lineIndex
1760
+ });
1761
+ break;
1762
+ case 'tags-not-lowercase':
1763
+ handleTagsNotLowercase(commentNode, parsed, v);
1764
+ break;
1765
+ case 'unknown':
1766
+ reportOnJsdocLine({
1767
+ commentNode: commentNode,
1768
+ parsed: parsed,
1769
+ sourceCode: sourceCode,
1770
+ lineIndex: v.lineIndex,
1771
+ messageId: 'unknownDbxModelFirebaseIndexTag',
1772
+ data: {
1773
+ name: v.suffix,
1774
+ known: knownCompanions.join(', ')
1775
+ },
1776
+ report: context.report
1777
+ });
1778
+ break;
1779
+ case 'duplicate':
1780
+ reportOnJsdocLine({
1781
+ commentNode: commentNode,
1782
+ parsed: parsed,
1783
+ sourceCode: sourceCode,
1784
+ lineIndex: v.lineIndex,
1785
+ messageId: 'duplicateCompanionTag',
1786
+ data: {
1787
+ name: v.suffix
1788
+ },
1789
+ report: context.report
1790
+ });
1791
+ break;
1792
+ }
1793
+ }
1794
+ function checkJsdoc(commentNode, parsed) {
1795
+ var _findFamilyTags = findFamilyTags(parsed, spec.marker), markerTag = _findFamilyTags.markerTag, familyTags = _findFamilyTags.familyTags;
1796
+ if (familyTags.length === 0 || requireBareMarker && !markerTag) return;
1797
+ var triggerTag = markerTag !== null && markerTag !== void 0 ? markerTag : familyTags[0];
1798
+ checkDbxTagFamily({
1799
+ spec: spec,
1800
+ markerTag: triggerTag,
1801
+ familyTags: familyTags,
1802
+ emit: function emit(v) {
1803
+ return handleViolation(commentNode, parsed, v);
1804
+ }
1805
+ });
1806
+ }
1807
+ function getModelTagValue(parsed) {
1808
+ var tag = parsed.tags.find(function(t) {
1809
+ return t.tag === "".concat(DBX_MODEL_FIREBASE_INDEX_MARKER, "Model");
1810
+ });
1811
+ return tag ? tag.description.trim() : null;
1812
+ }
1813
+ function getSkipTagValue(parsed) {
1814
+ var tag = parsed.tags.find(function(t) {
1815
+ return t.tag === "".concat(DBX_MODEL_FIREBASE_INDEX_MARKER, "Skip");
1816
+ });
1817
+ var result = false;
1818
+ if (tag) {
1819
+ var value = parseBooleanTagValue(tag.description.trim());
1820
+ result = value === true;
1821
+ }
1822
+ return result;
1823
+ }
1824
+ function collectConstraintCallsIntoArray(node, results) {
1825
+ var _node_callee;
1826
+ if (!node || (typeof node === "undefined" ? "undefined" : _type_of$1(node)) !== 'object') return;
1827
+ if (node.type === 'CallExpression' && ((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === 'Identifier' && constraintNames.has(node.callee.name)) {
1828
+ var _node_arguments;
1829
+ var genericName = extractGenericIdentifier(node);
1830
+ var firstArg = (_node_arguments = node.arguments) === null || _node_arguments === void 0 ? void 0 : _node_arguments[0];
1831
+ var fieldPathArgIsLiteral = (firstArg === null || firstArg === void 0 ? void 0 : firstArg.type) === 'Literal' && typeof firstArg.value === 'string';
1832
+ results.push({
1833
+ node: node,
1834
+ name: node.callee.name,
1835
+ genericName: genericName,
1836
+ fieldPathArgIsLiteral: fieldPathArgIsLiteral
1837
+ });
1838
+ }
1839
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1840
+ try {
1841
+ for(var _iterator = Object.keys(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1842
+ var key = _step.value;
1843
+ if (key === 'parent') continue;
1844
+ var value = node[key];
1845
+ if (Array.isArray(value)) {
1846
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1847
+ try {
1848
+ for(var _iterator1 = value[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1849
+ var child = _step1.value;
1850
+ if (child && (typeof child === "undefined" ? "undefined" : _type_of$1(child)) === 'object' && typeof child.type === 'string') collectConstraintCallsIntoArray(child, results);
1851
+ }
1852
+ } catch (err) {
1853
+ _didIteratorError1 = true;
1854
+ _iteratorError1 = err;
1855
+ } finally{
1856
+ try {
1857
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1858
+ _iterator1.return();
1859
+ }
1860
+ } finally{
1861
+ if (_didIteratorError1) {
1862
+ throw _iteratorError1;
1863
+ }
1864
+ }
1865
+ }
1866
+ } else if (value && (typeof value === "undefined" ? "undefined" : _type_of$1(value)) === 'object' && typeof value.type === 'string') {
1867
+ collectConstraintCallsIntoArray(value, results);
1868
+ }
1869
+ }
1870
+ } catch (err) {
1871
+ _didIteratorError = true;
1872
+ _iteratorError = err;
1873
+ } finally{
1874
+ try {
1875
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1876
+ _iterator.return();
1877
+ }
1878
+ } finally{
1879
+ if (_didIteratorError) {
1880
+ throw _iteratorError;
1881
+ }
1882
+ }
1883
+ }
1884
+ }
1885
+ function extractGenericIdentifier(callNode) {
1886
+ var _callNode_typeArguments;
1887
+ var params = (_callNode_typeArguments = callNode.typeArguments) !== null && _callNode_typeArguments !== void 0 ? _callNode_typeArguments : callNode.typeParameters;
1888
+ var result = null;
1889
+ if (params && Array.isArray(params.params) && params.params.length > 0) {
1890
+ var _first_typeName;
1891
+ var first = params.params[0];
1892
+ if ((first === null || first === void 0 ? void 0 : first.type) === 'TSTypeReference' && ((_first_typeName = first.typeName) === null || _first_typeName === void 0 ? void 0 : _first_typeName.type) === 'Identifier') {
1893
+ result = first.typeName.name;
1894
+ }
1895
+ }
1896
+ return result;
1897
+ }
1898
+ function checkBody(node, parsed) {
1899
+ if (!checkBodyCoherence) return;
1900
+ var skip = getSkipTagValue(parsed);
1901
+ if (skip) return;
1902
+ var calls = [];
1903
+ if (node.body) collectConstraintCallsIntoArray(node.body, calls);
1904
+ if (calls.length === 0) {
1905
+ var _getFunctionName, _node_id;
1906
+ var name = (_getFunctionName = getFunctionName(node)) !== null && _getFunctionName !== void 0 ? _getFunctionName : '<anonymous>';
1907
+ context.report({
1908
+ node: (_node_id = node.id) !== null && _node_id !== void 0 ? _node_id : node,
1909
+ messageId: 'taggedFactoryHasNoConstraints',
1910
+ data: {
1911
+ name: name
1912
+ }
1913
+ });
1914
+ return;
1915
+ }
1916
+ var modelTagValue = getModelTagValue(parsed);
1917
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1918
+ try {
1919
+ for(var _iterator = calls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1920
+ var call = _step.value;
1921
+ if (modelTagValue && call.genericName && call.genericName !== modelTagValue) {
1922
+ context.report({
1923
+ node: call.node,
1924
+ messageId: 'modelTagMismatchesGenericArg',
1925
+ data: {
1926
+ tagValue: modelTagValue,
1927
+ constraint: call.name,
1928
+ generic: call.genericName
1929
+ }
1930
+ });
1931
+ }
1932
+ if (!allowDynamicFieldPaths && !call.fieldPathArgIsLiteral && call.name !== 'limit' && call.name !== 'limitToLast' && call.name !== 'startAt' && call.name !== 'startAfter' && call.name !== 'endAt' && call.name !== 'endBefore') {
1933
+ context.report({
1934
+ node: call.node,
1935
+ messageId: 'nonLiteralFieldPathInTaggedQuery',
1936
+ data: {
1937
+ constraint: call.name
1938
+ }
1939
+ });
1940
+ }
1941
+ }
1942
+ } catch (err) {
1943
+ _didIteratorError = true;
1944
+ _iteratorError = err;
1945
+ } finally{
1946
+ try {
1947
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1948
+ _iterator.return();
1949
+ }
1950
+ } finally{
1951
+ if (_didIteratorError) {
1952
+ throw _iteratorError;
1953
+ }
1954
+ }
1955
+ }
1956
+ }
1957
+ function checkFunction(node) {
1958
+ if (!node.body) return;
1959
+ var anchor = node.parent && (node.parent.type === 'ExportNamedDeclaration' || node.parent.type === 'ExportDefaultDeclaration') ? node.parent : node;
1960
+ var commentNode = leadingJsdocFor(sourceCode, getStatementAnchor(anchor));
1961
+ if (!commentNode) return;
1962
+ var parsed = parseJsdocComment(commentNode.value);
1963
+ var markerTag = findFamilyTags(parsed, spec.marker).markerTag;
1964
+ if (!markerTag && requireBareMarker) return;
1965
+ checkJsdoc(commentNode, parsed);
1966
+ checkBody(node, parsed);
1967
+ }
1968
+ return {
1969
+ FunctionDeclaration: function FunctionDeclaration(node) {
1970
+ return checkFunction(node);
1971
+ }
1972
+ };
1973
+ }
1974
+ };
1975
+
1976
+ function _type_of(obj) {
1977
+ "@swc/helpers - typeof";
1978
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1979
+ }
1980
+ /**
1981
+ * Default JSDoc tag name used to mark a factory as an index dispatcher (boolean tag).
1982
+ */ var DEFAULT_DISPATCHER_TAG = 'dbxModelFirebaseIndexDispatcher';
1983
+ /**
1984
+ * Default suffix used to recognise a presumed-tagged query factory by name (single-file scope).
1985
+ */ var DEFAULT_PRESUMED_TAGGED_SUFFIX = 'Query';
1986
+ /**
1987
+ * ESLint rule enforcing that `@dbxModelFirebaseIndexDispatcher`-tagged factories delegate to
1988
+ * other `@dbxModelFirebaseIndex`-tagged query factories instead of building constraints directly.
1989
+ *
1990
+ * A dispatcher must never:
1991
+ *
1992
+ * 1. Call a `@dereekb/firebase` constraint factory (`where`/`orderBy`/`limit`/...) directly.
1993
+ * 2. Construct its own `FirestoreQueryConstraint[]` array via `[].push(...)`-style assembly.
1994
+ *
1995
+ * Permitted bodies return another tagged factory's result directly, spread several tagged
1996
+ * factories' results into a return array, or use a conditional to pick between tagged
1997
+ * factories — matching the dispatcher pattern documented at
1998
+ * `packages/dbx-components-mcp/src/tools/validate-app-model-firebase-index.tool.ts`.
1999
+ *
2000
+ * Not auto-fixable: extracting an inline constraint into a sibling tagged factory requires
2001
+ * choosing a name + signature + call-site replacement that is outside the safe scope of an
2002
+ * ESLint autofix.
2003
+ */ var FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_VALID_DISPATCHER_RULE = {
2004
+ meta: {
2005
+ type: 'problem',
2006
+ fixable: undefined,
2007
+ docs: {
2008
+ description: 'Disallow inline `@dereekb/firebase` constraint factory calls and ad-hoc constraint-array construction inside `@dbxModelFirebaseIndexDispatcher`-tagged factories. Dispatchers must delegate to other `@dbxModelFirebaseIndex`-tagged `*Query` factories.',
2009
+ recommended: true
2010
+ },
2011
+ messages: {
2012
+ dispatcherUsesInlineConstraint: '`{{name}}(...)` from `@dereekb/firebase` is not allowed inside a `@dbxModelFirebaseIndexDispatcher`-tagged factory. Dispatchers must call other `@dbxModelFirebaseIndex`-tagged query factories instead of building constraints directly.',
2013
+ dispatcherBuildsConstraintArray: '`@dbxModelFirebaseIndexDispatcher`-tagged factories must not construct their own constraint arrays. Return the result of other tagged `*Query` factories directly (or spread them into a return array).'
2014
+ },
2015
+ schema: [
2016
+ {
2017
+ type: 'object',
2018
+ additionalProperties: false,
2019
+ properties: {
2020
+ constraintNames: {
2021
+ type: 'array',
2022
+ items: {
2023
+ type: 'string'
2024
+ }
2025
+ },
2026
+ allowedImportSources: {
2027
+ type: 'array',
2028
+ items: {
2029
+ type: 'string'
2030
+ }
2031
+ },
2032
+ markerTag: {
2033
+ type: 'string'
2034
+ },
2035
+ dispatcherTag: {
2036
+ type: 'string'
2037
+ },
2038
+ presumedTaggedSuffix: {
2039
+ type: 'string'
2040
+ }
2041
+ }
2042
+ }
2043
+ ]
2044
+ },
2045
+ create: function create(context) {
2046
+ var _context_options_, _options_constraintNames, _options_allowedImportSources, _options_markerTag, _options_dispatcherTag, _options_presumedTaggedSuffix;
2047
+ var options = (_context_options_ = context.options[0]) !== null && _context_options_ !== void 0 ? _context_options_ : {};
2048
+ var sourceCode = context.sourceCode;
2049
+ var constraintNames = new Set((_options_constraintNames = options.constraintNames) !== null && _options_constraintNames !== void 0 ? _options_constraintNames : DEFAULT_CONSTRAINT_FACTORY_NAMES);
2050
+ var allowedSources = new Set((_options_allowedImportSources = options.allowedImportSources) !== null && _options_allowedImportSources !== void 0 ? _options_allowedImportSources : [
2051
+ FIREBASE_MODULE
2052
+ ]);
2053
+ var markerTag = (_options_markerTag = options.markerTag) !== null && _options_markerTag !== void 0 ? _options_markerTag : DBX_MODEL_FIREBASE_INDEX_MARKER;
2054
+ var dispatcherTagName = (_options_dispatcherTag = options.dispatcherTag) !== null && _options_dispatcherTag !== void 0 ? _options_dispatcherTag : DEFAULT_DISPATCHER_TAG;
2055
+ // presumedTaggedSuffix is reserved for future heuristics — the current detection only flags
2056
+ // disallowed patterns, so callee-name allow-listing is not consulted here. Read it once so the
2057
+ // option stays documented and validated against the schema.
2058
+ (_options_presumedTaggedSuffix = options.presumedTaggedSuffix) !== null && _options_presumedTaggedSuffix !== void 0 ? _options_presumedTaggedSuffix : DEFAULT_PRESUMED_TAGGED_SUFFIX;
2059
+ var registry = createImportRegistry();
2060
+ function jsdocFlagsDispatcher(anchor) {
2061
+ var jsdoc = leadingJsdocFor(sourceCode, anchor);
2062
+ var result = false;
2063
+ if (jsdoc) {
2064
+ var parsed = parseJsdocComment(jsdoc.value);
2065
+ var hasMarker = parsed.tags.some(function(t) {
2066
+ return t.tag === markerTag;
2067
+ });
2068
+ if (hasMarker) {
2069
+ var dispatcherTag = parsed.tags.find(function(t) {
2070
+ return t.tag === dispatcherTagName;
2071
+ });
2072
+ if (dispatcherTag) {
2073
+ var value = parseBooleanTagValue(dispatcherTag.description.trim());
2074
+ result = value === true;
2075
+ }
2076
+ }
2077
+ }
2078
+ return result;
2079
+ }
2080
+ function resolveConstraintCallName(node) {
2081
+ var _node_callee;
2082
+ var result = null;
2083
+ if (((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === 'Identifier') {
2084
+ var localName = node.callee.name;
2085
+ var source = registry.localToSource.get(localName);
2086
+ if (source && allowedSources.has(source) && isImportedFrom(registry, localName, source)) {
2087
+ var _registry_localToImported_get;
2088
+ var importedName = (_registry_localToImported_get = registry.localToImported.get(localName)) !== null && _registry_localToImported_get !== void 0 ? _registry_localToImported_get : localName;
2089
+ if (constraintNames.has(importedName)) {
2090
+ result = importedName;
2091
+ }
2092
+ }
2093
+ }
2094
+ return result;
2095
+ }
2096
+ function recordCallExpression(node, constraintCalls, pushReceivers) {
2097
+ var _node_callee, _node_callee_property, _node_callee_object;
2098
+ var constraintName = resolveConstraintCallName(node);
2099
+ if (constraintName) {
2100
+ constraintCalls.push({
2101
+ node: node,
2102
+ name: constraintName
2103
+ });
2104
+ }
2105
+ if (((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === 'MemberExpression' && ((_node_callee_property = node.callee.property) === null || _node_callee_property === void 0 ? void 0 : _node_callee_property.type) === 'Identifier' && node.callee.property.name === 'push' && ((_node_callee_object = node.callee.object) === null || _node_callee_object === void 0 ? void 0 : _node_callee_object.type) === 'Identifier') {
2106
+ pushReceivers.add(node.callee.object.name);
2107
+ }
2108
+ }
2109
+ function recordVariableDeclarator(node, emptyArrayDeclarators) {
2110
+ var _node_id, _node_init;
2111
+ if (((_node_id = node.id) === null || _node_id === void 0 ? void 0 : _node_id.type) === 'Identifier' && ((_node_init = node.init) === null || _node_init === void 0 ? void 0 : _node_init.type) === 'ArrayExpression' && Array.isArray(node.init.elements) && node.init.elements.length === 0) {
2112
+ emptyArrayDeclarators.push({
2113
+ node: node,
2114
+ name: node.id.name
2115
+ });
2116
+ }
2117
+ }
2118
+ function scanBody(body) {
2119
+ var constraintCalls = [];
2120
+ var emptyArrayDeclarators = [];
2121
+ var pushReceivers = new Set();
2122
+ function visit(node) {
2123
+ if (!node || (typeof node === "undefined" ? "undefined" : _type_of(node)) !== 'object') return;
2124
+ if (node.type === 'CallExpression') {
2125
+ recordCallExpression(node, constraintCalls, pushReceivers);
2126
+ } else if (node.type === 'VariableDeclarator') {
2127
+ recordVariableDeclarator(node, emptyArrayDeclarators);
2128
+ }
2129
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2130
+ try {
2131
+ for(var _iterator = Object.keys(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2132
+ var key = _step.value;
2133
+ if (key === 'parent') continue;
2134
+ var value = node[key];
2135
+ if (Array.isArray(value)) {
2136
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2137
+ try {
2138
+ for(var _iterator1 = value[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2139
+ var child = _step1.value;
2140
+ if (child && (typeof child === "undefined" ? "undefined" : _type_of(child)) === 'object' && typeof child.type === 'string') visit(child);
2141
+ }
2142
+ } catch (err) {
2143
+ _didIteratorError1 = true;
2144
+ _iteratorError1 = err;
2145
+ } finally{
2146
+ try {
2147
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2148
+ _iterator1.return();
2149
+ }
2150
+ } finally{
2151
+ if (_didIteratorError1) {
2152
+ throw _iteratorError1;
2153
+ }
2154
+ }
2155
+ }
2156
+ } else if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && typeof value.type === 'string') {
2157
+ visit(value);
2158
+ }
2159
+ }
2160
+ } catch (err) {
2161
+ _didIteratorError = true;
2162
+ _iteratorError = err;
2163
+ } finally{
2164
+ try {
2165
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2166
+ _iterator.return();
2167
+ }
2168
+ } finally{
2169
+ if (_didIteratorError) {
2170
+ throw _iteratorError;
2171
+ }
2172
+ }
2173
+ }
2174
+ }
2175
+ visit(body);
2176
+ return {
2177
+ constraintCalls: constraintCalls,
2178
+ emptyArrayDeclarators: emptyArrayDeclarators,
2179
+ pushReceivers: pushReceivers
2180
+ };
2181
+ }
2182
+ function reportViolations(scan) {
2183
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2184
+ try {
2185
+ for(var _iterator = scan.constraintCalls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2186
+ var call = _step.value;
2187
+ context.report({
2188
+ node: call.node,
2189
+ messageId: 'dispatcherUsesInlineConstraint',
2190
+ data: {
2191
+ name: call.name
2192
+ }
2193
+ });
2194
+ }
2195
+ } catch (err) {
2196
+ _didIteratorError = true;
2197
+ _iteratorError = err;
2198
+ } finally{
2199
+ try {
2200
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2201
+ _iterator.return();
2202
+ }
2203
+ } finally{
2204
+ if (_didIteratorError) {
2205
+ throw _iteratorError;
2206
+ }
2207
+ }
2208
+ }
2209
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2210
+ try {
2211
+ for(var _iterator1 = scan.emptyArrayDeclarators[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2212
+ var decl = _step1.value;
2213
+ if (scan.pushReceivers.has(decl.name)) {
2214
+ context.report({
2215
+ node: decl.node,
2216
+ messageId: 'dispatcherBuildsConstraintArray'
2217
+ });
2218
+ }
2219
+ }
2220
+ } catch (err) {
2221
+ _didIteratorError1 = true;
2222
+ _iteratorError1 = err;
2223
+ } finally{
2224
+ try {
2225
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2226
+ _iterator1.return();
2227
+ }
2228
+ } finally{
2229
+ if (_didIteratorError1) {
2230
+ throw _iteratorError1;
2231
+ }
2232
+ }
2233
+ }
2234
+ }
2235
+ function check(node) {
2236
+ if (!node.body) return;
2237
+ var anchor = getFunctionJsdocAnchor(node);
2238
+ if (!anchor) return;
2239
+ if (!jsdocFlagsDispatcher(anchor)) return;
2240
+ var scan = scanBody(node.body);
2241
+ reportViolations(scan);
2242
+ }
2243
+ return {
2244
+ ImportDeclaration: function ImportDeclaration(node) {
2245
+ return trackImportDeclaration(registry, node);
2246
+ },
2247
+ FunctionDeclaration: function FunctionDeclaration(node) {
2248
+ return check(node);
2249
+ },
2250
+ FunctionExpression: function FunctionExpression(node) {
2251
+ return check(node);
2252
+ },
2253
+ ArrowFunctionExpression: function ArrowFunctionExpression(node) {
2254
+ return check(node);
2255
+ }
2256
+ };
2257
+ }
2258
+ };
2259
+
2260
+ /**
2261
+ * ESLint plugin for `@dereekb/firebase` rules.
2262
+ *
2263
+ * Register as a plugin in your flat ESLint config, then enable individual rules
2264
+ * under the chosen plugin prefix (e.g. 'dereekb-firebase/require-tagged-firestore-constraints').
2265
+ */ var FIREBASE_ESLINT_PLUGIN = {
2266
+ rules: {
2267
+ 'require-tagged-firestore-constraints': FIREBASE_REQUIRE_TAGGED_FIRESTORE_CONSTRAINTS_RULE,
2268
+ 'require-dbx-model-firebase-index-query-suffix': FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_QUERY_SUFFIX_RULE,
2269
+ 'require-dbx-model-firebase-index-companion-tags': FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_COMPANION_TAGS_RULE,
2270
+ 'require-dbx-model-firebase-index-valid-dispatcher': FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_VALID_DISPATCHER_RULE
2271
+ }
2272
+ };
2273
+ /**
2274
+ * camelCase alias of {@link FIREBASE_ESLINT_PLUGIN} matching the conventional ESLint plugin export name.
2275
+ *
2276
+ * @dbxAllowConstantName
2277
+ */ var firebaseESLintPlugin = FIREBASE_ESLINT_PLUGIN;
2278
+
2279
+ exports.DBX_MODEL_FIREBASE_INDEX_MARKER = DBX_MODEL_FIREBASE_INDEX_MARKER;
2280
+ exports.DEFAULT_CONSTRAINT_FACTORY_NAMES = DEFAULT_CONSTRAINT_FACTORY_NAMES;
2281
+ exports.DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES = DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES;
2282
+ exports.DEFAULT_PAGINATION_CONSTRAINT_NAMES = DEFAULT_PAGINATION_CONSTRAINT_NAMES;
2283
+ exports.FIREBASE_ESLINT_PLUGIN = FIREBASE_ESLINT_PLUGIN;
2284
+ exports.FIREBASE_MODULE = FIREBASE_MODULE;
2285
+ exports.FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_COMPANION_TAGS_RULE = FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_COMPANION_TAGS_RULE;
2286
+ exports.FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_QUERY_SUFFIX_RULE = FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_QUERY_SUFFIX_RULE;
2287
+ exports.FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_VALID_DISPATCHER_RULE = FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_VALID_DISPATCHER_RULE;
2288
+ exports.FIREBASE_REQUIRE_TAGGED_FIRESTORE_CONSTRAINTS_RULE = FIREBASE_REQUIRE_TAGGED_FIRESTORE_CONSTRAINTS_RULE;
2289
+ exports.QUERY_SUFFIX = QUERY_SUFFIX;
2290
+ exports.firebaseESLintPlugin = firebaseESLintPlugin;