Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Jul 28, 2023
1 parent 2c7854b commit 9e8b10e
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions changelog/0.30.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Overview

Revision 0.30.0 is a milestone revision for the TypeBox project. This revision is primarily focused on internal refactorings to reduce bundle size, further modularity of internal modules and consolidating shared internal utility modules (in an effort to reduce bundle size). This revision also implements several new features, including new validation constraints for Array, new iterator types, a TypeScript code generation option for the compiler, and enhancements made to modifiers. This revision also includes new examples including a transform type for handling IO encode an decode as well as a reference implementation for JSON Type Definition specification.
Revision 0.30.0 is a milestone revision for the TypeBox project. It is primarily focused on internal optimizations, refactoring work to reduce package and bundle sizes, support increased modularity of internal sub modules (with some considerations given to future ESM publishing), renaming internal functions to address react native bundling issues and consolidating shared internal modules to reduce overall code overhead.

This revision includes breaking changes and some deprecations and mandates a minor semver revision.
This revision also implements several new features, including new validation constraints for Array, new iterator types, a TypeScript code generation option for the compiler, enhancements made to modifiers and better options for TypeScript to TypeBox code translation. This revision also includes new examples including a transform type for handling IO encode an decode as well as a reference implementation for JSON Type Definition specification.

This revision includes breaking changes and some deprecations. It requires a minor semver revision.

## Contents

Expand All @@ -25,8 +27,6 @@ This revision includes breaking changes and some deprecations and mandates a min
- [RegEx Renamed To RegExp](#RegEx-Renamed-To-RegExp)
- [ValueErrorType Custom Renamed To Kind](#ValueErrorType-Custom-Renamed-To-Kind)



<a name="TypeScript Code Generation"></a>

## TypeScript Code Generation
Expand Down
2 changes: 1 addition & 1 deletion examples/transform/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function TVoid(schema: Types.TVoid, references: Types.TSchema[], value: any, mod
function TKind(schema: Types.TSchema, references: Types.TSchema[], value: any, mode: ValueTransformMode) {
return Apply(schema, value, mode)
}
export function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any, mode: ValueTransformMode): any {
function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any, mode: ValueTransformMode): any {
const references_ = ValueGuard.IsString(schema.$id) ? [...references, schema] : references
const schema_ = schema as any
switch (schema[Types.Kind]) {
Expand Down
3 changes: 2 additions & 1 deletion hammer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export async function build(target = 'target/build') {
// -------------------------------------------------------------
export async function publish(otp, target = 'target/build') {
const { version } = JSON.parse(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-${version}.tgz --access=public --otp ${otp}`)
await shell(`git tag ${version}`)
await shell(`git push origin ${version}`)
Expand All @@ -73,6 +74,6 @@ export async function publish(otp, target = 'target/build') {
// -------------------------------------------------------------
export async function publish_dev(otp, target = 'target/build') {
const { version } = JSON.parse(readFileSync(`${target}/package.json`, 'utf8'))
if(!version.includes('-dev')) throw Error(`package version should include -dev specifier`)
if(!version.includes('-dev')) throw Error(`development package version should include -dev specifier`)
await shell(`cd ${target} && npm publish sinclair-typebox-${version}.tgz --access=public --otp ${otp} --tag dev`)
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sinclair/typebox",
"version": "0.30.0-dev-1",
"version": "0.30.0-dev-2",
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
"keywords": [
"typescript",
Expand Down
4 changes: 2 additions & 2 deletions src/value/cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function TVoid(schema: Types.TVoid, references: Types.TSchema[], value: any): an
function TKind(schema: Types.TSchema, references: Types.TSchema[], value: any): any {
return ValueCheck.Check(schema, references, value) ? ValueClone.Clone(value) : ValueCreate.Create(schema, references)
}
export function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any): any {
function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any): any {
const references_ = ValueGuard.IsString(schema.$id) ? [...references, schema] : references
const schema_ = schema as any
switch (schema[Types.Kind]) {
Expand Down Expand Up @@ -327,7 +327,7 @@ export function Visit(schema: Types.TSchema, references: Types.TSchema[], value:
// --------------------------------------------------------------------------
// Cast
// --------------------------------------------------------------------------
/** Casts a value into a given type. The return value will retain as much information of the original value as possible. */
/** Casts a value into a given type and references. The return value will retain as much information of the original value as possible. */
export function Cast<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): Types.Static<T>
/** Casts a value into a given type. The return value will retain as much information of the original value as possible. */
export function Cast<T extends Types.TSchema>(schema: T, value: unknown): Types.Static<T>
Expand Down
8 changes: 4 additions & 4 deletions src/value/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function TVoid(schema: Types.TVoid, references: Types.TSchema[], value: any): un
function TUserDefined(schema: Types.TSchema, references: Types.TSchema[], value: any): unknown {
return value
}
export function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any): unknown {
function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any): unknown {
const references_ = ValueGuard.IsString(schema.$id) ? [...references, schema] : references
const schema_ = schema as any
switch (schema[Types.Kind]) {
Expand Down Expand Up @@ -343,11 +343,11 @@ export function Visit(schema: Types.TSchema, references: Types.TSchema[], value:
// --------------------------------------------------------------------------
// Convert
// --------------------------------------------------------------------------
/** Converts any type mismatched values to their target type if a conversion is possible. */
/** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
export function Convert<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): unknown
/** Converts any type mismatched values to their target type if a conversion is possible. */
/** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
export function Convert<T extends Types.TSchema>(schema: T, value: unknown): unknown
/** Converts any type mismatched values to their target type if a conversion is possible. */
/** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
export function Convert(...args: any[]) {
return args.length === 3 ? Visit(args[0], args[1], args[2]) : Visit(args[0], [], args[1])
}
7 changes: 3 additions & 4 deletions src/value/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ function TKind(schema: Types.TSchema, references: Types.TSchema[]): any {
throw new Error('ValueCreate: User defined types must specify a default value')
}
}
/** Creates a value from the given schema. If the schema specifies a default value, then that value is returned. */
export function Visit(schema: Types.TSchema, references: Types.TSchema[]): unknown {
function Visit(schema: Types.TSchema, references: Types.TSchema[]): unknown {
const references_ = ValueGuard.IsString(schema.$id) ? [...references, schema] : references
const schema_ = schema as any
switch (schema_[Types.Kind]) {
Expand Down Expand Up @@ -444,10 +443,10 @@ let recursiveDepth = 0
// --------------------------------------------------------------------------
// Create
// --------------------------------------------------------------------------
/** Creates a value from the given schema */
/** Creates a value from the given schema and references */
export function Create<T extends Types.TSchema>(schema: T, references: Types.TSchema[]): Types.Static<T>
/** Creates a value from the given schema */
export function Create<T extends Types.TSchema>(schema: T, value: unknown): Types.Static<T>
export function Create<T extends Types.TSchema>(schema: T): Types.Static<T>
/** Creates a value from the given schema */
export function Create(...args: any[]) {
recursiveDepth = 0
Expand Down
2 changes: 1 addition & 1 deletion src/value/mutate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function IsMismatchedValue(current: unknown, next: unknown) {
// --------------------------------------------------------------------------
// Mutate
// --------------------------------------------------------------------------
/** Performs a deep mutable value assignment while retaining internal references. */
/** Performs a deep mutable value assignment while retaining internal references */
export function Mutate(current: Mutable, next: Mutable): void {
if (IsNonMutableValue(current) || IsNonMutableValue(next)) throw new ValueMutateInvalidRootMutationError()
if (IsMismatchedValue(current, next)) throw new ValueMutateTypeMismatchError()
Expand Down
14 changes: 7 additions & 7 deletions src/value/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ export namespace Value {
export function Cast(...args: any[]) {
return ValueCast.Cast.apply(ValueCast, args as any)
}
/** Creates a value from the given type */
/** Creates a value from the given type and references */
export function Create<T extends Types.TSchema>(schema: T, references: Types.TSchema[]): Types.Static<T>
/** Creates a value from the given type */
export function Create<T extends Types.TSchema>(schema: T): Types.Static<T>
/** Creates a value from the given type */
export function Create(...args: any[]) {
return ValueCreate.Create.apply(ValueCreate, args as any)
}
/** Returns true if the value matches the given type. */
/** Returns true if the value matches the given type and references */
export function Check<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): value is Types.Static<T>
/** Returns true if the value matches the given type. */
/** Returns true if the value matches the given type */
export function Check<T extends Types.TSchema>(schema: T, value: unknown): value is Types.Static<T>
/** Returns true if the value matches the given type. */
/** Returns true if the value matches the given type */
export function Check(...args: any[]) {
return ValueCheck.Check.apply(ValueCheck, args as any)
}
/** Converts any type mismatched values to their target type if a conversion is possible. */
/** Converts any type mismatched values to their target type if a reasonable conversion is possible */
export function Convert<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): unknown
/** Converts any type mismatched values to their target type if a conversion is possible. */
/** Converts any type mismatched values to their target type if a reasonable conversion is possibl. */
export function Convert<T extends Types.TSchema>(schema: T, value: unknown): unknown
/** Converts any type mismatched values to their target type if a conversion is possible. */
/** Converts any type mismatched values to their target type if a reasonable conversion is possible */
export function Convert(...args: any[]) {
return ValueConvert.Convert.apply(ValueConvert, args as any)
}
Expand Down

0 comments on commit 9e8b10e

Please sign in to comment.