@dereekb/dbx-cli 13.11.14 → 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.
@@ -64,6 +64,8 @@ export declare function buildModelDecodeCommand(manifest: CliModelManifest, opti
64
64
  * @param rawKey - The Firestore key string.
65
65
  * @param manifest - The generated model manifest.
66
66
  * @returns The decoded key with leaf, ancestors, and any unresolved prefixes.
67
+ * @throws {CliError} When `rawKey` is empty or does not parse into an even number of `prefix/id` segments.
68
+ *
67
69
  * @__NO_SIDE_EFFECTS__
68
70
  */
69
71
  export declare function decodeFirestoreModelKey(rawKey: string, manifest: CliModelManifest): DecodedKey;
@@ -72,8 +74,9 @@ export declare function decodeFirestoreModelKey(rawKey: string, manifest: CliMod
72
74
  * MCP `dbx_model_decode` key-mode output for consistency between agent and
73
75
  * shell consumers.
74
76
  *
75
- * @param decoded - the decoded key returned by {@link decodeFirestoreModelKey}.
76
- * @returns the formatted block with a trailing newline.
77
+ * @param decoded - The decoded key returned by {@link decodeFirestoreModelKey}.
78
+ * @returns The formatted block with a trailing newline.
79
+ *
77
80
  * @__NO_SIDE_EFFECTS__
78
81
  */
79
82
  export declare function renderDecodedKey(decoded: DecodedKey): string;
@@ -6,17 +6,19 @@ import type { CliModelManifest, CliModelManifestEntry } from './types';
6
6
  * Re-exports {@link findCliModelManifestEntry} under a more descriptive name
7
7
  * for the model-info command.
8
8
  *
9
- * @param manifest - the generated model manifest.
10
- * @param query - identifier to look up.
11
- * @returns the matching entry or `undefined`.
9
+ * @param manifest - The generated model manifest.
10
+ * @param query - Identifier to look up.
11
+ * @returns The matching entry or `undefined`.
12
+ *
12
13
  * @__NO_SIDE_EFFECTS__
13
14
  */
14
15
  export declare function resolveCliModel(manifest: CliModelManifest, query: string): CliModelManifestEntry | undefined;
15
16
  /**
16
17
  * Produces a column-aligned summary table of every model in the manifest.
17
18
  *
18
- * @param manifest - the generated model manifest.
19
- * @returns the formatted table as a single string with a trailing newline.
19
+ * @param manifest - The generated model manifest.
20
+ * @returns The formatted table as a single string with a trailing newline.
21
+ *
20
22
  * @__NO_SIDE_EFFECTS__
21
23
  */
22
24
  export declare function renderModelManifestList(manifest: CliModelManifest): string;
@@ -24,8 +26,9 @@ export declare function renderModelManifestList(manifest: CliModelManifest): str
24
26
  * Produces a human-readable summary of one model entry: header, description,
25
27
  * and an indented field tree (recursing into `nestedFields`).
26
28
  *
27
- * @param entry - the manifest entry to render.
28
- * @returns the formatted summary as a single string with a trailing newline.
29
+ * @param entry - The manifest entry to render.
30
+ * @returns The formatted summary as a single string with a trailing newline.
31
+ *
29
32
  * @__NO_SIDE_EFFECTS__
30
33
  */
31
34
  export declare function renderModelManifestEntry(entry: CliModelManifestEntry): string;
@@ -33,8 +36,9 @@ export declare function renderModelManifestEntry(entry: CliModelManifestEntry):
33
36
  * Produces the field-table portion of {@link renderModelManifestEntry} on its
34
37
  * own, used by the `--fields` flag of the `model-info` command.
35
38
  *
36
- * @param entry - the manifest entry whose fields should be rendered.
37
- * @returns the formatted field tree as a single string with a trailing newline.
39
+ * @param entry - The manifest entry whose fields should be rendered.
40
+ * @returns The formatted field tree as a single string with a trailing newline.
41
+ *
38
42
  * @__NO_SIDE_EFFECTS__
39
43
  */
40
44
  export declare function renderModelManifestFields(entry: CliModelManifestEntry): string;
@@ -39,11 +39,12 @@ export declare function createAuthMiddleware(input: CreateAuthMiddlewareInput):
39
39
  * Test-only middleware that skips OIDC discovery, disk token loading, and token refresh, attaching
40
40
  * a pre-built {@link CliContext} directly via {@link setCliContext}.
41
41
  *
42
- * @internal Intended for use by `@dereekb/dbx-cli/test`. Not for production wiring.
43
- *
44
42
  * @param input - The pre-built context to attach on every invocation.
45
43
  * @param input.cliContext - The {@link CliContext} that will be attached via {@link setCliContext}.
46
44
  * @returns A yargs middleware function that always sets the provided context.
45
+ *
46
+ * @internal Intended for use by `@dereekb/dbx-cli/test`. Not for production wiring.
47
+ *
47
48
  * @__NO_SIDE_EFFECTS__
48
49
  */
49
50
  export declare function createPassthroughAuthMiddleware(input: {
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Shared AST/JSDoc helpers used by the per-domain `*-extract.ts` modules.
3
+ *
4
+ * Each extractor walks ts-morph nodes the same way to read JSDoc tag bodies,
5
+ * unwrap fenced code blocks, split list-style tag text, inspect Angular
6
+ * `@Directive`/`@Component` decorators, and decide whether a class member is
7
+ * publicly visible. Centralising these helpers avoids byte-identical
8
+ * duplication across `actions-extract.ts`, `filters-extract.ts`,
9
+ * `pipes-extract.ts`, `ui-components-extract.ts`, and
10
+ * `forge-fields-extract.ts`.
11
+ */
12
+ import { type ClassDeclaration, type Decorator, type ObjectLiteralExpression, type PropertyDeclaration } from 'ts-morph';
13
+ /**
14
+ * Strips a leading and trailing triple-backtick fence (and optional language
15
+ * marker) from a JSDoc `@example` body. Falls through to the trimmed input
16
+ * when the fence pattern doesn't match.
17
+ *
18
+ * @param text - The raw `@example` body to unwrap.
19
+ * @returns The body with surrounding code fence removed, or the trimmed input when no fence is present.
20
+ */
21
+ export declare function unwrapFenced(text: string): string;
22
+ /**
23
+ * Splits a list-style tag body (whitespace or comma separated) into trimmed,
24
+ * non-empty pieces.
25
+ *
26
+ * @param text - The raw tag body to split.
27
+ * @returns Trimmed, non-empty tokens preserved in source order.
28
+ */
29
+ export declare function splitListTagText(text: string): readonly string[];
30
+ /**
31
+ * Flattens an array of list-style tag bodies into a single trimmed,
32
+ * non-empty array of pieces.
33
+ *
34
+ * @param values - Multiple raw tag bodies whose pieces should be merged.
35
+ * @returns Every trimmed, non-empty token from every body, in source order.
36
+ */
37
+ export declare function flattenList(values: readonly string[]): readonly string[];
38
+ /**
39
+ * Reads a string-literal property from an object literal. Returns `undefined`
40
+ * when the property is missing, isn't a property assignment, or when the
41
+ * initializer isn't a (non-substitution) string literal.
42
+ *
43
+ * @param obj - The object literal expression to inspect.
44
+ * @param propName - The property name whose string-literal value to read.
45
+ * @returns The string value, or `undefined` if the property is missing or not a string literal.
46
+ */
47
+ export declare function readStringProperty(obj: ObjectLiteralExpression, propName: string): string | undefined;
48
+ /**
49
+ * Reads the `selector` string from the first object-literal argument of an
50
+ * `@Directive()` / `@Component()` decorator call. Returns `undefined` when
51
+ * the decorator has no call expression, no first argument, or the first
52
+ * argument isn't an object literal with a string `selector`.
53
+ *
54
+ * @param decorator - The Angular decorator node to read.
55
+ * @returns The selector string, or `undefined` if absent.
56
+ */
57
+ export declare function readSelector(decorator: Decorator): string | undefined;
58
+ /**
59
+ * Walks the supplied class's decorators looking for the first
60
+ * `@Directive()` / `@Component()` whose object literal includes a
61
+ * `selector`. Returns `undefined` when no qualifying decorator is found.
62
+ *
63
+ * @param decl - The class declaration to inspect.
64
+ * @returns An object containing the discovered selector, or `undefined` if no qualifying decorator is present.
65
+ */
66
+ export declare function readDirectiveDecorator(decl: ClassDeclaration): {
67
+ readonly selector: string;
68
+ } | undefined;
69
+ /**
70
+ * Returns `true` when the property has neither `private` nor `protected`
71
+ * modifiers. Used as the default visibility filter when extracting Angular
72
+ * inputs/outputs.
73
+ *
74
+ * @param property - The property declaration to inspect.
75
+ * @returns `true` if the property is publicly visible.
76
+ */
77
+ export declare function isVisibleProperty(property: PropertyDeclaration): boolean;
78
+ /**
79
+ * Joins every JSDoc description block on the property with `\n\n`. Returns
80
+ * an empty string when the property has no JSDoc or only blank descriptions.
81
+ *
82
+ * @param property - The property declaration whose JSDoc descriptions to collect.
83
+ * @returns The concatenated description text, or an empty string when none is present.
84
+ */
85
+ export declare function readPropertyDescription(property: PropertyDeclaration): string;
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Shared I/O primitives for the build-manifest pipelines.
3
+ *
4
+ * Every scanner needs the same file-reading, glob-matching, exclude-filtering,
5
+ * and package-name-loading logic, so it lives here once. Individual
6
+ * `*-build-manifest.ts` modules import these and supply their own schema
7
+ * validation / entry assembly.
8
+ */
9
+ import { Project } from 'ts-morph';
10
+ /**
11
+ * Function shape used to read text files. Defaults to
12
+ * `node:fs/promises.readFile(path, 'utf-8')`.
13
+ */
14
+ export type ScanReadFile = (absolutePath: string) => Promise<string>;
15
+ /**
16
+ * Function shape used to resolve include/exclude globs against the project
17
+ * root. Defaults to `node:fs/promises.glob` filtered through a regex-derived
18
+ * exclude check.
19
+ */
20
+ export type ScanGlobber = (input: {
21
+ readonly projectRoot: string;
22
+ readonly include: readonly string[];
23
+ readonly exclude: readonly string[];
24
+ }) => Promise<readonly string[]>;
25
+ export declare const defaultReadFile: ScanReadFile;
26
+ export declare const defaultGlobber: ScanGlobber;
27
+ /**
28
+ * Shared outcome kinds for the `no-package` / `invalid-package` error
29
+ * paths. Every build-manifest outcome type includes these same two
30
+ * variants, so the shared loader can return a compatible discriminated
31
+ * union.
32
+ */
33
+ export type LoadPackageNameResult = {
34
+ readonly kind: 'ok';
35
+ readonly packageName: string;
36
+ } | {
37
+ readonly kind: 'fail';
38
+ readonly outcome: {
39
+ readonly kind: 'no-package';
40
+ readonly packagePath: string;
41
+ } | {
42
+ readonly kind: 'invalid-package';
43
+ readonly packagePath: string;
44
+ readonly error: string;
45
+ };
46
+ };
47
+ /**
48
+ * Reads `package.json` at the supplied path and returns its `name` field, normalising file/parse errors into a discriminated outcome compatible with `*-build-manifest.ts` callers.
49
+ *
50
+ * @param packagePath - Absolute path to `package.json`.
51
+ * @param readFile - File-reader injected by the scan runtime.
52
+ * @returns Either the parsed package name or a discriminated failure outcome.
53
+ */
54
+ export declare function loadPackageName(packagePath: string, readFile: ScanReadFile): Promise<LoadPackageNameResult>;
55
+ /**
56
+ * Failure variants surfaced by {@link loadScanSection}. Every per-cluster
57
+ * `Build*ManifestOutcome` includes these same two variants so the shared
58
+ * loader can return a value the caller forwards directly.
59
+ */
60
+ export type ScanConfigFailureOutcome = {
61
+ readonly kind: 'no-config';
62
+ readonly configPath: string;
63
+ } | {
64
+ readonly kind: 'invalid-scan-config';
65
+ readonly configPath: string;
66
+ readonly error: string;
67
+ };
68
+ /**
69
+ * Discriminated outcome from {@link loadScanSection}. On success carries the
70
+ * cluster's already-validated section; on failure carries an outcome the
71
+ * caller forwards as its own `Build*ManifestOutcome`.
72
+ */
73
+ export type LoadScanSectionResult<TSection> = {
74
+ readonly kind: 'ok';
75
+ readonly section: TSection;
76
+ } | {
77
+ readonly kind: 'fail';
78
+ readonly outcome: ScanConfigFailureOutcome;
79
+ };
80
+ /**
81
+ * Reads `dbx-mcp.scan.json` at {@link configPath}, parses it as JSON, and
82
+ * hands the parsed object to {@link parseSection} for cluster-specific
83
+ * arktype validation. Centralises the missing-file / bad-JSON / invalid-
84
+ * schema branches that every `*-build-manifest.ts` repeats verbatim.
85
+ *
86
+ * @param input - Config path, file reader, and the cluster-specific parse callback used to validate the section.
87
+ * @param input.configPath - Absolute path to the `dbx-mcp.scan.json` file to read.
88
+ * @param input.readFile - File-reader injected by the scan runtime; defaults to `node:fs/promises.readFile` in production callers.
89
+ * @param input.parseSection - Cluster-specific parser that validates the parsed JSON and extracts the relevant sub-section (typically wraps an arktype validator).
90
+ * @returns Either the validated section or a forwardable failure outcome (`no-config` or `invalid-scan-config`).
91
+ */
92
+ export declare function loadScanSection<TSection>(input: {
93
+ readonly configPath: string;
94
+ readonly readFile: ScanReadFile;
95
+ readonly parseSection: (parsed: unknown) => {
96
+ readonly ok: true;
97
+ readonly section: TSection;
98
+ } | {
99
+ readonly ok: false;
100
+ readonly error: string;
101
+ };
102
+ }): Promise<LoadScanSectionResult<TSection>>;
103
+ /**
104
+ * Builds an in-memory ts-morph {@link Project} populated with the supplied
105
+ * relative file paths. Resolves every path against {@link projectRoot},
106
+ * reads it via {@link readFile}, and adds it to the project as a source
107
+ * file. Used by every `*-build-manifest.ts` orchestrator before handing
108
+ * the project to its cluster-specific extractor.
109
+ *
110
+ * @param input - Project root, relative file paths to load, and the file reader used to fetch each file's contents.
111
+ * @param input.projectRoot - Absolute path used as the base for resolving each entry in `filePaths`.
112
+ * @param input.filePaths - Relative file paths to add to the in-memory project, resolved against `projectRoot`.
113
+ * @param input.readFile - File-reader used to fetch each file's contents before adding it to the project.
114
+ * @returns The populated ts-morph project ready for entry extraction.
115
+ */
116
+ export declare function buildScanProject(input: {
117
+ readonly projectRoot: string;
118
+ readonly filePaths: readonly string[];
119
+ readonly readFile: ScanReadFile;
120
+ }): Promise<Project>;
121
+ /**
122
+ * Translates a glob pattern into a RegExp suitable for testing
123
+ * `relative(projectRoot, file)` paths. Supports `**`, `*`, and `?`
124
+ * wildcards. Used by the default globber to filter exclude patterns
125
+ * — the matching logic intentionally mirrors `node:fs/promises.glob`.
126
+ *
127
+ * @param pattern - A glob pattern (no character classes)
128
+ * @returns A RegExp that matches paths satisfying the glob.
129
+ */
130
+ export declare function globToRegex(pattern: string): RegExp;
package/test/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli/test",
3
- "version": "13.11.14",
3
+ "version": "13.11.16",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.11.14",
6
- "@dereekb/dbx-cli": "13.11.14",
7
- "@dereekb/firebase": "13.11.14",
8
- "@dereekb/firebase-server/test": "13.11.14",
9
- "@dereekb/model": "13.11.14",
10
- "@dereekb/nestjs": "13.11.14",
11
- "@dereekb/rxjs": "13.11.14",
12
- "@dereekb/util": "13.11.14",
5
+ "@dereekb/date": "13.11.16",
6
+ "@dereekb/dbx-cli": "13.11.16",
7
+ "@dereekb/firebase": "13.11.16",
8
+ "@dereekb/firebase-server/test": "13.11.16",
9
+ "@dereekb/model": "13.11.16",
10
+ "@dereekb/nestjs": "13.11.16",
11
+ "@dereekb/rxjs": "13.11.16",
12
+ "@dereekb/util": "13.11.16",
13
13
  "@nestjs/common": "^11.1.19",
14
14
  "arktype": "^2.2.0",
15
15
  "yargs": "^18.0.0"