@lunora/config 1.0.0-alpha.403 → 1.0.0-alpha.404
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/dist/cloudflare/index.mjs +1 -1
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BISd53nh.mjs +1 -0
- package/dist/packem_shared/{REMOTE_ELIGIBLE_KEYS-DnbYTTWX.mjs → REMOTE_ELIGIBLE_KEYS-CuhB99R2.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-B-Xii8Ke.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-rjtY7n7Q.mjs +1 -0
- package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
- package/dist/packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs +1 -0
- package/dist/packem_shared/devVariablesStamp-Cetr3qFz.mjs +1 -0
- package/dist/packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs +1 -0
- package/dist/packem_shared/{materializeServiceDevConfigs-k_oLCcBT.mjs → materializeServiceDevConfigs-qUY4_iu1.mjs} +1 -1
- package/dist/packem_shared/write-atomic-nFihpdk8.mjs +3 -0
- package/dist/studio-host/index.d.mts +46 -1
- package/dist/studio-host/index.d.ts +46 -1
- package/dist/studio-host/index.mjs +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CXf64-YJ.mjs +0 -1
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-B_R_bpd5.mjs +0 -1
- package/dist/packem_shared/STUDIO_PATH-D77qXwaX.mjs +0 -1
- package/dist/packem_shared/hasCloudflareCredentials-CNPVIVBb.mjs +0 -1
- package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +0 -1
- package/dist/packem_shared/write-atomic-zoDF_EAO.mjs +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as t}from"../packem_shared/assertWranglerSatisfiesSchema-B4DcaiJY.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as l}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as E,detectCloudflareCliConfig as m,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as d}from"../packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs";import{default as C}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as x}from"../packem_shared/hasCloudflareCredentials-
|
|
1
|
+
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as t}from"../packem_shared/assertWranglerSatisfiesSchema-B4DcaiJY.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as l}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as E,detectCloudflareCliConfig as m,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as d}from"../packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs";import{default as C}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as x}from"../packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs";import{describeWithheld as c,withheldBindings as I}from"../packem_shared/describeWithheld-CbyzZjZF.mjs";import{bindingsNeedingDatabase as A,startLocalHyperdrive as D}from"../packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs";import{HYPERDRIVE_PLACEHOLDER_ID as S,collectExportGaps as W,reconcileWranglerBindings as T}from"../packem_shared/HYPERDRIVE_PLACEHOLDER_ID-DPgHQEDf.mjs";import{reconcileWranglerCompatibilityDate as v}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as b,reconcileWranglerCrons as B}from"../packem_shared/describePreservedCrons-C5KPuPy3.mjs";import{reconcileBindingsSafely as u,reconcileWranglerExtras as G}from"../packem_shared/reconcileBindingsSafely-xWmrGHnx.mjs";import{REMOTE_ELIGIBLE_KEYS as y,injectRemoteFlags as M,isRemoteEnvEnabled as P,materializeDevWranglerConfig as V,planRemoteBindings as H,resolveRemoteEnabled as w}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-CuhB99R2.mjs";import{materializeServiceDevConfigs as K}from"../packem_shared/materializeServiceDevConfigs-qUY4_iu1.mjs";import{default as z}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs";import{withTailConsumer as J}from"../packem_shared/withTailConsumer-CF3pk_Ov.mjs";import{WORKERS_CACHE_MIN_DATE as k,isCacheEnabled as q}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{wranglerCodegenInputs as $}from"../packem_shared/wranglerCodegenInputs-UqO5e_qJ.mjs";import{DEFAULT_OBSERVABILITY as re,resolveObservabilitySampling as oe}from"../packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{mergeWranglerEnvironment as te}from"../packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs";import{WRANGLER_FILES as ie,findWranglerFile as le,readWranglerJsonc as fe}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as me,validateWranglerProject as se}from"../packem_shared/UNEXPORTED_CLASS_MARKER-mdcw5KDY.mjs";import{scanWranglerVariablesForSecrets as de}from"../packem_shared/scanWranglerVariablesForSecrets-CZDS9y2i.mjs";import{wranglerToAlchemy as Ce}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as xe,REQUIRED_FLAG as _e,validateWrangler as ce,validateWranglerConfig as Ie}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs";export{i as BINDING_MANIFEST_VERSION,E as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,d as CLOUDFLARE_DRIVER,z as CLOUDFLARE_TOOLCHAIN_VERSIONS,re as DEFAULT_OBSERVABILITY,C as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,S as HYPERDRIVE_PLACEHOLDER_ID,y as REMOTE_ELIGIBLE_KEYS,xe as REQUIRED_COMPATIBILITY_DATE,_e as REQUIRED_FLAG,me as UNEXPORTED_CLASS_MARKER,k as WORKERS_CACHE_MIN_DATE,ie as WRANGLER_FILES,o as applyModify,t as assertWranglerSatisfiesSchema,A as bindingsNeedingDatabase,l as buildBindingManifest,W as collectExportGaps,b as describePreservedCrons,c as describeWithheld,m as detectCloudflareCliConfig,le as findWranglerFile,x as hasCloudflareCredentials,M as injectRemoteFlags,q as isCacheEnabled,P as isRemoteEnvEnabled,V as materializeDevWranglerConfig,K as materializeServiceDevConfigs,te as mergeWranglerEnvironment,H as planRemoteBindings,fe as readWranglerJsonc,u as reconcileBindingsSafely,T as reconcileWranglerBindings,v as reconcileWranglerCompatibilityDate,B as reconcileWranglerCrons,G as reconcileWranglerExtras,oe as resolveObservabilitySampling,w as resolveRemoteEnabled,de as scanWranglerVariablesForSecrets,D as startLocalHyperdrive,ce as validateWrangler,Ie as validateWranglerConfig,se as validateWranglerProject,s as warnCloudflareCliConfigOnce,J as withTailConsumer,I as withheldBindings,$ as wranglerCodegenInputs,Ce as wranglerToAlchemy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as d,readFileSync as y}from"node:fs";import{join as s,isAbsolute as a,relative as m}from"node:path";import{LunoraError as p}from"@lunora/errors";import{classifyPolicyEdit as k,scaffoldPolicyFile as h,resolveServerModule as l,wireRlsIntoProcedure as v}from"./classifyPolicyEdit-DJi9Fk8G.mjs";import{w as c,r as b}from"./write-atomic-nFihpdk8.mjs";const D="/__lunora/policy-scaffold",u=r=>r==="unknown-procedure"?404:r==="already-wired"||r==="destructive"?409:422,f=(r,o,e)=>{let t;try{t=b(r,o)}catch(n){return{body:{error:n instanceof Error?n.message:String(n),ok:!1},status:500}}return{body:{...e,diagnostics:t,ok:!0},status:200}},g=r=>({body:{edit:r,message:"Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",needsManualEdit:!0,ok:!1},status:409}),w=(r,o)=>{const e=h(o,l(r.projectRoot));if(!e.ok)return{body:{error:e.reason,ok:!1},status:u(e.reason)};const t=r.schemaDirectory??"lunora",n=s(r.projectRoot,t,e.fileName);return d(n)?{body:{error:"file-exists",fileName:e.fileName,ok:!1},status:409}:(c(n,e.source),f(r,{path:n,text:e.source},{fileName:e.fileName}))},R=(r,o,e)=>{if(typeof e!="string"||e.length===0||a(e)||e.includes("\\"))return;const t=s(r,o),n=s(t,`${e}.ts`),i=m(t,n);if(!(i.startsWith("..")||a(i)))return n},N=(r,o)=>{const e=R(r.projectRoot,r.schemaDirectory??"lunora",o.filePath);if(e===void 0||!d(e))return{body:{error:"unknown-procedure",ok:!1},status:404};const t=v(y(e,"utf8"),o,l(r.projectRoot));return t.ok?(c(e,t.text),f(r,{path:e,text:t.text},{exportName:o.exportName})):{body:{error:t.reason,ok:!1},status:u(t.reason)}},E=r=>{if(r.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:o}=r;if(o==null||typeof o!="object"||typeof o.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};const e=o;if(k(e)==="destructive")return g(e);if(e.kind==="scaffoldPolicy")return w(r,e);if(e.kind==="wireRls")return N(r,e);throw new p("INTERNAL",`unhandled additive policy edit kind: ${String(e.kind)}`)};export{D as POLICY_SCAFFOLD_ENDPOINT,E as handlePolicyScaffoldRequest};
|
package/dist/packem_shared/{REMOTE_ELIGIBLE_KEYS-DnbYTTWX.mjs → REMOTE_ELIGIBLE_KEYS-CuhB99R2.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as v}from"./hasCloudflareCredentials-
|
|
1
|
+
import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as v}from"./hasCloudflareCredentials-Bak5w1_6.mjs";import{withheldBindings as y,writeDevConfig as E,noopCleanup as R}from"./describeWithheld-CbyzZjZF.mjs";import{r as S}from"./lunora-manifest-DuH_Cmyu.mjs";import{o as _}from"./reconcile-services-DFqH4eMQ.mjs";import{findWranglerFile as j,readWranglerJsonc as w}from"./WRANGLER_FILES-UNW-xY5u.mjs";const p={ai:{label:"AI",shape:"object"},ai_search:{label:"AI Search",shape:"array"},ai_search_namespaces:{label:"AI Search namespace",shape:"array"},analytics:{label:"Analytics SQL",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},C=Object.keys(p),m=(e,r)=>typeof e.binding=="string"?e.binding:r,u=(e,r,t,n)=>{const i=[];for(const[s,o]of r.entries())o!=null&&(e==="kv_namespaces"&&(typeof o.id!="string"||o.id==="")||i.push({binding:m(o,`#${String(s)}`),kind:t,path:[...n,s],section:e}));return i},h=(e,r)=>p[e].shape===r,I=(e,r)=>{const{label:t}=p[e];if(h(e,"array"))return u(e,r[e]??[],t,[]);if(h(e,"object")){const n=r[e];return n==null?[]:[{binding:m(n,e),kind:t,path:[],section:e}]}return u(e,r.queues?.producers??[],t,["producers"])},B=e=>C.flatMap(r=>I(r,e)),L=(e,r)=>{let t=e;for(const n of r)t=g(t,[n.section,...n.path,"remote"],!0);return t},W=e=>{const r=a=>({cleanup:R,reason:a,remoteBindings:[],withheld:[]}),t=j(e.projectRoot);if(!t)return r("wrangler.jsonc not found");const{parsed:n,text:i}=w(t);if(n===void 0)return r(`failed to parse ${t} as JSONC`);const s=_(S(e.projectRoot)),o=e.remote?B(n).filter(a=>a.section!=="services"||!s.has(a.binding)):[],l=y(n,e.hasCredentials??(()=>v({projectRoot:e.projectRoot}))),c=l.some(({kind:a})=>a==="ai")?o.filter(a=>a.section!=="ai"):o;if(c.length===0&&l.length===0)return r(e.remote?"no remote-eligible bindings to proxy":void 0);let d=i;for(const{kind:a}of l)d=g(d,[a],void 0);const b=c.length>0?L(d,c):d,f=E(e.projectRoot,"dev",b);return{cleanup:f.cleanup,configPath:f.configPath,remoteBindings:c,withheld:l}},k=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},D=e=>e.flag===!0||k(e.envValue)?!0:e.configPreference??!1;export{p as REMOTE_ELIGIBLE_KEYS,L as injectRemoteFlags,k as isRemoteEnvEnabled,W as materializeDevWranglerConfig,B as planRemoteBindings,D as resolveRemoteEnabled};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as a,readFileSync as d}from"node:fs";import{classifyEdit as l,applyAdditiveEdit as c}from"./applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as u}from"./parseSchema-D1Wbr1qv.mjs";import{w as f,r as p}from"./write-atomic-nFihpdk8.mjs";import{join as m}from"node:path";const F="/__lunora/schema-edit",b=t=>t==="destructive"||t==="duplicate-table"||t==="duplicate-column"||t==="duplicate-index"?409:t==="unknown-table"?404:t==="invalid-identifier"||t==="invalid-validator"?400:422,y=t=>({body:{error:t.reason,ok:!1},status:422}),k=t=>{if(!a(t))return{response:{body:{error:"no-schema-file",ok:!1},status:404}};const e=u(d(t,"utf8"));return e.ok?{tables:e.tables}:{response:y(e)}},g=t=>({body:{edit:t,message:"This edit changes stored data and must go through a migration. Review the migration before applying.",needsMigration:!0,ok:!1},status:409}),h=(t,e)=>{const r=t.body;if(r==null||typeof r!="object"||typeof r.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};if(l(r)==="destructive")return g(r);if(!a(e))return{body:{error:"no-schema-file",ok:!1},status:404};const o=c(d(e,"utf8"),r);if(!o.ok)return{body:{error:o.reason,ok:!1},status:b(o.reason)};f(e,o.text);let i;try{i=p(t,{path:e,text:o.text})}catch(s){return{body:{error:s instanceof Error?s.message:String(s),ok:!1},status:500}}const n=u(o.text);return{body:{diagnostics:i,ok:!0,tables:n.ok?n.tables:[]},status:200}},R=t=>{const e=m(t.projectRoot,t.schemaDirectory??"lunora","schema.ts");if(t.method==="GET"){const r=k(e);return"response"in r?r.response:{body:{ok:!0,tables:r.tables},status:200}}return t.method==="POST"?h(t,e):{body:{error:"method-not-allowed",ok:!1},status:405}};export{F as SCHEMA_EDIT_ENDPOINT,R as handleSchemaEditRequest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveAdminToken as A}from"./devVariablesStamp-Cetr3qFz.mjs";import{sendStudioDocument as D,applyStudioAssetCache as I}from"./applyStudioAssetCache-DHQEJuuv.mjs";import{isStandaloneModulePath as O,studioAssetsStamp as _,loadStudioAssets as C,readStandaloneAsset as H,assetContentType as N}from"./assetContentType-CUb5bpbI.mjs";import E from"./createStudioDocumentCache-B3Sf1bIl.mjs";import{detectAgentRules as v}from"./AGENT_RULES_DIR-Bd6JPtNa.mjs";import{handlePolicyScaffoldRequest as L,POLICY_SCAFFOLD_ENDPOINT as R}from"./POLICY_SCAFFOLD_ENDPOINT-BISd53nh.mjs";import b from"./renderStudioHtml-ByowDtMl.mjs";import{handleSchemaEditRequest as x,SCHEMA_EDIT_ENDPOINT as k}from"./SCHEMA_EDIT_ENDPOINT-B-Xii8Ke.mjs";import{handleSeedRequest as $,SEED_ENDPOINT as g}from"./SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as j}from"./serveJsonHandler-Dv0EdCb9.mjs";import{transportRejectionReason as F}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";import"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const c="/__lunora",M=`${c}/studio.js`,m=`${c}/styles.css`,T=/\/$/,U={[R]:L,[k]:x,[g]:$},q=new Set(["127.0.0.1","::1","localhost"]),et=t=>t!==void 0&&t!==!1&&!q.has(t),y=t=>t===void 0||t==="/"?"":t.replace(T,""),ot=t=>`${y(t)}${c}`,h=(t,s,r)=>{t.statusCode=200,t.setHeader("Content-Type",r),t.end(s)},w=t=>{try{return new URL(t,"http://localhost").pathname}catch{const s=t.indexOf("?");return s===-1?t:t.slice(0,s)}},nt=t=>{const{logger:s,projectRoot:r}=t,u=y(t.base);let l,f;const p=E(r,()=>b({adminToken:A(r),basePath:c,dataEditable:!0,rulesInstalled:v(r).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:M,styleHref:m})),P=(o,n,e)=>{const i=_();if((l===void 0||i!==f)&&(l=C(s),f=i),l===void 0){e.statusCode=501,e.setHeader("Content-Type","text/plain"),e.end("Lunora studio assets not found — install and build @lunora/studio.");return}const a=o===m,d=o.slice(o.lastIndexOf("/")+1);if(I(n,e,d,i))return;if(a){h(e,l.styles,"text/css; charset=utf-8");return}const S=H(d);if(S===void 0){e.statusCode=404,e.setHeader("Content-Type","text/plain"),e.end("Not found");return}h(e,S,N(d))};return(o,n,e)=>{const i=w(o.url??"").replace(T,""),a=u!==""&&i.startsWith(u)?i.slice(u.length):i;if(a!==c&&!a.startsWith(`${c}/`)){e();return}if(t.isNonLoopbackBind||F(o,s)!==void 0){n.statusCode=403,n.setHeader("Content-Type","text/plain"),n.end("Lunora studio is only available on loopback hosts in dev.");return}const d=U[a];if(d!==void 0){j(o,n,d,r,{apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,schemaDirectory:t.schemaDirectory});return}if(a===m||O(a)){P(a,o,n);return}D(n,p())}};export{c as STUDIO_PATH,M as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,nt as createStudioMiddleware,et as isNonLoopbackHost,w as requestPathname,ot as studioMountPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as c}from"node:fs";import{resolve as i}from"node:path";const f=5e3,r=new Map,u=".lunora-tmp",d=(o,n,e=Date.now())=>{for(const[t,s]of r)s.expiresAt<e&&r.delete(t);r.set(i(o),{expiresAt:e+f,text:n})},l=(o,n=Date.now())=>{const e=i(o),t=r.get(e);if(t===void 0||(r.delete(e),t.expiresAt<n))return!1;try{return c(e,"utf8")===t.text}catch{return!1}};export{u as STUDIO_WRITE_TEMP_SUFFIX,l as consumeStudioWrite,d as recordStudioWrite};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{devVariablesStamp as u}from"./devVariablesStamp-Cetr3qFz.mjs";const c=(o,r)=>{let t,e;return()=>{const a=u(o);return(t===void 0||a!==e)&&(e=a,t={value:r()}),t.value}};export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{statSync as n,readFileSync as i}from"node:fs";import{join as o}from"node:path";import{parseDevVariableEntries as a}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const v=(t,e)=>{const r=a(t).find(s=>s.key===e);return r===void 0||r.value===""?void 0:r.value},f=t=>{let e;try{e=v(i(o(t,".dev.vars"),"utf8"),"LUNORA_ADMIN_TOKEN")}catch{e=void 0}const r=process.env.LUNORA_ADMIN_TOKEN;return typeof r=="string"&&r!==""&&r!==e&&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."),e},m=t=>{try{const e=n(o(t,".dev.vars"));return`${String(e.ctimeMs)}:${String(e.size)}`}catch{return"0"}};export{m as devVariablesStamp,v as parseDevVariable,f as resolveAdminToken};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawnSync as m}from"node:child_process";import{readFileSync as L,readdirSync as A,existsSync as O}from"node:fs";import{homedir as S}from"node:os";import{join as r,dirname as d}from"node:path";const v=[".env",".env.local",".env.development",".env.development.local"],E=["CLOUDFLARE_API_TOKEN","CF_API_TOKEN"],g=["CLOUDFLARE_API_KEY","CF_API_KEY"],_=["CLOUDFLARE_EMAIL","CF_EMAIL"],w=new Set([...E,...g,..._]),p=/^export\s+/u,D=/\r?\n/u,I=/"loggedIn"\s*:\s*false/u,T=1e4,f=new Map,C=/^(["'])(.*)\1$/u,a=e=>e!==void 0&&e.trim()!=="",h=(e,t)=>[t,e.XDG_CONFIG_HOME,r(t,"Library","Preferences"),r(t,".config"),e.APPDATA===void 0?void 0:r(e.APPDATA,"xdg.config"),r(t,"AppData","Roaming","xdg.config")].filter(o=>a(o)),F=e=>{try{return A(e).length>0}catch{return!1}},K=e=>{for(let t=e;;t=d(t)){const o=r(t,"node_modules","wrangler","bin","wrangler.js");if(O(o))return o;if(d(t)===t)return}},P=(e,t)=>{const o=f.get(e);if(o!==void 0&&Date.now()-o.at<T)return o.loggedOut;const s=K(e);if(s===void 0)return!1;const{stdout:i}=m(process.execPath,[s,"whoami","--json"],{cwd:e,encoding:"utf8",env:{...t,WRANGLER_SEND_METRICS:"false"},stdio:["ignore","pipe","ignore"],timeout:3e3}),n=I.test(i);return f.set(e,{at:Date.now(),loggedOut:n}),n},R=e=>{const t=new Set;for(const o of v){let s;try{s=L(r(e,o),"utf8")}catch{continue}for(const i of s.split(D)){const n=i.trim().replace(p,""),c=n.indexOf("=");if(n.startsWith("#")||c===-1)continue;const l=n.slice(0,c).trim(),u=n.slice(c+1).trim().replace(C,"$2");w.has(l)&&a(u)&&t.add(l)}}return t},M=(e={})=>{const t=e.env??process.env,o=e.projectRoot===void 0?new Set:R(e.projectRoot),s=n=>a(t[n])||o.has(n);return E.some(n=>s(n))||g.some(n=>s(n))&&_.some(n=>s(n))?!0:h(t,e.home??S()).some(n=>F(r(n,".wrangler","config")))&&(e.projectRoot===void 0||!P(e.projectRoot,t))};export{M as hasCloudflareCredentials};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolute as p,dirname as m,resolve as h}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as u}from"./hasCloudflareCredentials-
|
|
1
|
+
import{isAbsolute as p,dirname as m,resolve as h}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as u}from"./hasCloudflareCredentials-Bak5w1_6.mjs";import{withheldBindings as g,writeDevConfig as w}from"./describeWithheld-CbyzZjZF.mjs";import{readWranglerJsonc as v}from"./WRANGLER_FILES-UNW-xY5u.mjs";const C=(e,n)=>{const{parsed:t,text:c}=v(e),o=t?.build,r=g(t,n.hasCredentials??(()=>u({projectRoot:n.projectRoot}))),s=typeof o?.command=="string"&&o.command!==""&&!(typeof o.cwd=="string"&&p(o.cwd));if(!s&&r.length===0)return{configPath:e,withheld:r};const d=m(e);let i=c;for(const{kind:f}of r)i=l(i,[f],void 0);s&&(i=l(i,["build","cwd"],h(d,typeof o.cwd=="string"?o.cwd:".")));const a=w(d,"service",i);return{cleanup:a.cleanup,configPath:a.configPath,withheld:r}},x=(e,n)=>{const t=e.map(o=>C(o,n)),c=t.flatMap(o=>o.cleanup===void 0?[]:[o.cleanup]);return{cleanup:()=>{for(const o of c)o()},configPaths:t.map(o=>o.configPath),withheld:t.flatMap(o=>o.withheld)}};export{x as materializeServiceDevConfigs};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as S,tsconfigFingerprint as C,projectConfigCandidatePaths as h}from"@lunora/codegen";import{wranglerCodegenInputs as l}from"./wranglerCodegenInputs-UqO5e_qJ.mjs";import{isCodegenDisabled as w,CODEGEN_ENV as n}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{recordStudioWrite as P,STUDIO_WRITE_TEMP_SUFFIX as $}from"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const F=o=>({apiSpec:o.apiSpec,lazyFunctions:o.lazyFunctions,lunoraDirectory:o.schemaDirectory??"lunora",projectRoot:o.projectRoot,...l(o.projectRoot)});let r;const c=o=>{const t=a(o);return`${o}:${String(t.mtimeMs)}:${String(t.size)}`},E=o=>{const t=S(o);return[t===void 0?"":`${c(t)}
|
|
2
|
+
${C(t)}`,...h(o).filter(e=>s(e)).map(e=>c(e))].join(`
|
|
3
|
+
`)},R=o=>{const t=E(o);return r?.lunoraDirectory===o&&r.key===t?(u(r.project,o),r.project):(r={key:t,lunoraDirectory:o,project:y(o)},r.project)},x=(o,t)=>{if(w(process.env[n]))return[`codegen is off (${n}=0 / \`lunora dev --no-codegen\`) — the source was written but \`_generated/\` was NOT regenerated`];try{const e=m(o.projectRoot,o.schemaDirectory??"lunora");f({...F(o),project:R(e)})}catch(e){if(r=void 0,e instanceof j)return[e.message];throw e}return P(t.path,t.text),[]},z=(o,t)=>{const e=`${o}${$}`;try{p(e,t,"utf8"),d(e,o)}catch(i){throw g(e,{force:!0}),i}};export{x as r,z as w};
|
|
@@ -24,6 +24,12 @@ declare const parseDevVariable: (contents: string, key: string) => string | unde
|
|
|
24
24
|
* Returns `undefined` when `.dev.vars` carries no token (the studio then prompts).
|
|
25
25
|
*/
|
|
26
26
|
declare const resolveAdminToken: (root: string) => string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* A cheap change stamp for the project's `.dev.vars` (`"0"` when absent), so a
|
|
29
|
+
* host that caches the Studio document can re-render it when the admin token is
|
|
30
|
+
* edited mid-session instead of embedding the one read at startup.
|
|
31
|
+
*/
|
|
32
|
+
declare const devVariablesStamp: (root: string) => string;
|
|
27
33
|
/**
|
|
28
34
|
* Set the asset cache headers, answering `304` when the request already holds
|
|
29
35
|
* this version. Returns true when the response is finished, false when the
|
|
@@ -150,6 +156,18 @@ declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
|
150
156
|
* place.
|
|
151
157
|
*/
|
|
152
158
|
declare const assetContentType: (fileName: string) => string;
|
|
159
|
+
/**
|
|
160
|
+
* Cache a studio host's rendered document, re-rendering it whenever `.dev.vars`
|
|
161
|
+
* under `root` changes. The document embeds the admin token, which is edited
|
|
162
|
+
* mid-session (rotation, the first `lunora dev` run writing it), so a document
|
|
163
|
+
* cached past such an edit would hand the studio a token the worker rejects.
|
|
164
|
+
*
|
|
165
|
+
* Every call costs one `stat` ({@link devVariablesStamp}); `render` runs on the
|
|
166
|
+
* first call and again only after the stamp moves. The stamp is taken before
|
|
167
|
+
* `render` reads the file, so a write landing between the two is seen as a
|
|
168
|
+
* change on the next call rather than cached under the newer stamp.
|
|
169
|
+
*/
|
|
170
|
+
declare const createStudioDocumentCache: <T>(root: string, render: () => T) => (() => T);
|
|
153
171
|
/**
|
|
154
172
|
* The host's project configuration, forwarded verbatim to the handler. Separate
|
|
155
173
|
* from `projectRoot` (which every host has) because these two come from the
|
|
@@ -370,6 +388,17 @@ interface SeedResponse {
|
|
|
370
388
|
* rather than hand back children whose parents it just dropped.
|
|
371
389
|
*/
|
|
372
390
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
391
|
+
/**
|
|
392
|
+
* Suffix of the temporary file a studio handler writes and renames over its
|
|
393
|
+
* target. A watcher that sees every file has to ignore it: its events are part
|
|
394
|
+
* of the handler's write, not a change of their own.
|
|
395
|
+
*/
|
|
396
|
+
declare const STUDIO_WRITE_TEMP_SUFFIX = ".lunora-tmp";
|
|
397
|
+
/**
|
|
398
|
+
* Whether a watcher event for `path` is the echo of a studio write. Returns true,
|
|
399
|
+
* and spends the record, only when the file still holds the text that was written.
|
|
400
|
+
*/
|
|
401
|
+
declare const consumeStudioWrite: (path: string, now?: number) => boolean;
|
|
373
402
|
/** A single header value, lower-cased and trimmed; `undefined` when absent or array-valued. */
|
|
374
403
|
declare const headerValue: (raw: string | string[] | undefined) => string | undefined;
|
|
375
404
|
/**
|
|
@@ -402,7 +431,23 @@ declare const ALLOW_FORWARDED_ENV = "LUNORA_STUDIO_ALLOW_FORWARDED";
|
|
|
402
431
|
* the dev server, not just as an opaque 403 in the browser.
|
|
403
432
|
*/
|
|
404
433
|
declare const transportRejectionReason: (request: IncomingMessage, logger?: WarnLogger) => string | undefined;
|
|
405
|
-
export { ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, STUDIO_PATH, STUDIO_SCRIPT_PATH, STUDIO_STYLE_PATH, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type StudioMiddlewareOptions, type WarnLogger, type WirePolicyEdit, applyStudioAssetCache, assetContentType,
|
|
434
|
+
export { ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, STUDIO_PATH, STUDIO_SCRIPT_PATH, STUDIO_STYLE_PATH, STUDIO_WRITE_TEMP_SUFFIX, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type StudioMiddlewareOptions, type WarnLogger, type WirePolicyEdit, applyStudioAssetCache, assetContentType, consumeStudioWrite, createStudioDocumentCache, createStudioMiddleware,
|
|
435
|
+
/**
|
|
436
|
+
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
437
|
+
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
438
|
+
*
|
|
439
|
+
* Three dev hosts serve the studio from this code, so it behaves identically
|
|
440
|
+
* regardless of how the project is run:
|
|
441
|
+
* - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
|
|
442
|
+
* dev server at `/__lunora` — same routing, same URL.
|
|
443
|
+
* - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
|
|
444
|
+
* with its own routing (a root mount, and a read-only shell off loopback).
|
|
445
|
+
*
|
|
446
|
+
* The genuinely shared parts live here: render the host HTML with per-server
|
|
447
|
+
* config injected, resolve the admin token the same way the worker does, gate
|
|
448
|
+
* the transport, and load the prebuilt asset bytes.
|
|
449
|
+
*/
|
|
450
|
+
devVariablesStamp, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, headerValue, isLoopbackAddress, isNonLoopbackHost, isStandaloneModulePath, loadStudioAssets,
|
|
406
451
|
/**
|
|
407
452
|
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
408
453
|
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
@@ -24,6 +24,12 @@ declare const parseDevVariable: (contents: string, key: string) => string | unde
|
|
|
24
24
|
* Returns `undefined` when `.dev.vars` carries no token (the studio then prompts).
|
|
25
25
|
*/
|
|
26
26
|
declare const resolveAdminToken: (root: string) => string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* A cheap change stamp for the project's `.dev.vars` (`"0"` when absent), so a
|
|
29
|
+
* host that caches the Studio document can re-render it when the admin token is
|
|
30
|
+
* edited mid-session instead of embedding the one read at startup.
|
|
31
|
+
*/
|
|
32
|
+
declare const devVariablesStamp: (root: string) => string;
|
|
27
33
|
/**
|
|
28
34
|
* Set the asset cache headers, answering `304` when the request already holds
|
|
29
35
|
* this version. Returns true when the response is finished, false when the
|
|
@@ -150,6 +156,18 @@ declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
|
150
156
|
* place.
|
|
151
157
|
*/
|
|
152
158
|
declare const assetContentType: (fileName: string) => string;
|
|
159
|
+
/**
|
|
160
|
+
* Cache a studio host's rendered document, re-rendering it whenever `.dev.vars`
|
|
161
|
+
* under `root` changes. The document embeds the admin token, which is edited
|
|
162
|
+
* mid-session (rotation, the first `lunora dev` run writing it), so a document
|
|
163
|
+
* cached past such an edit would hand the studio a token the worker rejects.
|
|
164
|
+
*
|
|
165
|
+
* Every call costs one `stat` ({@link devVariablesStamp}); `render` runs on the
|
|
166
|
+
* first call and again only after the stamp moves. The stamp is taken before
|
|
167
|
+
* `render` reads the file, so a write landing between the two is seen as a
|
|
168
|
+
* change on the next call rather than cached under the newer stamp.
|
|
169
|
+
*/
|
|
170
|
+
declare const createStudioDocumentCache: <T>(root: string, render: () => T) => (() => T);
|
|
153
171
|
/**
|
|
154
172
|
* The host's project configuration, forwarded verbatim to the handler. Separate
|
|
155
173
|
* from `projectRoot` (which every host has) because these two come from the
|
|
@@ -370,6 +388,17 @@ interface SeedResponse {
|
|
|
370
388
|
* rather than hand back children whose parents it just dropped.
|
|
371
389
|
*/
|
|
372
390
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
391
|
+
/**
|
|
392
|
+
* Suffix of the temporary file a studio handler writes and renames over its
|
|
393
|
+
* target. A watcher that sees every file has to ignore it: its events are part
|
|
394
|
+
* of the handler's write, not a change of their own.
|
|
395
|
+
*/
|
|
396
|
+
declare const STUDIO_WRITE_TEMP_SUFFIX = ".lunora-tmp";
|
|
397
|
+
/**
|
|
398
|
+
* Whether a watcher event for `path` is the echo of a studio write. Returns true,
|
|
399
|
+
* and spends the record, only when the file still holds the text that was written.
|
|
400
|
+
*/
|
|
401
|
+
declare const consumeStudioWrite: (path: string, now?: number) => boolean;
|
|
373
402
|
/** A single header value, lower-cased and trimmed; `undefined` when absent or array-valued. */
|
|
374
403
|
declare const headerValue: (raw: string | string[] | undefined) => string | undefined;
|
|
375
404
|
/**
|
|
@@ -402,7 +431,23 @@ declare const ALLOW_FORWARDED_ENV = "LUNORA_STUDIO_ALLOW_FORWARDED";
|
|
|
402
431
|
* the dev server, not just as an opaque 403 in the browser.
|
|
403
432
|
*/
|
|
404
433
|
declare const transportRejectionReason: (request: IncomingMessage, logger?: WarnLogger) => string | undefined;
|
|
405
|
-
export { ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, STUDIO_PATH, STUDIO_SCRIPT_PATH, STUDIO_STYLE_PATH, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type StudioMiddlewareOptions, type WarnLogger, type WirePolicyEdit, applyStudioAssetCache, assetContentType,
|
|
434
|
+
export { ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, STUDIO_PATH, STUDIO_SCRIPT_PATH, STUDIO_STYLE_PATH, STUDIO_WRITE_TEMP_SUFFIX, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type StudioMiddlewareOptions, type WarnLogger, type WirePolicyEdit, applyStudioAssetCache, assetContentType, consumeStudioWrite, createStudioDocumentCache, createStudioMiddleware,
|
|
435
|
+
/**
|
|
436
|
+
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
437
|
+
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
438
|
+
*
|
|
439
|
+
* Three dev hosts serve the studio from this code, so it behaves identically
|
|
440
|
+
* regardless of how the project is run:
|
|
441
|
+
* - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
|
|
442
|
+
* dev server at `/__lunora` — same routing, same URL.
|
|
443
|
+
* - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
|
|
444
|
+
* with its own routing (a root mount, and a read-only shell off loopback).
|
|
445
|
+
*
|
|
446
|
+
* The genuinely shared parts live here: render the host HTML with per-server
|
|
447
|
+
* config injected, resolve the admin token the same way the worker does, gate
|
|
448
|
+
* the transport, and load the prebuilt asset bytes.
|
|
449
|
+
*/
|
|
450
|
+
devVariablesStamp, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, headerValue, isLoopbackAddress, isNonLoopbackHost, isStandaloneModulePath, loadStudioAssets,
|
|
406
451
|
/**
|
|
407
452
|
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
408
453
|
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-Cetr3qFz.mjs";import{applyStudioAssetCache as d,sendStudioDocument as n}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as i,isStandaloneModulePath as l,loadStudioAssets as m,readStandaloneAsset as p,resolveStandaloneDirectory as u,studioAssetsStamp as T}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{default as D}from"../packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs";import{STUDIO_PATH as c,STUDIO_SCRIPT_PATH as A,STUDIO_STYLE_PATH as E,createStudioMiddleware as P,isNonLoopbackHost as x,requestPathname as I,studioMountPath as O}from"../packem_shared/STUDIO_PATH-rjtY7n7Q.mjs";import{POLICY_SCAFFOLD_ENDPOINT as R,handlePolicyScaffoldRequest as N}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-BISd53nh.mjs";import{default as H}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as v,handleSchemaEditRequest as F}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-B-Xii8Ke.mjs";import{SEED_ENDPOINT as U,handleSeedRequest as b}from"../packem_shared/SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as y}from"../packem_shared/serveJsonHandler-Dv0EdCb9.mjs";import{STUDIO_WRITE_TEMP_SUFFIX as W,consumeStudioWrite as k}from"../packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";import{ALLOW_FORWARDED_ENV as j,headerValue as w,isLoopbackAddress as J,transportRejectionReason as X}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{j as ALLOW_FORWARDED_ENV,R as POLICY_SCAFFOLD_ENDPOINT,v as SCHEMA_EDIT_ENDPOINT,U as SEED_ENDPOINT,c as STUDIO_PATH,A as STUDIO_SCRIPT_PATH,E as STUDIO_STYLE_PATH,W as STUDIO_WRITE_TEMP_SUFFIX,d as applyStudioAssetCache,i as assetContentType,k as consumeStudioWrite,D as createStudioDocumentCache,P as createStudioMiddleware,t as devVariablesStamp,N as handlePolicyScaffoldRequest,F as handleSchemaEditRequest,b as handleSeedRequest,w as headerValue,J as isLoopbackAddress,x as isNonLoopbackHost,l as isStandaloneModulePath,m as loadStudioAssets,r as parseDevVariable,p as readStandaloneAsset,H as renderStudioHtml,I as requestPathname,a as resolveAdminToken,u as resolveStandaloneDirectory,n as sendStudioDocument,y as serveJsonHandler,T as studioAssetsStamp,O as studioMountPath,X as transportRejectionReason};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.404",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
62
|
-
"@lunora/container": "1.0.0-alpha.
|
|
61
|
+
"@lunora/codegen": "1.0.0-alpha.351",
|
|
62
|
+
"@lunora/container": "1.0.0-alpha.91",
|
|
63
63
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
64
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
64
|
+
"@lunora/seed": "1.0.0-alpha.253",
|
|
65
65
|
"@visulima/colorize": "2.1.1",
|
|
66
66
|
"@visulima/find-ai-runner": "1.0.2",
|
|
67
67
|
"@visulima/fs": "6.0.29",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as d,readFileSync as y}from"node:fs";import{join as s,isAbsolute as a,relative as m}from"node:path";import{LunoraError as p}from"@lunora/errors";import{classifyPolicyEdit as k,scaffoldPolicyFile as v,resolveServerModule as l,wireRlsIntoProcedure as b}from"./classifyPolicyEdit-DJi9Fk8G.mjs";import{w as c,r as h}from"./write-atomic-zoDF_EAO.mjs";const D="/__lunora/policy-scaffold",u=e=>e==="unknown-procedure"?404:e==="already-wired"||e==="destructive"?409:422,f=(e,o)=>{let r;try{r=h(e)}catch(t){return{body:{error:t instanceof Error?t.message:String(t),ok:!1},status:500}}return{body:{...o,diagnostics:r,ok:!0},status:200}},g=e=>({body:{edit:e,message:"Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",needsManualEdit:!0,ok:!1},status:409}),w=(e,o)=>{const r=v(o,l(e.projectRoot));if(!r.ok)return{body:{error:r.reason,ok:!1},status:u(r.reason)};const t=e.schemaDirectory??"lunora",n=s(e.projectRoot,t,r.fileName);return d(n)?{body:{error:"file-exists",fileName:r.fileName,ok:!1},status:409}:(c(n,r.source),f(e,{fileName:r.fileName}))},R=(e,o,r)=>{if(typeof r!="string"||r.length===0||a(r)||r.includes("\\"))return;const t=s(e,o),n=s(t,`${r}.ts`),i=m(t,n);if(!(i.startsWith("..")||a(i)))return n},N=(e,o)=>{const r=R(e.projectRoot,e.schemaDirectory??"lunora",o.filePath);if(r===void 0||!d(r))return{body:{error:"unknown-procedure",ok:!1},status:404};const t=b(y(r,"utf8"),o,l(e.projectRoot));return t.ok?(c(r,t.text),f(e,{exportName:o.exportName})):{body:{error:t.reason,ok:!1},status:u(t.reason)}},E=e=>{if(e.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:o}=e;if(o==null||typeof o!="object"||typeof o.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};const r=o;if(k(r)==="destructive")return g(r);if(r.kind==="scaffoldPolicy")return w(e,r);if(r.kind==="wireRls")return N(e,r);throw new p("INTERNAL",`unhandled additive policy edit kind: ${String(r.kind)}`)};export{D as POLICY_SCAFFOLD_ENDPOINT,E as handlePolicyScaffoldRequest};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as a,readFileSync as d}from"node:fs";import{classifyEdit as l,applyAdditiveEdit as c}from"./applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as u}from"./parseSchema-D1Wbr1qv.mjs";import{w as f,r as p}from"./write-atomic-zoDF_EAO.mjs";import{join as m}from"node:path";const F="/__lunora/schema-edit",b=t=>t==="destructive"||t==="duplicate-table"||t==="duplicate-column"||t==="duplicate-index"?409:t==="unknown-table"?404:t==="invalid-identifier"||t==="invalid-validator"?400:422,y=t=>({body:{error:t.reason,ok:!1},status:422}),h=t=>{if(!a(t))return{response:{body:{error:"no-schema-file",ok:!1},status:404}};const r=u(d(t,"utf8"));return r.ok?{tables:r.tables}:{response:y(r)}},k=t=>({body:{edit:t,message:"This edit changes stored data and must go through a migration. Review the migration before applying.",needsMigration:!0,ok:!1},status:409}),g=(t,r)=>{const e=t.body;if(e==null||typeof e!="object"||typeof e.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};if(l(e)==="destructive")return k(e);if(!a(r))return{body:{error:"no-schema-file",ok:!1},status:404};const o=c(d(r,"utf8"),e);if(!o.ok)return{body:{error:o.reason,ok:!1},status:b(o.reason)};f(r,o.text);let i;try{i=p(t)}catch(s){return{body:{error:s instanceof Error?s.message:String(s),ok:!1},status:500}}const n=u(o.text);return{body:{diagnostics:i,ok:!0,tables:n.ok?n.tables:[]},status:200}},R=t=>{const r=m(t.projectRoot,t.schemaDirectory??"lunora","schema.ts");if(t.method==="GET"){const e=h(r);return"response"in e?e.response:{body:{ok:!0,tables:e.tables},status:200}}return t.method==="POST"?g(t,r):{body:{error:"method-not-allowed",ok:!1},status:405}};export{F as SCHEMA_EDIT_ENDPOINT,R as handleSchemaEditRequest};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{resolveAdminToken as A}from"./parseDevVariable-teAAahVD.mjs";import{sendStudioDocument as I,applyStudioAssetCache as O}from"./applyStudioAssetCache-DHQEJuuv.mjs";import{isStandaloneModulePath as _,studioAssetsStamp as H,loadStudioAssets as N,readStandaloneAsset as C,assetContentType as D}from"./assetContentType-CUb5bpbI.mjs";import{detectAgentRules as E}from"./AGENT_RULES_DIR-Bd6JPtNa.mjs";import{handlePolicyScaffoldRequest as v,POLICY_SCAFFOLD_ENDPOINT as L}from"./POLICY_SCAFFOLD_ENDPOINT-CXf64-YJ.mjs";import R from"./renderStudioHtml-ByowDtMl.mjs";import{handleSchemaEditRequest as b,SCHEMA_EDIT_ENDPOINT as x}from"./SCHEMA_EDIT_ENDPOINT-B_R_bpd5.mjs";import{handleSeedRequest as k,SEED_ENDPOINT as $}from"./SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as g}from"./serveJsonHandler-Dv0EdCb9.mjs";import{transportRejectionReason as j}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";const d="/__lunora",F=`${d}/studio.js`,m=`${d}/styles.css`,y=/\/$/,M={[L]:v,[x]:b,[$]:k},U=new Set(["127.0.0.1","::1","localhost"]),X=t=>t!==void 0&&t!==!1&&!U.has(t),P=t=>t===void 0||t==="/"?"":t.replace(y,""),Z=t=>`${P(t)}${d}`,T=(t,a,c)=>{t.statusCode=200,t.setHeader("Content-Type",c),t.end(a)},q=t=>{try{return new URL(t,"http://localhost").pathname}catch{const a=t.indexOf("?");return a===-1?t:t.slice(0,a)}},tt=t=>{const{logger:a,projectRoot:c}=t,u=P(t.base);let l,f,S;const p=(o,n,e)=>{const i=H();if((l===void 0||i!==f)&&(l=N(a),f=i),l===void 0){e.statusCode=501,e.setHeader("Content-Type","text/plain"),e.end("Lunora studio assets not found — install and build @lunora/studio.");return}const s=o===m,r=o.slice(o.lastIndexOf("/")+1);if(O(n,e,r,i))return;if(s){T(e,l.styles,"text/css; charset=utf-8");return}const h=C(r);if(h===void 0){e.statusCode=404,e.setHeader("Content-Type","text/plain"),e.end("Not found");return}T(e,h,D(r))};return(o,n,e)=>{const i=q(o.url??"").replace(y,""),s=u!==""&&i.startsWith(u)?i.slice(u.length):i;if(s!==d&&!s.startsWith(`${d}/`)){e();return}if(t.isNonLoopbackBind||j(o,a)!==void 0){n.statusCode=403,n.setHeader("Content-Type","text/plain"),n.end("Lunora studio is only available on loopback hosts in dev.");return}const r=M[s];if(r!==void 0){g(o,n,r,c,{apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,schemaDirectory:t.schemaDirectory});return}if(s===m||_(s)){p(s,o,n);return}S??=R({adminToken:A(c),basePath:d,dataEditable:!0,rulesInstalled:E(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:F,styleHref:m}),I(n,S)}};export{d as STUDIO_PATH,F as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,tt as createStudioMiddleware,X as isNonLoopbackHost,q as requestPathname,Z as studioMountPath};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{spawnSync as m}from"node:child_process";import{readFileSync as L,readdirSync as A,existsSync as O}from"node:fs";import{homedir as S}from"node:os";import{join as r,dirname as d}from"node:path";const v=[".env",".env.local",".env.development",".env.development.local"],E=["CLOUDFLARE_API_TOKEN","CF_API_TOKEN"],g=["CLOUDFLARE_API_KEY","CF_API_KEY"],u=["CLOUDFLARE_EMAIL","CF_EMAIL"],w=new Set([...E,...g,...u]),p=/^export\s+/u,D=/\r?\n/u,I=/"loggedIn"\s*:\s*false/u,T=/"loggedIn"\s*:\s*true/u,C=1e4,f=new Map,h=/^(["'])(.*)\1$/u,a=t=>t!==void 0&&t.trim()!=="",F=(t,e)=>[e,t.XDG_CONFIG_HOME,r(e,"Library","Preferences"),r(e,".config"),t.APPDATA===void 0?void 0:r(t.APPDATA,"xdg.config"),r(e,"AppData","Roaming","xdg.config")].filter(o=>a(o)),K=t=>{try{return A(t).length>0}catch{return!1}},P=t=>{for(let e=t;;e=d(e)){const o=r(e,"node_modules","wrangler","bin","wrangler.js");if(O(o))return o;if(d(e)===e)return}},R=(t,e)=>{const o=f.get(t);if(o!==void 0&&(!o.loggedOut||Date.now()-o.at<C))return o.loggedOut;const s=P(t);if(s===void 0)return!1;const{stdout:i}=m(process.execPath,[s,"whoami","--json"],{cwd:t,encoding:"utf8",env:{...e,WRANGLER_SEND_METRICS:"false"},stdio:["ignore","pipe","ignore"],timeout:1e4}),n=I.test(i);return(n||T.test(i))&&f.set(t,{at:Date.now(),loggedOut:n}),n},y=t=>{const e=new Set;for(const o of v){let s;try{s=L(r(t,o),"utf8")}catch{continue}for(const i of s.split(D)){const n=i.trim().replace(p,""),c=n.indexOf("=");if(n.startsWith("#")||c===-1)continue;const l=n.slice(0,c).trim(),_=n.slice(c+1).trim().replace(h,"$2");w.has(l)&&a(_)&&e.add(l)}}return e},U=(t={})=>{const e=t.env??process.env,o=t.projectRoot===void 0?new Set:y(t.projectRoot),s=n=>a(e[n])||o.has(n);return E.some(n=>s(n))||g.some(n=>s(n))&&u.some(n=>s(n))?!0:F(e,t.home??S()).some(n=>K(r(n,".wrangler","config")))&&(t.projectRoot===void 0||!R(t.projectRoot,e))};export{U as hasCloudflareCredentials};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as C,tsconfigFingerprint as h,projectConfigCandidatePaths as l}from"@lunora/codegen";import{wranglerCodegenInputs as S}from"./wranglerCodegenInputs-UqO5e_qJ.mjs";import{isCodegenDisabled as w,CODEGEN_ENV as n}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";const P=o=>({apiSpec:o.apiSpec,lazyFunctions:o.lazyFunctions,lunoraDirectory:o.schemaDirectory??"lunora",projectRoot:o.projectRoot,...S(o.projectRoot)});let r;const c=o=>{const t=a(o);return`${o}:${String(t.mtimeMs)}:${String(t.size)}`},$=o=>{const t=C(o);return[t===void 0?"":`${c(t)}
|
|
2
|
-
${h(t)}`,...l(o).filter(e=>s(e)).map(e=>c(e))].join(`
|
|
3
|
-
`)},F=o=>{const t=$(o);return r?.lunoraDirectory===o&&r.key===t?(u(r.project,o),r.project):(r={key:t,lunoraDirectory:o,project:y(o)},r.project)},N=o=>{if(w(process.env[n]))return[`codegen is off (${n}=0 / \`lunora dev --no-codegen\`) — the source was written but \`_generated/\` was NOT regenerated`];try{const t=m(o.projectRoot,o.schemaDirectory??"lunora");f({...P(o),project:F(t)})}catch(t){if(r=void 0,t instanceof j)return[t.message];throw t}return[]},O=(o,t)=>{const e=`${o}.lunora-tmp`;try{p(e,t,"utf8"),d(e,o)}catch(i){throw g(e,{force:!0}),i}};export{N as r,O as w};
|