@shaclmate/compiler 4.0.40 → 4.0.41

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 (114) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +0 -8
  2. package/dist/ShapesGraphToAstTransformer.js +5 -85
  3. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
  4. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +0 -16
  6. package/dist/ast/AbstractCompoundType.d.ts +2 -1
  7. package/dist/ast/AbstractCompoundType.js +1 -1
  8. package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
  9. package/dist/ast/Ast.d.ts +1 -3
  10. package/dist/ast/ListType.d.ts +1 -1
  11. package/dist/ast/ListType.js +1 -1
  12. package/dist/ast/ObjectType.d.ts +0 -12
  13. package/dist/ast/ObjectType.js +0 -78
  14. package/dist/generators/AstJsonGenerator.js +7 -3
  15. package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
  16. package/dist/generators/ts/AbstractCollectionType.d.ts +4 -11
  17. package/dist/generators/ts/AbstractCollectionType.js +3 -62
  18. package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
  19. package/dist/generators/ts/AbstractContainerType.js +1 -4
  20. package/dist/generators/ts/AbstractDateType.d.ts +4 -1
  21. package/dist/generators/ts/AbstractDateType.js +6 -1
  22. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
  23. package/dist/generators/ts/AbstractIdentifierType.js +3 -0
  24. package/dist/generators/ts/AbstractLazyObjectType.d.ts +1 -1
  25. package/dist/generators/ts/AbstractLazyObjectType.js +12 -1
  26. package/dist/generators/ts/AbstractLiteralType.d.ts +1 -0
  27. package/dist/generators/ts/AbstractNumericType.js +7 -7
  28. package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
  29. package/dist/generators/ts/AbstractTermType.d.ts +1 -2
  30. package/dist/generators/ts/AbstractTermType.js +1 -3
  31. package/dist/generators/ts/AbstractType.d.ts +46 -16
  32. package/dist/generators/ts/AbstractType.js +31 -16
  33. package/dist/generators/ts/BigDecimalType.d.ts +4 -0
  34. package/dist/generators/ts/BigDecimalType.js +4 -1
  35. package/dist/generators/ts/BigIntType.d.ts +3 -1
  36. package/dist/generators/ts/BigIntType.js +1 -1
  37. package/dist/generators/ts/BlankNodeType.d.ts +1 -1
  38. package/dist/generators/ts/BlankNodeType.js +3 -3
  39. package/dist/generators/ts/BooleanType.d.ts +3 -1
  40. package/dist/generators/ts/BooleanType.js +1 -1
  41. package/dist/generators/ts/DefaultValueType.d.ts +39 -1
  42. package/dist/generators/ts/DefaultValueType.js +6 -3
  43. package/dist/generators/ts/FloatType.d.ts +3 -1
  44. package/dist/generators/ts/FloatType.js +1 -1
  45. package/dist/generators/ts/GraphqlSchema.js +2 -2
  46. package/dist/generators/ts/IdentifierType.d.ts +1 -1
  47. package/dist/generators/ts/IdentifierType.js +7 -5
  48. package/dist/generators/ts/IntType.d.ts +3 -1
  49. package/dist/generators/ts/IntType.js +1 -1
  50. package/dist/generators/ts/IriType.js +4 -2
  51. package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -0
  52. package/dist/generators/ts/LazyObjectOptionType.js +8 -4
  53. package/dist/generators/ts/LazyObjectSetType.js +9 -3
  54. package/dist/generators/ts/LazyObjectType.js +5 -2
  55. package/dist/generators/ts/ListType.d.ts +10 -1
  56. package/dist/generators/ts/ListType.js +45 -8
  57. package/dist/generators/ts/LiteralType.d.ts +4 -0
  58. package/dist/generators/ts/LiteralType.js +6 -3
  59. package/dist/generators/ts/ObjectType.d.ts +8 -22
  60. package/dist/generators/ts/ObjectType.js +6 -74
  61. package/dist/generators/ts/ObjectUnionType.js +2 -2
  62. package/dist/generators/ts/OptionType.d.ts +5 -1
  63. package/dist/generators/ts/OptionType.js +10 -5
  64. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -4
  65. package/dist/generators/ts/SetType.d.ts +16 -1
  66. package/dist/generators/ts/SetType.js +80 -2
  67. package/dist/generators/ts/Snippets.d.ts +3 -1
  68. package/dist/generators/ts/Snippets.js +18 -4
  69. package/dist/generators/ts/StringType.d.ts +3 -1
  70. package/dist/generators/ts/StringType.js +5 -1
  71. package/dist/generators/ts/TermType.d.ts +4 -0
  72. package/dist/generators/ts/TermType.js +3 -0
  73. package/dist/generators/ts/TsGenerator.d.ts +1 -1
  74. package/dist/generators/ts/TsGenerator.js +53 -28
  75. package/dist/generators/ts/TypeFactory.js +12 -25
  76. package/dist/generators/ts/UnionType.d.ts +3 -6
  77. package/dist/generators/ts/UnionType.js +42 -55
  78. package/dist/generators/ts/ZodGenerator.d.ts +1 -1
  79. package/dist/generators/ts/ZodGenerator.js +19 -12
  80. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +6 -3
  81. package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +8 -12
  82. package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +18 -35
  83. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +5 -5
  84. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +9 -30
  85. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.js +0 -4
  86. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -3
  87. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.js +0 -3
  88. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +0 -4
  89. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js +3 -22
  90. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +4 -29
  91. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +10 -39
  92. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +25 -29
  93. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +1 -5
  94. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +11 -8
  95. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +3 -9
  96. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +1 -8
  97. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +1 -3
  98. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +2 -4
  99. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +10 -31
  100. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js +1 -1
  101. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +2 -9
  102. package/dist/generators/ts/_ObjectType/ShaclProperty.js +6 -6
  103. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +0 -11
  104. package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
  105. package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
  106. package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
  107. package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
  108. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
  109. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
  110. package/dist/input/generated.d.ts +756 -115
  111. package/dist/input/generated.js +634 -126
  112. package/package.json +2 -4
  113. package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
  114. package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Maybe } from "purify-ts";
8
+ import { invariant } from "ts-invariant";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
10
11
  import { code } from "./ts-poet-wrapper.js";
@@ -12,16 +13,18 @@ export class LazyObjectType extends AbstractLazyObjectType {
12
13
  graphqlArgs = Maybe.empty();
13
14
  kind = "LazyObject";
14
15
  get conversionFunction() {
16
+ invariant(this.jsTypes.length === 1);
17
+ invariant(this.resolveType.jsTypes.length === 1);
15
18
  return Maybe.of({
16
19
  code: code `${this.reusables.snippets.convertToLazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.expression}, ${this.resolveType.expression}>(${this.resolveToPartialFunction({ partialType: this.partialType, resolveType: this.resolveType })})`,
17
20
  sourceTypes: [
18
21
  {
19
22
  expression: this.expression,
20
- typeof: "object",
23
+ jsType: this.jsTypes[0],
21
24
  },
22
25
  {
23
26
  expression: this.resolveType.expression,
24
- typeof: "object",
27
+ jsType: this.resolveType.jsTypes[0],
25
28
  },
26
29
  ],
27
30
  });
@@ -1,4 +1,5 @@
1
1
  import type { NamedNode } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
2
3
  import { AbstractCollectionType } from "./AbstractCollectionType.js";
3
4
  import type { BigDecimalType } from "./BigDecimalType.js";
4
5
  import type { BigIntType } from "./BigIntType.js";
@@ -21,20 +22,28 @@ import type { UnionType } from "./UnionType.js";
21
22
  export declare class ListType<ItemTypeT extends ListType.ItemType> extends AbstractCollectionType<ItemTypeT> {
22
23
  private readonly identifierNodeKind;
23
24
  private readonly toRdfTypes;
25
+ readonly jsTypes: readonly [{
26
+ readonly instanceof: "Array";
27
+ readonly typeof: "object";
28
+ }];
24
29
  readonly kind = "List";
25
30
  constructor({ identifierNodeKind, toRdfTypes, ...superParameters }: {
26
31
  identifierNodeKind: ListType<ItemTypeT>["identifierNodeKind"];
27
32
  toRdfTypes: readonly NamedNode[];
28
33
  } & ConstructorParameters<typeof AbstractCollectionType<ItemTypeT>>[0]);
34
+ get conversionFunction(): Maybe<AbstractCollectionType.ConversionFunction>;
35
+ get toRdfResourceValueTypes(): AbstractCollectionType<ItemTypeT>["toRdfResourceValueTypes"];
29
36
  get valueSparqlConstructTriplesFunction(): Code;
30
37
  get valueSparqlWherePatternsFunction(): Code;
38
+ fromJsonExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
31
39
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
40
+ jsonSchema(parameters: Parameters<AbstractCollectionType<ItemTypeT>["jsonSchema"]>[0]): Code;
32
41
  jsonType(): AbstractCollectionType.JsonType;
33
42
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
34
43
  toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
35
44
  }
36
45
  export declare namespace ListType {
37
- type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
46
+ type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
38
47
  function isItemType(type: Type): type is ItemType;
39
48
  }
40
49
  //# sourceMappingURL=ListType.d.ts.map
@@ -5,24 +5,48 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { rdf } from "@tpluscode/rdf-ns-builders";
8
+ import { Maybe } from "purify-ts";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractCollectionType } from "./AbstractCollectionType.js";
10
- import { code, joinCode } from "./ts-poet-wrapper.js";
11
+ import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
11
12
  export class ListType extends AbstractCollectionType {
12
13
  identifierNodeKind;
13
14
  toRdfTypes;
15
+ jsTypes = [
16
+ { instanceof: "Array", typeof: "object" },
17
+ ];
14
18
  kind = "List";
15
19
  constructor({ identifierNodeKind, toRdfTypes, ...superParameters }) {
16
20
  super(superParameters);
17
21
  this.identifierNodeKind = identifierNodeKind;
18
22
  this.toRdfTypes = toRdfTypes;
19
23
  }
24
+ get conversionFunction() {
25
+ const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
26
+ return Maybe.of({
27
+ code: code `${this.reusables.snippets.convertToList}(${itemConversionFunction.code}, ${literalOf(!this._mutable)})`,
28
+ sourceTypes: [
29
+ {
30
+ expression: code `readonly (${joinCode(itemConversionFunction.sourceTypes.map((itemSourceType) => code `${itemSourceType.expression}`), { on: " | " })})[]`,
31
+ jsType: { instanceof: "Array", typeof: "object" },
32
+ },
33
+ ],
34
+ });
35
+ }
36
+ get toRdfResourceValueTypes() {
37
+ return new Set(["BlankNode", "NamedNode"]); // List or rdf:nil
38
+ }
20
39
  get valueSparqlConstructTriplesFunction() {
21
40
  return code `${this.reusables.snippets.listSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
22
41
  }
23
42
  get valueSparqlWherePatternsFunction() {
24
43
  return code `${this.reusables.snippets.listSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
25
44
  }
45
+ fromJsonExpression({ variables, }) {
46
+ return code `${this.reusables.imports.Either}.sequence<Error, ${this.itemType.expression}>(${variables.value}.map(item => (${this.itemType.fromJsonExpression({
47
+ variables: { value: code `item` },
48
+ })})))`;
49
+ }
26
50
  fromRdfResourceValuesExpression({ variables, }) {
27
51
  return joinCode([
28
52
  variables.resourceValues,
@@ -39,22 +63,29 @@ export class ListType extends AbstractCollectionType {
39
63
  code `map(valueLists => valueLists.map(valueList => valueList.toArray()${this.mutable ? ".concat()" : ""}))`, // Convert inner Resource.Values to arrays
40
64
  ], { on: "." });
41
65
  }
66
+ jsonSchema(parameters) {
67
+ let schema = code `${this.itemType.jsonSchema(parameters)}.array()`;
68
+ if (!this._mutable) {
69
+ schema = code `${schema}.readonly()`;
70
+ }
71
+ return schema;
72
+ }
42
73
  jsonType() {
43
- return new AbstractCollectionType.JsonType(code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().name})[]`);
74
+ return new AbstractCollectionType.JsonType(code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().expression})[]`);
44
75
  }
45
76
  toRdfResourceValuesExpression({ variables, }) {
46
77
  let mintListIdentifierFunction;
47
78
  let mintSubListIdentifierFunction;
48
- let resourceTypeName;
79
+ let resourceTypeExpression;
49
80
  switch (this.identifierNodeKind) {
50
81
  case "BlankNode": {
51
82
  mintListIdentifierFunction =
52
83
  mintSubListIdentifierFunction = code `(() => ${this.reusables.imports.dataFactory}.blankNode())`;
53
- resourceTypeName = code `${this.reusables.imports.Resource}<${this.reusables.imports.BlankNode}>`;
84
+ resourceTypeExpression = code `${this.reusables.imports.Resource}<${this.reusables.imports.BlankNode}>`;
54
85
  break;
55
86
  }
56
87
  case "IRI": {
57
- resourceTypeName = code `${this.reusables.imports.Resource}<${this.reusables.imports.NamedNode}>`;
88
+ resourceTypeExpression = code `${this.reusables.imports.Resource}<${this.reusables.imports.NamedNode}>`;
58
89
  throw new RangeError("list IRI minting is unsupported");
59
90
  }
60
91
  }
@@ -81,8 +112,8 @@ export class ListType extends AbstractCollectionType {
81
112
  currentSubListResource: null,
82
113
  listResource: ${variables.resourceSet}.resource(${mintListIdentifierFunction}()),
83
114
  } as {
84
- currentSubListResource: ${resourceTypeName} | null;
85
- listResource: ${resourceTypeName};
115
+ currentSubListResource: ${resourceTypeExpression} | null;
116
+ listResource: ${resourceTypeExpression};
86
117
  },
87
118
  ).listResource.identifier : ${this.rdfjsTermExpression(rdf.nil)}]`;
88
119
  }
@@ -90,6 +121,12 @@ export class ListType extends AbstractCollectionType {
90
121
  return code `\`[\${${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })}))}]\``;
91
122
  }
92
123
  }
124
+ __decorate([
125
+ Memoize()
126
+ ], ListType.prototype, "conversionFunction", null);
127
+ __decorate([
128
+ Memoize()
129
+ ], ListType.prototype, "toRdfResourceValueTypes", null);
93
130
  __decorate([
94
131
  Memoize()
95
132
  ], ListType.prototype, "valueSparqlConstructTriplesFunction", null);
@@ -112,6 +149,7 @@ __decorate([
112
149
  case "Identifier":
113
150
  case "Iri":
114
151
  case "Int":
152
+ case "List":
115
153
  case "Literal":
116
154
  case "ObjectUnion":
117
155
  case "Object":
@@ -123,7 +161,6 @@ __decorate([
123
161
  case "LazyObjectOption":
124
162
  case "LazyObjectSet":
125
163
  case "LazyObject":
126
- case "List":
127
164
  case "Option":
128
165
  case "Set":
129
166
  return false;
@@ -7,6 +7,10 @@ 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 jsTypes: readonly [{
11
+ readonly instanceof: "Object";
12
+ readonly typeof: "object";
13
+ }];
10
14
  readonly kind = "Literal";
11
15
  readonly schemaType: Code;
12
16
  readonly valueSparqlWherePatternsFunction: Code;
@@ -9,20 +9,23 @@ export class LiteralType extends AbstractLiteralType {
9
9
  sourceTypes: [
10
10
  ...["bigint", "boolean", "number", "string"].map((typeof_) => ({
11
11
  expression: code `${typeof_}`,
12
- typeof: typeof_,
12
+ jsType: { typeof: typeof_ },
13
13
  })),
14
14
  {
15
15
  expression: code `Date`,
16
- typeof: "object",
16
+ jsType: { instanceof: "Date", typeof: "object" },
17
17
  },
18
18
  {
19
19
  expression: code `${this.reusables.imports.Literal}`,
20
- typeof: "object",
20
+ jsType: { instanceof: "Object", typeof: "object" },
21
21
  },
22
22
  ],
23
23
  });
24
24
  filterFunction = code `${this.reusables.snippets.filterLiteral}`;
25
25
  filterType = code `${this.reusables.snippets.LiteralFilter}`;
26
+ jsTypes = [
27
+ { instanceof: "Object", typeof: "object" },
28
+ ];
26
29
  kind = "Literal";
27
30
  schemaType = code `${this.reusables.snippets.LiteralSchema}`;
28
31
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
@@ -13,41 +13,33 @@ import { type Code } from "./ts-poet-wrapper.js";
13
13
  export declare class ObjectType extends AbstractType {
14
14
  protected readonly toRdfTypes: readonly NamedNode[];
15
15
  readonly conversionFunction: Maybe<AbstractType.ConversionFunction>;
16
+ readonly discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
16
17
  readonly extern: boolean;
17
18
  readonly fromRdfType: Maybe<NamedNode>;
18
19
  readonly graphqlArgs: AbstractType["graphqlArgs"];
19
20
  readonly identifierType: BlankNodeType | IdentifierType | IriType;
21
+ readonly jsTypes: readonly [{
22
+ readonly instanceof: "Object";
23
+ readonly typeof: "object";
24
+ }];
20
25
  readonly kind = "Object";
21
26
  readonly recursive: boolean;
22
27
  readonly referencesObjectType = true;
23
28
  readonly synthetic: boolean;
24
- readonly typeofs: "object"[];
25
29
  readonly validationFunction: Maybe<Code>;
26
- constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }: {
30
+ constructor({ discriminantProperty, extern, fromRdfType, identifierType, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }: {
31
+ discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
27
32
  comment: Maybe<string>;
28
33
  extern: boolean;
29
34
  fromRdfType: Maybe<NamedNode>;
30
35
  identifierType: BlankNodeType | IdentifierType | IriType;
31
36
  label: Maybe<string>;
32
- lazyAncestorObjectTypes: () => readonly ObjectType[];
33
- lazyChildObjectTypes: () => readonly ObjectType[];
34
- lazyDiscriminantProperty: (namedObjectType: ObjectType) => ObjectType.DiscriminantProperty;
35
- lazyDescendantObjectTypes: () => readonly ObjectType[];
36
- lazyParentObjectTypes: () => readonly ObjectType[];
37
- lazyProperties: (namedObjectType: ObjectType) => readonly ObjectType.Property[];
37
+ lazyProperties: (objectType: ObjectType) => readonly ObjectType.Property[];
38
38
  recursive: boolean;
39
39
  synthetic: boolean;
40
40
  toRdfTypes: readonly NamedNode[];
41
41
  } & ConstructorParameters<typeof AbstractType>[0]);
42
- get _discriminantProperty(): ObjectType.DiscriminantProperty;
43
- get ancestorObjectTypes(): readonly ObjectType[];
44
- get childObjectTypes(): readonly ObjectType[];
45
42
  get declaration(): Maybe<Code>;
46
- get descendantFromRdfTypeVariables(): readonly Code[];
47
- get descendantFromRdfTypes(): readonly NamedNode[];
48
- get descendantObjectTypes(): readonly ObjectType[];
49
- get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
50
- get discriminantValue(): string;
51
43
  get equalsFunction(): Code;
52
44
  get expression(): Code;
53
45
  get filterFunction(): Code;
@@ -58,7 +50,6 @@ export declare class ObjectType extends AbstractType {
58
50
  get identifierTypeAlias(): Code;
59
51
  get mutable(): boolean;
60
52
  get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
61
- get parentObjectTypes(): readonly ObjectType[];
62
53
  get properties(): readonly ObjectType.Property[];
63
54
  get schema(): Code;
64
55
  get schemaType(): Code;
@@ -80,11 +71,6 @@ export declare class ObjectType extends AbstractType {
80
71
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
81
72
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
82
73
  toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
83
- private readonly lazyAncestorObjectTypes;
84
- private readonly lazyChildObjectTypes;
85
- private readonly lazyDescendantObjectTypes;
86
- private readonly lazyDiscriminantProperty;
87
- private readonly lazyParentObjectTypes;
88
74
  private readonly lazyProperties;
89
75
  }
90
76
  export declare namespace ObjectType {
@@ -44,41 +44,31 @@ import { code, def, joinCode } from "./ts-poet-wrapper.js";
44
44
  export class ObjectType extends AbstractType {
45
45
  toRdfTypes;
46
46
  conversionFunction = Maybe.empty();
47
+ discriminantProperty;
47
48
  extern;
48
49
  fromRdfType;
49
50
  graphqlArgs = Maybe.empty();
50
51
  identifierType;
52
+ jsTypes = [
53
+ { instanceof: "Object", typeof: "object" },
54
+ ];
51
55
  kind = "Object";
52
56
  recursive;
53
57
  referencesObjectType = true;
54
58
  synthetic;
55
- typeofs = ["object"];
56
59
  validationFunction = Maybe.empty();
57
- constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }) {
60
+ constructor({ discriminantProperty, extern, fromRdfType, identifierType, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }) {
58
61
  super(superParameters);
62
+ this.discriminantProperty = discriminantProperty;
59
63
  this.extern = extern;
60
64
  this.fromRdfType = fromRdfType;
61
65
  this.identifierType = identifierType;
62
66
  // Lazily initialize some members in getters to avoid recursive construction
63
- this.lazyAncestorObjectTypes = lazyAncestorObjectTypes;
64
- this.lazyChildObjectTypes = lazyChildObjectTypes;
65
- this.lazyDescendantObjectTypes = lazyDescendantObjectTypes;
66
- this.lazyDiscriminantProperty = lazyDiscriminantProperty;
67
- this.lazyParentObjectTypes = lazyParentObjectTypes;
68
67
  this.lazyProperties = lazyProperties;
69
68
  this.recursive = recursive;
70
69
  this.synthetic = synthetic;
71
70
  this.toRdfTypes = toRdfTypes;
72
71
  }
73
- get _discriminantProperty() {
74
- return this.lazyDiscriminantProperty(this);
75
- }
76
- get ancestorObjectTypes() {
77
- return this.lazyAncestorObjectTypes();
78
- }
79
- get childObjectTypes() {
80
- return this.lazyChildObjectTypes();
81
- }
82
72
  get declaration() {
83
73
  const alias = this.alias.extract();
84
74
  if (!alias) {
@@ -123,26 +113,6 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
123
113
  }
124
114
  return Maybe.of(joinCode(declarations, { on: "\n\n" }));
125
115
  }
126
- get descendantFromRdfTypeVariables() {
127
- return this.descendantObjectTypes.flatMap((descendantObjectType) => descendantObjectType.fromRdfTypeVariable.toList());
128
- }
129
- get descendantFromRdfTypes() {
130
- return this.descendantObjectTypes.flatMap((descendantObjectType) => descendantObjectType.fromRdfType.toList());
131
- }
132
- get descendantObjectTypes() {
133
- return this.lazyDescendantObjectTypes();
134
- }
135
- get discriminantProperty() {
136
- return Maybe.of({
137
- jsonName: this._discriminantProperty.jsonName,
138
- name: this._discriminantProperty.name,
139
- ownValues: this._discriminantProperty.type.ownValues,
140
- descendantValues: this._discriminantProperty.type.descendantValues,
141
- });
142
- }
143
- get discriminantValue() {
144
- return this.alias.unsafeCoerce();
145
- }
146
116
  get equalsFunction() {
147
117
  return code `${this.alias.unsafeCoerce()}.equals`;
148
118
  }
@@ -176,9 +146,6 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
176
146
  configuration: this.configuration,
177
147
  });
178
148
  }
179
- get parentObjectTypes() {
180
- return this.lazyParentObjectTypes();
181
- }
182
149
  get properties() {
183
150
  const properties = this.lazyProperties(this);
184
151
  const propertyNames = new Set();
@@ -199,9 +166,6 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
199
166
  return new Set([...this.identifierType.nodeKinds].map(NodeKind.toTermType));
200
167
  }
201
168
  get toRdfjsResourceType() {
202
- if (this.parentObjectTypes.length > 0) {
203
- return this.parentObjectTypes[0].toRdfjsResourceType;
204
- }
205
169
  return code `${this.reusables.imports.Resource}${this.identifierType.kind === "Iri" ? code `<${this.reusables.imports.NamedNode}>` : ""}`;
206
170
  }
207
171
  get valueSparqlConstructTriplesFunction() {
@@ -251,37 +215,8 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
251
215
  toStringExpression({ variables, }) {
252
216
  return code `${this.alias.unsafeCoerce()}.${this.configuration.syntheticNamePrefix}toString(${variables.value})`;
253
217
  }
254
- lazyAncestorObjectTypes;
255
- lazyChildObjectTypes;
256
- lazyDescendantObjectTypes;
257
- lazyDiscriminantProperty;
258
- lazyParentObjectTypes;
259
218
  lazyProperties;
260
219
  }
261
- __decorate([
262
- Memoize()
263
- ], ObjectType.prototype, "_discriminantProperty", null);
264
- __decorate([
265
- Memoize()
266
- ], ObjectType.prototype, "ancestorObjectTypes", null);
267
- __decorate([
268
- Memoize()
269
- ], ObjectType.prototype, "childObjectTypes", null);
270
- __decorate([
271
- Memoize()
272
- ], ObjectType.prototype, "descendantFromRdfTypeVariables", null);
273
- __decorate([
274
- Memoize()
275
- ], ObjectType.prototype, "descendantFromRdfTypes", null);
276
- __decorate([
277
- Memoize()
278
- ], ObjectType.prototype, "descendantObjectTypes", null);
279
- __decorate([
280
- Memoize()
281
- ], ObjectType.prototype, "discriminantProperty", null);
282
- __decorate([
283
- Memoize()
284
- ], ObjectType.prototype, "discriminantValue", null);
285
220
  __decorate([
286
221
  Memoize()
287
222
  ], ObjectType.prototype, "equalsFunction", null);
@@ -312,9 +247,6 @@ __decorate([
312
247
  __decorate([
313
248
  Memoize()
314
249
  ], ObjectType.prototype, "objectSetMethodNames", null);
315
- __decorate([
316
- Memoize()
317
- ], ObjectType.prototype, "parentObjectTypes", null);
318
250
  __decorate([
319
251
  Memoize()
320
252
  ], ObjectType.prototype, "properties", null);
@@ -130,7 +130,7 @@ export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
130
130
  description: this.comment.map(JSON.stringify).extract(),
131
131
  name: alias,
132
132
  resolveType: code `(value: ${alias}) => value.${this.configuration.syntheticNamePrefix}type`,
133
- types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
133
+ types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableExpression), { on: ", " })}]`,
134
134
  }});`);
135
135
  }
136
136
  get identifierTypeDeclarations() {
@@ -163,7 +163,7 @@ export namespace Identifier {
163
163
  }
164
164
  const commonPropertiesByName = {};
165
165
  this.members.forEach((member, memberI) => {
166
- for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
166
+ for (const memberTypeProperty of member.type.properties) {
167
167
  if (memberTypeProperty.kind !== "Shacl") {
168
168
  continue;
169
169
  }
@@ -5,7 +5,10 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
5
5
  readonly discriminantProperty: Maybe<AbstractContainerType.DiscriminantProperty>;
6
6
  readonly graphqlArgs: AbstractContainerType<ItemTypeT>["graphqlArgs"];
7
7
  readonly kind = "Option";
8
- readonly typeofs: "object"[];
8
+ readonly jsTypes: readonly [{
9
+ readonly instanceof: "Maybe";
10
+ readonly typeof: "object";
11
+ }];
9
12
  get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
10
13
  get equalsFunction(): Code;
11
14
  get expression(): Code;
@@ -15,6 +18,7 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
15
18
  get hashFunction(): Code;
16
19
  get mutable(): boolean;
17
20
  get schemaType(): Code;
21
+ get toRdfResourceValueTypes(): AbstractContainerType<ItemTypeT>["toRdfResourceValueTypes"];
18
22
  get validationFunction(): Maybe<Code>;
19
23
  get valueSparqlConstructTriplesFunction(): Code;
20
24
  get valueSparqlWherePatternsFunction(): Code;
@@ -14,17 +14,19 @@ export class OptionType extends AbstractContainerType {
14
14
  discriminantProperty = Maybe.empty();
15
15
  graphqlArgs = Maybe.empty();
16
16
  kind = "Option";
17
- typeofs = ["object"];
17
+ jsTypes = [
18
+ { instanceof: "Maybe", typeof: "object" },
19
+ ];
18
20
  get conversionFunction() {
19
21
  const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
20
22
  return Maybe.of({
21
23
  code: code `${this.reusables.snippets.convertToMaybe}(${itemConversionFunction.code})`,
22
24
  sourceTypes: itemConversionFunction.sourceTypes.concat({
23
25
  expression: this.expression,
24
- typeof: "object",
26
+ jsType: { instanceof: "Maybe", typeof: "object" },
25
27
  }, {
26
28
  expression: code `undefined`,
27
- typeof: "undefined",
29
+ jsType: { typeof: "undefined" },
28
30
  }),
29
31
  });
30
32
  }
@@ -42,7 +44,7 @@ export class OptionType extends AbstractContainerType {
42
44
  }
43
45
  get graphqlType() {
44
46
  invariant(!this.itemType.graphqlType.nullable);
45
- return new AbstractContainerType.GraphqlType(this.itemType.graphqlType.name, this.reusables, {
47
+ return new AbstractContainerType.GraphqlType(this.itemType.graphqlType.expression, this.reusables, {
46
48
  nullable: true,
47
49
  });
48
50
  }
@@ -55,6 +57,9 @@ export class OptionType extends AbstractContainerType {
55
57
  get schemaType() {
56
58
  return code `${this.reusables.snippets.MaybeSchema}<${this.itemType.schemaType}>`;
57
59
  }
60
+ get toRdfResourceValueTypes() {
61
+ return this.itemType.toRdfResourceValueTypes;
62
+ }
58
63
  get validationFunction() {
59
64
  return Maybe.of(code `${this.reusables.snippets.validateMaybe}(${this.itemType.validationFunction.orDefault(this.itemValidationFunctionDefault)})`);
60
65
  }
@@ -84,7 +89,7 @@ export class OptionType extends AbstractContainerType {
84
89
  jsonType(parameters) {
85
90
  const itemTypeJsonType = this.itemType.jsonType(parameters);
86
91
  invariant(!itemTypeJsonType.optional);
87
- return new AbstractContainerType.JsonType(itemTypeJsonType.name, {
92
+ return new AbstractContainerType.JsonType(itemTypeJsonType.expression, {
88
93
  optional: true,
89
94
  });
90
95
  }
@@ -87,10 +87,7 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
87
87
  // objectsSync has per-object type logic, not just forwarding
88
88
  ];
89
89
  const runtimeObjectType = (filterFunction, namedObjectType) => {
90
- const fromRdfTypes = namedObjectType.fromRdfTypeVariable
91
- .toList()
92
- .concat(namedObjectType.descendantFromRdfTypeVariables);
93
- return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.expression}.fromRdfResource, fromRdfTypes: ${fromRdfTypes.length > 0 ? code `[${joinCode(fromRdfTypes, { on: ", " })}]` : "[]"} }`;
90
+ return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.expression}.fromRdfResource, fromRdfTypes: ${namedObjectType.fromRdfTypeVariable.map((fromRdfTypeVariable) => code `[${fromRdfTypeVariable}]`).orDefault(code `[]`)} }`;
94
91
  };
95
92
  switch (namedObjectType.kind) {
96
93
  case "Object": {
@@ -1,17 +1,32 @@
1
+ import { Maybe } from "purify-ts";
1
2
  import { AbstractCollectionType } from "./AbstractCollectionType.js";
3
+ import type { AbstractContainerType } from "./AbstractContainerType.js";
2
4
  import { type Code } from "./ts-poet-wrapper.js";
3
5
  export declare class SetType<ItemTypeT extends SetType.ItemType> extends AbstractCollectionType<ItemTypeT> {
4
6
  readonly graphqlArgs: AbstractCollectionType<ItemTypeT>["graphqlArgs"];
5
7
  readonly kind = "Set";
8
+ readonly minCount: bigint;
9
+ readonly jsTypes: readonly [{
10
+ readonly instanceof: "Array";
11
+ readonly typeof: "object";
12
+ }];
13
+ constructor({ minCount, ...superParameters }: {
14
+ minCount: bigint;
15
+ } & ConstructorParameters<typeof AbstractCollectionType<ItemTypeT>>[0]);
16
+ get conversionFunction(): Maybe<AbstractCollectionType.ConversionFunction>;
17
+ get toRdfResourceValueTypes(): AbstractCollectionType<ItemTypeT>["toRdfResourceValueTypes"];
6
18
  get valueSparqlConstructTriplesFunction(): Code;
7
19
  get valueSparqlWherePatternsFunction(): Code;
20
+ protected get schemaInitializers(): readonly Code[];
21
+ fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
8
22
  fromRdfResourceValuesExpression(parameters: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
23
+ jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
9
24
  jsonType(): AbstractCollectionType.JsonType;
10
25
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
11
26
  toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
12
27
  }
13
28
  export declare namespace SetType {
14
29
  type ItemType = AbstractCollectionType.ItemType;
15
- const isItemType: typeof import("./AbstractContainerType.js").AbstractContainerType.isItemType;
30
+ const isItemType: typeof AbstractContainerType.isItemType;
16
31
  }
17
32
  //# sourceMappingURL=SetType.d.ts.map