typebox 1.2.2 → 1.2.4

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.
Files changed (79) hide show
  1. package/build/type/action/_add_immutable.d.mts +11 -0
  2. package/build/type/action/_add_immutable.mjs +11 -0
  3. package/build/type/action/_add_optional.d.mts +11 -0
  4. package/build/type/action/_add_optional.mjs +11 -0
  5. package/build/type/action/_add_readonly.d.mts +11 -0
  6. package/build/type/action/_add_readonly.mjs +11 -0
  7. package/build/type/action/_remove_immutable.d.mts +11 -0
  8. package/build/type/action/_remove_immutable.mjs +11 -0
  9. package/build/type/action/_remove_optional.d.mts +11 -0
  10. package/build/type/action/_remove_optional.mjs +11 -0
  11. package/build/type/action/_remove_readonly.d.mts +11 -0
  12. package/build/type/action/_remove_readonly.mjs +11 -0
  13. package/build/type/action/conditional.d.mts +2 -3
  14. package/build/type/action/conditional.mjs +2 -1
  15. package/build/type/action/index.d.mts +6 -2
  16. package/build/type/action/index.mjs +6 -2
  17. package/build/type/action/mapped.d.mts +2 -3
  18. package/build/type/action/mapped.mjs +2 -1
  19. package/build/type/engine/call/instantiate.d.mts +1 -3
  20. package/build/type/engine/call/instantiate.mjs +3 -2
  21. package/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  22. package/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  23. package/build/type/engine/cyclic/instantiate.d.mts +2 -5
  24. package/build/type/engine/cyclic/instantiate.mjs +3 -2
  25. package/build/type/engine/evaluate/composite.d.mts +10 -6
  26. package/build/type/engine/evaluate/composite.mjs +10 -6
  27. package/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  28. package/build/type/engine/immutable/instantiate_add.mjs +14 -0
  29. package/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  30. package/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  31. package/build/type/engine/instantiate.d.mts +37 -20
  32. package/build/type/engine/instantiate.mjs +65 -62
  33. package/build/type/engine/interface/instantiate.d.mts +3 -6
  34. package/build/type/engine/module/instantiate.d.mts +1 -3
  35. package/build/type/engine/module/instantiate.mjs +2 -1
  36. package/build/type/engine/optional/instantiate_add.d.mts +10 -0
  37. package/build/type/engine/optional/instantiate_add.mjs +14 -0
  38. package/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  39. package/build/type/engine/optional/instantiate_remove.mjs +14 -0
  40. package/build/type/engine/parameters/instantiate.d.mts +3 -4
  41. package/build/type/engine/parameters/instantiate.mjs +2 -1
  42. package/build/type/engine/partial/from_object.d.mts +2 -2
  43. package/build/type/engine/partial/from_object.mjs +2 -2
  44. package/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  45. package/build/type/engine/readonly/instantiate_add.mjs +14 -0
  46. package/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  47. package/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  48. package/build/type/engine/readonly_object/from_array.d.mts +2 -2
  49. package/build/type/engine/readonly_object/from_array.mjs +2 -2
  50. package/build/type/engine/readonly_object/from_object.d.mts +2 -2
  51. package/build/type/engine/readonly_object/from_object.mjs +2 -2
  52. package/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  53. package/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  54. package/build/type/engine/ref/instantiate.d.mts +3 -3
  55. package/build/type/engine/ref/instantiate.mjs +6 -6
  56. package/build/type/engine/required/from_object.d.mts +2 -2
  57. package/build/type/engine/required/from_object.mjs +2 -2
  58. package/build/type/engine/template_literal/is_pattern.mjs +1 -0
  59. package/build/type/extends/tuple.d.mts +3 -6
  60. package/build/type/extends/tuple.mjs +3 -2
  61. package/build/type/script/mapping.d.mts +42 -42
  62. package/build/type/script/mapping.mjs +46 -46
  63. package/build/type/script/script.d.mts +3 -4
  64. package/build/type/script/script.mjs +3 -2
  65. package/build/type/types/_immutable.d.mts +2 -9
  66. package/build/type/types/_immutable.mjs +2 -10
  67. package/build/type/types/_optional.d.mts +2 -9
  68. package/build/type/types/_optional.mjs +2 -11
  69. package/build/type/types/_readonly.d.mts +2 -9
  70. package/build/type/types/_readonly.mjs +2 -10
  71. package/build/type/types/call.d.mts +3 -3
  72. package/build/type/types/call.mjs +3 -2
  73. package/build/type/types/deferred.d.mts +1 -0
  74. package/build/type/types/deferred.mjs +1 -1
  75. package/package.json +1 -1
  76. package/build/type/action/_optional.d.mts +0 -19
  77. package/build/type/action/_optional.mjs +0 -40
  78. package/build/type/action/_readonly.d.mts +0 -19
  79. package/build/type/action/_readonly.mjs +0 -40
@@ -1,16 +1,16 @@
1
1
  import { type TSchema } from './schema.mjs';
2
2
  import { type TCallInstantiate } from '../engine/call/instantiate.mjs';
3
+ import { type TState } from '../engine/instantiate.mjs';
3
4
  /** Represents a deferred generic Call */
4
5
  export interface TCall<Target extends TSchema = TSchema, Arguments extends TSchema[] = TSchema[]> extends TSchema {
5
6
  '~kind': 'Call';
7
+ type: 'call';
6
8
  target: Target;
7
9
  arguments: Arguments;
8
10
  }
9
11
  export type TCallConstruct<Target extends TSchema, Arguments extends TSchema[], Result extends TSchema = TCall<Target, Arguments>> = Result;
10
12
  export declare function CallConstruct<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallConstruct<Target, Arguments>;
11
13
  /** Creates a Call type. */
12
- export declare function Call<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallInstantiate<{}, {
13
- callstack: [];
14
- }, Target, Arguments>;
14
+ export declare function Call<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallInstantiate<{}, TState<[], []>, Target, Arguments>;
15
15
  /** Returns true if the given type is a TCall. */
16
16
  export declare function IsCall(value: unknown): value is TCall;
@@ -3,15 +3,16 @@
3
3
  import { Memory } from '../../system/memory/index.mjs';
4
4
  import { IsKind } from './schema.mjs';
5
5
  import { CallInstantiate } from '../engine/call/instantiate.mjs';
6
+ import { State } from '../engine/instantiate.mjs';
6
7
  export function CallConstruct(target, arguments_) {
7
- return Memory.Create({ ['~kind']: 'Call' }, { target, arguments: arguments_ }, {});
8
+ return Memory.Create({ ['~kind']: 'Call' }, { type: 'call', target, arguments: arguments_ }, {});
8
9
  }
9
10
  // ------------------------------------------------------------------
10
11
  // Factory
11
12
  // ------------------------------------------------------------------
12
13
  /** Creates a Call type. */
13
14
  export function Call(target, arguments_) {
14
- return CallInstantiate({}, { callstack: [] }, target, arguments_);
15
+ return CallInstantiate({}, State([], []), target, arguments_);
15
16
  }
16
17
  // ------------------------------------------------------------------
17
18
  // Guard
@@ -2,6 +2,7 @@ import { type TSchema, type TSchemaOptions } from './schema.mjs';
2
2
  /** Represents a deferred action. */
3
3
  export interface TDeferred<Action extends string = string, Types extends TSchema[] = TSchema[]> extends TSchema {
4
4
  '~kind': 'Deferred';
5
+ type: 'deferred';
5
6
  action: Action;
6
7
  parameters: Types;
7
8
  options: TSchemaOptions;
@@ -5,7 +5,7 @@ import { IsKind } from './schema.mjs';
5
5
  // ------------------------------------------------------------------
6
6
  /** Creates a Deferred action. */
7
7
  export function Deferred(action, parameters, options) {
8
- return Memory.Create({ '~kind': 'Deferred' }, { action, parameters, options }, {});
8
+ return Memory.Create({ '~kind': 'Deferred' }, { type: 'deferred', action, parameters, options }, {});
9
9
  }
10
10
  // ------------------------------------------------------------------
11
11
  // Guard
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.2",
4
+ "version": "1.2.4",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
@@ -1,19 +0,0 @@
1
- import { type TSchema } from '../types/schema.mjs';
2
- /** Represents a operation to apply Optional to a property */
3
- export interface TOptionalAddAction<Type extends TSchema = TSchema> extends TSchema {
4
- '~kind': 'OptionalAddAction';
5
- type: Type;
6
- }
7
- /** Creates an OptionalAddAction. */
8
- export declare function OptionalAddAction<Type extends TSchema>(type: Type): TOptionalAddAction<Type>;
9
- /** Returns true if this value is a OptionalAddAction. */
10
- export declare function IsOptionalAddAction(value: unknown): value is TOptionalAddAction;
11
- /** Represents a operation to remove Optional from a property */
12
- export interface TOptionalRemoveAction<Type extends TSchema = TSchema> extends TSchema {
13
- '~kind': 'OptionalRemoveAction';
14
- type: Type;
15
- }
16
- /** Creates a OptionalRemoveAction. */
17
- export declare function OptionalRemoveAction<Type extends TSchema>(type: Type): TOptionalRemoveAction<Type>;
18
- /** Returns true if this value is a OptionalRemoveAction. */
19
- export declare function IsOptionalRemoveAction(value: unknown): value is TOptionalRemoveAction;
@@ -1,40 +0,0 @@
1
- // deno-fmt-ignore-file
2
- import { Memory } from '../../system/memory/index.mjs';
3
- import { Guard } from '../../guard/index.mjs';
4
- import { IsSchema } from '../types/schema.mjs';
5
- // ------------------------------------------------------------------
6
- // Action
7
- // ------------------------------------------------------------------
8
- /** Creates an OptionalAddAction. */
9
- export function OptionalAddAction(type) {
10
- return Memory.Create({ ['~kind']: 'OptionalAddAction' }, { type }, {});
11
- }
12
- // ------------------------------------------------------------------
13
- // Guard
14
- // ------------------------------------------------------------------
15
- /** Returns true if this value is a OptionalAddAction. */
16
- export function IsOptionalAddAction(value) {
17
- return Guard.IsObject(value)
18
- && Guard.HasPropertyKey(value, '~kind')
19
- && Guard.HasPropertyKey(value, 'type')
20
- && Guard.IsEqual(value['~kind'], 'OptionalAddAction')
21
- && IsSchema(value.type);
22
- }
23
- // ------------------------------------------------------------------
24
- // Factory
25
- // ------------------------------------------------------------------
26
- /** Creates a OptionalRemoveAction. */
27
- export function OptionalRemoveAction(type) {
28
- return Memory.Create({ ['~kind']: 'OptionalRemoveAction' }, { type }, {});
29
- }
30
- // ------------------------------------------------------------------
31
- // Guard
32
- // ------------------------------------------------------------------
33
- /** Returns true if this value is a OptionalRemoveAction. */
34
- export function IsOptionalRemoveAction(value) {
35
- return Guard.IsObject(value)
36
- && Guard.HasPropertyKey(value, '~kind')
37
- && Guard.HasPropertyKey(value, 'type')
38
- && Guard.IsEqual(value['~kind'], 'OptionalRemoveAction')
39
- && IsSchema(value.type);
40
- }
@@ -1,19 +0,0 @@
1
- import { type TSchema } from '../types/schema.mjs';
2
- /** Represents an operation to apply Readonly to a property. */
3
- export interface TReadonlyAddAction<Type extends TSchema = TSchema> extends TSchema {
4
- '~kind': 'ReadonlyAddAction';
5
- type: Type;
6
- }
7
- /** Creates a ReadonlyAddAction. */
8
- export declare function ReadonlyAddAction<Type extends TSchema>(type: Type): TReadonlyAddAction<Type>;
9
- /** Returns true if this value is a ReadonlyAddAction. */
10
- export declare function IsReadonlyAddAction(value: unknown): value is TReadonlyAddAction;
11
- /** Represents an action to remove Readonly from a property. */
12
- export interface TReadonlyRemoveAction<Type extends TSchema = TSchema> extends TSchema {
13
- '~kind': 'ReadonlyRemoveAction';
14
- type: Type;
15
- }
16
- /** Creates a ReadonlyRemoveAction. */
17
- export declare function ReadonlyRemoveAction<Type extends TSchema>(type: Type): TReadonlyRemoveAction<Type>;
18
- /** Returns true if this value is a ReadonlyRemoveAction. */
19
- export declare function IsReadonlyRemoveAction(value: unknown): value is TReadonlyRemoveAction;
@@ -1,40 +0,0 @@
1
- // deno-fmt-ignore-file
2
- import { Memory } from '../../system/memory/index.mjs';
3
- import { Guard } from '../../guard/index.mjs';
4
- import { IsSchema } from '../types/schema.mjs';
5
- // ------------------------------------------------------------------
6
- // Action
7
- // ------------------------------------------------------------------
8
- /** Creates a ReadonlyAddAction. */
9
- export function ReadonlyAddAction(type) {
10
- return Memory.Create({ ['~kind']: 'ReadonlyAddAction' }, { type }, {});
11
- }
12
- // ------------------------------------------------------------------
13
- // Guard
14
- // ------------------------------------------------------------------
15
- /** Returns true if this value is a ReadonlyAddAction. */
16
- export function IsReadonlyAddAction(value) {
17
- return Guard.IsObject(value)
18
- && Guard.HasPropertyKey(value, '~kind')
19
- && Guard.HasPropertyKey(value, 'type')
20
- && Guard.IsEqual(value['~kind'], 'ReadonlyAddAction')
21
- && IsSchema(value.type);
22
- }
23
- // ------------------------------------------------------------------
24
- // Factory
25
- // ------------------------------------------------------------------
26
- /** Creates a ReadonlyRemoveAction. */
27
- export function ReadonlyRemoveAction(type) {
28
- return Memory.Create({ ['~kind']: 'ReadonlyRemoveAction' }, { type }, {});
29
- }
30
- // ------------------------------------------------------------------
31
- // Guard
32
- // ------------------------------------------------------------------
33
- /** Returns true if this value is a ReadonlyRemoveAction. */
34
- export function IsReadonlyRemoveAction(value) {
35
- return Guard.IsObject(value)
36
- && Guard.HasPropertyKey(value, '~kind')
37
- && Guard.HasPropertyKey(value, 'type')
38
- && Guard.IsEqual(value['~kind'], 'ReadonlyRemoveAction')
39
- && IsSchema(value.type);
40
- }