typebox 1.0.44 → 1.0.45

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.
@@ -1,7 +1,7 @@
1
1
  import { type StaticDirection, type StaticType } from './static.mjs';
2
2
  import { type TSchema } from './schema.mjs';
3
3
  import { type TProperties } from './properties.mjs';
4
- export type StaticCodec<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema, Decoded extends unknown> = Direction extends 'Decode' ? Decoded : StaticType<Stack, Direction, Context, This, Type>;
4
+ export type StaticCodec<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema, Decoded extends unknown> = (Direction extends 'Decode' ? Decoded : StaticType<Stack, Direction, Context, This, Omit<Type, '~codec'>>);
5
5
  export type TDecodeCallback<Type extends TSchema, Decoded = unknown> = (input: StaticType<[], 'Decode', {}, {}, Type>) => Decoded;
6
6
  export type TEncodeCallback<Type extends TSchema, Decoded = unknown> = (input: Decoded) => StaticType<[], 'Decode', {}, {}, Type>;
7
7
  export type TCodec<Type extends TSchema = TSchema, Decoded extends unknown = unknown> = Type & {
@@ -1,3 +1,4 @@
1
+ // deno-fmt-ignore-file
1
2
  import { Memory } from '../../system/index.mjs';
2
3
  import { Guard } from '../../guard/index.mjs';
3
4
  import { IsSchema } from './schema.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.0.44",
4
+ "version": "1.0.45",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
package/readme.md CHANGED
@@ -59,7 +59,6 @@ License: MIT
59
59
 
60
60
  - [Upgrade](#Upgrade)
61
61
  - [Type](#Type)
62
- - [Script](#Script)
63
62
  - [Value](#Value)
64
63
  - [Compile](#Compile)
65
64
  - [Contribute](#Contribute)
@@ -102,7 +101,7 @@ type T = Type.Static<typeof T> // type T = {
102
101
  // }
103
102
  ```
104
103
 
105
- Constraints and metadata can be passed on the last argument of any given type.
104
+ Options and constraints can be passed on the last argument of any given type.
106
105
 
107
106
  ```typescript
108
107
  const T = Type.Number({ // const T = {
@@ -115,80 +114,6 @@ const S = Type.String({ // const S = {
115
114
  format: 'email' // type: 'string',
116
115
  }) // format: 'email'
117
116
  // }
118
-
119
- const M = Type.Object({ // const M = {
120
- id: Type.String(), // type: 'object',
121
- message: Type.String() // required: ['id', 'message'],
122
- }, { // properties: {
123
- description: 'A protocol message' // id: { type: 'string' },
124
- }) // message: { type: 'string' }
125
- // },
126
- // description: 'A protocol message'
127
- // }
128
- ```
129
-
130
-
131
- <a name="Script"></a>
132
-
133
- ## Script
134
-
135
- [Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example](https://www.typescriptlang.org/play/?moduleResolution=99&target=99&jsx=0&module=199#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgYwgDsBneBOAXkSIDoBlGqYGBgAKAAYBvOJThwyALjj0AriGKooAGikykC5avVbpcAF56VaqFIC+ogJQzHT5y9dv3zgPSe4dJi3Y4cWMPULDwp29HQjQFPAhiACtUGhg8DRCIrOzInxkoVABHJWACgBMFAG08Ci08JHT8EzwAXQycjpyomTBsNFhgVEYFYM6x8O7HeSC4GNQ4-Us8OGt28fW3SZ0R2aIFi3Vl1cyN07gt0x25-YMoI5Oz9cnrB8exqJfaBmY4HkDkNC8fiCESSVirOASYyVADScGA9DgAGtUEgIBhEC0FAhYS04AAfRRKAA2xMotgcb3GUT8Pz+HFGVI2k2u+ASyVS6VeTOykwKxVKqAqcGqtXwDTqzTa3J5EUmvQg-Rgg2GQRlsrCF2mknVGo8FxkAEN6EgAPIYKq6vWbPKuSSsvCLQ4rIzWjoGxz2vb4ZSk+5urq2px4q0B3LOY5hrIXXQzUNR85BxzGs0WkXxqMemRe2I+g53F3aBOapNOHPzPN+lYZsMekPFksRtYN9wXMxxlv60twFPmy2d1vd7O7XOO-NHV0D1xZmYO33E-1Tlx1otL8NOSNr9fVrfhz5zX7-bg8GCG5U0AA8c3RvwAfE8fAf6Wrd45JtMnVZCfPm7vJrHPwJIlSV-LdJnbQDvxJMlXxkD4gA)
136
-
137
- TypeBox can translate TypeScript syntax into Json Schema. The Script function is a fully type-safe, syntactic frontend to the TypeBox type builder API, allowing Json Schema to be constructed and mapped using TypeScript type expressions encoded as strings.
138
-
139
- ### Example
140
-
141
- The following uses Script to construct and map Json Schema.
142
-
143
- ```typescript
144
- import Type from 'typebox'
145
-
146
- const T = Type.Script(`{
147
- x: number,
148
- y: number,
149
- z: number
150
- }`) // const T = {
151
- // type: 'object',
152
- // required: ['x', 'y', 'z'],
153
- // properties: {
154
- // x: { type: 'number' },
155
- // y: { type: 'number' },
156
- // z: { type: 'number' }
157
- // }
158
- // }
159
-
160
- const S = Type.Script({ T }, `{
161
- [K in keyof T]: T[K] | null
162
- }`) // const S = {
163
- // type: 'object',
164
- // required: ['x', 'y', 'z'],
165
- // properties: {
166
- // x: {
167
- // anyOf: [
168
- // { type: 'number' },
169
- // { type: 'null' }
170
- // ]
171
- // },
172
- // y: {
173
- // anyOf: [
174
- // { type: 'number' },
175
- // { type: 'null' }
176
- // ]
177
- // },
178
- // z: {
179
- // anyOf: [
180
- // { type: 'number' },
181
- // { type: 'null' }
182
- // ]
183
- // },
184
- // }
185
- // }
186
-
187
- type S = Type.Static<typeof S> // type S = {
188
- // x: number | null,
189
- // y: number | null,
190
- // z: number | null
191
- // }
192
117
  ```
193
118
 
194
119
  <a name="Value"></a>