envapt 7.0.0 → 7.0.1

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/browser/converters/Converters.mjs.map +1 -1
  3. package/dist/browser/core/AdvancedMethods.mjs +1 -1
  4. package/dist/browser/core/AdvancedMethods.mjs.map +1 -1
  5. package/dist/browser/core/EnvapterBase.mjs +1 -1
  6. package/dist/browser/core/EnvapterBase.mjs.map +1 -1
  7. package/dist/browser/core/EnvironmentMethods.mjs.map +1 -1
  8. package/dist/browser/core/PrimitiveMethods.mjs +1 -1
  9. package/dist/browser/core/PrimitiveMethods.mjs.map +1 -1
  10. package/dist/browser/infra/Debug.mjs.map +1 -1
  11. package/dist/browser/infra/Error.mjs.map +1 -1
  12. package/dist/browser/sources/ManualEnvSource.mjs.map +1 -1
  13. package/dist/browser/sources/WorkerEnvSource.mjs.map +1 -1
  14. package/dist/node/config.cjs.map +1 -1
  15. package/dist/node/config.mjs.map +1 -1
  16. package/dist/node/converters/Converters.cjs.map +1 -1
  17. package/dist/node/converters/Converters.mjs.map +1 -1
  18. package/dist/node/core/AdvancedMethods.cjs +1 -1
  19. package/dist/node/core/AdvancedMethods.cjs.map +1 -1
  20. package/dist/node/core/AdvancedMethods.mjs +1 -1
  21. package/dist/node/core/AdvancedMethods.mjs.map +1 -1
  22. package/dist/node/core/EnvapterBase.cjs +1 -1
  23. package/dist/node/core/EnvapterBase.cjs.map +1 -1
  24. package/dist/node/core/EnvapterBase.mjs +1 -1
  25. package/dist/node/core/EnvapterBase.mjs.map +1 -1
  26. package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
  27. package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
  28. package/dist/node/core/PrimitiveMethods.cjs +1 -1
  29. package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
  30. package/dist/node/core/PrimitiveMethods.mjs +1 -1
  31. package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
  32. package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
  33. package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
  34. package/dist/node/infra/Debug.cjs.map +1 -1
  35. package/dist/node/infra/Debug.mjs.map +1 -1
  36. package/dist/node/infra/Error.cjs.map +1 -1
  37. package/dist/node/infra/Error.mjs.map +1 -1
  38. package/dist/node/sources/ManualEnvSource.cjs.map +1 -1
  39. package/dist/node/sources/ManualEnvSource.mjs.map +1 -1
  40. package/dist/node/sources/NodeEnvSource.cjs.map +1 -1
  41. package/dist/node/sources/NodeEnvSource.mjs.map +1 -1
  42. package/dist/node/sources/WorkerEnvSource.cjs.map +1 -1
  43. package/dist/node/sources/WorkerEnvSource.mjs.map +1 -1
  44. package/dist/types/converters/Converters.d.mts +3 -0
  45. package/dist/types/core/EnvapterBase.d.mts +1 -0
  46. package/dist/types/core/EnvironmentMethods.d.mts +11 -0
  47. package/dist/types/core/PrimitiveMethods.d.mts +1 -0
  48. package/dist/types/engine/NodeEnvapter.d.mts +3 -1
  49. package/dist/types/infra/Debug.d.mts +4 -4
  50. package/dist/types/infra/Error.d.mts +6 -0
  51. package/dist/types/infra/StandardSchema.d.mts +1 -0
  52. package/dist/types/sources/ManualEnvSource.d.mts +3 -0
  53. package/dist/types/sources/NodeEnvSource.d.mts +10 -0
  54. package/dist/types/sources/WorkerEnvSource.d.mts +3 -0
  55. package/dist/types/types/Options.d.mts +3 -0
  56. package/dist/types/types/Schema.d.mts +12 -0
  57. package/dist/workerd/converters/Converters.mjs.map +1 -1
  58. package/dist/workerd/core/AdvancedMethods.mjs +1 -1
  59. package/dist/workerd/core/AdvancedMethods.mjs.map +1 -1
  60. package/dist/workerd/core/EnvapterBase.mjs +1 -1
  61. package/dist/workerd/core/EnvapterBase.mjs.map +1 -1
  62. package/dist/workerd/core/EnvironmentMethods.mjs.map +1 -1
  63. package/dist/workerd/core/PrimitiveMethods.mjs +1 -1
  64. package/dist/workerd/core/PrimitiveMethods.mjs.map +1 -1
  65. package/dist/workerd/infra/Debug.mjs.map +1 -1
  66. package/dist/workerd/infra/Error.mjs.map +1 -1
  67. package/dist/workerd/sources/ManualEnvSource.mjs.map +1 -1
  68. package/dist/workerd/sources/WorkerEnvSource.mjs.map +1 -1
  69. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { EnvapterBase } from './EnvapterBase';\nimport { debugWarn } from '../infra/Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, ProfilesConfig } from '../types';\n\n/**\n * Environment types supported by Envapter\n * @public\n */\nexport enum Environment {\n Development,\n Staging,\n Production,\n Test\n}\n\n// Keys carrying the environment name, highest precedence first. Checked in order until the first with a non-empty value is found, or defaulting to development if none are set.\nconst ENV_KEYS = ['ENVIRONMENT', 'ENV', 'NODE_ENV', 'MODE'] as const;\n\nfunction parseEnvironment(raw: string): Environment | undefined {\n switch (raw.toLowerCase()) {\n case 'production':\n return Environment.Production;\n case 'staging':\n return Environment.Staging;\n case 'test':\n return Environment.Test;\n case 'development':\n return Environment.Development;\n default:\n return undefined;\n }\n}\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n protected static _environment: Environment | undefined;\n protected static _environmentExplicitlySet = false;\n protected static _profiles: ProfilesConfig | undefined;\n\n protected static determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n this._environment = env;\n this._environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n this._environment = parseEnvironment(env) ?? Environment.Development;\n this._environmentExplicitlySet = true;\n return;\n }\n\n const raw = this.firstEnvKeyValue((key) => {\n const value = this.config.get(key);\n return typeof value === 'string' ? value : undefined;\n });\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n this._environment = parsed;\n }\n\n private static firstEnvKeyValue(read: (key: string) => string | undefined): string | undefined {\n for (const key of ENV_KEYS) {\n const value = read(key);\n if (value !== undefined && value.length > 0) return value;\n }\n return undefined;\n }\n\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (this._environment === undefined) {\n this.determineEnvironment();\n }\n return this._environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n this.determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n EnvironmentMethods.determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n\n protected static override refreshCache(): void {\n // If the env was inferred (not user-set), reset it so re-hydration re-determines\n // from current state. If the user explicitly set Envapter.environment = X, preserve\n // that value through the refresh. The immediate re-hydration inside super.refreshCache()\n // will use it for cascade selection.\n if (!this._environmentExplicitlySet) this._environment = undefined;\n super.refreshCache();\n }\n\n /**\n * Reads the source's raw vars (not `this.config`, which would recurse: cascade selection runs\n * before the `.env` load). `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.\n * @internal\n */\n protected static getCascadeEnvironment(): Environment {\n if (this._environment !== undefined) return this._environment;\n\n const vars = EnvapterBase._source.readVars();\n const raw = this.firstEnvKeyValue((key) => vars[key]);\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n }\n\n /**\n * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence\n * order (highest precedence first). Missing files are silently filtered.\n *\n * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):\n * `.env.${env}.local` \\> `.env.${env}` \\> `.env.local` \\> `.env`\n *\n * This differs from dotenv-flow / Next.js convention which puts `.env.local` above\n * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files\n * (`.env.production`) are authoritative for that environment regardless of whether a\n * stray `.env.local` is present.\n * @internal\n */\n protected static buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => this.resolveAgainstBase(name))\n .filter((p) => this.sourceFileExists(p));\n }\n\n private static normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n }\n\n /**\n * Override the base implementation to layer the dotenv-flow cascade + any\n * `Envapter.configureProfiles` overrides on top of `_envPaths` when the user has NOT\n * explicitly set `envPaths`.\n *\n * Precedence (passed to dotenv with first-wins semantics):\n * 1. profile-configured paths for the current env (if any)\n * 2. `.env.${env}.local`\n * 3. `.env.${env}`\n * 4. `.env.local`\n * 5. `.env`\n *\n * If `useDefaults: false` is set on the profiles config, only (1) is loaded, no cascade.\n * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).\n * @internal\n */\n protected static override resolveEffectivePaths(): string[] {\n if (this._envPathsExplicitlySet) return this._envPaths.map((p) => this.resolveAgainstBase(p));\n\n const env = this.getCascadeEnvironment();\n const profileEntry = this._profiles?.[env];\n const profilePaths = this.normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !this.sourceFileExists(this.resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = this._profiles?.useDefaults === false ? [] : this.buildCascadePaths(env);\n return [...profilePaths.map((p) => this.resolveAgainstBase(p)), ...cascade];\n }\n}\n"],"mappings":"kJAUA,IAAY,EAAL,SAAA,EAAA,OACH,GAAA,EAAA,YAAA,GAAA,cACA,EAAA,EAAA,QAAA,GAAA,UACA,EAAA,EAAA,WAAA,GAAA,aACA,EAAA,EAAA,KAAA,GAAA,QACJ,EAAA,CAAA,CAAA,EAGA,MAAM,EAAW,CAAC,cAAe,MAAO,WAAY,MAAM,EAE1D,SAAS,EAAiB,EAAsC,CAC5D,OAAQ,EAAI,YAAY,EAAxB,CACI,IAAK,aACD,MAAA,GACJ,IAAK,UACD,MAAA,GACJ,IAAK,OACD,MAAA,GACJ,IAAK,cACD,MAAA,GACJ,QACI,MACR,CACJ,CAMA,IAAa,EAAb,MAAa,UAA2B,CAAa,CACjD,OAAiB,aACjB,OAAiB,0BAA4B,GAC7C,OAAiB,UAEjB,OAAiB,qBAAqB,EAAkC,CACpE,GAAI,OAAO,GAAQ,SAAU,CACzB,KAAK,aAAe,EACpB,KAAK,0BAA4B,GACjC,MACJ,CACA,GAAI,OAAO,GAAQ,SAAU,CACzB,KAAK,aAAe,EAAiB,CAAG,GAAA,EACxC,KAAK,0BAA4B,GACjC,MACJ,CAEA,IAAM,EAAM,KAAK,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,CACJ"}
1
+ {"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { EnvapterBase } from './EnvapterBase';\nimport { debugWarn } from '../infra/Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, ProfilesConfig } from '../types';\n\n/**\n * Environment types supported by Envapter\n *\n * The following keys are checked in order until the first with a non-empty value is found, or defaulting to development if none are set:\n * - `ENVIRONMENT`\n * - `ENV`\n * - `NODE_ENV`\n * - `MODE`\n *\n * @public\n */\nexport enum Environment {\n /** The default when no environment variable names a known environment. */\n Development,\n /** Selected when an environment variable reads `staging`. */\n Staging,\n /** Selected when an environment variable reads `production`. */\n Production,\n /** Selected when an environment variable reads `test`. */\n Test\n}\n\n// Keys carrying the environment name, highest precedence first. Checked in order until the first with a non-empty value is found, or defaulting to development if none are set.\nconst ENV_KEYS = ['ENVIRONMENT', 'ENV', 'NODE_ENV', 'MODE'] as const;\n\nfunction parseEnvironment(raw: string): Environment | undefined {\n switch (raw.toLowerCase()) {\n case 'production':\n return Environment.Production;\n case 'staging':\n return Environment.Staging;\n case 'test':\n return Environment.Test;\n case 'development':\n return Environment.Development;\n default:\n return undefined;\n }\n}\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n protected static _environment: Environment | undefined;\n protected static _environmentExplicitlySet = false;\n protected static _profiles: ProfilesConfig | undefined;\n\n protected static determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n this._environment = env;\n this._environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n this._environment = parseEnvironment(env) ?? Environment.Development;\n this._environmentExplicitlySet = true;\n return;\n }\n\n const raw = this.firstEnvKeyValue((key) => {\n const value = this.config.get(key);\n return typeof value === 'string' ? value : undefined;\n });\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n this._environment = parsed;\n }\n\n private static firstEnvKeyValue(read: (key: string) => string | undefined): string | undefined {\n for (const key of ENV_KEYS) {\n const value = read(key);\n if (value !== undefined && value.length > 0) return value;\n }\n return undefined;\n }\n\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (this._environment === undefined) {\n this.determineEnvironment();\n }\n return this._environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n this.determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n EnvironmentMethods.determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n\n protected static override refreshCache(): void {\n // If the env was inferred (not user-set), reset it so re-hydration re-determines\n // from current state. If the user explicitly set Envapter.environment = X, preserve\n // that value through the refresh. The immediate re-hydration inside super.refreshCache()\n // will use it for cascade selection.\n if (!this._environmentExplicitlySet) this._environment = undefined;\n super.refreshCache();\n }\n\n /**\n * Reads the source's raw vars (not `this.config`, which would recurse: cascade selection runs\n * before the `.env` load). `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.\n * @internal\n */\n protected static getCascadeEnvironment(): Environment {\n if (this._environment !== undefined) return this._environment;\n\n const vars = EnvapterBase._source.readVars();\n const raw = this.firstEnvKeyValue((key) => vars[key]);\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n }\n\n /**\n * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence\n * order (highest precedence first). Missing files are silently filtered.\n *\n * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):\n * `.env.${env}.local` \\> `.env.${env}` \\> `.env.local` \\> `.env`\n *\n * This differs from dotenv-flow / Next.js convention which puts `.env.local` above\n * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files\n * (`.env.production`) are authoritative for that environment regardless of whether a\n * stray `.env.local` is present.\n * @internal\n */\n protected static buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => this.resolveAgainstBase(name))\n .filter((p) => this.sourceFileExists(p));\n }\n\n private static normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n }\n\n /**\n * Override the base implementation to layer the dotenv-flow cascade + any\n * `Envapter.configureProfiles` overrides on top of `_envPaths` when the user has NOT\n * explicitly set `envPaths`.\n *\n * Precedence (passed to dotenv with first-wins semantics):\n * 1. profile-configured paths for the current env (if any)\n * 2. `.env.${env}.local`\n * 3. `.env.${env}`\n * 4. `.env.local`\n * 5. `.env`\n *\n * If `useDefaults: false` is set on the profiles config, only (1) is loaded, no cascade.\n * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).\n * @internal\n */\n protected static override resolveEffectivePaths(): string[] {\n if (this._envPathsExplicitlySet) return this._envPaths.map((p) => this.resolveAgainstBase(p));\n\n const env = this.getCascadeEnvironment();\n const profileEntry = this._profiles?.[env];\n const profilePaths = this.normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !this.sourceFileExists(this.resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = this._profiles?.useDefaults === false ? [] : this.buildCascadePaths(env);\n return [...profilePaths.map((p) => this.resolveAgainstBase(p)), ...cascade];\n }\n}\n"],"mappings":"kJAiBA,IAAY,EAAL,SAAA,EAAA,OAEH,GAAA,EAAA,YAAA,GAAA,cAEA,EAAA,EAAA,QAAA,GAAA,UAEA,EAAA,EAAA,WAAA,GAAA,aAEA,EAAA,EAAA,KAAA,GAAA,QACJ,EAAA,CAAA,CAAA,EAGA,MAAM,EAAW,CAAC,cAAe,MAAO,WAAY,MAAM,EAE1D,SAAS,EAAiB,EAAsC,CAC5D,OAAQ,EAAI,YAAY,EAAxB,CACI,IAAK,aACD,MAAA,GACJ,IAAK,UACD,MAAA,GACJ,IAAK,OACD,MAAA,GACJ,IAAK,cACD,MAAA,GACJ,QACI,MACR,CACJ,CAMA,IAAa,EAAb,MAAa,UAA2B,CAAa,CACjD,OAAiB,aACjB,OAAiB,0BAA4B,GAC7C,OAAiB,UAEjB,OAAiB,qBAAqB,EAAkC,CACpE,GAAI,OAAO,GAAQ,SAAU,CACzB,KAAK,aAAe,EACpB,KAAK,0BAA4B,GACjC,MACJ,CACA,GAAI,OAAO,GAAQ,SAAU,CACzB,KAAK,aAAe,EAAiB,CAAG,GAAA,EACxC,KAAK,0BAA4B,GACjC,MACJ,CAEA,IA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AG,CAAO,CAC9E,CACJ"}
@@ -1,2 +1,2 @@
1
- import{debugWarn as e}from"../infra/Debug.mjs";import{EnvapterBase as t}from"./EnvapterBase.mjs";import{EnvironmentMethods as n}from"./EnvironmentMethods.mjs";import{BuiltInConverters as r}from"../converters/BuiltInConverters.mjs";import{ValueConverter as i}from"../converters/ValueConverter.mjs";import{TemplateResolver as a}from"../engine/TemplateResolver.mjs";var o=class o extends n{static service=new o;static templateResolver=new a(o.service);static valueConverter=new i(o.service);isStrict(){return t.strict}static _get(t,n,i){let{key:a,value:o}=this.resolveKeyInput(t);if(this.treatAsMissing(o))return i!==void 0&&e(`${a} not found, using fallback ${String(i)}`),i;let s=o,c=this.templateResolver.resolveTemplate(a,String(s)),l;return l=n===1?r.number(c,i):n===2?r.boolean(c,i):n===3?r.bigint(c,i):n===4?r.symbol(c,i):r.string(c,i),l}static get(e,t){return this._get(e,0,t)}get(e,t){return o._get(e,0,t)}static getNumber(e,t){return this._get(e,1,t)}getNumber(e,t){return o._get(e,1,t)}static getBoolean(e,t){return this._get(e,2,t)}getBoolean(e,t){return o._get(e,2,t)}static getBigInt(e,t){return this._get(e,3,t)}getBigInt(e,t){return o._get(e,3,t)}static getSymbol(e,t){return this._get(e,4,t)}getSymbol(e,t){return o._get(e,4,t)}};export{o as PrimitiveMethods};
1
+ import{debugWarn as e}from"../infra/Debug.mjs";import{EnvapterBase as t}from"./EnvapterBase.mjs";import{EnvironmentMethods as n}from"./EnvironmentMethods.mjs";import{BuiltInConverters as r}from"../converters/BuiltInConverters.mjs";import{ValueConverter as i}from"../converters/ValueConverter.mjs";import{TemplateResolver as a}from"../engine/TemplateResolver.mjs";var o=class o extends n{static service=new o;static templateResolver=new a(o.service);static valueConverter=new i(o.service);isStrict(){return t.strict}static resolveForMirror(e,t){return this.templateResolver.resolveTemplate(e,t)}static _get(t,n,i){let{key:a,value:o}=this.resolveKeyInput(t);if(this.treatAsMissing(o))return e(i===void 0?`${a} is missing or empty`:`${a} is missing or empty, using fallback ${String(i)}`),i;let s=o,c=this.templateResolver.resolveTemplate(a,String(s)),l;return l=n===1?r.number(c,i):n===2?r.boolean(c,i):n===3?r.bigint(c,i):n===4?r.symbol(c,i):r.string(c,i),l}static get(e,t){return this._get(e,0,t)}get(e,t){return o._get(e,0,t)}static getNumber(e,t){return this._get(e,1,t)}getNumber(e,t){return o._get(e,1,t)}static getBoolean(e,t){return this._get(e,2,t)}getBoolean(e,t){return o._get(e,2,t)}static getBigInt(e,t){return this._get(e,3,t)}getBigInt(e,t){return o._get(e,3,t)}static getSymbol(e,t){return this._get(e,4,t)}getSymbol(e,t){return o._get(e,4,t)}};export{o as PrimitiveMethods};
2
2
  //# sourceMappingURL=PrimitiveMethods.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitiveMethods.mjs","names":[],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { EnvapterBase } from './EnvapterBase';\nimport { EnvironmentMethods } from './EnvironmentMethods';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugWarn } from '../infra/Debug';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\n/**\n * @internal\n */\nenum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {\n private static readonly service = new PrimitiveMethods();\n protected static readonly templateResolver: TemplateResolver = new TemplateResolver(PrimitiveMethods.service);\n protected static readonly valueConverter: ValueConverter = new ValueConverter(PrimitiveMethods.service);\n\n // Read `EnvapterBase.strict` directly: `PrimitiveMethods._strict` would resolve to the\n // BaseClass default because a `Envapter.strict = true` write lands as an own-property\n // on `Envapter`, which is a descendant of `PrimitiveMethods`, not an ancestor.\n isStrict(): boolean {\n return EnvapterBase.strict;\n }\n\n private static _get<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n ): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = this.resolveKeyInput(key);\n if (this.treatAsMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} not found, using fallback ${String(def)}`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n const rawVal = value as string | number | boolean | undefined;\n\n const parsed = this.templateResolver.resolveTemplate(resolvedKey, String(rawVal));\n\n let result: EnvVarReturnType;\n if (type === Primitive.Number) result = BuiltInConverters.number(parsed, def as number) as EnvVarReturnType;\n else if (type === Primitive.Boolean)\n result = BuiltInConverters.boolean(parsed, def as boolean) as EnvVarReturnType;\n else if (type === Primitive.BigInt)\n result = BuiltInConverters.bigint(parsed, def as bigint) as EnvVarReturnType;\n else if (type === Primitive.Symbol)\n result = BuiltInConverters.symbol(parsed, def as symbol) as EnvVarReturnType;\n else result = BuiltInConverters.string(parsed, def as string) as EnvVarReturnType;\n\n return result;\n }\n\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return this._get(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return PrimitiveMethods._get(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return this._get(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return PrimitiveMethods._get(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return this._get(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return PrimitiveMethods._get(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return this._get(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return PrimitiveMethods._get(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return this._get(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return PrimitiveMethods._get(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"2WAuBA,IAAa,EAAb,MAAa,UAAyB,CAA8C,CAChF,OAAwB,QAAU,IAAI,E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AAK,EAAA,EAAuB,CAAG,CAC3D,CAOA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,KAAK,KAAK,EAAA,EAAuB,CAAG,CAC/C,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAiB,KAAK,EAAA,EAAuB,CAAG,CAC3D,CACJ"}
1
+ {"version":3,"file":"PrimitiveMethods.mjs","names":[],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { EnvapterBase } from './EnvapterBase';\nimport { EnvironmentMethods } from './EnvironmentMethods';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugWarn } from '../infra/Debug';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\n/**\n * @internal\n */\nenum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {\n private static readonly service = new PrimitiveMethods();\n protected static readonly templateResolver: TemplateResolver = new TemplateResolver(PrimitiveMethods.service);\n protected static readonly valueConverter: ValueConverter = new ValueConverter(PrimitiveMethods.service);\n\n // Read `EnvapterBase.strict` directly: `PrimitiveMethods._strict` would resolve to the\n // BaseClass default because a `Envapter.strict = true` write lands as an own-property\n // on `Envapter`, which is a descendant of `PrimitiveMethods`, not an ancestor.\n isStrict(): boolean {\n return EnvapterBase.strict;\n }\n\n protected static override resolveForMirror(key: string, value: string): string {\n return this.templateResolver.resolveTemplate(key, value);\n }\n\n private static _get<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n ): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = this.resolveKeyInput(key);\n if (this.treatAsMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} is missing or empty, using fallback ${String(def)}`);\n else debugWarn(`${resolvedKey} is missing or empty`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n const rawVal = value as string | number | boolean | undefined;\n\n const parsed = this.templateResolver.resolveTemplate(resolvedKey, String(rawVal));\n\n let result: EnvVarReturnType;\n if (type === Primitive.Number) result = BuiltInConverters.number(parsed, def as number) as EnvVarReturnType;\n else if (type === Primitive.Boolean)\n result = BuiltInConverters.boolean(parsed, def as boolean) as EnvVarReturnType;\n else if (type === Primitive.BigInt)\n result = BuiltInConverters.bigint(parsed, def as bigint) as EnvVarReturnType;\n else if (type === Primitive.Symbol)\n result = BuiltInConverters.symbol(parsed, def as symbol) as EnvVarReturnType;\n else result = BuiltInConverters.string(parsed, def as string) as EnvVarReturnType;\n\n return result;\n }\n\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return this._get(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return PrimitiveMethods._get(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return this._get(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return PrimitiveMethods._get(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return this._get(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return PrimitiveMethods._get(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return this._get(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return PrimitiveMethods._get(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return this._get(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return PrimitiveMethods._get(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"2WAuBA,IAAa,EAAb,MAAa,UAAyB,CAA8C,CAChF,OAAwB,QAAU,IAAI,EACtC,OAA0B,iBAAqC,IAAI,EAAiB,EAAiB,OAAO,EAC5G,OAA0B,eAAiC,IAAI,EAAe,EAAiB,OAAO,EAKtG,UAAoB,CAChB,OAAO,EAAa,MACxB,CAEA,OAA0B,iBAAiB,EAAa,EAAuB,CAC3E,OA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O,KAAK,KAAK,EAAA,EAAuB,CAAG,CAC/C,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAiB,KAAK,EAAA,EAAuB,CAAG,CAC3D,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Debug.mjs","names":[],"sources":["../../../src/infra/Debug.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from './Error';\nimport { readRuntimeEnv, writeRuntimeLine } from './runtime';\n\n/**\n * Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.\n * `warn` covers signals that might indicate misconfiguration: failed file reads,\n * unresolved templates (when not strict), fallback values used in place of missing\n * env. `verbose` adds every loaded file, per-file key count, per-key load lines, and\n * effective-paths / cache-rebuild notices.\n * @public\n */\nexport type DebugLevel = 'silent' | 'warn' | 'verbose';\n\nconst VALID_LEVELS: ReadonlySet<string> = new Set<DebugLevel>(['silent', 'warn', 'verbose']);\n\nlet currentLevel: DebugLevel = 'silent';\nlet initialized = false;\n\nfunction isDebugLevel(value: string | undefined): value is DebugLevel {\n return value !== undefined && VALID_LEVELS.has(value);\n}\n\n// Reads `ENVAPT_DEBUG` lazily on first access. Setter wins after that.\nfunction resolveLevel(): DebugLevel {\n if (!initialized) {\n const fromEnv = readRuntimeEnv().ENVAPT_DEBUG;\n currentLevel = isDebugLevel(fromEnv) ? fromEnv : 'silent';\n initialized = true;\n }\n return currentLevel;\n}\n\n/** @internal */\nexport function setDebugLevel(level: DebugLevel): void {\n if (!isDebugLevel(level)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Invalid debug level \"${String(level)}\". Expected 'silent' | 'warn' | 'verbose'.`\n );\n }\n currentLevel = level;\n initialized = true;\n}\n\n/** @internal */\nexport function getDebugLevel(): DebugLevel {\n return resolveLevel();\n}\n\n/** @internal */\nexport function resetDebugForTesting(): void {\n currentLevel = 'silent';\n initialized = false;\n}\n\n/** @internal */\nexport function debugWarn(message: string): void {\n const level = resolveLevel();\n if (level === 'warn' || level === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n\n/** @internal */\nexport function debugVerbose(message: string): void {\n if (resolveLevel() === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n"],"mappings":"+GAaA,MAAM,EAAoC,IAAI,IAAgB,CAAC,SAAU,OAAQ,SAAS,CAAC,EAE3F,IAAI,EAA2B,SAC3B,EAAc,GAElB,SAAS,EAAa,EAAgD,CAClE,OAAO,IAAU,IAAA,IAAa,EAAa,IAAI,CAAK,CACxD,CAGA,SAAS,GAA2B,CAChC,GAAI,CAAC,EAAa,CACd,IAAM,EAAU,EAAe,CAAC,CAAC,aACjC,EAAe,EAAa,CAAO,EAAI,EAAU,SACjD,EAAc,EAClB,CACA,OAAO,CACX,CAGA,SAAgB,EAAc,EAAyB,CACnD,GAAI,CAAC,EAAa,CAAK,EACnB,MAAM,IAAI,EAAA,IAEN,wBAAwB,OAAO,CAAK,EAAE,2CAC1C,EAEJ,EAAe,EACf,EAAc,EAClB,CAGA,SAAgB,GAA4B,CACxC,OAAO,EAAa,CACxB,CASA,SAAgB,EAAU,EAAuB,CAC7C,IAAM,EAAQ,EAAa,GACvB,IAAU,QAAU,IAAU,YAC9B,EAAiB,YAAY,GAAS,CAE9C,CAGA,SAAgB,EAAa,EAAuB,CAC5C,EAAa,IAAM,WACnB,EAAiB,YAAY,GAAS,CAE9C"}
1
+ {"version":3,"file":"Debug.mjs","names":[],"sources":["../../../src/infra/Debug.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from './Error';\nimport { readRuntimeEnv, writeRuntimeLine } from './runtime';\n\n/**\n * Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.\n * `warn` covers signals that might indicate misconfiguration, failed file reads,\n * unresolved templates (when not strict), and any read of a missing or empty variable\n * (whether it returns a fallback or `undefined`). `verbose` adds every loaded file,\n * per-file key count, per-key load lines, and effective-paths / cache-rebuild notices.\n * @public\n */\nexport type DebugLevel = 'silent' | 'warn' | 'verbose';\n\nconst VALID_LEVELS: ReadonlySet<string> = new Set<DebugLevel>(['silent', 'warn', 'verbose']);\n\nlet currentLevel: DebugLevel = 'silent';\nlet initialized = false;\n\nfunction isDebugLevel(value: string | undefined): value is DebugLevel {\n return value !== undefined && VALID_LEVELS.has(value);\n}\n\n// Reads `ENVAPT_DEBUG` lazily on first access. Setter wins after that.\nfunction resolveLevel(): DebugLevel {\n if (!initialized) {\n const fromEnv = readRuntimeEnv().ENVAPT_DEBUG;\n currentLevel = isDebugLevel(fromEnv) ? fromEnv : 'silent';\n initialized = true;\n }\n return currentLevel;\n}\n\n/** @internal */\nexport function setDebugLevel(level: DebugLevel): void {\n if (!isDebugLevel(level)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Invalid debug level \"${String(level)}\". Expected 'silent' | 'warn' | 'verbose'.`\n );\n }\n currentLevel = level;\n initialized = true;\n}\n\n/** @internal */\nexport function getDebugLevel(): DebugLevel {\n return resolveLevel();\n}\n\n/** @internal */\nexport function resetDebugForTesting(): void {\n currentLevel = 'silent';\n initialized = false;\n}\n\n/** @internal */\nexport function debugWarn(message: string): void {\n const level = resolveLevel();\n if (level === 'warn' || level === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n\n/** @internal */\nexport function debugVerbose(message: string): void {\n if (resolveLevel() === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n"],"mappings":"+GAaA,MAAM,EAAoC,IAAI,IAAgB,CAAC,SAAU,OAAQ,SAAS,CAAC,EAE3F,IAAI,EAA2B,SAC3B,EAAc,GAElB,SAAS,EAAa,EAAgD,CAClE,OAAO,IAAU,IAAA,IAAa,EAAa,IAAI,CAAK,CACxD,CAGA,SAAS,GAA2B,CAChC,GAAI,CAAC,EAAa,CACd,IAAM,EAAU,EAAe,CAAC,CAAC,aACjC,EAAe,EAAa,CAAO,EAAI,EAAU,SACjD,EAAc,EAClB,CACA,OAAO,CACX,CAGA,SAAgB,EAAc,EAAyB,CACnD,GAAI,CAAC,EAAa,CAAK,EACnB,MAAM,IAAI,EAAA,IAEN,wBAAwB,OAAO,CAAK,EAAE,2CAC1C,EAEJ,EAAe,EACf,EAAc,EAClB,CAGA,SAAgB,GAA4B,CACxC,OAAO,EAAa,CACxB,CASA,SAAgB,EAAU,EAAuB,CAC7C,IAAM,EAAQ,EAAa,GACvB,IAAU,QAAU,IAAU,YAC9B,EAAiB,YAAY,GAAS,CAE9C,CAGA,SAAgB,EAAa,EAAuB,CAC5C,EAAa,IAAM,WACnB,EAAiB,YAAY,GAAS,CAE9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Error.mjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"AAGA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CACnC,KAMA,OAEA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
1
+ {"version":3,"file":"Error.mjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"AAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"ManualEnvSource.mjs","names":[],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAClD,cAAyB,GACzB,KAEA,YAAY,EAA+B,CACvC,KAAK,KAAO,EAAqB,CAAI,CACzC,CAEA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
1
+ {"version":3,"file":"ManualEnvSource.mjs","names":[],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from `vars`. Non-string values are JSON-stringified so the converters still apply. */\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n /** Returns a snapshot clone of the provided object as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA+B,CACvC,KAAK,KAAO,EAAqB,CAAI,CACzC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerEnvSource.mjs","names":[],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAClD,cAAyB,GACzB,KAEA,YAAY,EAA8B,CACtC,KAAK,KAAO,EAAqB,CAAG,CACxC,CAEA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
1
+ {"version":3,"file":"WorkerEnvSource.mjs","names":[],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from the Workers `env` binding. Non-string values are JSON-stringified, so they must be JSON-serializable. */\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n /** Returns a snapshot clone of the `env` binding as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA8B,CACtC,KAAK,KAAO,EAAqB,CAAG,CACxC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "envapt",
3
3
  "type": "module",
4
- "version": "7.0.0",
4
+ "version": "7.0.1",
5
5
  "description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
6
6
  "types": "./dist/types/index.d.mts",
7
7
  "exports": {