@shaclmate/compiler 4.0.24 → 4.0.25

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 (87) hide show
  1. package/dist/Compiler.d.ts +1 -1
  2. package/dist/ShapesGraphToAstTransformer.d.ts +1 -1
  3. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +1 -1
  4. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
  5. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +0 -6
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -2
  7. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +14 -32
  8. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  9. package/dist/ast/ObjectType.d.ts +3 -23
  10. package/dist/ast/ObjectType.js +2 -20
  11. package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
  12. package/dist/generators/ts/AbstractContainerType.js +0 -1
  13. package/dist/generators/ts/AbstractLazyObjectType.d.ts +0 -1
  14. package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
  15. package/dist/generators/ts/AbstractNamedUnionType.d.ts +1 -2
  16. package/dist/generators/ts/AbstractNamedUnionType.js +16 -19
  17. package/dist/generators/ts/AbstractTermType.d.ts +0 -1
  18. package/dist/generators/ts/AbstractTermType.js +0 -1
  19. package/dist/generators/ts/AbstractType.d.ts +0 -4
  20. package/dist/generators/ts/AbstractUnionType.d.ts +1 -10
  21. package/dist/generators/ts/AbstractUnionType.js +26 -39
  22. package/dist/generators/ts/LazyObjectOptionType.js +3 -2
  23. package/dist/generators/ts/LazyObjectSetType.js +2 -1
  24. package/dist/generators/ts/LazyObjectType.js +2 -1
  25. package/dist/generators/ts/NamedObjectType.d.ts +2 -13
  26. package/dist/generators/ts/NamedObjectType.js +33 -104
  27. package/dist/generators/ts/NamedObjectUnionType.js +13 -24
  28. package/dist/generators/ts/TypeFactory.js +10 -28
  29. package/dist/generators/ts/ZodGenerator.js +2 -2
  30. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +1 -7
  31. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +1 -6
  32. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +0 -1
  33. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +4 -31
  34. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -17
  35. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +2 -2
  36. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +5 -0
  37. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +25 -0
  38. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +1 -1
  39. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
  40. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
  41. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -4
  42. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +1 -4
  43. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -4
  44. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +4 -0
  45. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +49 -0
  46. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +0 -3
  47. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  48. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
  49. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +2 -2
  50. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
  51. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +1 -1
  52. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -2
  53. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
  54. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
  55. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -2
  56. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  57. package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toJsonFunctionOrMethodDeclaration.js → NamedObjectType_toJsonFunctionDeclaration.js} +5 -27
  58. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  59. package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +4 -25
  60. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +4 -0
  61. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +40 -0
  62. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  63. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  64. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +6 -28
  65. package/dist/generators/ts/objectSetDeclarations.js +1 -3
  66. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -4
  67. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +1 -1
  68. package/dist/input/ShapesGraph.d.ts +1 -1
  69. package/dist/input/generated.d.ts +0 -134
  70. package/dist/input/generated.js +12 -239
  71. package/package.json +2 -4
  72. package/dist/enums/TsObjectDeclarationType.d.ts +0 -9
  73. package/dist/enums/TsObjectDeclarationType.js +0 -16
  74. package/dist/enums/Visibility.d.ts +0 -6
  75. package/dist/enums/Visibility.js +0 -18
  76. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +0 -4
  77. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -61
  78. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
  79. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -52
  80. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
  81. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -77
  82. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
  83. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
  84. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +0 -4
  85. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +0 -66
  86. /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
  87. /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { Either } from "purify-ts";
2
2
  import type { Logger } from "ts-log";
3
- import type { TsFeature } from "./enums/TsFeature.js";
4
3
  import type { Generator } from "./generators/Generator.js";
4
+ import type { TsFeature } from "./generators/ts/TsFeature.js";
5
5
  import type { ShapesGraph } from "./input/ShapesGraph.js";
6
6
  export declare class Compiler {
7
7
  private readonly generator;
@@ -3,7 +3,7 @@ import type { BlankNode, NamedNode } from "@rdfjs/types";
3
3
  import { Either } from "purify-ts";
4
4
  import type { Logger } from "ts-log";
5
5
  import type * as ast from "./ast/index.js";
6
- import type { TsFeature } from "./enums/TsFeature.js";
6
+ import type { TsFeature } from "./generators/ts/TsFeature.js";
7
7
  import type * as input from "./input/index.js";
8
8
  interface RelatedNodeShapes {
9
9
  readonly ancestors: input.NodeShape[];
@@ -1,5 +1,5 @@
1
1
  import { Either } from "purify-ts";
2
- import { type TsFeature } from "../enums/TsFeature.js";
2
+ import { type TsFeature } from "../generators/ts/TsFeature.js";
3
3
  import type * as input from "../input/index.js";
4
4
  import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
5
5
  export declare function nodeShapeTsFeatures(this: ShapesGraphToAstTransformer, nodeShape: input.NodeShape): Either<Error, ReadonlySet<TsFeature>>;
@@ -1,5 +1,5 @@
1
1
  import { Either } from "purify-ts";
2
- import { TS_FEATURES } from "../enums/TsFeature.js";
2
+ import { TS_FEATURES } from "../generators/ts/TsFeature.js";
3
3
  import { shapeOntology } from "./shapeOntology.js";
4
4
  export function nodeShapeTsFeatures(nodeShape) {
5
5
  const tsFeaturesDefault = this.tsFeaturesDefault;
@@ -55,9 +55,12 @@ export function nodeShapeTsFeatures(nodeShape) {
55
55
  tsFeatures.add(tsFeature);
56
56
  }
57
57
  }
58
- if (tsFeatures.has("graphql")) {
58
+ if (tsFeatures.has("graphql") || tsFeatures.has("sparql")) {
59
59
  tsFeatures.add("rdf");
60
60
  }
61
+ if (tsFeatures.has("json") || tsFeatures.has("rdf")) {
62
+ tsFeatures.add("create");
63
+ }
61
64
  return Either.of(tsFeatures);
62
65
  });
63
66
  }
@@ -4,7 +4,6 @@ import { Either, Left, Maybe } from "purify-ts";
4
4
  import { invariant } from "ts-invariant";
5
5
  import * as ast from "../ast/index.js";
6
6
  import { Eithers } from "../Eithers.js";
7
- import { Visibility } from "../enums/Visibility.js";
8
7
  import { ShapeStack } from "./ShapeStack.js";
9
8
  import { transformShapeToAstType } from "./transformShapeToAstType.js";
10
9
  function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
@@ -20,7 +19,6 @@ function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
20
19
  break;
21
20
  }
22
21
  return new ast.ObjectType({
23
- abstract: false,
24
22
  comment: Maybe.empty(),
25
23
  extern: false,
26
24
  fromRdfType: Maybe.empty(),
@@ -32,7 +30,6 @@ function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
32
30
  toRdfTypes: [],
33
31
  tsFeatures,
34
32
  tsImports: [],
35
- tsObjectDeclarationType: "class",
36
33
  });
37
34
  }
38
35
  function propertyName(objectType, propertyShape) {
@@ -261,9 +258,6 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
261
258
  path: propertyShape.path,
262
259
  shapeIdentifier: propertyShape.$identifier(),
263
260
  type: astType,
264
- visibility: propertyShape.visibility
265
- .map(Visibility.fromIri)
266
- .orDefault("public"),
267
261
  }));
268
262
  });
269
263
  }
@@ -8,7 +8,6 @@ import { shapeAstTypeName } from "./shapeAstTypeName.js";
8
8
  import { shapeNodeKinds } from "./shapeNodeKinds.js";
9
9
  import { transformPropertyShapeToAstObjectTypeProperty } from "./transformPropertyShapeToAstObjectTypeProperty.js";
10
10
  const listPropertiesObjectType = new ast.ObjectType({
11
- abstract: false,
12
11
  extern: false,
13
12
  comment: Maybe.empty(),
14
13
  label: Maybe.empty(),
@@ -22,7 +21,6 @@ const listPropertiesObjectType = new ast.ObjectType({
22
21
  name: Maybe.empty(),
23
22
  toRdfTypes: [],
24
23
  tsFeatures: new Set([]),
25
- tsObjectDeclarationType: "class",
26
24
  shapeIdentifier: dataFactory.blankNode(),
27
25
  synthetic: true,
28
26
  tsImports: [],
@@ -3,13 +3,11 @@ import { Either, Left, Maybe } from "purify-ts";
3
3
  import { invariant } from "ts-invariant";
4
4
  import * as ast from "../ast/index.js";
5
5
  import { Eithers } from "../Eithers.js";
6
- import { TsObjectDeclarationType } from "../enums/TsObjectDeclarationType.js";
7
6
  import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
8
7
  import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
9
8
  import { ShapeStack } from "./ShapeStack.js";
10
9
  import { shapeAstTypeName } from "./shapeAstTypeName.js";
11
10
  import { shapeNodeKinds } from "./shapeNodeKinds.js";
12
- import { shapeOntology } from "./shapeOntology.js";
13
11
  import { transformPropertyShapeToAstObjectTypeProperty } from "./transformPropertyShapeToAstObjectTypeProperty.js";
14
12
  import { transformShapeToAstType } from "./transformShapeToAstType.js";
15
13
  function isObjectTypePropertyRequired(property) {
@@ -56,39 +54,26 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
56
54
  if (nodeShape.$identifier().termType !== "NamedNode") {
57
55
  return Either.of(Maybe.empty());
58
56
  }
59
- return Eithers.chain4(shapeNodeKinds.call(this, nodeShape, { defaultNodeShapeNodeKinds }), Either.sequence(nodeShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier))), nodeShapeTsFeatures.call(this, nodeShape), nodeShape.tsObjectDeclarationType.isJust()
60
- ? Either.of(nodeShape.tsObjectDeclarationType.map(TsObjectDeclarationType.fromIri))
61
- : shapeOntology
62
- .call(this, nodeShape)
63
- .map((ontology) => ontology.chain((ontology) => ontology.tsObjectDeclarationType.map(TsObjectDeclarationType.fromIri)))).chain(([nodeKinds, propertyShapes, tsFeatures, tsObjectDeclarationType]) => {
64
- const abstract = nodeShape.abstract.orDefault(false);
57
+ return Eithers.chain3(shapeNodeKinds.call(this, nodeShape, { defaultNodeShapeNodeKinds }), Either.sequence(nodeShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier))), nodeShapeTsFeatures.call(this, nodeShape)).chain(([nodeKinds, propertyShapes, tsFeatures]) => {
65
58
  const nodeShapeIdentifier = nodeShape.$identifier();
66
59
  const { ancestors: ancestorNodeShapes, descendants: descendantNodeShapes, children: childNodeShapes, parents: parentNodeShapes, } = this.relatedNodeShapesByIdentifier.get(nodeShapeIdentifier);
67
60
  const isClass = nodeShape.subClassOf.length > 0 ||
68
61
  descendantNodeShapes.length > 0 || // A node shape that is the object of an rdfs:subClassOf is itself an rdfs:Class
69
62
  nodeShape.types.some((type) => type.equals(owl.Class) || type.equals(rdfs.Class));
70
- let fromRdfType;
71
- let toRdfTypes;
72
- if (!abstract) {
73
- fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
74
- if (isClass && nodeShapeIdentifier.termType === "NamedNode") {
75
- fromRdfType = fromRdfType.alt(Maybe.of(nodeShapeIdentifier));
76
- }
77
- toRdfTypes = nodeShape.toRdfTypes.concat();
78
- if (toRdfTypes.length === 0) {
79
- toRdfTypes.push(...nodeShape.rdfType.toList());
80
- }
81
- // Ensure toRdfTypes has fromRdfType
82
- fromRdfType.ifJust((fromRdfType) => {
83
- if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
84
- toRdfTypes.push(fromRdfType);
85
- }
86
- });
63
+ let fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
64
+ if (isClass && nodeShapeIdentifier.termType === "NamedNode") {
65
+ fromRdfType = fromRdfType.alt(Maybe.of(nodeShapeIdentifier));
87
66
  }
88
- else {
89
- fromRdfType = Maybe.empty();
90
- toRdfTypes = [];
67
+ const toRdfTypes = nodeShape.toRdfTypes.concat();
68
+ if (toRdfTypes.length === 0) {
69
+ toRdfTypes.push(...nodeShape.rdfType.toList());
91
70
  }
71
+ // Ensure toRdfTypes has fromRdfType
72
+ fromRdfType.ifJust((fromRdfType) => {
73
+ if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
74
+ toRdfTypes.push(fromRdfType);
75
+ }
76
+ });
92
77
  if (nodeKinds.has("Literal")) {
93
78
  return Left(new Error(`${nodeShape} should not have a nodeKind "Literal"`));
94
79
  }
@@ -128,7 +113,6 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
128
113
  // If this node shape's properties (directly or indirectly) refer to the node shape itself,
129
114
  // we'll return this placeholder.
130
115
  const objectType = new ast.ObjectType({
131
- abstract,
132
116
  comment: nodeShape.comment,
133
117
  extern: nodeShape.extern.orDefault(false),
134
118
  fromRdfType,
@@ -140,7 +124,6 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
140
124
  toRdfTypes,
141
125
  tsFeatures,
142
126
  tsImports: nodeShape.tsImports,
143
- tsObjectDeclarationType: tsObjectDeclarationType.orDefault("class"),
144
127
  });
145
128
  this.cachedAstTypesByShapeIdentifier.set(nodeShape.$identifier(), objectType);
146
129
  return (() => {
@@ -170,8 +153,7 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
170
153
  objectType.addProperties(property);
171
154
  });
172
155
  }
173
- if (!objectType.abstract &&
174
- !objectType.extern &&
156
+ if (!objectType.extern &&
175
157
  objectType.fromRdfType.isNothing() &&
176
158
  !objectType.properties.some(isObjectTypePropertyRequired)) {
177
159
  return Left(new Error(`${nodeShape} has no required properties and no implicitly required rdf:type`));
@@ -1,5 +1,5 @@
1
1
  import type { NodeKind } from "@shaclmate/shacl-ast";
2
- import type { TsFeature } from "../enums/TsFeature.js";
2
+ import type { TsFeature } from "../generators/ts/TsFeature.js";
3
3
  import { AbstractType } from "./AbstractType.js";
4
4
  import type { BlankNodeType } from "./BlankNodeType.js";
5
5
  import type { IdentifierType } from "./IdentifierType.js";
@@ -2,9 +2,7 @@ import type { BlankNode, NamedNode } from "@rdfjs/types";
2
2
  import { PropertyPath } from "@rdfx/resource";
3
3
  import type { NodeKind } from "@shaclmate/shacl-ast";
4
4
  import type { Maybe } from "purify-ts";
5
- import type { TsFeature } from "../enums/TsFeature.js";
6
- import type { TsObjectDeclarationType } from "../enums/TsObjectDeclarationType.js";
7
- import type { Visibility } from "../enums/Visibility.js";
5
+ import type { TsFeature } from "../generators/ts/TsFeature.js";
8
6
  import { AbstractType } from "./AbstractType.js";
9
7
  import type { BlankNodeType } from "./BlankNodeType.js";
10
8
  import type { IdentifierType } from "./IdentifierType.js";
@@ -12,12 +10,6 @@ import type { IriType } from "./IriType.js";
12
10
  import { Type } from "./Type.js";
13
11
  export declare class ObjectType extends AbstractType {
14
12
  #private;
15
- /**
16
- * Classes generated from this type are abstract / cannot be instantiated themselves.
17
- *
18
- * Defaults to false.
19
- */
20
- readonly abstract: boolean;
21
13
  /**
22
14
  * If true, the code for this ObjectType is defined externally and should not be generated.
23
15
  *
@@ -64,12 +56,7 @@ export declare class ObjectType extends AbstractType {
64
56
  * import { MyType } from "./MyType.js"
65
57
  */
66
58
  readonly tsImports: readonly string[];
67
- /**
68
- * Whether to generate a TypeScript class or interface for this type.
69
- */
70
- readonly tsObjectDeclarationType: TsObjectDeclarationType;
71
- constructor({ abstract, extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, tsObjectDeclarationType, ...superParameters }: {
72
- abstract: boolean;
59
+ constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, ...superParameters }: {
73
60
  extern: boolean;
74
61
  fromRdfType: Maybe<NamedNode>;
75
62
  identifierType: BlankNodeType | IdentifierType | IriType;
@@ -77,7 +64,6 @@ export declare class ObjectType extends AbstractType {
77
64
  toRdfTypes: readonly NamedNode[];
78
65
  tsFeatures: ReadonlySet<TsFeature>;
79
66
  tsImports: readonly string[];
80
- tsObjectDeclarationType: TsObjectDeclarationType;
81
67
  } & ConstructorParameters<typeof AbstractType>[0]);
82
68
  get ancestorObjectTypes(): readonly ObjectType[];
83
69
  get childObjectTypes(): readonly ObjectType[];
@@ -163,11 +149,7 @@ export declare namespace ObjectType {
163
149
  * Type of this property.
164
150
  */
165
151
  readonly type: Type;
166
- /**
167
- * Visibility: private, protected, public.
168
- */
169
- readonly visibility: Visibility;
170
- constructor({ comment, description, display, label, mutable, name, objectType, order, path, shapeIdentifier, type, visibility, }: {
152
+ constructor({ comment, description, display, label, mutable, name, objectType, order, path, shapeIdentifier, type, }: {
171
153
  comment: Maybe<string>;
172
154
  description: Maybe<string>;
173
155
  display: boolean;
@@ -179,7 +161,6 @@ export declare namespace ObjectType {
179
161
  path: PropertyPath;
180
162
  shapeIdentifier: BlankNode | NamedNode;
181
163
  type: Type;
182
- visibility: Visibility;
183
164
  });
184
165
  equals(other: Property): boolean;
185
166
  /**
@@ -204,7 +185,6 @@ export declare namespace ObjectType {
204
185
  recursive: boolean | undefined;
205
186
  shapeIdentifier: BlankNode | NamedNode<string>;
206
187
  };
207
- visibility: Visibility;
208
188
  };
209
189
  toString(): string;
210
190
  }
@@ -43,12 +43,6 @@ export class ObjectType extends AbstractType {
43
43
  * Mutable to support cycle-handling logic in the compiler.
44
44
  */
45
45
  #properties = [];
46
- /**
47
- * Classes generated from this type are abstract / cannot be instantiated themselves.
48
- *
49
- * Defaults to false.
50
- */
51
- abstract;
52
46
  /**
53
47
  * If true, the code for this ObjectType is defined externally and should not be generated.
54
48
  *
@@ -95,13 +89,8 @@ export class ObjectType extends AbstractType {
95
89
  * import { MyType } from "./MyType.js"
96
90
  */
97
91
  tsImports;
98
- /**
99
- * Whether to generate a TypeScript class or interface for this type.
100
- */
101
- tsObjectDeclarationType;
102
- constructor({ abstract, extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, tsObjectDeclarationType, ...superParameters }) {
92
+ constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, ...superParameters }) {
103
93
  super(superParameters);
104
- this.abstract = abstract;
105
94
  this.extern = extern;
106
95
  this.fromRdfType = fromRdfType;
107
96
  this.identifierType = identifierType;
@@ -109,7 +98,6 @@ export class ObjectType extends AbstractType {
109
98
  this.toRdfTypes = toRdfTypes;
110
99
  this.tsFeatures = tsFeatures;
111
100
  this.tsImports = tsImports;
112
- this.tsObjectDeclarationType = tsObjectDeclarationType;
113
101
  }
114
102
  get ancestorObjectTypes() {
115
103
  return this.#ancestorObjectTypes;
@@ -224,11 +212,7 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
224
212
  * Type of this property.
225
213
  */
226
214
  type;
227
- /**
228
- * Visibility: private, protected, public.
229
- */
230
- visibility;
231
- constructor({ comment, description, display, label, mutable, name, objectType, order, path, shapeIdentifier, type, visibility, }) {
215
+ constructor({ comment, description, display, label, mutable, name, objectType, order, path, shapeIdentifier, type, }) {
232
216
  this.comment = comment;
233
217
  this.description = description;
234
218
  this.display = display;
@@ -240,7 +224,6 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
240
224
  this.path = path;
241
225
  this.shapeIdentifier = shapeIdentifier;
242
226
  this.type = type;
243
- this.visibility = visibility;
244
227
  }
245
228
  equals(other) {
246
229
  return this.shapeIdentifier.equals(other.shapeIdentifier);
@@ -373,7 +356,6 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
373
356
  recursive: this.recursive ? true : undefined,
374
357
  shapeIdentifier: this.shapeIdentifier,
375
358
  type: this.type.toJSON(),
376
- visibility: this.visibility,
377
359
  };
378
360
  }
379
361
  toString() {
@@ -24,7 +24,6 @@ import { type Code } from "./ts-poet-wrapper.js";
24
24
  * Abstract base class for types that contain other types e.g., ListType, OptionType, SetType.
25
25
  */
26
26
  export declare abstract class AbstractContainerType<ItemTypeT extends AbstractContainerType.ItemType> extends AbstractType {
27
- readonly abstract = false;
28
27
  readonly declaration: Maybe<Code>;
29
28
  abstract readonly kind: "DefaultValueType" | "ListType" | "OptionType" | "SetType";
30
29
  /**
@@ -13,7 +13,6 @@ import { code } from "./ts-poet-wrapper.js";
13
13
  * Abstract base class for types that contain other types e.g., ListType, OptionType, SetType.
14
14
  */
15
15
  export class AbstractContainerType extends AbstractType {
16
- abstract = false;
17
16
  declaration = Maybe.empty();
18
17
  /**
19
18
  * Container item type.
@@ -13,7 +13,6 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
13
13
  readonly partialPropertyName: string;
14
14
  readonly rawName: Code;
15
15
  };
16
- readonly abstract = false;
17
16
  readonly declaration: Maybe<Code>;
18
17
  readonly discriminantProperty: AbstractType["discriminantProperty"];
19
18
  readonly mutable = false;
@@ -9,12 +9,12 @@ import { invariant } from "ts-invariant";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
11
11
  import { removeUndefined } from "./removeUndefined.js";
12
+ import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
12
13
  import { code, joinCode } from "./ts-poet-wrapper.js";
13
14
  export class AbstractLazyObjectType extends AbstractType {
14
15
  partialType;
15
16
  resolveType;
16
17
  runtimeClass;
17
- abstract = false;
18
18
  declaration = Maybe.empty();
19
19
  discriminantProperty = Maybe.empty();
20
20
  mutable = false;
@@ -124,7 +124,7 @@ export class AbstractLazyObjectType extends AbstractType {
124
124
  invariant(resolvedNamedObjectUnionType.members.length ===
125
125
  partialNamedObjectUnionType.members.length);
126
126
  const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
127
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.newExpression({ parameters: variables.resolvedObjectUnion })};`;
127
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.${syntheticNamePrefix}create(${variables.resolvedObjectUnion});`;
128
128
  });
129
129
  caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
130
130
  return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
- import type { TsFeature } from "../../enums/TsFeature.js";
3
2
  import { AbstractType } from "./AbstractType.js";
4
3
  import { AbstractUnionType } from "./AbstractUnionType.js";
4
+ import type { TsFeature } from "./TsFeature.js";
5
5
  import type { Type } from "./Type.js";
6
6
  import { type Code } from "./ts-poet-wrapper.js";
7
7
  export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> extends AbstractUnionType<MemberTypeT> {
@@ -18,7 +18,6 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
18
18
  get jsonSchemaFunctionDeclaration(): Code;
19
19
  get jsonTypeAliasDeclaration(): Code;
20
20
  get name(): string;
21
- get staticModuleName(): string;
22
21
  get valueSparqlConstructTriplesFunction(): Code;
23
22
  get valueSparqlWherePatternsFunction(): Code;
24
23
  protected get staticModuleDeclarations(): Record<string, Code>;
@@ -27,7 +27,7 @@ export class AbstractNamedUnionType extends AbstractUnionType {
27
27
  const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
28
28
  if (staticModuleDeclarations.length > 0) {
29
29
  declarations.push(code `\
30
- export namespace ${def(this.staticModuleName)} {
30
+ export namespace ${def(this.name)} {
31
31
  ${joinCode(staticModuleDeclarations
32
32
  .sort((left, right) => left[0].localeCompare(right[0]))
33
33
  .map((_) => _[1]), { on: "\n\n" })}
@@ -37,19 +37,19 @@ ${joinCode(staticModuleDeclarations
37
37
  }
38
38
  get equalsFunction() {
39
39
  if (this.features.has("equals")) {
40
- return code `${this.staticModuleName}.${syntheticNamePrefix}equals`;
40
+ return code `${this.name}.${syntheticNamePrefix}equals`;
41
41
  }
42
42
  return this.inlineEqualsFunction;
43
43
  }
44
44
  get filterFunction() {
45
- return code `${this.staticModuleName}.${syntheticNamePrefix}filter`;
45
+ return code `${this.name}.${syntheticNamePrefix}filter`;
46
46
  }
47
47
  get filterType() {
48
- return code `${this.staticModuleName}.${syntheticNamePrefix}Filter`;
48
+ return code `${this.name}.${syntheticNamePrefix}Filter`;
49
49
  }
50
50
  get jsonSchemaFunctionDeclaration() {
51
51
  const meta = {
52
- id: this.name,
52
+ // id: this.name,
53
53
  };
54
54
  this.comment.ifJust((description) => {
55
55
  meta["description"] = description;
@@ -65,18 +65,15 @@ ${joinCode(staticModuleDeclarations
65
65
  get name() {
66
66
  return this._name;
67
67
  }
68
- get staticModuleName() {
69
- return this._name;
70
- }
71
68
  get valueSparqlConstructTriplesFunction() {
72
69
  if (this.features.has("sparql")) {
73
- return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlConstructTriples`;
70
+ return code `${this.name}.${syntheticNamePrefix}valueSparqlConstructTriples`;
74
71
  }
75
72
  return this.inlineValueSparqlConstructTriplesFunction;
76
73
  }
77
74
  get valueSparqlWherePatternsFunction() {
78
75
  if (this.features.has("sparql")) {
79
- return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlWherePatterns`;
76
+ return code `${this.name}.${syntheticNamePrefix}valueSparqlWherePatterns`;
80
77
  }
81
78
  return this.inlineValueSparqlWherePatternsFunction;
82
79
  }
@@ -130,30 +127,30 @@ export namespace ${syntheticNamePrefix}Json {
130
127
  }
131
128
  fromJsonExpression({ variables, }) {
132
129
  if (this.features.has("json")) {
133
- return code `${this.staticModuleName}.${syntheticNamePrefix}fromJson(${variables.value})`;
130
+ return code `${this.name}.${syntheticNamePrefix}fromJson(${variables.value})`;
134
131
  }
135
132
  return code `${this.inlineFromJsonFunction}(${variables.value})`;
136
133
  }
137
134
  fromRdfResourceValuesExpression({ variables, }) {
138
135
  const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
139
136
  if (this.features.has("rdf")) {
140
- return code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
137
+ return code `${this.name}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
141
138
  }
142
139
  return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
143
140
  }
144
141
  hashStatements({ depth, variables, }) {
145
142
  if (this.features.has("hash")) {
146
143
  return [
147
- code `${this.staticModuleName}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
144
+ code `${this.name}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
148
145
  ];
149
146
  }
150
147
  return this.inlineHashStatements({ depth, variables });
151
148
  }
152
149
  jsonSchema({ context, }) {
153
150
  if (this.features.has("json")) {
154
- const expression = code `${this.staticModuleName}.${syntheticNamePrefix}Json.schema()`;
151
+ const expression = code `${this.name}.${syntheticNamePrefix}Json.schema()`;
155
152
  if (context === "property" && this.recursive) {
156
- return code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
153
+ return code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.name}.${syntheticNamePrefix}Json> => ${expression})`;
157
154
  }
158
155
  return expression;
159
156
  }
@@ -161,25 +158,25 @@ export namespace ${syntheticNamePrefix}Json {
161
158
  }
162
159
  jsonType() {
163
160
  if (this.features.has("json")) {
164
- return new AbstractType.JsonType(`${this.staticModuleName}.${syntheticNamePrefix}Json`);
161
+ return new AbstractType.JsonType(`${this.name}.${syntheticNamePrefix}Json`);
165
162
  }
166
163
  return this.inlineJsonType;
167
164
  }
168
165
  toJsonExpression({ variables, }) {
169
166
  if (this.features.has("json")) {
170
- return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
167
+ return code `${this.name}.${syntheticNamePrefix}toJson(${variables.value})`;
171
168
  }
172
169
  return code `${this.inlineToJsonFunction}(${variables.value})`;
173
170
  }
174
171
  toRdfResourceValuesExpression({ variables, }) {
175
172
  const { value: valueVariable, ...otherVariables } = variables;
176
173
  if (this.features.has("rdf")) {
177
- return code `${this.staticModuleName}.${syntheticNamePrefix}toRdfResourceValues(${valueVariable}, ${otherVariables})`;
174
+ return code `${this.name}.${syntheticNamePrefix}toRdfResourceValues(${valueVariable}, ${otherVariables})`;
178
175
  }
179
176
  return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
180
177
  }
181
178
  toStringExpression({ variables, }) {
182
- return code `${this.staticModuleName}.${syntheticNamePrefix}toString(${variables.value})`;
179
+ return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
183
180
  }
184
181
  }
185
182
  __decorate([
@@ -13,7 +13,6 @@ import { type Code } from "./ts-poet-wrapper.js";
13
13
  * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
14
14
  */
15
15
  export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractType {
16
- readonly abstract = false;
17
16
  readonly declaration: Maybe<Code>;
18
17
  readonly equalsFunction: Code;
19
18
  readonly graphqlArgs: AbstractType["graphqlArgs"];
@@ -22,7 +22,6 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
22
22
  * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
23
23
  */
24
24
  export class AbstractTermType extends AbstractType {
25
- abstract = false;
26
25
  declaration = Maybe.empty();
27
26
  equalsFunction = code `${snippets.booleanEquals}`;
28
27
  graphqlArgs = Maybe.empty();
@@ -7,10 +7,6 @@ import { type Code } from "./ts-poet-wrapper.js";
7
7
  */
8
8
  export declare abstract class AbstractType {
9
9
  protected readonly logger: Logger;
10
- /**
11
- * Is the type abstract?
12
- */
13
- abstract readonly abstract: boolean;
14
10
  /**
15
11
  * Comment from rdfs:comment.
16
12
  */
@@ -9,7 +9,6 @@ import { type Code } from "./ts-poet-wrapper.js";
9
9
  export declare abstract class AbstractUnionType<MemberTypeT extends Type> extends AbstractType {
10
10
  private readonly discriminant;
11
11
  private readonly identifierType;
12
- readonly abstract = false;
13
12
  readonly recursive: boolean;
14
13
  constructor({ identifierType, members, recursive, ...superParameters }: {
15
14
  identifierType: Maybe<BlankNodeType | IdentifierType | IriType>;
@@ -26,7 +25,6 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
26
25
  get schemaType(): Code;
27
26
  get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
28
27
  get typeofs(): AbstractType["typeofs"];
29
- protected get concreteMembers(): readonly AbstractUnionType.ConcreteMember<MemberTypeT>[];
30
28
  protected get inlineEqualsFunction(): Code;
31
29
  protected get inlineFilterFunction(): Code;
32
30
  protected get inlineFilterType(): Code;
@@ -81,13 +79,7 @@ export declare namespace Discriminant {
81
79
  }[]): Discriminant;
82
80
  }
83
81
  export declare namespace AbstractUnionType {
84
- interface AbstractMember<TypeT extends Type> {
85
- readonly abstract: true;
86
- readonly discriminantValues: readonly AbstractType.DiscriminantProperty.Value[];
87
- readonly type: TypeT;
88
- }
89
- interface ConcreteMember<TypeT extends Type> {
90
- readonly abstract: false;
82
+ interface Member<TypeT extends Type> {
91
83
  readonly discriminantValues: readonly AbstractType.DiscriminantProperty.Value[];
92
84
  readonly jsonType: Code | string;
93
85
  readonly jsonTypeCheck: (instance: Code) => Code;
@@ -98,7 +90,6 @@ export declare namespace AbstractUnionType {
98
90
  readonly unwrap: (instance: Code) => Code;
99
91
  readonly wrap: (instance: Code) => Code;
100
92
  }
101
- type Member<TypeT extends Type> = AbstractMember<TypeT> | ConcreteMember<TypeT>;
102
93
  }
103
94
  export {};
104
95
  //# sourceMappingURL=AbstractUnionType.d.ts.map