Revision 0.8.0
This commit is contained in:
0
.github/.keep
vendored
Normal file
0
.github/.keep
vendored
Normal file
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
TypeBox-Remix:
|
||||
TypeBox-Adapter:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@@ -3,7 +3,7 @@ on:
|
||||
schedule:
|
||||
- cron: '0 18 * * *' # 6pm Daily
|
||||
jobs:
|
||||
TypeBox-Remix-Nightly:
|
||||
TypeBox-Adapter-Nightly:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TypeCompiler } from '@sinclair/typebox/compiler'
|
||||
import { Value } from '@sinclair/typebox/value'
|
||||
import { Box } from '@sinclair/typebox-remix'
|
||||
import { Box } from '@sinclair/typebox-adapter'
|
||||
|
||||
import * as v from 'valibot'
|
||||
import * as z from 'zod'
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
import { Box } from '@sinclair/typebox-remix'
|
||||
import { Box } from '@sinclair/typebox-adapter'
|
||||
import * as v from 'valibot'
|
||||
import * as z from 'zod'
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export async function test(filter = '') {
|
||||
// ------------------------------------------------------------------
|
||||
export async function build_check(target = 'target/build') {
|
||||
const { version } = JSON.parse(Fs.readFileSync('package.json', 'utf8'))
|
||||
await shell(`cd ${target} && attw sinclair-typebox-remix-${version}.tgz --ignore-rules unexpected-module-syntax`)
|
||||
await shell(`cd ${target} && attw sinclair-typebox-adapter-${version}.tgz --ignore-rules unexpected-module-syntax`)
|
||||
}
|
||||
export async function build(target = 'target/build') {
|
||||
await test()
|
||||
@@ -56,7 +56,7 @@ export async function build(target = 'target/build') {
|
||||
export async function publish(otp, target = 'target/build') {
|
||||
const { version } = JSON.parse(Fs.readFileSync('package.json', 'utf8'))
|
||||
if(version.includes('-dev')) throw Error(`package version should not include -dev specifier`)
|
||||
await shell(`cd ${target} && npm publish sinclair-typebox-remix-${version}.tgz --access=public --otp ${otp}`)
|
||||
await shell(`cd ${target} && npm publish sinclair-typebox-adapter-${version}.tgz --access=public --otp ${otp}`)
|
||||
await shell(`git tag ${version}`)
|
||||
await shell(`git push origin ${version}`)
|
||||
}
|
||||
@@ -66,5 +66,5 @@ export async function publish(otp, target = 'target/build') {
|
||||
export async function publish_dev(otp, target = 'target/build') {
|
||||
const { version } = JSON.parse(Fs.readFileSync(`${target}/package.json`, 'utf8'))
|
||||
if(!version.includes('-dev')) throw Error(`development package version should include -dev specifier`)
|
||||
await shell(`cd ${target} && npm publish sinclair-typebox-remix-${version}.tgz --access=public --otp ${otp} --tag dev`)
|
||||
await shell(`cd ${target} && npm publish sinclair-typebox-adapter-${version}.tgz --access=public --otp ${otp} --tag dev`)
|
||||
}
|
||||
2
license
2
license
@@ -1,4 +1,4 @@
|
||||
@sinclair/typebox-remix
|
||||
@sinclair/typebox-adapter
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@sinclair/typebox-remix",
|
||||
"name": "@sinclair/typebox-adapter",
|
||||
"version": "0.8.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@sinclair/typebox-remix",
|
||||
"name": "@sinclair/typebox-adapter",
|
||||
"version": "0.8.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "@sinclair/typebox-remix",
|
||||
"name": "@sinclair/typebox-adapter",
|
||||
"version": "0.8.0",
|
||||
"description": "Integrate Valibot and Zod with TypeBox",
|
||||
"author": "sinclairzx81",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sinclairzx81/typebox-adapter"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "hammer task benchmark",
|
||||
"clean": "hammer task clean",
|
||||
|
||||
26
readme.md
26
readme.md
@@ -1,17 +1,17 @@
|
||||
<div align='center'>
|
||||
|
||||
<h1>TypeBox Remix</h1>
|
||||
<h1>TypeBox Adapter</h1>
|
||||
|
||||
<p>Integrate Valibot and Zod with TypeBox</p>
|
||||
|
||||
<img src="typebox-remix.png" />
|
||||
<img src="https://raw.githubusercontent.com/sinclairzx81/typebox-adapter/refs/heads/main/typebox-adapter.png" />
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
[](https://badge.fury.io/js/%40sinclair%2Ftypebox-remix)
|
||||
[](https://www.npmjs.com/package/%40sinclair%2Ftypebox-remix)
|
||||
[](https://github.com/sinclairzx81/typebox-remix/actions/workflows/build.yml)
|
||||
[](https://badge.fury.io/js/%40sinclair%2Ftypebox-adapter)
|
||||
[](https://www.npmjs.com/package/%40sinclair%2Ftypebox-adapter)
|
||||
[](https://github.com/sinclairzx81/typebox-adapter/actions/workflows/build.yml)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
</div>
|
||||
@@ -19,15 +19,15 @@
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install @sinclair/typebox-remix --save
|
||||
$ npm install @sinclair/typebox-adapter --save
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
TypeBox Remix converts Valibot and Zod Types into TypeBox compatible schematics
|
||||
TypeBox Adapter converts Valibot and Zod Types into TypeBox compatible schematics
|
||||
|
||||
```typescript
|
||||
import { Box } from '@sinclair/typebox-remix'
|
||||
import { Box } from '@sinclair/typebox-adapter'
|
||||
|
||||
import * as v from 'valibot'
|
||||
import * as z from 'zod'
|
||||
@@ -55,9 +55,7 @@ const Z = Box(z.object({ // const Z: TObject<{
|
||||
|
||||
## Overview
|
||||
|
||||
TypeBox Remix is a library that makes Zod and Valibot compatible with TypeBox. It works by structurally remapping the types provided by these libraries into Json Schema schematics, enabling them to integrate with the TypeBox infrastructure and making them compatible with Ajv.
|
||||
|
||||
This library can be used to integrate Valibot and Zod into server infrastructures that standardize on the Json Schema specification. By transforming these libraries to Json Schema, they can benefit from accelerated type checking and achieve better interoperability with non-JavaScript based systems.
|
||||
TypeBox Adapter is a library that transforms Zod and Valibot types into TypeBox compatiable schematics. It works by structurally remapping the types provided by these libraries both statically and at runtime, enabling them to integrate with TypeBox infrastructure as well as making them compatible with industry standard Json Schema validators like Ajv.
|
||||
|
||||
License MIT
|
||||
|
||||
@@ -73,14 +71,14 @@ License MIT
|
||||
|
||||
## Usage
|
||||
|
||||
TypeBox Remix provides a singular Box function to transform Valibot and Zod types into TypeBox schematics. The top-level export is capable of transforming both Valibot and Zod, but you should use the appropriate submodule depending on which library you are using.
|
||||
TypeBox Adapter provides a singular Box function to transform Valibot and Zod types into TypeBox schematics. The top-level export is capable of transforming both Valibot and Zod, but you should use the appropriate submodule depending on which library you are using.
|
||||
|
||||
### Valibot
|
||||
|
||||
Use the `/valibot` submodule if you only have Valibot installed.
|
||||
|
||||
```typescript
|
||||
import { Box } from '@sinclair/typebox-remix/valibot' // Transform Valibot Only
|
||||
import { Box } from '@sinclair/typebox-adapter/valibot' // Transform Valibot Only
|
||||
|
||||
import * as v from 'valibot'
|
||||
|
||||
@@ -94,7 +92,7 @@ Refer to the Valibot [documentation](https://valibot.dev/) for more information
|
||||
Use the `/zod` submodule if you only have Zod installed.
|
||||
|
||||
```typescript
|
||||
import { Box } from '@sinclair/typebox-remix/zod' // Transform Zod Only
|
||||
import { Box } from '@sinclair/typebox-adapter/zod' // Transform Zod Only
|
||||
|
||||
import * as z from 'zod'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
@sinclair/typebox-remix
|
||||
@sinclair/typebox-adapter
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
@sinclair/typebox-remix
|
||||
@sinclair/typebox-adapter
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
@sinclair/typebox-remix
|
||||
@sinclair/typebox-adapter
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
@sinclair/typebox-remix
|
||||
@sinclair/typebox-adapter
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
@sinclair/typebox-remix
|
||||
@sinclair/typebox-adapter
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Box } from '@sinclair/typebox-remix'
|
||||
import { Box } from '@sinclair/typebox-adapter'
|
||||
import * as Types from '@sinclair/typebox'
|
||||
import { TypeGuard } from '@sinclair/typebox'
|
||||
import { Assert } from './assert'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Box } from '@sinclair/typebox-remix'
|
||||
import { Box } from '@sinclair/typebox-adapter'
|
||||
import * as Types from '@sinclair/typebox'
|
||||
import { TypeGuard } from '@sinclair/typebox'
|
||||
import { Assert } from './assert'
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
"moduleResolution": "Node",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@sinclair/typebox-remix/typebox": ["src/typebox.ts"],
|
||||
"@sinclair/typebox-remix/valibot": ["src/valibot.ts"],
|
||||
"@sinclair/typebox-remix/zod": ["src/zod.ts"],
|
||||
"@sinclair/typebox-remix": ["src/index.ts"]
|
||||
"@sinclair/typebox-adapter/typebox": ["src/typebox.ts"],
|
||||
"@sinclair/typebox-adapter/valibot": ["src/valibot.ts"],
|
||||
"@sinclair/typebox-adapter/zod": ["src/zod.ts"],
|
||||
"@sinclair/typebox-adapter": ["src/index.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
typebox-adapter.png
Normal file
BIN
typebox-adapter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 807 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 859 KiB |
Reference in New Issue
Block a user