@sinclair/typebox 0.28.11 → 0.28.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.
@@ -194,13 +194,13 @@ var TypeCompiler;
194
194
  }
195
195
  function* Array(schema, references, value) {
196
196
  const expression = CreateExpression(schema.items, references, 'value');
197
- yield `Array.isArray(${value}) && ${value}.every(value => ${expression})`;
198
197
  if (IsNumber(schema.minItems))
199
198
  yield `${value}.length >= ${schema.minItems}`;
200
199
  if (IsNumber(schema.maxItems))
201
200
  yield `${value}.length <= ${schema.maxItems}`;
202
201
  if (schema.uniqueItems === true)
203
202
  yield `((function() { const set = new Set(); for(const element of ${value}) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true })())`;
203
+ yield `Array.isArray(${value}) && ${value}.every(value => ${expression})`;
204
204
  }
205
205
  function* BigInt(schema, references, value) {
206
206
  yield `(typeof ${value} === 'bigint')`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.28.11",
3
+ "version": "0.28.13",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
@@ -42,6 +42,6 @@
42
42
  "chai": "^4.3.6",
43
43
  "mocha": "^9.2.2",
44
44
  "prettier": "^2.7.1",
45
- "typescript": "^5.0.2"
45
+ "typescript": "^5.0.4"
46
46
  }
47
47
  }
package/readme.md CHANGED
@@ -109,6 +109,7 @@ License MIT
109
109
  - [Formats](#typesystem-formats)
110
110
  - [Policies](#typesystem-policies)
111
111
  - [Workbench](#workbench)
112
+ - [Ecosystem](#ecosystem)
112
113
  - [Benchmark](#benchmark)
113
114
  - [Compile](#benchmark-compile)
114
115
  - [Validate](#benchmark-validate)
@@ -1277,7 +1278,7 @@ The TypeCompiler is provided as an optional import.
1277
1278
  import { TypeCompiler } from '@sinclair/typebox/compiler'
1278
1279
  ```
1279
1280
 
1280
- Use the `Compile(...)` function to compile a type.
1281
+ Use the `Compile(...)` function to compile a type. Note that compilation is an expensive operation that should typically be performed once per type during application start up. TypeBox does not cache previously compiled types, so applications are expected to hold references to each compiled type for the lifetime of the application.
1281
1282
 
1282
1283
  ```typescript
1283
1284
  const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObject<{
@@ -1419,16 +1420,29 @@ TypeSystem.AllowNaN = true
1419
1420
 
1420
1421
  ## Workbench
1421
1422
 
1422
- TypeBox offers a web based code generation tool that can be used to create TypeBox types from TypeScript type definitions. This tool is written to prototype new TypeBox features, but can be used to rapidly convert TypeScript type definitions in to TypeBox types as well as raw JSON Schema.
1423
+ TypeBox offers a small web based code generation tool that can be used to convert TypeScript types into TypeBox type definitions as well as a variety of other formats.
1423
1424
 
1424
1425
  [Workbench Link Here](https://sinclairzx81.github.io/typebox-workbench/)
1425
1426
 
1426
1427
  <div align='center'>
1427
-
1428
+
1428
1429
  <a href="https://sinclairzx81.github.io/typebox-workbench/"><img src="https://github.com/sinclairzx81/typebox/blob/master/workbench.png?raw=true" /></a>
1429
1430
 
1430
1431
  </div>
1431
1432
 
1433
+ <a name='ecosystem'></a>
1434
+
1435
+ ## Ecosystem
1436
+
1437
+ The following is a list of community packages that provide general tooling and framework support for TypeBox.
1438
+
1439
+ | Package | Description |
1440
+ | ------------- | ------------- |
1441
+ | [elysia](https://github.com/elysiajs/elysia) | Fast and friendly Bun web framework |
1442
+ | [fastify-type-provider-typebox](https://github.com/fastify/fastify-type-provider-typebox) | Fastify TypeBox integration with the Fastify Type Provider |
1443
+ | [fetch-typebox](https://github.com/erfanium/fetch-typebox) | Drop-in replacement for fetch that brings easy integration with TypeBox |
1444
+ | [ts2typebox](https://github.com/xddq/ts2typebox) | Cli tool to generate TypeBox JSON schemas based on your Typescript types |
1445
+
1432
1446
  <a name='benchmark'></a>
1433
1447
 
1434
1448
  ## Benchmark
package/typebox.d.ts CHANGED
@@ -132,7 +132,7 @@ export interface TEnumOption<T> {
132
132
  export interface TEnum<T extends Record<string, string | number> = Record<string, string | number>> extends TSchema {
133
133
  [Kind]: 'Union';
134
134
  static: T[keyof T];
135
- anyOf: TLiteral<string | number>[];
135
+ anyOf: TLiteral<T[keyof T]>[];
136
136
  }
137
137
  export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = (Static<L> extends Static<R> ? T : U) extends infer O ? UnionToTuple<O> extends [infer X, infer Y] ? TUnion<[AssertType<X>, AssertType<Y>]> : AssertType<O> : never;
138
138
  export type TExcludeTemplateLiteralResult<T extends string> = UnionType<AssertRest<UnionToTuple<{