Compiled operations
Validation, equality, clone, diff, update, hash, serialization, security and mapping.
One schema can drive multiple independent compilers. Generate only what the application imports.
Validation
JIT.validate(User).is().compile();
JIT.validate(User).parse().compile();
JIT.validate(User).safeParse().compile();
JIT.validate(User).parseAsync().compile();
JIT.validate(User).issues().compile();is is fail-fast. safeParse collects issues and transformed output. parse
throws JITValidationError. Async variants settle promise schemas. issues
offers iterable consumption over the same compiled issue vector.
Structural operations
| API | Result | Allocation strategy |
|---|---|---|
JIT.equal(S) | boolean | early return, no result object |
JIT.clone(S) | deep shape clone | allocates required output only |
JIT.diff(S) | change entries | allocates only differences |
JIT.update(S) | immutable updated value | shares untouched branches |
JIT.hash(S) | numeric structural hash | scalar accumulator |
Hints such as entity, keyed, ordered, indexBy and hash influence
strategies for repeated collection operations. Benchmark index construction
against expected reuse; a single lookup may be cheaper as a scan. The
cache, hash and indexes guide documents the
immutability contract, adaptive threshold and invalidation choices.
Models
JIT.model(schema) is a compatible lazy facade over every operation. Accessing
one property compiles only that property, and the per-schema cache reuses it.
For application boundaries, prefer an explicit model so unsupported or unused
methods do not exist in the value or its TypeScript type.
const lazy = JIT.model(User);
const ReadUser = lazy.get("is", "parse");
const UserRuntime = JIT.model(User, {
is: true,
parse: true,
equal: true,
codec: false,
});
ReadUser.ops; // ["is", "parse"]
UserRuntime.equal(left, right);
// UserRuntime.clone does not exist.get() normalizes operation order and caches equal selections. Boolean model
configuration is convenient for feature flags and shared runtime modules. Both
forms compile validator methods together when possible, while unrelated
compilers are never called. Explicit model selections are grouped AOT markers,
so exporting UserRuntime from a configured *.jit.ts entry emits the same
narrow object. JIT.compile(schema, { ... }) remains the API for mixing model
operations with custom queries, mappers or other developer-defined functions.
Collection changes
const watchUsers = JIT.watch(JIT.array(User), { key: "id" });
const changes = watchUsers(previousUsers, currentUsers);
const members = JIT.watchedList(JIT.array(User), previousUsers, {
key: "id",
});
members.add(newUser);watch compiles a stateless O(n) snapshot diff and can be emitted as a pure
AOT function when it has no callbacks. watchedList retains state for an
aggregate or unit of work. See watched lists and collection
changes for identity rules and configuration.
For state owned by one process or UI store, JIT.update(User).reactive(initial)
adds typed path watchers, selectors, batching and configurable scheduling over
the compiled immutable updater. See reactive updates.
JSON and codecs
JIT.json(User).stringify().compile();
JIT.json(User).parse().compile();
JIT.json(Users).stringifyChunks().compile();
JIT.codec(Event, { version: 2 });JSON stringify bakes known keys and punctuation into source. Chunked JSON keeps large array output bounded. The binary codec is a persisted wire contract with a version byte; binary rowsets are process-local and may evolve independently.
Mapper and transform
const toPublic = JIT.mapper(UserEntity, PublicUser, {
name: { from: "fullName" },
}).get("map", "many");
toPublic.map(entity);
toPublic.many(entities);Mapper output is whitelisted by the destination schema. many() emits one
bulk indexed loop. Selection controls code generation itself: .get("map")
omits many, .get("many") omits map, and direct property access compiles
that operation lazily. JIT.transform provides field operations and selection
over one source schema.
JIT.dto(Target) aggregates inbound validation/transport operations.
JIT.dto(Source, Target, mapping) adds whitelist from and fused many
projections. See DTO aggregates for schema variants,
security boundaries and AOT behavior.
Security operations
const SafeLog = JIT.mask(User);
const CleanForm = JIT.sanitize(Form);.pii("redact" | "mask" | "hash") controls field masking. Sanitization
rebuilds only marked paths. These operations reduce accidental data exposure,
but application authorization and context-specific HTML policy remain separate
responsibilities.
Aggregated exports
const selected = JIT.validator(UserSchema).get("is", "parse");
export const User = JIT.compile(UserSchema, {
is: selected.is,
parse: selected.parse,
equal: JIT.equal(UserSchema),
});The object exposes only declared operations. AOT emits only those properties and required helpers. Standalone exports keep their exact declaration name.