import type { Maybe } from '@dereekb/util'; /** * Module that publishes the `@dereekb/firebase` Firestore constraint factories (`where`, `orderBy`, etc.). */ export declare const FIREBASE_MODULE = "@dereekb/firebase"; /** * Directory names the layout-agnostic discovery globs never descend into: installed dependencies * and build/cache output. Excluding these keeps a broad `**\/*.ts` scan from walking a downstream * consumer's `node_modules` (which can hold tens of thousands of declaration files) and from * double-counting compiled output under `dist`. */ export declare const DEFAULT_DISCOVERY_EXCLUDED_DIRS: readonly string[]; /** * Builds the `exclude` predicate passed to `fs.globSync(pattern, { cwd, exclude })` for the broad, * layout-agnostic discovery globs. Node invokes the predicate on each visited path (directories * included) and prunes the subtree when it returns true, so excluding a directory name here stops * the walk from ever descending into it. * * @param excludedDirs - Directory names to prune. Defaults to {@link DEFAULT_DISCOVERY_EXCLUDED_DIRS}. * @returns A predicate that returns true for any path containing an excluded directory segment. */ export declare function discoveryGlobExcludeFilter(excludedDirs?: readonly string[]): (path: string) => boolean; /** * Resolves the absolute path to the installed `@dereekb/firebase` package's `src/lib/model` * directory, as seen from the ESLint `cwd`. Used by rules that need to read the framework model * declarations (identities, service factories) directly from the package a consumer has installed — * the downstream case where these live under `node_modules/@dereekb/firebase/...` as compiled * bundles plus `.d.ts` rather than a scannable source tree. * * Resolution uses Node's own module resolver (`require.resolve('@dereekb/firebase/package.json')` * anchored at `cwd`), so it transparently handles hoisting / nested `node_modules`. Returns null * when `@dereekb/firebase` is not resolvable as a dependency from `cwd` (e.g. inside the * dbx-components monorepo itself, where it is consumed via TS path mapping rather than * `node_modules`) — callers fall back to their cwd-relative source globs in that case. * * @param cwd - The ESLint working directory to resolve the dependency from. * @returns The absolute model directory, or null when it cannot be resolved. */ export declare function resolveInstalledFirebaseModelDir(cwd: string): Maybe; /** * Resolves the referenced type name from either a `TSTypeReference` (`Foo<…>` / `ns.Foo<…>`) or a * `TSImportType` (`import("…").Foo<…>` — the form the TypeScript compiler emits in declaration * files for cross-module type references). Returns the rightmost identifier name in a qualified * name. * * @param node - A `TSTypeReference` or `TSImportType` node (or anything else). * @returns The referenced type name, or null when the node is neither shape. */ export declare function referencedTypeName(node: AstNode): Maybe; /** * JSDoc tag name that marks an exported query factory whose body should be scanned by * `dbx-components-mcp`'s index extractor (`packages/dbx-components-mcp/src/scan/model-firebase-index-extract.ts`). */ export declare const DBX_MODEL_FIREBASE_INDEX_MARKER = "dbxModelFirebaseIndex"; /** * The canonical suffix expected on every `@dbxModelFirebaseIndex`-tagged factory name. */ export declare const QUERY_SUFFIX = "Query"; /** * Index-affecting Firestore constraint factory identifiers exported from `@dereekb/firebase` * (see `packages/firebase/src/lib/common/firestore/query/constraint.ts`). These shape the * composite index Firestore needs to satisfy the query — calls to them must originate inside * a `@dbxModelFirebaseIndex`-tagged function so the dbx-components-mcp index extractor can * collect them. * * `where` and `orderBy` are the only constraint factories that influence composite indexes; * pagination/cursor factories (`limit`, `limitToLast`, `whereDocumentId`, `startAt`/`After`, * `endAt`/`Before`) only narrow the cursor/window of an already-indexed query and may be * composed freely outside tagged factories — see {@link DEFAULT_PAGINATION_CONSTRAINT_NAMES}. */ export declare const DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES: readonly string[]; /** * Pagination/cursor Firestore constraint factory identifiers exported from `@dereekb/firebase`. * These do not influence composite indexes and may be composed externally — e.g. a generic * pagination helper that appends `limit` + `startAfter` onto a caller-supplied tagged-query * constraint array. The "tagged-firestore-constraints" rule does not flag calls to these by * default. */ export declare const DEFAULT_PAGINATION_CONSTRAINT_NAMES: readonly string[]; /** * Combined list of every Firestore constraint factory exported from `@dereekb/firebase`. Used * by the body-coherence rule to ensure a tagged factory body contains at least one constraint * call of any kind (index-affecting or pagination) before warning that the marker is orphaned. */ export declare const DEFAULT_CONSTRAINT_FACTORY_NAMES: readonly string[]; /** * Loose AST node alias used by the rule implementations. */ export type AstNode = any; /** * Per-file registry of import information used by the firebase-eslint rules. * * `localToImported` maps the local binding name (which may be a rename, e.g. `fbWhere` from * `import { where as fbWhere }`) back to the imported name (`where`) — the rules check the * imported name against the firestore-constraint allowlist. */ export interface ImportRegistry { readonly bySource: Map>; readonly localToSource: Map; readonly localToImported: Map; } /** * Creates an empty {@link ImportRegistry}. * * @returns A fresh empty registry. */ export declare function createImportRegistry(): ImportRegistry; /** * Records an `ImportDeclaration` node in the registry. * * @param registry - The registry to mutate. * @param node - The ImportDeclaration AST node. */ export declare function trackImportDeclaration(registry: ImportRegistry, node: AstNode): void; /** * Returns true when the given local identifier name was imported from the given module. * * @param registry - The import registry built from the file's import declarations. * @param localName - The local identifier (as it appears in code). * @param fromSource - The expected source-module string. * @returns True when the local name maps to the given source. */ export declare function isImportedFrom(registry: ImportRegistry, localName: string, fromSource: string): boolean; /** * Returns the statement-level anchor node that ESLint attaches leading comments to for the * given function-like node. For function declarations this is the declaration (or its * `Export*Declaration` wrapper); for arrow/function expressions assigned to a variable, it * is the variable declaration (or its `Export*Declaration` wrapper); otherwise `null`. * * @param node - The function-like AST node (FunctionDeclaration / FunctionExpression / ArrowFunctionExpression). * @returns The anchor statement node, or null when the function has no JSDoc-anchorable container. */ export declare function getFunctionJsdocAnchor(node: AstNode): Maybe; /** * Returns the function name when resolvable: `node.id.name` for declarations, or the * containing `VariableDeclarator.id.name` for arrow/function expressions. Returns `null` * when the function is anonymous in an unrecognized context. * * @param node - The function-like AST node. * @returns The function name, or null when anonymous. */ export declare function getFunctionName(node: AstNode): Maybe; /** * Returns the name-bearing AST node for reporting on a function: the `id` for a * declaration, the `VariableDeclarator.id` for an arrow assignment, or the function node * itself as a last resort. * * @param node - The function-like AST node. * @returns The node to attach a `context.report` location to. */ export declare function getFunctionNameNode(node: AstNode): AstNode; /** * Default CRUD verb names that combine with the `ModelFunction` suffix to form a type-name * pattern the api-details rules treat as a CRUD function declaration (e.g. `OnCallCreateModelFunction`, * `DemoUpdateModelFunction`). * * Mirrors the verbs supported by `ModelFirebaseCrudFunctionConfigMap` — see * `packages/firebase/src/lib/client/function/model.function.factory.ts`. */ export declare const DEFAULT_CRUD_FUNCTION_TYPE_VERBS: readonly string[]; /** * Default factory function name that wraps CRUD function declarations and attaches the * `_apiDetails` metadata (`inputType`, `outputType`, `mcp.visibility`, `analytics`) consumed * by the MCP manifest builder. Defined in `packages/firebase-server/src/lib/nest/model/api.details.ts`. */ export declare const DEFAULT_API_DETAILS_FACTORY_NAME: string; /** * Property name on the `withApiDetails(...)` config object that declares the handler's input * parameter type (consumed by the MCP manifest builder to generate the tool input schema). */ export declare const INPUT_TYPE_PROPERTY_NAME: string; /** * Module the default api-details factory ({@link DEFAULT_API_DETAILS_FACTORY_NAME}) is exported * from. Used by the require-api-details auto-fix to insert a missing import. */ export declare const API_DETAILS_IMPORT_MODULE: string; /** * Unwraps `TSAsExpression` and `TSTypeAssertion` wrappers around an initializer so callers see the * underlying expression (matches the helper in `require-complete-crud-function-config-map.rule.ts`). * * @param node - The AST node to unwrap. * @returns The innermost wrapped expression, or `node` when no cast is present. */ export declare function unwrapTypeAssertion(node: AstNode): AstNode; /** * Resolves the identifier name from a `TSTypeReference` annotation, when present. * * @param node - A `TSTypeReference` node (or anything else). * @returns The identifier name when `node` is a TSTypeReference whose typeName is an Identifier; otherwise null. */ export declare function typeReferenceTypeName(node: AstNode): Maybe; /** * Resolves the type-argument nodes of a `TSTypeReference`, normalizing across `@typescript-eslint` * versions (`typeArguments` in v6+, `typeParameters` in older releases). * * @param node - A `TSTypeReference` node (or anything else). * @returns The generic argument nodes, or null when the reference has no type arguments. */ export declare function typeReferenceTypeArguments(node: AstNode): Maybe; /** * Resolves the callee identifier name from a `CallExpression`, looking through both bare identifier * callees (`withApiDetails(...)`) and member-expression callees (`api.withApiDetails(...)`). * * @param callee - The `CallExpression.callee` node. * @returns The callee name when resolvable; otherwise null. */ export declare function callExpressionCalleeName(callee: AstNode): Maybe; /** * Determines whether the (already-unwrapped) initializer is a call to the configured api-details factory. * * @param initializer - The unwrapped initializer node. * @param factoryName - The expected factory identifier name. * @returns True when the initializer is a `CallExpression` whose callee resolves to `factoryName`. */ export declare function isApiDetailsCall(initializer: AstNode, factoryName: string): boolean; /** * Returns the declarator's identifier name, when present. * * @param declaratorId - The `VariableDeclarator.id` node. * @returns The identifier name, or null when the declarator binds a destructuring pattern. */ export declare function declaratorName(declaratorId: AstNode): Maybe; /** * Returns the CRUD verb fragment that `typeName` ends with — i.e. the `` in a * `ModelFunction` suffix for one of the configured verbs (e.g. `OnCallCreateModelFunction` → * `Create`, `DemoUpdateModelFunction` → `Update`). * * @param typeName - The type-reference identifier name. * @param verbs - The allowed verb fragments. * @returns The matched verb, or null when the suffix matches no recognized CRUD verb. */ export declare function matchedCrudFunctionVerb(typeName: string, verbs: Iterable): Maybe; /** * Returns true when `typeName` ends with `ModelFunction` for one of the configured verbs. * * @param typeName - The type-reference identifier name. * @param verbs - The allowed verb fragments. * @returns True when the suffix matches a recognized CRUD verb. */ export declare function isCrudFunctionTypeName(typeName: string, verbs: Iterable): boolean; /** * Resolves the input-parameter type-argument node from a CRUD function type reference. * * @param typeRef - The `TSTypeReference` annotation node. * @param typeName - The resolved type-reference name (selects the generic position). * @returns The input type-argument node, or null when absent. */ export declare function crudFunctionInputTypeArgNode(typeRef: AstNode, typeName: string): Maybe; /** * Returns true when a CRUD function declares no meaningful input — either the input generic argument * is absent or it is an empty object type literal (`{}`). Such handlers need no MCP input schema, so * the require-input-type rule exempts them. * * @param typeRef - The `TSTypeReference` annotation node. * @param typeName - The resolved type-reference name. * @returns True when the input generic is empty or absent. */ export declare function isEmptyOrAbsentInputGeneric(typeRef: AstNode, typeName: string): boolean; /** * Returns true when an `ObjectExpression` has an own (non-computed) property with the given name. * * @param objExpr - The `ObjectExpression` node. * @param propName - The property name to look for. * @returns True when a matching property is present. */ export declare function objectExpressionHasProperty(objExpr: AstNode, propName: string): boolean; /** * Returns true when an `ObjectExpression` contains a spread element (`{ ...base }`), whose contents * cannot be introspected statically. * * @param objExpr - The `ObjectExpression` node. * @returns True when any property is a spread element. */ export declare function objectExpressionHasSpread(objExpr: AstNode): boolean; /** * Returns the character offset at which an auto-fixer should insert a new import — the start of the * first existing `ImportDeclaration`, or offset 0 when the file has no imports yet. * * @param program - The `Program` AST node. * @returns The character offset for the import-insertion point. */ export declare function findImportInsertionOffset(program: AstNode): number; /** * Returns true when the given identifier name is already in the module's top-level scope (imported * or declared). Used by the require-api-details auto-fix to avoid inserting a duplicate import. * * @param program - The `Program` AST node. * @param name - The identifier name to check. * @returns True when an existing import or declaration brings `name` into scope. */ export declare function isFactoryNameInScope(program: AstNode, name: string): boolean;