Framework extension setup
Last updated: 2026-06-18
Framework integrations should treat schema-dsl extensions as reusable application assets, similar to locale packs. Keep custom types, factories, chain methods, runtime setup, and transform options in one predictable directory.
Recommended directory
This structure makes custom types reusable across services, tests, workers, OpenAPI generation, and validation.
Application-level setup
Use this when the app has one extension set loaded during startup:
Call the installer once from your app bootstrap or framework plugin.
Runtime-scoped setup
Use runtime-scoped setup when each app, tenant, plugin, worker, or test fixture needs isolated extension state:
Dispose the runtime when the host instance is unloaded.
Transform setup
If the framework compiles direct String-chain source, export the transform options next to the extension setup:
Framework adapters can pass these options into transformSchemaDsl() or schemaDslEsbuildPlugin().
TypeScript setup
Place module augmentations in a .d.ts file that is included by the framework or application tsconfig:
Only augment schema-dsl/string-types when direct String-chain source is part of your framework authoring model.
Checklist
- Register global extensions during startup, not per request.
- Use
createRuntime()for framework, tenant, worker, and isolated test boundaries. - Keep transform options next to the extension package.
- Keep TypeScript declarations in the extension package or setup module.
- Clean global extension state in isolated tests with
resetRuntimeState(). - Dispose runtime instances in plugin or app teardown.
Corresponding sample file
Example entry: framework-extension-setup.ts Note: Demonstrates an app-level installer, runtime-scoped installer, transform options, validation, and cleanup.