tsondb 0.5.19 → 0.6.1

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 (223) 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 +91 -4
  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 +2 -0
  151. package/dist/src/web/components/ModalDialog.js +16 -0
  152. package/dist/src/web/components/Select.d.ts +1 -2
  153. package/dist/src/web/components/Settings.d.ts +2 -0
  154. package/dist/src/web/components/Settings.js +47 -0
  155. package/dist/src/web/components/typeInputs/ArrayTypeInput.d.ts +3 -11
  156. package/dist/src/web/components/typeInputs/ArrayTypeInput.js +5 -4
  157. package/dist/src/web/components/typeInputs/BooleanTypeInput.d.ts +3 -6
  158. package/dist/src/web/components/typeInputs/BooleanTypeInput.js +2 -2
  159. package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.d.ts +6 -0
  160. package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.js +27 -0
  161. package/dist/src/web/components/typeInputs/DateTypeInput.d.ts +3 -6
  162. package/dist/src/web/components/typeInputs/DateTypeInput.js +2 -2
  163. package/dist/src/web/components/typeInputs/EnumTypeInput.d.ts +3 -11
  164. package/dist/src/web/components/typeInputs/EnumTypeInput.js +55 -22
  165. package/dist/src/web/components/typeInputs/FloatTypeInput.d.ts +3 -6
  166. package/dist/src/web/components/typeInputs/FloatTypeInput.js +2 -2
  167. package/dist/src/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +3 -4
  168. package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +3 -11
  169. package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.js +3 -2
  170. package/dist/src/web/components/typeInputs/IntegerTypeInput.d.ts +3 -6
  171. package/dist/src/web/components/typeInputs/IntegerTypeInput.js +2 -2
  172. package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +3 -11
  173. package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.js +5 -4
  174. package/dist/src/web/components/typeInputs/ObjectTypeInput.d.ts +3 -11
  175. package/dist/src/web/components/typeInputs/ObjectTypeInput.js +8 -5
  176. package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -8
  177. package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.js +2 -2
  178. package/dist/src/web/components/typeInputs/StringTypeInput.d.ts +3 -6
  179. package/dist/src/web/components/typeInputs/StringTypeInput.js +3 -3
  180. package/dist/src/web/components/typeInputs/TypeInput.d.ts +12 -4
  181. package/dist/src/web/components/typeInputs/TypeInput.js +22 -17
  182. package/dist/src/web/components/typeInputs/utils/ValidationErrors.d.ts +1 -0
  183. package/dist/src/web/components/typeInputs/utils/ValidationErrors.js +1 -3
  184. package/dist/src/web/context/config.d.ts +11 -0
  185. package/dist/src/web/context/config.js +6 -0
  186. package/dist/src/web/context/entities.d.ts +8 -5
  187. package/dist/src/web/context/entities.js +1 -1
  188. package/dist/src/web/context/settings.d.ts +8 -0
  189. package/dist/src/web/context/settings.js +10 -0
  190. package/dist/src/web/hooks/useEntityFromRoute.d.ts +1 -1
  191. package/dist/src/web/hooks/useEntityFromRoute.js +2 -2
  192. package/dist/src/web/hooks/useInstanceNamesByEntity.d.ts +1 -1
  193. package/dist/src/web/hooks/useInstanceNamesByEntity.js +4 -2
  194. package/dist/src/web/hooks/useMappedAPIResource.js +2 -4
  195. package/dist/src/web/hooks/useSecondaryDeclarations.d.ts +1 -1
  196. package/dist/src/web/hooks/useSecondaryDeclarations.js +8 -4
  197. package/dist/src/web/hooks/useSettings.d.ts +10 -0
  198. package/dist/src/web/hooks/useSettings.js +51 -0
  199. package/dist/src/web/index.js +11 -5
  200. package/dist/src/web/routes/CreateInstance.js +40 -79
  201. package/dist/src/web/routes/Entity.js +42 -19
  202. package/dist/src/web/routes/Home.js +24 -5
  203. package/dist/src/web/routes/Instance.js +34 -85
  204. package/dist/src/web/utils/InlineMarkdown.d.ts +1 -1
  205. package/dist/src/web/utils/InlineMarkdown.js +13 -1
  206. package/dist/src/web/utils/api.d.ts +25 -0
  207. package/dist/src/web/utils/api.js +34 -0
  208. package/dist/src/web/utils/typeSkeleton.d.ts +1 -1
  209. package/dist/src/web/utils/typeSkeleton.js +2 -0
  210. package/package.json +14 -13
  211. package/public/css/styles.css +171 -12
  212. package/dist/src/node/schema/types/primitives/NumericType.d.ts +0 -6
  213. package/dist/src/node/schema/types/primitives/NumericType.js +0 -2
  214. package/dist/src/node/schema/types/primitives/PrimitiveType.d.ts +0 -6
  215. package/dist/src/node/schema/validation/type.d.ts +0 -4
  216. package/dist/src/node/schema/validation/type.js +0 -1
  217. package/dist/src/node/server/api/instanceOperations.d.ts +0 -6
  218. package/dist/src/node/server/api/instanceOperations.js +0 -93
  219. package/dist/src/shared/config.d.ts +0 -11
  220. package/dist/src/shared/config.js +0 -1
  221. package/dist/src/web/api.d.ts +0 -24
  222. package/dist/src/web/api.js +0 -201
  223. /package/dist/src/{node/schema/types/primitives/PrimitiveType.js → shared/schema/types/Type.js} +0 -0
@@ -1,11 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { discriminatorKey } from "../../../shared/enum.js";
3
3
  import { toTitleCase } from "../../../shared/utils/string.js";
4
+ import { assertExhaustive } from "../../../shared/utils/typeSafety.js";
5
+ import { useSetting } from "../../hooks/useSettings.js";
6
+ import { Markdown } from "../../utils/Markdown.js";
4
7
  import { createTypeSkeleton } from "../../utils/typeSkeleton.js";
5
8
  import { Select } from "../Select.js";
6
9
  import { TypeInput } from "./TypeInput.js";
7
10
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
8
- export const EnumTypeInput = ({ type, path, value, instanceNamesByEntity, getDeclFromDeclName, onChange, }) => {
11
+ export const EnumTypeInput = props => {
12
+ const { type, path, value, disabled, getDeclFromDeclName, onChange } = props;
13
+ const [enumDisplay] = useSetting("enumDisplay");
9
14
  if (typeof value !== "object" ||
10
15
  value === null ||
11
16
  Array.isArray(value) ||
@@ -13,26 +18,54 @@ export const EnumTypeInput = ({ type, path, value, instanceNamesByEntity, getDec
13
18
  typeof value[discriminatorKey] !== "string") {
14
19
  return _jsx(MismatchingTypeError, { expected: "enumeration value", actual: value });
15
20
  }
16
- const enumValues = Object.keys(type.values);
21
+ const enumValues = Object.entries(type.values);
17
22
  const activeEnumCase = value[discriminatorKey];
18
- const caseMember = type.values[activeEnumCase];
19
- return (_jsxs("div", { class: "field field--enum", children: [_jsx(Select, { value: activeEnumCase, onInput: event => {
20
- const caseMember = type.values[event.currentTarget.value];
21
- if (caseMember?.type == null) {
22
- onChange({
23
- [discriminatorKey]: event.currentTarget.value,
24
- });
25
- }
26
- else {
27
- onChange({
28
- [discriminatorKey]: event.currentTarget.value,
29
- [event.currentTarget.value]: createTypeSkeleton(getDeclFromDeclName, caseMember.type),
30
- });
31
- }
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, path: path === undefined ? `{${activeEnumCase}}` : `${path}.{${activeEnumCase}}`, value: value[activeEnumCase], instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newValue => {
33
- onChange({
34
- [discriminatorKey]: activeEnumCase,
35
- [activeEnumCase]: newValue,
36
- });
37
- } }) }))] }));
23
+ const activeCaseMember = type.values[activeEnumCase];
24
+ switch (enumDisplay) {
25
+ case "select":
26
+ return (_jsxs("div", { class: "field field--enum", children: [_jsx(Select, { value: activeEnumCase, onInput: event => {
27
+ const caseMember = type.values[event.currentTarget.value];
28
+ if (caseMember?.type == null) {
29
+ onChange({
30
+ [discriminatorKey]: event.currentTarget.value,
31
+ });
32
+ }
33
+ else {
34
+ onChange({
35
+ [discriminatorKey]: event.currentTarget.value,
36
+ [event.currentTarget.value]: createTypeSkeleton(getDeclFromDeclName, caseMember.type),
37
+ });
38
+ }
39
+ }, disabled: disabled, children: enumValues.map(([enumValue]) => (_jsx("option", { value: enumValue, selected: enumValue === activeEnumCase, children: toTitleCase(enumValue) }, enumValue))) }), activeCaseMember?.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: activeCaseMember.comment })), activeCaseMember?.type == null ? null : (_jsx("div", { className: "associated-type", children: _jsx(TypeInput, { ...props, parentKey: undefined, type: activeCaseMember.type, path: path === undefined ? `{${activeEnumCase}}` : `${path}.{${activeEnumCase}}`, value: value[activeEnumCase], onChange: newValue => {
40
+ onChange({
41
+ [discriminatorKey]: activeEnumCase,
42
+ [activeEnumCase]: newValue,
43
+ });
44
+ } }) }))] }));
45
+ case "radio":
46
+ return (_jsx("div", { class: "field field--enum", children: enumValues.map(([enumValue, caseMember]) => (_jsxs("div", { class: "field--option", children: [_jsx("input", { type: "radio", name: path, value: enumValue, id: path === undefined ? enumValue : `${path}-${enumValue}`, checked: enumValue === activeEnumCase, onInput: () => {
47
+ if (caseMember.type == null) {
48
+ onChange({
49
+ [discriminatorKey]: enumValue,
50
+ });
51
+ }
52
+ else {
53
+ onChange({
54
+ [discriminatorKey]: enumValue,
55
+ [enumValue]: createTypeSkeleton(getDeclFromDeclName, caseMember.type),
56
+ });
57
+ }
58
+ }, disabled: disabled }), _jsxs("div", { children: [_jsx("label", { htmlFor: path === undefined ? enumValue : `${path}-${enumValue}`, children: toTitleCase(enumValue) }), caseMember.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: caseMember.comment })), caseMember.type == null ? null : (_jsx("div", { className: "associated-type", children: _jsx(TypeInput, { ...props, parentKey: undefined, type: caseMember.type, path: path === undefined ? `{${activeEnumCase}}` : `${path}.{${activeEnumCase}}`, value: enumValue === activeEnumCase
59
+ ? value[activeEnumCase]
60
+ : createTypeSkeleton(getDeclFromDeclName, caseMember.type), disabled: disabled || enumValue !== activeEnumCase, onChange: disabled
61
+ ? () => { }
62
+ : newValue => {
63
+ onChange({
64
+ [discriminatorKey]: activeEnumCase,
65
+ [activeEnumCase]: newValue,
66
+ });
67
+ } }) }))] })] }, enumValue))) }));
68
+ default:
69
+ return assertExhaustive(enumDisplay);
70
+ }
38
71
  };
@@ -1,9 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedFloatType } from "../../../node/schema/types/primitives/FloatType.ts";
3
- type Props = {
4
- type: SerializedFloatType;
5
- value: unknown;
6
- onChange: (value: number) => void;
7
- };
2
+ import type { SerializedFloatType } from "../../../shared/schema/types/FloatType.ts";
3
+ import type { TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedFloatType, number>;
8
5
  export declare const FloatTypeInput: FunctionComponent<Props>;
9
6
  export {};
@@ -3,7 +3,7 @@ import { useState } from "preact/hooks";
3
3
  import { validateNumberConstraints } from "../../../shared/validation/number.js";
4
4
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
5
5
  import { ValidationErrors } from "./utils/ValidationErrors.js";
6
- export const FloatTypeInput = ({ type, value, onChange }) => {
6
+ export const FloatTypeInput = ({ type, value, disabled, onChange }) => {
7
7
  const [stringValue, setStringValue] = useState(typeof value === "number" ? value.toString() : "");
8
8
  if (typeof value !== "number") {
9
9
  return _jsx(MismatchingTypeError, { expected: "float", actual: value });
@@ -15,5 +15,5 @@ export const FloatTypeInput = ({ type, value, onChange }) => {
15
15
  if (!Number.isNaN(numericValue)) {
16
16
  onChange(numericValue);
17
17
  }
18
- }, step: 0.01, "aria-invalid": errors.length > 0 }), _jsx(ValidationErrors, { errors: errors })] }));
18
+ }, step: 0.01, "aria-invalid": errors.length > 0, disabled: disabled }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }));
19
19
  };
@@ -1,7 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedTypeArgumentType } from "../../../node/schema/types/references/TypeArgumentType.ts";
3
- type Props = {
4
- type: SerializedTypeArgumentType;
5
- };
2
+ import type { SerializedTypeArgumentType } from "../../../shared/schema/types/TypeArgumentType.ts";
3
+ import type { TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedTypeArgumentType>;
6
5
  export declare const TypeArgumentTypeInput: FunctionComponent<Props>;
7
6
  export {};
@@ -1,14 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedIncludeIdentifierType } from "../../../node/schema/index.ts";
3
- import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.ts";
4
- import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.ts";
5
- type Props = {
6
- type: SerializedIncludeIdentifierType;
7
- path: string | undefined;
8
- value: unknown;
9
- instanceNamesByEntity: InstanceNamesByEntity;
10
- getDeclFromDeclName: GetDeclFromDeclName;
11
- onChange: (value: unknown) => void;
12
- };
2
+ import type { SerializedIncludeIdentifierType } from "../../../shared/schema/types/IncludeIdentifierType.ts";
3
+ import { type TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedIncludeIdentifierType>;
13
5
  export declare const IncludeIdentifierTypeInput: FunctionComponent<Props>;
14
6
  export {};
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { TypeInput } from "./TypeInput.js";
3
- export const IncludeIdentifierTypeInput = ({ type, path, value, instanceNamesByEntity, getDeclFromDeclName, onChange, }) => {
3
+ export const IncludeIdentifierTypeInput = props => {
4
+ const { type, getDeclFromDeclName } = props;
4
5
  const decl = getDeclFromDeclName(type.reference);
5
6
  if (decl === undefined) {
6
7
  return (_jsxs("div", { role: "alert", children: ["Unresolved declaration identifier ", _jsx("code", { children: type.reference })] }));
7
8
  }
8
- return (_jsx(TypeInput, { type: decl.type, path: path, value: value, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: onChange }));
9
+ return _jsx(TypeInput, { ...props, parentKey: undefined, type: decl.type });
9
10
  };
@@ -1,9 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedIntegerType } from "../../../node/schema/types/primitives/IntegerType.ts";
3
- type Props = {
4
- type: SerializedIntegerType;
5
- value: unknown;
6
- onChange: (value: number) => void;
7
- };
2
+ import type { SerializedIntegerType } from "../../../shared/schema/types/IntegerType.ts";
3
+ import type { TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedIntegerType, number>;
8
5
  export declare const IntegerTypeInput: FunctionComponent<Props>;
9
6
  export {};
@@ -3,7 +3,7 @@ import { useState } from "preact/hooks";
3
3
  import { validateNumberConstraints } from "../../../shared/validation/number.js";
4
4
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
5
5
  import { ValidationErrors } from "./utils/ValidationErrors.js";
6
- export const IntegerTypeInput = ({ type, value, onChange }) => {
6
+ export const IntegerTypeInput = ({ type, value, disabled, onChange }) => {
7
7
  const [stringValue, setStringValue] = useState(typeof value === "number" ? value.toString() : "");
8
8
  if (typeof value !== "number") {
9
9
  return _jsx(MismatchingTypeError, { expected: "float", actual: value });
@@ -15,5 +15,5 @@ export const IntegerTypeInput = ({ type, value, onChange }) => {
15
15
  if (!Number.isNaN(numericValue)) {
16
16
  onChange(numericValue);
17
17
  }
18
- }, step: 0.01, "aria-invalid": errors.length > 0 }), _jsx(ValidationErrors, { errors: errors })] }));
18
+ }, step: 0.01, "aria-invalid": errors.length > 0, disabled: disabled }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }));
19
19
  };
@@ -1,14 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedNestedEntityMapType } from "../../../node/schema/types/references/NestedEntityMapType.ts";
3
- import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.ts";
4
- import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.ts";
5
- type Props = {
6
- type: SerializedNestedEntityMapType;
7
- path: string | undefined;
8
- value: unknown;
9
- instanceNamesByEntity: InstanceNamesByEntity;
10
- getDeclFromDeclName: GetDeclFromDeclName;
11
- onChange: (value: Record<string, unknown>) => void;
12
- };
2
+ import type { SerializedNestedEntityMapType } from "../../../shared/schema/types/NestedEntityMapType.ts";
3
+ import { type TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedNestedEntityMapType, Record<string, unknown>>;
13
5
  export declare const NestedEntityMapTypeInput: FunctionComponent<Props>;
14
6
  export {};
@@ -6,7 +6,8 @@ import { createTypeSkeleton } from "../../utils/typeSkeleton.js";
6
6
  import { Select } from "../Select.js";
7
7
  import { TypeInput } from "./TypeInput.js";
8
8
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
9
- export const NestedEntityMapTypeInput = ({ type, path, value, instanceNamesByEntity, getDeclFromDeclName, onChange, }) => {
9
+ export const NestedEntityMapTypeInput = props => {
10
+ const { type, path, value, instanceNamesByEntity, disabled, getDeclFromDeclName, onChange } = props;
10
11
  const [newKey, setNewKey] = useState("");
11
12
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
12
13
  return _jsx(MismatchingTypeError, { expected: "object", actual: value });
@@ -24,16 +25,16 @@ export const NestedEntityMapTypeInput = ({ type, path, value, instanceNamesByEnt
24
25
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
25
26
  delete newObj[key];
26
27
  onChange(newObj);
27
- }, children: ["Delete ", name] }) })] }), _jsx(TypeInput, { type: type.type, path: path === undefined ? key : `${path}.${key}`, value: item, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => {
28
+ }, disabled: disabled, children: ["Delete ", name] }) })] }), _jsx(TypeInput, { ...props, parentKey: undefined, type: type.type, path: path === undefined ? key : `${path}.${key}`, value: item, onChange: newItem => {
28
29
  onChange(sortObjectKeysAlphabetically({ ...value, [key]: newItem }));
29
30
  } })] }, key));
30
31
  }) })), _jsxs("div", { class: "add-item-container", children: [_jsxs(Select, { value: newKey, onInput: event => {
31
32
  setNewKey(event.currentTarget.value);
32
- }, 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)))] }), _jsxs("button", { onClick: () => {
33
+ }, disabled: 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)))] }), _jsxs("button", { onClick: () => {
33
34
  onChange(sortObjectKeysAlphabetically({
34
35
  ...value,
35
36
  [newKey]: createTypeSkeleton(getDeclFromDeclName, type.type),
36
37
  }));
37
38
  setNewKey("");
38
- }, disabled: newKey === "", children: ["Add ", newKey === "" ? "Key" : toTitleCase(newKey)] })] })] }));
39
+ }, disabled: disabled || newKey === "", children: ["Add ", newKey === "" ? "Key" : toTitleCase(newKey)] })] })] }));
39
40
  };
@@ -1,14 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedObjectType } from "../../../node/schema/types/generic/ObjectType.ts";
3
- import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.ts";
4
- import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.ts";
5
- type Props = {
6
- type: SerializedObjectType;
7
- path: string | undefined;
8
- value: unknown;
9
- instanceNamesByEntity: InstanceNamesByEntity;
10
- getDeclFromDeclName: GetDeclFromDeclName;
11
- onChange: (value: Record<string, unknown>) => void;
12
- };
2
+ import type { SerializedObjectType } from "../../../shared/schema/types/ObjectType.ts";
3
+ import { type TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedObjectType, Record<string, unknown>>;
13
5
  export declare const ObjectTypeInput: FunctionComponent<Props>;
14
6
  export {};
@@ -7,23 +7,26 @@ import { createTypeSkeleton } from "../../utils/typeSkeleton.js";
7
7
  import { TypeInput } from "./TypeInput.js";
8
8
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
9
9
  import { ValidationErrors } from "./utils/ValidationErrors.js";
10
- export const ObjectTypeInput = ({ type, path, value, instanceNamesByEntity, getDeclFromDeclName, onChange, }) => {
10
+ export const ObjectTypeInput = props => {
11
+ const { type, path, value, parentKey, disabled, getDeclFromDeclName, onChange } = props;
11
12
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
12
13
  return _jsx(MismatchingTypeError, { expected: "object", actual: value });
13
14
  }
14
15
  const errors = validateObjectConstraints(type, Object.keys(type.properties), value);
15
- return (_jsxs("div", { class: "field field--container field--object", children: [_jsx("ul", { children: Object.entries(type.properties).map(([key, memberDecl]) => (_jsxs("li", { class: "container-item object-item", children: [_jsxs("div", { className: "container-item-header", children: [_jsxs("div", { className: "container-item-title", children: [_jsx("strong", { children: toTitleCase(key) }), memberDecl.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: memberDecl.comment }))] }), memberDecl.isRequired ? null : value[key] ===
16
+ return (_jsxs("div", { class: "field field--container field--object" + (disabled ? " field--disabled" : ""), children: [_jsx("ul", { children: Object.entries(type.properties)
17
+ .filter(([key]) => key !== parentKey)
18
+ .map(([key, memberDecl]) => (_jsxs("li", { class: "container-item object-item", children: [_jsxs("div", { className: "container-item-header", children: [_jsxs("div", { className: "container-item-title", children: [_jsx("strong", { children: toTitleCase(key) }), memberDecl.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: memberDecl.comment }))] }), memberDecl.isRequired ? null : value[key] ===
16
19
  undefined ? (_jsxs("button", { onClick: () => {
17
20
  onChange(sortObjectKeys({
18
21
  ...value,
19
22
  [key]: createTypeSkeleton(getDeclFromDeclName, memberDecl.type),
20
23
  }, Object.keys(type.properties)));
21
- }, children: ["Add ", toTitleCase(key)] })) : (_jsxs("button", { class: "destructive", onClick: () => {
24
+ }, disabled: disabled, children: ["Add ", toTitleCase(key)] })) : (_jsxs("button", { class: "destructive", onClick: () => {
22
25
  const newObj = { ...value };
23
26
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
24
27
  delete newObj[key];
25
28
  onChange(newObj);
26
- }, children: ["Remove ", toTitleCase(key)] }))] }), memberDecl.isRequired || value[key] !== undefined ? (_jsx(TypeInput, { type: memberDecl.type, path: path === undefined ? key : `${path}.${key}`, value: value[key], instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: newItem => {
29
+ }, disabled: disabled, children: ["Remove ", toTitleCase(key)] }))] }), memberDecl.isRequired || value[key] !== undefined ? (_jsx(TypeInput, { ...props, parentKey: undefined, type: memberDecl.type, path: path === undefined ? key : `${path}.${key}`, value: value[key], onChange: newItem => {
27
30
  onChange(sortObjectKeys({ ...value, [key]: newItem }, Object.keys(type.properties)));
28
- } })) : null] }, key))) }), _jsx(ValidationErrors, { errors: errors })] }));
31
+ } })) : null] }, key))) }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }));
29
32
  };
@@ -1,11 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedReferenceIdentifierType } from "../../../node/schema/types/references/ReferenceIdentifierType.ts";
3
- import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.ts";
4
- type Props = {
5
- type: SerializedReferenceIdentifierType;
6
- value: unknown;
7
- instanceNamesByEntity: InstanceNamesByEntity;
8
- onChange: (value: string) => void;
9
- };
2
+ import type { SerializedReferenceIdentifierType } from "../../../shared/schema/types/ReferenceIdentifierType.ts";
3
+ import type { TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedReferenceIdentifierType, string>;
10
5
  export declare const ReferenceIdentifierTypeInput: FunctionComponent<Props>;
11
6
  export {};
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { Select } from "../Select.js";
3
3
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
4
4
  import { ValidationErrors } from "./utils/ValidationErrors.js";
5
- export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntity, onChange, }) => {
5
+ export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntity, disabled, onChange, }) => {
6
6
  if (typeof value !== "string") {
7
7
  return _jsx(MismatchingTypeError, { expected: "string identifier", actual: value });
8
8
  }
@@ -11,5 +11,5 @@ export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntit
11
11
  .sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
12
12
  return (_jsxs("div", { class: "field", children: [_jsxs(Select, { value: value, onInput: event => {
13
13
  onChange(event.currentTarget.value);
14
- }, 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")] : [] })] }));
14
+ }, disabled: 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, { disabled: disabled, errors: !value ? [ReferenceError("no reference provided")] : [] })] }));
15
15
  };
@@ -1,9 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedStringType } from "../../../node/schema/types/primitives/StringType.ts";
3
- type Props = {
4
- type: SerializedStringType;
5
- value: unknown;
6
- onChange: (value: string) => void;
7
- };
2
+ import type { SerializedStringType } from "../../../shared/schema/types/StringType.ts";
3
+ import type { TypeInputProps } from "./TypeInput.tsx";
4
+ type Props = TypeInputProps<SerializedStringType, string>;
8
5
  export declare const StringTypeInput: FunctionComponent<Props>;
9
6
  export {};
@@ -4,7 +4,7 @@ import { Markdown } from "../../utils/Markdown.js";
4
4
  import { MarkdownHighlighting } from "../../utils/MarkdownHighlighting.js";
5
5
  import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
6
6
  import { ValidationErrors } from "./utils/ValidationErrors.js";
7
- export const StringTypeInput = ({ type, value, onChange }) => {
7
+ export const StringTypeInput = ({ type, value, disabled, onChange }) => {
8
8
  if (typeof value !== "string") {
9
9
  return _jsx(MismatchingTypeError, { expected: "string", actual: value });
10
10
  }
@@ -12,11 +12,11 @@ export const StringTypeInput = ({ type, value, onChange }) => {
12
12
  const errors = validateStringConstraints(type, value);
13
13
  return (_jsx("div", { class: "field field--string", children: isMarkdown ? (_jsxs(_Fragment, { children: [_jsxs("div", { class: "editor editor--markdown", children: [_jsxs("div", { class: "textarea-grow-wrap", children: [_jsx("textarea", { value: value, minLength: minLength, maxLength: maxLength, onInput: event => {
14
14
  onChange(event.currentTarget.value);
15
- }, "aria-invalid": errors.length > 0 }), _jsxs("p", { class: "help", children: ["This textarea supports", " ", _jsx("a", { href: "https://www.markdownguide.org/getting-started/", target: "_blank", rel: "noreferrer", children: "Markdown" }), "."] }), _jsx(MarkdownHighlighting, { class: "textarea-grow-wrap__mirror editor-highlighting", string: value })] }), _jsx(ValidationErrors, { errors: errors })] }), _jsx("div", { class: "preview", children: _jsx(Markdown, { string: value }) })] })) : (_jsxs("div", { class: "editor", children: [_jsx("input", { type: "text", value: value, minLength: minLength, maxLength: maxLength, pattern: pattern === undefined
15
+ }, "aria-invalid": errors.length > 0, disabled: disabled }), _jsxs("p", { class: "help", children: ["This textarea supports", " ", _jsx("a", { href: "https://www.markdownguide.org/getting-started/", target: "_blank", rel: "noreferrer", children: "Markdown" }), "."] }), _jsx(MarkdownHighlighting, { class: "textarea-grow-wrap__mirror editor-highlighting", string: value })] }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }), _jsx("div", { class: "preview", children: _jsx(Markdown, { string: value }) })] })) : (_jsxs("div", { class: "editor", children: [_jsx("input", { type: "text", value: value, minLength: minLength, maxLength: maxLength, pattern: pattern === undefined
16
16
  ? undefined
17
17
  : pattern.startsWith("^(?:") && pattern.endsWith(")$")
18
18
  ? pattern.slice(4, -2)
19
19
  : `.*${pattern}.*`, onInput: event => {
20
20
  onChange(event.currentTarget.value);
21
- }, "aria-invalid": errors.length > 0 }), _jsx(ValidationErrors, { errors: errors })] })) }));
21
+ }, "aria-invalid": errors.length > 0, disabled: disabled }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] })) }));
22
22
  };
@@ -1,14 +1,22 @@
1
1
  import type { FunctionComponent } from "preact";
2
- import type { SerializedType } from "../../../node/schema/types/Type.ts";
2
+ import type { UnsafeEntityTaggedInstanceContainerWithChildInstances } from "../../../node/utils/childInstances.ts";
3
+ import type { SerializedType } from "../../../shared/schema/types/Type.ts";
3
4
  import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.ts";
4
5
  import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.ts";
5
- type Props = {
6
- type: SerializedType;
6
+ export type TypeInputProps<T, V = unknown> = {
7
+ type: T;
7
8
  path: string | undefined;
8
9
  value: unknown;
9
10
  instanceNamesByEntity: InstanceNamesByEntity;
11
+ parentKey?: string;
12
+ childInstances: UnsafeEntityTaggedInstanceContainerWithChildInstances[];
13
+ disabled?: boolean;
10
14
  getDeclFromDeclName: GetDeclFromDeclName;
11
- onChange: (value: unknown) => void;
15
+ onChange: (value: V) => void;
16
+ onChildChange: (index: number, value: unknown) => void;
17
+ onChildAdd: (entityName: string, value: unknown) => void;
18
+ onChildRemove: (index: number) => void;
12
19
  };
20
+ type Props = TypeInputProps<SerializedType>;
13
21
  declare const MemoizedTypeInput: FunctionComponent<Props>;
14
22
  export { MemoizedTypeInput as TypeInput };
@@ -3,6 +3,7 @@ import { memo } from "preact/compat";
3
3
  import { assertExhaustive } from "../../../shared/utils/typeSafety.js";
4
4
  import { ArrayTypeInput } from "./ArrayTypeInput.js";
5
5
  import { BooleanTypeInput } from "./BooleanTypeInput.js";
6
+ import { ChildEntitiesTypeInput } from "./ChildEntitiesTypeInput.js";
6
7
  import { DateTypeInput } from "./DateTypeInput.js";
7
8
  import { EnumTypeInput } from "./EnumTypeInput.js";
8
9
  import { FloatTypeInput } from "./FloatTypeInput.js";
@@ -13,36 +14,40 @@ import { NestedEntityMapTypeInput } from "./NestedEntityMapTypeInput.js";
13
14
  import { ObjectTypeInput } from "./ObjectTypeInput.js";
14
15
  import { ReferenceIdentifierTypeInput } from "./ReferenceIdentifierTypeInput.js";
15
16
  import { StringTypeInput } from "./StringTypeInput.js";
16
- const TypeInput = ({ type, path, value, instanceNamesByEntity, getDeclFromDeclName, onChange, }) => {
17
- // console.log("rendering node at path ", path ?? "<root>")
18
- switch (type.kind) {
17
+ const TypeInput = props => {
18
+ // console.log("rendering node at path ", props.path ?? "<root>")
19
+ switch (props.type.kind) {
19
20
  case "BooleanType":
20
- return _jsx(BooleanTypeInput, { type: type, value: value, onChange: onChange });
21
+ return _jsx(BooleanTypeInput, { ...props, type: props.type });
21
22
  case "DateType":
22
- return _jsx(DateTypeInput, { type: type, value: value, onChange: onChange });
23
+ return _jsx(DateTypeInput, { ...props, type: props.type });
23
24
  case "FloatType":
24
- return _jsx(FloatTypeInput, { type: type, value: value, onChange: onChange });
25
+ return _jsx(FloatTypeInput, { ...props, type: props.type });
25
26
  case "IntegerType":
26
- return _jsx(IntegerTypeInput, { type: type, value: value, onChange: onChange });
27
+ return _jsx(IntegerTypeInput, { ...props, type: props.type });
27
28
  case "StringType":
28
- return _jsx(StringTypeInput, { type: type, value: value, onChange: onChange });
29
+ return _jsx(StringTypeInput, { ...props, type: props.type });
29
30
  case "ArrayType":
30
- return (_jsx(ArrayTypeInput, { type: type, path: path, value: value, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: onChange }));
31
+ return _jsx(ArrayTypeInput, { ...props, type: props.type });
31
32
  case "ObjectType":
32
- return (_jsx(ObjectTypeInput, { type: type, path: path, value: value, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: onChange }));
33
+ return _jsx(ObjectTypeInput, { ...props, type: props.type });
33
34
  case "TypeArgumentType":
34
- return _jsx(TypeArgumentTypeInput, { type: type });
35
+ return _jsx(TypeArgumentTypeInput, { ...props, type: props.type });
35
36
  case "ReferenceIdentifierType":
36
- return (_jsx(ReferenceIdentifierTypeInput, { type: type, value: value, instanceNamesByEntity: instanceNamesByEntity, onChange: onChange }));
37
+ return _jsx(ReferenceIdentifierTypeInput, { ...props, type: props.type });
37
38
  case "IncludeIdentifierType":
38
- return (_jsx(IncludeIdentifierTypeInput, { type: type, path: path, value: value, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: onChange }));
39
+ return _jsx(IncludeIdentifierTypeInput, { ...props, type: props.type });
39
40
  case "NestedEntityMapType":
40
- return (_jsx(NestedEntityMapTypeInput, { type: type, path: path, value: value, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: onChange }));
41
+ return _jsx(NestedEntityMapTypeInput, { ...props, type: props.type });
41
42
  case "EnumType":
42
- return (_jsx(EnumTypeInput, { type: type, path: path, value: value, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: onChange }));
43
+ return _jsx(EnumTypeInput, { ...props, type: props.type });
44
+ case "ChildEntitiesType":
45
+ return _jsx(ChildEntitiesTypeInput, { ...props, type: props.type });
43
46
  default:
44
- return assertExhaustive(type);
47
+ return assertExhaustive(props.type);
45
48
  }
46
49
  };
47
- const MemoizedTypeInput = memo(TypeInput, (prevProps, nextProps) => prevProps.value === nextProps.value && prevProps.onChange === nextProps.onChange);
50
+ const MemoizedTypeInput = memo(TypeInput, (prevProps, nextProps) => prevProps.value === nextProps.value &&
51
+ prevProps.onChange === nextProps.onChange &&
52
+ prevProps.childInstances === nextProps.childInstances);
48
53
  export { MemoizedTypeInput as TypeInput };
@@ -1,5 +1,6 @@
1
1
  import type { FunctionComponent } from "preact";
2
2
  type Props = {
3
+ disabled?: boolean;
3
4
  errors: Error[];
4
5
  };
5
6
  export declare const ValidationErrors: FunctionComponent<Props>;
@@ -1,4 +1,2 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
- export const ValidationErrors = ({ errors }) => {
3
- return errors.length === 0 ? null : (_jsx("div", { role: "alert", class: "validation-errors", children: _jsx("ul", { children: errors.map((error, i) => (_jsx("li", { children: error.message }, i))) }) }));
4
- };
2
+ export const ValidationErrors = ({ disabled, errors }) => disabled || errors.length === 0 ? null : (_jsx("div", { role: "alert", class: "validation-errors", children: _jsx("ul", { children: errors.map((error, i) => (_jsx("li", { children: error.message }, i))) }) }));
@@ -0,0 +1,11 @@
1
+ export type WebConfig = {
2
+ localeEntityName: string | undefined;
3
+ defaultLocales: string[];
4
+ homeLayoutSections?: {
5
+ title: string;
6
+ comment?: string;
7
+ entities: string[];
8
+ }[];
9
+ };
10
+ export declare const defaultWebConfig: WebConfig;
11
+ export declare const ConfigContext: import("preact").Context<WebConfig>;
@@ -0,0 +1,6 @@
1
+ import { createContext } from "preact";
2
+ export const defaultWebConfig = {
3
+ localeEntityName: undefined,
4
+ defaultLocales: [],
5
+ };
6
+ export const ConfigContext = createContext(defaultWebConfig);
@@ -1,6 +1,9 @@
1
- import type { SerializedEntityDecl } from "../../node/schema/index.ts";
1
+ import type { SerializedEntityDecl } from "../../shared/schema/declarations/EntityDecl.ts";
2
2
  export declare const EntitiesContext: import("preact").Context<{
3
- declaration: SerializedEntityDecl;
4
- instanceCount: number;
5
- isLocaleEntity: boolean;
6
- }[]>;
3
+ entities: {
4
+ declaration: SerializedEntityDecl;
5
+ instanceCount: number;
6
+ isLocaleEntity: boolean;
7
+ }[];
8
+ reloadEntities: () => Promise<void>;
9
+ }>;
@@ -1,2 +1,2 @@
1
1
  import { createContext } from "preact";
2
- export const EntitiesContext = createContext([]);
2
+ export const EntitiesContext = createContext({ entities: [], reloadEntities: async () => { } });
@@ -0,0 +1,8 @@
1
+ import type { SetStateAction } from "preact/compat";
2
+ import { type UserSettings } from "../hooks/useSettings.ts";
3
+ export declare const defaultSettings: UserSettings;
4
+ export type SettingsContext = {
5
+ settings: UserSettings;
6
+ setSetting: <K extends keyof UserSettings>(key: K, value: SetStateAction<UserSettings[K]>) => void;
7
+ };
8
+ export declare const SettingsContext: import("preact").Context<SettingsContext>;
@@ -0,0 +1,10 @@
1
+ import { createContext } from "preact";
2
+ import {} from "../hooks/useSettings.js";
3
+ export const defaultSettings = {
4
+ displayedLocales: [],
5
+ enumDisplay: "select",
6
+ };
7
+ export const SettingsContext = createContext({
8
+ settings: defaultSettings,
9
+ setSetting: () => { },
10
+ });
@@ -1,4 +1,4 @@
1
- import type { SerializedEntityDecl } from "../../node/schema/declarations/EntityDecl.ts";
1
+ import type { SerializedEntityDecl } from "../../shared/schema/declarations/EntityDecl.ts";
2
2
  export declare const useEntityFromRoute: () => {
3
3
  declaration: SerializedEntityDecl;
4
4
  isLocaleEntity: boolean;
@@ -3,7 +3,7 @@ import { useContext, useMemo } from "preact/hooks";
3
3
  import { EntitiesContext } from "../context/entities.js";
4
4
  export const useEntityFromRoute = () => {
5
5
  const { params: { name }, } = useRoute();
6
- const entities = useContext(EntitiesContext);
7
- const entityObj = useMemo(() => entities.find(e => e.declaration.name === name), [entities, name]);
6
+ const { entities } = useContext(EntitiesContext);
7
+ const entityObj = useMemo(() => entities.find(e => e.declaration.name === name && e.declaration.parentReferenceKey === undefined), [entities, name]);
8
8
  return entityObj;
9
9
  };
@@ -1,3 +1,3 @@
1
1
  import type { GetAllInstancesResponseBody } from "../../shared/api.ts";
2
2
  export type InstanceNamesByEntity = GetAllInstancesResponseBody["instances"];
3
- export declare const useInstanceNamesByEntity: (locales?: string[]) => [InstanceNamesByEntity | undefined, () => void];
3
+ export declare const useInstanceNamesByEntity: () => [InstanceNamesByEntity | undefined, () => void];
@@ -1,6 +1,8 @@
1
1
  import { useCallback, useEffect, useState } from "preact/hooks";
2
- import { getAllInstances } from "../api.js";
3
- export const useInstanceNamesByEntity = (locales = []) => {
2
+ import { getAllInstances } from "../api/instances.js";
3
+ import { useSetting } from "./useSettings.js";
4
+ export const useInstanceNamesByEntity = () => {
5
+ const [locales] = useSetting("displayedLocales");
4
6
  const [instanceNamesByEntity, setInstanceNamesByEntity] = useState();
5
7
  const updateInstanceNamesByEntity = useCallback(() => {
6
8
  getAllInstances(locales)