@oh-my-pi/omptype 17.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ### Added
6
+
7
+ - Initial release: ArkType-compatible schema validation with a lazy JIT runtime. Schemas interpret their first two calls and compile a specialized validator via `new Function` on the third, making `type()` construction ~100x cheaper than arktype while beating its hot-path validation speed. Supports the string definition DSL (primitives, literals, unions, arrays, bounds, `number.integer`, `string.url`, inline defaults, value-suffix `?` optionals), object definitions (`"+": "reject"/"delete"`, `"[string]"` index signatures), `type.errors`/`OmpErrors` with per-entry `path`/`problem`, `type.enumerated`, `type.raw`, keyword statics, composition methods (`.or/.and/.array/.pipe/.narrow/.describe/.default/.allows/.assert`), static inference via `typeof schema.infer`, and draft-2020-12 `toJsonSchema()` emission.
8
+ - TypeBox-style (`@oh-my-pi/omptype/typebox`) and Zod-style (`@oh-my-pi/omptype/zod`) authoring adapters producing native omptype schemas.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @oh-my-pi/omptype
2
+
3
+ Fast, ArkType-compatible schema validation for Bun. Schemas start with a small
4
+ interpreter and lazily compile after repeated use, keeping construction cheap
5
+ without giving up hot-path validation speed.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ bun add @oh-my-pi/omptype
11
+ ```
12
+
13
+ Omptype requires Bun 1.3.14 or newer.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { type } from "@oh-my-pi/omptype";
19
+
20
+ const Config = type({
21
+ name: "string",
22
+ "retries?": "number.integer >= 0",
23
+ enabled: "boolean = true",
24
+ });
25
+
26
+ const config = Config.assert({ name: "worker" });
27
+ // { name: "worker", enabled: true }
28
+
29
+ const result = Config({ name: 42 });
30
+ if (result instanceof type.errors) {
31
+ console.error(result.summary);
32
+ }
33
+ ```
34
+
35
+ Schemas are callable and expose `.assert()`, `.allows()`, `.toJsonSchema()`,
36
+ `.or()`, `.and()`, `.array()`, `.pipe()`, `.narrow()`, `.describe()`, and
37
+ `.default()`.
38
+
39
+ ## Compatibility adapters
40
+
41
+ TypeBox-style and Zod-style builders produce native omptype schemas:
42
+
43
+ ```ts
44
+ import { Type, type Static } from "@oh-my-pi/omptype/typebox";
45
+ import { z } from "@oh-my-pi/omptype/zod";
46
+
47
+ const TypeBoxUser = Type.Object({ name: Type.String() });
48
+ type TypeBoxUser = Static<typeof TypeBoxUser>;
49
+
50
+ const ZodUser = z.object({ name: z.string() });
51
+ const user = ZodUser.parse({ name: "Ada" });
52
+ ```
53
+
54
+ `@oh-my-pi/omptype/ark` provides the repository's ArkType compatibility facade.
55
+ Its `scope()` export remains available as an alias-free no-op for existing
56
+ callers; new code should import `type` directly from `@oh-my-pi/omptype`.
57
+
58
+ ## License
59
+
60
+ MIT
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ArkType compatibility facade — `@oh-my-pi/omptype/ark`.
3
+ *
4
+ * Lets code written against arktype keep its imports and names while running
5
+ * on the omptype lazy-JIT runtime: swap `from "arktype"` for
6
+ * `from "@oh-my-pi/omptype/ark"` and nothing else changes. New code should
7
+ * import `@oh-my-pi/omptype` directly.
8
+ *
9
+ * Compatibility affordances beyond the plain re-export:
10
+ * - `ArkError` / `ArkErrors` alias `OmpError` / `OmpErrors`.
11
+ * - `scope()` (alias-free form only) returns `{ type }`; the `jitless` flag is
12
+ * obsolete — omptype always starts interpreted and JIT-compiles lazily.
13
+ */
14
+ import { OmpError, OmpErrors } from "./errors.js";
15
+ import { type } from "./type.js";
16
+ export * from "./index.js";
17
+ export declare const ArkError: typeof OmpError;
18
+ export type ArkError = OmpError;
19
+ export declare const ArkErrors: typeof OmpErrors;
20
+ export type ArkErrors = OmpErrors;
21
+ /** ArkType `scope()` shim: only the alias-free `scope({}, config?)` form is supported. */
22
+ export declare function scope(aliases: Record<string, never>, _config?: {
23
+ jitless?: boolean;
24
+ }): {
25
+ type: typeof type;
26
+ };
@@ -0,0 +1,5 @@
1
+ import { type IR } from "./ir.js";
2
+ /** Compile `ir` into a specialized validator. */
3
+ export declare function compile(ir: IR): (value: unknown) => unknown;
4
+ /** Generated source for inspection/debugging. */
5
+ export declare function compileToSource(ir: IR): string;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Validation error containers mirroring ArkType's observable error surface:
3
+ * `result instanceof type.errors` / `instanceof OmpErrors`, lazy `.summary`,
4
+ * array iteration, and per-entry `.path` / `.problem` / `.message`.
5
+ *
6
+ * Failure-path cost matters: schemas reject untrusted input constantly, so
7
+ * construction stores only the path, the expectation, and the offending value.
8
+ * All human-readable strings are built lazily on property access.
9
+ */
10
+ /** A single validation failure at one path. */
11
+ export declare class OmpError {
12
+ /** Property path from the root to the failing value (empty at root). */
13
+ readonly path: PropertyKey[];
14
+ /** Human-readable expectation, e.g. `"a string"` or `"at most 3600"`. */
15
+ readonly expected: string;
16
+ /** The value that failed validation. */
17
+ readonly data: unknown;
18
+ constructor(
19
+ /** Property path from the root to the failing value (empty at root). */
20
+ path: PropertyKey[],
21
+ /** Human-readable expectation, e.g. `"a string"` or `"at most 3600"`. */
22
+ expected: string,
23
+ /** The value that failed validation. */
24
+ data: unknown);
25
+ /** Short description of the received value, e.g. `"a number"` or `"missing"`. */
26
+ get actual(): string;
27
+ /** Path-less problem statement: `must be <expected> (was <actual>)`. */
28
+ get problem(): string;
29
+ /** Full message including the path prefix. */
30
+ get message(): string;
31
+ toString(): string;
32
+ }
33
+ /** Sentinel for a required key that was absent (distinguishes from `undefined`). */
34
+ export declare const MISSING: unique symbol;
35
+ /**
36
+ * Aggregate of validation failures; the value returned by a schema call on
37
+ * invalid input. Array-like so callers can `.map()` over entries.
38
+ */
39
+ export declare class OmpErrors extends Array<OmpError> {
40
+ static get [Symbol.species](): typeof Array;
41
+ /** Single-failure constructor used by generated validators. */
42
+ static single(path: PropertyKey[], expected: string, data: unknown): OmpErrors;
43
+ /** Prefix every entry's path with `key` (used when nesting sub-schemas). */
44
+ prefix(key: PropertyKey): this;
45
+ /** Human-readable digest of every failure, one per line. Built lazily. */
46
+ get summary(): string;
47
+ toString(): string;
48
+ /** Throw a `TraversalError` carrying the summary. */
49
+ throw(): never;
50
+ }
51
+ /** Error thrown by `Type.assert` on invalid input. */
52
+ export declare class TraversalError extends Error {
53
+ readonly errors: OmpErrors;
54
+ constructor(errors: OmpErrors);
55
+ }
56
+ /**
57
+ * Definition/usage error thrown while building a schema — malformed string
58
+ * DSL, unsupported composition, or an illegal builder call. Distinct from
59
+ * validation failures, which are returned as {@link OmpErrors}.
60
+ */
61
+ export declare class OmpTypeError extends Error {
62
+ constructor(message: string);
63
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * omptype — ArkType-compatible schema validation with a lazy JIT runtime.
3
+ *
4
+ * Drop-in for the arktype surface this repo uses:
5
+ * `type()`, `Type`, `type.errors` / `OmpErrors`, `type.enumerated()`,
6
+ * `.or/.and/.array/.pipe/.narrow/.describe/.default/.allows/.assert/.toJsonSchema`,
7
+ * plus `typeof schema.infer` static inference.
8
+ */
9
+ export * from "./errors.js";
10
+ export * from "./infer.js";
11
+ export * from "./ir.js";
12
+ export * from "./json-schema.js";
13
+ export * from "./type.js";
@@ -0,0 +1,49 @@
1
+ /** Type-level output inference for the definition forms accepted by omptype. */
2
+ type Whitespace = " " | "\n" | "\r" | "\t";
3
+ type TrimLeft<s extends string> = s extends `${Whitespace}${infer rest}` ? TrimLeft<rest> : s;
4
+ type TrimRight<s extends string> = s extends `${infer rest}${Whitespace}` ? TrimRight<rest> : s;
5
+ type Trim<s extends string> = TrimLeft<TrimRight<s>>;
6
+ type InferPrimitive<s extends string> = s extends "string" | "string.url" ? string : s extends "number" | "number.integer" ? number : s extends "boolean" ? boolean : s extends "null" ? null : s extends "undefined" ? undefined : s extends "unknown" ? unknown : s extends "object" ? object : s extends "bigint" ? bigint : s extends "true" ? true : s extends "false" ? false : never;
7
+ type InferMember<member extends string> = Trim<member> extends infer s extends string ? s extends `${infer element}[]` ? InferMember<element>[] : s extends `'${infer literal}'` | `"${infer literal}"` ? literal : s extends `${infer literal extends number}` ? literal : InferPrimitive<s> extends infer primitive ? [primitive] extends [never] ? s extends `${string}string${string}` ? string : s extends `${string}number${string}` ? number : unknown : primitive : unknown : unknown;
8
+ /** Split top-level unions without distributing over the accumulated members. */
9
+ type InferUnion<s extends string, result = never> = s extends `${infer head}|${infer tail}` ? InferUnion<tail, result | InferMember<head>> : result | InferMember<s>;
10
+ type HasInlineDefault<s extends string> = s extends `${string}=${string}` ? s extends `${string}<${string}` | `${string}>${string}` ? false : true : false;
11
+ type WithoutInlineDefault<s extends string> = HasInlineDefault<s> extends true ? (s extends `${infer base}=${string}` ? Trim<base> : s) : s;
12
+ /** String-DSL-only inference; safe inside recursive interfaces (never probes `Type`). */
13
+ export type InferString<s extends string> = WithoutInlineDefault<Trim<s>> extends infer trimmed extends string ? trimmed extends `${infer base}?` ? InferString<base> : trimmed extends `(${infer inner})[]` ? InferUnion<inner>[] : InferUnion<trimmed> : unknown;
14
+ type HasDefault<def> = def extends string ? HasInlineDefault<def> : def extends {
15
+ readonly hasDefault: true;
16
+ } ? true : false;
17
+ type DefinitionKeys<def extends object> = Exclude<keyof def, "+" | "[string]">;
18
+ /** Optional when the key carries a `?` suffix or the string value does (`limit: "number?"`). */
19
+ type IsOptionalProp<key, def> = key extends `${string}?` ? true : def extends string ? Trim<def> extends `${string}?` ? true : false : false;
20
+ type PropName<key extends PropertyKey> = key extends `${infer name}?` ? name : key;
21
+ type RequiredProperties<def extends object> = {
22
+ -readonly [key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true ? HasDefault<def[key]> extends true ? PropName<key> : never : PropName<key>]-?: InferDef<def[key]>;
23
+ };
24
+ type OptionalProperties<def extends object> = {
25
+ -readonly [key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true ? HasDefault<def[key]> extends true ? never : PropName<key> : never]?: InferDef<def[key]>;
26
+ };
27
+ type Simplify<t> = {
28
+ [key in keyof t]: t[key];
29
+ };
30
+ type PropertiesOf<def extends object> = Simplify<RequiredProperties<def> & OptionalProperties<def>>;
31
+ type InferObject<def extends object> = "[string]" extends keyof def ? [DefinitionKeys<def>] extends [never] ? Record<string, InferDef<def["[string]"]>> : PropertiesOf<def> & Record<string, InferDef<def["[string]"]>> : PropertiesOf<def>;
32
+ /** Object-literal inference for fluent composition without re-inspecting the containing `Type`. */
33
+ export type InferObjectDef<def extends object> = InferObject<def>;
34
+ type InferLiteralDef<def> = def extends string ? InferString<def> : def extends object ? InferObjectLiteral<def> : unknown;
35
+ type LiteralRequiredProperties<def extends object> = {
36
+ -readonly [key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true ? HasDefault<def[key]> extends true ? PropName<key> : never : PropName<key>]-?: InferLiteralDef<def[key]>;
37
+ };
38
+ type LiteralOptionalProperties<def extends object> = {
39
+ -readonly [key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true ? HasDefault<def[key]> extends true ? never : PropName<key> : never]?: InferLiteralDef<def[key]>;
40
+ };
41
+ /** Object-literal-only inference for fluent branches; never inspects embedded schema types. */
42
+ export type InferObjectLiteral<def extends object> = Simplify<LiteralRequiredProperties<def> & LiteralOptionalProperties<def>>;
43
+ /** Infer the validated output type produced by a definition. */
44
+ export type InferDef<def = unknown> = def extends {
45
+ infer: infer output;
46
+ } ? output : def extends string ? InferString<def> : def extends readonly [infer element, "[]"] ? InferDef<element>[] : def extends object ? InferObject<def> : unknown;
47
+ /** Input-side defaults and morphs are not distinguished yet. */
48
+ export type InferDefIn<def = unknown> = InferDef<def>;
49
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Tree-walking validator used for a schema's first few calls (before the JIT
3
+ * compiler kicks in) and as the fallback for IR shapes the compiler declines.
4
+ *
5
+ * Semantics must stay in lockstep with `compile.ts`:
6
+ * - success returns the output value; the input is returned as-is unless the
7
+ * schema morphs (defaults, `"+": "delete"`, embedded stepped schemas), in
8
+ * which case a fresh object/array is produced and the input is untouched
9
+ * - failure returns an `OmpErrors` with a single fast-fail entry
10
+ */
11
+ import { OmpErrors } from "./errors.js";
12
+ import { type IR } from "./ir.js";
13
+ /** Validate `value` against `ir`; returns output value or `OmpErrors`. */
14
+ export declare function walk(ir: IR, value: unknown): unknown;
15
+ /**
16
+ * Detailed failure for a union: descend into the member the value was clearly
17
+ * aimed at — unique runtime-kind match, else an object member whose literal
18
+ * discriminant property (e.g. `type: "'computer_call'"`) equals the value's —
19
+ * for a precise nested error (paths, narrow messages) instead of the coarse
20
+ * "A or B" expectation.
21
+ */
22
+ export declare function unionFail(ir: IR & {
23
+ k: "union";
24
+ }, v: unknown, path: PropertyKey[]): OmpErrors;
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Schema IR and the ArkType-compatible definition parser.
3
+ *
4
+ * `parseDef` turns the definition subset this repo uses — string DSL
5
+ * (primitives, literals, unions, arrays, bounds, `number.integer`,
6
+ * `string.url`, inline `= literal` defaults), object literals (optional `?`
7
+ * keys, `"+"` undeclared-key policy, `"[string]"` index signatures), tuple
8
+ * `[def, "[]"]` arrays, and embedded `Type` instances — into a small IR tree
9
+ * consumed by the interpreter (`interp.ts`), the JIT compiler (`compile.ts`),
10
+ * and the JSON Schema emitter (`json-schema.ts`).
11
+ */
12
+ /** Brand carried by `Type` instances so the parser can embed them in defs. */
13
+ export declare const IR_BRAND: unique symbol;
14
+ /**
15
+ * The parser-facing surface of an embedded `Type` instance.
16
+ * `type.ts` implements this on every schema it creates.
17
+ */
18
+ export interface EmbeddableSchema {
19
+ [IR_BRAND]: true;
20
+ /** Structural IR of the schema (base type when runtime steps exist). */
21
+ ir: IR;
22
+ /** True when the schema carries `.pipe()`/`.narrow()` steps. */
23
+ hasSteps: boolean;
24
+ /** `.default()` payload; a function is a factory invoked per fill. */
25
+ defaultValue?: unknown;
26
+ hasDefault: boolean;
27
+ /** `.describe()` annotation, emitted into JSON Schema. */
28
+ description?: string;
29
+ /** Full validate+morph pipeline (identical to calling the schema). */
30
+ run(value: unknown): unknown;
31
+ }
32
+ /** Policy for undeclared object keys. */
33
+ export type Extras = "keep" | "reject" | "delete";
34
+ export type IR = {
35
+ k: "unknown";
36
+ desc?: string;
37
+ } | {
38
+ k: "null";
39
+ desc?: string;
40
+ } | {
41
+ k: "undefined";
42
+ desc?: string;
43
+ } | {
44
+ k: "boolean";
45
+ desc?: string;
46
+ } | {
47
+ k: "bigint";
48
+ desc?: string;
49
+ }
50
+ /** Any non-null object (the bare `object` keyword). */
51
+ | {
52
+ k: "anyobject";
53
+ desc?: string;
54
+ } | {
55
+ k: "string";
56
+ min?: number;
57
+ max?: number;
58
+ url?: boolean;
59
+ desc?: string;
60
+ } | {
61
+ k: "number";
62
+ min?: number;
63
+ max?: number;
64
+ xmin?: boolean;
65
+ xmax?: boolean;
66
+ int?: boolean;
67
+ desc?: string;
68
+ } | {
69
+ k: "lit";
70
+ v: unknown;
71
+ desc?: string;
72
+ } | {
73
+ k: "union";
74
+ members: IR[];
75
+ desc?: string;
76
+ } | {
77
+ k: "array";
78
+ el: IR;
79
+ min?: number;
80
+ max?: number;
81
+ desc?: string;
82
+ } | {
83
+ k: "object";
84
+ props: PropIR[];
85
+ index?: IR;
86
+ extras: Extras;
87
+ desc?: string;
88
+ }
89
+ /** Embedded schema with runtime steps; validated by calling `run`. */
90
+ | {
91
+ k: "sub";
92
+ schema: EmbeddableSchema;
93
+ desc?: string;
94
+ };
95
+ export interface PropIR {
96
+ key: string;
97
+ opt: boolean;
98
+ val: IR;
99
+ /** Default payload (value, or factory when `defFactory`); missing key is filled. */
100
+ def?: unknown;
101
+ defFactory?: boolean;
102
+ hasDefault?: boolean;
103
+ }
104
+ /** Definition input accepted by `type()` and object property values. */
105
+ export type Def = string | EmbeddableSchema | readonly Def[] | {
106
+ readonly [k: string]: Def;
107
+ };
108
+ /** Embed a schema value: inline pure structure, keep `sub` nodes for stepped schemas. */
109
+ export declare function embed(schema: EmbeddableSchema): IR;
110
+ /** Parse a definition (string DSL, object literal, tuple, or embedded schema) into IR. */
111
+ export declare function parseDef(def: Def): IR;
112
+ /** True when validating `ir` can produce an output different from its input. */
113
+ export declare function hasMorph(ir: IR): boolean;
114
+ /** Human-readable expectation for error messages, e.g. `"a string"`. */
115
+ export declare function expectedOf(ir: IR): string;
@@ -0,0 +1,8 @@
1
+ import type { IR } from "./ir.js";
2
+ export interface JsonSchemaOptions {
3
+ description?: string;
4
+ }
5
+ type JsonSchema = Record<string, unknown>;
6
+ /** Emit the draft-2020-12 JSON Schema represented by an IR tree. */
7
+ export declare function irToJsonSchema(ir: IR, options?: JsonSchemaOptions): JsonSchema;
8
+ export {};
@@ -0,0 +1,100 @@
1
+ import { OmpErrors } from "./errors.js";
2
+ import type { InferDef, InferObjectLiteral, InferString } from "./infer.js";
3
+ import { type Def, hasMorph, type IR, IR_BRAND } from "./ir.js";
4
+ /** Context passed to `.narrow()` / `.pipe()` callbacks. */
5
+ export interface NarrowContext {
6
+ /** Record `must be <expectation>` and signal failure. */
7
+ mustBe(expectation: string): false;
8
+ /** Record a custom problem and signal failure. */
9
+ reject(problem: string): false;
10
+ }
11
+ /** Options accepted by `Type.toJsonSchema` (ArkType-compatible; emission is always draft 2020-12). */
12
+ export interface ToJsonSchemaOptions {
13
+ target?: string;
14
+ dialect?: string;
15
+ fallback?: (ctx: {
16
+ base: Record<string, unknown>;
17
+ }) => unknown;
18
+ }
19
+ interface SchemaInference<out t> {
20
+ readonly [IR_BRAND]: true;
21
+ readonly infer: t;
22
+ }
23
+ /** A compiled schema: callable validator plus composition methods. */
24
+ export interface Type<out t = unknown> {
25
+ (data: unknown): t | OmpErrors;
26
+ readonly [IR_BRAND]: true;
27
+ /** Structural IR (base type; runtime steps live in `steps`). */
28
+ readonly ir: IR;
29
+ /** `.pipe()` / `.narrow()` steps applied after structural validation. */
30
+ readonly hasSteps: boolean;
31
+ readonly hasDefault: boolean;
32
+ readonly defaultValue?: unknown;
33
+ readonly description?: string;
34
+ /** Full validate+morph pipeline; identical to calling the schema. */
35
+ readonly run: (data: unknown) => unknown;
36
+ /** Inference-only output type (no runtime value). */
37
+ readonly infer: t;
38
+ /** Inference-only input type (no runtime value). */
39
+ readonly inferIn: t;
40
+ /** Structural + narrow check without running pipes. */
41
+ allows(data: unknown): data is t;
42
+ /** Validate and return output, throwing `TraversalError` on failure. */
43
+ assert(data: unknown): t;
44
+ /** JSON Schema (draft 2020-12) for this schema's structural base. */
45
+ toJsonSchema(options?: ToJsonSchemaOptions): Record<string, unknown>;
46
+ }
47
+ /** Schema returned by omptype builders, with precise object-literal composition inference. */
48
+ export interface FluentType<t = unknown> extends Type<t> {
49
+ describe(description: string): FluentType<t>;
50
+ default(value: t | (() => t)): FluentType<t>;
51
+ or<r>(def: SchemaInference<r>): FluentType<t | r>;
52
+ or<const def extends string>(def: def): FluentType<t | InferString<def>>;
53
+ or<const def extends Record<string, unknown>>(def: def): FluentType<t | InferObjectLiteral<def>>;
54
+ or(def: Def): FluentType<unknown>;
55
+ and<r>(def: SchemaInference<r>): FluentType<t & r>;
56
+ and<const def extends Record<string, unknown>>(def: def): FluentType<t & InferObjectLiteral<def>>;
57
+ and(def: Def): FluentType<unknown>;
58
+ array(): FluentType<t[]>;
59
+ atLeastLength(bound: number): FluentType<t>;
60
+ atMostLength(bound: number): FluentType<t>;
61
+ atLeast(bound: number): FluentType<t>;
62
+ atMost(bound: number): FluentType<t>;
63
+ pipe<r>(fn: (data: t, ctx: NarrowContext) => r): FluentType<Exclude<r, OmpErrors>>;
64
+ narrow<narrowed extends t>(fn: (data: t, ctx: NarrowContext) => data is narrowed): FluentType<narrowed>;
65
+ narrow(fn: (data: t, ctx: NarrowContext) => boolean): FluentType<t>;
66
+ }
67
+ /** Runtime constructor-like value used by ArkType-compatible `instanceof Type` checks. */
68
+ export declare const Type: () => void;
69
+ /**
70
+ * The `type()` builder: parses a definition into a callable schema.
71
+ *
72
+ * The `const def` generic drives static inference (`typeof schema.infer`);
73
+ * the runtime is definition-shape-agnostic, hence the cast.
74
+ */
75
+ export declare function type<const def>(def: def): FluentType<InferDef<def>>;
76
+ export declare namespace type {
77
+ /** Error aggregate returned by failed validations (`result instanceof type.errors`). */
78
+ const errors: typeof OmpErrors;
79
+ type errors = OmpErrors;
80
+ /** Keyword statics for fluent building, e.g. `type.number.atLeast(5)`. */
81
+ const string: FluentType<string>;
82
+ const number: FluentType<number>;
83
+ const boolean: FluentType<boolean>;
84
+ const unknown: FluentType<unknown>;
85
+ /** Union of literal values from a runtime array (`type.enumerated(...list)`). */
86
+ function enumerated<const values extends readonly unknown[]>(...values: values): FluentType<values[number]>;
87
+ /** Untyped builder for runtime-assembled definitions (`type.raw({...})`). */
88
+ function raw(def: unknown): BaseType;
89
+ }
90
+ export interface ScopeOptions {
91
+ jitless?: boolean;
92
+ }
93
+ /** ArkType-compatible scope wrapper; omptype's global builder is already lazy. */
94
+ export declare function scope(_aliases: Record<string, unknown>, _options?: ScopeOptions): {
95
+ type: typeof type;
96
+ };
97
+ /** A schema whose output type is not statically known (`type.raw` results). */
98
+ export type BaseType = FluentType<unknown>;
99
+ /** `hasMorph` re-export for diagnostics/tooling. */
100
+ export { hasMorph };