tsondb 0.3.0 → 0.5.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 (206) hide show
  1. package/LICENSE +385 -0
  2. package/README.md +173 -1
  3. package/lib/bin/tsondb.d.ts +10 -0
  4. package/lib/bin/tsondb.js +84 -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} +6 -5
  9. package/lib/node/index.d.ts +9 -0
  10. package/lib/node/index.js +75 -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 +9 -2
  14. package/lib/{renderers → node/renderers}/jsonschema/render.d.ts +1 -1
  15. package/lib/{renderers → node/renderers}/jsonschema/render.js +15 -10
  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 +13 -9
  20. package/lib/{schema → node/schema}/Node.d.ts +5 -5
  21. package/lib/{schema → node/schema}/Node.js +9 -8
  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 +13 -12
  27. package/lib/{schema → node/schema}/declarations/EntityDecl.js +4 -5
  28. package/lib/{schema → node/schema}/declarations/EnumDecl.d.ts +9 -7
  29. package/lib/{schema → node/schema}/declarations/EnumDecl.js +6 -13
  30. package/lib/{schema → node/schema}/declarations/TypeAliasDecl.d.ts +8 -7
  31. package/lib/{schema → node/schema}/declarations/TypeAliasDecl.js +6 -14
  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 +54 -0
  35. package/lib/{schema → node/schema}/types/Type.js +55 -29
  36. package/lib/{schema → node/schema}/types/generic/ArrayType.d.ts +5 -4
  37. package/lib/{schema → node/schema}/types/generic/ArrayType.js +5 -5
  38. package/lib/{schema → node/schema}/types/generic/EnumType.d.ts +5 -4
  39. package/lib/{schema → node/schema}/types/generic/EnumType.js +10 -4
  40. package/lib/{schema → node/schema}/types/generic/ObjectType.d.ts +8 -7
  41. package/lib/{schema → node/schema}/types/generic/ObjectType.js +14 -7
  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 +8 -16
  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 +7 -3
  63. package/lib/{server → node/server}/api/git.js +14 -11
  64. package/lib/{server → node/server}/api/instanceOperations.d.ts +3 -3
  65. package/lib/{server → node/server}/api/instanceOperations.js +18 -7
  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 +23 -13
  69. package/lib/node/server/init.d.ts +5 -0
  70. package/lib/{server → node/server}/init.js +9 -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 +4 -3
  74. package/lib/{utils → node/utils}/instances.js +10 -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 +9 -3
  79. package/lib/shared/utils/array.d.ts +1 -0
  80. package/lib/shared/utils/array.js +13 -9
  81. package/lib/shared/utils/displayName.d.ts +1 -1
  82. package/lib/shared/utils/displayName.js +7 -2
  83. package/lib/shared/utils/instances.d.ts +2 -2
  84. package/lib/{utils → shared/utils}/lazy.js +1 -1
  85. package/lib/shared/utils/markdown.js +6 -6
  86. package/lib/shared/utils/object.d.ts +3 -0
  87. package/lib/shared/utils/object.js +5 -1
  88. package/lib/{utils → shared/utils}/result.js +2 -2
  89. package/lib/shared/utils/string.js +7 -4
  90. package/lib/shared/utils/validation.js +3 -2
  91. package/lib/shared/validation/number.js +3 -3
  92. package/lib/shared/validation/object.js +4 -3
  93. package/lib/shared/validation/string.js +12 -7
  94. package/lib/{client → web}/api.d.ts +3 -3
  95. package/lib/{client → web}/api.js +5 -6
  96. package/lib/web/components/Git.d.ts +2 -0
  97. package/lib/{client → web}/components/Git.js +59 -15
  98. package/lib/{client → web}/components/Layout.d.ts +1 -1
  99. package/lib/{client → web}/components/Layout.js +1 -1
  100. package/lib/web/components/Select.d.ts +3 -0
  101. package/lib/web/components/Select.js +5 -0
  102. package/lib/web/components/typeInputs/ArrayTypeInput.d.ts +13 -0
  103. package/lib/{client → web}/components/typeInputs/ArrayTypeInput.js +7 -1
  104. package/lib/{client → web}/components/typeInputs/BooleanTypeInput.d.ts +2 -2
  105. package/lib/{client → web}/components/typeInputs/DateTypeInput.d.ts +2 -2
  106. package/lib/web/components/typeInputs/EnumTypeInput.d.ts +13 -0
  107. package/lib/{client → web}/components/typeInputs/EnumTypeInput.js +1 -1
  108. package/lib/{client → web}/components/typeInputs/FloatTypeInput.d.ts +2 -2
  109. package/lib/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +7 -0
  110. package/lib/{client → web}/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.js +1 -1
  111. package/lib/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +13 -0
  112. package/lib/{client → web}/components/typeInputs/IntegerTypeInput.d.ts +2 -2
  113. package/lib/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +13 -0
  114. package/lib/{client → web}/components/typeInputs/NestedEntityMapTypeInput.js +7 -2
  115. package/lib/{client → web}/components/typeInputs/ObjectTypeInput.d.ts +4 -4
  116. package/lib/{client → web}/components/typeInputs/ObjectTypeInput.js +4 -1
  117. package/lib/{client → web}/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -3
  118. package/lib/web/components/typeInputs/ReferenceIdentifierTypeInput.js +11 -0
  119. package/lib/{client → web}/components/typeInputs/StringTypeInput.d.ts +2 -2
  120. package/lib/web/components/typeInputs/TypeInput.d.ts +13 -0
  121. package/lib/{client → web}/components/typeInputs/TypeInput.js +3 -3
  122. package/lib/{client → web}/components/typeInputs/utils/Markdown.d.ts +1 -1
  123. package/lib/{client → web}/components/typeInputs/utils/Markdown.js +2 -2
  124. package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.d.ts +1 -1
  125. package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.d.ts +1 -1
  126. package/lib/web/hooks/useAPIResource.d.ts +1 -0
  127. package/lib/{client → web}/hooks/useAPIResource.js +2 -1
  128. package/lib/{client → web}/hooks/useEntityFromRoute.d.ts +1 -1
  129. package/lib/{client → web}/hooks/useEntityFromRoute.js +1 -1
  130. package/lib/{client → web}/hooks/useInstanceNamesByEntity.d.ts +1 -1
  131. package/lib/{client → web}/hooks/useInstanceNamesByEntity.js +8 -6
  132. package/lib/web/hooks/useMappedAPIResource.d.ts +1 -0
  133. package/lib/{client → web}/hooks/useMappedAPIResource.js +9 -9
  134. package/lib/{client → web}/hooks/useSecondaryDeclarations.d.ts +1 -1
  135. package/lib/{client → web}/hooks/useSecondaryDeclarations.js +4 -2
  136. package/lib/{client → web}/routes/CreateInstance.d.ts +1 -1
  137. package/lib/{client → web}/routes/CreateInstance.js +4 -2
  138. package/lib/web/routes/Entity.d.ts +2 -0
  139. package/lib/{client → web}/routes/Entity.js +8 -6
  140. package/lib/web/routes/Home.d.ts +2 -0
  141. package/lib/{client → web}/routes/Home.js +2 -1
  142. package/lib/{client → web}/routes/Instance.d.ts +1 -1
  143. package/lib/{client → web}/routes/Instance.js +14 -8
  144. package/lib/{client → web}/routes/NotFound.d.ts +1 -1
  145. package/lib/web/utils/typeSkeleton.d.ts +3 -0
  146. package/lib/{client → web}/utils/typeSkeleton.js +4 -1
  147. package/package.json +33 -19
  148. package/lib/ModelContainer.d.ts +0 -17
  149. package/lib/ModelContainer.js +0 -65
  150. package/lib/client/components/Git.d.ts +0 -2
  151. package/lib/client/components/Select.d.ts +0 -3
  152. package/lib/client/components/Select.js +0 -2
  153. package/lib/client/components/typeInputs/ArrayTypeInput.d.ts +0 -13
  154. package/lib/client/components/typeInputs/EnumTypeInput.d.ts +0 -13
  155. package/lib/client/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +0 -7
  156. package/lib/client/components/typeInputs/IncludeIdentifierTypeInput.d.ts +0 -13
  157. package/lib/client/components/typeInputs/NestedEntityMapTypeInput.d.ts +0 -13
  158. package/lib/client/components/typeInputs/ReferenceIdentifierTypeInput.js +0 -9
  159. package/lib/client/components/typeInputs/TypeInput.d.ts +0 -13
  160. package/lib/client/hooks/useAPIResource.d.ts +0 -1
  161. package/lib/client/hooks/useMappedAPIResource.d.ts +0 -1
  162. package/lib/client/routes/Entity.d.ts +0 -2
  163. package/lib/client/routes/Home.d.ts +0 -2
  164. package/lib/client/utils/typeSkeleton.d.ts +0 -3
  165. package/lib/schema/types/Type.d.ts +0 -48
  166. package/lib/schema/types/primitives/PrimitiveType.d.ts +0 -6
  167. package/lib/schema/types/references/GenericArgumentIdentifierType.d.ts +0 -22
  168. package/lib/schema/types/references/GenericArgumentIdentifierType.js +0 -19
  169. package/lib/schema/validation/type.d.ts +0 -4
  170. package/lib/server/index.d.ts +0 -29
  171. package/lib/server/init.d.ts +0 -5
  172. package/lib/tsconfig.tsbuildinfo +0 -1
  173. package/lib/utils/object.d.ts +0 -3
  174. package/lib/utils/object.js +0 -1
  175. /package/lib/{renderers → node/renderers}/Output.js +0 -0
  176. /package/lib/{schema → node/schema}/types/primitives/BooleanType.js +0 -0
  177. /package/lib/{schema → node/schema}/types/primitives/NumericType.js +0 -0
  178. /package/lib/{schema → node/schema}/types/primitives/PrimitiveType.js +0 -0
  179. /package/lib/{schema → node/schema}/validation/options.d.ts +0 -0
  180. /package/lib/{schema → node/schema}/validation/options.js +0 -0
  181. /package/lib/{schema → node/schema}/validation/type.js +0 -0
  182. /package/lib/{server → node/server}/api/declarations.d.ts +0 -0
  183. /package/lib/{server → node/server}/api/git.d.ts +0 -0
  184. /package/lib/{server → node/server}/api/index.d.ts +0 -0
  185. /package/lib/{server → node/server}/api/index.js +0 -0
  186. /package/lib/{server → node/server}/api/instances.d.ts +0 -0
  187. /package/lib/{utils → node/utils}/error.d.ts +0 -0
  188. /package/lib/{utils → node/utils}/git.js +0 -0
  189. /package/lib/{utils → node/utils}/path.d.ts +0 -0
  190. /package/lib/{utils → node/utils}/path.js +0 -0
  191. /package/lib/{utils → node/utils}/render.d.ts +0 -0
  192. /package/lib/{utils → shared/utils}/enum.d.ts +0 -0
  193. /package/lib/{utils → shared/utils}/enum.js +0 -0
  194. /package/lib/{utils → shared/utils}/lazy.d.ts +0 -0
  195. /package/lib/{utils → shared/utils}/result.d.ts +0 -0
  196. /package/lib/{client → web}/components/typeInputs/BooleanTypeInput.js +0 -0
  197. /package/lib/{client → web}/components/typeInputs/DateTypeInput.js +0 -0
  198. /package/lib/{client → web}/components/typeInputs/FloatTypeInput.js +0 -0
  199. /package/lib/{client → web}/components/typeInputs/IncludeIdentifierTypeInput.js +0 -0
  200. /package/lib/{client → web}/components/typeInputs/IntegerTypeInput.js +0 -0
  201. /package/lib/{client → web}/components/typeInputs/StringTypeInput.js +0 -0
  202. /package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.js +0 -0
  203. /package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.js +0 -0
  204. /package/lib/{client → web}/index.d.ts +0 -0
  205. /package/lib/{client → web}/index.js +0 -0
  206. /package/lib/{client → web}/routes/NotFound.js +0 -0
@@ -7,5 +7,11 @@ import { ValidationErrors } from "./utils/ValidationErrors.js";
7
7
  export const ArrayTypeInput = ({ type, value, instanceNamesByEntity, getDeclFromDeclName, onChange, }) => {
8
8
  const errors = validateArrayConstraints(type, value);
9
9
  const isTuple = typeof type.minItems === "number" && type.minItems === type.maxItems;
10
- return (_jsxs("div", { class: "field field--container field--array", children: [value.length > 0 && (_jsx("ol", { children: value.map((item, i) => (_jsxs("li", { class: "container-item array-item", children: [isTuple ? null : (_jsxs("div", { className: "container-item-header", children: [_jsxs("div", { className: "container-item-title", children: [i + 1, "."] }), _jsx("button", { class: "destructive", onClick: () => onChange(removeAt(value, i)), disabled: type.minItems !== undefined && value.length <= type.minItems, children: "Delete Item" })] })), _jsx(TypeInput, { type: type.items, value: item, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => onChange(value.with(i, newItem)) })] }, i))) })), isTuple ? null : (_jsx("div", { class: "add-item-container", children: _jsx("button", { onClick: () => onChange([...value, createTypeSkeleton(getDeclFromDeclName, type.items)]), disabled: type.maxItems !== undefined && value.length >= type.maxItems, children: "Add Item" }) })), _jsx(ValidationErrors, { errors: errors })] }));
10
+ return (_jsxs("div", { class: "field field--container field--array", children: [value.length > 0 && (_jsx("ol", { children: value.map((item, i) => (_jsxs("li", { class: "container-item array-item", children: [isTuple ? null : (_jsxs("div", { className: "container-item-header", children: [_jsxs("div", { className: "container-item-title", children: [i + 1, "."] }), _jsx("button", { class: "destructive", onClick: () => {
11
+ onChange(removeAt(value, i));
12
+ }, disabled: type.minItems !== undefined && value.length <= type.minItems, children: "Delete Item" })] })), _jsx(TypeInput, { type: type.items, value: item, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => {
13
+ onChange(value.with(i, newItem));
14
+ } })] }, i))) })), isTuple ? null : (_jsx("div", { class: "add-item-container", children: _jsx("button", { onClick: () => {
15
+ onChange([...value, createTypeSkeleton(getDeclFromDeclName, type.items)]);
16
+ }, disabled: type.maxItems !== undefined && value.length >= type.maxItems, children: "Add Item" }) })), _jsx(ValidationErrors, { errors: errors })] }));
11
17
  };
@@ -1,5 +1,5 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedBooleanType } from "../../../schema/types/primitives/BooleanType.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedBooleanType } from "../../../node/schema/types/primitives/BooleanType.js";
3
3
  type Props = {
4
4
  type: SerializedBooleanType;
5
5
  value: boolean;
@@ -1,5 +1,5 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedDateType } from "../../../schema/types/primitives/DateType.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedDateType } from "../../../node/schema/types/primitives/DateType.js";
3
3
  type Props = {
4
4
  type: SerializedDateType;
5
5
  value: string;
@@ -0,0 +1,13 @@
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedEnumType } from "../../../node/schema/types/generic/EnumType.js";
3
+ import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
+ import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
5
+ type Props = {
6
+ type: SerializedEnumType;
7
+ value: unknown;
8
+ instanceNamesByEntity: InstanceNamesByEntity;
9
+ getDeclFromDeclName: GetDeclFromDeclName;
10
+ onChange: (value: unknown) => void;
11
+ };
12
+ export declare const EnumTypeInput: FunctionComponent<Props>;
13
+ export {};
@@ -29,7 +29,7 @@ export const EnumTypeInput = ({ type, value, instanceNamesByEntity, getDeclFromD
29
29
  [event.currentTarget.value]: createTypeSkeleton(getDeclFromDeclName, caseMember.type),
30
30
  });
31
31
  }
32
- }, children: enumValues.map(enumValue => (_jsx("option", { value: enumValue, selected: enumValue === activeEnumCase, children: toTitleCase(enumValue) }))) }), caseMember?.type == null ? null : (_jsx("div", { className: "associated-type", children: _jsx(TypeInput, { type: caseMember.type, value: value[activeEnumCase], instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newValue => {
32
+ }, children: enumValues.map(enumValue => (_jsx("option", { value: enumValue, selected: enumValue === activeEnumCase, children: toTitleCase(enumValue) }, enumValue))) }), caseMember?.type == null ? null : (_jsx("div", { className: "associated-type", children: _jsx(TypeInput, { type: caseMember.type, value: value[activeEnumCase], instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newValue => {
33
33
  onChange({
34
34
  [discriminatorKey]: activeEnumCase,
35
35
  [activeEnumCase]: newValue,
@@ -1,5 +1,5 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedFloatType } from "../../../schema/types/primitives/FloatType.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedFloatType } from "../../../node/schema/types/primitives/FloatType.js";
3
3
  type Props = {
4
4
  type: SerializedFloatType;
5
5
  value: number;
@@ -0,0 +1,7 @@
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedTypeArgumentType } from "../../../node/schema/types/references/TypeArgumentType.js";
3
+ type Props = {
4
+ type: SerializedTypeArgumentType;
5
+ };
6
+ export declare const TypeArgumentTypeInput: FunctionComponent<Props>;
7
+ export {};
@@ -1,4 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
- export const GenericArgumentIdentifierTypeInput = ({ type }) => {
2
+ export const TypeArgumentTypeInput = ({ type }) => {
3
3
  return (_jsxs("div", { role: "alert", children: ["Unresolved type argument ", _jsx("code", { children: type.argument.name })] }));
4
4
  };
@@ -0,0 +1,13 @@
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedIncludeIdentifierType } from "../../../node/schema/index.js";
3
+ import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
+ import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
5
+ type Props = {
6
+ type: SerializedIncludeIdentifierType;
7
+ value: unknown;
8
+ instanceNamesByEntity: InstanceNamesByEntity;
9
+ getDeclFromDeclName: GetDeclFromDeclName;
10
+ onChange: (value: unknown) => void;
11
+ };
12
+ export declare const IncludeIdentifierTypeInput: FunctionComponent<Props>;
13
+ export {};
@@ -1,5 +1,5 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedIntegerType } from "../../../schema/types/primitives/IntegerType.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedIntegerType } from "../../../node/schema/types/primitives/IntegerType.js";
3
3
  type Props = {
4
4
  type: SerializedIntegerType;
5
5
  value: number;
@@ -0,0 +1,13 @@
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedNestedEntityMapType } from "../../../node/schema/types/references/NestedEntityMapType.js";
3
+ import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
+ import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
5
+ type Props = {
6
+ type: SerializedNestedEntityMapType;
7
+ value: Record<string, unknown>;
8
+ instanceNamesByEntity: InstanceNamesByEntity;
9
+ getDeclFromDeclName: GetDeclFromDeclName;
10
+ onChange: (value: Record<string, unknown>) => void;
11
+ };
12
+ export declare const NestedEntityMapTypeInput: FunctionComponent<Props>;
13
+ export {};
@@ -11,11 +11,16 @@ export const NestedEntityMapTypeInput = ({ type, value, instanceNamesByEntity, g
11
11
  .slice()
12
12
  .filter(instance => !existingKeys.includes(instance.id))
13
13
  .sort((a, b) => a.name.localeCompare(b.name));
14
- return (_jsxs("div", { class: "field field--container field--nestedentitymap", children: [existingKeys.length > 0 && (_jsx("ul", { children: Object.entries(value).map(([key, item]) => (_jsxs("li", { class: "container-item dict-item", children: [_jsxs("div", { className: "container-item-header", children: [_jsx("div", { className: "container-item-title", children: _jsxs("span", { children: [_jsx("strong", { children: instanceNamesByEntity[type.secondaryEntity].find(instance => instance.id === key)?.name ?? key }), " ", _jsx("span", { className: "id", children: key })] }) }), _jsx("div", { className: "btns", children: _jsx("button", { class: "destructive", onClick: () => {
14
+ return (_jsxs("div", { class: "field field--container field--nestedentitymap", children: [existingKeys.length > 0 && (_jsx("ul", { children: Object.entries(value).map(([key, item]) => (_jsxs("li", { class: "container-item dict-item", children: [_jsxs("div", { className: "container-item-header", children: [_jsx("div", { className: "container-item-title", children: _jsxs("span", { children: [_jsx("strong", { children: instanceNamesByEntity[type.secondaryEntity]?.find(instance => instance.id === key)?.name ?? key }), " ", _jsx("span", { className: "id", children: key })] }) }), _jsx("div", { className: "btns", children: _jsx("button", { class: "destructive", onClick: () => {
15
15
  const newObj = { ...value };
16
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
16
17
  delete newObj[key];
17
18
  onChange(newObj);
18
- }, children: "Delete Key" }) })] }), _jsx(TypeInput, { type: type.type, value: item, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => onChange(sortObjectKeysAlphabetically({ ...value, [key]: newItem })) })] }, key))) })), _jsxs("div", { class: "add-item-container", children: [_jsxs(Select, { value: newKey, onInput: event => setNewKey(event.currentTarget.value), disabled: secondaryInstances.length === 0, children: [secondaryInstances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), secondaryInstances.map(instance => (_jsx("option", { value: instance.id, children: instance.name })))] }), _jsx("button", { onClick: () => {
19
+ }, children: "Delete Key" }) })] }), _jsx(TypeInput, { type: type.type, value: item, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => {
20
+ onChange(sortObjectKeysAlphabetically({ ...value, [key]: newItem }));
21
+ } })] }, key))) })), _jsxs("div", { class: "add-item-container", children: [_jsxs(Select, { value: newKey, onInput: event => {
22
+ setNewKey(event.currentTarget.value);
23
+ }, disabled: secondaryInstances.length === 0, children: [secondaryInstances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), secondaryInstances.map(instance => (_jsx("option", { value: instance.id, children: instance.name }, instance.id)))] }), _jsx("button", { onClick: () => {
19
24
  onChange(sortObjectKeysAlphabetically({
20
25
  ...value,
21
26
  [newKey]: createTypeSkeleton(getDeclFromDeclName, type.type),
@@ -1,7 +1,7 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedObjectType } from "../../../schema/types/generic/ObjectType.js";
3
- import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
- import { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedObjectType } from "../../../node/schema/types/generic/ObjectType.js";
3
+ import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
+ import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
5
5
  type Props = {
6
6
  type: SerializedObjectType;
7
7
  value: Record<string, unknown>;
@@ -14,7 +14,10 @@ export const ObjectTypeInput = ({ type, value, instanceNamesByEntity, getDeclFro
14
14
  }, Object.keys(type.properties)));
15
15
  }, children: "Add Property" })) : (_jsx("button", { class: "destructive", onClick: () => {
16
16
  const newObj = { ...value };
17
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
17
18
  delete newObj[key];
18
19
  onChange(newObj);
19
- }, children: "Remove Property" }))] }), memberDecl.isRequired || value[key] !== undefined ? (_jsx(TypeInput, { type: memberDecl.type, value: value[key], instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => onChange(sortObjectKeys({ ...value, [key]: newItem }, Object.keys(type.properties))) })) : null] }, key))) }), _jsx(ValidationErrors, { errors: errors })] }));
20
+ }, children: "Remove Property" }))] }), memberDecl.isRequired || value[key] !== undefined ? (_jsx(TypeInput, { type: memberDecl.type, value: value[key], instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => {
21
+ onChange(sortObjectKeys({ ...value, [key]: newItem }, Object.keys(type.properties)));
22
+ } })) : null] }, key))) }), _jsx(ValidationErrors, { errors: errors })] }));
20
23
  };
@@ -1,6 +1,6 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedReferenceIdentifierType } from "../../../schema/types/references/ReferenceIdentifierType.js";
3
- import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedReferenceIdentifierType } from "../../../node/schema/types/references/ReferenceIdentifierType.js";
3
+ import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
4
  type Props = {
5
5
  type: SerializedReferenceIdentifierType;
6
6
  value: string;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { Select } from "../Select.js";
3
+ import { ValidationErrors } from "./utils/ValidationErrors.js";
4
+ export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntity, onChange, }) => {
5
+ const instances = (instanceNamesByEntity[type.entity] ?? [])
6
+ .slice()
7
+ .sort((a, b) => a.name.localeCompare(b.name));
8
+ return (_jsxs("div", { class: "field", children: [_jsxs(Select, { value: value, onInput: event => {
9
+ onChange(event.currentTarget.value);
10
+ }, disabled: instances.length === 0, "aria-invalid": !value, children: [instances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), instances.map(instance => (_jsx("option", { value: instance.id, children: instance.name }, instance.id)))] }), _jsx(ValidationErrors, { errors: !value ? [ReferenceError("no reference provided")] : [] })] }));
11
+ };
@@ -1,5 +1,5 @@
1
- import { FunctionComponent } from "preact";
2
- import { SerializedStringType } from "../../../schema/types/primitives/StringType.js";
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedStringType } from "../../../node/schema/types/primitives/StringType.js";
3
3
  type Props = {
4
4
  type: SerializedStringType;
5
5
  value: string;
@@ -0,0 +1,13 @@
1
+ import type { FunctionComponent } from "preact";
2
+ import type { SerializedType } from "../../../node/schema/types/Type.js";
3
+ import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
4
+ import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
5
+ type Props = {
6
+ type: SerializedType;
7
+ value: unknown;
8
+ instanceNamesByEntity: InstanceNamesByEntity;
9
+ getDeclFromDeclName: GetDeclFromDeclName;
10
+ onChange: (value: unknown) => void;
11
+ };
12
+ export declare const TypeInput: FunctionComponent<Props>;
13
+ export {};
@@ -5,7 +5,7 @@ import { BooleanTypeInput } from "./BooleanTypeInput.js";
5
5
  import { DateTypeInput } from "./DateTypeInput.js";
6
6
  import { EnumTypeInput } from "./EnumTypeInput.js";
7
7
  import { FloatTypeInput } from "./FloatTypeInput.js";
8
- import { GenericArgumentIdentifierTypeInput } from "./GenericTypeArgumentIdentifierTypeInput.js";
8
+ import { TypeArgumentTypeInput } from "./GenericTypeArgumentIdentifierTypeInput.js";
9
9
  import { IncludeIdentifierTypeInput } from "./IncludeIdentifierTypeInput.js";
10
10
  import { IntegerTypeInput } from "./IntegerTypeInput.js";
11
11
  import { NestedEntityMapTypeInput } from "./NestedEntityMapTypeInput.js";
@@ -64,8 +64,8 @@ export const TypeInput = ({ type, value, instanceNamesByEntity, getDeclFromDeclN
64
64
  else {
65
65
  return _jsx(MismatchingTypeError, { expected: "object", actual: value });
66
66
  }
67
- case "GenericArgumentIdentifierType":
68
- return _jsx(GenericArgumentIdentifierTypeInput, { type: type });
67
+ case "TypeArgumentType":
68
+ return _jsx(TypeArgumentTypeInput, { type: type });
69
69
  case "ReferenceIdentifierType":
70
70
  if (typeof value === "string") {
71
71
  return (_jsx(ReferenceIdentifierTypeInput, { type: type, value: value, instanceNamesByEntity: instanceNamesByEntity, onChange: onChange }));
@@ -1,4 +1,4 @@
1
- import { FunctionalComponent } from "preact";
1
+ import type { FunctionalComponent } from "preact";
2
2
  type Props = {
3
3
  string: string;
4
4
  };
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
- import { parseBlockMarkdown, } from "../../../../shared/utils/markdown.js";
2
+ import { parseBlockMarkdown } from "../../../../shared/utils/markdown.js";
3
3
  export const Markdown = ({ string }) => {
4
4
  const blocks = parseBlockMarkdown(string);
5
- return blocks.map((block, i) => _jsx(BlockMarkdown, { node: block }, `md-block-${i}`));
5
+ return blocks.map((block, i) => _jsx(BlockMarkdown, { node: block }, `md-block-${i.toString()}`));
6
6
  };
7
7
  const BlockMarkdown = ({ node }) => {
8
8
  switch (node.kind) {
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from "preact";
1
+ import type { FunctionComponent } from "preact";
2
2
  type Props = {
3
3
  expected: string;
4
4
  actual: unknown;
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from "preact";
1
+ import type { FunctionComponent } from "preact";
2
2
  type Props = {
3
3
  errors: Error[];
4
4
  };
@@ -0,0 +1 @@
1
+ export declare const useAPIResource: <T, A extends unknown[]>(apiFn: (...args: A) => Promise<T>, ...args: A) => [T | undefined, () => Promise<void>];
@@ -1,2 +1,3 @@
1
1
  import { useMappedAPIResource } from "./useMappedAPIResource.js";
2
- export const useAPIResource = (apiFn, ...args) => useMappedAPIResource(apiFn, data => data, ...args);
2
+ const identity = (data) => data;
3
+ export const useAPIResource = (apiFn, ...args) => useMappedAPIResource(apiFn, identity, ...args);
@@ -1,4 +1,4 @@
1
- import { SerializedEntityDecl } from "../../schema/declarations/EntityDecl.js";
1
+ import type { SerializedEntityDecl } from "../../node/schema/declarations/EntityDecl.js";
2
2
  export declare const useEntityFromRoute: () => {
3
3
  entity: SerializedEntityDecl;
4
4
  isLocaleEntity: boolean;
@@ -10,7 +10,7 @@ export const useEntityFromRoute = () => {
10
10
  .then(data => {
11
11
  setEntityData(data);
12
12
  })
13
- .catch(error => {
13
+ .catch((error) => {
14
14
  console.error("Error fetching data:", error);
15
15
  });
16
16
  }
@@ -1,3 +1,3 @@
1
- import { GetAllInstancesResponseBody } from "../../shared/api.js";
1
+ import type { GetAllInstancesResponseBody } from "../../shared/api.js";
2
2
  export type InstanceNamesByEntity = GetAllInstancesResponseBody["instances"];
3
3
  export declare const useInstanceNamesByEntity: (locales?: string[]) => [InstanceNamesByEntity, () => void];
@@ -1,18 +1,20 @@
1
- import { useEffect, useState } from "preact/hooks";
1
+ import { useCallback, useEffect, useState } from "preact/hooks";
2
2
  import { getAllInstances } from "../api.js";
3
3
  export const useInstanceNamesByEntity = (locales = []) => {
4
4
  const [instanceNamesByEntity, setInstanceNamesByEntity] = useState({});
5
- const updateInstanceNamesByEntity = () => {
5
+ const updateInstanceNamesByEntity = useCallback(() => {
6
6
  getAllInstances(locales)
7
7
  .then(data => {
8
8
  setInstanceNamesByEntity(data.instances);
9
9
  })
10
- .catch(error => {
11
- console.error("Error fetching data:", error);
10
+ .catch((error) => {
11
+ if (error instanceof Error) {
12
+ console.error("Error fetching data:", error.toString());
13
+ }
12
14
  });
13
- };
15
+ }, [locales.toString()]);
14
16
  useEffect(() => {
15
17
  updateInstanceNamesByEntity();
16
- }, []);
18
+ }, [updateInstanceNamesByEntity]);
17
19
  return [instanceNamesByEntity, updateInstanceNamesByEntity];
18
20
  };
@@ -0,0 +1 @@
1
+ export declare const useMappedAPIResource: <T, A extends unknown[], U>(apiFn: (...args: A) => Promise<T>, mapFn: (data: T) => U, ...args: A) => [U | undefined, () => Promise<void>];
@@ -1,19 +1,19 @@
1
1
  import { useCallback, useEffect, useState } from "preact/hooks";
2
2
  export const useMappedAPIResource = (apiFn, mapFn, ...args) => {
3
3
  const [data, setData] = useState();
4
- const fetchData = () => apiFn(...args)
5
- .then(result => {
4
+ const fetchData = useCallback(() => apiFn(...args).then(result => {
6
5
  setData(mapFn(result));
7
- })
8
- .catch(err => {
9
- console.log(err);
10
- });
6
+ }),
7
+ // eslint-disable-next-line react-hooks/exhaustive-deps
8
+ [apiFn, mapFn, ...args]);
11
9
  useEffect(() => {
12
- fetchData();
13
- }, []);
10
+ fetchData().catch((err) => {
11
+ console.log(err);
12
+ });
13
+ }, [fetchData]);
14
14
  const reload = useCallback(() => {
15
15
  setData(undefined);
16
16
  return fetchData();
17
- }, [apiFn, ...args]);
17
+ }, [fetchData]);
18
18
  return [data, reload];
19
19
  };
@@ -1,3 +1,3 @@
1
- import { SerializedSecondaryDecl } from "../../schema/declarations/Declaration.js";
1
+ import type { SerializedSecondaryDecl } from "../../node/schema/declarations/Declaration.js";
2
2
  export type GetDeclFromDeclName = (name: string) => SerializedSecondaryDecl | undefined;
3
3
  export declare const useGetDeclFromDeclName: () => GetDeclFromDeclName;
@@ -9,8 +9,10 @@ export const useGetDeclFromDeclName = () => {
9
9
  .map(decl => decl.declaration)
10
10
  .filter((decl) => decl.kind === "EnumDecl" || decl.kind === "TypeAliasDecl"));
11
11
  })
12
- .catch(error => {
13
- console.error("Error fetching data:", error);
12
+ .catch((error) => {
13
+ if (error instanceof Error) {
14
+ console.error("Error fetching data:", error.toString());
15
+ }
14
16
  });
15
17
  }, []);
16
18
  const getDeclFromDeclName = useCallback((name) => secondaryDeclarations.find(decl => decl.name === name), [secondaryDeclarations]);
@@ -1,2 +1,2 @@
1
- import { FunctionalComponent } from "preact";
1
+ import type { FunctionalComponent } from "preact";
2
2
  export declare const CreateInstance: FunctionalComponent;
@@ -48,8 +48,10 @@ export const CreateInstance = () => {
48
48
  route(`/entities/${entity.name}?created=${encodeURIComponent(createdInstance.instance.id)}`);
49
49
  }
50
50
  })
51
- .catch(error => {
52
- alert(`Error updating instance:\n\n${error}`);
51
+ .catch((error) => {
52
+ if (error instanceof Error) {
53
+ alert(`Error creating instance:\n\n${error.toString()}`);
54
+ }
53
55
  });
54
56
  }
55
57
  };
@@ -0,0 +1,2 @@
1
+ import type { FunctionalComponent } from "preact";
2
+ export declare const Entity: FunctionalComponent;
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { useRoute } from "preact-iso";
3
3
  import { useEffect } from "preact/hooks";
4
- import { getDisplayNameFromEntityInstance } from "../../shared/utils/displayName.js";
5
4
  import { getGitStatusForDisplay, getLabelForGitStatus } from "../../shared/utils/git.js";
6
5
  import { deleteInstanceByEntityNameAndId, getEntityByName, getInstancesByEntityName, } from "../api.js";
7
6
  import { Layout } from "../components/Layout.js";
8
7
  import { useAPIResource } from "../hooks/useAPIResource.js";
9
8
  import { useMappedAPIResource } from "../hooks/useMappedAPIResource.js";
10
9
  import { NotFound } from "./NotFound.js";
10
+ const mapInstances = (data) => data.instances;
11
11
  export const Entity = () => {
12
12
  const { params: { name }, query: { created }, } = useRoute();
13
13
  const [entity] = useAPIResource(getEntityByName, name ?? "");
14
- const [instances, reloadInstances] = useMappedAPIResource(getInstancesByEntityName, data => data.instances, name ?? "");
14
+ const [instances, reloadInstances] = useMappedAPIResource(getInstancesByEntityName, mapInstances, name ?? "");
15
15
  useEffect(() => {
16
16
  if (created) {
17
17
  const instanceElement = document.getElementById(`instance-${created}`);
@@ -19,7 +19,7 @@ export const Entity = () => {
19
19
  instanceElement.scrollIntoView({ behavior: "smooth", block: "center" });
20
20
  }
21
21
  }
22
- }, []);
22
+ }, [created]);
23
23
  if (!name) {
24
24
  return _jsx(NotFound, {});
25
25
  }
@@ -28,12 +28,14 @@ export const Entity = () => {
28
28
  }
29
29
  return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: "Home" }], children: [_jsxs("div", { class: "header-with-btns", children: [_jsx("h1", { children: name }), _jsx("a", { class: "btn btn--primary", href: `/entities/${entity.declaration.name}/instances/create`, children: "Add" })] }), entity.declaration.comment && _jsx("p", { className: "description", children: entity.declaration.comment }), _jsxs("p", { children: [instances.length, " instance", instances.length === 1 ? "" : "s"] }), _jsx("ul", { class: "instances", children: instances.map(instance => {
30
30
  const gitStatusForDisplay = getGitStatusForDisplay(instance.gitStatus);
31
- return (_jsxs("li", { id: `instance-${instance.id}`, class: `instance-item ${created === instance.id ? "instance-item--created" : ""} ${gitStatusForDisplay === undefined ? "" : `git-status--${gitStatusForDisplay}`}`, children: [_jsx("h2", { children: getDisplayNameFromEntityInstance(entity.declaration, instance.content, instance.id) }), _jsx("p", { "aria-hidden": true, class: "id", children: instance.id }), gitStatusForDisplay !== undefined && (_jsx("p", { class: `git-status git-status--${gitStatusForDisplay}`, title: getLabelForGitStatus(gitStatusForDisplay), children: gitStatusForDisplay })), _jsxs("div", { className: "btns", children: [_jsx("a", { href: `/entities/${entity.declaration.name}/instances/${instance.id}`, class: "btn", children: "Edit" }), _jsx("button", { class: "destructive", onClick: () => {
31
+ return (_jsxs("li", { id: `instance-${instance.id}`, class: `instance-item ${created === instance.id ? "instance-item--created" : ""} ${gitStatusForDisplay === undefined ? "" : `git-status--${gitStatusForDisplay}`}`, children: [_jsx("h2", { children: instance.displayName }), _jsx("p", { "aria-hidden": true, class: "id", children: instance.id }), gitStatusForDisplay !== undefined && (_jsx("p", { class: `git-status git-status--${gitStatusForDisplay}`, title: getLabelForGitStatus(gitStatusForDisplay), children: gitStatusForDisplay })), _jsxs("div", { className: "btns", children: [_jsx("a", { href: `/entities/${entity.declaration.name}/instances/${instance.id}`, class: "btn", children: "Edit" }), _jsx("button", { class: "destructive", onClick: () => {
32
32
  if (confirm("Are you sure you want to delete this instance?")) {
33
33
  deleteInstanceByEntityNameAndId(entity.declaration.name, instance.id)
34
34
  .then(() => reloadInstances())
35
- .catch(error => {
36
- alert("Error deleting instance:\n\n" + error);
35
+ .catch((error) => {
36
+ if (error instanceof Error) {
37
+ alert("Error deleting instance:\n\n" + error.toString());
38
+ }
37
39
  });
38
40
  }
39
41
  }, children: "Delete" })] })] }, instance.id));
@@ -0,0 +1,2 @@
1
+ import type { FunctionalComponent } from "preact";
2
+ export declare const Home: FunctionalComponent;
@@ -3,7 +3,8 @@ import { toTitleCase } from "../../shared/utils/string.js";
3
3
  import { getAllEntities } from "../api.js";
4
4
  import { Layout } from "../components/Layout.js";
5
5
  import { useMappedAPIResource } from "../hooks/useMappedAPIResource.js";
6
+ const mapEntities = (data) => data.declarations.sort((a, b) => a.declaration.name.localeCompare(b.declaration.name));
6
7
  export const Home = () => {
7
- const [entities] = useMappedAPIResource(getAllEntities, data => data.declarations.sort((a, b) => a.declaration.name.localeCompare(b.declaration.name)));
8
+ const [entities] = useMappedAPIResource(getAllEntities, mapEntities);
8
9
  return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: "Home" }], children: [_jsx("h1", { children: "Entities" }), _jsx("ul", { class: "entities", children: (entities ?? []).map(entity => (_jsxs("li", { class: "entity-item", children: [_jsxs("div", { className: "title", children: [_jsx("h2", { children: toTitleCase(entity.declaration.name) }), entity.declaration.comment && _jsx("p", { children: entity.declaration.comment })] }), _jsxs("p", { class: "meta", children: [entity.instanceCount, " instance", entity.instanceCount === 1 ? "" : "s"] }), _jsx("div", { className: "btns", children: _jsx("a", { href: `/entities/${entity.declaration.name}`, class: "btn", children: "View" }) })] }, entity.declaration.name))) })] }));
9
10
  };
@@ -1,2 +1,2 @@
1
- import { FunctionalComponent } from "preact";
1
+ import type { FunctionalComponent } from "preact";
2
2
  export declare const Instance: FunctionalComponent;
@@ -26,22 +26,23 @@ export const Instance = () => {
26
26
  setInstance(instanceData.instance);
27
27
  setOriginalInstance(instanceData.instance);
28
28
  })
29
- .catch(error => {
29
+ .catch((error) => {
30
30
  console.error("Error fetching entities:", error);
31
31
  });
32
32
  }
33
- }, []);
33
+ }, [id, name]);
34
34
  const handleSubmit = (event) => {
35
35
  event.preventDefault();
36
36
  if (name && id && instance) {
37
37
  updateInstanceByEntityNameAndId(name, id, instance.content)
38
38
  .then(updatedInstance => {
39
- 0;
40
39
  setInstance(updatedInstance.instance);
41
40
  setOriginalInstance(updatedInstance.instance);
42
41
  })
43
- .catch(error => {
44
- alert(`Error updating instance:\n\n${error}`);
42
+ .catch((error) => {
43
+ if (error instanceof Error) {
44
+ alert(`Error updating instance:\n\n${error}`);
45
+ }
45
46
  });
46
47
  }
47
48
  };
@@ -65,9 +66,14 @@ export const Instance = () => {
65
66
  .then(() => {
66
67
  route(`/entities/${name}`);
67
68
  })
68
- .catch(error => {
69
- alert("Error deleting instance:\n\n" + error);
69
+ .catch((error) => {
70
+ if (error instanceof Error) {
71
+ alert("Error deleting instance:\n\n" + error.toString());
72
+ }
70
73
  });
71
74
  }
72
- }, children: "Delete" })] }), _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TypeInput, { type: entityFromRoute.entity.type, value: instance.content, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: value => setInstance(container => ({ ...container, content: value })) }), _jsx("button", { type: "submit", disabled: !hasChanges, class: "primary", children: "Save" })] })] }));
75
+ }, children: "Delete" })] }), _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TypeInput, { type: entityFromRoute.entity.type, value: instance.content, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: value => {
76
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
77
+ setInstance(container => ({ ...container, content: value }));
78
+ } }), _jsx("button", { type: "submit", disabled: !hasChanges, class: "primary", children: "Save" })] })] }));
73
79
  };
@@ -1,2 +1,2 @@
1
- import { FunctionalComponent } from "preact";
1
+ import type { FunctionalComponent } from "preact";
2
2
  export declare const NotFound: FunctionalComponent;
@@ -0,0 +1,3 @@
1
+ import type { SerializedType } from "../../node/schema/types/Type.js";
2
+ import type { GetDeclFromDeclName } from "../hooks/useSecondaryDeclarations.js";
3
+ export declare const createTypeSkeleton: (getDeclFromDeclName: GetDeclFromDeclName, type: SerializedType) => unknown;
@@ -17,7 +17,7 @@ export const createTypeSkeleton = (getDeclFromDeclName, type) => {
17
17
  return Object.fromEntries(Object.entries(type.properties).flatMap(([key, memberDecl]) => memberDecl.isRequired
18
18
  ? [[key, createTypeSkeleton(getDeclFromDeclName, memberDecl.type)]]
19
19
  : []));
20
- case "GenericArgumentIdentifierType":
20
+ case "TypeArgumentType":
21
21
  return undefined;
22
22
  case "ReferenceIdentifierType":
23
23
  return "";
@@ -32,6 +32,9 @@ export const createTypeSkeleton = (getDeclFromDeclName, type) => {
32
32
  return {};
33
33
  case "EnumType": {
34
34
  const firstCase = Object.entries(type.values)[0];
35
+ if (firstCase === undefined) {
36
+ return {};
37
+ }
35
38
  return {
36
39
  kind: firstCase[0],
37
40
  ...(firstCase[1].type === null