node-env-resolver 6.5.0 → 6.5.2
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/README.md +708 -400
- package/dist/builder.cjs +1 -1
- package/dist/builder.d.cts +1 -1
- package/dist/builder.d.ts +1 -1
- package/dist/builder.js +1 -1
- package/dist/chunk-3EWCMDFP.js +9 -0
- package/dist/chunk-BFLXBLZ3.cjs +1 -0
- package/dist/chunk-CDXO2XX3.cjs +2 -0
- package/dist/chunk-CTJYBBOB.js +2 -0
- package/dist/chunk-DIJNUFGZ.cjs +15 -0
- package/dist/chunk-DYFRO3NM.cjs +9 -0
- package/dist/chunk-K4NIC5T3.js +9 -0
- package/dist/chunk-WVMDTD6J.cjs +9 -0
- package/dist/chunk-ZMRT37K3.js +1 -0
- package/dist/chunk-ZSM2NDX5.js +15 -0
- package/dist/cli/bin.cjs +74 -0
- package/dist/cli/bin.js +74 -0
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +1 -1
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.cts +1 -1
- package/dist/resolver.d.ts +1 -1
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +2 -27
- package/dist/resolvers.d.ts +2 -27
- package/dist/resolvers.js +1 -1
- package/dist/runtime/index.cjs +1 -0
- package/dist/runtime/index.d.cts +161 -0
- package/dist/runtime/index.d.ts +161 -0
- package/dist/runtime/index.js +1 -0
- package/dist/types--RcOnfdl.d.cts +284 -0
- package/dist/types--RcOnfdl.d.ts +284 -0
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +1 -129
- package/dist/types.d.ts +1 -129
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +56 -12
- package/dist/utils.d.ts +56 -12
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.cts +12 -25
- package/dist/valibot.d.ts +12 -25
- package/dist/valibot.js +1 -1
- package/dist/validators.cjs +2 -2
- package/dist/validators.d.cts +25 -48
- package/dist/validators.d.ts +25 -48
- package/dist/validators.js +2 -2
- package/dist/web.cjs +5 -5
- package/dist/web.d.cts +3 -1
- package/dist/web.d.ts +3 -1
- package/dist/web.js +5 -5
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.cts +12 -25
- package/dist/zod.d.ts +12 -25
- package/dist/zod.js +1 -1
- package/package.json +29 -41
- package/dist/chunk-2IQQVAXA.cjs +0 -9
- package/dist/chunk-46CBATKM.js +0 -1
- package/dist/chunk-C34FGZOG.js +0 -9
- package/dist/chunk-FNF55TN4.cjs +0 -1
- package/dist/chunk-G36OESVW.cjs +0 -1
- package/dist/chunk-I5UKYTX6.js +0 -1
- package/dist/chunk-MFFH2ZXS.js +0 -17
- package/dist/chunk-QCKMQEJP.cjs +0 -17
- package/dist/chunk-S7AB6UX7.cjs +0 -9
- package/dist/chunk-TGIYWWDY.js +0 -9
- package/dist/chunk-VUUPIWFJ.js +0 -9
- package/dist/chunk-ZDRU3RSU.cjs +0 -9
- package/dist/cli-main.cjs +0 -4
- package/dist/cli-main.js +0 -4
- package/dist/redaction.cjs +0 -1
- package/dist/redaction.d.cts +0 -54
- package/dist/redaction.d.ts +0 -54
- package/dist/redaction.js +0 -1
- package/dist/typegen.cjs +0 -1
- package/dist/typegen.d.cts +0 -52
- package/dist/typegen.d.ts +0 -52
- package/dist/typegen.js +0 -1
- /package/dist/{cli-main.d.cts → cli/bin.d.cts} +0 -0
- /package/dist/{cli-main.d.ts → cli/bin.d.ts} +0 -0
package/dist/chunk-S7AB6UX7.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk2IQQVAXA_cjs=require('./chunk-2IQQVAXA.cjs'),chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');function v(){return [chunk4QOKRJ3F_cjs.a()]}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&("resolvers"in e||"schema"in e||"options"in e)}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!("resolvers"in e)&&!("schema"in e)&&!("options"in e)}function w(e,t){let o,l,i;if(h(e)){let s=e;if(s.schema)o=s.schema;else if(s.resolvers&&s.resolvers.length>0){o={};for(let[,n]of s.resolvers)Object.assign(o,n);}else throw new Error('resolve() config object must have either a "schema" property or "resolvers" array');l=s.resolvers?s.resolvers.map(([n])=>n):v(),i=s.options;}else if(S(e))o=e,l=v(),i=t;else throw new Error('resolve() expects either a schema object or a config object with "schema" or "resolvers" property');for(let[s,n]of Object.entries(o))if(n&&typeof n=="object"&&"~standard"in n)throw new Error(`\u274C resolve() cannot be used with async validators.
|
|
2
|
-
Variable '${s}' uses a Standard Schema validator (Zod, Valibot, etc.)
|
|
3
|
-
\u{1F4A1} Use resolveAsync() instead, or use shorthand syntax for sync validation.`);for(let s of l)if(!s.loadSync)throw new Error(`\u274C Resolver '${s.name}' does not support synchronous loading.
|
|
4
|
-
All resolvers passed to resolve() must have a loadSync() method.
|
|
5
|
-
\u{1F4A1} Use resolveAsync() for async resolvers, or use a sync-compatible resolver.`);let a=(process.env.NODE_ENV||"").toLowerCase()==="production",r=i?.policies??{},p={interpolate:true,strict:true,enableAudit:a,policies:r,...i},c=chunk2IQQVAXA_cjs.a(o);return chunk2IQQVAXA_cjs.c(c,l,p)}async function P(e){let t;if(e.schema)t=e.schema;else if(e.resolvers&&e.resolvers.length>0){t={};for(let[,c]of e.resolvers)Object.assign(t,c);}else throw new Error('resolveAsync() config object must have either a "schema" property or "resolvers" array');let o=e.resolvers?e.resolvers.map(([c])=>c):v(),l=(process.env.NODE_ENV||"").toLowerCase()==="production",i=e.options?.policies??{},a={interpolate:true,strict:true,enableAudit:l,policies:i,...e.options},r=chunk2IQQVAXA_cjs.a(t);return await chunk2IQQVAXA_cjs.b(r,o,a)}function g(e,t){let o,l,i;try{if(h(e)){let s=e;if(s.schema)o=s.schema;else if(s.resolvers&&s.resolvers.length>0){o={};for(let[,n]of s.resolvers)Object.assign(o,n);}else return {success:!1,error:'safeResolve() config object must have either a "schema" property or "resolvers" array'};l=s.resolvers?s.resolvers.map(([n])=>n):v(),i=s.options;}else if(S(e))o=e,l=v(),i=t;else return {success:!1,error:'safeResolve() expects either a schema object or a config object with "schema" or "resolvers" property'};for(let[s,n]of Object.entries(o))if(n&&typeof n=="object"&&"~standard"in n)return {success:!1,error:`\u274C safeResolve() cannot be used with async validators.
|
|
6
|
-
Variable '${s}' uses a Standard Schema validator (Zod, Valibot, etc.)
|
|
7
|
-
\u{1F4A1} Use safeResolveAsync() instead, or use shorthand syntax for sync validation.`};for(let s of l)if(!s.loadSync)return {success:!1,error:`\u274C Resolver '${s.name}' does not support synchronous loading.
|
|
8
|
-
All resolvers passed to safeResolve() must have a loadSync() method.
|
|
9
|
-
\u{1F4A1} Use safeResolveAsync() for async resolvers.`};let a=(process.env.NODE_ENV||"").toLowerCase()==="production",r=i?.policies??{},p={interpolate:!0,strict:!0,enableAudit:a,policies:r,...i},c=chunk2IQQVAXA_cjs.a(o);return {success:!0,data:chunk2IQQVAXA_cjs.c(c,l,p)}}catch(a){return {success:false,error:a instanceof Error?a.message:String(a)}}}async function k(e){let t;if(e.schema)t=e.schema;else if(e.resolvers&&e.resolvers.length>0){t={};for(let[,r]of e.resolvers)Object.assign(t,r);}else return {success:false,error:'safeResolveAsync() config object must have either a "schema" property or "resolvers" array'};let o=e.resolvers?e.resolvers.map(([r])=>r):v(),l=(process.env.NODE_ENV||"").toLowerCase()==="production",i=e.options?.policies??{},a={interpolate:true,strict:true,enableAudit:l,policies:i,...e.options};try{let r=chunk2IQQVAXA_cjs.a(t);return {success:!0,data:await chunk2IQQVAXA_cjs.b(r,o,a)}}catch(r){return {success:false,error:r instanceof Error?r.message:String(r)}}}exports.a=w;exports.b=P;exports.c=g;exports.d=k;
|
package/dist/chunk-TGIYWWDY.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {writeFileSync}from'fs';var g=`// Auto-generated by node-env-resolver typegen. DO NOT EDIT.
|
|
2
|
-
// Regenerate with: npx node-env-resolver typegen
|
|
3
|
-
`;function y(t){if(!t?.type)return "string";switch(t.type){case "string":case "url":case "email":case "json":case "custom":return "string";case "number":case "port":return "number";case "boolean":return "boolean";case "string[]":return "string[]";case "number[]":return "number[]";case "oneOf":{let n=t.enumValues;return !n||n.length===0?"string":n.map(r=>JSON.stringify(String(r))).join(" | ")}default:return "string"}}function m(t){if(!t?.type)return "string";switch(t.type){case "boolean":return "'true' | 'false'";case "oneOf":{let n=t.enumValues;return !n||n.length===0?"string":n.map(r=>JSON.stringify(String(r))).join(" | ")}default:return "string"}}function h(t){let n=[];for(let[r,i]of Object.entries(t)){let a="string",p="string",e=false,s,o=false;if(typeof i=="function"){let u=i,c=u.__meta;a=y(c),p=m(c),e=u.optional===true,s=c?.description,o=c?.sensitive===true;}else if(typeof i=="number")a="number";else if(typeof i=="boolean")a="boolean",p="'true' | 'false'";else if(Array.isArray(i)){let u=i;if(u.length>0){let c=u.map(l=>JSON.stringify(String(l))).join(" | ");a=c,p=c;}e=i.__optional===true;}n.push({key:r,tsType:a,stringType:p,isOptional:e,description:s,isSensitive:o});}return n}function d(t){let n=[];return t.description&&n.push(t.description),t.isSensitive&&n.push("@sensitive"),n.length===0?"":n.length===1?` /** ${n[0]} */
|
|
4
|
-
`:` /**
|
|
5
|
-
${n.map(r=>` * ${r}`).join(`
|
|
6
|
-
`)}
|
|
7
|
-
*/
|
|
8
|
-
`}function v(t,n={}){let{augmentProcessEnv:r=true,augmentImportMetaEnv:i=true,banner:a=g}=n,p=h(t),e=[];a&&e.push(a),e.push("export interface EnvSchema {");for(let s of p){let o=d(s);o&&e.push(o.trimEnd());let u=s.isOptional?"?":"";e.push(` ${s.key}${u}: ${s.tsType};`);}if(e.push("}"),e.push(""),r){e.push("declare global {"),e.push(" namespace NodeJS {"),e.push(" interface ProcessEnv {");for(let s of p){let o=s.isOptional?"?":"";e.push(` ${s.key}${o}: ${s.stringType};`);}e.push(" }"),e.push(" }"),e.push("}"),e.push("");}if(i){e.push("interface ImportMetaEnv {");for(let s of p){let o=s.isOptional?"?":"";e.push(` ${s.key}${o}: ${s.stringType};`);}e.push("}"),e.push(""),e.push("interface ImportMeta {"),e.push(" readonly env: ImportMetaEnv;"),e.push("}"),e.push("");}return e.join(`
|
|
9
|
-
`)}function b(t,n,r){let i=v(t,r);writeFileSync(n,i,"utf8");}export{v as a,b};
|
package/dist/chunk-VUUPIWFJ.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {a,b}from'./chunk-6EWR3WHU.js';import {d,c}from'./chunk-46CBATKM.js';import {join,resolve}from'path';import {readFileSync}from'fs';function L(i,u){try{let t=resolve(process.cwd(),i);return {valid:!0,value:readFileSync(t,"utf8").trim()}}catch(t){return {valid:false,error:`Failed to read file${u?` for ${u}`:""}: ${t instanceof Error?t.message:String(t)}`}}}var E=b,h=b,T=a;function H(i){let u={};for(let[t,s]of Object.entries(i))if(typeof s=="function"){let a=s,r=a.__isFileValidator===true,f=a.__meta;u[t]={type:r?"file":"custom",validator:s,...a.default!==void 0&&{default:a.default},...a.optional!==void 0&&{optional:a.optional},...a.secretsDir!==void 0&&{secretsDir:a.secretsDir},...f?.sensitive!==void 0&&{sensitive:f.sensitive},...f?.description!==void 0&&{description:f.description}};}else if(typeof s=="string")u[t]={type:"string",default:s,validator:a=>{let r=u[t];if(a===""&&!r.allowEmpty)throw new Error("String cannot be empty");return a}};else if(typeof s=="number")u[t]={type:"number",default:s,validator:a=>{let r=Number(a);if(isNaN(r))throw new Error(`Invalid number: "${a}"`);return r}};else if(typeof s=="boolean")u[t]={type:"boolean",default:s,validator:a=>{let r=a.toLowerCase();if(["true","1","yes","on"].includes(r))return true;if(["false","0","no","off",""].includes(r))return false;throw new Error(`Invalid boolean: "${a}"`)}};else if(Array.isArray(s)){let a=s.map(String),r=s.__optional===true;u[t]={type:"string",enum:a,optional:r,validator:(f,n)=>{if(!a.includes(f)){let o=n||t;throw new Error(`${o} must be one of: ${a.join(", ")}`)}return f}};}else u[t]=s;return u}function x(i,u){return i.replace(/\$\{([^}]+)\}/g,(t,s)=>u[s]||t)}async function q(i,u,t,s="last",a){let r={},f={};if(s==="last"){let n=await Promise.allSettled(i.map(async o=>({resolver:o,env:o.load?await o.load():{}})));for(let o of n){if(o.status==="rejected"){let d=o.reason;if(E({type:"resolver_error",timestamp:Date.now(),source:"unknown",error:d instanceof Error?d.message:String(d)}),t)throw new Error(`Resolver failed: ${d instanceof Error?d.message:d}`);continue}let{resolver:m,env:c}=o.value;for(let[d,b]of Object.entries(c))b!==void 0&&(r[d]=b,f[d]={source:m.name||"unknown",timestamp:Date.now(),...m.metadata?.cached!==void 0&&{cached:!!m.metadata.cached}});}}else for(let n of i)try{let o=n.load?await n.load():{};for(let[m,c]of Object.entries(o))if(c!==void 0){if(r[m]!==void 0)continue;r[m]=c,f[m]={source:n.name||"unknown",timestamp:Date.now(),...n.metadata?.cached!==void 0&&{cached:!!n.metadata.cached}};}if(a&&a.size>0&&Array.from(a).every(c=>r[c]!==void 0))break}catch(o){if(E({type:"resolver_error",timestamp:Date.now(),source:n.name,error:o instanceof Error?o.message:String(o)}),t)throw new Error(`Resolver ${n.name} failed: ${o instanceof Error?o.message:o}`,{cause:o})}if(u)for(let[n,o]of Object.entries(r))r[n]=x(o,r);return {mergedEnv:r,provenance:f}}function W(i,u,t,s="last",a){let r={},f={};for(let n of i)try{if(!n.loadSync){if(t)throw new Error(`Resolver ${n.name} has no loadSync() method`);continue}let o=n.loadSync();for(let[m,c]of Object.entries(o))if(c!==void 0){if(s==="first"&&r[m]!==void 0)continue;r[m]=c,f[m]={source:n.name||"unknown",timestamp:Date.now(),...n.metadata?.cached!==void 0&&{cached:!!n.metadata.cached}};}if(s==="first"&&a&&a.size>0&&Array.from(a).every(c=>r[c]!==void 0))break}catch(o){if(h({type:"resolver_error",timestamp:Date.now(),source:n.name,error:o instanceof Error?o.message:String(o)}),t)throw new Error(`Resolver ${n.name} failed: ${o instanceof Error?o.message:o}`,{cause:o})}if(u)for(let[n,o]of Object.entries(r))r[n]=x(o,r);return {mergedEnv:r,provenance:f}}function z(i,u,t,s){if(!s)return null;if((process.env.NODE_ENV||"").toLowerCase()==="production"&&t&&t.source.startsWith("dotenv(")){let f=s.allowDotenvInProduction;return f===true?null:Array.isArray(f)?f.includes(i)?null:`${i} cannot be sourced from .env files in production. Use process.env or cloud resolvers. To allow: policies.allowDotenvInProduction: ['${i}'] or set to true for all.`:`${i} cannot be sourced from .env files in production (secure default). Production platforms (Vercel, AWS, etc.) use process.env. To allow .env in production: policies.allowDotenvInProduction: true`}let r=s.enforceAllowedSources?.[i];return r&&t&&!r.includes(t.source)?`${i} must be sourced from one of: ${r.join(", ")} (actual: ${t.source})`:null}function M(i){let u=[],t=/^[A-Za-z_][A-Za-z0-9_]*$/;for(let s of Object.keys(i))t.test(s)||u.push(`Invalid environment variable name: "${s}". Environment variable names must contain only letters, numbers, and underscores, and cannot start with a number.`);return u}function B(i,u){let t={};for(let[s,a]of Object.entries(i)){if(!s.includes(u)){t[s]=a;continue}let r=s.split(u),f=t;for(let o=0;o<r.length-1;o++){let m=r[o].toLowerCase();m in f||(f[m]={}),f=f[m];}let n=r[r.length-1].toLowerCase();f[n]=a;}for(let s of Object.keys(i))delete i[s];return Object.assign(i,t),i}async function J(i,u,t){let s=(process.env.NODE_ENV||"").toLowerCase()==="production",{interpolate:a=false,strict:r=true,policies:f,enableAudit:n=s,priority:o="last",secretsDir:m}=t,c$1={},d$1;n&&(d$1=T(c$1));let b=M(i);if(b.length>0)throw n&&E({type:"validation_failure",timestamp:Date.now(),error:`Invalid environment variable names: ${b.join(", ")}`,sessionId:d$1}),new Error(`Environment validation failed:
|
|
2
|
-
${b.map(e=>` - ${e}`).join(`
|
|
3
|
-
`)}`);let O=new Set(Object.keys(i)),{mergedEnv:_,provenance:y}=await q(u,a,r,o,O),g=[];for(let[e,w]of Object.entries(i)){let v=w,D=_[e],S=z(e,v,y[e],f);if(S){g.push(S),n&&E({type:"policy_violation",timestamp:Date.now(),key:e,source:y[e]?.source??"unknown",error:S,sessionId:d$1});continue}try{let l;if(D===void 0){let p=v.secretsDir??m;if(v.type==="file"&&p){let j=e.toLowerCase().replace(/_/g,"-"),P=join(p,j),$=L(P,e);$.valid?(l={success:!0,value:$.value},y[e]={source:`secretsDir(${p})`,timestamp:Date.now()}):l={success:!1,error:$.error??`Failed to read secret for ${e}`};}else v.default!==void 0?l={success:!0,value:v.default}:v.optional?l={success:!0,value:void 0}:l={success:!1,error:`Missing required environment variable: ${e}`};}else if(v.validator)try{l={success:!0,value:v.validator(D,e)};}catch(p){l={success:!1,error:p instanceof Error?p.message:`Validation failed for ${e}`};}else l={success:!0,value:D};l.success?(c$1[e]=l.value,n&&E({type:"env_loaded",timestamp:Date.now(),key:e,source:y[e]?.source??"unknown",metadata:{cached:y[e]?.cached},sessionId:d$1})):(g.push(l.error),n&&E({type:"validation_failure",timestamp:Date.now(),key:e,error:l.error,sessionId:d$1}));}catch(l){let p=l instanceof Error?l.message:String(l);g.push(`${e}: ${p}`),n&&E({type:"validation_failure",timestamp:Date.now(),key:e,error:p,sessionId:d$1});}}if(g.length>0)throw n&&E({type:"validation_failure",timestamp:Date.now(),error:`${g.length} validation error(s)`,metadata:{errorCount:g.length},sessionId:d$1}),new Error(`Environment validation failed:
|
|
4
|
-
${g.map(e=>` - ${e}`).join(`
|
|
5
|
-
`)}`);n&&E({type:"validation_success",timestamp:Date.now(),metadata:{variableCount:Object.keys(i).length},sessionId:d$1});let R=new Set,k=new Map;for(let[e,w]of Object.entries(i))if(w.sensitive){R.add(e);let v=c$1[e];typeof v=="string"&&v.length>0&&k.set(e,v);}if(t.nestedDelimiter){B(c$1,t.nestedDelimiter);for(let[e,w]of k.entries())e in c$1||Object.defineProperty(c$1,e,{value:w,enumerable:false,configurable:false});}return Object.defineProperty(c$1,d,{value:R,enumerable:false,configurable:false}),Object.defineProperty(c$1,c,{value:y,enumerable:false,configurable:false}),c$1}function Q(i,u,t){let s=(process.env.NODE_ENV||"").toLowerCase()==="production",{interpolate:a=false,strict:r=true,policies:f,enableAudit:n=s,priority:o="last",secretsDir:m}=t,c$1={},d$1;n&&(d$1=T(c$1));let b=M(i);if(b.length>0)throw n&&h({type:"validation_failure",timestamp:Date.now(),error:`Invalid environment variable names: ${b.join(", ")}`,sessionId:d$1}),new Error(`Environment validation failed:
|
|
6
|
-
${b.map(e=>` - ${e}`).join(`
|
|
7
|
-
`)}`);let O=new Set(Object.keys(i)),{mergedEnv:_,provenance:y}=W(u,a,r,o,O),g=[];for(let[e,w]of Object.entries(i)){let v=w,D=_[e],S=z(e,v,y[e],f);if(S){g.push(S),n&&h({type:"policy_violation",timestamp:Date.now(),key:e,source:y[e]?.source??"unknown",error:S,sessionId:d$1});continue}try{let l;if(D===void 0){let p=v.secretsDir??m;if(v.type==="file"&&p){let j=e.toLowerCase().replace(/_/g,"-"),P=join(p,j),$=L(P,e);$.valid?(l={success:!0,value:$.value},y[e]={source:`secretsDir(${p})`,timestamp:Date.now()}):l={success:!1,error:$.error??`Failed to read secret for ${e}`};}else v.default!==void 0?l={success:!0,value:v.default}:v.optional?l={success:!0,value:void 0}:l={success:!1,error:`Missing required environment variable: ${e}`};}else if(v.validator)try{l={success:!0,value:v.validator(D,e)};}catch(p){l={success:!1,error:p instanceof Error?p.message:`Validation failed for ${e}`};}else l={success:!0,value:D};l.success?(c$1[e]=l.value,n&&h({type:"env_loaded",timestamp:Date.now(),key:e,source:y[e]?.source??"unknown",metadata:{cached:y[e]?.cached},sessionId:d$1})):(g.push(l.error),n&&h({type:"validation_failure",timestamp:Date.now(),key:e,error:l.error,sessionId:d$1}));}catch(l){let p=l instanceof Error?l.message:String(l);g.push(`${e}: ${p}`),n&&h({type:"validation_failure",timestamp:Date.now(),key:e,error:p,sessionId:d$1});}}if(g.length>0)throw n&&h({type:"validation_failure",timestamp:Date.now(),error:`${g.length} validation error(s)`,metadata:{errorCount:g.length},sessionId:d$1}),new Error(`Environment validation failed:
|
|
8
|
-
${g.map(e=>` - ${e}`).join(`
|
|
9
|
-
`)}`);n&&h({type:"validation_success",timestamp:Date.now(),metadata:{variableCount:Object.keys(i).length},sessionId:d$1});let R=new Set,k=new Map;for(let[e,w]of Object.entries(i))if(w.sensitive){R.add(e);let v=c$1[e];typeof v=="string"&&v.length>0&&k.set(e,v);}if(t.nestedDelimiter){B(c$1,t.nestedDelimiter);for(let[e,w]of k.entries())e in c$1||Object.defineProperty(c$1,e,{value:w,enumerable:false,configurable:false});}return Object.defineProperty(c$1,d,{value:R,enumerable:false,configurable:false}),Object.defineProperty(c$1,c,{value:y,enumerable:false,configurable:false}),c$1}export{H as a,J as b,Q as c};
|
package/dist/chunk-ZDRU3RSU.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';var fs=require('fs');var g=`// Auto-generated by node-env-resolver typegen. DO NOT EDIT.
|
|
2
|
-
// Regenerate with: npx node-env-resolver typegen
|
|
3
|
-
`;function y(t){if(!t?.type)return "string";switch(t.type){case "string":case "url":case "email":case "json":case "custom":return "string";case "number":case "port":return "number";case "boolean":return "boolean";case "string[]":return "string[]";case "number[]":return "number[]";case "oneOf":{let n=t.enumValues;return !n||n.length===0?"string":n.map(r=>JSON.stringify(String(r))).join(" | ")}default:return "string"}}function m(t){if(!t?.type)return "string";switch(t.type){case "boolean":return "'true' | 'false'";case "oneOf":{let n=t.enumValues;return !n||n.length===0?"string":n.map(r=>JSON.stringify(String(r))).join(" | ")}default:return "string"}}function h(t){let n=[];for(let[r,i]of Object.entries(t)){let a="string",p="string",e=false,s,o=false;if(typeof i=="function"){let u=i,c=u.__meta;a=y(c),p=m(c),e=u.optional===true,s=c?.description,o=c?.sensitive===true;}else if(typeof i=="number")a="number";else if(typeof i=="boolean")a="boolean",p="'true' | 'false'";else if(Array.isArray(i)){let u=i;if(u.length>0){let c=u.map(l=>JSON.stringify(String(l))).join(" | ");a=c,p=c;}e=i.__optional===true;}n.push({key:r,tsType:a,stringType:p,isOptional:e,description:s,isSensitive:o});}return n}function d(t){let n=[];return t.description&&n.push(t.description),t.isSensitive&&n.push("@sensitive"),n.length===0?"":n.length===1?` /** ${n[0]} */
|
|
4
|
-
`:` /**
|
|
5
|
-
${n.map(r=>` * ${r}`).join(`
|
|
6
|
-
`)}
|
|
7
|
-
*/
|
|
8
|
-
`}function v(t,n={}){let{augmentProcessEnv:r=true,augmentImportMetaEnv:i=true,banner:a=g}=n,p=h(t),e=[];a&&e.push(a),e.push("export interface EnvSchema {");for(let s of p){let o=d(s);o&&e.push(o.trimEnd());let u=s.isOptional?"?":"";e.push(` ${s.key}${u}: ${s.tsType};`);}if(e.push("}"),e.push(""),r){e.push("declare global {"),e.push(" namespace NodeJS {"),e.push(" interface ProcessEnv {");for(let s of p){let o=s.isOptional?"?":"";e.push(` ${s.key}${o}: ${s.stringType};`);}e.push(" }"),e.push(" }"),e.push("}"),e.push("");}if(i){e.push("interface ImportMetaEnv {");for(let s of p){let o=s.isOptional?"?":"";e.push(` ${s.key}${o}: ${s.stringType};`);}e.push("}"),e.push(""),e.push("interface ImportMeta {"),e.push(" readonly env: ImportMetaEnv;"),e.push("}"),e.push("");}return e.join(`
|
|
9
|
-
`)}function b(t,n,r){let i=v(t,r);fs.writeFileSync(n,i,"utf8");}exports.a=v;exports.b=b;
|
package/dist/cli-main.cjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';var chunkZDRU3RSU_cjs=require('./chunk-ZDRU3RSU.cjs'),chunkS7AB6UX7_cjs=require('./chunk-S7AB6UX7.cjs'),chunkFNF55TN4_cjs=require('./chunk-FNF55TN4.cjs');require('./chunk-2IQQVAXA.cjs'),require('./chunk-O7NR4K6A.cjs');var chunkG36OESVW_cjs=require('./chunk-G36OESVW.cjs');require('./chunk-4QOKRJ3F.cjs'),require('./chunk-D6WM53FN.cjs');var b=require('ansis'),fs=require('fs'),path=require('path'),url=require('url'),child_process=require('child_process');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var b__default=/*#__PURE__*/_interopDefault(b);var U=["env.config.mjs","env.config.js"];function G(e){if(e){let n=path.resolve(process.cwd(),e);if(!fs.existsSync(n))throw new Error(`Config file not found at ${e}. Pass a valid --config path or create env.config.js/env.config.mjs in the current directory.`);return n}for(let n of U){let r=path.resolve(process.cwd(),n);if(fs.existsSync(r))return r}throw new Error("No config file found. Create env.config.js or env.config.mjs in the current directory, or pass --config <path>.")}function M(e){if(e.endsWith(".ts")||e.endsWith(".mts")||e.endsWith(".cts"))throw new Error(["TypeScript config files are not loaded automatically.","Use Node with a loader such as tsx, for example:",""," node --import tsx ./node_modules/node-env-resolver/dist/cli-main.js load --config env.config.ts"].join(`
|
|
3
|
-
`))}async function y(e={}){let n=G(e.configPath);M(n);let o=await import(url.pathToFileURL(n).href),t=(o&&(o.default??o.config??o.env))??void 0;if(!t||typeof t!="object")throw new Error(`Config file at ${n} does not export a valid EnvConfig. Export an object with a "schema" property.`);let a=t;if(!a.schema||typeof a.schema!="object")throw new Error(`EnvConfig from ${n} is missing a "schema" object. Ensure it matches { schema, resolvers?, options? }.`);return a}function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function S(e,n,r={}){let o=r.prefix??"",t={};for(let[a,s]of Object.entries(e)){let m=a.toUpperCase(),i=o?`${o}${n}${m}`:m;if(!o&&r.preserveTopLevelKeys?.has(i)){t[i]=s==null?"":typeof s=="string"?s:JSON.stringify(s);continue}_(s)?Object.assign(t,S(s,n,{...r,prefix:i})):t[i]=s==null?"":String(s);}return t}function F(e){let n="pretty",r=false,o;for(let t=0;t<e.length;t++){let a=e[t];if(a==="--format"&&e[t+1]){let s=e[t+1];if(s==="pretty"||s==="json"||s==="env")n=s;else throw new Error(`Invalid --format value "${s}". Expected one of: pretty, json, env.`);t++;}else if(a.startsWith("--format=")){let s=a.split("=",2)[1];if(s==="pretty"||s==="json"||s==="env")n=s;else throw new Error(`Invalid --format value "${s}". Expected one of: pretty, json, env.`)}else a==="--reveal"?r=true:(a==="--config"||a==="-c")&&e[t+1]&&(o=e[t+1],t++);}return {format:n,reveal:r,configPath:o}}function J(e){let n=e[chunkG36OESVW_cjs.c];if(n&&typeof n=="object")return n}function W(e,n){let r=Object.keys(e).sort(),o=chunkFNF55TN4_cjs.c(e),t=J(e),a=chunkFNF55TN4_cjs.f(e),s=[];for(let f of r){let d=e[f],p=n?d:a(d),C=d===null?"null":Array.isArray(d)?"array":typeof d=="object"?"object":typeof d,P=t?.[f]?.source??"unknown",I=o.has(f),R=typeof p=="string"?p:JSON.stringify(p);s.push([f,C,P,I&&!n?`${R}`:R]);}let m=["KEY","TYPE","SOURCE","VALUE"],i=[m,...s],c=i[0].map((f,d)=>Math.max(...i.map(p=>p[d].length))),[u,g,v,l]=m;console.log(b__default.default.bold(`${u.padEnd(c[0])} ${g.padEnd(c[1])} ${v.padEnd(c[2])} ${l}`));for(let[f,d,p,C]of s){let P=chunkFNF55TN4_cjs.c(e).has(f)?b__default.default.yellow(f):f;console.log(`${P.padEnd(c[0])} ${d.padEnd(c[1])} ${p.padEnd(c[2])} ${C}`);}}async function O(e){let n=F(e),r=await y({configPath:n.configPath}),o=await chunkS7AB6UX7_cjs.b(r);if(n.format==="pretty")return W(o,n.reveal),0;if(n.format==="json"){let i=chunkFNF55TN4_cjs.f(o),c=n.reveal?o:i(o);return console.log(JSON.stringify(c,null,2)),0}let t=r.options?.nestedDelimiter,a=t?(()=>{let i=new Set(Object.keys(r.schema).filter(c=>!c.includes(t)));return S(o,t,{preserveTopLevelKeys:i})})():Object.fromEntries(Object.entries(o).map(([i,c])=>[i,String(c??"")])),s=chunkFNF55TN4_cjs.f(o),m=Object.keys(a).sort();for(let i of m){let c=a[i]??"",u=n.reveal?c:s(c);console.log(`${i}=${typeof u=="string"?u:c}`);}return 0}function B(e){let n,r=false,o=e.indexOf("--");if(o===-1||o===e.length-1)throw new Error("Missing child command. Usage: node-env-resolver run [--config path] [--no-redact] -- <command>");let t=e.slice(0,o),a=e.slice(o+1);for(let i=0;i<t.length;i++){let c=t[i];(c==="--config"||c==="-c")&&t[i+1]?(n=t[i+1],i++):c==="--no-redact"&&(r=true);}let[s,...m]=a;if(!s)throw new Error('Missing child command after "--". Example: node-env-resolver run -- npm run migrate');return {configPath:n,noRedact:r,command:s,commandArgs:m}}async function L(e){let n=B(e),r=await y({configPath:n.configPath}),o=await chunkS7AB6UX7_cjs.b(r),t=r.options?.nestedDelimiter,a=t?new Set(Object.keys(r.schema).filter(l=>!l.includes(t))):null,s=t?S(o,t,{preserveTopLevelKeys:a??void 0}):Object.fromEntries(Object.entries(o).map(([l,f])=>[l,String(f??"")])),m={...process.env,...s};if(t&&a)for(let l of a){let f=`${l}${t}`;for(let d of Object.keys(m))d.startsWith(f)&&delete m[d];}let c=chunkFNF55TN4_cjs.c(o).size>0&&!n.noRedact,u=c?chunkFNF55TN4_cjs.f(o):null,g=child_process.spawn(n.command,n.commandArgs,{env:m,stdio:c?["inherit","pipe","pipe"]:"inherit"}),v=l=>{g.killed||g.kill(l);};return process.on("SIGINT",v),process.on("SIGTERM",v),c&&g.stdout&&g.stderr&&(g.stdout.on("data",l=>{let f=l.toString(),d=u?u(f):f,p=typeof d=="string"?d:f;process.stdout.write(p);}),g.stderr.on("data",l=>{let f=l.toString(),d=u?u(f):f,p=typeof d=="string"?d:f;process.stderr.write(p);})),await new Promise(l=>{g.on("exit",(f,d)=>{process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),d&&console.error(b__default.default.red(`Child process terminated with signal ${d}`)),l(f??0);});})}function z(e){let n,r="env.d.ts";for(let o=0;o<e.length;o++){let t=e[o];(t==="--config"||t==="-c")&&e[o+1]?(n=e[o+1],o++):(t==="--output"||t==="-o")&&e[o+1]?(r=e[o+1],o++):t.startsWith("--output=")&&(r=t.split("=",2)[1]);}return {configPath:n,outputPath:r}}async function N(e){let n=z(e),r=await y({configPath:n.configPath});return chunkZDRU3RSU_cjs.b(r.schema,n.outputPath),console.log(b__default.default.green(`Type definitions written to ${n.outputPath} based on EnvConfig schema.`)),0}function Z(){try{let e=url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-main.cjs', document.baseURI).href))),n=path.join(path.dirname(e),"../package.json");return JSON.parse(fs.readFileSync(n,"utf8")).version??"unknown"}catch{return "unknown"}}function j(){console.log([b__default.default.bold("node-env-resolver CLI"),"","Usage:"," node-env-resolver <command> [options]","","Commands:"," load Resolve config and print it (pretty | json | env)"," run Resolve config and run a child command with injected env"," typegen Generate TypeScript definitions from EnvConfig schema","","Global options:"," -h, --help Show this help message"," -v, --version Show CLI version","","Examples:"," node-env-resolver load"," node-env-resolver load --format=json"," node-env-resolver run -- npm run migrate"," node-env-resolver typegen --output env.d.ts"].join(`
|
|
4
|
-
`));}async function ee(){let[,,...e]=process.argv;if(e.includes("--help")||e.includes("-h"))return j(),0;if(e.includes("--version")||e.includes("-v"))return console.log(Z()),0;let[n,...r]=e;if(!n)return j(),1;try{switch(n){case "load":return await O(r);case "run":return await L(r);case "typegen":return await N(r);default:return console.error(b__default.default.red(`Unknown command: ${n}`)),j(),1}}catch(o){let t=o instanceof Error?o.message:String(o);return console.error(b__default.default.red(t)),1}}ee().then(e=>{process.exit(e);});
|
package/dist/cli-main.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {b as b$1}from'./chunk-TGIYWWDY.js';import {b as b$2}from'./chunk-C34FGZOG.js';import {c,f}from'./chunk-I5UKYTX6.js';import'./chunk-VUUPIWFJ.js';import'./chunk-6EWR3WHU.js';import {c as c$1}from'./chunk-46CBATKM.js';import'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';import b from'ansis';import {readFileSync,existsSync}from'fs';import {join,dirname,resolve}from'path';import {fileURLToPath,pathToFileURL}from'url';import {spawn}from'child_process';var U=["env.config.mjs","env.config.js"];function G(e){if(e){let n=resolve(process.cwd(),e);if(!existsSync(n))throw new Error(`Config file not found at ${e}. Pass a valid --config path or create env.config.js/env.config.mjs in the current directory.`);return n}for(let n of U){let r=resolve(process.cwd(),n);if(existsSync(r))return r}throw new Error("No config file found. Create env.config.js or env.config.mjs in the current directory, or pass --config <path>.")}function M(e){if(e.endsWith(".ts")||e.endsWith(".mts")||e.endsWith(".cts"))throw new Error(["TypeScript config files are not loaded automatically.","Use Node with a loader such as tsx, for example:",""," node --import tsx ./node_modules/node-env-resolver/dist/cli-main.js load --config env.config.ts"].join(`
|
|
3
|
-
`))}async function y(e={}){let n=G(e.configPath);M(n);let o=await import(pathToFileURL(n).href),t=(o&&(o.default??o.config??o.env))??void 0;if(!t||typeof t!="object")throw new Error(`Config file at ${n} does not export a valid EnvConfig. Export an object with a "schema" property.`);let a=t;if(!a.schema||typeof a.schema!="object")throw new Error(`EnvConfig from ${n} is missing a "schema" object. Ensure it matches { schema, resolvers?, options? }.`);return a}function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function S(e,n,r={}){let o=r.prefix??"",t={};for(let[a,s]of Object.entries(e)){let m=a.toUpperCase(),i=o?`${o}${n}${m}`:m;if(!o&&r.preserveTopLevelKeys?.has(i)){t[i]=s==null?"":typeof s=="string"?s:JSON.stringify(s);continue}_(s)?Object.assign(t,S(s,n,{...r,prefix:i})):t[i]=s==null?"":String(s);}return t}function F(e){let n="pretty",r=false,o;for(let t=0;t<e.length;t++){let a=e[t];if(a==="--format"&&e[t+1]){let s=e[t+1];if(s==="pretty"||s==="json"||s==="env")n=s;else throw new Error(`Invalid --format value "${s}". Expected one of: pretty, json, env.`);t++;}else if(a.startsWith("--format=")){let s=a.split("=",2)[1];if(s==="pretty"||s==="json"||s==="env")n=s;else throw new Error(`Invalid --format value "${s}". Expected one of: pretty, json, env.`)}else a==="--reveal"?r=true:(a==="--config"||a==="-c")&&e[t+1]&&(o=e[t+1],t++);}return {format:n,reveal:r,configPath:o}}function J(e){let n=e[c$1];if(n&&typeof n=="object")return n}function W(e,n){let r=Object.keys(e).sort(),o=c(e),t=J(e),a=f(e),s=[];for(let f of r){let d=e[f],p=n?d:a(d),C=d===null?"null":Array.isArray(d)?"array":typeof d=="object"?"object":typeof d,P=t?.[f]?.source??"unknown",I=o.has(f),R=typeof p=="string"?p:JSON.stringify(p);s.push([f,C,P,I&&!n?`${R}`:R]);}let m=["KEY","TYPE","SOURCE","VALUE"],i=[m,...s],c$1=i[0].map((f,d)=>Math.max(...i.map(p=>p[d].length))),[u,g,v,l]=m;console.log(b.bold(`${u.padEnd(c$1[0])} ${g.padEnd(c$1[1])} ${v.padEnd(c$1[2])} ${l}`));for(let[f,d,p,C]of s){let P=c(e).has(f)?b.yellow(f):f;console.log(`${P.padEnd(c$1[0])} ${d.padEnd(c$1[1])} ${p.padEnd(c$1[2])} ${C}`);}}async function O(e){let n=F(e),r=await y({configPath:n.configPath}),o=await b$2(r);if(n.format==="pretty")return W(o,n.reveal),0;if(n.format==="json"){let i=f(o),c=n.reveal?o:i(o);return console.log(JSON.stringify(c,null,2)),0}let t=r.options?.nestedDelimiter,a=t?(()=>{let i=new Set(Object.keys(r.schema).filter(c=>!c.includes(t)));return S(o,t,{preserveTopLevelKeys:i})})():Object.fromEntries(Object.entries(o).map(([i,c])=>[i,String(c??"")])),s=f(o),m=Object.keys(a).sort();for(let i of m){let c=a[i]??"",u=n.reveal?c:s(c);console.log(`${i}=${typeof u=="string"?u:c}`);}return 0}function B(e){let n,r=false,o=e.indexOf("--");if(o===-1||o===e.length-1)throw new Error("Missing child command. Usage: node-env-resolver run [--config path] [--no-redact] -- <command>");let t=e.slice(0,o),a=e.slice(o+1);for(let i=0;i<t.length;i++){let c=t[i];(c==="--config"||c==="-c")&&t[i+1]?(n=t[i+1],i++):c==="--no-redact"&&(r=true);}let[s,...m]=a;if(!s)throw new Error('Missing child command after "--". Example: node-env-resolver run -- npm run migrate');return {configPath:n,noRedact:r,command:s,commandArgs:m}}async function L(e){let n=B(e),r=await y({configPath:n.configPath}),o=await b$2(r),t=r.options?.nestedDelimiter,a=t?new Set(Object.keys(r.schema).filter(l=>!l.includes(t))):null,s=t?S(o,t,{preserveTopLevelKeys:a??void 0}):Object.fromEntries(Object.entries(o).map(([l,f])=>[l,String(f??"")])),m={...process.env,...s};if(t&&a)for(let l of a){let f=`${l}${t}`;for(let d of Object.keys(m))d.startsWith(f)&&delete m[d];}let c$1=c(o).size>0&&!n.noRedact,u=c$1?f(o):null,g=spawn(n.command,n.commandArgs,{env:m,stdio:c$1?["inherit","pipe","pipe"]:"inherit"}),v=l=>{g.killed||g.kill(l);};return process.on("SIGINT",v),process.on("SIGTERM",v),c$1&&g.stdout&&g.stderr&&(g.stdout.on("data",l=>{let f=l.toString(),d=u?u(f):f,p=typeof d=="string"?d:f;process.stdout.write(p);}),g.stderr.on("data",l=>{let f=l.toString(),d=u?u(f):f,p=typeof d=="string"?d:f;process.stderr.write(p);})),await new Promise(l=>{g.on("exit",(f,d)=>{process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),d&&console.error(b.red(`Child process terminated with signal ${d}`)),l(f??0);});})}function z(e){let n,r="env.d.ts";for(let o=0;o<e.length;o++){let t=e[o];(t==="--config"||t==="-c")&&e[o+1]?(n=e[o+1],o++):(t==="--output"||t==="-o")&&e[o+1]?(r=e[o+1],o++):t.startsWith("--output=")&&(r=t.split("=",2)[1]);}return {configPath:n,outputPath:r}}async function N(e){let n=z(e),r=await y({configPath:n.configPath});return b$1(r.schema,n.outputPath),console.log(b.green(`Type definitions written to ${n.outputPath} based on EnvConfig schema.`)),0}function Z(){try{let e=fileURLToPath(import.meta.url),n=join(dirname(e),"../package.json");return JSON.parse(readFileSync(n,"utf8")).version??"unknown"}catch{return "unknown"}}function j(){console.log([b.bold("node-env-resolver CLI"),"","Usage:"," node-env-resolver <command> [options]","","Commands:"," load Resolve config and print it (pretty | json | env)"," run Resolve config and run a child command with injected env"," typegen Generate TypeScript definitions from EnvConfig schema","","Global options:"," -h, --help Show this help message"," -v, --version Show CLI version","","Examples:"," node-env-resolver load"," node-env-resolver load --format=json"," node-env-resolver run -- npm run migrate"," node-env-resolver typegen --output env.d.ts"].join(`
|
|
4
|
-
`));}async function ee(){let[,,...e]=process.argv;if(e.includes("--help")||e.includes("-h"))return j(),0;if(e.includes("--version")||e.includes("-v"))return console.log(Z()),0;let[n,...r]=e;if(!n)return j(),1;try{switch(n){case "load":return await O(r);case "run":return await L(r);case "typegen":return await N(r);default:return console.error(b.red(`Unknown command: ${n}`)),j(),1}}catch(o){let t=o instanceof Error?o.message:String(o);return console.error(b.red(t)),1}}ee().then(e=>{process.exit(e);});
|
package/dist/redaction.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkFNF55TN4_cjs=require('./chunk-FNF55TN4.cjs');require('./chunk-G36OESVW.cjs'),require('./chunk-D6WM53FN.cjs');Object.defineProperty(exports,"REVEAL_SYMBOL",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.a}});Object.defineProperty(exports,"createRedactor",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.f}});Object.defineProperty(exports,"getSensitiveKeys",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.c}});Object.defineProperty(exports,"getSensitiveValues",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.d}});Object.defineProperty(exports,"patchGlobalConsole",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.h}});Object.defineProperty(exports,"redactSensitiveConfig",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.g}});Object.defineProperty(exports,"redactString",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.e}});Object.defineProperty(exports,"reveal",{enumerable:true,get:function(){return chunkFNF55TN4_cjs.b}});
|
package/dist/redaction.d.cts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Symbol used to mark a value as intentionally revealed, so the redactor skips it.
|
|
3
|
-
*/
|
|
4
|
-
declare const REVEAL_SYMBOL: unique symbol;
|
|
5
|
-
/**
|
|
6
|
-
* A value wrapped with REVEAL_SYMBOL so the redactor skips redaction.
|
|
7
|
-
*/
|
|
8
|
-
type Revealed<T> = {
|
|
9
|
-
readonly [REVEAL_SYMBOL]: true;
|
|
10
|
-
readonly value: T;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Wrap a value so the redactor intentionally skips it.
|
|
14
|
-
* Use this when you need to log a sensitive value for debugging.
|
|
15
|
-
*/
|
|
16
|
-
declare function reveal<T>(value: T): Revealed<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Extract the set of keys marked as sensitive from a resolved config object.
|
|
19
|
-
*/
|
|
20
|
-
declare function getSensitiveKeys(config: object): Set<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Extract a map of sensitive key → resolved string value from a resolved config.
|
|
23
|
-
* Only includes keys whose resolved values are non-empty strings.
|
|
24
|
-
*/
|
|
25
|
-
declare function getSensitiveValues(config: object): Map<string, string>;
|
|
26
|
-
/**
|
|
27
|
-
* Mask a string value for display. Shows the first `showChars` characters
|
|
28
|
-
* followed by asterisks.
|
|
29
|
-
*
|
|
30
|
-
* @param value - The string to mask
|
|
31
|
-
* @param showChars - Number of leading characters to show (default: 2)
|
|
32
|
-
*/
|
|
33
|
-
declare function redactString(value: string, showChars?: number): string;
|
|
34
|
-
/**
|
|
35
|
-
* Create a bound redaction function for a specific resolved config.
|
|
36
|
-
* The regex is built once and cached via WeakMap.
|
|
37
|
-
*
|
|
38
|
-
* @param config - A resolved config object (from resolve/resolveAsync)
|
|
39
|
-
* @returns A function that redacts sensitive values from any input
|
|
40
|
-
*/
|
|
41
|
-
declare function createRedactor(config: object): (value: unknown) => unknown;
|
|
42
|
-
declare function redactSensitiveConfig(value: unknown, config: object): unknown;
|
|
43
|
-
/**
|
|
44
|
-
* Patch global console methods to redact sensitive values.
|
|
45
|
-
* Returns an unpatch function to restore original behavior.
|
|
46
|
-
*
|
|
47
|
-
* Best-effort, Node-only. Not guaranteed for all logging pipelines.
|
|
48
|
-
*
|
|
49
|
-
* @param config - A resolved config object with sensitive keys attached
|
|
50
|
-
* @returns A function to unpatch (restore original console methods)
|
|
51
|
-
*/
|
|
52
|
-
declare function patchGlobalConsole(config: object): () => void;
|
|
53
|
-
|
|
54
|
-
export { REVEAL_SYMBOL, type Revealed, createRedactor, getSensitiveKeys, getSensitiveValues, patchGlobalConsole, redactSensitiveConfig, redactString, reveal };
|
package/dist/redaction.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Symbol used to mark a value as intentionally revealed, so the redactor skips it.
|
|
3
|
-
*/
|
|
4
|
-
declare const REVEAL_SYMBOL: unique symbol;
|
|
5
|
-
/**
|
|
6
|
-
* A value wrapped with REVEAL_SYMBOL so the redactor skips redaction.
|
|
7
|
-
*/
|
|
8
|
-
type Revealed<T> = {
|
|
9
|
-
readonly [REVEAL_SYMBOL]: true;
|
|
10
|
-
readonly value: T;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Wrap a value so the redactor intentionally skips it.
|
|
14
|
-
* Use this when you need to log a sensitive value for debugging.
|
|
15
|
-
*/
|
|
16
|
-
declare function reveal<T>(value: T): Revealed<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Extract the set of keys marked as sensitive from a resolved config object.
|
|
19
|
-
*/
|
|
20
|
-
declare function getSensitiveKeys(config: object): Set<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Extract a map of sensitive key → resolved string value from a resolved config.
|
|
23
|
-
* Only includes keys whose resolved values are non-empty strings.
|
|
24
|
-
*/
|
|
25
|
-
declare function getSensitiveValues(config: object): Map<string, string>;
|
|
26
|
-
/**
|
|
27
|
-
* Mask a string value for display. Shows the first `showChars` characters
|
|
28
|
-
* followed by asterisks.
|
|
29
|
-
*
|
|
30
|
-
* @param value - The string to mask
|
|
31
|
-
* @param showChars - Number of leading characters to show (default: 2)
|
|
32
|
-
*/
|
|
33
|
-
declare function redactString(value: string, showChars?: number): string;
|
|
34
|
-
/**
|
|
35
|
-
* Create a bound redaction function for a specific resolved config.
|
|
36
|
-
* The regex is built once and cached via WeakMap.
|
|
37
|
-
*
|
|
38
|
-
* @param config - A resolved config object (from resolve/resolveAsync)
|
|
39
|
-
* @returns A function that redacts sensitive values from any input
|
|
40
|
-
*/
|
|
41
|
-
declare function createRedactor(config: object): (value: unknown) => unknown;
|
|
42
|
-
declare function redactSensitiveConfig(value: unknown, config: object): unknown;
|
|
43
|
-
/**
|
|
44
|
-
* Patch global console methods to redact sensitive values.
|
|
45
|
-
* Returns an unpatch function to restore original behavior.
|
|
46
|
-
*
|
|
47
|
-
* Best-effort, Node-only. Not guaranteed for all logging pipelines.
|
|
48
|
-
*
|
|
49
|
-
* @param config - A resolved config object with sensitive keys attached
|
|
50
|
-
* @returns A function to unpatch (restore original console methods)
|
|
51
|
-
*/
|
|
52
|
-
declare function patchGlobalConsole(config: object): () => void;
|
|
53
|
-
|
|
54
|
-
export { REVEAL_SYMBOL, type Revealed, createRedactor, getSensitiveKeys, getSensitiveValues, patchGlobalConsole, redactSensitiveConfig, redactString, reveal };
|
package/dist/redaction.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as REVEAL_SYMBOL,f as createRedactor,c as getSensitiveKeys,d as getSensitiveValues,h as patchGlobalConsole,g as redactSensitiveConfig,e as redactString,b as reveal}from'./chunk-I5UKYTX6.js';import'./chunk-46CBATKM.js';import'./chunk-I7AUKTXE.js';
|
package/dist/typegen.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkZDRU3RSU_cjs=require('./chunk-ZDRU3RSU.cjs');require('./chunk-D6WM53FN.cjs');Object.defineProperty(exports,"generateTypes",{enumerable:true,get:function(){return chunkZDRU3RSU_cjs.a}});Object.defineProperty(exports,"writeTypes",{enumerable:true,get:function(){return chunkZDRU3RSU_cjs.b}});
|
package/dist/typegen.d.cts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { SimpleEnvSchema } from './types.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Best-effort TypeScript type generation from env schemas.
|
|
5
|
-
*
|
|
6
|
-
* Generated types represent the **coerced output schema** (what resolve() returns).
|
|
7
|
-
* process.env augmentations remain string-ish at runtime — these are convenience,
|
|
8
|
-
* not enforcement. Edge cases (custom validators, complex compositions) fall back
|
|
9
|
-
* to `string`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { generateTypes, writeTypes } from 'node-env-resolver/typegen';
|
|
14
|
-
* import { string, number, oneOf, sensitive } from 'node-env-resolver/validators';
|
|
15
|
-
*
|
|
16
|
-
* const schema = {
|
|
17
|
-
* PORT: number({ default: 3000, description: 'Server port' }),
|
|
18
|
-
* API_KEY: sensitive(string({ description: 'API key for external service' })),
|
|
19
|
-
* NODE_ENV: oneOf(['development', 'production', 'test'] as const),
|
|
20
|
-
* };
|
|
21
|
-
*
|
|
22
|
-
* const types = generateTypes(schema);
|
|
23
|
-
* writeTypes(schema, './env.d.ts');
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
interface TypegenOptions {
|
|
28
|
-
/** Augment global process.env types (default: true) */
|
|
29
|
-
augmentProcessEnv?: boolean;
|
|
30
|
-
/** Augment global import.meta.env types (default: true) */
|
|
31
|
-
augmentImportMetaEnv?: boolean;
|
|
32
|
-
/** Custom banner comment at the top of the file */
|
|
33
|
-
banner?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Generate TypeScript type definitions from a schema.
|
|
37
|
-
*
|
|
38
|
-
* @param schema - The env schema definition
|
|
39
|
-
* @param options - Generation options
|
|
40
|
-
* @returns The generated .d.ts file content as a string
|
|
41
|
-
*/
|
|
42
|
-
declare function generateTypes(schema: SimpleEnvSchema, options?: TypegenOptions): string;
|
|
43
|
-
/**
|
|
44
|
-
* Generate TypeScript type definitions and write them to a file.
|
|
45
|
-
*
|
|
46
|
-
* @param schema - The env schema definition
|
|
47
|
-
* @param outputPath - Path to write the .d.ts file
|
|
48
|
-
* @param options - Generation options
|
|
49
|
-
*/
|
|
50
|
-
declare function writeTypes(schema: SimpleEnvSchema, outputPath: string, options?: TypegenOptions): void;
|
|
51
|
-
|
|
52
|
-
export { type TypegenOptions, generateTypes, writeTypes };
|
package/dist/typegen.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { SimpleEnvSchema } from './types.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Best-effort TypeScript type generation from env schemas.
|
|
5
|
-
*
|
|
6
|
-
* Generated types represent the **coerced output schema** (what resolve() returns).
|
|
7
|
-
* process.env augmentations remain string-ish at runtime — these are convenience,
|
|
8
|
-
* not enforcement. Edge cases (custom validators, complex compositions) fall back
|
|
9
|
-
* to `string`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { generateTypes, writeTypes } from 'node-env-resolver/typegen';
|
|
14
|
-
* import { string, number, oneOf, sensitive } from 'node-env-resolver/validators';
|
|
15
|
-
*
|
|
16
|
-
* const schema = {
|
|
17
|
-
* PORT: number({ default: 3000, description: 'Server port' }),
|
|
18
|
-
* API_KEY: sensitive(string({ description: 'API key for external service' })),
|
|
19
|
-
* NODE_ENV: oneOf(['development', 'production', 'test'] as const),
|
|
20
|
-
* };
|
|
21
|
-
*
|
|
22
|
-
* const types = generateTypes(schema);
|
|
23
|
-
* writeTypes(schema, './env.d.ts');
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
interface TypegenOptions {
|
|
28
|
-
/** Augment global process.env types (default: true) */
|
|
29
|
-
augmentProcessEnv?: boolean;
|
|
30
|
-
/** Augment global import.meta.env types (default: true) */
|
|
31
|
-
augmentImportMetaEnv?: boolean;
|
|
32
|
-
/** Custom banner comment at the top of the file */
|
|
33
|
-
banner?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Generate TypeScript type definitions from a schema.
|
|
37
|
-
*
|
|
38
|
-
* @param schema - The env schema definition
|
|
39
|
-
* @param options - Generation options
|
|
40
|
-
* @returns The generated .d.ts file content as a string
|
|
41
|
-
*/
|
|
42
|
-
declare function generateTypes(schema: SimpleEnvSchema, options?: TypegenOptions): string;
|
|
43
|
-
/**
|
|
44
|
-
* Generate TypeScript type definitions and write them to a file.
|
|
45
|
-
*
|
|
46
|
-
* @param schema - The env schema definition
|
|
47
|
-
* @param outputPath - Path to write the .d.ts file
|
|
48
|
-
* @param options - Generation options
|
|
49
|
-
*/
|
|
50
|
-
declare function writeTypes(schema: SimpleEnvSchema, outputPath: string, options?: TypegenOptions): void;
|
|
51
|
-
|
|
52
|
-
export { type TypegenOptions, generateTypes, writeTypes };
|
package/dist/typegen.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as generateTypes,b as writeTypes}from'./chunk-TGIYWWDY.js';import'./chunk-I7AUKTXE.js';
|
|
File without changes
|
|
File without changes
|