Fork from @sinclair/typebox 0.34.49 as @alkdev/typebox

- Rename package from @sinclair/typebox to @alkdev/typebox
- Update author, repository, and homepage to alkdev
- Remove GitHub workflows, .vscode config, and branding assets
- Update all source, test, example, changelog, and task imports
- Update tsconfig.json path mappings
- Clean up readme header (remove upstream badges/branding)
This commit is contained in:
2026-04-23 13:22:31 +00:00
parent 11f18ac6e9
commit bd758c2342
981 changed files with 1676 additions and 2054 deletions

View File

@@ -1,35 +1,33 @@
<div align='center'>
<h1>TypeBox 0.34.x</h1>
<h1>TypeBox</h1>
<p>Json Schema Type Builder with Static Type Resolution for TypeScript</p>
<img src="https://raw.githubusercontent.com/sinclairzx81/typebox-legacy/refs/heads/main/typebox.png" />
<br />
<br />
[![npm version](https://badge.fury.io/js/%40sinclair%2Ftypebox.svg)](https://badge.fury.io/js/%40sinclair%2Ftypebox)
[![Downloads](https://img.shields.io/npm/dm/%40sinclair%2Ftypebox.svg)](https://www.npmjs.com/package/%40sinclair%2Ftypebox)
[![Build](https://github.com/sinclairzx81/typebox/actions/workflows/build.yml/badge.svg)](https://github.com/sinclairzx81/typebox/actions/workflows/build.yml)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
</div>
<a name="Install"></a>
## Install
```bash
$ npm install @sinclair/typebox # TypeBox-Legacy | 0.34.x
For the latest version use [TypeBox 1.x](https://git.alk.dev/alkdev/typebox)
$ npm install typebox # TypeBox | 1.0.x
```bash
$ npm install @alkdev/typebox # TypeBox 0.x - Long Term Support
$ npm install typebox # TypeBox 1.x - Latest
```
## Example
```typescript
import { Type, type Static } from '@sinclair/typebox'
import { Type, type Static } from '@alkdev/typebox'
const T = Type.Object({ // const T = {
x: Type.Number(), // type: 'object',
@@ -48,13 +46,10 @@ type T = Static<typeof T> // type T = {
// }
```
<a name="Overview"></a>
## Overview
> ⚠️ TypeBox versions (pre-1.0) will continue active maintenance through 2026 and beyond. This repository services as the OIDC publishing environment for the `@sinclair/typebox` package scope on NPM. For TypeBox versions 1.0 and above, refer to https://github.com/sinclairzx81/typebox
TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
@@ -132,7 +127,7 @@ License MIT
The following shows general usage.
```typescript
import { Type, type Static } from '@sinclair/typebox'
import { Type, type Static } from '@alkdev/typebox'
//--------------------------------------------------------------------------------------------
//
@@ -190,7 +185,7 @@ type T = Static<typeof T> // type T = {
//
//--------------------------------------------------------------------------------------------
import { Value } from '@sinclair/typebox/value'
import { Value } from '@alkdev/typebox/value'
const R = Value.Parse(T, value) // const R: {
// id: string,
@@ -942,7 +937,7 @@ const C = Type.Exclude( // type C = Exclude<1 | 2 |
TypeBox supports value decoding and encoding with Transform types. These types work in tandem with the Encode and Decode functions available on the Value and TypeCompiler submodules. Transform types can be used to convert Json encoded values into constructs more natural to JavaScript. The following creates a Transform type to decode numbers into Dates using the Value submodule.
```typescript
import { Value } from '@sinclair/typebox/value'
import { Value } from '@alkdev/typebox/value'
const T = Type.Transform(Type.Number())
.Decode(value => new Date(value)) // decode: number to Date
@@ -953,7 +948,7 @@ const E = Value.Encode(T, D) // const E = 0
```
Use the StaticEncode or StaticDecode types to infer a Transform type.
```typescript
import { Static, StaticDecode, StaticEncode } from '@sinclair/typebox'
import { Static, StaticDecode, StaticEncode } from '@alkdev/typebox'
const T = Type.Transform(Type.Array(Type.Number(), { uniqueItems: true }))
.Decode(value => new Set(value))
@@ -1005,7 +1000,7 @@ type S = Static<typeof T> // type S = 'A' | 'B' | 'C'
TypeBox can check its own types with the TypeGuard module. This module is written for type introspection and provides structural tests for every built-in TypeBox type. Functions of this module return `is` guards which can be used with control flow assertions to obtain schema inference for unknown values. The following guards that the value `T` is TString.
```typescript
import { TypeGuard, Kind } from '@sinclair/typebox'
import { TypeGuard, Kind } from '@alkdev/typebox'
const T = { [Kind]: 'String', type: 'string' }
@@ -1022,7 +1017,7 @@ if(TypeGuard.IsString(T)) {
TypeBox provides an optional Value submodule that can be used to perform structural operations on JavaScript values. This submodule includes functionality to create, check and cast values from types as well as check equality, clone, diff and patch JavaScript values. This submodule is provided via optional import.
```typescript
import { Value } from '@sinclair/typebox/value'
import { Value } from '@alkdev/typebox/value'
```
<a name='values-assert'></a>
@@ -1296,7 +1291,7 @@ const R2 = A.x === X // const R2 = true
Use ValuePointer to perform mutable updates on existing values using [RFC6901](https://www.rfc-editor.org/rfc/rfc6901) Json Pointers.
```typescript
import { ValuePointer } from '@sinclair/typebox/value'
import { ValuePointer } from '@alkdev/typebox/value'
const A = { x: 0, y: 0, z: 0 }
@@ -1316,7 +1311,7 @@ TypeBox provides experimental support for parsing TypeScript annotation syntax i
This feature is provided via optional import.
```typescript
import { Syntax } from '@sinclair/typebox/syntax'
import { Syntax } from '@alkdev/typebox/syntax'
```
<a name='syntax-create'></a>
@@ -1403,7 +1398,7 @@ const T = Syntax(`number`, { minimum: 42 }) // const T = {
Syntax parsing is an expensive type level operation and can impact on language service performance. Use the NoInfer function parse syntax at runtime only.
```typescript
import { NoInfer } from '@sinclair/typebox/syntax'
import { NoInfer } from '@alkdev/typebox/syntax'
const T = NoInfer(`number | string`) // const T: TSchema = {
// anyOf: [
@@ -1426,7 +1421,7 @@ The TypeBox type system can be extended with additional types and formats using
Use the TypeRegistry to register a type. The Kind must match the registered type name.
```typescript
import { TSchema, Kind, TypeRegistry } from '@sinclair/typebox'
import { TSchema, Kind, TypeRegistry } from '@alkdev/typebox'
TypeRegistry.Set('Foo', (schema, value) => value === 'foo')
@@ -1444,7 +1439,7 @@ const B = Value.Check(Foo, 'bar') // const B = false
Use the FormatRegistry to register a string format.
```typescript
import { FormatRegistry } from '@sinclair/typebox'
import { FormatRegistry } from '@alkdev/typebox'
FormatRegistry.Set('foo', (value) => value === 'foo')
@@ -1474,7 +1469,7 @@ $ npm install ajv ajv-formats --save
```
```typescript
import { Type } from '@sinclair/typebox'
import { Type } from '@alkdev/typebox'
import addFormats from 'ajv-formats'
import Ajv from 'ajv'
@@ -1513,7 +1508,7 @@ The TypeBox TypeCompiler is a high performance JIT validation compiler that tran
The TypeCompiler is provided as an optional import.
```typescript
import { TypeCompiler } from '@sinclair/typebox/compiler'
import { TypeCompiler } from '@alkdev/typebox/compiler'
```
Use the Compile function to JIT compile a type. Note that compilation is generally an expensive operation and should only be performed once per type during application start up. TypeBox does not cache previously compiled types, and applications are expected to hold references to each compiled type for the lifetime of the application.
@@ -1580,7 +1575,7 @@ const C = TypeCompiler.Code(Type.String()) // const C = `return functi
TypeBox offers an external package for bidirectional mapping between TypeBox, Valibot, and Zod type libraries. It also includes syntax parsing support for Valibot and Zod and supports the Standard Schema specification. For more details on TypeMap, refer to the project repository.
[TypeMap Repository](https://github.com/sinclairzx81/typemap)
[TypeMap Repository](https://git.alk.dev/alkdev/typebox)
<a name='typemap-usage'></a>
@@ -1627,7 +1622,7 @@ TypeBox validates using standard Json Schema assertion policies by default. The
The following overrides are available.
```typescript
import { TypeSystemPolicy } from '@sinclair/typebox/system'
import { TypeSystemPolicy } from '@alkdev/typebox/system'
// Disallow undefined values for optional properties (default is false)
//
@@ -1664,7 +1659,7 @@ The following example shows an inline error function that intercepts errors for
```typescript
import { SetErrorFunction, DefaultErrorFunction, ValueErrorType } from '@sinclair/typebox/errors'
import { SetErrorFunction, DefaultErrorFunction, ValueErrorType } from '@alkdev/typebox/errors'
SetErrorFunction((error) => { // i18n override
switch(error.errorType) {
@@ -1707,7 +1702,7 @@ const E = [...Value.Errors(T, { // const E = [{
TypeBox offers a web based code generation tool that can convert TypeScript types into TypeBox types as well as several other ecosystem libraries.
[TypeBox Workbench Link Here](https://sinclairzx81.github.io/typebox-workbench/)
[TypeBox Workbench Link Here](https://git.alk.dev/alkdev/typebox/)
<a name='codegen'></a>
@@ -1715,7 +1710,7 @@ TypeBox offers a web based code generation tool that can convert TypeScript type
TypeBox provides a code generation library that can be integrated into toolchains to automate type translation between TypeScript and TypeBox. This library also includes functionality to transform TypeScript types to other ecosystem libraries.
[TypeBox Codegen Link Here](https://github.com/sinclairzx81/typebox-codegen)
[TypeBox Codegen Link Here](https://git.alk.dev/alkdev/typebox-codegen)
<a name='ecosystem'></a>