@shaclmate/compiler 4.0.23 → 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 (117) hide show
  1. package/dist/Compiler.d.ts +1 -1
  2. package/dist/ShapesGraphToAstTransformer.d.ts +1 -1
  3. package/dist/ShapesGraphToAstTransformer.js +16 -16
  4. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
  6. package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +6 -5
  7. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +1 -1
  8. package/dist/_ShapesGraphToAstTransformer/shapeOntology.js +4 -3
  9. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +11 -17
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +6 -11
  12. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +21 -40
  13. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
  14. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
  15. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  16. package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
  17. package/dist/ast/ListType.d.ts +1 -8
  18. package/dist/ast/ListType.js +1 -6
  19. package/dist/ast/ObjectType.d.ts +3 -30
  20. package/dist/ast/ObjectType.js +2 -26
  21. package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
  22. package/dist/generators/ts/AbstractContainerType.js +0 -1
  23. package/dist/generators/ts/AbstractLazyObjectType.d.ts +0 -1
  24. package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
  25. package/dist/generators/ts/AbstractNamedUnionType.d.ts +1 -2
  26. package/dist/generators/ts/AbstractNamedUnionType.js +16 -19
  27. package/dist/generators/ts/AbstractTermType.d.ts +0 -1
  28. package/dist/generators/ts/AbstractTermType.js +0 -1
  29. package/dist/generators/ts/AbstractType.d.ts +0 -4
  30. package/dist/generators/ts/AbstractUnionType.d.ts +1 -10
  31. package/dist/generators/ts/AbstractUnionType.js +27 -40
  32. package/dist/generators/ts/LazyObjectOptionType.js +3 -2
  33. package/dist/generators/ts/LazyObjectSetType.js +2 -1
  34. package/dist/generators/ts/LazyObjectType.js +2 -1
  35. package/dist/generators/ts/ListType.d.ts +1 -5
  36. package/dist/generators/ts/ListType.js +8 -27
  37. package/dist/generators/ts/NamedObjectType.d.ts +2 -21
  38. package/dist/generators/ts/NamedObjectType.js +33 -132
  39. package/dist/generators/ts/NamedObjectUnionType.js +14 -25
  40. package/dist/generators/ts/TypeFactory.js +11 -67
  41. package/dist/generators/ts/ZodGenerator.js +2 -2
  42. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +11 -17
  43. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +7 -6
  44. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +1 -4
  45. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +19 -34
  46. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +5 -15
  47. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +31 -212
  48. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +2 -2
  49. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +5 -0
  50. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +25 -0
  51. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +4 -4
  52. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +1 -1
  53. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +2 -2
  54. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +2 -2
  55. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -8
  56. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +5 -13
  57. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -4
  58. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +4 -0
  59. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +49 -0
  60. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
  61. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +0 -3
  62. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  63. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +2 -2
  64. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +2 -2
  65. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +2 -2
  66. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
  67. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +2 -2
  68. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -2
  69. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
  70. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
  71. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -2
  72. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  73. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +41 -0
  74. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  75. package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +8 -27
  76. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +4 -0
  77. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +40 -0
  78. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  79. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  80. package/dist/generators/ts/_NamedObjectType/Property.d.ts +1 -2
  81. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -3
  82. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +8 -39
  83. package/dist/generators/ts/_snippets/snippets_LazyObject.js +2 -2
  84. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +2 -2
  85. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +2 -2
  86. package/dist/generators/ts/imports.d.ts +0 -2
  87. package/dist/generators/ts/imports.js +0 -2
  88. package/dist/generators/ts/objectSetDeclarations.js +1 -3
  89. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +4 -6
  90. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
  91. package/dist/input/ShapesGraph.d.ts +1 -1
  92. package/dist/input/generated.d.ts +10 -181
  93. package/dist/input/generated.js +116 -392
  94. package/package.json +2 -4
  95. package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.d.ts +0 -6
  96. package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +0 -32
  97. package/dist/enums/IdentifierMintingStrategy.d.ts +0 -9
  98. package/dist/enums/IdentifierMintingStrategy.js +0 -18
  99. package/dist/enums/TsObjectDeclarationType.d.ts +0 -9
  100. package/dist/enums/TsObjectDeclarationType.js +0 -16
  101. package/dist/enums/Visibility.d.ts +0 -6
  102. package/dist/enums/Visibility.js +0 -18
  103. package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.d.ts +0 -33
  104. package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.js +0 -92
  105. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +0 -4
  106. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -62
  107. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
  108. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -51
  109. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
  110. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -73
  111. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
  112. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js +0 -59
  113. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
  114. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +0 -4
  115. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +0 -62
  116. /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
  117. /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
@@ -9,12 +9,10 @@ import { camelCase } from "change-case";
9
9
  import { Maybe, NonEmptyList } from "purify-ts";
10
10
  import { Memoize } from "typescript-memoize";
11
11
  import { DiscriminantProperty as _DiscriminantProperty } from "./_NamedObjectType/DiscriminantProperty.js";
12
- import { IdentifierPrefixProperty as _IdentifierPrefixProperty } from "./_NamedObjectType/IdentifierPrefixProperty.js";
13
12
  import { IdentifierProperty as _IdentifierProperty } from "./_NamedObjectType/IdentifierProperty.js";
14
13
  import { identifierTypeDeclarations } from "./_NamedObjectType/identifierTypeDeclarations.js";
15
- import { NamedObjectType_classDeclaration } from "./_NamedObjectType/NamedObjectType_classDeclaration.js";
16
14
  import { NamedObjectType_createFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_createFunctionDeclaration.js";
17
- import { NamedObjectType_equalsFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js";
15
+ import { NamedObjectType_equalsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js";
18
16
  import { NamedObjectType_filterFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js";
19
17
  import { NamedObjectType_filterTypeDeclaration } from "./_NamedObjectType/NamedObjectType_filterTypeDeclaration.js";
20
18
  import { NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js";
@@ -24,7 +22,7 @@ import { NamedObjectType_fromRdfResourceFunctionDeclaration } from "./_NamedObje
24
22
  import { NamedObjectType_fromRdfResourceValuesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js";
25
23
  import { NamedObjectType_fromRdfTypeVariableStatement } from "./_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js";
26
24
  import { NamedObjectType_graphqlTypeVariableStatement } from "./_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js";
27
- import { NamedObjectType_hashFunctionOrMethodDeclarations } from "./_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js";
25
+ import { NamedObjectType_hashFunctionDeclarations } from "./_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js";
28
26
  import { NamedObjectType_interfaceDeclaration } from "./_NamedObjectType/NamedObjectType_interfaceDeclaration.js";
29
27
  import { NamedObjectType_isTypeFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js";
30
28
  import { NamedObjectType_jsonParseFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js";
@@ -37,9 +35,9 @@ import { NamedObjectType_propertiesFromRdfResourceFunctionDeclaration } from "./
37
35
  import { NamedObjectType_schemaVariableStatement } from "./_NamedObjectType/NamedObjectType_schemaVariableStatement.js";
38
36
  import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js";
39
37
  import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
40
- import { NamedObjectType_toJsonFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js";
41
- import { NamedObjectType_toRdfResourceFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js";
42
- import { NamedObjectType_toStringFunctionOrMethodDeclarations } from "./_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js";
38
+ import { NamedObjectType_toJsonFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js";
39
+ import { NamedObjectType_toRdfResourceFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js";
40
+ import { NamedObjectType_toStringFunctionDeclarations } from "./_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js";
43
41
  import { NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js";
44
42
  import { NamedObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
45
43
  import { ShaclProperty as _ShaclProperty } from "./_NamedObjectType/ShaclProperty.js";
@@ -50,8 +48,6 @@ import { code, def, joinCode } from "./ts-poet-wrapper.js";
50
48
  export class NamedObjectType extends AbstractType {
51
49
  imports;
52
50
  toRdfTypes;
53
- abstract;
54
- declarationType;
55
51
  extern;
56
52
  features;
57
53
  fromRdfType;
@@ -60,13 +56,10 @@ export class NamedObjectType extends AbstractType {
60
56
  kind = "NamedObjectType";
61
57
  name;
62
58
  recursive;
63
- staticModuleName;
64
59
  synthetic;
65
60
  typeofs = NonEmptyList(["object"]);
66
- constructor({ abstract, declarationType, extern, features, fromRdfType, identifierType, imports, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyIdentifierProperty, lazyParentObjectTypes, lazyProperties, name, recursive, staticModuleName, synthetic, toRdfTypes, ...superParameters }) {
61
+ constructor({ extern, features, fromRdfType, identifierType, imports, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }) {
67
62
  super(superParameters);
68
- this.abstract = abstract;
69
- this.declarationType = declarationType;
70
63
  this.extern = extern;
71
64
  this.features = features;
72
65
  this.fromRdfType = fromRdfType;
@@ -77,12 +70,10 @@ export class NamedObjectType extends AbstractType {
77
70
  this.lazyChildObjectTypes = lazyChildObjectTypes;
78
71
  this.lazyDescendantObjectTypes = lazyDescendantObjectTypes;
79
72
  this.lazyDiscriminantProperty = lazyDiscriminantProperty;
80
- this.lazyIdentifierProperty = lazyIdentifierProperty;
81
73
  this.lazyParentObjectTypes = lazyParentObjectTypes;
82
74
  this.lazyProperties = lazyProperties;
83
75
  this.name = name;
84
76
  this.recursive = recursive;
85
- this.staticModuleName = staticModuleName;
86
77
  this.synthetic = synthetic;
87
78
  this.toRdfTypes = toRdfTypes;
88
79
  }
@@ -99,7 +90,7 @@ export class NamedObjectType extends AbstractType {
99
90
  return [
100
91
  {
101
92
  conversionExpression: (value) => value,
102
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof ${this.name}`,
93
+ sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
103
94
  sourceTypeName: this.name,
104
95
  sourceTypeof: "object",
105
96
  },
@@ -112,17 +103,8 @@ export class NamedObjectType extends AbstractType {
112
103
  }
113
104
  if (!this.extern) {
114
105
  const staticModuleDeclarations = [];
115
- switch (this.declarationType) {
116
- case "class": {
117
- declarations.push(NamedObjectType_classDeclaration.call(this));
118
- break;
119
- }
120
- case "interface": {
121
- declarations.push(NamedObjectType_interfaceDeclaration.call(this));
122
- staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionOrMethodDeclaration.bind(this)().toList(), ...NamedObjectType_hashFunctionOrMethodDeclarations.call(this));
123
- break;
124
- }
125
- }
106
+ declarations.push(NamedObjectType_interfaceDeclaration.call(this));
107
+ staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_hashFunctionDeclarations.call(this));
126
108
  const jsonModuleDeclarations = [
127
109
  ...NamedObjectType_jsonParseFunctionDeclaration.call(this).toList(),
128
110
  ...NamedObjectType_jsonSchemaFunctionDeclaration.call(this).toList(),
@@ -132,16 +114,10 @@ export class NamedObjectType extends AbstractType {
132
114
  ? [
133
115
  code `export namespace ${syntheticNamePrefix}Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
134
116
  ]
135
- : []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), NamedObjectType_isTypeFunctionDeclaration.call(this), ...NamedObjectType_propertiesFromJsonFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.bind(this)().toList(), NamedObjectType_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)().toList(), ...(this.declarationType === "interface"
136
- ? NamedObjectType_toJsonFunctionOrMethodDeclaration.call(this).toList()
137
- : []), ...(this.declarationType === "interface"
138
- ? NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.call(this).toList()
139
- : []), ...(this.declarationType === "interface"
140
- ? NamedObjectType_toStringFunctionOrMethodDeclarations.call(this)
141
- : []), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.bind(this)().toList());
117
+ : []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), NamedObjectType_isTypeFunctionDeclaration.call(this), ...NamedObjectType_propertiesFromJsonFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.bind(this)().toList(), NamedObjectType_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_toJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_toRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_toStringFunctionDeclarations.call(this), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.bind(this)().toList());
142
118
  if (staticModuleDeclarations.length > 0) {
143
119
  declarations.push(code `\
144
- export namespace ${def(this.staticModuleName)} {
120
+ export namespace ${def(this.name)} {
145
121
  ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
146
122
  }`);
147
123
  }
@@ -168,32 +144,22 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
168
144
  return this.name;
169
145
  }
170
146
  get equalsFunction() {
171
- switch (this.declarationType) {
172
- case "class":
173
- return code `((left, right) => left.${syntheticNamePrefix}equals(right))`;
174
- case "interface":
175
- return code `${this.staticModuleName}.${syntheticNamePrefix}equals`;
176
- default:
177
- throw new RangeError(this.declarationType);
178
- }
147
+ return code `${this.name}.${syntheticNamePrefix}equals`;
179
148
  }
180
149
  get filterFunction() {
181
- return code `${this.staticModuleName}.${syntheticNamePrefix}filter`;
150
+ return code `${this.name}.${syntheticNamePrefix}filter`;
182
151
  }
183
152
  get filterType() {
184
- return code `${this.staticModuleName}.${syntheticNamePrefix}Filter`;
153
+ return code `${this.name}.${syntheticNamePrefix}Filter`;
185
154
  }
186
155
  get fromRdfTypeVariable() {
187
- return this.fromRdfType.map(() => code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfType`);
156
+ return this.fromRdfType.map(() => code `${this.name}.${syntheticNamePrefix}fromRdfType`);
188
157
  }
189
158
  get graphqlType() {
190
- return new AbstractType.GraphqlType(code `${this.staticModuleName}.${syntheticNamePrefix}GraphQL`);
191
- }
192
- get identifierProperty() {
193
- return this.lazyIdentifierProperty(this);
159
+ return new AbstractType.GraphqlType(code `${this.name}.${syntheticNamePrefix}GraphQL`);
194
160
  }
195
161
  get identifierTypeAlias() {
196
- return code `${this.staticModuleName}.${syntheticNamePrefix}Identifier`;
162
+ return code `${this.name}.${syntheticNamePrefix}Identifier`;
197
163
  }
198
164
  get mutable() {
199
165
  return this.properties.some((property) => property.mutable);
@@ -201,18 +167,6 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
201
167
  get objectSetMethodNames() {
202
168
  return NamedObjectType_objectSetMethodNames.call(this);
203
169
  }
204
- get ownProperties() {
205
- if (this.parentObjectTypes.length === 0) {
206
- // Consider that a root of the object type hierarchy "owns" the identifier and type discriminant properties
207
- // for all of its subtypes in the hierarchy.
208
- // invariant(this.properties.length >= 2, this.name);
209
- return this.properties;
210
- }
211
- return this.ownShaclProperties;
212
- }
213
- get ownShaclProperties() {
214
- return this.properties.filter((property) => property.kind === "ShaclProperty");
215
- }
216
170
  get parentObjectTypes() {
217
171
  return this.lazyParentObjectTypes();
218
172
  }
@@ -227,7 +181,7 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
227
181
  return properties;
228
182
  }
229
183
  get schema() {
230
- return code `${this.staticModuleName}.${syntheticNamePrefix}schema`;
184
+ return code `${this.name}.${syntheticNamePrefix}schema`;
231
185
  }
232
186
  get schemaType() {
233
187
  return code `typeof ${this.schema}`;
@@ -242,100 +196,57 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
242
196
  return code `${imports.Resource}${this.identifierType.kind === "IriType" ? code `<${imports.NamedNode}>` : ""}`;
243
197
  }
244
198
  get valueSparqlConstructTriplesFunction() {
245
- return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlConstructTriples`;
199
+ return code `${this.name}.${syntheticNamePrefix}valueSparqlConstructTriples`;
246
200
  }
247
201
  get valueSparqlWherePatternsFunction() {
248
- return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlWherePatterns`;
202
+ return code `${this.name}.${syntheticNamePrefix}valueSparqlWherePatterns`;
249
203
  }
250
204
  get thisVariable() {
251
- switch (this.declarationType) {
252
- case "class":
253
- return code `this`;
254
- case "interface":
255
- return code `_${camelCase(this.name)}`;
256
- default:
257
- throw new RangeError(this.declarationType);
258
- }
205
+ return code `_${camelCase(this.name)}`;
259
206
  }
260
207
  fromJsonExpression({ variables, }) {
261
208
  // Assumes the JSON object has been recursively validated already.
262
- return code `${this.staticModuleName}.${syntheticNamePrefix}fromJson(${variables.value})`;
209
+ return code `${this.name}.${syntheticNamePrefix}fromJson(${variables.value})`;
263
210
  }
264
211
  fromRdfResourceValuesExpression({ variables, }) {
265
212
  const { resourceValues, ...options } = variables;
266
- return code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValues}, ${options})`;
213
+ return code `${this.name}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValues}, ${options})`;
267
214
  }
268
215
  graphqlResolveExpression({ variables, }) {
269
216
  return variables.value;
270
217
  }
271
218
  hashStatements({ variables, }) {
272
- switch (this.declarationType) {
273
- case "class":
274
- return [
275
- code `${variables.value}.${syntheticNamePrefix}hash(${variables.hasher});`,
276
- ];
277
- case "interface":
278
- return [
279
- code `${this.staticModuleName}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
280
- ];
281
- }
219
+ return [
220
+ code `${this.name}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
221
+ ];
282
222
  }
283
223
  jsonSchema({ context, }) {
284
- let expression = code `${this.staticModuleName}.${syntheticNamePrefix}Json.schema()`;
224
+ let expression = code `${this.name}.${syntheticNamePrefix}Json.schema()`;
285
225
  if (context === "property" &&
286
226
  this.properties.some((property) => property.recursive)) {
287
- expression = code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
227
+ expression = code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.name}.${syntheticNamePrefix}Json> => ${expression})`;
288
228
  }
289
229
  return expression;
290
230
  }
291
231
  jsonType() {
292
- return new AbstractType.JsonType(code `${this.staticModuleName}.${syntheticNamePrefix}Json`);
232
+ return new AbstractType.JsonType(code `${this.name}.${syntheticNamePrefix}Json`);
293
233
  }
294
234
  jsonUiSchemaElement({ variables, }) {
295
- return Maybe.of(code `${this.staticModuleName}.${syntheticNamePrefix}Json.uiSchema({ scopePrefix: ${variables.scopePrefix} })`);
296
- }
297
- newExpression({ parameters }) {
298
- switch (this.declarationType) {
299
- case "class":
300
- return code `new ${this.name}(${parameters})`;
301
- case "interface":
302
- return code `${this.staticModuleName}.${syntheticNamePrefix}create(${parameters})`;
303
- }
235
+ return Maybe.of(code `${this.name}.${syntheticNamePrefix}Json.uiSchema({ scopePrefix: ${variables.scopePrefix} })`);
304
236
  }
305
237
  toJsonExpression({ variables, }) {
306
- switch (this.declarationType) {
307
- case "class":
308
- return code `${variables.value}.${syntheticNamePrefix}toJson()`;
309
- case "interface":
310
- return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
311
- }
238
+ return code `${this.name}.${syntheticNamePrefix}toJson(${variables.value})`;
312
239
  }
313
240
  toStringExpression({ variables, }) {
314
- switch (this.declarationType) {
315
- case "class":
316
- return code `${variables.value}.toString()`;
317
- case "interface":
318
- return code `${this.staticModuleName}.${syntheticNamePrefix}toString(${variables.value})`;
319
- }
241
+ return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
320
242
  }
321
243
  toRdfResourceValuesExpression({ variables, }) {
322
- switch (this.declarationType) {
323
- case "class":
324
- return code `[${variables.value}.${syntheticNamePrefix}toRdfResource({ graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
325
- case "interface":
326
- return code `[${this.staticModuleName}.${syntheticNamePrefix}toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
327
- }
328
- }
329
- ensureAtMostOneSuperObjectType() {
330
- if (this.parentObjectTypes.length > 1) {
331
- throw new RangeError(`object type '${this.name}' has multiple super object types`);
332
- }
244
+ return code `[${this.name}.${syntheticNamePrefix}toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
333
245
  }
334
246
  lazyAncestorObjectTypes;
335
247
  lazyChildObjectTypes;
336
248
  lazyDescendantObjectTypes;
337
249
  lazyDiscriminantProperty;
338
- lazyIdentifierProperty;
339
250
  lazyParentObjectTypes;
340
251
  lazyProperties;
341
252
  }
@@ -381,9 +292,6 @@ __decorate([
381
292
  __decorate([
382
293
  Memoize()
383
294
  ], NamedObjectType.prototype, "graphqlType", null);
384
- __decorate([
385
- Memoize()
386
- ], NamedObjectType.prototype, "identifierProperty", null);
387
295
  __decorate([
388
296
  Memoize()
389
297
  ], NamedObjectType.prototype, "identifierTypeAlias", null);
@@ -393,12 +301,6 @@ __decorate([
393
301
  __decorate([
394
302
  Memoize()
395
303
  ], NamedObjectType.prototype, "objectSetMethodNames", null);
396
- __decorate([
397
- Memoize()
398
- ], NamedObjectType.prototype, "ownProperties", null);
399
- __decorate([
400
- Memoize()
401
- ], NamedObjectType.prototype, "ownShaclProperties", null);
402
304
  __decorate([
403
305
  Memoize()
404
306
  ], NamedObjectType.prototype, "parentObjectTypes", null);
@@ -430,7 +332,6 @@ __decorate([
430
332
  Memoize()
431
333
  ], NamedObjectType.prototype, "jsonType", null);
432
334
  (function (NamedObjectType) {
433
- NamedObjectType.IdentifierPrefixProperty = _IdentifierPrefixProperty;
434
335
  NamedObjectType.IdentifierProperty = _IdentifierProperty;
435
336
  NamedObjectType.ShaclProperty = _ShaclProperty;
436
337
  NamedObjectType.DiscriminantProperty = _DiscriminantProperty;
@@ -30,13 +30,13 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
30
30
  return new AbstractType.GraphqlType(code `${this._name}.${syntheticNamePrefix}GraphQL`);
31
31
  }
32
32
  get identifierTypeAlias() {
33
- return code `${this.staticModuleName}.${syntheticNamePrefix}Identifier`;
33
+ return code `${this.name}.${syntheticNamePrefix}Identifier`;
34
34
  }
35
35
  get objectSetMethodNames() {
36
36
  return NamedObjectType_objectSetMethodNames.call(this);
37
37
  }
38
38
  get schema() {
39
- return code `${this.staticModuleName}.${syntheticNamePrefix}schema`;
39
+ return code `${this.name}.${syntheticNamePrefix}schema`;
40
40
  }
41
41
  get schemaType() {
42
42
  return code `typeof ${this.schema}`;
@@ -66,7 +66,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
66
66
  }
67
67
  return singleEntryRecord(`${syntheticNamePrefix}focusSparqlConstructTriples`, code `\
68
68
  export function ${syntheticNamePrefix}focusSparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
69
- return [${joinCode(this.concreteMembers.map((member) => code `...${member.type.staticModuleName}.${syntheticNamePrefix}focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`), { on: ", " })}];
69
+ return [${joinCode(this.members.map((member) => code `...${member.type.name}.${syntheticNamePrefix}focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`), { on: ", " })}];
70
70
  }`);
71
71
  }
72
72
  get focusSparqlWherePatternsFunctionDeclaration() {
@@ -89,8 +89,8 @@ if (focusIdentifier.termType === "Variable") {
89
89
  variablePrefix,
90
90
  }));
91
91
  }`,
92
- code `patterns.push({ patterns: [${joinCode(this.concreteMembers.map((member) => code `${{
93
- patterns: code `${member.type.staticModuleName}.${syntheticNamePrefix}focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`,
92
+ code `patterns.push({ patterns: [${joinCode(this.members.map((member) => code `${{
93
+ patterns: code `${member.type.name}.${syntheticNamePrefix}focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`,
94
94
  type: literalOf("group"),
95
95
  }}`), { on: ", " })}], type: "union" });`,
96
96
  code `return patterns;`,
@@ -103,8 +103,8 @@ if (focusIdentifier.termType === "Variable") {
103
103
  }
104
104
  return singleEntryRecord(`${syntheticNamePrefix}fromRdfResource`, code `\
105
105
  export const ${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) =>
106
- ${this.concreteMembers.reduce((expression, member) => {
107
- const memberTypeExpression = code `(${member.type.staticModuleName}.${syntheticNamePrefix}fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${imports.Either}<Error, ${this.name}>)`;
106
+ ${this.members.reduce((expression, member) => {
107
+ const memberTypeExpression = code `(${member.type.name}.${syntheticNamePrefix}fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${imports.Either}<Error, ${this.name}>)`;
108
108
  return expression !== null
109
109
  ? code `${expression}.altLazy(() => ${memberTypeExpression})`
110
110
  : memberTypeExpression;
@@ -119,7 +119,7 @@ export const ${syntheticNamePrefix}GraphQL = new ${imports.GraphQLUnionType}(${{
119
119
  description: this.comment.map(JSON.stringify).extract(),
120
120
  name: this.name,
121
121
  resolveType: code `(value: ${this.name}) => value.${syntheticNamePrefix}type`,
122
- types: code `[${joinCode(this.concreteMembers.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
122
+ types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
123
123
  }});`);
124
124
  }
125
125
  get identifierTypeDeclarations() {
@@ -136,13 +136,13 @@ export namespace ${syntheticNamePrefix}Identifier {
136
136
  }
137
137
  return singleEntryRecord(`is${this._name}`, code `\
138
138
  export function is${this._name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
139
- return ${joinCode(this.concreteMembers.map((member) => code `${member.type.staticModuleName}.is${member.type.name}(object)`), { on: " || " })};
139
+ return ${joinCode(this.members.map((member) => code `${member.type.name}.is${member.type.name}(object)`), { on: " || " })};
140
140
  }`);
141
141
  }
142
142
  get schemaVariableStatement() {
143
143
  const commonPropertiesByName = {};
144
- this.concreteMembers.forEach((member, memberI) => {
145
- for (const memberTypeProperty of member.type.ownProperties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.ownProperties))) {
144
+ this.members.forEach((member, memberI) => {
145
+ for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
146
146
  if (memberTypeProperty.kind !== "ShaclProperty") {
147
147
  continue;
148
148
  }
@@ -154,7 +154,7 @@ export namespace ${syntheticNamePrefix}Identifier {
154
154
  }
155
155
  else {
156
156
  commonPropertiesByName[memberTypeProperty.name] = commonProperty = {
157
- memberTypesWithProperty: new Array(this.concreteMembers.length).fill(false),
157
+ memberTypesWithProperty: new Array(this.members.length).fill(false),
158
158
  property: memberTypeProperty,
159
159
  };
160
160
  commonProperty.memberTypesWithProperty[memberI] = true;
@@ -182,19 +182,8 @@ ${{
182
182
  }
183
183
  return singleEntryRecord(`${syntheticNamePrefix}toRdfResource`, code `\
184
184
  export const ${syntheticNamePrefix}toRdfResource: ${snippets.ToRdfResourceFunction}<${this.name}> = (value, options) => {
185
- ${joinCode(this.concreteMembers
186
- .map((member) => {
187
- let returnExpression;
188
- switch (member.type.declarationType) {
189
- case "class":
190
- returnExpression = code `value.${syntheticNamePrefix}toRdfResource(options)`;
191
- break;
192
- case "interface":
193
- returnExpression = code `${member.type.staticModuleName}.${syntheticNamePrefix}toRdfResource(value, options)`;
194
- break;
195
- }
196
- return code `if (${member.type.staticModuleName}.is${member.type.name}(value)) { return ${returnExpression}; }`;
197
- })
185
+ ${joinCode(this.members
186
+ .map((member) => code `if (${member.type.name}.is${member.type.name}(value)) { return ${member.type.name}.${syntheticNamePrefix}toRdfResource(value, options); }`)
198
187
  .concat(code `throw new Error("unrecognized type");`))}
199
188
  };`);
200
189
  }
@@ -2,7 +2,7 @@ import TermMap from "@rdfjs/term-map";
2
2
  import TermSet from "@rdfjs/term-set";
3
3
  import { LiteralDecoder, literalDatatypeDefinitions } from "@rdfx/literal";
4
4
  import base62 from "@sindresorhus/base62";
5
- import { rdf, xsd } from "@tpluscode/rdf-ns-builders";
5
+ import { rdf } from "@tpluscode/rdf-ns-builders";
6
6
  import { Maybe } from "purify-ts";
7
7
  import reservedTsIdentifiers_ from "reserved-identifiers";
8
8
  import { invariant } from "ts-invariant";
@@ -75,11 +75,8 @@ export class TypeFactory {
75
75
  const name = tsName(astType.name.unsafeCoerce(), {
76
76
  synthetic: astType.synthetic,
77
77
  });
78
- const staticModuleName = astType.childObjectTypes.length > 0 ? `${name}Static` : name;
79
78
  const namedObjectType = new NamedObjectType({
80
- abstract: astType.abstract,
81
79
  comment: astType.comment,
82
- declarationType: astType.tsObjectDeclarationType,
83
80
  extern: astType.extern,
84
81
  features: astType.tsFeatures,
85
82
  fromRdfType: astType.fromRdfType,
@@ -91,14 +88,9 @@ export class TypeFactory {
91
88
  lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createNamedObjectType(astType)),
92
89
  lazyDiscriminantProperty: (namedObjectType) => {
93
90
  // Discriminant property
94
- const discriminantOwnValue = !astType.abstract
95
- ? namedObjectType.discriminantValue
96
- : undefined;
97
91
  const discriminantDescendantValues = new Set();
98
92
  for (const descendantObjectType of namedObjectType.descendantObjectTypes) {
99
- if (!descendantObjectType.abstract) {
100
- discriminantDescendantValues.add(descendantObjectType.discriminantValue);
101
- }
93
+ discriminantDescendantValues.add(descendantObjectType.discriminantValue);
102
94
  }
103
95
  return new NamedObjectType.DiscriminantProperty({
104
96
  logger: this.logger,
@@ -107,21 +99,10 @@ export class TypeFactory {
107
99
  type: new NamedObjectType.DiscriminantProperty.Type({
108
100
  descendantValues: [...discriminantDescendantValues].sort(),
109
101
  mutable: false,
110
- ownValues: discriminantOwnValue ? [discriminantOwnValue] : [],
102
+ ownValues: [namedObjectType.discriminantValue],
111
103
  }),
112
- visibility: "public",
113
104
  });
114
105
  },
115
- lazyIdentifierProperty: (namedObjectType) => new NamedObjectType.IdentifierProperty({
116
- identifierMintingStrategy: astType.identifierMintingStrategy,
117
- identifierPrefixPropertyName: `${syntheticNamePrefix}identifierPrefix`,
118
- logger: this.logger,
119
- name: `${syntheticNamePrefix}identifier`,
120
- namedObjectType,
121
- type: identifierType,
122
- typeAlias: code `${staticModuleName}.${syntheticNamePrefix}Identifier`,
123
- visibility: "public",
124
- }),
125
106
  lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createNamedObjectType(astType)),
126
107
  lazyProperties: (namedObjectType) => {
127
108
  const properties = astType.properties
@@ -138,38 +119,19 @@ export class TypeFactory {
138
119
  astObjectTypeProperty: astProperty,
139
120
  namedObjectType,
140
121
  }));
141
- if (namedObjectType._discriminantProperty.type.ownValues.length > 0 ||
142
- namedObjectType._discriminantProperty.type.descendantValues.length > 0) {
143
- properties.splice(0, 0, namedObjectType._discriminantProperty);
144
- }
145
- // Some ObjectTypes have an identifierPrefix property, depending on their identifier minting strategy.
146
- if (namedObjectTypeNeedsIdentifierPrefixProperty(astType)) {
147
- properties.splice(0, 0, new NamedObjectType.IdentifierPrefixProperty({
148
- logger: this.logger,
149
- name: `${syntheticNamePrefix}identifierPrefix`,
150
- namedObjectType,
151
- own: !astType.ancestorObjectTypes.some(namedObjectTypeNeedsIdentifierPrefixProperty),
152
- type: new StringType({
153
- comment: astType.comment,
154
- datatype: xsd.string,
155
- hasValues: [],
156
- in_: [],
157
- label: astType.label,
158
- logger: this.logger,
159
- languageIn: [],
160
- primitiveIn: [],
161
- }),
162
- visibility: "protected",
163
- }));
164
- }
165
- // Every NamedObjectType has an identifier property. Some are abstract.
166
- properties.splice(0, 0, namedObjectType.identifierProperty);
122
+ properties.splice(0, 0, namedObjectType._discriminantProperty);
123
+ properties.splice(0, 0, new NamedObjectType.IdentifierProperty({
124
+ logger: this.logger,
125
+ name: `${syntheticNamePrefix}identifier`,
126
+ namedObjectType,
127
+ type: identifierType,
128
+ typeAlias: code `${name}.${syntheticNamePrefix}Identifier`,
129
+ }));
167
130
  return properties;
168
131
  },
169
132
  logger: this.logger,
170
133
  name,
171
134
  recursive: astType.recursive,
172
- staticModuleName,
173
135
  synthetic: astType.synthetic,
174
136
  toRdfTypes: astType.toRdfTypes,
175
137
  });
@@ -321,7 +283,6 @@ export class TypeFactory {
321
283
  logger: this.logger,
322
284
  minCount: 0,
323
285
  mutable: astType.mutable,
324
- identifierMintingStrategy: astType.identifierMintingStrategy,
325
286
  toRdfTypes: astType.toRdfTypes,
326
287
  });
327
288
  }
@@ -464,7 +425,6 @@ export class TypeFactory {
464
425
  path: astObjectTypeProperty.path,
465
426
  recursive: !!astObjectTypeProperty.recursive,
466
427
  type: this.createType(astObjectTypeProperty.type),
467
- visibility: astObjectTypeProperty.visibility,
468
428
  });
469
429
  this.cachedObjectTypePropertiesByShapeIdentifier.set(astObjectTypeProperty.shapeIdentifier, property);
470
430
  return property;
@@ -502,22 +462,6 @@ export class TypeFactory {
502
462
  });
503
463
  }
504
464
  }
505
- function namedObjectTypeNeedsIdentifierPrefixProperty(namedObjectType) {
506
- return namedObjectType.identifierMintingStrategy
507
- .map((identifierMintingStrategy) => {
508
- switch (identifierMintingStrategy) {
509
- case "blankNode":
510
- return false;
511
- case "sha256":
512
- case "uuidv4":
513
- return true;
514
- default:
515
- identifierMintingStrategy;
516
- throw new RangeError(identifierMintingStrategy);
517
- }
518
- })
519
- .orDefault(false);
520
- }
521
465
  function tsName(name, options) {
522
466
  if (name[0] === "$") {
523
467
  return name;
@@ -15,7 +15,7 @@ export class ZodGenerator {
15
15
  const declarations = [];
16
16
  for (const namedObjectType of ast.ObjectType.toposort(ast_.namedObjectTypes).map((astObjectType) => this.typeFactory.createNamedObjectType(astObjectType))) {
17
17
  declarations.push(code `\
18
- export namespace ${namedObjectType.staticModuleName} {
18
+ export namespace ${namedObjectType.name} {
19
19
  ${joinCode(NamedObjectType_jsonTypeAliasDeclaration.bind(namedObjectType)().toList())}
20
20
 
21
21
  export namespace ${syntheticNamePrefix}Json {
@@ -26,7 +26,7 @@ export namespace ${namedObjectType.staticModuleName} {
26
26
  for (const astNamedUnionType of ast_.namedUnionTypes.map((astNamedUnionType) => this.typeFactory.createUnionType(astNamedUnionType))) {
27
27
  invariant(astNamedUnionType.kind !== "AnonymousUnionType");
28
28
  declarations.push(code `\
29
- export namespace ${astNamedUnionType.staticModuleName} {
29
+ export namespace ${astNamedUnionType.name} {
30
30
  ${astNamedUnionType.jsonTypeAliasDeclaration}
31
31
  export namespace ${syntheticNamePrefix}Json {
32
32
  ${astNamedUnionType.jsonSchemaFunctionDeclaration}