@lunora/config 1.0.0-alpha.39 → 1.0.0-alpha.390
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +135 -0
- package/README.md +3 -3
- package/dist/cli/index.d.mts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.mjs +1 -0
- package/dist/cloudflare/index.d.mts +1306 -0
- package/dist/cloudflare/index.d.ts +1306 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +845 -974
- package/dist/index.d.ts +845 -974
- package/dist/index.mjs +1 -23
- package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
- package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
- package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
- package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs +1 -0
- package/dist/packem_shared/CODEGEN_ENV-CkUo3_GU.mjs +1 -0
- package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs +1 -0
- package/dist/packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs +1 -0
- package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
- package/dist/packem_shared/DEV_WORKER_ENV_VALUE-CARjGoAv.mjs +1 -0
- package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
- package/dist/packem_shared/HYPERDRIVE_PLACEHOLDER_ID-ChryQmwG.mjs +2 -0
- package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs +1 -0
- package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
- package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
- package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-DI99PpTL.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BGmCp5gf.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DnbYTTWX.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-oGE8lMFF.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-DEi8zoNu.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-mdcw5KDY.mjs +1 -0
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
- package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
- package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
- package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
- package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
- package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
- package/dist/packem_shared/assertWranglerSatisfiesSchema-B4DcaiJY.mjs +3 -0
- package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
- package/dist/packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs +3 -0
- package/dist/packem_shared/blockingFindingsMessage-BVbijPdn.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-C5WZfMwe.mjs +19 -0
- package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
- package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
- package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
- package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
- package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.mts +184 -0
- package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.ts +184 -0
- package/dist/packem_shared/describePreservedCrons-C5KPuPy3.mjs +1 -0
- package/dist/packem_shared/describeWithheld-CbyzZjZF.mjs +1 -0
- package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
- package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
- package/dist/packem_shared/discoverSchemaInfo-BBRlXZop.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
- package/dist/packem_shared/guards-Buu_E7mP.mjs +1 -0
- package/dist/packem_shared/hasCloudflareCredentials-CNPVIVBb.mjs +1 -0
- package/dist/packem_shared/index.d-Cmx4jMFV.d.ts +270 -0
- package/dist/packem_shared/index.d-DkNi7r6E.d.mts +270 -0
- package/dist/packem_shared/infer-bindings.d-BNrKAI1c.d.mts +300 -0
- package/dist/packem_shared/infer-bindings.d-BNrKAI1c.d.ts +300 -0
- package/dist/packem_shared/inferLunoraBindings-BT4-fwiQ.mjs +1 -0
- package/dist/packem_shared/interpretRemote-CcmGeGZ_.mjs +1 -0
- package/dist/packem_shared/lunora-manifest-DuH_Cmyu.mjs +6 -0
- package/dist/packem_shared/materializeServiceDevConfigs-k_oLCcBT.mjs +1 -0
- package/dist/packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs +1 -0
- package/dist/packem_shared/package-secrets-registry-BEJELdls.mjs +1 -0
- package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
- package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
- package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
- package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
- package/dist/packem_shared/reconcile-services-DFqH4eMQ.mjs +1 -0
- package/dist/packem_shared/reconcileBindingsSafely-Bpi7q5vG.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
- package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
- package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
- package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
- package/dist/packem_shared/scanWranglerVariablesForSecrets-CZDS9y2i.mjs +1 -0
- package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
- package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
- package/dist/packem_shared/validate-bindings-PVHSAU6M.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-CF3pk_Ov.mjs +1 -0
- package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
- package/dist/packem_shared/wranglerCodegenInputs-UqO5e_qJ.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
- package/dist/packem_shared/write-atomic-zfU6flfm.mjs +1 -0
- package/dist/studio-host/index.d.mts +320 -110
- package/dist/studio-host/index.d.ts +320 -110
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +32 -7
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
- package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
- package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
- package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
- package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
- package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
- package/dist/packem_shared/buildPackageSecretsBlock-BCHtfQ2A.mjs +0 -280
- package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
- package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
- package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
- package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
- package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
- package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
- package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
- package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
- package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
- package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
- package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
- package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { SchemaIR, AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
2
|
+
/**
|
|
3
|
+
* An invocation-scoped memo for project discovery. A CLI command creates one,
|
|
4
|
+
* threads it through every `discover*` / `inferLunoraBindings` call it makes,
|
|
5
|
+
* and clears it after anything rewrites the sources discovery reads (codegen).
|
|
6
|
+
* Deliberately not module-level: tests and long-lived processes never see a
|
|
7
|
+
* stale result.
|
|
8
|
+
*/
|
|
9
|
+
interface DiscoveryCache {
|
|
10
|
+
/** Drop every memoised result. */
|
|
11
|
+
clear: () => void;
|
|
12
|
+
/** Return the result memoised under `key`, computing it on first use. */
|
|
13
|
+
memo: <T>(key: string, compute: () => T) => T;
|
|
14
|
+
}
|
|
15
|
+
declare const createDiscoveryCache: () => DiscoveryCache;
|
|
16
|
+
/** One filterable Vectorize metadata property a schema declares. */
|
|
17
|
+
interface VectorMetadataDeclaration {
|
|
18
|
+
/** The vector index the property belongs to. */
|
|
19
|
+
index: string;
|
|
20
|
+
/**
|
|
21
|
+
* The validator kind behind the column, with `v.optional(...)` and a
|
|
22
|
+
* nullable union unwrapped (metadata columns are usually optional), or
|
|
23
|
+
* `undefined` when the column isn't in the owning table's shape. Callers map it to the Vectorize
|
|
24
|
+
* metadata type; a kind that can't be filtered on is reported, not indexed.
|
|
25
|
+
*/
|
|
26
|
+
kind: string | undefined;
|
|
27
|
+
/** Column mirrored into vector metadata. */
|
|
28
|
+
property: string;
|
|
29
|
+
}
|
|
30
|
+
interface SchemaInfo {
|
|
31
|
+
/**
|
|
32
|
+
* Whether the schema declares a **D1-backed** `.global()` table — the only
|
|
33
|
+
* flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
|
|
34
|
+
* A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
|
|
35
|
+
* here demanded a D1 database of a project that has none.
|
|
36
|
+
*/
|
|
37
|
+
hasD1GlobalTable: boolean;
|
|
38
|
+
/** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
|
|
39
|
+
hasHyperdriveGlobalTable: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Data-residency jurisdiction declared via `defineSchema(...).jurisdiction("…")`.
|
|
42
|
+
* It pins the app's Durable Objects only; KV namespaces and R2 buckets carry
|
|
43
|
+
* their own jurisdiction, set when they are created.
|
|
44
|
+
*/
|
|
45
|
+
jurisdiction?: SchemaIR["jurisdiction"];
|
|
46
|
+
/** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
|
|
47
|
+
vectorIndexNames?: ReadonlyArray<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Metadata properties declared filterable on a vector index. Cloudflare
|
|
50
|
+
* needs an explicit metadata index per property before a `filter` can match
|
|
51
|
+
* anything, so deploy provisions these and doctor reports them.
|
|
52
|
+
*/
|
|
53
|
+
vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
|
|
54
|
+
}
|
|
55
|
+
interface DiscoverSchemaInfoResult {
|
|
56
|
+
/** Parse error message, when the schema exists but could not be analyzed. */
|
|
57
|
+
error?: string;
|
|
58
|
+
/** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
|
|
59
|
+
info: SchemaInfo | undefined;
|
|
60
|
+
}
|
|
61
|
+
/** Discover the schema facts, memoised on `cache` when one is given. */
|
|
62
|
+
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string, cache?: DiscoveryCache) => DiscoverSchemaInfoResult;
|
|
63
|
+
interface DurableObjectSpec {
|
|
64
|
+
binding: string;
|
|
65
|
+
className: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Canonical Durable Object class → binding name. wrangler requires the worker
|
|
69
|
+
* to export a class of this exact name, so detection keys on the class name.
|
|
70
|
+
*/
|
|
71
|
+
declare const DURABLE_OBJECT_BINDINGS: {
|
|
72
|
+
readonly LunoraDO: "SHARD";
|
|
73
|
+
readonly SchedulerDO: "SCHEDULER";
|
|
74
|
+
readonly SessionDO: "SESSION";
|
|
75
|
+
readonly ShardDO: "SHARD";
|
|
76
|
+
readonly ShardRegistryDO: "SHARD_REGISTRY";
|
|
77
|
+
};
|
|
78
|
+
type DurableObjectClass = keyof typeof DURABLE_OBJECT_BINDINGS;
|
|
79
|
+
/**
|
|
80
|
+
* The `_generated/` modules that hold a generated Durable Object / Workflow
|
|
81
|
+
* class — one per class kind a project can declare. wrangler validates every
|
|
82
|
+
* `class_name` against the worker's exports, so this is the set a worker entry
|
|
83
|
+
* re-exports (and the set the composed class-A entry star-re-exports for the
|
|
84
|
+
* kinds the project has).
|
|
85
|
+
*
|
|
86
|
+
* Owned here because four places need it and they must not drift:
|
|
87
|
+
* `@lunora/vite` emits one star re-export per entry, the wrangler validator
|
|
88
|
+
* DECIDES the composed entry's exports from it, `reconcile-bindings` types its
|
|
89
|
+
* export-gap `module` field on it, and this module's own `detectClassExports`
|
|
90
|
+
* probes the same names.
|
|
91
|
+
*
|
|
92
|
+
* `scheduler` carries no `define*` declarations of its own — codegen writes it
|
|
93
|
+
* off `hasScheduler` purely so the composed class-A entry has a `SchedulerDO`
|
|
94
|
+
* to forward. Its presence is therefore the ONLY signal the plugin and the
|
|
95
|
+
* validator need, and it is the same signal that decides whether the builder
|
|
96
|
+
* has a `.scheduler()` method at all. `@lunora/vite` depends on `@lunora/config`, so config
|
|
97
|
+
* owning it is the direction the dependency graph allows.
|
|
98
|
+
*/
|
|
99
|
+
declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "scheduler", "shardRegistry", "workflows"];
|
|
100
|
+
/** One {@link GENERATED_CLASS_MODULES} entry. */
|
|
101
|
+
type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
|
|
102
|
+
/**
|
|
103
|
+
* The framework Durable Object each class module forwards, for the modules that
|
|
104
|
+
* carry one: codegen writes them off the same signal that gives the builder the
|
|
105
|
+
* matching method, so the module's existence means the composed entry exports
|
|
106
|
+
* the class.
|
|
107
|
+
*/
|
|
108
|
+
declare const GENERATED_MODULE_DURABLE_OBJECTS: Partial<Record<GeneratedClassModule, DurableObjectClass>>;
|
|
109
|
+
/** The `_generated/` module codegen writes when `lunora.config` opts in to the merge. */
|
|
110
|
+
declare const MERGED_DURABLE_OBJECTS_MODULE: "durableObjects";
|
|
111
|
+
/**
|
|
112
|
+
* Whether the project merges its Durable Objects: codegen wrote the merge
|
|
113
|
+
* module. The one test the composed entry, binding inference and the export
|
|
114
|
+
* validator all ask — the same "module existence is the signal" rule the
|
|
115
|
+
* scheduler and registry modules follow.
|
|
116
|
+
*/
|
|
117
|
+
declare const isMergedProject: (generatedDirectory: string) => boolean;
|
|
118
|
+
/** Whether `module` holds a class the merged class hosts — imported into it, never re-exported. */
|
|
119
|
+
declare const isMergedRoleModule: (module: string) => boolean;
|
|
120
|
+
/**
|
|
121
|
+
* The class-B composed entry. `lunora deploy` passes this file to wrangler as
|
|
122
|
+
* the positional script whenever it exists, overriding `wrangler.main` — so it
|
|
123
|
+
* is what actually gets bundled and what wrangler checks its DO/Workflow
|
|
124
|
+
* bindings against. `main` in a class-B project names the framework adapter's
|
|
125
|
+
* build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
|
|
126
|
+
* exists after `vite build` and exports only the SSR fetch handler. Lexing that
|
|
127
|
+
* instead read every declared class as unexported: nothing provisioned, plus a
|
|
128
|
+
* "add `export * from …`" warning the user cannot silence.
|
|
129
|
+
*
|
|
130
|
+
* Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
|
|
131
|
+
* imports this constant, so the deploy's positional entry and the file this
|
|
132
|
+
* module lexes for exported classes cannot drift apart.
|
|
133
|
+
*/
|
|
134
|
+
declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
|
|
135
|
+
/**
|
|
136
|
+
* A `defineContainer` declaration plus whether its generated DO class is
|
|
137
|
+
* exported by the worker entry. Only exported containers are safe to
|
|
138
|
+
* provision — wrangler rejects a `containers[].class_name` (and its Durable
|
|
139
|
+
* Object binding) that the worker doesn't export.
|
|
140
|
+
*/
|
|
141
|
+
type InferredContainer = ContainerIR & {
|
|
142
|
+
exported: boolean;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* A `defineWorkflow` declaration plus whether its generated
|
|
146
|
+
* `WorkflowEntrypoint` class is exported by the worker entry. Only exported
|
|
147
|
+
* workflows are safe to provision — wrangler rejects an `exports.<Class>`
|
|
148
|
+
* workflow the worker doesn't export. Workflows are NOT Durable Objects, so this never
|
|
149
|
+
* implies a `durable_objects` binding or migration.
|
|
150
|
+
*/
|
|
151
|
+
interface InferredWorkflow extends WorkflowIR {
|
|
152
|
+
exported: boolean;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A `defineAgent` declaration plus whether its generated agent
|
|
156
|
+
* `WorkflowEntrypoint` class (e.g. `SupportAgentWorkflow`) is exported by the
|
|
157
|
+
* worker entry. An agent compiles onto a Cloudflare Workflow, so — exactly like
|
|
158
|
+
* {@link InferredWorkflow} — only exported agents are safe to provision
|
|
159
|
+
* (wrangler rejects an `exports.<Class>` workflow the worker doesn't export), and
|
|
160
|
+
* an agent is NOT a Durable Object (no `durable_objects` binding or migration).
|
|
161
|
+
*/
|
|
162
|
+
interface InferredAgent extends AgentIR {
|
|
163
|
+
exported: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A queue declared in `lunora/queues.ts`. Unlike workflows, a queue needs no
|
|
167
|
+
* worker-entry class export (its `queue()` handler rides `createWorker`), so
|
|
168
|
+
* there is no `exported` flag — every declared queue is reconcilable into the
|
|
169
|
+
* wrangler `queues.producers[]` / `queues.consumers[]`.
|
|
170
|
+
*/
|
|
171
|
+
type InferredQueue = QueueIR;
|
|
172
|
+
interface InferredBindings {
|
|
173
|
+
/** Agents declared in `lunora/agents.ts` (exported or not — see {@link InferredAgent.exported}); reconciled into wrangler `exports`. */
|
|
174
|
+
agents: InferredAgent[];
|
|
175
|
+
/** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
|
|
176
|
+
containers: InferredContainer[];
|
|
177
|
+
/** Durable Objects the worker entry exports → safe to bind. */
|
|
178
|
+
durableObjects: DurableObjectSpec[];
|
|
179
|
+
/**
|
|
180
|
+
* The wrangler `flagship[].binding` name implied by `lunora/flags.ts` when it
|
|
181
|
+
* uses the Flagship provider in binding mode — `undefined` for HTTP-mode
|
|
182
|
+
* Flagship, a custom OpenFeature provider, or no flags. The binding needs an
|
|
183
|
+
* un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
|
|
184
|
+
*/
|
|
185
|
+
flagshipBinding?: string;
|
|
186
|
+
/**
|
|
187
|
+
* The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
|
|
188
|
+
* hints whose resource takes its residency at creation (Artifacts), so the
|
|
189
|
+
* hint can name the jurisdiction to create it in.
|
|
190
|
+
*/
|
|
191
|
+
jurisdiction?: SchemaInfo["jurisdiction"];
|
|
192
|
+
/** Schema declares a `.global()` table → needs the `DB` D1 binding. */
|
|
193
|
+
needsD1: boolean;
|
|
194
|
+
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
195
|
+
queues: InferredQueue[];
|
|
196
|
+
/**
|
|
197
|
+
* Sibling Workers declared in `lunora.config` `services` → reconciled into
|
|
198
|
+
* `services[]` (plan 457). `undefined` when the declaration is unreadable, so
|
|
199
|
+
* reconcile leaves every entry alone rather than removing the owned ones.
|
|
200
|
+
*/
|
|
201
|
+
services: ServiceBindingIR[] | undefined;
|
|
202
|
+
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
203
|
+
signals: string[];
|
|
204
|
+
/** `@lunora/ai` is imported, `ctx.ai` read, or `env.AI` used → needs the `ai` Workers AI binding. */
|
|
205
|
+
usesAi: boolean;
|
|
206
|
+
/** `@lunora/bindings/ai-search` is value-imported or `ctx.aiSearch` read → self-describing `ai_search_namespaces` binding (`AI_SEARCH` on namespace `default`; auto-writeable). */
|
|
207
|
+
usesAiSearch: boolean;
|
|
208
|
+
/** `@lunora/bindings/analytics` is imported or `ctx.analytics` read → self-describing `analytics_engine_datasets` binding (auto-writeable). */
|
|
209
|
+
usesAnalytics: boolean;
|
|
210
|
+
/** `@lunora/bindings/analytics-sql` is value-imported or `ctx.analyticsSql` read → self-describing `analytics` binding (`{ binding: ANALYTICS_SQL }`; auto-writeable, wrangler >= 4.145.0). */
|
|
211
|
+
usesAnalyticsSql: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* `ctx.artifacts` is read or `@lunora/bindings/artifacts` value-imported.
|
|
214
|
+
* Reconcile writes the binding with the Worker's name as its namespace. The first repo
|
|
215
|
+
* `create()` against a missing namespace creates it UNRESTRICTED and the jurisdiction can
|
|
216
|
+
* never change after that, so `lunora deploy` creates a pinned schema's namespace in its
|
|
217
|
+
* jurisdiction, and stops when it can't.
|
|
218
|
+
*/
|
|
219
|
+
usesArtifacts: boolean;
|
|
220
|
+
/** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
|
|
221
|
+
usesAuth: boolean;
|
|
222
|
+
/** `@lunora/browser` is imported or `ctx.browser` read → self-describing `browser` binding (auto-writeable). */
|
|
223
|
+
usesBrowser: boolean;
|
|
224
|
+
/** `@lunora/auth/cimd/workers` is imported → needs the `global_fetch_strictly_public` compatibility flag (no binding; `lunora doctor` checks it). */
|
|
225
|
+
usesCimdWorkers: boolean;
|
|
226
|
+
/** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
|
|
227
|
+
usesFlags: boolean;
|
|
228
|
+
/** `@lunora/hyperdrive` is imported or `ctx.sql` read (reconcile writes `{ binding: "HYPERDRIVE" }` with a placeholder `id`; `lunora deploy` swaps in the created config's). */
|
|
229
|
+
usesHyperdrive: boolean;
|
|
230
|
+
/** `@lunora/bindings/images` is imported or `ctx.images` read → self-describing `images` binding (auto-writeable). */
|
|
231
|
+
usesImages: boolean;
|
|
232
|
+
/** `@lunora/bindings/kv` is imported or `ctx.kv` read (reconcile writes `{ binding: "KV" }` without an id and wrangler creates the namespace on deploy, unless the schema pins a jurisdiction). */
|
|
233
|
+
usesKv: boolean;
|
|
234
|
+
/** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). No `ctx.mail` helper exists, so only the import counts. */
|
|
235
|
+
usesMail: boolean;
|
|
236
|
+
/** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride `usesNotifyFcm` / `usesNotifyWebPush`). */
|
|
237
|
+
usesNotify: boolean;
|
|
238
|
+
/** `lunora/notify.ts` configures the `fcm` channel → the `FCM_*` secrets in `.dev.vars`. */
|
|
239
|
+
usesNotifyFcm: boolean;
|
|
240
|
+
/** `lunora/notify.ts` configures the `webPush` channel → the `VAPID_*` secrets in `.dev.vars`. */
|
|
241
|
+
usesNotifyWebPush: boolean;
|
|
242
|
+
/** `@lunora/payment/autumn` is imported → the Autumn secrets in `.dev.vars` (no binding). */
|
|
243
|
+
usesPaymentAutumn: boolean;
|
|
244
|
+
/** `@lunora/payment/creem` is imported → the Creem secrets in `.dev.vars` (no binding). */
|
|
245
|
+
usesPaymentCreem: boolean;
|
|
246
|
+
/** `@lunora/payment/dodopayments` is imported → the Dodo Payments secrets in `.dev.vars` (no binding). */
|
|
247
|
+
usesPaymentDodopayments: boolean;
|
|
248
|
+
/** `@lunora/payment/polar` is imported → the Polar secrets in `.dev.vars` (no binding). */
|
|
249
|
+
usesPaymentPolar: boolean;
|
|
250
|
+
/** `@lunora/payment` is imported or `ctx.payments` read (provider secrets must be set in `.dev.vars`; no binding). */
|
|
251
|
+
usesPayments: boolean;
|
|
252
|
+
/** `@lunora/payment/stripe` is imported → the Stripe secrets in `.dev.vars` (no binding). */
|
|
253
|
+
usesPaymentStripe: boolean;
|
|
254
|
+
/** `@lunora/bindings/pipelines` is value-imported or `ctx.pipelines` read (binding needs an un-mintable remote pipeline name; hint-only). */
|
|
255
|
+
usesPipelines: boolean;
|
|
256
|
+
/** `@lunora/bindings/r2sql` is value-imported or `ctx.r2sql` read (needs the `R2_SQL_*` secrets in `.dev.vars`; no binding). */
|
|
257
|
+
usesR2sql: boolean;
|
|
258
|
+
/** `lunora/` value-imports `requestSecretTool` from `@lunora/agent` → the `LUNORA_SECRET_VALUE_KEY` secret in `.dev.vars` (no binding). Read off the same rule codegen gates on. */
|
|
259
|
+
usesRequestSecretTool: boolean;
|
|
260
|
+
/** `@lunora/scheduler` is imported or `ctx.scheduler` read. */
|
|
261
|
+
usesScheduler: boolean;
|
|
262
|
+
/** `@lunora/storage` is imported or `ctx.storage` read under `lunora/` (R2 bucket binding name is user-defined). */
|
|
263
|
+
usesStorage: boolean;
|
|
264
|
+
/** `jsCodeTool` is imported from `@lunora/agent` in `lunora/` → self-describing `worker_loaders` binding (`LOADER`). */
|
|
265
|
+
usesWorkerLoader: boolean;
|
|
266
|
+
/** `@lunora/x402/pay` is imported or `ctx.x402` read — the agent-wallet pay rail signs from a Secrets Store binding paired with a spend policy (ActionCtx-only; hint-only). */
|
|
267
|
+
usesX402: boolean;
|
|
268
|
+
/** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
|
|
269
|
+
usesX402Charge: boolean;
|
|
270
|
+
/** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
|
|
271
|
+
workflows: InferredWorkflow[];
|
|
272
|
+
}
|
|
273
|
+
interface InferOptions {
|
|
274
|
+
/** Memoises the source scans, so one CLI invocation parses the project once. */
|
|
275
|
+
cache?: DiscoveryCache;
|
|
276
|
+
projectRoot: string;
|
|
277
|
+
/** Directories (relative to root) to scan. Defaults to `lunora` + `src`. */
|
|
278
|
+
scanDirs?: ReadonlyArray<string>;
|
|
279
|
+
/** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
|
|
280
|
+
schemaDir?: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Scan a Lunora project and report which Cloudflare bindings its code implies.
|
|
284
|
+
* Read-only: performs no writes. Binding provisioning is driven by the worker
|
|
285
|
+
* entry's Durable Object exports plus the schema's D1 need; capability imports
|
|
286
|
+
* surface as hints.
|
|
287
|
+
*/
|
|
288
|
+
declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBindings>;
|
|
289
|
+
/**
|
|
290
|
+
* The secret sources a project uses — the {@link PACKAGE_SECRETS_REGISTRY} keys
|
|
291
|
+
* whose secrets it needs, derived from its already-resolved {@link InferredBindings}.
|
|
292
|
+
*
|
|
293
|
+
* This is the canonical bridge between binding inference and the
|
|
294
|
+
* `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
|
|
295
|
+
* {@link FLAG_PACKAGES}' sources whose flag is `true` in `bindings` — in
|
|
296
|
+
* flag-name order — followed by the configured `@lunora/notify` channels
|
|
297
|
+
* ({@link SECRET_SOURCE_FLAGS}), keeping only sources that carry secrets.
|
|
298
|
+
*/
|
|
299
|
+
declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
|
|
300
|
+
export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GENERATED_CLASS_MODULES as G, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, DURABLE_OBJECT_BINDINGS as a, DiscoverSchemaInfoResult as b, GENERATED_MODULE_DURABLE_OBJECTS as c, GeneratedClassModule as d, InferredAgent as e, InferredBindings as f, InferredContainer as g, InferredWorkflow as h, createDiscoveryCache as i, discoverSchemaInfo as j, inferLunoraBindings as k, isMergedProject as l, isMergedRoleModule as m, secretSourcesFromBindings as s };
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { SchemaIR, AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
2
|
+
/**
|
|
3
|
+
* An invocation-scoped memo for project discovery. A CLI command creates one,
|
|
4
|
+
* threads it through every `discover*` / `inferLunoraBindings` call it makes,
|
|
5
|
+
* and clears it after anything rewrites the sources discovery reads (codegen).
|
|
6
|
+
* Deliberately not module-level: tests and long-lived processes never see a
|
|
7
|
+
* stale result.
|
|
8
|
+
*/
|
|
9
|
+
interface DiscoveryCache {
|
|
10
|
+
/** Drop every memoised result. */
|
|
11
|
+
clear: () => void;
|
|
12
|
+
/** Return the result memoised under `key`, computing it on first use. */
|
|
13
|
+
memo: <T>(key: string, compute: () => T) => T;
|
|
14
|
+
}
|
|
15
|
+
declare const createDiscoveryCache: () => DiscoveryCache;
|
|
16
|
+
/** One filterable Vectorize metadata property a schema declares. */
|
|
17
|
+
interface VectorMetadataDeclaration {
|
|
18
|
+
/** The vector index the property belongs to. */
|
|
19
|
+
index: string;
|
|
20
|
+
/**
|
|
21
|
+
* The validator kind behind the column, with `v.optional(...)` and a
|
|
22
|
+
* nullable union unwrapped (metadata columns are usually optional), or
|
|
23
|
+
* `undefined` when the column isn't in the owning table's shape. Callers map it to the Vectorize
|
|
24
|
+
* metadata type; a kind that can't be filtered on is reported, not indexed.
|
|
25
|
+
*/
|
|
26
|
+
kind: string | undefined;
|
|
27
|
+
/** Column mirrored into vector metadata. */
|
|
28
|
+
property: string;
|
|
29
|
+
}
|
|
30
|
+
interface SchemaInfo {
|
|
31
|
+
/**
|
|
32
|
+
* Whether the schema declares a **D1-backed** `.global()` table — the only
|
|
33
|
+
* flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
|
|
34
|
+
* A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
|
|
35
|
+
* here demanded a D1 database of a project that has none.
|
|
36
|
+
*/
|
|
37
|
+
hasD1GlobalTable: boolean;
|
|
38
|
+
/** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
|
|
39
|
+
hasHyperdriveGlobalTable: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Data-residency jurisdiction declared via `defineSchema(...).jurisdiction("…")`.
|
|
42
|
+
* It pins the app's Durable Objects only; KV namespaces and R2 buckets carry
|
|
43
|
+
* their own jurisdiction, set when they are created.
|
|
44
|
+
*/
|
|
45
|
+
jurisdiction?: SchemaIR["jurisdiction"];
|
|
46
|
+
/** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
|
|
47
|
+
vectorIndexNames?: ReadonlyArray<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Metadata properties declared filterable on a vector index. Cloudflare
|
|
50
|
+
* needs an explicit metadata index per property before a `filter` can match
|
|
51
|
+
* anything, so deploy provisions these and doctor reports them.
|
|
52
|
+
*/
|
|
53
|
+
vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
|
|
54
|
+
}
|
|
55
|
+
interface DiscoverSchemaInfoResult {
|
|
56
|
+
/** Parse error message, when the schema exists but could not be analyzed. */
|
|
57
|
+
error?: string;
|
|
58
|
+
/** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
|
|
59
|
+
info: SchemaInfo | undefined;
|
|
60
|
+
}
|
|
61
|
+
/** Discover the schema facts, memoised on `cache` when one is given. */
|
|
62
|
+
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string, cache?: DiscoveryCache) => DiscoverSchemaInfoResult;
|
|
63
|
+
interface DurableObjectSpec {
|
|
64
|
+
binding: string;
|
|
65
|
+
className: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Canonical Durable Object class → binding name. wrangler requires the worker
|
|
69
|
+
* to export a class of this exact name, so detection keys on the class name.
|
|
70
|
+
*/
|
|
71
|
+
declare const DURABLE_OBJECT_BINDINGS: {
|
|
72
|
+
readonly LunoraDO: "SHARD";
|
|
73
|
+
readonly SchedulerDO: "SCHEDULER";
|
|
74
|
+
readonly SessionDO: "SESSION";
|
|
75
|
+
readonly ShardDO: "SHARD";
|
|
76
|
+
readonly ShardRegistryDO: "SHARD_REGISTRY";
|
|
77
|
+
};
|
|
78
|
+
type DurableObjectClass = keyof typeof DURABLE_OBJECT_BINDINGS;
|
|
79
|
+
/**
|
|
80
|
+
* The `_generated/` modules that hold a generated Durable Object / Workflow
|
|
81
|
+
* class — one per class kind a project can declare. wrangler validates every
|
|
82
|
+
* `class_name` against the worker's exports, so this is the set a worker entry
|
|
83
|
+
* re-exports (and the set the composed class-A entry star-re-exports for the
|
|
84
|
+
* kinds the project has).
|
|
85
|
+
*
|
|
86
|
+
* Owned here because four places need it and they must not drift:
|
|
87
|
+
* `@lunora/vite` emits one star re-export per entry, the wrangler validator
|
|
88
|
+
* DECIDES the composed entry's exports from it, `reconcile-bindings` types its
|
|
89
|
+
* export-gap `module` field on it, and this module's own `detectClassExports`
|
|
90
|
+
* probes the same names.
|
|
91
|
+
*
|
|
92
|
+
* `scheduler` carries no `define*` declarations of its own — codegen writes it
|
|
93
|
+
* off `hasScheduler` purely so the composed class-A entry has a `SchedulerDO`
|
|
94
|
+
* to forward. Its presence is therefore the ONLY signal the plugin and the
|
|
95
|
+
* validator need, and it is the same signal that decides whether the builder
|
|
96
|
+
* has a `.scheduler()` method at all. `@lunora/vite` depends on `@lunora/config`, so config
|
|
97
|
+
* owning it is the direction the dependency graph allows.
|
|
98
|
+
*/
|
|
99
|
+
declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "scheduler", "shardRegistry", "workflows"];
|
|
100
|
+
/** One {@link GENERATED_CLASS_MODULES} entry. */
|
|
101
|
+
type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
|
|
102
|
+
/**
|
|
103
|
+
* The framework Durable Object each class module forwards, for the modules that
|
|
104
|
+
* carry one: codegen writes them off the same signal that gives the builder the
|
|
105
|
+
* matching method, so the module's existence means the composed entry exports
|
|
106
|
+
* the class.
|
|
107
|
+
*/
|
|
108
|
+
declare const GENERATED_MODULE_DURABLE_OBJECTS: Partial<Record<GeneratedClassModule, DurableObjectClass>>;
|
|
109
|
+
/** The `_generated/` module codegen writes when `lunora.config` opts in to the merge. */
|
|
110
|
+
declare const MERGED_DURABLE_OBJECTS_MODULE: "durableObjects";
|
|
111
|
+
/**
|
|
112
|
+
* Whether the project merges its Durable Objects: codegen wrote the merge
|
|
113
|
+
* module. The one test the composed entry, binding inference and the export
|
|
114
|
+
* validator all ask — the same "module existence is the signal" rule the
|
|
115
|
+
* scheduler and registry modules follow.
|
|
116
|
+
*/
|
|
117
|
+
declare const isMergedProject: (generatedDirectory: string) => boolean;
|
|
118
|
+
/** Whether `module` holds a class the merged class hosts — imported into it, never re-exported. */
|
|
119
|
+
declare const isMergedRoleModule: (module: string) => boolean;
|
|
120
|
+
/**
|
|
121
|
+
* The class-B composed entry. `lunora deploy` passes this file to wrangler as
|
|
122
|
+
* the positional script whenever it exists, overriding `wrangler.main` — so it
|
|
123
|
+
* is what actually gets bundled and what wrangler checks its DO/Workflow
|
|
124
|
+
* bindings against. `main` in a class-B project names the framework adapter's
|
|
125
|
+
* build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
|
|
126
|
+
* exists after `vite build` and exports only the SSR fetch handler. Lexing that
|
|
127
|
+
* instead read every declared class as unexported: nothing provisioned, plus a
|
|
128
|
+
* "add `export * from …`" warning the user cannot silence.
|
|
129
|
+
*
|
|
130
|
+
* Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
|
|
131
|
+
* imports this constant, so the deploy's positional entry and the file this
|
|
132
|
+
* module lexes for exported classes cannot drift apart.
|
|
133
|
+
*/
|
|
134
|
+
declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
|
|
135
|
+
/**
|
|
136
|
+
* A `defineContainer` declaration plus whether its generated DO class is
|
|
137
|
+
* exported by the worker entry. Only exported containers are safe to
|
|
138
|
+
* provision — wrangler rejects a `containers[].class_name` (and its Durable
|
|
139
|
+
* Object binding) that the worker doesn't export.
|
|
140
|
+
*/
|
|
141
|
+
type InferredContainer = ContainerIR & {
|
|
142
|
+
exported: boolean;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* A `defineWorkflow` declaration plus whether its generated
|
|
146
|
+
* `WorkflowEntrypoint` class is exported by the worker entry. Only exported
|
|
147
|
+
* workflows are safe to provision — wrangler rejects an `exports.<Class>`
|
|
148
|
+
* workflow the worker doesn't export. Workflows are NOT Durable Objects, so this never
|
|
149
|
+
* implies a `durable_objects` binding or migration.
|
|
150
|
+
*/
|
|
151
|
+
interface InferredWorkflow extends WorkflowIR {
|
|
152
|
+
exported: boolean;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A `defineAgent` declaration plus whether its generated agent
|
|
156
|
+
* `WorkflowEntrypoint` class (e.g. `SupportAgentWorkflow`) is exported by the
|
|
157
|
+
* worker entry. An agent compiles onto a Cloudflare Workflow, so — exactly like
|
|
158
|
+
* {@link InferredWorkflow} — only exported agents are safe to provision
|
|
159
|
+
* (wrangler rejects an `exports.<Class>` workflow the worker doesn't export), and
|
|
160
|
+
* an agent is NOT a Durable Object (no `durable_objects` binding or migration).
|
|
161
|
+
*/
|
|
162
|
+
interface InferredAgent extends AgentIR {
|
|
163
|
+
exported: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A queue declared in `lunora/queues.ts`. Unlike workflows, a queue needs no
|
|
167
|
+
* worker-entry class export (its `queue()` handler rides `createWorker`), so
|
|
168
|
+
* there is no `exported` flag — every declared queue is reconcilable into the
|
|
169
|
+
* wrangler `queues.producers[]` / `queues.consumers[]`.
|
|
170
|
+
*/
|
|
171
|
+
type InferredQueue = QueueIR;
|
|
172
|
+
interface InferredBindings {
|
|
173
|
+
/** Agents declared in `lunora/agents.ts` (exported or not — see {@link InferredAgent.exported}); reconciled into wrangler `exports`. */
|
|
174
|
+
agents: InferredAgent[];
|
|
175
|
+
/** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
|
|
176
|
+
containers: InferredContainer[];
|
|
177
|
+
/** Durable Objects the worker entry exports → safe to bind. */
|
|
178
|
+
durableObjects: DurableObjectSpec[];
|
|
179
|
+
/**
|
|
180
|
+
* The wrangler `flagship[].binding` name implied by `lunora/flags.ts` when it
|
|
181
|
+
* uses the Flagship provider in binding mode — `undefined` for HTTP-mode
|
|
182
|
+
* Flagship, a custom OpenFeature provider, or no flags. The binding needs an
|
|
183
|
+
* un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
|
|
184
|
+
*/
|
|
185
|
+
flagshipBinding?: string;
|
|
186
|
+
/**
|
|
187
|
+
* The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
|
|
188
|
+
* hints whose resource takes its residency at creation (Artifacts), so the
|
|
189
|
+
* hint can name the jurisdiction to create it in.
|
|
190
|
+
*/
|
|
191
|
+
jurisdiction?: SchemaInfo["jurisdiction"];
|
|
192
|
+
/** Schema declares a `.global()` table → needs the `DB` D1 binding. */
|
|
193
|
+
needsD1: boolean;
|
|
194
|
+
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
195
|
+
queues: InferredQueue[];
|
|
196
|
+
/**
|
|
197
|
+
* Sibling Workers declared in `lunora.config` `services` → reconciled into
|
|
198
|
+
* `services[]` (plan 457). `undefined` when the declaration is unreadable, so
|
|
199
|
+
* reconcile leaves every entry alone rather than removing the owned ones.
|
|
200
|
+
*/
|
|
201
|
+
services: ServiceBindingIR[] | undefined;
|
|
202
|
+
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
203
|
+
signals: string[];
|
|
204
|
+
/** `@lunora/ai` is imported, `ctx.ai` read, or `env.AI` used → needs the `ai` Workers AI binding. */
|
|
205
|
+
usesAi: boolean;
|
|
206
|
+
/** `@lunora/bindings/ai-search` is value-imported or `ctx.aiSearch` read → self-describing `ai_search_namespaces` binding (`AI_SEARCH` on namespace `default`; auto-writeable). */
|
|
207
|
+
usesAiSearch: boolean;
|
|
208
|
+
/** `@lunora/bindings/analytics` is imported or `ctx.analytics` read → self-describing `analytics_engine_datasets` binding (auto-writeable). */
|
|
209
|
+
usesAnalytics: boolean;
|
|
210
|
+
/** `@lunora/bindings/analytics-sql` is value-imported or `ctx.analyticsSql` read → self-describing `analytics` binding (`{ binding: ANALYTICS_SQL }`; auto-writeable, wrangler >= 4.145.0). */
|
|
211
|
+
usesAnalyticsSql: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* `ctx.artifacts` is read or `@lunora/bindings/artifacts` value-imported.
|
|
214
|
+
* Reconcile writes the binding with the Worker's name as its namespace. The first repo
|
|
215
|
+
* `create()` against a missing namespace creates it UNRESTRICTED and the jurisdiction can
|
|
216
|
+
* never change after that, so `lunora deploy` creates a pinned schema's namespace in its
|
|
217
|
+
* jurisdiction, and stops when it can't.
|
|
218
|
+
*/
|
|
219
|
+
usesArtifacts: boolean;
|
|
220
|
+
/** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
|
|
221
|
+
usesAuth: boolean;
|
|
222
|
+
/** `@lunora/browser` is imported or `ctx.browser` read → self-describing `browser` binding (auto-writeable). */
|
|
223
|
+
usesBrowser: boolean;
|
|
224
|
+
/** `@lunora/auth/cimd/workers` is imported → needs the `global_fetch_strictly_public` compatibility flag (no binding; `lunora doctor` checks it). */
|
|
225
|
+
usesCimdWorkers: boolean;
|
|
226
|
+
/** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
|
|
227
|
+
usesFlags: boolean;
|
|
228
|
+
/** `@lunora/hyperdrive` is imported or `ctx.sql` read (reconcile writes `{ binding: "HYPERDRIVE" }` with a placeholder `id`; `lunora deploy` swaps in the created config's). */
|
|
229
|
+
usesHyperdrive: boolean;
|
|
230
|
+
/** `@lunora/bindings/images` is imported or `ctx.images` read → self-describing `images` binding (auto-writeable). */
|
|
231
|
+
usesImages: boolean;
|
|
232
|
+
/** `@lunora/bindings/kv` is imported or `ctx.kv` read (reconcile writes `{ binding: "KV" }` without an id and wrangler creates the namespace on deploy, unless the schema pins a jurisdiction). */
|
|
233
|
+
usesKv: boolean;
|
|
234
|
+
/** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). No `ctx.mail` helper exists, so only the import counts. */
|
|
235
|
+
usesMail: boolean;
|
|
236
|
+
/** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride `usesNotifyFcm` / `usesNotifyWebPush`). */
|
|
237
|
+
usesNotify: boolean;
|
|
238
|
+
/** `lunora/notify.ts` configures the `fcm` channel → the `FCM_*` secrets in `.dev.vars`. */
|
|
239
|
+
usesNotifyFcm: boolean;
|
|
240
|
+
/** `lunora/notify.ts` configures the `webPush` channel → the `VAPID_*` secrets in `.dev.vars`. */
|
|
241
|
+
usesNotifyWebPush: boolean;
|
|
242
|
+
/** `@lunora/payment/autumn` is imported → the Autumn secrets in `.dev.vars` (no binding). */
|
|
243
|
+
usesPaymentAutumn: boolean;
|
|
244
|
+
/** `@lunora/payment/creem` is imported → the Creem secrets in `.dev.vars` (no binding). */
|
|
245
|
+
usesPaymentCreem: boolean;
|
|
246
|
+
/** `@lunora/payment/dodopayments` is imported → the Dodo Payments secrets in `.dev.vars` (no binding). */
|
|
247
|
+
usesPaymentDodopayments: boolean;
|
|
248
|
+
/** `@lunora/payment/polar` is imported → the Polar secrets in `.dev.vars` (no binding). */
|
|
249
|
+
usesPaymentPolar: boolean;
|
|
250
|
+
/** `@lunora/payment` is imported or `ctx.payments` read (provider secrets must be set in `.dev.vars`; no binding). */
|
|
251
|
+
usesPayments: boolean;
|
|
252
|
+
/** `@lunora/payment/stripe` is imported → the Stripe secrets in `.dev.vars` (no binding). */
|
|
253
|
+
usesPaymentStripe: boolean;
|
|
254
|
+
/** `@lunora/bindings/pipelines` is value-imported or `ctx.pipelines` read (binding needs an un-mintable remote pipeline name; hint-only). */
|
|
255
|
+
usesPipelines: boolean;
|
|
256
|
+
/** `@lunora/bindings/r2sql` is value-imported or `ctx.r2sql` read (needs the `R2_SQL_*` secrets in `.dev.vars`; no binding). */
|
|
257
|
+
usesR2sql: boolean;
|
|
258
|
+
/** `lunora/` value-imports `requestSecretTool` from `@lunora/agent` → the `LUNORA_SECRET_VALUE_KEY` secret in `.dev.vars` (no binding). Read off the same rule codegen gates on. */
|
|
259
|
+
usesRequestSecretTool: boolean;
|
|
260
|
+
/** `@lunora/scheduler` is imported or `ctx.scheduler` read. */
|
|
261
|
+
usesScheduler: boolean;
|
|
262
|
+
/** `@lunora/storage` is imported or `ctx.storage` read under `lunora/` (R2 bucket binding name is user-defined). */
|
|
263
|
+
usesStorage: boolean;
|
|
264
|
+
/** `jsCodeTool` is imported from `@lunora/agent` in `lunora/` → self-describing `worker_loaders` binding (`LOADER`). */
|
|
265
|
+
usesWorkerLoader: boolean;
|
|
266
|
+
/** `@lunora/x402/pay` is imported or `ctx.x402` read — the agent-wallet pay rail signs from a Secrets Store binding paired with a spend policy (ActionCtx-only; hint-only). */
|
|
267
|
+
usesX402: boolean;
|
|
268
|
+
/** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
|
|
269
|
+
usesX402Charge: boolean;
|
|
270
|
+
/** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
|
|
271
|
+
workflows: InferredWorkflow[];
|
|
272
|
+
}
|
|
273
|
+
interface InferOptions {
|
|
274
|
+
/** Memoises the source scans, so one CLI invocation parses the project once. */
|
|
275
|
+
cache?: DiscoveryCache;
|
|
276
|
+
projectRoot: string;
|
|
277
|
+
/** Directories (relative to root) to scan. Defaults to `lunora` + `src`. */
|
|
278
|
+
scanDirs?: ReadonlyArray<string>;
|
|
279
|
+
/** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
|
|
280
|
+
schemaDir?: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Scan a Lunora project and report which Cloudflare bindings its code implies.
|
|
284
|
+
* Read-only: performs no writes. Binding provisioning is driven by the worker
|
|
285
|
+
* entry's Durable Object exports plus the schema's D1 need; capability imports
|
|
286
|
+
* surface as hints.
|
|
287
|
+
*/
|
|
288
|
+
declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBindings>;
|
|
289
|
+
/**
|
|
290
|
+
* The secret sources a project uses — the {@link PACKAGE_SECRETS_REGISTRY} keys
|
|
291
|
+
* whose secrets it needs, derived from its already-resolved {@link InferredBindings}.
|
|
292
|
+
*
|
|
293
|
+
* This is the canonical bridge between binding inference and the
|
|
294
|
+
* `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
|
|
295
|
+
* {@link FLAG_PACKAGES}' sources whose flag is `true` in `bindings` — in
|
|
296
|
+
* flag-name order — followed by the configured `@lunora/notify` channels
|
|
297
|
+
* ({@link SECRET_SOURCE_FLAGS}), keeping only sources that carry secrets.
|
|
298
|
+
*/
|
|
299
|
+
declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
|
|
300
|
+
export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GENERATED_CLASS_MODULES as G, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, DURABLE_OBJECT_BINDINGS as a, DiscoverSchemaInfoResult as b, GENERATED_MODULE_DURABLE_OBJECTS as c, GeneratedClassModule as d, InferredAgent as e, InferredBindings as f, InferredContainer as g, InferredWorkflow as h, createDiscoveryCache as i, discoverSchemaInfo as j, inferLunoraBindings as k, isMergedProject as l, isMergedRoleModule as m, secretSourcesFromBindings as s };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as O,statSync as P,readFileSync as F,readdirSync as k}from"node:fs";import{discoverFlags as L,FLAGS_FILENAME as B,discoverQueues as G,CAPABILITY_PROBES as $,readServiceBindings as W,discoverNotifyChannels as q,NOTIFY_FILENAME as Y,mayReadCapabilityContext as K,foldCapabilitySignals as C,capabilitiesUsedBy as U,sourceCapabilitySignals as M}from"@lunora/codegen";import{init as V}from"es-module-lexer";import{Project as H}from"ts-morph";import{discoverAgentInfo as X}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as Q}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as J}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as x}from"./discover-info-DC2MrAIM.mjs";import{relative as z,sep as Z,isAbsolute as ee,join as S}from"node:path";import{P as se}from"./package-secrets-registry-BEJELdls.mjs";import{discoverSchemaInfo as te}from"./discoverSchemaInfo-BBRlXZop.mjs";import{resolveWorkerEntry as re,composedEntryDurableObjects as oe,GENERATED_DIRECTORY as _,DURABLE_OBJECT_BINDINGS as ne,detectExportedDurableObjects as ae,detectClassExports as R,isMergedProject as ie}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import{discoverWorkflowInfo as ce}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const de=(e,s)=>{const{error:r,value:t}=x(e,s,B,L);return r===void 0?{flags:t}:{error:r}},ue=(e,s)=>{const r=z(s,e);return r!==""&&r!==".."&&!r.startsWith(`..${Z}`)&&!ee(r)},le=(e,s)=>{const{error:r,value:t}=x(e,s,void 0,G);return r===void 0?{queues:t??[]}:{error:r,queues:[]}},me=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),pe=new Set([".git",".lunora-cache",".wrangler","dist",_,"node_modules"]),he=["lunora","src"],fe=/\benv\s*\.\s*DB\b/,ge=/\benv\s*\.\s*AI\b/,D=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],T=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,w=[["usesAuth","@lunora/auth"],["usesCimdWorkers","@lunora/auth/cimd/workers"],["usesX402Charge","@lunora/x402/charge"],["usesPaymentAutumn","@lunora/payment/autumn"],["usesPaymentCreem","@lunora/payment/creem"],["usesPaymentDodopayments","@lunora/payment/dodopayments"],["usesPaymentPolar","@lunora/payment/polar"],["usesPaymentStripe","@lunora/payment/stripe"]],N=[...D.map(e=>[T(e),$[e].moduleSpecifier]),...w].toSorted(([e],[s])=>e.localeCompare(s)),Se=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyWebPush","@lunora/notify:webPush"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],be=["@lunora/agent","@lunora/agent/sandbox"],ye=new RegExp(String.raw`["'\x60](?:${[...N.map(([,e])=>e),...be].map(e=>J(e)).join("|")})["'\x60]`,"u"),n=e=>{const{contextProperty:s,moduleSpecifier:r}=$[e];return s===void 0?`${r} is imported`:`${r} is imported or ctx.${s} is read`},ve="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",Ee=()=>{let e;return()=>(e??=new H({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),e)},Ae=/\bfrom\s+["']\.{1,2}\//u,Re=(e,s,r)=>{const t=r(),o=t.createSourceFile(s,e,{overwrite:!0}),a=M(o);return t.removeSourceFile(o),a},j=(e,s)=>{let r;try{r=k(e,{withFileTypes:!0})}catch{return}for(const t of r){if(t.isDirectory()){pe.has(t.name)||j(S(e,t.name),s);continue}const o=t.name.lastIndexOf(".");o!==-1&&me.has(t.name.slice(o))&&s.push(S(e,t.name))}},_e=(e,s,r)=>{const{info:t}=te(e,s,r);return{jurisdiction:t?.jurisdiction,needsD1:t?.hasD1GlobalTable??!1}},xe=(e,s,r)=>{const t=Ee(),o=S(e,r),a=[],d=[];let u=!1,i=!1;for(const l of s){const h=S(e,l);if(!O(h)||!P(h).isDirectory())continue;const f=[];j(h,f);for(const m of f){const c=F(m,"utf8"),A=ue(m,o);u||=ge.test(c),i||=fe.test(c),(ye.test(c)||A&&(K(c)||Ae.test(c)))&&(A?a:d).push(Re(c,m,t))}}const p=C(a),b=C([p,...d]),y=new Set([...b.valueImports,...b.dynamicImports]),v=U({contextReads:p.contextReads,valueImports:y});return{...Object.fromEntries([...D.map(l=>[T(l),v.has(l)]),...w.map(([l,h])=>[l,y.has(h)])]),needsD1:i,usesRequestSecretTool:p.requestSecretTool,usesAi:v.has("ai")||u,usesBrowser:v.has("browser")||p.sandboxTools.usesSandboxBrowser,usesWorkerLoader:p.sandboxTools.usesSandboxLoader}},Ie=(e,s,r)=>[...e.map(t=>t.exported?`${t.bindingName}/${t.className} (container "${t.exportName}" declared and exported)`:`hint: container "${t.exportName}" is declared but ${t.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(t=>t.exported?`exports.${t.className} (workflow "${t.exportName}" declared and exported)`:`hint: workflow "${t.exportName}" is declared but ${t.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...r.map(t=>t.exported?`exports.${t.className} (agent "${t.exportName}" declared and exported)`:`hint: agent "${t.exportName}" is declared but ${t.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Ce=(e,s,r)=>[[e.usesAi,`AI (${n("ai")}, or env.AI is used)`],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),`hint: ${n("scheduler")}, but no SchedulerDO is exported by the worker entry`],[e.usesStorage,`hint: ${n("storage")}; add an r2_buckets binding (bucket binding names are user-defined)`],[e.usesMail,`hint: ${n("mail")}; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)`],[e.usesPayments,`hint: ${n("payments")}; set the provider secrets in .dev.vars — ${ve}`],[e.usesBrowser,`browser (${n("browser")}, or a sandbox browserTool imported in lunora/) — self-describing { binding: BROWSER }`],[e.usesImages,`images (${n("images")}) — self-describing { binding: IMAGES }`],[e.usesAnalytics,`analytics_engine_datasets (${n("analytics")}) — self-describing { binding: ANALYTICS, dataset }`],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesAiSearch,`ai_search_namespaces (${n("aiSearch")}) — self-describing { binding: AI_SEARCH, namespace: "default" }; remote-only, so \`lunora dev\` reaches the deployed AI Search service`],[e.usesAnalyticsSql,`analytics (${n("analyticsSql")}) — self-describing { binding: ANALYTICS_SQL }; needs wrangler >= 4.145.0, and is remote-only, so \`lunora dev\` queries the account's live analytics`],[e.usesKv,r.jurisdiction===void 0?`kv_namespaces (${n("kv")}) — { binding: KV } with no id; wrangler creates the namespace on the first deploy`:`hint: ${n("kv")} and the schema pins "${r.jurisdiction}"; create the namespace with --jurisdiction ${r.jurisdiction} and add a kv_namespaces binding ({ binding, id })`],[e.usesHyperdrive,`hyperdrive (${n("hyperdrive")}) — { binding: HYPERDRIVE } with a placeholder id; dev uses an embedded Postgres and \`lunora deploy\` creates the config`],[e.usesPipelines,`hint: ${n("pipelines")}; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned`],[e.usesArtifacts,r.jurisdiction===void 0?`artifacts (${n("artifacts")}) — { binding: ARTIFACTS, namespace }`:`hint: ${n("artifacts")}; the schema pins data to "${r.jurisdiction}", so create the namespace in that jurisdiction first and add { binding: ARTIFACTS, namespace } yourself — \`lunora deploy\` then checks it (a first create() in dev would make it unrestricted)`],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402,`hint: ${n("x402")} (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned`]].filter(([o])=>o).map(([,o])=>o),$e=(e,s,r,t=[],o=[],a=[])=>{const d=new Set(e.map(i=>i.className)),u=e.map(i=>`${i.binding}/${i.className} (exported by worker entry)`);return s.needsD1&&u.push("DB (.global() table declared)"),u.push(...Ie(t,o,a),...Ce(r,d,s)),u},qe=async e=>{await V;const s=e.schemaDir??"lunora",r=e.scanDirs??he,t=()=>xe(e.projectRoot,r,s),o=e.cache===void 0?t():e.cache.memo(`capabilities:${e.projectRoot}:${s}:${r.join(",")}`,t),a=re(e.projectRoot);let d;a.composed?d=oe(S(e.projectRoot,s,_)).map(I=>({binding:ne[I],className:I})):d=a.path===void 0?[]:ae(a.path);const u=_e(e.projectRoot,s,e.cache),i={...u,needsD1:o.needsD1||u.needsD1},p=R(a,Q(e.projectRoot,s,e.cache).containers,"containers"),b=R(a,ce(e.projectRoot,s).workflows,"workflows"),y=R(a,X(e.projectRoot,s).agents,"agents"),v=[...le(e.projectRoot,s).queues],{flags:E}=de(e.projectRoot,s),l=x(e.projectRoot,s,Y,q),h=l.error===void 0?l.value:{hasFcm:!0,hasWebPush:!0},f=E?.provider==="flagship"&&E.mode==="binding"?E.bindingName:void 0,m=$e(d,i,o,p,b,y);!a.composed&&ie(S(e.projectRoot,s,_))&&!d.some(g=>g.className==="LunoraDO")&&m.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),f!==void 0&&m.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${f}", app_id }) — the app_id can't be auto-provisioned`);const c=W(e.projectRoot),A=c.error===void 0?c.services:void 0;return c.error!==void 0&&m.push(`hint: lunora.config \`services\` not reconciled — ${c.error}`),m.push(...c.services.map(g=>`${g.binding} → ${g.worker} (lunora.config services.${g.name})`)),{...o,agents:y,containers:p,durableObjects:d,flagshipBinding:f,...i.jurisdiction===void 0?{}:{jurisdiction:i.jurisdiction},needsD1:i.needsD1,queues:v,services:A,signals:m,usesFlags:E!==void 0,usesNotifyFcm:h?.hasFcm??!1,usesNotifyWebPush:h?.hasWebPush??!1,workflows:b}},Ye=e=>[...N,...Se].filter(([s,r])=>e[s]&&se[r]!==void 0).map(([,s])=>s);export{qe as inferLunoraBindings,Ye as secretSourcesFromBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readProjectConfigLiterals as o,readProjectTarget as n}from"@lunora/codegen";import{DEFAULT_DEPLOY_TARGET as c,resolveDeployDriver as a}from"./DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs";const s=e=>{if(typeof e=="boolean")return e;if(e!==null&&typeof e=="object")return!0},g=e=>s(o(e).remote),i=e=>n(e),T=(e,r)=>r??i(e)??c,j=(e,r)=>{const t=T(e,r);return a(t),t};export{s as interpretRemote,g as readProjectRemotePreference,i as readProjectTarget,T as resolveProjectTarget,j as resolveTargetOrThrow};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{readFileSync as b,writeFileSync as v}from"node:fs";import{applyEdits as $,modify as S,parseTree as N,findNodeAtLocation as g}from"jsonc-parser";import{join as h}from"node:path";const A=/^([\t ]+)"/mu,F=n=>{const o=A.exec(n)?.[1]??" ";return{eol:n.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`,insertSpaces:!o.startsWith(" "),tabSize:o.length}},I=n=>{const o=h(n,"package.json");try{const t=b(o,"utf8"),{lunora:r}=JSON.parse(t),e=typeof r=="object"&&r!==null&&!Array.isArray(r);return{lunora:e?r:void 0,lunoraIsForeign:r!==void 0&&!e,path:o,text:t}}catch{return}},p=n=>JSON.stringify(n,(o,t)=>typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).toSorted(([r],[e])=>r.localeCompare(e))):t),j=(n,o,t)=>{const r=F(n),e=r.insertSpaces===!1?" ":" ".repeat(r.tabSize??4),i=r.eol??`
|
|
5
|
+
`,c=e.repeat(o.length),f=JSON.stringify(t,void 0,e).split(`
|
|
6
|
+
`).join(i+c),l=N(n),a=l===void 0?void 0:g(l,[...o]);if(a!==void 0)return n.slice(0,a.offset)+f+n.slice(a.offset+a.length);let s=l;l!==void 0&&o.length>1&&(s=g(l,o.slice(0,-1)));const y=JSON.stringify(o.at(-1));if(s===void 0&&o.length>1)return j(n,o.slice(0,-1),{[o.at(-1)]:t});if(s?.type!=="object")return $(n,S(n,[...o],t,{formattingOptions:r}));const d=s.children?.at(-1);if(d===void 0){const O=`${i}${c}${y}: ${f}${i}${e.repeat(o.length-1)}`;return`${n.slice(0,s.offset+1)}${O}${n.slice(s.offset+s.length-1)}`}const u=d.offset+d.length;return`${n.slice(0,u)},${i}${c}${y}: ${f}${n.slice(u)}`},K=(n,o,t)=>{const r=Object.keys(n.lunora??{}).every(c=>c===o);if(n.lunoraIsForeign||p(n.lunora?.[o])===p(t))return;const e=t===void 0&&r?["lunora"]:["lunora",o],i=t===void 0?$(n.text,S(n.text,e,void 0,{})):j(n.text,e,t);i!==n.text&&v(n.path,i,"utf8")};export{K as a,p as c,F as f,I as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isAbsolute as p,dirname as m,resolve as h}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as u}from"./hasCloudflareCredentials-CNPVIVBb.mjs";import{withheldBindings as g,writeDevConfig as w}from"./describeWithheld-CbyzZjZF.mjs";import{readWranglerJsonc as v}from"./WRANGLER_FILES-UNW-xY5u.mjs";const C=(e,n)=>{const{parsed:t,text:c}=v(e),o=t?.build,r=g(t,n.hasCredentials??(()=>u({projectRoot:n.projectRoot}))),s=typeof o?.command=="string"&&o.command!==""&&!(typeof o.cwd=="string"&&p(o.cwd));if(!s&&r.length===0)return{configPath:e,withheld:r};const d=m(e);let i=c;for(const{kind:f}of r)i=l(i,[f],void 0);s&&(i=l(i,["build","cwd"],h(d,typeof o.cwd=="string"?o.cwd:".")));const a=w(d,"service",i);return{cleanup:a.cleanup,configPath:a.configPath,withheld:r}},x=(e,n)=>{const t=e.map(o=>C(o,n)),c=t.flatMap(o=>o.cleanup===void 0?[]:[o.cleanup]);return{cleanup:()=>{for(const o of c)o()},configPaths:t.map(o=>o.configPath),withheld:t.flatMap(o=>o.withheld)}};export{x as materializeServiceDevConfigs};
|