@lunora/cli 1.0.0-alpha.23 → 1.0.0-alpha.231
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/LICENSE.md +33 -0
- package/README.md +1 -1
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +778 -346
- package/dist/index.d.ts +778 -346
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/handler.mjs +1 -150
- package/dist/packem_chunks/handler10.mjs +3 -16
- package/dist/packem_chunks/handler11.mjs +2 -22
- package/dist/packem_chunks/handler12.mjs +1 -192
- package/dist/packem_chunks/handler13.mjs +1 -131
- package/dist/packem_chunks/handler14.mjs +1 -65
- package/dist/packem_chunks/handler15.mjs +1 -58
- package/dist/packem_chunks/handler16.mjs +3 -79
- package/dist/packem_chunks/handler17.mjs +1 -43
- package/dist/packem_chunks/handler18.mjs +1 -105
- package/dist/packem_chunks/handler19.mjs +7 -170
- package/dist/packem_chunks/handler2.mjs +2 -114
- package/dist/packem_chunks/handler20.mjs +1 -89
- package/dist/packem_chunks/handler21.mjs +3 -94
- package/dist/packem_chunks/handler22.mjs +3 -0
- package/dist/packem_chunks/handler23.mjs +1 -0
- package/dist/packem_chunks/handler24.mjs +2 -0
- package/dist/packem_chunks/handler25.mjs +99 -0
- package/dist/packem_chunks/handler26.mjs +10 -0
- package/dist/packem_chunks/handler3.mjs +1 -204
- package/dist/packem_chunks/handler4.mjs +1 -33
- package/dist/packem_chunks/handler5.mjs +1 -49
- package/dist/packem_chunks/handler6.mjs +1 -91
- package/dist/packem_chunks/handler7.mjs +3 -42
- package/dist/packem_chunks/handler8.mjs +1 -174
- package/dist/packem_chunks/handler9.mjs +1 -315
- package/dist/packem_chunks/planDevCommand.mjs +7 -509
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +7 -594
- package/dist/packem_chunks/runInitCommand.mjs +162 -1392
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-rRB9TbDL.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-BMH-ZXl5.mjs +1 -0
- package/dist/packem_shared/admin-token-VdUnvnKW.mjs +1 -0
- package/dist/packem_shared/admin-url-BhF5ufg1.mjs +1 -0
- package/dist/packem_shared/binding-manifest-file-CQ1eQYy1.mjs +2 -0
- package/dist/packem_shared/buildRegistryIndex-DVmy8fHE.mjs +1 -0
- package/dist/packem_shared/catalog-Cbzph90w.mjs +1 -0
- package/dist/packem_shared/cli-DIb5Ay4K.mjs +3 -0
- package/dist/packem_shared/codegen-error-AmH54ofi.mjs +3 -0
- package/dist/packem_shared/command-DwC11Cwe.mjs +1 -0
- package/dist/packem_shared/commands-I18aR_DJ.mjs +15 -0
- package/dist/packem_shared/createLogger-hGafwf-3.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-DJlNacZ6.mjs +1 -0
- package/dist/packem_shared/deploy-target-B0Xcb2jV.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-DtC5Cs4Z.mjs +5 -0
- package/dist/packem_shared/docker-DpVxvYpL.mjs +1 -0
- package/dist/packem_shared/import-Dqd1MOOv.mjs +12 -0
- package/dist/packem_shared/insertSchemaExtension-DuiV6cba.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-DKZagpqk.mjs +2 -0
- package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
- package/dist/packem_shared/output-format-DfogXx0p.mjs +2 -0
- package/dist/packem_shared/parseManifest-CwPTKdtS.mjs +1 -0
- package/dist/packem_shared/path-containment-CgxYZggb.mjs +1 -0
- package/dist/packem_shared/platform-diagnostics-Cn2g6Jh-.mjs +4 -0
- package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
- package/dist/packem_shared/resolve-B9ReA3FV.mjs +5 -0
- package/dist/packem_shared/resolve-target-BRvw8Pf7.mjs +1 -0
- package/dist/packem_shared/runAddCommand-BXea8slz.mjs +1 -0
- package/dist/packem_shared/runExportCommand-Dq-SpjAe.mjs +5 -0
- package/dist/packem_shared/schema-drift-gate-BDCkQ1S6.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-e5fO6GRg.mjs +1 -0
- package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
- package/dist/packem_shared/storage-B0ixDDxG.mjs +1 -0
- package/dist/packem_shared/tui-prompts-DzYd2fL3.mjs +4 -0
- package/dist/packem_shared/vectorize-metadata-dXpl2_Ar.mjs +1 -0
- package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-CCdt0mUl.mjs +1 -0
- package/package.json +39 -17
- package/skills/README.md +35 -17
- package/skills/lunora/SKILL.md +65 -9
- package/skills/lunora-deploy/SKILL.md +42 -11
- package/skills/lunora-functions/SKILL.md +78 -15
- package/skills/lunora-migration-helper/SKILL.md +74 -21
- package/skills/lunora-performance-audit/SKILL.md +42 -9
- package/skills/lunora-quickstart/SKILL.md +93 -27
- package/skills/lunora-realtime/SKILL.md +58 -30
- package/skills/lunora-setup-auth/SKILL.md +23 -6
- package/skills/lunora-setup-hyperdrive/SKILL.md +33 -13
- package/skills/lunora-setup-mail/SKILL.md +34 -28
- package/skills/lunora-setup-scheduler/SKILL.md +18 -14
- package/skills/lunora-setup-storage/SKILL.md +182 -25
- package/dist/packem_shared/COMMANDS-Dwo9q7Bt.mjs +0 -947
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
- package/dist/packem_shared/command-BC30oSBW.mjs +0 -14
- package/dist/packem_shared/commands-hl0mRqqg.mjs +0 -845
- package/dist/packem_shared/createLogger-B40gPzQo.mjs +0 -78
- package/dist/packem_shared/createRecordingSpawner-DxI3mebw.mjs +0 -43
- package/dist/packem_shared/detect-package-manager-DYp7n3mJ.mjs +0 -61
- package/dist/packem_shared/diffSnapshots-BeDvvNiF.mjs +0 -161
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
- package/dist/packem_shared/insertSchemaExtension-DAqbfr9Z.mjs +0 -64
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
- package/dist/packem_shared/output-format-wUvAN6AL.mjs +0 -17
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
- package/dist/packem_shared/runAddCommand-vJdgiR5t.mjs +0 -4
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
- package/dist/packem_shared/schemaIrToSnapshot-DdsljJT-.mjs +0 -43
- package/dist/packem_shared/storage-B7hHSTZP.mjs +0 -84
- package/dist/packem_shared/tui-prompts-M6OWsuyw.mjs +0 -663
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
- package/dist/packem_shared/wrangler-secrets-P2_ZUR-k.mjs +0 -47
package/dist/index.d.mts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { CodegenOptions, SchemaIR } from '@lunora/codegen';
|
|
2
|
-
import '@
|
|
3
|
-
import {
|
|
4
|
-
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
|
|
1
|
+
import { CodegenOptions, Finding, FieldSnapshot, SchemaIR } from '@lunora/codegen';
|
|
2
|
+
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome, PackageManager, PackageManagerProbe } from '@lunora/config';
|
|
3
|
+
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
4
|
+
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
|
|
5
5
|
/** Every command name the CLI registers (drives the `CommandName` type + tests). */
|
|
6
|
-
declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules"];
|
|
6
|
+
declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "eval", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules", "mcp"];
|
|
7
7
|
type CommandName = (typeof COMMANDS)[number];
|
|
8
8
|
declare const VERSION: string;
|
|
9
9
|
interface RunCliOptions {
|
|
10
10
|
argv?: ReadonlyArray<string>;
|
|
11
11
|
cwd?: string;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
* Inject a console-like logger so callers (tests) can capture cerebro's
|
|
14
|
+
* help / version / usage rendering. Omitted in production, where cerebro
|
|
15
|
+
* uses its default stdout/stderr logger.
|
|
16
|
+
*/
|
|
17
17
|
logger?: Console;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Run the CLI and resolve to the process exit code. cerebro handles help,
|
|
21
|
-
* version, usage, and unknown commands (the latter throws, caught here as 1).
|
|
22
|
-
* `shouldExitProcess: false` keeps the process alive so callers/tests read the
|
|
23
|
-
* captured exit code.
|
|
24
|
-
*/
|
|
20
|
+
* Run the CLI and resolve to the process exit code. cerebro handles help,
|
|
21
|
+
* version, usage, and unknown commands (the latter throws, caught here as 1).
|
|
22
|
+
* `shouldExitProcess: false` keeps the process alive so callers/tests read the
|
|
23
|
+
* captured exit code.
|
|
24
|
+
*/
|
|
25
25
|
declare const runCli: (options?: RunCliOptions) => Promise<number>;
|
|
26
26
|
/**
|
|
27
|
-
* The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
|
|
28
|
-
* `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
|
|
29
|
-
* `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
|
|
30
|
-
*/
|
|
27
|
+
* The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
|
|
28
|
+
* `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
|
|
29
|
+
* `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
|
|
30
|
+
*/
|
|
31
31
|
type ApiSpec = NonNullable<CodegenOptions["apiSpec"]>;
|
|
32
32
|
interface Logger {
|
|
33
33
|
debug?: (message: string) => void;
|
|
@@ -37,11 +37,11 @@ interface Logger {
|
|
|
37
37
|
warn: (message: string) => void;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Narrowed view over the pail instance. `createPail` returns an intersection
|
|
41
|
-
* type that includes a constructor signature and `(...args: any[])` logger
|
|
42
|
-
* overloads, which the type-aware linter cannot safely resolve. We only ever
|
|
43
|
-
* call the level methods with a string, so we describe exactly that surface.
|
|
44
|
-
*/
|
|
40
|
+
* Narrowed view over the pail instance. `createPail` returns an intersection
|
|
41
|
+
* type that includes a constructor signature and `(...args: any[])` logger
|
|
42
|
+
* overloads, which the type-aware linter cannot safely resolve. We only ever
|
|
43
|
+
* call the level methods with a string, so we describe exactly that surface.
|
|
44
|
+
*/
|
|
45
45
|
interface PailLogger {
|
|
46
46
|
debug: (message: string) => void;
|
|
47
47
|
error: (message: string) => void;
|
|
@@ -51,25 +51,12 @@ interface PailLogger {
|
|
|
51
51
|
}
|
|
52
52
|
declare const createLogger: () => Logger;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
/**
|
|
61
|
-
* Direct access to the underlying pail instance for advanced use-cases.
|
|
62
|
-
* A Proxy keeps the public `pail` binding lazy: the real pail is only
|
|
63
|
-
* constructed on first property access, so importing this module (and thus
|
|
64
|
-
* the package barrel) stays side-effect-free.
|
|
65
|
-
*/
|
|
54
|
+
* Direct access to the underlying pail instance for advanced use-cases.
|
|
55
|
+
* A Proxy keeps the public `pail` binding lazy: the real pail is only
|
|
56
|
+
* constructed on first property access, so importing this module (and thus
|
|
57
|
+
* the package barrel) stays side-effect-free.
|
|
58
|
+
*/
|
|
66
59
|
declare const pail: PailLogger;
|
|
67
|
-
/**
|
|
68
|
-
* Emit a badged step line through the shared pail (the `init` flow's off-TTY
|
|
69
|
-
* fallback for the create-astro-style transcript). The `message` may contain
|
|
70
|
-
* newlines — `LunoraReporter` indents continuation lines under the badge so a
|
|
71
|
-
* dimmed answer sits below its question.
|
|
72
|
-
*/
|
|
73
60
|
interface CodegenCommandOptions {
|
|
74
61
|
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
75
62
|
apiSpec?: ApiSpec;
|
|
@@ -77,33 +64,43 @@ interface CodegenCommandOptions {
|
|
|
77
64
|
/** Output format: `pretty` (default) or `json`. */
|
|
78
65
|
format?: string;
|
|
79
66
|
logger: Logger;
|
|
67
|
+
/**
|
|
68
|
+
* Fail the run when any ERROR-level advisory is reported. Defaults to CI
|
|
69
|
+
* detection so a local `lunora codegen` stays advisory while a pipeline
|
|
70
|
+
* gates on it; `--no-strict-advisories` forces it off either way.
|
|
71
|
+
*/
|
|
72
|
+
strictAdvisories?: boolean;
|
|
73
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
74
|
+
target?: string;
|
|
80
75
|
}
|
|
81
76
|
interface CodegenCommandResult {
|
|
82
77
|
advisories: ReadonlyArray<{
|
|
83
78
|
detail: string;
|
|
84
|
-
level:
|
|
79
|
+
level: Finding["level"];
|
|
85
80
|
name: string;
|
|
86
81
|
remediation: string;
|
|
87
82
|
}>;
|
|
88
83
|
cronTriggers: ReadonlyArray<string>;
|
|
89
|
-
/** Set when the run
|
|
84
|
+
/** Set when the run failed: an invalid `--format`, an unregistered target, or an error-level platform diagnostic. */
|
|
90
85
|
error?: string;
|
|
86
|
+
/** ERROR-level advisories that made the run fail, when strict mode is on. */
|
|
87
|
+
failedAdvisories: number;
|
|
91
88
|
outputDirectory: string;
|
|
92
89
|
}
|
|
93
90
|
declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
|
|
94
|
-
/** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
|
|
95
|
-
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
96
|
-
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
97
91
|
/**
|
|
98
|
-
* Minimal projection of `globalThis.fetch` for the
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
|
|
92
|
+
* Minimal projection of `globalThis.fetch` for the transfer commands: `body` is
|
|
93
|
+
* exposed as a stream-iterable (the export path pipes it) and accepts bytes (the
|
|
94
|
+
* blob path uploads them). The JSON-only commands use the narrower `FetchLike`
|
|
95
|
+
* in `../run/handler` instead.
|
|
96
|
+
*/
|
|
102
97
|
type StreamingFetchLike = (input: string, init?: {
|
|
103
|
-
body?: string;
|
|
98
|
+
body?: string | Uint8Array;
|
|
104
99
|
headers?: Record<string, string>;
|
|
105
100
|
method?: string;
|
|
106
101
|
}) => Promise<{
|
|
102
|
+
/** Optional: only the storage transfer reads raw bytes, and only real `fetch` needs to supply it. */
|
|
103
|
+
arrayBuffer?: () => Promise<ArrayBuffer>;
|
|
107
104
|
body: ReadableStream<Uint8Array> | null;
|
|
108
105
|
json: () => Promise<unknown>;
|
|
109
106
|
ok: boolean;
|
|
@@ -132,11 +129,82 @@ interface ExportCommandResult {
|
|
|
132
129
|
rows: number;
|
|
133
130
|
}
|
|
134
131
|
/**
|
|
135
|
-
* Stream an export. The worker emits NDJSON; we count newlines as we go and
|
|
136
|
-
* pipe straight to the output sink, so a 10M-row export doesn't materialise
|
|
137
|
-
* the body in memory.
|
|
138
|
-
*/
|
|
132
|
+
* Stream an export. The worker emits NDJSON; we count newlines as we go and
|
|
133
|
+
* pipe straight to the output sink, so a 10M-row export doesn't materialise
|
|
134
|
+
* the body in memory.
|
|
135
|
+
*/
|
|
139
136
|
declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
|
|
137
|
+
/** One row-scoped failure as the admin import endpoint reports it. */
|
|
138
|
+
interface ImportRowError {
|
|
139
|
+
code: string;
|
|
140
|
+
line: number;
|
|
141
|
+
message: string;
|
|
142
|
+
table: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* One SHARD the fan-out never reached, as the admin import endpoint reports it.
|
|
146
|
+
*
|
|
147
|
+
* Distinct from {@link ImportRowError}: the rows a dead shard owned contribute
|
|
148
|
+
* to neither `inserted` nor `errors`, so an unknown slice of the batch is simply
|
|
149
|
+
* missing. The endpoint answers 207 Multi-Status when this array is non-empty.
|
|
150
|
+
*/
|
|
151
|
+
interface ImportShardFailure {
|
|
152
|
+
message: string;
|
|
153
|
+
shardKey: string;
|
|
154
|
+
timedOut: boolean;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The sources `--from` accepts.
|
|
158
|
+
*
|
|
159
|
+
* Only the two that cannot be detected. A Convex snapshot announces itself (a
|
|
160
|
+
* directory of `<table>/documents.jsonl`, or a `.zip` of one) and anything else
|
|
161
|
+
* is NDJSON, so naming those would advertise a control this does not implement:
|
|
162
|
+
* `--from ndjson` against a Convex export would have to either refuse it or
|
|
163
|
+
* silently import it as Convex, and the second is what an unhonoured flag
|
|
164
|
+
* actually did.
|
|
165
|
+
*/
|
|
166
|
+
declare const IMPORT_SOURCE_NAMES: readonly ["firebase", "supabase"];
|
|
167
|
+
type ImportSourceName = (typeof IMPORT_SOURCE_NAMES)[number];
|
|
168
|
+
/**
|
|
169
|
+
* The storage-reference rewrite: turning a Convex storage id into the
|
|
170
|
+
* content-hash R2 key its blob was migrated to.
|
|
171
|
+
*
|
|
172
|
+
* Split out of `./storage-mapping` (which owns the mapping *file*) because it
|
|
173
|
+
* has two callers that must never diverge — the import rewrite and `--scan`,
|
|
174
|
+
* which runs this same walk as a dry run to propose the mapping. A detector
|
|
175
|
+
* that proposed columns the rewrite would not touch, or missed ones it would,
|
|
176
|
+
* is worse than no detector.
|
|
177
|
+
*/
|
|
178
|
+
/** One reference the walk could not rewrite, with where it was found. */
|
|
179
|
+
interface UnresolvedStorageReference {
|
|
180
|
+
column: string;
|
|
181
|
+
storageId: string;
|
|
182
|
+
table: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* What a run's storage references resolved to. The two failure buckets are
|
|
186
|
+
* deliberately separate, because they are not the same problem and do not have
|
|
187
|
+
* the same remedy:
|
|
188
|
+
*
|
|
189
|
+
* `unmigrated` is a reference to a blob that does not exist — the export omitted
|
|
190
|
+
* it, or `--include-file-storage` was not passed. Nothing the operator writes in
|
|
191
|
+
* a mapping file can fix it, and the data is broken after import, so it fails
|
|
192
|
+
* `--verify`.
|
|
193
|
+
*
|
|
194
|
+
* `ambiguous` is a string that exactly matches a blob that *did* migrate, sitting
|
|
195
|
+
* in a column the mapping does not name. It may be a storage reference the
|
|
196
|
+
* mapping forgot, or it may be user text that happens to equal an id. Failing the
|
|
197
|
+
* run on a coincidence is not defensible, so it warns and names the column the
|
|
198
|
+
* operator would add to resolve it.
|
|
199
|
+
*/
|
|
200
|
+
interface StorageRemapReport {
|
|
201
|
+
ambiguous: UnresolvedStorageReference[];
|
|
202
|
+
/** Number of references rewritten to a content-hash key. */
|
|
203
|
+
rewritten: number;
|
|
204
|
+
unmigrated: UnresolvedStorageReference[];
|
|
205
|
+
}
|
|
206
|
+
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
207
|
+
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
140
208
|
interface ImportCommandOptions {
|
|
141
209
|
/** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
|
|
142
210
|
batchSize?: number;
|
|
@@ -144,84 +212,176 @@ interface ImportCommandOptions {
|
|
|
144
212
|
fetchImpl?: StreamingFetchLike;
|
|
145
213
|
/** Source NDJSON file. Required. */
|
|
146
214
|
file: string;
|
|
215
|
+
/**
|
|
216
|
+
* Which reader to use. Omit to auto-detect between a Convex export snapshot
|
|
217
|
+
* and a plain NDJSON file; `supabase`/`firebase` must be explicit, because a
|
|
218
|
+
* directory of CSV or JSON has no signature that distinguishes it from
|
|
219
|
+
* anything else a user might point at.
|
|
220
|
+
*/
|
|
221
|
+
from?: ImportSourceName;
|
|
147
222
|
logger: Logger;
|
|
148
223
|
prod?: boolean;
|
|
149
224
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
225
|
+
* Scan the export for columns holding `_storage` ids and write a candidate
|
|
226
|
+
* `lunora/import-convex.json`. Scan-only: nothing is imported.
|
|
227
|
+
*/
|
|
228
|
+
scan?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Local directory of storage objects to migrate alongside the rows — how
|
|
231
|
+
* Firebase Cloud Storage arrives, after `gcloud storage cp -r`.
|
|
232
|
+
*/
|
|
233
|
+
storageDir?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
|
|
236
|
+
* is bare docs from a single table — Convex's `convex import --table users`
|
|
237
|
+
* shape.
|
|
238
|
+
*/
|
|
154
239
|
table?: string;
|
|
155
240
|
token?: string;
|
|
156
241
|
url?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Verify per-table row parity + dangling-storage after import. Exits non-zero
|
|
244
|
+
* when a table's inserted count differs from its source line count, or when a
|
|
245
|
+
* document references a storage id that was not migrated.
|
|
246
|
+
*/
|
|
247
|
+
verify?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Also migrate Convex `_storage` blobs: read `_storage/documents.jsonl`, upload
|
|
250
|
+
* each blob with sha256+size verification, and build the `storageId → key` map.
|
|
251
|
+
* Off by default so the plain-document import path is unchanged.
|
|
252
|
+
*/
|
|
253
|
+
withStorage?: boolean;
|
|
254
|
+
/** Confirm bulk-writing production. Required alongside `--prod`. */
|
|
255
|
+
yes?: boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The JSON summary a run prints and returns — the same object either way, so a
|
|
259
|
+
* caller reading `body.conflicts` does not have to cast its way there.
|
|
260
|
+
*
|
|
261
|
+
* `undefined` on every path that imports nothing: a rejected source, a failed
|
|
262
|
+
* storage phase, or `--scan` (whose product is the mapping file it writes, not
|
|
263
|
+
* a return value).
|
|
264
|
+
*/
|
|
265
|
+
interface ImportSummary {
|
|
266
|
+
conflicts: number;
|
|
267
|
+
errors: ImportRowError[];
|
|
268
|
+
/** Shards the endpoint could not reach (it answered 207). Their rows are MISSING, not rejected — present only when non-empty. */
|
|
269
|
+
failed?: ImportShardFailure[];
|
|
270
|
+
inserted: Record<string, number>;
|
|
271
|
+
received: number;
|
|
272
|
+
storage?: {
|
|
273
|
+
/** Up to {@link UNRESOLVED_REPORT_LIMIT} distinct references — a sample, not the whole set. See `ambiguousTotal`. */
|
|
274
|
+
ambiguous: StorageRemapReport["ambiguous"];
|
|
275
|
+
/** How many DISTINCT `(table, column, storageId)` references were ambiguous. */
|
|
276
|
+
ambiguousTotal: number;
|
|
277
|
+
blobs: number;
|
|
278
|
+
rewritten: number;
|
|
279
|
+
/** Up to {@link UNRESOLVED_REPORT_LIMIT} distinct references — a sample, not the whole set. See `unmigratedTotal`. */
|
|
280
|
+
unmigrated: StorageRemapReport["unmigrated"];
|
|
281
|
+
/** How many DISTINCT `(table, column, storageId)` references resolved to no migrated blob. */
|
|
282
|
+
unmigratedTotal: number;
|
|
283
|
+
};
|
|
284
|
+
warnings?: string[];
|
|
157
285
|
}
|
|
158
286
|
interface ImportCommandResult {
|
|
159
|
-
body:
|
|
287
|
+
body: ImportSummary | undefined;
|
|
160
288
|
code: number;
|
|
161
289
|
/** Total inserted rows across batches. */
|
|
162
290
|
inserted: number;
|
|
163
291
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Stream an NDJSON file in chunks, POSTing each batch to
|
|
166
|
-
* `/_lunora/admin/import`. We keep the line buffer bounded by `batchSize` so a
|
|
167
|
-
* multi-GiB file imports without buffering everything in memory.
|
|
168
|
-
*/
|
|
169
292
|
declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
|
|
170
293
|
/**
|
|
171
|
-
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
172
|
-
* stub; production uses {@link isDockerAvailable}.
|
|
173
|
-
*/
|
|
294
|
+
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
295
|
+
* stub; production uses {@link isDockerAvailable}.
|
|
296
|
+
*/
|
|
174
297
|
type DockerProbe = () => boolean;
|
|
175
298
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
|
|
299
|
+
* The shared `/_lunora/health` probe used by `lunora verify --health-url` and
|
|
300
|
+
* `lunora deploy --health-check`.
|
|
301
|
+
*
|
|
302
|
+
* Both commands ask the same question — "does this deployment answer?" — so
|
|
303
|
+
* they ask it through one implementation with one error-message shape. The
|
|
304
|
+
* runtime auto-registers both routes (`packages/runtime/src/health-routes.ts`):
|
|
305
|
+
* `/_lunora/health/ready` is the readiness gate ("can this version serve"), and
|
|
306
|
+
* `/_lunora/health` is the aggregate that also exists on older deployments.
|
|
307
|
+
*
|
|
308
|
+
* The probe is transport-only: it never throws, and reports its verdict as an
|
|
309
|
+
* `{ error }` message the caller decides what to do with.
|
|
310
|
+
*/
|
|
311
|
+
/**
|
|
312
|
+
* Minimal fetch surface the probe needs — a subset of the global `fetch`,
|
|
313
|
+
* injectable so a test can feed a canned response without a network.
|
|
314
|
+
*/
|
|
315
|
+
type HealthFetch = (url: string) => Promise<{
|
|
316
|
+
ok: boolean;
|
|
317
|
+
status: number;
|
|
318
|
+
}>;
|
|
181
319
|
interface SpawnDescriptor {
|
|
182
320
|
args: ReadonlyArray<string>;
|
|
183
321
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
322
|
+
* Capture the child's stderr (in addition to streaming it to the parent).
|
|
323
|
+
* Needed when a tool reports the *expected* outcome as an error there —
|
|
324
|
+
* `wrangler vectorize create-metadata-index` writes "already exists" to
|
|
325
|
+
* stderr, and without this the caller can only see a bare exit code and
|
|
326
|
+
* would warn on every re-run. Composes with `stdoutToStderr`, so a caller
|
|
327
|
+
* can keep stdout clean for `--format json` and still read the reason.
|
|
328
|
+
*/
|
|
329
|
+
captureStderr?: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Capture the child's stdout (in addition to streaming it to the parent), so
|
|
332
|
+
* the caller can parse it — used by `deploy` to read the deployed URL from
|
|
333
|
+
* `wrangler deploy` output. Each chunk is still teed to the parent's stdout
|
|
334
|
+
* so the user sees live progress. Mutually exclusive with `stdoutToStderr`
|
|
335
|
+
* and `captureStdoutSilently`.
|
|
336
|
+
*/
|
|
189
337
|
captureStdout?: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Capture the child's stdout WITHOUT teeing it to the parent's stdout —
|
|
340
|
+
* for output that is parsed, never displayed (e.g. `wrangler secret list
|
|
341
|
+
* --format json`). Unlike `captureStdout`, nothing is written to
|
|
342
|
+
* `process.stdout`, so it can't interleave with — and corrupt — a
|
|
343
|
+
* caller's own stdout (notably `lunora deploy --format json`, which must
|
|
344
|
+
* emit exactly one JSON document). Mutually exclusive with `captureStdout`
|
|
345
|
+
* and `stdoutToStderr`.
|
|
346
|
+
*/
|
|
347
|
+
captureStdoutSilently?: boolean;
|
|
190
348
|
command: string;
|
|
191
349
|
cwd?: string;
|
|
192
350
|
env?: Readonly<Record<string, string>>;
|
|
193
351
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
352
|
+
* Pipe this string into the child's stdin and close it. Used to feed
|
|
353
|
+
* `wrangler secret put` its value without exposing it on the command
|
|
354
|
+
* line or in env. When absent, stdin is inherited from the parent.
|
|
355
|
+
*/
|
|
198
356
|
input?: string;
|
|
199
357
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
358
|
+
* Route the child's stdout to the parent's STDERR instead of stdout. Set in
|
|
359
|
+
* `--format json` mode so a spawned tool's human output (e.g. `wrangler
|
|
360
|
+
* deploy`'s progress + the deployed URL) can't interleave with — and corrupt
|
|
361
|
+
* — the single JSON document the command prints to stdout.
|
|
362
|
+
*/
|
|
205
363
|
stdoutToStderr?: boolean;
|
|
206
364
|
}
|
|
207
365
|
interface SpawnResult {
|
|
208
366
|
code: number;
|
|
209
|
-
/** The captured
|
|
367
|
+
/** The captured stderr, present only when the descriptor set `captureStderr`. */
|
|
368
|
+
stderr?: string;
|
|
369
|
+
/** The captured stdout, present only when the descriptor set `captureStdout` or `captureStdoutSilently`. */
|
|
210
370
|
stdout?: string;
|
|
211
371
|
}
|
|
212
372
|
/**
|
|
213
|
-
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
214
|
-
* instead of executing a real subprocess.
|
|
215
|
-
*/
|
|
373
|
+
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
374
|
+
* instead of executing a real subprocess.
|
|
375
|
+
*/
|
|
216
376
|
type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
|
|
217
377
|
declare const defaultSpawner: Spawner;
|
|
218
378
|
interface RecordedSpawn {
|
|
219
379
|
descriptor: SpawnDescriptor;
|
|
220
380
|
}
|
|
221
381
|
/**
|
|
222
|
-
* Test helper: returns a spawner that records every invocation and resolves
|
|
223
|
-
* with the configured exit code.
|
|
224
|
-
*/
|
|
382
|
+
* Test helper: returns a spawner that records every invocation and resolves
|
|
383
|
+
* with the configured exit code.
|
|
384
|
+
*/
|
|
225
385
|
declare const createRecordingSpawner: (exitCode?: number) => {
|
|
226
386
|
calls: RecordedSpawn[];
|
|
227
387
|
spawner: Spawner;
|
|
@@ -250,11 +410,6 @@ interface ListRemoteSecretsResult {
|
|
|
250
410
|
/** False when wrangler failed or its output could not be parsed. */
|
|
251
411
|
ok: boolean;
|
|
252
412
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Parse `wrangler secret list --format json` output into a sorted name list.
|
|
255
|
-
* The payload is an array of `{ name, type }`; anything else yields `undefined`
|
|
256
|
-
* so the caller can report a parse failure rather than silently returning [].
|
|
257
|
-
*/
|
|
258
413
|
type FetchLike = (input: string, init?: {
|
|
259
414
|
body?: string;
|
|
260
415
|
headers?: Record<string, string>;
|
|
@@ -267,11 +422,17 @@ type FetchLike = (input: string, init?: {
|
|
|
267
422
|
}>;
|
|
268
423
|
interface RunCommandOptions {
|
|
269
424
|
args?: string;
|
|
425
|
+
/** Forge this user id for the call (dispatches through the admin-gated `runAs` op). */
|
|
426
|
+
as?: string;
|
|
427
|
+
/** JSON-encoded extra identity claims to accompany {@link RunCommandOptions.as}. */
|
|
428
|
+
claims?: string;
|
|
270
429
|
cwd?: string;
|
|
271
430
|
fetchImpl?: FetchLike;
|
|
272
431
|
functionPath: string;
|
|
273
432
|
logger: Logger;
|
|
274
433
|
shard?: string;
|
|
434
|
+
/** Admin bearer for the `runAs` dispatch; resolved from the environment / `.dev.vars` when absent. */
|
|
435
|
+
token?: string;
|
|
275
436
|
url?: string;
|
|
276
437
|
}
|
|
277
438
|
interface RunCommandResult {
|
|
@@ -280,70 +441,96 @@ interface RunCommandResult {
|
|
|
280
441
|
requestUrl: string;
|
|
281
442
|
}
|
|
282
443
|
declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
|
|
283
|
-
/** `lunora run <functionPath>` handler (lazy-loaded via the command's `loader`). */
|
|
284
444
|
interface DeployCommandOptions {
|
|
285
445
|
/** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
|
|
286
446
|
allowSchemaDrift?: boolean;
|
|
287
447
|
/** Which API spec(s) codegen emits. Defaults to codegen's `"openapi"` when omitted. */
|
|
288
448
|
apiSpec?: ApiSpec;
|
|
449
|
+
/**
|
|
450
|
+
* The command the operator actually ran. `build` delegates here with
|
|
451
|
+
* `dryRun: true`; without this the gate names the wrong command in its
|
|
452
|
+
* blocked message and offers flags the real caller does not accept.
|
|
453
|
+
*/
|
|
454
|
+
commandName?: PreDeployCommand;
|
|
289
455
|
cwd?: string;
|
|
290
456
|
/** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
|
|
291
457
|
dockerAvailable?: DockerProbe;
|
|
292
458
|
/**
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
459
|
+
* Validate, bundle, and run all pre-deploy gates without publishing
|
|
460
|
+
* (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
|
|
461
|
+
* baseline re-bless) are skipped since nothing shipped.
|
|
462
|
+
*/
|
|
297
463
|
dryRun?: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Write the binding manifest (`build --emit-bindings`) to this path once the
|
|
466
|
+
* bundle exists. Owned here rather than by the caller because it is the last
|
|
467
|
+
* artifact that has to read the PROVISIONED `wrangler.jsonc`, and the dry-run
|
|
468
|
+
* rollback below closes that window as soon as this function returns.
|
|
469
|
+
* Relative paths resolve against the project root.
|
|
470
|
+
*/
|
|
471
|
+
emitBindings?: string;
|
|
298
472
|
env?: string;
|
|
299
473
|
/** Fetch implementation injected in tests for `--migrate` RPC calls. */
|
|
300
474
|
fetchImpl?: FetchLike;
|
|
301
475
|
/** Output format: `pretty` (default) or `json`. */
|
|
302
476
|
format?: string;
|
|
477
|
+
/**
|
|
478
|
+
* After a successful live deploy, probe the new version's health route
|
|
479
|
+
* (`/_lunora/health/ready`, falling back to `/_lunora/health`) and fail the
|
|
480
|
+
* command when it never answers. Opt-in, not default-on: a worker whose
|
|
481
|
+
* health route is admin-gated or unreachable from CI must still be
|
|
482
|
+
* deployable, and a default network step would turn a successful deploy
|
|
483
|
+
* into a red build for an unrelated reason.
|
|
484
|
+
*/
|
|
485
|
+
healthCheck?: boolean;
|
|
486
|
+
/** Injectable fetch for `--health-check`; defaults to the global `fetch`. */
|
|
487
|
+
healthFetch?: HealthFetch;
|
|
488
|
+
/** Injectable inter-attempt delay for `--health-check`; injected in tests to skip the real wait. */
|
|
489
|
+
healthSleep?: (ms: number) => Promise<void>;
|
|
303
490
|
/** Set to `false` to disable interactive spinners (test injection). */
|
|
304
491
|
interactive?: boolean;
|
|
305
492
|
logger: Logger;
|
|
306
493
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
494
|
+
* When true, after a successful `wrangler deploy`, discover and run all
|
|
495
|
+
* pending data migrations via the worker's `/_lunora/migrate` admin RPC.
|
|
496
|
+
* The worker must be live (exit 0) before migrations are attempted.
|
|
497
|
+
*
|
|
498
|
+
* Implementation note: the status RPC returns the full shard-level
|
|
499
|
+
* migration state, but there is no single authoritative "list of pending
|
|
500
|
+
* migration ids" that can be read client-side before running the worker.
|
|
501
|
+
* Instead, `--migrate` runs `migrate status` followed by `migrate up` for
|
|
502
|
+
* each migration id discovered locally via `discoverMigrations`. The
|
|
503
|
+
* worker's `MigrationRunner` is idempotent — running `up` on an already-
|
|
504
|
+
* applied migration is a no-op — so this approach is safe.
|
|
505
|
+
*/
|
|
319
506
|
migrate?: boolean;
|
|
320
507
|
/** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
|
|
321
508
|
migrateToken?: string;
|
|
322
509
|
/**
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
510
|
+
* Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
|
|
511
|
+
* handler never captures the URL `wrangler deploy` published to, so there is
|
|
512
|
+
* no safe default; omitting it would silently target `http://localhost:8787`
|
|
513
|
+
* (the dev worker), applying the migration to local state instead of prod.
|
|
514
|
+
*/
|
|
328
515
|
migrateUrl?: string;
|
|
329
516
|
/**
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
517
|
+
* Confirm a production data migration triggered via `--migrate` (the
|
|
518
|
+
* `migrate up --prod` confirmation the standalone command requires). Without
|
|
519
|
+
* it a `--migrate --migrate-url <prod>` deploy refuses to run the migration.
|
|
520
|
+
*/
|
|
334
521
|
migrateYes?: boolean;
|
|
335
522
|
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
523
|
+
* Emit the bundled worker to this directory via `wrangler deploy --outdir`
|
|
524
|
+
* (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
|
|
525
|
+
* `<outDir>/bundle-meta.json`. When unset, no artifact is written.
|
|
526
|
+
*/
|
|
340
527
|
outDir?: string;
|
|
341
528
|
/**
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
529
|
+
* Upload a preview version (`wrangler versions upload`) instead of a live
|
|
530
|
+
* `wrangler deploy`. Codegen + the drift gate + validation still run, but
|
|
531
|
+
* the post-deploy finalize (migrations, baseline re-bless, auto-link, the
|
|
532
|
+
* production summary) is skipped — a preview never shifts live traffic.
|
|
533
|
+
*/
|
|
347
534
|
preview?: boolean;
|
|
348
535
|
/** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
|
|
349
536
|
railpackAvailable?: DockerProbe;
|
|
@@ -354,22 +541,89 @@ interface DeployCommandOptions {
|
|
|
354
541
|
skipCodegen?: boolean;
|
|
355
542
|
spawner?: Spawner;
|
|
356
543
|
/**
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
544
|
+
* Fail the deploy when codegen reports an ERROR-level advisory. Same
|
|
545
|
+
* option `lunora codegen` exposes as `--no-strict-advisories`; defaults to
|
|
546
|
+
* CI detection (on in CI, off locally) so a legitimately-partial target
|
|
547
|
+
* can still be shipped interactively. Does NOT gate platform diagnostics
|
|
548
|
+
* (`platform_unsupported_feature` / `platform_unknown_target`), which
|
|
549
|
+
* always block — those mean the emitted `ctx.*` surface does not match
|
|
550
|
+
* what the target can serve, not merely a style nit.
|
|
551
|
+
*/
|
|
552
|
+
strictAdvisories?: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Deploy target. Falls back to `"target"` in `lunora.json`, then
|
|
555
|
+
* `"cloudflare"`, which selects the wrangler
|
|
556
|
+
* toolchain — i.e. today's behavior for every project. An unregistered name
|
|
557
|
+
* throws rather than falling back, so a typo can never ship the app to the
|
|
558
|
+
* wrong provider.
|
|
559
|
+
*/
|
|
560
|
+
target?: string;
|
|
561
|
+
/**
|
|
562
|
+
* Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
|
|
563
|
+
* For unauthenticated use only: wrangler provisions a short-lived account +
|
|
564
|
+
* token, deploys, and prints a claim URL; the deployment stays live ~60
|
|
565
|
+
* minutes before the unclaimed account is deleted. Wrangler itself errors
|
|
566
|
+
* if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
|
|
567
|
+
* global API key), so we pass the flag straight through without guarding.
|
|
568
|
+
*/
|
|
364
569
|
temporary?: boolean;
|
|
365
570
|
/** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
|
|
366
571
|
updateSchemaBaseline?: boolean;
|
|
367
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* What this run put where — the identity of the thing that was just deployed.
|
|
575
|
+
*
|
|
576
|
+
* Present on every run that reached (and completed) the wrangler invocation,
|
|
577
|
+
* including `--dry-run` and `--preview`, so a consumer can tell "nothing went
|
|
578
|
+
* live" from "went live" without inferring it from a missing `url`. A dry run
|
|
579
|
+
* publishes nothing and therefore never carries a `url`.
|
|
580
|
+
*
|
|
581
|
+
* No `versionId`: the pinned wrangler (see the `wrangler` catalog entry in
|
|
582
|
+
* `pnpm-workspace.yaml`) has no structured deploy output
|
|
583
|
+
* and no flag that returns the version id — it only prints it in prose, and
|
|
584
|
+
* scraping a second value out of prose is exactly what this shouldn't do. The
|
|
585
|
+
* id is available from `lunora deployments list` after the fact.
|
|
586
|
+
*/
|
|
587
|
+
interface DeployedIdentity {
|
|
588
|
+
/** ISO-8601 stamp taken when the wrangler invocation returned. */
|
|
589
|
+
deployedAt: string;
|
|
590
|
+
/** True when `--dry-run` validated + bundled without publishing. */
|
|
591
|
+
dryRun: boolean;
|
|
592
|
+
/** The Cloudflare environment this run targeted, when `--env` named one. */
|
|
593
|
+
env?: string;
|
|
594
|
+
/** True when `--preview` uploaded a version instead of shifting live traffic. */
|
|
595
|
+
preview: boolean;
|
|
596
|
+
/** The URL wrangler reported publishing to; absent on a dry run, or when the output carried no URL. */
|
|
597
|
+
url?: string;
|
|
598
|
+
/** The Worker name from the project's wrangler config. */
|
|
599
|
+
workerName?: string;
|
|
600
|
+
}
|
|
368
601
|
interface DeployCommandResult {
|
|
369
602
|
code: number;
|
|
603
|
+
/** What was deployed and where — set once the wrangler invocation completed. */
|
|
604
|
+
deployment?: DeployedIdentity;
|
|
370
605
|
descriptor: SpawnDescriptor | undefined;
|
|
371
606
|
/** Set when the run aborted before reaching the wrangler invocation. */
|
|
372
607
|
error?: string;
|
|
608
|
+
/**
|
|
609
|
+
* The `--health-check` probe's verdict, when the flag was set and the probe
|
|
610
|
+
* ran. A red probe fails the command (`code` is non-zero) — but the deploy
|
|
611
|
+
* itself still succeeded, which is why the reason is reported separately
|
|
612
|
+
* from `error`.
|
|
613
|
+
*/
|
|
614
|
+
healthCheck?: {
|
|
615
|
+
error?: string;
|
|
616
|
+
ok: boolean;
|
|
617
|
+
url: string;
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* The `.dev.vars`-shaped filename (never a full path, never a value) a
|
|
621
|
+
* secret minted during this run was recorded into, when the missing-
|
|
622
|
+
* secret gate minted one — `.dev.vars` for the default environment, or a
|
|
623
|
+
* `.dev.vars.<env>` sibling for an explicit `--env`. `undefined` when
|
|
624
|
+
* nothing was minted this run.
|
|
625
|
+
*/
|
|
626
|
+
mintedSecretsFile?: string;
|
|
373
627
|
/** The schema-drift gate verdict, when it ran (skipped on `--skip-codegen`). */
|
|
374
628
|
schemaDrift?: {
|
|
375
629
|
blocked: boolean;
|
|
@@ -381,48 +635,107 @@ interface DeployCommandResult {
|
|
|
381
635
|
};
|
|
382
636
|
}
|
|
383
637
|
/**
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
|
|
638
|
+
* The commands that run the pre-deploy pipeline, as the OPERATOR typed them.
|
|
639
|
+
*
|
|
640
|
+
* These checks are reached from `lunora deploy`, `lunora prepare` and
|
|
641
|
+
* `lunora build`, and a blocked run naming a command the operator never ran
|
|
642
|
+
* reads as a bug in the tool rather than a problem in the project.
|
|
643
|
+
*
|
|
644
|
+
* `build` is one of them: it delegates to `runDeployCommand({ dryRun: true })`.
|
|
645
|
+
* The name is threaded through rather than assumed, because the drift gate uses
|
|
646
|
+
* it for two operator-facing decisions — which override flags to offer, and what
|
|
647
|
+
* to call the thing that was blocked. Hardcoding `"deploy"` here meant `lunora
|
|
648
|
+
* build` reported "deploy blocked" for a deploy nobody attempted and recommended
|
|
649
|
+
* a flag `build` rejects with a raw stack trace.
|
|
650
|
+
*/
|
|
651
|
+
type PreDeployCommand = "build" | "deploy" | "prepare";
|
|
652
|
+
/**
|
|
653
|
+
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
654
|
+
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
655
|
+
* stderr for json output so stdout carries only the single JSON document.
|
|
656
|
+
*/
|
|
388
657
|
declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
|
|
389
|
-
/** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
|
|
390
658
|
/**
|
|
391
|
-
* Start the codegen watch loop and return a handle to stop it. Regenerates on
|
|
392
|
-
* startup, then on debounced changes under `lunora/` (ignoring writes to the
|
|
393
|
-
* `_generated/` output to avoid a feedback loop). If the platform can't do a
|
|
394
|
-
* recursive watch, it logs once and falls back to startup-only codegen.
|
|
395
|
-
*/
|
|
659
|
+
* Start the codegen watch loop and return a handle to stop it. Regenerates on
|
|
660
|
+
* startup, then on debounced changes under `lunora/` (ignoring writes to the
|
|
661
|
+
* `_generated/` output to avoid a feedback loop). If the platform can't do a
|
|
662
|
+
* recursive watch, it logs once and falls back to startup-only codegen.
|
|
663
|
+
*/
|
|
396
664
|
declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
|
|
397
665
|
interface CodegenWatcherOptions {
|
|
398
666
|
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
399
667
|
apiSpec?: CodegenOptions["apiSpec"];
|
|
400
668
|
/** Debounce window for coalescing rapid edits. Defaults to 100ms. */
|
|
401
669
|
debounceMs?: number;
|
|
670
|
+
/**
|
|
671
|
+
* The caller's logs are NDJSON on stdout, so the `postcodegen` hook's own
|
|
672
|
+
* stdout must be routed to stderr or it corrupts the stream. `lunora dev`
|
|
673
|
+
* turns this on for `--json` AND for a detected AI agent.
|
|
674
|
+
*/
|
|
675
|
+
jsonLogs?: boolean;
|
|
402
676
|
logger: Logger;
|
|
403
677
|
/** Override the lunora subdirectory name. Defaults to `"lunora"`. */
|
|
404
678
|
lunoraDirectory?: string;
|
|
405
679
|
/** Project root containing the `lunora/` directory. */
|
|
406
680
|
projectRoot: string;
|
|
681
|
+
/** Process spawner for the `postcodegen` hook. Injectable so tests need no real subprocess. */
|
|
682
|
+
spawner?: Spawner;
|
|
683
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
684
|
+
target?: string;
|
|
407
685
|
}
|
|
408
686
|
interface CodegenWatcherHandle {
|
|
409
|
-
/**
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
687
|
+
/**
|
|
688
|
+
* Stop watching, drop any queued regeneration, and resolve once the run
|
|
689
|
+
* already in flight has finished.
|
|
690
|
+
*
|
|
691
|
+
* Awaiting the result is what keeps a `postcodegen` child from being
|
|
692
|
+
* orphaned by the caller's `process.exit`; a caller that only needs the
|
|
693
|
+
* watcher detached can ignore it.
|
|
694
|
+
*/
|
|
695
|
+
close: () => Promise<void>;
|
|
696
|
+
/**
|
|
697
|
+
* Resolves once the startup regeneration — codegen AND the project's
|
|
698
|
+
* `postcodegen` — has finished.
|
|
699
|
+
*
|
|
700
|
+
* Await it before starting anything that reads generated output. `runCodegen`
|
|
701
|
+
* is synchronous and has already run by the time `startCodegenWatch` returns,
|
|
702
|
+
* but the hook is the step that FINISHES that output, so a worker spawned
|
|
703
|
+
* without waiting can bundle the unfinished copy. Resolves (never rejects)
|
|
704
|
+
* even when codegen or the hook failed — both report for themselves, and a
|
|
705
|
+
* dev server still has to come up.
|
|
706
|
+
*/
|
|
707
|
+
ready: Promise<void>;
|
|
708
|
+
/**
|
|
709
|
+
* `true` when the platform supports recursive watch and the loop is active.
|
|
710
|
+
* `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
|
|
711
|
+
* but schema edits will NOT auto-regenerate. Callers can surface this in the
|
|
712
|
+
* dev banner so the degraded state is visible beyond the single startup warning.
|
|
713
|
+
*/
|
|
417
714
|
watchAvailable: boolean;
|
|
418
715
|
}
|
|
419
716
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
|
|
717
|
+
* Readiness probe seam — tests swap the real HTTP probe out.
|
|
718
|
+
*
|
|
719
|
+
* The optional `signal` lets a caller cancel an attempt already in flight. Its
|
|
720
|
+
* absence is why a teardown used to leave one request dangling for up to
|
|
721
|
+
* {@link ATTEMPT_TIMEOUT_MS} after the dev server had been told to stop.
|
|
722
|
+
*/
|
|
723
|
+
type ReadinessProbe = (origin: string, signal?: AbortSignal) => Promise<boolean>;
|
|
724
|
+
/**
|
|
725
|
+
* Start the studio server and resolve once it is listening. Loads the static
|
|
726
|
+
* bundle + renders the host HTML once up front; serves them and proxies
|
|
727
|
+
* `/_lunora/*` (HTTP + WS) to the worker.
|
|
728
|
+
*/
|
|
424
729
|
declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
|
|
425
730
|
interface StudioServerOptions {
|
|
731
|
+
/**
|
|
732
|
+
* API-spec mode the host runs codegen with, forwarded to the local endpoints
|
|
733
|
+
* so a studio edit regenerates the SAME spec files the host's own codegen run
|
|
734
|
+
* writes. Codegen writes the spec its mode names and deletes the other, so
|
|
735
|
+
* omitting it made every studio edit delete an `apiSpec: "openrpc"` project's
|
|
736
|
+
* `openrpc.json`.
|
|
737
|
+
*/
|
|
738
|
+
apiSpec?: CodegenOptions["apiSpec"];
|
|
426
739
|
/** Project root — `.dev.vars` is read from here for the admin token. */
|
|
427
740
|
cwd: string;
|
|
428
741
|
/** Loopback host to bind. Defaults to `127.0.0.1` (admin tooling stays local). */
|
|
@@ -442,6 +755,24 @@ interface StudioServerHandle {
|
|
|
442
755
|
/** The URL to open in a browser. */
|
|
443
756
|
url: string;
|
|
444
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
|
|
760
|
+
* worker + embedded studio + codegen watch) for a standalone class-C project.
|
|
761
|
+
* `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
|
|
762
|
+
* studio, and codegen inside the Vite dev server, so `lunora dev` runs the
|
|
763
|
+
* project's own dev script and gets out of the way — this also covers class-B
|
|
764
|
+
* frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
|
|
765
|
+
* `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
|
|
766
|
+
* SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
|
|
767
|
+
* is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
|
|
768
|
+
* Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
|
|
769
|
+
* which runs an empty-script Miniflare and does not emulate internal DOs); there
|
|
770
|
+
* `lunora dev` runs the framework's own dev server (front door, HMR, and — via
|
|
771
|
+
* its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
|
|
772
|
+
* sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
|
|
773
|
+
* `wrangler.dev.jsonc`.
|
|
774
|
+
*/
|
|
775
|
+
type DevFlavor = "framework-worker" | "vite" | "wrangler";
|
|
445
776
|
/** A running worker child the orchestrator controls: send signals, await its exit. */
|
|
446
777
|
interface WorkerProcess {
|
|
447
778
|
/** Resolves with the worker's exit code (1 if it failed to start). */
|
|
@@ -458,17 +789,37 @@ interface DevCommandOptions {
|
|
|
458
789
|
/** Disable the codegen watch loop. */
|
|
459
790
|
codegen?: boolean;
|
|
460
791
|
cwd?: string;
|
|
792
|
+
/**
|
|
793
|
+
* Override where the binding manifest is written. One is always produced at
|
|
794
|
+
* {@link DEV_BINDINGS_FILE}; naming a path also makes a derivation failure
|
|
795
|
+
* fatal, since a named path means something is waiting on it.
|
|
796
|
+
*/
|
|
797
|
+
emitBindings?: string;
|
|
461
798
|
/** Injection seam for tests — defaults to the real `.dev.vars` scaffolder. */
|
|
462
799
|
ensureEnv?: typeof ensureDevVariables;
|
|
463
800
|
/** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
|
|
464
801
|
ensureExample?: typeof ensureDevVarsExample;
|
|
465
802
|
/** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
|
|
466
803
|
fillSecrets?: typeof fillDevSecrets;
|
|
804
|
+
/** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
|
|
805
|
+
findFreePort?: (preferred: number) => Promise<number>;
|
|
806
|
+
/** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
|
|
807
|
+
flavor?: DevFlavor;
|
|
808
|
+
/** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
|
|
809
|
+
hasIpv6Loopback?: () => boolean;
|
|
810
|
+
/**
|
|
811
|
+
* Logs are NDJSON on stdout (`--json`, or a detected AI agent). Forwarded to
|
|
812
|
+
* the codegen watcher so a `postcodegen` script's own stdout is routed to
|
|
813
|
+
* stderr instead of corrupting the stream.
|
|
814
|
+
*/
|
|
815
|
+
jsonLogs?: boolean;
|
|
467
816
|
logger: Logger;
|
|
468
817
|
/** Injection seam for tests — defaults to the real remote-config materializer. */
|
|
469
818
|
materializeRemote?: typeof materializeRemoteWranglerConfig;
|
|
470
819
|
/** Studio server port. */
|
|
471
820
|
port?: number;
|
|
821
|
+
/** Injection seam for tests — defaults to the real HTTP readiness probe. Without it the suite issues live GETs to the dev port. */
|
|
822
|
+
probeReady?: ReadinessProbe;
|
|
472
823
|
/** Proxy D1/KV/R2 bindings to the deployed worker during dev (`LUNORA_REMOTE=1` / `--remote`); DO shards stay local. */
|
|
473
824
|
remote?: boolean;
|
|
474
825
|
/** Injection seam for tests — defaults to the real codegen watcher. */
|
|
@@ -479,6 +830,19 @@ interface DevCommandOptions {
|
|
|
479
830
|
startWorker?: WorkerSpawner;
|
|
480
831
|
/** Disable the embedded studio server. */
|
|
481
832
|
studio?: boolean;
|
|
833
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
834
|
+
target?: string;
|
|
835
|
+
/**
|
|
836
|
+
* Injection seam for tests — defaults to parking until SIGINT.
|
|
837
|
+
*
|
|
838
|
+
* Attached mode (`--no-worker`) ends only on a signal, so without this the
|
|
839
|
+
* whole branch is unreachable from a test. That is how the readiness probe
|
|
840
|
+
* came to be wired after the early return, reported for a flavor it never
|
|
841
|
+
* covered, and shipped.
|
|
842
|
+
*/
|
|
843
|
+
waitForInterrupt?: (logger: Logger) => Promise<number>;
|
|
844
|
+
/** Disable the `wrangler dev` spawn — an external task runner owns the worker. */
|
|
845
|
+
worker?: boolean;
|
|
482
846
|
/** `wrangler dev` port. */
|
|
483
847
|
workerPort?: number;
|
|
484
848
|
}
|
|
@@ -486,10 +850,10 @@ interface DevRemotePlan {
|
|
|
486
850
|
/** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
|
|
487
851
|
bindings: string[];
|
|
488
852
|
/**
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
853
|
+
* Removes the generated temp wrangler config when dev exits. Always present
|
|
854
|
+
* and idempotent — a no-op when remote mode is off or nothing was
|
|
855
|
+
* materialized. The dev loop calls it on every shutdown path.
|
|
856
|
+
*/
|
|
493
857
|
cleanup: () => void;
|
|
494
858
|
/** Whether remote mode was requested. */
|
|
495
859
|
enabled: boolean;
|
|
@@ -497,58 +861,87 @@ interface DevRemotePlan {
|
|
|
497
861
|
reason?: string;
|
|
498
862
|
}
|
|
499
863
|
interface DevCommandPlan {
|
|
500
|
-
|
|
864
|
+
/** Which stack the child runs — see {@link DevFlavor}. */
|
|
865
|
+
flavor: DevFlavor;
|
|
866
|
+
/**
|
|
867
|
+
* One-line redirect hint printed when a meta-framework is detected on the
|
|
868
|
+
* wrangler flavor: without `@lunora/vite` in the dependencies the worker
|
|
869
|
+
* still runs *inside* the framework's dev server, so the user should run
|
|
870
|
+
* their framework dev script for the full app. `undefined` for the vite
|
|
871
|
+
* flavor (`lunora dev` already runs the project's dev script there) and
|
|
872
|
+
* for a standalone project. Purely informational: the wrangler spawn runs
|
|
873
|
+
* regardless.
|
|
874
|
+
*/
|
|
875
|
+
frameworkHint?: string;
|
|
876
|
+
/**
|
|
877
|
+
* True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
|
|
878
|
+
* IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
|
|
879
|
+
* Always `false` for the vite flavor (the plugin owns its own bind).
|
|
880
|
+
*/
|
|
881
|
+
ipv4LoopbackForced: boolean;
|
|
501
882
|
/** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
|
|
502
883
|
remote: DevRemotePlan;
|
|
884
|
+
runsCodegenWatch: boolean;
|
|
885
|
+
/**
|
|
886
|
+
* The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
|
|
887
|
+
* Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
|
|
888
|
+
* the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
|
|
889
|
+
* only the two-process class-B stack has a sidecar. When present, `wrangler`
|
|
890
|
+
* (above) is the framework's own dev server (the front door / HMR) and this
|
|
891
|
+
* is the Lunora realtime plane.
|
|
892
|
+
*/
|
|
893
|
+
sidecar?: SpawnDescriptor & {
|
|
894
|
+
tag: string;
|
|
895
|
+
};
|
|
503
896
|
studioEnabled: boolean;
|
|
504
897
|
studioPort: number;
|
|
898
|
+
/**
|
|
899
|
+
* Whether this process spawns `wrangler dev`.
|
|
900
|
+
*
|
|
901
|
+
* `--no-worker` turns it off so an external task runner (Turbo, Nx, vis, a
|
|
902
|
+
* Procfile) can own worker supervision while `lunora dev` still provides
|
|
903
|
+
* codegen-watch and Studio. Without it, `lunora dev` insisted on being the
|
|
904
|
+
* process root, which is what blocked running the Lunora worker as one node
|
|
905
|
+
* in a larger dev graph.
|
|
906
|
+
*/
|
|
907
|
+
workerEnabled: boolean;
|
|
505
908
|
workerOrigin: string;
|
|
506
909
|
workerPort: number;
|
|
507
|
-
/** The
|
|
910
|
+
/** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
|
|
508
911
|
wrangler: SpawnDescriptor & {
|
|
509
912
|
tag: string;
|
|
510
913
|
};
|
|
511
914
|
}
|
|
512
915
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
|
|
519
|
-
*/
|
|
520
|
-
/**
|
|
521
|
-
* Plan `lunora dev`: it runs the worker via `wrangler dev` and nothing else as a
|
|
522
|
-
* child process. Vite is intentionally NOT spawned — a project may not use Vite,
|
|
523
|
-
* and when it does, the `@lunora/vite` plugin already runs the worker inside
|
|
524
|
-
* Vite, so the user runs `vite` themselves. Pure + synchronous so it's unit-testable.
|
|
525
|
-
*/
|
|
916
|
+
* Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
|
|
917
|
+
* nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
|
|
918
|
+
* plugin already runs the worker inside the Vite dev server, so the one child
|
|
919
|
+
* is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
|
|
920
|
+
* sibling is disabled. Pure + synchronous so it's unit-testable.
|
|
921
|
+
*/
|
|
526
922
|
declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
|
|
527
923
|
/**
|
|
528
|
-
* Start codegen watch + the studio server, spawn `wrangler dev`, print the
|
|
529
|
-
* banner, and resolve when the worker exits or the user interrupts — tearing
|
|
530
|
-
* down the sibling servers either way. The three side-effecting pieces (worker,
|
|
531
|
-
* studio, codegen) are injectable so this is testable without real I/O.
|
|
532
|
-
*/
|
|
924
|
+
* Start codegen watch + the studio server, spawn `wrangler dev`, print the
|
|
925
|
+
* banner, and resolve when the worker exits or the user interrupts — tearing
|
|
926
|
+
* down the sibling servers either way. The three side-effecting pieces (worker,
|
|
927
|
+
* studio, codegen) are injectable so this is testable without real I/O.
|
|
928
|
+
*/
|
|
533
929
|
declare const runDevCommand: (options: DevCommandOptions) => Promise<{
|
|
534
930
|
code: number;
|
|
535
931
|
plan: DevCommandPlan;
|
|
536
932
|
}>;
|
|
537
|
-
/** `lunora dev` handler (lazy-loaded via the command's `loader`). */
|
|
538
933
|
/** Supported CI providers. */
|
|
539
934
|
type CiProvider = "github" | "gitlab";
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
*/
|
|
935
|
+
/**
|
|
936
|
+
* The per-framework auth-UI registry items (`auth-ui` resolves to one of these).
|
|
937
|
+
*
|
|
938
|
+
* Solid has two because these are copy-in source files, not a compiled package:
|
|
939
|
+
* the 1.x and 2.0 spellings are mutually exclusive in the source itself, so the
|
|
940
|
+
* two majors get one item each and {@link detectAuthUiItem} picks.
|
|
941
|
+
*/
|
|
942
|
+
type AuthUiItem = "auth-ui-angular" | "auth-ui-react" | "auth-ui-solid" | "auth-ui-solid-v2" | "auth-ui-svelte" | "auth-ui-vue";
|
|
549
943
|
/** A registry item a feature can install. */
|
|
550
|
-
type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
|
|
551
|
-
/** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
|
|
944
|
+
type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | AuthUiItem | "mail";
|
|
552
945
|
/** A single file the item scaffolds into the project. */
|
|
553
946
|
interface RegistryFile {
|
|
554
947
|
/** Source path inside the item dir (e.g. `schema.ts`). */
|
|
@@ -564,10 +957,10 @@ interface RegistryBinding {
|
|
|
564
957
|
value: unknown;
|
|
565
958
|
}
|
|
566
959
|
/**
|
|
567
|
-
* An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
|
|
568
|
-
* local-secrets file) on add — non-secrets get their `value`; secrets get an
|
|
569
|
-
* empty placeholder and a reminder to run `wrangler secret put` for production.
|
|
570
|
-
*/
|
|
960
|
+
* An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
|
|
961
|
+
* local-secrets file) on add — non-secrets get their `value`; secrets get an
|
|
962
|
+
* empty placeholder and a reminder to run `wrangler secret put` for production.
|
|
963
|
+
*/
|
|
571
964
|
interface RegistryEnvVariable {
|
|
572
965
|
/** Human note on what the variable is for. */
|
|
573
966
|
description?: string;
|
|
@@ -578,6 +971,13 @@ interface RegistryEnvVariable {
|
|
|
578
971
|
/** A default/example value for non-secret vars. */
|
|
579
972
|
value?: string;
|
|
580
973
|
}
|
|
974
|
+
/** A re-export the item needs injected into the worker entry point (class-B/C only). */
|
|
975
|
+
interface EntrypointReexport {
|
|
976
|
+
/** Optional JS comment placed above the re-export line. */
|
|
977
|
+
comment?: string;
|
|
978
|
+
/** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
|
|
979
|
+
module: string;
|
|
980
|
+
}
|
|
581
981
|
/** The `registry.json` manifest shape. */
|
|
582
982
|
interface RegistryManifest {
|
|
583
983
|
/** wrangler.jsonc additions (best-effort structural edits). */
|
|
@@ -589,6 +989,8 @@ interface RegistryManifest {
|
|
|
589
989
|
devDependencies?: Readonly<Record<string, string>>;
|
|
590
990
|
/** Post-install guidance printed after the item is added (per-item next steps). */
|
|
591
991
|
docs?: string;
|
|
992
|
+
/** Worker-entry re-exports the item needs (class-B/C only). */
|
|
993
|
+
entrypointReexports?: ReadonlyArray<EntrypointReexport>;
|
|
592
994
|
/** Environment variables the item needs; scaffolded into `.dev.vars`. */
|
|
593
995
|
envVars?: ReadonlyArray<RegistryEnvVariable>;
|
|
594
996
|
files: ReadonlyArray<RegistryFile>;
|
|
@@ -628,11 +1030,11 @@ interface AddCommandOptions {
|
|
|
628
1030
|
/** Override the remote registry source base (default gh:anolilab/lunora/registry). */
|
|
629
1031
|
source?: string;
|
|
630
1032
|
/**
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
1033
|
+
* Customize each resolved manifest after it is loaded but before the plan is
|
|
1034
|
+
* printed / reconciled — used to inject user-chosen values into otherwise
|
|
1035
|
+
* static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
|
|
1036
|
+
* for). Applied to every item; return the manifest unchanged to leave it as-is.
|
|
1037
|
+
*/
|
|
636
1038
|
transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
|
|
637
1039
|
/** Skip the package.json mutation confirmation prompt. */
|
|
638
1040
|
yes?: boolean;
|
|
@@ -648,21 +1050,20 @@ interface AddCommandResult {
|
|
|
648
1050
|
/** Files written (absolute paths). */
|
|
649
1051
|
written: ReadonlyArray<string>;
|
|
650
1052
|
}
|
|
651
|
-
/** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
|
|
652
1053
|
/**
|
|
653
|
-
* A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
|
|
654
|
-
* sub-prompt or alias; every other value IS the registry item name applied
|
|
655
|
-
* directly (`storage` → the `storage` registry item, etc.).
|
|
656
|
-
*/
|
|
657
|
-
type StackFeature = "auth" | "backup" | "crons" | "email" | "presence" | "
|
|
1054
|
+
* A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
|
|
1055
|
+
* sub-prompt or alias; every other value IS the registry item name applied
|
|
1056
|
+
* directly (`storage` → the `storage` registry item, etc.).
|
|
1057
|
+
*/
|
|
1058
|
+
type StackFeature = "ai" | "auth" | "auth-ui" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
|
|
658
1059
|
/** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
|
|
659
1060
|
type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
|
|
660
1061
|
/**
|
|
661
|
-
* One feature ready to apply: the registry item name(s), an optional manifest
|
|
662
|
-
* transform, and a short `label` (the feature value) shown on the combined
|
|
663
|
-
* progress line. Built up-front by the collectors so every prompt is answered
|
|
664
|
-
* before any apply runs.
|
|
665
|
-
*/
|
|
1062
|
+
* One feature ready to apply: the registry item name(s), an optional manifest
|
|
1063
|
+
* transform, and a short `label` (the feature value) shown on the combined
|
|
1064
|
+
* progress line. Built up-front by the collectors so every prompt is answered
|
|
1065
|
+
* before any apply runs.
|
|
1066
|
+
*/
|
|
666
1067
|
interface FeatureApply {
|
|
667
1068
|
label: string;
|
|
668
1069
|
names: ReadonlyArray<string>;
|
|
@@ -670,11 +1071,11 @@ interface FeatureApply {
|
|
|
670
1071
|
}
|
|
671
1072
|
interface OfferDeps {
|
|
672
1073
|
/**
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
1074
|
+
* Apply the collected features into the new project in one batch — resolves
|
|
1075
|
+
* `true` when every item succeeds. The CLI renders this as a single progress
|
|
1076
|
+
* line whose label changes per feature; each plan's `transformManifest`
|
|
1077
|
+
* customizes that item's manifest before it is written.
|
|
1078
|
+
*/
|
|
678
1079
|
applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
|
|
679
1080
|
/** When `false`, skip all prompts and print the later-setup hint. */
|
|
680
1081
|
interactive: boolean;
|
|
@@ -688,13 +1089,24 @@ interface OfferDeps {
|
|
|
688
1089
|
defaults?: ReadonlyArray<StackFeature>;
|
|
689
1090
|
}) => Promise<StackFeature[]>;
|
|
690
1091
|
/**
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
1092
|
+
* Features chosen non-interactively (the `--add` flag). When set, the
|
|
1093
|
+
* multi-select and every sub-prompt are skipped — each feature is applied with
|
|
1094
|
+
* its shipped defaults (base registry item, placeholder bindings).
|
|
1095
|
+
*/
|
|
695
1096
|
preselected?: ReadonlyArray<StackFeature>;
|
|
696
1097
|
/** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
|
|
697
1098
|
projectName: string;
|
|
1099
|
+
/**
|
|
1100
|
+
* Resolve which per-framework auth-UI item (`auth-ui-react|vue|…`) fits the
|
|
1101
|
+
* scaffolded project. Injected by the CLI (detected from the template's deps);
|
|
1102
|
+
* defaults to `auth-ui-react` when absent so this module stays pure/testable.
|
|
1103
|
+
*
|
|
1104
|
+
* `undefined` is a REFUSAL, not "unknown": no auth-UI item fits this project
|
|
1105
|
+
* (React Native). `lunora add auth-ui` already refuses there, and this offer
|
|
1106
|
+
* used to `?? "auth-ui-react"` its way past that — copying ~85 DOM files into
|
|
1107
|
+
* an Expo app and exiting 0.
|
|
1108
|
+
*/
|
|
1109
|
+
resolveAuthUiItem?: () => string | undefined;
|
|
698
1110
|
/** Single-select among the auth providers (TTY-backed in production). */
|
|
699
1111
|
select: (message: string, options: ReadonlyArray<{
|
|
700
1112
|
description?: string;
|
|
@@ -709,114 +1121,127 @@ interface OfferDeps {
|
|
|
709
1121
|
placeholder?: string;
|
|
710
1122
|
}) => Promise<string>;
|
|
711
1123
|
}
|
|
712
|
-
/**
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
1124
|
+
/** One choice in the multi-select. */
|
|
1125
|
+
interface LintToolOption {
|
|
1126
|
+
description: string;
|
|
1127
|
+
label: string;
|
|
1128
|
+
value: LintTool;
|
|
1129
|
+
}
|
|
1130
|
+
interface LintToolOfferDeps {
|
|
1131
|
+
/** Write the ignores for the chosen tools — `applyLintIgnores` in production. */
|
|
1132
|
+
apply: (tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
|
|
1133
|
+
/** Tools already detectable in the scaffolded project — pre-selected in the prompt. */
|
|
1134
|
+
detected: ReadonlyArray<LintTool>;
|
|
1135
|
+
/** False in CI / `--yes` / off a TTY: skip the prompt and configure whatever was detected. */
|
|
1136
|
+
interactive: boolean;
|
|
1137
|
+
logger: Logger;
|
|
1138
|
+
multiSelect: (message: string, choices: ReadonlyArray<LintToolOption>, settings?: {
|
|
1139
|
+
defaults?: ReadonlyArray<LintTool>;
|
|
1140
|
+
}) => Promise<LintTool[]>;
|
|
1141
|
+
}
|
|
1142
|
+
type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "solid-v2" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid" | "vinext" | "vinext-pages";
|
|
724
1143
|
interface InitCommandOptions {
|
|
725
1144
|
/**
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
1145
|
+
* Add features non-interactively after scaffolding (the `--add` flag): a
|
|
1146
|
+
* comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
|
|
1147
|
+
* Bypasses the interactive multi-select and sub-prompts —
|
|
1148
|
+
* each named feature is applied with its shipped defaults.
|
|
1149
|
+
*/
|
|
731
1150
|
add?: string;
|
|
732
1151
|
/**
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
1152
|
+
* When true, accept `--source` values that don't start with `gh:` /
|
|
1153
|
+
* `github:` / `https://` or that contain `..`. Defaults to false; the CLI
|
|
1154
|
+
* gate exists to stop arbitrary filesystem / scheme sources from being
|
|
1155
|
+
* pulled without the caller opting in.
|
|
1156
|
+
*/
|
|
738
1157
|
allowUnsafeSource?: boolean;
|
|
739
1158
|
/** When set, also scaffold a CI deploy pipeline for the given provider. */
|
|
740
1159
|
ci?: CiProvider;
|
|
741
1160
|
cwd?: string;
|
|
742
1161
|
/**
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
1162
|
+
* Walk the whole flow — prompts, task list, next-steps, mascot — but make no
|
|
1163
|
+
* changes: skip the template fetch/copy, the feature applies, the dependency
|
|
1164
|
+
* install, and `git init`. Each skipped action logs a `would …` line instead.
|
|
1165
|
+
*/
|
|
747
1166
|
dryRun?: boolean;
|
|
748
1167
|
/**
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
1168
|
+
* Local directory containing the template subdirs (e.g. `vite/`,
|
|
1169
|
+
* `standalone/`). When provided, skips the network fetch entirely.
|
|
1170
|
+
* Useful for offline runs, the clean-machine smoke test, and unit tests.
|
|
1171
|
+
*/
|
|
753
1172
|
from?: string;
|
|
754
1173
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
1174
|
+
* When true, configure Lunora into the CURRENT project (`cwd`) instead of
|
|
1175
|
+
* scaffolding a new directory. Finds an existing `vite.config.*` and
|
|
1176
|
+
* patches it via `patchViteConfig`, or creates a minimal one when absent.
|
|
1177
|
+
* All other scaffold options (`name`, `templateType`, `source`, `from`)
|
|
1178
|
+
* are ignored in this mode.
|
|
1179
|
+
*/
|
|
761
1180
|
inPlace?: boolean;
|
|
762
1181
|
/**
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
1182
|
+
* Inject the post-scaffold install offer's prompts (tests). When set, the
|
|
1183
|
+
* offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
|
|
1184
|
+
* `selectManager` picks among the detected managers.
|
|
1185
|
+
*/
|
|
767
1186
|
installPrompt?: {
|
|
768
1187
|
confirmInstall: () => Promise<boolean>;
|
|
769
1188
|
selectManager: (managers: ReadonlyArray<PackageManager>) => Promise<PackageManager>;
|
|
770
1189
|
};
|
|
771
1190
|
/**
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
1191
|
+
* Force the post-scaffold "add auth / email?" offer on (the `--interactive`
|
|
1192
|
+
* flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
|
|
1193
|
+
* suppresses it regardless. Has no effect once {@link prompt} is injected.
|
|
1194
|
+
*/
|
|
776
1195
|
interactive?: boolean;
|
|
1196
|
+
/**
|
|
1197
|
+
* Test seam for the lint/formatter multi-select. Separate from {@link prompt}
|
|
1198
|
+
* because that one is pinned to the feature-offer's value union — reusing it
|
|
1199
|
+
* here would only typecheck through a cast.
|
|
1200
|
+
*/
|
|
1201
|
+
lintPrompt?: LintToolOfferDeps["multiSelect"];
|
|
777
1202
|
logger: Logger;
|
|
778
1203
|
name?: string;
|
|
779
1204
|
/**
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
1205
|
+
* Local directory holding create-vite bases (one `template-<id>/` subdir per
|
|
1206
|
+
* framework). When set with `vite`, the overlay copies the base from disk
|
|
1207
|
+
* instead of fetching `create-vite` over the network — offline mode + tests.
|
|
1208
|
+
*/
|
|
784
1209
|
overlayBaseFrom?: string;
|
|
785
|
-
/** Probe for which package managers are installed (tests). Defaults to a real
|
|
1210
|
+
/** Probe for which package managers are installed (tests). Defaults to a real `<pm> --version` check. */
|
|
786
1211
|
packageManagerProbe?: PackageManagerProbe;
|
|
787
1212
|
/**
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1213
|
+
* Inject the offer's prompts (tests). When set, the offer is treated as
|
|
1214
|
+
* interactive regardless of TTY, and these drive the feature multi-select,
|
|
1215
|
+
* the auth-provider sub-select, and the storage bucket-name text input.
|
|
1216
|
+
*/
|
|
792
1217
|
prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
|
|
793
1218
|
/**
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
1219
|
+
* Override the git ref (branch, tag, or commit) the default template source
|
|
1220
|
+
* is fetched from. Takes precedence over the version-derived ref. Ignored
|
|
1221
|
+
* when `source` or `from` is set.
|
|
1222
|
+
*/
|
|
798
1223
|
ref?: string;
|
|
799
1224
|
/** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
|
|
800
1225
|
registryFrom?: string;
|
|
801
1226
|
/** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
|
|
802
1227
|
registrySource?: string;
|
|
803
1228
|
/**
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1229
|
+
* Override the remote source giget downloads from. Default:
|
|
1230
|
+
* `gh:anolilab/lunora/templates/<templateType>#<ref>`, where `<ref>` is
|
|
1231
|
+
* the `ref` option when set, else derived from the CLI version (pre-release
|
|
1232
|
+
* channels → their branch, stable → `main`). Tests typically use `from`
|
|
1233
|
+
* instead to skip the network.
|
|
1234
|
+
*/
|
|
810
1235
|
source?: string;
|
|
811
1236
|
/** Spawner for the post-scaffold dependency install (tests inject a recording stub). Defaults to a real subprocess. */
|
|
812
1237
|
spawner?: Spawner;
|
|
813
1238
|
templateType?: Template;
|
|
814
1239
|
/**
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
1240
|
+
* Scaffold via the **create-vite overlay** for this framework (`react`,
|
|
1241
|
+
* `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
|
|
1242
|
+
* the official create-vite base and apply the Lunora layer on top. Takes
|
|
1243
|
+
* precedence over `templateType`.
|
|
1244
|
+
*/
|
|
820
1245
|
vite?: string;
|
|
821
1246
|
/** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
|
|
822
1247
|
yes?: boolean;
|
|
@@ -826,8 +1251,12 @@ interface InitCommandResult {
|
|
|
826
1251
|
files: ReadonlyArray<string>;
|
|
827
1252
|
target: string;
|
|
828
1253
|
}
|
|
1254
|
+
/**
|
|
1255
|
+
* `lunora init` entry: scaffold (in-place or a new directory), then — on success
|
|
1256
|
+
* — offer to add auth + email via the registry. The offer never affects the
|
|
1257
|
+
* scaffold's exit code.
|
|
1258
|
+
*/
|
|
829
1259
|
declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
|
|
830
|
-
/** Narrow a raw `--template` value to a known {@link Template}. */
|
|
831
1260
|
interface MigrateGenerateCommandOptions {
|
|
832
1261
|
cwd?: string;
|
|
833
1262
|
logger: Logger;
|
|
@@ -853,29 +1282,27 @@ interface CatalogItem {
|
|
|
853
1282
|
interface IndexItem extends CatalogItem {
|
|
854
1283
|
title?: string;
|
|
855
1284
|
}
|
|
856
|
-
/** Names of the subdirectories under `root` that ship a `registry.json`. */
|
|
857
|
-
|
|
858
1285
|
/**
|
|
859
|
-
* Build the catalog (`index.json` contents) from a local registry root by
|
|
860
|
-
* reading every item's `registry.json`. Used by both `lunora registry build`
|
|
861
|
-
* and the registry tests so the committed index can't drift from the item dirs.
|
|
862
|
-
*/
|
|
1286
|
+
* Build the catalog (`index.json` contents) from a local registry root by
|
|
1287
|
+
* reading every item's `registry.json`. Used by both `lunora registry build`
|
|
1288
|
+
* and the registry tests so the committed index can't drift from the item dirs.
|
|
1289
|
+
*/
|
|
863
1290
|
declare const buildRegistryIndex: (root: string) => {
|
|
864
1291
|
items: IndexItem[];
|
|
865
1292
|
};
|
|
866
1293
|
/** `lunora registry add` (one or more item names): scaffold items into the project. */
|
|
867
1294
|
declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
868
1295
|
/**
|
|
869
|
-
* `lunora registry view` — inspect a registry item without installing it:
|
|
870
|
-
* print its plan (files / deps / env vars) followed by the full contents of each
|
|
871
|
-
* file it would scaffold. Resolves only the named item — no `requires` expansion.
|
|
872
|
-
*/
|
|
1296
|
+
* `lunora registry view` — inspect a registry item without installing it:
|
|
1297
|
+
* print its plan (files / deps / env vars) followed by the full contents of each
|
|
1298
|
+
* file it would scaffold. Resolves only the named item — no `requires` expansion.
|
|
1299
|
+
*/
|
|
873
1300
|
declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
874
1301
|
/**
|
|
875
|
-
* `lunora registry build` — regenerate `index.json` from the item directories
|
|
876
|
-
* (the catalog `list` reads). With `--check`, verify the committed index matches
|
|
877
|
-
* instead of rewriting it (exits non-zero on drift) — a CI guard.
|
|
878
|
-
*/
|
|
1302
|
+
* `lunora registry build` — regenerate `index.json` from the item directories
|
|
1303
|
+
* (the catalog `list` reads). With `--check`, verify the committed index matches
|
|
1304
|
+
* instead of rewriting it (exits non-zero on drift) — a CI guard.
|
|
1305
|
+
*/
|
|
879
1306
|
declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
880
1307
|
/** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
|
|
881
1308
|
declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
|
|
@@ -893,23 +1320,6 @@ interface ResetCommandResult {
|
|
|
893
1320
|
removed: ReadonlyArray<string>;
|
|
894
1321
|
}
|
|
895
1322
|
declare const runResetCommand: (options: ResetCommandOptions) => Promise<ResetCommandResult>;
|
|
896
|
-
/** `lunora reset` handler (lazy-loaded via the command's `loader`). */
|
|
897
|
-
/**
|
|
898
|
-
* Tiny argv parser.
|
|
899
|
-
*
|
|
900
|
-
* Supports long options (`--name value`, `--name=value`, `--flag`), short
|
|
901
|
-
* options (`-x value`, `-xvalue`), positional arguments (everything else, in
|
|
902
|
-
* order), and a `--` terminator after which everything is positional.
|
|
903
|
-
*
|
|
904
|
-
* Intentionally small — replaces a full CLI library for the handful of
|
|
905
|
-
* subcommands we need.
|
|
906
|
-
*/
|
|
907
|
-
interface ParsedArgs {
|
|
908
|
-
flags: Record<string, boolean>;
|
|
909
|
-
options: Record<string, string>;
|
|
910
|
-
positional: ReadonlyArray<string>;
|
|
911
|
-
}
|
|
912
|
-
declare const parseArgs: (argv: ReadonlyArray<string>, booleanFlags?: ReadonlySet<string>) => ParsedArgs;
|
|
913
1323
|
type InsertSchemaExtensionResult = {
|
|
914
1324
|
ok: true;
|
|
915
1325
|
text: string;
|
|
@@ -918,12 +1328,12 @@ type InsertSchemaExtensionResult = {
|
|
|
918
1328
|
reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
|
|
919
1329
|
};
|
|
920
1330
|
/**
|
|
921
|
-
* Append `.extend(
|
|
922
|
-
* `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
|
|
923
|
-
* `already-applied` and leaves the text unchanged.
|
|
924
|
-
* @param source the current `lunora/schema.ts` contents
|
|
925
|
-
* @param key the registry item key (e.g. `"ratelimit"`)
|
|
926
|
-
*/
|
|
1331
|
+
* Append `.extend(<key>.extension)` and a managed import to an existing
|
|
1332
|
+
* `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
|
|
1333
|
+
* `already-applied` and leaves the text unchanged.
|
|
1334
|
+
* @param source the current `lunora/schema.ts` contents
|
|
1335
|
+
* @param key the registry item key (e.g. `"ratelimit"`)
|
|
1336
|
+
*/
|
|
927
1337
|
declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
|
|
928
1338
|
/** Compact snapshot of a single global table — what we persist + diff. */
|
|
929
1339
|
interface TableSnapshot {
|
|
@@ -933,6 +1343,20 @@ interface TableSnapshot {
|
|
|
933
1343
|
name: string;
|
|
934
1344
|
}
|
|
935
1345
|
interface ColumnSnapshot {
|
|
1346
|
+
/**
|
|
1347
|
+
* The column's full validator shape — the SAME {@link FieldSnapshot} the
|
|
1348
|
+
* deploy gate diffs (`shared/schema-snapshot.ts`), not a second parallel
|
|
1349
|
+
* format.
|
|
1350
|
+
*
|
|
1351
|
+
* `sqlType` alone is lossy: `bigint`, `array`, `record`, `id`, `literal` and
|
|
1352
|
+
* `string` all map to the TEXT affinity, so `v.string()` → `v.bigint()` was
|
|
1353
|
+
* byte-identical here and `migrate generate` answered "no schema changes
|
|
1354
|
+
* detected" for a change `lunora prepare` blocks as breaking.
|
|
1355
|
+
*
|
|
1356
|
+
* Optional so a `.snapshot.json` written before this existed still parses —
|
|
1357
|
+
* it simply gets no deep check until the next generate rewrites it.
|
|
1358
|
+
*/
|
|
1359
|
+
field?: FieldSnapshot;
|
|
936
1360
|
/** True when the column accepts NULL (validator wrapped in v.optional). */
|
|
937
1361
|
nullable: boolean;
|
|
938
1362
|
/** SQLite type affinity, derived from the validator. */
|
|
@@ -966,26 +1390,34 @@ interface SchemaDiff {
|
|
|
966
1390
|
unsupported: ReadonlyArray<UnsupportedEntry>;
|
|
967
1391
|
}
|
|
968
1392
|
/**
|
|
969
|
-
* Map a Lunora validator kind to a SQLite type affinity — the canonical
|
|
970
|
-
* `@lunora/d1/dialect` mapping. Re-exported under this name because
|
|
971
|
-
* `schema-snapshot.ts` builds the persisted snapshot from it.
|
|
972
|
-
*/
|
|
1393
|
+
* Map a Lunora validator kind to a SQLite type affinity — the canonical
|
|
1394
|
+
* `@lunora/d1/dialect` mapping. Re-exported under this name because
|
|
1395
|
+
* `schema-snapshot.ts` builds the persisted snapshot from it.
|
|
1396
|
+
*/
|
|
973
1397
|
declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
|
|
974
|
-
/**
|
|
1398
|
+
/**
|
|
1399
|
+
* Emit `CREATE TABLE` SQL for a new global table.
|
|
1400
|
+
*
|
|
1401
|
+
* Refuses a table past D1's column ceiling rather than writing SQL that
|
|
1402
|
+
* `lunora migrate up` will reject: the runtime auto-provisioner checks the same
|
|
1403
|
+
* number, and a migration file is the worse place to find out — the failure
|
|
1404
|
+
* lands later, against a database, with none of the schema context that names
|
|
1405
|
+
* which table and field to split.
|
|
1406
|
+
*/
|
|
975
1407
|
declare const renderCreateTable: (table: TableSnapshot) => string;
|
|
976
1408
|
declare const renderDropTable: (tableName: string) => string;
|
|
977
1409
|
declare const renderAddColumn: (tableName: string, columnName: string, column: ColumnSnapshot) => string;
|
|
978
1410
|
declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
|
|
979
1411
|
declare const renderDropIndex: (tableName: string, indexName: string) => string;
|
|
980
1412
|
/**
|
|
981
|
-
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
982
|
-
*/
|
|
1413
|
+
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
1414
|
+
*/
|
|
983
1415
|
declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
|
|
984
1416
|
/**
|
|
985
|
-
* Render a complete migration file body from a diff. Includes a header,
|
|
986
|
-
* each SQL statement, and (if any) a trailing comment block describing the
|
|
987
|
-
* manual SQL the user needs to fill in for unsupported deltas.
|
|
988
|
-
*/
|
|
1417
|
+
* Render a complete migration file body from a diff. Includes a header,
|
|
1418
|
+
* each SQL statement, and (if any) a trailing comment block describing the
|
|
1419
|
+
* manual SQL the user needs to fill in for unsupported deltas.
|
|
1420
|
+
*/
|
|
989
1421
|
declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
|
|
990
1422
|
declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
|
|
991
|
-
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail,
|
|
1423
|
+
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DeployedIdentity, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
|