@lunora/config 1.0.0-alpha.35 → 1.0.0-alpha.351
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/cloudflare/index.d.mts +1252 -0
- package/dist/cloudflare/index.d.ts +1252 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +1048 -917
- package/dist/index.d.ts +1048 -917
- 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-HrrbNZPy.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-ZsCxV1kP.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-2XFXmRrP.mjs +1 -0
- package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -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-CiQM3BkI.mjs +1 -0
- package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-38Plje8b.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BmJYwAy2.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-PLeh_74E.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-OLQlG0oj.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-BeTxqCuQ.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-CSx_psKS.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-DwJCN8fX.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-Dd7ZPhw7.mjs +3 -0
- package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-BWV_VxqV.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/collectExportGaps-BPuhGH2J.mjs +2 -0
- package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
- package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
- package/dist/packem_shared/describePreservedCrons-C5KPuPy3.mjs +1 -0
- package/dist/packem_shared/describeWithheldWorkersAi-IIxe3TuI.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-byvHpEiD.mjs +1 -0
- package/dist/packem_shared/infer-bindings-C1NFOdMi.mjs +1 -0
- package/dist/packem_shared/infer-bindings.d-CFxssIAC.d.mts +480 -0
- package/dist/packem_shared/infer-bindings.d-CFxssIAC.d.ts +480 -0
- package/dist/packem_shared/inferLunoraBindings-Gp_7yyIo.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-DLUHefD-.mjs +1 -0
- package/dist/packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs +1 -0
- package/dist/packem_shared/package-secrets-registry-BeheNwsP.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-7IJ58Uit.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-BFTVje1q.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-CvNBF3U4.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-DngzpJMK.mjs +1 -0
- package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
- package/dist/packem_shared/wranglerCodegenInputs-CbisphsH.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
- package/dist/packem_shared/write-atomic-CK6VZaPI.mjs +1 -0
- package/dist/studio-host/index.d.mts +314 -110
- package/dist/studio-host/index.d.ts +314 -110
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +16 -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-DWDKHViT.mjs +0 -243
- 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,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server-module specifier to scaffold into a project's own source:
|
|
3
|
+
* `lunorash/server` when the project depends on the umbrella, `@lunora/server`
|
|
4
|
+
* when it installs the granular packages. Same detection codegen and the Vite
|
|
5
|
+
* compose plugin use, so a scaffolded file imports what the emitted code does.
|
|
6
|
+
*/
|
|
7
|
+
declare const resolveServerModule: (projectRoot: string) => string;
|
|
8
|
+
/** Scaffold a new policy/role/permission stub file under `lunora/`. */
|
|
9
|
+
interface ScaffoldPolicyEdit {
|
|
10
|
+
readonly kind: "scaffoldPolicy";
|
|
11
|
+
/**
|
|
12
|
+
* Base name for the generated file and its exported policy-set identifier,
|
|
13
|
+
* e.g. `invoices` → `lunora/invoices.policies.ts` exporting `invoicesPolicies`.
|
|
14
|
+
*/
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** Logical table the scaffolded policy guards (used in the stub body). */
|
|
17
|
+
readonly table: string;
|
|
18
|
+
}
|
|
19
|
+
/** Append `.use(rls(<policies>))` to an existing procedure's builder chain. */
|
|
20
|
+
interface WireRlsEdit {
|
|
21
|
+
/** Exported procedure name to wire, e.g. `listInvoices`. */
|
|
22
|
+
readonly exportName: string;
|
|
23
|
+
readonly kind: "wireRls";
|
|
24
|
+
/** Identifier of the policy set passed to `rls(...)`, e.g. `invoicesPolicies`. */
|
|
25
|
+
readonly policies: string;
|
|
26
|
+
}
|
|
27
|
+
/** Additive scaffolder edits — the only requests the scaffolder applies. */
|
|
28
|
+
type AdditivePolicyEdit = ScaffoldPolicyEdit | WireRlsEdit;
|
|
29
|
+
/**
|
|
30
|
+
* Destructive scaffolder requests — never applied. Rewriting an existing `when`
|
|
31
|
+
* body changes evaluation semantics silently, so it is refused (STOP condition
|
|
32
|
+
* in plan 025); carried as data so the editor can describe the request.
|
|
33
|
+
*/
|
|
34
|
+
interface DestructivePolicyEdit {
|
|
35
|
+
readonly exportName?: string;
|
|
36
|
+
readonly kind: "rewritePolicyWhen";
|
|
37
|
+
readonly table?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Any request the scaffolder can receive. */
|
|
40
|
+
type PolicyEdit = AdditivePolicyEdit | DestructivePolicyEdit;
|
|
41
|
+
/**
|
|
42
|
+
* Classify a scaffolder request. Additive requests ({@link AdditivePolicyEdit})
|
|
43
|
+
* apply directly; everything else (rewriting an existing predicate) changes
|
|
44
|
+
* evaluation semantics and is destructive.
|
|
45
|
+
*/
|
|
46
|
+
declare const classifyPolicyEdit: (edit: PolicyEdit) => "additive" | "destructive";
|
|
47
|
+
/** Failure reasons a scaffolder request can report. */
|
|
48
|
+
type PolicyScaffoldFailureReason = "already-wired" | "destructive" | "invalid-identifier" | "unknown-procedure" | "unsupported-procedure-shape";
|
|
49
|
+
/** Tagged result of generating a stub file. */
|
|
50
|
+
type ScaffoldFileResult = {
|
|
51
|
+
fileName: string;
|
|
52
|
+
ok: true;
|
|
53
|
+
source: string;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
reason: PolicyScaffoldFailureReason;
|
|
57
|
+
};
|
|
58
|
+
/** Tagged result of wiring a procedure. */
|
|
59
|
+
type WireResult = {
|
|
60
|
+
ok: false;
|
|
61
|
+
reason: PolicyScaffoldFailureReason;
|
|
62
|
+
} | {
|
|
63
|
+
ok: true;
|
|
64
|
+
text: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Generate the source of a new policy/role/permission stub file. The `when`
|
|
68
|
+
* predicate is a `() => false` skeleton with a TODO — the scaffolder never
|
|
69
|
+
* authors real logic, the developer fills it in. Pure (no I/O); the handler
|
|
70
|
+
* writes the returned source and refuses to overwrite an existing file.
|
|
71
|
+
*
|
|
72
|
+
* `serverModule` is the specifier the PROJECT can resolve the builders from
|
|
73
|
+
* (see {@link resolveServerModule}) — an umbrella-only install has no
|
|
74
|
+
* `@lunora/server` on disk, so hard-coding it would scaffold a file that
|
|
75
|
+
* cannot be bundled.
|
|
76
|
+
*/
|
|
77
|
+
declare const scaffoldPolicyFile: (edit: ScaffoldPolicyEdit, serverModule: string) => ScaffoldFileResult;
|
|
78
|
+
/**
|
|
79
|
+
* Append `.use(rls(<policies>))` to a procedure's builder chain, preserving the
|
|
80
|
+
* terminal `.query(handler)` (and its handler body) byte-for-byte. Only the
|
|
81
|
+
* **builder** form can be wired; the bare-factory form (`query({ handler })`)
|
|
82
|
+
* has no chain and is reported `unsupported-procedure-shape` so the editor can
|
|
83
|
+
* tell the developer to convert it rather than silently rewriting their code.
|
|
84
|
+
*/
|
|
85
|
+
declare const wireRlsIntoProcedure: (source: string, edit: WireRlsEdit, serverModule: string) => WireResult;
|
|
86
|
+
export { AdditivePolicyEdit as A, DestructivePolicyEdit as D, PolicyEdit as P, ScaffoldPolicyEdit as S, WireRlsEdit as W, PolicyScaffoldFailureReason as a, ScaffoldFileResult as b, WireResult as c, classifyPolicyEdit as d, resolveServerModule as r, scaffoldPolicyFile as s, wireRlsIntoProcedure as w };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=e=>process.env[e]==="1",r=e=>s(e)?!1:(process.env[e]="1",!0);export{r as c,s as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join as o}from"node:path";import{readJsonSync as c}from"@visulima/fs";const r=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),s=e=>{try{const n=c(o(e,"package.json"));return r(n)?n:void 0}catch{return}},t=e=>r(e)?Object.fromEntries(Object.entries(e).filter(n=>typeof n[1]=="string")):{},i=e=>{const n=s(e);return{...t(n?.devDependencies),...t(n?.dependencies)}},p=e=>new Set(Object.keys(i(e)));export{i as readProjectDependencies,p as readProjectDependencyNames,s as readProjectManifest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as k,writeFileSync as M}from"node:fs";import{applyModify as _}from"./applyModify-DKP2l6S9.mjs";import{c as h,a as A}from"./lunora-manifest-DuH_Cmyu.mjs";import{readWranglerJsonc as D}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as F}from"node:path";const $="services",m="services",O="wrangler.dev.jsonc",v="dev:services",L=(t,n,i)=>{const r=n===void 0?t.worker:t.envWorkers[n]??`${t.worker}-${n}`,c=t.entrypoint??(n===void 0?void 0:i);return{binding:t.binding,...c===void 0?{}:{entrypoint:c},service:r}},f=t=>typeof t?.binding=="string"?t.binding:"",E=(t,n,i,r,c,a,w)=>{const s=n.join("."),o=new Map(r.map(e=>[e.binding,L(e,a,w.get(e.binding))])),p=i.filter(e=>!c.has(f(e))),u=new Set(p.map(e=>f(e))),g=new Map(i.filter(e=>c.has(f(e))).map(e=>[f(e),e])),d=[...o].filter(([e])=>!u.has(e)),y=[...p,...d.map(([,e])=>e)],S=d.filter(([e])=>!g.has(e)).map(([e,l])=>`${s}/${e} → ${l.service??""}`),b=[...d.filter(([e,l])=>g.has(e)&&h(g.get(e))!==h(l)).map(([e])=>`${s}/${e}`),...[...g.keys()].filter(e=>!o.has(e)).map(e=>`${s}/${e} (removed)`)],x=p.filter(e=>o.has(f(e))&&h(e)!==h(o.get(f(e)))).map(e=>`${s}: the hand-written "${f(e)}" entry is left as is — remove it to let lunora.config \`services\` manage that binding.`),j=S.length>0||b.length>0,C=y.length===0?void 0:y;return{added:S,owned:d.map(([e])=>e).toSorted((e,l)=>e.localeCompare(l)),text:j?_(t,n,C):t,updated:b,warnings:x}},V=t=>{const n=t?.lunora?.[$];return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(i=>Array.isArray(i[1])&&i[1].every(r=>typeof r=="string")))},G=t=>new Set(V(t)[m]),N=(t,n,i,r)=>{const c=[{current:n.services??[],path:[m]},...Object.entries(n.env??{}).map(([o,p])=>({current:p?.services??[],environment:o,path:["env",o,"services"]}))],a={added:[],owned:{},text:t,updated:[],warnings:[]},w=new Set(r[m]),s=new Map;for(const o of n.services??[])typeof o?.binding=="string"&&typeof o.entrypoint=="string"&&!w.has(o.binding)&&s.set(o.binding,o.entrypoint);for(const{current:o,environment:p,path:u}of c){const g=u.join("."),d=E(a.text,u,o,i,new Set(r[g]),p,s);a.text=d.text,a.added.push(...d.added),a.updated?.push(...d.updated??[]),a.warnings?.push(...d.warnings??[]),d.owned.length>0&&(a.owned[g]=d.owned)}return a},T=(t,n,i)=>{const r=F(t,O),c={added:[],path:r,updated:[],warnings:[]};if(n.length===0&&i[v]===void 0)return{...c,owned:{}};const{parsed:a,text:w}=k(r)?D(r):{parsed:void 0,text:""};if(a===void 0){const o=i[v];return{...c,owned:o===void 0||o.length===0?{}:{[v]:o}}}const s=E(w,["services"],a.services??[],n,new Set(i[v]),void 0,new Map);return s.text!==w&&M(r,s.text,"utf8"),{added:s.added,owned:s.owned.length>0?{[v]:s.owned}:{},path:r,updated:s.updated??[],warnings:(s.warnings??[]).map(o=>`${O} ${o}`)}},J=(t,n)=>{A(t,$,Object.keys(n).length===0?void 0:n)};export{N as a,T as b,J as c,G as o,V as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as g}from"./infer-bindings-C1NFOdMi.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as p}from"./collectExportGaps-BPuhGH2J.mjs";import{reconcileWranglerCompatibilityDate as $}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-C5KPuPy3.mjs";const j=async(i,t,a)=>{try{const n=await g({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=p(i.projectRoot,n,{target:i.target}),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:s,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...s,...f].join(", ")} (written to ${d})`)}for(const s of e.warnings)t.warn(`${r} ${s}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},c=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)a.warn(`${r} ${s}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||c.get(i)!==e)&&a.info?.(`${r} ${o}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=$(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as d}from"node:fs";import{modify as c,applyEdits as l}from"jsonc-parser";import{FORMATTING as s}from"./applyModify-DKP2l6S9.mjs";import{isCacheEnabled as f,WORKERS_CACHE_MIN_DATE as a}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as m,readWranglerJsonc as p}from"./WRANGLER_FILES-UNW-xY5u.mjs";const _=i=>{const e=m(i);if(!e)return{changed:!1,date:void 0,reason:"wrangler.jsonc not found"};const{parsed:r,text:n}=p(e);if(r===void 0)return{changed:!1,date:void 0,reason:`failed to parse ${e} as JSONC`,wranglerPath:e};const t=r.compatibility_date??"";if(!f(r))return{changed:!1,date:t||void 0,reason:"cache not enabled",wranglerPath:e};if(t>=a)return{changed:!1,date:t,reason:`compatibility_date already >= ${a}`,wranglerPath:e};const o=c(n,["compatibility_date"],a,s);return o.length===0?{changed:!1,date:t||void 0,reason:"no structural edit produced",wranglerPath:e}:(d(e,l(n,o),"utf8"),{changed:!0,date:a,wranglerPath:e})};export{_ as reconcileWranglerCompatibilityDate};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const r=t=>JSON.stringify(t).replaceAll("<",String.raw`\u003c`),i=t=>t.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<"),_=t=>{const e=[`window.__LUNORA_BASE_PATH__=${r(t.basePath)};`];return t.adminToken!==void 0&&t.adminToken!==""&&e.push(`window.__LUNORA_ADMIN_TOKEN__=${r(t.adminToken)};`),t.dataEditable===!0&&e.push("window.__LUNORA_DATA_EDITABLE__=true;"),t.runAsIdentity===!0&&e.push("window.__LUNORA_RUN_AS_IDENTITY__=true;"),t.schemaEditable===!0&&e.push("window.__LUNORA_SCHEMA_EDITABLE__=true;"),t.rulesInstalled===!1&&e.push("window.__LUNORA_RULES_INSTALLED__=false;"),`<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Lunora Studio</title>
|
|
7
|
+
<script>${e.join("")}<\/script>
|
|
8
|
+
<link rel="stylesheet" href="${i(t.styleHref)}" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
<script type="module" src="${i(t.scriptSrc)}"><\/script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
15
|
+
`};export{_ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as p,readFileSync as m}from"node:fs";import{join as f,basename as d}from"node:path";import{Project as S,SyntaxKind as I,Node as t}from"ts-morph";const n="lunora",v=["vite.config.js","vite.config.mjs","vite.config.ts","vite.config.cjs","vite.config.mts","vite.config.cts"],y="@lunora/vite",l="lunora",N=u=>{const i=v.map(e=>f(u,e)).find(e=>p(e));if(i===void 0)return n;let r;try{r=m(i,"utf8")}catch{return n}const s=new S({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(d(i),r),g=new Set(s.getImportDeclarations().filter(e=>e.getModuleSpecifierValue()===y).flatMap(e=>e.getNamedImports()).filter(e=>e.getName()===l).map(e=>e.getAliasNode()?.getText()??l));for(const e of s.getDescendantsOfKind(I.CallExpression)){const[c]=e.getArguments();if(!g.has(e.getExpression().getText())||!t.isObjectLiteralExpression(c))continue;const a=c.getProperty("schemaDir"),o=t.isPropertyAssignment(a)?a.getInitializer():void 0;if(t.isStringLiteral(o)||t.isNoSubstitutionTemplateLiteral(o))return o.getLiteralValue()}return n};export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as i}from"node:child_process";import{runScriptArgsFor as d,detectPackageManager as u}from"./addArgsFor-CYZKhNIo.mjs";import{readProjectManifest as g}from"./readProjectDependencies-l3uhUKjo.mjs";const s="postcodegen",f=r=>new Promise((e,o)=>{const n=i(r.command,[...r.args],{cwd:r.cwd??process.cwd(),shell:process.platform==="win32",stdio:["inherit",r.stdoutToStderr===!0?2:"inherit","inherit"]});n.on("error",o),n.on("close",c=>{e({code:c??1})})}),l=r=>{const e=g(r)?.scripts,o=typeof e=="object"&&e!==null?e[s]:void 0;return typeof o=="string"&&o!==""},w=async r=>{const{cwd:e,logger:o}=r;if(!l(e))return{ran:!1};const n=t=>(o.error(t),{error:t,ran:!0});let c;try{c=d(u(e),s)}catch(t){return n(`cannot run \`${s}\`: ${t instanceof Error?t.message:String(t)}`)}o.info(`running \`${s}\``);let a;try{a=await(r.spawner??f)({args:c.args,command:c.command,cwd:e,stdoutToStderr:r.stdoutToStderr})}catch(t){return n(`\`${s}\` failed to start: ${t instanceof Error?t.message:String(t)}`)}return a.code!==0?n(`\`${s}\` exited ${String(a.code)}`):{ran:!0}};export{w as runPostCodegenHook};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{secretKindOf as s,redact as c}from"@lunora/codegen";import{i as a,a as f}from"./package-secrets-registry-BeheNwsP.mjs";import{isPlaceholderValue as d}from"./buildPackageSecretsBlock-BWV_VxqV.mjs";const u=8,h=(n,o)=>{if(n===void 0)return[];const r=[];for(const[i,e]of Object.entries(n)){if(typeof e!="string"||d(e)||a(i))continue;const t=s(e)??(f(i)&&e.length>=u?"secret_named_var":void 0);t!==void 0&&r.push({file:o,key:i,kind:t,preview:c(e)})}return r};export{h as scanWranglerVariablesForSecrets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{headerValue as a}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";const l=1e6,g=async t=>await new Promise((o,e)=>{const n=[];let i=0;t.on("data",c=>{if(i+=c.length,i>l){e(new Error("request body too large"));return}n.push(c)}),t.on("end",()=>{o(Buffer.concat(n).toString("utf8"))}),t.on("error",e)}),s=(t,o,e)=>{t.statusCode=o,t.setHeader("Content-Type","application/json; charset=utf-8"),t.end(JSON.stringify(e))},u=new Set(["none","same-origin","same-site"]),y=t=>{const o=a(t.headers["sec-fetch-site"]);if(o!==void 0)return u.has(o)?void 0:"cross-origin request rejected";const e=a(t.headers.origin);if(e===void 0||e==="null")return;let n;try{n=new URL(e).host.toLowerCase()}catch{return"invalid origin header"}return n===a(t.headers.host)?void 0:"cross-origin request rejected"},p=t=>{const o=(t.method??"GET").toUpperCase(),e=o!=="GET"&&o!=="HEAD",n=y(t);if(n!==void 0)return n;if(e&&!a(t.headers["content-type"])?.startsWith("application/json"))return"content-type must be application/json"},v=(t,o,e,n,i={})=>{(async()=>{try{const r=p(t);if(r!==void 0){s(o,403,{error:r,ok:!1});return}const d=t.method==="GET"?"":await g(t);let h;try{h=d===""?void 0:JSON.parse(d)}catch{s(o,400,{error:"invalid-json",ok:!1});return}const f=e({...i,body:h,method:t.method??"POST",projectRoot:n});s(o,f.status,f.body)}catch(r){s(o,500,{error:r instanceof Error?r.message:String(r),ok:!1})}})().catch(()=>{})};export{v as serveJsonHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{watch as A}from"node:fs";import{createServer as _}from"node:net";import{dirname as C}from"node:path";import{readServiceBindings as R}from"@lunora/codegen";import{acceptsConnection as b,startDevProcess as M}from"./acceptsConnection-DHhUYGjT.mjs";import{p as D,a as x}from"./celld-config-D-L6uskI.mjs";const N=6e4,O=200,j=new Set([".celld",".wrangler","node_modules"]),I=/[/\\]/u,B=async()=>new Promise((r,a)=>{const s=_();s.once("error",a),s.listen(0,"127.0.0.1",()=>{const o=s.address();s.close(()=>{r(typeof o=="object"&&o!==null?o.port:0)})})}),F=r=>r?.split(I).some(a=>j.has(a))===!0,G=(r,a,s)=>{let o;const c=A(r,{recursive:!0},(l,w)=>{F(w)||(clearTimeout(o),o=setTimeout(a,O))}),i=()=>{clearTimeout(o),c.close()};return c.once("error",l=>{i(),s(l)}),{close:i}},H=r=>r instanceof Error?r.message:String(r),J=async r=>{const{log:a,port:s,projectRoot:o}=r,c=(t,e="stdout")=>{a(t,{stream:e,tag:"celld"})};if(await b(s))throw new Error(`port ${String(s)} is already in use — stop whatever is serving there (another dev server?), or pick another worker port`);const i=R(o);if(i.error!==void 0)throw new Error(`could not read the lunora.config services: ${i.error}`);const l=D(o,"dev");l.write();const w=C(l.configPath),m=[...new Map(i.services.map(t=>[t.wranglerPath,t])).values()],p=new AbortController,h=()=>p.signal.aborted,v=async(t,e,n)=>M({args:["dev",t,"--port",String(n)],command:"celld",cwd:o,label:"celld dev",notFound:"`celld` was not found on PATH — install it (https://celld.dev) to run the celld target",onLine:T=>{T.trim()!==""&&a(T,{stream:"stdout",tag:e})},port:n,readyTimeoutMs:N,signal:p.signal,spawn:r.spawn}),S=async t=>{const e=x(w,t.wranglerPath);e.write(),c(`registering service ${t.worker} in the local dev state`),await(await v(e.configPath,`celld:${t.worker}`,await B())).stop()};for(const t of m)await S(t);let g=()=>{};const E=new Promise(t=>{g=t}),y=async()=>{const t=await v(l.configPath,"celld",s);return t.crashed.then(g).catch(()=>{}),t};let d=await y();const $=async t=>{await d.stop();let e;try{await S(t)}catch(n){e=n instanceof Error?n:new Error(String(n))}if(!h()){try{d=await y()}catch(n){throw h()||g(1),n}if(e!==void 0)throw e}};let f=Promise.resolve();const k=t=>{c(`service ${t.worker} changed — restarting`),f=f.then(async()=>$(t)).catch(e=>{h()||c(`service ${t.worker} failed to restart: ${H(e)}`,"stderr")})},P=[],u=()=>{for(const t of P)t.close()};try{for(const t of m)P.push(G(C(t.wranglerPath),()=>{k(t)},e=>{c(`stopped watching service ${t.worker}: ${e.message} — restart the dev server to pick up its edits`,"stderr")}))}catch(t){throw u(),await d.stop(),t}return E.then(u).catch(()=>{}),{exited:E,stop:async()=>{p.abort(),u(),await f,await d.stop()}}};export{J as startCelldDevSession};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Writable as D}from"node:stream";import{StringDecoder as N}from"node:string_decoder";const y="cloudflare-dev/",_=1500,b=async()=>{const{default:t}=await import("dockerode");return new t},C=t=>{if(!t.startsWith(y))return;const[a]=t.slice(y.length).split(":");return a!==void 0&&a.length>0?a:void 0},I=t=>{const a=new N("utf8");let c="";const o=r=>{t(r.endsWith("\r")?r.slice(0,-1):r)};return new D({final(r){c+=a.end(),c.length>0&&(o(c),c=""),r()},write(r,m,i){c+=a.write(r);const d=c.split(`
|
|
2
|
+
`);c=d.pop()??"";for(const v of d)o(v);i()}})},T=t=>{const a=new Map(t.containers.map(e=>[e.className.toLowerCase(),e.exportName]));if(a.size===0)return{close:()=>{}};const c=t.pollIntervalMs??_,o=new Map;let r=!1,m=!1,i,d;const v=async()=>(d??=t.docker?Promise.resolve(t.docker):b(),d),p=async(e,s,f)=>{try{const n=await e.getContainer(s).logs({follow:!0,stderr:!0,stdout:!0,tail:"all",timestamps:!1});if(r){n.destroy();return}const l=I(w=>{t.onLine({level:"info",name:f,text:w})}),u=I(w=>{t.onLine({level:"error",name:f,text:w})});e.modem.demuxStream(n,l,u),n.on("end",()=>{l.end(),u.end(),o.delete(s)}),n.on("error",()=>{o.delete(s)}),o.set(s,n)}catch{}},L=async()=>{try{const s=await(await v()).listContainers({filters:{status:["running"]}});return m=!1,s}catch(e){m||(m=!0,t.onUnavailable?.(e instanceof Error?e.message:String(e)));return}},k=async(e,s)=>{const f=new Set;for(const n of s){const l=C(n.Image),u=l===void 0?void 0:a.get(l);u!==void 0&&(f.add(n.Id),o.has(n.Id)||await p(e,n.Id,u))}for(const[n,l]of o)f.has(n)||(l.destroy(),o.delete(n))},E=async()=>{if(r)return;const e=await L();e!==void 0&&await k(await v(),e)};let g=!1;const h=()=>{g||r||(g=!0,E().finally(()=>{g=!1}).catch(()=>{}))};return i=setInterval(h,c),i.unref(),h(),{close:()=>{r=!0,i&&(clearInterval(i),i=void 0);for(const[e,s]of o)s.destroy(),o.delete(e)}}};export{T as streamContainerLogs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CUSTOM_INSTANCE_TYPE_LIMITS as f,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as y}from"@lunora/container";import{i as g,a as d}from"./guards-Buu_E7mP.mjs";const h=[{of:e=>e.schedules===void 0?void 0:[...e.schedules],path:["schedules"]},{of:e=>e.limits?.steps,path:["limits","steps"]},{of:e=>e.defaultRetention?.successRetention,path:["default_retention","success_retention"]},{of:e=>e.defaultRetention?.errorRetention,path:["default_retention","error_retention"]}],B=[...new Set(h.map(({path:e})=>e[0]))],_=(e,n)=>{let a=e;for(const s of n)a=g(a)?a[s]:void 0;return a},L=e=>{const n={};for(const{of:a,path:s}of h){const t=a(e);if(t===void 0)continue;const[i,o]=s;n[i]=o===void 0?t:{...n[i],[o]:t}}return n},F=(e,n,a)=>{if(n.length===0)return;const s=e.vectorize??[],t=new Set(s.filter(Boolean).map(i=>i?.index_name));for(const i of n)t.has(i)||a.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},M=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),S={disk_mb:f.diskMb,memory_mib:f.memoryMib,vcpu:{...f.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},j=(e,n,a)=>{const s=e.instance_type;if(s===void 0)return;if(typeof s=="string"){M.has(s)||a.push(`${n} has unknown instance_type "${s}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,{hint:r,max:c,min:b}]of Object.entries(S)){const m=s[o];if(m!==void 0&&(typeof m!="number"||Number.isNaN(m)||m<b||m>c)){const w=r!==void 0&&typeof m=="number"&&m<b?` — ${r}`:"";a.push(`${n} custom instance_type ${o} must be a number in ${String(b)}–${String(c)} (got ${String(m)})${w}`)}}const{memory_mib:t,vcpu:i}=s;typeof i=="number"&&typeof t=="number"&&t<i*y&&a.push(`${n} custom instance_type needs ≥ 3 GiB (${String(y)} MiB) memory per vCPU (got ${String(t)} MiB for ${String(i)} vCPU)`)},E=(e,n,a)=>{for(const s of["image","instance_type","max_instances"])e[s]!==void 0&&a.push(`${n} sets "${s}", which the durable_object scheduling policy does not take — the Durable Object picks image and size at start`);for(const[s,t]of Object.entries(e.images??{}))[t?.dockerfile,t?.image].filter(o=>typeof o=="string"&&o.length>0).length!==1&&a.push(`${n} images["${s}"] must set exactly one of "dockerfile" or "image"`)},A=(e,n,a)=>{const{boundClasses:s,classKinds:t,errors:i,warnings:o}=a;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){i.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}const r=e.scheduling_policy==="durable_object";e.scheduling_policy!==void 0&&e.scheduling_policy!=="default"&&!r&&i.push(`${n} ("${e.class_name}") has unknown scheduling_policy "${e.scheduling_policy}" — expected "default" or "durable_object"`),r?E(e,`${n} ("${e.class_name}")`,i):(typeof e.image!="string"||e.image.length===0)&&i.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),s.has(e.class_name)||i.push(`${n} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const c=t.get(e.class_name);c!=="sqlite"&&i.push(c==="classic"?`${n} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${n} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),j(e,`${n} ("${e.class_name}")`,i),e.max_instances===void 0&&!r&&o.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},u=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],p=e=>Array.isArray(e)?e.filter(n=>d(n)):[],k=e=>{const n=new Map;for(const a of u(e)){for(const s of p(a.new_classes))n.set(s,"classic");for(const s of p(a.new_sqlite_classes))n.set(s,"sqlite");for(const s of u(a.renamed_classes))if(d(s.from)&&d(s.to)){const t=n.get(s.from)??"sqlite";n.delete(s.from),n.set(s.to,t)}for(const s of p(a.deleted_classes))n.delete(s)}return n},x=e=>new Set(k(e).keys()),P=(e,n)=>{const a=x(e.migrations);for(const s of u(e.durable_objects?.bindings))s.script_name===void 0&&d(s.class_name)&&!a.has(s.class_name)&&n.push(`durable_objects.bindings declares class "${s.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${s.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},W=(e,n,a)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const s=e.containers;if(s.length===0)return;const t=new Set(u(e.durable_objects?.bindings).map(o=>o.class_name)),i=k(e.migrations);for(const[o,r]of s.entries())A(r,`containers[${String(o)}]`,{boundClasses:t,classKinds:i,errors:n,warnings:a});e.observability?.enabled!==!0&&a.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},l=e=>e,v=(e,n,a,s)=>{if(e!==void 0){if(!Array.isArray(e)){s.push(a.arrayMessage);return}for(const[t,i]of l(e).entries()){const o=`${n}[${String(t)}]`;if(!i||typeof i!="object"){s.push(a.objectMessage(o));continue}for(const r of a.fields)d(i[r.field])||s.push(r.message(o))}}},G={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. MY_WORKFLOW)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},I=(e,n)=>e===void 0||n&&d(e)||Array.isArray(e)&&e.length>0&&e.every(s=>d(s))?void 0:"schedules must be a non-empty array of cron expression strings",R=e=>{if(e!==void 0)return g(e)?e.steps===void 0||Number.isInteger(e.steps)&&e.steps>0?void 0:"limits.steps must be a positive integer":"limits must be an object"},N=e=>e===void 0?[]:g(e)?["success_retention","error_retention"].filter(n=>e[n]!==void 0&&!d(e[n])).map(n=>`default_retention.${n} must be a duration string (e.g. "7 days")`):["default_retention must be an object"],$=(e,n,a,s)=>{const t=[I(e.schedules,a),R(e.limits),...N(e.default_retention)];for(const i of t)i!==void 0&&s.push(`${n}.${i}`)},q=(e,n)=>h.map(({path:a})=>a).filter(a=>{const s=_(e,a),t=_(n,a),i=typeof t=="string"&&a[0]==="schedules"?[t]:t;return s!==void 0&&t!==void 0&&JSON.stringify(s)!==JSON.stringify(i)}).map(a=>a.join(".")),O=(e,n,a,s)=>{const t=`exports["${e}"]`,i=String(n.name);for(const o of a){if(!g(o)||o.name!==n.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){s.push(`${r} binds workflow "${i}" in another Worker, but ${t} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&s.push(`${r} and ${t} both declare workflow "${i}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const c of q(o,n))s.push(`${r} and ${t} set ${c} to different values for workflow "${i}" — set it in one place`)}},K=(e,n)=>{const a=Array.isArray(e.workflows)?l(e.workflows):[];for(const[t,i]of a.entries())g(i)&&$(i,`workflows[${String(t)}]`,!1,n);const s=g(e.exports)?Object.entries(e.exports):[];for(const[t,i]of s)!g(i)||i.type!=="workflow"||(d(i.name)?($(i,`exports["${t}"]`,!0,n),O(t,i,a,n)):n.push(`exports["${t}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},C={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},T={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},Q=(e,n)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){n.push("queues must be a { producers, consumers } object");return}v(e.queues.producers,"queues.producers",C,n),v(e.queues.consumers,"queues.consumers",T,n)}},V={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:n=>`${n} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},Y=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,n)=>`${e} ("${n}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,n)=>`${e} ("${n}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,n)=>`${e} ("${n}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],z=(e,n,a,s)=>{const t=e[n.key];if(t!==void 0){if(!Array.isArray(t)){a.push(n.arrayMessage);return}for(const[i,o]of l(t).entries()){const r=`${n.key}[${String(i)}]`;if(!o||typeof o!="object"||!d(o.binding)){a.push(n.bindingMessage(r));continue}(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(b=>d(o[b]))||s.push(n.hintMessage(r,o.binding))}}},H=[{key:"analytics",message:'analytics must be an object with a non-empty "binding" (e.g. { "binding": "ANALYTICS_SQL" })'},{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'},{key:"media",message:'media must be an object with a non-empty "binding" (e.g. { "binding": "MEDIA" })'},{key:"stream",message:'stream must be an object with a non-empty "binding" (e.g. { "binding": "STREAM" })'}],J=(e,n,a)=>{const s=e[n.key];s!==void 0&&(typeof s!="object"||s===null||Array.isArray(s)||!d(s.binding))&&a.push(n.message)},X=[{arrayMessage:"ai_search_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the AI Search namespace (every account has "default")`}],key:"ai_search_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"ai_search must be an array of { binding, instance_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"instance_name",message:e=>`${e} must have a non-empty "instance_name" naming an existing AI Search instance`}],key:"ai_search",objectMessage:e=>`${e} must be a { binding, instance_name } object`},{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`},{arrayMessage:"vpc_services must be an array of { binding, service_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the VPC Service binding`},{field:"service_id",message:e=>`${e} must have a non-empty "service_id" (create one with \`wrangler vpc service create\`)`}],key:"vpc_services",objectMessage:e=>`${e} must be a { binding, service_id } object`},{arrayMessage:"artifacts must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Artifacts binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the Artifacts namespace`}],key:"artifacts",objectMessage:e=>`${e} must be a { binding, namespace } object`}],Z=(e,n,a)=>{n?.hasD1GlobalTable&&!u(e.d1_databases).some(s=>s.binding==="DB")&&a.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),n?.hasHyperdriveGlobalTable&&u(e.hyperdrive).length===0&&a.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},ee=(e,n)=>{const{d1_databases:a}=e;if(a!==void 0){if(!Array.isArray(a)){n.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[s,t]of l(a).entries()){const i=`d1_databases[${String(s)}]`;if(!t||typeof t!="object"){n.push(`${i} must be a { binding, database_id | database_name } object`);continue}d(t.binding)||n.push(`${i} must have a non-empty "binding" naming the D1 binding`),!d(t.database_id)&&!d(t.database_name)&&n.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},ne=(e,n)=>{const{vpc_networks:a}=e;if(a!==void 0){if(!Array.isArray(a)){n.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[s,t]of l(a).entries()){const i=`vpc_networks[${String(s)}]`;if(!t||typeof t!="object"){n.push(`${i} must be a { binding, tunnel_id | network_id } object`);continue}d(t.binding)||n.push(`${i} must have a non-empty "binding" naming the VPC Network binding`),d(t.tunnel_id)===d(t.network_id)&&n.push(`${i} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}};export{Y as H,X as R,H as S,G as W,Z as a,ee as b,F as c,W as d,v as e,x as f,K as g,Q as h,z as i,J as j,ne as k,V as l,B as m,p as n,u as o,h as p,_ as s,P as v,L as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as u,a as f}from"./guards-Buu_E7mP.mjs";import{o as v}from"./validate-bindings-CvNBF3U4.mjs";const _=new Set(["1","enabled","on","true","yes"]),A=s=>typeof s=="string"&&_.has(s.trim().toLowerCase()),b=(s,t,e,i)=>{s!==void 0&&typeof s!="boolean"&&e.push(`${t} must be a boolean${i===void 0?"":` (${i})`}`)},O=(s,t,e)=>{s!==void 0&&(typeof s!="number"||Number.isNaN(s)||s<0||s>1)&&e.push(`${t} must be a number in [0, 1] (the fraction of requests sampled)`)},N=(s,t,e)=>{const i=s.send_email;if(i===void 0)return;if(!Array.isArray(i)){t.push("send_email must be an array of { name, destination_address? } entries");return}const n=i;for(const[o,a]of n.entries())(!a||typeof a!="object"||typeof a.name!="string"||a.name.length===0)&&e.push(`send_email[${String(o)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},k=(s,t)=>{b(s.logpush,"logpush",t,'set "logpush": true to enable Cloudflare Logpush')},I=(s,t)=>{const e=s.secrets;if(e===void 0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e.required:void 0;(!Array.isArray(i)||i.some(n=>typeof n!="string"||n===""))&&t.push('secrets must be an object whose "required" is an array of secret names (e.g. { "required": ["API_KEY"] })')},m=3e5,C=(s,t)=>{const{limits:e}=s;if(e===void 0)return;if(typeof e!="object"||Array.isArray(e)){t.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const i=e.cpu_ms;if(i!==void 0){if(typeof i!="number"||!Number.isFinite(i)||!Number.isInteger(i)||i<=0){t.push("limits.cpu_ms must be a positive integer number of milliseconds");return}i>m&&t.push(`limits.cpu_ms must be at most ${String(m)} (Cloudflare's per-invocation ceiling)`)}},p=new Set(["off","smart","targeted"]),w=(s,t)=>{const{placement:e}=s;if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e)){t.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:i}=e;i!==void 0&&(typeof i!="string"||!p.has(i))&&t.push(`placement.mode must be one of ${[...p].map(n=>`"${n}"`).join(", ")}`)},c={kind:"boolean"},h={kind:"samplingRate"},y={destinations:{kind:"destinations"},enabled:c,head_sampling_rate:h,persist:c},S={...y,invocation_logs:{hint:'set "invocation_logs": true to keep per-invocation summaries',kind:"boolean"}},L={enabled:c,head_sampling_rate:h,issues:{kind:"level",level:{enabled:c}},logs:{kind:"level",level:S},redact_query_string:c,traces:{kind:"level",level:y}},E=(s,t,e,i)=>{switch(s.kind){case"boolean":{b(t,e,i,s.hint);break}case"destinations":{t!==void 0&&(!Array.isArray(t)||t.some(n=>!f(n)))&&i.push(`${e} must be an array of destination names configured in the Cloudflare dashboard`);break}case"samplingRate":{O(t,e,i);break}}},g=(s,t,e,i,n)=>{for(const[o,a]of Object.entries(s)){const r=Object.hasOwn(t,o)?t[o]:void 0,l=`${e}.${o}`;r===void 0?n.push(`${l} is not a documented wrangler key (expected one of ${Object.keys(t).join(", ")}) — a typo is silently ignored by wrangler`):r.kind!=="level"?E(r,a,l,i):u(a)?g(a,r.level,l,i,n):a!==void 0&&i.push(`${l} must be an object`)}},x=(s,t,e)=>{const{observability:i}=s;if(i!==void 0){if(!u(i)){t.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}g(i,L,"observability",t,e)}},D=(s,t)=>{const{cache:e}=s;if(e!==void 0){if(!u(e)){t.push('cache must be an object (e.g. { "enabled": true })');return}b(e.enabled,"cache.enabled",t)}},T=(s,t)=>{const{exports:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push("exports must be an object keyed by entrypoint name");return}for(const[i,n]of Object.entries(e)){if(typeof n!="object"||n===null){t.push(`exports["${i}"] must be an object`);continue}n.type!==void 0&&typeof n.type!="string"&&t.push(`exports["${i}"].type must be a string`),n.cache!==void 0&&(typeof n.cache!="object"||n.cache===null||Array.isArray(n.cache)?t.push(`exports["${i}"].cache must be an object`):n.cache.enabled!==void 0&&typeof n.cache.enabled!="boolean"&&t.push(`exports["${i}"].cache.enabled must be a boolean`))}}},B=(s,t)=>{const{assets:e}=s;if(e!==void 0){if(typeof e!="object"||Array.isArray(e)){t.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof e.directory!="string"||e.directory.length===0)&&t.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),e.binding!==void 0&&(typeof e.binding!="string"||e.binding.length===0)&&t.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),e.html_handling!==void 0&&typeof e.html_handling!="string"&&t.push("assets.html_handling must be a string"),e.not_found_handling!==void 0&&typeof e.not_found_handling!="string"&&t.push("assets.not_found_handling must be a string")}},U=(s,t)=>{const e=s.tail_consumers;if(e===void 0)return;if(!Array.isArray(e)){t.push("tail_consumers must be an array of { service, environment? } entries");return}const i=e;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&t.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},G=(s,t)=>{const e=s.tail_consumers??[];return e.some(n=>!!n&&n?.service===t.service&&n?.environment===t.environment)?s:{...s,tail_consumers:[...e,t]}},P=(s,t)=>{const{vars:e}=s;if(!e||typeof e!="object")return;const i=e.LUNORA_ALLOWED_ORIGINS,n=e.LUNORA_CORS_ALLOW_CREDENTIALS,o=typeof i=="string"&&i.split(",").some(r=>r.trim()==="*"),a=A(n);o&&a&&t.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},j=s=>v(s.durable_objects?.bindings).some(t=>t.class_name==="SchedulerDO"&&t.script_name===void 0),d="LUNORA_ORIGIN_URL",W=(s,t,e,i=j(s)?"durable_objects.bindings declares the SchedulerDO":void 0)=>{if(i===void 0||f(s.vars?.[d]))return;const n=t===void 0?"vars":`env.${t}.vars`,o=t===void 0?"":` --env ${t}`;e.push(`${i} but ${n}.${d} is unset — the DO reads its dispatch origin from its own env and refuses to schedule without it, so every ctx.scheduler.runAfter/runAt fails with ORIGIN_NOT_CONFIGURED. Set ${n}.${d} to the worker's public URL, or \`wrangler secret put ${d}${o}\` (ignore this if it is already set as a secret or in the dashboard).`)};export{B as validateAssets,D as validateCache,P as validateCorsVariables,T as validateExports,C as validateLimits,k as validateLogpush,x as validateObservability,w as validatePlacement,W as validateSchedulerOrigin,I as validateSecretsRequired,N as validateSendEmail,U as validateTailConsumers,G as withTailConsumer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as f,readFileSync as N,readdirSync as I}from"node:fs";import{join as p,dirname as v,extname as h,basename as x}from"node:path";import{Project as b,Node as d}from"ts-morph";import{COMPOSED_WORKER_ENTRY as w,LUNORA_WORKER_VIRTUAL_ID as u,isGeneratedOutput as L,WORKER_ENTRY_FALLBACKS as M,GENERATED_DIRECTORY as j,isMergedProject as F,MERGED_DURABLE_OBJECT as P,COMPOSED_ENTRY_DURABLE_OBJECTS as k,GENERATED_CLASS_MODULES as U,isMergedRoleModule as W,SOURCE_DOT_DIRECTORIES as B,NON_SOURCE_DIRECTORIES as K}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";const E=[".ts",".tsx",".mts",".cts"],g=new Set(E),X=new Set([".cjs",".js",".mjs"]),m="default",S={".cjs":[".cts"],".js":[".ts",".tsx"],".mjs":[".mts"]},Y=250,ae=(e,o,t)=>{const s=p(o,w);if(f(s))return{origin:"declared",path:s};if(e===u)return{origin:"composed"};const n=()=>{const i=M.map(a=>p(o,a)).find(a=>f(a));return i===void 0?void 0:{origin:"probed",path:i}};if(typeof e!="string"||e.length===0||L(e))return n();const r=p(v(t),e),c=h(r);if(!(!g.has(c)&&!X.has(c)))return f(r)?{origin:"declared",path:r}:{origin:"absent",path:r}},_=(e,o)=>{if(d.isIdentifier(e)){o.add(e.getText());return}if(d.isObjectBindingPattern(e)||d.isArrayBindingPattern(e))for(const t of e.getElements())d.isBindingElement(t)&&_(t.getNameNode(),o)},G=(e,o)=>{const t=[];for(const s of e.getExportDeclarations())if(!s.isTypeOnly()){if(s.isNamespaceExport()){const n=s.getNamespaceExport();n===void 0?t.push(s.getModuleSpecifierValue()??""):o.add(n.getName());continue}for(const n of s.getNamedExports())n.isTypeOnly()||o.add(n.getAliasNode()?.getText()??n.getName())}return t},$=(e,o)=>{for(const t of e.getVariableStatements().filter(s=>s.getExportKeyword()!==void 0))for(const s of t.getDeclarations())_(s.getNameNode(),o);for(const t of[...e.getClasses(),...e.getFunctions(),...e.getEnums()]){if(t.getExportKeyword()===void 0)continue;const s=t.isDefaultExport()?m:t.getName();s!==void 0&&o.add(s)}e.getExportAssignments().length>0&&o.add(m)},y=(e,o)=>{const t=new b({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),s=t.createSourceFile(e,o,{overwrite:!0});return t.getProgram().compilerObject.getSyntacticDiagnostics(s.compilerNode).length>0?void 0:s},J=(e,o)=>{if(!o.startsWith("./")&&!o.startsWith("../"))return;const t=p(v(e),o),s=h(t),n=g.has(s)||S[s]!==void 0,r=n?t.slice(0,-s.length):t;return[...g.has(s)?[t]:[],...(S[s]??[]).map(i=>`${r}${i}`),...n?[]:E.map(i=>`${t}${i}`),...n||s.length===0?E.map(i=>p(r,`index${i}`)):[]].find(i=>f(i))},T=e=>{const o=new Set,t=new Set([e]),s=[e];for(;s.length>0;){if(t.size-1>Y)return;const n=s.pop();let r;try{r=N(n,"utf8")}catch{return}const c=y(x(n),r);if(c===void 0)return;const i=G(c,o);$(c,o);for(const a of i){const l=J(n,a);if(l===void 0)return;t.has(l)||(t.add(l),s.push(l))}}return o},z=(e,o)=>{const t={exports:void 0,kind:"composed",path:u},s=p(e,o,j);if(!f(s))return t;const n=F(s),r=new Set(n?[P]:k);for(const c of U){const i=p(s,`${c}.ts`);if(!f(i)||n&&W(c))continue;const a=T(i);if(a===void 0)return t;for(const l of a)r.add(l)}return{exports:r,kind:"composed",path:u}},de=(e,o,t)=>{if(e===void 0||e.origin==="absent")return;if(e.origin==="composed")return z(o,t);const s=T(e.path);if(!(e.origin==="probed"&&s!==void 0&&!s.has(m)))return{exports:s,kind:"authored",path:e.path}},q=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),V=2e3,O="defineTable",R="defineApp",H=e=>{const o=[],t=[];let s;try{s=I(e,{withFileTypes:!0})}catch{return{files:o,subdirectories:t}}for(const n of s)n.isDirectory()?n.name.startsWith(".")&&!B.has(n.name)||K.has(n.name)||t.push(p(e,n.name)):q.has(h(n.name))&&o.push(p(e,n.name));return{files:o,subdirectories:t}},D=(e,o)=>{const t=new Set;for(const s of e.getImportDeclarations())for(const n of s.getNamedImports())!n.isTypeOnly()&&n.getName()===o&&t.add(n.getAliasNode()?.getText()??n.getName());return t},Q=(e,o)=>{let t=!1;return e.forEachDescendant((s,n)=>{if(!d.isCallExpression(s))return;const r=s.getExpression();d.isIdentifier(r)&&o.has(r.getText())&&(t=!0,n.stop())}),t},Z=e=>{let o=e;for(;d.isCallExpression(o)||d.isPropertyAccessExpression(o);)o=o.getExpression();return o},ee=(e,o)=>{const t=Z(e);return d.isIdentifier(t)&&o.has(t.getText())},A={analyticsSql:/\.\s*analyticsSql\s*\(/u,global:/\.\s*global\s*\(/u,hyperdriveGlobal:/\.\s*hyperdriveGlobal\s*\(/u,vectors:/\.\s*vectors\s*\(/u},te=e=>Object.hasOwn(A,e),se=(e,o)=>{const t=new Set,s=new Set([O,...D(e,O)]);return e.forEachDescendant(n=>{if(!d.isCallExpression(n))return;const r=n.getExpression();if(!d.isPropertyAccessExpression(r)||ee(r,s))return;const c=r.getName();te(c)&&o.has(c)&&t.add(c)}),t},oe=(e,o)=>{let t;try{t=N(e,"utf8")}catch{return}const s=new Set([...o].filter(r=>A[r].test(t)));if(s.size===0&&!t.includes(R))return;const n=y(x(e),t);return n===void 0?{chained:s,composes:!1}:{chained:se(n,s),composes:Q(n,D(n,R))}},le=(e,o)=>{const t=[e],s=new Set;let n=0,r;const c=i=>{if(n+=1,n>V)return!1;const a=oe(i,o);for(const l of a?.chained??[])s.add(l);return a?.composes&&(r??=i),!0};for(;t.length>0;){const i=t.pop(),{files:a,subdirectories:l}=H(i);t.push(...l);for(const C of a){if(!c(C))return;if(r!==void 0&&s.size===o.size)return{chained:s,site:r}}}return r===void 0?void 0:{chained:s,site:r}};export{ae as l,de as r,le as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{relative as t}from"node:path";import{i as o}from"./guards-Buu_E7mP.mjs";import{findWranglerFile as u,readWranglerJsonc as d}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{scanWranglerVariablesForSecrets as l}from"./scanWranglerVariablesForSecrets-BFTVje1q.mjs";const n=(s,e)=>{const r=s?.producers;return(Array.isArray(r)?r:[]).flatMap(i=>o(i)&&typeof i.binding=="string"&&typeof i.queue=="string"?[{binding:i.binding,queue:i.queue,...e===void 0?{}:{env:e}}]:[])},v=s=>{const e=u(s),r=e===void 0?void 0:d(e).parsed;return e===void 0||r===void 0?{wranglerQueueProducers:[],wranglerVariables:[]}:{wranglerQueueProducers:[...n(r.queues),...Object.entries(r.env??{}).flatMap(([a,i])=>n(i?.queues,a))],wranglerVariables:l(o(r.vars)?r.vars:void 0,t(s,e))}};export{v as wranglerCodegenInputs};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const o=e=>JSON.stringify(e),$=/^[A-Z_a-z][\w$]*$/u,d=e=>$.test(e),u=e=>d(e)?e:`binding_${e.replaceAll(/\W/gu,"_")}`,m=(e,t=u(e))=>{const n=d(e);return n&&t===e?`${e},`:`${n?e:o(e)}: ${t},`},h=e=>{const t=new Set;for(const n of e.migrations??[])for(const r of n.new_sqlite_classes??[])t.add(r);return t},g=(e,t,n,r,c)=>{for(const a of e.durable_objects?.bindings??[])if(!(a.name===void 0||a.class_name===void 0)){if(a.script_name!==void 0){c.push(`durable_objects.${a.name} (external script_name "${a.script_name}")`);continue}n.add("DurableObjectNamespace"),r.push(m(a.name,`DurableObjectNamespace(${o(a.name)}, { className: ${o(a.class_name)}, sqlite: ${String(t.has(a.class_name))} })`))}},v=(e,t)=>{for(const[n,r]of Object.entries(e.vars??{}))t.push(m(n,o(r)))},f=["ai","ai_search","ai_search_namespaces","analytics","analytics_engine_datasets","artifacts","assets","browser","containers","flagship","hyperdrive","images","k2","pipelines","secrets_store_secrets","send_email","services","tail_consumers","vectorize","worker_loaders","workflows","exports"],w=(e,t)=>{for(const n of f){const r=e[n];r!==void 0&&(!Array.isArray(r)||r.length>0)&&t.push(n)}(e.queues?.consumers?.length??0)>0&&t.push("queues.consumers")},k=e=>{const t=e.name??"worker",n=[],r=new Set(["Worker"]),c=[],a=[],p=h(e),b=[{construct:"D1Database",entries:(e.d1_databases??[]).map(s=>({binding:s.binding,name:s.database_name})),nameKey:"name"},{construct:"R2Bucket",entries:(e.r2_buckets??[]).map(s=>({binding:s.binding,name:s.bucket_name})),nameKey:"name"},{construct:"KVNamespace",entries:(e.kv_namespaces??[]).map(s=>({binding:s.binding,name:s.binding})),nameKey:"title"},{construct:"Queue",entries:(e.queues?.producers??[]).map(s=>({binding:s.binding,name:s.queue})),nameKey:"name"}];for(const{construct:s,entries:l,nameKey:y}of b)for(const i of l)i.binding!==void 0&&(r.add(s),c.push(`const ${u(i.binding)} = await ${s}(${o(i.binding)}, { adopt: true, ${y}: ${o(i.name??i.binding)} });`),a.push(m(i.binding)));g(e,p,r,a,n),v(e,a),w(e,n);const _=["adopt: true,",a.length===0?void 0:`bindings: {
|
|
2
|
+
${a.join(`
|
|
3
|
+
`)}
|
|
4
|
+
},`,e.compatibility_date===void 0?void 0:`compatibilityDate: ${o(e.compatibility_date)},`,e.compatibility_flags===void 0||e.compatibility_flags.length===0?void 0:`compatibilityFlags: ${o([...e.compatibility_flags])},`,e.triggers?.crons===void 0||e.triggers.crons.length===0?void 0:`crons: ${o([...e.triggers.crons])},`,e.main===void 0?void 0:`entrypoint: ${o(e.main)},`,`name: ${o(t)},`].filter(s=>s!==void 0);return{source:["// GENERATED by @lunora/config from wrangler.jsonc — do not edit.","// Re-generated on every `lunora deploy`; edit wrangler.jsonc instead.","",'import alchemy from "alchemy";',`import { ${[...r].toSorted((s,l)=>s.localeCompare(l)).join(", ")} } from "alchemy/cloudflare";`,"",`const app = await alchemy(${o(t)});`,"",...c.length===0?[]:[...c,""],`export const worker = await Worker(${o(t)}, {`,` ${_.join(`
|
|
5
|
+
`)}`,"});","","await app.finalize();",""].join(`
|
|
6
|
+
`),unsupported:n}};export{h as sqliteClasses,k as wranglerToAlchemy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runCodegen as c,CodegenDiagnosticError as i}from"@lunora/codegen";import{wranglerCodegenInputs as a}from"./wranglerCodegenInputs-CbisphsH.mjs";import{isCodegenDisabled as s,CODEGEN_ENV as t}from"./CODEGEN_ENV-ZsCxV1kP.mjs";import{writeFileSync as p,renameSync as m,rmSync as d}from"node:fs";const u=r=>({apiSpec:r.apiSpec,lunoraDirectory:r.schemaDirectory??"lunora",projectRoot:r.projectRoot,...a(r.projectRoot)}),y=r=>{if(s(process.env[t]))return[`codegen is off (${t}=0 / \`lunora dev --no-codegen\`) — the source was written but \`_generated/\` was NOT regenerated`];try{c(u(r))}catch(o){if(o instanceof i)return[o.message];throw o}return[]},C=(r,o)=>{const e=`${r}.lunora-tmp`;try{p(e,o,"utf8"),m(e,r)}catch(n){throw d(e,{force:!0}),n}};export{y as r,C as w};
|