pimbay/sequence-formatter-spec

Language-agnostic JSON test vectors and schemas for the PimBay Sequence Stack

Maintainers

Package info

codeberg.org/pimbay/sequence-formatter-spec

Homepage

Issues

Documentation

pkg:composer/pimbay/sequence-formatter-spec

Transparency log

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

v1.0.0 2026-05-22 18:17 UTC

This package is auto-updated.

Last update: 2026-07-22 18:36:35 UTC


README

License

Language-agnostic JSON test vectors and schemas for the PimBay Sequence Stack. Used to verify ports of the sequence formatter to other languages and runtimes.

What is this

The sequence formatter formats integer sequence values into business identifiers, generates initial values for sequence groups, and produces random codes — all driven by a pattern string. This repository contains the canonical test vectors that any port must pass to be considered correct.

Pattern syntax

Patterns are strings with {token} placeholders. Literals outside tokens pass through unchanged.

Sequence tokens — PatternFormatter / InitialValueGenerator

TokenDescription
{N}Single digit, right-to-left indexed
{N4} / {NNNN}Fixed padding — 4 digits
{N3..5}Dynamic range — min 3, max 5 digits
{N+}Unlimited — full number, no padding

Random tokens — CodeGenerator

TokenDescription
{R}One random character
{R4}Exactly 4 random characters
{R3..5}Random length between 3 and 5

Shared tokens

TokenOutput (2026-04-16)
{YYYY}2026
{YY}26
{MM}04
{DD}16
{key}runtime context value

Examples:

PatternInputOutput
INV/{N4}1INV/0001
INV/{YYYY}/{N4}125INV/2026/0125
{branch}/{YY}/{N4}1, branch=SKSK/26/0001
{YY}{MM}{N4}126040001
{R4}-{R4}A3KM-7PXT
{YY}{MM}-{R4}2604-A3KM

Structure

schema/    — JSON Schema 2020-12 definitions
vectors/   — test vector files, one per component
scripts/   — validation tooling (Node.js)

Vectors

FileComponentPositiveNegative
alphabet.jsonAlphabet22
pattern-formatter.jsonPatternFormatter2013
initial-value-generator.jsonInitialValueGenerator1213
code-generator.jsonCodeGenerator1113
transformer-base-n.jsonTransformer.Number.BaseNTransformer82
transformer-luhn.jsonTransformer.Number.LuhnChecksumTransformer32
transformer-modulo.jsonTransformer.Number.ModuloChecksumTransformer41
transformer-obfuscator32.jsonTransformer.Number.Obfuscator32Transformer53
transformer-obfuscator64.jsonTransformer.Number.Obfuscator64Transformer62
transformer-mask.jsonTransformer.Code.MaskTransformer68

Vector conventions

config.reference_date — ISO 8601 datetime used as the clock value. null means no clock is needed. Cases tagged clocked require a non-null value; ports must inject it into whatever clock mechanism they use.

config.alphabet — named constant (e.g. "UNAMBIGUOUS_UPPER") or inline string (e.g. "ABC"). Named constants are defined in vectors/alphabet.json under constants.

expected.matches_regex — PCRE regex the generated output must match. Present on all CodeGenerator positive cases because output is random. For clocked cases the date prefix is hardcoded in the regex (e.g. ^2604-).

expected.unique_chars — when true, all characters in the output must be distinct. Used for repeatable: false cases.

expected.max_length — present in all PatternFormatter and CodeGenerator positive cases. null for patterns containing {N+} or a context token.

expected_error.reason — snake_case identifier a port must map to its own error type. The type field uses class name conventions as reference only. All reason values used across vectors:

ReasonUsed by
missing_clockPatternFormatter, InitialValueGenerator, CodeGenerator
missing_keyPatternFormatter, InitialValueGenerator, CodeGenerator
non_numeric_valueInitialValueGenerator
max_value_exceededPatternFormatter
max_length_exceededPatternFormatter, CodeGenerator
initial_value_exceeds_capacityInitialValueGenerator
unsupported_token_typePatternFormatter, InitialValueGenerator, CodeGenerator
empty_patternPatternFormatter, InitialValueGenerator, CodeGenerator
mixed_digit_tokensPatternFormatter, InitialValueGenerator, CodeGenerator
multiple_unlimitedPatternFormatter, InitialValueGenerator, CodeGenerator
invalid_rangePatternFormatter, InitialValueGenerator, CodeGenerator
zero_countPatternFormatter, InitialValueGenerator, CodeGenerator
unknown_tokenPatternFormatter, InitialValueGenerator, CodeGenerator
no_sequence_tokenPatternFormatter, InitialValueGenerator, CodeGenerator
non_numeric_resultInitialValueGenerator
invalid_alphabetAlphabet, CodeGenerator, BaseNTransformer
invalid_configurationCodeGenerator, MaskTransformer, ModuloChecksumTransformer, Obfuscator32Transformer, Obfuscator64Transformer
invalid_keyObfuscator32Transformer, Obfuscator64Transformer
invalid_modulusModuloChecksumTransformer
invalid_valueMaskTransformer
value_out_of_rangeObfuscator32Transformer, Obfuscator64Transformer
insufficient_alphabet_for_non_repeatableCodeGenerator
char_not_in_alphabetBaseNTransformer
luhn_check_failedLuhnChecksumTransformer
value_too_shortLuhnChecksumTransformer

tags — informational, not enforced by schema:

TagMeaning
clockedrequires reference_date to be set
randomoutput is non-deterministic; verify with matches_regex
contextrequires input.context key(s)
overflowtests overflow: silent or overflow throw behaviour
round_tripobfuscator: inverse(transform(n)) === n; encoded value is fixed

Porting checklist

  1. Load the vector file for the component you are implementing.
  2. Positive case — instantiate with pattern + config, call the method with input, assert result matches expected.
  3. Negative case — assert the correct error type and reason is raised.
  4. random tag — assert expected.matches_regex instead of equality. If unique_chars: true, assert all characters are distinct.
  5. clocked tag — inject config.reference_date as the clock value before calling.
  6. round_trip tag — assert inverse(transform(input)) === input. Encoded string must match expected.transform exactly.

Validation

Requires Node.js 18+.

npm install
npm test

Packages in the stack

PackageDescription
pimbay/sequence-formatter-specThis package
pimbay/sequence-number-sqlSQL snippets for number sequence adapters
pimbay/sequence-random-sqlSQL snippets for random sequence adapters

License

Public domain — Unlicense

Created by Jan Sarmir · No conditions · No copyright