@buckeyestudio/omptype 18.4.13

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,76 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [18.2.1] - 2026-09-15
6
+
7
+ ### Added
8
+
9
+ - Added `trim()`, `superRefine()`, and one-argument `record()` support to the Zod compatibility facade ([#12011](https://github.com/can1357/oh-my-pi/pull/12011) by [@bnivanov](https://github.com/bnivanov)).
10
+
11
+ ## [17.3.1] - 2026-08-13
12
+
13
+ ### Fixed
14
+
15
+ - Fixed TypeBox adapter omitting pattern, non-URL format, and multipleOf constraints from the emitted JSON Schema.
16
+
17
+ ## [17.3.0] - 2026-08-13
18
+
19
+ ### Added
20
+
21
+ - Added `type.withJsonSchema(schema, json)` to wrap a validation-only schema, ensuring JSON Schema emission yields the provided `json` verbatim even when nested inside objects, arrays, or unions. Schemas with defaults or output-changing morphs are rejected to prevent transformed outputs from being discarded.
22
+
23
+ ## [17.2.10] - 2026-08-06
24
+
25
+ ### Changed
26
+
27
+ - Reimplemented the Zod compatibility facade (`@oh-my-pi/omptype/zod`) to run purely on internal mechanics, removing the dependency on `zod`.
28
+
29
+ ## [17.2.9] - 2026-08-05
30
+
31
+ ### Fixed
32
+
33
+ - Fixed the TypeBox adapter emitting an invalid left-bound-only DSL for min-only numeric schemas (e.g. `Type.Integer({ minimum: 1 })`), which threw `left bound requires a corresponding right bound` and broke extension tool loading ([#7648](https://github.com/can1357/oh-my-pi/issues/7648)).
34
+
35
+ ## [17.2.8] - 2026-08-04
36
+
37
+ ### Added
38
+
39
+ - Added `io: 'input'` and `io: 'output'` options to `toJsonSchema()`, supporting input validation shapes and piped `.to()` target types
40
+ - Added Standard Schema V1 interop: every schema exposes `~standard` with synchronous validation, enabling direct use with `@t3-oss/env`, tRPC, and other Standard Schema consumers.
41
+ - Added `fromJsonSchema()`, rebuilding callable schemas from JSON Schema documents (draft-07 / draft-2020-12 structural keywords, string formats, `$defs` recursion, enums, and `anyOf`/`oneOf`/`allOf` composition) — the inverse of `Type.toJsonSchema()`.
42
+ - Added `$defs`/`$ref` emission for recursive alias schemas in `toJsonSchema()` (draft-07 converts to `definitions`), preventing unbounded recursion on cyclic scopes.
43
+ - Added `AnyType`, a minimal structural constraint for generic functions accepting any schema without descending the recursive fluent surface.
44
+ - Root `.default()` values now materialize for `undefined` input in direct calls and at the Standard Schema boundary (factories run per call).
45
+ - `.narrow()`/`.filter()` boolean overloads accept `OmpErrors` returns, so `cond || ctx.reject(...)` recipes typecheck.
46
+
47
+ ### Changed
48
+
49
+ - Restored low-overhead schema construction by lazily activating advanced normalization and compatibility machinery.
50
+ - `.default()` is typed input-side (`i | (() => i)`) and marks the schema's input as optional (`i | undefined`).
51
+ - Parse keywords (`string.integer.parse`, `parse.number`, ...) now infer their morph output inside union strings, and input-side inference is union-aware.
52
+ - Object-literal inference for `.merge()`/`.or()`/`.and()` unwraps embedded schema values (output and input sides).
53
+
54
+ ### Fixed
55
+
56
+ - Alias intersections defer through memoized lazy nodes, so cyclic scope schemas no longer overflow the stack in `.and()` or morph-union determinism checks.
57
+
58
+ ## [17.2.7] - 2026-08-03
59
+
60
+ ### Added
61
+
62
+ - Introduced omptype, an ArkType-compatible schema validation library featuring a lazy JIT runtime that compiles specialized validators on the third call for ultra-fast hot-path validation and low construction overhead.
63
+ - Added support for a rich string definition DSL (primitives, literals, unions, arrays, bounds, inline defaults, and optional keys), object definitions (including index signatures and strict key rejection/deletion), and comprehensive composition methods (.or, .and, .array, .pipe, .narrow, .describe, .default, .allows, .assert).
64
+ - Added TypeBox-style (@oh-my-pi/omptype/typebox) and Zod-style (@oh-my-pi/omptype/zod) authoring adapters that produce native omptype schemas.
65
+ - Added support for recursive named scopes, modules, runtime generics, fixed/optional/variadic tuples, Date literals/bounds, disjointness-aware intersections, separate input/output inference, and draft-2020-12 JSON Schema emission.
66
+ - Shipped transpiled ESM and TypeScript declarations in the npm package to support plain Node.js environments, while preserving TS source resolution for Bun consumers.
67
+
68
+ ### Changed
69
+
70
+ - Optimized the lazy JIT compiler to support tuples, refinements, morphs, intersections, instances, and recursive aliases, while reducing schema construction overhead.
71
+
72
+ ### Fixed
73
+
74
+ - Fixed a TypeScript compiler error (TS2589: "type instantiation is excessively deep") when using generic fluent composition methods on nested schemas.
75
+ - Fixed type.raw() results (BaseType) to correctly expose fluent composition methods like .array(), .or(), and .pipe().
76
+ - Fixed an issue in the TypeBox adapter where keyword-carrying schemas (e.g., uniqueItems arrays) would throw an error during JSON Schema emission.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Can Bölük
4
+ Copyright (c) 2026 Stencil Labs, Inc.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # @buckeyestudio/omptype
2
+
3
+ Fast, ArkType-compatible schema validation for JavaScript and TypeScript.
4
+ Schemas start with a small interpreter and lazily compile after repeated use,
5
+ keeping construction cheap without giving up hot-path validation speed.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install @buckeyestudio/omptype
11
+ # or
12
+ bun add @buckeyestudio/omptype
13
+ ```
14
+
15
+ Runs on Node 20+ (published as compiled ESM with bundled type declarations)
16
+ and Bun 1.3.14+ (which resolves the TypeScript source directly via the `bun`
17
+ export condition). No runtime dependencies.
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import { type } from "@buckeyestudio/omptype";
23
+
24
+ const Config = type({
25
+ name: "string",
26
+ "retries?": "number.integer >= 0",
27
+ enabled: "boolean = true",
28
+ });
29
+
30
+ const config = Config.assert({ name: "worker" });
31
+ // { name: "worker", enabled: true }
32
+
33
+ const result = Config({ name: 42 });
34
+ if (result instanceof type.errors) {
35
+ console.error(result.summary);
36
+ }
37
+ ```
38
+
39
+ Schemas are callable and expose composition (`.or()`, `.and()`, `.array()`,
40
+ `.pipe()`, `.narrow()`), object transforms (`.pick()`, `.omit()`, `.partial()`,
41
+ `.required()`, `.merge()`, `.map()`), refinements, semantic comparison, error
42
+ configuration, and JSON Schema emission.
43
+
44
+ Built-in keyword modules include `type.string.email`, `type.string.uuid.v4`,
45
+ `type.string.date.iso.parse`, `type.string.normalize.NFKC`,
46
+ `type.number.integer`, and the parsers under `type.parse`.
47
+
48
+ ## Named and recursive schemas
49
+
50
+ ```ts
51
+ const models = type
52
+ .scope({
53
+ User: { name: "string", "manager?": "User" },
54
+ Users: "User[]",
55
+ PublicUser: "Pick<User, 'name'>",
56
+ })
57
+ .export();
58
+
59
+ models.User.assert({ name: "Ada", manager: { name: "Grace" } });
60
+ ```
61
+
62
+ Scopes resolve aliases lazily, including cycles. `type.module()` exports a
63
+ scope directly, `type.define()` preserves literal definitions, and
64
+ `type.generic("<value>", definition)` builds parameterized runtime schemas.
65
+
66
+ Failed validation returns `OmpErrors`; each entry exposes `code`, `path`,
67
+ `expected`, `actual`, `problem`, and `message`, while the aggregate exposes
68
+ `summary` and `byPath`. `.configure()` accepts string or callback overrides for
69
+ error text. `.toJsonSchema()` accepts `target`, `dialect`, and `fallback`
70
+ options.
71
+
72
+ ## Compatibility adapters
73
+
74
+ TypeBox-style and Zod-style builders produce native omptype schemas:
75
+
76
+ ```ts
77
+ import { Type, type Static } from "@buckeyestudio/omptype/typebox";
78
+ import { z } from "@buckeyestudio/omptype/zod";
79
+
80
+ const TypeBoxUser = Type.Object({ name: Type.String() });
81
+ type TypeBoxUser = Static<typeof TypeBoxUser>;
82
+
83
+ const ZodUser = z.object({ name: z.string() });
84
+ const user = ZodUser.parse({ name: "Ada" });
85
+ ```
86
+
87
+ `@buckeyestudio/omptype/ark` provides the repository's ArkType compatibility facade
88
+ and re-exports the same `type` and `scope` implementations.
89
+
90
+ ## Performance
91
+
92
+ Run the benchmark from the repository root:
93
+
94
+ ```sh
95
+ bun packages/omptype/bench/bench.ts
96
+ ```
97
+
98
+ The harness first requires every candidate to accept, reject, and transform the
99
+ same fixtures correctly. Compile and cold-start results use 400 unique object
100
+ schemas and report the fastest of five repetitions. Hot validation mixes valid
101
+ and invalid inputs after 2,000 warmup calls. The valid-only row uses each
102
+ library's public boolean path after 20,000 warmup calls.
103
+
104
+ Representative result on an Apple M4 Max with Darwin 25.6.0 and Bun 1.3.14:
105
+
106
+ | Phase | omptype | ArkType | TypeBox |
107
+ | ----------------------- | ---------: | ----------------: | --------------: |
108
+ | Compile `type()` | **509ns** | 271.08µs (532.3×) | 27.36µs (53.7×) |
109
+ | Compile + 2 validations | **2.18µs** | 526.46µs (241.5×) | 46.90µs (21.5×) |
110
+
111
+ | Hot workload | omptype | ArkType | TypeBox |
112
+ | -------------------------- | -------: | --------------: | --------------: |
113
+ | `flat-small` | **25ns** | 5.10µs (203.7×) | 1.23µs (49.2×) |
114
+ | `enum-union` | **27ns** | 4.92µs (185.0×) | 2.20µs (83.0×) |
115
+ | `nested-arrays` | **29ns** | 4.80µs (163.0×) | 3.01µs (102.2×) |
116
+ | `strict-defaults` | **40ns** | 4.85µs (122.1×) | 4.92µs (123.9×) |
117
+ | `delete-extras` | **22ns** | 4.12µs (191.6×) | 2.07µs (96.0×) |
118
+ | `record-mixed` | **43ns** | 4.32µs (100.4×) | 3.35µs (77.9×) |
119
+ | `deep-message` | **31ns** | 6.32µs (202.5×) | 5.13µs (164.5×) |
120
+ | `nested-arrays` valid-only | **15ns** | 28ns (1.8×) | 45ns (2.9×) |
121
+
122
+ Lower times are better. Parenthetical values show how many times slower each
123
+ candidate was than omptype in this run. Results vary with hardware, runtime,
124
+ thermal state, and dependency versions; use the command above for local
125
+ measurements.
126
+
127
+ ## License
128
+
129
+ MIT
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "type": "module",
3
+ "name": "@buckeyestudio/omptype",
4
+ "version": "18.4.13",
5
+ "description": "ArkType-compatible runtime schema validation with lazy JIT compilation",
6
+ "homepage": "https://omp.sh",
7
+ "author": { "name": "Stencil Labs, Inc.", "url": "https://stencil.so" },
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/can1357/oh-my-pi.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": "./src/index.ts",
24
+ "types": "./src/index.ts",
25
+ "scripts": {
26
+ "check": "oxlint . && oxfmt --check --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts' && bun run check:types",
27
+ "check:types": "tsgo -p tsconfig.json --noEmit",
28
+ "lint": "oxlint .",
29
+ "fix": "oxlint --fix --fix-suggestions . && bun run fmt",
30
+ "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'",
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": "catalog:",
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
+ ],
52
+ "exports": {
53
+ ".": {
54
+ "types": "./src/index.ts",
55
+ "import": "./src/index.ts"
56
+ },
57
+ "./*": {
58
+ "types": "./src/*.ts",
59
+ "import": "./src/*.ts"
60
+ },
61
+ "./*.js": "./src/*.ts"
62
+ }
63
+ }
package/src/ark.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ArkType compatibility facade — `@buckeyestudio/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 "@buckeyestudio/omptype/ark"` and nothing else changes. New code should
7
+ * import `@buckeyestudio/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;