typebox 1.2.12 → 1.2.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.
@@ -1,30 +1,30 @@
1
- import { type StaticDirection, type StaticType } from './static.mjs';
1
+ import { type StaticDirection, type StaticDecode, type StaticType } from './static.mjs';
2
2
  import { type TSchema } from './schema.mjs';
3
3
  import { type TProperties } from './properties.mjs';
4
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
- export type TDecodeCallback<Type extends TSchema, Decoded = unknown> = (input: StaticType<[], 'Decode', {}, {}, Type>) => Decoded;
6
- export type TEncodeCallback<Type extends TSchema, Decoded = unknown> = (input: Decoded) => StaticType<[], 'Decode', {}, {}, Type>;
5
+ export type TDecodeCallback<Encoded extends unknown, Decoded = unknown> = (input: Encoded) => Decoded;
6
+ export type TEncodeCallback<Encoded extends unknown, Decoded = unknown> = (input: Decoded) => Encoded;
7
7
  export type TCodec<Type extends TSchema = TSchema, Decoded extends unknown = unknown> = Type & {
8
8
  '~codec': {
9
- encode: TDecodeCallback<Type, Decoded>;
10
- decode: TEncodeCallback<Type, Decoded>;
9
+ encode: TDecodeCallback<unknown, Decoded>;
10
+ decode: TEncodeCallback<unknown, Decoded>;
11
11
  };
12
12
  };
13
- export declare class EncodeBuilder<Type extends TSchema, Decoded extends unknown> {
13
+ export declare class EncodeBuilder<Type extends TSchema, Encoded extends unknown, Decoded extends unknown> {
14
14
  private readonly type;
15
15
  private readonly decode;
16
16
  constructor(type: Type, decode: globalThis.Function);
17
- Encode<Callback extends TEncodeCallback<Type, Decoded>>(callback: Callback): TCodec<Type, Decoded>;
17
+ Encode(callback: TEncodeCallback<Encoded, Decoded>): TCodec<Type, Decoded>;
18
18
  }
19
- export declare class DecodeBuilder<Type extends TSchema> {
19
+ export declare class DecodeBuilder<Type extends TSchema, Encoded extends unknown> {
20
20
  private readonly type;
21
21
  constructor(type: Type);
22
- Decode<Callback extends TDecodeCallback<Type>>(callback: Callback): EncodeBuilder<Type, ReturnType<Callback>>;
22
+ Decode<Callback extends TDecodeCallback<Encoded, unknown>>(callback: Callback): EncodeBuilder<Type, Encoded, ReturnType<Callback>>;
23
23
  }
24
24
  /** Creates a bi-directional Codec. Codec functions are called on Value.Decode and Value.Encode. */
25
- export declare function Codec<Type extends TSchema>(type: Type): DecodeBuilder<Type>;
25
+ export declare function Codec<Type extends TSchema>(type: Type): DecodeBuilder<Type, StaticDecode<Type>>;
26
26
  /** Createsa uni-directional Codec with Decode only. The Decode function is called on Value.Decode */
27
- export declare function Decode<Type extends TSchema, Callback extends TDecodeCallback<Type>>(type: Type, callback: Callback): TCodec<Type, ReturnType<Callback>>;
27
+ export declare function Decode<Type extends TSchema, Callback extends TDecodeCallback<StaticDecode<Type>, unknown>>(type: Type, callback: Callback): TCodec<Type, ReturnType<Callback>>;
28
28
  /** Creates a uni-directional Codec with Encode only. The Encode function is called on Value.Encode */
29
- export declare function Encode<Type extends TSchema, Callback extends TEncodeCallback<Type, unknown>>(type: Type, callback: Callback): TCodec<Type, unknown>;
29
+ export declare function Encode<Type extends TSchema>(type: Type, callback: TEncodeCallback<StaticDecode<Type>, unknown>): TCodec<Type, unknown>;
30
30
  export declare function IsCodec(value: unknown): value is TCodec;
@@ -1,4 +1,3 @@
1
- // deno-lint-ignore-file ban-types
2
1
  // deno-fmt-ignore-file
3
2
  import { Memory } from '../../system/index.mjs';
4
3
  import { Guard } from '../../guard/index.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.2.12",
4
+ "version": "1.2.13",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"