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,19 +1,17 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from "preact/hooks";
|
|
2
2
|
export const useMappedAPIResource = (apiFn, mapFn, ...args) => {
|
|
3
3
|
const [data, setData] = useState();
|
|
4
|
-
const fetchData = () => apiFn(...args)
|
|
5
|
-
.then(result => {
|
|
4
|
+
const fetchData = useCallback(() => apiFn(...args).then(result => {
|
|
6
5
|
setData(mapFn(result));
|
|
7
|
-
})
|
|
8
|
-
.catch(err => {
|
|
9
|
-
console.log(err);
|
|
10
|
-
});
|
|
6
|
+
}), [apiFn, args, mapFn]);
|
|
11
7
|
useEffect(() => {
|
|
12
|
-
fetchData()
|
|
13
|
-
|
|
8
|
+
fetchData().catch((err) => {
|
|
9
|
+
console.log(err);
|
|
10
|
+
});
|
|
11
|
+
}, [fetchData]);
|
|
14
12
|
const reload = useCallback(() => {
|
|
15
13
|
setData(undefined);
|
|
16
14
|
return fetchData();
|
|
17
|
-
}, [
|
|
15
|
+
}, [fetchData]);
|
|
18
16
|
return [data, reload];
|
|
19
17
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SerializedSecondaryDecl } from "../../schema/declarations/Declaration.js";
|
|
1
|
+
import type { SerializedSecondaryDecl } from "../../node/schema/declarations/Declaration.js";
|
|
2
2
|
export type GetDeclFromDeclName = (name: string) => SerializedSecondaryDecl | undefined;
|
|
3
3
|
export declare const useGetDeclFromDeclName: () => GetDeclFromDeclName;
|
|
@@ -9,8 +9,10 @@ export const useGetDeclFromDeclName = () => {
|
|
|
9
9
|
.map(decl => decl.declaration)
|
|
10
10
|
.filter((decl) => decl.kind === "EnumDecl" || decl.kind === "TypeAliasDecl"));
|
|
11
11
|
})
|
|
12
|
-
.catch(error => {
|
|
13
|
-
|
|
12
|
+
.catch((error) => {
|
|
13
|
+
if (error instanceof Error) {
|
|
14
|
+
console.error("Error fetching data:", error.toString());
|
|
15
|
+
}
|
|
14
16
|
});
|
|
15
17
|
}, []);
|
|
16
18
|
const getDeclFromDeclName = useCallback((name) => secondaryDeclarations.find(decl => decl.name === name), [secondaryDeclarations]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FunctionalComponent } from "preact";
|
|
1
|
+
import type { FunctionalComponent } from "preact";
|
|
2
2
|
export declare const CreateInstance: FunctionalComponent;
|
|
@@ -48,8 +48,10 @@ export const CreateInstance = () => {
|
|
|
48
48
|
route(`/entities/${entity.name}?created=${encodeURIComponent(createdInstance.instance.id)}`);
|
|
49
49
|
}
|
|
50
50
|
})
|
|
51
|
-
.catch(error => {
|
|
52
|
-
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
if (error instanceof Error) {
|
|
53
|
+
alert(`Error creating instance:\n\n${error.toString()}`);
|
|
54
|
+
}
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
};
|
|
@@ -19,7 +19,7 @@ export const Entity = () => {
|
|
|
19
19
|
instanceElement.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
}, []);
|
|
22
|
+
}, [created]);
|
|
23
23
|
if (!name) {
|
|
24
24
|
return _jsx(NotFound, {});
|
|
25
25
|
}
|
|
@@ -32,8 +32,10 @@ export const Entity = () => {
|
|
|
32
32
|
if (confirm("Are you sure you want to delete this instance?")) {
|
|
33
33
|
deleteInstanceByEntityNameAndId(entity.declaration.name, instance.id)
|
|
34
34
|
.then(() => reloadInstances())
|
|
35
|
-
.catch(error => {
|
|
36
|
-
|
|
35
|
+
.catch((error) => {
|
|
36
|
+
if (error instanceof Error) {
|
|
37
|
+
alert("Error deleting instance:\n\n" + error.toString());
|
|
38
|
+
}
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
}, children: "Delete" })] })] }, instance.id));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FunctionalComponent } from "preact";
|
|
1
|
+
import type { FunctionalComponent } from "preact";
|
|
2
2
|
export declare const Instance: FunctionalComponent;
|
|
@@ -26,22 +26,23 @@ export const Instance = () => {
|
|
|
26
26
|
setInstance(instanceData.instance);
|
|
27
27
|
setOriginalInstance(instanceData.instance);
|
|
28
28
|
})
|
|
29
|
-
.catch(error => {
|
|
29
|
+
.catch((error) => {
|
|
30
30
|
console.error("Error fetching entities:", error);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
}, []);
|
|
33
|
+
}, [id, name]);
|
|
34
34
|
const handleSubmit = (event) => {
|
|
35
35
|
event.preventDefault();
|
|
36
36
|
if (name && id && instance) {
|
|
37
37
|
updateInstanceByEntityNameAndId(name, id, instance.content)
|
|
38
38
|
.then(updatedInstance => {
|
|
39
|
-
0;
|
|
40
39
|
setInstance(updatedInstance.instance);
|
|
41
40
|
setOriginalInstance(updatedInstance.instance);
|
|
42
41
|
})
|
|
43
|
-
.catch(error => {
|
|
44
|
-
|
|
42
|
+
.catch((error) => {
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
alert(`Error updating instance:\n\n${error}`);
|
|
45
|
+
}
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
};
|
|
@@ -65,9 +66,14 @@ export const Instance = () => {
|
|
|
65
66
|
.then(() => {
|
|
66
67
|
route(`/entities/${name}`);
|
|
67
68
|
})
|
|
68
|
-
.catch(error => {
|
|
69
|
-
|
|
69
|
+
.catch((error) => {
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
alert("Error deleting instance:\n\n" + error.toString());
|
|
72
|
+
}
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
|
-
}, children: "Delete" })] }), _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TypeInput, { type: entityFromRoute.entity.type, value: instance.content, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: value =>
|
|
75
|
+
}, children: "Delete" })] }), _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TypeInput, { type: entityFromRoute.entity.type, value: instance.content, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: value => {
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
77
|
+
setInstance(container => ({ ...container, content: value }));
|
|
78
|
+
} }), _jsx("button", { type: "submit", disabled: !hasChanges, class: "primary", children: "Save" })] })] }));
|
|
73
79
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FunctionalComponent } from "preact";
|
|
1
|
+
import type { FunctionalComponent } from "preact";
|
|
2
2
|
export declare const NotFound: FunctionalComponent;
|
|
@@ -17,7 +17,7 @@ export const createTypeSkeleton = (getDeclFromDeclName, type) => {
|
|
|
17
17
|
return Object.fromEntries(Object.entries(type.properties).flatMap(([key, memberDecl]) => memberDecl.isRequired
|
|
18
18
|
? [[key, createTypeSkeleton(getDeclFromDeclName, memberDecl.type)]]
|
|
19
19
|
: []));
|
|
20
|
-
case "
|
|
20
|
+
case "TypeArgumentType":
|
|
21
21
|
return undefined;
|
|
22
22
|
case "ReferenceIdentifierType":
|
|
23
23
|
return "";
|
|
@@ -32,6 +32,9 @@ export const createTypeSkeleton = (getDeclFromDeclName, type) => {
|
|
|
32
32
|
return {};
|
|
33
33
|
case "EnumType": {
|
|
34
34
|
const firstCase = Object.entries(type.values)[0];
|
|
35
|
+
if (firstCase === undefined) {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
35
38
|
return {
|
|
36
39
|
kind: firstCase[0],
|
|
37
40
|
...(firstCase[1].type === null
|
package/package.json
CHANGED
|
@@ -1,44 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsondb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Lukas Obermann",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"files": [
|
|
9
|
-
"lib",
|
|
9
|
+
"lib/**/*.d.ts",
|
|
10
|
+
"lib/**/*.js",
|
|
10
11
|
"public"
|
|
11
12
|
],
|
|
13
|
+
"bin": {
|
|
14
|
+
"tsondb": "lib/bin/tsondb.js"
|
|
15
|
+
},
|
|
12
16
|
"main": "lib/index.js",
|
|
13
17
|
"exports": {
|
|
14
18
|
".": "./lib/index.js",
|
|
15
|
-
"./renderer/jsonschema": "./lib/renderers/jsonschema/index.js",
|
|
16
|
-
"./renderer/ts": "./lib/renderers/ts/index.js",
|
|
17
|
-
"./
|
|
18
|
-
"./schema": "./lib/
|
|
19
|
-
"./schema/def": "./lib/schema/index.js"
|
|
19
|
+
"./renderer/jsonschema": "./lib/node/renderers/jsonschema/index.js",
|
|
20
|
+
"./renderer/ts": "./lib/node/renderers/ts/index.js",
|
|
21
|
+
"./schema": "./lib/node/Schema.js",
|
|
22
|
+
"./schema/def": "./lib/node/schema/index.js"
|
|
20
23
|
},
|
|
21
24
|
"scripts": {
|
|
22
25
|
"build": "tsc -b",
|
|
23
26
|
"watch": "tsc -b -w",
|
|
24
|
-
"test": "
|
|
27
|
+
"test": "node --import tsx --test",
|
|
28
|
+
"lint": "eslint",
|
|
29
|
+
"check-format": "prettier \"{src,test}/**/*.{ts,tsx}\" --check",
|
|
30
|
+
"format": "prettier \"{src,test}/**/*.{ts,tsx}\" --write",
|
|
25
31
|
"release": "commit-and-tag-version"
|
|
26
32
|
},
|
|
27
33
|
"devDependencies": {
|
|
34
|
+
"@eslint/js": "^9.30.1",
|
|
28
35
|
"@types/debug": "^4.1.12",
|
|
29
|
-
"@types/express": "^5.0.
|
|
30
|
-
"@types/node": "^
|
|
36
|
+
"@types/express": "^5.0.3",
|
|
37
|
+
"@types/node": "^24.0.12",
|
|
31
38
|
"commit-and-tag-version": "^12.5.1",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
39
|
+
"eslint": "^9.30.1",
|
|
40
|
+
"eslint-plugin-react": "^7.37.5",
|
|
41
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
42
|
+
"globals": "^16.3.0",
|
|
43
|
+
"prettier": "^3.6.2",
|
|
44
|
+
"tsx": "^4.20.3",
|
|
45
|
+
"typescript": "^5.8.3",
|
|
46
|
+
"typescript-eslint": "^8.36.0"
|
|
35
47
|
},
|
|
36
48
|
"dependencies": {
|
|
37
|
-
"debug": "^4.4.
|
|
49
|
+
"debug": "^4.4.1",
|
|
38
50
|
"express": "^5.1.0",
|
|
39
|
-
"preact": "^10.26.
|
|
40
|
-
"preact-iso": "^2.9.
|
|
41
|
-
"simple-
|
|
51
|
+
"preact": "^10.26.9",
|
|
52
|
+
"preact-iso": "^2.9.2",
|
|
53
|
+
"simple-cli-args": "^0.1.0",
|
|
54
|
+
"simple-git": "^3.28.0",
|
|
42
55
|
"supports-color": "^10.0.0",
|
|
43
56
|
"uuid": "^11.1.0"
|
|
44
57
|
},
|
|
@@ -47,6 +60,6 @@
|
|
|
47
60
|
"url": "https://github.com/elyukai/tsondb/issues"
|
|
48
61
|
},
|
|
49
62
|
"engines": {
|
|
50
|
-
"node": ">=
|
|
63
|
+
"node": ">=23.6.0"
|
|
51
64
|
}
|
|
52
65
|
}
|
package/lib/ModelContainer.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Output } from "./renderers/Output.js";
|
|
2
|
-
import { Schema } from "./Schema.js";
|
|
3
|
-
export interface ModelContainer {
|
|
4
|
-
schema: Schema;
|
|
5
|
-
outputs: Output[];
|
|
6
|
-
dataRootPath: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const ModelContainer: (options: {
|
|
9
|
-
schema: Schema;
|
|
10
|
-
outputs: Output[];
|
|
11
|
-
dataRootPath: string;
|
|
12
|
-
}) => ModelContainer;
|
|
13
|
-
export declare const generateOutputs: (modelContainer: ModelContainer) => Promise<void>;
|
|
14
|
-
export declare const validate: (modelContainer: ModelContainer) => Promise<void>;
|
|
15
|
-
export declare const generateAndValidate: (modelContainer: ModelContainer) => Promise<void>;
|
|
16
|
-
export declare const serve: (modelContainer: ModelContainer) => Promise<void>;
|
|
17
|
-
export declare const generateValidateAndServe: (modelContainer: ModelContainer) => Promise<void>;
|
package/lib/ModelContainer.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import Debug from "debug";
|
|
2
|
-
import { mkdir } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { getEntities } from "./Schema.js";
|
|
5
|
-
import { createValidators, validateEntityDecl } from "./schema/index.js";
|
|
6
|
-
import { createServer } from "./server/index.js";
|
|
7
|
-
import { parallelizeErrors } from "./shared/utils/validation.js";
|
|
8
|
-
import { getErrorMessageForDisplay, wrapErrorsIfAny } from "./utils/error.js";
|
|
9
|
-
import { getInstancesByEntityName } from "./utils/instances.js";
|
|
10
|
-
const debug = Debug("tsondb:schema");
|
|
11
|
-
export const ModelContainer = (options) => ({
|
|
12
|
-
...options,
|
|
13
|
-
});
|
|
14
|
-
const prepareFolders = async (modelContainer, entities) => {
|
|
15
|
-
await mkdir(modelContainer.dataRootPath, { recursive: true });
|
|
16
|
-
for (const entity of entities) {
|
|
17
|
-
const entityDir = join(modelContainer.dataRootPath, entity.name);
|
|
18
|
-
await mkdir(entityDir, { recursive: true });
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const generateOutputs = async (modelContainer) => {
|
|
22
|
-
for (const output of modelContainer.outputs) {
|
|
23
|
-
await output.run(modelContainer.schema);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const _validate = async (entities, instancesByEntityName) => {
|
|
27
|
-
const errors = entities.flatMap(entity => parallelizeErrors(instancesByEntityName[entity.name].map(instance => wrapErrorsIfAny(`in file "${entity.name}/${instance.fileName}"`, validateEntityDecl(createValidators(instancesByEntityName), entity, instance.content)))));
|
|
28
|
-
if (errors.length === 0) {
|
|
29
|
-
debug("All entities are valid");
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
debug("Errors:\n");
|
|
33
|
-
for (const error of errors) {
|
|
34
|
-
debug(getErrorMessageForDisplay(error) + "\n");
|
|
35
|
-
}
|
|
36
|
-
throw new Error("Validation failed");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
export const validate = async (modelContainer) => {
|
|
40
|
-
const entities = getEntities(modelContainer.schema);
|
|
41
|
-
await prepareFolders(modelContainer, entities);
|
|
42
|
-
const instancesByEntityName = await getInstancesByEntityName(modelContainer.dataRootPath, entities);
|
|
43
|
-
return _validate(entities, instancesByEntityName);
|
|
44
|
-
};
|
|
45
|
-
export const generateAndValidate = async (modelContainer) => {
|
|
46
|
-
await generateOutputs(modelContainer);
|
|
47
|
-
const entities = getEntities(modelContainer.schema);
|
|
48
|
-
await prepareFolders(modelContainer, entities);
|
|
49
|
-
const instancesByEntityName = await getInstancesByEntityName(modelContainer.dataRootPath, entities);
|
|
50
|
-
await _validate(entities, instancesByEntityName);
|
|
51
|
-
};
|
|
52
|
-
export const serve = async (modelContainer) => {
|
|
53
|
-
const entities = getEntities(modelContainer.schema);
|
|
54
|
-
await prepareFolders(modelContainer, entities);
|
|
55
|
-
const instancesByEntityName = await getInstancesByEntityName(modelContainer.dataRootPath, entities);
|
|
56
|
-
createServer(modelContainer, instancesByEntityName);
|
|
57
|
-
};
|
|
58
|
-
export const generateValidateAndServe = async (modelContainer) => {
|
|
59
|
-
await generateOutputs(modelContainer);
|
|
60
|
-
const entities = getEntities(modelContainer.schema);
|
|
61
|
-
await prepareFolders(modelContainer, entities);
|
|
62
|
-
const instancesByEntityName = await getInstancesByEntityName(modelContainer.dataRootPath, entities);
|
|
63
|
-
await _validate(entities, instancesByEntityName);
|
|
64
|
-
createServer(modelContainer, instancesByEntityName);
|
|
65
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "preact";
|
|
2
|
-
import { SerializedArrayType } from "../../../schema/types/generic/ArrayType.js";
|
|
3
|
-
import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
|
|
4
|
-
import { 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 {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "preact";
|
|
2
|
-
import { SerializedEnumType } from "../../../schema/types/generic/EnumType.js";
|
|
3
|
-
import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
|
|
4
|
-
import { 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 {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "preact";
|
|
2
|
-
import { SerializedGenericArgumentIdentifierType } from "../../../schema/types/references/GenericArgumentIdentifierType.js";
|
|
3
|
-
type Props = {
|
|
4
|
-
type: SerializedGenericArgumentIdentifierType;
|
|
5
|
-
};
|
|
6
|
-
export declare const GenericArgumentIdentifierTypeInput: FunctionComponent<Props>;
|
|
7
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "preact";
|
|
2
|
-
import { SerializedIncludeIdentifierType } from "../../../schema/index.js";
|
|
3
|
-
import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
|
|
4
|
-
import { 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,13 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "preact";
|
|
2
|
-
import { SerializedNestedEntityMapType } from "../../../schema/types/references/NestedEntityMapType.js";
|
|
3
|
-
import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
|
|
4
|
-
import { 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 {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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 => onChange(event.currentTarget.value), 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 })))] }), _jsx(ValidationErrors, { errors: !value ? [ReferenceError("no reference provided")] : [] })] }));
|
|
9
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "preact";
|
|
2
|
-
import { SerializedType } from "../../../schema/types/Type.js";
|
|
3
|
-
import { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.js";
|
|
4
|
-
import { 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 {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useAPIResource: <T, A extends any[]>(apiFn: (...args: A) => Promise<T>, ...args: A) => [T | undefined, () => Promise<void>];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useMappedAPIResource: <T, A extends any[], U>(apiFn: (...args: A) => Promise<T>, mapFn: (data: T) => U, ...args: A) => [U | undefined, () => Promise<void>];
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Decl } from "../declarations/Declaration.js";
|
|
2
|
-
import { BaseNode, GetReferences, Serializer } from "../Node.js";
|
|
3
|
-
import { Validator } from "../validation/type.js";
|
|
4
|
-
import { ArrayType, SerializedArrayType } from "./generic/ArrayType.js";
|
|
5
|
-
import { EnumType, SerializedEnumType } from "./generic/EnumType.js";
|
|
6
|
-
import { MemberDecl, ObjectType, SerializedMemberDecl, SerializedObjectType } from "./generic/ObjectType.js";
|
|
7
|
-
import { BooleanType, SerializedBooleanType } from "./primitives/BooleanType.js";
|
|
8
|
-
import { DateType, SerializedDateType } from "./primitives/DateType.js";
|
|
9
|
-
import { FloatType, SerializedFloatType } from "./primitives/FloatType.js";
|
|
10
|
-
import { IntegerType, SerializedIntegerType } from "./primitives/IntegerType.js";
|
|
11
|
-
import { PrimitiveType, SerializedPrimitiveType } from "./primitives/PrimitiveType.js";
|
|
12
|
-
import { SerializedStringType, StringType } from "./primitives/StringType.js";
|
|
13
|
-
import { GenericArgumentIdentifierType, SerializedGenericArgumentIdentifierType } from "./references/GenericArgumentIdentifierType.js";
|
|
14
|
-
import { IncludeIdentifierType, SerializedIncludeIdentifierType } from "./references/IncludeIdentifierType.js";
|
|
15
|
-
import { NestedEntityMapType, SerializedNestedEntityMapType } from "./references/NestedEntityMapType.js";
|
|
16
|
-
import { ReferenceIdentifierType, SerializedReferenceIdentifierType } from "./references/ReferenceIdentifierType.js";
|
|
17
|
-
export interface BaseType extends BaseNode {
|
|
18
|
-
/**
|
|
19
|
-
* The parent node of this type will be set when the type is used in a declaration or nested in another type.
|
|
20
|
-
*/
|
|
21
|
-
parent?: Type | Decl;
|
|
22
|
-
}
|
|
23
|
-
export interface SerializedBaseType extends BaseNode {
|
|
24
|
-
}
|
|
25
|
-
export type Type = PrimitiveType | ArrayType | ObjectType | GenericArgumentIdentifierType | ReferenceIdentifierType | IncludeIdentifierType | NestedEntityMapType | EnumType;
|
|
26
|
-
export type SerializedType = SerializedPrimitiveType | SerializedArrayType | SerializedObjectType | SerializedGenericArgumentIdentifierType | SerializedReferenceIdentifierType | SerializedIncludeIdentifierType | SerializedNestedEntityMapType | SerializedEnumType;
|
|
27
|
-
export declare const validate: Validator<Type>;
|
|
28
|
-
export declare const resolveTypeArgumentsInType: <Args extends Record<string, Type>>(args: Args, type: Type) => Type;
|
|
29
|
-
export declare function walkTypeNodeTree(callbackFn: (type: Type) => void, type: Type): void;
|
|
30
|
-
export type AsType<T extends Type> = T extends ArrayType<infer I> ? AsType<I>[] : T extends ObjectType<infer P> ? {
|
|
31
|
-
[K in keyof P]: P[K] extends MemberDecl<Type, true> ? AsType<P[K]["type"]> : AsType<P[K]["type"]> | undefined;
|
|
32
|
-
} : T extends BooleanType ? boolean : T extends DateType ? Date : T extends FloatType ? number : T extends IntegerType ? number : T extends StringType ? string : T extends GenericArgumentIdentifierType ? unknown : T extends IncludeIdentifierType ? unknown : T extends NestedEntityMapType ? unknown : T extends ReferenceIdentifierType ? unknown : never;
|
|
33
|
-
export type SerializedAsType<T extends SerializedType> = T extends SerializedArrayType<infer I> ? SerializedAsType<I>[] : T extends SerializedObjectType<infer P> ? {
|
|
34
|
-
[K in keyof P]: P[K] extends SerializedMemberDecl<SerializedType, true> ? SerializedAsType<P[K]["type"]> : SerializedAsType<P[K]["type"]> | undefined;
|
|
35
|
-
} : T extends SerializedBooleanType ? boolean : T extends SerializedDateType ? Date : T extends SerializedFloatType ? number : T extends SerializedIntegerType ? number : T extends SerializedStringType ? string : T extends SerializedGenericArgumentIdentifierType ? unknown : T extends SerializedIncludeIdentifierType ? unknown : T extends SerializedNestedEntityMapType ? unknown : T extends SerializedReferenceIdentifierType ? unknown : never;
|
|
36
|
-
export type AsNode<T> = T extends (infer I)[] ? ArrayType<AsNode<I>> : T extends Record<string, any> ? ObjectType<{
|
|
37
|
-
[K in keyof T]: T[K] extends MemberDecl<Type, boolean> ? T[K] : T extends null | undefined ? MemberDecl<AsNode<NonNullable<T[K]>>, false> : MemberDecl<AsNode<T[K]>, true>;
|
|
38
|
-
}> : T extends string ? StringType : T extends number ? FloatType : T extends boolean ? BooleanType : never;
|
|
39
|
-
export declare const getParentDecl: (type: Type) => Decl | undefined;
|
|
40
|
-
export declare const findTypeAtPath: (type: Type, path: string[]) => Type | undefined;
|
|
41
|
-
export declare const serializeType: Serializer<Type, SerializedType>;
|
|
42
|
-
export declare const removeParentKey: <T extends BaseType>(type: T) => Omit<T, "parent">;
|
|
43
|
-
export declare const getReferencesForType: GetReferences<Type>;
|
|
44
|
-
/**
|
|
45
|
-
* Format the structure of a value to always look the same when serialized as JSON.
|
|
46
|
-
*/
|
|
47
|
-
export type StructureFormatter<T extends Type> = (type: T, value: unknown) => unknown;
|
|
48
|
-
export declare const formatValue: StructureFormatter<Type>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { BooleanType, SerializedBooleanType } from "./BooleanType.js";
|
|
2
|
-
import { DateType, SerializedDateType } from "./DateType.js";
|
|
3
|
-
import { NumericType, SerializedNumericType } from "./NumericType.js";
|
|
4
|
-
import { SerializedStringType, StringType } from "./StringType.js";
|
|
5
|
-
export type PrimitiveType = BooleanType | DateType | NumericType | StringType;
|
|
6
|
-
export type SerializedPrimitiveType = SerializedBooleanType | SerializedDateType | SerializedNumericType | SerializedStringType;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { GetReferences, Node, NodeKind, Serializer } from "../../Node.js";
|
|
2
|
-
import { SerializedTypeParameter, TypeParameter } from "../../parameters/TypeParameter.js";
|
|
3
|
-
import { Validator } from "../../validation/type.js";
|
|
4
|
-
import { BaseType, SerializedBaseType, StructureFormatter, Type } from "../Type.js";
|
|
5
|
-
type TConstraint = TypeParameter;
|
|
6
|
-
export interface GenericArgumentIdentifierType<T extends TConstraint = TConstraint> extends BaseType {
|
|
7
|
-
kind: NodeKind["GenericArgumentIdentifierType"];
|
|
8
|
-
argument: T;
|
|
9
|
-
}
|
|
10
|
-
type TSerializedConstraint = SerializedTypeParameter;
|
|
11
|
-
export interface SerializedGenericArgumentIdentifierType<T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseType {
|
|
12
|
-
kind: NodeKind["GenericArgumentIdentifierType"];
|
|
13
|
-
argument: T;
|
|
14
|
-
}
|
|
15
|
-
export declare const GenericArgumentIdentifierType: <T extends TConstraint>(argument: T) => GenericArgumentIdentifierType<T>;
|
|
16
|
-
export { GenericArgumentIdentifierType as GenericArgumentIdentifier };
|
|
17
|
-
export declare const isGenericArgumentIdentifierType: (node: Node) => node is GenericArgumentIdentifierType;
|
|
18
|
-
export declare const validateGenericArgumentIdentifierType: Validator<GenericArgumentIdentifierType>;
|
|
19
|
-
export declare const resolveTypeArgumentsInGenericArgumentIdentifierType: <T extends TConstraint, Args extends Record<string, Type>>(args: Args, type: GenericArgumentIdentifierType<T>) => Args[T["name"]];
|
|
20
|
-
export declare const serializeGenericArgumentIdentifierType: Serializer<GenericArgumentIdentifierType, SerializedGenericArgumentIdentifierType>;
|
|
21
|
-
export declare const getReferencesForGenericArgumentIdentifierType: GetReferences<GenericArgumentIdentifierType>;
|
|
22
|
-
export declare const formatGenericArgumentIdentifierValue: StructureFormatter<GenericArgumentIdentifierType>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { NodeKind } from "../../Node.js";
|
|
2
|
-
import { serializeTypeParameter, } from "../../parameters/TypeParameter.js";
|
|
3
|
-
import { removeParentKey } from "../Type.js";
|
|
4
|
-
export const GenericArgumentIdentifierType = (argument) => ({
|
|
5
|
-
kind: NodeKind.GenericArgumentIdentifierType,
|
|
6
|
-
argument,
|
|
7
|
-
});
|
|
8
|
-
export { GenericArgumentIdentifierType as GenericArgumentIdentifier };
|
|
9
|
-
export const isGenericArgumentIdentifierType = (node) => node.kind === NodeKind.GenericArgumentIdentifierType;
|
|
10
|
-
export const validateGenericArgumentIdentifierType = (_helpers, type, _value) => {
|
|
11
|
-
throw new TypeError(`generic argument "${type.argument.name}" has not been replaced with a concrete type`);
|
|
12
|
-
};
|
|
13
|
-
export const resolveTypeArgumentsInGenericArgumentIdentifierType = (args, type) => args[type.argument.name];
|
|
14
|
-
export const serializeGenericArgumentIdentifierType = type => ({
|
|
15
|
-
...removeParentKey(type),
|
|
16
|
-
argument: serializeTypeParameter(type.argument),
|
|
17
|
-
});
|
|
18
|
-
export const getReferencesForGenericArgumentIdentifierType = (_type, _value) => [];
|
|
19
|
-
export const formatGenericArgumentIdentifierValue = (_type, value) => value;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Validators } from "../Node.js";
|
|
2
|
-
import { Type } from "../types/Type.js";
|
|
3
|
-
export type ValidatorHelpers = Validators;
|
|
4
|
-
export type Validator<T extends Type, Args extends any[] = []> = (helpers: ValidatorHelpers, type: T, value: unknown, ...args: Args) => Error[];
|
package/lib/server/index.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SimpleGit } from "simple-git";
|
|
2
|
-
import { ModelContainer } from "../ModelContainer.js";
|
|
3
|
-
import { Decl } from "../schema/declarations/Declaration.js";
|
|
4
|
-
import { EntityDecl } from "../schema/declarations/EntityDecl.js";
|
|
5
|
-
import { InstancesByEntityName } from "../shared/utils/instances.js";
|
|
6
|
-
import { ReferencesToInstances } from "../utils/references.js";
|
|
7
|
-
type ServerOptions = {
|
|
8
|
-
name: string;
|
|
9
|
-
port: number;
|
|
10
|
-
};
|
|
11
|
-
export interface TSONDBRequestLocals {
|
|
12
|
-
git: SimpleGit;
|
|
13
|
-
gitRoot: string | undefined;
|
|
14
|
-
dataRoot: string;
|
|
15
|
-
declarations: readonly Decl[];
|
|
16
|
-
entities: readonly EntityDecl[];
|
|
17
|
-
instancesByEntityName: InstancesByEntityName;
|
|
18
|
-
entitiesByName: Record<string, EntityDecl>;
|
|
19
|
-
localeEntity?: EntityDecl;
|
|
20
|
-
referencesToInstances: ReferencesToInstances;
|
|
21
|
-
}
|
|
22
|
-
declare global {
|
|
23
|
-
namespace Express {
|
|
24
|
-
interface Request extends TSONDBRequestLocals {
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export declare const createServer: (modelContainer: ModelContainer, instancesByEntityName: InstancesByEntityName, options?: Partial<ServerOptions>) => Promise<void>;
|
|
29
|
-
export {};
|
package/lib/server/init.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ModelContainer } from "../ModelContainer.js";
|
|
2
|
-
import { InstancesByEntityName } from "../shared/utils/instances.js";
|
|
3
|
-
import { TSONDBRequestLocals } from "./index.js";
|
|
4
|
-
export declare const init: (modelContainer: ModelContainer, instancesByEntityName: InstancesByEntityName) => Promise<TSONDBRequestLocals>;
|
|
5
|
-
export declare const reinit: (locals: TSONDBRequestLocals) => Promise<void>;
|