README.md

March 18, 2026 ยท View on GitHub

License: CC0-1.0 License: MIT npm

This package contains the data specification for coding assessment output.

It provides:

  • JSON Schema: coding-scheme.schema.json
  • Schema documentation: generated into public/ (based on AsyncAPI Generator)
  • TypeScript types for the schema (CodingSchemeData, VariableCodingData, CodeData, ...)
  • A small helper class CodingScheme for reading/writing versioned scheme JSON

Installation

npm i @iqbspecs/coding-scheme

Usage (TypeScript)

Import from the package root:

import {
    CodingScheme,
    type CodingSchemeData,
    type VariableCodingData,
    CodingSchemeVersionMajor,
    CodingSchemeVersionMinor,
} from "@iqbspecs/coding-scheme";

Parse a scheme and re-serialize it

CodingScheme accepts either a JSON string or a parsed object.

const raw = '{"version":"3.4","variableCodings":[]}';
const scheme = new CodingScheme(raw);

// normalized, versioned JSON string
const normalized = scheme.toString();

Check compatibility of a scheme version

const status = CodingScheme.checkVersion({
    version: "3.4",
    variableCodings: [],
} satisfies CodingSchemeData);

// 'OK' | 'MAJOR_LESS' | 'MAJOR_GREATER' | 'MINOR_GREATER'

The current library version constants are:

  • CodingSchemeVersionMajor: 3
  • CodingSchemeVersionMinor: 4

Types

The package exports the schema types from coding-scheme.interface.ts, including:

  • CodingSchemeData: top-level object with version and variableCodings
  • VariableCodingData: per-variable coding configuration
  • CodeData, RuleSet, CodingRule: rule-driven coding definitions

Public API exports

In addition to the TypeScript types, the package exports constants and helpers from coding-scheme.ts:

  • CodingScheme
  • State constants:
    • validStatesForDerivingValue
    • validStatesForDerivingCode
    • validStatesToStartDeriving
    • statesToReplaceByDeriveError
  • Rule constants:
    • RuleMethodParameterCount
    • numericRules
    • booleanRules
  • Derive constants:
    • deriveMethodsFromValue
    • DeriveConcatDelimiter

Schema validation and documentation generation (repo)

This repository includes scripts to validate and generate documentation.

  • Validate schema against test cases:
npm run test_schema
  • Generate HTML docs into public/:
npm run generate_docs

Read more