Docs@skmtc/core

Projections and snippets

CLASS

ContentSettings

@skmtc/core 0.63.4

Configuration settings for content generators in the SKMTC DSL system.

ContentSettings encapsulates the configuration needed by generators to produce content, including where to export the generated files, how to identify the content, and any custom enrichment data for extending the generation process.

This class is used by ModelProjectionBase and OasOperationProjectionBase to configure their generation behavior, providing a consistent interface for generator settings across the system.

Key Features

  • Export Path Management: Specifies where generated content should be written
  • Identifier Integration: Links content to specific identifiers for naming
  • Enrichment Support: Allows custom data to extend generation capabilities
  • Type Safety: Generic enrichment typing for compile-time validation

Signature

import { ContentSettings } from '@skmtc/core'

class ContentSettings<EnrichmentType = undefined>
EnrichmentType

The type of enrichment data (default: undefined)

Examples

Basic settings without enrichments
import { ContentSettings, normalizeWorkspacePath } from '@skmtc/core';
import { createType } from '@skmtc/lang-typescript';

const settings = ContentSettings.empty({
  exportPath: normalizeWorkspacePath('./src/generated/models.ts'),
  identifier: createType('UserModels')
});

console.log(settings.exportPath); // '@/src/generated/models.ts'
console.log(settings.enrichments); // undefined
Settings with custom enrichments
type ValidationEnrichment = {
  validateRequired: boolean;
  generateComments: boolean;
  customValidators: string[];
};

const enrichedSettings = new ContentSettings({
  identifier: createType('ValidatedModels'),
  exportPath: normalizeWorkspacePath('./src/models/validated.ts'),
  enrichments: {
    validateRequired: true,
    generateComments: true,
    customValidators: ['email', 'phone']
  }
});

// Access enrichment data in generators
if (enrichedSettings.enrichments?.validateRequired) {
  // Generate validation logic
}
Using with ModelProjectionBase
class ValidatedModelGenerator extends ModelProjectionBase<ValidationEnrichment> {
  constructor(args) {
    super({
      ...args,
      settings: new ContentSettings({
        identifier: createType(args.refName),
        exportPath: normalizeWorkspacePath('./src/validated-models.ts'),
        enrichments: {
          validateRequired: true,
          generateComments: false,
          customValidators: []
        }
      })
    });
  }

  toDefinition(): Definition {
    const validation = this.settings.enrichments?.validateRequired
      ? this.generateValidation()
      : '';

    return new Definition({
      context: this.context,
      identifier: this.settings.identifier,
      value: {
        generatorKey: this.generatorKey,
        content: `${this.generateInterface()}${validation}`
      }
    });
  }
}

Constructor

constructor

constructor(args: CreateArgs<EnrichmentType>)

Creates a new ContentSettings instance with enrichments.

args

Settings configuration

args.identifier

The identifier for the content being generated

args.exportPath

The path where generated content will be exported

args.enrichments

Custom enrichment data for extending generation

args.variant

Operation variant name ('main' for variants-unaware Projections)

Properties

identifier, IdentifierBase

The identifier for the content being generated

exportPath, WorkspacePath

The path where generated content will be exported, normalized (normalizeWorkspacePath): it finds its file without being normalized again.

enrichments, EnrichmentType

Custom enrichment data for extending generation

variant, string

Operation variant this content belongs to. Carries the variant name threaded from the engine's per-operation dispatch through the Driver into this Projection. 'main' for variants-unaware operation generators and for model Projections.

indexPath, IdentifierPath | undefined

The identifiers that lead from the file's Index to the Index this content's definition sits in. Absent or empty at the file level. Optional so settings written as plain objects stay valid.

Methods

ContentSettings.empty

ContentSettings.empty(args: EmptyArgs): ContentSettings<undefined>

Factory method to create ContentSettings without enrichments.

This is a convenience method for creating ContentSettings when no custom enrichment data is needed. It explicitly sets enrichments to undefined and returns a properly typed instance.

args

Basic settings arguments

args.identifier

The identifier for the content being generated

args.exportPath

The path where generated content will be exported

Returns

ContentSettings instance with undefined enrichments