tsondb 0.5.18 → 0.6.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 (222) hide show
  1. package/dist/src/bin/tsondb.js +1 -1
  2. package/dist/src/index.d.ts +1 -1
  3. package/dist/src/node/config.d.ts +20 -0
  4. package/dist/src/node/config.js +5 -0
  5. package/dist/src/node/index.d.ts +3 -2
  6. package/dist/src/node/index.js +13 -8
  7. package/dist/src/node/renderers/jsonschema/render.d.ts +1 -1
  8. package/dist/src/node/renderers/jsonschema/render.js +12 -7
  9. package/dist/src/node/renderers/ts/render.d.ts +1 -1
  10. package/dist/src/node/renderers/ts/render.js +12 -6
  11. package/dist/src/node/schema/Node.d.ts +100 -29
  12. package/dist/src/node/schema/Node.js +268 -61
  13. package/dist/src/node/schema/Schema.js +96 -1
  14. package/dist/src/node/schema/TypeParameter.d.ts +7 -9
  15. package/dist/src/node/schema/TypeParameter.js +7 -5
  16. package/dist/src/node/schema/declarations/Declaration.d.ts +10 -28
  17. package/dist/src/node/schema/declarations/Declaration.js +8 -110
  18. package/dist/src/node/schema/declarations/EntityDecl.d.ts +48 -48
  19. package/dist/src/node/schema/declarations/EntityDecl.js +15 -12
  20. package/dist/src/node/schema/declarations/EnumDecl.d.ts +14 -17
  21. package/dist/src/node/schema/declarations/EnumDecl.js +12 -12
  22. package/dist/src/node/schema/declarations/TypeAliasDecl.d.ts +8 -14
  23. package/dist/src/node/schema/declarations/TypeAliasDecl.js +10 -11
  24. package/dist/src/node/schema/index.d.ts +0 -2
  25. package/dist/src/node/schema/index.js +0 -1
  26. package/dist/src/node/schema/types/Type.d.ts +19 -42
  27. package/dist/src/node/schema/types/Type.js +29 -167
  28. package/dist/src/node/schema/types/generic/ArrayType.d.ts +5 -14
  29. package/dist/src/node/schema/types/generic/ArrayType.js +15 -20
  30. package/dist/src/node/schema/types/generic/EnumType.d.ts +5 -17
  31. package/dist/src/node/schema/types/generic/EnumType.js +12 -20
  32. package/dist/src/node/schema/types/generic/ObjectType.d.ts +5 -19
  33. package/dist/src/node/schema/types/generic/ObjectType.js +11 -15
  34. package/dist/src/node/schema/types/primitives/BooleanType.d.ts +7 -8
  35. package/dist/src/node/schema/types/primitives/BooleanType.js +5 -4
  36. package/dist/src/node/schema/types/primitives/DateType.d.ts +6 -8
  37. package/dist/src/node/schema/types/primitives/DateType.js +5 -4
  38. package/dist/src/node/schema/types/primitives/FloatType.d.ts +9 -21
  39. package/dist/src/node/schema/types/primitives/FloatType.js +5 -4
  40. package/dist/src/node/schema/types/primitives/IntegerType.d.ts +9 -21
  41. package/dist/src/node/schema/types/primitives/IntegerType.js +5 -4
  42. package/dist/src/node/schema/types/primitives/StringType.d.ts +6 -10
  43. package/dist/src/node/schema/types/primitives/StringType.js +5 -4
  44. package/dist/src/node/schema/types/references/ChildEntitiesType.d.ts +18 -0
  45. package/dist/src/node/schema/types/references/ChildEntitiesType.js +18 -0
  46. package/dist/src/node/schema/types/references/IncludeIdentifierType.d.ts +7 -13
  47. package/dist/src/node/schema/types/references/IncludeIdentifierType.js +12 -12
  48. package/dist/src/node/schema/types/references/NestedEntityMapType.d.ts +7 -17
  49. package/dist/src/node/schema/types/references/NestedEntityMapType.js +11 -13
  50. package/dist/src/node/schema/types/references/ReferenceIdentifierType.d.ts +4 -10
  51. package/dist/src/node/schema/types/references/ReferenceIdentifierType.js +3 -5
  52. package/dist/src/node/schema/types/references/TypeArgumentType.d.ts +5 -10
  53. package/dist/src/node/schema/types/references/TypeArgumentType.js +10 -5
  54. package/dist/src/node/server/api/declarations.js +24 -6
  55. package/dist/src/node/server/api/index.js +11 -0
  56. package/dist/src/node/server/api/instances.js +9 -6
  57. package/dist/src/node/server/index.d.ts +6 -1
  58. package/dist/src/node/server/index.js +7 -3
  59. package/dist/src/node/server/init.d.ts +2 -1
  60. package/dist/src/node/server/init.js +11 -11
  61. package/dist/src/node/server/utils/childInstances.d.ts +4 -0
  62. package/dist/src/node/server/utils/childInstances.js +41 -0
  63. package/dist/src/node/server/utils/instanceOperations.d.ts +8 -0
  64. package/dist/src/node/server/utils/instanceOperations.js +107 -0
  65. package/dist/src/node/server/utils/locales.d.ts +2 -0
  66. package/dist/src/node/server/utils/locales.js +8 -0
  67. package/dist/src/node/utils/childInstances.d.ts +32 -0
  68. package/dist/src/node/utils/childInstances.js +164 -0
  69. package/dist/src/node/utils/displayName.d.ts +2 -1
  70. package/dist/src/node/utils/displayName.js +5 -4
  71. package/dist/src/node/utils/files.d.ts +5 -0
  72. package/dist/src/node/utils/files.js +9 -0
  73. package/dist/src/node/utils/instanceOperations.d.ts +14 -0
  74. package/dist/src/node/utils/instanceOperations.js +88 -0
  75. package/dist/src/node/utils/instances.d.ts +1 -1
  76. package/dist/src/node/utils/instances.js +12 -6
  77. package/dist/src/node/utils/references.d.ts +3 -1
  78. package/dist/src/node/utils/references.js +43 -18
  79. package/dist/src/node/utils/referencesWorker.d.ts +5 -0
  80. package/dist/src/node/utils/referencesWorker.js +22 -0
  81. package/dist/src/node/utils/workers.d.ts +15 -0
  82. package/dist/src/node/utils/workers.js +90 -0
  83. package/dist/src/shared/api.d.ts +14 -1
  84. package/dist/src/shared/schema/Node.d.ts +63 -0
  85. package/dist/src/shared/schema/Node.js +128 -0
  86. package/dist/src/shared/schema/TypeParameter.d.ts +9 -0
  87. package/dist/src/shared/schema/TypeParameter.js +2 -0
  88. package/dist/src/shared/schema/declarations/Declaration.d.ts +21 -0
  89. package/dist/src/shared/schema/declarations/Declaration.js +4 -0
  90. package/dist/src/shared/schema/declarations/EntityDecl.d.ts +32 -0
  91. package/dist/src/shared/schema/declarations/EntityDecl.js +8 -0
  92. package/dist/src/shared/schema/declarations/EnumDecl.d.ts +11 -0
  93. package/dist/src/shared/schema/declarations/EnumDecl.js +9 -0
  94. package/dist/src/shared/schema/declarations/TypeAliasDecl.d.ts +11 -0
  95. package/dist/src/shared/schema/declarations/TypeAliasDecl.js +7 -0
  96. package/dist/src/shared/schema/types/ArrayType.d.ts +11 -0
  97. package/dist/src/shared/schema/types/ArrayType.js +8 -0
  98. package/dist/src/shared/schema/types/BooleanType.d.ts +7 -0
  99. package/dist/src/shared/schema/types/BooleanType.js +2 -0
  100. package/dist/src/shared/schema/types/ChildEntitiesType.d.ts +8 -0
  101. package/dist/src/shared/schema/types/ChildEntitiesType.js +2 -0
  102. package/dist/src/shared/schema/types/DateType.d.ts +8 -0
  103. package/dist/src/shared/schema/types/DateType.js +2 -0
  104. package/dist/src/shared/schema/types/EnumType.d.ts +14 -0
  105. package/dist/src/shared/schema/types/EnumType.js +28 -0
  106. package/dist/src/shared/schema/types/FloatType.d.ts +11 -0
  107. package/dist/src/shared/schema/types/FloatType.js +2 -0
  108. package/dist/src/shared/schema/types/IncludeIdentifierType.d.ts +11 -0
  109. package/dist/src/shared/schema/types/IncludeIdentifierType.js +13 -0
  110. package/dist/src/shared/schema/types/IntegerType.d.ts +11 -0
  111. package/dist/src/shared/schema/types/IntegerType.js +2 -0
  112. package/dist/src/shared/schema/types/NestedEntityMapType.d.ts +17 -0
  113. package/dist/src/shared/schema/types/NestedEntityMapType.js +14 -0
  114. package/dist/src/shared/schema/types/ObjectType.d.ts +19 -0
  115. package/dist/src/shared/schema/types/ObjectType.js +14 -0
  116. package/dist/src/shared/schema/types/ReferenceIdentifierType.d.ts +8 -0
  117. package/dist/src/shared/schema/types/ReferenceIdentifierType.js +2 -0
  118. package/dist/src/shared/schema/types/StringType.d.ts +10 -0
  119. package/dist/src/shared/schema/types/StringType.js +2 -0
  120. package/dist/src/shared/schema/types/Type.d.ts +20 -0
  121. package/dist/src/shared/schema/types/TypeArgumentType.d.ts +12 -0
  122. package/dist/src/shared/schema/types/TypeArgumentType.js +7 -0
  123. package/dist/src/shared/utils/array.d.ts +4 -0
  124. package/dist/src/shared/utils/array.js +30 -0
  125. package/dist/src/shared/utils/async.d.ts +8 -0
  126. package/dist/src/shared/utils/async.js +35 -0
  127. package/dist/src/shared/utils/compare.js +3 -3
  128. package/dist/src/shared/utils/displayName.d.ts +6 -2
  129. package/dist/src/shared/utils/displayName.js +21 -8
  130. package/dist/src/shared/utils/instances.d.ts +2 -3
  131. package/dist/src/shared/utils/instances.js +3 -1
  132. package/dist/src/shared/utils/markdown.d.ts +4 -0
  133. package/dist/src/shared/utils/markdown.js +173 -110
  134. package/dist/src/shared/utils/object.d.ts +2 -0
  135. package/dist/src/shared/utils/object.js +2 -0
  136. package/dist/src/shared/utils/result.d.ts +8 -2
  137. package/dist/src/shared/utils/result.js +1 -1
  138. package/dist/src/web/api/declarations.d.ts +26 -0
  139. package/dist/src/web/api/declarations.js +51 -0
  140. package/dist/src/web/api/git.d.ts +14 -0
  141. package/dist/src/web/api/git.js +20 -0
  142. package/dist/src/web/api/index.d.ts +1 -0
  143. package/dist/src/web/api/index.js +2 -0
  144. package/dist/src/web/api/instances.d.ts +2 -0
  145. package/dist/src/web/api/instances.js +2 -0
  146. package/dist/src/web/components/Git.js +19 -16
  147. package/dist/src/web/components/InstanceRouteSkeleton.d.ts +42 -0
  148. package/dist/src/web/components/InstanceRouteSkeleton.js +114 -0
  149. package/dist/src/web/components/Layout.js +3 -2
  150. package/dist/src/web/components/ModalDialog.d.ts +3 -0
  151. package/dist/src/web/components/ModalDialog.js +16 -0
  152. package/dist/src/web/components/Settings.d.ts +2 -0
  153. package/dist/src/web/components/Settings.js +47 -0
  154. package/dist/src/web/components/typeInputs/ArrayTypeInput.d.ts +3 -11
  155. package/dist/src/web/components/typeInputs/ArrayTypeInput.js +5 -4
  156. package/dist/src/web/components/typeInputs/BooleanTypeInput.d.ts +3 -6
  157. package/dist/src/web/components/typeInputs/BooleanTypeInput.js +2 -2
  158. package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.d.ts +6 -0
  159. package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.js +27 -0
  160. package/dist/src/web/components/typeInputs/DateTypeInput.d.ts +3 -6
  161. package/dist/src/web/components/typeInputs/DateTypeInput.js +2 -2
  162. package/dist/src/web/components/typeInputs/EnumTypeInput.d.ts +3 -11
  163. package/dist/src/web/components/typeInputs/EnumTypeInput.js +55 -22
  164. package/dist/src/web/components/typeInputs/FloatTypeInput.d.ts +3 -6
  165. package/dist/src/web/components/typeInputs/FloatTypeInput.js +2 -2
  166. package/dist/src/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +3 -4
  167. package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +3 -11
  168. package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.js +3 -2
  169. package/dist/src/web/components/typeInputs/IntegerTypeInput.d.ts +3 -6
  170. package/dist/src/web/components/typeInputs/IntegerTypeInput.js +2 -2
  171. package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +3 -11
  172. package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.js +5 -4
  173. package/dist/src/web/components/typeInputs/ObjectTypeInput.d.ts +3 -11
  174. package/dist/src/web/components/typeInputs/ObjectTypeInput.js +8 -5
  175. package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -8
  176. package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.js +2 -2
  177. package/dist/src/web/components/typeInputs/StringTypeInput.d.ts +3 -6
  178. package/dist/src/web/components/typeInputs/StringTypeInput.js +3 -3
  179. package/dist/src/web/components/typeInputs/TypeInput.d.ts +12 -4
  180. package/dist/src/web/components/typeInputs/TypeInput.js +22 -17
  181. package/dist/src/web/components/typeInputs/utils/ValidationErrors.d.ts +1 -0
  182. package/dist/src/web/components/typeInputs/utils/ValidationErrors.js +1 -3
  183. package/dist/src/web/context/config.d.ts +11 -0
  184. package/dist/src/web/context/config.js +6 -0
  185. package/dist/src/web/context/entities.d.ts +8 -5
  186. package/dist/src/web/context/entities.js +1 -1
  187. package/dist/src/web/context/settings.d.ts +8 -0
  188. package/dist/src/web/context/settings.js +10 -0
  189. package/dist/src/web/hooks/useEntityFromRoute.d.ts +1 -1
  190. package/dist/src/web/hooks/useEntityFromRoute.js +2 -2
  191. package/dist/src/web/hooks/useInstanceNamesByEntity.d.ts +1 -1
  192. package/dist/src/web/hooks/useInstanceNamesByEntity.js +4 -2
  193. package/dist/src/web/hooks/useMappedAPIResource.js +2 -4
  194. package/dist/src/web/hooks/useSecondaryDeclarations.d.ts +1 -1
  195. package/dist/src/web/hooks/useSecondaryDeclarations.js +8 -4
  196. package/dist/src/web/hooks/useSettings.d.ts +10 -0
  197. package/dist/src/web/hooks/useSettings.js +51 -0
  198. package/dist/src/web/index.js +11 -5
  199. package/dist/src/web/routes/CreateInstance.js +40 -79
  200. package/dist/src/web/routes/Entity.js +42 -19
  201. package/dist/src/web/routes/Home.js +24 -5
  202. package/dist/src/web/routes/Instance.js +34 -85
  203. package/dist/src/web/utils/InlineMarkdown.d.ts +1 -1
  204. package/dist/src/web/utils/InlineMarkdown.js +13 -1
  205. package/dist/src/web/utils/api.d.ts +25 -0
  206. package/dist/src/web/utils/api.js +34 -0
  207. package/dist/src/web/utils/typeSkeleton.d.ts +1 -1
  208. package/dist/src/web/utils/typeSkeleton.js +2 -0
  209. package/package.json +2 -1
  210. package/public/css/styles.css +171 -12
  211. package/dist/src/node/schema/types/primitives/NumericType.d.ts +0 -6
  212. package/dist/src/node/schema/types/primitives/NumericType.js +0 -2
  213. package/dist/src/node/schema/types/primitives/PrimitiveType.d.ts +0 -6
  214. package/dist/src/node/schema/validation/type.d.ts +0 -4
  215. package/dist/src/node/schema/validation/type.js +0 -1
  216. package/dist/src/node/server/api/instanceOperations.d.ts +0 -6
  217. package/dist/src/node/server/api/instanceOperations.js +0 -93
  218. package/dist/src/shared/config.d.ts +0 -11
  219. package/dist/src/shared/config.js +0 -1
  220. package/dist/src/web/api.d.ts +0 -24
  221. package/dist/src/web/api.js +0 -201
  222. /package/dist/src/{node/schema/types/primitives/PrimitiveType.js → shared/schema/types/Type.js} +0 -0
@@ -1,18 +1,16 @@
1
1
  import type { DateConstraints } from "../../../../shared/validation/date.ts";
2
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
2
+ import type { GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, Validator } from "../../Node.ts";
3
3
  import { NodeKind } from "../../Node.ts";
4
- import type { Validator } from "../../validation/type.ts";
5
- import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.ts";
4
+ import type { BaseType, StructureFormatter } from "../Type.ts";
6
5
  export interface DateType extends BaseType, DateConstraints {
7
6
  kind: NodeKind["DateType"];
8
7
  }
9
- export interface SerializedDateType extends SerializedBaseType, DateConstraints {
10
- kind: NodeKind["DateType"];
11
- }
12
8
  export declare const DateType: (options?: DateConstraints) => DateType;
13
9
  export { DateType as Date };
14
- export declare const isDateType: (node: Node) => node is DateType;
10
+ export declare const isDateType: Predicate<DateType>;
11
+ export declare const getNestedDeclarationsInDateType: GetNestedDeclarations<DateType>;
15
12
  export declare const validateDateType: Validator<DateType>;
16
- export declare const serializeDateType: Serializer<DateType, SerializedDateType>;
13
+ export declare const resolveTypeArgumentsInDateType: TypeArgumentsResolver<DateType>;
14
+ export declare const serializeDateType: Serializer<DateType>;
17
15
  export declare const getReferencesForDateType: GetReferences<DateType>;
18
16
  export declare const formatDateValue: StructureFormatter<DateType>;
@@ -1,19 +1,20 @@
1
1
  import { validateDateConstraints } from "../../../../shared/validation/date.js";
2
2
  import { json } from "../../../utils/errorFormatting.js";
3
3
  import { NodeKind } from "../../Node.js";
4
- import { removeParentKey } from "../Type.js";
5
4
  export const DateType = (options) => ({
6
5
  ...options,
7
6
  kind: NodeKind.DateType,
8
7
  });
9
8
  export { DateType as Date };
10
- export const isDateType = (node) => node.kind === NodeKind.DateType;
9
+ export const isDateType = node => node.kind === NodeKind.DateType;
10
+ export const getNestedDeclarationsInDateType = addedDecls => addedDecls;
11
11
  export const validateDateType = (helpers, type, value) => {
12
12
  if (typeof value !== "string") {
13
13
  return [TypeError(`expected a string, but got ${json(value, helpers.useStyling)}`)];
14
14
  }
15
15
  return validateDateConstraints(type, value);
16
16
  };
17
- export const serializeDateType = type => removeParentKey(type);
18
- export const getReferencesForDateType = (_type, _value) => [];
17
+ export const resolveTypeArgumentsInDateType = (_args, type) => type;
18
+ export const serializeDateType = type => type;
19
+ export const getReferencesForDateType = () => [];
19
20
  export const formatDateValue = (_type, value) => value;
@@ -1,28 +1,16 @@
1
- import type { RangeBound } from "../../../../shared/validation/number.ts";
2
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
1
+ import type { NumberConstraints } from "../../../../shared/validation/number.ts";
2
+ import type { GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, Validator } from "../../Node.ts";
3
3
  import { NodeKind } from "../../Node.ts";
4
- import type { Validator } from "../../validation/type.ts";
5
- import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.ts";
6
- export interface FloatType extends BaseType {
4
+ import type { BaseType, StructureFormatter } from "../Type.ts";
5
+ export interface FloatType extends BaseType, NumberConstraints {
7
6
  kind: NodeKind["FloatType"];
8
- minimum?: RangeBound;
9
- maximum?: RangeBound;
10
- multipleOf?: number;
11
7
  }
12
- export interface SerializedFloatType extends SerializedBaseType {
13
- kind: NodeKind["FloatType"];
14
- minimum?: RangeBound;
15
- maximum?: RangeBound;
16
- multipleOf?: number;
17
- }
18
- export declare const FloatType: (options?: {
19
- minimum?: RangeBound;
20
- maximum?: RangeBound;
21
- multipleOf?: number;
22
- }) => FloatType;
8
+ export declare const FloatType: (options?: NumberConstraints) => FloatType;
23
9
  export { FloatType as Float };
24
- export declare const isFloatType: (node: Node) => node is FloatType;
10
+ export declare const isFloatType: Predicate<FloatType>;
11
+ export declare const getNestedDeclarationsInFloatType: GetNestedDeclarations<FloatType>;
25
12
  export declare const validateFloatType: Validator<FloatType>;
26
- export declare const serializeFloatType: Serializer<FloatType, SerializedFloatType>;
13
+ export declare const resolveTypeArgumentsInFloatType: TypeArgumentsResolver<FloatType>;
14
+ export declare const serializeFloatType: Serializer<FloatType>;
27
15
  export declare const getReferencesForFloatType: GetReferences<FloatType>;
28
16
  export declare const formatFloatValue: StructureFormatter<FloatType>;
@@ -1,13 +1,13 @@
1
1
  import { validateNumberConstraints } from "../../../../shared/validation/number.js";
2
2
  import { json } from "../../../utils/errorFormatting.js";
3
3
  import { NodeKind } from "../../Node.js";
4
- import { removeParentKey } from "../Type.js";
5
4
  export const FloatType = (options = {}) => ({
6
5
  ...options,
7
6
  kind: NodeKind.FloatType,
8
7
  });
9
8
  export { FloatType as Float };
10
- export const isFloatType = (node) => node.kind === NodeKind.FloatType;
9
+ export const isFloatType = node => node.kind === NodeKind.FloatType;
10
+ export const getNestedDeclarationsInFloatType = addedDecls => addedDecls;
11
11
  export const validateFloatType = (helpers, type, value) => {
12
12
  if (typeof value !== "number") {
13
13
  return [
@@ -16,6 +16,7 @@ export const validateFloatType = (helpers, type, value) => {
16
16
  }
17
17
  return validateNumberConstraints(type, value);
18
18
  };
19
- export const serializeFloatType = type => removeParentKey(type);
20
- export const getReferencesForFloatType = (_type, _value) => [];
19
+ export const resolveTypeArgumentsInFloatType = (_args, type) => type;
20
+ export const serializeFloatType = type => type;
21
+ export const getReferencesForFloatType = () => [];
21
22
  export const formatFloatValue = (_type, value) => value;
@@ -1,28 +1,16 @@
1
- import type { RangeBound } from "../../../../shared/validation/number.ts";
2
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
1
+ import type { NumberConstraints } from "../../../../shared/validation/number.ts";
2
+ import type { GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, Validator } from "../../Node.ts";
3
3
  import { NodeKind } from "../../Node.ts";
4
- import type { Validator } from "../../validation/type.ts";
5
- import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.ts";
6
- export interface IntegerType extends BaseType {
4
+ import type { BaseType, StructureFormatter } from "../Type.ts";
5
+ export interface IntegerType extends BaseType, NumberConstraints {
7
6
  kind: NodeKind["IntegerType"];
8
- minimum?: RangeBound;
9
- maximum?: RangeBound;
10
- multipleOf?: number;
11
7
  }
12
- export interface SerializedIntegerType extends SerializedBaseType {
13
- kind: NodeKind["IntegerType"];
14
- minimum?: RangeBound;
15
- maximum?: RangeBound;
16
- multipleOf?: number;
17
- }
18
- export declare const IntegerType: (options?: {
19
- minimum?: RangeBound;
20
- maximum?: RangeBound;
21
- multipleOf?: number;
22
- }) => IntegerType;
8
+ export declare const IntegerType: (options?: NumberConstraints) => IntegerType;
23
9
  export { IntegerType as Integer };
24
- export declare const isIntegerType: (node: Node) => node is IntegerType;
10
+ export declare const isIntegerType: Predicate<IntegerType>;
11
+ export declare const getNestedDeclarationsInIntegerType: GetNestedDeclarations<IntegerType>;
25
12
  export declare const validateIntegerType: Validator<IntegerType>;
26
- export declare const serializeIntegerType: Serializer<IntegerType, SerializedIntegerType>;
13
+ export declare const resolveTypeArgumentsInIntegerType: TypeArgumentsResolver<IntegerType>;
14
+ export declare const serializeIntegerType: Serializer<IntegerType>;
27
15
  export declare const getReferencesForIntegerType: GetReferences<IntegerType>;
28
16
  export declare const formatIntegerValue: StructureFormatter<IntegerType>;
@@ -2,7 +2,6 @@ import { validateNumberConstraints } from "../../../../shared/validation/number.
2
2
  import { json } from "../../../utils/errorFormatting.js";
3
3
  import { NodeKind } from "../../Node.js";
4
4
  import { validateOption } from "../../validation/options.js";
5
- import { removeParentKey } from "../Type.js";
6
5
  const isIntegerRangeBoundOption = (option) => Number.isInteger(typeof option === "number" ? option : option.value);
7
6
  export const IntegerType = (options = {}) => ({
8
7
  kind: NodeKind.IntegerType,
@@ -11,13 +10,15 @@ export const IntegerType = (options = {}) => ({
11
10
  multipleOf: options.multipleOf,
12
11
  });
13
12
  export { IntegerType as Integer };
14
- export const isIntegerType = (node) => node.kind === NodeKind.IntegerType;
13
+ export const isIntegerType = node => node.kind === NodeKind.IntegerType;
14
+ export const getNestedDeclarationsInIntegerType = addedDecls => addedDecls;
15
15
  export const validateIntegerType = (helpers, type, value) => {
16
16
  if (typeof value !== "number" || !Number.isInteger(value)) {
17
17
  return [TypeError(`expected an integer, but got ${json(value, helpers.useStyling)}`)];
18
18
  }
19
19
  return validateNumberConstraints(type, value);
20
20
  };
21
- export const serializeIntegerType = type => removeParentKey(type);
22
- export const getReferencesForIntegerType = (_type, _value) => [];
21
+ export const resolveTypeArgumentsInIntegerType = (_args, type) => type;
22
+ export const serializeIntegerType = type => type;
23
+ export const getReferencesForIntegerType = () => [];
23
24
  export const formatIntegerValue = (_type, value) => value;
@@ -1,18 +1,12 @@
1
1
  import type { StringConstraints } from "../../../../shared/validation/string.ts";
2
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
2
+ import type { GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, Validator } from "../../Node.ts";
3
3
  import { NodeKind } from "../../Node.ts";
4
- import type { Validator } from "../../validation/type.ts";
5
- import type { BaseType, SerializedBaseType, StructureFormatter } from "../Type.ts";
4
+ import type { BaseType, StructureFormatter } from "../Type.ts";
6
5
  export interface StringType extends BaseType, StringConstraints {
7
6
  kind: NodeKind["StringType"];
8
7
  pattern?: RegExp;
9
8
  isMarkdown?: boolean;
10
9
  }
11
- export interface SerializedStringType extends SerializedBaseType, StringConstraints {
12
- kind: NodeKind["StringType"];
13
- pattern?: string;
14
- isMarkdown?: boolean;
15
- }
16
10
  export declare const StringType: (options?: {
17
11
  minLength?: number;
18
12
  maxLength?: number;
@@ -20,8 +14,10 @@ export declare const StringType: (options?: {
20
14
  isMarkdown?: boolean;
21
15
  }) => StringType;
22
16
  export { StringType as String };
23
- export declare const isStringType: (node: Node) => node is StringType;
17
+ export declare const isStringType: Predicate<StringType>;
18
+ export declare const getNestedDeclarationsInStringType: GetNestedDeclarations<StringType>;
24
19
  export declare const validateStringType: Validator<StringType>;
25
- export declare const serializeStringType: Serializer<StringType, SerializedStringType>;
20
+ export declare const resolveTypeArgumentsInStringType: TypeArgumentsResolver<StringType>;
21
+ export declare const serializeStringType: Serializer<StringType>;
26
22
  export declare const getReferencesForStringType: GetReferences<StringType>;
27
23
  export declare const formatStringValue: StructureFormatter<StringType>;
@@ -1,22 +1,23 @@
1
1
  import { validateStringConstraints } from "../../../../shared/validation/string.js";
2
2
  import { json } from "../../../utils/errorFormatting.js";
3
3
  import { NodeKind } from "../../Node.js";
4
- import { removeParentKey } from "../Type.js";
5
4
  export const StringType = (options = {}) => ({
6
5
  ...options,
7
6
  kind: NodeKind.StringType,
8
7
  });
9
8
  export { StringType as String };
10
- export const isStringType = (node) => node.kind === NodeKind.StringType;
9
+ export const isStringType = node => node.kind === NodeKind.StringType;
10
+ export const getNestedDeclarationsInStringType = addedDecls => addedDecls;
11
11
  export const validateStringType = (helpers, type, value) => {
12
12
  if (typeof value !== "string") {
13
13
  return [TypeError(`expected a string, but got ${json(value, helpers.useStyling)}`)];
14
14
  }
15
15
  return validateStringConstraints(type, value);
16
16
  };
17
- export const serializeStringType = type => removeParentKey({
17
+ export const resolveTypeArgumentsInStringType = (_args, type) => type;
18
+ export const serializeStringType = type => ({
18
19
  ...type,
19
20
  pattern: type.pattern?.source,
20
21
  });
21
- export const getReferencesForStringType = (_type, _value) => [];
22
+ export const getReferencesForStringType = () => [];
22
23
  export const formatStringValue = (_type, value) => value;
@@ -0,0 +1,18 @@
1
+ import { type EntityDecl } from "../../declarations/EntityDecl.ts";
2
+ import { type GetNestedDeclarations, type GetReferences, type Predicate, type Serializer, type TypeArgumentsResolver, type Validator } from "../../Node.js";
3
+ import { NodeKind } from "../../Node.ts";
4
+ import type { MemberDecl } from "../generic/ObjectType.ts";
5
+ import type { BaseType, StructureFormatter } from "../Type.ts";
6
+ export interface ChildEntitiesType<T extends EntityDecl<string, Record<string, MemberDecl>, string> = EntityDecl<string, Record<string, MemberDecl>, string>> extends BaseType {
7
+ kind: NodeKind["ChildEntitiesType"];
8
+ entity: T;
9
+ }
10
+ export declare const ChildEntitiesType: <T extends EntityDecl<string, Record<string, MemberDecl>, string>>(entity: T) => ChildEntitiesType<T>;
11
+ export { ChildEntitiesType as ChildEntities };
12
+ export declare const isChildEntitiesType: Predicate<ChildEntitiesType>;
13
+ export declare const getNestedDeclarationsInChildEntitiesType: GetNestedDeclarations<ChildEntitiesType>;
14
+ export declare const validateChildEntitiesType: Validator<ChildEntitiesType>;
15
+ export declare const resolveTypeArgumentsInChildEntitiesType: TypeArgumentsResolver<ChildEntitiesType>;
16
+ export declare const serializeChildEntitiesType: Serializer<ChildEntitiesType>;
17
+ export declare const getReferencesForChildEntitiesType: GetReferences<ChildEntitiesType>;
18
+ export declare const formatChildEntitiesValue: StructureFormatter<ChildEntitiesType>;
@@ -0,0 +1,18 @@
1
+ import {} from "../../declarations/EntityDecl.js";
2
+ import {} from "../../Node.js";
3
+ import { getNestedDeclarations, NodeKind } from "../../Node.js";
4
+ export const ChildEntitiesType = (entity) => ({
5
+ kind: NodeKind.ChildEntitiesType,
6
+ entity,
7
+ });
8
+ export { ChildEntitiesType as ChildEntities };
9
+ export const isChildEntitiesType = node => node.kind === NodeKind.ChildEntitiesType;
10
+ export const getNestedDeclarationsInChildEntitiesType = (addedDecls, type) => getNestedDeclarations([type.entity, ...addedDecls], type.entity);
11
+ export const validateChildEntitiesType = () => [];
12
+ export const resolveTypeArgumentsInChildEntitiesType = (_args, type) => type;
13
+ export const serializeChildEntitiesType = type => ({
14
+ ...type,
15
+ entity: type.entity.name,
16
+ });
17
+ export const getReferencesForChildEntitiesType = (_type, value) => (Array.isArray(value) && value.every(id => typeof id === "string") ? value : []);
18
+ export const formatChildEntitiesValue = (_type, value) => Array.isArray(value) ? value.toSorted() : value;
@@ -1,32 +1,26 @@
1
- import type { GetNestedDeclarations, IncludableDeclP, SerializedTypeArguments, TypeArguments } from "../../declarations/Declaration.ts";
1
+ import type { SerializedIncludeIdentifierType } from "../../../../shared/schema/types/IncludeIdentifierType.ts";
2
+ import type { IncludableDeclP, TypeArguments } from "../../declarations/Declaration.ts";
2
3
  import type { EnumDecl } from "../../declarations/EnumDecl.ts";
3
4
  import type { TypeAliasDecl } from "../../declarations/TypeAliasDecl.ts";
4
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
5
+ import type { GetNestedDeclarations, GetReferences, Predicate, SerializedTypeParameters, Validator } from "../../Node.ts";
5
6
  import { NodeKind } from "../../Node.ts";
6
- import type { SerializedTypeParameter, TypeParameter } from "../../TypeParameter.ts";
7
- import type { Validator } from "../../validation/type.ts";
7
+ import type { TypeParameter } from "../../TypeParameter.ts";
8
8
  import type { EnumCaseDecl } from "../generic/EnumType.ts";
9
- import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.ts";
9
+ import type { BaseType, StructureFormatter, Type } from "../Type.ts";
10
10
  type TConstraint<Params extends TypeParameter[]> = TypeAliasDecl<string, Type, Params> | EnumDecl<string, Record<string, EnumCaseDecl>, Params>;
11
11
  export interface IncludeIdentifierType<Params extends TypeParameter[] = TypeParameter[], T extends TConstraint<Params> = TConstraint<Params>> extends BaseType {
12
12
  kind: NodeKind["IncludeIdentifierType"];
13
13
  reference: T;
14
14
  args: TypeArguments<Params>;
15
15
  }
16
- export interface SerializedIncludeIdentifierType<Params extends SerializedTypeParameter[] = SerializedTypeParameter[]> extends SerializedBaseType {
17
- kind: NodeKind["IncludeIdentifierType"];
18
- reference: string;
19
- args: SerializedTypeArguments<Params>;
20
- }
21
16
  export declare const GenIncludeIdentifierType: <T extends TConstraint<Params>, Params extends TypeParameter[] = []>(reference: T, args: TypeArguments<Params>) => IncludeIdentifierType<Params, T>;
22
17
  export { GenIncludeIdentifierType as GenIncludeIdentifier };
23
18
  export declare const IncludeIdentifierType: <T extends TConstraint<[]>>(reference: T) => IncludeIdentifierType<[], T>;
24
19
  export { IncludeIdentifierType as IncludeIdentifier };
25
- export declare const isIncludeIdentifierType: (node: Node) => node is IncludeIdentifierType;
26
- export declare const isNoGenericIncludeIdentifierType: (node: IncludeIdentifierType) => node is IncludeIdentifierType<[], IncludableDeclP<[]>>;
20
+ export declare const isIncludeIdentifierType: Predicate<IncludeIdentifierType>;
27
21
  export declare const getNestedDeclarationsInIncludeIdentifierType: GetNestedDeclarations<IncludeIdentifierType>;
28
22
  export declare const validateIncludeIdentifierType: Validator<IncludeIdentifierType>;
29
23
  export declare const resolveTypeArgumentsInIncludeIdentifierType: <T extends IncludeIdentifierType>(args: Record<string, Type>, type: T) => T extends IncludeIdentifierType<[], IncludableDeclP<[]>> ? T : Type;
30
- export declare const serializeIncludeIdentifierType: Serializer<IncludeIdentifierType, SerializedIncludeIdentifierType>;
24
+ export declare const serializeIncludeIdentifierType: <Params extends TypeParameter[] = TypeParameter<string, Type>[], T extends TConstraint<Params> = TConstraint<Params>>(type: IncludeIdentifierType<Params, T>) => SerializedIncludeIdentifierType<SerializedTypeParameters<Params>>;
31
25
  export declare const getReferencesForIncludeIdentifierType: GetReferences<IncludeIdentifierType>;
32
26
  export declare const formatIncludeIdentifierValue: StructureFormatter<IncludeIdentifierType>;
@@ -1,7 +1,7 @@
1
- import { getNestedDeclarations, getReferencesForDecl, resolveTypeArgumentsInDecl, validateDecl, } from "../../declarations/Declaration.js";
2
- import { NodeKind } from "../../Node.js";
1
+ import { getTypeArgumentsRecord } from "../../declarations/Declaration.js";
2
+ import { getNestedDeclarations, getReferences, NodeKind, resolveTypeArguments, serializeNode, validateDecl, } from "../../Node.js";
3
3
  import { formatEnumType } from "../generic/EnumType.js";
4
- import { formatValue, removeParentKey, resolveTypeArgumentsInType, serializeType } from "../Type.js";
4
+ import { formatValue } from "../Type.js";
5
5
  export const GenIncludeIdentifierType = (reference, args) => ({
6
6
  kind: NodeKind.IncludeIdentifierType,
7
7
  reference,
@@ -14,21 +14,21 @@ export const IncludeIdentifierType = (reference) => ({
14
14
  args: [],
15
15
  });
16
16
  export { IncludeIdentifierType as IncludeIdentifier };
17
- export const isIncludeIdentifierType = (node) => node.kind === NodeKind.IncludeIdentifierType;
18
- export const isNoGenericIncludeIdentifierType = (node) => node.args.length === 0 && node.reference.parameters.length === 0;
17
+ export const isIncludeIdentifierType = node => node.kind === NodeKind.IncludeIdentifierType;
18
+ const isNoGenericIncludeIdentifierType = (node) => node.args.length === 0 && node.reference.parameters.length === 0;
19
19
  export const getNestedDeclarationsInIncludeIdentifierType = (addedDecls, type) => type.args.reduce((accAddedDecls, arg) => getNestedDeclarations(accAddedDecls, arg), addedDecls.includes(type.reference)
20
20
  ? addedDecls
21
21
  : getNestedDeclarations([type.reference, ...addedDecls], type.reference));
22
22
  export const validateIncludeIdentifierType = (helpers, type, value) => validateDecl(helpers, type.reference, type.args, value);
23
- export const resolveTypeArgumentsInIncludeIdentifierType = (args, type) => (isNoGenericIncludeIdentifierType(type)
23
+ export const resolveTypeArgumentsInIncludeIdentifierType = ((args, type) => (isNoGenericIncludeIdentifierType(type)
24
24
  ? type
25
- : resolveTypeArgumentsInDecl(type.reference, type.args.map(arg => resolveTypeArgumentsInType(args, arg))).type.value);
26
- export const serializeIncludeIdentifierType = type => ({
27
- ...removeParentKey(type),
25
+ : resolveTypeArguments(getTypeArgumentsRecord(type.reference, type.args.map(arg => resolveTypeArguments(args, arg))), type.reference).type.value));
26
+ export const serializeIncludeIdentifierType = ((type) => ({
27
+ ...type,
28
28
  reference: type.reference.name,
29
- args: type.args.map(arg => serializeType(arg)),
30
- });
31
- export const getReferencesForIncludeIdentifierType = (type, value) => getReferencesForDecl(resolveTypeArgumentsInDecl(type.reference, type.args), value);
29
+ args: type.args.map(arg => serializeNode(arg)),
30
+ }));
31
+ export const getReferencesForIncludeIdentifierType = (type, value) => getReferences(resolveTypeArguments(getTypeArgumentsRecord(type.reference, type.args), type.reference), value);
32
32
  export const formatIncludeIdentifierValue = (type, value) => {
33
33
  switch (type.reference.kind) {
34
34
  case NodeKind.TypeAliasDecl:
@@ -1,13 +1,11 @@
1
1
  import { Lazy } from "../../../../shared/utils/lazy.ts";
2
- import { type GetNestedDeclarations } from "../../declarations/Declaration.ts";
3
2
  import type { EntityDecl } from "../../declarations/EntityDecl.ts";
4
3
  import type { TypeAliasDecl } from "../../declarations/TypeAliasDecl.ts";
5
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
4
+ import type { GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, Validator } from "../../Node.ts";
6
5
  import { NodeKind } from "../../Node.ts";
7
- import type { Validator } from "../../validation/type.ts";
8
- import type { MemberDecl, ObjectType, SerializedMemberDecl, SerializedObjectType } from "../generic/ObjectType.ts";
9
- import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.ts";
10
- import { type IncludeIdentifier, type SerializedIncludeIdentifierType } from "./IncludeIdentifierType.ts";
6
+ import type { MemberDecl, ObjectType } from "../generic/ObjectType.ts";
7
+ import type { BaseType, StructureFormatter } from "../Type.ts";
8
+ import { type IncludeIdentifier } from "./IncludeIdentifierType.ts";
11
9
  type TConstraint = Record<string, MemberDecl>;
12
10
  type PossibleType<T extends TConstraint> = ObjectType<T> | IncludeIdentifier<[], TypeAliasDecl<string, ObjectType<T>, []>>;
13
11
  export interface NestedEntityMapType<Name extends string = string, T extends TConstraint = TConstraint> extends BaseType {
@@ -17,14 +15,6 @@ export interface NestedEntityMapType<Name extends string = string, T extends TCo
17
15
  secondaryEntity: EntityDecl;
18
16
  type: Lazy<PossibleType<T>>;
19
17
  }
20
- type TSerializedConstraint = Record<string, SerializedMemberDecl>;
21
- export interface SerializedNestedEntityMapType<Name extends string = string, T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseType {
22
- kind: NodeKind["NestedEntityMapType"];
23
- name: Name;
24
- comment?: string;
25
- secondaryEntity: string;
26
- type: SerializedObjectType<T> | SerializedIncludeIdentifierType;
27
- }
28
18
  export declare const NestedEntityMapType: <Name extends string, T extends TConstraint>(options: {
29
19
  name: Name;
30
20
  comment?: string;
@@ -32,10 +22,10 @@ export declare const NestedEntityMapType: <Name extends string, T extends TConst
32
22
  type: PossibleType<T>;
33
23
  }) => NestedEntityMapType<Name, T>;
34
24
  export { NestedEntityMapType as NestedEntityMap };
35
- export declare const isNestedEntityMapType: (node: Node) => node is NestedEntityMapType;
25
+ export declare const isNestedEntityMapType: Predicate<NestedEntityMapType>;
36
26
  export declare const getNestedDeclarationsInNestedEntityMapType: GetNestedDeclarations<NestedEntityMapType>;
37
27
  export declare const validateNestedEntityMapType: Validator<NestedEntityMapType>;
38
- export declare const resolveTypeArgumentsInNestedEntityMapType: (args: Record<string, Type>, type: NestedEntityMapType) => NestedEntityMapType;
39
- export declare const serializeNestedEntityMapType: Serializer<NestedEntityMapType, SerializedNestedEntityMapType>;
28
+ export declare const resolveTypeArgumentsInNestedEntityMapType: TypeArgumentsResolver<NestedEntityMapType>;
29
+ export declare const serializeNestedEntityMapType: Serializer<NestedEntityMapType>;
40
30
  export declare const getReferencesForNestedEntityMapType: GetReferences<NestedEntityMapType>;
41
31
  export declare const formatNestedEntityMapValue: StructureFormatter<NestedEntityMapType>;
@@ -3,16 +3,16 @@ import { sortObjectKeysAlphabetically } from "../../../../shared/utils/object.js
3
3
  import { parallelizeErrors } from "../../../../shared/utils/validation.js";
4
4
  import { wrapErrorsIfAny } from "../../../utils/error.js";
5
5
  import { entity, json, key as keyColor } from "../../../utils/errorFormatting.js";
6
- import { getNestedDeclarations, } from "../../declarations/Declaration.js";
7
- import { NodeKind } from "../../Node.js";
8
- import { getReferencesForObjectType, isObjectType, resolveTypeArgumentsInObjectType, serializeObjectType, } from "../generic/ObjectType.js";
9
- import { formatValue, removeParentKey, setParent, validate } from "../Type.js";
10
- import { formatIncludeIdentifierValue, getReferencesForIncludeIdentifierType, resolveTypeArgumentsInIncludeIdentifierType, serializeIncludeIdentifierType, } from "./IncludeIdentifierType.js";
6
+ import {} from "../../declarations/Declaration.js";
7
+ import { getNestedDeclarations, NodeKind, resolveTypeArguments, validateType } from "../../Node.js";
8
+ import { getReferencesForObjectType, isObjectType, serializeObjectType, } from "../generic/ObjectType.js";
9
+ import { formatValue } from "../Type.js";
10
+ import { formatIncludeIdentifierValue, getReferencesForIncludeIdentifierType, serializeIncludeIdentifierType, } from "./IncludeIdentifierType.js";
11
11
  export const NestedEntityMapType = (options) => {
12
12
  const nestedEntityMapType = {
13
13
  ...options,
14
14
  kind: NodeKind.NestedEntityMapType,
15
- type: Lazy.of(() => setParent(options.type, nestedEntityMapType)),
15
+ type: Lazy.of(() => options.type),
16
16
  };
17
17
  return nestedEntityMapType;
18
18
  };
@@ -21,29 +21,27 @@ const _NestedEntityMapType = (options) => {
21
21
  const nestedEntityMapType = {
22
22
  ...options,
23
23
  kind: NodeKind.NestedEntityMapType,
24
- type: Lazy.of(() => setParent(options.type(), nestedEntityMapType)),
24
+ type: Lazy.of(() => options.type()),
25
25
  };
26
26
  return nestedEntityMapType;
27
27
  };
28
- export const isNestedEntityMapType = (node) => node.kind === NodeKind.NestedEntityMapType;
28
+ export const isNestedEntityMapType = node => node.kind === NodeKind.NestedEntityMapType;
29
29
  export const getNestedDeclarationsInNestedEntityMapType = (addedDecls, type) => getNestedDeclarations(addedDecls.includes(type.secondaryEntity) ? addedDecls : [type.secondaryEntity, ...addedDecls], type.type.value);
30
30
  export const validateNestedEntityMapType = (helpers, type, value) => {
31
31
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
32
32
  return [TypeError(`expected an object, but got ${json(value, helpers.useStyling)}`)];
33
33
  }
34
- return parallelizeErrors(Object.keys(value).map(key => wrapErrorsIfAny(`at nested entity map ${entity(`"${type.name}"`, helpers.useStyling)} at key ${keyColor(`"${key}"`, helpers.useStyling)}`, validate(helpers, type.type.value, value[key]).concat(helpers.checkReferentialIntegrity({
34
+ return parallelizeErrors(Object.keys(value).map(key => wrapErrorsIfAny(`at nested entity map ${entity(`"${type.name}"`, helpers.useStyling)} at key ${keyColor(`"${key}"`, helpers.useStyling)}`, validateType(helpers, type.type.value, value[key]).concat(helpers.checkReferentialIntegrity({
35
35
  name: type.secondaryEntity.name,
36
36
  value: key,
37
37
  })))));
38
38
  };
39
39
  export const resolveTypeArgumentsInNestedEntityMapType = (args, type) => _NestedEntityMapType({
40
40
  ...type,
41
- type: () => isObjectType(type.type.value)
42
- ? resolveTypeArgumentsInObjectType(args, type.type.value)
43
- : resolveTypeArgumentsInIncludeIdentifierType(args, type.type.value),
41
+ type: () => resolveTypeArguments(args, type.type.value),
44
42
  });
45
43
  export const serializeNestedEntityMapType = type => ({
46
- ...removeParentKey(type),
44
+ ...type,
47
45
  secondaryEntity: type.secondaryEntity.name,
48
46
  type: isObjectType(type.type.value)
49
47
  ? serializeObjectType(type.type.value)
@@ -1,23 +1,17 @@
1
- import type { GetNestedDeclarations } from "../../declarations/Declaration.ts";
2
1
  import type { EntityDecl } from "../../declarations/EntityDecl.ts";
3
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
2
+ import type { GetNestedDeclarations, GetReferences, Node, Serializer, TypeArgumentsResolver, Validator } from "../../Node.ts";
4
3
  import { NodeKind } from "../../Node.ts";
5
- import type { Validator } from "../../validation/type.ts";
6
- import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.ts";
4
+ import type { BaseType, StructureFormatter } from "../Type.ts";
7
5
  export interface ReferenceIdentifierType extends BaseType {
8
6
  kind: NodeKind["ReferenceIdentifierType"];
9
7
  entity: EntityDecl;
10
8
  }
11
- export interface SerializedReferenceIdentifierType extends SerializedBaseType {
12
- kind: NodeKind["ReferenceIdentifierType"];
13
- entity: string;
14
- }
15
9
  export declare const ReferenceIdentifierType: (entity: EntityDecl) => ReferenceIdentifierType;
16
10
  export { ReferenceIdentifierType as ReferenceIdentifier };
17
11
  export declare const isReferenceIdentifierType: (node: Node) => node is ReferenceIdentifierType;
18
12
  export declare const getNestedDeclarationsInReferenceIdentifierType: GetNestedDeclarations<ReferenceIdentifierType>;
19
13
  export declare const validateReferenceIdentifierType: Validator<ReferenceIdentifierType>;
20
- export declare const resolveTypeArgumentsInReferenceIdentifierType: (_args: Record<string, Type>, type: ReferenceIdentifierType) => ReferenceIdentifierType;
21
- export declare const serializeReferenceIdentifierType: Serializer<ReferenceIdentifierType, SerializedReferenceIdentifierType>;
14
+ export declare const resolveTypeArgumentsInReferenceIdentifierType: TypeArgumentsResolver<ReferenceIdentifierType>;
15
+ export declare const serializeReferenceIdentifierType: Serializer<ReferenceIdentifierType>;
22
16
  export declare const getReferencesForReferenceIdentifierType: GetReferences<ReferenceIdentifierType>;
23
17
  export declare const formatReferenceIdentifierValue: StructureFormatter<ReferenceIdentifierType>;
@@ -1,7 +1,5 @@
1
- import { getNestedDeclarations } from "../../declarations/Declaration.js";
2
1
  import { createEntityIdentifierType } from "../../declarations/EntityDecl.js";
3
- import { NodeKind } from "../../Node.js";
4
- import { removeParentKey, validate } from "../Type.js";
2
+ import { getNestedDeclarations, NodeKind, validateType } from "../../Node.js";
5
3
  export const ReferenceIdentifierType = (entity) => ({
6
4
  kind: NodeKind.ReferenceIdentifierType,
7
5
  entity,
@@ -11,13 +9,13 @@ export const isReferenceIdentifierType = (node) => node.kind === NodeKind.Refere
11
9
  export const getNestedDeclarationsInReferenceIdentifierType = (addedDecls, type) => addedDecls.includes(type.entity)
12
10
  ? addedDecls
13
11
  : getNestedDeclarations([...addedDecls, type.entity], type.entity);
14
- export const validateReferenceIdentifierType = (helpers, type, value) => validate(helpers, createEntityIdentifierType(), value).concat(helpers.checkReferentialIntegrity({
12
+ export const validateReferenceIdentifierType = (helpers, type, value) => validateType(helpers, createEntityIdentifierType(), value).concat(helpers.checkReferentialIntegrity({
15
13
  name: type.entity.name,
16
14
  value: value,
17
15
  }));
18
16
  export const resolveTypeArgumentsInReferenceIdentifierType = (_args, type) => type;
19
17
  export const serializeReferenceIdentifierType = type => ({
20
- ...removeParentKey(type),
18
+ ...type,
21
19
  entity: type.entity.name,
22
20
  });
23
21
  export const getReferencesForReferenceIdentifierType = (_type, value) => (typeof value === "string" ? [value] : []);
@@ -1,23 +1,18 @@
1
- import type { GetReferences, Node, Serializer } from "../../Node.ts";
1
+ import type { GetNestedDeclarations, GetReferences, Node, Serializer, Validator } from "../../Node.ts";
2
2
  import { NodeKind } from "../../Node.ts";
3
- import type { SerializedTypeParameter, TypeParameter } from "../../TypeParameter.ts";
4
- import type { Validator } from "../../validation/type.ts";
5
- import type { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.ts";
3
+ import type { TypeParameter } from "../../TypeParameter.ts";
4
+ import type { BaseType, StructureFormatter, Type } from "../Type.ts";
6
5
  type TConstraint = TypeParameter;
7
6
  export interface TypeArgumentType<T extends TConstraint = TConstraint> extends BaseType {
8
7
  kind: NodeKind["TypeArgumentType"];
9
8
  argument: T;
10
9
  }
11
- type TSerializedConstraint = SerializedTypeParameter;
12
- export interface SerializedTypeArgumentType<T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseType {
13
- kind: NodeKind["TypeArgumentType"];
14
- argument: T;
15
- }
16
10
  export declare const TypeArgumentType: <T extends TConstraint>(argument: T) => TypeArgumentType<T>;
17
11
  export { TypeArgumentType as TypeArgument };
18
12
  export declare const isTypeArgumentType: (node: Node) => node is TypeArgumentType;
13
+ export declare const getNestedDeclarationsInTypeArgumentType: GetNestedDeclarations<TypeArgumentType>;
19
14
  export declare const validateTypeArgumentType: Validator<TypeArgumentType>;
20
15
  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>;
16
+ export declare const serializeTypeArgumentType: Serializer<TypeArgumentType>;
22
17
  export declare const getReferencesForTypeArgumentType: GetReferences<TypeArgumentType>;
23
18
  export declare const formatTypeArgumentValue: StructureFormatter<TypeArgumentType>;
@@ -1,19 +1,24 @@
1
1
  import { NodeKind } from "../../Node.js";
2
2
  import { serializeTypeParameter } from "../../TypeParameter.js";
3
- import { removeParentKey } from "../Type.js";
4
3
  export const TypeArgumentType = (argument) => ({
5
4
  kind: NodeKind.TypeArgumentType,
6
5
  argument,
7
6
  });
8
7
  export { TypeArgumentType as TypeArgument };
9
8
  export const isTypeArgumentType = (node) => node.kind === NodeKind.TypeArgumentType;
10
- export const validateTypeArgumentType = (_helpers, type, _value) => {
9
+ export const getNestedDeclarationsInTypeArgumentType = addedDecls => addedDecls;
10
+ export const validateTypeArgumentType = (_helpers, type) => {
11
11
  throw new TypeError(`generic argument "${type.argument.name}" has not been replaced with a concrete type`);
12
12
  };
13
- export const resolveTypeArgumentsInTypeArgumentType = (args, type) => args[type.argument.name];
13
+ export const resolveTypeArgumentsInTypeArgumentType = ((args, type) => {
14
+ if (!(type.argument.name in args)) {
15
+ throw new TypeError(`no generic argument provided for "${type.argument.name}"`);
16
+ }
17
+ return args[type.argument.name];
18
+ });
14
19
  export const serializeTypeArgumentType = type => ({
15
- ...removeParentKey(type),
20
+ ...type,
16
21
  argument: serializeTypeParameter(type.argument),
17
22
  });
18
- export const getReferencesForTypeArgumentType = (_type, _value) => [];
23
+ export const getReferencesForTypeArgumentType = () => [];
19
24
  export const formatTypeArgumentValue = (_type, value) => value;