@lunora/config 1.0.0-alpha.102 → 1.0.0-alpha.104
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/README.md +2 -2
- package/dist/cloudflare/index.d.mts +628 -0
- package/dist/cloudflare/index.d.ts +628 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +97 -723
- package/dist/index.d.ts +97 -723
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/CLOUDFLARE_DRIVER-DqnWynqM.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-DDfyhjj8.mjs +1 -0
- package/dist/packem_shared/LUNORA_CONFIG_FILE-DVkEe5L6.mjs +1 -0
- package/dist/packem_shared/{inferLunoraBindings-B2y-19KL.mjs → inferLunoraBindings-BP-OTizO.mjs} +1 -1
- package/dist/packem_shared/schema-info.d-DS0bUsWE.d.mts +375 -0
- package/dist/packem_shared/schema-info.d-DS0bUsWE.d.ts +375 -0
- package/dist/packem_shared/wranglerToAlchemy-Fh5KfTPB.mjs +6 -0
- package/package.json +7 -3
- package/dist/packem_shared/LUNORA_CONFIG_FILE-3bpx6TZN.mjs +0 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ pnpm add @lunora/config
|
|
|
57
57
|
Validate a project's `wrangler.jsonc` from disk. `validateWranglerProject` finds the config file, parses the JSONC, discovers the schema (to know whether a `DB` D1 binding or Vectorize bindings are required), and returns a structured report:
|
|
58
58
|
|
|
59
59
|
```ts
|
|
60
|
-
import { validateWranglerProject } from "@lunora/config";
|
|
60
|
+
import { validateWranglerProject } from "@lunora/config/cloudflare";
|
|
61
61
|
|
|
62
62
|
const { report, wranglerPath } = validateWranglerProject({ projectRoot: process.cwd() });
|
|
63
63
|
|
|
@@ -70,7 +70,7 @@ for (const warning of report.warnings) console.warn(warning);
|
|
|
70
70
|
If you already hold a parsed config object, `validateWranglerConfig` (aliased as `validateWrangler`) is the pure, I/O-free form. Pass the discovered `SchemaInfo` so it knows which bindings the schema demands:
|
|
71
71
|
|
|
72
72
|
```ts
|
|
73
|
-
import { validateWranglerConfig } from "@lunora/config";
|
|
73
|
+
import { validateWranglerConfig } from "@lunora/config/cloudflare";
|
|
74
74
|
|
|
75
75
|
const report = validateWranglerConfig(wrangler, { hasGlobalTable: true });
|
|
76
76
|
// report: { valid: boolean; errors: string[]; warnings: string[] }
|
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import { D as DeployDriver, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-DS0bUsWE.mjs";
|
|
2
|
+
import { WranglerVariableIR } from '@lunora/codegen';
|
|
3
|
+
/** The Cloudflare deploy driver. */
|
|
4
|
+
declare const CLOUDFLARE_DRIVER: DeployDriver;
|
|
5
|
+
/**
|
|
6
|
+
* A container/workflow that is declared (so codegen emits its class) but the
|
|
7
|
+
* worker entry never re-exports — the one wiring step the generators can't always
|
|
8
|
+
* do for the developer. wrangler rejects a `class_name` the deployed worker
|
|
9
|
+
* doesn't export, so a deploy fails late on this; surfacing it as structured data
|
|
10
|
+
* lets the Vite plugin raise it in the dev error overlay (not just the console)
|
|
11
|
+
* the moment the gap appears. The human-readable form is also folded into
|
|
12
|
+
* {@link ReconcileBindingsResult.warnings}.
|
|
13
|
+
*/
|
|
14
|
+
interface ExportGap {
|
|
15
|
+
/** Generated class wrangler needs exported, e.g. `OrderPipelineWorkflow`. */
|
|
16
|
+
className: string;
|
|
17
|
+
/** The `lunora/{agents,containers,workflows}.ts` export name, e.g. `orderPipeline`. */
|
|
18
|
+
exportName: string;
|
|
19
|
+
/** Which declaration is unexported. */
|
|
20
|
+
kind: "agent" | "container" | "workflow";
|
|
21
|
+
/** The `_generated/{module}` to re-export from, e.g. `workflows`. */
|
|
22
|
+
module: "agents" | "containers" | "workflows";
|
|
23
|
+
}
|
|
24
|
+
interface ReconcileBindingsResult {
|
|
25
|
+
/** Short labels for each binding written (e.g. `"SCHEDULER/SchedulerDO"`). */
|
|
26
|
+
added: string[];
|
|
27
|
+
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
28
|
+
changed: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Declared containers/workflows the worker entry doesn't re-export — the
|
|
31
|
+
* structured form of the corresponding `warnings` entries, for the dev error
|
|
32
|
+
* overlay. Empty when every declaration is wired.
|
|
33
|
+
*/
|
|
34
|
+
exportGaps: ExportGap[];
|
|
35
|
+
/** Reason reconciliation was skipped, for logging. */
|
|
36
|
+
reason?: string;
|
|
37
|
+
/** Non-fatal hints for capabilities that cannot be auto-provisioned. */
|
|
38
|
+
warnings: string[];
|
|
39
|
+
/** Resolved wrangler path, or `undefined` when none was found. */
|
|
40
|
+
wranglerPath?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reconcile inferred Durable Object / D1 bindings into `wrangler.jsonc`.
|
|
44
|
+
*
|
|
45
|
+
* Writes only when something is missing; returns `changed: false` when the
|
|
46
|
+
* config already satisfies the inferred needs.
|
|
47
|
+
*/
|
|
48
|
+
declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings) => ReconcileBindingsResult;
|
|
49
|
+
interface ReconcileCompatibilityDateResult {
|
|
50
|
+
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
51
|
+
changed: boolean;
|
|
52
|
+
/** The new date value, or the existing one when unchanged. */
|
|
53
|
+
date: string | undefined;
|
|
54
|
+
/** Human-readable reason when reconciliation was skipped. */
|
|
55
|
+
reason?: string;
|
|
56
|
+
/** Resolved wrangler path, or `undefined` when none was found. */
|
|
57
|
+
wranglerPath?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Reconcile the `compatibility_date` in `wrangler.jsonc` when Workers Cache
|
|
61
|
+
* is enabled but the date is below the minimum required.
|
|
62
|
+
*/
|
|
63
|
+
declare const reconcileWranglerCompatibilityDate: (projectRoot: string) => ReconcileCompatibilityDateResult;
|
|
64
|
+
interface ReconcileResult {
|
|
65
|
+
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
66
|
+
changed: boolean;
|
|
67
|
+
/** Human-readable reason when reconciliation was skipped (for logging). */
|
|
68
|
+
reason?: string;
|
|
69
|
+
/** Resolved wrangler path, or `undefined` when none was found. */
|
|
70
|
+
wranglerPath?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reconcile the codegen-derived cron schedules into the project's
|
|
74
|
+
* `wrangler.jsonc` `triggers.crons` array, preserving comments and formatting
|
|
75
|
+
* via `jsonc-parser`'s structural edits.
|
|
76
|
+
*
|
|
77
|
+
* When `triggers.crons` already matches `cronTriggers`, nothing is written (so
|
|
78
|
+
* we don't churn the file or trip the dev server's file watcher). When the
|
|
79
|
+
* project declares no crons, a stale non-empty array is cleared so removed
|
|
80
|
+
* crons stop firing.
|
|
81
|
+
*
|
|
82
|
+
* This intentionally writes the SAME `triggers.crons` shape the
|
|
83
|
+
* `@lunora/config` validator accepts, so the wrangler validator never fights
|
|
84
|
+
* the generated value.
|
|
85
|
+
*/
|
|
86
|
+
declare const reconcileWranglerCrons: (projectRoot: string, cronTriggers: ReadonlyArray<string>) => ReconcileResult;
|
|
87
|
+
/**
|
|
88
|
+
* The wrangler config sections Lunora can safely flip to remote mode in dev,
|
|
89
|
+
* each with the human label used in logs and the structural `shape` the entry
|
|
90
|
+
* lives in.
|
|
91
|
+
*
|
|
92
|
+
* `"array"` is a top-level array of binding objects (`d1_databases`,
|
|
93
|
+
* `kv_namespaces`, `r2_buckets`, `vectorize`, `services`). `"producers"` is
|
|
94
|
+
* `queues.producers[]` — consumers are NOT remoted (their schema has no `remote`
|
|
95
|
+
* field) and the edit path is two levels deep. `"object"` is a single binding
|
|
96
|
+
* object, not an array (`ai`), whose edit path targets the section key directly.
|
|
97
|
+
*
|
|
98
|
+
* Every kind here was confirmed against `wrangler/config-schema.json`: the
|
|
99
|
+
* entry's schema declares a `remote` property. Deliberately omits
|
|
100
|
+
* `durable_objects` (no CF remote-DO mode; shards stay local) and sections whose
|
|
101
|
+
* schema has no `remote` field (`hyperdrive`, `analytics_engine_datasets`,
|
|
102
|
+
* `secrets_store_secrets`, queue consumers, …). Widening further is a one-line
|
|
103
|
+
* table edit.
|
|
104
|
+
*/
|
|
105
|
+
declare const REMOTE_ELIGIBLE_KEYS: {
|
|
106
|
+
readonly ai: {
|
|
107
|
+
readonly label: "AI";
|
|
108
|
+
readonly shape: "object";
|
|
109
|
+
};
|
|
110
|
+
readonly d1_databases: {
|
|
111
|
+
readonly label: "D1";
|
|
112
|
+
readonly shape: "array";
|
|
113
|
+
};
|
|
114
|
+
readonly kv_namespaces: {
|
|
115
|
+
readonly label: "KV";
|
|
116
|
+
readonly shape: "array";
|
|
117
|
+
};
|
|
118
|
+
readonly queues: {
|
|
119
|
+
readonly label: "Queue";
|
|
120
|
+
readonly shape: "producers";
|
|
121
|
+
};
|
|
122
|
+
readonly r2_buckets: {
|
|
123
|
+
readonly label: "R2";
|
|
124
|
+
readonly shape: "array";
|
|
125
|
+
};
|
|
126
|
+
readonly services: {
|
|
127
|
+
readonly label: "Service";
|
|
128
|
+
readonly shape: "array";
|
|
129
|
+
};
|
|
130
|
+
readonly vectorize: {
|
|
131
|
+
readonly label: "Vectorize";
|
|
132
|
+
readonly shape: "array";
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
type RemoteEligibleKey = keyof typeof REMOTE_ELIGIBLE_KEYS;
|
|
136
|
+
/** One binding object as it appears in any eligible section. */
|
|
137
|
+
interface BindingEntry {
|
|
138
|
+
binding?: string;
|
|
139
|
+
remote?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** One binding entry we mark remote, with enough provenance to log + edit it. */
|
|
142
|
+
interface RemoteBindingPlan {
|
|
143
|
+
/** The binding name as declared in the config (e.g. `"DB"`, `"FILES"`). */
|
|
144
|
+
binding: string;
|
|
145
|
+
/** Short kind label for logging (`"D1"`, `"KV"`, `"R2"`, `"Vectorize"`, …). */
|
|
146
|
+
kind: string;
|
|
147
|
+
/**
|
|
148
|
+
* The jsonc edit path within {@link RemoteBindingPlan.section}, relative to
|
|
149
|
+
* the section key: `[index]` for an `"array"` section, `["producers", index]`
|
|
150
|
+
* for a queue producer, or `[]` for the single-object `ai` section. The
|
|
151
|
+
* materializer prepends the section key and appends `"remote"`.
|
|
152
|
+
*/
|
|
153
|
+
path: ReadonlyArray<number | string>;
|
|
154
|
+
/** The wrangler config key the entry lives under. */
|
|
155
|
+
section: RemoteEligibleKey;
|
|
156
|
+
}
|
|
157
|
+
/** The structural slice of a wrangler config the remote planner reads. */
|
|
158
|
+
interface RemoteWranglerShape {
|
|
159
|
+
ai?: BindingEntry | null;
|
|
160
|
+
d1_databases?: ReadonlyArray<BindingEntry | null | undefined>;
|
|
161
|
+
kv_namespaces?: ReadonlyArray<BindingEntry | null | undefined>;
|
|
162
|
+
queues?: {
|
|
163
|
+
producers?: ReadonlyArray<BindingEntry | null | undefined>;
|
|
164
|
+
} | null;
|
|
165
|
+
r2_buckets?: ReadonlyArray<BindingEntry | null | undefined>;
|
|
166
|
+
services?: ReadonlyArray<BindingEntry | null | undefined>;
|
|
167
|
+
vectorize?: ReadonlyArray<BindingEntry | null | undefined>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Inspect a parsed wrangler config and list every eligible binding that should
|
|
171
|
+
* be flipped to remote mode. Pure — no file-system access, no mutation. An
|
|
172
|
+
* entry already carrying `"remote": true` is still reported (so logging is
|
|
173
|
+
* complete) but the materializer's edit is a harmless no-op for it.
|
|
174
|
+
*/
|
|
175
|
+
declare const planRemoteBindings: (parsed: RemoteWranglerShape) => RemoteBindingPlan[];
|
|
176
|
+
/**
|
|
177
|
+
* Inject `"remote": true` onto each planned binding in the config `text`,
|
|
178
|
+
* comment-preservingly via jsonc edits. Pure string→string; the edits target
|
|
179
|
+
* disjoint entries so applying them sequentially is safe. The edit path is
|
|
180
|
+
* `[section, ...plan.path, "remote"]`, which resolves to the array element, the
|
|
181
|
+
* `queues.producers[i]` entry, or the single `ai` object as the plan demands.
|
|
182
|
+
*/
|
|
183
|
+
declare const injectRemoteFlags: (text: string, plans: ReadonlyArray<RemoteBindingPlan>) => string;
|
|
184
|
+
interface MaterializeOptions {
|
|
185
|
+
/** When `false`, the call is a no-op (returns `enabled: false`). */
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
projectRoot: string;
|
|
188
|
+
}
|
|
189
|
+
interface MaterializeResult {
|
|
190
|
+
/**
|
|
191
|
+
* Removes the generated temp config file. Always present and always safe to
|
|
192
|
+
* call: it is idempotent, a no-op when nothing was written (disabled /
|
|
193
|
+
* fall-through cases), and never throws if the path is already gone. The dev
|
|
194
|
+
* command calls this on every exit path (normal, signal, error).
|
|
195
|
+
*/
|
|
196
|
+
cleanup: () => void;
|
|
197
|
+
/**
|
|
198
|
+
* Absolute path to the generated temp config to pass to
|
|
199
|
+
* `wrangler dev --config`. `undefined` when remote mode is disabled, no
|
|
200
|
+
* wrangler config was found, it failed to parse, or it declared no eligible
|
|
201
|
+
* binding (nothing to remote — run plain local dev).
|
|
202
|
+
*/
|
|
203
|
+
configPath?: string;
|
|
204
|
+
/** Whether remote mode was requested at all. */
|
|
205
|
+
enabled: boolean;
|
|
206
|
+
/** Why no temp config was produced, for logging (only set when none was). */
|
|
207
|
+
reason?: string;
|
|
208
|
+
/** The bindings flipped to remote, for the dev banner. */
|
|
209
|
+
remoteBindings: RemoteBindingPlan[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Produce a temporary wrangler config with `"remote": true` on every eligible
|
|
213
|
+
* binding, so `lunora dev` can run `wrangler dev --config <temp>` against the
|
|
214
|
+
* deployed D1/KV/R2 without touching the user's file.
|
|
215
|
+
*
|
|
216
|
+
* The temp file is written as a sibling of the source `wrangler.jsonc` (in the
|
|
217
|
+
* project root), NOT an OS temp dir: wrangler resolves a config's relative paths
|
|
218
|
+
* (`main`, `assets`, `migrations_dir`, …) against the **config file's own
|
|
219
|
+
* directory**, so a temp config in `/tmp` would make wrangler look for
|
|
220
|
+
* `/tmp/src/server.ts` and fail to start the worker. Keeping it beside the real
|
|
221
|
+
* config preserves those relative paths. Returns `configPath: undefined` (with a
|
|
222
|
+
* `reason`) for every fall-through case so the caller degrades to plain local
|
|
223
|
+
* dev instead of failing.
|
|
224
|
+
*/
|
|
225
|
+
declare const materializeRemoteWranglerConfig: (options: MaterializeOptions) => MaterializeResult;
|
|
226
|
+
/**
|
|
227
|
+
* Parse a `LUNORA_REMOTE` env value into the on/off decision. Truthy when set to
|
|
228
|
+
* `"1"` or `"true"` (case-insensitive); anything else — unset, `"0"`, `"false"`,
|
|
229
|
+
* empty — is off. Mirrors the `"1" | "true"` convention used across the runtime.
|
|
230
|
+
*/
|
|
231
|
+
declare const isRemoteEnvEnabled: (value: string | undefined) => boolean;
|
|
232
|
+
/** The three inputs that can switch remote-binding dev on, in precedence order. */
|
|
233
|
+
interface RemoteEnableInputs {
|
|
234
|
+
/**
|
|
235
|
+
* The `remote` preference from `lunora.json` (the lowest-priority signal).
|
|
236
|
+
* `undefined` means "no project preference"; an explicit `false` here loses
|
|
237
|
+
* to neither the flag nor the env when those are absent — it just stays off.
|
|
238
|
+
*/
|
|
239
|
+
configPreference?: boolean;
|
|
240
|
+
/** The raw `LUNORA_REMOTE` env value (parsed with {@link isRemoteEnvEnabled}). */
|
|
241
|
+
envValue?: string;
|
|
242
|
+
/** The explicit `--remote` CLI flag — `true` when passed, `undefined`/`false` otherwise. */
|
|
243
|
+
flag?: boolean;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Resolve whether remote-binding dev is on, with a clear precedence:
|
|
247
|
+
*
|
|
248
|
+
* 1. an explicit `--remote` flag (highest — a deliberate per-invocation choice),
|
|
249
|
+
* 2. then `LUNORA_REMOTE` in the environment,
|
|
250
|
+
* 3. then the `remote` key in `lunora.json` (lowest — a project default).
|
|
251
|
+
*
|
|
252
|
+
* The flag and env are one-directional (they can only turn remote *on*); only
|
|
253
|
+
* the config preference carries a meaningful `false`, and it applies solely when
|
|
254
|
+
* neither stronger signal is present. So a project that sets `"remote": false`
|
|
255
|
+
* is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
|
|
256
|
+
*/
|
|
257
|
+
declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Single source of truth for "does this wrangler config enable Workers
|
|
260
|
+
* Cache?" and "what compatibility_date does that require?".
|
|
261
|
+
*
|
|
262
|
+
* Before this module, `reconcile-compatibility-date.ts` (auto-bump) and
|
|
263
|
+
* `wrangler-validator.ts` (validation) each carried their own
|
|
264
|
+
* `WORKERS_CACHE_MIN_DATE` literal and their own top-level/`exports[]`
|
|
265
|
+
* cache-enabled walk — two copies of the same fact that could silently drift
|
|
266
|
+
* apart (a date bumped in one file without the other would either validate a
|
|
267
|
+
* config the reconciler wouldn't produce, or vice versa).
|
|
268
|
+
*/
|
|
269
|
+
/** The `compatibility_date` Workers Cache (`cache.enabled: true`) requires. */
|
|
270
|
+
declare const WORKERS_CACHE_MIN_DATE = "2026-05-01";
|
|
271
|
+
/** The subset of a parsed `wrangler.jsonc` the cache-enabled check reads. */
|
|
272
|
+
interface WranglerCacheShape {
|
|
273
|
+
cache?: {
|
|
274
|
+
enabled?: boolean;
|
|
275
|
+
} | null;
|
|
276
|
+
exports?: Record<string, {
|
|
277
|
+
cache?: {
|
|
278
|
+
enabled?: boolean;
|
|
279
|
+
} | null;
|
|
280
|
+
} | null> | null;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Whether Workers Cache is enabled anywhere in a parsed wrangler config — the
|
|
284
|
+
* top-level `cache.enabled` toggle, or a per-export override in
|
|
285
|
+
* `exports[name].cache.enabled` (Workers can scope cache per named export).
|
|
286
|
+
* `undefined`/`null` (an unparsed or absent config) is treated as disabled.
|
|
287
|
+
*/
|
|
288
|
+
declare const isCacheEnabled: (parsed: WranglerCacheShape | null | undefined) => boolean;
|
|
289
|
+
/** Candidate wrangler config filenames, in the order every consumer probes them. */
|
|
290
|
+
declare const WRANGLER_FILES: readonly ["wrangler.jsonc", "wrangler.json"];
|
|
291
|
+
/** Locate the project's wrangler config, or `undefined` when none exists. */
|
|
292
|
+
declare const findWranglerFile: (projectRoot: string) => string | undefined;
|
|
293
|
+
interface ReadWranglerResult<T> {
|
|
294
|
+
/** Parsed config, or `undefined` when the file was not valid JSONC. */
|
|
295
|
+
parsed: T | undefined;
|
|
296
|
+
/** Raw file text — needed for comment-preserving `modify`/`applyEdits`. */
|
|
297
|
+
text: string;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Read and JSONC-parse a wrangler config file. Returns the raw `text` (for
|
|
301
|
+
* structural edits) alongside `parsed`, which is `undefined` when the file is
|
|
302
|
+
* not valid JSONC or does not parse to an object. Allows trailing commas, as
|
|
303
|
+
* wrangler does.
|
|
304
|
+
*/
|
|
305
|
+
declare const readWranglerJsonc: <T = unknown>(wranglerPath: string) => ReadWranglerResult<T>;
|
|
306
|
+
/**
|
|
307
|
+
* Pure scan of a `vars` map for plaintext secrets — the FS-free core, exported for
|
|
308
|
+
* unit tests. A variable is flagged when, for a **string** value that is neither a
|
|
309
|
+
* placeholder nor a public/publishable key, EITHER the value matches a known
|
|
310
|
+
* secret shape (`secretKindOf`) OR the key name strongly implies a secret and the
|
|
311
|
+
* value is long enough to plausibly be one. `kind` is the matched shape, or
|
|
312
|
+
* `secret_named_var` for the key-name path.
|
|
313
|
+
*/
|
|
314
|
+
declare const scanWranglerVariablesForSecrets: (variables: Record<string, unknown> | undefined, file: string) => WranglerVariableIR[];
|
|
315
|
+
/**
|
|
316
|
+
* Read the project's `wrangler.jsonc` and return its plaintext-secret `vars` as IR
|
|
317
|
+
* for the `plaintext_secret_in_wrangler_vars` lint. Returns `[]` when there is no
|
|
318
|
+
* wrangler config, it doesn't parse, or nothing looks like a secret. Scans the
|
|
319
|
+
* top-level `vars` block (mirroring the existing `validateCorsVariables` scope);
|
|
320
|
+
* per-environment `env.<name>.vars` overrides are out of scope for now.
|
|
321
|
+
*/
|
|
322
|
+
declare const collectWranglerSecretVariables: (projectRoot: string) => WranglerVariableIR[];
|
|
323
|
+
/**
|
|
324
|
+
* Translate a `wrangler.jsonc` into an [Alchemy](https://alchemy.run) program.
|
|
325
|
+
*
|
|
326
|
+
* # Why translate rather than ask for a second config
|
|
327
|
+
*
|
|
328
|
+
* `wrangler.jsonc` is already the source of truth for what an app needs, and
|
|
329
|
+
* Lunora already infers and reconciles it — `inferLunoraBindings` decides that
|
|
330
|
+
* a project needs a shard namespace and a bucket, `reconcileWranglerBindings`
|
|
331
|
+
* writes them. Asking a developer to restate all of that in an
|
|
332
|
+
* `alchemy.run.ts` would give the project two sources of truth that drift, and
|
|
333
|
+
* the drift would surface as a deploy that provisions something the app does
|
|
334
|
+
* not bind.
|
|
335
|
+
*
|
|
336
|
+
* So Alchemy is an implementation detail of `deploy`, not a thing to configure:
|
|
337
|
+
* read the config, emit the program, run it.
|
|
338
|
+
*
|
|
339
|
+
* # Why this emits source rather than calling Alchemy
|
|
340
|
+
*
|
|
341
|
+
* `alchemy@0.93` has thirty dependencies, nine of them Node-shaped —
|
|
342
|
+
* `wrangler`, `miniflare`, `esbuild`, `execa`, `find-process`, `glob`, `open`,
|
|
343
|
+
* `proper-lockfile`, `signal-exit`. `@lunora/config` is imported by
|
|
344
|
+
* `@lunora/vite`, so importing Alchemy here would push that tree into every
|
|
345
|
+
* project that merely wanted to read `lunora.json`, and into any bundle
|
|
346
|
+
* targeting workerd — where none of it survives.
|
|
347
|
+
*
|
|
348
|
+
* Emitting text keeps this module pure and dependency-free. Alchemy is invoked
|
|
349
|
+
* as a CLI against the generated file, so it only has to exist on the machine
|
|
350
|
+
* that deploys.
|
|
351
|
+
*
|
|
352
|
+
* # Adoption, not re-creation
|
|
353
|
+
*
|
|
354
|
+
* Every resource is emitted with `adopt: true`. A project translated from an
|
|
355
|
+
* existing `wrangler.jsonc` already *has* its D1 database and its bucket, with
|
|
356
|
+
* data in them. Without adoption Alchemy would treat them as new and try to
|
|
357
|
+
* create alongside — the one outcome a deploy must never have.
|
|
358
|
+
*/
|
|
359
|
+
/** A Durable Object binding as `wrangler.jsonc` spells it. */
|
|
360
|
+
interface WranglerDurableObjectBinding$1 {
|
|
361
|
+
class_name?: string;
|
|
362
|
+
name?: string;
|
|
363
|
+
script_name?: string;
|
|
364
|
+
}
|
|
365
|
+
/** The slice of `wrangler.jsonc` that translates into Alchemy resources. */
|
|
366
|
+
interface WranglerConfigShape {
|
|
367
|
+
compatibility_date?: string;
|
|
368
|
+
compatibility_flags?: ReadonlyArray<string>;
|
|
369
|
+
d1_databases?: ReadonlyArray<{
|
|
370
|
+
binding?: string;
|
|
371
|
+
database_id?: string;
|
|
372
|
+
database_name?: string;
|
|
373
|
+
}>;
|
|
374
|
+
durable_objects?: {
|
|
375
|
+
bindings?: ReadonlyArray<WranglerDurableObjectBinding$1>;
|
|
376
|
+
};
|
|
377
|
+
kv_namespaces?: ReadonlyArray<{
|
|
378
|
+
binding?: string;
|
|
379
|
+
id?: string;
|
|
380
|
+
}>;
|
|
381
|
+
main?: string;
|
|
382
|
+
/** `new_sqlite_classes` marks which DO classes get SQLite storage — Alchemy needs that per namespace. */
|
|
383
|
+
migrations?: ReadonlyArray<{
|
|
384
|
+
new_classes?: ReadonlyArray<string>;
|
|
385
|
+
new_sqlite_classes?: ReadonlyArray<string>;
|
|
386
|
+
}>;
|
|
387
|
+
name?: string;
|
|
388
|
+
queues?: {
|
|
389
|
+
producers?: ReadonlyArray<{
|
|
390
|
+
binding?: string;
|
|
391
|
+
queue?: string;
|
|
392
|
+
}>;
|
|
393
|
+
};
|
|
394
|
+
r2_buckets?: ReadonlyArray<{
|
|
395
|
+
binding?: string;
|
|
396
|
+
bucket_name?: string;
|
|
397
|
+
}>;
|
|
398
|
+
triggers?: {
|
|
399
|
+
crons?: ReadonlyArray<string>;
|
|
400
|
+
};
|
|
401
|
+
vars?: Readonly<Record<string, unknown>>;
|
|
402
|
+
}
|
|
403
|
+
/** What the translation could not carry over, so the caller can say so out loud. */
|
|
404
|
+
interface AlchemyTranslation {
|
|
405
|
+
/** The emitted program source. */
|
|
406
|
+
source: string;
|
|
407
|
+
/**
|
|
408
|
+
* Bindings present in `wrangler.jsonc` that this translation drops.
|
|
409
|
+
*
|
|
410
|
+
* Reported rather than silently omitted: a deploy that quietly loses a
|
|
411
|
+
* Vectorize index produces a worker whose `env.POSTS_SEARCH` is undefined
|
|
412
|
+
* at runtime, and nothing in the build says why.
|
|
413
|
+
*/
|
|
414
|
+
unsupported: ReadonlyArray<string>;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Translate a parsed `wrangler.jsonc` into an Alchemy program.
|
|
418
|
+
*
|
|
419
|
+
* Pure: it reads nothing and writes nothing, so the caller decides where the
|
|
420
|
+
* source lands and the whole thing stays testable as a string comparison.
|
|
421
|
+
* @param config The parsed `wrangler.jsonc`.
|
|
422
|
+
* @returns the program source, plus whatever could not be carried over.
|
|
423
|
+
*/
|
|
424
|
+
declare const wranglerToAlchemy: (config: WranglerConfigShape) => AlchemyTranslation;
|
|
425
|
+
declare const REQUIRED_COMPATIBILITY_DATE: string;
|
|
426
|
+
declare const REQUIRED_FLAG: string;
|
|
427
|
+
interface WranglerDurableObjectBinding {
|
|
428
|
+
class_name?: string;
|
|
429
|
+
name?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* A `tail_consumers` entry: a Worker that receives this Worker's tail events
|
|
433
|
+
* (logs, exceptions, fetch metadata) for forwarding to an external sink. See
|
|
434
|
+
* `withTailConsumer` for the wiring helper.
|
|
435
|
+
*/
|
|
436
|
+
interface TailConsumer {
|
|
437
|
+
/** Optional Cloudflare environment of the consumer Worker. */
|
|
438
|
+
environment?: string;
|
|
439
|
+
/** Name of the Worker that consumes tail events. */
|
|
440
|
+
service?: string;
|
|
441
|
+
}
|
|
442
|
+
/** A wrangler `containers[]` entry (parsed from untrusted JSONC). */
|
|
443
|
+
interface WranglerContainerEntry {
|
|
444
|
+
class_name?: string;
|
|
445
|
+
image?: string;
|
|
446
|
+
instance_type?: string | {
|
|
447
|
+
disk_mb?: number;
|
|
448
|
+
memory_mib?: number;
|
|
449
|
+
vcpu?: number;
|
|
450
|
+
};
|
|
451
|
+
max_instances?: number;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* A wrangler `workflows[]` entry (parsed from untrusted JSONC). Unlike
|
|
455
|
+
* containers, workflows are NOT Durable Objects — the entry stands alone (no
|
|
456
|
+
* `durable_objects` binding, no migration class).
|
|
457
|
+
*/
|
|
458
|
+
interface WranglerWorkflowEntry {
|
|
459
|
+
binding?: string;
|
|
460
|
+
class_name?: string;
|
|
461
|
+
name?: string;
|
|
462
|
+
}
|
|
463
|
+
/** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
|
|
464
|
+
interface WranglerQueueProducer {
|
|
465
|
+
binding?: string;
|
|
466
|
+
delivery_delay?: number;
|
|
467
|
+
queue?: string;
|
|
468
|
+
}
|
|
469
|
+
/** A wrangler `queues.consumers[]` entry — push (worker) or `type: "http_pull"`. */
|
|
470
|
+
interface WranglerQueueConsumer {
|
|
471
|
+
dead_letter_queue?: string;
|
|
472
|
+
max_batch_size?: number;
|
|
473
|
+
max_batch_timeout?: number;
|
|
474
|
+
max_retries?: number;
|
|
475
|
+
queue?: string;
|
|
476
|
+
retry_delay?: number;
|
|
477
|
+
type?: string;
|
|
478
|
+
}
|
|
479
|
+
interface WranglerConfig {
|
|
480
|
+
analytics_engine_datasets?: ReadonlyArray<{
|
|
481
|
+
binding?: string;
|
|
482
|
+
dataset?: string;
|
|
483
|
+
} | null | undefined>;
|
|
484
|
+
assets?: {
|
|
485
|
+
binding?: string;
|
|
486
|
+
directory?: string;
|
|
487
|
+
html_handling?: string;
|
|
488
|
+
not_found_handling?: string;
|
|
489
|
+
};
|
|
490
|
+
browser?: {
|
|
491
|
+
binding?: string;
|
|
492
|
+
};
|
|
493
|
+
cache?: {
|
|
494
|
+
enabled?: boolean;
|
|
495
|
+
} | null;
|
|
496
|
+
compatibility_date?: string;
|
|
497
|
+
compatibility_flags?: ReadonlyArray<string>;
|
|
498
|
+
containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
|
|
499
|
+
d1_databases?: ReadonlyArray<{
|
|
500
|
+
binding?: string;
|
|
501
|
+
}>;
|
|
502
|
+
dispatch_namespaces?: ReadonlyArray<{
|
|
503
|
+
binding?: string;
|
|
504
|
+
namespace?: string;
|
|
505
|
+
outbound?: unknown;
|
|
506
|
+
} | null | undefined>;
|
|
507
|
+
durable_objects?: {
|
|
508
|
+
bindings?: ReadonlyArray<WranglerDurableObjectBinding>;
|
|
509
|
+
};
|
|
510
|
+
exports?: Record<string, {
|
|
511
|
+
cache?: {
|
|
512
|
+
enabled?: boolean;
|
|
513
|
+
} | null;
|
|
514
|
+
type?: string;
|
|
515
|
+
} | null> | null;
|
|
516
|
+
flagship?: ReadonlyArray<{
|
|
517
|
+
app_id?: string;
|
|
518
|
+
binding?: string;
|
|
519
|
+
} | null | undefined>;
|
|
520
|
+
hyperdrive?: ReadonlyArray<{
|
|
521
|
+
binding?: string;
|
|
522
|
+
id?: string;
|
|
523
|
+
localConnectionString?: string;
|
|
524
|
+
} | null | undefined>;
|
|
525
|
+
images?: {
|
|
526
|
+
binding?: string;
|
|
527
|
+
};
|
|
528
|
+
kv_namespaces?: ReadonlyArray<{
|
|
529
|
+
binding?: string;
|
|
530
|
+
id?: string;
|
|
531
|
+
} | null | undefined>;
|
|
532
|
+
logpush?: boolean;
|
|
533
|
+
migrations?: ReadonlyArray<{
|
|
534
|
+
new_classes?: ReadonlyArray<string>;
|
|
535
|
+
new_sqlite_classes?: ReadonlyArray<string>;
|
|
536
|
+
} | null | undefined>;
|
|
537
|
+
mtls_certificates?: ReadonlyArray<{
|
|
538
|
+
binding?: string;
|
|
539
|
+
certificate_id?: string;
|
|
540
|
+
} | null | undefined>;
|
|
541
|
+
observability?: {
|
|
542
|
+
enabled?: boolean;
|
|
543
|
+
head_sampling_rate?: number;
|
|
544
|
+
logs?: {
|
|
545
|
+
enabled?: boolean;
|
|
546
|
+
head_sampling_rate?: number;
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
pipelines?: ReadonlyArray<{
|
|
550
|
+
binding?: string;
|
|
551
|
+
pipeline?: string;
|
|
552
|
+
stream?: string;
|
|
553
|
+
} | null | undefined>;
|
|
554
|
+
placement?: {
|
|
555
|
+
mode?: string;
|
|
556
|
+
};
|
|
557
|
+
queues?: {
|
|
558
|
+
consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
|
|
559
|
+
producers?: ReadonlyArray<WranglerQueueProducer | null | undefined>;
|
|
560
|
+
};
|
|
561
|
+
r2_buckets?: ReadonlyArray<{
|
|
562
|
+
binding?: string;
|
|
563
|
+
}>;
|
|
564
|
+
secrets_store_secrets?: ReadonlyArray<{
|
|
565
|
+
binding?: string;
|
|
566
|
+
secret_name?: string;
|
|
567
|
+
store_id?: string;
|
|
568
|
+
} | null | undefined>;
|
|
569
|
+
send_email?: ReadonlyArray<{
|
|
570
|
+
allowed_destination_addresses?: ReadonlyArray<string>;
|
|
571
|
+
destination_address?: string;
|
|
572
|
+
name?: string;
|
|
573
|
+
} | null | undefined>;
|
|
574
|
+
services?: ReadonlyArray<{
|
|
575
|
+
binding?: string;
|
|
576
|
+
entrypoint?: string;
|
|
577
|
+
environment?: string;
|
|
578
|
+
service?: string;
|
|
579
|
+
} | null | undefined>;
|
|
580
|
+
tail_consumers?: ReadonlyArray<TailConsumer | null | undefined>;
|
|
581
|
+
vars?: Record<string, unknown>;
|
|
582
|
+
vectorize?: ReadonlyArray<{
|
|
583
|
+
binding?: string;
|
|
584
|
+
index_name?: string;
|
|
585
|
+
} | null | undefined>;
|
|
586
|
+
workflows?: ReadonlyArray<WranglerWorkflowEntry | null | undefined>;
|
|
587
|
+
}
|
|
588
|
+
interface WranglerValidationReport {
|
|
589
|
+
errors: string[];
|
|
590
|
+
valid: boolean;
|
|
591
|
+
warnings: string[];
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Return a new `WranglerConfig` with `consumer` present in `tail_consumers`,
|
|
595
|
+
* wiring this Worker to forward its tail events (logs/exceptions) to another
|
|
596
|
+
* Worker that fans them out to an external sink. Pure and idempotent: an
|
|
597
|
+
* existing entry with the same `service` + `environment` is left untouched
|
|
598
|
+
* rather than duplicated, so it is safe to call on every codegen/deploy.
|
|
599
|
+
*/
|
|
600
|
+
declare const withTailConsumer: (wrangler: WranglerConfig, consumer: TailConsumer) => WranglerConfig;
|
|
601
|
+
/**
|
|
602
|
+
* Pure validator: given a parsed `WranglerConfig` object and an optional
|
|
603
|
+
* `SchemaInfo`, produce a structured report. Performs no I/O.
|
|
604
|
+
*/
|
|
605
|
+
declare const validateWranglerConfig: (wrangler: WranglerConfig | undefined, schema?: SchemaInfo) => WranglerValidationReport;
|
|
606
|
+
/**
|
|
607
|
+
* Convenience alias matching the original task-spec signature
|
|
608
|
+
* `validateWrangler(wranglerJson, schema)` returning
|
|
609
|
+
* `{ valid, errors, warnings }`.
|
|
610
|
+
*/
|
|
611
|
+
declare const validateWrangler: typeof validateWranglerConfig;
|
|
612
|
+
interface WranglerProjectValidationOptions {
|
|
613
|
+
projectRoot: string;
|
|
614
|
+
schemaDir?: string;
|
|
615
|
+
}
|
|
616
|
+
interface WranglerProjectValidationResult {
|
|
617
|
+
problems: ReadonlyArray<string>;
|
|
618
|
+
report: WranglerValidationReport;
|
|
619
|
+
wranglerPath: string | undefined;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* File-system aware variant: reads `wrangler.jsonc`/`wrangler.json` from
|
|
623
|
+
* the given project root, discovers the schema (if any), and delegates to
|
|
624
|
+
* `validateWranglerConfig`. Returns the legacy
|
|
625
|
+
* `{ problems, wranglerPath }` shape plus the structured `report`.
|
|
626
|
+
*/
|
|
627
|
+
declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
|
|
628
|
+
export { type AlchemyTranslation, CLOUDFLARE_DRIVER, type ExportGap, type MaterializeOptions, type MaterializeResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type ReadWranglerResult, type ReconcileBindingsResult, type ReconcileCompatibilityDateResult, type ReconcileResult as ReconcileCronsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type TailConsumer, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, collectWranglerSecretVariables, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, readWranglerJsonc, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, wranglerToAlchemy };
|