@t3-oss/env-nextjs
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -6,4 +6,5 @@ import * as zod from 'zod'; | ||
type Impossible<T extends Record<string, any>> = Partial<Record<keyof T, never>>; | ||
interface BaseOptions { | ||
interface BaseOptions<TShared extends Record<string, ZodType>> { | ||
isServer?: boolean; | ||
shared?: TShared; | ||
onValidationError?: (error: ZodError) => never; | ||
@@ -13,3 +14,3 @@ onInvalidAccess?: (variable: string) => never; | ||
} | ||
interface StrictOptions<TPrefix extends string, TServer extends Record<string, ZodType>, TClient extends Record<string, ZodType>> extends BaseOptions { | ||
interface StrictOptions<TPrefix extends string, TServer extends Record<string, ZodType>, TClient extends Record<string, ZodType>, TShared extends Record<string, ZodType>> extends BaseOptions<TShared> { | ||
runtimeEnvStrict: Record<{ | ||
@@ -19,3 +20,5 @@ [TKey in keyof TClient]: TKey extends `${TPrefix}${string}` ? TKey : never; | ||
[TKey in keyof TServer]: TKey extends `${TPrefix}${string}` ? never : TKey; | ||
}[keyof TServer], string | boolean | number | undefined>; | ||
}[keyof TServer] | { | ||
[TKey in keyof TShared]: TKey extends string ? TKey : never; | ||
}[keyof TShared], string | boolean | number | undefined>; | ||
runtimeEnv?: never; | ||
@@ -38,4 +41,4 @@ } | ||
type ClientPrefix = typeof CLIENT_PREFIX; | ||
type Options<TServer extends Record<string, ZodType>, TClient extends Record<`${ClientPrefix}${string}`, ZodType>> = Omit<StrictOptions<ClientPrefix, TServer, TClient> & ServerClientOptions<ClientPrefix, TServer, TClient>, "runtimeEnvStrict" | "runtimeEnv" | "clientPrefix"> & ({ | ||
runtimeEnv: StrictOptions<ClientPrefix, TServer, TClient>["runtimeEnvStrict"]; | ||
type Options<TServer extends Record<string, ZodType>, TClient extends Record<`${ClientPrefix}${string}`, ZodType>, TShared extends Record<string, ZodType>> = Omit<StrictOptions<ClientPrefix, TServer, TClient, TShared> & ServerClientOptions<ClientPrefix, TServer, TClient>, "runtimeEnvStrict" | "runtimeEnv" | "clientPrefix"> & ({ | ||
runtimeEnv: StrictOptions<ClientPrefix, TServer, TClient, TShared>["runtimeEnvStrict"]; | ||
experimental__runtimeEnv?: never; | ||
@@ -46,6 +49,8 @@ } | { | ||
[TKey in keyof TClient]: TKey extends `${ClientPrefix}${string}` ? TKey : never; | ||
}[keyof TClient], string | boolean | number | undefined>; | ||
}[keyof TClient] | { | ||
[TKey in keyof TShared]: TKey extends string ? TKey : never; | ||
}[keyof TShared], string | boolean | number | undefined>; | ||
}); | ||
declare function createEnv<TServer extends Record<string, ZodType> = NonNullable<unknown>, TClient extends Record<`${ClientPrefix}${string}`, ZodType> = NonNullable<unknown>>(opts: Options<TServer, TClient>): (zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }> extends infer T_3 extends object ? { [k in keyof T_3]: zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }>[k]; } : never) & (zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }> extends infer T_4 extends object ? { [k_1 in keyof T_4]: zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }>[k_1]; } : never) extends infer T ? { [P in keyof T]: ((zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }> extends infer T_1 extends object ? { [k in keyof T_1]: zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }>[k]; } : never) & (zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }> extends infer T_2 extends object ? { [k_1 in keyof T_2]: zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }>[k_1]; } : never))[P]; } : never; | ||
declare function createEnv<TServer extends Record<string, ZodType> = NonNullable<unknown>, TClient extends Record<`${ClientPrefix}${string}`, ZodType> = NonNullable<unknown>, TShared extends Record<string, ZodType> = NonNullable<unknown>>(opts: Options<TServer, TClient, TShared>): (zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }> extends infer T_4 extends object ? { [k in keyof T_4]: zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }>[k]; } : never) & (zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }> extends infer T_5 extends object ? { [k_1 in keyof T_5]: zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }>[k_1]; } : never) & (zod.objectUtil.addQuestionMarks<{ [k_4 in keyof TShared]: TShared[k_4]["_output"]; }> extends infer T_6 extends object ? { [k_3 in keyof T_6]: zod.objectUtil.addQuestionMarks<{ [k_4 in keyof TShared]: TShared[k_4]["_output"]; }>[k_3]; } : never) extends infer T ? { [P in keyof T]: ((zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }> extends infer T_1 extends object ? { [k in keyof T_1]: zod.objectUtil.addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }>[k]; } : never) & (zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }> extends infer T_2 extends object ? { [k_1 in keyof T_2]: zod.objectUtil.addQuestionMarks<{ [k_2 in keyof TClient]: TClient[k_2]["_output"]; }>[k_1]; } : never) & (zod.objectUtil.addQuestionMarks<{ [k_4 in keyof TShared]: TShared[k_4]["_output"]; }> extends infer T_3 extends object ? { [k_3 in keyof T_3]: zod.objectUtil.addQuestionMarks<{ [k_4 in keyof TShared]: TShared[k_4]["_output"]; }>[k_3]; } : never))[P]; } : never; | ||
export { createEnv }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _zod = require('zod');function a(e){let r=_nullishCoalesce(_nullishCoalesce(e.runtimeEnvStrict, () => (e.runtimeEnv)), () => (process.env));if(e.skipValidation)return r;let i=typeof e.client=="object"?e.client:{},o=typeof e.server=="object"?e.server:{},l=_zod.z.object(i),f=_zod.z.object(o),c=_nullishCoalesce(e.isServer, () => (typeof window>"u")),E=f.merge(l),s=c?E.safeParse(r):l.safeParse(r),m=_nullishCoalesce(e.onValidationError, () => ((n=>{throw console.error("\u274C Invalid environment variables:",n.flatten().fieldErrors),new Error("Invalid environment variables")}))),p=_nullishCoalesce(e.onInvalidAccess, () => ((n=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")})));return s.success===!1?m(s.error):new Proxy(s.data,{get(n,t){if(typeof t=="string")return!c&&e.clientPrefix&&!t.startsWith(e.clientPrefix)?p(t):n[t]}})}var u="NEXT_PUBLIC_";function y(e){let r=typeof e.client=="object"?e.client:{},i=typeof e.server=="object"?e.server:{},o=e.runtimeEnv?e.runtimeEnv:{...process.env,...e.experimental__runtimeEnv,NODE_ENV:process.env.NODE_ENV};return a({...e,client:r,server:i,clientPrefix:u,runtimeEnv:o})}exports.createEnv = y; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _zod = require('zod');function T(e){let r=_nullishCoalesce(_nullishCoalesce(e.runtimeEnvStrict, () => (e.runtimeEnv)), () => (process.env));if(e.skipValidation)return r;let i=typeof e.client=="object"?e.client:{},o=typeof e.server=="object"?e.server:{},s=typeof e.shared=="object"?e.shared:{},d=_zod.z.object(i),f=_zod.z.object(o),a=_zod.z.object(s),v=_nullishCoalesce(e.isServer, () => (typeof window>"u")),y=d.merge(a),p=f.merge(a).merge(d),l=v?p.safeParse(r):y.safeParse(r),m=_nullishCoalesce(e.onValidationError, () => ((t=>{throw console.error("\u274C Invalid environment variables:",t.flatten().fieldErrors),new Error("Invalid environment variables")}))),u=_nullishCoalesce(e.onInvalidAccess, () => ((t=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")})));return l.success===!1?m(l.error):new Proxy(l.data,{get(t,n){if(typeof n=="string")return!v&&e.clientPrefix&&!n.startsWith(e.clientPrefix)&&a.shape[n]===void 0?u(n):t[n]}})}var x="NEXT_PUBLIC_";function P(e){let r=typeof e.client=="object"?e.client:{},i=typeof e.server=="object"?e.server:{},o=typeof e.shared=="object"?e.shared:{},s=e.runtimeEnv?e.runtimeEnv:{...process.env,...e.experimental__runtimeEnv};return T({...e,shared:o,client:r,server:i,clientPrefix:x,runtimeEnv:s})}exports.createEnv = P; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@t3-oss/env-nextjs", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"keywords": [ | ||
@@ -35,3 +35,3 @@ "create-t3-app", | ||
"dependencies": { | ||
"@t3-oss/env-core": "0.5.1" | ||
"@t3-oss/env-core": "0.6.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
33239
67
4
+ Added@t3-oss/env-core@0.6.0(transitive)
- Removed@t3-oss/env-core@0.5.1(transitive)
Updated@t3-oss/env-core@0.6.0