@lunora/errors 1.0.0-alpha.3 → 1.0.0-alpha.30
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 -1
- package/dist/index.d.mts +789 -83
- package/dist/index.d.ts +789 -83
- package/dist/index.mjs +1 -5
- package/dist/packem_shared/CLOUDFLARE_PLATFORM_ERRORS-DGVs_zjo.mjs +15 -0
- package/dist/packem_shared/LunoraError-DFKtD_mx.mjs +1 -0
- package/dist/packem_shared/invariant-DWxFrL2o.mjs +1 -0
- package/dist/packem_shared/isLunoraError-kpNg-Mxd.mjs +1 -0
- package/dist/packem_shared/toErrorBody-zbeIbpi8.mjs +1 -0
- package/package.json +1 -1
- package/dist/packem_shared/ERROR_CATALOG-CoCPcAHf.mjs +0 -224
- package/dist/packem_shared/LunoraError-CwQSmeL3.mjs +0 -38
- package/dist/packem_shared/invariant-DawIQfjN.mjs +0 -12
- package/dist/packem_shared/isLunoraError-CSQtYMrF.mjs +0 -9
- package/dist/packem_shared/toErrorBody-CyqyVwGF.mjs +0 -26
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The central Lunora error catalog — the single source of truth mapping a
|
|
3
|
-
* machine-readable `code` to its transport `status`, a short human `title`, and
|
|
4
|
-
* (where useful) an actionable Markdown `hint` plus a `docsUrl`.
|
|
5
|
-
*
|
|
6
|
-
* This table is consumed everywhere an error is surfaced: the runtime/DO wire
|
|
7
|
-
* mappers (status), the client SDK (code discrimination), the CLI renderer and
|
|
8
|
-
* the Vite overlay (hint), and the Studio UI (title + hint + docs link). It also
|
|
9
|
-
* absorbs the former `@lunora/codegen` "solutions" table (see {@link MESSAGE_SOLUTIONS})
|
|
10
|
-
* so codegen build-time errors — which are thrown as plain messages into
|
|
11
|
-
* generated code and lose their class identity before a consumer sees them —
|
|
12
|
-
* keep their message-matched hints.
|
|
13
|
-
*/
|
|
14
1
|
/** Markdown hint: a single string or an array of lines. Shape matches `@visulima/error`'s `hint`. */
|
|
15
|
-
type ErrorHint = string | string
|
|
2
|
+
type ErrorHint = string | ReadonlyArray<string>;
|
|
16
3
|
/** A catalog entry: the fixed metadata for one error `code`. */
|
|
17
4
|
interface ErrorCatalogEntry {
|
|
18
5
|
/** Optional URL to deeper docs for this error. */
|
|
@@ -20,11 +7,11 @@ interface ErrorCatalogEntry {
|
|
|
20
7
|
/** Optional actionable fix, authored as Markdown (rendered by CLI/overlay/Studio). */
|
|
21
8
|
hint?: ErrorHint;
|
|
22
9
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
* When `true`, this code's `message` must NOT cross the wire — an internal
|
|
11
|
+
* failure or unhandled invariant may carry SQL fragments, file paths, or
|
|
12
|
+
* internal identifiers. The transport mappers emit a generic message for
|
|
13
|
+
* these (and log the real one server-side). See {@link isInternalCode}.
|
|
14
|
+
*/
|
|
28
15
|
internal?: boolean;
|
|
29
16
|
/** HTTP/RPC status this code maps to on the wire. */
|
|
30
17
|
status: number;
|
|
@@ -32,10 +19,10 @@ interface ErrorCatalogEntry {
|
|
|
32
19
|
title: string;
|
|
33
20
|
}
|
|
34
21
|
/**
|
|
35
|
-
* Every well-known Lunora error code. Domain packages may throw additional
|
|
36
|
-
* codes (passing an explicit `status`); those are added here as their package is
|
|
37
|
-
* migrated. The keys of this object form the {@link LunoraErrorCode} union.
|
|
38
|
-
*/
|
|
22
|
+
* Every well-known Lunora error code. Domain packages may throw additional
|
|
23
|
+
* codes (passing an explicit `status`); those are added here as their package is
|
|
24
|
+
* migrated. The keys of this object form the {@link LunoraErrorCode} union.
|
|
25
|
+
*/
|
|
39
26
|
declare const ERROR_CATALOG: {
|
|
40
27
|
readonly BAD_REQUEST: {
|
|
41
28
|
readonly status: 400;
|
|
@@ -78,7 +65,8 @@ declare const ERROR_CATALOG: {
|
|
|
78
65
|
readonly NOT_IMPLEMENTED: {
|
|
79
66
|
readonly status: 501;
|
|
80
67
|
readonly title: "Not implemented";
|
|
81
|
-
};
|
|
68
|
+
};
|
|
69
|
+
/** RPC/REST dispatch codes emitted by the runtime + Durable Object router. */
|
|
82
70
|
readonly FUNCTION_NOT_FOUND: {
|
|
83
71
|
readonly status: 404;
|
|
84
72
|
readonly title: "Function not found";
|
|
@@ -90,7 +78,8 @@ declare const ERROR_CATALOG: {
|
|
|
90
78
|
readonly PAYLOAD_TOO_LARGE: {
|
|
91
79
|
readonly status: 413;
|
|
92
80
|
readonly title: "Payload too large";
|
|
93
|
-
};
|
|
81
|
+
};
|
|
82
|
+
/** Free-form internal failure — redacted to a generic message on the wire. */
|
|
94
83
|
readonly INTERNAL: {
|
|
95
84
|
readonly internal: true;
|
|
96
85
|
readonly status: 500;
|
|
@@ -130,6 +119,24 @@ declare const ERROR_CATALOG: {
|
|
|
130
119
|
readonly status: 500;
|
|
131
120
|
readonly title: "Run depth exceeded";
|
|
132
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* A `query` context reached for `ctx.runMutation` / `ctx.runAction`. The
|
|
124
|
+
* generated context object installs all three `run*` methods on every kind, so
|
|
125
|
+
* the TYPE is the only thing that stops a read-only handler from writing — and
|
|
126
|
+
* a cast walks straight past it, inside a subscription re-run that may execute
|
|
127
|
+
* many times per write. Deliberately NOT `internal`: the message names the
|
|
128
|
+
* function that was reached for, and it is a programming error the developer
|
|
129
|
+
* needs to read.
|
|
130
|
+
*/
|
|
131
|
+
readonly RUN_KIND_FORBIDDEN: {
|
|
132
|
+
readonly status: 500;
|
|
133
|
+
readonly title: "Function kind may not be composed from a query";
|
|
134
|
+
};
|
|
135
|
+
readonly TRANSACTION_LIMIT_EXCEEDED: {
|
|
136
|
+
readonly hint: readonly ["A single mutation may only read and write a bounded amount before it is stopped.", "", "Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations — for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.", "", "The ceilings are deliberately conservative — they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."];
|
|
137
|
+
readonly status: 413;
|
|
138
|
+
readonly title: "Transaction limit exceeded";
|
|
139
|
+
};
|
|
133
140
|
readonly MIGRATION_NOT_FOUND: {
|
|
134
141
|
readonly status: 404;
|
|
135
142
|
readonly title: "Data migration not found";
|
|
@@ -150,10 +157,31 @@ declare const ERROR_CATALOG: {
|
|
|
150
157
|
readonly status: 503;
|
|
151
158
|
readonly title: "Shard unavailable";
|
|
152
159
|
};
|
|
160
|
+
/** A fan-out shard call exceeded the coordinator's per-shard deadline. */
|
|
161
|
+
readonly SHARD_TIMEOUT: {
|
|
162
|
+
readonly status: 504;
|
|
163
|
+
readonly title: "Shard timeout";
|
|
164
|
+
};
|
|
165
|
+
/** A fan-out shard call answered with a non-2xx status; the status is in the message, the body is not. */
|
|
166
|
+
readonly SHARD_HTTP_ERROR: {
|
|
167
|
+
readonly status: 502;
|
|
168
|
+
readonly title: "Shard HTTP error";
|
|
169
|
+
};
|
|
170
|
+
/** The shard could not write a subscription's attachment to storage, so the subscription was refused. */
|
|
171
|
+
readonly SUBSCRIPTION_PERSIST_FAILED: {
|
|
172
|
+
readonly status: 500;
|
|
173
|
+
readonly title: "Subscription persist failed";
|
|
174
|
+
};
|
|
175
|
+
/** A connection asked for more concurrent subscriptions than the shard allows. */
|
|
176
|
+
readonly TOO_MANY_SUBSCRIPTIONS: {
|
|
177
|
+
readonly status: 429;
|
|
178
|
+
readonly title: "Too many subscriptions";
|
|
179
|
+
};
|
|
153
180
|
readonly OFFLINE_IDENTITY_CHANGED: {
|
|
154
181
|
readonly status: 409;
|
|
155
182
|
readonly title: "Offline identity changed";
|
|
156
|
-
};
|
|
183
|
+
};
|
|
184
|
+
/** Package-specific codes. Build-time-only — never cross the RPC wire, so deliberately not `internal`. */
|
|
157
185
|
readonly CODEGEN_DIAGNOSTIC: {
|
|
158
186
|
readonly status: 500;
|
|
159
187
|
readonly title: "Codegen diagnostic";
|
|
@@ -176,11 +204,31 @@ declare const ERROR_CATALOG: {
|
|
|
176
204
|
readonly title: "Auth headers missing";
|
|
177
205
|
};
|
|
178
206
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
207
|
+
* Signup rejected by `@lunora/auth`'s email-domain gate — a disposable/throwaway
|
|
208
|
+
* provider (or a caller deny-list hit). Client-safe: the message names only the
|
|
209
|
+
* offending domain class, never a secret, so it is echoed rather than redacted.
|
|
210
|
+
*/
|
|
211
|
+
readonly EMAIL_DOMAIN_BLOCKED: {
|
|
212
|
+
readonly hint: readonly ["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).", "", "Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` to `emailGate(...)` (`@lunora/auth/email-guard`)."];
|
|
213
|
+
readonly status: 400;
|
|
214
|
+
readonly title: "Email domain not allowed";
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Opt-in MX verification (`@lunora/auth/email-guard`, `mx: true`) found no mail
|
|
218
|
+
* exchanger for the address's domain, so mail to it would never deliver.
|
|
219
|
+
* Client-safe: names only the domain, no secret.
|
|
220
|
+
*/
|
|
221
|
+
readonly EMAIL_UNDELIVERABLE: {
|
|
222
|
+
readonly hint: readonly ["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.", "", "Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS — leave it off on the edge path if DNS is unavailable."];
|
|
223
|
+
readonly status: 400;
|
|
224
|
+
readonly title: "Email domain cannot receive mail";
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Upstream Cloudflare API failures surfaced from an action. The message
|
|
228
|
+
* carries the upstream response body (Cloudflare's own error text — trusted
|
|
229
|
+
* infra, not user input), so it is echoed rather than redacted. `status`
|
|
230
|
+
* here is a fallback; each throw passes the actual upstream HTTP status.
|
|
231
|
+
*/
|
|
184
232
|
readonly ANALYTICS_SQL_ERROR: {
|
|
185
233
|
readonly status: 502;
|
|
186
234
|
readonly title: "Analytics Engine SQL API error";
|
|
@@ -193,25 +241,567 @@ declare const ERROR_CATALOG: {
|
|
|
193
241
|
readonly status: 502;
|
|
194
242
|
readonly title: "Cloudflare Workflows REST API error";
|
|
195
243
|
};
|
|
244
|
+
/**
|
|
245
|
+
* Admin-gated `/_lunora/admin/*` and `__lunora_admin__:*` codes. Registered
|
|
246
|
+
* here (plan 230, ERRORS-01) after an audit found them minted with `code:`
|
|
247
|
+
* but never added to the catalog — `isInternalCode` fails OPEN for an
|
|
248
|
+
* unregistered code, so each was already echoing its message unredacted.
|
|
249
|
+
* Below is that audit's verdict per code, not a blanket allow: most of these
|
|
250
|
+
* are deliberately actionable ("you forgot to configure X") and stay
|
|
251
|
+
* client-safe; the ones that can carry backend detail are flagged
|
|
252
|
+
* `internal: true` individually, with the reason noted alongside.
|
|
253
|
+
*/
|
|
254
|
+
readonly ADMIN_FORBIDDEN: {
|
|
255
|
+
readonly status: 403;
|
|
256
|
+
readonly title: "Admin access forbidden";
|
|
257
|
+
};
|
|
258
|
+
readonly ADMIN_TOKEN_NOT_CONFIGURED: {
|
|
259
|
+
readonly status: 400;
|
|
260
|
+
readonly title: "Admin token not configured";
|
|
261
|
+
};
|
|
262
|
+
readonly AUTH_NOT_CONFIGURED: {
|
|
263
|
+
readonly status: 400;
|
|
264
|
+
readonly title: "Auth admin not configured";
|
|
265
|
+
};
|
|
266
|
+
readonly AUTH_OP_NOT_SUPPORTED: {
|
|
267
|
+
readonly status: 400;
|
|
268
|
+
readonly title: "Auth admin operation not supported";
|
|
269
|
+
};
|
|
270
|
+
readonly BACKUP_NOT_CONFIGURED: {
|
|
271
|
+
readonly status: 500;
|
|
272
|
+
readonly title: "Scheduled backup not configured";
|
|
273
|
+
};
|
|
274
|
+
readonly BACKUP_RETENTION_NOT_CONFIGURED: {
|
|
275
|
+
readonly hint: readonly ["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.", "", "Nothing was deleted. A default is deliberately not invented here — retention deleting on its own is exactly what this command exists to replace."];
|
|
276
|
+
readonly status: 400;
|
|
277
|
+
readonly title: "Backup retention window not configured";
|
|
278
|
+
};
|
|
279
|
+
readonly BACKUP_TOO_LARGE: {
|
|
280
|
+
readonly hint: readonly ["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.", "", "The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.", "", "Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help — every run is a full snapshot."];
|
|
281
|
+
readonly status: 507;
|
|
282
|
+
readonly title: "Backup too large to assemble in a Worker";
|
|
283
|
+
};
|
|
284
|
+
readonly CRON_JOBS_NOT_CONFIGURED: {
|
|
285
|
+
readonly status: 400;
|
|
286
|
+
readonly title: "Cron jobs not configured";
|
|
287
|
+
};
|
|
288
|
+
readonly CRON_JOB_NOT_FOUND: {
|
|
289
|
+
readonly status: 404;
|
|
290
|
+
readonly title: "Cron job not found";
|
|
291
|
+
};
|
|
292
|
+
readonly EXPORT_TAP_NOT_CONFIGURED: {
|
|
293
|
+
readonly status: 400;
|
|
294
|
+
readonly title: "Export tap not configured";
|
|
295
|
+
};
|
|
296
|
+
readonly FUNCTIONS_NOT_CONFIGURED: {
|
|
297
|
+
readonly status: 400;
|
|
298
|
+
readonly title: "Functions registry not configured";
|
|
299
|
+
};
|
|
300
|
+
readonly GLOBALS_NOT_CONFIGURED: {
|
|
301
|
+
readonly status: 400;
|
|
302
|
+
readonly title: "Global-table introspector not configured";
|
|
303
|
+
};
|
|
304
|
+
readonly KV_NOT_CONFIGURED: {
|
|
305
|
+
readonly status: 400;
|
|
306
|
+
readonly title: "KV introspector not configured";
|
|
307
|
+
};
|
|
308
|
+
readonly MIGRATION_ID_REQUIRED: {
|
|
309
|
+
readonly status: 400;
|
|
310
|
+
readonly title: "Migration id required";
|
|
311
|
+
};
|
|
312
|
+
readonly PITR_UNAVAILABLE: {
|
|
313
|
+
readonly status: 409;
|
|
314
|
+
readonly title: "Point-in-time recovery unavailable";
|
|
315
|
+
};
|
|
316
|
+
readonly SCHEDULER_NOT_CONFIGURED: {
|
|
317
|
+
readonly status: 400;
|
|
318
|
+
readonly title: "Scheduler not configured";
|
|
319
|
+
};
|
|
320
|
+
readonly STORAGE_CHECKSUM_MISMATCH: {
|
|
321
|
+
readonly hint: readonly ["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written — this check fails closed.", "", "Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."];
|
|
322
|
+
readonly status: 400;
|
|
323
|
+
readonly title: "Storage checksum mismatch";
|
|
324
|
+
};
|
|
325
|
+
readonly STORAGE_DELETE_NOT_CONFIGURED: {
|
|
326
|
+
readonly status: 400;
|
|
327
|
+
readonly title: "Storage delete not configured";
|
|
328
|
+
};
|
|
329
|
+
readonly STORAGE_DOWNLOAD_NOT_CONFIGURED: {
|
|
330
|
+
readonly hint: readonly ["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` — forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.", "", "Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."];
|
|
331
|
+
readonly status: 400;
|
|
332
|
+
readonly title: "Storage download not configured";
|
|
333
|
+
};
|
|
334
|
+
readonly STORAGE_NOT_CONFIGURED: {
|
|
335
|
+
readonly status: 400;
|
|
336
|
+
readonly title: "Storage not configured";
|
|
337
|
+
};
|
|
338
|
+
readonly STORAGE_OBJECT_NOT_FOUND: {
|
|
339
|
+
readonly status: 404;
|
|
340
|
+
readonly title: "Storage object not found";
|
|
341
|
+
};
|
|
342
|
+
readonly STORAGE_UPLOAD_NOT_CONFIGURED: {
|
|
343
|
+
readonly status: 400;
|
|
344
|
+
readonly title: "Storage upload not configured";
|
|
345
|
+
};
|
|
346
|
+
readonly STORAGE_URL_NOT_CONFIGURED: {
|
|
347
|
+
readonly status: 400;
|
|
348
|
+
readonly title: "Storage signed URL not configured";
|
|
349
|
+
};
|
|
350
|
+
readonly RAG_DIMENSION_MISMATCH: {
|
|
351
|
+
readonly hint: readonly ["A stored vector and the query embedding have different widths, so they cannot be compared.", "", "This is what changing a RAG index's `embeddingModel` (or a provider's `dimensions` option) without reindexing looks like. Either put the previous model back, or reindex the namespace under the new one — bump `embeddingModelVersion` so the index rebuilds instead of mixing widths."];
|
|
352
|
+
readonly status: 409;
|
|
353
|
+
readonly title: "Embedding dimension mismatch";
|
|
354
|
+
};
|
|
355
|
+
readonly VECTORS_NOT_CONFIGURED: {
|
|
356
|
+
readonly status: 400;
|
|
357
|
+
readonly title: "Vector index introspector not configured";
|
|
358
|
+
};
|
|
359
|
+
readonly VECTOR_QUERY_UNSUPPORTED: {
|
|
360
|
+
readonly status: 400;
|
|
361
|
+
readonly title: "Vector index querying not enabled";
|
|
362
|
+
};
|
|
363
|
+
readonly WORKFLOWS_NOT_CONFIGURED: {
|
|
364
|
+
readonly status: 501;
|
|
365
|
+
readonly title: "Workflows not configured";
|
|
366
|
+
};
|
|
367
|
+
/** The auth/security audit read plane (`__lunora_admin__:getAuthAuditLog`). */
|
|
368
|
+
readonly AUTH_AUDIT_NOT_CONFIGURED: {
|
|
369
|
+
readonly status: 400;
|
|
370
|
+
readonly title: "Auth audit reader not configured";
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* Backend/DB failure reading the auth audit store. The throw site already
|
|
374
|
+
* keeps the message generic and logs the real error server-side only — flagged
|
|
375
|
+
* `internal: true` anyway as the deliberate posture for "a backend read
|
|
376
|
+
* failed", so a future edit that inlines the driver error can't leak it.
|
|
377
|
+
*/
|
|
378
|
+
readonly AUTH_AUDIT_READ_FAILED: {
|
|
379
|
+
readonly internal: true;
|
|
380
|
+
readonly status: 500;
|
|
381
|
+
readonly title: "Auth audit read failed";
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Cron-job codes. The `*_NOT_STATIC` / `_INVALID` family are codegen
|
|
385
|
+
* build-time diagnostics — like `CODEGEN_DIAGNOSTIC`, they're thrown as plain
|
|
386
|
+
* messages into the CLI/Vite-overlay output, never cross the RPC wire, and are
|
|
387
|
+
* deliberately not `internal` (the message IS the fix). `CRON_JOB_FAILED` is
|
|
388
|
+
* the one runtime-reachable code in this family — its message interpolates
|
|
389
|
+
* binding/function/job names from the deployment, so it is flagged internal.
|
|
390
|
+
*/
|
|
391
|
+
readonly CRON_EXPR_INVALID: {
|
|
392
|
+
readonly status: 500;
|
|
393
|
+
readonly title: "Invalid cron expression";
|
|
394
|
+
};
|
|
395
|
+
readonly CRON_EXPR_NOT_STATIC: {
|
|
396
|
+
readonly status: 500;
|
|
397
|
+
readonly title: "Cron expression is not statically analyzable";
|
|
398
|
+
};
|
|
399
|
+
readonly CRON_JOB_FAILED: {
|
|
400
|
+
readonly internal: true;
|
|
401
|
+
readonly status: 500;
|
|
402
|
+
readonly title: "Cron job failed";
|
|
403
|
+
};
|
|
404
|
+
readonly CRON_NAME_NOT_STATIC: {
|
|
405
|
+
readonly status: 500;
|
|
406
|
+
readonly title: "Cron job name is not statically analyzable";
|
|
407
|
+
};
|
|
408
|
+
readonly CRON_NON_STATIC_FN: {
|
|
409
|
+
readonly status: 500;
|
|
410
|
+
readonly title: "Cron function reference is not statically analyzable";
|
|
411
|
+
};
|
|
412
|
+
readonly CRON_NON_STATIC_VALUE: {
|
|
413
|
+
readonly status: 500;
|
|
414
|
+
readonly title: "Cron value is not statically analyzable";
|
|
415
|
+
};
|
|
416
|
+
readonly CRON_SCHEDULE_INVALID: {
|
|
417
|
+
readonly status: 500;
|
|
418
|
+
readonly title: "Invalid cron schedule";
|
|
419
|
+
};
|
|
420
|
+
readonly CRON_SCHEDULE_NOT_STATIC: {
|
|
421
|
+
readonly status: 500;
|
|
422
|
+
readonly title: "Cron schedule is not statically analyzable";
|
|
423
|
+
};
|
|
424
|
+
readonly DUPLICATE_CRON_NAME: {
|
|
425
|
+
readonly status: 500;
|
|
426
|
+
readonly title: "Duplicate cron job name";
|
|
427
|
+
};
|
|
428
|
+
/** More codegen build-time diagnostics — see the cron-family comment above; same reasoning applies. */
|
|
429
|
+
readonly DUPLICATE_AGENT_BINDING: {
|
|
430
|
+
readonly status: 500;
|
|
431
|
+
readonly title: "Duplicate agent binding";
|
|
432
|
+
};
|
|
433
|
+
readonly DUPLICATE_AGENT_CLASS: {
|
|
434
|
+
readonly status: 500;
|
|
435
|
+
readonly title: "Duplicate agent generated class name";
|
|
436
|
+
};
|
|
437
|
+
readonly DUPLICATE_AGENT_NAME: {
|
|
438
|
+
readonly status: 500;
|
|
439
|
+
readonly title: "Duplicate agent name";
|
|
440
|
+
};
|
|
441
|
+
readonly DUPLICATE_MIGRATION_ID: {
|
|
442
|
+
readonly status: 500;
|
|
443
|
+
readonly title: "Duplicate migration id";
|
|
444
|
+
};
|
|
445
|
+
readonly DUPLICATE_QUEUE_BINDING: {
|
|
446
|
+
readonly status: 500;
|
|
447
|
+
readonly title: "Duplicate queue binding";
|
|
448
|
+
};
|
|
449
|
+
readonly DUPLICATE_QUEUE_NAME: {
|
|
450
|
+
readonly status: 500;
|
|
451
|
+
readonly title: "Duplicate queue name";
|
|
452
|
+
};
|
|
453
|
+
readonly DUPLICATE_WORKFLOW_CLASS: {
|
|
454
|
+
readonly status: 500;
|
|
455
|
+
readonly title: "Duplicate workflow generated class name";
|
|
456
|
+
};
|
|
457
|
+
readonly MIGRATION_ID_NOT_STATIC: {
|
|
458
|
+
readonly status: 500;
|
|
459
|
+
readonly title: "Migration id is not statically analyzable";
|
|
460
|
+
};
|
|
461
|
+
readonly NAMESPACE_COLLISION: {
|
|
462
|
+
readonly status: 500;
|
|
463
|
+
readonly title: "Function namespace collision";
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* `@lunora/runtime`'s dispatch/security-boundary codes — RPC/HTTP entry, not
|
|
467
|
+
* admin-gated. Fixed, non-sensitive messages throughout, so none are `internal`.
|
|
468
|
+
*/
|
|
469
|
+
readonly BAD_ROW: {
|
|
470
|
+
readonly status: 400;
|
|
471
|
+
readonly title: "Malformed import row";
|
|
472
|
+
};
|
|
473
|
+
readonly BAD_SUBSCRIPTION_ARGS: {
|
|
474
|
+
readonly status: 400;
|
|
475
|
+
readonly title: "Invalid subscription arguments";
|
|
476
|
+
};
|
|
477
|
+
readonly BATCH_LIMIT_EXCEEDED: {
|
|
478
|
+
readonly status: 400;
|
|
479
|
+
readonly title: "Batch limit exceeded";
|
|
480
|
+
};
|
|
481
|
+
readonly CROSS_SHARD_RANK_UNSUPPORTED: {
|
|
482
|
+
readonly status: 400;
|
|
483
|
+
readonly title: "Cross-shard rank() is unsupported";
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* The `/_lunora/scheduler/dispatch` entry rejected the request's own
|
|
487
|
+
* signature/bearer — a worker/scheduler MISCONFIGURATION (missing, wrong, or
|
|
488
|
+
* rotated `LUNORA_SCHEDULER_SECRET` / `LUNORA_ADMIN_TOKEN`), not a verdict on
|
|
489
|
+
* the function being dispatched. Distinct from `FORBIDDEN`/`FORBIDDEN_SHARD`
|
|
490
|
+
* because dispatch consumers classify a 403 as deterministic and stop
|
|
491
|
+
* retrying: an auth failure clears the moment the secret is fixed, so it must
|
|
492
|
+
* stay retryable or every queued message drains into the void while the
|
|
493
|
+
* credential is wrong. See `isDeterministicDispatchFailure` in
|
|
494
|
+
* `@lunora/dispatch`.
|
|
495
|
+
*/
|
|
496
|
+
readonly DISPATCH_UNAUTHENTICATED: {
|
|
497
|
+
readonly hint: "The scheduler could not authenticate to the worker. Check that `LUNORA_SCHEDULER_SECRET` matches on both sides, or that `LUNORA_ADMIN_TOKEN` is set and current.";
|
|
498
|
+
readonly status: 403;
|
|
499
|
+
readonly title: "Dispatch caller not authenticated";
|
|
500
|
+
};
|
|
501
|
+
readonly FORBIDDEN_FANOUT: {
|
|
502
|
+
readonly status: 403;
|
|
503
|
+
readonly title: "Fan-out forbidden";
|
|
504
|
+
};
|
|
505
|
+
readonly GLOBAL_SEARCH_SCORES_UNSUPPORTED: {
|
|
506
|
+
readonly status: 400;
|
|
507
|
+
readonly title: "collectWithScores() is unsupported on a global table";
|
|
508
|
+
};
|
|
509
|
+
readonly FORBIDDEN_ORIGIN: {
|
|
510
|
+
readonly status: 403;
|
|
511
|
+
readonly title: "Origin forbidden";
|
|
512
|
+
};
|
|
513
|
+
readonly FORBIDDEN_SHARD: {
|
|
514
|
+
readonly status: 403;
|
|
515
|
+
readonly title: "Shard access forbidden";
|
|
516
|
+
};
|
|
517
|
+
readonly GLOBAL_NOT_CONFIGURED: {
|
|
518
|
+
readonly status: 400;
|
|
519
|
+
readonly title: "Global table import not configured";
|
|
520
|
+
};
|
|
521
|
+
readonly INVALID_INPUT: {
|
|
522
|
+
readonly status: 400;
|
|
523
|
+
readonly title: "Invalid input";
|
|
524
|
+
};
|
|
525
|
+
readonly RATE_LIMITED: {
|
|
526
|
+
readonly status: 429;
|
|
527
|
+
readonly title: "Rate limited";
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* A read replica could not answer at the freshness the caller required. `421`
|
|
531
|
+
* rather than an error class: it is a ROUTING verdict the runtime turns into
|
|
532
|
+
* one retry against the owner, and a caller never sees it.
|
|
533
|
+
*/
|
|
534
|
+
readonly REPLICA_NOT_READY: {
|
|
535
|
+
readonly status: 421;
|
|
536
|
+
readonly title: "Replica not caught up";
|
|
537
|
+
};
|
|
538
|
+
/** A write reached a read replica. Same `421` routing verdict — writes belong to the owner. */
|
|
539
|
+
readonly REPLICA_READ_ONLY: {
|
|
540
|
+
readonly status: 421;
|
|
541
|
+
readonly title: "Replica is read-only";
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* A search index is provisioned but still covers only part of its table, so
|
|
545
|
+
* the read refuses rather than answering from the indexed prefix.
|
|
546
|
+
*
|
|
547
|
+
* `503` and retryable, but deliberately NOT `SERVICE_UNAVAILABLE`: nothing is
|
|
548
|
+
* down. One index on one table is warming, every other read is fine, and the
|
|
549
|
+
* backfill advances on each read — so a caller that retries makes progress,
|
|
550
|
+
* where a generic outage code invites it to back off. The message names both
|
|
551
|
+
* exits (wait, or run the `backfillSearch` admin op).
|
|
552
|
+
*/
|
|
553
|
+
readonly SEARCH_INDEX_BUILDING: {
|
|
554
|
+
readonly status: 503;
|
|
555
|
+
readonly title: "Search index is still building";
|
|
556
|
+
};
|
|
557
|
+
/** Thrown by `@lunora/auth` (Turnstile) and `@lunora/ratelimit` — an upstream dependency didn't respond. Fixed, safe message. */
|
|
558
|
+
readonly SERVICE_UNAVAILABLE: {
|
|
559
|
+
readonly status: 503;
|
|
560
|
+
readonly title: "Service unavailable";
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* A shape was declared over, or whose predicate joins, a `.memory()` table. Refused at subscribe, because
|
|
564
|
+
* the poke path replicates from `__cdc_log` and a memory table is deliberately
|
|
565
|
+
* never appended to it — so the shape would seed once and then stay frozen
|
|
566
|
+
* while the table changed underneath it. Same registration-time refusal as
|
|
567
|
+
* `SHAPE_CROSS_SHARD_JOIN`, for the same reason: the diff can never move.
|
|
568
|
+
*/
|
|
569
|
+
readonly SHAPE_MEMORY_TABLE: {
|
|
570
|
+
readonly status: 400;
|
|
571
|
+
readonly title: "Shape over a memory table is unsupported";
|
|
572
|
+
};
|
|
573
|
+
readonly SHAPE_CROSS_SHARD_JOIN: {
|
|
574
|
+
readonly status: 400;
|
|
575
|
+
readonly title: "Shape cross-shard join is unsupported";
|
|
576
|
+
};
|
|
577
|
+
readonly UNAUTHENTICATED: {
|
|
578
|
+
readonly status: 401;
|
|
579
|
+
readonly title: "Unauthenticated";
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* The client could not decode a frame the server sent for a subscription.
|
|
583
|
+
*
|
|
584
|
+
* `502` because the failure is upstream of the caller: their query was valid
|
|
585
|
+
* and the payload that came back was not readable. Delivered to the
|
|
586
|
+
* subscription's `onError` rather than thrown, so one bad frame cannot escape
|
|
587
|
+
* the socket listener and abort every other subscription on the connection —
|
|
588
|
+
* which is what it did before, while the status indicator still read
|
|
589
|
+
* `connected` and the cursor silently stopped advancing.
|
|
590
|
+
*/
|
|
591
|
+
readonly WIRE_DECODE_FAILED: {
|
|
592
|
+
readonly status: 502;
|
|
593
|
+
readonly title: "Could not decode a server frame";
|
|
594
|
+
};
|
|
595
|
+
readonly UNKNOWN_COLUMN: {
|
|
596
|
+
readonly status: 404;
|
|
597
|
+
readonly title: "Unknown column";
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* `@lunora/do`'s ShardDO — WebSocket-frame codes, changelog-retention refusals
|
|
601
|
+
* and SQLite-in-DO invariants.
|
|
602
|
+
*
|
|
603
|
+
* `NESTED_TRANSACTION` and `SQL_UNAVAILABLE` are "should never happen" state
|
|
604
|
+
* invariants (mirrors `RUN_DEPTH_EXCEEDED`'s posture above): today's message
|
|
605
|
+
* is static and safe, but flagged internal so a future edit that adds
|
|
606
|
+
* diagnostic detail can't accidentally start leaking it. The two `CDC_*`
|
|
607
|
+
* codes are the opposite — ordinary, expected, operator-configured outcomes
|
|
608
|
+
* — and both are `409` because the cursor the caller holds is real but no
|
|
609
|
+
* longer serveable, so the recovery is a snapshot rather than a retry.
|
|
610
|
+
*/
|
|
611
|
+
/** A resume below the deleted changelog prefix: the entries are gone outright, for every consumer. */
|
|
612
|
+
readonly CDC_LOG_TRIMMED: {
|
|
613
|
+
readonly status: 409;
|
|
614
|
+
readonly title: "CDC log trimmed";
|
|
615
|
+
};
|
|
616
|
+
/** A resume below the compacted prefix: the keys survive but their post-images do not, so only a payload consumer (streaming export, replay-PITR, a read replica) is refused. */
|
|
617
|
+
readonly CDC_PAYLOAD_COMPACTED: {
|
|
618
|
+
readonly status: 409;
|
|
619
|
+
readonly title: "CDC payloads compacted";
|
|
620
|
+
};
|
|
621
|
+
readonly EXPIRED: {
|
|
622
|
+
readonly status: 404;
|
|
623
|
+
readonly title: "Session expired";
|
|
624
|
+
};
|
|
625
|
+
readonly NESTED_TRANSACTION: {
|
|
626
|
+
readonly internal: true;
|
|
627
|
+
readonly status: 500;
|
|
628
|
+
readonly title: "Nested transaction";
|
|
629
|
+
};
|
|
630
|
+
readonly OUT_OF_ORDER: {
|
|
631
|
+
readonly status: 409;
|
|
632
|
+
readonly title: "Out-of-order mutation";
|
|
633
|
+
};
|
|
634
|
+
readonly SHAPE_GLOBAL_TOO_LARGE: {
|
|
635
|
+
readonly status: 413;
|
|
636
|
+
readonly title: "Global shape too large";
|
|
637
|
+
};
|
|
638
|
+
readonly SHAPE_NOT_FOUND: {
|
|
639
|
+
readonly status: 404;
|
|
640
|
+
readonly title: "Shape not found";
|
|
641
|
+
};
|
|
642
|
+
readonly SHAPE_REQUIRES_CDC: {
|
|
643
|
+
readonly status: 409;
|
|
644
|
+
readonly title: "Shape requires change-data-capture";
|
|
645
|
+
};
|
|
646
|
+
readonly SQL_UNAVAILABLE: {
|
|
647
|
+
readonly internal: true;
|
|
648
|
+
readonly status: 500;
|
|
649
|
+
readonly title: "SQL storage unavailable";
|
|
650
|
+
};
|
|
651
|
+
readonly STREAM_INTERRUPTED: {
|
|
652
|
+
readonly status: 503;
|
|
653
|
+
readonly title: "Durable stream interrupted";
|
|
654
|
+
};
|
|
655
|
+
readonly STREAM_TOO_LONG: {
|
|
656
|
+
readonly status: 507;
|
|
657
|
+
readonly title: "Durable stream exceeded its chunk ceiling";
|
|
658
|
+
};
|
|
659
|
+
readonly TOKEN_EXPIRED: {
|
|
660
|
+
readonly status: 401;
|
|
661
|
+
readonly title: "Authentication token expired";
|
|
662
|
+
};
|
|
663
|
+
readonly TOO_MANY_STREAMS: {
|
|
664
|
+
readonly status: 429;
|
|
665
|
+
readonly title: "Too many streams";
|
|
666
|
+
};
|
|
667
|
+
readonly UNKNOWN_ADMIN_OP: {
|
|
668
|
+
readonly status: 404;
|
|
669
|
+
readonly title: "Unknown admin operation";
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* `@lunora/platform-cloudflare`'s `SocketHost.accept` guard — a caller
|
|
673
|
+
* supplied more accept-time tags (or a longer tag) than Cloudflare's
|
|
674
|
+
* `acceptWebSocket` budget allows once the host's own identity tag is
|
|
675
|
+
* reserved. Caller-actionable and safe (names counts, not internals) —
|
|
676
|
+
* not `internal`.
|
|
677
|
+
*/
|
|
678
|
+
readonly SOCKET_TAG_BUDGET_EXCEEDED: {
|
|
679
|
+
readonly status: 400;
|
|
680
|
+
readonly title: "Socket tag budget exceeded";
|
|
681
|
+
};
|
|
682
|
+
/**
|
|
683
|
+
* `@lunora/shard-engine`'s relay hub (cross-shard shape relay coordination).
|
|
684
|
+
* Mirrors `SHARD_ERROR`/`SHARD_UNAVAILABLE` above: operational status for an
|
|
685
|
+
* app's own relay topology, not a secret — not `internal`.
|
|
686
|
+
*/
|
|
687
|
+
readonly RELAY_CANNOT_SEED: {
|
|
688
|
+
readonly status: 500;
|
|
689
|
+
readonly title: "Relay cannot seed";
|
|
690
|
+
};
|
|
691
|
+
readonly RELAY_MISCONFIGURED: {
|
|
692
|
+
readonly status: 500;
|
|
693
|
+
readonly title: "Relay misconfigured";
|
|
694
|
+
};
|
|
695
|
+
readonly RELAY_SEED_FAILED: {
|
|
696
|
+
readonly status: 502;
|
|
697
|
+
readonly title: "Relay seed failed";
|
|
698
|
+
};
|
|
699
|
+
readonly RELAY_SHAPE_UNROUTABLE: {
|
|
700
|
+
readonly status: 500;
|
|
701
|
+
readonly title: "Relay shape unroutable";
|
|
702
|
+
};
|
|
703
|
+
/**
|
|
704
|
+
* A worker option required by the request path is absent (a deploy-config
|
|
705
|
+
* gap, not a caller error) — the fixed message names the missing option, so
|
|
706
|
+
* it's actionable and echoed. `MISCONFIGURED` is the one exception: its
|
|
707
|
+
* message interpolates the caller-supplied `functionPath`, and it's the code
|
|
708
|
+
* this plan's audit found live-leaking (`create-worker.ts`'s x402 gate).
|
|
709
|
+
*/
|
|
710
|
+
readonly MISCONFIGURED: {
|
|
711
|
+
readonly internal: true;
|
|
712
|
+
readonly status: 500;
|
|
713
|
+
readonly title: "Worker misconfigured";
|
|
714
|
+
};
|
|
715
|
+
/** `@lunora/nuxt`'s Nitro bridge: the request carried no Cloudflare bindings. Fixed, safe message. */
|
|
716
|
+
readonly LUNORA_RUNTIME_UNAVAILABLE: {
|
|
717
|
+
readonly status: 500;
|
|
718
|
+
readonly title: "Lunora runtime unavailable";
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* `@lunora/replica`'s event-log Durable Object: generic request-handler
|
|
722
|
+
* catch-all, mirroring `INTERNAL`/`INTERNAL_SERVER_ERROR`/`RPC_FAILED` above
|
|
723
|
+
* — the real error is logged server-side only, never in this code's message.
|
|
724
|
+
*/
|
|
725
|
+
readonly INTERNAL_ERROR: {
|
|
726
|
+
readonly internal: true;
|
|
727
|
+
readonly status: 500;
|
|
728
|
+
readonly title: "Internal error";
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* Client-SDK-only codes (`@lunora/client`), thrown locally in the browser/app
|
|
732
|
+
* process rather than by the server — `internal`'s wire-redaction semantics
|
|
733
|
+
* don't apply the same way here, since the "wire" is the app's own code
|
|
734
|
+
* catching its own client's exception. Kept in the catalog for the client's
|
|
735
|
+
* `code`-discrimination union and Studio/CLI rendering consistency.
|
|
736
|
+
*/
|
|
737
|
+
readonly BROWSER_TIMEOUT: {
|
|
738
|
+
readonly status: 504;
|
|
739
|
+
readonly title: "Browser operation timed out";
|
|
740
|
+
};
|
|
741
|
+
readonly CLIENT_CLOSED: {
|
|
742
|
+
readonly status: 400;
|
|
743
|
+
readonly title: "Client is closed";
|
|
744
|
+
};
|
|
745
|
+
readonly HTTP_STREAM_BAD_CHUNK: {
|
|
746
|
+
readonly status: 502;
|
|
747
|
+
readonly title: "Malformed HTTP stream chunk";
|
|
748
|
+
};
|
|
749
|
+
readonly HTTP_STREAM_INTERRUPTED: {
|
|
750
|
+
readonly status: 502;
|
|
751
|
+
readonly title: "HTTP stream interrupted";
|
|
752
|
+
};
|
|
753
|
+
readonly HTTP_STREAM_MISSING_PARAM: {
|
|
754
|
+
readonly status: 400;
|
|
755
|
+
readonly title: "HTTP stream missing path parameter";
|
|
756
|
+
};
|
|
757
|
+
readonly HTTP_STREAM_NO_BODY: {
|
|
758
|
+
readonly status: 502;
|
|
759
|
+
readonly title: "HTTP stream response has no body";
|
|
760
|
+
};
|
|
761
|
+
readonly HTTP_STREAM_STATUS: {
|
|
762
|
+
readonly status: 502;
|
|
763
|
+
readonly title: "HTTP stream request failed";
|
|
764
|
+
};
|
|
765
|
+
readonly HTTP_STREAM_TRANSPORT: {
|
|
766
|
+
readonly status: 502;
|
|
767
|
+
readonly title: "HTTP stream transport error";
|
|
768
|
+
};
|
|
769
|
+
readonly STREAM_BACKPRESSURE: {
|
|
770
|
+
readonly status: 429;
|
|
771
|
+
readonly title: "Stream backpressure";
|
|
772
|
+
};
|
|
773
|
+
readonly STREAM_DISCONNECTED: {
|
|
774
|
+
readonly status: 503;
|
|
775
|
+
readonly title: "Stream disconnected";
|
|
776
|
+
};
|
|
777
|
+
readonly STREAM_QUEUE_OVERFLOW: {
|
|
778
|
+
readonly status: 429;
|
|
779
|
+
readonly title: "Stream queue overflow";
|
|
780
|
+
};
|
|
781
|
+
/** `@lunora/db`'s offline outbox: a queued write targeted a collection removed/renamed in a later deploy. */
|
|
782
|
+
readonly UNKNOWN_MUTATION_FN: {
|
|
783
|
+
readonly status: 404;
|
|
784
|
+
readonly title: "Unknown mutation function";
|
|
785
|
+
};
|
|
196
786
|
};
|
|
197
787
|
/** A well-known Lunora error code (a key of {@link ERROR_CATALOG}). */
|
|
198
788
|
type LunoraErrorCode = keyof typeof ERROR_CATALOG;
|
|
199
789
|
/**
|
|
200
|
-
* True when `code` is an internal/redacted code — an internal failure or
|
|
201
|
-
* unhandled invariant whose `message` must NOT cross the wire (it may carry SQL
|
|
202
|
-
* fragments, file paths, or internal identifiers). Derived from the catalog's
|
|
203
|
-
* `internal` flag so the redaction posture stays in one place (the table).
|
|
204
|
-
* Throwing a `LunoraError` with any non-internal code is the author's vouch that
|
|
205
|
-
* its message is client-safe; an unknown/unregistered code is treated as safe.
|
|
206
|
-
*/
|
|
790
|
+
* True when `code` is an internal/redacted code — an internal failure or
|
|
791
|
+
* unhandled invariant whose `message` must NOT cross the wire (it may carry SQL
|
|
792
|
+
* fragments, file paths, or internal identifiers). Derived from the catalog's
|
|
793
|
+
* `internal` flag so the redaction posture stays in one place (the table).
|
|
794
|
+
* Throwing a `LunoraError` with any non-internal code is the author's vouch that
|
|
795
|
+
* its message is client-safe; an unknown/unregistered code is treated as safe.
|
|
796
|
+
*/
|
|
207
797
|
declare const isInternalCode: (code: string) => boolean;
|
|
208
798
|
/**
|
|
209
|
-
* A message-matched solution for errors that reach a consumer without a `code`
|
|
210
|
-
* — chiefly `@lunora/codegen` build errors, which are thrown as plain messages
|
|
211
|
-
* into generated code (and flattened to `{ message }` by the Vite overlay), so
|
|
212
|
-
* the message text is the only stable join key. Ordered most- to least-specific;
|
|
213
|
-
* the first matching rule wins.
|
|
214
|
-
*/
|
|
799
|
+
* A message-matched solution for errors that reach a consumer without a `code`
|
|
800
|
+
* — chiefly `@lunora/codegen` build errors, which are thrown as plain messages
|
|
801
|
+
* into generated code (and flattened to `{ message }` by the Vite overlay), so
|
|
802
|
+
* the message text is the only stable join key. Ordered most- to least-specific;
|
|
803
|
+
* the first matching rule wins.
|
|
804
|
+
*/
|
|
215
805
|
interface Solution {
|
|
216
806
|
/** Markdown body shown under the header. */
|
|
217
807
|
body: string;
|
|
@@ -226,27 +816,92 @@ interface SolutionRule extends Solution {
|
|
|
226
816
|
test: (message: string) => boolean;
|
|
227
817
|
}
|
|
228
818
|
/**
|
|
229
|
-
* Message-matched solutions (migrated verbatim from the former
|
|
230
|
-
* `@lunora/codegen` solutions table). Re-exported by `@lunora/codegen` as
|
|
231
|
-
* `LUNORA_SOLUTION_RULES` for backward compatibility.
|
|
232
|
-
*/
|
|
819
|
+
* Message-matched solutions (migrated verbatim from the former
|
|
820
|
+
* `@lunora/codegen` solutions table). Re-exported by `@lunora/codegen` as
|
|
821
|
+
* `LUNORA_SOLUTION_RULES` for backward compatibility.
|
|
822
|
+
*/
|
|
233
823
|
declare const MESSAGE_SOLUTIONS: ReadonlyArray<SolutionRule>;
|
|
234
824
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
|
|
825
|
+
* One documented Cloudflare **platform** error — an edge/origin (5xx) or
|
|
826
|
+
* Cloudflare-service (1xxx) failure surfaced in an error *message* rather than
|
|
827
|
+
* thrown by Lunora as a coded `LunoraError`. These reach a Lunora app as
|
|
828
|
+
* plain text: a Worker that fetches a Cloudflare-fronted origin sees `Error 522`,
|
|
829
|
+
* a deploy that throws surfaces as `Error 1101`, and so on. The fields are the
|
|
830
|
+
* curated facts a grounded explainer elaborates on — never invents beyond.
|
|
831
|
+
*/
|
|
832
|
+
interface CloudflarePlatformError {
|
|
833
|
+
/** Documented likely causes (a short, comma-joined clause). */
|
|
834
|
+
causes: string;
|
|
835
|
+
/** The numeric Cloudflare error code, as it appears in the message (e.g. `"522"`, `"1101"`). */
|
|
836
|
+
code: string;
|
|
837
|
+
/** Canonical Cloudflare support-docs URL for this error's family. */
|
|
838
|
+
docsUrl: string;
|
|
839
|
+
/** Which docs family the code belongs to — shown in the "see docs" line. */
|
|
840
|
+
family: "1xxx" | "5xx";
|
|
841
|
+
/** The documented remediation. */
|
|
842
|
+
fix: string;
|
|
843
|
+
/** One-line summary of what the code means. */
|
|
844
|
+
summary: string;
|
|
845
|
+
/** Cloudflare's short name for the code (e.g. `"Connection timed out"`). */
|
|
846
|
+
title: string;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* The curated Cloudflare platform-error table. Sourced from Cloudflare's official
|
|
850
|
+
* support docs — the codes surfaced to app authors on Workers/DO deployments (the
|
|
851
|
+
* origin-connection 52x family and the Worker/DNS/security 1xxx family). `1101`
|
|
852
|
+
* (a Worker threw) and `1102` (a Worker exceeded CPU) are the most Lunora-relevant.
|
|
853
|
+
*/
|
|
854
|
+
declare const CLOUDFLARE_PLATFORM_ERRORS: ReadonlyArray<CloudflarePlatformError>;
|
|
855
|
+
/**
|
|
856
|
+
* Recognize a Cloudflare platform-error {@link CloudflarePlatformError} in a raw
|
|
857
|
+
* error message, conservatively: the message must carry Cloudflare's own
|
|
858
|
+
* `Error <code>` phrasing, or mention `cloudflare` alongside the standalone
|
|
859
|
+
* code. That keeps a bare number (`expected 520 items`) from false-matching a 5xx
|
|
860
|
+
* code, at the cost of missing a context-free code — the safe trade for a
|
|
861
|
+
* grounded hint. Returns the matched code's {@link Solution}, or `undefined`.
|
|
862
|
+
*
|
|
863
|
+
* Matching runs in two passes, strongest first: Cloudflare's own `Error <code>`
|
|
864
|
+
* phrasing is unambiguous, so it must win over the weaker "mentions cloudflare
|
|
865
|
+
* near some number" heuristic regardless of table order. A single pass let a weak
|
|
866
|
+
* match on an earlier entry beat an explicit match on a later one — `"Cloudflare
|
|
867
|
+
* Error 1102: exceeded after 524 ms"` resolved to 524, and that wrong grounded
|
|
868
|
+
* fix is exactly what the explainer prompt is built from.
|
|
869
|
+
*/
|
|
870
|
+
declare const findCloudflarePlatformSolution: (message: string) => Solution | undefined;
|
|
871
|
+
/**
|
|
872
|
+
* Flatten a Markdown hint to plain text for a terminal / non-Markdown surface:
|
|
873
|
+
* drop code-fence markers and strip inline `**bold**` / `` `code` `` emphasis.
|
|
874
|
+
* Shared by the CLI renderer and the Studio `ErrorAlert` so the two can't drift.
|
|
875
|
+
*/
|
|
239
876
|
declare const flattenHint: (hint: ErrorHint) => string;
|
|
240
877
|
/**
|
|
241
|
-
* Find the first message-matched {@link Solution} for `message`, or `undefined`
|
|
242
|
-
* if none recognize it. Re-exported by `@lunora/codegen` as `findLunoraSolution`.
|
|
243
|
-
*/
|
|
878
|
+
* Find the first message-matched {@link Solution} for `message`, or `undefined`
|
|
879
|
+
* if none recognize it. Re-exported by `@lunora/codegen` as `findLunoraSolution`.
|
|
880
|
+
*/
|
|
244
881
|
declare const findSolutionByMessage: (message: string) => Solution | undefined;
|
|
245
882
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* `
|
|
249
|
-
|
|
883
|
+
* Find a solution for `message` across BOTH Lunora's own rules and the curated
|
|
884
|
+
* Cloudflare platform-error table — the lookup the Studio Issues panel and the
|
|
885
|
+
* `explainIssue` grounding use.
|
|
886
|
+
*
|
|
887
|
+
* Deliberately separate from {@link findSolutionByMessage} rather than folded into
|
|
888
|
+
* it. That function is on `resolveHint`, and therefore on `toErrorBody` — the
|
|
889
|
+
* envelope builder for every failed request. Most `ERROR_CATALOG` entries
|
|
890
|
+
* carry no `hint`, so folding the platform table in there meant an ordinary
|
|
891
|
+
* `BAD_REQUEST` whose message merely mentioned "cloudflare" near a number shipped
|
|
892
|
+
* zone-configuration guidance ("review the zone's Firewall/WAF and IP Access
|
|
893
|
+
* Rules") to unauthenticated browsers. The same fold put the table on the CLI
|
|
894
|
+
* renderer and the Vite overlay, and on `toErrorBody`'s hot path.
|
|
895
|
+
*
|
|
896
|
+
* Platform errors are operator-facing context for an already-persisted Issue, so
|
|
897
|
+
* the operator-facing surfaces opt in here and the wire path stays Lunora-only.
|
|
898
|
+
*/
|
|
899
|
+
declare const findIssueSolution: (message: string) => Solution | undefined;
|
|
900
|
+
/**
|
|
901
|
+
* Resolve an actionable hint for an error: prefer a hint carried on the error
|
|
902
|
+
* (or its `code`'s catalog entry), then fall back to a message match. Returns
|
|
903
|
+
* `undefined` when nothing recognizes it.
|
|
904
|
+
*/
|
|
250
905
|
declare const resolveHint: (input: {
|
|
251
906
|
code?: string;
|
|
252
907
|
hint?: ErrorHint;
|
|
@@ -278,16 +933,16 @@ interface LunoraErrorOptions {
|
|
|
278
933
|
title?: string;
|
|
279
934
|
}
|
|
280
935
|
/**
|
|
281
|
-
* A code string: a well-known {@link LunoraErrorCode} (with autocomplete) or any
|
|
282
|
-
* package-specific code not yet in the catalog.
|
|
283
|
-
*/
|
|
936
|
+
* A code string: a well-known {@link LunoraErrorCode} (with autocomplete) or any
|
|
937
|
+
* package-specific code not yet in the catalog.
|
|
938
|
+
*/
|
|
284
939
|
type LunoraErrorCodeInput = LunoraErrorCode | (string & {});
|
|
285
940
|
declare class LunoraError extends Error {
|
|
286
941
|
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
942
|
+
* Discriminator recognised by `@visulima/error`'s `renderError`/`isVisulimaError`
|
|
943
|
+
* (`error.type === "VisulimaError"`), so a `LunoraError` renders like a native
|
|
944
|
+
* `VisulimaError` — hint and all.
|
|
945
|
+
*/
|
|
291
946
|
readonly type = "VisulimaError";
|
|
292
947
|
/** Actionable fix (Markdown), rendered by the CLI/overlay/Studio. */
|
|
293
948
|
readonly hint: ErrorHint | undefined;
|
|
@@ -295,7 +950,7 @@ declare class LunoraError extends Error {
|
|
|
295
950
|
readonly title: string | undefined;
|
|
296
951
|
/** Source location, when known (mirrors `VisulimaError.loc`). */
|
|
297
952
|
readonly loc: ErrorLocation | undefined;
|
|
298
|
-
/** Machine-readable reason, keyed into
|
|
953
|
+
/** Machine-readable reason, keyed into `ERROR_CATALOG`. */
|
|
299
954
|
readonly code: string;
|
|
300
955
|
/** HTTP/RPC status for the transport mappers. */
|
|
301
956
|
readonly status: number;
|
|
@@ -316,16 +971,37 @@ interface LunoraErrorLike extends Error {
|
|
|
316
971
|
type: "VisulimaError";
|
|
317
972
|
}
|
|
318
973
|
/**
|
|
319
|
-
* True when `error` carries the Lunora transport shape (string `code` + numeric
|
|
320
|
-
* `status` + the `VisulimaError` brand). The `type` brand is what distinguishes
|
|
321
|
-
* a real `LunoraError` (or its wire-decoded twin) from a foreign error that
|
|
322
|
-
* happens to carry `code`/`status` — see plan 119 for the full rationale.
|
|
323
|
-
*/
|
|
974
|
+
* True when `error` carries the Lunora transport shape (string `code` + numeric
|
|
975
|
+
* `status` + the `VisulimaError` brand). The `type` brand is what distinguishes
|
|
976
|
+
* a real `LunoraError` (or its wire-decoded twin) from a foreign error that
|
|
977
|
+
* happens to carry `code`/`status` — see plan 119 for the full rationale.
|
|
978
|
+
*/
|
|
324
979
|
declare const isLunoraError: (error: unknown) => error is LunoraErrorLike;
|
|
325
980
|
/** Throw an `INTERNAL` {@link LunoraError} when `condition` is falsy. */
|
|
326
981
|
declare const invariant: (condition: unknown, message: string) => asserts condition;
|
|
327
982
|
/** Throw an `INTERNAL` {@link LunoraError} for an unreachable branch. */
|
|
328
983
|
declare const unreachable: (message: string) => never;
|
|
984
|
+
/**
|
|
985
|
+
* Throw a {@link LunoraError} from expression position.
|
|
986
|
+
*
|
|
987
|
+
* `throw` is a statement, so it cannot sit on the right of `??` or in a ternary
|
|
988
|
+
* arm — the two places a missing value is most naturally rejected. Unlike
|
|
989
|
+
* {@link invariant} and {@link unreachable}, which are pinned to `INTERNAL`, this
|
|
990
|
+
* takes the code, which is what a client-actionable failure needs.
|
|
991
|
+
*
|
|
992
|
+
* Any string is a valid `code`. A well-known `ERROR_CATALOG` key fills in the
|
|
993
|
+
* status, title and hint; a package-specific code with no catalog entry defaults
|
|
994
|
+
* to status 500 and no hint, so pass those in `options` instead.
|
|
995
|
+
* @param code machine-readable reason
|
|
996
|
+
* @param message human-readable detail; defaults to `code`
|
|
997
|
+
* @param options status/title/hint/data overrides
|
|
998
|
+
* @example
|
|
999
|
+
* ```ts
|
|
1000
|
+
* const thread = (await ctx.db.threads.get(id)) ?? raise("NOT_FOUND", `thread ${id}`);
|
|
1001
|
+
* // thread is non-nullable here
|
|
1002
|
+
* ```
|
|
1003
|
+
*/
|
|
1004
|
+
declare const raise: (code: LunoraErrorCodeInput, message?: string, options?: LunoraErrorOptions) => never;
|
|
329
1005
|
/** The client-facing error envelope body. */
|
|
330
1006
|
interface ErrorBody {
|
|
331
1007
|
code: string;
|
|
@@ -336,9 +1012,9 @@ interface ErrorBody {
|
|
|
336
1012
|
}
|
|
337
1013
|
interface ToErrorBodyOptions {
|
|
338
1014
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
1015
|
+
* Wire-encode a `LunoraError`'s structured `data` for the client (so a
|
|
1016
|
+
* `bigint`/`bytes` inside it survives). Omit to drop `data` from the body.
|
|
1017
|
+
*/
|
|
342
1018
|
encodeData?: (data: unknown) => unknown;
|
|
343
1019
|
/** Code for an unrecognized (non-`LunoraError`) throw. Default `"INTERNAL"`. */
|
|
344
1020
|
fallbackCode?: string;
|
|
@@ -353,12 +1029,42 @@ interface ToErrorBodyResult {
|
|
|
353
1029
|
status: number;
|
|
354
1030
|
}
|
|
355
1031
|
/**
|
|
356
|
-
* Turn a thrown value into an {@link ErrorBody} + status, applying the redaction
|
|
357
|
-
* invariant. A `LunoraError` with a non-internal code is echoed with its
|
|
358
|
-
* `message`, resolved `hint`, `docsUrl`, and (when `encodeData` is given) its
|
|
359
|
-
* `data`. An internal-coded `LunoraError` keeps its `code`/`status` but its
|
|
360
|
-
* message is replaced with `redactedMessage`. Anything else becomes a generic
|
|
361
|
-
* `fallbackCode`/500. When `redacted` is `true`, log the raw error server-side.
|
|
362
|
-
*/
|
|
1032
|
+
* Turn a thrown value into an {@link ErrorBody} + status, applying the redaction
|
|
1033
|
+
* invariant. A `LunoraError` with a non-internal code is echoed with its
|
|
1034
|
+
* `message`, resolved `hint`, `docsUrl`, and (when `encodeData` is given) its
|
|
1035
|
+
* `data`. An internal-coded `LunoraError` keeps its `code`/`status` but its
|
|
1036
|
+
* message is replaced with `redactedMessage`. Anything else becomes a generic
|
|
1037
|
+
* `fallbackCode`/500. When `redacted` is `true`, log the raw error server-side.
|
|
1038
|
+
*/
|
|
363
1039
|
declare const toErrorBody: (error: unknown, options?: ToErrorBodyOptions) => ToErrorBodyResult;
|
|
364
|
-
export {
|
|
1040
|
+
export { CLOUDFLARE_PLATFORM_ERRORS, type CloudflarePlatformError, ERROR_CATALOG, type ErrorBody, type ErrorCatalogEntry, type ErrorHint,
|
|
1041
|
+
/**
|
|
1042
|
+
* `@lunora/errors` — the unified error layer.
|
|
1043
|
+
*
|
|
1044
|
+
* This package is **zero-dependency** and safe on every runtime (browser client,
|
|
1045
|
+
* workerd runtime, Node CLI): it exports the `LunoraError` class, the central
|
|
1046
|
+
* catalog, the structural guard, and the invariant helpers. The terminal
|
|
1047
|
+
* renderer (`renderLunoraError`, using `@visulima/error`'s `renderError`) lives
|
|
1048
|
+
* in `@lunora/cli`, which already depends on `@visulima/error`.
|
|
1049
|
+
*/
|
|
1050
|
+
type ErrorLocation, LunoraError, type LunoraErrorCode,
|
|
1051
|
+
/**
|
|
1052
|
+
* `@lunora/errors` — the unified error layer.
|
|
1053
|
+
*
|
|
1054
|
+
* This package is **zero-dependency** and safe on every runtime (browser client,
|
|
1055
|
+
* workerd runtime, Node CLI): it exports the `LunoraError` class, the central
|
|
1056
|
+
* catalog, the structural guard, and the invariant helpers. The terminal
|
|
1057
|
+
* renderer (`renderLunoraError`, using `@visulima/error`'s `renderError`) lives
|
|
1058
|
+
* in `@lunora/cli`, which already depends on `@visulima/error`.
|
|
1059
|
+
*/
|
|
1060
|
+
type LunoraErrorCodeInput, type LunoraErrorLike,
|
|
1061
|
+
/**
|
|
1062
|
+
* `@lunora/errors` — the unified error layer.
|
|
1063
|
+
*
|
|
1064
|
+
* This package is **zero-dependency** and safe on every runtime (browser client,
|
|
1065
|
+
* workerd runtime, Node CLI): it exports the `LunoraError` class, the central
|
|
1066
|
+
* catalog, the structural guard, and the invariant helpers. The terminal
|
|
1067
|
+
* renderer (`renderLunoraError`, using `@visulima/error`'s `renderError`) lives
|
|
1068
|
+
* in `@lunora/cli`, which already depends on `@visulima/error`.
|
|
1069
|
+
*/
|
|
1070
|
+
type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findCloudflarePlatformSolution, findIssueSolution, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, raise, resolveHint, toErrorBody, unreachable };
|