Changelog - 2026-09-06
Conditional entries in configs.artifacts
New FeatureIn one line. An entry of configs.artifacts can carry a when; the indexes behind it register only when the condition answers true.
What changed
IConditionalArtifactIndexis new:{ when: TArtifactCondition; index: TArtifactIndexInput }.TArtifactIndexInputnow also accepts it.whenreceives{ application }and may be async, like thewhenon a class decorator. It may ignore its argument and read the environment.- A false
whendrops the whole subtree, nested arrays included. Nothing behind it is bound, sobootChecks.binding.doVerifynever sees it either. A per-classwhenon a decorator still applies inside a kept subtree. ArtifactIndexHelper.flatten()is now async and takes{ input, application }.- Run-mode gate.
registerArtifactsruns at boot step 5, beforepreConfigure(). A gate that used to live inpreConfigure()is now too late: after moving to the generated index, a worker boot mounted its REST routes with no authentication strategy bound.
typescript
const runMode = process.env.RUN_MODE ?? 'server';
export const configs: IApplicationConfigs = {
path: { base: '/api', isStrict: true },
artifacts: [
{ dataSources: GeneratedArtifacts.dataSources, repositories: GeneratedArtifacts.repositories },
{ when: () => runMode !== 'migrate', index: { services: GeneratedArtifacts.services, components: GeneratedArtifacts.components } },
{ when: () => runMode === 'server', index: { controllers: GeneratedArtifacts.controllers } },
],
};Who is affected
- Applications that filter the index by run mode in their own code. Replace the filter with conditional entries as above and delete the helper.
- Applications that gate controllers in
preConfigure(). That gate no longer protects a worker: move it intoconfigs.artifacts. This is a security fix, not a convenience. - Direct callers of
ArtifactIndexHelper.flatten(). It is async now and needsapplication. - Everyone else. No action needed.
Details
- Reference: Artifact registration. Guide: Registering artifacts. Migration: boot API removal.