BSB Node.js Type Definitions
    Preparing search index...

    Function createConfigSchema

    • Helper function to create a typed plugin configuration class with metadata.

      v9 Breaking Change: This replaces the manual Config class pattern. Instead of extending BSBPluginConfig directly, use this helper to create a Config class with built-in metadata support.

      The metadata is used to:

      • Auto-generate PLUGIN_CLIENT for ServiceClient usage
      • Auto-generate bsb-plugin.json during build
      • Provide plugin discovery and marketplace information

      Type Parameters

      • const TSchema extends BaseSchema<any, any>

      Parameters

      • metadata: BSBPluginMetadata

        Plugin metadata (name, description, documentation, tags, etc.)

      • schema: TSchema

        AnyVali validation schema for the plugin configuration

      Returns BSBPluginConfigClass<TSchema>

      A Config class that extends BSBPluginConfig with metadata

      // v9 pattern:
      const TodoConfigSchema = av.object({
      database: av.object({
      // .default() makes the key optional in config files while keeping the
      // inferred type non-optional. Only wrap in av.optional() when there is
      // no default and the field may genuinely be absent.
      host: av.string().default('localhost'),
      port: av.int32().default(5432),
      }),
      });

      export const Config = createConfigSchema(
      {
      name: 'service-demo-todo',
      description: 'Demo Todo Service',
      tags: ['demo', 'todo', 'example'],
      },
      TodoConfigSchema
      );

      // Usage in plugin:
      export class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
      static Config = Config; // Required for auto-generation
      }
    • Helper function to create a typed plugin configuration class with metadata.

      v9 Breaking Change: This replaces the manual Config class pattern. Instead of extending BSBPluginConfig directly, use this helper to create a Config class with built-in metadata support.

      The metadata is used to:

      • Auto-generate PLUGIN_CLIENT for ServiceClient usage
      • Auto-generate bsb-plugin.json during build
      • Provide plugin discovery and marketplace information

      Parameters

      • metadata: BSBPluginMetadata

        Plugin metadata (name, description, documentation, tags, etc.)

      Returns BSBPluginConfigClass<undefined>

      A Config class that extends BSBPluginConfig with metadata

      // v9 pattern:
      const TodoConfigSchema = av.object({
      database: av.object({
      // .default() makes the key optional in config files while keeping the
      // inferred type non-optional. Only wrap in av.optional() when there is
      // no default and the field may genuinely be absent.
      host: av.string().default('localhost'),
      port: av.int32().default(5432),
      }),
      });

      export const Config = createConfigSchema(
      {
      name: 'service-demo-todo',
      description: 'Demo Todo Service',
      tags: ['demo', 'todo', 'example'],
      },
      TodoConfigSchema
      );

      // Usage in plugin:
      export class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
      static Config = Config; // Required for auto-generation
      }