@shaclmate/compiler 4.0.38 → 4.0.39

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 (161) hide show
  1. package/dist/ShapesGraphToAstTransformer.js +12 -12
  2. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +24 -24
  3. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -4
  4. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +16 -16
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
  7. package/dist/ast/AbstractCollectionType.d.ts +1 -1
  8. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  9. package/dist/ast/AbstractCompoundType.js +15 -15
  10. package/dist/ast/AbstractContainerType.d.ts +1 -1
  11. package/dist/ast/AbstractContainerType.js +15 -15
  12. package/dist/ast/AbstractLazyObjectType.d.ts +1 -1
  13. package/dist/ast/AbstractTermType.d.ts +1 -1
  14. package/dist/ast/BlankNodeType.d.ts +1 -1
  15. package/dist/ast/BlankNodeType.js +1 -1
  16. package/dist/ast/DefaultValueType.d.ts +1 -1
  17. package/dist/ast/DefaultValueType.js +2 -2
  18. package/dist/ast/IdentifierType.d.ts +1 -1
  19. package/dist/ast/IdentifierType.js +1 -1
  20. package/dist/ast/IntersectionType.d.ts +1 -1
  21. package/dist/ast/IntersectionType.js +3 -3
  22. package/dist/ast/IriType.d.ts +1 -1
  23. package/dist/ast/IriType.js +1 -1
  24. package/dist/ast/LazyObjectOptionType.d.ts +1 -1
  25. package/dist/ast/LazyObjectOptionType.js +1 -1
  26. package/dist/ast/LazyObjectSetType.d.ts +1 -1
  27. package/dist/ast/LazyObjectSetType.js +1 -1
  28. package/dist/ast/LazyObjectType.d.ts +1 -1
  29. package/dist/ast/LazyObjectType.js +1 -1
  30. package/dist/ast/ListType.d.ts +1 -1
  31. package/dist/ast/ListType.js +16 -16
  32. package/dist/ast/LiteralType.d.ts +1 -1
  33. package/dist/ast/LiteralType.js +1 -1
  34. package/dist/ast/ObjectCompoundType.js +3 -3
  35. package/dist/ast/ObjectType.d.ts +1 -1
  36. package/dist/ast/ObjectType.js +16 -16
  37. package/dist/ast/OptionType.d.ts +1 -1
  38. package/dist/ast/OptionType.js +1 -1
  39. package/dist/ast/SetType.d.ts +1 -1
  40. package/dist/ast/SetType.js +1 -1
  41. package/dist/ast/TermType.d.ts +1 -1
  42. package/dist/ast/TermType.js +1 -1
  43. package/dist/ast/Type.js +15 -15
  44. package/dist/ast/UnionType.d.ts +1 -1
  45. package/dist/ast/UnionType.js +3 -3
  46. package/dist/generators/transformAstToLabeledPropertyGraph.js +10 -10
  47. package/dist/generators/ts/AbstractCollectionType.d.ts +1 -5
  48. package/dist/generators/ts/AbstractCollectionType.js +6 -5
  49. package/dist/generators/ts/AbstractContainerType.d.ts +3 -6
  50. package/dist/generators/ts/AbstractContainerType.js +34 -34
  51. package/dist/generators/ts/AbstractDateType.d.ts +1 -1
  52. package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
  53. package/dist/generators/ts/AbstractLazyObjectType.d.ts +7 -10
  54. package/dist/generators/ts/AbstractLazyObjectType.js +20 -32
  55. package/dist/generators/ts/AbstractLiteralType.d.ts +1 -5
  56. package/dist/generators/ts/AbstractLiteralType.js +7 -6
  57. package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
  58. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -6
  59. package/dist/generators/ts/AbstractPrimitiveType.js +7 -8
  60. package/dist/generators/ts/AbstractTermType.d.ts +1 -5
  61. package/dist/generators/ts/AbstractTermType.js +1 -15
  62. package/dist/generators/ts/AbstractType.d.ts +7 -5
  63. package/dist/generators/ts/AbstractType.js +12 -7
  64. package/dist/generators/ts/AbstractUnionType.d.ts +7 -10
  65. package/dist/generators/ts/AbstractUnionType.js +70 -81
  66. package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
  67. package/dist/generators/ts/AnonymousUnionType.js +1 -1
  68. package/dist/generators/ts/BigDecimalType.d.ts +1 -1
  69. package/dist/generators/ts/BigDecimalType.js +1 -1
  70. package/dist/generators/ts/BigIntType.d.ts +1 -1
  71. package/dist/generators/ts/BigIntType.js +1 -1
  72. package/dist/generators/ts/BlankNodeType.d.ts +1 -1
  73. package/dist/generators/ts/BlankNodeType.js +1 -1
  74. package/dist/generators/ts/BooleanType.d.ts +1 -1
  75. package/dist/generators/ts/BooleanType.js +2 -2
  76. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  77. package/dist/generators/ts/DateTimeType.js +1 -1
  78. package/dist/generators/ts/DateType.d.ts +1 -1
  79. package/dist/generators/ts/DateType.js +1 -1
  80. package/dist/generators/ts/DefaultValueType.d.ts +2 -6
  81. package/dist/generators/ts/DefaultValueType.js +12 -15
  82. package/dist/generators/ts/FloatType.d.ts +1 -1
  83. package/dist/generators/ts/FloatType.js +1 -1
  84. package/dist/generators/ts/IdentifierType.d.ts +1 -1
  85. package/dist/generators/ts/IdentifierType.js +1 -1
  86. package/dist/generators/ts/IntType.d.ts +1 -1
  87. package/dist/generators/ts/IntType.js +1 -1
  88. package/dist/generators/ts/IriType.d.ts +3 -1
  89. package/dist/generators/ts/IriType.js +22 -17
  90. package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
  91. package/dist/generators/ts/LazyObjectOptionType.js +1 -1
  92. package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
  93. package/dist/generators/ts/LazyObjectSetType.js +1 -1
  94. package/dist/generators/ts/LazyObjectType.d.ts +1 -1
  95. package/dist/generators/ts/LazyObjectType.js +1 -1
  96. package/dist/generators/ts/ListType.d.ts +1 -1
  97. package/dist/generators/ts/ListType.js +24 -24
  98. package/dist/generators/ts/LiteralType.d.ts +2 -1
  99. package/dist/generators/ts/LiteralType.js +9 -2
  100. package/dist/generators/ts/NamedObjectType.d.ts +1 -0
  101. package/dist/generators/ts/NamedObjectType.js +2 -1
  102. package/dist/generators/ts/NamedObjectUnionType.d.ts +1 -1
  103. package/dist/generators/ts/NamedObjectUnionType.js +6 -8
  104. package/dist/generators/ts/NamedUnionType.d.ts +1 -1
  105. package/dist/generators/ts/NamedUnionType.js +1 -1
  106. package/dist/generators/ts/OptionType.d.ts +1 -5
  107. package/dist/generators/ts/OptionType.js +2 -8
  108. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -1
  109. package/dist/generators/ts/SetType.d.ts +1 -1
  110. package/dist/generators/ts/SetType.js +1 -1
  111. package/dist/generators/ts/Snippets.d.ts +1 -0
  112. package/dist/generators/ts/Snippets.js +7 -0
  113. package/dist/generators/ts/StringType.d.ts +1 -1
  114. package/dist/generators/ts/StringType.js +2 -2
  115. package/dist/generators/ts/TermType.d.ts +1 -1
  116. package/dist/generators/ts/TermType.js +1 -1
  117. package/dist/generators/ts/TypeFactory.js +18 -18
  118. package/dist/generators/ts/ZodGenerator.js +1 -1
  119. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +7 -7
  120. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +8 -11
  121. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +2 -1
  122. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +16 -7
  123. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +2 -1
  124. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -3
  125. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
  126. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +3 -27
  127. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +2 -2
  128. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
  129. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +1 -1
  130. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +2 -6
  131. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +19 -23
  132. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +2 -2
  133. package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -1
  134. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -1
  135. package/dist/generators/ts/_snippets/snippets_IriSchema.js +2 -2
  136. package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +2 -2
  137. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  138. package/dist/generators/ts/_snippets/snippets_StringSchema.js +2 -2
  139. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +1 -1
  140. package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
  141. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  142. package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.d.ts +3 -0
  143. package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.js +16 -0
  144. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +1 -1
  145. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
  146. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
  147. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +1 -1
  148. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +3 -3
  149. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +1 -1
  150. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +1 -1
  151. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +1 -1
  152. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +1 -1
  153. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +1 -1
  154. package/dist/generators/ts/_snippets/snippets_validateArray.js +1 -1
  155. package/dist/generators/ts/_snippets/snippets_validateMaybe.js +1 -1
  156. package/dist/generators/ts/tsComment.js +1 -1
  157. package/dist/input/generated.d.ts +1397 -1466
  158. package/dist/input/generated.js +516 -653
  159. package/package.json +2 -2
  160. package/dist/generators/ts/removeUndefined.d.ts +0 -2
  161. package/dist/generators/ts/removeUndefined.js +0 -17
@@ -34,7 +34,7 @@ export class IdentifierType extends AbstractIdentifierType {
34
34
  filterFunction = code `${this.reusables.snippets.filterIdentifier}`;
35
35
  filterType = code `${this.reusables.snippets.IdentifierFilter}`;
36
36
  parseFunction = code `${this.reusables.snippets.parseIdentifier};`;
37
- kind = "IdentifierType";
37
+ kind = "Identifier";
38
38
  name = code `(${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode})`;
39
39
  nodeKinds = nodeKinds;
40
40
  schemaType = code `${this.reusables.snippets.IdentifierSchema}`;
@@ -2,7 +2,7 @@ import type { Literal } from "@rdfjs/types";
2
2
  import { AbstractNumericType } from "./AbstractNumericType.js";
3
3
  import { type Code } from "./ts-poet-wrapper.js";
4
4
  export declare class IntType extends AbstractNumericType<number> {
5
- readonly kind = "IntType";
5
+ readonly kind = "Int";
6
6
  readonly typeofs: "number"[];
7
7
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
8
8
  literalExpression(literal: Literal | number): Code;
@@ -9,7 +9,7 @@ import { Memoize } from "typescript-memoize";
9
9
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
10
  import { code } from "./ts-poet-wrapper.js";
11
11
  export class IntType extends AbstractNumericType {
12
- kind = "IntType";
12
+ kind = "Int";
13
13
  typeofs = ["number"];
14
14
  get graphqlType() {
15
15
  return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLInt}`, this.reusables);
@@ -5,13 +5,15 @@ import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class IriType extends AbstractIdentifierType<NamedNode> {
6
6
  readonly filterFunction: Code;
7
7
  readonly filterType: Code;
8
- readonly kind = "IriType";
8
+ readonly kind = "Iri";
9
9
  readonly nodeKinds: ReadonlySet<"IRI">;
10
10
  readonly schemaType: Code;
11
11
  readonly valueSparqlWherePatternsFunction: Code;
12
12
  get conversionFunction(): Maybe<AbstractIdentifierType.ConversionFunction>;
13
13
  get name(): Code;
14
+ private get valueTypeName();
14
15
  get parseFunction(): Code;
16
+ protected get schemaInitializers(): readonly Code[];
15
17
  fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<NamedNode>["fromJsonExpression"]>[0]): Code;
16
18
  jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<NamedNode>["jsonSchema"]>[0]): Code;
17
19
  jsonType(parameters?: Parameters<AbstractIdentifierType<NamedNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
@@ -7,23 +7,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
10
- import { arrayOf, code, joinCode, literalOf, } from "./ts-poet-wrapper.js";
10
+ import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
11
11
  export class IriType extends AbstractIdentifierType {
12
12
  filterFunction = code `${this.reusables.snippets.filterIri}`;
13
13
  filterType = code `${this.reusables.snippets.IriFilter}`;
14
- kind = "IriType";
14
+ kind = "Iri";
15
15
  nodeKinds = nodeKinds;
16
- schemaType = code `${this.reusables.snippets.IriSchema}`;
16
+ schemaType = code `${this.reusables.snippets.IriSchema}<${this.valueTypeName}>`;
17
17
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.iriSparqlWherePatterns}`;
18
18
  get conversionFunction() {
19
- const IriT = this.in_.length > 0
20
- ? code `${joinCode(this.in_.map((iri) => code `${literalOf(iri.value)}`), { on: "| " })}`
21
- : code `string`;
22
19
  return Maybe.of({
23
- code: code `${this.reusables.snippets.convertToIri}<${IriT}>`,
20
+ code: code `${this.reusables.snippets.convertToIri}<${this.valueTypeName}>`,
24
21
  sourceTypes: [
25
22
  {
26
- name: IriT,
23
+ name: this.valueTypeName,
27
24
  typeof: "string",
28
25
  },
29
26
  {
@@ -35,18 +32,28 @@ export class IriType extends AbstractIdentifierType {
35
32
  }
36
33
  get name() {
37
34
  if (this.in_.length > 0) {
38
- // Treat sh:in as a union of the IRIs
39
- // rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
40
- return code `${this.reusables.imports.NamedNode}<${joinCode(this.in_.map((iri) => code `${literalOf(iri.value)}`), { on: "| " })}>`;
35
+ return code `${this.reusables.imports.NamedNode}<${this.valueTypeName}>`;
41
36
  }
42
37
  return code `${this.reusables.imports.NamedNode}`;
43
38
  }
39
+ get valueTypeName() {
40
+ return this.in_.length > 0
41
+ ? `(${this.in_.map((in_) => `"${in_.value}"`).join(" | ")})`
42
+ : "string";
43
+ }
44
44
  get parseFunction() {
45
45
  if (this.in_.length > 0) {
46
46
  return code `(identifier: string) => ${this.reusables.snippets.parseIri}(identifier).chain((identifier) => { switch (identifier.value) { ${joinCode(this.in_.map((iri) => code `case "${iri.value}": return ${this.reusables.imports.Right}(identifier as ${this.name});`))} default: return ${this.reusables.imports.Left}(new Error("expected NamedNode identifier to be one of ${this.in_.map((iri) => iri.value).join(" ")}")); } })`;
47
47
  }
48
48
  return code `${this.reusables.snippets.parseIri}`;
49
49
  }
50
+ get schemaInitializers() {
51
+ let initializers = super.schemaInitializers;
52
+ if (this.in_.length > 0) {
53
+ initializers = initializers.concat(code `in: ${arrayOf(...this.in_.map((in_) => this.rdfjsTermExpression(in_)))}`);
54
+ }
55
+ return initializers;
56
+ }
50
57
  fromJsonExpression({ variables, }) {
51
58
  return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"]))`;
52
59
  }
@@ -69,12 +76,7 @@ export class IriType extends AbstractIdentifierType {
69
76
  const discriminantProperty = parameters?.includeDiscriminantProperty
70
77
  ? `, readonly termType: "NamedNode"`
71
78
  : "";
72
- if (this.in_.length > 0) {
73
- // Treat sh:in as a union of the IRIs
74
- // rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
75
- return new AbstractIdentifierType.JsonType(code `{ readonly "@id": ${this.in_.map((iri) => `"${iri.value}"`).join(" | ")}${discriminantProperty} }`);
76
- }
77
- return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
79
+ return new AbstractIdentifierType.JsonType(code `{ readonly "@id": ${this.valueTypeName}${discriminantProperty} }`);
78
80
  }
79
81
  toJsonExpression({ includeDiscriminantProperty, variables, }) {
80
82
  const discriminantProperty = includeDiscriminantProperty
@@ -97,6 +99,9 @@ __decorate([
97
99
  __decorate([
98
100
  Memoize()
99
101
  ], IriType.prototype, "name", null);
102
+ __decorate([
103
+ Memoize()
104
+ ], IriType.prototype, "valueTypeName", null);
100
105
  __decorate([
101
106
  Memoize()
102
107
  ], IriType.prototype, "parseFunction", null);
@@ -18,7 +18,7 @@ declare const Super: (abstract new ({ partialType, resolveType, ...superParamete
18
18
  };
19
19
  export declare class LazyObjectOptionType extends Super {
20
20
  readonly graphqlArgs: Super["graphqlArgs"];
21
- readonly kind = "LazyObjectOptionType";
21
+ readonly kind = "LazyObjectOption";
22
22
  get conversionFunction(): Maybe<AbstractLazyObjectType.ConversionFunction>;
23
23
  protected get runtimeClass(): {
24
24
  name: Code;
@@ -11,7 +11,7 @@ import { code } from "./ts-poet-wrapper.js";
11
11
  const Super = (AbstractLazyObjectType);
12
12
  export class LazyObjectOptionType extends Super {
13
13
  graphqlArgs = Maybe.empty();
14
- kind = "LazyObjectOptionType";
14
+ kind = "LazyObjectOption";
15
15
  get conversionFunction() {
16
16
  return Maybe.of({
17
17
  code: code `${this.reusables.snippets.convertToLazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
@@ -4,7 +4,7 @@ import type { SetType } from "./SetType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class LazyObjectSetType extends AbstractLazyObjectType<SetType<AbstractLazyObjectType.ObjectTypeConstraint>, SetType<AbstractLazyObjectType.ObjectTypeConstraint>> {
6
6
  readonly graphqlArgs: Super["graphqlArgs"];
7
- readonly kind = "LazyObjectSetType";
7
+ readonly kind = "LazyObjectSet";
8
8
  get conversionFunction(): Maybe<AbstractLazyObjectType.ConversionFunction>;
9
9
  protected get runtimeClass(): {
10
10
  name: Code;
@@ -17,7 +17,7 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
17
17
  type: code `${this.reusables.imports.GraphQLInt}`,
18
18
  },
19
19
  });
20
- kind = "LazyObjectSetType";
20
+ kind = "LazyObjectSet";
21
21
  get conversionFunction() {
22
22
  return Maybe.of({
23
23
  code: code `${this.reusables.snippets.convertToLazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
@@ -3,7 +3,7 @@ import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
3
3
  import { type Code } from "./ts-poet-wrapper.js";
4
4
  export declare class LazyObjectType extends AbstractLazyObjectType<AbstractLazyObjectType.ObjectTypeConstraint, AbstractLazyObjectType.ObjectTypeConstraint> {
5
5
  readonly graphqlArgs: Super["graphqlArgs"];
6
- readonly kind = "LazyObjectType";
6
+ readonly kind = "LazyObject";
7
7
  get conversionFunction(): Maybe<AbstractLazyObjectType.ConversionFunction>;
8
8
  protected get runtimeClass(): {
9
9
  name: Code;
@@ -10,7 +10,7 @@ import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
10
10
  import { code } from "./ts-poet-wrapper.js";
11
11
  export class LazyObjectType extends AbstractLazyObjectType {
12
12
  graphqlArgs = Maybe.empty();
13
- kind = "LazyObjectType";
13
+ kind = "LazyObject";
14
14
  get conversionFunction() {
15
15
  return Maybe.of({
16
16
  code: code `${this.reusables.snippets.convertToLazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.name}, ${this.resolveType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType, resolveType: this.resolveType })})`,
@@ -22,7 +22,7 @@ import { type Code } from "./ts-poet-wrapper.js";
22
22
  export declare class ListType<ItemTypeT extends ListType.ItemType> extends AbstractCollectionType<ItemTypeT> {
23
23
  private readonly identifierNodeKind;
24
24
  private readonly toRdfTypes;
25
- readonly kind = "ListType";
25
+ readonly kind = "List";
26
26
  constructor({ identifierNodeKind, toRdfTypes, ...superParameters }: {
27
27
  identifierNodeKind: ListType<ItemTypeT>["identifierNodeKind"];
28
28
  toRdfTypes: readonly NamedNode[];
@@ -11,7 +11,7 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
11
11
  export class ListType extends AbstractCollectionType {
12
12
  identifierNodeKind;
13
13
  toRdfTypes;
14
- kind = "ListType";
14
+ kind = "List";
15
15
  constructor({ identifierNodeKind, toRdfTypes, ...superParameters }) {
16
16
  super(superParameters);
17
17
  this.identifierNodeKind = identifierNodeKind;
@@ -102,31 +102,31 @@ __decorate([
102
102
  (function (ListType) {
103
103
  function isItemType(type) {
104
104
  switch (type.kind) {
105
- case "AnonymousUnionType":
106
- case "BigDecimalType":
107
- case "BigIntType":
108
- case "BlankNodeType":
109
- case "BooleanType":
110
- case "DateTimeType":
111
- case "DateType":
112
- case "FloatType":
113
- case "IdentifierType":
114
- case "IriType":
115
- case "IntType":
116
- case "LiteralType":
117
- case "NamedObjectUnionType":
118
- case "NamedUnionType":
105
+ case "AnonymousUnion":
106
+ case "BigDecimal":
107
+ case "BigInt":
108
+ case "BlankNode":
109
+ case "Boolean":
110
+ case "DateTime":
111
+ case "Date":
112
+ case "Float":
113
+ case "Identifier":
114
+ case "Iri":
115
+ case "Int":
116
+ case "Literal":
117
+ case "NamedObjectUnion":
118
+ case "NamedUnion":
119
119
  case "NamedObjectType":
120
- case "StringType":
121
- case "TermType":
120
+ case "String":
121
+ case "Term":
122
122
  return true;
123
- case "DefaultValueType":
124
- case "LazyObjectOptionType":
125
- case "LazyObjectSetType":
126
- case "LazyObjectType":
127
- case "ListType":
128
- case "OptionType":
129
- case "SetType":
123
+ case "DefaultValue":
124
+ case "LazyObjectOption":
125
+ case "LazyObjectSet":
126
+ case "LazyObject":
127
+ case "List":
128
+ case "Option":
129
+ case "Set":
130
130
  return false;
131
131
  }
132
132
  }
@@ -7,10 +7,11 @@ export declare class LiteralType extends AbstractLiteralType {
7
7
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
8
8
  readonly filterFunction: Code;
9
9
  readonly filterType: Code;
10
- readonly kind = "LiteralType";
10
+ readonly kind = "Literal";
11
11
  readonly schemaType: Code;
12
12
  readonly valueSparqlWherePatternsFunction: Code;
13
13
  get graphqlType(): AbstractLiteralType.GraphqlType;
14
+ protected get schemaInitializers(): readonly Code[];
14
15
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
15
16
  graphqlResolveExpression(_parameters: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
16
17
  jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractLiteralType["jsonSchema"]>[0]): Code;
@@ -1,7 +1,7 @@
1
1
  import { xsd } from "@tpluscode/rdf-ns-builders";
2
2
  import { Maybe } from "purify-ts";
3
3
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
- import { code } from "./ts-poet-wrapper.js";
4
+ import { arrayOf, code } from "./ts-poet-wrapper.js";
5
5
  export class LiteralType extends AbstractLiteralType {
6
6
  name = code `${this.reusables.imports.Literal}`;
7
7
  conversionFunction = Maybe.of({
@@ -23,12 +23,19 @@ export class LiteralType extends AbstractLiteralType {
23
23
  });
24
24
  filterFunction = code `${this.reusables.snippets.filterLiteral}`;
25
25
  filterType = code `${this.reusables.snippets.LiteralFilter}`;
26
- kind = "LiteralType";
26
+ kind = "Literal";
27
27
  schemaType = code `${this.reusables.snippets.LiteralSchema}`;
28
28
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
29
29
  get graphqlType() {
30
30
  throw new Error("not implemented");
31
31
  }
32
+ get schemaInitializers() {
33
+ let initializers = super.schemaInitializers;
34
+ if (this.in_.length > 0) {
35
+ initializers = initializers.concat(code `in: ${arrayOf(...this.in_.map((in_) => this.rdfjsTermExpression(in_)))}`);
36
+ }
37
+ return initializers;
38
+ }
32
39
  fromJsonExpression({ variables, }) {
33
40
  return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined)))`;
34
41
  }
@@ -20,6 +20,7 @@ export declare class NamedObjectType extends AbstractType {
20
20
  readonly kind = "NamedObjectType";
21
21
  readonly name: string;
22
22
  readonly recursive: boolean;
23
+ readonly referencesObjectType = true;
23
24
  readonly synthetic: boolean;
24
25
  readonly typeofs: "object"[];
25
26
  readonly validationFunction: Maybe<Code>;
@@ -51,6 +51,7 @@ export class NamedObjectType extends AbstractType {
51
51
  kind = "NamedObjectType";
52
52
  name;
53
53
  recursive;
54
+ referencesObjectType = true;
54
55
  synthetic;
55
56
  typeofs = ["object"];
56
57
  validationFunction = Maybe.empty();
@@ -196,7 +197,7 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
196
197
  if (this.parentObjectTypes.length > 0) {
197
198
  return this.parentObjectTypes[0].toRdfjsResourceType;
198
199
  }
199
- return code `${this.reusables.imports.Resource}${this.identifierType.kind === "IriType" ? code `<${this.reusables.imports.NamedNode}>` : ""}`;
200
+ return code `${this.reusables.imports.Resource}${this.identifierType.kind === "Iri" ? code `<${this.reusables.imports.NamedNode}>` : ""}`;
200
201
  }
201
202
  get valueSparqlConstructTriplesFunction() {
202
203
  return code `${this.name}.valueSparqlConstructTriples`;
@@ -8,7 +8,7 @@ import { type Code } from "./ts-poet-wrapper.js";
8
8
  export declare class NamedObjectUnionType extends AbstractNamedUnionType<NamedObjectType> {
9
9
  #private;
10
10
  readonly graphqlArgs: AbstractType["graphqlArgs"];
11
- readonly kind = "NamedObjectUnionType";
11
+ readonly kind = "NamedObjectUnion";
12
12
  readonly synthetic: boolean;
13
13
  constructor({ identifierType, synthetic, ...superParameters }: {
14
14
  identifierType: BlankNodeType | IdentifierType | IriType;
@@ -18,7 +18,7 @@ import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
18
18
  export class NamedObjectUnionType extends AbstractNamedUnionType {
19
19
  #identifierType;
20
20
  graphqlArgs = Maybe.empty();
21
- kind = "NamedObjectUnionType";
21
+ kind = "NamedObjectUnion";
22
22
  synthetic;
23
23
  constructor({ identifierType, synthetic, ...superParameters }) {
24
24
  super({ ...superParameters, identifierType: Maybe.of(identifierType) });
@@ -167,7 +167,7 @@ export namespace Identifier {
167
167
  const commonPropertiesByName = {};
168
168
  this.members.forEach((member, memberI) => {
169
169
  for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
170
- if (memberTypeProperty.kind !== "ShaclProperty") {
170
+ if (memberTypeProperty.kind !== "Shacl") {
171
171
  continue;
172
172
  }
173
173
  let commonProperty = commonPropertiesByName[memberTypeProperty.name];
@@ -191,14 +191,12 @@ export namespace Identifier {
191
191
  if (!memberTypesWithProperty.every((value) => value)) {
192
192
  continue;
193
193
  }
194
- propertiesObject.push(code `${property.name}: ${property.schema}`);
194
+ property.schema.ifJust(propertySchema => {
195
+ propertiesObject.push(code `${property.name}: ${propertySchema}`);
196
+ });
195
197
  }
196
198
  return singleEntryRecord(`schema`, code `\
197
- export const schema =
198
- ${{
199
- ...super.schemaObject,
200
- properties: code `{ ${joinCode(propertiesObject, { on: ", " })} }`,
201
- }} as const;`);
199
+ export const schema = { ${joinCode(super.schemaInitializers.concat(code `properties: { ${joinCode(propertiesObject, { on: ", " })} }`), { on: ", " })} } as const;`);
202
200
  }
203
201
  get toRdfResourceFunctionDeclaration() {
204
202
  if (!this.configuration.features.has("Object.toRdf")) {
@@ -4,7 +4,7 @@ import type { Type } from "./Type.js";
4
4
  import type { Code } from "./ts-poet-wrapper.js";
5
5
  export declare class NamedUnionType extends AbstractNamedUnionType<Type> {
6
6
  readonly graphqlArgs: AbstractType["graphqlArgs"];
7
- readonly kind = "NamedUnionType";
7
+ readonly kind = "NamedUnion";
8
8
  graphqlResolveExpression(): Code;
9
9
  get graphqlType(): AbstractType.GraphqlType;
10
10
  }
@@ -2,7 +2,7 @@ import { Maybe } from "purify-ts";
2
2
  import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
3
3
  export class NamedUnionType extends AbstractNamedUnionType {
4
4
  graphqlArgs = Maybe.empty();
5
- kind = "NamedUnionType";
5
+ kind = "NamedUnion";
6
6
  graphqlResolveExpression() {
7
7
  throw new Error("GraphQL doesn't support scalar unions");
8
8
  }
@@ -4,7 +4,7 @@ import { type Code } from "./ts-poet-wrapper.js";
4
4
  export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends AbstractContainerType<ItemTypeT> {
5
5
  readonly discriminantProperty: Maybe<AbstractContainerType.DiscriminantProperty>;
6
6
  readonly graphqlArgs: AbstractContainerType<ItemTypeT>["graphqlArgs"];
7
- readonly kind = "OptionType";
7
+ readonly kind = "Option";
8
8
  readonly typeofs: "object"[];
9
9
  get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
10
10
  get equalsFunction(): Code;
@@ -18,10 +18,6 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
18
18
  get validationFunction(): Maybe<Code>;
19
19
  get valueSparqlConstructTriplesFunction(): Code;
20
20
  get valueSparqlWherePatternsFunction(): Code;
21
- protected get schemaObject(): {
22
- kind: Code;
23
- item: Code;
24
- };
25
21
  fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
26
22
  fromRdfResourceValuesExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
27
23
  graphqlResolveExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
@@ -9,11 +9,11 @@ import { invariant } from "ts-invariant";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractContainerType } from "./AbstractContainerType.js";
11
11
  import { codeEquals } from "./codeEquals.js";
12
- import { code, literalOf } from "./ts-poet-wrapper.js";
12
+ import { code } from "./ts-poet-wrapper.js";
13
13
  export class OptionType extends AbstractContainerType {
14
14
  discriminantProperty = Maybe.empty();
15
15
  graphqlArgs = Maybe.empty();
16
- kind = "OptionType";
16
+ kind = "Option";
17
17
  typeofs = ["object"];
18
18
  get conversionFunction() {
19
19
  const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
@@ -64,12 +64,6 @@ export class OptionType extends AbstractContainerType {
64
64
  get valueSparqlWherePatternsFunction() {
65
65
  return code `${this.reusables.snippets.maybeSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
66
66
  }
67
- get schemaObject() {
68
- return {
69
- ...super.schemaObject,
70
- kind: code `${literalOf("Maybe")} as const`,
71
- };
72
- }
73
67
  fromJsonExpression({ variables, }) {
74
68
  const expression = code `${this.reusables.imports.Maybe}.fromNullable(${variables.value})`;
75
69
  const itemFromJsonExpression = this.itemType.fromJsonExpression({
@@ -99,7 +99,7 @@ ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${
99
99
  return this.#objectsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType.filterFunction, namedObjectType)}, query);
100
100
  }`);
101
101
  }
102
- case "NamedObjectUnionType":
102
+ case "NamedObjectUnion":
103
103
  return delegatingMethods.concat(code `\
104
104
  ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]> {
105
105
  return this.#objectUnionsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>([
@@ -2,7 +2,7 @@ import { AbstractCollectionType } from "./AbstractCollectionType.js";
2
2
  import { type Code } from "./ts-poet-wrapper.js";
3
3
  export declare class SetType<ItemTypeT extends SetType.ItemType> extends AbstractCollectionType<ItemTypeT> {
4
4
  readonly graphqlArgs: AbstractCollectionType<ItemTypeT>["graphqlArgs"];
5
- readonly kind = "SetType";
5
+ readonly kind = "Set";
6
6
  get valueSparqlConstructTriplesFunction(): Code;
7
7
  get valueSparqlWherePatternsFunction(): Code;
8
8
  fromRdfResourceValuesExpression(parameters: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
@@ -10,7 +10,7 @@ import { AbstractCollectionType } from "./AbstractCollectionType.js";
10
10
  import { code, joinCode } from "./ts-poet-wrapper.js";
11
11
  export class SetType extends AbstractCollectionType {
12
12
  graphqlArgs = Maybe.empty();
13
- kind = "SetType";
13
+ kind = "Set";
14
14
  get valueSparqlConstructTriplesFunction() {
15
15
  return code `${this.reusables.snippets.setSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
16
16
  }
@@ -87,6 +87,7 @@ export declare class Snippets {
87
87
  get decodeBigDecimalLiteral(): Snippet;
88
88
  get deduplicateSparqlPatterns(): Snippet;
89
89
  get defaultValueSparqlWherePatterns(): Snippet;
90
+ get ensureRdfResourceType(): Snippet;
90
91
  get filterArray(): Snippet;
91
92
  get filterBigDecimal(): Snippet;
92
93
  get filterBlankNode(): Snippet;
@@ -45,6 +45,7 @@ import { snippets_decodeBigDecimalLiteral } from "./_snippets/snippets_decodeBig
45
45
  import { snippets_deduplicateSparqlPatterns } from "./_snippets/snippets_deduplicateSparqlPatterns.js";
46
46
  import { snippets_defaultValueSparqlWherePatterns } from "./_snippets/snippets_defaultValueSparqlWherePatterns.js";
47
47
  import { snippets_EqualsResult } from "./_snippets/snippets_EqualsResult.js";
48
+ import { snippets_ensureRdfResourceType } from "./_snippets/snippets_ensureRdfResourceType.js";
48
49
  import { snippets_FocusSparqlConstructTriplesFunction } from "./_snippets/snippets_FocusSparqlConstructTriplesFunction.js";
49
50
  import { snippets_FocusSparqlWherePatternsFunction } from "./_snippets/snippets_FocusSparqlWherePatternsFunction.js";
50
51
  import { snippets_FromRdfResourceFunction } from "./_snippets/snippets_FromRdfResourceFunction.js";
@@ -379,6 +380,9 @@ export class Snippets {
379
380
  get defaultValueSparqlWherePatterns() {
380
381
  return this.snippet(snippets_defaultValueSparqlWherePatterns);
381
382
  }
383
+ get ensureRdfResourceType() {
384
+ return this.snippet(snippets_ensureRdfResourceType);
385
+ }
382
386
  get filterArray() {
383
387
  return this.snippet(snippets_filterArray);
384
388
  }
@@ -827,6 +831,9 @@ __decorate([
827
831
  __decorate([
828
832
  Memoize()
829
833
  ], Snippets.prototype, "defaultValueSparqlWherePatterns", null);
834
+ __decorate([
835
+ Memoize()
836
+ ], Snippets.prototype, "ensureRdfResourceType", null);
830
837
  __decorate([
831
838
  Memoize()
832
839
  ], Snippets.prototype, "filterArray", null);
@@ -6,7 +6,7 @@ export declare class StringType extends AbstractPrimitiveType<string> {
6
6
  readonly filterType: Code;
7
7
  readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
8
8
  readonly hashFunction: Code;
9
- readonly kind = "StringType";
9
+ readonly kind = "String";
10
10
  readonly schemaType: Code;
11
11
  readonly typeofs: "string"[];
12
12
  readonly valueSparqlWherePatternsFunction: Code;
@@ -13,8 +13,8 @@ export class StringType extends AbstractPrimitiveType {
13
13
  filterType = code `${this.reusables.snippets.StringFilter}`;
14
14
  graphqlType = new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
15
15
  hashFunction = code `${this.reusables.snippets.hashString}`;
16
- kind = "StringType";
17
- schemaType = code `${this.reusables.snippets.StringSchema}`;
16
+ kind = "String";
17
+ schemaType = code `${this.reusables.snippets.StringSchema}<${this.name}>`;
18
18
  typeofs = ["string"];
19
19
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.stringSparqlWherePatterns}`;
20
20
  get name() {
@@ -7,7 +7,7 @@ export declare class TermType<ConstantTermT extends Literal | NamedNode = Litera
7
7
  readonly conversionFunction: Maybe<AbstractTermType.ConversionFunction>;
8
8
  readonly filterFunction: Code;
9
9
  readonly filterType: Code;
10
- readonly kind = "TermType";
10
+ readonly kind = "Term";
11
11
  readonly nodeKinds: ReadonlySet<NodeKind>;
12
12
  readonly schemaType: Code;
13
13
  readonly valueSparqlWherePatternsFunction: Code;
@@ -15,7 +15,7 @@ export class TermType extends AbstractTermType {
15
15
  conversionFunction = Maybe.empty();
16
16
  filterFunction = code `${this.reusables.snippets.filterTerm}`;
17
17
  filterType = code `${this.reusables.snippets.TermFilter}`;
18
- kind = "TermType";
18
+ kind = "Term";
19
19
  nodeKinds;
20
20
  schemaType = code `${this.reusables.snippets.TermSchema}`;
21
21
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.termSparqlWherePatterns}`;