@lunora/server 1.0.0-alpha.272 → 1.0.0-alpha.273
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/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/LunoraEnvError-06_Zc4yc.mjs +3 -0
- package/dist/packem_shared/redact-secrets-BpatNz48.mjs +2 -0
- package/dist/packem_shared/redactSecrets-Dmh9pHZu.mjs +1 -0
- package/package.json +1 -1
- package/dist/packem_shared/LunoraEnvError-bkdMu_-N.mjs +0 -4
package/dist/index.d.mts
CHANGED
|
@@ -1568,6 +1568,13 @@ declare const documentHistoryExtension: SchemaExtension<{
|
|
|
1568
1568
|
* @returns a component bundling the extension, the functions, and the recorder.
|
|
1569
1569
|
*/
|
|
1570
1570
|
declare const defineDocumentHistory: (options?: DefineDocumentHistoryOptions) => DocumentHistoryComponent;
|
|
1571
|
+
/** One key the contract rejected; `message` is already secret-redacted. */
|
|
1572
|
+
interface EnvKeyFailure {
|
|
1573
|
+
/** The env key that failed. */
|
|
1574
|
+
key: string;
|
|
1575
|
+
/** Redacted human-readable reason. */
|
|
1576
|
+
message: string;
|
|
1577
|
+
}
|
|
1571
1578
|
/**
|
|
1572
1579
|
* Redact secrets from a free-form message. Masks, in order: any quoted value
|
|
1573
1580
|
* whose contents look like a credential (so a value surfaced as `received string
|
|
@@ -1587,13 +1594,6 @@ declare const defineDocumentHistory: (options?: DefineDocumentHistoryOptions) =>
|
|
|
1587
1594
|
* derived from `env`, request bodies, or thrown errors.
|
|
1588
1595
|
*/
|
|
1589
1596
|
declare const redactSecrets: (message: string) => string;
|
|
1590
|
-
/** One key's validation failure, secrets already redacted out of `message`. */
|
|
1591
|
-
interface EnvKeyFailure {
|
|
1592
|
-
/** The env key that failed. */
|
|
1593
|
-
key: string;
|
|
1594
|
-
/** Redacted human-readable reason. */
|
|
1595
|
-
message: string;
|
|
1596
|
-
}
|
|
1597
1597
|
/**
|
|
1598
1598
|
* Thrown when one or more env keys are missing or fail validation. Carries the
|
|
1599
1599
|
* structured list of `failures` (each with the offending `key`) so callers can
|
package/dist/index.d.ts
CHANGED
|
@@ -1568,6 +1568,13 @@ declare const documentHistoryExtension: SchemaExtension<{
|
|
|
1568
1568
|
* @returns a component bundling the extension, the functions, and the recorder.
|
|
1569
1569
|
*/
|
|
1570
1570
|
declare const defineDocumentHistory: (options?: DefineDocumentHistoryOptions) => DocumentHistoryComponent;
|
|
1571
|
+
/** One key the contract rejected; `message` is already secret-redacted. */
|
|
1572
|
+
interface EnvKeyFailure {
|
|
1573
|
+
/** The env key that failed. */
|
|
1574
|
+
key: string;
|
|
1575
|
+
/** Redacted human-readable reason. */
|
|
1576
|
+
message: string;
|
|
1577
|
+
}
|
|
1571
1578
|
/**
|
|
1572
1579
|
* Redact secrets from a free-form message. Masks, in order: any quoted value
|
|
1573
1580
|
* whose contents look like a credential (so a value surfaced as `received string
|
|
@@ -1587,13 +1594,6 @@ declare const defineDocumentHistory: (options?: DefineDocumentHistoryOptions) =>
|
|
|
1587
1594
|
* derived from `env`, request bodies, or thrown errors.
|
|
1588
1595
|
*/
|
|
1589
1596
|
declare const redactSecrets: (message: string) => string;
|
|
1590
|
-
/** One key's validation failure, secrets already redacted out of `message`. */
|
|
1591
|
-
interface EnvKeyFailure {
|
|
1592
|
-
/** The env key that failed. */
|
|
1593
|
-
key: string;
|
|
1594
|
-
/** Redacted human-readable reason. */
|
|
1595
|
-
message: string;
|
|
1596
|
-
}
|
|
1597
1597
|
/**
|
|
1598
1598
|
* Thrown when one or more env keys are missing or fail validation. Carries the
|
|
1599
1599
|
* structured list of `failures` (each with the offending `key`) so callers can
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as i,actionCacheExtension as n,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-DMYtb827.mjs";import{initLunora as s}from"./packem_shared/initLunora-DcvCGLL_.mjs";import{isPerDispatchMiddleware as p,tagPerDispatchMiddleware as x}from"./packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs";import{createSecrets as l}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{beginDeferredDeletes as u,flushDeferredDeletes as S,withDeferredDeletes as D}from"./packem_shared/beginDeferredDeletes-DhwFBbvs.mjs";import{beginDeferredSchedules as T,withDeferredSchedules as R}from"./packem_shared/beginDeferredSchedules--FVDtp-M.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as g,DOCUMENT_HISTORY_TABLE as L,defineDocumentHistory as _,documentHistoryExtension as I}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-MUPXbAHR.mjs";import{LunoraEnvError as M,defineEnv as P
|
|
1
|
+
import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as i,actionCacheExtension as n,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-DMYtb827.mjs";import{initLunora as s}from"./packem_shared/initLunora-DcvCGLL_.mjs";import{isPerDispatchMiddleware as p,tagPerDispatchMiddleware as x}from"./packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs";import{createSecrets as l}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{beginDeferredDeletes as u,flushDeferredDeletes as S,withDeferredDeletes as D}from"./packem_shared/beginDeferredDeletes-DhwFBbvs.mjs";import{beginDeferredSchedules as T,withDeferredSchedules as R}from"./packem_shared/beginDeferredSchedules--FVDtp-M.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as g,DOCUMENT_HISTORY_TABLE as L,defineDocumentHistory as _,documentHistoryExtension as I}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-MUPXbAHR.mjs";import{LunoraEnvError as M,defineEnv as P}from"./packem_shared/LunoraEnvError-06_Zc4yc.mjs";import{bindOrm as y,bindTableFacade as O,defineLazyFacade as F}from"./packem_shared/bindOrm-D5mVDvbi.mjs";import{httpAction as N,httpRoute as U,httpRouter as H,lastEventId as k,sseEvent as w}from"./packem_shared/httpAction-Bfw3qwLG.mjs";import{serveStorageObject as V}from"./packem_shared/serveStorageObject-CLz3qhNI.mjs";import{defineIdentity as j}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{default as z}from"./packem_shared/defineIdentityGuard-Bt8N65Zs.mjs";import{onConnect as J,onDisconnect as K,onShardInit as Q}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as q,DEFAULT_MAX_LIMIT as Z,clampLimit as $,defineListArgs as ee}from"./packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs";import{defineLiveStream as oe,liveStreamRouter as te}from"./packem_shared/defineLiveStream-q9yO3wl6.mjs";import{defineMigration as ne}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as ae}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as se}from"./packem_shared/defineMutator-DlLFSWbO.mjs";import{platformAdmin as pe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as ce,d as le,a as Ee,b as ue,e as Se,f as De,g as he,h as Te,i as Re,j as Ae,k as ge,m as Le}from"./packem_shared/plugin-D0ogWCbA.mjs";import{PRESENCE_DEFAULT_TTL_MS as Ie,PRESENCE_TABLE as Ce,definePresence as Me,presenceExtension as Pe}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-CKPKoWy_.mjs";import{PROCEDURE_META as ye,UNLOADED_META as Oe,procedureMeta as Fe}from"./packem_shared/PROCEDURE_META-DVzrXpfa.mjs";import{protectPublic as Ne}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as He}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as we}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as Ve}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as je}from"./packem_shared/defineShape-CAIsX21I.mjs";import{defineWebSocket as ze}from"./packem_shared/defineWebSocket-BHoy6_ox.mjs";import{onWhisper as Je}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Qe}from"@lunora/errors";import{cronJobs as qe}from"@lunora/scheduler";import{ValidationError as $e,v as er}from"@lunora/values";import{allowAll as or,deny as tr,isDeny as ir,toWhereInput as nr}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as ar}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as sr,buildRlsReadRegistry as mr,composeShapeReadWhere as pr}from"./packem_shared/assertShapesDeclareReadPolicies-CWrMYcqw.mjs";import{buildMaskRegistry as cr}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as Er,definePermission as ur,definePolicies as Sr,definePolicy as Dr,defineRole as hr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as Rr,defineStorageRules as Ar}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{isSafeHeaderValue as Lr}from"./packem_shared/isSafeHeaderValue-DswDADFy.mjs";import{mask as Ir}from"./packem_shared/mask--ZXtzCj7.mjs";import{r as Mr}from"./packem_shared/redact-secrets-BpatNz48.mjs";import{r as br}from"./packem_shared/middleware-CdoC33P7.mjs";import{storageRules as Or}from"./packem_shared/storageRules-BZgB67oS.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,i as ACTION_CACHE_TABLE,q as DEFAULT_LIMIT,Z as DEFAULT_MAX_LIMIT,g as DOCUMENT_HISTORY_REDACTED_FIELDS,L as DOCUMENT_HISTORY_TABLE,M as LunoraEnvError,Qe as LunoraError,Ie as PRESENCE_DEFAULT_TTL_MS,Ce as PRESENCE_TABLE,ye as PROCEDURE_META,Oe as UNLOADED_META,e as VERSION,$e as ValidationError,n as actionCacheExtension,or as allowAll,ar as asBucketStorage,sr as assertShapesDeclareReadPolicies,u as beginDeferredDeletes,T as beginDeferredSchedules,y as bindOrm,O as bindTableFacade,cr as buildMaskRegistry,mr as buildRlsReadRegistry,f as cacheKeyFor,$ as clampLimit,ce as composePluginMiddleware,pr as composeShapeReadWhere,Er as createPolicyDsl,l as createSecrets,Ve as createServices,qe as cronJobs,a as defineActionCache,le as defineAggregateIndex,Ee as defineComponent,_ as defineDocumentHistory,P as defineEnv,j as defineIdentity,z as defineIdentityGuard,F as defineLazyFacade,ee as defineListArgs,oe as defineLiveStream,ne as defineMigration,ae as defineModule,se as defineMutator,ur as definePermission,ue as definePlugin,Sr as definePolicies,Dr as definePolicy,Me as definePresence,Se as defineRankIndex,hr as defineRole,we as defineRoom,De as defineSchema,he as defineSchemaExtension,je as defineShape,Rr as defineStorageRule,Ar as defineStorageRules,Te as defineTable,Re as defineVectorIndex,ze as defineWebSocket,tr as deny,I as documentHistoryExtension,S as flushDeferredDeletes,N as httpAction,U as httpRoute,H as httpRouter,Ae as indexFieldsFromSchema,s as initLunora,ge as installPlugins,ir as isDeny,p as isPerDispatchMiddleware,Lr as isSafeHeaderValue,k as lastEventId,te as liveStreamRouter,Ir as mask,Le as mergeSchemaExtension,J as onConnect,K as onDisconnect,He as onQueryChange,Q as onShardInit,Je as onWhisper,pe as platformAdmin,Pe as presenceExtension,Fe as procedureMeta,Ne as protectPublic,Mr as redactSecrets,br as rls,V as serveStorageObject,w as sseEvent,Or as storageRules,x as tagPerDispatchMiddleware,nr as toWhereInput,er as v,D as withDeferredDeletes,R as withDeferredSchedules};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{LunoraError as y}from"@lunora/errors";import{optionalInner as h}from"@lunora/values";import{r as E,i as L,R as N}from"./redact-secrets-BpatNz48.mjs";const S=Symbol.for("lunora.env"),A=(t,e,n)=>{const o=E(t);return typeof n=="string"&&n!==""&&L(e)?o.replaceAll(n,N):o};class d extends y{failures;constructor(e){const n=e.map(o=>` - ${o.key}: ${o.message}`).join(`
|
|
2
|
+
`);super("ENV_INVALID",`Invalid environment (${String(e.length)} key(s)):
|
|
3
|
+
${n}`,{name:"LunoraEnvError"}),this.failures=e}}const _=new Set(["1","on","true","yes"]),w=new Set(["0","false","no","off"]),I=/^-?\d+$/u,b=t=>{if(t.kind!=="optional")return t.kind;const e=h(t);return e?b(e):t.kind},j=(t,e)=>{if(typeof e!="string")return e;switch(b(t)){case"bigint":return I.test(e.trim())?BigInt(e.trim()):e;case"boolean":{const n=e.trim().toLowerCase();return _.has(n)?!0:w.has(n)?!1:e}case"number":{const n=e.trim();if(n==="")return e;const o=Number(n);return Number.isNaN(o)?e:o}default:return e}},v=(t,e,n,o)=>{const f=n[t];if(f===void 0&&e.kind==="optional")return{ok:!0,value:void 0};const m=e.safeParse(j(e,f));return m.ok?{ok:!0,value:m.value}:(o.push({key:t,message:A(m.error.message,t,f)}),{ok:!1})},k=t=>{if(typeof t!="object"||t===null)throw new d([{key:"<env>",message:`expected an object, received ${t===null?"null":typeof t}`}]);return t},$=t=>{const e=Object.keys(t),n=new WeakMap,o=(i=>{const r=k(i);let u=n.get(r);u===void 0&&(u=new Map,n.set(r,u));const a=u,l=c=>{if(a.has(c))return a.get(c);const s=[],g=v(c,t[c],r,s);if(!g.ok)throw new d(s);return a.set(c,g.value),g.value};return new Proxy({},{get(c,s){if(!(typeof s!="string"||!(s in t)))return l(s)},getOwnPropertyDescriptor(c,s){if(typeof s=="string"&&s in t)return{configurable:!0,enumerable:!0,value:l(s),writable:!1}},has(c,s){return typeof s=="string"&&s in t},ownKeys(){return e}})}),f=i=>{const r=[],u={};for(const a of e){const l=v(a,t[a],i,r);l.ok&&l.value!==void 0&&(u[a]=l.value)}return{failures:r,out:u}};return o.parse=i=>{const{failures:r,out:u}=f(k(i));if(r.length>0)throw new d(r);return u},Object.defineProperty(o,S,{value:i=>{try{return f(k(i)).failures}catch(r){return r instanceof d?r.failures:[{key:"<env>",message:E(r instanceof Error?r.message:String(r))}]}}}),o};export{d as LunoraEnvError,$ as defineEnv,E as redactSecrets};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const l=t=>t.endsWith("S")?t.slice(0,-1):t,_=t=>t.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(e=>e.length>0),a=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),A=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],i=new RegExp(`(?:${[...a,...A.map(t=>t.replaceAll("_",""))].join("|")})S?$`,"iu"),S=t=>_(t).some(e=>e==="PUBLIC"||e==="PUBLISHABLE"),h=t=>{if(S(t))return!1;const e=_(t);if(e.some(n=>a.has(l(n))))return!0;const r=l(e.join("_"));return A.some(n=>r===n||r.endsWith(`_${n}`))||i.test(t)},p=[/^sk_/u,/^pk_/u,/^rk_/u,/^ghp_/u,/^gho_/u,/^ghs_/u,/^ghr_/u,/^github_pat_/u,/^xox[baprs]-/u,/^AKIA/u,/^AIza/u,/^Bearer\s/u],R=/[\w./+-]{24,}/gu,I=/^[\w./+-]+$/u,T=/\b(?:(?:sk|pk|rk|ghp|gho|ghs|ghr)_[\w./+-]*|github_pat_[\w./+-]*|xox[baprs]-[\w./+-]*)/gu,N=/\b(?:AKIA|AIza)[\w./+-]+|Bearer\s+[\w./+-]+/gu,D=/:\/\/([\w.%+-]*):[\w.%+\-!$&'()*,;=~]+@/gu,E="[redacted]",K=t=>{if(p.some(r=>r.test(t)))return!0;const e=t.trim();return e.length>=24&&I.test(e)},u=new Set([`
|
|
2
|
+
`,"\r","\u2028","\u2029"]),g=(t,e)=>{const r=t.charAt(e);let n=-1,c=e+1;for(;c<t.length;){const s=t.charAt(c);if(s===r)return c;if(u.has(s))break;const o=t.charAt(c+1);s==="\\"&&c+1<t.length&&!u.has(o)?(o===r&&(n=c+1),c+=2):c+=1}return n},d=(t,e)=>{let r="",n=0;for(;n<t.length;){const c=t.charAt(n),s=c==='"'||c==="'"?g(t,n):-1;s===-1?(r+=c,n+=1):(r+=e(t.slice(n,s+1),t.slice(n+1,s)),n=s+1)}return r},O=/\b(?<key>[A-Za-z_]\w*)\s*[=:]\s*(?:"(?:[^"\\\n]|\\[^\n])*"|'(?:[^'\\\n]|\\[^\n])*'|\S+)/gu,P=t=>{let e=t;return e=d(e,(r,n)=>K(n)?E:r),e=e.replaceAll(D,(r,n)=>`://${n}:${E}@`),e=e.replaceAll(T,E),e=e.replaceAll(N,E),e=e.replaceAll(O,(r,...n)=>{const c=n.at(-1);return c?.key!==void 0&&h(c.key)?`${c.key}=${E}`:r}),e=e.replaceAll(R,E),e};export{E as R,h as i,P as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as a,r as s}from"./redact-secrets-BpatNz48.mjs";export{a as REDACTED,s as redactSecrets};
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{LunoraError as R}from"@lunora/errors";import{optionalInner as T}from"@lunora/values";const A=e=>e.endsWith("S")?e.slice(0,-1):e,d=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(t=>t.length>0),m=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),I=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],p=new RegExp(`(?:${[...m,...I.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),L=e=>d(e).some(t=>t==="PUBLIC"||t==="PUBLISHABLE"),k=e=>{if(L(e))return!1;const t=d(e);if(t.some(n=>m.has(A(n))))return!0;const r=A(t.join("_"));return I.some(n=>r===n||r.endsWith(`_${n}`))||p.test(e)},b=[/^sk_/u,/^pk_/u,/^rk_/u,/^ghp_/u,/^gho_/u,/^ghs_/u,/^ghr_/u,/^github_pat_/u,/^xox[baprs]-/u,/^AKIA/u,/^AIza/u,/^Bearer\s/u],K=/[\w./+-]{24,}/gu,w=/^[\w./+-]+$/u,D=/\b(?:(?:sk|pk|rk|ghp|gho|ghs|ghr)_[\w./+-]*|github_pat_[\w./+-]*|xox[baprs]-[\w./+-]*)/gu,O=/\b(?:AKIA|AIza)[\w./+-]+|Bearer\s+[\w./+-]+/gu,P=/:\/\/([\w.%+-]*):[\w.%+-]+@/gu,l="[redacted]",$=e=>{if(b.some(r=>r.test(e)))return!0;const t=e.trim();return t.length>=24&&w.test(t)},g=new Set([`
|
|
2
|
-
`,"\r","\u2028","\u2029"]),v=(e,t)=>{const r=e.charAt(t);let n=-1,o=t+1;for(;o<e.length;){const s=e.charAt(o);if(s===r)return o;if(g.has(s))break;const i=e.charAt(o+1);s==="\\"&&o+1<e.length&&!g.has(i)?(i===r&&(n=o+1),o+=2):o+=1}return n},y=(e,t)=>{let r="",n=0;for(;n<e.length;){const o=e.charAt(n),s=o==='"'||o==="'"?v(e,n):-1;s===-1?(r+=o,n+=1):(r+=t(e.slice(n,s+1),e.slice(n+1,s)),n=s+1)}return r},C=/\b(?<key>[A-Za-z_]\w*)\s*[=:]\s*\S+/gu,x=e=>{let t=e;return t=y(t,(r,n)=>$(n)?l:r),t=t.replaceAll(P,(r,n)=>`://${n}:${l}@`),t=t.replaceAll(D,l),t=t.replaceAll(O,l),t=t.replaceAll(C,(r,...n)=>{const o=n.at(-1);return o?.key!==void 0&&k(o.key)?`${o.key}=${l}`:r}),t=t.replaceAll(K,l),t},U=(e,t,r)=>{const n=x(e);return typeof r=="string"&&r!==""&&k(t)?n.replaceAll(r,l):n};class f extends R{failures;constructor(t){const r=t.map(n=>` - ${n.key}: ${n.message}`).join(`
|
|
3
|
-
`);super("ENV_INVALID",`Invalid environment (${String(t.length)} key(s)):
|
|
4
|
-
${r}`,{name:"LunoraEnvError"}),this.failures=t}}const V=new Set(["1","on","true","yes"]),Y=new Set(["0","false","no","off"]),B=/^-?\d+$/u,N=e=>{if(e.kind!=="optional")return e.kind;const t=T(e);return t?N(t):e.kind},j=(e,t)=>{if(typeof t!="string")return t;switch(N(e)){case"bigint":return B.test(t.trim())?BigInt(t.trim()):t;case"boolean":{const r=t.trim().toLowerCase();return V.has(r)?!0:Y.has(r)?!1:t}case"number":{const r=t.trim();if(r==="")return t;const n=Number(r);return Number.isNaN(n)?t:n}default:return t}},h=(e,t,r,n)=>{const o=r[e];if(o===void 0&&t.kind==="optional")return{ok:!0,value:void 0};const s=t.safeParse(j(t,o));return s.ok?{ok:!0,value:s.value}:(n.push({key:e,message:U(s.error.message,e,o)}),{ok:!1})},S=e=>{if(typeof e!="object"||e===null)throw new f([{key:"<env>",message:`expected an object, received ${e===null?"null":typeof e}`}]);return e},z=e=>{const t=Object.keys(e),r=new WeakMap,n=(o=>{const s=S(o);let i=r.get(s);i===void 0&&(i=new Map,r.set(s,i));const a=i,E=u=>{if(a.has(u))return a.get(u);const c=[],_=h(u,e[u],s,c);if(!_.ok)throw new f(c);return a.set(u,_.value),_.value};return new Proxy({},{get(u,c){if(!(typeof c!="string"||!(c in e)))return E(c)},getOwnPropertyDescriptor(u,c){if(typeof c=="string"&&c in e)return{configurable:!0,enumerable:!0,value:E(c),writable:!1}},has(u,c){return typeof c=="string"&&c in e},ownKeys(){return t}})});return n.parse=o=>{const s=S(o),i=[],a={};for(const E of t){const u=h(E,e[E],s,i);u.ok&&u.value!==void 0&&(a[E]=u.value)}if(i.length>0)throw new f(i);return a},n};export{f as LunoraEnvError,z as defineEnv,x as redactSecrets};
|