tsondb 0.21.0 → 0.21.2
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/node/config.d.ts +2 -2
- package/dist/src/node/git.d.ts +4 -4
- package/dist/src/node/index.d.ts +39 -4
- package/dist/src/node/index.js +112 -11
- package/dist/src/node/renderers/jsonschema/render.js +7 -0
- package/dist/src/node/renderers/ts/render.d.ts +8 -0
- package/dist/src/node/renderers/ts/render.js +12 -0
- package/dist/src/node/schema/dsl/declarations/Decl.d.ts +3 -2
- package/dist/src/node/schema/dsl/declarations/Decl.js +2 -1
- package/dist/src/node/schema/dsl/declarations/SingletonEntityDecl.d.ts +35 -0
- package/dist/src/node/schema/dsl/declarations/SingletonEntityDecl.js +23 -0
- package/dist/src/node/schema/dsl/index.d.ts +1 -0
- package/dist/src/node/schema/dsl/index.js +1 -0
- package/dist/src/node/schema/generatedTypeHelpers.d.ts +18 -0
- package/dist/src/node/schema/guards.d.ts +1 -0
- package/dist/src/node/schema/guards.js +1 -0
- package/dist/src/node/schema/helpers.js +1 -0
- package/dist/src/node/schema/index.d.ts +12 -1
- package/dist/src/node/schema/index.js +44 -0
- package/dist/src/node/schema/treeOperations/customConstraints.d.ts +2 -1
- package/dist/src/node/schema/treeOperations/customConstraints.js +10 -10
- package/dist/src/node/schema/treeOperations/implicitSchema.js +1 -0
- package/dist/src/node/schema/treeOperations/references.js +1 -0
- package/dist/src/node/schema/treeOperations/serialization.d.ts +4 -1
- package/dist/src/node/schema/treeOperations/serialization.js +8 -0
- package/dist/src/node/schema/treeOperations/typeResolution.d.ts +4 -1
- package/dist/src/node/schema/treeOperations/typeResolution.js +6 -0
- package/dist/src/node/schema/treeOperations/validation.js +2 -0
- package/dist/src/node/server/api/declarations.js +165 -23
- package/dist/src/node/transaction.d.ts +28 -11
- package/dist/src/node/transaction.js +93 -0
- package/dist/src/node/utils/customConstraints.d.ts +6 -5
- package/dist/src/node/utils/customConstraints.js +34 -15
- package/dist/src/node/utils/databaseInMemory.d.ts +20 -8
- package/dist/src/node/utils/databaseInMemory.js +67 -9
- package/dist/src/node/utils/databaseOnDisk.js +27 -30
- package/dist/src/node/utils/files.d.ts +7 -2
- package/dist/src/node/utils/files.js +9 -0
- package/dist/src/node/utils/references.d.ts +2 -0
- package/dist/src/node/utils/references.js +6 -1
- package/dist/src/shared/api.d.ts +41 -2
- package/dist/src/shared/schema/Node.d.ts +5 -1
- package/dist/src/shared/schema/Node.js +6 -0
- package/dist/src/shared/schema/declarations/Declaration.d.ts +3 -2
- package/dist/src/shared/schema/declarations/SingletonEntityDecl.d.ts +18 -0
- package/dist/src/shared/schema/declarations/SingletonEntityDecl.js +8 -0
- package/dist/src/shared/utils/childInstances.d.ts +4 -0
- package/dist/src/shared/utils/instances.d.ts +4 -0
- package/dist/src/web/web.js +573 -130
- package/package.json +1 -1
- package/public/css/styles.css +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SerializedDecl } from "./declarations/Declaration.ts";
|
|
2
2
|
import { type SerializedEntityDecl } from "./declarations/EntityDecl.ts";
|
|
3
3
|
import { type SerializedEnumDecl } from "./declarations/EnumDecl.ts";
|
|
4
|
+
import { type SerializedSingletonEntityDecl } from "./declarations/SingletonEntityDecl.ts";
|
|
4
5
|
import { type SerializedTypeAliasDecl } from "./declarations/TypeAliasDecl.ts";
|
|
5
6
|
import { type SerializedTypeParameter } from "./TypeParameter.ts";
|
|
6
7
|
import { type SerializedArrayType } from "./types/ArrayType.ts";
|
|
@@ -21,6 +22,7 @@ import { type SerializedTypeArgumentType } from "./types/TypeArgumentType.ts";
|
|
|
21
22
|
export interface NodeKind {
|
|
22
23
|
ChildEntityDecl: "ChildEntityDecl";
|
|
23
24
|
EntityDecl: "EntityDecl";
|
|
25
|
+
SingletonEntityDecl: "SingletonEntityDecl";
|
|
24
26
|
EnumDecl: "EnumDecl";
|
|
25
27
|
EnumCaseDecl: "EnumCaseDecl";
|
|
26
28
|
TypeAliasDecl: "TypeAliasDecl";
|
|
@@ -48,7 +50,9 @@ export interface BaseNode {
|
|
|
48
50
|
export type SerializedNode = SerializedDecl | SerializedType | SerializedTypeParameter;
|
|
49
51
|
export type SerializedNodeWithResolvedTypeArguments<T extends SerializedNode | null> = T extends SerializedBooleanType | SerializedDateType | SerializedFloatType | SerializedIntegerType | SerializedStringType | SerializedReferenceIdentifierType | SerializedChildEntitiesType | SerializedTranslationObjectType ? T : T extends SerializedEntityDecl<infer N, infer P, infer FK> ? SerializedEntityDecl<N, {
|
|
50
52
|
[K in keyof P]: P[K] extends SerializedMemberDecl<infer PT, infer R> ? SerializedMemberDecl<SerializedNodeWithResolvedTypeArguments<PT>, R> : never;
|
|
51
|
-
}, FK> : T extends
|
|
53
|
+
}, FK> : T extends SerializedSingletonEntityDecl<infer N, infer P> ? SerializedSingletonEntityDecl<N, {
|
|
54
|
+
[K in keyof P]: P[K] extends SerializedMemberDecl<infer PT, infer R> ? SerializedMemberDecl<SerializedNodeWithResolvedTypeArguments<PT>, R> : never;
|
|
55
|
+
}> : T extends SerializedEnumDecl<infer N, infer V, SerializedTypeParameter[]> ? SerializedEnumDecl<N, {
|
|
52
56
|
[K in keyof V]: V[K] extends SerializedEnumCaseDecl<infer CT> ? SerializedEnumCaseDecl<SerializedNodeWithResolvedTypeArguments<CT>> : never;
|
|
53
57
|
}, [
|
|
54
58
|
]> : T extends SerializedTypeAliasDecl<infer N, infer U, SerializedTypeParameter[]> ? SerializedTypeAliasDecl<N, SerializedNodeWithResolvedTypeArguments<U>, []> : T extends SerializedArrayType<infer I> ? SerializedArrayType<SerializedNodeWithResolvedTypeArguments<I>> : T extends SerializedEnumType<infer V> ? SerializedEnumType<{
|
|
@@ -2,6 +2,7 @@ import { assertExhaustive } from "@elyukai/utils/typeSafety";
|
|
|
2
2
|
import { enumOfObject } from "../utils/enum.js";
|
|
3
3
|
import { getReferencesForSerializedEntityDecl, resolveTypeArgumentsInSerializedEntityDecl, } from "./declarations/EntityDecl.js";
|
|
4
4
|
import { getReferencesForSerializedEnumDecl, resolveTypeArgumentsInSerializedEnumDecl, } from "./declarations/EnumDecl.js";
|
|
5
|
+
import { getReferencesForSerializedSingletonEntityDecl, resolveTypeArgumentsInSerializedSingletonEntityDecl, } from "./declarations/SingletonEntityDecl.js";
|
|
5
6
|
import { getReferencesForSerializedTypeAliasDecl, resolveTypeArgumentsInSerializedTypeAliasDecl, } from "./declarations/TypeAliasDecl.js";
|
|
6
7
|
import { getReferencesForSerializedTypeParameter, resolveTypeArgumentsInSerializedTypeParameter, } from "./TypeParameter.js";
|
|
7
8
|
import { getReferencesForSerializedArrayType, resolveTypeArgumentsInSerializedArrayType, } from "./types/ArrayType.js";
|
|
@@ -21,6 +22,7 @@ import { getReferencesForSerializedTypeArgumentType, resolveTypeArgumentsInSeria
|
|
|
21
22
|
export const NodeKind = enumOfObject({
|
|
22
23
|
ChildEntityDecl: null,
|
|
23
24
|
EntityDecl: null,
|
|
25
|
+
SingletonEntityDecl: null,
|
|
24
26
|
EnumDecl: null,
|
|
25
27
|
EnumCaseDecl: null,
|
|
26
28
|
TypeAliasDecl: null,
|
|
@@ -45,6 +47,8 @@ export const resolveSerializedTypeArguments = (decls, args, node) => {
|
|
|
45
47
|
switch (node.kind) {
|
|
46
48
|
case NodeKind.EntityDecl:
|
|
47
49
|
return resolveTypeArgumentsInSerializedEntityDecl(decls, args, node);
|
|
50
|
+
case NodeKind.SingletonEntityDecl:
|
|
51
|
+
return resolveTypeArgumentsInSerializedSingletonEntityDecl(decls, args, node);
|
|
48
52
|
case NodeKind.EnumDecl:
|
|
49
53
|
return resolveTypeArgumentsInSerializedEnumDecl(decls, args, node);
|
|
50
54
|
case NodeKind.TypeAliasDecl:
|
|
@@ -87,6 +91,8 @@ export const getReferencesSerialized = (decls, node, value) => {
|
|
|
87
91
|
switch (node.kind) {
|
|
88
92
|
case NodeKind.EntityDecl:
|
|
89
93
|
return getReferencesForSerializedEntityDecl(decls, node, value);
|
|
94
|
+
case NodeKind.SingletonEntityDecl:
|
|
95
|
+
return getReferencesForSerializedSingletonEntityDecl(decls, node, value);
|
|
90
96
|
case NodeKind.EnumDecl:
|
|
91
97
|
return getReferencesForSerializedEnumDecl(decls, node, value);
|
|
92
98
|
case NodeKind.TypeAliasDecl:
|
|
@@ -5,13 +5,14 @@ import type { SerializedMemberDecl } from "../types/ObjectType.ts";
|
|
|
5
5
|
import { type SerializedType } from "../types/Type.ts";
|
|
6
6
|
import type { SerializedEntityDecl } from "./EntityDecl.ts";
|
|
7
7
|
import type { SerializedEnumDecl } from "./EnumDecl.ts";
|
|
8
|
+
import type { SerializedSingletonEntityDecl } from "./SingletonEntityDecl.ts";
|
|
8
9
|
import type { SerializedTypeAliasDecl } from "./TypeAliasDecl.ts";
|
|
9
10
|
export type SerializedTypeArguments<Params extends SerializedTypeParameter[]> = {
|
|
10
11
|
[K in keyof Params]: Params[K] extends SerializedTypeParameter<string, infer T> ? T : SerializedType;
|
|
11
12
|
};
|
|
12
13
|
export declare const getSerializedTypeArgumentsRecord: <Params extends SerializedTypeParameter[]>(decl: SerializedDeclP<Params>, args: SerializedTypeArguments<Params>) => Record<string, SerializedType>;
|
|
13
|
-
export type SerializedDecl = SerializedEntityDecl | SerializedEnumDecl | SerializedTypeAliasDecl;
|
|
14
|
-
export type SerializedDeclP<Params extends SerializedTypeParameter[] = SerializedTypeParameter[]> = SerializedEntityDecl | SerializedEnumDecl<string, Record<string, SerializedEnumCaseDecl>, Params> | SerializedTypeAliasDecl<string, SerializedType, Params>;
|
|
14
|
+
export type SerializedDecl = SerializedEntityDecl | SerializedSingletonEntityDecl | SerializedEnumDecl | SerializedTypeAliasDecl;
|
|
15
|
+
export type SerializedDeclP<Params extends SerializedTypeParameter[] = SerializedTypeParameter[]> = SerializedEntityDecl | SerializedSingletonEntityDecl | SerializedEnumDecl<string, Record<string, SerializedEnumCaseDecl>, Params> | SerializedTypeAliasDecl<string, SerializedType, Params>;
|
|
15
16
|
export type SerializedSecondaryDecl = SerializedEnumDecl | SerializedTypeAliasDecl | SerializedEntityDecl<string, Record<string, SerializedMemberDecl>, string>;
|
|
16
17
|
export type GetDeclFromDeclName = (name: string) => SerializedSecondaryDecl | undefined;
|
|
17
18
|
export interface SerializedBaseDecl<Name extends string = string, Params extends SerializedTypeParameter[] = SerializedTypeParameter[]> extends BaseNode {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NodeKind, type GetReferencesSerialized, type SerializedNode, type SerializedTypeArgumentsResolver } from "../Node.ts";
|
|
2
|
+
import { type SerializedMemberDecl, type SerializedObjectType } from "../types/ObjectType.ts";
|
|
3
|
+
import type { SerializedBaseDecl } from "./Declaration.ts";
|
|
4
|
+
type TSerializedConstraint = Record<string, SerializedMemberDecl>;
|
|
5
|
+
export interface SerializedSingletonEntityDecl<Name extends string = string, T extends TSerializedConstraint = TSerializedConstraint> extends SerializedBaseDecl<Name, []> {
|
|
6
|
+
kind: NodeKind["SingletonEntityDecl"];
|
|
7
|
+
/**
|
|
8
|
+
* Changes the appearance of the entity’s name in singular form.
|
|
9
|
+
*/
|
|
10
|
+
displayName?: string;
|
|
11
|
+
type: SerializedObjectType<T>;
|
|
12
|
+
isDeprecated?: boolean;
|
|
13
|
+
customConstraints: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const isSerializedSingletonEntityDecl: (node: SerializedNode) => node is SerializedSingletonEntityDecl;
|
|
16
|
+
export declare const resolveTypeArgumentsInSerializedSingletonEntityDecl: SerializedTypeArgumentsResolver<SerializedSingletonEntityDecl>;
|
|
17
|
+
export declare const getReferencesForSerializedSingletonEntityDecl: GetReferencesSerialized<SerializedSingletonEntityDecl>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NodeKind, resolveSerializedTypeArguments, } from "../Node.js";
|
|
2
|
+
import { getReferencesForSerializedObjectType, } from "../types/ObjectType.js";
|
|
3
|
+
export const isSerializedSingletonEntityDecl = (node) => node.kind === NodeKind.SingletonEntityDecl;
|
|
4
|
+
export const resolveTypeArgumentsInSerializedSingletonEntityDecl = (decls, _args, decl) => ({
|
|
5
|
+
...decl,
|
|
6
|
+
type: resolveSerializedTypeArguments(decls, {}, decl.type),
|
|
7
|
+
});
|
|
8
|
+
export const getReferencesForSerializedSingletonEntityDecl = (decls, decl, value) => getReferencesForSerializedObjectType(decls, decl.type, value);
|
|
@@ -10,6 +10,10 @@ export interface EntityTaggedInstanceContainer {
|
|
|
10
10
|
id: string;
|
|
11
11
|
content: InstanceContent;
|
|
12
12
|
}
|
|
13
|
+
export interface EntityTaggedSingletonInstanceContainer {
|
|
14
|
+
entityName: string;
|
|
15
|
+
content: InstanceContent;
|
|
16
|
+
}
|
|
13
17
|
export interface CreatedEntityTaggedInstanceContainerWithChildInstances extends GenEntityTaggedInstanceContainerWithChildInstances<undefined, UnsafeEntityTaggedInstanceContainerWithChildInstances> {
|
|
14
18
|
}
|
|
15
19
|
export interface UpdatedEntityTaggedInstanceContainerWithChildInstances extends GenEntityTaggedInstanceContainerWithChildInstances<string, UnsafeEntityTaggedInstanceContainerWithChildInstances> {
|
|
@@ -5,6 +5,10 @@ export interface InstanceContainer<T = InstanceContent> {
|
|
|
5
5
|
content: T;
|
|
6
6
|
gitStatus?: GitFileStatus;
|
|
7
7
|
}
|
|
8
|
+
export interface SingletonInstanceContainer<T = InstanceContent> {
|
|
9
|
+
content: T;
|
|
10
|
+
gitStatus?: GitFileStatus;
|
|
11
|
+
}
|
|
8
12
|
export interface InstanceContainerOverview {
|
|
9
13
|
id: string;
|
|
10
14
|
gitStatus?: GitFileStatus;
|