@dereekb/dbx-cli 13.11.4 → 13.11.5
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.
- package/firebase-api-manifest/main.js +666 -16
- package/firebase-api-manifest/package.json +1 -1
- package/index.cjs.js +567 -48
- package/index.esm.js +560 -49
- package/manifest-extract/index.cjs.js +705 -0
- package/manifest-extract/index.esm.js +705 -1
- package/manifest-extract/package.json +1 -1
- package/manifest-extract/src/index.d.ts +1 -0
- package/manifest-extract/src/lib/extract-models.d.ts +33 -0
- package/manifest-extract/src/lib/types.d.ts +148 -0
- package/package.json +5 -5
- package/src/lib/api/expand-keys.d.ts +31 -0
- package/src/lib/api/index.d.ts +1 -0
- package/src/lib/manifest/build-manifest-commands.d.ts +12 -1
- package/src/lib/manifest/build-model-info-command.d.ts +37 -0
- package/src/lib/manifest/index.d.ts +2 -0
- package/src/lib/manifest/model-info-utils.d.ts +40 -0
- package/src/lib/manifest/types.d.ts +126 -0
- package/src/lib/runner/run.d.ts +29 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-source-file walker that pulls Firestore-model metadata out of a `.ts`
|
|
3
|
+
* file: identities, `@dbxModel`-tagged interfaces with their property JSDocs,
|
|
4
|
+
* snapshot converters (top-level `snapshotConverterFunctions`,
|
|
5
|
+
* `firestoreSubObject`, and `firestoreObjectArray` consts), enums, and
|
|
6
|
+
* `@dbxModelGroup`-tagged collection containers.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the per-file outputs of `dbx-components-mcp`'s `extractModels()`
|
|
9
|
+
* but lives inside `@dereekb/dbx-cli/manifest-extract` so the `dbx-cli`
|
|
10
|
+
* build pipeline can reuse it without taking on a runtime dependency on the
|
|
11
|
+
* MCP package. The orchestrator that stitches per-file outputs into a
|
|
12
|
+
* downstream-shape `CliModelManifest` lives in
|
|
13
|
+
* `packages/dbx-cli/firebase-api-manifest/src/generate-api-manifest/`.
|
|
14
|
+
*/
|
|
15
|
+
import type { ModelExtraction } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Inputs for {@link extractModelsFromSource}.
|
|
18
|
+
*/
|
|
19
|
+
export interface ExtractModelsFromSourceInput {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly text: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Walks a single source file and reports raw model-extraction artifacts.
|
|
25
|
+
* Best-effort: a malformed call shape leaves the corresponding entry out
|
|
26
|
+
* rather than throwing.
|
|
27
|
+
*
|
|
28
|
+
* @param input - in-memory `{ name, text }` source pair.
|
|
29
|
+
* @returns the per-file extraction. Aggregation across files happens in the
|
|
30
|
+
* firebase-api-manifest orchestrator so cross-file converter consts can be
|
|
31
|
+
* resolved against a global registry.
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractModelsFromSource(input: ExtractModelsFromSourceInput): ModelExtraction;
|
|
@@ -84,3 +84,151 @@ export interface CrudExtraction {
|
|
|
84
84
|
*/
|
|
85
85
|
readonly functionsClassName?: string;
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* One `firestoreModelIdentity(...)` declaration found by
|
|
89
|
+
* {@link ../lib/extract-models#extractModelsFromSource}.
|
|
90
|
+
*/
|
|
91
|
+
export interface ModelExtractionIdentity {
|
|
92
|
+
readonly identityConst: string;
|
|
93
|
+
readonly modelType: string;
|
|
94
|
+
readonly collectionPrefix: string | undefined;
|
|
95
|
+
readonly parentIdentityConst: string | undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* One property on a `@dbxModel`-tagged interface.
|
|
99
|
+
*/
|
|
100
|
+
export interface ModelExtractionInterfaceProp {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly tsType: string;
|
|
103
|
+
readonly optional: boolean;
|
|
104
|
+
readonly description: string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Long form parsed from the property's `@dbxModelVariable <name>` JSDoc tag,
|
|
107
|
+
* when present.
|
|
108
|
+
*/
|
|
109
|
+
readonly longName: string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Description parsed from the property's `@dbxModelVariableSyncFlag …` JSDoc
|
|
112
|
+
* tag, when present.
|
|
113
|
+
*/
|
|
114
|
+
readonly syncFlag: string | undefined;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* One exported `interface` declaration. The walker captures every exported
|
|
118
|
+
* interface so cross-interface lookups (e.g. nested interface refs from a
|
|
119
|
+
* sub-object converter) work; the orchestrator filters by
|
|
120
|
+
* `hasDbxModelTag` to find the canonical model interfaces.
|
|
121
|
+
*/
|
|
122
|
+
export interface ModelExtractionInterface {
|
|
123
|
+
readonly name: string;
|
|
124
|
+
readonly description: string | undefined;
|
|
125
|
+
readonly hasDbxModelTag: boolean;
|
|
126
|
+
readonly extendsNames: readonly string[];
|
|
127
|
+
readonly props: readonly ModelExtractionInterfaceProp[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* One field inside a converter's `fields` map.
|
|
131
|
+
*/
|
|
132
|
+
export interface ModelExtractionConverterField {
|
|
133
|
+
readonly key: string;
|
|
134
|
+
/**
|
|
135
|
+
* Verbatim expression text of the field's value (whitespace collapsed).
|
|
136
|
+
*/
|
|
137
|
+
readonly converter: string;
|
|
138
|
+
/**
|
|
139
|
+
* Name of a referenced converter const when the field's expression is
|
|
140
|
+
* `firestoreObjectArray({ objectField: <const> })` or
|
|
141
|
+
* `firestoreSubObject({ objectField: <const> })`. Resolved by the
|
|
142
|
+
* orchestrator against the cross-file converter registry.
|
|
143
|
+
*/
|
|
144
|
+
readonly nestedConverterRef?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Inline nested converter when the field's expression is
|
|
147
|
+
* `firestoreObjectArray({ objectField: { fields: { … } } })` or
|
|
148
|
+
* `firestoreSubObject({ objectField: { fields: { … } } })`.
|
|
149
|
+
*/
|
|
150
|
+
readonly nestedConverterInline?: ModelExtractionConverter;
|
|
151
|
+
/**
|
|
152
|
+
* `true` when the wrapping factory is `firestoreObjectArray` (array element
|
|
153
|
+
* shape); `false` for `firestoreSubObject`. Only meaningful when one of
|
|
154
|
+
* `nestedConverterRef` or `nestedConverterInline` is set.
|
|
155
|
+
*/
|
|
156
|
+
readonly nestedIsArray?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* One snapshot-converter call. Captures both top-level
|
|
160
|
+
* `export const <X>Converter = snapshotConverterFunctions<…>(…)` declarations
|
|
161
|
+
* and inline `firestoreSubObject(…)` / `firestoreObjectArray(…)` calls
|
|
162
|
+
* embedded in another converter's field map.
|
|
163
|
+
*/
|
|
164
|
+
export interface ModelExtractionConverter {
|
|
165
|
+
/**
|
|
166
|
+
* Name of the variable this converter is assigned to. `undefined` when the
|
|
167
|
+
* converter is an inline literal inside another converter's field map.
|
|
168
|
+
*/
|
|
169
|
+
readonly converterConst: string | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* Factory function that produced the converter
|
|
172
|
+
* (`snapshotConverterFunctions` / `firestoreSubObject` / `firestoreObjectArray`).
|
|
173
|
+
*/
|
|
174
|
+
readonly factory: string;
|
|
175
|
+
/**
|
|
176
|
+
* Generic interface-name argument (e.g. `NotificationBox`), with any nested
|
|
177
|
+
* generic arguments stripped. `undefined` when the call had no type
|
|
178
|
+
* arguments.
|
|
179
|
+
*/
|
|
180
|
+
readonly interfaceName: string | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Source-line number of the converter declaration (1-based) for diagnostics.
|
|
183
|
+
*/
|
|
184
|
+
readonly line: number;
|
|
185
|
+
readonly fields: readonly ModelExtractionConverterField[];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* One enum value with its JSDoc paragraph and persisted literal value.
|
|
189
|
+
*/
|
|
190
|
+
export interface ModelExtractionEnumValue {
|
|
191
|
+
readonly name: string;
|
|
192
|
+
readonly value: number | string;
|
|
193
|
+
readonly description: string | undefined;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* One `export enum` declaration found in the source.
|
|
197
|
+
*/
|
|
198
|
+
export interface ModelExtractionEnum {
|
|
199
|
+
readonly name: string;
|
|
200
|
+
readonly values: readonly ModelExtractionEnumValue[];
|
|
201
|
+
readonly description: string | undefined;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* One `<X>FirestoreCollections` container tagged with `@dbxModelGroup`.
|
|
205
|
+
*/
|
|
206
|
+
export interface ModelExtractionGroup {
|
|
207
|
+
/**
|
|
208
|
+
* Group name parsed from the `@dbxModelGroup <name>` JSDoc tag.
|
|
209
|
+
*/
|
|
210
|
+
readonly name: string;
|
|
211
|
+
/**
|
|
212
|
+
* Container interface name (e.g. `NotificationFirestoreCollections`).
|
|
213
|
+
*/
|
|
214
|
+
readonly containerName: string;
|
|
215
|
+
readonly description: string | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* Model names referenced by the container's `<X>FirestoreCollection` /
|
|
218
|
+
* `<X>FirestoreCollectionFactory` properties, in source order.
|
|
219
|
+
*/
|
|
220
|
+
readonly modelNames: readonly string[];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Per-source-file output of {@link ../lib/extract-models#extractModelsFromSource}.
|
|
224
|
+
*
|
|
225
|
+
* Aggregation across files happens in the firebase-api-manifest orchestrator
|
|
226
|
+
* so cross-file converter consts can be resolved against a global registry.
|
|
227
|
+
*/
|
|
228
|
+
export interface ModelExtraction {
|
|
229
|
+
readonly identities: readonly ModelExtractionIdentity[];
|
|
230
|
+
readonly interfaces: readonly ModelExtractionInterface[];
|
|
231
|
+
readonly converters: readonly ModelExtractionConverter[];
|
|
232
|
+
readonly enums: readonly ModelExtractionEnum[];
|
|
233
|
+
readonly modelGroups: readonly ModelExtractionGroup[];
|
|
234
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"dbx-cli-generate-firebase-api-manifest": "firebase-api-manifest/main.js"
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@dereekb/date": "13.11.
|
|
28
|
-
"@dereekb/firebase": "13.11.
|
|
29
|
-
"@dereekb/nestjs": "13.11.
|
|
30
|
-
"@dereekb/util": "13.11.
|
|
27
|
+
"@dereekb/date": "13.11.5",
|
|
28
|
+
"@dereekb/firebase": "13.11.5",
|
|
29
|
+
"@dereekb/nestjs": "13.11.5",
|
|
30
|
+
"@dereekb/util": "13.11.5",
|
|
31
31
|
"arktype": "^2.2.0",
|
|
32
32
|
"yargs": "^18.0.0"
|
|
33
33
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CliModelManifest, CliModelManifestEntry } from '../manifest/types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the manifest entry for `modelType`. Lookup tries
|
|
4
|
+
* `modelType` first, then falls back to `identityConst` and `collectionPrefix`
|
|
5
|
+
* so callers can pass any of the three forms a user might type at the CLI.
|
|
6
|
+
*
|
|
7
|
+
* @param modelType - identifier to look up.
|
|
8
|
+
* @param manifest - generated model manifest.
|
|
9
|
+
* @returns the matching entry, or `undefined` when none exists.
|
|
10
|
+
* @__NO_SIDE_EFFECTS__
|
|
11
|
+
*/
|
|
12
|
+
export declare function findCliModelManifestEntry(modelType: string, manifest: CliModelManifest): CliModelManifestEntry | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Rewrites the persisted (short) keys in `data` to the long-name form
|
|
15
|
+
* declared in the model's manifest entry. Recurses into nested object-array
|
|
16
|
+
* and sub-object fields when the manifest captured a nested field map.
|
|
17
|
+
*
|
|
18
|
+
* Returns the input untouched when `modelType` is not in the manifest, when
|
|
19
|
+
* the model has no fields, or when the input is not a plain object/array.
|
|
20
|
+
* Unknown keys, primitives, `Date`, `null`, and `undefined` pass through
|
|
21
|
+
* unchanged.
|
|
22
|
+
*
|
|
23
|
+
* @param modelType - the model identifier (`modelType`, `identityConst`,
|
|
24
|
+
* or `collectionPrefix`) used to look up the rewrite map.
|
|
25
|
+
* @param data - the value to rewrite (typically a `read`/`query` response
|
|
26
|
+
* payload).
|
|
27
|
+
* @param manifest - generated model manifest.
|
|
28
|
+
* @returns the rewritten value, or `data` unchanged when no rewrite applies.
|
|
29
|
+
* @__NO_SIDE_EFFECTS__
|
|
30
|
+
*/
|
|
31
|
+
export declare function expandModelKeys(modelType: string, data: unknown, manifest: CliModelManifest): unknown;
|
package/src/lib/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CommandModule } from 'yargs';
|
|
2
|
-
import { type CliApiManifest } from './types';
|
|
2
|
+
import { type CliApiManifest, type CliModelManifest } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Controls which sections of an action's `--help` epilogue are rendered.
|
|
5
5
|
*
|
|
@@ -79,6 +79,17 @@ export interface BuildManifestCommandsOptions {
|
|
|
79
79
|
* full invocation reads `<cli> model <model> <action>`.
|
|
80
80
|
*/
|
|
81
81
|
readonly modelCommandName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Generated model manifest used to power the per-action `--expand-keys`
|
|
84
|
+
* flag. When supplied, a payload returned from the `/model/call` endpoint
|
|
85
|
+
* is rewritten to use the long-name form of each persisted field (recursing
|
|
86
|
+
* into nested object-array and sub-object converters captured in the
|
|
87
|
+
* manifest).
|
|
88
|
+
*
|
|
89
|
+
* Optional. When omitted the flag is not registered and result payloads are
|
|
90
|
+
* emitted with their original short keys.
|
|
91
|
+
*/
|
|
92
|
+
readonly modelManifest?: CliModelManifest;
|
|
82
93
|
}
|
|
83
94
|
/**
|
|
84
95
|
* Default name of the parent command that groups all per-model manifest commands.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CommandModule } from 'yargs';
|
|
2
|
+
import type { CliModelManifest } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Default command name for the model-info command. Top-level so it stays out
|
|
5
|
+
* of the API-call namespace owned by `model <model> <action>`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_MODEL_INFO_COMMAND_NAME = "model-info";
|
|
8
|
+
/**
|
|
9
|
+
* Options accepted by {@link buildModelInfoCommand}.
|
|
10
|
+
*/
|
|
11
|
+
export interface BuildModelInfoCommandOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Override the parent command name. Defaults to
|
|
14
|
+
* {@link DEFAULT_MODEL_INFO_COMMAND_NAME}.
|
|
15
|
+
*/
|
|
16
|
+
readonly commandName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds the top-level `model-info [model]` command.
|
|
20
|
+
*
|
|
21
|
+
* Without an argument: prints a column-aligned table summarising every model
|
|
22
|
+
* in the manifest. With an argument: looks the model up by `modelType`,
|
|
23
|
+
* `identityConst`, or `collectionPrefix` and prints its full per-field
|
|
24
|
+
* documentation, recursing into nested converters when the manifest captured
|
|
25
|
+
* them.
|
|
26
|
+
*
|
|
27
|
+
* Flags:
|
|
28
|
+
* - `--json` emits a structured `{ ok, data }` envelope instead of the
|
|
29
|
+
* human-readable table (useful for scripting or LLM agents).
|
|
30
|
+
* - `--fields` prints only the field table for the resolved model.
|
|
31
|
+
*
|
|
32
|
+
* @param manifest - The generated model manifest (e.g. `DEMO_CLI_MODEL_MANIFEST`).
|
|
33
|
+
* @param options - Optional overrides; see {@link BuildModelInfoCommandOptions}.
|
|
34
|
+
* @returns A yargs `CommandModule` ready to be passed to `runCli({ configCommands })`.
|
|
35
|
+
* @__NO_SIDE_EFFECTS__
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildModelInfoCommand(manifest: CliModelManifest, options?: BuildModelInfoCommandOptions): CommandModule;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CliModelManifest, CliModelManifestEntry } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the manifest entry for `query` against `modelType`, `identityConst`,
|
|
4
|
+
* and `collectionPrefix` in that order.
|
|
5
|
+
*
|
|
6
|
+
* Re-exports {@link findCliModelManifestEntry} under a more descriptive name
|
|
7
|
+
* for the model-info command.
|
|
8
|
+
*
|
|
9
|
+
* @param manifest - the generated model manifest.
|
|
10
|
+
* @param query - identifier to look up.
|
|
11
|
+
* @returns the matching entry or `undefined`.
|
|
12
|
+
* @__NO_SIDE_EFFECTS__
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveCliModel(manifest: CliModelManifest, query: string): CliModelManifestEntry | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Produces a column-aligned summary table of every model in the manifest.
|
|
17
|
+
*
|
|
18
|
+
* @param manifest - the generated model manifest.
|
|
19
|
+
* @returns the formatted table as a single string with a trailing newline.
|
|
20
|
+
* @__NO_SIDE_EFFECTS__
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderModelManifestList(manifest: CliModelManifest): string;
|
|
23
|
+
/**
|
|
24
|
+
* Produces a human-readable summary of one model entry: header, description,
|
|
25
|
+
* and an indented field tree (recursing into `nestedFields`).
|
|
26
|
+
*
|
|
27
|
+
* @param entry - the manifest entry to render.
|
|
28
|
+
* @returns the formatted summary as a single string with a trailing newline.
|
|
29
|
+
* @__NO_SIDE_EFFECTS__
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderModelManifestEntry(entry: CliModelManifestEntry): string;
|
|
32
|
+
/**
|
|
33
|
+
* Produces the field-table portion of {@link renderModelManifestEntry} on its
|
|
34
|
+
* own, used by the `--fields` flag of the `model-info` command.
|
|
35
|
+
*
|
|
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.
|
|
38
|
+
* @__NO_SIDE_EFFECTS__
|
|
39
|
+
*/
|
|
40
|
+
export declare function renderModelManifestFields(entry: CliModelManifestEntry): string;
|
|
@@ -1,4 +1,130 @@
|
|
|
1
1
|
import { type Type } from 'arktype';
|
|
2
|
+
/**
|
|
3
|
+
* One persisted field on a {@link CliModelManifestEntry}.
|
|
4
|
+
*
|
|
5
|
+
* Captures both the persisted (Firestore) short key and the human-readable
|
|
6
|
+
* long name from the model's `@dbxModelVariable` JSDoc tag, plus the verbatim
|
|
7
|
+
* converter expression text and any nested converter shape (for
|
|
8
|
+
* `firestoreObjectArray` / `firestoreSubObject` fields) so downstream tooling
|
|
9
|
+
* can recursively rewrite payload keys.
|
|
10
|
+
*/
|
|
11
|
+
export interface CliModelField {
|
|
12
|
+
/**
|
|
13
|
+
* Persisted Firestore short key (e.g. `fn`, `cat`, `gc`).
|
|
14
|
+
*/
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Human-readable long name resolved from the interface property's
|
|
18
|
+
* `@dbxModelVariable` JSDoc tag. Falls back to `name` when no tag is
|
|
19
|
+
* declared and the persisted key is already long-form.
|
|
20
|
+
*/
|
|
21
|
+
readonly longName: string;
|
|
22
|
+
/**
|
|
23
|
+
* Verbatim converter expression text from the converter's `fields` literal
|
|
24
|
+
* (e.g. `firestoreDate()`, `firestoreObjectArray({ objectField: foo })`).
|
|
25
|
+
*/
|
|
26
|
+
readonly converter: string;
|
|
27
|
+
/**
|
|
28
|
+
* TypeScript type text from the interface property declaration, when the
|
|
29
|
+
* field's interface property could be located (e.g. `Date`, `Maybe<NotificationUserState>`).
|
|
30
|
+
*/
|
|
31
|
+
readonly tsType?: string;
|
|
32
|
+
/**
|
|
33
|
+
* `true` when the interface property is optional (`?`) or typed as `Maybe<>`,
|
|
34
|
+
* or when the converter is an `optionalFirestore...()` factory.
|
|
35
|
+
*/
|
|
36
|
+
readonly optional: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* First paragraph of the interface property's JSDoc, when present.
|
|
39
|
+
*/
|
|
40
|
+
readonly description?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Enum name referenced by either the interface property's TS type or the
|
|
43
|
+
* converter's `firestoreEnum<Enum>()` generic argument, when an enum is
|
|
44
|
+
* present in the same source file.
|
|
45
|
+
*/
|
|
46
|
+
readonly enumRef?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Free-text description from the interface property's
|
|
49
|
+
* `@dbxModelVariableSyncFlag` JSDoc tag, when present.
|
|
50
|
+
*/
|
|
51
|
+
readonly syncFlag?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Recursively-resolved nested fields when this field's converter is a
|
|
54
|
+
* `firestoreObjectArray({ objectField: ... })` or
|
|
55
|
+
* `firestoreSubObject({ objectField: ... })` call whose inner converter
|
|
56
|
+
* could be resolved (either inline or via cross-file converter const).
|
|
57
|
+
*
|
|
58
|
+
* Absent when the converter is opaque (custom helper, dynamic expression,
|
|
59
|
+
* `firestoreEnum`, primitive factory, etc.).
|
|
60
|
+
*/
|
|
61
|
+
readonly nestedFields?: readonly CliModelField[];
|
|
62
|
+
/**
|
|
63
|
+
* `true` when the nested fields describe an array element shape
|
|
64
|
+
* (`firestoreObjectArray`); `false` for sub-object fields. Only meaningful
|
|
65
|
+
* when {@link nestedFields} is set.
|
|
66
|
+
*/
|
|
67
|
+
readonly nestedIsArray?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* One Firestore model entry in a downstream CLI's `<NAMESPACE>_MODEL_MANIFEST`.
|
|
71
|
+
*
|
|
72
|
+
* Generated at build time by `dbx-cli-generate-firebase-api-manifest` from the
|
|
73
|
+
* same source packages it walks for the API manifest. Drives both the
|
|
74
|
+
* `model-info` command's catalog/per-model help and the `--expand-keys` flag's
|
|
75
|
+
* payload-rewrite behaviour.
|
|
76
|
+
*/
|
|
77
|
+
export interface CliModelManifestEntry {
|
|
78
|
+
/**
|
|
79
|
+
* Persisted model type id (e.g. `notificationBox`, `profile`).
|
|
80
|
+
*/
|
|
81
|
+
readonly modelType: string;
|
|
82
|
+
/**
|
|
83
|
+
* Pascal-case model name as declared by the source interface (e.g.
|
|
84
|
+
* `NotificationBox`).
|
|
85
|
+
*/
|
|
86
|
+
readonly modelName: string;
|
|
87
|
+
/**
|
|
88
|
+
* Group name from the source `@dbxModelGroup` tag on the
|
|
89
|
+
* `<X>FirestoreCollections` container (e.g. `Notification`, `Profile`).
|
|
90
|
+
*/
|
|
91
|
+
readonly modelGroup?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Identity const name from the source file (e.g. `notificationBoxIdentity`).
|
|
94
|
+
*/
|
|
95
|
+
readonly identityConst: string;
|
|
96
|
+
/**
|
|
97
|
+
* Collection-name prefix used by the identity (e.g. `nb`, `p`).
|
|
98
|
+
*/
|
|
99
|
+
readonly collectionPrefix: string;
|
|
100
|
+
/**
|
|
101
|
+
* Parent identity const name when the model is a subcollection.
|
|
102
|
+
*/
|
|
103
|
+
readonly parentIdentityConst?: string;
|
|
104
|
+
/**
|
|
105
|
+
* First paragraph of the source interface's JSDoc, when present.
|
|
106
|
+
*/
|
|
107
|
+
readonly description?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Source package providing the model (e.g. `@dereekb/firebase`,
|
|
110
|
+
* `demo-firebase`).
|
|
111
|
+
*/
|
|
112
|
+
readonly sourcePackage: string;
|
|
113
|
+
/**
|
|
114
|
+
* Workspace-relative path of the source `.ts` file that declares the model.
|
|
115
|
+
*/
|
|
116
|
+
readonly sourceFile: string;
|
|
117
|
+
/**
|
|
118
|
+
* Persisted-field metadata in source order.
|
|
119
|
+
*/
|
|
120
|
+
readonly fields: readonly CliModelField[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Generated array of {@link CliModelManifestEntry} consumed by `model-info`
|
|
124
|
+
* and the `--expand-keys` rewrite. Each downstream CLI app exports its own
|
|
125
|
+
* `<NAMESPACE>_MODEL_MANIFEST` of this type.
|
|
126
|
+
*/
|
|
127
|
+
export type CliModelManifest = readonly CliModelManifestEntry[];
|
|
2
128
|
export type CliApiVerb = 'create' | 'read' | 'update' | 'delete' | 'query' | 'standalone';
|
|
3
129
|
export interface CliApiManifestField {
|
|
4
130
|
readonly name: string;
|
package/src/lib/runner/run.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Argv, type CommandModule } from 'yargs';
|
|
2
2
|
import { type CliEnvDefault } from '../config/env';
|
|
3
3
|
import { type DoctorCheck } from '../doctor/doctor.command.factory';
|
|
4
|
+
import { type CliModelManifest } from '../manifest/types';
|
|
4
5
|
/**
|
|
5
6
|
* Names of the global options registered by {@link createCli} that are not
|
|
6
7
|
* specific to a single manifest command's payload. Manifest commands hide
|
|
@@ -43,6 +44,30 @@ export interface CreateCliInput {
|
|
|
43
44
|
* Disable the built-in `call` passthrough — useful when an app prefers to expose only typed wrappers.
|
|
44
45
|
*/
|
|
45
46
|
readonly disableCallPassthrough?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Generated Firestore model manifest used to drive the built-in `model-info` command.
|
|
49
|
+
*
|
|
50
|
+
* Opt-in: when provided, a top-level `model-info [model]` command is auto-wired into the built-in
|
|
51
|
+
* config commands so users can browse the model catalog and per-model field documentation. When
|
|
52
|
+
* omitted, no `model-info` command is registered. Apps that pass the manifest but want to suppress
|
|
53
|
+
* the command can additionally set {@link disableModelInfo} to `true`.
|
|
54
|
+
*
|
|
55
|
+
* The manifest itself is also opt-in at build time. The `dbx-cli-firebase-api-manifest` generator
|
|
56
|
+
* only emits `<NAMESPACE>_MODEL_MANIFEST` when invoked with `--emit-models`, so apps that never
|
|
57
|
+
* enable this option won't bundle model metadata into their final binary.
|
|
58
|
+
*
|
|
59
|
+
* Note: this option only controls the `model-info` command. Manifest-driven typed model commands
|
|
60
|
+
* are still wired explicitly via {@link apiCommands} (see `buildManifestCommands`), and the
|
|
61
|
+
* `--expand-keys` flag still requires passing the manifest to `buildManifestCommands`.
|
|
62
|
+
*/
|
|
63
|
+
readonly modelManifest?: CliModelManifest;
|
|
64
|
+
/**
|
|
65
|
+
* Disable the built-in `model-info` command even when {@link modelManifest} is provided.
|
|
66
|
+
*
|
|
67
|
+
* Useful when an app wants the manifest available for `--expand-keys` (via `buildManifestCommands`)
|
|
68
|
+
* but does not want to surface the `model-info` command itself.
|
|
69
|
+
*/
|
|
70
|
+
readonly disableModelInfo?: boolean;
|
|
46
71
|
}
|
|
47
72
|
/**
|
|
48
73
|
* Top-level CLI builder.
|
|
@@ -61,6 +86,10 @@ export interface CreateCliInput {
|
|
|
61
86
|
* @param input.defaultEnvs - Built-in env presets shipped with the CLI.
|
|
62
87
|
* @param input.argv - Argv to parse. Defaults to `hideBin(process.argv)`.
|
|
63
88
|
* @param input.disableCallPassthrough - When `true`, omits the built-in `call` passthrough.
|
|
89
|
+
* @param input.modelManifest - Optional Firestore model manifest. When provided, auto-wires the
|
|
90
|
+
* built-in `model-info` command. Opt-in per app.
|
|
91
|
+
* @param input.disableModelInfo - When `true`, suppresses the auto-wired `model-info` command even
|
|
92
|
+
* if {@link CreateCliInput.modelManifest} is provided.
|
|
64
93
|
* @returns The configured yargs `Argv` ready to be `.parse()`-d.
|
|
65
94
|
* @__NO_SIDE_EFFECTS__
|
|
66
95
|
*/
|