@arundo/typed-env
Advanced tools
Comparing version 0.0.1 to 0.0.2
# @arunod/typed-env | ||
## 0.0.2 | ||
### Patch Changes | ||
- support camelcase naming convention | ||
## 0.0.1 | ||
@@ -4,0 +10,0 @@ |
import { z } from 'zod'; | ||
declare const typeEnvironment: <TSchema extends Record<string, unknown>>(schema: z.ZodType<TSchema, z.ZodTypeDef, TSchema>, transformKeyFn?: (key: string) => string, formatErrorFn?: (error: z.ZodError) => string) => TSchema; | ||
type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${Lowercase<T>}${Capitalize<SnakeToCamelCase<U>>}` : Lowercase<S>; | ||
type OutputType<InputType> = { | ||
[K in keyof InputType as SnakeToCamelCase<string & K>]: InputType[K]; | ||
}; | ||
type NamingConvention = 'camelcase' | 'default'; | ||
type BaseSchema = Record<string, unknown>; | ||
type EnvReturnType<T, S extends BaseSchema> = T extends 'camelcase' ? OutputType<S> : S; | ||
declare const typeEnvironment: <TSchema extends BaseSchema, TTransform extends NamingConvention = "default">(schema: z.ZodType<TSchema, z.ZodTypeDef, TSchema>, transform?: TTransform, formatErrorFn?: (error: z.ZodError) => string) => EnvReturnType<TTransform, TSchema>; | ||
export { typeEnvironment }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(n,r)=>{for(var o in r)a(n,o,{get:r[o],enumerable:!0})},h=(n,r,o,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of m(r))!c.call(n,t)&&t!==o&&a(n,t,{get:()=>r[t],enumerable:!(e=i(r,t))||e.enumerable});return n};var E=n=>h(a({},"__esModule",{value:!0}),n);var v={};d(v,{typeEnvironment:()=>p});module.exports=E(v);var s=require("zod"),f=n=>r=>Object.fromEntries(Object.entries(r).map(([o,e])=>[n(o),e])),g=n=>`Environment variable validation failed:${n.issues.map(r=>` | ||
'${r.path.join(",")}': ${r.message}`).join(",")}`,p=(n,r=e=>e,o=g)=>{try{return n.transform(f(r)).parse(process.env)}catch(e){throw e instanceof s.z.ZodError?new Error(o(e)):new Error("Environment variable validation failed")}};0&&(module.exports={typeEnvironment}); | ||
"use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var T=(a,e)=>{for(var r in e)o(a,r,{get:e[r],enumerable:!0})},p=(a,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of c(e))!i.call(a,t)&&t!==r&&o(a,t,{get:()=>e[t],enumerable:!(n=m(e,t))||n.enumerable});return a};var S=a=>p(o({},"__esModule",{value:!0}),a);var l={};T(l,{typeEnvironment:()=>d});module.exports=S(l);var s=require("zod"),f=a=>a.toLowerCase().replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),h=a=>e=>Object.fromEntries(Object.entries(e).map(([r,n])=>[a(r),n])),y=a=>`Environment variable validation failed:${a.issues.map(e=>` | ||
'${e.path.join(",")}': ${e.message}`).join(",")}`,d=(a,e="default",r=y)=>{try{return a.transform(n=>e==="camelcase"?h(f)(n):n).parse(process.env)}catch(n){throw n instanceof s.z.ZodError?new Error(r(n)):new Error("Environment variable validation failed")}};0&&(module.exports={typeEnvironment}); |
{ | ||
"name": "@arundo/typed-env", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Typed environment variables made easy 🚀", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
4737
18
0