tsondb 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/LICENSE +385 -0
  2. package/README.md +173 -1
  3. package/lib/bin/tsondb.d.ts +10 -0
  4. package/lib/bin/tsondb.js +84 -0
  5. package/lib/index.d.ts +2 -1
  6. package/lib/index.js +1 -1
  7. package/lib/{Schema.d.ts → node/Schema.d.ts} +2 -2
  8. package/lib/{Schema.js → node/Schema.js} +6 -5
  9. package/lib/node/index.d.ts +9 -0
  10. package/lib/node/index.js +75 -0
  11. package/lib/{renderers → node/renderers}/Output.d.ts +1 -1
  12. package/lib/{renderers → node/renderers}/jsonschema/index.d.ts +2 -2
  13. package/lib/{renderers → node/renderers}/jsonschema/index.js +9 -2
  14. package/lib/{renderers → node/renderers}/jsonschema/render.d.ts +1 -1
  15. package/lib/{renderers → node/renderers}/jsonschema/render.js +15 -10
  16. package/lib/{renderers → node/renderers}/ts/index.d.ts +2 -2
  17. package/lib/{renderers → node/renderers}/ts/index.js +2 -2
  18. package/lib/{renderers → node/renderers}/ts/render.d.ts +1 -1
  19. package/lib/{renderers → node/renderers}/ts/render.js +13 -9
  20. package/lib/{schema → node/schema}/Node.d.ts +5 -5
  21. package/lib/{schema → node/schema}/Node.js +9 -8
  22. package/lib/{schema/parameters → node/schema}/TypeParameter.d.ts +3 -2
  23. package/lib/{schema/parameters → node/schema}/TypeParameter.js +2 -2
  24. package/lib/{schema → node/schema}/declarations/Declaration.d.ts +10 -11
  25. package/lib/{schema → node/schema}/declarations/Declaration.js +7 -5
  26. package/lib/{schema → node/schema}/declarations/EntityDecl.d.ts +13 -12
  27. package/lib/{schema → node/schema}/declarations/EntityDecl.js +4 -5
  28. package/lib/{schema → node/schema}/declarations/EnumDecl.d.ts +9 -7
  29. package/lib/{schema → node/schema}/declarations/EnumDecl.js +6 -13
  30. package/lib/{schema → node/schema}/declarations/TypeAliasDecl.d.ts +8 -7
  31. package/lib/{schema → node/schema}/declarations/TypeAliasDecl.js +6 -14
  32. package/lib/{schema → node/schema}/index.d.ts +4 -4
  33. package/lib/{schema → node/schema}/index.js +3 -4
  34. package/lib/node/schema/types/Type.d.ts +54 -0
  35. package/lib/{schema → node/schema}/types/Type.js +55 -29
  36. package/lib/{schema → node/schema}/types/generic/ArrayType.d.ts +5 -4
  37. package/lib/{schema → node/schema}/types/generic/ArrayType.js +5 -5
  38. package/lib/{schema → node/schema}/types/generic/EnumType.d.ts +5 -4
  39. package/lib/{schema → node/schema}/types/generic/EnumType.js +10 -4
  40. package/lib/{schema → node/schema}/types/generic/ObjectType.d.ts +8 -7
  41. package/lib/{schema → node/schema}/types/generic/ObjectType.js +14 -7
  42. package/lib/{schema → node/schema}/types/primitives/BooleanType.d.ts +4 -3
  43. package/lib/{schema → node/schema}/types/primitives/DateType.d.ts +5 -4
  44. package/lib/{schema → node/schema}/types/primitives/DateType.js +1 -1
  45. package/lib/{schema → node/schema}/types/primitives/FloatType.d.ts +5 -4
  46. package/lib/{schema → node/schema}/types/primitives/FloatType.js +1 -1
  47. package/lib/{schema → node/schema}/types/primitives/IntegerType.d.ts +5 -4
  48. package/lib/{schema → node/schema}/types/primitives/IntegerType.js +1 -1
  49. package/lib/{schema → node/schema}/types/primitives/NumericType.d.ts +2 -2
  50. package/lib/node/schema/types/primitives/PrimitiveType.d.ts +6 -0
  51. package/lib/{schema → node/schema}/types/primitives/StringType.d.ts +5 -4
  52. package/lib/{schema → node/schema}/types/primitives/StringType.js +1 -1
  53. package/lib/{schema → node/schema}/types/references/IncludeIdentifierType.d.ts +9 -8
  54. package/lib/{schema → node/schema}/types/references/IncludeIdentifierType.js +1 -1
  55. package/lib/{schema → node/schema}/types/references/NestedEntityMapType.d.ts +10 -9
  56. package/lib/{schema → node/schema}/types/references/NestedEntityMapType.js +8 -16
  57. package/lib/{schema → node/schema}/types/references/ReferenceIdentifierType.d.ts +7 -6
  58. package/lib/{schema → node/schema}/types/references/ReferenceIdentifierType.js +1 -1
  59. package/lib/node/schema/types/references/TypeArgumentType.d.ts +23 -0
  60. package/lib/node/schema/types/references/TypeArgumentType.js +19 -0
  61. package/lib/node/schema/validation/type.d.ts +4 -0
  62. package/lib/{server → node/server}/api/declarations.js +7 -3
  63. package/lib/{server → node/server}/api/git.js +14 -11
  64. package/lib/{server → node/server}/api/instanceOperations.d.ts +3 -3
  65. package/lib/{server → node/server}/api/instanceOperations.js +18 -7
  66. package/lib/{server → node/server}/api/instances.js +7 -3
  67. package/lib/node/server/index.d.ts +28 -0
  68. package/lib/{server → node/server}/index.js +23 -13
  69. package/lib/node/server/init.d.ts +5 -0
  70. package/lib/{server → node/server}/init.js +9 -8
  71. package/lib/{utils → node/utils}/error.js +4 -1
  72. package/lib/{utils → node/utils}/git.d.ts +2 -2
  73. package/lib/{utils → node/utils}/instances.d.ts +4 -3
  74. package/lib/{utils → node/utils}/instances.js +10 -6
  75. package/lib/{utils → node/utils}/references.d.ts +2 -2
  76. package/lib/{utils → node/utils}/references.js +3 -3
  77. package/lib/{utils → node/utils}/render.js +1 -1
  78. package/lib/shared/api.d.ts +9 -3
  79. package/lib/shared/utils/array.d.ts +1 -0
  80. package/lib/shared/utils/array.js +13 -9
  81. package/lib/shared/utils/displayName.d.ts +1 -1
  82. package/lib/shared/utils/displayName.js +7 -2
  83. package/lib/shared/utils/instances.d.ts +2 -2
  84. package/lib/{utils → shared/utils}/lazy.js +1 -1
  85. package/lib/shared/utils/markdown.js +6 -6
  86. package/lib/shared/utils/object.d.ts +3 -0
  87. package/lib/shared/utils/object.js +5 -1
  88. package/lib/{utils → shared/utils}/result.js +2 -2
  89. package/lib/shared/utils/string.js +7 -4
  90. package/lib/shared/utils/validation.js +3 -2
  91. package/lib/shared/validation/number.js +3 -3
  92. package/lib/shared/validation/object.js +4 -3
  93. package/lib/shared/validation/string.js +12 -7
  94. package/lib/{client → web}/api.d.ts +3 -3
  95. package/lib/{client → web}/api.js +5 -6
  96. package/lib/web/components/Git.d.ts +2 -0
  97. package/lib/{client → web}/components/Git.js +59 -15
  98. package/lib/{client → web}/components/Layout.d.ts +1 -1
  99. package/lib/{client → web}/components/Layout.js +1 -1
  100. package/lib/web/components/Select.d.ts +3 -0
  101. package/lib/web/components/Select.js +5 -0
  102. package/lib/web/components/typeInputs/ArrayTypeInput.d.ts +13 -0
  103. package/lib/{client → web}/components/typeInputs/ArrayTypeInput.js +7 -1
  104. package/lib/{client → web}/components/typeInputs/BooleanTypeInput.d.ts +2 -2
  105. package/lib/{client → web}/components/typeInputs/DateTypeInput.d.ts +2 -2
  106. package/lib/web/components/typeInputs/EnumTypeInput.d.ts +13 -0
  107. package/lib/{client → web}/components/typeInputs/EnumTypeInput.js +1 -1
  108. package/lib/{client → web}/components/typeInputs/FloatTypeInput.d.ts +2 -2
  109. package/lib/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +7 -0
  110. package/lib/{client → web}/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.js +1 -1
  111. package/lib/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +13 -0
  112. package/lib/{client → web}/components/typeInputs/IntegerTypeInput.d.ts +2 -2
  113. package/lib/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +13 -0
  114. package/lib/{client → web}/components/typeInputs/NestedEntityMapTypeInput.js +7 -2
  115. package/lib/{client → web}/components/typeInputs/ObjectTypeInput.d.ts +4 -4
  116. package/lib/{client → web}/components/typeInputs/ObjectTypeInput.js +4 -1
  117. package/lib/{client → web}/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -3
  118. package/lib/web/components/typeInputs/ReferenceIdentifierTypeInput.js +11 -0
  119. package/lib/{client → web}/components/typeInputs/StringTypeInput.d.ts +2 -2
  120. package/lib/web/components/typeInputs/TypeInput.d.ts +13 -0
  121. package/lib/{client → web}/components/typeInputs/TypeInput.js +3 -3
  122. package/lib/{client → web}/components/typeInputs/utils/Markdown.d.ts +1 -1
  123. package/lib/{client → web}/components/typeInputs/utils/Markdown.js +2 -2
  124. package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.d.ts +1 -1
  125. package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.d.ts +1 -1
  126. package/lib/web/hooks/useAPIResource.d.ts +1 -0
  127. package/lib/{client → web}/hooks/useAPIResource.js +2 -1
  128. package/lib/{client → web}/hooks/useEntityFromRoute.d.ts +1 -1
  129. package/lib/{client → web}/hooks/useEntityFromRoute.js +1 -1
  130. package/lib/{client → web}/hooks/useInstanceNamesByEntity.d.ts +1 -1
  131. package/lib/{client → web}/hooks/useInstanceNamesByEntity.js +8 -6
  132. package/lib/web/hooks/useMappedAPIResource.d.ts +1 -0
  133. package/lib/{client → web}/hooks/useMappedAPIResource.js +9 -9
  134. package/lib/{client → web}/hooks/useSecondaryDeclarations.d.ts +1 -1
  135. package/lib/{client → web}/hooks/useSecondaryDeclarations.js +4 -2
  136. package/lib/{client → web}/routes/CreateInstance.d.ts +1 -1
  137. package/lib/{client → web}/routes/CreateInstance.js +4 -2
  138. package/lib/web/routes/Entity.d.ts +2 -0
  139. package/lib/{client → web}/routes/Entity.js +8 -6
  140. package/lib/web/routes/Home.d.ts +2 -0
  141. package/lib/{client → web}/routes/Home.js +2 -1
  142. package/lib/{client → web}/routes/Instance.d.ts +1 -1
  143. package/lib/{client → web}/routes/Instance.js +14 -8
  144. package/lib/{client → web}/routes/NotFound.d.ts +1 -1
  145. package/lib/web/utils/typeSkeleton.d.ts +3 -0
  146. package/lib/{client → web}/utils/typeSkeleton.js +4 -1
  147. package/package.json +33 -19
  148. package/lib/ModelContainer.d.ts +0 -17
  149. package/lib/ModelContainer.js +0 -65
  150. package/lib/client/components/Git.d.ts +0 -2
  151. package/lib/client/components/Select.d.ts +0 -3
  152. package/lib/client/components/Select.js +0 -2
  153. package/lib/client/components/typeInputs/ArrayTypeInput.d.ts +0 -13
  154. package/lib/client/components/typeInputs/EnumTypeInput.d.ts +0 -13
  155. package/lib/client/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +0 -7
  156. package/lib/client/components/typeInputs/IncludeIdentifierTypeInput.d.ts +0 -13
  157. package/lib/client/components/typeInputs/NestedEntityMapTypeInput.d.ts +0 -13
  158. package/lib/client/components/typeInputs/ReferenceIdentifierTypeInput.js +0 -9
  159. package/lib/client/components/typeInputs/TypeInput.d.ts +0 -13
  160. package/lib/client/hooks/useAPIResource.d.ts +0 -1
  161. package/lib/client/hooks/useMappedAPIResource.d.ts +0 -1
  162. package/lib/client/routes/Entity.d.ts +0 -2
  163. package/lib/client/routes/Home.d.ts +0 -2
  164. package/lib/client/utils/typeSkeleton.d.ts +0 -3
  165. package/lib/schema/types/Type.d.ts +0 -48
  166. package/lib/schema/types/primitives/PrimitiveType.d.ts +0 -6
  167. package/lib/schema/types/references/GenericArgumentIdentifierType.d.ts +0 -22
  168. package/lib/schema/types/references/GenericArgumentIdentifierType.js +0 -19
  169. package/lib/schema/validation/type.d.ts +0 -4
  170. package/lib/server/index.d.ts +0 -29
  171. package/lib/server/init.d.ts +0 -5
  172. package/lib/tsconfig.tsbuildinfo +0 -1
  173. package/lib/utils/object.d.ts +0 -3
  174. package/lib/utils/object.js +0 -1
  175. /package/lib/{renderers → node/renderers}/Output.js +0 -0
  176. /package/lib/{schema → node/schema}/types/primitives/BooleanType.js +0 -0
  177. /package/lib/{schema → node/schema}/types/primitives/NumericType.js +0 -0
  178. /package/lib/{schema → node/schema}/types/primitives/PrimitiveType.js +0 -0
  179. /package/lib/{schema → node/schema}/validation/options.d.ts +0 -0
  180. /package/lib/{schema → node/schema}/validation/options.js +0 -0
  181. /package/lib/{schema → node/schema}/validation/type.js +0 -0
  182. /package/lib/{server → node/server}/api/declarations.d.ts +0 -0
  183. /package/lib/{server → node/server}/api/git.d.ts +0 -0
  184. /package/lib/{server → node/server}/api/index.d.ts +0 -0
  185. /package/lib/{server → node/server}/api/index.js +0 -0
  186. /package/lib/{server → node/server}/api/instances.d.ts +0 -0
  187. /package/lib/{utils → node/utils}/error.d.ts +0 -0
  188. /package/lib/{utils → node/utils}/git.js +0 -0
  189. /package/lib/{utils → node/utils}/path.d.ts +0 -0
  190. /package/lib/{utils → node/utils}/path.js +0 -0
  191. /package/lib/{utils → node/utils}/render.d.ts +0 -0
  192. /package/lib/{utils → shared/utils}/enum.d.ts +0 -0
  193. /package/lib/{utils → shared/utils}/enum.js +0 -0
  194. /package/lib/{utils → shared/utils}/lazy.d.ts +0 -0
  195. /package/lib/{utils → shared/utils}/result.d.ts +0 -0
  196. /package/lib/{client → web}/components/typeInputs/BooleanTypeInput.js +0 -0
  197. /package/lib/{client → web}/components/typeInputs/DateTypeInput.js +0 -0
  198. /package/lib/{client → web}/components/typeInputs/FloatTypeInput.js +0 -0
  199. /package/lib/{client → web}/components/typeInputs/IncludeIdentifierTypeInput.js +0 -0
  200. /package/lib/{client → web}/components/typeInputs/IntegerTypeInput.js +0 -0
  201. /package/lib/{client → web}/components/typeInputs/StringTypeInput.js +0 -0
  202. /package/lib/{client → web}/components/typeInputs/utils/MismatchingTypeError.js +0 -0
  203. /package/lib/{client → web}/components/typeInputs/utils/ValidationErrors.js +0 -0
  204. /package/lib/{client → web}/index.d.ts +0 -0
  205. /package/lib/{client → web}/index.js +0 -0
  206. /package/lib/{client → web}/routes/NotFound.js +0 -0
package/package.json CHANGED
@@ -1,44 +1,58 @@
1
1
  {
2
2
  "name": "tsondb",
3
- "version": "0.3.0",
3
+ "version": "0.5.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
- "./modelcontainer": "./lib/ModelContainer.js",
18
- "./schema": "./lib/Schema.js",
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": "glob -c \"node --import tsx --test\" \"./test/**/*.ts\"",
25
- "release": "commit-and-tag-version"
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",
31
+ "release": "commit-and-tag-version",
32
+ "release:sign": "commit-and-tag-version --sign --signoff"
26
33
  },
27
34
  "devDependencies": {
35
+ "@eslint/js": "^9.30.1",
28
36
  "@types/debug": "^4.1.12",
29
- "@types/express": "^5.0.1",
30
- "@types/node": "^22.13.14",
37
+ "@types/express": "^5.0.3",
38
+ "@types/node": "^24.0.12",
31
39
  "commit-and-tag-version": "^12.5.1",
32
- "glob": "^11.0.1",
33
- "tsx": "^4.19.3",
34
- "typescript": "^5.8.2"
40
+ "eslint": "^9.30.1",
41
+ "eslint-plugin-react": "^7.37.5",
42
+ "eslint-plugin-react-hooks": "^5.2.0",
43
+ "globals": "^16.3.0",
44
+ "prettier": "^3.6.2",
45
+ "tsx": "^4.20.3",
46
+ "typescript": "^5.8.3",
47
+ "typescript-eslint": "^8.36.0"
35
48
  },
36
49
  "dependencies": {
37
- "debug": "^4.4.0",
50
+ "debug": "^4.4.1",
38
51
  "express": "^5.1.0",
39
- "preact": "^10.26.5",
40
- "preact-iso": "^2.9.1",
41
- "simple-git": "^3.27.0",
52
+ "preact": "^10.26.9",
53
+ "preact-iso": "^2.9.2",
54
+ "simple-cli-args": "^0.1.0",
55
+ "simple-git": "^3.28.0",
42
56
  "supports-color": "^10.0.0",
43
57
  "uuid": "^11.1.0"
44
58
  },
@@ -47,6 +61,6 @@
47
61
  "url": "https://github.com/elyukai/tsondb/issues"
48
62
  },
49
63
  "engines": {
50
- "node": ">=21.2.0"
64
+ "node": ">=23.6.0"
51
65
  }
52
66
  }
@@ -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>;
@@ -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,2 +0,0 @@
1
- import { FunctionComponent } from "preact";
2
- export declare const Git: FunctionComponent;
@@ -1,3 +0,0 @@
1
- import { FunctionalComponent } from "preact";
2
- import { SelectHTMLAttributes } from "preact/compat";
3
- export declare const Select: FunctionalComponent<SelectHTMLAttributes>;
@@ -1,2 +0,0 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
2
- export const Select = props => (_jsx("div", { class: "select-wrapper", children: _jsx("select", { ...props, class: `${props.class ?? ""} ${props.className ?? ""} ${!props.value ? "no-selection" : ""}` }) }));
@@ -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,2 +0,0 @@
1
- import { FunctionalComponent } from "preact";
2
- export declare const Entity: FunctionalComponent;
@@ -1,2 +0,0 @@
1
- import { FunctionalComponent } from "preact";
2
- export declare const Home: FunctionalComponent;
@@ -1,3 +0,0 @@
1
- import { SerializedType } from "../../schema/types/Type.js";
2
- import { GetDeclFromDeclName } from "../hooks/useSecondaryDeclarations.js";
3
- export declare const createTypeSkeleton: (getDeclFromDeclName: GetDeclFromDeclName, type: SerializedType) => unknown;
@@ -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[];
@@ -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 {};
@@ -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>;