mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
src/next is src (the main export), src/next-node is src/node with short subpaths (/http, /workers, /plugins, /plugins/runtime, /app, /surfaces, /web, /react, /tui, /tui/launcher); the foundations get /json and /watch; Chord v1 moves to src/old (/old, /old/node) until p2 runs on v2; tests and docs move likewise (test/, docs/, test/old, docs/old). Durable and env import the foundations from their subpaths.
14 lines
768 B
TypeScript
14 lines
768 B
TypeScript
// Schemas with the exact JSON TypeBox's `Type.Literal` and `Type.Record` built, so contracts declared with them keep
|
|
// the fingerprints they had under TypeBox (see the migration notes in CHANGELOG.md).
|
|
|
|
import type { Schema } from "@earendil-works/pi-schema";
|
|
|
|
/** `Type.Literal(value)`: the literal with its JSON type (pi-schema's `lit` has no `type`). */
|
|
export function typedLit<const V extends string | number | boolean>(value: V): Schema<V> {
|
|
return { type: typeof value, const: value };
|
|
}
|
|
|
|
/** `Type.Record(Type.String(), value)`: one pattern property for every key (pi-schema's `map` uses `additionalProperties`). */
|
|
export function record<T>(value: Schema<T>): Schema<Record<string, T>> {
|
|
return { type: "object", patternProperties: { "^.*$": value } };
|
|
}
|