@dereekb/dbx-cli 13.11.17 → 13.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/firebase-api-manifest/main.js +70 -9
  2. package/firebase-api-manifest/package.json +1 -1
  3. package/firestore-indexes/src/firestore-indexes-generate.d.ts +125 -0
  4. package/firestore-indexes/src/firestore-model-identity-resolver.d.ts +93 -0
  5. package/firestore-indexes/src/firestore-query-helpers.d.ts +108 -0
  6. package/firestore-indexes/src/generate-firestore-indexes-cli.d.ts +94 -0
  7. package/firestore-indexes/src/index.d.ts +7 -0
  8. package/firestore-indexes/src/model-firebase-index-analyze.d.ts +68 -0
  9. package/firestore-indexes/src/model-firebase-index-build-manifest.d.ts +123 -0
  10. package/firestore-indexes/src/model-firebase-index-extract.d.ts +246 -0
  11. package/firestore-indexes/src/model-firebase-index-runtime.d.ts +126 -0
  12. package/firestore-indexes/src/model-firebase-index-scan-config-schema.d.ts +58 -0
  13. package/firestore-indexes/src/model-firebase-index-schema.d.ts +366 -0
  14. package/generate-firestore-indexes/main.js +1 -1
  15. package/generate-firestore-indexes/package.json +1 -1
  16. package/generate-mcp-manifest/src/generate-mcp-manifest/main.d.ts +26 -0
  17. package/generate-mcp-manifest/src/generate-mcp-manifest/render.d.ts +38 -0
  18. package/generated/firebase-models.generated.d.ts +3 -0
  19. package/index.cjs.js +45234 -640
  20. package/index.esm.js +44941 -643
  21. package/lint-cache/main.js +19 -19
  22. package/lint-cache/package.json +2 -2
  23. package/manifest-extract/index.cjs.js +169 -4
  24. package/manifest-extract/index.esm.js +169 -4
  25. package/manifest-extract/package.json +1 -1
  26. package/manifest-extract/src/lib/types.d.ts +26 -1
  27. package/package.json +14 -10
  28. package/src/lib/index.d.ts +3 -0
  29. package/src/lib/manifest/types.d.ts +155 -0
  30. package/src/lib/mcp-scan/config/config-schema.d.ts +226 -0
  31. package/src/lib/mcp-scan/config/load-config.d.ts +63 -0
  32. package/src/lib/mcp-scan/index.d.ts +16 -0
  33. package/src/lib/mcp-scan/manifest/actions-loader.d.ts +49 -0
  34. package/src/lib/mcp-scan/manifest/actions-schema.d.ts +328 -0
  35. package/src/lib/mcp-scan/manifest/core-topics.d.ts +38 -0
  36. package/src/lib/mcp-scan/manifest/css-utilities-loader.d.ts +55 -0
  37. package/src/lib/mcp-scan/manifest/css-utilities-schema.d.ts +168 -0
  38. package/src/lib/mcp-scan/manifest/dbx-docs-ui-examples-loader.d.ts +33 -0
  39. package/src/lib/mcp-scan/manifest/dbx-docs-ui-examples-schema.d.ts +133 -0
  40. package/src/lib/mcp-scan/manifest/filters-loader.d.ts +61 -0
  41. package/src/lib/mcp-scan/manifest/filters-schema.d.ts +190 -0
  42. package/src/lib/mcp-scan/manifest/forge-fields-loader.d.ts +53 -0
  43. package/src/lib/mcp-scan/manifest/forge-fields-schema.d.ts +170 -0
  44. package/src/lib/mcp-scan/manifest/index.d.ts +43 -0
  45. package/src/lib/mcp-scan/manifest/load-actions-registry.d.ts +38 -0
  46. package/src/lib/mcp-scan/manifest/load-auth-registry.d.ts +82 -0
  47. package/src/lib/mcp-scan/manifest/load-css-utilities-registry.d.ts +67 -0
  48. package/src/lib/mcp-scan/manifest/load-dbx-docs-ui-examples-registry.d.ts +45 -0
  49. package/src/lib/mcp-scan/manifest/load-filters-registry.d.ts +69 -0
  50. package/src/lib/mcp-scan/manifest/load-forge-fields-registry.d.ts +70 -0
  51. package/src/lib/mcp-scan/manifest/load-model-firebase-index-registry.d.ts +61 -0
  52. package/src/lib/mcp-scan/manifest/load-model-snapshot-fields-registry.d.ts +74 -0
  53. package/src/lib/mcp-scan/manifest/load-pipes-registry.d.ts +69 -0
  54. package/src/lib/mcp-scan/manifest/load-registry.d.ts +76 -0
  55. package/src/lib/mcp-scan/manifest/load-tokens-registry.d.ts +69 -0
  56. package/src/lib/mcp-scan/manifest/load-ui-components-registry.d.ts +70 -0
  57. package/src/lib/mcp-scan/manifest/load-utils-registry.d.ts +73 -0
  58. package/src/lib/mcp-scan/manifest/loader.d.ts +120 -0
  59. package/src/lib/mcp-scan/manifest/manifest-loader-base.d.ts +130 -0
  60. package/src/lib/mcp-scan/manifest/model-firebase-index-loader.d.ts +53 -0
  61. package/src/lib/mcp-scan/manifest/model-snapshot-fields-loader.d.ts +54 -0
  62. package/src/lib/mcp-scan/manifest/model-snapshot-fields-schema.d.ts +127 -0
  63. package/src/lib/mcp-scan/manifest/pipes-loader.d.ts +54 -0
  64. package/src/lib/mcp-scan/manifest/pipes-schema.d.ts +125 -0
  65. package/src/lib/mcp-scan/manifest/semantic-types-schema.d.ts +108 -0
  66. package/src/lib/mcp-scan/manifest/tokens-loader.d.ts +55 -0
  67. package/src/lib/mcp-scan/manifest/tokens-schema.d.ts +116 -0
  68. package/src/lib/mcp-scan/manifest/ui-components-loader.d.ts +54 -0
  69. package/src/lib/mcp-scan/manifest/ui-components-schema.d.ts +149 -0
  70. package/src/lib/mcp-scan/manifest/utils-loader.d.ts +54 -0
  71. package/src/lib/mcp-scan/manifest/utils-schema.d.ts +120 -0
  72. package/src/lib/mcp-scan/registry/actions-runtime.d.ts +173 -0
  73. package/src/lib/mcp-scan/registry/archetypes.d.ts +235 -0
  74. package/src/lib/mcp-scan/registry/auth-builtin.d.ts +59 -0
  75. package/src/lib/mcp-scan/registry/auth-runtime.d.ts +343 -0
  76. package/src/lib/mcp-scan/registry/css-utilities-runtime.d.ts +133 -0
  77. package/src/lib/mcp-scan/registry/dbx-docs-ui-examples-runtime.d.ts +58 -0
  78. package/src/lib/mcp-scan/registry/downstream-models-runtime.d.ts +93 -0
  79. package/src/lib/mcp-scan/registry/filters-runtime.d.ts +128 -0
  80. package/src/lib/mcp-scan/registry/firebase-models.d.ts +387 -0
  81. package/src/lib/mcp-scan/registry/forge-fields.d.ts +101 -0
  82. package/src/lib/mcp-scan/registry/form-fields.d.ts +203 -0
  83. package/src/lib/mcp-scan/registry/index.d.ts +165 -0
  84. package/src/lib/mcp-scan/registry/model-snapshot-fields-runtime.d.ts +138 -0
  85. package/src/lib/mcp-scan/registry/pipes-runtime.d.ts +136 -0
  86. package/src/lib/mcp-scan/registry/reserved-model-folders.d.ts +29 -0
  87. package/src/lib/mcp-scan/registry/semantic-types.d.ts +81 -0
  88. package/src/lib/mcp-scan/registry/tokens-runtime.d.ts +96 -0
  89. package/src/lib/mcp-scan/registry/ui-components-runtime.d.ts +90 -0
  90. package/src/lib/mcp-scan/registry/utils-runtime.d.ts +136 -0
  91. package/src/lib/mcp-scan/scan/_jsdoc-tagged-export/extract-base.d.ts +245 -0
  92. package/src/lib/mcp-scan/scan/actions-build-manifest.d.ts +58 -0
  93. package/src/lib/mcp-scan/scan/actions-cli.d.ts +38 -0
  94. package/src/lib/mcp-scan/scan/actions-extract.d.ts +99 -0
  95. package/src/lib/mcp-scan/scan/actions-scan-config-schema.d.ts +42 -0
  96. package/src/lib/mcp-scan/scan/auth-extract.d.ts +120 -0
  97. package/src/lib/mcp-scan/scan/build-manifest.d.ts +76 -0
  98. package/src/lib/mcp-scan/scan/cli.d.ts +60 -0
  99. package/src/lib/mcp-scan/scan/css-utilities-build-manifest.d.ts +76 -0
  100. package/src/lib/mcp-scan/scan/css-utilities-cli.d.ts +36 -0
  101. package/src/lib/mcp-scan/scan/css-utilities-extract.d.ts +187 -0
  102. package/src/lib/mcp-scan/scan/css-utilities-scan-config-schema.d.ts +57 -0
  103. package/src/lib/mcp-scan/scan/dbx-docs-ui-examples-build-manifest.d.ts +68 -0
  104. package/src/lib/mcp-scan/scan/dbx-docs-ui-examples-cli.d.ts +20 -0
  105. package/src/lib/mcp-scan/scan/dbx-docs-ui-examples-extract.d.ts +160 -0
  106. package/src/lib/mcp-scan/scan/dbx-docs-ui-examples-scan-config-schema.d.ts +56 -0
  107. package/src/lib/mcp-scan/scan/discover-downstream-packages.d.ts +76 -0
  108. package/src/lib/mcp-scan/scan/discover-firebase-packages.d.ts +58 -0
  109. package/src/lib/mcp-scan/scan/extract-models/assemble.d.ts +105 -0
  110. package/src/lib/mcp-scan/scan/extract-models/collect-inherited.d.ts +22 -0
  111. package/src/lib/mcp-scan/scan/extract-models/find-converters.d.ts +19 -0
  112. package/src/lib/mcp-scan/scan/extract-models/find-enums.d.ts +19 -0
  113. package/src/lib/mcp-scan/scan/extract-models/find-identities.d.ts +25 -0
  114. package/src/lib/mcp-scan/scan/extract-models/find-interfaces.d.ts +31 -0
  115. package/src/lib/mcp-scan/scan/extract-models/find-model-groups.d.ts +21 -0
  116. package/src/lib/mcp-scan/scan/extract-models/find-service-factories.d.ts +19 -0
  117. package/src/lib/mcp-scan/scan/extract-models/find-sub-object-consts.d.ts +20 -0
  118. package/src/lib/mcp-scan/scan/extract-models/index.d.ts +74 -0
  119. package/src/lib/mcp-scan/scan/extract-models/infer-collection-kind.d.ts +22 -0
  120. package/src/lib/mcp-scan/scan/extract-models/service-factory-constants.d.ts +6 -0
  121. package/src/lib/mcp-scan/scan/extract-models/types.d.ts +171 -0
  122. package/src/lib/mcp-scan/scan/extract.d.ts +82 -0
  123. package/src/lib/mcp-scan/scan/filters-build-manifest.d.ts +78 -0
  124. package/src/lib/mcp-scan/scan/filters-cli.d.ts +37 -0
  125. package/src/lib/mcp-scan/scan/filters-extract.d.ts +101 -0
  126. package/src/lib/mcp-scan/scan/filters-scan-config-schema.d.ts +56 -0
  127. package/src/lib/mcp-scan/scan/forge-fields-build-manifest.d.ts +78 -0
  128. package/src/lib/mcp-scan/scan/forge-fields-cli.d.ts +37 -0
  129. package/src/lib/mcp-scan/scan/forge-fields-extract.d.ts +165 -0
  130. package/src/lib/mcp-scan/scan/forge-fields-scan-config-schema.d.ts +61 -0
  131. package/src/lib/mcp-scan/scan/index.d.ts +60 -0
  132. package/src/lib/mcp-scan/scan/model-firebase-index-cli.d.ts +22 -0
  133. package/src/lib/mcp-scan/scan/model-firebase-index-dispatcher-credit.d.ts +47 -0
  134. package/src/lib/mcp-scan/scan/model-firebase-index-reference-scan.d.ts +100 -0
  135. package/src/lib/mcp-scan/scan/model-snapshot-fields-build-manifest.d.ts +79 -0
  136. package/src/lib/mcp-scan/scan/model-snapshot-fields-cli.d.ts +37 -0
  137. package/src/lib/mcp-scan/scan/model-snapshot-fields-extract.d.ts +115 -0
  138. package/src/lib/mcp-scan/scan/model-snapshot-fields-scan-config-schema.d.ts +59 -0
  139. package/src/lib/mcp-scan/scan/pipes-build-manifest.d.ts +78 -0
  140. package/src/lib/mcp-scan/scan/pipes-cli.d.ts +37 -0
  141. package/src/lib/mcp-scan/scan/pipes-extract.d.ts +90 -0
  142. package/src/lib/mcp-scan/scan/pipes-scan-config-schema.d.ts +56 -0
  143. package/src/lib/mcp-scan/scan/scan-angular-io.d.ts +89 -0
  144. package/src/lib/mcp-scan/scan/scan-cli-base.d.ts +162 -0
  145. package/src/lib/mcp-scan/scan/scan-config-schema.d.ts +44 -0
  146. package/src/lib/mcp-scan/scan/ui-components-build-manifest.d.ts +78 -0
  147. package/src/lib/mcp-scan/scan/ui-components-cli.d.ts +37 -0
  148. package/src/lib/mcp-scan/scan/ui-components-extract.d.ts +124 -0
  149. package/src/lib/mcp-scan/scan/ui-components-scan-config-schema.d.ts +62 -0
  150. package/src/lib/mcp-scan/scan/utils-build-manifest.d.ts +78 -0
  151. package/src/lib/mcp-scan/scan/utils-cli.d.ts +37 -0
  152. package/src/lib/mcp-scan/scan/utils-extract.d.ts +103 -0
  153. package/src/lib/mcp-scan/scan/utils-scan-config-schema.d.ts +57 -0
  154. package/test/package.json +9 -9
  155. package/index.cjs.default.js +0 -1
  156. package/index.cjs.mjs +0 -2
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Orchestrator for the `scan-model-firebase-indexes` generator.
3
+ *
4
+ * Composes a complete {@link ModelFirebaseIndexManifest} from a project
5
+ * root by:
6
+ *
7
+ * 1. reading `dbx-mcp.scan.json` against {@link ModelFirebaseIndexScanConfig}
8
+ * 2. reading `package.json` to derive the entry-level `module` field
9
+ * 3. resolving include/exclude globs against the project root
10
+ * 4. feeding matched files into a ts-morph project
11
+ * 5. building a build-time identity resolver from the same project
12
+ * 6. extracting entries via {@link extractModelFirebaseIndexEntries}
13
+ * 7. running them through {@link analyzeModelFirebaseIndexEntries}
14
+ * 8. assembling the manifest envelope and validating it against
15
+ * {@link ModelFirebaseIndexManifest}
16
+ *
17
+ * I/O is fully injectable so tests drive every code path without touching
18
+ * the real filesystem.
19
+ */
20
+ import { ModelFirebaseIndexManifest } from './model-firebase-index-schema.js';
21
+ import { type AnalyzerWarning } from './model-firebase-index-analyze.js';
22
+ import { type ModelFirebaseIndexExtractWarning } from './model-firebase-index-extract.js';
23
+ import { type ScanGlobber, type ScanReadFile } from '../../src/lib/scan-helpers/scan-io.js';
24
+ export type BuildModelFirebaseIndexReadFile = ScanReadFile;
25
+ export type BuildModelFirebaseIndexGlobber = ScanGlobber;
26
+ /**
27
+ * Combined warnings emitted by one generator run — extractor warnings plus
28
+ * analyzer warnings. Surfaced to the CLI / MCP tool layer so authors can
29
+ * see ambiguity (missing model tag, unresolved field, orderby conflict)
30
+ * without dropping silently.
31
+ */
32
+ export type ModelFirebaseIndexBuildWarning = {
33
+ readonly stage: 'extract';
34
+ readonly warning: ModelFirebaseIndexExtractWarning;
35
+ } | {
36
+ readonly stage: 'analyze';
37
+ readonly warning: AnalyzerWarning;
38
+ };
39
+ /**
40
+ * Input to {@link buildModelFirebaseIndexManifest}.
41
+ */
42
+ export interface BuildModelFirebaseIndexManifestInput {
43
+ readonly projectRoot: string;
44
+ readonly generator: string;
45
+ readonly now?: () => Date;
46
+ readonly readFile?: BuildModelFirebaseIndexReadFile;
47
+ readonly globber?: BuildModelFirebaseIndexGlobber;
48
+ }
49
+ /**
50
+ * One dispatcher-tagged factory's delegate summary. The `name` is the
51
+ * dispatcher's exported function name (matched against scanner reference
52
+ * counts) and `delegates` are the identifier-callee names captured from
53
+ * its body. Surfaced by {@link buildModelFirebaseIndexManifest} so the
54
+ * validator can credit dispatcher caller counts against the factories
55
+ * the dispatcher returns into.
56
+ */
57
+ export interface ModelFirebaseIndexDispatcherSummary {
58
+ readonly slug: string;
59
+ readonly name: string;
60
+ readonly delegates: readonly string[];
61
+ }
62
+ /**
63
+ * Outcome of one generator run.
64
+ */
65
+ export type BuildModelFirebaseIndexManifestOutcome = {
66
+ readonly kind: 'success';
67
+ readonly manifest: ModelFirebaseIndexManifest;
68
+ readonly outPath: string;
69
+ readonly scannedFileCount: number;
70
+ readonly extractWarnings: readonly ModelFirebaseIndexBuildWarning[];
71
+ readonly entryFilePathsBySlug: ReadonlyMap<string, string>;
72
+ readonly dispatcherSummaries: readonly ModelFirebaseIndexDispatcherSummary[];
73
+ } | {
74
+ readonly kind: 'no-config';
75
+ readonly configPath: string;
76
+ } | {
77
+ readonly kind: 'invalid-scan-config';
78
+ readonly configPath: string;
79
+ readonly error: string;
80
+ } | {
81
+ readonly kind: 'no-package';
82
+ readonly packagePath: string;
83
+ } | {
84
+ readonly kind: 'invalid-package';
85
+ readonly packagePath: string;
86
+ readonly error: string;
87
+ } | {
88
+ readonly kind: 'invalid-manifest';
89
+ readonly error: string;
90
+ };
91
+ /**
92
+ * Builds a {@link ModelFirebaseIndexManifest} from the supplied project
93
+ * root. The function is pure with respect to the injected I/O hooks, so
94
+ * unit tests can drive every branch without disk access.
95
+ *
96
+ * @param input - The project root + injection hooks for testing.
97
+ * @returns A discriminated outcome describing the result.
98
+ */
99
+ export declare function buildModelFirebaseIndexManifest(input: BuildModelFirebaseIndexManifestInput): Promise<BuildModelFirebaseIndexManifestOutcome>;
100
+ /**
101
+ * JSON-stringifies a manifest with stable key ordering and trailing
102
+ * newline so `--check` mode can byte-compare against a committed file
103
+ * without false-positive diffs from key reordering.
104
+ *
105
+ * @param manifest - The manifest to serialise.
106
+ * @returns The canonical string form.
107
+ */
108
+ export declare function serializeModelFirebaseIndexManifest(manifest: ModelFirebaseIndexManifest): string;
109
+ /**
110
+ * Renders a {@link ModelFirebaseIndexBuildWarning} into a single human-readable
111
+ * line. Shared by the `scan-model-firebase-indexes` CLI and the
112
+ * `dbx_model_firebase_index_list_app` MCP tool so both surfaces describe the
113
+ * same warning identically.
114
+ *
115
+ * @param warning - Warning emitted by the extractor or analyzer.
116
+ * @returns A one-line description suitable for CLI logs or markdown bullets.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * outcome.extractWarnings.map(formatModelFirebaseIndexBuildWarning).forEach(log);
121
+ * ```
122
+ */
123
+ export declare function formatModelFirebaseIndexBuildWarning(warning: ModelFirebaseIndexBuildWarning): string;
@@ -0,0 +1,246 @@
1
+ /**
2
+ * AST extraction for the `scan-model-firebase-indexes` generator.
3
+ *
4
+ * Walks every source file in the supplied ts-morph `Project` looking for
5
+ * top-level exported functions tagged with the `@dbxModelFirebaseIndex`
6
+ * JSDoc marker. For each match:
7
+ *
8
+ * 1. Reads JSDoc-tag metadata (model, scope, manual/skip flags, category,
9
+ * tags, related slugs).
10
+ * 2. Resolves the target model's short collection name and nested flag
11
+ * via {@link FirestoreModelIdentityResolver}.
12
+ * 3. Walks the function body collecting `where(...)`, `orderBy(...)`, and
13
+ * known-helper calls (from {@link FIRESTORE_QUERY_HELPERS}) in source
14
+ * order, expanding helpers into their base constraint sequences.
15
+ * 4. Emits one {@link ExtractedModelFirebaseIndexEntry} per factory.
16
+ *
17
+ * Conditional-branch enumeration is opt-in via `@dbxModelFirebaseIndexPath`.
18
+ * Each path tag declares one call pattern as a comma-separated list of
19
+ * field paths, and the extractor produces one constraint sequence per tag
20
+ * (filtered to the listed fields, preserving body source order). When no
21
+ * path tag is declared, the extractor falls back to a single 'all'
22
+ * sequence containing every constraint call in the body; if any of those
23
+ * calls sits inside an `if`/`switch`/ternary branch, a `missing-paths`
24
+ * warning surfaces the conditional fields so the author can declare the
25
+ * meaningful subsets.
26
+ *
27
+ * Mirrors `model-snapshot-fields-extract.ts` for tag parsing + entry
28
+ * assembly conventions.
29
+ */
30
+ import { type Project } from 'ts-morph';
31
+ import { type ConstraintSequence, type FirestoreQueryScope, type ModelFirebaseIndexParamEntry } from './model-firebase-index-schema.js';
32
+ import { type FirestoreModelIdentityResolver } from './firestore-model-identity-resolver.js';
33
+ /**
34
+ * One firebase-index entry extracted from a source file. Mirrors
35
+ * {@link ModelFirebaseIndexEntry} minus `module` and `subpath` (derived in
36
+ * build-manifest from the package being scanned and the project root).
37
+ * `filePath` and `line` are kept for in-process warnings and never
38
+ * persisted to the manifest.
39
+ */
40
+ export interface ExtractedModelFirebaseIndexEntry {
41
+ readonly slug: string;
42
+ readonly name: string;
43
+ readonly model: string;
44
+ readonly collection: string;
45
+ readonly isNested: boolean;
46
+ readonly scope: FirestoreQueryScope;
47
+ readonly manual: boolean;
48
+ readonly skip: boolean;
49
+ /**
50
+ * True when the factory carries `@dbxModelFirebaseIndexSpecFilesOnly`. The
51
+ * factory is intentionally for `.spec.ts` use only — the analyzer suppresses
52
+ * composite + fieldOverride emission (mirroring `skip`), and the validator
53
+ * raises `MODEL_FIREBASE_INDEX_SPEC_FILES_ONLY_VIOLATION` (error) if a
54
+ * non-spec file references the factory by name.
55
+ */
56
+ readonly specOnly: boolean;
57
+ /**
58
+ * True when the factory carries `@dbxModelFirebaseIndexExclude`. The
59
+ * constraint sequence is still parsed (unlike `skip`, which empties it)
60
+ * so the list-app / lookup tools can display the would-be query shape;
61
+ * the analyzer suppresses composite + fieldOverride emission. Every
62
+ * excluded factory also produces an `excluded-factory` warning so the
63
+ * exclusion is auditable.
64
+ */
65
+ readonly excluded: boolean;
66
+ /**
67
+ * True when the factory carries `@dbxModelFirebaseIndexDispatcher`. The
68
+ * factory itself produces no composite/fieldOverride (its
69
+ * `constraintSequences` is always empty), but the validator credits its
70
+ * caller count to every name listed in `dispatcherDelegates` so a
71
+ * dispatcher-only primitive does not perpetually false-positive on
72
+ * `MODEL_FIREBASE_INDEX_UNUSED_FACTORY`.
73
+ */
74
+ readonly dispatcher: boolean;
75
+ /**
76
+ * Identifier-callee names captured from the body of a dispatcher-tagged
77
+ * factory. Populated only when `dispatcher` is true; empty otherwise.
78
+ * Names are reported as written in source (no resolution to slugs) — the
79
+ * validator matches them against other tagged factories' `name` fields
80
+ * when crediting unused-factory references.
81
+ */
82
+ readonly dispatcherDelegates: readonly string[];
83
+ readonly allowArrayContainsAny: boolean;
84
+ readonly category: string;
85
+ readonly signature: string;
86
+ readonly description: string;
87
+ readonly params: readonly ModelFirebaseIndexParamEntry[];
88
+ readonly returns: string;
89
+ readonly tags: readonly string[];
90
+ readonly relatedSlugs?: readonly string[];
91
+ readonly skillRefs?: readonly string[];
92
+ readonly example: string;
93
+ readonly constraintSequences: readonly ConstraintSequence[];
94
+ readonly deprecated?: boolean | string;
95
+ readonly since?: string;
96
+ readonly filePath: string;
97
+ readonly line: number;
98
+ }
99
+ /**
100
+ * Discriminated union of the non-fatal events the extractor emits when an
101
+ * entry can't be assembled cleanly.
102
+ */
103
+ export type ModelFirebaseIndexExtractWarningSeverity = 'error' | 'warning';
104
+ /**
105
+ * The branch construct that disqualified a tagged query factory's body.
106
+ */
107
+ export type ComplexQueryBranchKind = 'if' | 'switch' | 'ternary' | 'loop';
108
+ export type ModelFirebaseIndexExtractWarning = {
109
+ readonly kind: 'missing-name';
110
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
111
+ readonly filePath: string;
112
+ readonly line: number;
113
+ } | {
114
+ readonly kind: 'missing-model-tag';
115
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
116
+ readonly name: string;
117
+ readonly filePath: string;
118
+ readonly line: number;
119
+ } | {
120
+ readonly kind: 'unresolved-model';
121
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
122
+ readonly name: string;
123
+ readonly model: string;
124
+ readonly filePath: string;
125
+ readonly line: number;
126
+ } | {
127
+ readonly kind: 'unsupported-scope';
128
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
129
+ readonly name: string;
130
+ readonly scope: string;
131
+ readonly filePath: string;
132
+ readonly line: number;
133
+ } | {
134
+ readonly kind: 'duplicate-slug';
135
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
136
+ readonly name: string;
137
+ readonly slug: string;
138
+ readonly previousName: string;
139
+ readonly filePath: string;
140
+ readonly line: number;
141
+ } | {
142
+ readonly kind: 'unknown-helper';
143
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
144
+ readonly name: string;
145
+ readonly helper: string;
146
+ readonly filePath: string;
147
+ readonly line: number;
148
+ } | {
149
+ readonly kind: 'unresolved-field';
150
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
151
+ readonly name: string;
152
+ readonly callee: string;
153
+ readonly filePath: string;
154
+ readonly line: number;
155
+ } | {
156
+ readonly kind: 'missing-paths';
157
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
158
+ readonly name: string;
159
+ readonly conditionalFields: readonly string[];
160
+ readonly filePath: string;
161
+ readonly line: number;
162
+ } | {
163
+ readonly kind: 'unknown-path-field';
164
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
165
+ readonly name: string;
166
+ readonly field: string;
167
+ readonly filePath: string;
168
+ readonly line: number;
169
+ } | {
170
+ readonly kind: 'unannotated-query-helper';
171
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
172
+ readonly name: string;
173
+ readonly callee: string;
174
+ readonly calleeFilePath: string;
175
+ readonly calleeLine: number;
176
+ readonly filePath: string;
177
+ readonly line: number;
178
+ } | {
179
+ readonly kind: 'transitive-cycle';
180
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
181
+ readonly name: string;
182
+ readonly callee: string;
183
+ readonly filePath: string;
184
+ readonly line: number;
185
+ } | {
186
+ readonly kind: 'unresolvable-transitive-callee';
187
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
188
+ readonly name: string;
189
+ readonly callee: string;
190
+ readonly filePath: string;
191
+ readonly line: number;
192
+ } | {
193
+ readonly kind: 'complex-query-body';
194
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
195
+ readonly name: string;
196
+ readonly branchKind: ComplexQueryBranchKind;
197
+ readonly filePath: string;
198
+ readonly line: number;
199
+ } | {
200
+ readonly kind: 'non-delegating-dispatcher';
201
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
202
+ readonly name: string;
203
+ readonly callee: string;
204
+ readonly filePath: string;
205
+ readonly line: number;
206
+ } | {
207
+ readonly kind: 'excluded-factory';
208
+ readonly severity: ModelFirebaseIndexExtractWarningSeverity;
209
+ readonly name: string;
210
+ readonly filePath: string;
211
+ readonly line: number;
212
+ };
213
+ /**
214
+ * Input to {@link extractModelFirebaseIndexEntries}.
215
+ */
216
+ export interface ExtractModelFirebaseIndexEntriesInput {
217
+ readonly project: Project;
218
+ readonly identityResolver: FirestoreModelIdentityResolver;
219
+ readonly projectRoot?: string;
220
+ }
221
+ /**
222
+ * Result of {@link extractModelFirebaseIndexEntries}.
223
+ */
224
+ export interface ExtractModelFirebaseIndexEntriesResult {
225
+ readonly entries: readonly ExtractedModelFirebaseIndexEntry[];
226
+ readonly warnings: readonly ModelFirebaseIndexExtractWarning[];
227
+ }
228
+ /**
229
+ * Walks the supplied project and returns every export tagged with the
230
+ * `@dbxModelFirebaseIndex` JSDoc marker. Order is stable: source files in
231
+ * the order ts-morph reports them, declarations within a file in source
232
+ * order.
233
+ *
234
+ * @param input - The ts-morph project, identity resolver, and project root.
235
+ * @returns The extracted entries plus any non-fatal warnings.
236
+ */
237
+ export declare function extractModelFirebaseIndexEntries(input: ExtractModelFirebaseIndexEntriesInput): ExtractModelFirebaseIndexEntriesResult;
238
+ /**
239
+ * Converts an export name into its kebab-case slug form. Handles
240
+ * camelCase (`jobLocationWeeksDirty` → `job-location-weeks-dirty`) and
241
+ * SCREAMING_SNAKE_CASE; already-kebab inputs pass through unchanged.
242
+ *
243
+ * @param name - The export identifier.
244
+ * @returns The kebab-case slug.
245
+ */
246
+ export declare function toKebabCase(name: string): string;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Model-firebase-index runtime registry wrapper.
3
+ *
4
+ * Wraps the raw {@link LoadModelFirebaseIndexManifestsResult} produced by
5
+ * the loader with domain-friendly accessors so the lookup/search tools
6
+ * and the registry resource don't have to walk Maps directly.
7
+ *
8
+ * The registry is loaded once at server startup and passed into the tool
9
+ * factories. Tests can construct a registry from any entry array via
10
+ * {@link createModelFirebaseIndexRegistryFromEntries} to drive the tools
11
+ * without touching disk.
12
+ */
13
+ import type { ConstraintSequence, DerivedComposite, DerivedFieldOverride, FirestoreQueryScope, ModelFirebaseIndexEntry, ModelFirebaseIndexParamEntry } from './model-firebase-index-schema.js';
14
+ /**
15
+ * Subset of the `LoadModelFirebaseIndexManifestsResult` shape (defined by
16
+ * `model-firebase-index-loader.ts` in `@dereekb/dbx-components-mcp`) that
17
+ * `createModelFirebaseIndexRegistry` consumes. Inlined here so this
18
+ * runtime stays free of any back-import into the MCP server package.
19
+ *
20
+ * `warnings` is typed as `readonly unknown[]` because the registry never
21
+ * reads them — the loader collects them and surfaces them through its own
22
+ * (more strongly typed) return shape. Any `readonly Warning[]` is
23
+ * structurally assignable to `readonly unknown[]`.
24
+ */
25
+ export interface LoadModelFirebaseIndexManifestsResult {
26
+ readonly entries: ReadonlyMap<string, ModelFirebaseIndexEntry>;
27
+ readonly collectionIndex: ReadonlyMap<string, readonly string[]>;
28
+ readonly warnings: readonly unknown[];
29
+ readonly loadedSources: readonly string[];
30
+ }
31
+ /**
32
+ * One curated firebase-index entry surfaced through the
33
+ * `dbx_model_firebase_index_*` tools.
34
+ *
35
+ * Mirrors {@link ModelFirebaseIndexEntry} but normalises optional manifest
36
+ * fields to empty arrays / safe defaults so callers (lookup, search,
37
+ * resources) don't have to defensively branch.
38
+ */
39
+ export interface ModelFirebaseIndexEntryInfo {
40
+ readonly slug: string;
41
+ readonly name: string;
42
+ readonly module: string;
43
+ readonly subpath: string;
44
+ readonly signature: string;
45
+ readonly description: string;
46
+ readonly model: string;
47
+ readonly collection: string;
48
+ readonly isNested: boolean;
49
+ readonly scope: FirestoreQueryScope;
50
+ readonly manual: boolean;
51
+ readonly skip: boolean;
52
+ readonly category: string;
53
+ readonly params: readonly ModelFirebaseIndexParamEntry[];
54
+ readonly returns: string;
55
+ readonly tags: readonly string[];
56
+ readonly constraintSequences: readonly ConstraintSequence[];
57
+ readonly derivedComposites: readonly DerivedComposite[];
58
+ readonly derivedFieldOverrides: readonly DerivedFieldOverride[];
59
+ readonly example: string;
60
+ readonly relatedSlugs: readonly string[];
61
+ readonly skillRefs: readonly string[];
62
+ readonly deprecated: boolean | string;
63
+ readonly since: string;
64
+ }
65
+ /**
66
+ * Domain-friendly read API over a merged model-firebase-index manifest set.
67
+ * All accessors return readonly arrays preserving the order the manifests
68
+ * declared their entries.
69
+ */
70
+ export interface ModelFirebaseIndexRegistry {
71
+ readonly all: readonly ModelFirebaseIndexEntryInfo[];
72
+ readonly loadedSources: readonly string[];
73
+ readonly collections: readonly string[];
74
+ readonly models: readonly string[];
75
+ readonly modules: readonly string[];
76
+ readonly categories: readonly string[];
77
+ findBySlug(slug: string): ModelFirebaseIndexEntryInfo | undefined;
78
+ findByName(name: string): ModelFirebaseIndexEntryInfo | undefined;
79
+ findByCollection(collection: string): readonly ModelFirebaseIndexEntryInfo[];
80
+ findByModel(model: string): readonly ModelFirebaseIndexEntryInfo[];
81
+ findByModule(module: string): readonly ModelFirebaseIndexEntryInfo[];
82
+ findByCategory(category: string): readonly ModelFirebaseIndexEntryInfo[];
83
+ findByTag(tag: string): readonly ModelFirebaseIndexEntryInfo[];
84
+ }
85
+ /**
86
+ * Builds a {@link ModelFirebaseIndexRegistry} from a loader result.
87
+ *
88
+ * @param loaded - The merged registry returned by `loadModelFirebaseIndexManifests`
89
+ * @returns A domain-friendly read API over the merged entries.
90
+ *
91
+ * @__NO_SIDE_EFFECTS__
92
+ */
93
+ export declare function createModelFirebaseIndexRegistry(loaded: LoadModelFirebaseIndexManifestsResult): ModelFirebaseIndexRegistry;
94
+ /**
95
+ * Builds a {@link ModelFirebaseIndexRegistry} from a raw entry array.
96
+ * Used by tests that need to drive the tools without going through the
97
+ * loader pipeline.
98
+ *
99
+ * @param input - The entries plus the source labels to advertise.
100
+ * @param input.entries - The full entry list.
101
+ * @param input.loadedSources - Source labels reported via `registry.loadedSources`
102
+ * @returns A domain-friendly read API over the supplied entries.
103
+ *
104
+ * @__NO_SIDE_EFFECTS__
105
+ */
106
+ export declare function createModelFirebaseIndexRegistryFromEntries(input: {
107
+ readonly entries: readonly ModelFirebaseIndexEntryInfo[];
108
+ readonly loadedSources: readonly string[];
109
+ }): ModelFirebaseIndexRegistry;
110
+ /**
111
+ * Empty registry suitable as a default when the server has no
112
+ * model-firebase-index manifest sources to load. Tools wired against
113
+ * this registry behave like a registry that loaded successfully with
114
+ * zero entries.
115
+ */
116
+ export declare const EMPTY_MODEL_FIREBASE_INDEX_REGISTRY: ModelFirebaseIndexRegistry;
117
+ /**
118
+ * Converts a manifest entry into the {@link ModelFirebaseIndexEntryInfo}
119
+ * shape the lookup/search tools consume. Optional manifest fields fall
120
+ * back to safe defaults so a partially-populated entry still renders
121
+ * cleanly.
122
+ *
123
+ * @param entry - The manifest entry to convert.
124
+ * @returns The matching ModelFirebaseIndexEntryInfo.
125
+ */
126
+ export declare function toModelFirebaseIndexEntryInfo(entry: ModelFirebaseIndexEntry): ModelFirebaseIndexEntryInfo;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Arktype schema for the `modelFirebaseIndex` section of `dbx-mcp.scan.json`.
3
+ *
4
+ * Mirrors the existing `modelSnapshotFields` section — same `dbx-mcp.scan.json`
5
+ * filename so a project that opts into multiple pipelines keeps a single
6
+ * config file. The CLI subcommand `scan-model-firebase-indexes` reads only
7
+ * the `modelFirebaseIndex` field; sibling subcommands continue to read their
8
+ * own top-level fields unchanged.
9
+ */
10
+ /**
11
+ * Inner config that drives one model-firebase-index scan run. `source`
12
+ * becomes the manifest's `source` label (used for collision detection across
13
+ * loaded sources); `module` becomes the npm package name attached to every
14
+ * produced entry. Both default to the project's `package.json#name` when
15
+ * omitted.
16
+ */
17
+ export declare const ModelFirebaseIndexScanSection: import("arktype/internal/variants/object.ts").ObjectType<{
18
+ include: string[];
19
+ source?: string | undefined;
20
+ module?: string | undefined;
21
+ exclude?: string[] | undefined;
22
+ out?: string | undefined;
23
+ }, {}>;
24
+ /**
25
+ * Static type for {@link ModelFirebaseIndexScanSection}.
26
+ */
27
+ export type ModelFirebaseIndexScanSection = typeof ModelFirebaseIndexScanSection.infer;
28
+ /**
29
+ * Top-level shape used by the model-firebase-index builder. Only the
30
+ * `modelFirebaseIndex` key is consumed; the rest of the document is ignored
31
+ * so a single `dbx-mcp.scan.json` can house all the scan sections
32
+ * side-by-side.
33
+ */
34
+ export declare const ModelFirebaseIndexScanConfig: import("arktype/internal/variants/object.ts").ObjectType<{
35
+ version: 1;
36
+ modelFirebaseIndex: {
37
+ include: string[];
38
+ source?: string | undefined;
39
+ module?: string | undefined;
40
+ exclude?: string[] | undefined;
41
+ out?: string | undefined;
42
+ };
43
+ }, {}>;
44
+ /**
45
+ * Static type for {@link ModelFirebaseIndexScanConfig}.
46
+ */
47
+ export type ModelFirebaseIndexScanConfig = typeof ModelFirebaseIndexScanConfig.infer;
48
+ /**
49
+ * Default value used when the scan config does not specify `out`.
50
+ * Lives next to the scan config in the project root.
51
+ */
52
+ export declare const DEFAULT_MODEL_FIREBASE_INDEX_SCAN_OUT_PATH = "model-firebase-index.mcp.generated.json";
53
+ /**
54
+ * Filename the loader looks for at `${projectRoot}/`. Re-exported here so
55
+ * the model-firebase-index CLI does not have to import from a sibling scan
56
+ * config module.
57
+ */
58
+ export declare const MODEL_FIREBASE_INDEX_SCAN_CONFIG_FILENAME = "dbx-mcp.scan.json";