bc39ffa265
- Introduce `@oh-my-pi/omptype` as a new ArkType-compatible schema validation package featuring a lazy JIT runtime, JSON Schema emission, and compatibility adapters. - Replace `arktype` across workspace packages and test utilities with `@oh-my-pi/omptype`. - Add benchmark suites, tests, and documentation for the new validation engine and adapters. - Update workspace build, test runner, and release configurations to include the new package.
27 lines
809 B
TypeScript
27 lines
809 B
TypeScript
import { spyOn } from "bun:test";
|
|
import * as arktype from "@oh-my-pi/omptype";
|
|
|
|
declare global {
|
|
var __computerSchemaConstructionCount: number;
|
|
}
|
|
|
|
globalThis.__computerSchemaConstructionCount = 0;
|
|
const originalType = arktype.type;
|
|
const invokeType = originalType as unknown as (definition: unknown) => unknown;
|
|
const countedType = new Proxy(originalType, {
|
|
apply(_target, thisArg, args) {
|
|
const definition = args[0];
|
|
if (
|
|
definition !== null &&
|
|
typeof definition === "object" &&
|
|
Object.hasOwn(definition, "code") &&
|
|
Object.hasOwn(definition, "read_only?")
|
|
) {
|
|
globalThis.__computerSchemaConstructionCount += 1;
|
|
}
|
|
return Reflect.apply(invokeType, thisArg, args);
|
|
},
|
|
});
|
|
const typeSpy = spyOn(arktype, "type").mockImplementation(countedType);
|
|
Object.assign(typeSpy, originalType);
|