fatima

Generated SDKs

Understand the files Fatima writes for TypeScript, JavaScript, and Python.

SDK generation converts loaded environment variables into a runtime file that your application can import.

Supported generators

GeneratorDefault fileOutput
typescriptenv.tsPrivate env.ts plus public env.public.ts.
javascriptenv.jsPrivate env.js plus public env.public.js.
pythonenv.pyOne Python file.

Set the generator and output file in fatima.json:

{
  "generator": "typescript",
  "file": "src/env.ts"
}

Private and public output

JavaScript and TypeScript generation separates variables by prefix. The default public prefix is PUBLIC_.

  • Variables that start with the prefix are available in the public output.
  • Variables without the prefix stay in the private output.
  • The TypeScript private output prevents client-side reads of private variables through a runtime guard.

Change the prefix with either spelling:

{
  "publicPrefix": "NEXT_PUBLIC_"
}

Runtime helpers in generated JavaScript and TypeScript

The private TypeScript and JavaScript files include:

ExportPurpose
envLazy access to validated environment values.
registerSynchronously load dotenv files into process.env.
registerAsyncPopulate process.env from an async source.

The public output exports publicEnv.

What gets generated

Fatima generates keys from the variables actually loaded by providers. The model changes generated types and validation expressions, but it does not create variables that were not loaded.

For example, if PORT=3000 is loaded and PORT is modeled as integer, the generated TypeScript type for env.PORT is number.