tsondb 0.18.1 → 0.19.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 (130) hide show
  1. package/dist/src/node/config.d.ts +2 -2
  2. package/dist/src/node/index.d.ts +11 -4
  3. package/dist/src/node/index.js +16 -4
  4. package/dist/src/node/renderers/jsonschema/index.js +1 -1
  5. package/dist/src/node/renderers/jsonschema/render.d.ts +1 -1
  6. package/dist/src/node/renderers/jsonschema/render.js +9 -8
  7. package/dist/src/node/renderers/ts/index.js +1 -1
  8. package/dist/src/node/renderers/ts/render.d.ts +1 -1
  9. package/dist/src/node/renderers/ts/render.js +11 -10
  10. package/dist/src/node/schema/dsl/TypeParameter.d.ts +9 -0
  11. package/dist/src/node/schema/dsl/TypeParameter.js +7 -0
  12. package/dist/src/node/schema/{declarations/Declaration.d.ts → dsl/declarations/Decl.d.ts} +4 -4
  13. package/dist/src/node/schema/{declarations/Declaration.js → dsl/declarations/Decl.js} +4 -15
  14. package/dist/src/node/schema/{declarations → dsl/declarations}/EntityDecl.d.ts +11 -21
  15. package/dist/src/node/schema/{declarations → dsl/declarations}/EntityDecl.js +5 -21
  16. package/dist/src/node/schema/{declarations → dsl/declarations}/EnumDecl.d.ts +8 -14
  17. package/dist/src/node/schema/dsl/declarations/EnumDecl.js +26 -0
  18. package/dist/src/node/schema/{declarations → dsl/declarations}/TypeAliasDecl.d.ts +6 -12
  19. package/dist/src/node/schema/dsl/declarations/TypeAliasDecl.js +22 -0
  20. package/dist/src/node/schema/dsl/index.d.ts +24 -0
  21. package/dist/src/node/schema/dsl/index.js +19 -0
  22. package/dist/src/node/schema/dsl/types/ArrayType.d.ts +17 -0
  23. package/dist/src/node/schema/dsl/types/ArrayType.js +11 -0
  24. package/dist/src/node/schema/dsl/types/BooleanType.d.ts +9 -0
  25. package/dist/src/node/schema/dsl/types/BooleanType.js +6 -0
  26. package/dist/src/node/schema/dsl/types/ChildEntitiesType.d.ts +12 -0
  27. package/dist/src/node/schema/dsl/types/ChildEntitiesType.js +8 -0
  28. package/dist/src/node/schema/dsl/types/DateType.d.ts +10 -0
  29. package/dist/src/node/schema/dsl/types/DateType.js +7 -0
  30. package/dist/src/node/schema/{types/generic → dsl/types}/EnumType.d.ts +4 -11
  31. package/dist/src/node/schema/dsl/types/EnumType.js +11 -0
  32. package/dist/src/node/schema/dsl/types/FloatType.d.ts +13 -0
  33. package/dist/src/node/schema/dsl/types/FloatType.js +13 -0
  34. package/dist/src/node/schema/dsl/types/IncludeIdentifierType.d.ts +20 -0
  35. package/dist/src/node/schema/dsl/types/IncludeIdentifierType.js +16 -0
  36. package/dist/src/node/schema/dsl/types/IntegerType.d.ts +10 -0
  37. package/dist/src/node/schema/dsl/types/IntegerType.js +11 -0
  38. package/dist/src/node/schema/dsl/types/NestedEntityMapType.d.ts +38 -0
  39. package/dist/src/node/schema/dsl/types/NestedEntityMapType.js +21 -0
  40. package/dist/src/node/schema/{types/generic → dsl/types}/ObjectType.d.ts +4 -11
  41. package/dist/src/node/schema/dsl/types/ObjectType.js +27 -0
  42. package/dist/src/node/schema/dsl/types/ReferenceIdentifierType.d.ts +11 -0
  43. package/dist/src/node/schema/dsl/types/ReferenceIdentifierType.js +7 -0
  44. package/dist/src/node/schema/dsl/types/StringType.d.ts +17 -0
  45. package/dist/src/node/schema/dsl/types/StringType.js +7 -0
  46. package/dist/src/node/schema/dsl/types/TranslationObjectType.d.ts +19 -0
  47. package/dist/src/node/schema/dsl/types/TranslationObjectType.js +20 -0
  48. package/dist/src/node/schema/dsl/types/Type.d.ts +18 -0
  49. package/dist/src/node/schema/dsl/types/TypeArgumentType.d.ts +12 -0
  50. package/dist/src/node/schema/dsl/types/TypeArgumentType.js +7 -0
  51. package/dist/src/node/schema/generatedTypeHelpers.d.ts +124 -0
  52. package/dist/src/node/schema/generatedTypeHelpers.js +29 -0
  53. package/dist/src/node/schema/guards.d.ts +17 -0
  54. package/dist/src/node/schema/guards.js +17 -0
  55. package/dist/src/node/schema/helpers.d.ts +82 -80
  56. package/dist/src/node/schema/helpers.js +139 -26
  57. package/dist/src/node/schema/index.d.ts +16 -22
  58. package/dist/src/node/schema/index.js +412 -21
  59. package/dist/src/node/schema/treeOperations/customConstraints.d.ts +5 -0
  60. package/dist/src/node/schema/treeOperations/customConstraints.js +57 -0
  61. package/dist/src/node/schema/treeOperations/format.d.ts +5 -0
  62. package/dist/src/node/schema/treeOperations/format.js +77 -0
  63. package/dist/src/node/schema/treeOperations/implicitSchema.d.ts +10 -0
  64. package/dist/src/node/schema/treeOperations/implicitSchema.js +51 -0
  65. package/dist/src/node/schema/treeOperations/references.d.ts +3 -0
  66. package/dist/src/node/schema/treeOperations/references.js +59 -0
  67. package/dist/src/node/schema/treeOperations/serialization.d.ts +71 -0
  68. package/dist/src/node/schema/treeOperations/serialization.js +143 -0
  69. package/dist/src/node/schema/treeOperations/typeResolution.d.ts +35 -0
  70. package/dist/src/node/schema/treeOperations/typeResolution.js +103 -0
  71. package/dist/src/node/schema/treeOperations/validation.d.ts +16 -0
  72. package/dist/src/node/schema/treeOperations/validation.js +218 -0
  73. package/dist/src/node/server/api/declarations.js +4 -4
  74. package/dist/src/node/transaction.d.ts +2 -2
  75. package/dist/src/node/transaction.js +3 -2
  76. package/dist/src/node/utils/childInstances.d.ts +1 -1
  77. package/dist/src/node/utils/childInstances.js +6 -3
  78. package/dist/src/node/utils/customConstraints.d.ts +1 -2
  79. package/dist/src/node/utils/customConstraints.js +3 -3
  80. package/dist/src/node/utils/databaseInMemory.d.ts +2 -2
  81. package/dist/src/node/utils/displayName.d.ts +2 -3
  82. package/dist/src/node/utils/displayName.js +3 -3
  83. package/dist/src/node/utils/files.d.ts +1 -1
  84. package/dist/src/node/utils/files.js +2 -1
  85. package/dist/src/node/utils/git.d.ts +1 -1
  86. package/dist/src/node/utils/references.d.ts +1 -2
  87. package/dist/src/node/utils/references.js +5 -5
  88. package/dist/src/node/utils/unique.d.ts +1 -1
  89. package/dist/src/shared/output.d.ts +1 -1
  90. package/dist/src/shared/schema/declarations/EntityDecl.d.ts +1 -1
  91. package/dist/src/shared/utils/instances.d.ts +2 -2
  92. package/package.json +4 -3
  93. package/dist/src/node/schema/Node.d.ts +0 -125
  94. package/dist/src/node/schema/Node.js +0 -324
  95. package/dist/src/node/schema/Schema.d.ts +0 -17
  96. package/dist/src/node/schema/Schema.js +0 -411
  97. package/dist/src/node/schema/TypeParameter.d.ts +0 -13
  98. package/dist/src/node/schema/TypeParameter.js +0 -13
  99. package/dist/src/node/schema/declarations/EnumDecl.js +0 -47
  100. package/dist/src/node/schema/declarations/TypeAliasDecl.js +0 -39
  101. package/dist/src/node/schema/externalTypes.d.ts +0 -44
  102. package/dist/src/node/schema/types/Type.d.ts +0 -65
  103. package/dist/src/node/schema/types/Type.js +0 -161
  104. package/dist/src/node/schema/types/generic/ArrayType.d.ts +0 -24
  105. package/dist/src/node/schema/types/generic/ArrayType.js +0 -38
  106. package/dist/src/node/schema/types/generic/EnumType.js +0 -121
  107. package/dist/src/node/schema/types/generic/ObjectType.js +0 -82
  108. package/dist/src/node/schema/types/generic/TranslationObjectType.d.ts +0 -26
  109. package/dist/src/node/schema/types/generic/TranslationObjectType.js +0 -86
  110. package/dist/src/node/schema/types/primitives/BooleanType.d.ts +0 -17
  111. package/dist/src/node/schema/types/primitives/BooleanType.js +0 -19
  112. package/dist/src/node/schema/types/primitives/DateType.d.ts +0 -17
  113. package/dist/src/node/schema/types/primitives/DateType.js +0 -21
  114. package/dist/src/node/schema/types/primitives/FloatType.d.ts +0 -20
  115. package/dist/src/node/schema/types/primitives/FloatType.js +0 -29
  116. package/dist/src/node/schema/types/primitives/IntegerType.d.ts +0 -17
  117. package/dist/src/node/schema/types/primitives/IntegerType.js +0 -25
  118. package/dist/src/node/schema/types/primitives/StringType.d.ts +0 -24
  119. package/dist/src/node/schema/types/primitives/StringType.js +0 -24
  120. package/dist/src/node/schema/types/references/ChildEntitiesType.d.ts +0 -19
  121. package/dist/src/node/schema/types/references/ChildEntitiesType.js +0 -19
  122. package/dist/src/node/schema/types/references/IncludeIdentifierType.d.ts +0 -27
  123. package/dist/src/node/schema/types/references/IncludeIdentifierType.js +0 -63
  124. package/dist/src/node/schema/types/references/NestedEntityMapType.d.ts +0 -37
  125. package/dist/src/node/schema/types/references/NestedEntityMapType.js +0 -63
  126. package/dist/src/node/schema/types/references/ReferenceIdentifierType.d.ts +0 -18
  127. package/dist/src/node/schema/types/references/ReferenceIdentifierType.js +0 -23
  128. package/dist/src/node/schema/types/references/TypeArgumentType.d.ts +0 -19
  129. package/dist/src/node/schema/types/references/TypeArgumentType.js +0 -27
  130. /package/dist/src/node/schema/{externalTypes.js → dsl/types/Type.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { Output } from "../shared/output.ts";
2
2
  import type { ValidationOptions } from "./index.ts";
3
- import type { EntityDecl } from "./schema/index.ts";
4
- import type { Schema } from "./schema/Schema.ts";
3
+ import type { EntityDecl } from "./schema/dsl/index.ts";
4
+ import type { Schema } from "./schema/index.ts";
5
5
  /**
6
6
  * The main configuration type for TSONDB.
7
7
  */
@@ -1,10 +1,10 @@
1
1
  import type { Output } from "../shared/output.ts";
2
2
  import type { InstanceContainer, InstanceContainerOverview } from "../shared/utils/instances.ts";
3
3
  import { Git } from "./git.js";
4
- import type { AnyChildEntityMap, AnyEntityMap, AnyEnumMap, AnyTypeAliasMap } from "./schema/externalTypes.ts";
5
- import { type IdArgsVariant } from "./schema/helpers.ts";
6
- import { type EntityDecl } from "./schema/index.ts";
7
- import type { Schema } from "./schema/Schema.ts";
4
+ import { type EntityDecl } from "./schema/dsl/index.ts";
5
+ import type { AnyChildEntityMap, AnyEntityMap, AnyEnumMap, AnyTypeAliasMap } from "./schema/generatedTypeHelpers.ts";
6
+ import { type IdArgsVariant } from "./schema/generatedTypeHelpers.ts";
7
+ import type { Schema } from "./schema/index.ts";
8
8
  import { Transaction } from "./transaction.ts";
9
9
  export interface DefaultTSONDBTypes {
10
10
  entityMap: AnyEntityMap;
@@ -215,6 +215,13 @@ export declare class TSONDB<T extends DefaultTSONDBTypes = DefaultTSONDBTypes> {
215
215
  queryLowerCase: string;
216
216
  }) => number;
217
217
  }>): [string, InstanceContainerOverview][];
218
+ /**
219
+ * Compresses the entire database into a single JSON file at the specified path.
220
+ *
221
+ * Instead of storing each instance in its own file, this method serializes the entire database into a single JSON file. This can be useful for backup, transfer or archiving purposes. The resulting file contains all instances organized by entity names. No spaces or indentation are used in the JSON output to minimize file size.
222
+ * @param path The file path where the compressed database will be saved.
223
+ */
224
+ compressToSingleFile(path: string): Promise<void>;
218
225
  }
219
226
  export type TSONDBWithGit<T extends DefaultTSONDBTypes = DefaultTSONDBTypes> = TSONDB<T> & {
220
227
  git: Git<T>;
@@ -2,15 +2,18 @@ import { deepEqual } from "@elyukai/utils/equality";
2
2
  import { Lazy } from "@elyukai/utils/lazy";
3
3
  import { isError } from "@elyukai/utils/result";
4
4
  import Debug from "debug";
5
- import { mkdir } from "node:fs/promises";
5
+ import { mkdir, writeFile } from "node:fs/promises";
6
6
  import { join, sep } from "node:path";
7
7
  import { stderr } from "node:process";
8
8
  import { styleText } from "node:util";
9
9
  import { simpleGit } from "simple-git";
10
10
  import { parallelizeErrors } from "../shared/utils/validation.js";
11
11
  import { Git } from "./git.js";
12
- import { normalizedIdArgs } from "./schema/helpers.js";
13
- import { createValidationContext, isEntityDeclWithParentReference, serializeNode, validateEntityDecl, } from "./schema/index.js";
12
+ import {} from "./schema/dsl/index.js";
13
+ import { normalizedIdArgs } from "./schema/generatedTypeHelpers.js";
14
+ import { isEntityDeclWithParentReference } from "./schema/guards.js";
15
+ import { serializeNode } from "./schema/treeOperations/serialization.js";
16
+ import { createValidationContext, validateDecl } from "./schema/treeOperations/validation.js";
14
17
  import { Transaction } from "./transaction.js";
15
18
  import { checkCustomConstraintsForAllEntities } from "./utils/customConstraints.js";
16
19
  import { asyncForEachInstanceInDatabaseInMemory, countInstancesInDatabaseInMemory, countInstancesOfEntityInDatabaseInMemory, createDatabaseInMemory, getGroupedInstancesFromDatabaseInMemory, getInstanceOfEntityFromDatabaseInMemory, getInstancesOfEntityFromDatabaseInMemory, hasInstanceOfEntityFromDatabaseInMemory, } from "./utils/databaseInMemory.js";
@@ -159,7 +162,7 @@ export class TSONDB {
159
162
  const errors = (checkOnlyEntities.length > 0
160
163
  ? entities.filter(entity => checkOnlyEntities.includes(entity.name))
161
164
  : entities)
162
- .flatMap(entity => parallelizeErrors(getInstancesOfEntityFromDatabaseInMemory(this.#data, entity.name).map(instance => wrapErrorsIfAny(`in file ${styleText("white", `"${this.#dataRootPath}${sep}${styleText("bold", join(entity.name, getFileNameForId(instance.id)))}"`)}`, validateEntityDecl(validationContext, [], entity, instance.content)))))
165
+ .flatMap(entity => parallelizeErrors(getInstancesOfEntityFromDatabaseInMemory(this.#data, entity.name).map(instance => wrapErrorsIfAny(`in file ${styleText("white", `"${this.#dataRootPath}${sep}${styleText("bold", join(entity.name, getFileNameForId(instance.id)))}"`)}`, validateDecl(validationContext, [], entity, [], instance.content)))))
163
166
  .toSorted((a, b) => a.message.localeCompare(b.message));
164
167
  if (errors.length > 0) {
165
168
  const errorCount = countErrors(errors);
@@ -471,4 +474,13 @@ export class TSONDB {
471
474
  .toSorted((a, b) => a[1].relevance - b[1].relevance ||
472
475
  a[1].displayName.localeCompare(b[1].displayName, a[1].displayNameLocaleId));
473
476
  }
477
+ /**
478
+ * Compresses the entire database into a single JSON file at the specified path.
479
+ *
480
+ * Instead of storing each instance in its own file, this method serializes the entire database into a single JSON file. This can be useful for backup, transfer or archiving purposes. The resulting file contains all instances organized by entity names. No spaces or indentation are used in the JSON output to minimize file size.
481
+ * @param path The file path where the compressed database will be saved.
482
+ */
483
+ async compressToSingleFile(path) {
484
+ await writeFile(path, JSON.stringify(this.#data), "utf-8");
485
+ }
474
486
  }
@@ -3,7 +3,7 @@ import Debug from "debug";
3
3
  import { mkdir, rm, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, extname, join, relative } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { groupDeclarationsBySourceUrl } from "../../schema/index.js";
6
+ import { groupDeclarationsBySourceUrl } from "../../schema/dsl/declarations/Decl.js";
7
7
  import { render } from "./render.js";
8
8
  const debug = Debug("tsondb:renderer:jsonschema");
9
9
  const extension = ".schema.json";
@@ -1,4 +1,4 @@
1
- import { type Decl } from "../../schema/declarations/Declaration.ts";
1
+ import { type Decl } from "../../schema/dsl/declarations/Decl.ts";
2
2
  export type JsonSchemaRendererOptions = {
3
3
  format: "minified" | "tabs" | {
4
4
  kind: "spaces";
@@ -1,14 +1,15 @@
1
1
  import { assertExhaustive } from "@elyukai/utils/typeSafety";
2
2
  import { dirname, relative } from "node:path";
3
3
  import { ENUM_DISCRIMINATOR_KEY } from "../../../shared/schema/declarations/EnumDecl.js";
4
- import { asDecl } from "../../schema/declarations/Declaration.js";
5
- import { addEphemeralUUIDToType, createEntityIdentifierTypeAsDecl, isEntityDecl, } from "../../schema/declarations/EntityDecl.js";
6
- import { TypeAliasDecl } from "../../schema/declarations/TypeAliasDecl.js";
7
- import { flatMapAuxiliaryDecls, NodeKind } from "../../schema/Node.js";
8
- import { ArrayType } from "../../schema/types/generic/ArrayType.js";
9
- import { getTypeOfKey } from "../../schema/types/generic/TranslationObjectType.js";
10
- import { isNestedEntityMapType } from "../../schema/types/references/NestedEntityMapType.js";
11
- import { ReferenceIdentifierType } from "../../schema/types/references/ReferenceIdentifierType.js";
4
+ import { NodeKind } from "../../../shared/schema/Node.js";
5
+ import { asDecl } from "../../schema/dsl/declarations/Decl.js";
6
+ import { addEphemeralUUIDToType, createEntityIdentifierTypeAsDecl, isEntityDecl, } from "../../schema/dsl/declarations/EntityDecl.js";
7
+ import { TypeAliasDecl } from "../../schema/dsl/declarations/TypeAliasDecl.js";
8
+ import { ArrayType } from "../../schema/dsl/types/ArrayType.js";
9
+ import { isNestedEntityMapType } from "../../schema/dsl/types/NestedEntityMapType.js";
10
+ import { ReferenceIdentifierType } from "../../schema/dsl/types/ReferenceIdentifierType.js";
11
+ import { getTypeOfKey } from "../../schema/dsl/types/TranslationObjectType.js";
12
+ import { flatMapAuxiliaryDecls } from "../../schema/helpers.js";
12
13
  import { ensureSpecialDirStart } from "../../utils/path.js";
13
14
  const defaultIndentation = 2;
14
15
  const defaultOptions = {
@@ -3,7 +3,7 @@ import Debug from "debug";
3
3
  import { mkdir, rm, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, extname, join, relative } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { groupDeclarationsBySourceUrl } from "../../schema/declarations/Declaration.js";
6
+ import { groupDeclarationsBySourceUrl } from "../../schema/dsl/declarations/Decl.js";
7
7
  import { render } from "./render.js";
8
8
  const debug = Debug("tsondb:renderer:ts");
9
9
  const extension = ".d.ts";
@@ -1,4 +1,4 @@
1
- import { type Decl } from "../../schema/declarations/Declaration.ts";
1
+ import { type Decl } from "../../schema/dsl/declarations/Decl.ts";
2
2
  export type TypeScriptRendererOptions = {
3
3
  indentation: number;
4
4
  objectTypeKeyword: "interface" | "type";
@@ -4,17 +4,18 @@ import { assertExhaustive } from "@elyukai/utils/typeSafety";
4
4
  import { EOL } from "node:os";
5
5
  import { dirname, relative } from "node:path";
6
6
  import { ENUM_DISCRIMINATOR_KEY } from "../../../shared/schema/declarations/EnumDecl.js";
7
+ import { NodeKind } from "../../../shared/schema/Node.js";
7
8
  import { extractParameterTypeNamesFromMessage, mapParameterTypeNames, } from "../../../shared/utils/translation.js";
8
- import { asDecl } from "../../schema/declarations/Declaration.js";
9
- import { addEphemeralUUIDToType, createEntityIdentifierTypeAsDecl, isEntityDecl, isEntityDeclWithParentReference, } from "../../schema/declarations/EntityDecl.js";
10
- import { isEnumDecl } from "../../schema/declarations/EnumDecl.js";
11
- import { isTypeAliasDecl, TypeAliasDecl } from "../../schema/declarations/TypeAliasDecl.js";
12
- import { flatMapAuxiliaryDecls, NodeKind } from "../../schema/Node.js";
13
- import { ArrayType } from "../../schema/types/generic/ArrayType.js";
14
- import { isObjectType } from "../../schema/types/generic/ObjectType.js";
15
- import { getTypeOfKey } from "../../schema/types/generic/TranslationObjectType.js";
16
- import { isNestedEntityMapType } from "../../schema/types/references/NestedEntityMapType.js";
17
- import { ReferenceIdentifierType } from "../../schema/types/references/ReferenceIdentifierType.js";
9
+ import { asDecl } from "../../schema/dsl/declarations/Decl.js";
10
+ import { addEphemeralUUIDToType, createEntityIdentifierTypeAsDecl, isEntityDecl, isEntityDeclWithParentReference, } from "../../schema/dsl/declarations/EntityDecl.js";
11
+ import { isEnumDecl } from "../../schema/dsl/declarations/EnumDecl.js";
12
+ import { isTypeAliasDecl, TypeAliasDecl } from "../../schema/dsl/declarations/TypeAliasDecl.js";
13
+ import { ArrayType } from "../../schema/dsl/types/ArrayType.js";
14
+ import { isNestedEntityMapType } from "../../schema/dsl/types/NestedEntityMapType.js";
15
+ import { isObjectType } from "../../schema/dsl/types/ObjectType.js";
16
+ import { ReferenceIdentifierType } from "../../schema/dsl/types/ReferenceIdentifierType.js";
17
+ import { getTypeOfKey } from "../../schema/dsl/types/TranslationObjectType.js";
18
+ import { flatMapAuxiliaryDecls } from "../../schema/helpers.js";
18
19
  import { ensureSpecialDirStart } from "../../utils/path.js";
19
20
  import { combineSyntaxes, emptyRenderResult, getIndentation, indent, prefixLines, syntax, } from "../../utils/render.js";
20
21
  const defaultOptions = {
@@ -0,0 +1,9 @@
1
+ import { NodeKind } from "../../../shared/schema/Node.ts";
2
+ import type { Type } from "./types/Type.ts";
3
+ export interface TypeParameter<N extends string = string, T extends Type = Type> {
4
+ kind: NodeKind["TypeParameter"];
5
+ name: N;
6
+ constraint?: T;
7
+ }
8
+ export declare const TypeParameter: <N extends string = string, T extends Type = Type>(name: N, constraint?: T) => TypeParameter<N, T>;
9
+ export { TypeParameter as Param };
@@ -0,0 +1,7 @@
1
+ import { NodeKind } from "../../../shared/schema/Node.js";
2
+ export const TypeParameter = (name, constraint) => ({
3
+ kind: NodeKind.TypeParameter,
4
+ name,
5
+ constraint,
6
+ });
7
+ export { TypeParameter as Param };
@@ -1,7 +1,8 @@
1
- import type { BaseNode, CustomConstraintValidator, Node } from "../Node.ts";
1
+ import type { BaseNode } from "../../../../shared/schema/Node.ts";
2
+ import type { Node } from "../index.ts";
2
3
  import type { TypeParameter } from "../TypeParameter.ts";
3
- import type { EnumCaseDecl } from "../types/generic/EnumType.ts";
4
- import { type Type } from "../types/Type.ts";
4
+ import type { EnumCaseDecl } from "../types/EnumType.ts";
5
+ import type { Type } from "../types/Type.ts";
5
6
  import type { EntityDecl } from "./EntityDecl.ts";
6
7
  import type { EnumDecl } from "./EnumDecl.ts";
7
8
  import type { TypeAliasDecl } from "./TypeAliasDecl.ts";
@@ -27,4 +28,3 @@ export declare const isDeclWithoutTypeParameters: (decl: Decl) => decl is DeclP<
27
28
  export declare const resolveTypeArgumentsInDecls: (decls: readonly Decl[]) => Decl[];
28
29
  export declare function walkNodeTree(callbackFn: (node: Node, parentTypes: Type[], parentDecl: Decl) => void, decl: Decl): void;
29
30
  export declare const groupDeclarationsBySourceUrl: (decls: readonly Decl[]) => Partial<Record<string, Decl[]>>;
30
- export declare const checkCustomConstraintsInNestedDecl: CustomConstraintValidator<SecondaryDecl>;
@@ -1,9 +1,8 @@
1
- import { assertExhaustive } from "@elyukai/utils/typeSafety";
2
- import { NodeKind, resolveTypeArguments } from "../Node.js";
3
- import { walkTypeNodeTree } from "../types/Type.js";
1
+ import { walkTypeNodeTree } from "../../helpers.js";
2
+ import { resolveTypeArguments } from "../../treeOperations/typeResolution.js";
4
3
  import { isEntityDecl } from "./EntityDecl.js";
5
- import { checkCustomConstraintsInEnumDecl, isEnumDecl } from "./EnumDecl.js";
6
- import { checkCustomConstraintsInTypeAliasDecl, isTypeAliasDecl } from "./TypeAliasDecl.js";
4
+ import { isEnumDecl } from "./EnumDecl.js";
5
+ import { isTypeAliasDecl } from "./TypeAliasDecl.js";
7
6
  export const getParameterNames = (decl) => decl.parameters.map(param => param.name);
8
7
  export const getTypeArgumentsRecord = (decl, args) => Object.fromEntries(
9
8
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -23,13 +22,3 @@ export function walkNodeTree(callbackFn, decl) {
23
22
  walkTypeNodeTree(callbackFn, decl.type.value, [], decl);
24
23
  }
25
24
  export const groupDeclarationsBySourceUrl = (decls) => Object.groupBy(decls, decl => decl.sourceUrl);
26
- export const checkCustomConstraintsInNestedDecl = (decl, value, helpers) => {
27
- switch (decl.kind) {
28
- case NodeKind.EnumDecl:
29
- return checkCustomConstraintsInEnumDecl(decl, value, helpers);
30
- case NodeKind.TypeAliasDecl:
31
- return checkCustomConstraintsInTypeAliasDecl(decl, value, helpers);
32
- default:
33
- return assertExhaustive(decl);
34
- }
35
- };
@@ -1,15 +1,14 @@
1
1
  import { Lazy } from "@elyukai/utils/lazy";
2
- import type { SortOrder } from "../../../shared/schema/utils/sortOrder.ts";
3
- import type { UniqueConstraints } from "../../../shared/schema/utils/uniqueConstraint.ts";
4
- import type { InstanceContent } from "../../../shared/utils/instances.ts";
5
- import type { CustomConstraint, TypedCustomConstraint } from "../../utils/customConstraints.ts";
6
- import type { DisplayNameCustomizer, TypedDisplayNameCustomizer } from "../../utils/displayName.ts";
7
- import type { CustomConstraintValidator, GetNestedDeclarations, GetReferences, Predicate, Serialized, TypeArgumentsResolver, Validator } from "../Node.ts";
8
- import { NodeKind } from "../Node.ts";
9
- import type { MemberDecl, ObjectType } from "../types/generic/ObjectType.ts";
10
- import { StringType } from "../types/primitives/StringType.ts";
11
- import type { NestedEntityMapType } from "../types/references/NestedEntityMapType.ts";
12
- import type { BaseDecl } from "./Declaration.ts";
2
+ import { NodeKind } from "../../../../shared/schema/Node.js";
3
+ import type { SortOrder } from "../../../../shared/schema/utils/sortOrder.ts";
4
+ import type { UniqueConstraints } from "../../../../shared/schema/utils/uniqueConstraint.ts";
5
+ import type { CustomConstraint, TypedCustomConstraint } from "../../../utils/customConstraints.ts";
6
+ import type { DisplayNameCustomizer, TypedDisplayNameCustomizer } from "../../../utils/displayName.ts";
7
+ import type { Node } from "../index.ts";
8
+ import type { NestedEntityMapType } from "../types/NestedEntityMapType.ts";
9
+ import type { MemberDecl, ObjectType } from "../types/ObjectType.ts";
10
+ import { StringType } from "../types/StringType.ts";
11
+ import type { BaseDecl } from "./Decl.ts";
13
12
  import { TypeAliasDecl } from "./TypeAliasDecl.ts";
14
13
  export type GenericEntityDisplayName = string | {
15
14
  pathToLocaleMap?: string;
@@ -125,19 +124,10 @@ export declare const EntityDecl: {
125
124
  }): EntityDecl<Name, T, FK>;
126
125
  };
127
126
  export { EntityDecl as Entity };
128
- export declare const isEntityDecl: Predicate<EntityDecl>;
127
+ export declare const isEntityDecl: (node: Node) => node is EntityDecl;
129
128
  export declare const isEntityDeclWithParentReference: <Name extends string, T extends TConstraint, FK extends Extract<keyof T, string> | undefined>(decl: EntityDecl<Name, T, FK>) => decl is EntityDecl<Name, T, NonNullable<FK>>;
130
- export declare const getNestedDeclarationsInEntityDecl: GetNestedDeclarations<EntityDecl>;
131
- export declare const validateEntityDecl: Validator<EntityDecl>;
132
- export declare const resolveTypeArgumentsInEntityDecl: TypeArgumentsResolver<EntityDecl>;
133
129
  export declare const addEphemeralUUIDToType: <T extends TConstraint>(decl: EntityDecl<string, T>) => ObjectType<Omit<T, "id"> & {
134
130
  id: MemberDecl<StringType, true>;
135
131
  }>;
136
132
  export declare const createEntityIdentifierType: () => StringType;
137
133
  export declare const createEntityIdentifierTypeAsDecl: <Name extends string>(decl: EntityDecl<Name>) => TypeAliasDecl<`${Name}_ID`, StringType, []>;
138
- export declare const serializeEntityDecl: <Name extends string, T extends TConstraint, FK extends Extract<keyof T, string> | undefined>(type: EntityDecl<Name, T, FK>) => Serialized<EntityDecl<Name, T, FK>>;
139
- export declare const getReferencesForEntityDecl: GetReferences<EntityDecl>;
140
- export declare const checkCustomConstraintsInEntityDecl: CustomConstraintValidator<EntityDecl, [
141
- id: string,
142
- content: InstanceContent
143
- ]>;
@@ -1,9 +1,8 @@
1
1
  import { Lazy } from "@elyukai/utils/lazy";
2
- import { NodeKind, resolveTypeArguments, validateType } from "../Node.js";
3
- import { getNestedDeclarationsInObjectType, getReferencesForObjectType, Required, serializeObjectType, } from "../types/generic/ObjectType.js";
4
- import { StringType } from "../types/primitives/StringType.js";
5
- import { checkCustomConstraintsInType } from "../types/Type.js";
6
- import { validateDeclName } from "./Declaration.js";
2
+ import { NodeKind } from "../../../../shared/schema/Node.js";
3
+ import { Required } from "../types/ObjectType.js";
4
+ import { StringType } from "../types/StringType.js";
5
+ import { validateDeclName } from "./Decl.js";
7
6
  import { TypeAliasDecl } from "./TypeAliasDecl.js";
8
7
  export const EntityDecl = (sourceUrl, options) => {
9
8
  validateDeclName(options.name);
@@ -27,14 +26,8 @@ export const EntityDecl = (sourceUrl, options) => {
27
26
  };
28
27
  };
29
28
  export { EntityDecl as Entity };
30
- export const isEntityDecl = node => node.kind === NodeKind.EntityDecl;
29
+ export const isEntityDecl = (node) => node.kind === NodeKind.EntityDecl;
31
30
  export const isEntityDeclWithParentReference = (decl) => decl.parentReferenceKey !== undefined;
32
- export const getNestedDeclarationsInEntityDecl = (isDeclAdded, decl) => getNestedDeclarationsInObjectType(isDeclAdded, decl.type.value, decl);
33
- export const validateEntityDecl = (helpers, inDecls, decl, value) => validateType(helpers, inDecls, decl.type.value, value);
34
- export const resolveTypeArgumentsInEntityDecl = (_args, decl, inDecl) => EntityDecl(decl.sourceUrl, {
35
- ...decl,
36
- type: () => resolveTypeArguments({}, decl.type.value, [...inDecl, decl]),
37
- });
38
31
  const createEntityIdentifierComment = () => "The entity’s identifier. A UUID or a locale code if it is registered as the locale entity.";
39
32
  export const addEphemeralUUIDToType = (decl) => ({
40
33
  ...decl.type.value,
@@ -52,12 +45,3 @@ export const createEntityIdentifierTypeAsDecl = (decl) => TypeAliasDecl(decl.sou
52
45
  name: (decl.name + "_ID"),
53
46
  type: createEntityIdentifierType,
54
47
  });
55
- export const serializeEntityDecl = ((type) => ({
56
- ...type,
57
- type: serializeObjectType(type.type.value),
58
- instanceDisplayName: type.instanceDisplayName,
59
- instanceDisplayNameCustomizer: type.instanceDisplayNameCustomizer !== undefined,
60
- customConstraints: type.customConstraints !== undefined,
61
- }));
62
- export const getReferencesForEntityDecl = (decl, value, inDecl) => getReferencesForObjectType(decl.type.value, value, [...inDecl, decl]);
63
- export const checkCustomConstraintsInEntityDecl = (decl, value, helpers) => (decl.customConstraints?.({ ...helpers, instanceId: value[0], instanceContent: value[1] }) ?? []).concat(checkCustomConstraintsInType(decl.type.value, value, helpers));
@@ -1,12 +1,12 @@
1
1
  import { Lazy } from "@elyukai/utils/lazy";
2
- import { type EnumValue } from "../../../shared/schema/declarations/EnumDecl.ts";
3
- import type { NestedCustomConstraint, TypedNestedCustomConstraint } from "../../utils/customConstraints.ts";
4
- import type { CustomConstraintValidator, GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, ValidatorOfParamDecl } from "../Node.ts";
5
- import { NodeKind } from "../Node.ts";
2
+ import { type EnumValue } from "../../../../shared/schema/declarations/EnumDecl.ts";
3
+ import { NodeKind } from "../../../../shared/schema/Node.ts";
4
+ import type { NestedCustomConstraint, TypedNestedCustomConstraint } from "../../../utils/customConstraints.ts";
5
+ import type { Node } from "../index.ts";
6
6
  import type { TypeParameter } from "../TypeParameter.ts";
7
- import type { EnumCaseDecl } from "../types/generic/EnumType.ts";
8
- import { EnumType } from "../types/generic/EnumType.ts";
9
- import type { BaseDecl } from "./Declaration.ts";
7
+ import type { EnumCaseDecl } from "../types/EnumType.ts";
8
+ import { EnumType } from "../types/EnumType.ts";
9
+ import type { BaseDecl } from "./Decl.ts";
10
10
  type TConstraint = Record<string, EnumCaseDecl>;
11
11
  export interface EnumDecl<Name extends string = string, T extends TConstraint = TConstraint, Params extends TypeParameter[] = TypeParameter[]> extends BaseDecl<Name, Params> {
12
12
  kind: NodeKind["EnumDecl"];
@@ -68,12 +68,6 @@ export declare const GenEnumDecl: <Name extends string, T extends TConstraint, P
68
68
  customConstraints?: TypedNestedCustomConstraint<Name>;
69
69
  }) => EnumDecl<Name, T, Params>;
70
70
  export { GenEnumDecl as GenEnum };
71
- export declare const isEnumDecl: Predicate<EnumDecl>;
72
- export declare const getNestedDeclarationsInEnumDecl: GetNestedDeclarations<EnumDecl>;
73
- export declare const validateEnumDecl: ValidatorOfParamDecl<EnumDecl>;
74
- export declare const resolveTypeArgumentsInEnumDecl: TypeArgumentsResolver<EnumDecl>;
75
- export declare const serializeEnumDecl: Serializer<EnumDecl>;
76
- export declare const getReferencesForEnumDecl: GetReferences<EnumDecl>;
71
+ export declare const isEnumDecl: (node: Node) => node is EnumDecl;
77
72
  export declare const cases: <T extends TConstraint>(decl: EnumDecl<string, T>) => EnumCaseDecl<T[keyof T]["type"]>[];
78
73
  export declare const getAnyEnumCaseValue: <K extends string, V>(enumValue: { [Key in K]: EnumValue<Key, V>; }[K]) => V;
79
- export declare const checkCustomConstraintsInEnumDecl: CustomConstraintValidator<EnumDecl>;
@@ -0,0 +1,26 @@
1
+ import { Lazy } from "@elyukai/utils/lazy";
2
+ import { onlyKeys } from "@elyukai/utils/object";
3
+ import { ENUM_DISCRIMINATOR_KEY, } from "../../../../shared/schema/declarations/EnumDecl.js";
4
+ import { NodeKind } from "../../../../shared/schema/Node.js";
5
+ import { EnumType } from "../types/EnumType.js";
6
+ import { validateDeclName } from "./Decl.js";
7
+ const EnumDeclConstructor = (sourceUrl, options) => {
8
+ validateDeclName(options.name);
9
+ const parameters = (options.parameters ?? []);
10
+ const decl = {
11
+ ...onlyKeys(options, "name", "comment", "isDeprecated"),
12
+ kind: NodeKind.EnumDecl,
13
+ sourceUrl,
14
+ parameters,
15
+ type: Lazy.of(() => EnumType(options.values(...parameters))),
16
+ customConstraints: options.customConstraints, // ignore contravariance of registered enum type
17
+ };
18
+ return decl;
19
+ };
20
+ export const EnumDecl = EnumDeclConstructor;
21
+ export { EnumDecl as Enum };
22
+ export const GenEnumDecl = EnumDeclConstructor;
23
+ export { GenEnumDecl as GenEnum };
24
+ export const isEnumDecl = (node) => node.kind === NodeKind.EnumDecl;
25
+ export const cases = (decl) => Object.values(decl.type.value.values);
26
+ export const getAnyEnumCaseValue = (enumValue) => enumValue[enumValue[ENUM_DISCRIMINATOR_KEY]];
@@ -1,10 +1,10 @@
1
1
  import { Lazy } from "@elyukai/utils/lazy";
2
- import type { NestedCustomConstraint, TypedNestedCustomConstraint } from "../../utils/customConstraints.ts";
3
- import type { CustomConstraintValidator, GetNestedDeclarations, GetReferences, Predicate, Serializer, TypeArgumentsResolver, ValidationContext } from "../Node.ts";
4
- import { NodeKind } from "../Node.ts";
2
+ import { NodeKind } from "../../../../shared/schema/Node.js";
3
+ import type { NestedCustomConstraint, TypedNestedCustomConstraint } from "../../../utils/customConstraints.ts";
4
+ import type { Node } from "../index.ts";
5
5
  import type { TypeParameter } from "../TypeParameter.ts";
6
- import { type Type } from "../types/Type.ts";
7
- import type { BaseDecl, Decl, TypeArguments } from "./Declaration.ts";
6
+ import type { Type } from "../types/Type.ts";
7
+ import type { BaseDecl } from "./Decl.ts";
8
8
  export interface TypeAliasDecl<Name extends string = string, T extends Type = Type, Params extends TypeParameter[] = TypeParameter[]> extends BaseDecl<Name, Params> {
9
9
  kind: NodeKind["TypeAliasDecl"];
10
10
  type: Lazy<T>;
@@ -63,10 +63,4 @@ export declare const GenTypeAliasDecl: <Name extends string, T extends Type, Par
63
63
  customConstraints?: TypedNestedCustomConstraint<Name>;
64
64
  }) => TypeAliasDecl<Name, T, Params>;
65
65
  export { GenTypeAliasDecl as GenTypeAlias };
66
- export declare const isTypeAliasDecl: Predicate<TypeAliasDecl>;
67
- export declare const getNestedDeclarationsInTypeAliasDecl: GetNestedDeclarations<TypeAliasDecl>;
68
- export declare const validateTypeAliasDecl: <Params extends TypeParameter[]>(helpers: ValidationContext, inDecls: Decl[], decl: TypeAliasDecl<string, Type, Params>, args: TypeArguments<Params>, value: unknown) => Error[];
69
- export declare const resolveTypeArgumentsInTypeAliasDecl: TypeArgumentsResolver<TypeAliasDecl>;
70
- export declare const serializeTypeAliasDecl: Serializer<TypeAliasDecl>;
71
- export declare const getReferencesForTypeAliasDecl: GetReferences<TypeAliasDecl>;
72
- export declare const checkCustomConstraintsInTypeAliasDecl: CustomConstraintValidator<TypeAliasDecl>;
66
+ export declare const isTypeAliasDecl: (node: Node) => node is TypeAliasDecl;
@@ -0,0 +1,22 @@
1
+ import { Lazy } from "@elyukai/utils/lazy";
2
+ import { onlyKeys } from "@elyukai/utils/object";
3
+ import { NodeKind } from "../../../../shared/schema/Node.js";
4
+ import { validateDeclName } from "./Decl.js";
5
+ const TypeAliasDeclConstructor = (sourceUrl, options) => {
6
+ validateDeclName(options.name);
7
+ const parameters = (options.parameters ?? []);
8
+ const decl = {
9
+ ...onlyKeys(options, "name", "comment", "isDeprecated"),
10
+ kind: NodeKind.TypeAliasDecl,
11
+ sourceUrl,
12
+ parameters,
13
+ type: Lazy.of(() => options.type(...parameters)),
14
+ customConstraints: options.customConstraints, // ignore contravariance of registered type alias type
15
+ };
16
+ return decl;
17
+ };
18
+ export const TypeAliasDecl = TypeAliasDeclConstructor;
19
+ export { TypeAliasDecl as TypeAlias };
20
+ export const GenTypeAliasDecl = TypeAliasDeclConstructor;
21
+ export { GenTypeAliasDecl as GenTypeAlias };
22
+ export const isTypeAliasDecl = (node) => node.kind === NodeKind.TypeAliasDecl;
@@ -0,0 +1,24 @@
1
+ import type { TypeParameter } from "./TypeParameter.ts";
2
+ import type { Decl } from "./declarations/Decl.ts";
3
+ import type { Type } from "./types/Type.ts";
4
+ export { Param, TypeParameter } from "./TypeParameter.ts";
5
+ export { type Decl, type DeclP, type IncludableDeclP, type SecondaryDecl, } from "./declarations/Decl.ts";
6
+ export { Entity, EntityDecl, type EntityDeclWithParentReference, type EntityDisplayName, type GenericEntityDisplayName, } from "./declarations/EntityDecl.ts";
7
+ export { Enum, EnumDecl, GenEnum, GenEnumDecl } from "./declarations/EnumDecl.ts";
8
+ export { GenTypeAlias, GenTypeAliasDecl, TypeAlias, TypeAliasDecl, } from "./declarations/TypeAliasDecl.ts";
9
+ export { Array, ArrayType } from "./types/ArrayType.ts";
10
+ export { Boolean, BooleanType } from "./types/BooleanType.ts";
11
+ export { ChildEntities, ChildEntitiesType } from "./types/ChildEntitiesType.ts";
12
+ export { Date, DateType } from "./types/DateType.ts";
13
+ export { EnumCase, EnumCaseDecl } from "./types/EnumType.ts";
14
+ export { Float, FloatType } from "./types/FloatType.ts";
15
+ export { GenIncludeIdentifier, GenIncludeIdentifierType, IncludeIdentifier, IncludeIdentifierType, } from "./types/IncludeIdentifierType.ts";
16
+ export { Integer, IntegerType } from "./types/IntegerType.ts";
17
+ export { NestedEntityMap, NestedEntityMapType } from "./types/NestedEntityMapType.ts";
18
+ export { Object, ObjectType, Optional, Required, type MemberDecl } from "./types/ObjectType.ts";
19
+ export { ReferenceIdentifier, ReferenceIdentifierType } from "./types/ReferenceIdentifierType.ts";
20
+ export { String, StringType } from "./types/StringType.ts";
21
+ export { TranslationObject, TranslationObjectType } from "./types/TranslationObjectType.ts";
22
+ export type { Type } from "./types/Type.ts";
23
+ export { TypeArgument, TypeArgumentType } from "./types/TypeArgumentType.ts";
24
+ export type Node = Decl | Type | TypeParameter;
@@ -0,0 +1,19 @@
1
+ export { Param, TypeParameter } from "./TypeParameter.js";
2
+ export {} from "./declarations/Decl.js";
3
+ export { Entity, EntityDecl, } from "./declarations/EntityDecl.js";
4
+ export { Enum, EnumDecl, GenEnum, GenEnumDecl } from "./declarations/EnumDecl.js";
5
+ export { GenTypeAlias, GenTypeAliasDecl, TypeAlias, TypeAliasDecl, } from "./declarations/TypeAliasDecl.js";
6
+ export { Array, ArrayType } from "./types/ArrayType.js";
7
+ export { Boolean, BooleanType } from "./types/BooleanType.js";
8
+ export { ChildEntities, ChildEntitiesType } from "./types/ChildEntitiesType.js";
9
+ export { Date, DateType } from "./types/DateType.js";
10
+ export { EnumCase, EnumCaseDecl } from "./types/EnumType.js";
11
+ export { Float, FloatType } from "./types/FloatType.js";
12
+ export { GenIncludeIdentifier, GenIncludeIdentifierType, IncludeIdentifier, IncludeIdentifierType, } from "./types/IncludeIdentifierType.js";
13
+ export { Integer, IntegerType } from "./types/IntegerType.js";
14
+ export { NestedEntityMap, NestedEntityMapType } from "./types/NestedEntityMapType.js";
15
+ export { Object, ObjectType, Optional, Required } from "./types/ObjectType.js";
16
+ export { ReferenceIdentifier, ReferenceIdentifierType } from "./types/ReferenceIdentifierType.js";
17
+ export { String, StringType } from "./types/StringType.js";
18
+ export { TranslationObject, TranslationObjectType } from "./types/TranslationObjectType.js";
19
+ export { TypeArgument, TypeArgumentType } from "./types/TypeArgumentType.js";
@@ -0,0 +1,17 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.ts";
2
+ import type { Node } from "../index.ts";
3
+ import type { BaseType, Type } from "./Type.ts";
4
+ export interface ArrayType<T extends Type = Type> extends BaseType {
5
+ kind: NodeKind["ArrayType"];
6
+ minItems?: number;
7
+ maxItems?: number;
8
+ uniqueItems?: boolean;
9
+ items: T;
10
+ }
11
+ export declare const ArrayType: <T extends Type>(items: T, options?: {
12
+ minItems?: number;
13
+ maxItems?: number;
14
+ uniqueItems?: boolean;
15
+ }) => ArrayType<T>;
16
+ export { ArrayType as Array };
17
+ export declare const isArrayType: (node: Node) => node is ArrayType;
@@ -0,0 +1,11 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.js";
2
+ import { validateOption } from "../../validation/options.js";
3
+ export const ArrayType = (items, options = {}) => ({
4
+ ...options,
5
+ kind: NodeKind.ArrayType,
6
+ minItems: validateOption(options.minItems, "minItems", option => Number.isInteger(option) && option >= 0),
7
+ maxItems: validateOption(options.maxItems, "maxItems", option => Number.isInteger(option) && option >= 0),
8
+ items,
9
+ });
10
+ export { ArrayType as Array };
11
+ export const isArrayType = (node) => node.kind === NodeKind.ArrayType;
@@ -0,0 +1,9 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.ts";
2
+ import type { Node } from "../index.ts";
3
+ import type { BaseType } from "./Type.ts";
4
+ export interface BooleanType extends BaseType {
5
+ kind: NodeKind["BooleanType"];
6
+ }
7
+ export declare const BooleanType: () => BooleanType;
8
+ export { BooleanType as Boolean };
9
+ export declare const isBooleanType: (node: Node) => node is BooleanType;
@@ -0,0 +1,6 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.js";
2
+ export const BooleanType = () => ({
3
+ kind: NodeKind.BooleanType,
4
+ });
5
+ export { BooleanType as Boolean };
6
+ export const isBooleanType = (node) => node.kind === NodeKind.BooleanType;
@@ -0,0 +1,12 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.ts";
2
+ import { type EntityDecl } from "../declarations/EntityDecl.ts";
3
+ import type { Node } from "../index.ts";
4
+ import type { MemberDecl } from "./ObjectType.ts";
5
+ import type { BaseType } from "./Type.ts";
6
+ export interface ChildEntitiesType<T extends EntityDecl<string, Record<string, MemberDecl>, string> = EntityDecl<string, Record<string, MemberDecl>, string>> extends BaseType {
7
+ kind: NodeKind["ChildEntitiesType"];
8
+ entity: T;
9
+ }
10
+ export declare const ChildEntitiesType: <T extends EntityDecl<string, Record<string, MemberDecl>, string>>(entity: T) => ChildEntitiesType<T>;
11
+ export { ChildEntitiesType as ChildEntities };
12
+ export declare const isChildEntitiesType: (node: Node) => node is ChildEntitiesType;
@@ -0,0 +1,8 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.js";
2
+ import {} from "../declarations/EntityDecl.js";
3
+ export const ChildEntitiesType = (entity) => ({
4
+ kind: NodeKind.ChildEntitiesType,
5
+ entity,
6
+ });
7
+ export { ChildEntitiesType as ChildEntities };
8
+ export const isChildEntitiesType = (node) => node.kind === NodeKind.ChildEntitiesType;
@@ -0,0 +1,10 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.ts";
2
+ import type { DateConstraints } from "../../../../shared/validation/date.ts";
3
+ import type { Node } from "../index.ts";
4
+ import type { BaseType } from "./Type.ts";
5
+ export interface DateType extends BaseType, DateConstraints {
6
+ kind: NodeKind["DateType"];
7
+ }
8
+ export declare const DateType: (options?: DateConstraints) => DateType;
9
+ export { DateType as Date };
10
+ export declare const isDateType: (node: Node) => node is DateType;
@@ -0,0 +1,7 @@
1
+ import { NodeKind } from "../../../../shared/schema/Node.js";
2
+ export const DateType = (options) => ({
3
+ ...options,
4
+ kind: NodeKind.DateType,
5
+ });
6
+ export { DateType as Date };
7
+ export const isDateType = (node) => node.kind === NodeKind.DateType;