tsondb 0.5.18 → 0.6.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/dist/src/bin/tsondb.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/node/config.d.ts +20 -0
- package/dist/src/node/config.js +5 -0
- package/dist/src/node/index.d.ts +3 -2
- package/dist/src/node/index.js +13 -8
- package/dist/src/node/renderers/jsonschema/render.d.ts +1 -1
- package/dist/src/node/renderers/jsonschema/render.js +12 -7
- package/dist/src/node/renderers/ts/render.d.ts +1 -1
- package/dist/src/node/renderers/ts/render.js +12 -6
- package/dist/src/node/schema/Node.d.ts +100 -29
- package/dist/src/node/schema/Node.js +268 -61
- package/dist/src/node/schema/Schema.js +96 -1
- package/dist/src/node/schema/TypeParameter.d.ts +7 -9
- package/dist/src/node/schema/TypeParameter.js +7 -5
- package/dist/src/node/schema/declarations/Declaration.d.ts +10 -28
- package/dist/src/node/schema/declarations/Declaration.js +8 -110
- package/dist/src/node/schema/declarations/EntityDecl.d.ts +48 -48
- package/dist/src/node/schema/declarations/EntityDecl.js +15 -12
- package/dist/src/node/schema/declarations/EnumDecl.d.ts +14 -17
- package/dist/src/node/schema/declarations/EnumDecl.js +12 -12
- package/dist/src/node/schema/declarations/TypeAliasDecl.d.ts +8 -14
- package/dist/src/node/schema/declarations/TypeAliasDecl.js +10 -11
- package/dist/src/node/schema/index.d.ts +0 -2
- package/dist/src/node/schema/index.js +0 -1
- package/dist/src/node/schema/types/Type.d.ts +19 -42
- package/dist/src/node/schema/types/Type.js +29 -167
- package/dist/src/node/schema/types/generic/ArrayType.d.ts +5 -14
- package/dist/src/node/schema/types/generic/ArrayType.js +15 -20
- package/dist/src/node/schema/types/generic/EnumType.d.ts +5 -17
- package/dist/src/node/schema/types/generic/EnumType.js +12 -20
- package/dist/src/node/schema/types/generic/ObjectType.d.ts +5 -19
- package/dist/src/node/schema/types/generic/ObjectType.js +11 -15
- package/dist/src/node/schema/types/primitives/BooleanType.d.ts +7 -8
- package/dist/src/node/schema/types/primitives/BooleanType.js +5 -4
- package/dist/src/node/schema/types/primitives/DateType.d.ts +6 -8
- package/dist/src/node/schema/types/primitives/DateType.js +5 -4
- package/dist/src/node/schema/types/primitives/FloatType.d.ts +9 -21
- package/dist/src/node/schema/types/primitives/FloatType.js +5 -4
- package/dist/src/node/schema/types/primitives/IntegerType.d.ts +9 -21
- package/dist/src/node/schema/types/primitives/IntegerType.js +5 -4
- package/dist/src/node/schema/types/primitives/StringType.d.ts +6 -10
- package/dist/src/node/schema/types/primitives/StringType.js +5 -4
- package/dist/src/node/schema/types/references/ChildEntitiesType.d.ts +18 -0
- package/dist/src/node/schema/types/references/ChildEntitiesType.js +18 -0
- package/dist/src/node/schema/types/references/IncludeIdentifierType.d.ts +7 -13
- package/dist/src/node/schema/types/references/IncludeIdentifierType.js +12 -12
- package/dist/src/node/schema/types/references/NestedEntityMapType.d.ts +7 -17
- package/dist/src/node/schema/types/references/NestedEntityMapType.js +11 -13
- package/dist/src/node/schema/types/references/ReferenceIdentifierType.d.ts +4 -10
- package/dist/src/node/schema/types/references/ReferenceIdentifierType.js +3 -5
- package/dist/src/node/schema/types/references/TypeArgumentType.d.ts +5 -10
- package/dist/src/node/schema/types/references/TypeArgumentType.js +10 -5
- package/dist/src/node/server/api/declarations.js +24 -6
- package/dist/src/node/server/api/index.js +11 -0
- package/dist/src/node/server/api/instances.js +9 -6
- package/dist/src/node/server/index.d.ts +6 -1
- package/dist/src/node/server/index.js +7 -3
- package/dist/src/node/server/init.d.ts +2 -1
- package/dist/src/node/server/init.js +11 -11
- package/dist/src/node/server/utils/childInstances.d.ts +4 -0
- package/dist/src/node/server/utils/childInstances.js +41 -0
- package/dist/src/node/server/utils/instanceOperations.d.ts +8 -0
- package/dist/src/node/server/utils/instanceOperations.js +107 -0
- package/dist/src/node/server/utils/locales.d.ts +2 -0
- package/dist/src/node/server/utils/locales.js +8 -0
- package/dist/src/node/utils/childInstances.d.ts +32 -0
- package/dist/src/node/utils/childInstances.js +164 -0
- package/dist/src/node/utils/displayName.d.ts +2 -1
- package/dist/src/node/utils/displayName.js +5 -4
- package/dist/src/node/utils/files.d.ts +5 -0
- package/dist/src/node/utils/files.js +9 -0
- package/dist/src/node/utils/instanceOperations.d.ts +14 -0
- package/dist/src/node/utils/instanceOperations.js +88 -0
- package/dist/src/node/utils/instances.d.ts +1 -1
- package/dist/src/node/utils/instances.js +12 -6
- package/dist/src/node/utils/references.d.ts +3 -1
- package/dist/src/node/utils/references.js +43 -18
- package/dist/src/node/utils/referencesWorker.d.ts +5 -0
- package/dist/src/node/utils/referencesWorker.js +22 -0
- package/dist/src/node/utils/workers.d.ts +15 -0
- package/dist/src/node/utils/workers.js +90 -0
- package/dist/src/shared/api.d.ts +14 -1
- package/dist/src/shared/schema/Node.d.ts +63 -0
- package/dist/src/shared/schema/Node.js +128 -0
- package/dist/src/shared/schema/TypeParameter.d.ts +9 -0
- package/dist/src/shared/schema/TypeParameter.js +2 -0
- package/dist/src/shared/schema/declarations/Declaration.d.ts +21 -0
- package/dist/src/shared/schema/declarations/Declaration.js +4 -0
- package/dist/src/shared/schema/declarations/EntityDecl.d.ts +32 -0
- package/dist/src/shared/schema/declarations/EntityDecl.js +8 -0
- package/dist/src/shared/schema/declarations/EnumDecl.d.ts +11 -0
- package/dist/src/shared/schema/declarations/EnumDecl.js +9 -0
- package/dist/src/shared/schema/declarations/TypeAliasDecl.d.ts +11 -0
- package/dist/src/shared/schema/declarations/TypeAliasDecl.js +7 -0
- package/dist/src/shared/schema/types/ArrayType.d.ts +11 -0
- package/dist/src/shared/schema/types/ArrayType.js +8 -0
- package/dist/src/shared/schema/types/BooleanType.d.ts +7 -0
- package/dist/src/shared/schema/types/BooleanType.js +2 -0
- package/dist/src/shared/schema/types/ChildEntitiesType.d.ts +8 -0
- package/dist/src/shared/schema/types/ChildEntitiesType.js +2 -0
- package/dist/src/shared/schema/types/DateType.d.ts +8 -0
- package/dist/src/shared/schema/types/DateType.js +2 -0
- package/dist/src/shared/schema/types/EnumType.d.ts +14 -0
- package/dist/src/shared/schema/types/EnumType.js +28 -0
- package/dist/src/shared/schema/types/FloatType.d.ts +11 -0
- package/dist/src/shared/schema/types/FloatType.js +2 -0
- package/dist/src/shared/schema/types/IncludeIdentifierType.d.ts +11 -0
- package/dist/src/shared/schema/types/IncludeIdentifierType.js +13 -0
- package/dist/src/shared/schema/types/IntegerType.d.ts +11 -0
- package/dist/src/shared/schema/types/IntegerType.js +2 -0
- package/dist/src/shared/schema/types/NestedEntityMapType.d.ts +17 -0
- package/dist/src/shared/schema/types/NestedEntityMapType.js +14 -0
- package/dist/src/shared/schema/types/ObjectType.d.ts +19 -0
- package/dist/src/shared/schema/types/ObjectType.js +14 -0
- package/dist/src/shared/schema/types/ReferenceIdentifierType.d.ts +8 -0
- package/dist/src/shared/schema/types/ReferenceIdentifierType.js +2 -0
- package/dist/src/shared/schema/types/StringType.d.ts +10 -0
- package/dist/src/shared/schema/types/StringType.js +2 -0
- package/dist/src/shared/schema/types/Type.d.ts +20 -0
- package/dist/src/shared/schema/types/TypeArgumentType.d.ts +12 -0
- package/dist/src/shared/schema/types/TypeArgumentType.js +7 -0
- package/dist/src/shared/utils/array.d.ts +4 -0
- package/dist/src/shared/utils/array.js +30 -0
- package/dist/src/shared/utils/async.d.ts +8 -0
- package/dist/src/shared/utils/async.js +35 -0
- package/dist/src/shared/utils/compare.js +3 -3
- package/dist/src/shared/utils/displayName.d.ts +6 -2
- package/dist/src/shared/utils/displayName.js +21 -8
- package/dist/src/shared/utils/instances.d.ts +2 -3
- package/dist/src/shared/utils/instances.js +3 -1
- package/dist/src/shared/utils/markdown.d.ts +4 -0
- package/dist/src/shared/utils/markdown.js +173 -110
- package/dist/src/shared/utils/object.d.ts +2 -0
- package/dist/src/shared/utils/object.js +2 -0
- package/dist/src/shared/utils/result.d.ts +8 -2
- package/dist/src/shared/utils/result.js +1 -1
- package/dist/src/web/api/declarations.d.ts +26 -0
- package/dist/src/web/api/declarations.js +51 -0
- package/dist/src/web/api/git.d.ts +14 -0
- package/dist/src/web/api/git.js +20 -0
- package/dist/src/web/api/index.d.ts +1 -0
- package/dist/src/web/api/index.js +2 -0
- package/dist/src/web/api/instances.d.ts +2 -0
- package/dist/src/web/api/instances.js +2 -0
- package/dist/src/web/components/Git.js +19 -16
- package/dist/src/web/components/InstanceRouteSkeleton.d.ts +42 -0
- package/dist/src/web/components/InstanceRouteSkeleton.js +114 -0
- package/dist/src/web/components/Layout.js +3 -2
- package/dist/src/web/components/ModalDialog.d.ts +3 -0
- package/dist/src/web/components/ModalDialog.js +16 -0
- package/dist/src/web/components/Settings.d.ts +2 -0
- package/dist/src/web/components/Settings.js +47 -0
- package/dist/src/web/components/typeInputs/ArrayTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/ArrayTypeInput.js +5 -4
- package/dist/src/web/components/typeInputs/BooleanTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/BooleanTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.d.ts +6 -0
- package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.js +27 -0
- package/dist/src/web/components/typeInputs/DateTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/DateTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/EnumTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/EnumTypeInput.js +55 -22
- package/dist/src/web/components/typeInputs/FloatTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/FloatTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +3 -4
- package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.js +3 -2
- package/dist/src/web/components/typeInputs/IntegerTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/IntegerTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.js +5 -4
- package/dist/src/web/components/typeInputs/ObjectTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/ObjectTypeInput.js +8 -5
- package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -8
- package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/StringTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/StringTypeInput.js +3 -3
- package/dist/src/web/components/typeInputs/TypeInput.d.ts +12 -4
- package/dist/src/web/components/typeInputs/TypeInput.js +22 -17
- package/dist/src/web/components/typeInputs/utils/ValidationErrors.d.ts +1 -0
- package/dist/src/web/components/typeInputs/utils/ValidationErrors.js +1 -3
- package/dist/src/web/context/config.d.ts +11 -0
- package/dist/src/web/context/config.js +6 -0
- package/dist/src/web/context/entities.d.ts +8 -5
- package/dist/src/web/context/entities.js +1 -1
- package/dist/src/web/context/settings.d.ts +8 -0
- package/dist/src/web/context/settings.js +10 -0
- package/dist/src/web/hooks/useEntityFromRoute.d.ts +1 -1
- package/dist/src/web/hooks/useEntityFromRoute.js +2 -2
- package/dist/src/web/hooks/useInstanceNamesByEntity.d.ts +1 -1
- package/dist/src/web/hooks/useInstanceNamesByEntity.js +4 -2
- package/dist/src/web/hooks/useMappedAPIResource.js +2 -4
- package/dist/src/web/hooks/useSecondaryDeclarations.d.ts +1 -1
- package/dist/src/web/hooks/useSecondaryDeclarations.js +8 -4
- package/dist/src/web/hooks/useSettings.d.ts +10 -0
- package/dist/src/web/hooks/useSettings.js +51 -0
- package/dist/src/web/index.js +11 -5
- package/dist/src/web/routes/CreateInstance.js +40 -79
- package/dist/src/web/routes/Entity.js +42 -19
- package/dist/src/web/routes/Home.js +24 -5
- package/dist/src/web/routes/Instance.js +34 -85
- package/dist/src/web/utils/InlineMarkdown.d.ts +1 -1
- package/dist/src/web/utils/InlineMarkdown.js +13 -1
- package/dist/src/web/utils/api.d.ts +25 -0
- package/dist/src/web/utils/api.js +34 -0
- package/dist/src/web/utils/typeSkeleton.d.ts +1 -1
- package/dist/src/web/utils/typeSkeleton.js +2 -0
- package/package.json +2 -1
- package/public/css/styles.css +171 -12
- package/dist/src/node/schema/types/primitives/NumericType.d.ts +0 -6
- package/dist/src/node/schema/types/primitives/NumericType.js +0 -2
- package/dist/src/node/schema/types/primitives/PrimitiveType.d.ts +0 -6
- package/dist/src/node/schema/validation/type.d.ts +0 -4
- package/dist/src/node/schema/validation/type.js +0 -1
- package/dist/src/node/server/api/instanceOperations.d.ts +0 -6
- package/dist/src/node/server/api/instanceOperations.js +0 -93
- package/dist/src/shared/config.d.ts +0 -11
- package/dist/src/shared/config.js +0 -1
- package/dist/src/web/api.d.ts +0 -24
- package/dist/src/web/api.js +0 -201
- /package/dist/src/{node/schema/types/primitives/PrimitiveType.js → shared/schema/types/Type.js} +0 -0
|
@@ -29,3 +29,33 @@ export const difference = (oldArr, newArr) => newArr.reduce((acc, item) => {
|
|
|
29
29
|
return acc;
|
|
30
30
|
}, { removed: oldArr, added: newArr });
|
|
31
31
|
export const unique = (arr, equalityCheck = (a, b) => a === b) => arr.filter((item, index) => arr.findIndex(other => equalityCheck(item, other)) === index);
|
|
32
|
+
/**
|
|
33
|
+
* Moves an element from one position to another within the array.
|
|
34
|
+
*/
|
|
35
|
+
export const reorder = (arr, sourceIndex, targetIndex) => {
|
|
36
|
+
if (sourceIndex < 0 || sourceIndex >= arr.length) {
|
|
37
|
+
throw new RangeError(`source index ${sourceIndex.toString()} is out of bounds for array of length ${arr.length.toString()}`);
|
|
38
|
+
}
|
|
39
|
+
if (targetIndex < 0 || targetIndex >= arr.length) {
|
|
40
|
+
throw new RangeError(`target index ${targetIndex.toString()} is out of bounds for array of length ${arr.length.toString()}`);
|
|
41
|
+
}
|
|
42
|
+
if (sourceIndex === targetIndex) {
|
|
43
|
+
return arr;
|
|
44
|
+
}
|
|
45
|
+
if (sourceIndex < targetIndex) {
|
|
46
|
+
return [
|
|
47
|
+
...arr.slice(0, sourceIndex),
|
|
48
|
+
...arr.slice(sourceIndex + 1, targetIndex + 1),
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
|
+
arr[sourceIndex],
|
|
51
|
+
...arr.slice(targetIndex + 1),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return [
|
|
55
|
+
...arr.slice(0, targetIndex),
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
57
|
+
arr[sourceIndex],
|
|
58
|
+
...arr.slice(targetIndex, sourceIndex),
|
|
59
|
+
...arr.slice(sourceIndex + 1),
|
|
60
|
+
];
|
|
61
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple async map to process tasks with a concurrency limit.
|
|
3
|
+
* @param tasks The list of tasks to process.
|
|
4
|
+
* @param worker The async function to process each task.
|
|
5
|
+
* @param concurrency The maximum number of concurrent tasks.
|
|
6
|
+
* @returns A promise that resolves to the list of results.
|
|
7
|
+
*/
|
|
8
|
+
export declare const mapAsync: <T, R>(tasks: readonly T[], worker: (task: T) => Promise<R>, concurrency: number) => Promise<R[]>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple async map to process tasks with a concurrency limit.
|
|
3
|
+
* @param tasks The list of tasks to process.
|
|
4
|
+
* @param worker The async function to process each task.
|
|
5
|
+
* @param concurrency The maximum number of concurrent tasks.
|
|
6
|
+
* @returns A promise that resolves to the list of results.
|
|
7
|
+
*/
|
|
8
|
+
export const mapAsync = (tasks, worker, concurrency) => new Promise((resolve, reject) => {
|
|
9
|
+
const results = [];
|
|
10
|
+
let activeIndex = 0;
|
|
11
|
+
let activeCount = 0;
|
|
12
|
+
let resolvedCount = 0;
|
|
13
|
+
const totalCount = tasks.length;
|
|
14
|
+
const runNext = () => {
|
|
15
|
+
if (resolvedCount === totalCount) {
|
|
16
|
+
resolve(results);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
while (activeCount < concurrency && activeIndex < totalCount) {
|
|
20
|
+
const currentIndex = activeIndex++;
|
|
21
|
+
const task = tasks[currentIndex];
|
|
22
|
+
activeCount++;
|
|
23
|
+
worker(task)
|
|
24
|
+
.then(result => {
|
|
25
|
+
results[currentIndex] = result;
|
|
26
|
+
resolvedCount++;
|
|
27
|
+
activeCount--;
|
|
28
|
+
runNext();
|
|
29
|
+
})
|
|
30
|
+
.catch(reject);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
runNext();
|
|
35
|
+
});
|
|
@@ -2,15 +2,15 @@ export const lt = (a, b) => a < b;
|
|
|
2
2
|
export const lte = (a, b) => a <= b;
|
|
3
3
|
export const gt = (a, b) => a > b;
|
|
4
4
|
export const gte = (a, b) => a >= b;
|
|
5
|
-
export const eq = (a, b) => a
|
|
6
|
-
export const neq = (a, b) => a
|
|
5
|
+
export const eq = (a, b) => Object.is(a, b);
|
|
6
|
+
export const neq = (a, b) => !Object.is(a, b);
|
|
7
7
|
/**
|
|
8
8
|
* Checks two values for value equality. This is a deep equality check that
|
|
9
9
|
* works for all types, including objects and arrays. For objects, it only
|
|
10
10
|
* compares all enumerable keys, no other properties or the prototype chain.
|
|
11
11
|
*/
|
|
12
12
|
export const deepEqual = (a, b) => {
|
|
13
|
-
if (a
|
|
13
|
+
if (Object.is(a, b)) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
if (typeof a === "object" && typeof b === "object" && a !== null && b !== null) {
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { SerializedEntityDecl } from "
|
|
2
|
-
export
|
|
1
|
+
import type { SerializedEntityDecl } from "../schema/declarations/EntityDecl.ts";
|
|
2
|
+
export type DisplayNameResult = {
|
|
3
|
+
name: string;
|
|
4
|
+
localeId?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const getSerializedDisplayNameFromEntityInstance: (entity: SerializedEntityDecl, instance: unknown, defaultName: string, locales: string[]) => DisplayNameResult;
|
|
@@ -11,13 +11,16 @@ const getValueAtPath = (value, path) => {
|
|
|
11
11
|
}
|
|
12
12
|
return current;
|
|
13
13
|
};
|
|
14
|
-
export const getSerializedDisplayNameFromEntityInstance = (entity, instance, defaultName, locales
|
|
14
|
+
export const getSerializedDisplayNameFromEntityInstance = (entity, instance, defaultName, locales) => {
|
|
15
15
|
if (entity.displayName === null) {
|
|
16
|
-
return defaultName;
|
|
16
|
+
return { name: defaultName, localeId: locales[0] };
|
|
17
17
|
}
|
|
18
18
|
const displayNamePath = entity.displayName ?? "name";
|
|
19
19
|
if (typeof displayNamePath === "string") {
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
name: getValueAtPath(instance, displayNamePath) ?? defaultName,
|
|
22
|
+
localeId: locales[0],
|
|
23
|
+
};
|
|
21
24
|
}
|
|
22
25
|
else {
|
|
23
26
|
const localeMapPath = displayNamePath.pathToLocaleMap ?? "translations";
|
|
@@ -25,12 +28,22 @@ export const getSerializedDisplayNameFromEntityInstance = (entity, instance, def
|
|
|
25
28
|
const pathInLocaleMap = displayNamePath.pathInLocaleMap ?? "name";
|
|
26
29
|
const availableLocales = Object.keys(localeMap ?? {});
|
|
27
30
|
return availableLocales.length === 0
|
|
28
|
-
? defaultName
|
|
29
|
-
: (locales.reduce((name, locale) =>
|
|
31
|
+
? { name: defaultName }
|
|
32
|
+
: (locales.reduce((name, locale) => {
|
|
33
|
+
if (name)
|
|
34
|
+
return name;
|
|
30
35
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
31
|
-
getValueAtPath(localeMap[locale], pathInLocaleMap)
|
|
36
|
+
const possibleName = getValueAtPath(localeMap[locale], pathInLocaleMap);
|
|
37
|
+
if (possibleName) {
|
|
38
|
+
return { name: possibleName, localeId: locale };
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}, undefined) ?? {
|
|
44
|
+
name:
|
|
32
45
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
|
-
getValueAtPath(localeMap[availableLocales[0]], pathInLocaleMap) ??
|
|
34
|
-
|
|
46
|
+
getValueAtPath(localeMap[availableLocales[0]], pathInLocaleMap) ?? defaultName,
|
|
47
|
+
});
|
|
35
48
|
}
|
|
36
49
|
};
|
|
@@ -2,16 +2,15 @@ import type { EntityDecl } from "../../node/schema/index.ts";
|
|
|
2
2
|
import type { GetInstanceById } from "../../node/server/index.ts";
|
|
3
3
|
import type { GitFileStatus } from "./git.ts";
|
|
4
4
|
export interface InstanceContainer {
|
|
5
|
-
fileName: string;
|
|
6
5
|
id: string;
|
|
7
6
|
content: unknown;
|
|
8
7
|
gitStatus?: GitFileStatus;
|
|
9
8
|
}
|
|
10
9
|
export interface InstanceContainerOverview {
|
|
11
|
-
fileName: string;
|
|
12
10
|
id: string;
|
|
13
11
|
gitStatus?: GitFileStatus;
|
|
14
12
|
displayName: string;
|
|
13
|
+
displayNameLocaleId?: string;
|
|
15
14
|
}
|
|
16
|
-
export declare const getInstanceContainerOverview: (entity: EntityDecl, instanceContainer: InstanceContainer, getInstanceById: GetInstanceById, locales
|
|
15
|
+
export declare const getInstanceContainerOverview: (entity: EntityDecl, instanceContainer: InstanceContainer, getInstanceById: GetInstanceById, locales: string[]) => InstanceContainerOverview;
|
|
17
16
|
export type InstancesByEntityName = Record<string, InstanceContainer[]>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { getDisplayNameFromEntityInstance } from "../../node/utils/displayName.js";
|
|
2
2
|
export const getInstanceContainerOverview = (entity, instanceContainer, getInstanceById, locales) => {
|
|
3
3
|
const { content: _, ...rest } = instanceContainer;
|
|
4
|
+
const { name: displayName, localeId: displayNameLocaleId } = getDisplayNameFromEntityInstance(entity, instanceContainer.content, getInstanceById, locales);
|
|
4
5
|
return {
|
|
5
6
|
...rest,
|
|
6
|
-
displayName
|
|
7
|
+
displayName,
|
|
8
|
+
displayNameLocaleId,
|
|
7
9
|
};
|
|
8
10
|
};
|
|
@@ -12,6 +12,10 @@ export type InlineMarkdownNode = {
|
|
|
12
12
|
kind: "link";
|
|
13
13
|
href: string;
|
|
14
14
|
content: InlineMarkdownNode[];
|
|
15
|
+
} | {
|
|
16
|
+
kind: "attributed";
|
|
17
|
+
attributes: Record<string, string | number | boolean>;
|
|
18
|
+
content: InlineMarkdownNode[];
|
|
15
19
|
} | TextNode;
|
|
16
20
|
export type BlockMarkdownNode = {
|
|
17
21
|
kind: "paragraph";
|
|
@@ -1,92 +1,184 @@
|
|
|
1
1
|
const codeRule = {
|
|
2
2
|
pattern: /`(.*?)`/,
|
|
3
|
-
map:
|
|
3
|
+
map: result => ({
|
|
4
|
+
kind: "code",
|
|
5
|
+
content: result[1] ?? "",
|
|
6
|
+
}),
|
|
7
|
+
mapHighlighting: result => ({
|
|
4
8
|
kind: "code",
|
|
5
|
-
content:
|
|
9
|
+
content: `\`${result[1] ?? ""}\``,
|
|
6
10
|
}),
|
|
7
11
|
};
|
|
8
12
|
const boldWithItalicRule = {
|
|
9
13
|
pattern: /(?<!\\)\*\*((.*?[^\\*])?\*(?!\*).*?[^\\*]\*.*?)(?<!\\)\*\*/,
|
|
10
|
-
map: (result, parseInside
|
|
14
|
+
map: (result, parseInside) => ({
|
|
11
15
|
kind: "bold",
|
|
12
|
-
content:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]
|
|
18
|
-
: parseInside(result[1] ?? ""),
|
|
16
|
+
content: parseInside(result[1] ?? ""),
|
|
17
|
+
}),
|
|
18
|
+
mapHighlighting: (result, parseInside) => ({
|
|
19
|
+
kind: "bold",
|
|
20
|
+
content: [textNode("**"), ...parseInside(result[1] ?? ""), textNode("**")],
|
|
19
21
|
}),
|
|
20
22
|
};
|
|
21
23
|
const italicWithBoldRule = {
|
|
22
24
|
pattern: /(?<![\\*])\*(?=\*\*|[^*])(.*?\*\*.*?\*\*.*?)(?<=[^\\*]|[^\\]\*\*)\*(?!\*)/,
|
|
23
|
-
map: (result, parseInside
|
|
25
|
+
map: (result, parseInside) => ({
|
|
24
26
|
kind: "italic",
|
|
25
|
-
content:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]
|
|
31
|
-
: parseInside(result[1] ?? ""),
|
|
27
|
+
content: parseInside(result[1] ?? ""),
|
|
28
|
+
}),
|
|
29
|
+
mapHighlighting: (result, parseInside) => ({
|
|
30
|
+
kind: "italic",
|
|
31
|
+
content: [textNode("*"), ...parseInside(result[1] ?? ""), textNode("*")],
|
|
32
32
|
}),
|
|
33
33
|
};
|
|
34
34
|
const boldRule = {
|
|
35
35
|
pattern: /(?<!\\)\*\*(.*?[^\\*])\*\*/,
|
|
36
|
-
map: (result, parseInside
|
|
36
|
+
map: (result, parseInside) => ({
|
|
37
37
|
kind: "bold",
|
|
38
|
-
content:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
]
|
|
44
|
-
: parseInside(result[1] ?? ""),
|
|
38
|
+
content: parseInside(result[1] ?? ""),
|
|
39
|
+
}),
|
|
40
|
+
mapHighlighting: (result, parseInside) => ({
|
|
41
|
+
kind: "bold",
|
|
42
|
+
content: [textNode("**"), ...parseInside(result[1] ?? ""), textNode("**")],
|
|
45
43
|
}),
|
|
46
44
|
};
|
|
47
45
|
const italicRule = {
|
|
48
46
|
pattern: /(?<!\\)\*(.*?[^\\*])\*/,
|
|
49
|
-
map: (result, parseInside
|
|
47
|
+
map: (result, parseInside) => ({
|
|
50
48
|
kind: "italic",
|
|
51
|
-
content:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]
|
|
57
|
-
: parseInside(result[1] ?? ""),
|
|
49
|
+
content: parseInside(result[1] ?? ""),
|
|
50
|
+
}),
|
|
51
|
+
mapHighlighting: (result, parseInside) => ({
|
|
52
|
+
kind: "italic",
|
|
53
|
+
content: [textNode("*"), ...parseInside(result[1] ?? ""), textNode("*")],
|
|
58
54
|
}),
|
|
59
55
|
};
|
|
60
56
|
const linkRule = {
|
|
61
|
-
pattern: /(
|
|
62
|
-
map: (result, parseInside
|
|
57
|
+
pattern: /(?<![\\^])\[(.*?[^\\])\]\((.*?[^\\])\)/,
|
|
58
|
+
map: (result, parseInside) => ({
|
|
59
|
+
kind: "link",
|
|
60
|
+
href: result[2] ?? "",
|
|
61
|
+
content: parseInside(result[1] ?? ""),
|
|
62
|
+
}),
|
|
63
|
+
mapHighlighting: (result, parseInside) => ({
|
|
63
64
|
kind: "link",
|
|
64
65
|
href: result[2] ?? "",
|
|
65
|
-
content:
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
content: [textNode("["), ...parseInside(result[1] ?? ""), textNode(`](${result[2] ?? ""})`)],
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
const booleanAttributePattern = /^(true|false)/;
|
|
70
|
+
const numberAttributePattern = /^(-?\d+(\.\d+)?)/;
|
|
71
|
+
const stringAttributePattern = /^("(.*?)(?<!\\)"|'(.*?)(?<!\\)')/;
|
|
72
|
+
const parseAttributeValue = (text) => {
|
|
73
|
+
const booleanResult = booleanAttributePattern.exec(text);
|
|
74
|
+
if (booleanResult !== null) {
|
|
75
|
+
return [booleanResult[1] === "true", booleanResult[0]];
|
|
76
|
+
}
|
|
77
|
+
const numberResult = numberAttributePattern.exec(text);
|
|
78
|
+
if (numberResult !== null) {
|
|
79
|
+
return [Number.parseFloat(numberResult[1] ?? "0"), numberResult[0]];
|
|
80
|
+
}
|
|
81
|
+
const stringResult = stringAttributePattern.exec(text);
|
|
82
|
+
if (stringResult !== null) {
|
|
83
|
+
return [stringResult[2] ?? stringResult[3] ?? "", stringResult[0]];
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
const attributeNamePattern = /^(\w+)(: *)/;
|
|
88
|
+
const attributeSeparatorPattern = /^,( *)/;
|
|
89
|
+
const parseNextAttributes = (text) => {
|
|
90
|
+
const separatorResult = attributeSeparatorPattern.exec(text);
|
|
91
|
+
if (separatorResult === null) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const remainingText = text.slice(separatorResult[0].length);
|
|
95
|
+
return [separatorResult[0], ...parseAttributes(remainingText)];
|
|
96
|
+
};
|
|
97
|
+
const parseAttributes = (text) => {
|
|
98
|
+
const nameResult = attributeNamePattern.exec(text);
|
|
99
|
+
if (nameResult === null) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const name = nameResult[1] ?? "";
|
|
103
|
+
const separator = nameResult[2] ?? "";
|
|
104
|
+
const remainingText = text.slice(nameResult[0].length);
|
|
105
|
+
const valueResult = parseAttributeValue(remainingText);
|
|
106
|
+
if (valueResult === null) {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
const [value, rawValue] = valueResult;
|
|
110
|
+
return [
|
|
111
|
+
{ name, separator, value, rawValue },
|
|
112
|
+
...parseNextAttributes(remainingText.slice(rawValue.length)),
|
|
113
|
+
];
|
|
114
|
+
};
|
|
115
|
+
const mapAttributesToObject = (rawAttributes) => Object.fromEntries(rawAttributes.filter(attr => typeof attr !== "string").map(attr => [attr.name, attr.value]));
|
|
116
|
+
const mapAttributesToNodes = (rawAttributes) => rawAttributes.flatMap(attr => typeof attr === "string"
|
|
117
|
+
? [textNode(attr)]
|
|
118
|
+
: [textNode(attr.name), textNode(attr.separator), textNode(attr.rawValue)]);
|
|
119
|
+
const parsedAttributesLength = (rawAttributes) => rawAttributes.reduce((sum, attr) => sum +
|
|
120
|
+
(typeof attr === "string"
|
|
121
|
+
? attr.length
|
|
122
|
+
: attr.name.length + attr.separator.length + attr.rawValue.length), 0);
|
|
123
|
+
const attributedRule = {
|
|
124
|
+
pattern: /(?<!\\)\^\[(.*?[^\\])\]\(((?:\w+: *(?:true|false|\d+(?:\.\d+)?|"(.*?)(?<!\\)"|'(.*?)(?<!\\)'))(?:, *\w+: *(?:true|false|\d+(?:\.\d+)?|"(.*?)(?<!\\)"|'(.*?)(?<!\\)'))*)\)/,
|
|
125
|
+
map: (result, parseInside) => ({
|
|
126
|
+
kind: "attributed",
|
|
127
|
+
attributes: mapAttributesToObject(parseAttributes(result[2] ?? "")),
|
|
128
|
+
content: parseInside(result[1] ?? ""),
|
|
129
|
+
}),
|
|
130
|
+
mapHighlighting: (result, parseInside) => {
|
|
131
|
+
const attributesText = result[2] ?? "";
|
|
132
|
+
const attributes = parseAttributes(attributesText);
|
|
133
|
+
const length = parsedAttributesLength(attributes);
|
|
134
|
+
const unparsedText = attributesText.length > length
|
|
135
|
+
? [{ kind: "text", content: attributesText.slice(length) }]
|
|
136
|
+
: [];
|
|
137
|
+
return {
|
|
138
|
+
kind: "attributed",
|
|
139
|
+
attributes: mapAttributesToObject(attributes),
|
|
140
|
+
content: [
|
|
141
|
+
textNode("^["),
|
|
68
142
|
...parseInside(result[1] ?? ""),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
143
|
+
textNode("]("),
|
|
144
|
+
...mapAttributesToNodes(attributes),
|
|
145
|
+
...unparsedText,
|
|
146
|
+
textNode(")"),
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
const textNode = (content) => ({
|
|
152
|
+
kind: "text",
|
|
153
|
+
content: content,
|
|
154
|
+
});
|
|
155
|
+
const parseEscapedCharacters = (text) => text.replace(/\\([*_`[\]()\\])/g, "$1");
|
|
156
|
+
const textRule = {
|
|
157
|
+
pattern: /.+/,
|
|
158
|
+
map: result => ({
|
|
159
|
+
kind: "text",
|
|
160
|
+
content: parseEscapedCharacters(result[0]),
|
|
161
|
+
}),
|
|
162
|
+
mapHighlighting: result => ({
|
|
163
|
+
kind: "text",
|
|
164
|
+
content: result[0],
|
|
72
165
|
}),
|
|
73
166
|
};
|
|
74
167
|
const inlineRules = [
|
|
75
168
|
codeRule,
|
|
76
169
|
linkRule,
|
|
170
|
+
attributedRule,
|
|
77
171
|
boldWithItalicRule,
|
|
78
172
|
italicWithBoldRule,
|
|
79
173
|
boldRule,
|
|
80
174
|
italicRule,
|
|
175
|
+
textRule,
|
|
81
176
|
];
|
|
82
177
|
const parseForInlineRules = (rules, text, forSyntaxHighlighting) => {
|
|
83
|
-
if (text.length === 0) {
|
|
178
|
+
if (text.length === 0 || rules[0] === undefined) {
|
|
84
179
|
return [];
|
|
85
180
|
}
|
|
86
181
|
const activeRule = rules[0];
|
|
87
|
-
if (activeRule === undefined) {
|
|
88
|
-
return [{ kind: "text", content: text }];
|
|
89
|
-
}
|
|
90
182
|
const res = activeRule.pattern.exec(text);
|
|
91
183
|
if (res && (activeRule.predicate?.(res) ?? true)) {
|
|
92
184
|
const { index } = res;
|
|
@@ -96,7 +188,7 @@ const parseForInlineRules = (rules, text, forSyntaxHighlighting) => {
|
|
|
96
188
|
...(before.length > 0
|
|
97
189
|
? parseForInlineRules(rules.slice(1), before, forSyntaxHighlighting)
|
|
98
190
|
: []),
|
|
99
|
-
activeRule.map(res, text => parseForInlineRules(rules.slice(1), text, forSyntaxHighlighting)
|
|
191
|
+
(forSyntaxHighlighting ? activeRule.mapHighlighting : activeRule.map)(res, text => parseForInlineRules(rules.slice(1), text, forSyntaxHighlighting)),
|
|
100
192
|
...(after.length > 0 ? parseForInlineRules(rules, after, forSyntaxHighlighting) : []),
|
|
101
193
|
];
|
|
102
194
|
}
|
|
@@ -105,6 +197,10 @@ const parseForInlineRules = (rules, text, forSyntaxHighlighting) => {
|
|
|
105
197
|
}
|
|
106
198
|
};
|
|
107
199
|
const parseInlineMarkdown = (text, forSyntaxHighlighting) => parseForInlineRules(inlineRules, text, forSyntaxHighlighting);
|
|
200
|
+
const nodesForTrailingWhitespace = (text) => {
|
|
201
|
+
const trailingWhitespace = text ?? "";
|
|
202
|
+
return trailingWhitespace.length === 0 ? [] : [textNode(trailingWhitespace)];
|
|
203
|
+
};
|
|
108
204
|
const listRule = {
|
|
109
205
|
pattern: /^((?:(?:\d+\.|[-*]) [^\n]+?)(?:\n(?:\d+\.|[-*]) [^\n]+?)*)(\n{2,}|$)/,
|
|
110
206
|
map: result => ({
|
|
@@ -122,9 +218,9 @@ const listRule = {
|
|
|
122
218
|
content: /^(\d+\. |[-*] )/.exec(item)?.[1] ?? "",
|
|
123
219
|
},
|
|
124
220
|
...parseInlineMarkdown(item.replace(/^\d+\. |[-*] /, ""), true),
|
|
125
|
-
...(index < array.length - 1 ? [
|
|
221
|
+
...(index < array.length - 1 ? [textNode("\n")] : []),
|
|
126
222
|
]),
|
|
127
|
-
|
|
223
|
+
...nodesForTrailingWhitespace(result[2]),
|
|
128
224
|
],
|
|
129
225
|
};
|
|
130
226
|
const paragraphRule = {
|
|
@@ -135,10 +231,14 @@ const paragraphRule = {
|
|
|
135
231
|
}),
|
|
136
232
|
mapHighlighting: result => [
|
|
137
233
|
...parseInlineMarkdown(result[1] ?? "", true),
|
|
138
|
-
|
|
234
|
+
...nodesForTrailingWhitespace(result[2]),
|
|
139
235
|
],
|
|
140
236
|
};
|
|
141
237
|
const removeSurroundingPipes = (text) => text.replace(/^\|/, "").replace(/\|$/, "");
|
|
238
|
+
const tableMarker = (text) => ({
|
|
239
|
+
kind: "tablemarker",
|
|
240
|
+
content: text,
|
|
241
|
+
});
|
|
142
242
|
const tableRule = {
|
|
143
243
|
pattern: /^(\| *)?(.+?(?: *(?<!\\)\| *.+?)+)( *\|)?\n((?:\| *)?(?:-{3,}|:-{2,}|-{2,}:|:-+:)(?: *\| *(?:-{3,}|:-{2,}|-{2,}:|:-+:))*(?: *\|)?)((?:\n\|? *.+?(?: *(?<!\\)\| *.+?)* *(?<!\\)\|?)+)(\n{2,}|$)/,
|
|
144
244
|
map: result => ({
|
|
@@ -152,86 +252,49 @@ const tableRule = {
|
|
|
152
252
|
.map(tc => parseInlineMarkdown(tc.trim(), false))) ?? [],
|
|
153
253
|
}),
|
|
154
254
|
mapHighlighting: result => [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
...(result[2]?.split("|").flatMap((th, i) => i === 0
|
|
255
|
+
tableMarker(result[1] ?? ""),
|
|
256
|
+
...(result[2]
|
|
257
|
+
?.split("|")
|
|
258
|
+
.flatMap((th, i) => i === 0
|
|
160
259
|
? parseInlineMarkdown(th, true)
|
|
161
|
-
: [
|
|
162
|
-
|
|
163
|
-
kind: "tablemarker",
|
|
164
|
-
content: "|",
|
|
165
|
-
},
|
|
166
|
-
...parseInlineMarkdown(th, true),
|
|
167
|
-
]) ?? []),
|
|
168
|
-
{
|
|
169
|
-
kind: "tablemarker",
|
|
170
|
-
content: (result[3] ?? "") + "\n" + (result[4] ?? ""),
|
|
171
|
-
},
|
|
260
|
+
: [tableMarker("|"), ...parseInlineMarkdown(th, true)]) ?? []),
|
|
261
|
+
tableMarker((result[3] ?? "") + "\n" + (result[4] ?? "")),
|
|
172
262
|
...(result[5]
|
|
173
263
|
?.split("\n")
|
|
174
264
|
.slice(1)
|
|
175
265
|
.flatMap((tr) => [
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
...tr.split("|").flatMap((tc, i) => i === 0
|
|
266
|
+
textNode("\n"),
|
|
267
|
+
...tr
|
|
268
|
+
.split("|")
|
|
269
|
+
.flatMap((tc, i) => i === 0
|
|
181
270
|
? parseInlineMarkdown(tc, true)
|
|
182
|
-
: [
|
|
183
|
-
{
|
|
184
|
-
kind: "tablemarker",
|
|
185
|
-
content: "|",
|
|
186
|
-
},
|
|
187
|
-
...parseInlineMarkdown(tc, true),
|
|
188
|
-
]),
|
|
271
|
+
: [tableMarker("|"), ...parseInlineMarkdown(tc, true)]),
|
|
189
272
|
]) ?? []),
|
|
190
|
-
|
|
191
|
-
kind: "text",
|
|
192
|
-
content: result[6] ?? "",
|
|
193
|
-
},
|
|
273
|
+
...nodesForTrailingWhitespace(result[6]),
|
|
194
274
|
],
|
|
195
275
|
};
|
|
196
276
|
const blockRules = [tableRule, listRule, paragraphRule];
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
return [{ kind: "paragraph", content: [{ kind: "text", content: text }] }];
|
|
204
|
-
}
|
|
205
|
-
const res = activeRule.pattern.exec(text);
|
|
206
|
-
if (res && (activeRule.predicate?.(res) ?? true)) {
|
|
207
|
-
const { index } = res;
|
|
208
|
-
const after = text.slice(index + res[0].length);
|
|
209
|
-
return [activeRule.map(res), ...(after.length > 0 ? parseForBlockRules(rules, after) : [])];
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
return parseForBlockRules(rules, text, remainingRules.slice(1));
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
const parseForBlockRulesSyntaxHighlighting = (rules, text, remainingRules = rules) => {
|
|
216
|
-
if (text.length === 0) {
|
|
277
|
+
const parseActiveBlockRule = (rule, res) => [
|
|
278
|
+
rule.map(res),
|
|
279
|
+
];
|
|
280
|
+
const parseActiveBlockSyntaxRule = (rule, res) => rule.mapHighlighting(res);
|
|
281
|
+
const parseForBlockRules = (rules, text, ruleParser, remainingRules = rules) => {
|
|
282
|
+
if (text.length === 0 || remainingRules[0] === undefined) {
|
|
217
283
|
return [];
|
|
218
284
|
}
|
|
219
285
|
const activeRule = remainingRules[0];
|
|
220
|
-
if (activeRule === undefined) {
|
|
221
|
-
return [{ kind: "text", content: text }];
|
|
222
|
-
}
|
|
223
286
|
const res = activeRule.pattern.exec(text);
|
|
224
287
|
if (res && (activeRule.predicate?.(res) ?? true)) {
|
|
225
288
|
const { index } = res;
|
|
226
289
|
const after = text.slice(index + res[0].length);
|
|
227
290
|
return [
|
|
228
|
-
...activeRule
|
|
229
|
-
...(after.length > 0 ?
|
|
291
|
+
...ruleParser(activeRule, res),
|
|
292
|
+
...(after.length > 0 ? parseForBlockRules(rules, after, ruleParser) : []),
|
|
230
293
|
];
|
|
231
294
|
}
|
|
232
295
|
else {
|
|
233
|
-
return
|
|
296
|
+
return parseForBlockRules(rules, text, ruleParser, remainingRules.slice(1));
|
|
234
297
|
}
|
|
235
298
|
};
|
|
236
|
-
export const parseBlockMarkdown = (text) => parseForBlockRules(blockRules, text);
|
|
237
|
-
export const parseBlockMarkdownForSyntaxHighlighting = (text) =>
|
|
299
|
+
export const parseBlockMarkdown = (text) => parseForBlockRules(blockRules, text, parseActiveBlockRule);
|
|
300
|
+
export const parseBlockMarkdownForSyntaxHighlighting = (text) => parseForBlockRules(blockRules, text, parseActiveBlockSyntaxRule);
|
|
@@ -4,3 +4,5 @@ export declare const mergeObjects: <T>(obj1: Record<string, T>, obj2: Record<str
|
|
|
4
4
|
export type Leaves<T> = T extends object ? {
|
|
5
5
|
[K in keyof T]: T[K] extends unknown[] ? never : `${Exclude<K, symbol>}${Leaves<T[K]> extends never ? "" : `.${Leaves<T[K]>}`}`;
|
|
6
6
|
}[keyof T] : never;
|
|
7
|
+
export declare const onlyKeys: <T extends object, K extends keyof T>(obj: T, ...keys: K[]) => Pick<T, K>;
|
|
8
|
+
export declare const hasKey: <T extends object, K extends PropertyKey>(obj: T, key: K) => obj is T & { [k in K]: unknown; };
|
|
@@ -8,3 +8,5 @@ export const mergeObjects = (obj1, obj2, solveConflict) => Object.entries(obj2).
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
9
|
[key]: Object.hasOwn(acc, key) ? solveConflict(acc[key], value) : value,
|
|
10
10
|
}), obj1);
|
|
11
|
+
export const onlyKeys = (obj, ...keys) => Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key)));
|
|
12
|
+
export const hasKey = (obj, key) => Object.hasOwn(obj, key);
|
|
@@ -19,7 +19,10 @@ export interface Error<E> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Creates a result that contains a value.
|
|
21
21
|
*/
|
|
22
|
-
export declare const ok:
|
|
22
|
+
export declare const ok: {
|
|
23
|
+
(): Result<void, never>;
|
|
24
|
+
<T>(value: T): Result<T, never>;
|
|
25
|
+
};
|
|
23
26
|
/**
|
|
24
27
|
* Checks if a result contains a value.
|
|
25
28
|
*/
|
|
@@ -46,7 +49,10 @@ export declare const map: <T, U, E>(result: Result<T, E>, f: (value: T) => U) =>
|
|
|
46
49
|
export declare const mapError: <T, E, F>(result: Result<T, E>, f: (value: E) => F) => Result<T, F>;
|
|
47
50
|
export declare const combine: <T1, T2, TR, E1, E2, ER>(result1: Result<T1, E1>, result2: Result<T2, E2>, fok: (value1: T1, value2: T2) => TR, ferror: (error1: E1, error2: E2) => ER) => Result<TR, E1 | E2 | ER>;
|
|
48
51
|
export declare const Result: Readonly<{
|
|
49
|
-
ok:
|
|
52
|
+
ok: {
|
|
53
|
+
(): Result<void, never>;
|
|
54
|
+
<T>(value: T): Result<T, never>;
|
|
55
|
+
};
|
|
50
56
|
isOk: <T, E>(result: Result<T, E>) => result is Ok<T>;
|
|
51
57
|
error: <E>(error: E) => Result<never, E>;
|
|
52
58
|
isError: <T, E>(result: Result<T, E>) => result is Error<E>;
|