@arundo/typed-env
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -10,3 +10,3 @@ import { ZodIssue, ZodTypeAny } from 'zod'; | ||
}; | ||
type ConditionalType<TTransform extends NamingConvention, TSchema> = 'default' extends TTransform ? TSchema : 'constantcase' extends TTransform ? ConstantKeys<TSchema> : 'camelcase' extends TTransform ? CamelKeys<TSchema> : 'pascalcase' extends TTransform ? PascalKeys<TSchema> : 'kebabcase' extends TTransform ? KebabKeys<TSchema> : never; | ||
type ConditionalType<TTransform extends NamingConvention | undefined, TSchema> = 'default' extends TTransform ? Readonly<TSchema> : 'constantcase' extends TTransform ? Readonly<ConstantKeys<TSchema>> : 'camelcase' extends TTransform ? Readonly<CamelKeys<TSchema>> : 'pascalcase' extends TTransform ? Readonly<PascalKeys<TSchema>> : 'kebabcase' extends TTransform ? Readonly<KebabKeys<TSchema>> : never; | ||
@@ -13,0 +13,0 @@ declare function removePrefix<T extends Record<string, unknown>, L extends string>(obj: T, prefix: L): T | { [K in Extract<keyof T, string> as Replace<Extract<keyof T, string>, L, "">]: T[K]; }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var l=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},y=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of p(e))!v.call(n,o)&&o!==t&&c(n,o,{get:()=>e[o],enumerable:!(s=T(e,o))||s.enumerable});return n};var x=n=>y(c({},"__esModule",{value:!0}),n);var R={};l(R,{removePrefix:()=>f,typeEnvironment:()=>h});module.exports=x(R);var r=require("string-ts"),m={},d=n=>new Error(`Environment variable validation failed:${n.map(e=>` | ||
'${e.path.join(",")}': ${e.message}`).join(",")}`),g=()=>{if(m?.env!==void 0)return m.env;if(process.env!==void 0)return process.env;throw new Error("Failed to get environment object")};function f(n,e){if(!e)return n;let t={};for(let s in n){let o=e?e.endsWith("_")?(0,r.replace)(s,e,""):(0,r.replace)(s,`${e}_`,""):s;t[o]=n[s]}return t}var E=(n,e)=>{switch(n){case"camelcase":return(0,r.camelKeys)(e);case"pascalcase":return(0,r.pascalKeys)(e);case"kebabcase":return(0,r.kebabKeys)(e);case"constantcase":default:return(0,r.constantKeys)(e)}},h=(n,e={},t=g())=>{let{transform:s="default",constructErrorFn:o=d,excludePrefix:u=""}=e;try{let i=n.parse(t),a=f(i,u);return E(s,a)}catch(i){let a=i?.issues||i?.errors||[];throw a.length>0?o?o(a):d(a):new Error("Environment variable validation failed")}};0&&(module.exports={removePrefix,typeEnvironment}); | ||
"use strict";var c=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var p=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},v=(n,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!y.call(n,o)&&o!==t&&c(n,o,{get:()=>e[o],enumerable:!(a=l(e,o))||a.enumerable});return n};var h=n=>v(c({},"__esModule",{value:!0}),n);var g={};p(g,{removePrefix:()=>T,typeEnvironment:()=>K});module.exports=h(g);var r=require("string-ts"),d={},m=n=>new Error(`Environment variable validation failed:${n.map(e=>` | ||
'${e.path.join(",")}': ${e.message}`).join(",")}`),x=()=>{if(d?.env!==void 0)return d.env;if(process.env!==void 0)return process.env;throw new Error("Failed to get environment object")};function T(n,e){if(!e)return n;let t={};for(let a in n){let o=e?e.endsWith("_")?(0,r.replace)(a,e,""):(0,r.replace)(a,`${e}_`,""):a;t[o]=n[a]}return t}var R=(n,e)=>{switch(n){case"camelcase":return(0,r.camelKeys)(e);case"pascalcase":return(0,r.pascalKeys)(e);case"kebabcase":return(0,r.kebabKeys)(e);case"constantcase":default:return(0,r.constantKeys)(e)}},K=(n,e={},t=x())=>{let{transform:a="default",constructErrorFn:o=m,excludePrefix:f=""}=e;try{let i=n.parse(t),s=T(i,f);return R(a,s)}catch(i){let s=i?.issues||i?.errors||[];throw s.length>0?o?o(s):m(s):new Error("Environment variable validation failed")}};0&&(module.exports={removePrefix,typeEnvironment}); |
{ | ||
"name": "@arundo/typed-env", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Typed environment variables made easy 🚀", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -30,3 +30,3 @@ # @arundo/typed-env | ||
NODE_ENV: z.enum(['test', 'development', 'production']), | ||
PORT: z.coerse.number().int().default(3000), | ||
PORT: z.coerce.number().int().default(3000), | ||
}); | ||
@@ -73,3 +73,3 @@ | ||
export const envSchema = z.object({ | ||
PORT: z.coerse.number().int().default(3000), | ||
PORT: z.coerce.number().int().default(3000), | ||
}); | ||
@@ -76,0 +76,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9493