@dereekb/dbx-cli 13.11.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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/firebase-api-manifest/src/generate-api-manifest/bind-validators.d.ts +44 -0
  3. package/firebase-api-manifest/src/generate-api-manifest/emit.d.ts +29 -0
  4. package/firebase-api-manifest/src/generate-api-manifest/extract-crud.d.ts +25 -0
  5. package/firebase-api-manifest/src/generate-api-manifest/find-api-files.d.ts +16 -0
  6. package/firebase-api-manifest/src/generate-api-manifest/main.d.ts +46 -0
  7. package/firebase-api-manifest/src/generate-api-manifest/parse-functions.d.ts +18 -0
  8. package/firebase-api-manifest/src/generate-api-manifest/resolve-package.d.ts +59 -0
  9. package/firebase-api-manifest/src/generate-api-manifest/types.d.ts +44 -0
  10. package/index.cjs.default.js +1 -0
  11. package/index.cjs.js +8162 -0
  12. package/index.cjs.mjs +2 -0
  13. package/index.d.ts +1 -0
  14. package/index.esm.js +8084 -0
  15. package/package.json +27 -0
  16. package/src/index.d.ts +1 -0
  17. package/src/lib/api/call-model.client.d.ts +37 -0
  18. package/src/lib/api/call-model.command.factory.d.ts +42 -0
  19. package/src/lib/api/call.passthrough.command.d.ts +8 -0
  20. package/src/lib/api/index.d.ts +3 -0
  21. package/src/lib/auth/auth.command.factory.d.ts +29 -0
  22. package/src/lib/auth/index.d.ts +3 -0
  23. package/src/lib/auth/oidc.client.d.ts +125 -0
  24. package/src/lib/auth/oidc.flow.d.ts +79 -0
  25. package/src/lib/config/cli.config.d.ts +112 -0
  26. package/src/lib/config/env.d.ts +183 -0
  27. package/src/lib/config/index.d.ts +4 -0
  28. package/src/lib/config/paths.d.ts +33 -0
  29. package/src/lib/config/token.cache.d.ts +51 -0
  30. package/src/lib/context/cli.context.d.ts +41 -0
  31. package/src/lib/context/index.d.ts +1 -0
  32. package/src/lib/doctor/doctor.command.factory.d.ts +48 -0
  33. package/src/lib/doctor/index.d.ts +1 -0
  34. package/src/lib/env/env.command.factory.d.ts +22 -0
  35. package/src/lib/env/index.d.ts +1 -0
  36. package/src/lib/index.d.ts +11 -0
  37. package/src/lib/manifest/build-manifest-commands.d.ts +77 -0
  38. package/src/lib/manifest/index.d.ts +2 -0
  39. package/src/lib/manifest/types.d.ts +20 -0
  40. package/src/lib/middleware/auth.middleware.d.ts +29 -0
  41. package/src/lib/middleware/index.d.ts +2 -0
  42. package/src/lib/middleware/output.middleware.d.ts +54 -0
  43. package/src/lib/output/index.d.ts +1 -0
  44. package/src/lib/output/output.command.factory.d.ts +55 -0
  45. package/src/lib/runner/index.d.ts +1 -0
  46. package/src/lib/runner/run.d.ts +71 -0
  47. package/src/lib/util/args.d.ts +78 -0
  48. package/src/lib/util/context.slot.d.ts +50 -0
  49. package/src/lib/util/handler.d.ts +13 -0
  50. package/src/lib/util/index.d.ts +6 -0
  51. package/src/lib/util/interactive.d.ts +26 -0
  52. package/src/lib/util/output.d.ts +152 -0
  53. package/src/lib/util/pagination.d.ts +91 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hapier Creative LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,44 @@
1
+ /**
2
+ * For a given Params type name (e.g. `SetProfileUsernameParams`), derives the
3
+ * canonical arktype validator identifier (`setProfileUsernameParamsType`) by
4
+ * naming convention and confirms it is exported from the resolved package.
5
+ *
6
+ * Verification is best-effort: we string-search the package's `src/index.ts`
7
+ * and follow `export * from './...';` re-exports recursively until we find
8
+ * the declaration of the validator. The convention everywhere in the codebase
9
+ * is `export const <name>ParamsType = ... as Type<<Name>Params>`.
10
+ */
11
+ /**
12
+ * Derives the canonical arktype validator identifier from a Params type name.
13
+ *
14
+ * `SetProfileUsernameParams` → `setProfileUsernameParamsType`.
15
+ *
16
+ * @param paramsTypeName - PascalCase Params type identifier.
17
+ * @returns The lowerCamelCase validator identifier (or empty string for empty input).
18
+ */
19
+ export declare function deriveValidatorName(paramsTypeName: string): string;
20
+ /**
21
+ * Inputs for {@link isExportedFromPackage}.
22
+ */
23
+ export interface IsExportedInput {
24
+ readonly packageRoot: string;
25
+ readonly identifier: string;
26
+ }
27
+ /**
28
+ * Confirms an identifier is exported from `packageRoot/src/index.ts` —
29
+ * directly or via re-export chains.
30
+ *
31
+ * @param input - Package root + identifier to look up.
32
+ * @returns `true` when the identifier is reachable from the barrel.
33
+ */
34
+ export declare function isExportedFromPackage(input: IsExportedInput): boolean;
35
+ /**
36
+ * Walks the `src/lib` tree under a package and returns the absolute file
37
+ * paths of every `.ts` file (used as a fallback when index-chain lookup
38
+ * misses the identifier — some packages rely on flat barrels that don't
39
+ * `export *`).
40
+ *
41
+ * @param packageRoot - Absolute path to the source package's root directory.
42
+ * @returns Absolute paths of every non-spec `.ts` file under `src`.
43
+ */
44
+ export declare function listPackageTsFiles(packageRoot: string): string[];
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Renders the final manifest TS module — banner + grouped imports + the
3
+ * `<NAMESPACE>` array literal. Formatted with the workspace prettier config
4
+ * so the output matches what `prettier --write` would produce on the
5
+ * committed file.
6
+ *
7
+ * The reusable `CliApiManifest` type is imported from `@dereekb/dbx-cli` so
8
+ * any consuming app gets it from the shared dbx-cli barrel.
9
+ */
10
+ import type { CollectedEntry } from './types';
11
+ /**
12
+ * Inputs for {@link renderManifest}.
13
+ */
14
+ export interface RenderManifestInput {
15
+ readonly outputFile: string;
16
+ readonly entries: readonly CollectedEntry[];
17
+ readonly projectName: string;
18
+ readonly namespace: string;
19
+ }
20
+ /**
21
+ * Renders the manifest TS source for a CLI app and formats it with the
22
+ * workspace prettier config so the output matches a `prettier --write` of the
23
+ * committed file.
24
+ *
25
+ * @param input - Output file path, collected entries, project name (banner),
26
+ * and the manifest namespace identifier.
27
+ * @returns Prettier-formatted TypeScript source.
28
+ */
29
+ export declare function renderManifest(input: RenderManifestInput): Promise<string>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Walks `<Group>ModelCrudFunctionsConfig` and `<Group>FunctionTypeMap` type
3
+ * aliases in a `<model>.api.ts` source. Returns one entry per callable leaf,
4
+ * keyed by (model, verb, specifier).
5
+ *
6
+ * Mirrors `extractCrudEntries` from
7
+ * packages/dbx-components-mcp/src/tools/model-api-shared/extract-crud.ts —
8
+ * keep the two in lockstep when the .api.ts convention changes.
9
+ */
10
+ import type { CrudExtraction } from './types';
11
+ /**
12
+ * Inputs for {@link extractCrudEntries}.
13
+ */
14
+ export interface ExtractCrudInput {
15
+ readonly name: string;
16
+ readonly text: string;
17
+ }
18
+ /**
19
+ * Extracts CRUD + standalone entries from a `.api.ts` source by walking its
20
+ * `<Group>ModelCrudFunctionsConfig` and `<Group>FunctionTypeMap` aliases.
21
+ *
22
+ * @param source - The source file's name + text.
23
+ * @returns The extracted entries, group name, model keys, and `*Functions` class name.
24
+ */
25
+ export declare function extractCrudEntries(source: ExtractCrudInput): CrudExtraction;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Walks a package's `src/lib/**\/*.api.ts` and returns the files that declare
3
+ * an abstract `*Functions` class along with the class name. Used to map a
4
+ * class identifier from `<APP>_FIREBASE_FUNCTIONS_CONFIG` back to the source
5
+ * `*.api.ts`.
6
+ */
7
+ import type { ApiFileMatch } from './types';
8
+ /**
9
+ * Walks `packageRoot/src/lib/**\/*.api.ts` and returns the files that declare
10
+ * an abstract `*Functions` class along with the class name and the
11
+ * extracted CRUD entries.
12
+ *
13
+ * @param packageRoot - Absolute path to the source package's root directory.
14
+ * @returns One {@link ApiFileMatch} per qualifying `.api.ts`.
15
+ */
16
+ export declare function findApiFiles(packageRoot: string): ApiFileMatch[];
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generates an API manifest TS file for any dbx-components CLI app.
3
+ *
4
+ * Pipeline (build-time, run via `nx run <cli>:generate-api-manifest`):
5
+ *
6
+ * 1. Parse the app's `<APP>_FIREBASE_FUNCTIONS_CONFIG` from the file passed
7
+ * via --functions-config to enumerate the `*Functions` abstract classes
8
+ * used by the app, including their source-module specifier
9
+ * ("@dereekb/firebase", "demo-firebase", "./model", "./development",
10
+ * ...). The leading-app prefix is matched generically by
11
+ * `/FIREBASE_FUNCTIONS_CONFIG$/` so any app variable name works.
12
+ *
13
+ * 2. Resolve each module to a source-package root via the workspace's
14
+ * tsconfig.base.json `paths`.
15
+ *
16
+ * 3. Walk that package's `src/lib/**\/*.api.ts`, run the CRUD-entry walker
17
+ * on each, and pick the file whose abstract `*Functions` class name
18
+ * matches the entry's class identifier.
19
+ *
20
+ * 4. For each CRUD entry with a `paramsTypeName`, derive the canonical
21
+ * arktype validator name (lowercaseFirst + `Type`) and confirm it is
22
+ * exported from the package's barrel chain. Warn on miss; the entry is
23
+ * still emitted with `paramsValidator: undefined`. `--strict` makes a
24
+ * miss fatal.
25
+ *
26
+ * 5. Emit the manifest to the path passed via --output with grouped
27
+ * per-package imports + the `<NAMESPACE>_API_MANIFEST` array literal.
28
+ * Skip the write if the file content is byte-identical (preserves mtime
29
+ * for incremental builds).
30
+ *
31
+ * Flags:
32
+ * --functions-config=<path> (required) path to the app's functions.ts.
33
+ * Absolute or workspace-relative.
34
+ * --output=<path> (required) path to the manifest TS file to write.
35
+ * Absolute or workspace-relative.
36
+ * --project=<name> Project name shown in the regenerate banner
37
+ * (defaults to "<cli>"). Also used to derive
38
+ * the manifest namespace (e.g. "demo-cli" ->
39
+ * DEMO_CLI_API_MANIFEST).
40
+ * --only=<model[,model]> Filter the emitted entries to those models.
41
+ * --strict Exit 1 if any validator is missing.
42
+ *
43
+ * Run from any cwd; workspace-relative paths resolve against `process.cwd()`
44
+ * (Nx invokes with cwd: "{workspaceRoot}").
45
+ */
46
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Parses the `<APP>_FIREBASE_FUNCTIONS_CONFIG` variable from a CLI app's
3
+ * `functions.ts` and returns the (groupKey, className, importedFromModule)
4
+ * tuple for every entry.
5
+ *
6
+ * We follow the import declaration of the abstract-class identifier to know
7
+ * which package the `*.api.ts` lives in. The variable name is matched
8
+ * generically by `/FIREBASE_FUNCTIONS_CONFIG$/` so any app-prefix works.
9
+ */
10
+ import type { FunctionsGroup } from './types';
11
+ /**
12
+ * Parses the `<APP>_FIREBASE_FUNCTIONS_CONFIG` literal at `functionsTsPath`
13
+ * into one entry per group declared in the config object.
14
+ *
15
+ * @param functionsTsPath - Absolute path to the app's `functions.ts`.
16
+ * @returns One {@link FunctionsGroup} per `<groupKey>: [<Class>, ...]` pair.
17
+ */
18
+ export declare function parseFunctionsConfig(functionsTsPath: string): FunctionsGroup[];
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Resolves a workspace module specifier (e.g. "@dereekb/firebase",
3
+ * "demo-firebase", "./model", "./development") to a source-package root and
4
+ * canonical import name.
5
+ *
6
+ * Reads the workspace tsconfig.base.json `compilerOptions.paths` to map bare
7
+ * specifiers to their `src/index.ts` entry. Relative specifiers are resolved
8
+ * against the importing file's directory and then walked back up to the
9
+ * nearest `package.json` that owns them.
10
+ */
11
+ import type { PackageRef } from './types';
12
+ /**
13
+ * Inputs accepted by {@link resolveModuleToPackage}.
14
+ */
15
+ export interface ResolveModuleInput {
16
+ readonly workspaceRoot: string;
17
+ readonly importingFile: string;
18
+ readonly moduleSpecifier: string;
19
+ }
20
+ /**
21
+ * Reads `tsconfig.base.json` and returns the `compilerOptions.paths` map
22
+ * (canonical bare specifier → absolute path to its `src/index.ts`).
23
+ *
24
+ * @param workspaceRoot - Workspace root directory.
25
+ * @returns Cached map of canonical specifiers to absolute index paths.
26
+ */
27
+ export declare function loadTsconfigPaths(workspaceRoot: string): Map<string, string>;
28
+ /**
29
+ * Resolves a module specifier to the source-package that owns it.
30
+ *
31
+ * @param input - Workspace root + importing-file location + the specifier.
32
+ * @returns The {@link PackageRef} of the owning package, or `undefined` when unresolved.
33
+ */
34
+ export declare function resolveModuleToPackage(input: ResolveModuleInput): PackageRef | undefined;
35
+ /**
36
+ * Walks up from `startPath` until it finds a directory containing a `package.json`
37
+ * with a `name` field, then returns its package name + root.
38
+ *
39
+ * @param workspaceRoot - Stop walking when this directory is reached.
40
+ * @param startPath - Path to walk up from.
41
+ * @returns The package name + root, or `undefined` if no package.json is found.
42
+ */
43
+ export declare function locatePackageForPath(workspaceRoot: string, startPath: string): PackageRef | undefined;
44
+ /**
45
+ * Returns the workspace-root-relative path with forward slashes for display.
46
+ *
47
+ * @param workspaceRoot - Workspace root directory.
48
+ * @param absolutePath - Absolute path to make relative.
49
+ * @returns The workspace-relative path with forward slashes.
50
+ */
51
+ export declare function relPath(workspaceRoot: string, absolutePath: string): string;
52
+ /**
53
+ * Type-narrowed `isAbsolute` re-export so the generator scripts only depend on
54
+ * `node:path` indirectly through this module.
55
+ *
56
+ * @param value - Path to test.
57
+ * @returns `true` when the path is absolute.
58
+ */
59
+ export declare function isAbsolutePathLike(value: string): boolean;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Internal types shared between the generator's pipeline stages.
3
+ *
4
+ * The runtime manifest types (`CliApiManifest`, `CliApiManifestEntry`,
5
+ * `CliApiVerb`) live in `packages/dbx-cli/src/lib/manifest/types.ts` and are
6
+ * re-exported from `@dereekb/dbx-cli`. The generator emits TypeScript that
7
+ * imports those runtime types — it does not reference them itself.
8
+ */
9
+ export interface FunctionsGroup {
10
+ readonly groupKey: string;
11
+ readonly className: string;
12
+ readonly importedFromModule: string;
13
+ }
14
+ export interface PackageRef {
15
+ readonly packageName: string;
16
+ readonly packageRoot: string;
17
+ }
18
+ export interface CrudEntry {
19
+ readonly model: string;
20
+ readonly verb: string;
21
+ readonly specifier?: string;
22
+ readonly paramsTypeName?: string;
23
+ readonly resultTypeName?: string;
24
+ readonly line: number;
25
+ }
26
+ export interface CrudExtraction {
27
+ readonly groupName: string | undefined;
28
+ readonly modelKeys: readonly string[];
29
+ readonly entries: readonly CrudEntry[];
30
+ readonly functionsClassName?: string;
31
+ }
32
+ export interface ApiFileMatch {
33
+ readonly filePath: string;
34
+ readonly className: string;
35
+ readonly extraction: CrudExtraction;
36
+ }
37
+ export interface CollectedEntry {
38
+ readonly entry: CrudEntry & {
39
+ readonly groupName: string;
40
+ readonly sourceFile: string;
41
+ };
42
+ readonly packageName?: string;
43
+ readonly validatorName?: string;
44
+ }
@@ -0,0 +1 @@
1
+ exports._default = require('./index.cjs.js').default;