tsondb 0.5.12 → 0.5.14

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.
@@ -23,7 +23,7 @@ export const generateOutputs = async (schema, outputs) => {
23
23
  }
24
24
  };
25
25
  const _validate = (dataRootPath, entities, instancesByEntityName, options = {}) => {
26
- const { checkReferentialIntegrity = false, checkOnlyEntities = [] } = options;
26
+ const { checkReferentialIntegrity = true, checkOnlyEntities = [] } = options;
27
27
  for (const onlyEntity of checkOnlyEntities) {
28
28
  if (!entities.find(entity => entity.name === onlyEntity)) {
29
29
  throw new Error(`Entity "${onlyEntity}" not found in schema`);
@@ -32,7 +32,7 @@ const _validate = (dataRootPath, entities, instancesByEntityName, options = {})
32
32
  const errors = (checkOnlyEntities.length > 0
33
33
  ? entities.filter(entity => checkOnlyEntities.includes(entity.name))
34
34
  : entities)
35
- .flatMap(entity => parallelizeErrors(instancesByEntityName[entity.name]?.map(instance => wrapErrorsIfAny(`in file ${styleText("white", `"${dataRootPath}${sep}${styleText("bold", join(entity.name, instance.fileName))}"`)}`, validateEntityDecl(createValidators(instancesByEntityName, checkReferentialIntegrity), entity, instance.content))) ?? []))
35
+ .flatMap(entity => parallelizeErrors(instancesByEntityName[entity.name]?.map(instance => wrapErrorsIfAny(`in file ${styleText("white", `"${dataRootPath}${sep}${styleText("bold", join(entity.name, instance.fileName))}"`)}`, validateEntityDecl(createValidators(instancesByEntityName, true, checkReferentialIntegrity), entity, instance.content))) ?? []))
36
36
  .toSorted((a, b) => a.message.localeCompare(b.message));
37
37
  if (errors.length === 0) {
38
38
  debug("All entities are valid");
@@ -32,8 +32,9 @@ export type IdentifierToCheck = {
32
32
  value: unknown;
33
33
  };
34
34
  export interface Validators {
35
+ useStyling: boolean;
35
36
  checkReferentialIntegrity: (identifier: IdentifierToCheck) => Error[];
36
37
  }
37
- export declare const createValidators: (instancesByEntityName: InstancesByEntityName, checkReferentialIntegrity?: boolean) => Validators;
38
+ export declare const createValidators: (instancesByEntityName: InstancesByEntityName, useStyling: boolean, checkReferentialIntegrity?: boolean) => Validators;
38
39
  export type Serializer<T, U> = (node: T) => U;
39
40
  export type GetReferences<T extends Node> = (node: T, value: unknown) => string[];
@@ -75,7 +75,8 @@ export const flatMapAuxiliaryDecls = (callbackFn, declarations) => {
75
75
  };
76
76
  return declarations.reduce((decls, node) => mapNodeTree(reducer, node, [...decls, node]), []);
77
77
  };
78
- export const createValidators = (instancesByEntityName, checkReferentialIntegrity = true) => ({
78
+ export const createValidators = (instancesByEntityName, useStyling, checkReferentialIntegrity = true) => ({
79
+ useStyling,
79
80
  checkReferentialIntegrity: checkReferentialIntegrity
80
81
  ? ({ name, value }) => instancesByEntityName[name]?.some(instance => typeof instance.content === "object" &&
81
82
  instance.content !== null &&
@@ -83,7 +84,7 @@ export const createValidators = (instancesByEntityName, checkReferentialIntegrit
83
84
  instance.id === value)
84
85
  ? []
85
86
  : [
86
- ReferenceError(`Invalid reference to instance of entity ${entity(`"${name}"`)} with identifier ${json(value)}`),
87
+ ReferenceError(`Invalid reference to instance of entity ${entity(`"${name}"`, useStyling)} with identifier ${json(value, useStyling)}`),
87
88
  ]
88
89
  : () => [],
89
90
  });
@@ -22,11 +22,11 @@ export const isArrayType = (node) => node.kind === NodeKind.ArrayType;
22
22
  export const getNestedDeclarationsInArrayType = (addedDecls, type) => getNestedDeclarations(addedDecls, type.items);
23
23
  export const validateArrayType = (helpers, type, value) => {
24
24
  if (!Array.isArray(value)) {
25
- return [TypeError(`expected an array, but got ${json(value)}`)];
25
+ return [TypeError(`expected an array, but got ${json(value, helpers.useStyling)}`)];
26
26
  }
27
27
  return parallelizeErrors([
28
28
  ...validateArrayConstraints(type, value),
29
- ...value.map((item, index) => wrapErrorsIfAny(`at index ${key(index.toString())}`, validate(helpers, type.items, item))),
29
+ ...value.map((item, index) => wrapErrorsIfAny(`at index ${key(index.toString(), helpers.useStyling)}`, validate(helpers, type.items, item))),
30
30
  ]);
31
31
  };
32
32
  export const resolveTypeArgumentsInArrayType = (args, type) => ArrayType(resolveTypeArgumentsInType(args, type.items), {
@@ -1,4 +1,6 @@
1
1
  import { discriminatorKey } from "../../../../shared/enum.js";
2
+ import { parallelizeErrors } from "../../../../shared/utils/validation.js";
3
+ import { wrapErrorsIfAny } from "../../../utils/error.js";
2
4
  import { json, key } from "../../../utils/errorFormatting.js";
3
5
  import { getNestedDeclarations } from "../../declarations/Declaration.js";
4
6
  import { NodeKind } from "../../Node.js";
@@ -18,24 +20,24 @@ export const isEnumType = (node) => node.kind === NodeKind.EnumType;
18
20
  export const getNestedDeclarationsInEnumType = (addedDecls, type) => Object.values(type.values).reduce((acc, caseMember) => caseMember.type === null ? acc : getNestedDeclarations(acc, caseMember.type), addedDecls);
19
21
  export const validateEnumType = (helpers, type, value) => {
20
22
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
21
- return [TypeError(`expected an object, but got ${json(value)}`)];
23
+ return [TypeError(`expected an object, but got ${json(value, helpers.useStyling)}`)];
22
24
  }
23
25
  const actualKeys = Object.keys(value);
24
26
  if (!(discriminatorKey in value) || typeof value[discriminatorKey] !== "string") {
25
27
  return [
26
- TypeError(`missing required discriminator value at key ${key(`"${discriminatorKey}"`)} of type string`),
28
+ TypeError(`missing required discriminator value at key ${key(`"${discriminatorKey}"`, helpers.useStyling)} of type string`),
27
29
  ];
28
30
  }
29
31
  const caseName = value[discriminatorKey];
30
32
  if (!(caseName in type.values)) {
31
33
  return [
32
- TypeError(`discriminator ${key(`"${caseName}"`)} is not a valid enum case, possible cases are: ${Object.keys(type.values).join(", ")}`),
34
+ TypeError(`discriminator ${key(`"${caseName}"`, helpers.useStyling)} is not a valid enum case, possible cases are: ${Object.keys(type.values).join(", ")}`),
33
35
  ];
34
36
  }
35
37
  const unknownKeyErrors = actualKeys.flatMap(actualKey => actualKey === discriminatorKey || actualKey in type.values
36
38
  ? []
37
39
  : [
38
- TypeError(`key ${key(`"${actualKey}"`)} is not the discriminator key ${key(`"${caseName}"`)} or a valid enum case, possible cases are: ${Object.keys(type.values).join(", ")}`),
40
+ TypeError(`key ${key(`"${actualKey}"`, helpers.useStyling)} is not the discriminator key ${key(`"${caseName}"`, helpers.useStyling)} or a valid enum case, possible cases are: ${Object.keys(type.values).join(", ")}`),
39
41
  ]);
40
42
  if (unknownKeyErrors.length > 0) {
41
43
  return unknownKeyErrors;
@@ -43,9 +45,13 @@ export const validateEnumType = (helpers, type, value) => {
43
45
  const associatedType = type.values[caseName]?.type;
44
46
  if (associatedType != null) {
45
47
  if (!(caseName in value)) {
46
- return [TypeError(`missing required associated value for case ${key(`"${caseName}"`)}`)];
48
+ return [
49
+ TypeError(`missing required associated value for case ${key(`"${caseName}"`, helpers.useStyling)}`),
50
+ ];
47
51
  }
48
- return validate(helpers, associatedType, value[caseName]);
52
+ return parallelizeErrors([
53
+ wrapErrorsIfAny(`at enum key ${key(`"${caseName}"`, helpers.useStyling)}`, validate(helpers, associatedType, value[caseName])),
54
+ ]);
49
55
  }
50
56
  return [];
51
57
  };
@@ -30,7 +30,7 @@ export const isObjectType = (node) => node.kind === NodeKind.ObjectType;
30
30
  export const getNestedDeclarationsInObjectType = (addedDecls, type) => Object.values(type.properties).reduce((acc, prop) => getNestedDeclarations(acc, prop.type), addedDecls);
31
31
  export const validateObjectType = (helpers, type, value) => {
32
32
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
33
- return [TypeError(`expected an object, but got ${json(value)}`)];
33
+ return [TypeError(`expected an object, but got ${json(value, helpers.useStyling)}`)];
34
34
  }
35
35
  const expectedKeys = Object.keys(type.properties);
36
36
  return parallelizeErrors([
@@ -39,10 +39,10 @@ export const validateObjectType = (helpers, type, value) => {
39
39
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
40
40
  const prop = type.properties[key];
41
41
  if (prop.isRequired && !(key in value)) {
42
- return TypeError(`missing required property ${keyColor(`"${key}"`)}`);
42
+ return TypeError(`missing required property ${keyColor(`"${key}"`, helpers.useStyling)}`);
43
43
  }
44
44
  else if (prop.isRequired || value[key] !== undefined) {
45
- return wrapErrorsIfAny(`at object key ${keyColor(`"${key}"`)}`, validate(helpers, prop.type, value[key]));
45
+ return wrapErrorsIfAny(`at object key ${keyColor(`"${key}"`, helpers.useStyling)}`, validate(helpers, prop.type, value[key]));
46
46
  }
47
47
  return undefined;
48
48
  }),
@@ -6,9 +6,9 @@ export const BooleanType = () => ({
6
6
  });
7
7
  export { BooleanType as Boolean };
8
8
  export const isBooleanType = (node) => node.kind === NodeKind.BooleanType;
9
- export const validateBooleanType = (_helpers, _type, value) => {
9
+ export const validateBooleanType = (helpers, _type, value) => {
10
10
  if (typeof value !== "boolean") {
11
- return [TypeError(`expected a boolean value, but got ${json(value)}`)];
11
+ return [TypeError(`expected a boolean value, but got ${json(value, helpers.useStyling)}`)];
12
12
  }
13
13
  return [];
14
14
  };
@@ -8,9 +8,9 @@ export const DateType = (options) => ({
8
8
  });
9
9
  export { DateType as Date };
10
10
  export const isDateType = (node) => node.kind === NodeKind.DateType;
11
- export const validateDateType = (_helpers, type, value) => {
11
+ export const validateDateType = (helpers, type, value) => {
12
12
  if (typeof value !== "string") {
13
- return [TypeError(`expected a string, but got ${json(value)}`)];
13
+ return [TypeError(`expected a string, but got ${json(value, helpers.useStyling)}`)];
14
14
  }
15
15
  return validateDateConstraints(type, value);
16
16
  };
@@ -8,9 +8,11 @@ export const FloatType = (options = {}) => ({
8
8
  });
9
9
  export { FloatType as Float };
10
10
  export const isFloatType = (node) => node.kind === NodeKind.FloatType;
11
- export const validateFloatType = (_helpers, type, value) => {
11
+ export const validateFloatType = (helpers, type, value) => {
12
12
  if (typeof value !== "number") {
13
- return [TypeError(`expected a floating-point number, but got ${json(value)}`)];
13
+ return [
14
+ TypeError(`expected a floating-point number, but got ${json(value, helpers.useStyling)}`),
15
+ ];
14
16
  }
15
17
  return validateNumberConstraints(type, value);
16
18
  };
@@ -12,9 +12,9 @@ export const IntegerType = (options = {}) => ({
12
12
  });
13
13
  export { IntegerType as Integer };
14
14
  export const isIntegerType = (node) => node.kind === NodeKind.IntegerType;
15
- export const validateIntegerType = (_helpers, type, value) => {
15
+ export const validateIntegerType = (helpers, type, value) => {
16
16
  if (typeof value !== "number" || !Number.isInteger(value)) {
17
- return [TypeError(`expected an integer, but got ${json(value)}`)];
17
+ return [TypeError(`expected an integer, but got ${json(value, helpers.useStyling)}`)];
18
18
  }
19
19
  return validateNumberConstraints(type, value);
20
20
  };
@@ -8,9 +8,9 @@ export const StringType = (options = {}) => ({
8
8
  });
9
9
  export { StringType as String };
10
10
  export const isStringType = (node) => node.kind === NodeKind.StringType;
11
- export const validateStringType = (_helpers, type, value) => {
11
+ export const validateStringType = (helpers, type, value) => {
12
12
  if (typeof value !== "string") {
13
- return [TypeError(`expected a string, but got ${json(value)}`)];
13
+ return [TypeError(`expected a string, but got ${json(value, helpers.useStyling)}`)];
14
14
  }
15
15
  return validateStringConstraints(type, value);
16
16
  };
@@ -27,9 +27,9 @@ export const isNestedEntityMapType = (node) => node.kind === NodeKind.NestedEnti
27
27
  export const getNestedDeclarationsInNestedEntityMapType = (addedDecls, type) => getNestedDeclarationsInObjectType(addedDecls.includes(type.secondaryEntity) ? addedDecls : [type.secondaryEntity, ...addedDecls], type.type.value);
28
28
  export const validateNestedEntityMapType = (helpers, type, value) => {
29
29
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
30
- return [TypeError(`expected an object, but got ${json(value)}`)];
30
+ return [TypeError(`expected an object, but got ${json(value, helpers.useStyling)}`)];
31
31
  }
32
- return parallelizeErrors(Object.keys(value).map(key => wrapErrorsIfAny(`at nested entity map ${entity(`"${type.name}"`)} at key ${keyColor(`"${key}"`)}`, validateObjectType(helpers, type.type.value, value[key]).concat(helpers.checkReferentialIntegrity({
32
+ return parallelizeErrors(Object.keys(value).map(key => wrapErrorsIfAny(`at nested entity map ${entity(`"${type.name}"`, helpers.useStyling)} at key ${keyColor(`"${key}"`, helpers.useStyling)}`, validateObjectType(helpers, type.type.value, value[key]).concat(helpers.checkReferentialIntegrity({
33
33
  name: type.secondaryEntity.name,
34
34
  value: key,
35
35
  })))));
@@ -14,7 +14,7 @@ export const createInstance = async (locals, entityName, instance, idQueryParam)
14
14
  if (entity === undefined) {
15
15
  return error([400, "Entity not found"]);
16
16
  }
17
- const validationErrors = validateEntityDecl(createValidators(locals.instancesByEntityName), entity, instance);
17
+ const validationErrors = validateEntityDecl(createValidators(locals.instancesByEntityName, false), entity, instance);
18
18
  if (validationErrors.length > 0) {
19
19
  return error([400, validationErrors.map(getErrorMessageForDisplay).join("\n\n")]);
20
20
  }
@@ -54,7 +54,7 @@ export const updateInstance = async (locals, entityName, instanceId, instance) =
54
54
  if (entity === undefined) {
55
55
  return error([400, "Entity not found"]);
56
56
  }
57
- const validationErrors = validateEntityDecl(createValidators(locals.instancesByEntityName), entity, instance);
57
+ const validationErrors = validateEntityDecl(createValidators(locals.instancesByEntityName, false), entity, instance);
58
58
  if (validationErrors.length > 0) {
59
59
  return error([400, validationErrors.map(getErrorMessageForDisplay).join("\n\n")]);
60
60
  }
@@ -1,3 +1,3 @@
1
- export declare const json: (value: unknown) => string;
2
- export declare const key: (str: string) => string;
3
- export declare const entity: (str: string) => string;
1
+ export declare const json: (value: unknown, useStyling: boolean) => string;
2
+ export declare const key: (str: string, useStyling: boolean) => string;
3
+ export declare const entity: (str: string, useStyling: boolean) => string;
@@ -1,4 +1,6 @@
1
1
  import { styleText } from "node:util";
2
- export const json = (value) => styleText("blue", JSON.stringify(value, undefined, 2));
3
- export const key = (str) => styleText(["yellow", "bold"], str);
4
- export const entity = (str) => styleText("green", str);
2
+ export const json = (value, useStyling) => useStyling
3
+ ? styleText("blue", JSON.stringify(value, undefined, 2))
4
+ : JSON.stringify(value, undefined, 2);
5
+ export const key = (str, useStyling) => useStyling ? styleText(["yellow", "bold"], str) : str;
6
+ export const entity = (str, useStyling) => useStyling ? styleText("green", str) : str;
@@ -12,6 +12,7 @@ import { useEntityFromRoute } from "../hooks/useEntityFromRoute.js";
12
12
  import { useInstanceNamesByEntity } from "../hooks/useInstanceNamesByEntity.js";
13
13
  import { useGetDeclFromDeclName } from "../hooks/useSecondaryDeclarations.js";
14
14
  import { createTypeSkeleton } from "../utils/typeSkeleton.js";
15
+ import { homeTitle } from "./Home.js";
15
16
  import { NotFound } from "./NotFound.js";
16
17
  export const CreateInstance = () => {
17
18
  const { params: { name }, } = useRoute();
@@ -73,7 +74,7 @@ export const CreateInstance = () => {
73
74
  const instanceName = getSerializedDisplayNameFromEntityInstance(entity, instance, defaultName);
74
75
  const idErrors = isLocaleEntity ? validateLocaleIdentifier(customId) : [];
75
76
  return (_jsxs(Layout, { breadcrumbs: [
76
- { url: "/", label: "Home" },
77
+ { url: "/", label: homeTitle },
77
78
  { url: `/entities/${entity.name}`, label: entity.name },
78
79
  ], children: [_jsx("div", { class: "header-with-btns", children: _jsx("h1", { class: instanceName.length === 0 ? "empty-name" : undefined, children: instanceName || defaultName }) }), isLocaleEntity && (_jsxs("div", { class: "field field--id", children: [_jsx("label", { htmlFor: "id", children: "ID" }), _jsx("p", { className: "comment", children: "The instance\u2019s identifier. An IETF language tag (BCP47)." }), _jsx("input", { type: "text", id: "id", value: customId, required: true, pattern: "[a-z]{2,3}(-[A-Z]{2,3})?", placeholder: "en-US, de-DE, \u2026", onInput: event => {
79
80
  setCustomId(event.currentTarget.value);
@@ -8,6 +8,7 @@ import { Layout } from "../components/Layout.js";
8
8
  import { useAPIResource } from "../hooks/useAPIResource.js";
9
9
  import { useMappedAPIResource } from "../hooks/useMappedAPIResource.js";
10
10
  import { Markdown } from "../utils/Markdown.js";
11
+ import { homeTitle } from "./Home.js";
11
12
  import { NotFound } from "./NotFound.js";
12
13
  const mapInstances = (data) => data.instances;
13
14
  export const Entity = () => {
@@ -37,7 +38,7 @@ export const Entity = () => {
37
38
  ? instances
38
39
  : instances.filter(instance => instance.id.includes(searchText) ||
39
40
  instance.displayName.toLowerCase().includes(lowerSearchText));
40
- return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: "Home" }], children: [_jsxs("div", { class: "header-with-btns", children: [_jsx("h1", { children: toTitleCase(entity.declaration.namePlural) }), _jsx("a", { class: "btn btn--primary", href: `/entities/${entity.declaration.name}/instances/create`, children: "Add" })] }), entity.declaration.comment && (_jsx(Markdown, { class: "description", string: entity.declaration.comment })), _jsxs("div", { className: "list-header", children: [_jsxs("p", { class: "instance-count", children: [searchText === "" ? "" : `${filteredInstances.length.toString()} of `, instances.length, " instance", instances.length === 1 ? "" : "s"] }), _jsxs("form", { action: "", rel: "search", onSubmit: e => {
41
+ return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: homeTitle }], children: [_jsxs("div", { class: "header-with-btns", children: [_jsx("h1", { children: toTitleCase(entity.declaration.namePlural) }), _jsx("a", { class: "btn btn--primary", href: `/entities/${entity.declaration.name}/instances/create`, children: "Add" })] }), entity.declaration.comment && (_jsx(Markdown, { class: "description", string: entity.declaration.comment })), _jsxs("div", { className: "list-header", children: [_jsxs("p", { class: "instance-count", children: [searchText === "" ? "" : `${filteredInstances.length.toString()} of `, instances.length, " instance", instances.length === 1 ? "" : "s"] }), _jsxs("form", { action: "", rel: "search", onSubmit: e => {
41
42
  e.preventDefault();
42
43
  }, children: [_jsx("label", { htmlFor: "instance-search", class: "visually-hidden", children: "Search" }), _jsx("input", { type: "text", id: "instance-search", value: searchText, onInput: event => {
43
44
  setSearchText(event.currentTarget.value);
@@ -1,2 +1,3 @@
1
1
  import type { FunctionalComponent } from "preact";
2
+ export declare const homeTitle = "Entities";
2
3
  export declare const Home: FunctionalComponent;
@@ -6,10 +6,11 @@ import { Layout } from "../components/Layout.js";
6
6
  import { useMappedAPIResource } from "../hooks/useMappedAPIResource.js";
7
7
  import { Markdown } from "../utils/Markdown.js";
8
8
  const mapEntities = (data) => data.declarations.sort((a, b) => a.declaration.name.localeCompare(b.declaration.name));
9
+ export const homeTitle = "Entities";
9
10
  export const Home = () => {
10
11
  const [entities] = useMappedAPIResource(getAllEntities, mapEntities);
11
12
  useEffect(() => {
12
- document.title = "Entities — TSONDB";
13
+ document.title = homeTitle + " — TSONDB";
13
14
  }, []);
14
15
  const [searchText, setSearchText] = useState("");
15
16
  const lowerSearchText = searchText.toLowerCase().replaceAll(" ", "");
@@ -17,7 +18,7 @@ export const Home = () => {
17
18
  ? entities
18
19
  : entities?.filter(entity => entity.declaration.name.toLowerCase().includes(lowerSearchText) ||
19
20
  entity.declaration.namePlural.toLowerCase().includes(lowerSearchText));
20
- return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: "Home" }], children: [_jsx("h1", { children: "Entities" }), _jsxs("div", { className: "list-header", children: [_jsxs("p", { class: "instance-count", children: [searchText === "" ? "" : `${(filteredEntities?.length ?? 0).toString()} of `, entities?.length ?? 0, " entit", entities?.length === 1 ? "y" : "ies"] }), _jsxs("form", { action: "", rel: "search", onSubmit: e => {
21
+ return (_jsxs(Layout, { breadcrumbs: [], children: [_jsx("h1", { children: homeTitle }), _jsxs("div", { className: "list-header", children: [_jsxs("p", { class: "instance-count", children: [searchText === "" ? "" : `${(filteredEntities?.length ?? 0).toString()} of `, entities?.length ?? 0, " entit", entities?.length === 1 ? "y" : "ies"] }), _jsxs("form", { action: "", rel: "search", onSubmit: e => {
21
22
  e.preventDefault();
22
23
  }, children: [_jsx("label", { htmlFor: "entity-search", class: "visually-hidden", children: "Search" }), _jsx("input", { type: "text", id: "entity-search", value: searchText, onInput: event => {
23
24
  setSearchText(event.currentTarget.value);
@@ -9,7 +9,7 @@ import { TypeInput } from "../components/typeInputs/TypeInput.js";
9
9
  import { useEntityFromRoute } from "../hooks/useEntityFromRoute.js";
10
10
  import { useInstanceNamesByEntity } from "../hooks/useInstanceNamesByEntity.js";
11
11
  import { useGetDeclFromDeclName } from "../hooks/useSecondaryDeclarations.js";
12
- import { printJson } from "../utils/debug.js";
12
+ import { homeTitle } from "./Home.js";
13
13
  import { NotFound } from "./NotFound.js";
14
14
  export const Instance = () => {
15
15
  const { params: { name, id }, } = useRoute();
@@ -69,14 +69,14 @@ export const Instance = () => {
69
69
  !instanceNamesByEntity ||
70
70
  !declsLoaded) {
71
71
  return (_jsxs(Layout, { breadcrumbs: [
72
- { url: "/", label: "Home" },
72
+ { url: "/", label: homeTitle },
73
73
  { url: `/entities/${name}`, label: name },
74
74
  ], children: [_jsx("h1", { children: id }), _jsx("p", { className: "loading", children: "Loading \u2026" })] }));
75
75
  }
76
76
  const defaultName = id;
77
77
  const instanceName = getSerializedDisplayNameFromEntityInstance(entityFromRoute.entity, instance.content, defaultName);
78
78
  return (_jsxs(Layout, { breadcrumbs: [
79
- { url: "/", label: "Home" },
79
+ { url: "/", label: homeTitle },
80
80
  { url: `/entities/${name}`, label: entityFromRoute.entity.name },
81
81
  ], children: [_jsxs("div", { class: "header-with-btns", children: [_jsxs("h1", { class: instanceName.length === 0 ? "empty-name" : undefined, children: [_jsx("span", { children: instanceName || defaultName }), " ", _jsx("span", { className: "id", "aria-hidden": true, children: instance.id })] }), _jsx("button", { class: "destructive", onClick: () => {
82
82
  if (confirm("Are you sure you want to delete this instance?")) {
@@ -90,5 +90,5 @@ export const Instance = () => {
90
90
  }
91
91
  });
92
92
  }
93
- }, children: "Delete" })] }), _jsxs("div", { class: "debug-compare", style: { display: "flex", gap: "1rem", width: "100%" }, children: [_jsxs("div", { style: { flex: "1 1 0", position: "relative" }, children: [_jsx("p", { children: "Original" }), _jsx("pre", { style: { overflowX: "scroll", width: "40rem", maxWidth: "100%" }, children: _jsx("code", { dangerouslySetInnerHTML: { __html: printJson(originalInstance.content) } }) })] }), _jsxs("div", { style: { flex: "1 1 0", position: "relative" }, children: [_jsx("p", { children: "Current" }), _jsx("pre", { style: { overflowX: "scroll", width: "40rem", maxWidth: "100%" }, children: _jsx("code", { dangerouslySetInnerHTML: { __html: printJson(instance.content) } }) })] })] }), _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TypeInput, { type: entityFromRoute.entity.type, value: instance.content, path: undefined, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: handleOnChange }), _jsx("div", { class: "form-footer btns", children: _jsx("button", { type: "submit", name: "save", class: "primary", children: "Save" }) })] })] }));
93
+ }, children: "Delete" })] }), _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TypeInput, { type: entityFromRoute.entity.type, value: instance.content, path: undefined, instanceNamesByEntity: instanceNamesByEntity, getDeclFromDeclName: getDeclFromDeclName, onChange: handleOnChange }), _jsx("div", { class: "form-footer btns", children: _jsx("button", { type: "submit", name: "save", class: "primary", children: "Save" }) })] })] }));
94
94
  };
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { useEffect } from "preact/hooks";
3
3
  import { Layout } from "../components/Layout.js";
4
+ import { homeTitle } from "./Home.js";
4
5
  export const NotFound = () => {
5
6
  useEffect(() => {
6
7
  document.title = "Not found — TSONDB";
7
8
  }, []);
8
- return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: "Home" }], children: [_jsx("h1", { children: "404 Not Found" }), _jsx("p", { children: "The page you are looking for does not exist." })] }));
9
+ return (_jsxs(Layout, { breadcrumbs: [{ url: "/", label: homeTitle }], children: [_jsx("h1", { children: "404 Not Found" }), _jsx("p", { children: "The page you are looking for does not exist." })] }));
9
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsondb",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Lukas Obermann",
@@ -110,6 +110,10 @@ header {
110
110
  grid-area: header;
111
111
  }
112
112
 
113
+ header nav {
114
+ min-height: 1.4rem;
115
+ }
116
+
113
117
  header nav ol {
114
118
  list-style-type: " ";
115
119
  display: flex;