{"version":3,"sources":["../../src/types/index.ts","../../shared/errors/libMessages.ts","../../shared/errors/index.ts","../../src/regex.ts","../../src/core/parser/helpers.ts","../../src/config.ts","../../src/core/parser/parser.ts","../../src/core/parser/index.ts","../../src/utils/index.ts","../../src/core/validator.ts","../../src/utils/system-env.ts","../../src/core/utils.ts","../../src/core/resolver.ts","../../shared/constants.ts","../../shared/utils/index.ts","../../shared/configLoader.ts","../../src/envx/fileExt.ts","../../src/envx/index.ts"],"names":["EnvxError","message","LIB_ERROR_MESSAGES","path","lineNumber","type","key","value","allowed","ERROR_MESSAGES","TERNARY_REGEX","VALID_ENUM_VALUE_REGEX","SCHEMA_BLOCK_HEADER_REGEX","VALID_SCHEMA_KEY_REGEX","isSafeString","str","isSchemaHeader","line","assertNoTrailingPunctuation","raw","forbiddenChars","lastChar","applyDefault","target","values","num","splitKeyValue","eqIndex","stripQuotes","first","last","findCommentIndex","inSingleQuote","inDoubleQuote","i","char","handleMultilineLine","multilineKey","multilineBuffer","env","trimmedLine","quoteIndex","beforeQuote","allowedSchemaTypes","BUILTIN_SCHEMA","parseSchemaLine","getNextLine","rawKey","rawValue","descLines","currentLine","nextLine","parsed","v","parseSchemaHeader","schema","parseEnvLine","trimmedValue","parseEnvx","content","lines","currentSchemaKey","originalLine","result","commentIndex","isMultilineStart","toBoolean","_throw","checkOnly","normalized","isValid","isEmail","inferTypeFromValue","fillMissingSchemaEntries","completedSchema","resolveEnvFilePath","inputPath","parseValueByType","validateEnv","parsedMap","required","defValue","WHITELISTED_SYSTEM_KEYS","readSystemEnv","loadEnvxFromString","noValidate","parsedSchema","fullSchema","effectiveSchema","resolved","resolveEnvx","filteredResult","isTernary","cleaned","hasInterpolation","getEnvVar","name","rawEnv","resolvedEnv","resolving","depth","resolveValue","sysVal","entries","entry","currentKey","prev","resolveTernary","resolveInterpolation","_","varName","match","operator","compareValueRaw","trueValRaw","falseValRaw","actualValue","compareValue","actualValStr","condition","cmp","trueVal","falseVal","parseIfLiteral","META_JSON_FILE_NAME","JSON_CONFIG_FILE_NAME","DEFAULT_ENV_FILE","DEFAULT_ENVX_FILE","parseEnvxMetaFile","filePath","resolvedPath","fs","err","defaultUserConfig","isValidUserConfig","obj","loadUserConfig","jsonPath","existsSync","readFileSync","parsed_config","errMsg","fileExts","checkFileExt","filePathOrExt","baseName","ext","throwIfUnknownExtUsed","config","readFileSafe","e","getEnv","metaFileFullPath","metaFilePath","envFilePath","absPath","envContent","envxSchema","getEnvx","envxFilePath","loadEnvx","envVars"],"mappings":"gEAsBO,IAAMA,CAAAA,CAAN,cAAwB,KAAM,CACnC,WAAA,CAAYC,CAAAA,CAAiB,CAC3B,MAAMA,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,YACd,CACF,EC3BO,IAAMC,CAAAA,CAAqB,CAChC,gBAAA,CAAmBC,CAAAA,EACjB,CAAA,mCAAA,EAAsCA,CAAI,GAE5C,eAAA,CAAiB,CAACC,CAAAA,CAAoBC,CAAAA,GACpC,CAAA,KAAA,EAAQD,CAAAA,CAAa,CAAC,CAAA,oBAAA,EAAuBC,CAAI,CAAA,EAAA,CAAA,CAEnD,SAAA,CAAW,CACT,aAAA,CAAe,CAACC,EAAaC,CAAAA,GAC3B,CAAA,mBAAA,EAAsBD,CAAG,CAAA,mCAAA,EAAsCC,CAAK,CAAA,EAAA,CAAA,CACtE,cAAA,CAAgB,CAACD,CAAAA,CAAaC,CAAAA,GAC5B,CAAA,qBAAA,EAAwBD,CAAG,CAAA,4CAAA,EAA+CC,CAAK,KACjF,iBAAA,CAAoBD,CAAAA,EAClB,CAAA,iCAAA,EAAoCA,CAAG,CAAA,iCAAA,CAAA,CACzC,WAAA,CAAa,CAACA,CAAAA,CAAaC,CAAAA,CAAeC,CAAAA,GACxC,CAAA,wBAAA,EAA2BF,CAAG,CAAA,oBAAA,EAAuBE,CAAAA,CAAQ,KAC3D,IACF,CAAC,CAAA,gBAAA,EAAmBD,CAAK,CAAA,EAAA,CAAA,CAC3B,YAAA,CAA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string\"\r\n  | \"number\"\r\n  | \"boolean\"\r\n  | \"enum\"\r\n  | \"email\"\r\n  | \"url\";\r\n\r\nexport interface EnvxVarSchema {\r\n  type: EnvxType;\r\n  required?: boolean;\r\n  default?: string | number | boolean;\r\n  values?: Array<string>;\r\n  deprecated?: boolean;\r\n  description?: string;\r\n}\r\n\r\nexport type EnvxSchema = Record<string, EnvxVarSchema>;\r\nexport type EnvxVarKey = keyof EnvxVarSchema;\r\n\r\nexport type EnvxResult = Record<string, string | number | boolean>;\r\n\r\nexport class EnvxError extends Error {\r\n  constructor(message: string) {\r\n    super(message);\r\n    this.name = \"EnvxError\";\r\n  }\r\n}\r\n\r\n// OTHERS\r\nexport type ParsedLine = { key: string; value: string };","export const LIB_ERROR_MESSAGES = {\r\n  fileDoesNotExist: (path: string) =>\r\n    `The specified file does not exist: ${path}`,\r\n\r\n  unsupportedType: (lineNumber: number, type: string) =>\r\n    `Line ${lineNumber + 1}: Unsupported type \"${type}\".`,\r\n\r\n  validator: {\r\n    invalidNumber: (key: string, value: string) =>\r\n      `Invalid value for \"${key}\": expected a number but received \"${value}\".`,\r\n    invalidBoolean: (key: string, value: string) =>\r\n      `Invalid boolean for \"${key}\": expected \"true\" or \"false\" but received \"${value}\".`,\r\n    missingEnumValues: (key: string) =>\r\n      `Enum values are not defined for \"${key}\". Please specify allowed values.`,\r\n    invalidEnum: (key: string, value: string, allowed: string[]) =>\r\n      `Invalid enum value for \"${key}\": expected one of [${allowed.join(\r\n        \", \"\r\n      )}] but received \"${value}\".`,\r\n    invalidEmail: (key: string, value: string) =>\r\n      `Invalid email format for \"${key}\": received \"${value}\". Please provide a valid email address.`,\r\n    invalidUrl: (key: string, value: string) =>\r\n      `Invalid URL format for \"${key}\": received \"${value}\". Please provide a valid URL.`,\r\n    unsupportedType: (key: string, type: string) =>\r\n      `Unsupported type \"${type}\" specified for \"${key}\".`,\r\n    requiredMissing: (key: string) =>\r\n      `Required environment variable \"${key}\" is missing and has no default value.`,\r\n  },\r\n\r\n  resolver: {\r\n    circularDependency: (key: string) =>\r\n      `Circular dependency detected while resolving \"${key}\".\\n→ Check for variables referencing each other in a loop.`,\r\n    interpolationFailed: (key: string, type: \"interpolation\" | \"ternary\" = \"interpolation\") =>\r\n      `Failed to resolve variable \"${key}\". No value found for ${type}.`,\r\n    requiredMissingInResolve: (key: string) =>\r\n      `Environment variable \"${key}\" is not set and no default is defined.\\n→ Define \"${key}\" in your .envx file or provide a default value in the schema.`,\r\n  },\r\n\r\n  parser: {\r\n    schemaBlockEmpty: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: Schema block name cannot be empty.`,\r\n    schemaKeyDuplicate: (lineNumber: number, key: string) =>\r\n      `Line ${\r\n        lineNumber + 1\r\n      }: Schema key \"${key}\" is already defined. Duplicate schema definitions are not allowed.`,\r\n    typeAlreadyDefined: (lineNumber: number) =>\r\n      `Line ${\r\n        lineNumber + 1\r\n      }: \"type\" is already defined for this variable. You cannot redefine it.`,\r\n    unknownSchemaProperty: (lineNumber: number, key: string) =>\r\n      `Line ${lineNumber + 1}: Unknown schema property \"${key}\".`,\r\n    missingDelimiter: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: Missing \"=\" delimiter in assignment.`,\r\n    variableNameEmpty: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: Variable name cannot be empty.`,\r\n    typeRequiredBeforeDefault: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: \"type\" must be defined before \"default\".`,\r\n    defaultMustBeNumber: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: Default value must be a valid number.`,\r\n    defaultMustBeBoolean: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: Default value must be \"true\" or \"false\".`,\r\n    defaultNotInEnum: (lineNumber: number, value: string) =>\r\n      `Line ${lineNumber + 1}: Default \"${value}\" is not in enum values.`,\r\n    invalidValuesJson: (lineNumber: number) =>\r\n      `Line ${lineNumber + 1}: \"values\" must be a valid JSON string array.`,\r\n  },\r\n};\r\n","import { LIB_ERROR_MESSAGES } from \"./libMessages\";\r\n\r\nexport const ERROR_MESSAGES = {\r\n  lib: LIB_ERROR_MESSAGES,\r\n  cli: {},\r\n};\r\n","export const TERNARY_REGEX = /^\\s*\\$\\{([^}]+)\\}(?:\\s*(==|!=)\\s*([\"'])?([^\"']+)\\3)?\\s*\\?\\s*([\"'])?([^\"']+?)\\5?\\s*:\\s*([\"'])?([^\"']+?)\\7?\\s*$/;\r\n\r\nexport const VALID_ENUM_VALUE_REGEX = /^[a-zA-Z0-9_\\-\\.]+$/;\r\nexport const SCHEMA_BLOCK_HEADER_REGEX = /^\\[.*\\]$/;\r\nexport const VALID_SCHEMA_KEY_REGEX = /^[a-zA-Z0-9_\\-\\.]+$/;\r\n","import { ERROR_MESSAGES } from \"../../../shared/errors\";\r\nimport { SCHEMA_BLOCK_HEADER_REGEX, VALID_ENUM_VALUE_REGEX } from \"../../regex\";\r\nimport { EnvxError, EnvxVarSchema, ParsedLine } from \"../../types\";\r\n\r\nfunction isSafeString(str: string): boolean {\r\n  return VALID_ENUM_VALUE_REGEX.test(str);\r\n}\r\n\r\nfunction isSchemaHeader(line: string): boolean {\r\n  return SCHEMA_BLOCK_HEADER_REGEX.test(line);\r\n}\r\n\r\nconst assertNoTrailingPunctuation = (raw: string, lineNumber: number) => {\r\n  const forbiddenChars = [\r\n    \",\",\r\n    \";\",\r\n    \":\",\r\n    \".\",\r\n    \"-\",\r\n    \"?\",\r\n    \"!\",\r\n    \"|\",\r\n    \"\\\\\",\r\n    \"/\",\r\n    \"(\",\r\n    \")\",\r\n    \"{\",\r\n    \"<\",\r\n    \">\",\r\n    \"`\",\r\n    \"~\",\r\n    \"=\",\r\n  ];\r\n\r\n  const lastChar = raw.trimEnd().slice(-1);\r\n\r\n  if (forbiddenChars.includes(lastChar)) {\r\n    throw new EnvxError(\r\n      `[envx:error] Line ${\r\n        lineNumber + 1\r\n      }: Value ends with a suspicious character (${lastChar}). Please remove unnecessary character  at the end.`\r\n    );\r\n  }\r\n};\r\n\r\nfunction applyDefault(\r\n  value: string,\r\n  lineNumber: number,\r\n  target: EnvxVarSchema\r\n) {\r\n  const { type, values } = target;\r\n  if (!type) {\r\n    // [THROW_ERR_MSG] => Throws error if \"type\" is missing before \"default\".\r\n    throw new EnvxError(\r\n      ERROR_MESSAGES.lib.parser.typeRequiredBeforeDefault(lineNumber)\r\n    );\r\n  }\r\n\r\n  switch (type) {\r\n    case \"number\":\r\n      const num = Number(value);\r\n      if (isNaN(num)) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.parser.defaultMustBeNumber(lineNumber)\r\n        );\r\n      }\r\n      target.default = num;\r\n      break;\r\n\r\n    case \"boolean\":\r\n      if (value !== \"true\" && value !== \"false\") {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.parser.defaultMustBeBoolean(lineNumber)\r\n        );\r\n      }\r\n      target.default = value === \"true\";\r\n      break;\r\n\r\n    case \"enum\":\r\n      if (!values || !values.includes(value)) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.parser.defaultNotInEnum(lineNumber, value)\r\n        );\r\n      }\r\n      target.default = value;\r\n      break;\r\n\r\n    default:\r\n      target.default = value;\r\n  }\r\n}\r\n\r\nfunction splitKeyValue(line: string, lineNumber: number): [string, string] {\r\n  const eqIndex = line.indexOf(\"=\");\r\n  if (eqIndex === -1) {\r\n    // * Splits a line into key and value by first '=' character.\r\n    // * Throws error if '=' not found.\r\n    throw new EnvxError(ERROR_MESSAGES.lib.parser.missingDelimiter(lineNumber));\r\n  }\r\n  return [line.slice(0, eqIndex), line.slice(eqIndex + 1)];\r\n}\r\n\r\nfunction stripQuotes(value: string): string {\r\n  const first = value[0];\r\n  const last = value[value.length - 1];\r\n  if ((first === `\"` && last === `\"`) || (first === `'` && last === `'`)) {\r\n    return value.slice(1, -1);\r\n  }\r\n  return value;\r\n}\r\n\r\n/**\r\n * Finds index of unquoted '#' symbol to identify inline comment start.\r\n */\r\nfunction findCommentIndex(line: string): number {\r\n  let inSingleQuote = false;\r\n  let inDoubleQuote = false;\r\n\r\n  for (let i = 0; i < line.length; i++) {\r\n    const char = line[i];\r\n    if (char === '\"' && !inSingleQuote) {\r\n      inDoubleQuote = !inDoubleQuote;\r\n    } else if (char === \"'\" && !inDoubleQuote) {\r\n      inSingleQuote = !inSingleQuote;\r\n    } else if (char === \"#\" && !inSingleQuote && !inDoubleQuote) {\r\n      return i;\r\n    }\r\n  }\r\n  return -1; // if comment dont have return `-1`\r\n}\r\n\r\n// func(handleMultilineLine) => its purpose is to handle multi-line strings\r\nfunction handleMultilineLine(\r\n  line: string,\r\n  multilineKey: string,\r\n  multilineBuffer: string[],\r\n  env: ParsedLine[]\r\n): { multilineKey: string | null; multilineBuffer: string[] } {\r\n  const trimmedLine = line.trim();\r\n  if (trimmedLine.includes('\"\"\"')) {\r\n    const quoteIndex = trimmedLine.indexOf('\"\"\"');\r\n    const beforeQuote = trimmedLine.slice(0, quoteIndex);\r\n    multilineBuffer.push(beforeQuote.trimEnd());\r\n    env.push({ key: multilineKey, value: multilineBuffer.join(\"\\n\") });\r\n    return { multilineKey: null, multilineBuffer: [] };\r\n  } else {\r\n    multilineBuffer.push(line);\r\n    return { multilineKey, multilineBuffer };\r\n  }\r\n}\r\n\r\nexport {\r\n  isSafeString,\r\n  isSchemaHeader,\r\n  assertNoTrailingPunctuation,\r\n  applyDefault,\r\n  splitKeyValue,\r\n  stripQuotes,\r\n  findCommentIndex,\r\n  handleMultilineLine,\r\n};\r\n","import { EnvxSchema, EnvxType } from \"./types\";\r\n\r\nexport const allowedSchemaTypes: Array<EnvxType> = [\r\n  \"string\",\r\n  \"number\",\r\n  \"boolean\",\r\n  \"enum\",\r\n  \"email\",\r\n  \"url\",\r\n];\r\n\r\n// [COMING_SOON_FEATURES] future features\r\nexport const BUILTIN_SCHEMA: EnvxSchema = {\r\n};\r\n","import { ERROR_MESSAGES } from \"../../../shared/errors\";\r\nimport { allowedSchemaTypes } from \"../../config\";\r\nimport { EnvxError, EnvxSchema, EnvxVarSchema } from \"../../types\";\r\n\r\nimport {\r\n  isSafeString,\r\n  assertNoTrailingPunctuation,\r\n  applyDefault,\r\n  splitKeyValue,\r\n  stripQuotes,\r\n} from \"./helpers\";\r\nimport { VALID_SCHEMA_KEY_REGEX } from \"../../regex\";\r\n\r\n/**\r\n * Parses a line inside a schema block and applies it to the given schema variable.\r\n *\r\n * Supported keys: type, required, default, values\r\n *\r\n * @param {string} line - The line inside the schema block.\r\n * @param {number} lineNumber - Current line number (zero-based).\r\n * @param {EnvxVarSchema} target - Target schema object for this variable.\r\n *\r\n * @throws {EnvxError} For unknown keys or invalid value formats.\r\n */\r\nfunction parseSchemaLine(\r\n  line: string,\r\n  lineNumber: number,\r\n  target: EnvxVarSchema & { __pendingDefault?: string },\r\n  getNextLine?: () => string | null\r\n) {\r\n  const [rawKey, rawValue] = splitKeyValue(line, lineNumber);\r\n  const key = rawKey.trim();\r\n  const value: any = stripQuotes(rawValue.trim());\r\n\r\n  if (key === \"description\" && rawValue.trim().startsWith('\"\"\"')) {\r\n    let descLines = [];\r\n    let currentLine = rawValue.trim().slice(3);\r\n\r\n    if (currentLine.endsWith('\"\"\"')) {\r\n      target.description = currentLine.slice(0, -3);\r\n      return;\r\n    }\r\n\r\n    descLines.push(currentLine);\r\n\r\n    while (getNextLine) {\r\n      const nextLine = getNextLine();\r\n      if (nextLine === null) {\r\n        throw new EnvxError(\r\n          `Line ${lineNumber + 1}: Unterminated multiline description.`\r\n        );\r\n      }\r\n      if (nextLine.endsWith('\"\"\"')) {\r\n        descLines.push(nextLine.slice(0, -3));\r\n        break;\r\n      } else {\r\n        descLines.push(nextLine);\r\n      }\r\n    }\r\n\r\n    target.description = descLines.join(\"\\n\");\r\n    return;\r\n  }\r\n\r\n  switch (key) {\r\n    case \"required\":\r\n      target.required = value === \"true\";\r\n      break;\r\n\r\n    case \"type\":\r\n      if (target.type !== undefined) {\r\n        // [THROW_ERR_MSG] => Throw if \"type\" is defined more than once for a schema\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.parser.typeAlreadyDefined(lineNumber)\r\n        );\r\n      }\r\n      if (!allowedSchemaTypes.includes(value)) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.unsupportedType(lineNumber, value)\r\n        );\r\n      }\r\n      target.type = value as EnvxVarSchema[\"type\"];\r\n      break;\r\n\r\n    case \"default\":\r\n      if (target.type == \"enum\" && !target.values) {\r\n        target.__pendingDefault = value;\r\n      } else {\r\n        applyDefault(value, lineNumber, target);\r\n      }\r\n      break;\r\n\r\n    case \"values\":\r\n      try {\r\n        const parsed = JSON.parse(value);\r\n\r\n        const isValidArray =\r\n          Array.isArray(parsed) &&\r\n          parsed.length <= 25 &&\r\n          parsed.every((v) => typeof v === \"string\" && isSafeString(v));\r\n\r\n        if (!isValidArray) {\r\n          throw new EnvxError(\r\n            `[envx:error] Line ${\r\n              lineNumber + 1\r\n            }: \"values\" must be a JSON array (max 25) of safe strings. Allowed characters: a-z, A-Z, 0-9, _, -, .`\r\n          );\r\n        }\r\n\r\n        target.values = parsed;\r\n\r\n        if (target.__pendingDefault) {\r\n          applyDefault(target.__pendingDefault, lineNumber, target);\r\n          // delete (target as any).__pendingDefault;\r\n        }\r\n      } catch (e) {\r\n        // [THROW_ERR_MSG] => Throw if \"values\" is not a valid JSON array of strings\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.parser.invalidValuesJson(lineNumber)\r\n        );\r\n      }\r\n      break;\r\n\r\n    // Note: 'deprecated' and 'description' are mostly for editor tooling (like VSCode extensions),\r\n    // they don't affect runtime behavior directly.\r\n    case \"deprecated\":\r\n      target.deprecated = value;\r\n      break;\r\n    case \"description\":\r\n      target.description = value;\r\n      break;\r\n\r\n    default:\r\n      // [THROW_ERR_MSG] => Throws error if a schema property is unknown.\r\n      throw new EnvxError(\r\n        ERROR_MESSAGES.lib.parser.unknownSchemaProperty(lineNumber, key)\r\n      );\r\n  }\r\n}\r\n\r\nfunction parseSchemaHeader(\r\n  line: string,\r\n  lineNumber: number,\r\n  schema: EnvxSchema\r\n): string {\r\n  const key = line.slice(1, -1).trim();\r\n\r\n  if (!key) {\r\n    // [THROW_ERR_MSG] => Throws error if a schema block name is empty.\r\n    throw new EnvxError(ERROR_MESSAGES.lib.parser.schemaBlockEmpty(lineNumber));\r\n  }\r\n\r\n  if (!VALID_SCHEMA_KEY_REGEX.test(key)) {\r\n    throw new EnvxError(\r\n      `[envx:error] Line ${lineNumber + 1}: ` +\r\n        `Schema block name \"${key}\" contains invalid characters. ` +\r\n        `Only letters, numbers, underscore (_), hyphen (-), and dot (.) are allowed.`\r\n    );\r\n  }\r\n\r\n  if (schema[key]) {\r\n    // [THROW_ERR_MSG] => Throws error if a schema key is duplicated.\r\n    throw new EnvxError(\r\n      ERROR_MESSAGES.lib.parser.schemaKeyDuplicate(lineNumber, key)\r\n    );\r\n  }\r\n\r\n  schema[key] = schema[key] ?? {};\r\n  return key;\r\n}\r\n\r\nfunction parseEnvLine(\r\n  line: string,\r\n  lineNumber: number\r\n): {\r\n  key: string;\r\n  value: string;\r\n  isMultilineStart: boolean;\r\n} {\r\n  const [rawKey, rawValue] = splitKeyValue(line, lineNumber);\r\n  const key = rawKey.trim();\r\n\r\n  if (!key) {\r\n    // [THROW_ERR_MSG] => Throws error if environment variable name is empty.\r\n    throw new EnvxError(\r\n      ERROR_MESSAGES.lib.parser.variableNameEmpty(lineNumber)\r\n    );\r\n  }\r\n\r\n  const trimmedValue = rawValue.trim();\r\n\r\n  if (trimmedValue.startsWith('\"\"\"')) {\r\n    if (trimmedValue.endsWith('\"\"\"') && trimmedValue.length > 6) {\r\n      return {\r\n        key,\r\n        value: trimmedValue.slice(3, -3),\r\n        isMultilineStart: false,\r\n      };\r\n    }\r\n\r\n    return {\r\n      key,\r\n      value: trimmedValue.slice(3),\r\n      isMultilineStart: true,\r\n    };\r\n  }\r\n  assertNoTrailingPunctuation(trimmedValue, lineNumber);\r\n\r\n  return {\r\n    key,\r\n    value: stripQuotes(trimmedValue),\r\n    isMultilineStart: false,\r\n  };\r\n}\r\n\r\nexport { parseEnvLine, parseSchemaHeader, parseSchemaLine };\r\n","import { EnvxError, EnvxSchema, ParsedLine } from \"../../types\";\r\n\r\nimport {\r\n  isSchemaHeader,\r\n  findCommentIndex,\r\n  handleMultilineLine,\r\n} from \"./helpers\";\r\n\r\nimport { parseEnvLine, parseSchemaHeader, parseSchemaLine } from \"./parser\";\r\n\r\ninterface ParseResult {\r\n  env: ParsedLine[];\r\n  schema: EnvxSchema;\r\n}\r\n\r\n/**\r\n * Parses a custom `.envx` file format into structured environment variables and their schema.\r\n *\r\n * This parser supports:\r\n * - Standard key=value pairs, with automatic trimming and comment removal.\r\n * - Multiline values wrapped in triple quotes (`\"\"\"`), preserving line breaks.\r\n * - Optional schema sections defined via headers like `[VARNAME]`, with key-specific metadata.\r\n *\r\n * Example `.envx` content:\r\n * ```\r\n * API_KEY=\"abc123\"\r\n *\r\n * [API_KEY]\r\n * type = string\r\n * required = true\r\n * ```\r\n *\r\n * @param {string} content - The raw string content of a `.envx` file to parse.\r\n * @returns {{ env: ParsedLine[], schema: EnvxSchema }} An object containing:\r\n *   - `env`: An array of parsed environment variables as `{ key, value }`.\r\n *   - `schema`: An object mapping variable names to their schema definitions.\r\n *\r\n * @throws {EnvxError} Throws if:\r\n *   - Syntax errors are encountered (e.g., malformed lines, invalid schema headers).\r\n *   - Inline comments appear improperly in schema headers.\r\n *   - Required attributes are missing from schema definitions.\r\n *\r\n * @remarks\r\n * The parser maintains state to handle multi-line strings seamlessly,\r\n * buffering lines until triple quotes close the value.\r\n * Schema parsing supports metadata like type, required flags, defaults, and deprecation.\r\n */\r\nfunction parseEnvx(content: string): ParseResult {\r\n  const lines = content.split(/\\r?\\n/);\r\n  const env: ParsedLine[] = [];\r\n  const schema: EnvxSchema = {};\r\n\r\n  let currentSchemaKey: string | null = null;\r\n  let multilineKey: string | null = null;\r\n  let multilineBuffer: string[] = [];\r\n\r\n  for (let i = 0; i < lines.length; i++) {\r\n    let originalLine = lines[i];\r\n\r\n    let trimmedLine = originalLine.trim();\r\n    if (!trimmedLine || trimmedLine.startsWith(\"#\")) continue;\r\n    if (multilineKey) {\r\n      const result = handleMultilineLine(\r\n        originalLine,\r\n        multilineKey,\r\n        multilineBuffer,\r\n        env\r\n      );\r\n\r\n      multilineBuffer = result.multilineBuffer;\r\n      multilineKey = result.multilineKey;\r\n      continue;\r\n    }\r\n\r\n    // >_ Remove inline comments\r\n    const commentIndex = findCommentIndex(originalLine);\r\n    if (commentIndex !== -1) {\r\n      originalLine = originalLine.slice(0, commentIndex);\r\n    }\r\n    trimmedLine = originalLine.trim();\r\n\r\n    if (isSchemaHeader(trimmedLine)) {\r\n      if (commentIndex > -1 && commentIndex > originalLine.indexOf(\"]\")) {\r\n        throw new EnvxError(\r\n          `[envx:error] Line ${\r\n            i + 1\r\n          }: Schema header line cannot contain inline comments.`\r\n        );\r\n      }\r\n      currentSchemaKey = parseSchemaHeader(trimmedLine, i, schema);\r\n      continue;\r\n    }\r\n\r\n    if (currentSchemaKey) {\r\n      parseSchemaLine(trimmedLine, i, schema[currentSchemaKey], () => {\r\n        i++;\r\n        if (i >= lines.length) return null;\r\n        let nextLine = lines[i].trim();\r\n        return nextLine;\r\n      });\r\n      continue;\r\n    }\r\n\r\n    const { key, value, isMultilineStart } = parseEnvLine(trimmedLine, i);\r\n    if (isMultilineStart) {\r\n      multilineKey = key;\r\n      multilineBuffer.push(value);\r\n    } else {\r\n      env.push({ key, value });\r\n    }\r\n  }\r\n\r\n  if (multilineKey) {\r\n    throw new EnvxError(\r\n      `[envx:error] End of file reached but multiline value for key \"${multilineKey}\" was not closed with triple quotes (\"\"\").`\r\n    );\r\n  }\r\n  return { env, schema };\r\n}\r\n\r\nexport { parseEnvx };\r\n","import { ERROR_MESSAGES } from \"../../shared/errors\";\r\nimport { BUILTIN_SCHEMA } from \"../config\";\r\nimport { EnvxError, EnvxSchema, EnvxVarSchema } from \"../types\";\r\nimport path from \"path\";\r\n\r\nexport function toBoolean(\r\n  value: any,\r\n  key?: string,\r\n  _throw = false,\r\n  checkOnly = false\r\n): boolean {\r\n  const normalized = typeof value === \"string\" ? value.toLowerCase() : value;\r\n\r\n  const isValid =\r\n    normalized === true ||\r\n    normalized === false ||\r\n    normalized === \"true\" ||\r\n    normalized === \"false\" ||\r\n    normalized === 1 ||\r\n    normalized === 0;\r\n\r\n  if (checkOnly) return isValid;\r\n\r\n  if (!isValid) {\r\n    if (_throw) {\r\n      throw new EnvxError(\r\n        ERROR_MESSAGES.lib.validator.invalidBoolean(key || \"\", value)\r\n      );\r\n    }\r\n    return false;\r\n  }\r\n\r\n  if (normalized === true || normalized === \"true\" || normalized === 1) {\r\n    return true;\r\n  }\r\n\r\n  return false;\r\n}\r\n\r\nexport const isEmail = (value: string) => {\r\n  return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value);\r\n};\r\n\r\nfunction inferTypeFromValue(value: any): EnvxVarSchema[\"type\"] {\r\n  const isBoolean = toBoolean(value, \"\", false, true);\r\n  if (isBoolean) return \"boolean\";\r\n  if (!isNaN(Number(value)) && value !== \"\" && value !== null) return \"number\";\r\n  return \"string\";\r\n}\r\n\r\n/**\r\n * Completes the environment variable schema by adding entries for variables\r\n * present in the `.envx` file but missing in the user-defined schema.\r\n *\r\n * For each variable without an explicit schema:\r\n * - Infers the type from its value (string, number, boolean).\r\n * - Marks it as optional (`required: false`).\r\n *\r\n * Also merges built-in environment variable schemas.\r\n *\r\n * This ensures every environment variable has a schema definition,\r\n * even if not explicitly declared by the user.\r\n *\r\n * @param env - List of environment variables from `.envx` with their values.\r\n * @param schema - User-defined environment schema with explicit variable definitions.\r\n * @returns A fully completed schema including built-in, user-defined, and inferred entries.\r\n */\r\nexport function fillMissingSchemaEntries(\r\n  env: { key: string; value: any }[],\r\n  schema: EnvxSchema\r\n): EnvxSchema {\r\n  const completedSchema: EnvxSchema = { ...BUILTIN_SCHEMA, ...schema };\r\n\r\n  env.forEach(({ key, value }) => {\r\n    if (!completedSchema[key]) {\r\n      completedSchema[key] = {\r\n        type: inferTypeFromValue(value),\r\n        required: false,\r\n      };\r\n    }\r\n  });\r\n\r\n  return completedSchema;\r\n}\r\n\r\nexport function addBuiltinEnvVarsToSchema(schema?: EnvxSchema): EnvxSchema {\r\n  return {\r\n    ...BUILTIN_SCHEMA,\r\n    ...(schema || {}),\r\n  };\r\n}\r\n\r\n/**\r\n * Resolves a given file path to an absolute path.\r\n *\r\n * If the input path is already absolute, it is returned as-is.\r\n * Otherwise, it is resolved relative to the current working directory.\r\n *\r\n * @param inputPath - The file path to resolve.\r\n * @returns The absolute file path.\r\n */\r\nexport function resolveEnvFilePath(inputPath: string): string {\r\n  return path.isAbsolute(inputPath)\r\n    ? inputPath\r\n    : path.resolve(process.cwd(), inputPath);\r\n}\r\n","import { ERROR_MESSAGES } from \"../../shared/errors\";\r\nimport { EnvxSchema, EnvxResult, EnvxType, EnvxError, ParsedLine } from \"../types\";\r\nimport { isEmail, toBoolean } from \"../utils\";\r\n\r\n/**\r\n * Parses a single environment variable value according to its declared type.\r\n *\r\n * @param key - The environment variable name.\r\n * @param value - The raw string value to parse.\r\n * @param type - Expected type of the value.\r\n * @param values - Allowed enum values if type is \"enum\".\r\n * @throws {EnvxError} When the value doesn't conform to the expected type.\r\n */\r\nfunction parseValueByType(\r\n  key: string,\r\n  value: string,\r\n  type: EnvxType,\r\n  values?: string[]\r\n): string | number | boolean {\r\n  switch (type) {\r\n    case \"string\":\r\n      return value;\r\n\r\n    case \"number\": {\r\n      const num = Number(value);\r\n      if (isNaN(num)) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.validator.invalidNumber(key, value)\r\n        );\r\n      }\r\n      return num;\r\n    }\r\n\r\n    case \"boolean\": {\r\n      return toBoolean(value, key, true);\r\n    }\r\n\r\n    case \"enum\": {\r\n      if (!values?.length) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.validator.missingEnumValues(key)\r\n        );\r\n      }\r\n      if (!values.includes(value)) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.validator.invalidEnum(key, value, values)\r\n        );\r\n      }\r\n      return value;\r\n    }\r\n\r\n    case \"email\": {\r\n      if (!isEmail(value)) {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.validator.invalidEmail(key, value)\r\n        );\r\n      }\r\n      return value;\r\n    }\r\n\r\n    case \"url\": {\r\n      try {\r\n        new URL(value);\r\n        return value;\r\n      } catch {\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.validator.invalidUrl(key, value)\r\n        );\r\n      }\r\n    }\r\n\r\n    default:\r\n      throw new EnvxError(\r\n        ERROR_MESSAGES.lib.validator.unsupportedType(key, type)\r\n      );\r\n  }\r\n}\r\n\r\n/**\r\n * Validates and parses environment variables based on the provided schema.\r\n * @throws {EnvxError} When required variables are missing or values are invalid.\r\n */\r\nexport function validateEnv(\r\n  parsed: ParsedLine[],\r\n  schema?: EnvxSchema\r\n): EnvxResult {\r\n  const result: EnvxResult = {};\r\n  const parsedMap = new Map(parsed.map(({ key, value }) => [key, value]));\r\n\r\n  for (const key in schema) {\r\n    const { type, required, default: defValue, values } = schema[key];\r\n    const rawValue = parsedMap.get(key);\r\n\r\n    if (rawValue !== undefined) {\r\n      // >_if value have check type\r\n      result[key] = parseValueByType(\r\n        key,\r\n        rawValue,\r\n        type,\r\n        type === \"enum\" ? values : undefined\r\n      );\r\n      continue;\r\n    }\r\n\r\n    if (defValue !== undefined) {\r\n      result[key] = parseValueByType(\r\n        key,\r\n        String(defValue),\r\n        type,\r\n        type === \"enum\" ? values : undefined\r\n      );\r\n      continue;\r\n    }\r\n\r\n    if (required) {\r\n      throw new EnvxError(ERROR_MESSAGES.lib.validator.requiredMissing(key));\r\n    }\r\n  }\r\n\r\n  for (const [key, value] of parsedMap.entries()) {\r\n    if (!(key in result)) {\r\n      result[key] = value;\r\n    }\r\n  }\r\n\r\n  return result;\r\n}\r\n","export const WHITELISTED_SYSTEM_KEYS = new Set([\r\n  \"NODE_ENV\",\r\n  \"CI\",\r\n  \"VERCEL_ENV\",\r\n]);\r\n\r\nexport function readSystemEnv(key: string): string | undefined {\r\n  if (WHITELISTED_SYSTEM_KEYS.has(key)) {\r\n\r\n    // [SUPPORT_SYSTEM_ENV] NODE.JS\r\n    if (typeof process !== \"undefined\" && process.env) {\r\n      return process.env[key];\r\n    }\r\n  }\r\n  return undefined;\r\n}\r\n","import { parseEnvx } from \"./parser\";\r\nimport { validateEnv } from \"./validator\";\r\nimport { EnvxSchema, EnvxResult, ParsedLine } from \"../types\";\r\nimport { resolveEnvx } from \"./resolver\";\r\nimport { fillMissingSchemaEntries } from \"../utils\";\r\nimport { TERNARY_REGEX } from \"../regex\";\r\n\r\nexport function loadEnvxFromString(\r\n  content: string,\r\n  schema?: EnvxSchema,\r\n  noValidate?: boolean\r\n): { result: EnvxResult; schema?: EnvxSchema; rawEnv: ParsedLine[] } {\r\n  const { env, schema: parsedSchema } = parseEnvx(content);\r\n\r\n  const fullSchema = fillMissingSchemaEntries(env, parsedSchema);\r\n\r\n  const effectiveSchema: EnvxSchema | undefined = schema\r\n    ? { ...fullSchema, ...schema }\r\n    : Object.keys(fullSchema).length > 0\r\n    ? fullSchema\r\n    : undefined;\r\n\r\n  const resolved = resolveEnvx(env, effectiveSchema);\r\n\r\n  /**\r\n   * Filter out variables that are not explicitly defined in the effective schema.\r\n   *\r\n   * This is important because some variables (like system environment variables\r\n   * such as NODE_ENV) may be injected at runtime (e.g., via process.env)\r\n   * and resolved correctly by `resolveEnvx`, even if the user did not define them\r\n   * in the .envx file or the schema.\r\n   *\r\n   * By filtering them out here, we ensure that only user-declared variables\r\n   * are included in the final result. This avoids polluting the generated output\r\n   * with runtime-only values that are not relevant to the declared configuration.\r\n   *\r\n   * Note: These values can still be *used* (e.g., in interpolations or ternaries),\r\n   * but they won't appear in the final output unless explicitly declared in schema.\r\n   */\r\n  const filteredResult = Object.fromEntries(\r\n    Object.entries(resolved).filter(\r\n      ([key]) => effectiveSchema?.[key] !== undefined\r\n    )\r\n  );\r\n\r\n  if (effectiveSchema && !noValidate) {\r\n    const validatedEnvs = validateEnv(\r\n      Object.entries(filteredResult).map(([key, value]) => ({ key, value })),\r\n      effectiveSchema\r\n    );\r\n\r\n    return { result: validatedEnvs, schema: effectiveSchema, rawEnv: [] };\r\n  }\r\n\r\n  return { result: filteredResult, schema: effectiveSchema, rawEnv: env };\r\n}\r\n\r\nexport function isTernary(str: string): boolean {\r\n  const cleaned = str.trim();\r\n  return TERNARY_REGEX.test(cleaned);\r\n}\r\nexport function hasInterpolation(str: string): boolean {\r\n  return typeof str === \"string\" && str.includes(\"${\");\r\n}\r\n","import { ERROR_MESSAGES } from \"../../shared/errors\";\r\nimport { TERNARY_REGEX } from \"../regex\";\r\nimport { EnvxError, EnvxSchema } from \"../types\";\r\nimport { toBoolean } from \"../utils\";\r\nimport { readSystemEnv } from \"../utils/system-env\";\r\nimport { hasInterpolation, isTernary } from \"./utils\";\r\n\r\ntype EnvMap = Record<string, any>;\r\n\r\nfunction getEnvVar(\r\n  name: string,\r\n  rawEnv: EnvMap,\r\n  resolvedEnv: EnvMap,\r\n  resolving: Set<string>,\r\n  depth: number,\r\n  type: \"interpolation\" | \"ternary\" = \"interpolation\"\r\n): any {\r\n  if (resolvedEnv[name] !== undefined) {\r\n    return resolvedEnv[name];\r\n  } else if (rawEnv[name] !== undefined) {\r\n    return resolveValue(\r\n      rawEnv[name],\r\n      rawEnv,\r\n      resolvedEnv,\r\n      resolving,\r\n      name,\r\n      depth + 1\r\n    );\r\n  } else {\r\n    const sysVal = readSystemEnv(name);\r\n    if (sysVal !== undefined) {\r\n      resolvedEnv[name] = sysVal;\r\n      return sysVal;\r\n    }\r\n    throw new EnvxError(\r\n      ERROR_MESSAGES.lib.resolver.interpolationFailed(name, type)\r\n    );\r\n  }\r\n}\r\n\r\n/**\r\n * Resolves environment variables by evaluating interpolations and conditional expressions.\r\n *\r\n * The function:\r\n * 1. Merges raw entries with schema defaults.\r\n * 2. Recursively resolves variable references.\r\n * 3. Detects circular references and throws an error if found.\r\n * 4. Validates required variables defined in the schema.\r\n *\r\n * @param entries - List of key-value pairs representing environment variables.\r\n * @param schema - Optional schema defining defaults and required flags.\r\n * @returns A map of resolved environment variables.\r\n * @throws EnvxError if circular dependency or max resolution depth is exceeded.\r\n */\r\nexport function resolveEnvx(\r\n  entries: { key: string; value: any }[],\r\n  schema?: EnvxSchema\r\n): EnvMap {\r\n  const rawEnv: EnvMap = {};\r\n  const resolvedEnv: EnvMap = {};\r\n\r\n  for (const entry of entries) {\r\n    rawEnv[entry.key] = entry.value;\r\n  }\r\n\r\n  if (schema) {\r\n    for (const key in schema) {\r\n      if (rawEnv[key] === undefined && schema[key].default !== undefined) {\r\n        rawEnv[key] = schema[key].default;\r\n      }\r\n    }\r\n  }\r\n\r\n  const resolving = new Set<string>();\r\n\r\n  for (const key of Object.keys(rawEnv)) {\r\n    resolvedEnv[key] = resolveValue(\r\n      rawEnv[key],\r\n      rawEnv,\r\n      resolvedEnv,\r\n      resolving,\r\n      key,\r\n      0\r\n    );\r\n  }\r\n\r\n  if (schema) {\r\n    for (const key in schema) {\r\n      if (schema[key].required && rawEnv[key] === undefined) {\r\n        // [THROW_ERR_MSG] => Throws error if a required env variable is missing and no default is defined.\r\n        throw new EnvxError(\r\n          ERROR_MESSAGES.lib.resolver.requiredMissingInResolve(key)\r\n        );\r\n      }\r\n    }\r\n  }\r\n  return resolvedEnv;\r\n}\r\n\r\n/**\r\n * Resolves the value of an environment variable by replacing references\r\n * to other variables and evaluating conditional expressions.\r\n *\r\n * Stops and throws an error if a variable refers to itself directly or indirectly,\r\n * or if the resolution goes too deep to avoid infinite loops.\r\n *\r\n * @param rawValue The original value (may contain references or conditions).\r\n * @param rawEnv All raw environment variables as key-value pairs.\r\n * @param resolvedEnv Variables already resolved.\r\n * @param resolving The set of variables currently being resolved (used to detect cycles).\r\n * @param currentKey The key of the variable currently being processed.\r\n * @param depth How deep the recursion currently is (to limit max depth).\r\n * @returns The final resolved value with all references and conditions evaluated.\r\n * @throws EnvxError If circular references or maximum recursion depth are detected.\r\n */\r\nfunction resolveValue(\r\n  rawValue: any,\r\n  rawEnv: EnvMap,\r\n  resolvedEnv: EnvMap,\r\n  resolving: Set<string>,\r\n  currentKey: string,\r\n  depth: number = 0\r\n): any {\r\n  if (typeof rawValue !== \"string\") return rawValue;\r\n\r\n  // [circularDependency] => Detects circular dependencies to prevent infinite resolution loops.\r\n  if (resolving.has(currentKey)) {\r\n    throw new EnvxError(\r\n      ERROR_MESSAGES.lib.resolver.circularDependency(currentKey)\r\n    );\r\n  }\r\n\r\n  const MAX_DEPTH = 10;\r\n  // [maxDepthExceeded] => Enforces a maximum recursion depth to prevent infinite resolution loops.\r\n  if (depth > MAX_DEPTH) {\r\n    throw new EnvxError(\r\n      `[envx:error] Max resolution depth exceeded while resolving \"${currentKey}\".`\r\n    );\r\n  }\r\n\r\n  resolving.add(currentKey);\r\n\r\n  let result = rawValue;\r\n  let prev: string;\r\n\r\n  while (typeof result === \"string\") {\r\n    prev = result;\r\n\r\n    if (isTernary(result)) {\r\n      result = resolveTernary(\r\n        result,\r\n        rawEnv,\r\n        resolvedEnv,\r\n        resolving,\r\n        depth + 1\r\n      );\r\n      continue;\r\n    }\r\n\r\n    if (hasInterpolation(result)) {\r\n      result = resolveInterpolation(\r\n        result,\r\n        rawEnv,\r\n        resolvedEnv,\r\n        resolving,\r\n        depth + 1\r\n      );\r\n      continue;\r\n    }\r\n\r\n    if (result === prev) break;\r\n  }\r\n\r\n  resolving.delete(currentKey);\r\n  return result;\r\n}\r\n\r\nfunction resolveInterpolation(\r\n  str: string,\r\n  rawEnv: EnvMap,\r\n  resolvedEnv: EnvMap,\r\n  resolving: Set<string>,\r\n  depth: number\r\n): string {\r\n  return str.replace(/\\${([^}]+)}/g, (_, varName) => {\r\n    const name = varName.trim();\r\n\r\n    return String(getEnvVar(name, rawEnv, resolvedEnv, resolving, depth));\r\n  });\r\n}\r\n\r\nfunction resolveTernary(\r\n  str: string,\r\n  rawEnv: EnvMap,\r\n  resolvedEnv: EnvMap,\r\n  resolving: Set<string>,\r\n  depth: number\r\n): string {\r\n  const cleaned = str?.trim();\r\n  const match = cleaned.match(TERNARY_REGEX);\r\n\r\n  if (!match) return str;\r\n\r\n  const [\r\n    ,\r\n    varName,\r\n    operator,\r\n    ,\r\n    compareValueRaw,\r\n    ,\r\n    trueValRaw,\r\n    ,\r\n    falseValRaw,\r\n  ] = match;\r\n  const name = varName?.trim();\r\n\r\n  // [DEPRACTED]\r\n  // const actualValue =\r\n  //   resolvedEnv[name] !== undefined\r\n  //     ? resolvedEnv[name]\r\n  //     : resolveValue(\r\n  //         rawEnv[name],\r\n  //         rawEnv,\r\n  //         resolvedEnv,\r\n  //         resolving,\r\n  //         name,\r\n  //         depth + 1\r\n  //       );\r\n\r\n  const actualValue = getEnvVar(\r\n    name,\r\n    rawEnv,\r\n    resolvedEnv,\r\n    resolving,\r\n    depth,\r\n    \"ternary\"\r\n  );\r\n\r\n  let compareValue = compareValueRaw?.trim();\r\n  if (\r\n    (compareValue?.startsWith('\"') && compareValue?.endsWith('\"')) ||\r\n    (compareValue?.startsWith(\"'\") && compareValue?.endsWith(\"'\"))\r\n  ) {\r\n    compareValue = compareValue.slice(1, -1);\r\n  }\r\n\r\n  const actualValStr = String(actualValue);\r\n\r\n  let condition: boolean;\r\n  // only accept operators => `==`, `!=`\r\n  if (operator === \"==\" || operator === \"!=\") {\r\n    const cmp = actualValStr === compareValue;\r\n    condition = operator === \"==\" ? cmp : !cmp;\r\n  } else {\r\n    condition = toBoolean(actualValue);\r\n  }\r\n\r\n  const trueVal = trueValRaw.trim();\r\n  const falseVal = falseValRaw.trim();\r\n  return condition ? parseIfLiteral(trueVal) : parseIfLiteral(falseVal);\r\n}\r\n\r\n// ----------------------------------- //\r\n// ---  Resolver helper functions  --- //\r\n// ----------------------------------- //\r\n\r\nfunction parseIfLiteral(value: string): any {\r\n  if (value === \"true\") return true;\r\n  if (value === \"false\") return false;\r\n  if (!isNaN(Number(value))) return Number(value);\r\n  return value;\r\n}\r\n","export const META_JSON_FILE_NAME = \"envx.meta.json\";\r\nexport const JSON_CONFIG_FILE_NAME = \"envx.config.json\";\r\nexport const DEFAULT_ENV_FILE = \".env\";\r\nexport const DEFAULT_ENVX_FILE = \".envx\";\r\n","import fs from \"fs\";\r\nimport path from \"path\";\r\nimport { EnvxSchema } from \"../../src/types\";\r\nimport { META_JSON_FILE_NAME } from \"../constants\";\r\n\r\n/**\r\n * Reads `envx.meta.json` file and returns it as a typed EnvxSchema object.\r\n * @param filePath - Path to envx.meta.json (default: ./envx.meta.json)\r\n */\r\nexport function parseEnvxMetaFile(filePath?: string): EnvxSchema {\r\n  const resolvedPath =\r\n    filePath ?? path.join(process.cwd(), META_JSON_FILE_NAME);\r\n\r\n  if (!fs.existsSync(resolvedPath)) {\r\n    throw new Error(`Meta file not found at ${resolvedPath}`);\r\n  }\r\n\r\n  const raw = fs.readFileSync(resolvedPath, \"utf-8\");\r\n\r\n  try {\r\n    const parsed: EnvxSchema = JSON.parse(raw);\r\n    return parsed;\r\n  } catch (err) {\r\n    throw new Error(\r\n      `Invalid JSON in ${resolvedPath}: ${(err as Error).message}`\r\n    );\r\n  }\r\n}\r\n","/*\r\nCONFIG FILE STRUCT and ARGUMENTS\r\n`envx.config.json`\r\n{\r\n  \"input\": \"./examples/.envx\", // Path to your .envx file\r\n  \"outputs\": {\r\n    \"env\": \"./examples/.env\", // Output .env file path\r\n    \"types\": \"./examples/envx.ts\", // Output TypeScript definition file\r\n    \"metaFilePath\": \"./examples\" // Folder where meta JSON will be placed (file name is fixed)\r\n  },\r\n  \"overwrite\": true // If true, existing .env will be overwritten without prompt\r\n}\r\n\r\n\r\ninput -> Specifies the path to the .envx file\r\noutputs -> used to specify output files\r\n  env -> Used to specify the path of the .env file to be converted from .envx\r\n  types -> to specify the path to the typescript type file to create\r\n  [NEW] metaFilePath -> It is a json file with type etc. data to be created with .env during build, only the folder pathh name can be specified.\r\noverwrite (true/false) -> If .env is present at the time of conversion and the value is true, it is overwritten directly, no questions asked \r\n\r\n*/\r\n\r\nimport path from \"path\";\r\nimport { existsSync, readFileSync } from \"fs\";\r\nimport { JSON_CONFIG_FILE_NAME } from \"./constants\";\r\n\r\nexport const defaultUserConfig = {\r\n  input: \"./.envx\",\r\n  outputs: {\r\n    env: \"./.env\",\r\n    types: \"./types/envx.ts\",\r\n    metaFilePath: \".\",\r\n  },\r\n  overwrite: false,\r\n};\r\n\r\nfunction isValidUserConfig(obj: any): obj is Partial<typeof defaultUserConfig> {\r\n  return (\r\n    obj &&\r\n    typeof obj === \"object\" &&\r\n    typeof obj.input === \"string\" &&\r\n    (obj.outputs === undefined ||\r\n      (typeof obj.outputs === \"object\" &&\r\n        (obj.outputs.env === undefined ||\r\n          typeof obj.outputs.env === \"string\") &&\r\n        (obj.outputs.types === undefined ||\r\n          typeof obj.outputs.types === \"string\") &&\r\n        (obj.outputs.metaFilePath === undefined ||\r\n          typeof obj.outputs.metaFilePath === \"string\"))) &&\r\n    (typeof obj.overwrite === \"boolean\" || obj.overwrite === undefined)\r\n  );\r\n}\r\n\r\nexport function loadUserConfig() {\r\n  const jsonPath = path.resolve(JSON_CONFIG_FILE_NAME);\r\n\r\n  if (existsSync(jsonPath)) {\r\n    const raw = readFileSync(jsonPath, \"utf-8\");\r\n\r\n    try {\r\n      const parsed_config = JSON.parse(raw);\r\n\r\n      if (isValidUserConfig(parsed_config)) {\r\n        return {\r\n          ...defaultUserConfig,\r\n          ...parsed_config,\r\n          outputs: {\r\n            ...defaultUserConfig.outputs,\r\n            ...parsed_config.outputs,\r\n          },\r\n        };\r\n      } else {\r\n        console.warn(\r\n          `[envx:info:config] Invalid config structure, falling back to default.`\r\n        );\r\n        return defaultUserConfig;\r\n      }\r\n    } catch (err) {\r\n      const errMsg = err instanceof Error ? err.message : String(err);\r\n      console.warn(\r\n        `[envx:warn:config] Could not parse ${JSON_CONFIG_FILE_NAME}: ${errMsg}`\r\n      );\r\n      return defaultUserConfig;\r\n    }\r\n  }\r\n\r\n  return defaultUserConfig;\r\n}\r\n","/**\r\n * 📄 File Extension Support\r\n *\r\n * This module only supports `.envx` files as the standard configuration format.\r\n * Other extensions like `.tenv`, `.envt` are not supported.\r\n * Please ensure all environment files use the `.envx` extension.\r\n */\r\nimport path from \"path\";\r\n\r\nexport type FileExtsType = \"envx\";\r\nexport const fileExts: FileExtsType[] = [\"envx\"];\r\n\r\n/**\r\n * Checks if the provided file path or extension matches supported environment file patterns.\r\n * Supported patterns include:\r\n *  - Exact \".envx\" filename\r\n *  - Files starting with \".envx.\" (e.g., \".envx.local\", \".envx.dev\")\r\n *  - Files ending with \".envx\" extension (e.g., \"config.envx\")\r\n *  - Files with the \".envx\" extension recognized by the system\r\n *\r\n * @param filePathOrExt - The filename or path to validate.\r\n * @returns True if the file matches supported patterns; otherwise, false.\r\n */\r\nexport const checkFileExt = (filePathOrExt: string): boolean => {\r\n  const baseName = path.basename(filePathOrExt);\r\n\r\n  if (baseName === \".envx\") return true;\r\n  if (baseName.startsWith(\".envx.\")) return true;\r\n  if (baseName.endsWith(\".envx\")) return true;\r\n\r\n  const ext = path.extname(baseName).replace(/^\\./, \"\");\r\n  if (fileExts.includes(ext as FileExtsType)) return true;\r\n\r\n  return false;\r\n};\r\n\r\n/**\r\n * Validates the file extension and throws an error if the file is not supported.\r\n * Only files matching the supported patterns (e.g., \".envx\", \".envx.local\", \"config.envx\") are allowed.\r\n *\r\n * @param filePath - The filename or path to validate.\r\n * @throws Will throw an error if the file extension is unsupported.\r\n */\r\nexport function throwIfUnknownExtUsed(filePath: string): void {\r\n  if (!checkFileExt(filePath)) {\r\n    const ext = path.extname(filePath).replace(/^\\./, \"\");\r\n    throw new Error(\r\n      `[Typenv Error] Unsupported file extension '.${ext}'. Please use a '.envx' file or a valid variant such as '.envx.local'.`\r\n    );\r\n  }\r\n}\r\n","import fs from \"fs\";\r\nimport path from \"path\";\r\nimport { EnvxSchema, EnvxResult, EnvxError } from \"../types\";\r\nimport { loadEnvxFromString } from \"../core\";\r\n\r\nimport { ERROR_MESSAGES } from \"../../shared/errors\";\r\nimport { resolveEnvFilePath } from \"../utils\";\r\n\r\nimport { parseEnvxMetaFile } from \"../../shared/utils\";\r\nimport { loadUserConfig } from \"../../shared/configLoader\";\r\nimport {\r\n  DEFAULT_ENV_FILE,\r\n  DEFAULT_ENVX_FILE,\r\n  META_JSON_FILE_NAME,\r\n} from \"../../shared/constants\";\r\nimport { throwIfUnknownExtUsed } from \"./fileExt\";\r\n\r\n// ---- Load user configuration ---- //\r\nconst config = loadUserConfig();\r\n\r\nfunction readFileSafe(filePath: string): string {\r\n  try {\r\n    if (!fs.existsSync(filePath)) {\r\n      throw new EnvxError(ERROR_MESSAGES.lib.fileDoesNotExist(filePath));\r\n    }\r\n    return fs.readFileSync(filePath, \"utf-8\");\r\n  } catch (e) {\r\n    const message = e instanceof Error ? e.message : String(e);\r\n    throw new EnvxError(`Failed to read file at ${filePath}: ${message}`);\r\n  }\r\n}\r\n\r\n/**\r\n * Loads and validates a pre-generated `.env` file using a corresponding schema from `.envx.meta.json`,\r\n * and returns a fully typed, type-safe environment object.\r\n *\r\n * This function is designed for **runtime environments** where you don’t want to ship `.envx` files\r\n * to production, but instead use the compiled `.env` + generated schema (`.envx.meta.json`).\r\n *\r\n * > Note: This function **does NOT** mutate `process.env`. If you need to inject variables into\r\n * > `process.env`, consider using `loadEnvx()` instead.\r\n *\r\n * ---\r\n *\r\n * ## How it works:\r\n *\r\n * - Reads the `.env` file (default: `.env` or `config.outputs.env`)\r\n * - Reads the compiled schema file (default: `.envx.meta.json` or `config.outputs.metaFilePath`)\r\n * - Validates the values based on types (string, number, boolean, enum, etc.)\r\n * - Returns a typed object matching the expected shape.\r\n *\r\n * ---\r\n *\r\n * ## Type Generation (Optional)\r\n * To benefit from static typing, run the following to generate your types:\r\n *\r\n * ```bash\r\n * npx typenv types --out types/envx.d.ts\r\n * ```\r\n *\r\n * Then use it like:\r\n *\r\n * ```ts\r\n * import { getEnv } from \"typenvx\";\r\n * import type { EnvVars } from \"../types/envx\"; // <- your generated types\r\n *\r\n * const env = getEnv<EnvVars>();\r\n * console.log(env.API_URL); // Fully typed\r\n * ```\r\n *\r\n * ---\r\n *\r\n * @template T - The type of the expected environment object. Defaults to `EnvxResult`.\r\n * @param {string} [filePath=DEFAULT_ENV_FILE] - Path to the `.env` file. Defaults to the configured or standard path.\r\n * @returns {T} A fully validated and typed environment object.\r\n *\r\n * @throws {EnvxError} If the `.env` or `.envx.meta.json` file is missing or invalid.\r\n *\r\n * @example\r\n * ```ts\r\n * // Assuming `.env` and `.envx.meta.json` exist\r\n * const env = getEnv();\r\n * console.log(env.DATABASE_URL); // Typed access\r\n * ```\r\n */\r\nfunction getEnv<T extends Record<string, any> = EnvxResult>(\r\n  filePath = DEFAULT_ENV_FILE\r\n): T {\r\n  const metaFileFullPath = path.join(\r\n    config?.outputs?.metaFilePath || \".\",\r\n    META_JSON_FILE_NAME\r\n  );\r\n  const metaFilePath = path.resolve(process.cwd(), metaFileFullPath);\r\n  const envFilePath = config?.outputs?.env || filePath;\r\n  const absPath = resolveEnvFilePath(envFilePath);\r\n\r\n  const envContent = readFileSafe(absPath);\r\n  let envxSchema: EnvxSchema;\r\n  try {\r\n    envxSchema = parseEnvxMetaFile(metaFilePath);\r\n  } catch (e) {\r\n    const message = e instanceof Error ? e.message : String(e);\r\n    throw new EnvxError(`Failed to parse meta schema file: ${message}`);\r\n  }\r\n\r\n  const envVars = loadEnvxFromString(envContent, envxSchema);\r\n\r\n  return envVars.result as T;\r\n}\r\n\r\n/**\r\n * Loads and parses a `.envx` file into a fully typed, validated environment object.\r\n *\r\n * Designed for **development**, **server-side rendering**, or any environment\r\n * where `.envx` files are available and can be parsed at runtime.\r\n *\r\n * ---\r\n *\r\n * ## What it does\r\n *\r\n * - Reads a `.envx` file (default: `.envx`)\r\n * - Optionally uses a provided schema, or reads schema inline from the file itself\r\n * - Validates and casts values based on type definitions\r\n * - Returns a fully typed result, **without modifying `process.env`**\r\n *\r\n * ---\r\n *\r\n * ## When to use\r\n *\r\n * This function is ideal when you:\r\n * - Want full `.envx` syntax support (e.g., multi-line values, inline schema)\r\n * - Don't want to pre-generate `.env` or `.envx.meta.json`\r\n * - Are working in **development** or **local SSR** environments\r\n *\r\n * ---\r\n *\r\n * ## Type-Safety\r\n *\r\n * If you want full IntelliSense and compile-time safety, you can generate types:\r\n *\r\n * ```bash\r\n * npx typenv types --out types/envx.d.ts\r\n * ```\r\n *\r\n * ```ts\r\n * import { getEnvx } from \"typenvx\";\r\n * import type { EnvVars } from \"./types/envx\";\r\n *\r\n * const env = getEnvx<EnvVars>();\r\n * console.log(env.API_URL); // fully typed\r\n * ```\r\n *\r\n * ---\r\n *\r\n * ## Future-proof Design\r\n *\r\n * `getEnvx()` serves as the **most powerful way** to handle `.envx` at runtime.\r\n * Until native `.envx` support is adopted in runtimes like Node.js or Deno,\r\n * this function provides full spec-compliant parsing with validation.\r\n *\r\n * ---\r\n *\r\n * @template T - The expected shape of the environment variables.\r\n * @param {string} [filePath=DEFAULT_ENVX_FILE] - Path to the `.envx` file.\r\n * @param {EnvxSchema} [schema] - Optional schema override (if not inline).\r\n * @returns {T} A fully validated, typed object of environment variables.\r\n *\r\n * @throws {EnvxError} If the file cannot be read, parsed, or validated.\r\n */\r\nfunction getEnvx<T extends Record<string, any> = EnvxResult>(\r\n  filePath = DEFAULT_ENVX_FILE,\r\n  schema?: EnvxSchema\r\n): T {\r\n  const envxFilePath = config?.input || filePath;\r\n  const absPath = resolveEnvFilePath(envxFilePath);\r\n  throwIfUnknownExtUsed(absPath);\r\n\r\n  const content = readFileSafe(absPath);\r\n\r\n  const envVars = loadEnvxFromString(content, schema);\r\n\r\n  return envVars.result as T;\r\n}\r\n\r\n/**\r\n * Loads environment variables from a `.envx` file, validates them against the schema,\r\n * and **injects them into `process.env`**, allowing global access within the Node.js process.\r\n *\r\n * Use this function when you want environment variables available globally in your app.\r\n *\r\n * @template T - The shape of the environment variables (defaults to EnvxResult).\r\n * @param {string} [filePath=DEFAULT_ENVX_FILE] - Path to the `.envx` file.\r\n * @param {EnvxSchema} [schema] - Optional schema for validation and type inference.\r\n * @returns {T} The loaded and injected environment variables as a typed object.\r\n *\r\n * @throws {EnvxError} Throws if `.envx` file does not exist.\r\n *\r\n * @example\r\n * ```ts\r\n * import { loadEnvx } from \"typenvx\";\r\n * loadEnvx(\"path/to/.envx\");\r\n * console.log(process.env.API_KEY);\r\n * ```\r\n */\r\nfunction loadEnvx<T extends Record<string, any> = EnvxResult>(\r\n  filePath = DEFAULT_ENVX_FILE,\r\n  schema?: EnvxSchema\r\n): T {\r\n  const envVars = getEnvx<T>(filePath, schema);\r\n\r\n  Object.entries(envVars).forEach(([key, value]) => {\r\n    process.env[key] = String(value);\r\n  });\r\n\r\n  return envVars as T;\r\n}\r\n\r\nexport { getEnv, getEnvx, loadEnvx, readFileSafe };\r\n"]}