@linxiraos/pi-omptype 1.0.0
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 +58 -0
- package/README.md +129 -0
- package/dist/js/ark.js +16 -0
- package/dist/js/compile.js +942 -0
- package/dist/js/errors.js +394 -0
- package/dist/js/from-json-schema.js +234 -0
- package/dist/js/index.js +13 -0
- package/dist/js/infer.js +2 -0
- package/dist/js/interp.js +858 -0
- package/dist/js/ir.js +1700 -0
- package/dist/js/json-schema.js +312 -0
- package/dist/js/keywords.js +340 -0
- package/dist/js/type.js +3087 -0
- package/dist/js/typebox.js +368 -0
- package/dist/js/zod.js +269 -0
- package/dist/types/ark.d.ts +18 -0
- package/dist/types/compile.d.ts +7 -0
- package/dist/types/errors.d.ts +100 -0
- package/dist/types/from-json-schema.d.ts +9 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/infer.d.ts +165 -0
- package/dist/types/interp.d.ts +33 -0
- package/dist/types/ir.d.ts +235 -0
- package/dist/types/json-schema.d.ts +22 -0
- package/dist/types/keywords.d.ts +7 -0
- package/dist/types/type.d.ts +575 -0
- package/dist/types/typebox.d.ts +212 -0
- package/dist/types/zod.d.ts +100 -0
- package/package.json +71 -0
- package/src/ark.ts +20 -0
- package/src/compile.ts +1148 -0
- package/src/errors.ts +446 -0
- package/src/from-json-schema.ts +231 -0
- package/src/index.ts +13 -0
- package/src/infer.ts +442 -0
- package/src/interp.ts +765 -0
- package/src/ir.ts +1796 -0
- package/src/json-schema.ts +315 -0
- package/src/keywords.ts +380 -0
- package/src/type.ts +4010 -0
- package/src/typebox.ts +540 -0
- package/src/zod.ts +352 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { EmbeddableSchema } from "./ir.js";
|
|
2
|
+
import { type NarrowContext, type Type as OmpType, type ToJsonSchemaOptions } from "./type.js";
|
|
3
|
+
export interface Meta {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
default?: unknown;
|
|
7
|
+
examples?: unknown[];
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface StringOpts extends Meta {
|
|
11
|
+
minLength?: number;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
pattern?: string;
|
|
14
|
+
format?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface NumberOpts extends Meta {
|
|
17
|
+
minimum?: number;
|
|
18
|
+
maximum?: number;
|
|
19
|
+
exclusiveMinimum?: number;
|
|
20
|
+
exclusiveMaximum?: number;
|
|
21
|
+
multipleOf?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ArrayOpts extends Meta {
|
|
24
|
+
minItems?: number;
|
|
25
|
+
maxItems?: number;
|
|
26
|
+
uniqueItems?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ObjectOpts extends Meta {
|
|
29
|
+
additionalProperties?: boolean | AnySchema;
|
|
30
|
+
}
|
|
31
|
+
declare const OPTIONAL_INNER: unique symbol;
|
|
32
|
+
declare const OBJECT_INFO: unique symbol;
|
|
33
|
+
export interface TypeBoxValidationFailure {
|
|
34
|
+
message: string;
|
|
35
|
+
}
|
|
36
|
+
export type TypeBoxSafeParseResult<T> = {
|
|
37
|
+
success: true;
|
|
38
|
+
data: T;
|
|
39
|
+
} | {
|
|
40
|
+
success: false;
|
|
41
|
+
error: TypeBoxValidationFailure;
|
|
42
|
+
};
|
|
43
|
+
interface LegacyTypeBoxCompat<T> {
|
|
44
|
+
/** TypeBox compatibility validator used by legacy extension loaders. */
|
|
45
|
+
__validator(data: unknown): T | TypeBoxValidationFailure;
|
|
46
|
+
/** Zod-style compatibility parser used by legacy extensions. */
|
|
47
|
+
safeParse(input: unknown): TypeBoxSafeParseResult<T>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Erased schema surface accepted anywhere this facade takes a schema, native
|
|
51
|
+
* omptype schemas included (those carry no legacy compat members).
|
|
52
|
+
*
|
|
53
|
+
* Members use method syntax so parameter positions stay bivariant: the typed
|
|
54
|
+
* {@link TTyped} form is invariant in its static type (its `in`/`out`
|
|
55
|
+
* validators are), so a concrete `TString` is not assignable to
|
|
56
|
+
* `TTyped<unknown>`. Erasing here is what keeps `TString`, `TObject<…>` and
|
|
57
|
+
* friends assignable to a plain schema annotation.
|
|
58
|
+
*/
|
|
59
|
+
export interface AnySchema extends EmbeddableSchema {
|
|
60
|
+
(data: unknown): unknown;
|
|
61
|
+
readonly infer: unknown;
|
|
62
|
+
readonly hasSteps: boolean;
|
|
63
|
+
toJsonSchema(options?: ToJsonSchemaOptions): Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Every schema this facade returns: the TypeBox `TSchema` analog. Erased like
|
|
67
|
+
* {@link AnySchema}, plus the legacy compat members builder results carry.
|
|
68
|
+
*/
|
|
69
|
+
export interface TSchema extends AnySchema {
|
|
70
|
+
/** TypeBox compatibility validator used by legacy extension loaders. */
|
|
71
|
+
__validator(data: unknown): unknown;
|
|
72
|
+
/** Zod-style compatibility parser used by legacy extensions. */
|
|
73
|
+
safeParse(input: unknown): TypeBoxSafeParseResult<unknown>;
|
|
74
|
+
}
|
|
75
|
+
/** Schema carrying a statically known type; every `TXxx` alias resolves here. */
|
|
76
|
+
export type TTyped<T> = OmpType<T> & LegacyTypeBoxCompat<T>;
|
|
77
|
+
export type Static<T extends AnySchema> = T["infer"];
|
|
78
|
+
export type TAny = TTyped<unknown>;
|
|
79
|
+
export type TUnknown = TTyped<unknown>;
|
|
80
|
+
export type TNever = TTyped<never>;
|
|
81
|
+
export type TNull = TTyped<null>;
|
|
82
|
+
export type TString = TTyped<string>;
|
|
83
|
+
export type TNumber = TTyped<number>;
|
|
84
|
+
export type TInteger = TTyped<number>;
|
|
85
|
+
export type TBoolean = TTyped<boolean>;
|
|
86
|
+
export type TLiteral<V extends string | number | boolean | null> = TTyped<V>;
|
|
87
|
+
export type TArray<E extends AnySchema> = TTyped<Static<E>[]>;
|
|
88
|
+
export type TTuple<E extends readonly AnySchema[] = readonly AnySchema[]> = TTyped<{
|
|
89
|
+
-readonly [K in keyof E]: Static<E[K]>;
|
|
90
|
+
}>;
|
|
91
|
+
export type TOptional<E extends AnySchema> = TTyped<Static<E> | undefined> & {
|
|
92
|
+
readonly [OPTIONAL_INNER]: E;
|
|
93
|
+
};
|
|
94
|
+
export type TUnion<E extends readonly AnySchema[] = readonly AnySchema[]> = TTyped<Static<E[number]>>;
|
|
95
|
+
export type TIntersect<E extends readonly AnySchema[] = readonly AnySchema[]> = TTyped<UnionToIntersection<Static<E[number]>>>;
|
|
96
|
+
export type TEnum<E extends readonly (string | number)[] = readonly (string | number)[]> = TTyped<E[number]>;
|
|
97
|
+
export type TRecord<K extends AnySchema, V extends AnySchema> = TTyped<Record<Extract<Static<K>, PropertyKey>, Static<V>>>;
|
|
98
|
+
export type TNullable<E extends AnySchema> = TTyped<Static<E> | null>;
|
|
99
|
+
export type TReadonly<E extends AnySchema> = TTyped<Readonly<Static<E>>>;
|
|
100
|
+
export type TUnsafe<T = unknown> = TTyped<T>;
|
|
101
|
+
type OptionalKeys<P extends Record<string, AnySchema>> = {
|
|
102
|
+
[K in keyof P]-?: P[K] extends {
|
|
103
|
+
readonly [OPTIONAL_INNER]: AnySchema;
|
|
104
|
+
} ? K : never;
|
|
105
|
+
}[keyof P];
|
|
106
|
+
type RequiredKeys<P extends Record<string, AnySchema>> = Exclude<keyof P, OptionalKeys<P>>;
|
|
107
|
+
type ObjectStatic<P extends Record<string, AnySchema>> = {
|
|
108
|
+
[K in RequiredKeys<P>]: Static<P[K]>;
|
|
109
|
+
} & {
|
|
110
|
+
[K in OptionalKeys<P>]?: Exclude<Static<P[K]>, undefined>;
|
|
111
|
+
};
|
|
112
|
+
export type TObject<P extends Record<string, AnySchema> = Record<string, AnySchema>> = TTyped<ObjectStatic<P>>;
|
|
113
|
+
type RequiredProps<P extends Record<string, AnySchema>> = {
|
|
114
|
+
[K in keyof P]: P[K] extends TOptional<infer E> ? E : P[K];
|
|
115
|
+
};
|
|
116
|
+
interface RuntimeType<T> extends OmpType<T> {
|
|
117
|
+
[OPTIONAL_INNER]?: AnySchema;
|
|
118
|
+
[OBJECT_INFO]?: ObjectInfo;
|
|
119
|
+
describe(description: string): RuntimeType<T>;
|
|
120
|
+
default(value: T | (() => T)): RuntimeType<T>;
|
|
121
|
+
or<schema extends AnySchema>(schema: schema): RuntimeType<T | Static<schema>>;
|
|
122
|
+
and<schema extends AnySchema>(schema: schema): RuntimeType<T & Static<schema>>;
|
|
123
|
+
array(): RuntimeType<T[]>;
|
|
124
|
+
atLeastLength(bound: number): RuntimeType<T>;
|
|
125
|
+
atMostLength(bound: number): RuntimeType<T>;
|
|
126
|
+
atLeast(bound: number): RuntimeType<T>;
|
|
127
|
+
atMost(bound: number): RuntimeType<T>;
|
|
128
|
+
narrow<N extends T>(predicate: (value: T, ctx: NarrowContext) => value is N): RuntimeType<N>;
|
|
129
|
+
narrow(predicate: (value: T, ctx: NarrowContext) => boolean): RuntimeType<T>;
|
|
130
|
+
}
|
|
131
|
+
type CompatRuntime<T> = RuntimeType<T> & LegacyTypeBoxCompat<T>;
|
|
132
|
+
type ObjectInfo = {
|
|
133
|
+
props: Record<string, AnySchema>;
|
|
134
|
+
additionalProperties?: boolean | AnySchema;
|
|
135
|
+
};
|
|
136
|
+
declare function tString(opts?: StringOpts): TString;
|
|
137
|
+
declare function tLiteral<const V extends string | number | boolean | null>(value: V, opts?: Meta): TLiteral<V>;
|
|
138
|
+
declare function tNever(opts?: Meta): TNever;
|
|
139
|
+
declare function tUnion<const E extends readonly AnySchema[]>(schemas: E, opts?: Meta): TUnion<E>;
|
|
140
|
+
declare function tIntersect<const E extends readonly AnySchema[]>(schemas: E, opts?: Meta): TTyped<UnionToIntersection<Static<E[number]>>>;
|
|
141
|
+
type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends (value: infer I) => void ? I : never;
|
|
142
|
+
declare function tEnum<const E extends Record<string, string | number> | readonly (string | number)[]>(values: E, opts?: Meta): TTyped<E extends readonly (infer V)[] ? V : E[keyof E]>;
|
|
143
|
+
declare function tArray<E extends AnySchema>(item: E, opts?: ArrayOpts): TArray<E>;
|
|
144
|
+
declare function tTuple<const E extends readonly AnySchema[]>(items: E, opts?: Meta): TTuple<E>;
|
|
145
|
+
declare function tObject<const P extends Record<string, AnySchema>>(properties: P, opts?: ObjectOpts): TObject<P>;
|
|
146
|
+
declare function tRecord<K extends AnySchema, V extends AnySchema>(key: K, value: V, opts?: Meta): TRecord<K, V>;
|
|
147
|
+
declare function tOptional<E extends AnySchema>(schema: E, opts?: Meta): TOptional<E>;
|
|
148
|
+
declare function tNullable<E extends AnySchema>(schema: E, opts?: Meta): TTyped<Static<E> | null>;
|
|
149
|
+
declare function tPartial<P extends Record<string, AnySchema>>(schema: TObject<P>): TTyped<Partial<ObjectStatic<P>>>;
|
|
150
|
+
declare function tRequired<P extends Record<string, AnySchema>>(schema: TObject<P>): TObject<RequiredProps<P>>;
|
|
151
|
+
declare function tPick<P extends Record<string, AnySchema>, const K extends readonly (keyof P)[]>(schema: TObject<P>, keys: K): TObject<Pick<P, K[number]>>;
|
|
152
|
+
declare function tOmit<P extends Record<string, AnySchema>, const K extends readonly (keyof P)[]>(schema: TObject<P>, keys: K): TObject<Omit<P, K[number]>>;
|
|
153
|
+
declare function tComposite<const E extends readonly TObject<Record<string, AnySchema>>[]>(schemas: E, opts?: ObjectOpts): TTyped<UnionToIntersection<Static<E[number]>>>;
|
|
154
|
+
declare function tUnsafe<T = unknown>(_jsonSchema?: Record<string, unknown>): TUnsafe<T>;
|
|
155
|
+
export declare const Type: {
|
|
156
|
+
readonly String: typeof tString;
|
|
157
|
+
readonly Number: (opts?: NumberOpts) => TNumber;
|
|
158
|
+
readonly Integer: (opts?: NumberOpts) => TNumber;
|
|
159
|
+
readonly Boolean: (opts?: Meta) => CompatRuntime<boolean>;
|
|
160
|
+
readonly Null: (opts?: Meta) => CompatRuntime<null>;
|
|
161
|
+
readonly Any: (opts?: Meta) => CompatRuntime<unknown>;
|
|
162
|
+
readonly Unknown: (opts?: Meta) => CompatRuntime<unknown>;
|
|
163
|
+
readonly Never: typeof tNever;
|
|
164
|
+
readonly Literal: typeof tLiteral;
|
|
165
|
+
readonly Union: typeof tUnion;
|
|
166
|
+
readonly Intersect: typeof tIntersect;
|
|
167
|
+
readonly Enum: typeof tEnum;
|
|
168
|
+
readonly Array: typeof tArray;
|
|
169
|
+
readonly Tuple: typeof tTuple;
|
|
170
|
+
readonly Object: typeof tObject;
|
|
171
|
+
readonly Record: typeof tRecord;
|
|
172
|
+
readonly Optional: typeof tOptional;
|
|
173
|
+
readonly Nullable: typeof tNullable;
|
|
174
|
+
readonly Readonly: <E extends AnySchema>(schema: E) => TReadonly<E>;
|
|
175
|
+
readonly Partial: typeof tPartial;
|
|
176
|
+
readonly Required: typeof tRequired;
|
|
177
|
+
readonly Pick: typeof tPick;
|
|
178
|
+
readonly Omit: typeof tOmit;
|
|
179
|
+
readonly Composite: typeof tComposite;
|
|
180
|
+
readonly Unsafe: typeof tUnsafe;
|
|
181
|
+
};
|
|
182
|
+
export type TypeBuilder = typeof Type;
|
|
183
|
+
declare const _default: {
|
|
184
|
+
Type: {
|
|
185
|
+
readonly String: typeof tString;
|
|
186
|
+
readonly Number: (opts?: NumberOpts) => TNumber;
|
|
187
|
+
readonly Integer: (opts?: NumberOpts) => TNumber;
|
|
188
|
+
readonly Boolean: (opts?: Meta) => CompatRuntime<boolean>;
|
|
189
|
+
readonly Null: (opts?: Meta) => CompatRuntime<null>;
|
|
190
|
+
readonly Any: (opts?: Meta) => CompatRuntime<unknown>;
|
|
191
|
+
readonly Unknown: (opts?: Meta) => CompatRuntime<unknown>;
|
|
192
|
+
readonly Never: typeof tNever;
|
|
193
|
+
readonly Literal: typeof tLiteral;
|
|
194
|
+
readonly Union: typeof tUnion;
|
|
195
|
+
readonly Intersect: typeof tIntersect;
|
|
196
|
+
readonly Enum: typeof tEnum;
|
|
197
|
+
readonly Array: typeof tArray;
|
|
198
|
+
readonly Tuple: typeof tTuple;
|
|
199
|
+
readonly Object: typeof tObject;
|
|
200
|
+
readonly Record: typeof tRecord;
|
|
201
|
+
readonly Optional: typeof tOptional;
|
|
202
|
+
readonly Nullable: typeof tNullable;
|
|
203
|
+
readonly Readonly: <E extends AnySchema>(schema: E) => TReadonly<E>;
|
|
204
|
+
readonly Partial: typeof tPartial;
|
|
205
|
+
readonly Required: typeof tRequired;
|
|
206
|
+
readonly Pick: typeof tPick;
|
|
207
|
+
readonly Omit: typeof tOmit;
|
|
208
|
+
readonly Composite: typeof tComposite;
|
|
209
|
+
readonly Unsafe: typeof tUnsafe;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
export default _default;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type Type } from "./type.js";
|
|
2
|
+
interface OptionalSchemaMarker {
|
|
3
|
+
readonly _optional: true;
|
|
4
|
+
}
|
|
5
|
+
interface RefineOptions {
|
|
6
|
+
message?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ZodLikeIssue {
|
|
10
|
+
path: PropertyKey[];
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export type ZodLikeSafeParseResult<Out> = {
|
|
14
|
+
success: true;
|
|
15
|
+
data: Out;
|
|
16
|
+
} | {
|
|
17
|
+
success: false;
|
|
18
|
+
error: {
|
|
19
|
+
message: string;
|
|
20
|
+
issues: ZodLikeIssue[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** A callable omptype schema carrying the Zod-v4-style fluent surface. */
|
|
24
|
+
export interface ZodLikeSchema<out Out> extends Type<Out, unknown> {
|
|
25
|
+
readonly _output: Out;
|
|
26
|
+
/** @internal Used while composing object property IR. */
|
|
27
|
+
readonly isOptional: boolean;
|
|
28
|
+
parse(value: unknown): Out;
|
|
29
|
+
safeParse(value: unknown): ZodLikeSafeParseResult<Out>;
|
|
30
|
+
min(bound: number): ZodLikeSchema<Out>;
|
|
31
|
+
max(bound: number): ZodLikeSchema<Out>;
|
|
32
|
+
int(): ZodLikeSchema<Out>;
|
|
33
|
+
positive(): ZodLikeSchema<Out>;
|
|
34
|
+
nonnegative(): ZodLikeSchema<Out>;
|
|
35
|
+
regex(expression: RegExp, message?: string): ZodLikeSchema<Out>;
|
|
36
|
+
url(): ZodLikeSchema<Out>;
|
|
37
|
+
optional(): ZodLikeSchema<Out | undefined> & OptionalSchemaMarker;
|
|
38
|
+
nullable(): ZodLikeSchema<Out | null>;
|
|
39
|
+
default(value: Exclude<Out, undefined> | (() => Exclude<Out, undefined>)): ZodLikeSchema<Exclude<Out, undefined>>;
|
|
40
|
+
describe(description: string): ZodLikeSchema<Out>;
|
|
41
|
+
refine(predicate: (value: Out) => unknown, messageOrOptions?: string | RefineOptions): ZodLikeSchema<Out>;
|
|
42
|
+
transform<Next>(transformer: (value: Out) => Next): ZodLikeSchema<Next>;
|
|
43
|
+
catch(fallback: Out | (() => Out)): ZodLikeSchema<Out>;
|
|
44
|
+
strict(): ZodLikeSchema<Out>;
|
|
45
|
+
passthrough(): ZodLikeSchema<Out & Record<string, unknown>>;
|
|
46
|
+
strip(): ZodLikeSchema<Out>;
|
|
47
|
+
partial(): Out extends object ? ZodLikeSchema<Partial<Out>> : ZodLikeSchema<Out>;
|
|
48
|
+
}
|
|
49
|
+
export type infer<T> = T extends {
|
|
50
|
+
readonly _output: infer Out;
|
|
51
|
+
} ? Out : never;
|
|
52
|
+
type SchemaOutput<Schema> = Schema extends {
|
|
53
|
+
readonly _output: infer Out;
|
|
54
|
+
} ? Out : never;
|
|
55
|
+
type Shape = Readonly<Record<string, ZodLikeSchema<unknown>>>;
|
|
56
|
+
type ObjectOutput<S extends Shape> = {
|
|
57
|
+
-readonly [K in keyof S as S[K] extends OptionalSchemaMarker ? never : K]: SchemaOutput<S[K]>;
|
|
58
|
+
} & {
|
|
59
|
+
-readonly [K in keyof S as S[K] extends OptionalSchemaMarker ? K : never]?: SchemaOutput<S[K]>;
|
|
60
|
+
};
|
|
61
|
+
type Simplify<T> = {
|
|
62
|
+
[K in keyof T]: T[K];
|
|
63
|
+
};
|
|
64
|
+
type UnionOutput<Schemas extends readonly ZodLikeSchema<unknown>[]> = SchemaOutput<Schemas[number]>;
|
|
65
|
+
export declare const string: () => ZodLikeSchema<string>;
|
|
66
|
+
export declare const number: () => ZodLikeSchema<number>;
|
|
67
|
+
export declare const boolean: () => ZodLikeSchema<boolean>;
|
|
68
|
+
export declare const literal: <const Value>(value: Value) => ZodLikeSchema<Value>;
|
|
69
|
+
declare const enumSchema: <const Values extends readonly [string, ...string[]]>(values: Values) => ZodLikeSchema<Values[number]>;
|
|
70
|
+
export { enumSchema as enum };
|
|
71
|
+
export declare const union: <const Schemas extends readonly [ZodLikeSchema<unknown>, ZodLikeSchema<unknown>, ...ZodLikeSchema<unknown>[]]>(schemas: Schemas) => ZodLikeSchema<UnionOutput<Schemas>>;
|
|
72
|
+
export declare const array: <Element>(element: ZodLikeSchema<Element>) => ZodLikeSchema<Element[]>;
|
|
73
|
+
export declare const object: <const S extends Shape>(shape: S) => ZodLikeSchema<Simplify<ObjectOutput<S>>>;
|
|
74
|
+
export declare const record: <Key extends string, Value>(keySchema: ZodLikeSchema<Key>, valueSchema: ZodLikeSchema<Value>) => ZodLikeSchema<Record<string, Value>>;
|
|
75
|
+
export declare const unknown: () => ZodLikeSchema<unknown>;
|
|
76
|
+
export declare const any: () => ZodLikeSchema<unknown>;
|
|
77
|
+
declare const nullSchema: () => ZodLikeSchema<null>;
|
|
78
|
+
declare const undefinedSchema: () => ZodLikeSchema<undefined>;
|
|
79
|
+
export { nullSchema as null, undefinedSchema as undefined };
|
|
80
|
+
/** Runtime `z.*` facade, merged with the `z.infer` type namespace below. */
|
|
81
|
+
export declare const z: {
|
|
82
|
+
string: typeof string;
|
|
83
|
+
number: typeof number;
|
|
84
|
+
boolean: typeof boolean;
|
|
85
|
+
literal: typeof literal;
|
|
86
|
+
enum: typeof enumSchema;
|
|
87
|
+
union: typeof union;
|
|
88
|
+
array: typeof array;
|
|
89
|
+
object: typeof object;
|
|
90
|
+
record: typeof record;
|
|
91
|
+
unknown: typeof unknown;
|
|
92
|
+
any: typeof any;
|
|
93
|
+
null: typeof nullSchema;
|
|
94
|
+
undefined: typeof undefinedSchema;
|
|
95
|
+
};
|
|
96
|
+
export declare namespace z {
|
|
97
|
+
type infer<Schema> = Schema extends {
|
|
98
|
+
readonly _output: infer Out;
|
|
99
|
+
} ? Out : never;
|
|
100
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@linxiraos/pi-omptype",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "ArkType-compatible runtime schema validation with lazy JIT compilation",
|
|
6
|
+
"homepage": "https://omp.sh",
|
|
7
|
+
"author": "Can Boluk",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Linxira-OS/linxira-zeta.git",
|
|
12
|
+
"directory": "packages/omptype"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/can1357/oh-my-pi/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"schema",
|
|
19
|
+
"validation",
|
|
20
|
+
"arktype",
|
|
21
|
+
"jit"
|
|
22
|
+
],
|
|
23
|
+
"main": "./dist/js/index.js",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"check": "biome check . && bun run check:types",
|
|
27
|
+
"check:types": "tsgo -p tsconfig.json --noEmit",
|
|
28
|
+
"lint": "biome lint .",
|
|
29
|
+
"fix": "biome check --write --unsafe .",
|
|
30
|
+
"fmt": "biome format --write .",
|
|
31
|
+
"test": "bun test --parallel",
|
|
32
|
+
"bench": "bun bench/bench.ts"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@ark/attest": "0.56.3",
|
|
36
|
+
"@ark/schema": "0.56.2",
|
|
37
|
+
"@ark/util": "0.56.2",
|
|
38
|
+
"@sinclair/typebox": "^0.34.0",
|
|
39
|
+
"@types/bun": "^1.3.14",
|
|
40
|
+
"arkregex": "0.0.8",
|
|
41
|
+
"arktype": "2.2.3"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20",
|
|
45
|
+
"bun": ">=1.3.14"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"src",
|
|
49
|
+
"README.md",
|
|
50
|
+
"CHANGELOG.md",
|
|
51
|
+
"dist/types",
|
|
52
|
+
"dist/js"
|
|
53
|
+
],
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/types/index.d.ts",
|
|
57
|
+
"bun": "./src/index.ts",
|
|
58
|
+
"default": "./dist/js/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./*": {
|
|
61
|
+
"types": "./dist/types/*.d.ts",
|
|
62
|
+
"bun": "./src/*.ts",
|
|
63
|
+
"default": "./dist/js/*.js"
|
|
64
|
+
},
|
|
65
|
+
"./*.js": {
|
|
66
|
+
"types": "./dist/types/*.d.ts",
|
|
67
|
+
"bun": "./src/*.ts",
|
|
68
|
+
"default": "./dist/js/*.js"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/ark.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArkType compatibility facade — `@linxiraos/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 "@linxiraos/pi-omptype/ark"` and nothing else changes. New code should
|
|
7
|
+
* import `@linxiraos/pi-omptype` directly.
|
|
8
|
+
*
|
|
9
|
+
* Compatibility affordance: `ArkError` / `ArkErrors` alias `OmpError` /
|
|
10
|
+
* `OmpErrors`. All schema builders, including recursive `scope()`, are
|
|
11
|
+
* re-exported unchanged.
|
|
12
|
+
*/
|
|
13
|
+
import { OmpError, OmpErrors } from "./errors";
|
|
14
|
+
|
|
15
|
+
export * from "./index";
|
|
16
|
+
|
|
17
|
+
export const ArkError = OmpError;
|
|
18
|
+
export type ArkError = OmpError;
|
|
19
|
+
export const ArkErrors = OmpErrors;
|
|
20
|
+
export type ArkErrors = OmpErrors;
|