Skip to content

@xtandard/kit/util/core

@xtandard/kit/util/core — the dependency-free part of @xtandard/kit/util: durations, id generators, canonical JSON and the JSON / Actor types. It never loads valibot, so hot paths that only mint ids or parse durations stay light. @xtandard/kit/util re-exports all of it plus the validation core.

import { … } from "@xtandard/kit/util/core";
Name Summary
canonicalStringify Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike canonicalJson it throws on non-finite numbers instead of writing null. Matches RFC 8785 (JCS) for strings and integers. A top-level undefined serialises as null.
createIdGenerator Create an id generator for one product. The prefix union is a type parameter, so newId("typo") fails to compile.
durationToMs Convert a Duration to milliseconds. Throws on malformed strings or negative / non-finite numbers.
parseDurationList Parse a comma-separated list of durations ("0,30s,5m,1h"), as used for retry schedules in env vars. Bare numbers become milliseconds; empty items are skipped. Every item is validated eagerly, so a bad list fails at parse time rather than when it is first used.
Name Summary
Actor Who performed a mutation, as recorded in hook events and audit trails.
IdGenerator What createIdGenerator returns.
IdGeneratorOptions Options for createIdGenerator.
Name Summary
CanonicalInput What canonicalStringify accepts: a JsonValue whose object members (and array items) may also be undefined. Undefined members are dropped and undefined items become null, exactly as JSON.stringify does.
Duration A duration: milliseconds, or a number with a unit (ms, s, m, h, d, w).
IdFormat The id formats createIdGenerator supports.
Name Documented on
JsonObject @xtandard/kit/storage
JsonValue @xtandard/kit/storage