@lunora/codegen 1.0.0-alpha.144 → 1.0.0-alpha.146
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 +1 -1
- package/dist/index.d.mts +75 -12
- package/dist/index.d.ts +75 -12
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-D1qA0h5m.mjs → AGENTS_FILENAME-B1Abt3Gl.mjs} +1 -1
- package/dist/packem_shared/{CONTAINERS_FILENAME-oKaARMoA.mjs → CONTAINERS_FILENAME-CtcysaKS.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_TARGET-BvzxeWRZ.mjs +1 -0
- package/dist/packem_shared/FLAGS_FILENAME-B3VZ6vTw.mjs +1 -0
- package/dist/packem_shared/{GENERATED_HEADER-F2VhjmJG.mjs → GENERATED_HEADER-Dfc3qlLQ.mjs} +1 -1
- package/dist/packem_shared/{NOTIFY_FILENAME-B-eIjru_.mjs → NOTIFY_FILENAME-CKO5gtGe.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-C30LtXay.mjs → OPENRPC_VERSION-CdKqq_QT.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-D229WtRm.mjs → QUEUES_FILENAME-C-pzLGy4.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-CeOctEWC.mjs +9 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-CTWRkAF5.mjs +2 -0
- package/dist/packem_shared/SchemaSnapshotParseError-qXCOA7dD.mjs +18 -0
- package/dist/packem_shared/{WORKFLOWS_FILENAME-DRaiCNa6.mjs → WORKFLOWS_FILENAME-BfvqsG9Z.mjs} +1 -1
- package/dist/packem_shared/ast-BYoSZlae.mjs +1 -0
- package/dist/packem_shared/{buildOpenApiDocument-CmLfuJpW.mjs → buildOpenApiDocument-D40ZeYsu.mjs} +1 -1
- package/dist/packem_shared/chain-Dygm2apY.mjs +1 -0
- package/dist/packem_shared/{classify-procedure-call-AKeIK05y.mjs → classify-procedure-call-Ib2EMtFH.mjs} +1 -1
- package/dist/packem_shared/{context-property-calls-DXH-4MTZ.mjs → context-property-calls-Br0sVv8E.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-C35kkayg.mjs → discoverAuthApiCalls-DoNQSgso.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-wXBfQcfn.mjs → discoverCrons-DCxl4hty.mjs} +1 -1
- package/dist/packem_shared/{discoverFunctions-DglkHRlt.mjs → discoverFunctions-C29Tvxas.mjs} +1 -1
- package/dist/packem_shared/{discoverHttpRoutes-B60GWv_I.mjs → discoverHttpRoutes-CFIXlUy4.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-DTq4PKT5.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-C5l2INmE.mjs → discoverInserts-qU5F4W4g.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-BZsC5dHd.mjs +1 -0
- package/dist/packem_shared/{discoverMigrations-CWH7T6qz.mjs → discoverMigrations-BFkJQ8Sy.mjs} +1 -1
- package/dist/packem_shared/{discoverNondeterministicCalls-JsO91i57.mjs → discoverNondeterministicCalls-B-NNzzPW.mjs} +1 -1
- package/dist/packem_shared/discoverQueries-B4emAFn5.mjs +1 -0
- package/dist/packem_shared/discoverR2sqlCalls-C2GtrFnl.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-DGUGYgWs.mjs → discoverRlsMetadata-BKcUnSNr.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsProcedures-CRshfYZE.mjs → discoverRlsProcedures-fAhxiIyD.mjs} +1 -1
- package/dist/packem_shared/discoverSandboxUsage-CJhnKA0_.mjs +1 -0
- package/dist/packem_shared/{discoverStorageRulesMetadata-gyO60A5S.mjs → discoverStorageRulesMetadata-C7XmORWp.mjs} +1 -1
- package/dist/packem_shared/{emit-EJw8shd_.mjs → emit-BcAkLUfn.mjs} +179 -199
- package/dist/packem_shared/{emitApp-DftAzAA2.mjs → emitApp-DoR55vKV.mjs} +1 -1
- package/dist/packem_shared/{exported-procedure-chains-MlZRKqSD.mjs → exported-procedure-chains-M40rbSYM.mjs} +1 -1
- package/dist/packem_shared/{index-CCDlo9L7.mjs → index-xGhyK9J_.mjs} +1 -1
- package/dist/packem_shared/{queries-B_xEHIeL.mjs → queries-Ddvo5dCs.mjs} +1 -1
- package/package.json +10 -10
- package/dist/packem_shared/DEFAULT_TARGET-CwB3hjFH.mjs +0 -1
- package/dist/packem_shared/FLAGS_FILENAME-BasxlnVS.mjs +0 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-D7qF6qrd.mjs +0 -9
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DLXXalg2.mjs +0 -2
- package/dist/packem_shared/SchemaSnapshotParseError-CvPTjDrT.mjs +0 -16
- package/dist/packem_shared/ast-CjWtsS6S.mjs +0 -1
- package/dist/packem_shared/chain-CtC3-wwZ.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-De_QiFIl.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-Df4JQp_2.mjs +0 -1
- package/dist/packem_shared/discoverQueries-iypfwfdZ.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-BdkZw-D2.mjs +0 -1
- package/dist/packem_shared/discoverSandboxUsage-DdewAOuj.mjs +0 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
The Lunora code generator. It parses your `lunora/schema.ts` plus every function file under `lunora/`, then writes `lunora/_generated/` so the rest of your app gets typed access to its own backend. The core outputs are `api.ts` (the `api` / `internal` function references), `server.ts` (the `query` / `mutation` / `action` / `internalQuery` / `internalMutation` / `internalAction` / `definePolicy` procedure builders bound to your schema), and `dataModel.ts` (the `Doc` / `Id` types). It also emits `app.ts`, `functions.ts`, `shard.ts`, Drizzle schemas, and — when the relevant features are used — `crons.ts`, `containers.ts`, `workflows.ts`, `vectors.ts`, `seed.ts`, and OpenAPI/OpenRPC specs.
|
|
37
|
+
The Lunora code generator. It parses your `lunora/schema.ts` plus every function file under `lunora/`, then writes `lunora/_generated/` so the rest of your app gets typed access to its own backend. The core outputs are `api.ts` (the `api` / `internal` function references), `server.ts` (the `query` / `mutation` / `action` / `internalQuery` / `internalMutation` / `internalAction` / `definePolicy` procedure builders bound to your schema), and `dataModel.ts` (the `Doc` / `Id` types). It also emits `app.ts`, `functions.ts`, `shard.ts`, the Drizzle schemas (`drizzle.shard.ts` / `drizzle.global.ts` — your tables as Drizzle `sqliteTable` objects, split by whether they are `.global()`, for when you need raw Drizzle rather than `ctx.db`), and — when the relevant features are used — `crons.ts`, `containers.ts`, `workflows.ts`, `vectors.ts`, `seed.ts`, and OpenAPI/OpenRPC specs.
|
|
38
38
|
|
|
39
39
|
Most apps never call this package directly — the `lunora codegen` CLI command and the `@lunora/vite` plugin invoke it for you.
|
|
40
40
|
|
package/dist/index.d.mts
CHANGED
|
@@ -75,15 +75,38 @@ interface SchemaSnapshot {
|
|
|
75
75
|
* UI-disagrees-with-the-deploy-gate divergence this module exists to prevent.
|
|
76
76
|
*/
|
|
77
77
|
type DriftScope = "schema" | "table";
|
|
78
|
+
/**
|
|
79
|
+
* What actually fixes a change, so a consumer can name the right tool.
|
|
80
|
+
*
|
|
81
|
+
* - `"backfill"` — a `defineMigration` transform rewrites the affected rows.
|
|
82
|
+
* The ONLY value for which a data migration is the answer.
|
|
83
|
+
* - `"rehome"` — the rows' physical storage moves (a different Durable Object,
|
|
84
|
+
* or a different region). The per-shard runner only ever replaces a row inside
|
|
85
|
+
* the shard it was handed, so no transform reaches these; the fix is an
|
|
86
|
+
* export/import round trip, or a revert.
|
|
87
|
+
* - `"code"` — nothing happens to stored data; a query or a call site has to
|
|
88
|
+
* change (a dropped index, a dropped relation).
|
|
89
|
+
* - `"none"` — additive, nothing to do.
|
|
90
|
+
*
|
|
91
|
+
* This lives HERE, next to the change union, for the same reason {@link DriftScope}
|
|
92
|
+
* does: a hand-maintained set of type names in the consumer gives zero
|
|
93
|
+
* compile-time pressure, so a new variant would silently default to whatever the
|
|
94
|
+
* set omits. The deploy gate uses this to decide both what a data migration may
|
|
95
|
+
* excuse and which tables it offers to scaffold one for — a wrong default there
|
|
96
|
+
* sends the operator to a tool that cannot work.
|
|
97
|
+
*/
|
|
98
|
+
type DriftRemediation = "backfill" | "code" | "none" | "rehome";
|
|
78
99
|
/** One classified structural change between two snapshots. */
|
|
79
100
|
interface DriftChange {
|
|
101
|
+
/** What fixes this change — see {@link DriftRemediation}. `"none"` for every `safe` change. */
|
|
102
|
+
remediation: DriftRemediation;
|
|
80
103
|
/**
|
|
81
104
|
* `"table"` means this table's own DDL moved (fields, indexes, shard mode) —
|
|
82
105
|
* a relation whose foreign key lives on the OTHER table stays `"schema"`, so
|
|
83
106
|
* the "changed" signal keeps meaning "this table's shape moved".
|
|
84
107
|
*/
|
|
85
108
|
scope: DriftScope;
|
|
86
|
-
/** `"breaking"` changes need
|
|
109
|
+
/** `"breaking"` changes need attention before deploy; `"safe"` changes are additive. */
|
|
87
110
|
severity: "breaking" | "safe";
|
|
88
111
|
/** Human-readable, actionable description (used in the gate message). */
|
|
89
112
|
summary: string;
|
|
@@ -436,8 +459,10 @@ interface FunctionIR {
|
|
|
436
459
|
/**
|
|
437
460
|
* A `defineMigration({...})` declaration discovered in the user's lunora
|
|
438
461
|
* sources. The emitted `LUNORA_MIGRATIONS` registry keys on {@link MigrationIR.id}; the
|
|
439
|
-
* import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}.
|
|
440
|
-
*
|
|
462
|
+
* import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}. The runtime object
|
|
463
|
+
* carries the authoritative {@link MigrationIR.table}, but the lifted value is
|
|
464
|
+
* load-bearing at build time: the schema-drift gate matches it against the
|
|
465
|
+
* tables with breaking drift, so a migration left at `""` covers nothing.
|
|
441
466
|
*/
|
|
442
467
|
interface MigrationIR {
|
|
443
468
|
/** Export binding name, used to reference the module member in generated imports. */
|
|
@@ -2546,6 +2571,13 @@ interface CodegenResult {
|
|
|
2546
2571
|
/** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
|
|
2547
2572
|
workflows: string;
|
|
2548
2573
|
};
|
|
2574
|
+
/**
|
|
2575
|
+
* Data migrations discovered from `defineMigration` exports under `lunora/`,
|
|
2576
|
+
* each with the table it iterates. The drift gate matches a NEW id against
|
|
2577
|
+
* its table so a backfill only excuses breaking drift on the table it
|
|
2578
|
+
* actually visits. Empty when the project declares none.
|
|
2579
|
+
*/
|
|
2580
|
+
migrations: ReadonlyArray<MigrationIR>;
|
|
2549
2581
|
outputDirectory: string;
|
|
2550
2582
|
/**
|
|
2551
2583
|
* Portability diagnostics for the requested {@link CodegenOptions.target}:
|
|
@@ -2825,16 +2857,28 @@ declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) =
|
|
|
2825
2857
|
/**
|
|
2826
2858
|
* Which sandbox tools a project imports from `@lunora/agent` (main entry or the
|
|
2827
2859
|
* `/sandbox` subpath), detected by NAMED value import. Drives two things:
|
|
2828
|
-
* registering the `sandbox:invoke` dispatcher (
|
|
2829
|
-
*
|
|
2830
|
-
* `
|
|
2860
|
+
* registering the `sandbox:invoke` dispatcher (ANY of the three tools — an agent
|
|
2861
|
+
* whose only sandbox tool was `fsTool` used to be missed here, so every
|
|
2862
|
+
* `ls`/`read`/`write`/`rm`/`stat` died on FUNCTION_NOT_FOUND) and provisioning
|
|
2863
|
+
* the `BROWSER` wrangler binding (`browserTool` only — the browser op runs on
|
|
2864
|
+
* `ctx.browser` inside the dispatcher, while `fsTool` reads a hand-declared R2
|
|
2865
|
+
* bucket).
|
|
2831
2866
|
*/
|
|
2832
2867
|
interface SandboxUsage {
|
|
2833
2868
|
/** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2834
2869
|
usesSandboxBrowser: boolean;
|
|
2835
2870
|
/** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2836
2871
|
usesSandboxContainer: boolean;
|
|
2872
|
+
/** `import { fsTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2873
|
+
usesSandboxFs: boolean;
|
|
2837
2874
|
}
|
|
2875
|
+
/**
|
|
2876
|
+
* Scan the `lunora/` source set for named imports of the sandbox tools
|
|
2877
|
+
* ({@link TOOL_FLAGS}) from `@lunora/agent` (main entry or the `/sandbox`
|
|
2878
|
+
* subpath). Type-only imports (the input/option types) do not count — only a
|
|
2879
|
+
* value import wires a tool into an agent. A project that imports none yields
|
|
2880
|
+
* all-`false` and codegen emits byte-identical output.
|
|
2881
|
+
*/
|
|
2838
2882
|
declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
|
|
2839
2883
|
/**
|
|
2840
2884
|
* Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
|
|
@@ -3365,11 +3409,15 @@ declare class SchemaSnapshotParseError extends LunoraError {
|
|
|
3365
3409
|
declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
|
|
3366
3410
|
/** The decision the pre-deploy gate returns. */
|
|
3367
3411
|
interface SchemaDriftDecision {
|
|
3368
|
-
/** True when the deploy must be blocked (breaking drift
|
|
3412
|
+
/** True when the deploy must be blocked (breaking drift no new migration covers, and no override). */
|
|
3369
3413
|
blocked: boolean;
|
|
3370
3414
|
/** Every classified change (both severities), for reporting. */
|
|
3371
3415
|
changes: ReadonlyArray<DriftChange>;
|
|
3372
|
-
/**
|
|
3416
|
+
/**
|
|
3417
|
+
* Migration ids declared now but absent from the baseline. Reported for
|
|
3418
|
+
* context; the gate acts on which of them cover an affected TABLE, not on how
|
|
3419
|
+
* many there are.
|
|
3420
|
+
*/
|
|
3373
3421
|
newMigrationIds: ReadonlyArray<string>;
|
|
3374
3422
|
/**
|
|
3375
3423
|
* A multi-line, actionable explanation. Always present; empty string when
|
|
@@ -3381,9 +3429,22 @@ interface SchemaDriftDecision {
|
|
|
3381
3429
|
* Decide whether breaking schema drift should block a deploy.
|
|
3382
3430
|
*
|
|
3383
3431
|
* Blocks only when the baseline exists (a first-ever capture is never blocking),
|
|
3384
|
-
* there is at least one `breaking` change, no
|
|
3385
|
-
*
|
|
3386
|
-
*
|
|
3432
|
+
* there is at least one `breaking` change, no new migration COVERS it, and the
|
|
3433
|
+
* `allowDrift` override is not set. Safe-only drift passes.
|
|
3434
|
+
*
|
|
3435
|
+
* "Covers" is per-table, not per-run: a new migration excuses breaking drift on
|
|
3436
|
+
* the table it iterates, and nothing else. Counting new ids alone let a backfill
|
|
3437
|
+
* on `messages` unblock a required field added to `users` — the gate reported
|
|
3438
|
+
* "accompanied by a migration" for a change that migration would never visit.
|
|
3439
|
+
* The shard-mode diff cites this block to justify the studio not shipping a
|
|
3440
|
+
* stranded-rows detector (see `shared/schema-snapshot.ts`), and that claim only
|
|
3441
|
+
* holds if an unrelated migration cannot wave it through.
|
|
3442
|
+
*
|
|
3443
|
+
* Only a `"backfill"` change is coverable at all. A `"rehome"` change moves rows
|
|
3444
|
+
* to another Durable Object or region and a `"code"` change breaks a call site;
|
|
3445
|
+
* rewriting rows fixes neither, so a migration must not excuse them however well
|
|
3446
|
+
* its table matches. Those are cleared by fixing the code or accepting the new
|
|
3447
|
+
* shape (`--allow-schema-drift` / `--update-schema-baseline`).
|
|
3387
3448
|
*/
|
|
3388
3449
|
declare const evaluateSchemaDrift: (options: {
|
|
3389
3450
|
allowDrift?: boolean;
|
|
@@ -3391,6 +3452,8 @@ declare const evaluateSchemaDrift: (options: {
|
|
|
3391
3452
|
/** The command printing the remediation, so it names only flags that command accepts. */
|
|
3392
3453
|
command?: string;
|
|
3393
3454
|
current: SchemaSnapshot;
|
|
3455
|
+
/** This run's declared migrations, so a new one is matched to the table it iterates. */
|
|
3456
|
+
migrations: ReadonlyArray<Pick<MigrationIR, "id" | "table">>;
|
|
3394
3457
|
}) => SchemaDriftDecision;
|
|
3395
3458
|
/**
|
|
3396
3459
|
* Convert a {@link SchemaIR} into a synthetic runtime {@link Schema} carrying just
|
|
@@ -3707,4 +3770,4 @@ declare const secretKindOf: (value: string) => string | undefined;
|
|
|
3707
3770
|
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
3708
3771
|
declare const redact: (value: string) => string;
|
|
3709
3772
|
declare const VERSION = "0.0.0";
|
|
3710
|
-
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, type PlatformDiagnostic, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findTsconfig, formatAdvisories, generateSdk, isTypedSchema, lintSchema, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, toAdvisorContext, validatorIrToJsonSchema };
|
|
3773
|
+
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftRemediation, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, type PlatformDiagnostic, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findTsconfig, formatAdvisories, generateSdk, isTypedSchema, lintSchema, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, toAdvisorContext, validatorIrToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,15 +75,38 @@ interface SchemaSnapshot {
|
|
|
75
75
|
* UI-disagrees-with-the-deploy-gate divergence this module exists to prevent.
|
|
76
76
|
*/
|
|
77
77
|
type DriftScope = "schema" | "table";
|
|
78
|
+
/**
|
|
79
|
+
* What actually fixes a change, so a consumer can name the right tool.
|
|
80
|
+
*
|
|
81
|
+
* - `"backfill"` — a `defineMigration` transform rewrites the affected rows.
|
|
82
|
+
* The ONLY value for which a data migration is the answer.
|
|
83
|
+
* - `"rehome"` — the rows' physical storage moves (a different Durable Object,
|
|
84
|
+
* or a different region). The per-shard runner only ever replaces a row inside
|
|
85
|
+
* the shard it was handed, so no transform reaches these; the fix is an
|
|
86
|
+
* export/import round trip, or a revert.
|
|
87
|
+
* - `"code"` — nothing happens to stored data; a query or a call site has to
|
|
88
|
+
* change (a dropped index, a dropped relation).
|
|
89
|
+
* - `"none"` — additive, nothing to do.
|
|
90
|
+
*
|
|
91
|
+
* This lives HERE, next to the change union, for the same reason {@link DriftScope}
|
|
92
|
+
* does: a hand-maintained set of type names in the consumer gives zero
|
|
93
|
+
* compile-time pressure, so a new variant would silently default to whatever the
|
|
94
|
+
* set omits. The deploy gate uses this to decide both what a data migration may
|
|
95
|
+
* excuse and which tables it offers to scaffold one for — a wrong default there
|
|
96
|
+
* sends the operator to a tool that cannot work.
|
|
97
|
+
*/
|
|
98
|
+
type DriftRemediation = "backfill" | "code" | "none" | "rehome";
|
|
78
99
|
/** One classified structural change between two snapshots. */
|
|
79
100
|
interface DriftChange {
|
|
101
|
+
/** What fixes this change — see {@link DriftRemediation}. `"none"` for every `safe` change. */
|
|
102
|
+
remediation: DriftRemediation;
|
|
80
103
|
/**
|
|
81
104
|
* `"table"` means this table's own DDL moved (fields, indexes, shard mode) —
|
|
82
105
|
* a relation whose foreign key lives on the OTHER table stays `"schema"`, so
|
|
83
106
|
* the "changed" signal keeps meaning "this table's shape moved".
|
|
84
107
|
*/
|
|
85
108
|
scope: DriftScope;
|
|
86
|
-
/** `"breaking"` changes need
|
|
109
|
+
/** `"breaking"` changes need attention before deploy; `"safe"` changes are additive. */
|
|
87
110
|
severity: "breaking" | "safe";
|
|
88
111
|
/** Human-readable, actionable description (used in the gate message). */
|
|
89
112
|
summary: string;
|
|
@@ -436,8 +459,10 @@ interface FunctionIR {
|
|
|
436
459
|
/**
|
|
437
460
|
* A `defineMigration({...})` declaration discovered in the user's lunora
|
|
438
461
|
* sources. The emitted `LUNORA_MIGRATIONS` registry keys on {@link MigrationIR.id}; the
|
|
439
|
-
* import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}.
|
|
440
|
-
*
|
|
462
|
+
* import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}. The runtime object
|
|
463
|
+
* carries the authoritative {@link MigrationIR.table}, but the lifted value is
|
|
464
|
+
* load-bearing at build time: the schema-drift gate matches it against the
|
|
465
|
+
* tables with breaking drift, so a migration left at `""` covers nothing.
|
|
441
466
|
*/
|
|
442
467
|
interface MigrationIR {
|
|
443
468
|
/** Export binding name, used to reference the module member in generated imports. */
|
|
@@ -2546,6 +2571,13 @@ interface CodegenResult {
|
|
|
2546
2571
|
/** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
|
|
2547
2572
|
workflows: string;
|
|
2548
2573
|
};
|
|
2574
|
+
/**
|
|
2575
|
+
* Data migrations discovered from `defineMigration` exports under `lunora/`,
|
|
2576
|
+
* each with the table it iterates. The drift gate matches a NEW id against
|
|
2577
|
+
* its table so a backfill only excuses breaking drift on the table it
|
|
2578
|
+
* actually visits. Empty when the project declares none.
|
|
2579
|
+
*/
|
|
2580
|
+
migrations: ReadonlyArray<MigrationIR>;
|
|
2549
2581
|
outputDirectory: string;
|
|
2550
2582
|
/**
|
|
2551
2583
|
* Portability diagnostics for the requested {@link CodegenOptions.target}:
|
|
@@ -2825,16 +2857,28 @@ declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) =
|
|
|
2825
2857
|
/**
|
|
2826
2858
|
* Which sandbox tools a project imports from `@lunora/agent` (main entry or the
|
|
2827
2859
|
* `/sandbox` subpath), detected by NAMED value import. Drives two things:
|
|
2828
|
-
* registering the `sandbox:invoke` dispatcher (
|
|
2829
|
-
*
|
|
2830
|
-
* `
|
|
2860
|
+
* registering the `sandbox:invoke` dispatcher (ANY of the three tools — an agent
|
|
2861
|
+
* whose only sandbox tool was `fsTool` used to be missed here, so every
|
|
2862
|
+
* `ls`/`read`/`write`/`rm`/`stat` died on FUNCTION_NOT_FOUND) and provisioning
|
|
2863
|
+
* the `BROWSER` wrangler binding (`browserTool` only — the browser op runs on
|
|
2864
|
+
* `ctx.browser` inside the dispatcher, while `fsTool` reads a hand-declared R2
|
|
2865
|
+
* bucket).
|
|
2831
2866
|
*/
|
|
2832
2867
|
interface SandboxUsage {
|
|
2833
2868
|
/** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2834
2869
|
usesSandboxBrowser: boolean;
|
|
2835
2870
|
/** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2836
2871
|
usesSandboxContainer: boolean;
|
|
2872
|
+
/** `import { fsTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2873
|
+
usesSandboxFs: boolean;
|
|
2837
2874
|
}
|
|
2875
|
+
/**
|
|
2876
|
+
* Scan the `lunora/` source set for named imports of the sandbox tools
|
|
2877
|
+
* ({@link TOOL_FLAGS}) from `@lunora/agent` (main entry or the `/sandbox`
|
|
2878
|
+
* subpath). Type-only imports (the input/option types) do not count — only a
|
|
2879
|
+
* value import wires a tool into an agent. A project that imports none yields
|
|
2880
|
+
* all-`false` and codegen emits byte-identical output.
|
|
2881
|
+
*/
|
|
2838
2882
|
declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
|
|
2839
2883
|
/**
|
|
2840
2884
|
* Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
|
|
@@ -3365,11 +3409,15 @@ declare class SchemaSnapshotParseError extends LunoraError {
|
|
|
3365
3409
|
declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
|
|
3366
3410
|
/** The decision the pre-deploy gate returns. */
|
|
3367
3411
|
interface SchemaDriftDecision {
|
|
3368
|
-
/** True when the deploy must be blocked (breaking drift
|
|
3412
|
+
/** True when the deploy must be blocked (breaking drift no new migration covers, and no override). */
|
|
3369
3413
|
blocked: boolean;
|
|
3370
3414
|
/** Every classified change (both severities), for reporting. */
|
|
3371
3415
|
changes: ReadonlyArray<DriftChange>;
|
|
3372
|
-
/**
|
|
3416
|
+
/**
|
|
3417
|
+
* Migration ids declared now but absent from the baseline. Reported for
|
|
3418
|
+
* context; the gate acts on which of them cover an affected TABLE, not on how
|
|
3419
|
+
* many there are.
|
|
3420
|
+
*/
|
|
3373
3421
|
newMigrationIds: ReadonlyArray<string>;
|
|
3374
3422
|
/**
|
|
3375
3423
|
* A multi-line, actionable explanation. Always present; empty string when
|
|
@@ -3381,9 +3429,22 @@ interface SchemaDriftDecision {
|
|
|
3381
3429
|
* Decide whether breaking schema drift should block a deploy.
|
|
3382
3430
|
*
|
|
3383
3431
|
* Blocks only when the baseline exists (a first-ever capture is never blocking),
|
|
3384
|
-
* there is at least one `breaking` change, no
|
|
3385
|
-
*
|
|
3386
|
-
*
|
|
3432
|
+
* there is at least one `breaking` change, no new migration COVERS it, and the
|
|
3433
|
+
* `allowDrift` override is not set. Safe-only drift passes.
|
|
3434
|
+
*
|
|
3435
|
+
* "Covers" is per-table, not per-run: a new migration excuses breaking drift on
|
|
3436
|
+
* the table it iterates, and nothing else. Counting new ids alone let a backfill
|
|
3437
|
+
* on `messages` unblock a required field added to `users` — the gate reported
|
|
3438
|
+
* "accompanied by a migration" for a change that migration would never visit.
|
|
3439
|
+
* The shard-mode diff cites this block to justify the studio not shipping a
|
|
3440
|
+
* stranded-rows detector (see `shared/schema-snapshot.ts`), and that claim only
|
|
3441
|
+
* holds if an unrelated migration cannot wave it through.
|
|
3442
|
+
*
|
|
3443
|
+
* Only a `"backfill"` change is coverable at all. A `"rehome"` change moves rows
|
|
3444
|
+
* to another Durable Object or region and a `"code"` change breaks a call site;
|
|
3445
|
+
* rewriting rows fixes neither, so a migration must not excuse them however well
|
|
3446
|
+
* its table matches. Those are cleared by fixing the code or accepting the new
|
|
3447
|
+
* shape (`--allow-schema-drift` / `--update-schema-baseline`).
|
|
3387
3448
|
*/
|
|
3388
3449
|
declare const evaluateSchemaDrift: (options: {
|
|
3389
3450
|
allowDrift?: boolean;
|
|
@@ -3391,6 +3452,8 @@ declare const evaluateSchemaDrift: (options: {
|
|
|
3391
3452
|
/** The command printing the remediation, so it names only flags that command accepts. */
|
|
3392
3453
|
command?: string;
|
|
3393
3454
|
current: SchemaSnapshot;
|
|
3455
|
+
/** This run's declared migrations, so a new one is matched to the table it iterates. */
|
|
3456
|
+
migrations: ReadonlyArray<Pick<MigrationIR, "id" | "table">>;
|
|
3394
3457
|
}) => SchemaDriftDecision;
|
|
3395
3458
|
/**
|
|
3396
3459
|
* Convert a {@link SchemaIR} into a synthetic runtime {@link Schema} carrying just
|
|
@@ -3707,4 +3770,4 @@ declare const secretKindOf: (value: string) => string | undefined;
|
|
|
3707
3770
|
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
3708
3771
|
declare const redact: (value: string) => string;
|
|
3709
3772
|
declare const VERSION = "0.0.0";
|
|
3710
|
-
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, type PlatformDiagnostic, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findTsconfig, formatAdvisories, generateSdk, isTypedSchema, lintSchema, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, toAdvisorContext, validatorIrToJsonSchema };
|
|
3773
|
+
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftRemediation, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, type PlatformDiagnostic, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findTsconfig, formatAdvisories, generateSdk, isTypedSchema, lintSchema, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, toAdvisorContext, validatorIrToJsonSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-CTWRkAF5.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-CkEu1eye.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l}from"./packem_shared/describeErrorLevelFindings-D23VSkFP.mjs";import{CodegenDiagnosticError as x,diagnosticAt as E}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as u,discoverAgents as v}from"./packem_shared/AGENTS_FILENAME-B1Abt3Gl.mjs";import{default as g}from"./packem_shared/discoverAuthApiCalls-DoNQSgso.mjs";import{CONTAINERS_FILENAME as R,discoverContainers as C}from"./packem_shared/CONTAINERS_FILENAME-CtcysaKS.mjs";import{default as h}from"./packem_shared/discoverCrons-DCxl4hty.mjs";import{FLAGS_FILENAME as T,discoverFlags as I}from"./packem_shared/FLAGS_FILENAME-B3VZ6vTw.mjs";import{default as F}from"./packem_shared/discoverFunctions-C29Tvxas.mjs";import{default as P}from"./packem_shared/discoverHttpRoutes-CFIXlUy4.mjs";import{default as G}from"./packem_shared/discoverHyperdriveCalls-DTq4PKT5.mjs";import{default as b}from"./packem_shared/discoverInserts-qU5F4W4g.mjs";import{d as y}from"./packem_shared/index-xGhyK9J_.mjs";import{default as j}from"./packem_shared/discoverMigrations-BFkJQ8Sy.mjs";import{MUTATORS_FILENAME as V,discoverMutators as z}from"./packem_shared/MUTATORS_FILENAME-BKSzaCkq.mjs";import{default as w}from"./packem_shared/discoverNondeterministicCalls-B-NNzzPW.mjs";import{NOTIFY_FILENAME as B,discoverNotifyCalls as J,discoverNotifyConfig as Y}from"./packem_shared/NOTIFY_FILENAME-CKO5gtGe.mjs";import{default as Z}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as ee}from"./packem_shared/queries-Ddvo5dCs.mjs";import{QUEUES_FILENAME as oe,discoverQueues as te}from"./packem_shared/QUEUES_FILENAME-C-pzLGy4.mjs";import{default as ae}from"./packem_shared/discoverR2sqlCalls-C2GtrFnl.mjs";import{default as me}from"./packem_shared/discoverRlsProcedures-fAhxiIyD.mjs";import{default as fe}from"./packem_shared/discoverRlsMetadata-BKcUnSNr.mjs";import{discoverSandboxUsage as ce}from"./packem_shared/discoverSandboxUsage-CJhnKA0_.mjs";import{default as le}from"./packem_shared/discoverSchema-CubSTjtY.mjs";import{SHAPES_FILENAME as xe,discoverShapes as Ee}from"./packem_shared/SHAPES_FILENAME-D3N7xcEk.mjs";import{default as ue}from"./packem_shared/discoverStorageRulesMetadata-C7XmORWp.mjs";import{WORKFLOWS_FILENAME as Ne,discoverWorkflows as ge}from"./packem_shared/WORKFLOWS_FILENAME-BfvqsG9Z.mjs";import{G as Re,e as Ce,a as Me,b as he,c as _e,d as Te,f as Ie,g as Le,h as Fe,i as De,j as Pe,k as Ue,l as Ge,m as He}from"./packem_shared/emit-BcAkLUfn.mjs";import{emitApp as ke}from"./packem_shared/emitApp-DoR55vKV.mjs";import{buildOpenApiDocument as We,emitOpenApi as je,emitOpenApiModule as Ke}from"./packem_shared/buildOpenApiDocument-D40ZeYsu.mjs";import{OPENRPC_VERSION as ze,buildOpenRpcDocument as Qe,emitOpenRpc as we,emitOpenRpcModule as qe}from"./packem_shared/OPENRPC_VERSION-CdKqq_QT.mjs";import{DEFAULT_TARGET as Je,platformMatrixIds as Ye,readProjectTarget as Xe,resolveCodegenTarget as Ze}from"./packem_shared/DEFAULT_TARGET-BvzxeWRZ.mjs";import{SCHEMA_SNAPSHOT_FILENAME as er,createCodegenProject as rr,findTsconfig as or,refreshCodegenProject as tr,runCodegen as sr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-CeOctEWC.mjs";import{SchemaSnapshotParseError as ir,buildSchemaSnapshot as mr,evaluateSchemaDrift as dr,parseSchemaSnapshot as fr}from"./packem_shared/SchemaSnapshotParseError-qXCOA7dD.mjs";import{schemaFromIr as cr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as lr,validatorIrToJsonSchema as Sr}from"./packem_shared/LUNORA_ERROR_CODES-BYg8Lpgb.mjs";import{SDK_LANGUAGES as Er,SDK_TARGETS as Ar,generateSdk as ur}from"./packem_shared/SDK_LANGUAGES-CFyux-74.mjs";import{redact as Nr,secretKindOf as gr}from"./packem_shared/redact-Cy14LEnc.mjs";import{MESSAGE_SOLUTIONS as Rr,findSolutionByMessage as Cr}from"@lunora/errors";import{isTypedSchema as hr}from"./packem_shared/isTypedSchema-B_qlBbE-.mjs";const e="0.0.0";export{u as AGENTS_FILENAME,R as CONTAINERS_FILENAME,x as CodegenDiagnosticError,Je as DEFAULT_TARGET,T as FLAGS_FILENAME,Re as GENERATED_HEADER,lr as LUNORA_ERROR_CODES,Rr as LUNORA_SOLUTION_RULES,V as MUTATORS_FILENAME,B as NOTIFY_FILENAME,ze as OPENRPC_VERSION,oe as QUEUES_FILENAME,er as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Er as SDK_LANGUAGES,Ar as SDK_TARGETS,xe as SHAPES_FILENAME,ir as SchemaSnapshotParseError,e as VERSION,Ne as WORKFLOWS_FILENAME,We as buildOpenApiDocument,Qe as buildOpenRpcDocument,mr as buildSchemaSnapshot,rr as createCodegenProject,c as describeErrorLevelFindings,E as diagnosticAt,s as diffSchemaSnapshots,v as discoverAgents,g as discoverAuthApiCalls,C as discoverContainers,h as discoverCrons,I as discoverFlags,F as discoverFunctions,P as discoverHttpRoutes,G as discoverHyperdriveCalls,b as discoverInserts,y as discoverMaskProcedures,j as discoverMigrations,z as discoverMutators,w as discoverNondeterministicCalls,J as discoverNotifyCalls,Y as discoverNotifyConfig,ee as discoverQueries,te as discoverQueues,ae as discoverR2sqlCalls,fe as discoverRlsMetadata,me as discoverRlsProcedures,ce as discoverSandboxUsage,le as discoverSchema,Ee as discoverShapes,ue as discoverStorageRulesMetadata,ge as discoverWorkflows,Ce as emitAgents,Me as emitApi,ke as emitApp,he as emitCollections,_e as emitContainers,Te as emitCrons,Ie as emitDataModel,Le as emitDrizzleSchema,Fe as emitFunctions,je as emitOpenApi,Ke as emitOpenApiModule,we as emitOpenRpc,qe as emitOpenRpcModule,De as emitServer,Pe as emitShard,Ue as emitVectors,Ge as emitWorkflows,He as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,dr as evaluateSchemaDrift,Cr as findLunoraSolution,or as findTsconfig,m as formatAdvisories,ur as generateSdk,hr as isTypedSchema,d as lintSchema,fr as parseSchemaSnapshot,Ye as platformMatrixIds,Z as readPackageDependencies,Xe as readProjectTarget,Nr as redact,tr as refreshCodegenProject,Ze as resolveCodegenTarget,sr as runCodegen,cr as schemaFromIr,gr as secretKindOf,a as serializeSchemaSnapshot,f as toAdvisorContext,Sr as validatorIrToJsonSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as u}from"node:fs";import{join as p}from"node:path";import{agentDefaultName as d,agentClassName as f,agentBindingName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as l}from"@lunora/errors";import{Node as a,SyntaxKind as m}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{u as A,s as w}from"./ast-
|
|
1
|
+
import{existsSync as u}from"node:fs";import{join as p}from"node:path";import{agentDefaultName as d,agentClassName as f,agentBindingName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as l}from"@lunora/errors";import{Node as a,SyntaxKind as m}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{u as A,s as w}from"./ast-BYoSZlae.mjs";const h="agents.ts",E=i=>{const t=i.getSymbol();if(!t)return i.getText()==="defineAgent";for(const n of t.getDeclarations())if(a.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:n.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),I=(i,t,n)=>{if(i.getKind()===m.TrueKeyword)return!0;if(i.getKind()===m.FalseKeyword)return!1;throw g(i,`agent "${t}": \`${n}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},T=(i,t)=>{const n=i.getArguments()[0];if(!n||!a.isObjectLiteralExpression(n))throw g(i,`agent "${t}": defineAgent must be passed an inline object literal`);const o={bindingName:b(t),className:f(t),exportName:t,name:d(t)},e=n.getProperty("name");e&&a.isPropertyAssignment(e)&&(o.name=P(e.getInitializerOrThrow(),t,"name"));const r=n.getProperty("publicRun");r&&a.isPropertyAssignment(r)&&I(r.getInitializerOrThrow(),t,"publicRun")&&(o.publicRun=!0);const s=n.getProperty("voice");if(s&&a.isPropertyAssignment(s)){const c=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(c))throw g(c,`agent "${t}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);o.voice=!0,o.voiceBindingName=N(t),o.voiceClassName=y(t)}return n.getProperty("onEmail")&&(o.onEmail=!0),o},v=i=>{const t=[];for(const n of i.getVariableDeclarations()){if(!n.isExported())continue;const o=A(n.getInitializer());if(!o)continue;const e=o.getExpression();if(!a.isIdentifier(e)||!E(e))continue;const r=n.getNameNode();if(!a.isIdentifier(r))throw g(r,"defineAgent exports must be plain named exports (no destructuring)");t.push(T(o,r.getText()))}return t},D=i=>{const t=new Map,n=new Map,o=new Map;for(const e of i){const r=t.get(e.name);if(r!==void 0)throw new l("DUPLICATE_AGENT_NAME",`Duplicate agent name "${e.name}": produced by both "${r}" and "${e.exportName}". Deployed agent names must be unique across the project.`,{status:500});t.set(e.name,e.exportName);const s=n.get(e.bindingName);if(s!==void 0)throw new l("DUPLICATE_AGENT_BINDING",`Duplicate agent binding "${e.bindingName}": produced by both "${s}" and "${e.exportName}". Agent export names must yield unique binding names.`,{status:500});n.set(e.bindingName,e.exportName);const c=o.get(e.className);if(c!==void 0)throw new l("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${e.className}": produced by both "${c}" and "${e.exportName}". Agent export names must yield unique generated class names.`,{status:500});o.set(e.className,e.exportName)}},j=(i,t)=>{const n=p(t,h);if(!u(n))return[];const o=i.getSourceFile(n)??i.addSourceFileAtPath(n),e=v(o);return e.sort((r,s)=>r.exportName.localeCompare(s.exportName)),D(e),e};export{h as AGENTS_FILENAME,j as discoverAgents};
|
package/dist/packem_shared/{CONTAINERS_FILENAME-oKaARMoA.mjs → CONTAINERS_FILENAME-CtcysaKS.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as f}from"node:fs";import{join as d}from"node:path";import{containerClassName as b,containerBindingName as p,normalizeContainerImage as u}from"@lunora/container";import{SyntaxKind as y,Node as n}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as L}from"./ast-
|
|
1
|
+
import{existsSync as f}from"node:fs";import{join as d}from"node:path";import{containerClassName as b,containerBindingName as p,normalizeContainerImage as u}from"@lunora/container";import{SyntaxKind as y,Node as n}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as L}from"./ast-BYoSZlae.mjs";const P="containers.ts",h=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineContainer";for(const i of t.getDeclarations())if(n.isImportSpecifier(i))return i.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:i.getNameNode().getText()==="defineContainer";return!1},g=L("container"),m=(e,t,i)=>{if(n.isNumericLiteral(e))return e.getLiteralValue();throw c(e,`container "${t}": \`${i}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},T=(e,t)=>{if(n.isStringLiteral(e)||n.isNoSubstitutionTemplateLiteral(e))return u(e.getLiteralValue());if(n.isObjectLiteralExpression(e)){const i=e.getProperty("registry");if(i&&n.isPropertyAssignment(i)){const o=i.getInitializerOrThrow();return u({registry:g(o,t,"image.registry")})}const r=e.getProperty("build");if(r&&n.isPropertyAssignment(r)){const o=r.getInitializerOrThrow();return u({build:g(o,t,"image.build")})}}throw c(e,`container "${t}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},k=e=>{if(!n.isObjectLiteralExpression(e))return;const t={};for(const i of e.getProperties()){if(!n.isPropertyAssignment(i))continue;const r=i.getInitializerOrThrow();(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))&&(t[i.getName()]=r.getLiteralValue())}return Object.keys(t).length>0?t:void 0},I=e=>{if(!n.isObjectLiteralExpression(e))return;const t={};for(const i of e.getProperties()){if(!n.isPropertyAssignment(i))continue;const r=i.getName(),o=i.getInitializerOrThrow();n.isNumericLiteral(o)&&(r==="gracePeriodSeconds"||r==="stepPercentage")&&(t[r]=o.getLiteralValue())}return t.gracePeriodSeconds===void 0&&t.stepPercentage===void 0?void 0:t},w=e=>{if(n.isTrueLiteral(e))return!0;if(n.isFalseLiteral(e))return!1},S=e=>{if(n.isStringLiteral(e)||n.isNoSubstitutionTemplateLiteral(e)||n.isNumericLiteral(e))return e.getLiteralValue()},A=(e,t)=>{if(n.isStringLiteral(e))return e.getLiteralValue();if(n.isObjectLiteralExpression(e)){const i={};for(const r of e.getProperties()){if(!n.isPropertyAssignment(r))throw c(r,`container "${t}": \`instanceType\` must be an object of static number literals`);const o=r.getName();if(o!=="diskMb"&&o!=="memoryMib"&&o!=="vcpu")throw c(r,`container "${t}": unknown \`instanceType\` field "${o}" — expected vcpu, memoryMib, or diskMb`);i[o]=m(r.getInitializerOrThrow(),t,`instanceType.${o}`)}return i}throw c(e,`container "${t}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},v=(e,t)=>{const i=e.getArguments()[0];if(!i||!n.isObjectLiteralExpression(i))throw c(e,`container "${t}": defineContainer must be passed an inline object literal`);const r={bindingName:p(t),className:b(t),exportName:t,image:{buildContext:".",dockerfilePath:"./Dockerfile",kind:"dockerfile"}};let o=!1;for(const a of i.getProperties()){if(!n.isPropertyAssignment(a))continue;const l=a.getName(),s=a.getInitializerOrThrow();switch(l){case"buildArgs":{r.buildArgs=k(s);break}case"enableInternet":{r.enableInternet=w(s);break}case"image":{r.image=T(s,t),o=!0;break}case"instanceType":{r.instanceType=A(s,t);break}case"maxInstances":{r.maxInstances=m(s,t,"maxInstances");break}case"name":{r.name=g(s,t,"name");break}case"rollout":{r.rollout=I(s);break}case"sleepAfter":{r.sleepAfter=S(s);break}}}if(!o)throw c(i,`container "${t}": defineContainer requires a static \`image\` property`);return r},C=e=>{const t=[];for(const i of e.getVariableDeclarations()){if(!i.isExported())continue;const r=i.getInitializer();if(r?.getKind()!==y.CallExpression)continue;const o=r,a=o.getExpression();if(!n.isIdentifier(a)||!h(a))continue;const l=i.getNameNode();if(!n.isIdentifier(l))throw c(l,"defineContainer exports must be plain named exports (no destructuring)");t.push(v(o,l.getText()))}return t},F=(e,t)=>{const i=d(t,P);if(!f(i))return[];const r=e.getSourceFile(i)??e.addSourceFileAtPath(i),o=C(r);return o.sort((a,l)=>a.exportName.localeCompare(l.exportName)),o};export{P as CONTAINERS_FILENAME,F as discoverContainers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as c,readFileSync as p}from"node:fs";import{join as m}from"node:path";import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h}from"@lunora/platform";import{parse as g}from"jsonc-parser";const v="cloudflare",y="lunora.json",b=r=>{const e=m(r,y);if(!c(e))return;let a;try{a=p(e,"utf8")}catch{return}const s=[],n=g(a,s,{allowTrailingComma:!0});if(s.length>0||n===null||typeof n!="object")return;const{target:o}=n;return typeof o=="string"&&o.length>0?o:void 0},E=(r,e)=>e??b(r)??v,i={cloudflare:h,node:f},L=()=>Object.keys(i).toSorted((r,e)=>r.localeCompare(e)),T={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},_=["commitOrderedTables","crossShardFanout","durableStreams","globalTables","queues","secrets"],d={commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",secrets:"the secrets store (`ctx.secrets`)"},$=(r,e,a,s={})=>{const n={...r},o=[];for(const[t,l]of Object.entries(T)){if(l===null||!r[t])continue;const u=e.features[l]?.level;u==="unsupported"?(n[t]=!1,o.push({feature:t,level:"error",message:`${e.name} does not support "${t}" (ctx.${t}). Its surface was omitted from the generated types.`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${t} usage, or deploy to a target whose capability matrix marks "${l}" as native or emulated.`,target:a})):u===void 0&&(n[t]=!1,o.push({feature:t,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${t}" (ctx.${t}). Treated as unsupported and its surface was omitted from the generated types.`,name:"platform_undeclared_feature",remediation:`Rate "${l}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}for(const t of _){if(s[t]!==!0)continue;const l=e.features[t]?.level;l==="unsupported"?o.push({level:"error",message:`${e.name} does not support ${d[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}):l===void 0&&o.push({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${d[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a})}return{diagnostics:o,usage:n}},O=(r,e,a={})=>{const s=i[e];return s===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(i).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],usage:{...r}}:$(r,s,e,a)};export{T as CAPABILITY_TO_FEATURE,v as DEFAULT_TARGET,y as PROJECT_CONFIG_FILE,$ as gateAgainstMatrix,O as gatePlatformFeatures,L as platformMatrixIds,b as readProjectTarget,E as resolveCodegenTarget};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as l}from"node:fs";import{join as p}from"node:path";import{Node as i}from"ts-morph";import{d as g,p as f}from"./ast-BYoSZlae.mjs";const d="flags.ts",c=new Set(["@lunora/flags/providers/flagship","lunorash/flags/flagship"]),u=e=>{const t=e.getSymbol();if(!t)return e.getText()==="flagshipProvider";for(const r of t.getDeclarations())if(i.isImportSpecifier(r))return c.has(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="flagshipProvider":!1;return!1},m=(e,t)=>{const r=e.getProperty(t);if(!r||!i.isPropertyAssignment(r))return;const o=r.getInitializerOrThrow();if(i.isStringLiteral(o)||i.isNoSubstitutionTemplateLiteral(o))return o.getLiteralValue()},v=e=>{const t=e.getArguments()[0];if(t&&i.isObjectLiteralExpression(t)){const r=m(t,"binding");if(r!==void 0&&r.length>0)return{bindingName:r,mode:"binding",provider:"flagship"}}return{mode:"http",provider:"flagship"}},h=e=>f(e.getArguments()[0],"provider"),P=(e,t)=>{const r=p(t,d);if(!l(r))return;const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=g(o);if(!n||!i.isCallExpression(n))return{provider:"custom"};const s=h(n);if(s&&i.isCallExpression(s)){const a=s.getExpression();if(i.isIdentifier(a)&&u(a))return v(s)}return{provider:"custom"}};export{d as FLAGS_FILENAME,P as discoverFlags};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./SCHEMA_SNAPSHOT_VERSION-
|
|
1
|
+
import"./SCHEMA_SNAPSHOT_VERSION-CTWRkAF5.mjs";import{G as t,U as m,n as r,e as o,a as n,b as l,c as A,d as E,f as S,g,h as C,o as c,p as d,i as p,j as u,k as D,l as f,m as h}from"./emit-BcAkLUfn.mjs";import"./paths-C-9fwEgQ.mjs";export{t as GENERATED_HEADER,m as UMBRELLA_BASE_PACKAGES,r as buildStorageColumns,o as emitAgents,n as emitApi,l as emitCollections,A as emitContainers,E as emitCrons,S as emitDataModel,g as emitDrizzleSchema,C as emitFunctions,c as emitQueues,d as emitSeed,p as emitServer,u as emitShard,D as emitVectors,f as emitWorkflows,h as emitWranglerCronTriggers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as m}from"node:fs";import{join as x}from"node:path";import{SyntaxKind as d,Node as c}from"ts-morph";import{l,a as g,d as P,h as E}from"./ast-
|
|
1
|
+
import{existsSync as m}from"node:fs";import{join as x}from"node:path";import{SyntaxKind as d,Node as c}from"ts-morph";import{l,a as g,d as P,h as E}from"./ast-BYoSZlae.mjs";import{c as S}from"./classify-procedure-call-Ib2EMtFH.mjs";const y="notify.ts",v=new Set(["chat","inApp","send","webhook"]),p=new Set(["broadcast","send"]),N=e=>{const t=e.getInitializer();if(!t||!c.isCallExpression(t))return;const s=S(t);if(!s)return;const o=E(t,s.receiver);return o?{exportName:e.getName(),handler:o,kind:s.kind}:void 0},h=e=>{const t=[];for(const s of e.getVariableStatements())if(s.isExported())for(const o of s.getDeclarations()){const r=N(o);r&&t.push(r)}return t},f=e=>{if(!c.isPropertyAccessExpression(e))return;const t=e.getName(),s=e.getExpression();if((t==="notify"||t==="push")&&c.isIdentifier(s)&&s.getText()==="ctx")return t;if(t==="push"&&f(s)==="notify")return"push"},F=e=>{if(!c.isPropertyAccessExpression(e))return;const t=e.getName(),s=f(e.getExpression());if(s==="notify"&&v.has(t))return`ctx.notify.${t}`;if(s==="push"&&p.has(t))return`ctx.push.${t}`},A=e=>c.isPropertyAccessExpression(e)?f(e.getExpression())==="push"&&p.has(e.getName()):!1,T=(e,t)=>{const s=[];for(const o of l(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o),a=g(t,o);for(const n of h(r))if(!(n.kind!=="query"&&n.kind!=="mutation"))for(const i of n.handler.getDescendantsOfKind(d.PropertyAccessExpression)){const u=F(i);u!==void 0&&s.push({callee:u,exportName:n.exportName,file:a,kind:n.kind,line:i.getStartLineNumber()})}}return s},O=(e,t)=>{for(const s of l(t)){const o=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const r of h(o))for(const a of r.handler.getDescendantsOfKind(d.PropertyAccessExpression))if(A(a))return!0}return!1},_=(e,t)=>{const s=x(t,y);if(!m(s))return;const o=e.getSourceFile(s)??e.addSourceFileAtPath(s),r=P(o);let a=!1,n=!1;if(r&&c.isCallExpression(r)){const i=r.getArguments()[0];i&&c.isObjectLiteralExpression(i)&&(a=i.getProperty("webPush")!==void 0,n=i.getProperty("fcm")!==void 0)}return{hasFcm:n,hasWebPush:a,usesPush:O(e,t)}};export{y as NOTIFY_FILENAME,T as discoverNotifyCalls,_ as discoverNotifyConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{G as c}from"./emit-
|
|
1
|
+
import{G as c}from"./emit-BcAkLUfn.mjs";import{s as u}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as m,objectSchema as p,LUNORA_ERROR_CODES as i}from"./LUNORA_ERROR_CODES-BYg8Lpgb.mjs";const l="1.3.2",d={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},R=e=>{const n=u(e.filePath),o=`${n}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${o}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${o}", "args": { … } }\`).`,errors:i.map((r,s)=>({code:-32e3-s,data:{code:r},message:r})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:p(e.args)}],result:{name:"result",schema:e.output?m(e.output):d},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},g=e=>{const n=e.version??"0.0.0",r=e.functions.filter(t=>t.visibility!=="internal"&&t.kind!=="stream").map(t=>R(t)).toSorted((t,a)=>t.name.localeCompare(a.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:n},methods:r,openrpc:l}},S=e=>`${JSON.stringify(g(e),void 0,2)}
|
|
2
2
|
`,v=e=>`${c}export const openRpcSpec: Record<string, unknown> = ${JSON.stringify(e,void 0,4)};
|
|
3
3
|
`;export{l as OPENRPC_VERSION,g as buildOpenRpcDocument,S as emitOpenRpc,v as emitOpenRpcModule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as g}from"node:fs";import{join as l}from"node:path";import{LunoraError as d}from"@lunora/errors";import{queueDefaultName as p,queueBindingName as f}from"@lunora/queue";import{SyntaxKind as y,Node as u}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as h}from"./ast-
|
|
1
|
+
import{existsSync as g}from"node:fs";import{join as l}from"node:path";import{LunoraError as d}from"@lunora/errors";import{queueDefaultName as p,queueBindingName as f}from"@lunora/queue";import{SyntaxKind as y,Node as u}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as h}from"./ast-BYoSZlae.mjs";const q="queues.ts",b=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineQueue";for(const e of t.getDeclarations())if(u.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue"?!1:e.getNameNode().getText()==="defineQueue";return!1},c=h("queue"),N=(r,t,e)=>{if(u.isNumericLiteral(r))return r.getLiteralValue();throw a(r,`queue "${t}": \`${e}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},w=(r,t)=>{const e=r.getProperty("name");if(!e||!u.isPropertyAssignment(e))return;const n=c(e.getInitializerOrThrow(),t,"name");if(n.length===0)throw a(e,`queue "${t}": \`name\` must be a non-empty string when provided`);return n},P=(r,t)=>{const e=r.getArguments()[0];if(!e||!u.isObjectLiteralExpression(e))throw a(r,`queue "${t}": defineQueue must be passed an inline object literal`);const n={bindingName:f(t),exportName:t,mode:"push",name:w(e,t)??p(t),tuning:{}},o=e.getProperty("mode");if(o&&u.isPropertyAssignment(o)){const i=c(o.getInitializerOrThrow(),t,"mode");if(i!=="push"&&i!=="pull")throw a(o,`queue "${t}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(i)})`);n.mode=i}const s=e.getProperty("deadLetterQueue");s&&u.isPropertyAssignment(s)&&(n.tuning.deadLetterQueue=c(s.getInitializerOrThrow(),t,"deadLetterQueue"));for(const i of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const m=e.getProperty(i);m&&u.isPropertyAssignment(m)&&(n.tuning[i]=N(m.getInitializerOrThrow(),t,i))}return n},E=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const n=e.getInitializer();if(n?.getKind()!==y.CallExpression)continue;const o=n,s=o.getExpression();if(!u.isIdentifier(s)||!b(s))continue;const i=e.getNameNode();if(!u.isIdentifier(i))throw a(i,"defineQueue exports must be plain named exports (no destructuring)");t.push(P(o,i.getText()))}return t},I=r=>{const t=new Map,e=new Map;for(const n of r){const o=t.get(n.name);if(o!==void 0)throw new d("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${n.name}": produced by both "${o}" and "${n.exportName}". Deployed queue names must be unique across the project.`,{status:500});t.set(n.name,n.exportName);const s=e.get(n.bindingName);if(s!==void 0)throw new d("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${n.bindingName}": produced by both "${s}" and "${n.exportName}". Queue export names must yield unique binding names.`,{status:500});e.set(n.bindingName,n.exportName)}},T=(r,t)=>{const e=l(t,q);if(!g(e))return[];const n=r.getSourceFile(e)??r.addSourceFileAtPath(e),o=E(n);return o.sort((s,i)=>s.exportName.localeCompare(i.exportName)),I(o),o};export{q as QUEUES_FILENAME,T as discoverQueues};
|