tsondb 0.3.0 → 0.4.0

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 (205) hide show
  1. package/LICENSE +385 -0
  2. package/README.md +173 -1
  3. package/lib/bin/tsondb.d.ts +8 -0
  4. package/lib/bin/tsondb.js +83 -0
  5. package/lib/index.d.ts +2 -1
  6. package/lib/index.js +1 -1
  7. package/lib/{Schema.d.ts → node/Schema.d.ts} +2 -2
  8. package/lib/{Schema.js → node/Schema.js} +1 -1
  9. package/lib/node/index.d.ts +8 -0
  10. package/lib/node/index.js +62 -0
  11. package/lib/{renderers → node/renderers}/Output.d.ts +1 -1
  12. package/lib/{renderers → node/renderers}/jsonschema/index.d.ts +2 -2
  13. package/lib/{renderers → node/renderers}/jsonschema/index.js +2 -2
  14. package/lib/{renderers → node/renderers}/jsonschema/render.d.ts +1 -1
  15. package/lib/{renderers → node/renderers}/jsonschema/render.js +9 -9
  16. package/lib/{renderers → node/renderers}/ts/index.d.ts +2 -2
  17. package/lib/{renderers → node/renderers}/ts/index.js +2 -2
  18. package/lib/{renderers → node/renderers}/ts/render.d.ts +1 -1
  19. package/lib/{renderers → node/renderers}/ts/render.js +9 -8
  20. package/lib/{schema → node/schema}/Node.d.ts +4 -4
  21. package/lib/{schema → node/schema}/Node.js +5 -5
  22. package/lib/{schema/parameters → node/schema}/TypeParameter.d.ts +3 -2
  23. package/lib/{schema/parameters → node/schema}/TypeParameter.js +2 -2
  24. package/lib/{schema → node/schema}/declarations/Declaration.d.ts +10 -11
  25. package/lib/{schema → node/schema}/declarations/Declaration.js +7 -5
  26. package/lib/{schema → node/schema}/declarations/EntityDecl.d.ts +10 -9
  27. package/lib/{schema → node/schema}/declarations/EntityDecl.js +2 -2
  28. package/lib/{schema → node/schema}/declarations/EnumDecl.d.ts +9 -7
  29. package/lib/{schema → node/schema}/declarations/EnumDecl.js +3 -3
  30. package/lib/{schema → node/schema}/declarations/TypeAliasDecl.d.ts +8 -7
  31. package/lib/{schema → node/schema}/declarations/TypeAliasDecl.js +3 -3
  32. package/lib/{schema → node/schema}/index.d.ts +4 -4
  33. package/lib/{schema → node/schema}/index.js +3 -4
  34. package/lib/node/schema/types/Type.d.ts +48 -0
  35. package/lib/{schema → node/schema}/types/Type.js +41 -25
  36. package/lib/{schema → node/schema}/types/generic/ArrayType.d.ts +5 -4
  37. package/lib/{schema → node/schema}/types/generic/ArrayType.js +3 -3
  38. package/lib/{schema → node/schema}/types/generic/EnumType.d.ts +5 -4
  39. package/lib/{schema → node/schema}/types/generic/EnumType.js +4 -2
  40. package/lib/{schema → node/schema}/types/generic/ObjectType.d.ts +8 -7
  41. package/lib/{schema → node/schema}/types/generic/ObjectType.js +8 -4
  42. package/lib/{schema → node/schema}/types/primitives/BooleanType.d.ts +4 -3
  43. package/lib/{schema → node/schema}/types/primitives/DateType.d.ts +5 -4
  44. package/lib/{schema → node/schema}/types/primitives/DateType.js +1 -1
  45. package/lib/{schema → node/schema}/types/primitives/FloatType.d.ts +5 -4
  46. package/lib/{schema → node/schema}/types/primitives/FloatType.js +1 -1
  47. package/lib/{schema → node/schema}/types/primitives/IntegerType.d.ts +5 -4
  48. package/lib/{schema → node/schema}/types/primitives/IntegerType.js +1 -1
  49. package/lib/{schema → node/schema}/types/primitives/NumericType.d.ts +2 -2
  50. package/lib/node/schema/types/primitives/PrimitiveType.d.ts +6 -0
  51. package/lib/{schema → node/schema}/types/primitives/StringType.d.ts +5 -4
  52. package/lib/{schema → node/schema}/types/primitives/StringType.js +1 -1
  53. package/lib/{schema → node/schema}/types/references/IncludeIdentifierType.d.ts +9 -8
  54. package/lib/{schema → node/schema}/types/references/IncludeIdentifierType.js +1 -1
  55. package/lib/{schema → node/schema}/types/references/NestedEntityMapType.d.ts +10 -9
  56. package/lib/{schema → node/schema}/types/references/NestedEntityMapType.js +4 -4
  57. package/lib/{schema → node/schema}/types/references/ReferenceIdentifierType.d.ts +7 -6
  58. package/lib/{schema → node/schema}/types/references/ReferenceIdentifierType.js +1 -1
  59. package/lib/node/schema/types/references/TypeArgumentType.d.ts +23 -0
  60. package/lib/node/schema/types/references/TypeArgumentType.js +19 -0
  61. package/lib/node/schema/validation/type.d.ts +4 -0
  62. package/lib/{server → node/server}/api/declarations.js +1 -1
  63. package/lib/{server → node/server}/api/git.js +14 -10
  64. package/lib/{server → node/server}/api/instanceOperations.d.ts +3 -3
  65. package/lib/{server → node/server}/api/instanceOperations.js +13 -4
  66. package/lib/{server → node/server}/api/instances.js +7 -3
  67. package/lib/node/server/index.d.ts +28 -0
  68. package/lib/{server → node/server}/index.js +6 -6
  69. package/lib/node/server/init.d.ts +5 -0
  70. package/lib/{server → node/server}/init.js +8 -8
  71. package/lib/{utils → node/utils}/error.js +4 -1
  72. package/lib/{utils → node/utils}/git.d.ts +2 -2
  73. package/lib/{utils → node/utils}/instances.d.ts +3 -3
  74. package/lib/{utils → node/utils}/instances.js +8 -6
  75. package/lib/{utils → node/utils}/references.d.ts +2 -2
  76. package/lib/{utils → node/utils}/references.js +3 -3
  77. package/lib/{utils → node/utils}/render.js +1 -1
  78. package/lib/shared/api.d.ts +8 -2
  79. package/lib/shared/utils/array.js +12 -9
  80. package/lib/shared/utils/displayName.d.ts +1 -1
  81. package/lib/shared/utils/displayName.js +4 -2
  82. package/lib/shared/utils/instances.d.ts +2 -2
  83. package/lib/{utils → shared/utils}/lazy.js +1 -1
  84. package/lib/shared/utils/markdown.js +6 -6
  85. package/lib/shared/utils/object.d.ts +3 -0
  86. package/lib/shared/utils/object.js +1 -0
  87. package/lib/{utils → shared/utils}/result.js +2 -2
  88. package/lib/shared/utils/string.js +7 -4
  89. package/lib/shared/utils/validation.js +3 -2
  90. package/lib/shared/validation/number.js +3 -3
  91. package/lib/shared/validation/object.js +4 -3
  92. package/lib/shared/validation/string.js +12 -7
  93. package/lib/{client → web}/api.d.ts +2 -2
  94. package/lib/{client → web}/api.js +4 -2
  95. package/lib/web/components/Git.d.ts +2 -0
  96. package/lib/{client → web}/components/Git.js +58 -14
  97. package/lib/{client → web}/components/Layout.d.ts +1 -1
  98. package/lib/{client → web}/components/Layout.js +1 -1
  99. package/lib/web/components/Select.d.ts +3 -0
  100. package/lib/web/components/Select.js +5 -0
  101. package/lib/web/components/typeInputs/ArrayTypeInput.d.ts +13 -0
  102. package/lib/{client → web}/components/typeInputs/ArrayTypeInput.js +7 -1
  103. package/lib/{client → web}/components/typeInputs/BooleanTypeInput.d.ts +2 -2
  104. package/lib/{client → web}/components/typeInputs/DateTypeInput.d.ts +2 -2
  105. package/lib/web/components/typeInputs/EnumTypeInput.d.ts +13 -0
  106. package/lib/{client → web}/components/typeInputs/EnumTypeInput.js +1 -1
  107. package/lib/{client → web}/components/typeInputs/FloatTypeInput.d.ts +2 -2
  108. package/lib/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +7 -0
  109. package/lib/{client → web}/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.js +1 -1
  110. package/lib/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +13 -0
  111. package/lib/{client → web}/components/typeInputs/IntegerTypeInput.d.ts +2 -2
  112. package/lib/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +13 -0
  113. package/lib/{client → web}/components/typeInputs/NestedEntityMapTypeInput.js +7 -2
  114. package/lib/{client → web}/components/typeInputs/ObjectTypeInput.d.ts +4 -4
  115. package/lib/{client → web}/components/typeInputs/ObjectTypeInput.js +4 -1
  116. package/lib/{client → web}/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -3
  117. package/lib/web/components/typeInputs/ReferenceIdentifierTypeInput.js +11 -0
  118. package/lib/{client → web}/components/typeInputs/StringTypeInput.d.ts +2 -2
  119. package/lib/web/components/typeInputs/TypeInput.d.ts +13 -0
  120. package/lib/{client → web}/components/typeInputs/TypeInput.js +3 -3
  121. package/lib/{client → web}/components/typeInputs/utils/Markdown.d.ts +1 -1
  122. package/lib/{client → web}/components/typeInputs/utils/Markdown.js +2 -2
  123. package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.d.ts +1 -1
  124. package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.d.ts +1 -1
  125. package/lib/web/hooks/useAPIResource.d.ts +1 -0
  126. package/lib/{client → web}/hooks/useEntityFromRoute.d.ts +1 -1
  127. package/lib/{client → web}/hooks/useEntityFromRoute.js +1 -1
  128. package/lib/{client → web}/hooks/useInstanceNamesByEntity.d.ts +1 -1
  129. package/lib/{client → web}/hooks/useInstanceNamesByEntity.js +8 -6
  130. package/lib/web/hooks/useMappedAPIResource.d.ts +1 -0
  131. package/lib/{client → web}/hooks/useMappedAPIResource.js +7 -9
  132. package/lib/{client → web}/hooks/useSecondaryDeclarations.d.ts +1 -1
  133. package/lib/{client → web}/hooks/useSecondaryDeclarations.js +4 -2
  134. package/lib/{client → web}/routes/CreateInstance.d.ts +1 -1
  135. package/lib/{client → web}/routes/CreateInstance.js +4 -2
  136. package/lib/web/routes/Entity.d.ts +2 -0
  137. package/lib/{client → web}/routes/Entity.js +5 -3
  138. package/lib/web/routes/Home.d.ts +2 -0
  139. package/lib/{client → web}/routes/Instance.d.ts +1 -1
  140. package/lib/{client → web}/routes/Instance.js +14 -8
  141. package/lib/{client → web}/routes/NotFound.d.ts +1 -1
  142. package/lib/web/utils/typeSkeleton.d.ts +3 -0
  143. package/lib/{client → web}/utils/typeSkeleton.js +4 -1
  144. package/package.json +31 -18
  145. package/lib/ModelContainer.d.ts +0 -17
  146. package/lib/ModelContainer.js +0 -65
  147. package/lib/client/components/Git.d.ts +0 -2
  148. package/lib/client/components/Select.d.ts +0 -3
  149. package/lib/client/components/Select.js +0 -2
  150. package/lib/client/components/typeInputs/ArrayTypeInput.d.ts +0 -13
  151. package/lib/client/components/typeInputs/EnumTypeInput.d.ts +0 -13
  152. package/lib/client/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +0 -7
  153. package/lib/client/components/typeInputs/IncludeIdentifierTypeInput.d.ts +0 -13
  154. package/lib/client/components/typeInputs/NestedEntityMapTypeInput.d.ts +0 -13
  155. package/lib/client/components/typeInputs/ReferenceIdentifierTypeInput.js +0 -9
  156. package/lib/client/components/typeInputs/TypeInput.d.ts +0 -13
  157. package/lib/client/hooks/useAPIResource.d.ts +0 -1
  158. package/lib/client/hooks/useMappedAPIResource.d.ts +0 -1
  159. package/lib/client/routes/Entity.d.ts +0 -2
  160. package/lib/client/routes/Home.d.ts +0 -2
  161. package/lib/client/utils/typeSkeleton.d.ts +0 -3
  162. package/lib/schema/types/Type.d.ts +0 -48
  163. package/lib/schema/types/primitives/PrimitiveType.d.ts +0 -6
  164. package/lib/schema/types/references/GenericArgumentIdentifierType.d.ts +0 -22
  165. package/lib/schema/types/references/GenericArgumentIdentifierType.js +0 -19
  166. package/lib/schema/validation/type.d.ts +0 -4
  167. package/lib/server/index.d.ts +0 -29
  168. package/lib/server/init.d.ts +0 -5
  169. package/lib/tsconfig.tsbuildinfo +0 -1
  170. package/lib/utils/object.d.ts +0 -3
  171. package/lib/utils/object.js +0 -1
  172. /package/lib/{renderers → node/renderers}/Output.js +0 -0
  173. /package/lib/{schema → node/schema}/types/primitives/BooleanType.js +0 -0
  174. /package/lib/{schema → node/schema}/types/primitives/NumericType.js +0 -0
  175. /package/lib/{schema → node/schema}/types/primitives/PrimitiveType.js +0 -0
  176. /package/lib/{schema → node/schema}/validation/options.d.ts +0 -0
  177. /package/lib/{schema → node/schema}/validation/options.js +0 -0
  178. /package/lib/{schema → node/schema}/validation/type.js +0 -0
  179. /package/lib/{server → node/server}/api/declarations.d.ts +0 -0
  180. /package/lib/{server → node/server}/api/git.d.ts +0 -0
  181. /package/lib/{server → node/server}/api/index.d.ts +0 -0
  182. /package/lib/{server → node/server}/api/index.js +0 -0
  183. /package/lib/{server → node/server}/api/instances.d.ts +0 -0
  184. /package/lib/{utils → node/utils}/error.d.ts +0 -0
  185. /package/lib/{utils → node/utils}/git.js +0 -0
  186. /package/lib/{utils → node/utils}/path.d.ts +0 -0
  187. /package/lib/{utils → node/utils}/path.js +0 -0
  188. /package/lib/{utils → node/utils}/render.d.ts +0 -0
  189. /package/lib/{utils → shared/utils}/enum.d.ts +0 -0
  190. /package/lib/{utils → shared/utils}/enum.js +0 -0
  191. /package/lib/{utils → shared/utils}/lazy.d.ts +0 -0
  192. /package/lib/{utils → shared/utils}/result.d.ts +0 -0
  193. /package/lib/{client → web}/components/typeInputs/BooleanTypeInput.js +0 -0
  194. /package/lib/{client → web}/components/typeInputs/DateTypeInput.js +0 -0
  195. /package/lib/{client → web}/components/typeInputs/FloatTypeInput.js +0 -0
  196. /package/lib/{client → web}/components/typeInputs/IncludeIdentifierTypeInput.js +0 -0
  197. /package/lib/{client → web}/components/typeInputs/IntegerTypeInput.js +0 -0
  198. /package/lib/{client → web}/components/typeInputs/StringTypeInput.js +0 -0
  199. /package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.js +0 -0
  200. /package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.js +0 -0
  201. /package/lib/{client → web}/hooks/useAPIResource.js +0 -0
  202. /package/lib/{client → web}/index.d.ts +0 -0
  203. /package/lib/{client → web}/index.js +0 -0
  204. /package/lib/{client → web}/routes/Home.js +0 -0
  205. /package/lib/{client → web}/routes/NotFound.js +0 -0
@@ -0,0 +1,48 @@
1
+ import type { Decl } from "../declarations/Declaration.js";
2
+ import type { BaseNode, GetReferences, Serializer } from "../Node.js";
3
+ import type { Validator } from "../validation/type.js";
4
+ import type { ArrayType, SerializedArrayType } from "./generic/ArrayType.js";
5
+ import type { EnumType, SerializedEnumType } from "./generic/EnumType.js";
6
+ import type { MemberDecl, ObjectType, SerializedMemberDecl, SerializedObjectType } from "./generic/ObjectType.js";
7
+ import type { BooleanType, SerializedBooleanType } from "./primitives/BooleanType.js";
8
+ import type { DateType, SerializedDateType } from "./primitives/DateType.js";
9
+ import type { FloatType, SerializedFloatType } from "./primitives/FloatType.js";
10
+ import type { IntegerType, SerializedIntegerType } from "./primitives/IntegerType.js";
11
+ import type { PrimitiveType, SerializedPrimitiveType } from "./primitives/PrimitiveType.js";
12
+ import type { SerializedStringType, StringType } from "./primitives/StringType.js";
13
+ import type { IncludeIdentifierType, SerializedIncludeIdentifierType } from "./references/IncludeIdentifierType.js";
14
+ import type { NestedEntityMapType, SerializedNestedEntityMapType } from "./references/NestedEntityMapType.js";
15
+ import type { ReferenceIdentifierType, SerializedReferenceIdentifierType } from "./references/ReferenceIdentifierType.js";
16
+ import type { SerializedTypeArgumentType, TypeArgumentType } from "./references/TypeArgumentType.js";
17
+ export interface BaseType extends BaseNode {
18
+ /**
19
+ * The parent node of this type will be set when the type is used in a declaration or nested in another type.
20
+ */
21
+ parent?: Type | Decl;
22
+ }
23
+ export interface SerializedBaseType extends BaseNode {
24
+ }
25
+ export type Type = PrimitiveType | ArrayType | ObjectType | TypeArgumentType | ReferenceIdentifierType | IncludeIdentifierType | NestedEntityMapType | EnumType;
26
+ export type SerializedType = SerializedPrimitiveType | SerializedArrayType | SerializedObjectType | SerializedTypeArgumentType | SerializedReferenceIdentifierType | SerializedIncludeIdentifierType | SerializedNestedEntityMapType | SerializedEnumType;
27
+ export declare const validate: Validator<Type>;
28
+ export declare const resolveTypeArgumentsInType: (args: Record<string, Type>, type: Type) => Type;
29
+ export declare function walkTypeNodeTree(callbackFn: (type: Type) => void, type: Type): void;
30
+ export type AsType<T extends Type> = T extends ArrayType<infer I> ? AsType<I>[] : T extends ObjectType<infer P> ? {
31
+ [K in keyof P]: P[K] extends MemberDecl<Type, true> ? AsType<P[K]["type"]> : AsType<P[K]["type"]> | undefined;
32
+ } : T extends BooleanType ? boolean : T extends DateType ? Date : T extends FloatType ? number : T extends IntegerType ? number : T extends StringType ? string : T extends TypeArgumentType ? unknown : T extends IncludeIdentifierType ? unknown : T extends NestedEntityMapType ? unknown : T extends ReferenceIdentifierType ? unknown : never;
33
+ export type SerializedAsType<T extends SerializedType> = T extends SerializedArrayType<infer I> ? SerializedAsType<I>[] : T extends SerializedObjectType<infer P> ? {
34
+ [K in keyof P]: P[K] extends SerializedMemberDecl<SerializedType, true> ? SerializedAsType<P[K]["type"]> : SerializedAsType<P[K]["type"]> | undefined;
35
+ } : T extends SerializedBooleanType ? boolean : T extends SerializedDateType ? Date : T extends SerializedFloatType ? number : T extends SerializedIntegerType ? number : T extends SerializedStringType ? string : T extends SerializedTypeArgumentType ? unknown : T extends SerializedIncludeIdentifierType ? unknown : T extends SerializedNestedEntityMapType ? unknown : T extends SerializedReferenceIdentifierType ? unknown : never;
36
+ export type AsNode<T> = T extends (infer I)[] ? ArrayType<AsNode<I>> : T extends Record<string, unknown> ? ObjectType<{
37
+ [K in keyof T]: T[K] extends MemberDecl ? T[K] : T extends null | undefined ? MemberDecl<AsNode<NonNullable<T[K]>>, false> : MemberDecl<AsNode<T[K]>, true>;
38
+ }> : T extends string ? StringType : T extends number ? FloatType : T extends boolean ? BooleanType : never;
39
+ export declare const getParentDecl: (type: Type) => Decl | undefined;
40
+ export declare const findTypeAtPath: (type: Type, path: string[]) => Type | undefined;
41
+ export declare const serializeType: Serializer<Type, SerializedType>;
42
+ export declare const removeParentKey: <T extends BaseType>(type: T) => Omit<T, "parent">;
43
+ export declare const getReferencesForType: GetReferences<Type>;
44
+ /**
45
+ * Format the structure of a value to always look the same when serialized as JSON.
46
+ */
47
+ export type StructureFormatter<T extends Type> = (type: T, value: unknown) => unknown;
48
+ export declare const formatValue: StructureFormatter<Type>;
@@ -1,4 +1,4 @@
1
- import { assertExhaustive } from "../../shared/utils/typeSafety.js";
1
+ import { assertExhaustive } from "../../../shared/utils/typeSafety.js";
2
2
  import { isDecl } from "../declarations/Declaration.js";
3
3
  import { NodeKind } from "../Node.js";
4
4
  import { formatArrayValue, getReferencesForArrayType, resolveTypeArgumentsInArrayType, serializeArrayType, validateArrayType, } from "./generic/ArrayType.js";
@@ -9,10 +9,10 @@ import { formatDateValue, getReferencesForDateType, serializeDateType, validateD
9
9
  import { formatFloatValue, getReferencesForFloatType, serializeFloatType, validateFloatType, } from "./primitives/FloatType.js";
10
10
  import { formatIntegerValue, getReferencesForIntegerType, serializeIntegerType, validateIntegerType, } from "./primitives/IntegerType.js";
11
11
  import { formatStringValue, getReferencesForStringType, serializeStringType, validateStringType, } from "./primitives/StringType.js";
12
- import { formatGenericArgumentIdentifierValue, getReferencesForGenericArgumentIdentifierType, resolveTypeArgumentsInGenericArgumentIdentifierType, serializeGenericArgumentIdentifierType, validateGenericArgumentIdentifierType, } from "./references/GenericArgumentIdentifierType.js";
13
12
  import { formatIncludeIdentifierValue, getReferencesForIncludeIdentifierType, resolveTypeArgumentsInIncludeIdentifierType, serializeIncludeIdentifierType, validateIncludeIdentifierType, } from "./references/IncludeIdentifierType.js";
14
13
  import { formatNestedEntityMapValue, getReferencesForNestedEntityMapType, resolveTypeArgumentsInNestedEntityMapType, serializeNestedEntityMapType, validateNestedEntityMapType, } from "./references/NestedEntityMapType.js";
15
14
  import { formatReferenceIdentifierValue, getReferencesForReferenceIdentifierType, resolveTypeArgumentsInReferenceIdentifierType, serializeReferenceIdentifierType, validateReferenceIdentifierType, } from "./references/ReferenceIdentifierType.js";
15
+ import { formatTypeArgumentValue, getReferencesForTypeArgumentType, resolveTypeArgumentsInTypeArgumentType, serializeTypeArgumentType, validateTypeArgumentType, } from "./references/TypeArgumentType.js";
16
16
  export const validate = (helpers, type, value) => {
17
17
  switch (type.kind) {
18
18
  case NodeKind.ArrayType:
@@ -29,8 +29,8 @@ export const validate = (helpers, type, value) => {
29
29
  return validateIntegerType(helpers, type, value);
30
30
  case NodeKind.StringType:
31
31
  return validateStringType(helpers, type, value);
32
- case NodeKind.GenericArgumentIdentifierType:
33
- return validateGenericArgumentIdentifierType(helpers, type, value);
32
+ case NodeKind.TypeArgumentType:
33
+ return validateTypeArgumentType(helpers, type, value);
34
34
  case NodeKind.ReferenceIdentifierType:
35
35
  return validateReferenceIdentifierType(helpers, type, value);
36
36
  case NodeKind.IncludeIdentifierType:
@@ -55,8 +55,8 @@ export const resolveTypeArgumentsInType = (args, type) => {
55
55
  case NodeKind.IntegerType:
56
56
  case NodeKind.StringType:
57
57
  return type;
58
- case NodeKind.GenericArgumentIdentifierType:
59
- return resolveTypeArgumentsInGenericArgumentIdentifierType(args, type);
58
+ case NodeKind.TypeArgumentType:
59
+ return resolveTypeArgumentsInTypeArgumentType(args, type);
60
60
  case NodeKind.ReferenceIdentifierType:
61
61
  return resolveTypeArgumentsInReferenceIdentifierType(args, type);
62
62
  case NodeKind.IncludeIdentifierType:
@@ -73,29 +73,45 @@ export function walkTypeNodeTree(callbackFn, type) {
73
73
  switch (type.kind) {
74
74
  case NodeKind.ArrayType:
75
75
  callbackFn(type);
76
- return walkTypeNodeTree(callbackFn, type.items);
76
+ {
77
+ walkTypeNodeTree(callbackFn, type.items);
78
+ return;
79
+ }
77
80
  case NodeKind.ObjectType:
78
81
  callbackFn(type);
79
- return Object.values(type.properties).forEach(prop => walkTypeNodeTree(callbackFn, prop.type));
82
+ {
83
+ Object.values(type.properties).forEach(prop => {
84
+ walkTypeNodeTree(callbackFn, prop.type);
85
+ });
86
+ return;
87
+ }
80
88
  case NodeKind.NestedEntityMapType:
81
89
  callbackFn(type);
82
- return walkTypeNodeTree(callbackFn, type.type.value);
90
+ {
91
+ walkTypeNodeTree(callbackFn, type.type.value);
92
+ return;
93
+ }
83
94
  case NodeKind.BooleanType:
84
95
  case NodeKind.DateType:
85
96
  case NodeKind.FloatType:
86
97
  case NodeKind.IntegerType:
87
98
  case NodeKind.StringType:
88
- case NodeKind.GenericArgumentIdentifierType:
99
+ case NodeKind.TypeArgumentType:
89
100
  case NodeKind.ReferenceIdentifierType:
90
- case NodeKind.IncludeIdentifierType:
91
- return callbackFn(type);
101
+ case NodeKind.IncludeIdentifierType: {
102
+ callbackFn(type);
103
+ return;
104
+ }
92
105
  case NodeKind.EnumType:
93
106
  callbackFn(type);
94
- return Object.values(type.values).forEach(value => {
95
- if (value.type) {
96
- walkTypeNodeTree(callbackFn, value.type);
97
- }
98
- });
107
+ {
108
+ Object.values(type.values).forEach(value => {
109
+ if (value.type) {
110
+ walkTypeNodeTree(callbackFn, value.type);
111
+ }
112
+ });
113
+ return;
114
+ }
99
115
  default:
100
116
  return assertExhaustive(type);
101
117
  }
@@ -112,10 +128,10 @@ export const getParentDecl = (type) => {
112
128
  }
113
129
  };
114
130
  export const findTypeAtPath = (type, path) => {
115
- if (path.length === 0) {
131
+ const [head, ...tail] = path;
132
+ if (head === undefined) {
116
133
  return type;
117
134
  }
118
- const [head, ...tail] = path;
119
135
  if (type.kind === NodeKind.ObjectType) {
120
136
  const prop = type.properties[head];
121
137
  if (prop) {
@@ -143,8 +159,8 @@ export const serializeType = type => {
143
159
  return serializeIntegerType(type);
144
160
  case NodeKind.StringType:
145
161
  return serializeStringType(type);
146
- case NodeKind.GenericArgumentIdentifierType:
147
- return serializeGenericArgumentIdentifierType(type);
162
+ case NodeKind.TypeArgumentType:
163
+ return serializeTypeArgumentType(type);
148
164
  case NodeKind.ReferenceIdentifierType:
149
165
  return serializeReferenceIdentifierType(type);
150
166
  case NodeKind.IncludeIdentifierType:
@@ -177,8 +193,8 @@ export const getReferencesForType = (type, value) => {
177
193
  return getReferencesForIntegerType(type, value);
178
194
  case NodeKind.StringType:
179
195
  return getReferencesForStringType(type, value);
180
- case NodeKind.GenericArgumentIdentifierType:
181
- return getReferencesForGenericArgumentIdentifierType(type, value);
196
+ case NodeKind.TypeArgumentType:
197
+ return getReferencesForTypeArgumentType(type, value);
182
198
  case NodeKind.ReferenceIdentifierType:
183
199
  return getReferencesForReferenceIdentifierType(type, value);
184
200
  case NodeKind.IncludeIdentifierType:
@@ -207,8 +223,8 @@ export const formatValue = (type, value) => {
207
223
  return formatIntegerValue(type, value);
208
224
  case NodeKind.StringType:
209
225
  return formatStringValue(type, value);
210
- case NodeKind.GenericArgumentIdentifierType:
211
- return formatGenericArgumentIdentifierValue(type, value);
226
+ case NodeKind.TypeArgumentType:
227
+ return formatTypeArgumentValue(type, value);
212
228
  case NodeKind.IncludeIdentifierType:
213
229
  return formatIncludeIdentifierValue(type, value);
214
230
  case NodeKind.NestedEntityMapType:
@@ -1,7 +1,8 @@
1
- import { GetNestedDeclarations } from "../../declarations/Declaration.js";
2
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
3
- import { Validator } from "../../validation/type.js";
4
- import { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
1
+ import type { GetNestedDeclarations } from "../../declarations/Declaration.js";
2
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
5
6
  export interface ArrayType<T extends Type = Type> extends BaseType {
6
7
  kind: NodeKind["ArrayType"];
7
8
  minItems?: number;
@@ -1,5 +1,5 @@
1
- import { parallelizeErrors } from "../../../shared/utils/validation.js";
2
- import { validateArrayConstraints } from "../../../shared/validation/array.js";
1
+ import { parallelizeErrors } from "../../../../shared/utils/validation.js";
2
+ import { validateArrayConstraints } from "../../../../shared/validation/array.js";
3
3
  import { wrapErrorsIfAny } from "../../../utils/error.js";
4
4
  import { getNestedDeclarations } from "../../declarations/Declaration.js";
5
5
  import { NodeKind } from "../../Node.js";
@@ -25,7 +25,7 @@ export const validateArrayType = (helpers, type, value) => {
25
25
  }
26
26
  return parallelizeErrors([
27
27
  ...validateArrayConstraints(type, value),
28
- ...value.map((item, index) => wrapErrorsIfAny(`at index ${index}`, validate(helpers, type.items, item))),
28
+ ...value.map((item, index) => wrapErrorsIfAny(`at index ${index.toString()}`, validate(helpers, type.items, item))),
29
29
  ]);
30
30
  };
31
31
  export const resolveTypeArgumentsInArrayType = (args, type) => ArrayType(resolveTypeArgumentsInType(args, type.items), {
@@ -1,7 +1,8 @@
1
- import { GetNestedDeclarations } from "../../declarations/Declaration.js";
2
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
3
- import { Validator } from "../../validation/type.js";
4
- import { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
1
+ import type { GetNestedDeclarations } from "../../declarations/Declaration.js";
2
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
5
6
  export interface EnumType<T extends Record<string, EnumCaseDecl> = Record<string, EnumCaseDecl>> extends BaseType {
6
7
  kind: NodeKind["EnumType"];
7
8
  values: T;
@@ -1,4 +1,4 @@
1
- import { discriminatorKey } from "../../../shared/enum.js";
1
+ import { discriminatorKey } from "../../../../shared/enum.js";
2
2
  import { getNestedDeclarations } from "../../declarations/Declaration.js";
3
3
  import { NodeKind } from "../../Node.js";
4
4
  import { formatValue, getReferencesForType, removeParentKey, resolveTypeArgumentsInType, serializeType, validate, } from "../Type.js";
@@ -74,7 +74,9 @@ export const getReferencesForEnumType = (type, value) => typeof value === "objec
74
74
  value[discriminatorKey] in type.values &&
75
75
  type.values[value[discriminatorKey]]?.type == null &&
76
76
  value[discriminatorKey] in value
77
- ? getReferencesForType(type.values[value[discriminatorKey]].type, value[value[discriminatorKey]])
77
+ ? getReferencesForType(
78
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
79
+ type.values[value[discriminatorKey]].type, value[value[discriminatorKey]])
78
80
  : [];
79
81
  export const formatEnumType = (type, value) => {
80
82
  if (typeof value === "object" &&
@@ -1,14 +1,15 @@
1
- import { ObjectConstraints } from "../../../shared/validation/object.js";
2
- import { GetNestedDeclarations } from "../../declarations/Declaration.js";
3
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
4
- import { Validator } from "../../validation/type.js";
5
- import { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
6
- type TConstraint = Record<string, MemberDecl<Type, boolean>>;
1
+ import type { ObjectConstraints } from "../../../../shared/validation/object.js";
2
+ import type { GetNestedDeclarations } from "../../declarations/Declaration.js";
3
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
4
+ import { NodeKind } from "../../Node.js";
5
+ import type { Validator } from "../../validation/type.js";
6
+ import type { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
7
+ type TConstraint = Record<string, MemberDecl>;
7
8
  export interface ObjectType<T extends TConstraint = TConstraint> extends BaseType, ObjectConstraints {
8
9
  kind: NodeKind["ObjectType"];
9
10
  properties: T;
10
11
  }
11
- type TSerializedConstraint = Record<string, SerializedMemberDecl<SerializedType, boolean>>;
12
+ type TSerializedConstraint = Record<string, SerializedMemberDecl>;
12
13
  export interface SerializedObjectType<T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseType, ObjectConstraints {
13
14
  kind: NodeKind["ObjectType"];
14
15
  properties: T;
@@ -1,6 +1,6 @@
1
- import { sortObjectKeys } from "../../../shared/utils/object.js";
2
- import { parallelizeErrors } from "../../../shared/utils/validation.js";
3
- import { validateObjectConstraints } from "../../../shared/validation/object.js";
1
+ import { sortObjectKeys } from "../../../../shared/utils/object.js";
2
+ import { parallelizeErrors } from "../../../../shared/utils/validation.js";
3
+ import { validateObjectConstraints } from "../../../../shared/validation/object.js";
4
4
  import { wrapErrorsIfAny } from "../../../utils/error.js";
5
5
  import { getNestedDeclarations } from "../../declarations/Declaration.js";
6
6
  import { NodeKind } from "../../Node.js";
@@ -19,6 +19,7 @@ export const ObjectType = (properties, options = {}) => {
19
19
  if (!keyPattern.test(key)) {
20
20
  throw new TypeError(`Invalid object key "${key}". Object keys must not start with an underscore and may only contain letters, digits and underscores. (Pattern: ${keyPattern.source})`);
21
21
  }
22
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
23
  properties[key].type.parent = type;
23
24
  });
24
25
  return type;
@@ -34,6 +35,7 @@ export const validateObjectType = (helpers, type, value) => {
34
35
  return parallelizeErrors([
35
36
  ...validateObjectConstraints(type, expectedKeys, value),
36
37
  ...expectedKeys.map(key => {
38
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
39
  const prop = type.properties[key];
38
40
  if (prop.isRequired && !(key in value)) {
39
41
  return TypeError(`missing required property "${key}"`);
@@ -68,7 +70,9 @@ export const serializeObjectType = type => ({
68
70
  ])),
69
71
  });
70
72
  export const getReferencesForObjectType = (type, value) => typeof value === "object" && value !== null
71
- ? Object.entries(value).flatMap(([key, propValue]) => key in type.properties ? getReferencesForType(type.properties[key].type, propValue) : [])
73
+ ? Object.entries(value).flatMap(([key, propValue]) =>
74
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
+ key in type.properties ? getReferencesForType(type.properties[key].type, propValue) : [])
72
76
  : [];
73
77
  export const formatObjectValue = (type, value) => typeof value === "object" && value !== null && !Array.isArray(value)
74
78
  ? sortObjectKeys(value, Object.keys(type.properties))
@@ -1,6 +1,7 @@
1
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
2
- import { Validator } from "../../validation/type.js";
3
- import { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
1
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
2
+ import { NodeKind } from "../../Node.js";
3
+ import type { Validator } from "../../validation/type.js";
4
+ import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
4
5
  export interface BooleanType extends BaseType {
5
6
  kind: NodeKind["BooleanType"];
6
7
  }
@@ -1,7 +1,8 @@
1
- import { DateConstraints } from "../../../shared/validation/date.js";
2
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
3
- import { Validator } from "../../validation/type.js";
4
- import { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
1
+ import type { DateConstraints } from "../../../../shared/validation/date.js";
2
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
5
6
  export interface DateType extends BaseType, DateConstraints {
6
7
  kind: NodeKind["DateType"];
7
8
  }
@@ -1,4 +1,4 @@
1
- import { validateDateConstraints } from "../../../shared/validation/date.js";
1
+ import { validateDateConstraints } from "../../../../shared/validation/date.js";
2
2
  import { NodeKind } from "../../Node.js";
3
3
  import { removeParentKey } from "../Type.js";
4
4
  export const DateType = (options) => ({
@@ -1,7 +1,8 @@
1
- import { RangeBound } from "../../../shared/validation/number.js";
2
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
3
- import { Validator } from "../../validation/type.js";
4
- import { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
1
+ import type { RangeBound } from "../../../../shared/validation/number.js";
2
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
5
6
  export interface FloatType extends BaseType {
6
7
  kind: NodeKind["FloatType"];
7
8
  minimum?: RangeBound;
@@ -1,4 +1,4 @@
1
- import { validateNumberConstraints } from "../../../shared/validation/number.js";
1
+ import { validateNumberConstraints } from "../../../../shared/validation/number.js";
2
2
  import { NodeKind } from "../../Node.js";
3
3
  import { removeParentKey } from "../Type.js";
4
4
  export const FloatType = (options = {}) => ({
@@ -1,7 +1,8 @@
1
- import { RangeBound } from "../../../shared/validation/number.js";
2
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
3
- import { Validator } from "../../validation/type.js";
4
- import { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
1
+ import type { RangeBound } from "../../../../shared/validation/number.js";
2
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
5
6
  export interface IntegerType extends BaseType {
6
7
  kind: NodeKind["IntegerType"];
7
8
  minimum?: RangeBound;
@@ -1,4 +1,4 @@
1
- import { validateNumberConstraints } from "../../../shared/validation/number.js";
1
+ import { validateNumberConstraints } from "../../../../shared/validation/number.js";
2
2
  import { NodeKind } from "../../Node.js";
3
3
  import { validateOption } from "../../validation/options.js";
4
4
  import { removeParentKey } from "../Type.js";
@@ -1,5 +1,5 @@
1
- import { FloatType, SerializedFloatType } from "./FloatType.js";
2
- import { IntegerType, SerializedIntegerType } from "./IntegerType.js";
1
+ import type { FloatType, SerializedFloatType } from "./FloatType.js";
2
+ import type { IntegerType, SerializedIntegerType } from "./IntegerType.js";
3
3
  export type NumericType = FloatType | IntegerType;
4
4
  export type SerializedNumericType = SerializedFloatType | SerializedIntegerType;
5
5
  export * from "./FloatType.js";
@@ -0,0 +1,6 @@
1
+ import type { BooleanType, SerializedBooleanType } from "./BooleanType.js";
2
+ import type { DateType, SerializedDateType } from "./DateType.js";
3
+ import type { NumericType, SerializedNumericType } from "./NumericType.js";
4
+ import type { SerializedStringType, StringType } from "./StringType.js";
5
+ export type PrimitiveType = BooleanType | DateType | NumericType | StringType;
6
+ export type SerializedPrimitiveType = SerializedBooleanType | SerializedDateType | SerializedNumericType | SerializedStringType;
@@ -1,7 +1,8 @@
1
- import { StringConstraints } from "../../../shared/validation/string.js";
2
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
3
- import { Validator } from "../../validation/type.js";
4
- import { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
1
+ import type { StringConstraints } from "../../../../shared/validation/string.js";
2
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.js";
5
6
  export interface StringType extends BaseType, StringConstraints {
6
7
  kind: NodeKind["StringType"];
7
8
  pattern?: RegExp;
@@ -1,4 +1,4 @@
1
- import { validateStringConstraints } from "../../../shared/validation/string.js";
1
+ import { validateStringConstraints } from "../../../../shared/validation/string.js";
2
2
  import { NodeKind } from "../../Node.js";
3
3
  import { removeParentKey } from "../Type.js";
4
4
  export const StringType = (options = {}) => ({
@@ -1,11 +1,12 @@
1
- import { GetNestedDeclarations, SerializedTypeArguments, TypeArguments } from "../../declarations/Declaration.js";
2
- import { EnumDecl } from "../../declarations/EnumDecl.js";
3
- import { TypeAliasDecl } from "../../declarations/TypeAliasDecl.js";
4
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
5
- import { SerializedTypeParameter, TypeParameter } from "../../parameters/TypeParameter.js";
6
- import { Validator } from "../../validation/type.js";
7
- import { EnumCaseDecl } from "../generic/EnumType.js";
8
- import { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
1
+ import type { GetNestedDeclarations, SerializedTypeArguments, TypeArguments } from "../../declarations/Declaration.js";
2
+ import type { EnumDecl } from "../../declarations/EnumDecl.js";
3
+ import type { TypeAliasDecl } from "../../declarations/TypeAliasDecl.js";
4
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
5
+ import { NodeKind } from "../../Node.js";
6
+ import type { SerializedTypeParameter, TypeParameter } from "../../TypeParameter.js";
7
+ import type { Validator } from "../../validation/type.js";
8
+ import type { EnumCaseDecl } from "../generic/EnumType.js";
9
+ import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
9
10
  type TConstraint<Params extends TypeParameter[]> = TypeAliasDecl<string, Type, Params> | EnumDecl<string, Record<string, EnumCaseDecl>, Params>;
10
11
  export interface IncludeIdentifierType<Params extends TypeParameter[] = TypeParameter[], T extends TConstraint<Params> = TConstraint<Params>> extends BaseType {
11
12
  kind: NodeKind["IncludeIdentifierType"];
@@ -1,7 +1,7 @@
1
1
  import { getNestedDeclarations, getReferencesForDecl, resolveTypeArgumentsInDecl, validateDecl, } from "../../declarations/Declaration.js";
2
2
  import { NodeKind } from "../../Node.js";
3
3
  import { formatEnumType } from "../generic/EnumType.js";
4
- import { formatValue, removeParentKey, resolveTypeArgumentsInType, serializeType, } from "../Type.js";
4
+ import { formatValue, removeParentKey, resolveTypeArgumentsInType, serializeType } from "../Type.js";
5
5
  export const GenIncludeIdentifierType = (reference, args) => ({
6
6
  kind: NodeKind.IncludeIdentifierType,
7
7
  reference,
@@ -1,11 +1,12 @@
1
- import { Lazy } from "../../../utils/lazy.js";
2
- import { GetNestedDeclarations } from "../../declarations/Declaration.js";
3
- import { EntityDecl } from "../../declarations/EntityDecl.js";
4
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
5
- import { Validator } from "../../validation/type.js";
6
- import { MemberDecl, ObjectType, SerializedMemberDecl, SerializedObjectType } from "../generic/ObjectType.js";
7
- import { BaseType, SerializedBaseType, SerializedType, StructureFormatter, Type } from "../Type.js";
8
- type TConstraint = Record<string, MemberDecl<Type, boolean>>;
1
+ import { Lazy } from "../../../../shared/utils/lazy.js";
2
+ import type { GetNestedDeclarations } from "../../declarations/Declaration.js";
3
+ import type { EntityDecl } from "../../declarations/EntityDecl.js";
4
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
5
+ import { NodeKind } from "../../Node.js";
6
+ import type { Validator } from "../../validation/type.js";
7
+ import type { MemberDecl, ObjectType, SerializedMemberDecl, SerializedObjectType } from "../generic/ObjectType.js";
8
+ import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
9
+ type TConstraint = Record<string, MemberDecl>;
9
10
  export interface NestedEntityMapType<Name extends string = string, T extends TConstraint = TConstraint> extends BaseType {
10
11
  kind: NodeKind["NestedEntityMapType"];
11
12
  name: Name;
@@ -13,7 +14,7 @@ export interface NestedEntityMapType<Name extends string = string, T extends TCo
13
14
  secondaryEntity: EntityDecl;
14
15
  type: Lazy<ObjectType<T>>;
15
16
  }
16
- type TSerializedConstraint = Record<string, SerializedMemberDecl<SerializedType, boolean>>;
17
+ type TSerializedConstraint = Record<string, SerializedMemberDecl>;
17
18
  export interface SerializedNestedEntityMapType<Name extends string = string, T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseType {
18
19
  kind: NodeKind["NestedEntityMapType"];
19
20
  name: Name;
@@ -1,10 +1,10 @@
1
- import { sortObjectKeysAlphabetically } from "../../../shared/utils/object.js";
2
- import { parallelizeErrors } from "../../../shared/utils/validation.js";
1
+ import { Lazy } from "../../../../shared/utils/lazy.js";
2
+ import { sortObjectKeysAlphabetically } from "../../../../shared/utils/object.js";
3
+ import { parallelizeErrors } from "../../../../shared/utils/validation.js";
3
4
  import { wrapErrorsIfAny } from "../../../utils/error.js";
4
- import { Lazy } from "../../../utils/lazy.js";
5
5
  import { NodeKind } from "../../Node.js";
6
6
  import { getNestedDeclarationsInObjectType, getReferencesForObjectType, resolveTypeArgumentsInObjectType, serializeObjectType, validateObjectType, } from "../generic/ObjectType.js";
7
- import { removeParentKey, } from "../Type.js";
7
+ import { removeParentKey } from "../Type.js";
8
8
  export const NestedEntityMapType = (options) => {
9
9
  const nestedEntityMapType = {
10
10
  ...options,
@@ -1,8 +1,9 @@
1
- import { GetNestedDeclarations } from "../../declarations/Declaration.js";
2
- import { EntityDecl } from "../../declarations/EntityDecl.js";
3
- import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
4
- import { Validator } from "../../validation/type.js";
5
- import { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
1
+ import type { GetNestedDeclarations } from "../../declarations/Declaration.js";
2
+ import type { EntityDecl } from "../../declarations/EntityDecl.js";
3
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
4
+ import { NodeKind } from "../../Node.js";
5
+ import type { Validator } from "../../validation/type.js";
6
+ import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
6
7
  export interface ReferenceIdentifierType extends BaseType {
7
8
  kind: NodeKind["ReferenceIdentifierType"];
8
9
  entity: EntityDecl;
@@ -16,7 +17,7 @@ export { ReferenceIdentifierType as ReferenceIdentifier };
16
17
  export declare const isReferenceIdentifierType: (node: Node) => node is ReferenceIdentifierType;
17
18
  export declare const getNestedDeclarationsInReferenceIdentifierType: GetNestedDeclarations<ReferenceIdentifierType>;
18
19
  export declare const validateReferenceIdentifierType: Validator<ReferenceIdentifierType>;
19
- export declare const resolveTypeArgumentsInReferenceIdentifierType: <Args extends Record<string, Type>>(_args: Args, type: ReferenceIdentifierType) => ReferenceIdentifierType;
20
+ export declare const resolveTypeArgumentsInReferenceIdentifierType: (_args: Record<string, Type>, type: ReferenceIdentifierType) => ReferenceIdentifierType;
20
21
  export declare const serializeReferenceIdentifierType: Serializer<ReferenceIdentifierType, SerializedReferenceIdentifierType>;
21
22
  export declare const getReferencesForReferenceIdentifierType: GetReferences<ReferenceIdentifierType>;
22
23
  export declare const formatReferenceIdentifierValue: StructureFormatter<ReferenceIdentifierType>;
@@ -1,7 +1,7 @@
1
1
  import { getNestedDeclarations } from "../../declarations/Declaration.js";
2
2
  import { createEntityIdentifierType } from "../../declarations/EntityDecl.js";
3
3
  import { NodeKind } from "../../Node.js";
4
- import { removeParentKey, validate, } from "../Type.js";
4
+ import { removeParentKey, validate } from "../Type.js";
5
5
  export const ReferenceIdentifierType = (entity) => ({
6
6
  kind: NodeKind.ReferenceIdentifierType,
7
7
  entity,
@@ -0,0 +1,23 @@
1
+ import type { GetReferences, Node, Serializer } from "../../Node.js";
2
+ import { NodeKind } from "../../Node.js";
3
+ import type { SerializedTypeParameter, TypeParameter } from "../../TypeParameter.js";
4
+ import type { Validator } from "../../validation/type.js";
5
+ import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
6
+ type TConstraint = TypeParameter;
7
+ export interface TypeArgumentType<T extends TConstraint = TConstraint> extends BaseType {
8
+ kind: NodeKind["TypeArgumentType"];
9
+ argument: T;
10
+ }
11
+ type TSerializedConstraint = SerializedTypeParameter;
12
+ export interface SerializedTypeArgumentType<T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseType {
13
+ kind: NodeKind["TypeArgumentType"];
14
+ argument: T;
15
+ }
16
+ export declare const TypeArgumentType: <T extends TConstraint>(argument: T) => TypeArgumentType<T>;
17
+ export { TypeArgumentType as TypeArgument };
18
+ export declare const isTypeArgumentType: (node: Node) => node is TypeArgumentType;
19
+ export declare const validateTypeArgumentType: Validator<TypeArgumentType>;
20
+ export declare const resolveTypeArgumentsInTypeArgumentType: <T extends TConstraint, Args extends Record<string, Type>>(args: Args, type: TypeArgumentType<T>) => Args[T["name"]];
21
+ export declare const serializeTypeArgumentType: Serializer<TypeArgumentType, SerializedTypeArgumentType>;
22
+ export declare const getReferencesForTypeArgumentType: GetReferences<TypeArgumentType>;
23
+ export declare const formatTypeArgumentValue: StructureFormatter<TypeArgumentType>;
@@ -0,0 +1,19 @@
1
+ import { NodeKind } from "../../Node.js";
2
+ import { serializeTypeParameter } from "../../TypeParameter.js";
3
+ import { removeParentKey } from "../Type.js";
4
+ export const TypeArgumentType = (argument) => ({
5
+ kind: NodeKind.TypeArgumentType,
6
+ argument,
7
+ });
8
+ export { TypeArgumentType as TypeArgument };
9
+ export const isTypeArgumentType = (node) => node.kind === NodeKind.TypeArgumentType;
10
+ export const validateTypeArgumentType = (_helpers, type, _value) => {
11
+ throw new TypeError(`generic argument "${type.argument.name}" has not been replaced with a concrete type`);
12
+ };
13
+ export const resolveTypeArgumentsInTypeArgumentType = (args, type) => args[type.argument.name];
14
+ export const serializeTypeArgumentType = type => ({
15
+ ...removeParentKey(type),
16
+ argument: serializeTypeParameter(type.argument),
17
+ });
18
+ export const getReferencesForTypeArgumentType = (_type, _value) => [];
19
+ export const formatTypeArgumentValue = (_type, value) => value;
@@ -0,0 +1,4 @@
1
+ import type { Validators } from "../Node.js";
2
+ import type { Type } from "../types/Type.js";
3
+ export type ValidatorHelpers = Validators;
4
+ export type Validator<T extends Type, Args extends unknown[] = []> = (helpers: ValidatorHelpers, type: T, value: unknown, ...args: Args) => Error[];