tsondb 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +385 -0
- package/README.md +173 -1
- package/lib/bin/tsondb.d.ts +8 -0
- package/lib/bin/tsondb.js +83 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/{Schema.d.ts → node/Schema.d.ts} +2 -2
- package/lib/{Schema.js → node/Schema.js} +1 -1
- package/lib/node/index.d.ts +8 -0
- package/lib/node/index.js +62 -0
- package/lib/{renderers → node/renderers}/Output.d.ts +1 -1
- package/lib/{renderers → node/renderers}/jsonschema/index.d.ts +2 -2
- package/lib/{renderers → node/renderers}/jsonschema/index.js +2 -2
- package/lib/{renderers → node/renderers}/jsonschema/render.d.ts +1 -1
- package/lib/{renderers → node/renderers}/jsonschema/render.js +9 -9
- package/lib/{renderers → node/renderers}/ts/index.d.ts +2 -2
- package/lib/{renderers → node/renderers}/ts/index.js +2 -2
- package/lib/{renderers → node/renderers}/ts/render.d.ts +1 -1
- package/lib/{renderers → node/renderers}/ts/render.js +9 -8
- package/lib/{schema → node/schema}/Node.d.ts +4 -4
- package/lib/{schema → node/schema}/Node.js +5 -5
- package/lib/{schema/parameters → node/schema}/TypeParameter.d.ts +3 -2
- package/lib/{schema/parameters → node/schema}/TypeParameter.js +2 -2
- package/lib/{schema → node/schema}/declarations/Declaration.d.ts +10 -11
- package/lib/{schema → node/schema}/declarations/Declaration.js +7 -5
- package/lib/{schema → node/schema}/declarations/EntityDecl.d.ts +10 -9
- package/lib/{schema → node/schema}/declarations/EntityDecl.js +2 -2
- package/lib/{schema → node/schema}/declarations/EnumDecl.d.ts +9 -7
- package/lib/{schema → node/schema}/declarations/EnumDecl.js +3 -3
- package/lib/{schema → node/schema}/declarations/TypeAliasDecl.d.ts +8 -7
- package/lib/{schema → node/schema}/declarations/TypeAliasDecl.js +3 -3
- package/lib/{schema → node/schema}/index.d.ts +4 -4
- package/lib/{schema → node/schema}/index.js +3 -4
- package/lib/node/schema/types/Type.d.ts +48 -0
- package/lib/{schema → node/schema}/types/Type.js +41 -25
- package/lib/{schema → node/schema}/types/generic/ArrayType.d.ts +5 -4
- package/lib/{schema → node/schema}/types/generic/ArrayType.js +3 -3
- package/lib/{schema → node/schema}/types/generic/EnumType.d.ts +5 -4
- package/lib/{schema → node/schema}/types/generic/EnumType.js +4 -2
- package/lib/{schema → node/schema}/types/generic/ObjectType.d.ts +8 -7
- package/lib/{schema → node/schema}/types/generic/ObjectType.js +8 -4
- package/lib/{schema → node/schema}/types/primitives/BooleanType.d.ts +4 -3
- package/lib/{schema → node/schema}/types/primitives/DateType.d.ts +5 -4
- package/lib/{schema → node/schema}/types/primitives/DateType.js +1 -1
- package/lib/{schema → node/schema}/types/primitives/FloatType.d.ts +5 -4
- package/lib/{schema → node/schema}/types/primitives/FloatType.js +1 -1
- package/lib/{schema → node/schema}/types/primitives/IntegerType.d.ts +5 -4
- package/lib/{schema → node/schema}/types/primitives/IntegerType.js +1 -1
- package/lib/{schema → node/schema}/types/primitives/NumericType.d.ts +2 -2
- package/lib/node/schema/types/primitives/PrimitiveType.d.ts +6 -0
- package/lib/{schema → node/schema}/types/primitives/StringType.d.ts +5 -4
- package/lib/{schema → node/schema}/types/primitives/StringType.js +1 -1
- package/lib/{schema → node/schema}/types/references/IncludeIdentifierType.d.ts +9 -8
- package/lib/{schema → node/schema}/types/references/IncludeIdentifierType.js +1 -1
- package/lib/{schema → node/schema}/types/references/NestedEntityMapType.d.ts +10 -9
- package/lib/{schema → node/schema}/types/references/NestedEntityMapType.js +4 -4
- package/lib/{schema → node/schema}/types/references/ReferenceIdentifierType.d.ts +7 -6
- package/lib/{schema → node/schema}/types/references/ReferenceIdentifierType.js +1 -1
- package/lib/node/schema/types/references/TypeArgumentType.d.ts +23 -0
- package/lib/node/schema/types/references/TypeArgumentType.js +19 -0
- package/lib/node/schema/validation/type.d.ts +4 -0
- package/lib/{server → node/server}/api/declarations.js +1 -1
- package/lib/{server → node/server}/api/git.js +14 -10
- package/lib/{server → node/server}/api/instanceOperations.d.ts +3 -3
- package/lib/{server → node/server}/api/instanceOperations.js +13 -4
- package/lib/{server → node/server}/api/instances.js +7 -3
- package/lib/node/server/index.d.ts +28 -0
- package/lib/{server → node/server}/index.js +6 -6
- package/lib/node/server/init.d.ts +5 -0
- package/lib/{server → node/server}/init.js +8 -8
- package/lib/{utils → node/utils}/error.js +4 -1
- package/lib/{utils → node/utils}/git.d.ts +2 -2
- package/lib/{utils → node/utils}/instances.d.ts +3 -3
- package/lib/{utils → node/utils}/instances.js +8 -6
- package/lib/{utils → node/utils}/references.d.ts +2 -2
- package/lib/{utils → node/utils}/references.js +3 -3
- package/lib/{utils → node/utils}/render.js +1 -1
- package/lib/shared/api.d.ts +8 -2
- package/lib/shared/utils/array.js +12 -9
- package/lib/shared/utils/displayName.d.ts +1 -1
- package/lib/shared/utils/displayName.js +4 -2
- package/lib/shared/utils/instances.d.ts +2 -2
- package/lib/{utils → shared/utils}/lazy.js +1 -1
- package/lib/shared/utils/markdown.js +6 -6
- package/lib/shared/utils/object.d.ts +3 -0
- package/lib/shared/utils/object.js +1 -0
- package/lib/{utils → shared/utils}/result.js +2 -2
- package/lib/shared/utils/string.js +7 -4
- package/lib/shared/utils/validation.js +3 -2
- package/lib/shared/validation/number.js +3 -3
- package/lib/shared/validation/object.js +4 -3
- package/lib/shared/validation/string.js +12 -7
- package/lib/{client → web}/api.d.ts +2 -2
- package/lib/{client → web}/api.js +4 -2
- package/lib/web/components/Git.d.ts +2 -0
- package/lib/{client → web}/components/Git.js +58 -14
- package/lib/{client → web}/components/Layout.d.ts +1 -1
- package/lib/{client → web}/components/Layout.js +1 -1
- package/lib/web/components/Select.d.ts +3 -0
- package/lib/web/components/Select.js +5 -0
- package/lib/web/components/typeInputs/ArrayTypeInput.d.ts +13 -0
- package/lib/{client → web}/components/typeInputs/ArrayTypeInput.js +7 -1
- package/lib/{client → web}/components/typeInputs/BooleanTypeInput.d.ts +2 -2
- package/lib/{client → web}/components/typeInputs/DateTypeInput.d.ts +2 -2
- package/lib/web/components/typeInputs/EnumTypeInput.d.ts +13 -0
- package/lib/{client → web}/components/typeInputs/EnumTypeInput.js +1 -1
- package/lib/{client → web}/components/typeInputs/FloatTypeInput.d.ts +2 -2
- package/lib/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +7 -0
- package/lib/{client → web}/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.js +1 -1
- package/lib/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +13 -0
- package/lib/{client → web}/components/typeInputs/IntegerTypeInput.d.ts +2 -2
- package/lib/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +13 -0
- package/lib/{client → web}/components/typeInputs/NestedEntityMapTypeInput.js +7 -2
- package/lib/{client → web}/components/typeInputs/ObjectTypeInput.d.ts +4 -4
- package/lib/{client → web}/components/typeInputs/ObjectTypeInput.js +4 -1
- package/lib/{client → web}/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -3
- package/lib/web/components/typeInputs/ReferenceIdentifierTypeInput.js +11 -0
- package/lib/{client → web}/components/typeInputs/StringTypeInput.d.ts +2 -2
- package/lib/web/components/typeInputs/TypeInput.d.ts +13 -0
- package/lib/{client → web}/components/typeInputs/TypeInput.js +3 -3
- package/lib/{client → web}/components/typeInputs/utils/Markdown.d.ts +1 -1
- package/lib/{client → web}/components/typeInputs/utils/Markdown.js +2 -2
- package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.d.ts +1 -1
- package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.d.ts +1 -1
- package/lib/web/hooks/useAPIResource.d.ts +1 -0
- package/lib/{client → web}/hooks/useEntityFromRoute.d.ts +1 -1
- package/lib/{client → web}/hooks/useEntityFromRoute.js +1 -1
- package/lib/{client → web}/hooks/useInstanceNamesByEntity.d.ts +1 -1
- package/lib/{client → web}/hooks/useInstanceNamesByEntity.js +8 -6
- package/lib/web/hooks/useMappedAPIResource.d.ts +1 -0
- package/lib/{client → web}/hooks/useMappedAPIResource.js +7 -9
- package/lib/{client → web}/hooks/useSecondaryDeclarations.d.ts +1 -1
- package/lib/{client → web}/hooks/useSecondaryDeclarations.js +4 -2
- package/lib/{client → web}/routes/CreateInstance.d.ts +1 -1
- package/lib/{client → web}/routes/CreateInstance.js +4 -2
- package/lib/web/routes/Entity.d.ts +2 -0
- package/lib/{client → web}/routes/Entity.js +5 -3
- package/lib/web/routes/Home.d.ts +2 -0
- package/lib/{client → web}/routes/Instance.d.ts +1 -1
- package/lib/{client → web}/routes/Instance.js +14 -8
- package/lib/{client → web}/routes/NotFound.d.ts +1 -1
- package/lib/web/utils/typeSkeleton.d.ts +3 -0
- package/lib/{client → web}/utils/typeSkeleton.js +4 -1
- package/package.json +31 -18
- package/lib/ModelContainer.d.ts +0 -17
- package/lib/ModelContainer.js +0 -65
- package/lib/client/components/Git.d.ts +0 -2
- package/lib/client/components/Select.d.ts +0 -3
- package/lib/client/components/Select.js +0 -2
- package/lib/client/components/typeInputs/ArrayTypeInput.d.ts +0 -13
- package/lib/client/components/typeInputs/EnumTypeInput.d.ts +0 -13
- package/lib/client/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +0 -7
- package/lib/client/components/typeInputs/IncludeIdentifierTypeInput.d.ts +0 -13
- package/lib/client/components/typeInputs/NestedEntityMapTypeInput.d.ts +0 -13
- package/lib/client/components/typeInputs/ReferenceIdentifierTypeInput.js +0 -9
- package/lib/client/components/typeInputs/TypeInput.d.ts +0 -13
- package/lib/client/hooks/useAPIResource.d.ts +0 -1
- package/lib/client/hooks/useMappedAPIResource.d.ts +0 -1
- package/lib/client/routes/Entity.d.ts +0 -2
- package/lib/client/routes/Home.d.ts +0 -2
- package/lib/client/utils/typeSkeleton.d.ts +0 -3
- package/lib/schema/types/Type.d.ts +0 -48
- package/lib/schema/types/primitives/PrimitiveType.d.ts +0 -6
- package/lib/schema/types/references/GenericArgumentIdentifierType.d.ts +0 -22
- package/lib/schema/types/references/GenericArgumentIdentifierType.js +0 -19
- package/lib/schema/validation/type.d.ts +0 -4
- package/lib/server/index.d.ts +0 -29
- package/lib/server/init.d.ts +0 -5
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/utils/object.d.ts +0 -3
- package/lib/utils/object.js +0 -1
- /package/lib/{renderers → node/renderers}/Output.js +0 -0
- /package/lib/{schema → node/schema}/types/primitives/BooleanType.js +0 -0
- /package/lib/{schema → node/schema}/types/primitives/NumericType.js +0 -0
- /package/lib/{schema → node/schema}/types/primitives/PrimitiveType.js +0 -0
- /package/lib/{schema → node/schema}/validation/options.d.ts +0 -0
- /package/lib/{schema → node/schema}/validation/options.js +0 -0
- /package/lib/{schema → node/schema}/validation/type.js +0 -0
- /package/lib/{server → node/server}/api/declarations.d.ts +0 -0
- /package/lib/{server → node/server}/api/git.d.ts +0 -0
- /package/lib/{server → node/server}/api/index.d.ts +0 -0
- /package/lib/{server → node/server}/api/index.js +0 -0
- /package/lib/{server → node/server}/api/instances.d.ts +0 -0
- /package/lib/{utils → node/utils}/error.d.ts +0 -0
- /package/lib/{utils → node/utils}/git.js +0 -0
- /package/lib/{utils → node/utils}/path.d.ts +0 -0
- /package/lib/{utils → node/utils}/path.js +0 -0
- /package/lib/{utils → node/utils}/render.d.ts +0 -0
- /package/lib/{utils → shared/utils}/enum.d.ts +0 -0
- /package/lib/{utils → shared/utils}/enum.js +0 -0
- /package/lib/{utils → shared/utils}/lazy.d.ts +0 -0
- /package/lib/{utils → shared/utils}/result.d.ts +0 -0
- /package/lib/{client → web}/components/typeInputs/BooleanTypeInput.js +0 -0
- /package/lib/{client → web}/components/typeInputs/DateTypeInput.js +0 -0
- /package/lib/{client → web}/components/typeInputs/FloatTypeInput.js +0 -0
- /package/lib/{client → web}/components/typeInputs/IncludeIdentifierTypeInput.js +0 -0
- /package/lib/{client → web}/components/typeInputs/IntegerTypeInput.js +0 -0
- /package/lib/{client → web}/components/typeInputs/StringTypeInput.js +0 -0
- /package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.js +0 -0
- /package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.js +0 -0
- /package/lib/{client → web}/hooks/useAPIResource.js +0 -0
- /package/lib/{client → web}/index.d.ts +0 -0
- /package/lib/{client → web}/index.js +0 -0
- /package/lib/{client → web}/routes/Home.js +0 -0
- /package/lib/{client → web}/routes/NotFound.js +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { parallelizeErrors } from "../utils/validation.js";
|
|
2
2
|
export const validateStringConstraints = (constraints, value) => parallelizeErrors([
|
|
3
3
|
constraints.minLength !== undefined && value.length < constraints.minLength
|
|
4
|
-
? RangeError(`expected a string with at least ${constraints.minLength} character${constraints.minLength === 1 ? "" : "s"}, but got ${value.length} character${value.length === 1 ? "" : "s"}`)
|
|
4
|
+
? RangeError(`expected a string with at least ${constraints.minLength.toString()} character${constraints.minLength === 1 ? "" : "s"}, but got ${value.length.toString()} character${value.length === 1 ? "" : "s"}`)
|
|
5
5
|
: undefined,
|
|
6
6
|
constraints.maxLength !== undefined && value.length > constraints.maxLength
|
|
7
|
-
? RangeError(`expected a string with at most ${constraints.maxLength} character${constraints.maxLength === 1 ? "" : "s"}, but got ${value.length} character${value.length === 1 ? "" : "s"}`)
|
|
7
|
+
? RangeError(`expected a string with at most ${constraints.maxLength.toString()} character${constraints.maxLength === 1 ? "" : "s"}, but got ${value.length.toString()} character${value.length === 1 ? "" : "s"}`)
|
|
8
8
|
: undefined,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
(() => {
|
|
10
|
+
if (constraints.pattern === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const pattern = typeof constraints.pattern === "string"
|
|
11
14
|
? new RegExp(constraints.pattern)
|
|
12
|
-
: constraints.pattern
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
: constraints.pattern;
|
|
16
|
+
return !pattern.test(value)
|
|
17
|
+
? TypeError(`string does not match the pattern ${pattern.toString()}`)
|
|
18
|
+
: undefined;
|
|
19
|
+
})(),
|
|
15
20
|
]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SerializedEntityDecl } from "../schema/declarations/EntityDecl.js";
|
|
2
|
-
import { CreateInstanceOfEntityResponseBody, DeleteInstanceOfEntityResponseBody, GetAllDeclarationsResponseBody, GetAllGitBranchesResponseBody, GetAllInstancesOfEntityResponseBody, GetAllInstancesResponseBody, GetDeclarationResponseBody, GetInstanceOfEntityResponseBody, GitStatusResponseBody, UpdateInstanceOfEntityResponseBody } from "../shared/api.js";
|
|
1
|
+
import type { SerializedEntityDecl } from "../node/schema/declarations/EntityDecl.js";
|
|
2
|
+
import type { CreateInstanceOfEntityResponseBody, DeleteInstanceOfEntityResponseBody, GetAllDeclarationsResponseBody, GetAllGitBranchesResponseBody, GetAllInstancesOfEntityResponseBody, GetAllInstancesResponseBody, GetDeclarationResponseBody, GetInstanceOfEntityResponseBody, GitStatusResponseBody, UpdateInstanceOfEntityResponseBody } from "../shared/api.js";
|
|
3
3
|
export declare const getAllDeclarations: (kind?: "Entity" | "Enum" | "TypeAlias") => Promise<GetAllDeclarationsResponseBody>;
|
|
4
4
|
export declare const getAllEntities: () => Promise<GetAllDeclarationsResponseBody<SerializedEntityDecl>>;
|
|
5
5
|
export declare const getEntityByName: (name: string) => Promise<GetDeclarationResponseBody<SerializedEntityDecl>>;
|
|
@@ -141,9 +141,10 @@ export const unstageFileOfEntity = async (entityName, id) => {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
export const commitStagedFiles = async (message) => {
|
|
144
|
+
const body = { message };
|
|
144
145
|
const response = await fetch(`/api/git/commit`, {
|
|
145
146
|
method: "POST",
|
|
146
|
-
body: JSON.stringify(
|
|
147
|
+
body: JSON.stringify(body),
|
|
147
148
|
headers: {
|
|
148
149
|
"Content-Type": "application/json",
|
|
149
150
|
},
|
|
@@ -181,9 +182,10 @@ export const getBranches = async () => {
|
|
|
181
182
|
return response.json();
|
|
182
183
|
};
|
|
183
184
|
export const createBranch = async (branchName) => {
|
|
185
|
+
const body = { branchName };
|
|
184
186
|
const response = await fetch(`/api/git/branch`, {
|
|
185
187
|
method: "POST",
|
|
186
|
-
body: JSON.stringify(
|
|
188
|
+
body: JSON.stringify(body),
|
|
187
189
|
headers: {
|
|
188
190
|
"Content-Type": "application/json",
|
|
189
191
|
},
|
|
@@ -14,7 +14,7 @@ const filterFilesForDisplay = (predicate, entities, data) => Object.entries(data
|
|
|
14
14
|
.sort((a, b) => a[1].localeCompare(b[1]));
|
|
15
15
|
const GitFileList = ({ filesByEntity, onFile, isIndex = false }) => filesByEntity.length === 0 ? (_jsx("p", { class: "no-changes", children: "No changes" })) : (_jsx("ul", { class: "git-entity-list", children: filesByEntity.map(([entityName, entityNamePlural, instances]) => (_jsxs("li", { class: "git-entity-list-item", children: [_jsx("span", { class: "title", children: entityNamePlural }), _jsx("ul", { class: "git-instance-list", children: instances.map(instance => {
|
|
16
16
|
const gitStatusForDisplay = getGitStatusForDisplay(instance.gitStatus);
|
|
17
|
-
return (_jsxs("li", { class: "git-instance-list-item", children: [_jsx("span", { class: "title", children: instance.displayName }), _jsx("span", { class: `git-status git-status--${gitStatusForDisplay}`, title: getLabelForGitStatus(gitStatusForDisplay), children: gitStatusForDisplay }), _jsx("button", { onClick: () => {
|
|
17
|
+
return (_jsxs("li", { class: "git-instance-list-item", children: [_jsx("span", { class: "title", children: instance.displayName }), _jsx("span", { class: `git-status git-status--${gitStatusForDisplay ?? ""}`, title: getLabelForGitStatus(gitStatusForDisplay), children: gitStatusForDisplay }), _jsx("button", { onClick: () => {
|
|
18
18
|
onFile(entityName, instance);
|
|
19
19
|
}, children: isIndex ? "Unstage" : "Stage" })] }, instance.fileName));
|
|
20
20
|
}) })] }, entityName))) }));
|
|
@@ -37,31 +37,67 @@ export const Git = () => {
|
|
|
37
37
|
setCurrentBranch(branchesData.currentBranch);
|
|
38
38
|
});
|
|
39
39
|
useEffect(() => {
|
|
40
|
-
getAllEntities()
|
|
40
|
+
getAllEntities()
|
|
41
|
+
.then(async (data) => {
|
|
41
42
|
const entitiesFromServer = data.declarations.map(decl => decl.declaration);
|
|
42
43
|
setEntities(entitiesFromServer);
|
|
43
44
|
return updateGitStatus(entitiesFromServer);
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
console.error("Error fetching entities:", error.toString());
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
}, []);
|
|
46
52
|
const stage = (entityName, instance) => {
|
|
47
|
-
stageFileOfEntity(entityName, instance.id)
|
|
53
|
+
stageFileOfEntity(entityName, instance.id)
|
|
54
|
+
.then(() => updateGitStatus(entities))
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
if (error instanceof Error) {
|
|
57
|
+
console.error("Error staging instance:", error.toString());
|
|
58
|
+
}
|
|
59
|
+
});
|
|
48
60
|
};
|
|
49
61
|
const stageAll = () => {
|
|
50
|
-
stageAllFiles()
|
|
62
|
+
stageAllFiles()
|
|
63
|
+
.then(() => updateGitStatus(entities))
|
|
64
|
+
.catch((error) => {
|
|
65
|
+
if (error instanceof Error) {
|
|
66
|
+
console.error("Error staging all instances:", error.toString());
|
|
67
|
+
}
|
|
68
|
+
});
|
|
51
69
|
};
|
|
52
70
|
const unstage = (entityName, instance) => {
|
|
53
|
-
unstageFileOfEntity(entityName, instance.id)
|
|
71
|
+
unstageFileOfEntity(entityName, instance.id)
|
|
72
|
+
.then(() => updateGitStatus(entities))
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
if (error instanceof Error) {
|
|
75
|
+
console.error("Error unstaging instance:", error.toString());
|
|
76
|
+
}
|
|
77
|
+
});
|
|
54
78
|
};
|
|
55
79
|
const unstageAll = () => {
|
|
56
|
-
unstageAllFiles()
|
|
80
|
+
unstageAllFiles()
|
|
81
|
+
.then(() => updateGitStatus(entities))
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
if (error instanceof Error) {
|
|
84
|
+
console.error("Error unstaging all instances:", error.toString());
|
|
85
|
+
}
|
|
86
|
+
});
|
|
57
87
|
};
|
|
58
88
|
const commit = () => {
|
|
59
89
|
if (commitMessage.length > 0 &&
|
|
60
90
|
indexFiles.length > 0 &&
|
|
61
91
|
confirm("Do you want to commit all staged files?")) {
|
|
62
|
-
commitStagedFiles(commitMessage)
|
|
92
|
+
commitStagedFiles(commitMessage)
|
|
93
|
+
.then(() => {
|
|
63
94
|
setCommitMessage("");
|
|
64
95
|
return updateGitStatus(entities);
|
|
96
|
+
})
|
|
97
|
+
.catch((error) => {
|
|
98
|
+
if (error instanceof Error) {
|
|
99
|
+
console.error("Error committing instances:", error.toString());
|
|
100
|
+
}
|
|
65
101
|
});
|
|
66
102
|
}
|
|
67
103
|
};
|
|
@@ -71,7 +107,7 @@ export const Git = () => {
|
|
|
71
107
|
alert("Pushed commits successfully");
|
|
72
108
|
return updateGitStatus(entities);
|
|
73
109
|
})
|
|
74
|
-
.catch(error => {
|
|
110
|
+
.catch((error) => {
|
|
75
111
|
console.error("Error pushing commits:", error);
|
|
76
112
|
});
|
|
77
113
|
};
|
|
@@ -81,7 +117,7 @@ export const Git = () => {
|
|
|
81
117
|
alert("Pulled commits successfully");
|
|
82
118
|
return updateGitStatus(entities);
|
|
83
119
|
})
|
|
84
|
-
.catch(error => {
|
|
120
|
+
.catch((error) => {
|
|
85
121
|
console.error("Error pulling commits:", error);
|
|
86
122
|
});
|
|
87
123
|
};
|
|
@@ -99,8 +135,10 @@ export const Git = () => {
|
|
|
99
135
|
.then(() => {
|
|
100
136
|
return updateGitStatus(entities);
|
|
101
137
|
})
|
|
102
|
-
.catch(error => {
|
|
103
|
-
|
|
138
|
+
.catch((error) => {
|
|
139
|
+
if (error instanceof Error) {
|
|
140
|
+
alert("Error switching branch:" + error.toString());
|
|
141
|
+
}
|
|
104
142
|
});
|
|
105
143
|
};
|
|
106
144
|
const onSwitchBranch = (event) => {
|
|
@@ -108,9 +146,15 @@ export const Git = () => {
|
|
|
108
146
|
.then(() => {
|
|
109
147
|
return updateGitStatus(entities);
|
|
110
148
|
})
|
|
111
|
-
.catch(error => {
|
|
112
|
-
|
|
149
|
+
.catch((error) => {
|
|
150
|
+
if (error instanceof Error) {
|
|
151
|
+
alert("Error switching branch: " + error.toString());
|
|
152
|
+
}
|
|
113
153
|
});
|
|
114
154
|
};
|
|
115
|
-
return (_jsxs("aside", { class: "git", children: [_jsx("h2", { class: "h1-faded", children: "Version Control" }), _jsx("button", { onClick: () =>
|
|
155
|
+
return (_jsxs("aside", { class: "git", children: [_jsx("h2", { class: "h1-faded", children: "Version Control" }), _jsx("button", { onClick: () => {
|
|
156
|
+
setIsOpen(b => !b);
|
|
157
|
+
}, children: "File changes" }), _jsxs("div", { className: `git-overlay ${isOpen ? "git-overlay--open" : ""}`, children: [_jsxs("div", { class: "sync", children: [_jsxs("button", { onClick: push, children: ["Push", commitsAhead > 0 ? ` (${commitsAhead.toString()})` : ""] }), _jsxs("button", { onClick: pull, children: ["Pull", commitsBehind > 0 ? ` (${commitsBehind.toString()})` : ""] })] }), _jsxs("div", { className: "branch", children: [_jsx("div", { className: "select-wrapper", children: _jsx("select", { value: currentBranch, onInput: onSwitchBranch, children: allBranches.map(branch => (_jsx("option", { value: branch, children: branch }, branch))) }) }), _jsx("button", { onClick: onCreateBranch, children: "New branch" })] }), _jsxs("div", { class: "commit", children: [_jsx("input", { type: "text", value: commitMessage, onInput: event => {
|
|
158
|
+
setCommitMessage(event.currentTarget.value);
|
|
159
|
+
}, placeholder: "added X to instance Y, \u2026" }), _jsx("button", { onClick: commit, disabled: commitMessage.length === 0 || indexFiles.length === 0, children: "Commit" })] }), _jsxs("div", { className: "git-section-title", children: [_jsx("h3", { children: "Files to be committed" }), _jsx("button", { onClick: unstageAll, children: "Unstage all" })] }), _jsx(GitFileList, { filesByEntity: indexFiles, isIndex: true, onFile: unstage }), _jsxs("div", { className: "git-section-title", children: [_jsx("h3", { children: "Working tree changes" }), _jsx("button", { onClick: stageAll, children: "Stage all" })] }), _jsx(GitFileList, { filesByEntity: workingTreeFiles, onFile: stage })] })] }));
|
|
116
160
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
2
|
import { Git } from "./Git.js";
|
|
3
3
|
export const Layout = ({ breadcrumbs, children }) => {
|
|
4
|
-
return (_jsxs(_Fragment, { children: [_jsx("header", { children: _jsx("nav", { children: _jsx("ol", { children: breadcrumbs.map(({ url, label }) => (_jsx("li", { children: _jsx("a", { href: url, children: label }) }))) }) }) }), _jsx(Git, {}), _jsx("main", { children: children })] }));
|
|
4
|
+
return (_jsxs(_Fragment, { children: [_jsx("header", { children: _jsx("nav", { children: _jsx("ol", { children: breadcrumbs.map(({ url, label }) => (_jsx("li", { children: _jsx("a", { href: url, children: label }) }, url))) }) }) }), _jsx(Git, {}), _jsx("main", { children: children })] }));
|
|
5
5
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
const isNullableString = (value) => {
|
|
3
|
+
return typeof value === "string" || value === undefined;
|
|
4
|
+
};
|
|
5
|
+
export const Select = props => (_jsx("div", { class: "select-wrapper", children: _jsx("select", { ...props, class: `${(isNullableString(props.class) ? props.class : props.class.value) ?? ""} ${(isNullableString(props.className) ? props.className : props.className.value) ?? ""} ${!props.value ? "no-selection" : ""}` }) }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FunctionComponent } from "preact";
|
|
2
|
+
import type { SerializedArrayType } from "../../../node/schema/types/generic/ArrayType.js";
|
|
3
|
+
import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
|
|
4
|
+
import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.js";
|
|
5
|
+
type Props = {
|
|
6
|
+
type: SerializedArrayType;
|
|
7
|
+
value: unknown[];
|
|
8
|
+
instanceNamesByEntity: InstanceNamesByEntity;
|
|
9
|
+
getDeclFromDeclName: GetDeclFromDeclName;
|
|
10
|
+
onChange: (value: unknown[]) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const ArrayTypeInput: FunctionComponent<Props>;
|
|
13
|
+
export {};
|
|
@@ -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: () =>
|
|
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
|
|
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]
|
|
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 =>
|
|
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 =>
|
|
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 {
|
|
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 "
|
|
68
|
-
return _jsx(
|
|
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,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
-
import { parseBlockMarkdown
|
|
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) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAPIResource: <T, A extends unknown[]>(apiFn: (...args: A) => Promise<T>, ...args: A) => [T | undefined, () => Promise<void>];
|
|
@@ -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;
|
|
@@ -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
|
-
|
|
10
|
+
.catch((error) => {
|
|
11
|
+
if (error instanceof Error) {
|
|
12
|
+
console.error("Error fetching data:", error.toString());
|
|
13
|
+
}
|
|
12
14
|
});
|
|
13
|
-
};
|
|
15
|
+
}, [locales]);
|
|
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>];
|