/** * Spec-file naming conventions for API test files. * * Downstream Firebase Functions API apps keep their tests under * `/src/app/function//`, with each spec file named so that * "what does this test, and where do I add the next one?" can be answered * from the filename alone. The canonical forms are: * * - `.crud.spec.ts` — non-scenario tests of the CRUD function map for the group. * - `.crud.[....].spec.ts` — CRUD tests focused on a sub-area * (e.g. `job.crud.requirement.spec.ts`). * - `.scenario.spec.ts` — generic multi-step scenario tests using fixture * chains. * - `.scenario.[....].spec.ts` — focused scenario sub-bucket * (e.g. `job.scenario.requirement.worker.state.spec.ts`). * * Drift forms (still parsed, but flagged with a rename suggestion): * - `..crud.spec.ts` — `crud` placed after a subgroup. * Suggestion: `.crud..spec.ts`. * - `..scenario.spec.ts` — `scenario` placed after a subgroup * (e.g. `worker.payroll.scenario.spec.ts`, `school.job.publish.scenario.spec.ts`). * Suggestion: `.scenario..spec.ts`. * - `..spec.ts` — no `crud` / `scenario` segment at all * (e.g. `worker.system.spec.ts`). Defaults to a scenario rename suggestion * because the missing bucket is more often scenario-like. * * This module is pure: classification and canonical-path rendering live * here, with no disk I/O. It's consumed by `@dereekb/dbx-components-mcp` * (the `dbx_model_test_*` tool cluster) and by * `@dereekb/firebase/eslint` (the `require-canonical-api-spec-filename` * and `require-api-crud-spec-for-group` rules). */ /** * The naming buckets recognised by the classifier. `non-spec` is emitted when * the input does not end in `.spec.ts`; `non-group` when the first filename * segment doesn't match the parent folder name (the file belongs to a different * model group or to no group at all). */ export type SpecFileKind = 'crud' | 'crud-subgroup' | 'scenario' | 'scenario-subgroup' | 'crud-misplaced' | 'scenario-misplaced' | 'no-bucket' | 'non-spec' | 'non-group'; /** * Whether a given kind is on-convention. Drift kinds (`-misplaced`, * `no-bucket`) are still parseable but earn a warning + rename suggestion. */ export declare const CANONICAL_KINDS: readonly SpecFileKind[]; /** * One classified spec file. Drift entries carry a {@link recommendedRename} * suggesting the canonical filename; canonical entries leave it undefined. */ export interface SpecFileClassification { readonly filename: string; readonly group: string; readonly kind: SpecFileKind; /** * Segments between the group name and the `crud` / `scenario` marker for * `crud-subgroup` / `scenario-subgroup` kinds (e.g. `['requirement','worker']` * for `job.scenario.requirement.worker.spec.ts`). Empty for `crud` / * `scenario` and for non-group kinds. */ readonly subgroups: readonly string[]; /** * `true` when the kind is one of {@link CANONICAL_KINDS}. */ readonly isCanonical: boolean; /** * Suggested canonical filename when the input is drift. `undefined` for * canonical entries and for {@link `non-spec`} / {@link `non-group`}. */ readonly recommendedRename?: string; /** * Human-readable reason emitted with drift kinds; `undefined` for canonical * entries. Used by the formatter so each warning line explains itself. */ readonly driftReason?: string; } /** * Classifies a spec filename against the conventions for the given parent * folder. Pure function — never touches the filesystem. * * @param config - Inputs. * @param config.filename - Bare filename including the `.spec.ts` suffix * (e.g. `job.scenario.requirement.spec.ts`). * @param config.parentFolderName - Name of the directory containing the file * (e.g. `job`). Used to detect cross-group misplacement. * @returns The classification. */ export declare function classifySpecFile(config: { readonly filename: string; readonly parentFolderName: string; }): SpecFileClassification; /** * Renders a canonical spec filename for the given group + bucket + subgroup * chain. Pure data — used both by drift remediation and by the * `recommendSpecPath()` helper below. * * @param config - Inputs. * @param config.group - The model-group name (e.g. `job`). * @param config.bucket - `crud` or `scenario`. * @param config.subgroups - Optional ordered subgroup segments * (e.g. `['requirement','worker']`). * @returns The canonical filename (e.g. `job.scenario.requirement.worker.spec.ts`). */ export declare function buildCanonicalFilename(config: { readonly group: string; readonly bucket: 'crud' | 'scenario'; readonly subgroups: readonly string[]; }): string; /** * Renders the canonical relative path for a spec file under a given API app. * The shape mirrors the layout used throughout the workspace: * `/src/app/function//`. * * @param config - Inputs. * @param config.apiDir - The relative API-app directory * (e.g. `apps/hellosubs-api`). * @param config.group - The model-group name. * @param config.bucket - `crud` or `scenario`. * @param config.subgroups - Optional subgroup chain. * @returns The canonical relative spec-file path. */ export declare function recommendSpecPath(config: { readonly apiDir: string; readonly group: string; readonly bucket: 'crud' | 'scenario'; readonly subgroups: readonly string[]; }): string; /** * One recommendation slot rendered by the list-app tool's "where to add a new * test" section. `subgroups` is left empty for the base buckets; callers * substitute their own subgroup chain when scaffolding a focused file. */ export interface SpecBucketRecommendation { readonly bucket: 'crud' | 'scenario'; readonly label: string; readonly canonicalPath: string; readonly summary: string; } /** * Returns the two canonical buckets for a given model group, with rendered * paths and one-line summaries. Used by the list-app formatter. * * @param config - Inputs. * @param config.apiDir - Relative API-app directory. * @param config.group - Model-group name. * @returns The crud + scenario recommendations. */ export declare function recommendBucketsForGroup(config: { readonly apiDir: string; readonly group: string; }): readonly SpecBucketRecommendation[];