API/devkit

@functional-examples/devkit

Plugin development kit for functional-examples

npm install @functional-examples/devkit
v0.1.2NPMGitHub

@functional-examples/devkit

Plugin development kit for functional-examples — shared types and utilities.

Installation

npm install @functional-examples/devkit

Overview

The devkit provides the foundational types and utility modules used by functional-examples and its plugins.

Usage

Types (root)

import type {
  Config,
  Example,
  Extractor,
  Plugin,
} from '@functional-examples/devkit';

Core type definitions: Plugin, Extractor, ExtractorResult, Config, Example, ExampleFile, and more.

Utilities (root)

import {
  createMatcher,
  glob,
  isMatch,
  JsonParseError,
  parseJson,
  parseYaml,
  tryParseJson,
  tryParseYaml,
  YamlParseError,
} from '@functional-examples/devkit';

Includes JSON parsing (parseJson, tryParseJson, JsonParseError), YAML parsing (parseYaml, tryParseYaml, YamlParseError), and glob helpers (glob, isMatch, createMatcher) from the root import.

Peer Dependencies

The utility helpers rely on optional peer dependencies:

Utility areaOptional peers
Glob helperstinyglobby, picomatch
YAML parseryaml
JSON parserjsonc-parser and/or json5 for extended formats

License

MIT

API EXPORTS

Interfaces

BaseMetadatainterface

Base metadata that all examples should have. Used for type constraints when users want stricter typing.

Configinterface
ConfigValidationErrorinterface

Error from config validation.

Exampleinterface

A discovered example with metadata and files. This is the base type returned by extractors. Metadata is typed via `ExampleMetadata` by default, which can be augmented by running `functional-examples generate`. You can also pass an explicit generic parameter for custom typing.

ExampleMetadataRegistryinterface

Augmentable registry for example metadata typing. Run `functional-examples generate` to create a declaration file that augments this interface, providing type-safe metadata for your examples.

Extractorinterface

Candidate-based extractor interface. Called with pre-filtered candidates (files and/or directories). Extractor decides which candidates it can handle.

ExtractorConfiginterface

Reference to an extractor package (for config files)

ExtractorErrorinterface

Error encountered during extraction

ExtractorOptionsinterface

Options passed to extractor during extraction

ExtractorResultinterface

Result from a candidate-based extractor

FileContentsParserinterface

Parser that processes file contents in a pipeline. Receives accumulated context, transforms it, returns updated context.

FileParseContextinterface

Context passed through the FileContentsParser pipeline. Each parser receives this, transforms it, and returns an updated version.

GenerateConfiginterface

Configuration for the generate command output.

GlobOptionsinterface

Options for the glob function.

JSONSchemaObjectinterface

JSON Schema object for metadata validation. Subset of JSON Schema spec used for config files.

ParsedRegioninterface

Parsed code region from #region markers.

PathMappinginterface

Path-to-extractor mapping for conflict resolution.

Plugininterface

Plugin containing optional extractors, parsers, schemas, and validators. Auto-registers for declared file extensions.

PluginRegistryInterfaceinterface

Plugin registry interface for accessing validators/schemas. Full implementation is in plugins/registry.ts.

PluginSchemaEntryinterface

Schema entry from a plugin with plugin name context.

PluginSchemasinterface

Schema definitions for a plugin (JSON Schema format). Used for IDE autocomplete and documentation generation.

PluginValidatorEntryinterface

Wrapper for a plugin's validator function with plugin name context.

PluginValidatorsinterface

Validator functions for a plugin. Allows plugins to use any validation library (Zod, TypeBox, etc.)

RegionConfiginterface

Configuration for region marker parsing.

ResolvedConfiginterface

Resolved configuration with actual extractor instances. This is the runtime-ready configuration after all plugins are loaded.

ScanConfiginterface

Scan configuration options.

ValidationErrorinterface

A single validation error.

ValidationResultinterface

Result of a validation operation.