@lunora/config 1.0.0-alpha.29 → 1.0.0-alpha.290

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.
Files changed (114) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/dist/cloudflare/index.d.mts +1065 -0
  4. package/dist/cloudflare/index.d.ts +1065 -0
  5. package/dist/cloudflare/index.mjs +1 -0
  6. package/dist/index.d.mts +1024 -918
  7. package/dist/index.d.ts +1024 -918
  8. package/dist/index.mjs +1 -23
  9. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  10. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  11. package/dist/packem_shared/AGENT_RULES_DIR-C54Ta_vz.mjs +1 -0
  12. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  13. package/dist/packem_shared/BINDING_MANIFEST_VERSION-vItUTnHk.mjs +1 -0
  14. package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs +1 -0
  15. package/dist/packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs +1 -0
  16. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-C69wqbSP.mjs +1 -0
  17. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs +1 -0
  18. package/dist/packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs +4 -0
  19. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  20. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-DwGANZVw.mjs +1 -0
  21. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  22. package/dist/packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs +1 -0
  23. package/dist/packem_shared/LUNORA_IGNORED_PATHS-B0-PPvRp.mjs +19 -0
  24. package/dist/packem_shared/LUNORA_TAG-CiQM3BkI.mjs +1 -0
  25. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  26. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-De7gLGIy.mjs +1 -0
  27. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-0QiGKazX.mjs +1 -0
  28. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-ikHvqvS5.mjs +1 -0
  29. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-jTnj2MPJ.mjs +1 -0
  30. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Dbt0faMd.mjs +1 -0
  31. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  32. package/dist/packem_shared/STUDIO_PATH-BZI8go9A.mjs +1 -0
  33. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-CugcZbPf.mjs +1 -0
  34. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  35. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  36. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  37. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  38. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  39. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  40. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  41. package/dist/packem_shared/assertWranglerSatisfiesSchema-BiABHeMv.mjs +3 -0
  42. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  43. package/dist/packem_shared/buildPackageSecretsBlock-yv9mjKEW.mjs +19 -0
  44. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  45. package/dist/packem_shared/classifyPolicyEdit-D8NwrHxR.mjs +24 -0
  46. package/dist/packem_shared/collectExportGaps-CIYe_DRY.mjs +2 -0
  47. package/dist/packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs +1 -0
  48. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  49. package/dist/packem_shared/describePreservedCrons-7gaDLxWx.mjs +1 -0
  50. package/dist/packem_shared/detectFramework-CUiVEHDQ.mjs +1 -0
  51. package/dist/packem_shared/discover-info-Vj9d4qYt.mjs +1 -0
  52. package/dist/packem_shared/discoverAgentInfo-CTdCSfYM.mjs +1 -0
  53. package/dist/packem_shared/discoverContainerInfo-EhZtEBQs.mjs +1 -0
  54. package/dist/packem_shared/discoverSchemaInfo-DJvevsCm.mjs +1 -0
  55. package/dist/packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs +1 -0
  56. package/dist/packem_shared/inferLunoraBindings-DXLEJY9w.mjs +1 -0
  57. package/dist/packem_shared/interpretRemote-C9yJC_ZK.mjs +1 -0
  58. package/dist/packem_shared/lunora-manifest-v90ZUbVp.mjs +6 -0
  59. package/dist/packem_shared/mergeWranglerEnvironment-DOKJUNH8.mjs +1 -0
  60. package/dist/packem_shared/package-secrets-registry-DvtTiK4b.mjs +1 -0
  61. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  62. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  63. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  64. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  65. package/dist/packem_shared/reconcile-services-3dn35zgy.mjs +1 -0
  66. package/dist/packem_shared/reconcileBindingsSafely-VBbLYoAx.mjs +1 -0
  67. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  68. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  69. package/dist/packem_shared/runPostCodegenHook-B0T1q2YI.mjs +1 -0
  70. package/dist/packem_shared/schema-info.d-fEhxTb9k.d.mts +397 -0
  71. package/dist/packem_shared/schema-info.d-fEhxTb9k.d.ts +397 -0
  72. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  73. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  74. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  75. package/dist/packem_shared/validate-bindings-Dnf1t0SY.mjs +1 -0
  76. package/dist/packem_shared/withTailConsumer-B1NoKIsj.mjs +1 -0
  77. package/dist/packem_shared/wranglerToAlchemy-BMOQYRyw.mjs +6 -0
  78. package/dist/packem_shared/write-atomic-9d9xs5ON.mjs +1 -0
  79. package/dist/studio-host/index.d.mts +314 -110
  80. package/dist/studio-host/index.d.ts +314 -110
  81. package/dist/studio-host/index.mjs +1 -7
  82. package/package.json +15 -7
  83. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  84. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  85. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  86. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  87. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  88. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  89. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  90. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  91. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
  92. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  93. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  94. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  95. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  96. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  97. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  98. package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
  99. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  100. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  101. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  102. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  103. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  104. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  105. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  106. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  107. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  108. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  109. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  110. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  111. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  112. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  113. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  114. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
@@ -0,0 +1 @@
1
+ import{existsSync as _,statSync as O,readFileSync as D,readdirSync as U}from"node:fs";import{discoverFlags as Y,FLAGS_FILENAME as M,discoverQueues as W,QUEUES_FILENAME as G,readServiceBindings as K}from"@lunora/codegen";import{parse as C,init as X}from"es-module-lexer";import{discoverAgentInfo as q}from"./discoverAgentInfo-CTdCSfYM.mjs";import{discoverContainerInfo as H}from"./discoverContainerInfo-EhZtEBQs.mjs";import{d as w}from"./discover-info-Vj9d4qYt.mjs";import{escapeRegExp as Q}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverSchemaInfo as V}from"./discoverSchemaInfo-DJvevsCm.mjs";import{resolveWorkerEntry as J,COMPOSED_ENTRY_DURABLE_OBJECTS as z,GENERATED_MODULE_DURABLE_OBJECTS as Z,GENERATED_DIRECTORY as k,DURABLE_OBJECT_BINDINGS as ee,detectExportedDurableObjects as se,detectClassExports as y}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{discoverWorkflowInfo as re}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as m}from"node:path";const oe=(e,s)=>{const{error:o,value:r}=w(e,s,M,Y);return o===void 0?{flags:r}:{error:o}},L=/^\s*import\s+type\b/,te=new Set(["@lunora/agent","@lunora/agent/sandbox"]),h=["browserTool","jsCodeTool"],v=Object.fromEntries(h.map(e=>{const s=Q(e);return[e,{fallback:new RegExp(String.raw`import\s+\{[^}]*\b${s}\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']`,"u"),name:new RegExp(String.raw`\b${s}\b`,"u"),typeSpecifier:new RegExp(String.raw`\btype\s+${s}\b`,"u")}]})),ne=e=>{const s=e.indexOf("{");if(s===-1)return"";const o=e.indexOf("}",s+1);return o===-1?e.slice(s+1):e.slice(s+1,o)},ae=(e,s)=>{if(L.test(e))return!1;const o=ne(e);return v[s].name.test(o)&&!v[s].typeSpecifier.test(o)},ie=e=>{let s;try{const[o]=C(e);s=o.filter(r=>r.n!==void 0&&te.has(r.n)).map(r=>e.slice(r.ss,r.se))}catch{s=void 0}return Object.fromEntries(h.map(o=>[o,s===void 0?v[o].fallback.test(e):s.some(r=>ae(r,o))]))},ce=(e,s)=>{const{error:o,value:r}=w(e,s,G,W);return o===void 0?{queues:r??[]}:{error:o,queues:[]}},de=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),ue=new Set([".git",".lunora-cache",".wrangler","dist",k,"node_modules"]),le=["lunora","src"],pe=/\benv\s*\.\s*DB\b/,me=/\benv\s*\.\s*AI\b/,P=/\bctx\s*\.\s*pipelines\b/,B=/\bctx\s*\.\s*r2sql\b/,E={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesNotify:{pattern:/\bfrom\s+["']@lunora\/notify["']/,source:"@lunora/notify"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:P,source:"@lunora/bindings/pipelines"},usesR2sql:{pattern:B,source:"@lunora/bindings/r2sql"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},f=Object.keys(E),fe="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",j=[...f,"needsD1","usesWorkerLoader"],be=()=>{const e={};for(const s of j)e[s]=!1;return e},l=Object.freeze(be()),x=(e,s)=>{const o={};for(const r of j)o[r]=e[r]||s[r];return o},ge=e=>{for(const s of f)if(E[s].source===e)return{...l,[s]:!0};return l},he=e=>{const[s]=C(e);let o=l;for(const r of s){const t=r.n;!t||L.test(e.slice(r.ss,r.se))||(o=x(o,ge(t)))}return o},Ee=e=>{const s={...l};for(const o of f)s[o]=E[o].pattern.test(e);return s},Se=e=>{let s;try{s=he(e)}catch{s=Ee(e)}return x(s,{...l,needsD1:pe.test(e),usesAi:me.test(e),usesPipelines:P.test(e),usesR2sql:B.test(e)})},R=(e,s)=>{let o;try{o=U(e,{withFileTypes:!0})}catch{return}for(const r of o){if(r.isDirectory()){ue.has(r.name)||R(m(e,r.name),s);continue}const t=r.name.lastIndexOf(".");t!==-1&&de.has(r.name.slice(t))&&s.push(m(e,r.name))}},ye=(e,s)=>V(e,s).info?.hasD1GlobalTable??!1,ve=(e,s)=>{let o=l;for(const r of s){const t=m(e,r);if(!_(t)||!O(t).isDirectory())continue;const n=[];R(t,n);for(const a of n)o=x(o,Se(D(a,"utf8")))}return o},_e=(e,s)=>{const o=m(e,s),r=Object.fromEntries(h.map(n=>[n,!1]));if(!_(o)||!O(o).isDirectory())return r;const t=[];R(o,t);for(const n of t){const a=ie(D(n,"utf8"));for(const i of h)r[i]||=a[i]}return r},xe=(e,s,o)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`exports.${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...o.map(r=>r.exported?`exports.${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Re=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI 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: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${fe}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned"],[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.usesX402Pay,"hint: @lunora/x402/pay is imported (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(([r])=>r).map(([,r])=>r),Ie=(e,s,o,r=[],t=[],n=[])=>{const a=new Set(e.map(c=>c.className)),i=e.map(c=>`${c.binding}/${c.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...xe(r,t,n),...Re(o,a)),i},je=async e=>{await X;const s=e.schemaDir??"lunora",o=e.scanDirs??le,r=ve(e.projectRoot,o),t=_e(e.projectRoot,s),n={...r,usesBrowser:r.usesBrowser||t.browserTool,usesWorkerLoader:t.jsCodeTool},a=J(e.projectRoot);let i;a.composed?i=[...z,...Object.entries(Z).filter(([u])=>_(m(e.projectRoot,s,k,`${u}.ts`))).map(([,u])=>u)].map(u=>({binding:ee[u],className:u})):i=a.path===void 0?[]:se(a.path);const c=n.needsD1||ye(e.projectRoot,s),I=y(a,H(e.projectRoot,s).containers,"containers"),A=y(a,re(e.projectRoot,s).workflows,"workflows"),N=y(a,q(e.projectRoot,s).agents,"agents"),$=[...ce(e.projectRoot,s).queues],{flags:b}=oe(e.projectRoot,s),S=b?.provider==="flagship"&&b.mode==="binding"?b.bindingName:void 0,T={};for(const d of f)T[d]=n[d];const g=Ie(i,c,n,I,A,N);S!==void 0&&g.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${S}", app_id }) — the app_id can't be auto-provisioned`);const p=K(e.projectRoot),F=p.error===void 0?p.services:void 0;return p.error!==void 0&&g.push(`hint: lunora.config \`services\` not reconciled — ${p.error}`),g.push(...p.services.map(d=>`${d.binding} → ${d.worker} (lunora.config services.${d.name})`)),{agents:N,containers:I,durableObjects:i,flagshipBinding:S,needsD1:c,queues:$,services:F,signals:g,usesFlags:b!==void 0,usesWorkerLoader:n.usesWorkerLoader,workflows:A,...T}},$e=e=>{const s=[];for(const o of f)e[o]&&s.push(E[o].source);return s};export{je as inferLunoraBindings,$e as packageNamesFromBindings};
@@ -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-CfoV0tDu.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{existsSync as O,readFileSync as b,writeFileSync as N}from"node:fs";import{applyEdits as $,modify as S,parseTree as h,findNodeAtLocation as g}from"jsonc-parser";import{join as A}from"node:path";const F=/^([\t ]+)"/mu,J=n=>{const o=F.exec(n)?.[1]??" ";return{eol:n.includes(`\r
2
+ `)?`\r
3
+ `:`
4
+ `,insertSpaces:!o.startsWith(" "),tabSize:o.length}},K=n=>{const o=A(n,"package.json");if(O(o))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=J(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=h(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 v=`${i}${c}${y}: ${f}${i}${e.repeat(o.length-1)}`;return`${n.slice(0,s.offset+1)}${v}${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&&N(n.path,i,"utf8")};export{k as a,p as c,J as f,K as r};
@@ -0,0 +1 @@
1
+ const c=["artifacts","containers","d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],i=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],m=(s,n)=>{if(n===void 0)return{merged:s,unverifiedKeys:[]};const t=s.env?.[n];if(t===void 0){const e=Object.keys(s.env??{}).toSorted((v,f)=>v.localeCompare(f)),l=e.length>0?` (declared: ${e.join(", ")}).`:" (no environments are declared).";return{error:`--env "${n}" names no environment declared in wrangler.jsonc's "env" block${l}`,merged:s,unverifiedKeys:[]}}const o={...s},r=Object.keys(t).filter(e=>e!=="env");for(const e of r)i.includes(e)&&(o[e]=t[e]);for(const e of c)o[e]=t[e];const a=new Set([...c,...i]),d=r.filter(e=>!a.has(e)).map(String);return{merged:o,unverifiedKeys:d}};export{m as mergeWranglerEnvironment};
@@ -0,0 +1 @@
1
+ const a=e=>e.endsWith("S")?e.slice(0,-1):e,r=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),n=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),c=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],i=new RegExp(`(?:${[...n,...c.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),p=e=>r(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),d=e=>{if(p(e))return!1;const s=r(e);if(s.some(o=>n.has(a(o))))return!0;const t=a(s.join("_"));return c.some(o=>t===o||t.endsWith(`_${o}`))||i.test(e)},h=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],u=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],l={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/notify":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"},{description:"Firebase project id for FCM (HTTP v1) push. Found in the Firebase console project settings.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"},{description:"OAuth2 access token for FCM (HTTP v1). Convenient for dev but expires — in production supply a getAccessToken() in defineNotify instead. Obtain via the Google Cloud SDK / a service account.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_ACCESS_TOKEN",placeholderValue:"<your-fcm-access-token>"}],"@lunora/payment":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"},{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"},{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"},{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"},{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}]},y=new Set([...u,...[...h,...Object.values(l).flat()].filter(e=>d(e.key)&&!e.placeholderValue.startsWith("<")).map(e=>e.key)]),k=e=>{const s=[];for(const t of e){const o=l[t];o!==void 0&&s.push(...o)}return s};export{h as C,y as M,l as P,d as a,p as i,k as s};
@@ -0,0 +1 @@
1
+ import{readFileSync as n}from"node:fs";import{join as s}from"node:path";import{parseDevVariableEntries as i}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const a=(o,r)=>{const e=i(o).find(t=>t.key===r);return e===void 0||e.value===""?void 0:e.value},d=o=>{let r;try{r=a(n(s(o,".dev.vars"),"utf8"),"LUNORA_ADMIN_TOKEN")}catch{r=void 0}const e=process.env.LUNORA_ADMIN_TOKEN;return typeof e=="string"&&e!==""&&e!==r&&console.warn("[lunora] LUNORA_ADMIN_TOKEN is exported in this shell but differs from .dev.vars — the local worker only verifies the .dev.vars token, so the studio uses that one."),r};export{a as parseDevVariable,d as resolveAdminToken};
@@ -0,0 +1 @@
1
+ import{Project as m,SyntaxKind as n}from"ts-morph";const f=/^v\s*\.\s*optional\s*\(/u,x=/\.shardBy\(\s*["']([^"']+)["']\s*\)/u,T=/\.global\(\s*(?:\{[^{}]*\}\s*)?\)/u,p=/["']/gu,u=e=>{const t=e.getDescendantsOfKind(n.CallExpression);return e.getKind()===n.CallExpression&&t.push(e.asKindOrThrow(n.CallExpression)),t},A=e=>f.test(e.trim()),h=e=>e?.getKind()!==n.ArrayLiteralExpression?[]:e.asKindOrThrow(n.ArrayLiteralExpression).getElements().filter(t=>t.getKind()===n.StringLiteral).map(t=>t.asKindOrThrow(n.StringLiteral).getLiteralText()),E=e=>{if(e?.getKind()!==n.ObjectLiteralExpression)return!1;const t=e.asKindOrThrow(n.ObjectLiteralExpression).getProperty("unique");return t?.getKind()===n.PropertyAssignment&&t.getInitializer()?.getText()==="true"},K=e=>{const t=e.getExpression();if(t.getKind()!==n.PropertyAccessExpression||t.asKindOrThrow(n.PropertyAccessExpression).getName()!=="index")return;const[r,a,s]=e.getArguments();if(r?.getKind()===n.StringLiteral)return{fields:h(a),name:r.asKindOrThrow(n.StringLiteral).getLiteralText(),unique:E(s)}},O=e=>{const t=e.getInitializer();if(t===void 0)return[];const r=[];for(const a of u(t)){const s=K(a);s!==void 0&&r.push(s)}return r},y=e=>{const t=[],r=e.getInitializer(),s=(r===void 0?void 0:u(r).find(l=>l.getExpression().getText()==="defineTable"))?.getArguments()[0];if(s?.getKind()!==n.ObjectLiteralExpression)return t;for(const l of s.getProperties()){if(l.getKind()!==n.PropertyAssignment)continue;const i=l,o=i.getName().replaceAll(p,""),c=i.getInitializer()?.getText()??"";t.push({name:o,optional:A(c),validator:c})}return t},P=e=>{const r=new m({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("schema.ts",e,{overwrite:!0}),a=r.getDescendantsOfKind(n.CallExpression).find(i=>i.getExpression().getText()==="defineSchema");if(a===void 0)return{ok:!1,reason:r.getImportDeclarations().some(o=>o.getNamedImports().some(c=>c.getName()==="defineSchema"&&c.getAliasNode()!==void 0))?"aliased-define-schema":"no-define-schema"};const s=a.getArguments()[0];if(s?.getKind()!==n.ObjectLiteralExpression)return{ok:!1,reason:"non-object-argument"};const l=[];for(const i of s.getProperties()){if(i.getKind()!==n.PropertyAssignment)continue;const o=i,c=o.getName().replaceAll(p,""),g=o.getInitializer()?.getText()??"",d=x.exec(g);l.push({columns:y(o),global:T.test(g),indexes:O(o),name:c,...d?.[1]===void 0?{}:{shardBy:d[1]}})}return{ok:!0,tables:l}};export{u as collectCalls,P as parseSchema};
@@ -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,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
+ import{existsSync as C,writeFileSync as k}from"node:fs";import{applyModify as _}from"./applyModify-DKP2l6S9.mjs";import{c as h,a as A}from"./lunora-manifest-v90ZUbVp.mjs";import{readWranglerJsonc as D}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as F}from"node:path";const O="services",$="services",S="wrangler.dev.jsonc",f="dev:services",M=(n,t)=>{const s=t===void 0?n.worker:n.envWorkers[t]??`${n.worker}-${t}`;return{binding:n.binding,...n.entrypoint===void 0?{}:{entrypoint:n.entrypoint},service:s}},g=n=>typeof n?.binding=="string"?n.binding:"",b=(n,t,s,d,p,o)=>{const i=t.join("."),r=new Map(d.map(e=>[e.binding,M(e,o)])),a=s.filter(e=>!p.has(g(e))),w=new Set(a.map(e=>g(e))),c=new Map(s.filter(e=>p.has(g(e))).map(e=>[g(e),e])),u=[...r].filter(([e])=>!w.has(e)),v=[...a,...u.map(([,e])=>e)],m=u.filter(([e])=>!c.has(e)).map(([e,l])=>`${i}/${e} → ${l.service??""}`),y=[...u.filter(([e,l])=>c.has(e)&&h(c.get(e))!==h(l)).map(([e])=>`${i}/${e}`),...[...c.keys()].filter(e=>!r.has(e)).map(e=>`${i}/${e} (removed)`)],x=a.filter(e=>r.has(g(e))&&h(e)!==h(r.get(g(e)))).map(e=>`${i}: the hand-written "${g(e)}" entry is left as is — remove it to let lunora.config \`services\` manage that binding.`),E=m.length>0||y.length>0,j=v.length===0?void 0:v;return{added:m,owned:u.map(([e])=>e).toSorted((e,l)=>e.localeCompare(l)),text:E?_(n,t,j):n,updated:y,warnings:x}},V=n=>{const t=n?.lunora?.[O];return typeof t!="object"||t===null||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(s=>Array.isArray(s[1])&&s[1].every(d=>typeof d=="string")))},G=n=>new Set(V(n)[$]),L=(n,t,s,d)=>{const p=[{current:t.services??[],path:[$]},...Object.entries(t.env??{}).map(([i,r])=>({current:r?.services??[],environment:i,path:["env",i,"services"]}))],o={added:[],owned:{},text:n,updated:[],warnings:[]};for(const{current:i,environment:r,path:a}of p){const w=a.join("."),c=b(o.text,a,i,s,new Set(d[w]),r);o.text=c.text,o.added.push(...c.added),o.updated?.push(...c.updated??[]),o.warnings?.push(...c.warnings??[]),c.owned.length>0&&(o.owned[w]=c.owned)}return o},N=(n,t,s)=>{const d=F(n,S),p={added:[],path:d,updated:[],warnings:[]};if(t.length===0&&s[f]===void 0)return{...p,owned:{}};const{parsed:o,text:i}=C(d)?D(d):{parsed:void 0,text:""};if(o===void 0){const a=s[f];return{...p,owned:a===void 0||a.length===0?{}:{[f]:a}}}const r=b(i,["services"],o.services??[],t,new Set(s[f]),void 0);return r.text!==i&&k(d,r.text,"utf8"),{added:r.added,owned:r.owned.length>0?{[f]:r.owned}:{},path:d,updated:r.updated??[],warnings:(r.warnings??[]).map(a=>`${S} ${a}`)}},J=(n,t)=>{A(n,O,Object.keys(t).length===0?void 0:t)};export{L as a,N as b,J as c,G as o,V as r};
@@ -0,0 +1 @@
1
+ import{inferLunoraBindings as p}from"./inferLunoraBindings-DXLEJY9w.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-CIYe_DRY.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-7gaDLxWx.mjs";const j=async(i,t,o)=>{try{const n=await p({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n),a=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${a})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${a})`),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&&o?.(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,o)=>{try{const n=m(i,t);n.changed&&o.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)o.warn(`${r} ${s}`);const e=n.preserved.join("\0"),a=w(n.preserved);a!==void 0&&(n.changed||c.get(i)!==e)&&o.info?.(`${r} ${a}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);o.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=g(i);n.changed&&o.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);o.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("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;"),_=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{spawn as i}from"node:child_process";import{existsSync as d,readFileSync as u}from"node:fs";import{join as f}from"node:path";import{runScriptArgsFor as g,detectPackageManager as m}from"./addArgsFor-CYZKhNIo.mjs";const o="postcodegen",l=r=>new Promise((n,s)=>{const e=i(r.command,[...r.args],{cwd:r.cwd??process.cwd(),shell:process.platform==="win32",stdio:["inherit",r.stdoutToStderr===!0?2:"inherit","inherit"]});e.on("error",s),e.on("close",a=>{n({code:a??1})})}),p=r=>{const n=f(r,"package.json");if(!d(n))return!1;try{const e=JSON.parse(u(n,"utf8"))?.scripts;return typeof e?.[o]=="string"&&e[o]!==""}catch{return!1}},P=async r=>{const{cwd:n,logger:s}=r;if(!p(n))return{ran:!1};const e=t=>(s.error(t),{error:t,ran:!0});let a;try{a=g(m(n),o)}catch(t){return e(`cannot run \`${o}\`: ${t instanceof Error?t.message:String(t)}`)}s.info(`running \`${o}\``);let c;try{c=await(r.spawner??l)({args:a.args,command:a.command,cwd:n,stdoutToStderr:r.stdoutToStderr})}catch(t){return e(`\`${o}\` failed to start: ${t instanceof Error?t.message:String(t)}`)}return c.code!==0?e(`\`${o}\` exited ${String(c.code)}`):{ran:!0}};export{P as runPostCodegenHook};