@shaclmate/compiler 2.0.22 → 2.0.24

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 (194) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +6 -5
  2. package/dist/ShapesGraphToAstTransformer.js +61 -17
  3. package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
  4. package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
  5. package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
  6. package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
  7. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
  8. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
  9. package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
  10. package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
  11. package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
  12. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
  13. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
  14. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
  15. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
  16. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
  17. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
  18. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
  19. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
  20. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
  21. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
  22. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
  23. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
  24. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
  25. package/dist/ast/Ast.d.ts +0 -1
  26. package/dist/ast/Curie.d.ts +14 -0
  27. package/dist/ast/Curie.js +21 -0
  28. package/dist/ast/IdentifierType.d.ts +3 -2
  29. package/dist/ast/ListType.d.ts +2 -1
  30. package/dist/ast/LiteralType.d.ts +1 -1
  31. package/dist/ast/Name.d.ts +40 -5
  32. package/dist/ast/ObjectCompositeType.d.ts +11 -0
  33. package/dist/ast/ObjectType.d.ts +18 -13
  34. package/dist/ast/ObjectUnionType.d.ts +0 -11
  35. package/dist/ast/OptionType.d.ts +2 -4
  36. package/dist/ast/SetType.d.ts +2 -7
  37. package/dist/ast/TermType.d.ts +12 -4
  38. package/dist/ast/Type.d.ts +1 -1
  39. package/dist/ast/index.d.ts +1 -0
  40. package/dist/ast/index.js +1 -0
  41. package/dist/enums/TsFeature.d.ts +1 -4
  42. package/dist/enums/TsFeature.js +1 -15
  43. package/dist/generators/json/AstJsonGenerator.js +26 -4
  44. package/dist/generators/ts/BooleanType.d.ts +4 -2
  45. package/dist/generators/ts/BooleanType.js +12 -3
  46. package/dist/generators/ts/DateTimeType.d.ts +9 -8
  47. package/dist/generators/ts/DateTimeType.js +32 -8
  48. package/dist/generators/ts/DateType.d.ts +5 -2
  49. package/dist/generators/ts/DateType.js +15 -1
  50. package/dist/generators/ts/DeclaredType.d.ts +2 -2
  51. package/dist/generators/ts/DeclaredType.js +2 -2
  52. package/dist/generators/ts/FloatType.d.ts +6 -0
  53. package/dist/generators/ts/FloatType.js +18 -0
  54. package/dist/generators/ts/IdentifierType.d.ts +17 -7
  55. package/dist/generators/ts/IdentifierType.js +112 -18
  56. package/dist/generators/ts/Import.d.ts +2 -0
  57. package/dist/generators/ts/Import.js +10 -0
  58. package/dist/generators/ts/IntType.d.ts +6 -0
  59. package/dist/generators/ts/IntType.js +18 -0
  60. package/dist/generators/ts/ListType.d.ts +15 -12
  61. package/dist/generators/ts/ListType.js +113 -61
  62. package/dist/generators/ts/LiteralType.d.ts +17 -9
  63. package/dist/generators/ts/LiteralType.js +92 -17
  64. package/dist/generators/ts/NumberType.d.ts +3 -2
  65. package/dist/generators/ts/NumberType.js +8 -3
  66. package/dist/generators/ts/ObjectType.d.ts +65 -43
  67. package/dist/generators/ts/ObjectType.js +143 -123
  68. package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
  69. package/dist/generators/ts/ObjectUnionType.js +303 -101
  70. package/dist/generators/ts/OptionType.d.ts +14 -10
  71. package/dist/generators/ts/OptionType.js +62 -34
  72. package/dist/generators/ts/PrimitiveType.d.ts +23 -5
  73. package/dist/generators/ts/PrimitiveType.js +34 -6
  74. package/dist/generators/ts/SetType.d.ts +17 -13
  75. package/dist/generators/ts/SetType.js +76 -44
  76. package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
  77. package/dist/generators/ts/SnippetDeclarations.js +226 -101
  78. package/dist/generators/ts/StringType.d.ts +4 -2
  79. package/dist/generators/ts/StringType.js +20 -8
  80. package/dist/generators/ts/TermType.d.ts +29 -33
  81. package/dist/generators/ts/TermType.js +89 -68
  82. package/dist/generators/ts/TsGenerator.d.ts +2 -1
  83. package/dist/generators/ts/TsGenerator.js +26 -12
  84. package/dist/generators/ts/Type.d.ts +100 -32
  85. package/dist/generators/ts/Type.js +58 -54
  86. package/dist/generators/ts/TypeFactory.d.ts +12 -5
  87. package/dist/generators/ts/TypeFactory.js +380 -226
  88. package/dist/generators/ts/UnionType.d.ts +14 -10
  89. package/dist/generators/ts/UnionType.js +319 -142
  90. package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
  91. package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +31 -0
  92. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
  93. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
  94. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
  95. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
  96. package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
  97. package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
  98. package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
  99. package/dist/generators/ts/_ObjectType/Property.js +1 -10
  100. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
  101. package/dist/generators/ts/_ObjectType/ShaclProperty.js +120 -85
  102. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
  103. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
  104. package/dist/generators/ts/_ObjectType/classDeclaration.js +22 -17
  105. package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
  106. package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
  107. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
  108. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
  109. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
  110. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +49 -0
  111. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
  112. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
  113. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
  114. package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
  115. package/dist/generators/ts/_ObjectType/index.js +9 -7
  116. package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
  117. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
  118. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
  119. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
  120. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
  121. package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
  122. package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
  123. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
  124. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
  125. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
  126. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +144 -0
  127. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
  128. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
  129. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
  130. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
  131. package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
  132. package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
  133. package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
  134. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
  135. package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
  136. package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
  137. package/dist/generators/ts/objectSetDeclarations.js +59 -0
  138. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
  139. package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
  140. package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
  141. package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
  142. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
  143. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
  144. package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
  145. package/dist/generators/ts/rdfjsTermExpression.js +57 -0
  146. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
  147. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
  148. package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
  149. package/dist/generators/ts/syntheticNamePrefix.js +2 -0
  150. package/dist/generators/ts/tsName.js +27 -13
  151. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
  152. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
  153. package/dist/input/NodeShape.d.ts +6 -8
  154. package/dist/input/NodeShape.js +20 -44
  155. package/dist/input/Ontology.d.ts +0 -3
  156. package/dist/input/Ontology.js +0 -9
  157. package/dist/input/PropertyPath.d.ts +5 -5
  158. package/dist/input/PropertyPath.js +14 -24
  159. package/dist/input/PropertyShape.d.ts +3 -1
  160. package/dist/input/PropertyShape.js +8 -2
  161. package/dist/input/ShapesGraph.js +4 -8
  162. package/dist/input/generated.d.ts +967 -107
  163. package/dist/input/generated.js +2548 -1046
  164. package/dist/input/tsFeatures.d.ts +3 -2
  165. package/dist/input/tsFeatures.js +44 -27
  166. package/package.json +18 -16
  167. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
  168. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
  169. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
  170. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
  171. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
  172. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
  173. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
  174. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
  175. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
  176. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
  177. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
  178. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
  179. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
  180. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
  181. package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
  182. package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
  183. package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  184. package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
  185. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
  186. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
  187. package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
  188. package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
  189. package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
  190. package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
  191. package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
  192. package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
  193. package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
  194. package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Maybe } from "purify-ts";
8
+ import { Memoize } from "typescript-memoize";
9
+ import { ShaclProperty } from "./ShaclProperty.js";
10
+ export class EagerShaclProperty extends ShaclProperty {
11
+ mutable;
12
+ recursive;
13
+ constructor({ mutable, recursive, ...superParameters }) {
14
+ super(superParameters);
15
+ this.mutable = mutable;
16
+ this.recursive = recursive;
17
+ }
18
+ get graphqlField() {
19
+ return Maybe.of({
20
+ args: Maybe.empty(),
21
+ description: this.comment.map(JSON.stringify),
22
+ name: this.name,
23
+ resolve: `(source, _args) => ${this.type.graphqlResolveExpression({ variables: { args: "_args", value: `source.${this.name}` } })}`,
24
+ type: this.type.graphqlName.toString(),
25
+ });
26
+ }
27
+ }
28
+ __decorate([
29
+ Memoize()
30
+ ], EagerShaclProperty.prototype, "graphqlField", null);
31
+ //# sourceMappingURL=EagerShaclProperty.js.map
@@ -1,31 +1,32 @@
1
- import type { IdentifierType } from "generators/ts/IdentifierType.js";
2
- import type { Import } from "generators/ts/Import.js";
3
1
  import { Maybe } from "purify-ts";
4
2
  import { type GetAccessorDeclarationStructure, type OptionalKind, type PropertyDeclarationStructure, type PropertySignatureStructure } from "ts-morph";
3
+ import type { IdentifierType } from "../IdentifierType.js";
4
+ import type { Import } from "../Import.js";
5
5
  import type { StringType } from "../StringType.js";
6
6
  import { Property } from "./Property.js";
7
7
  export declare class IdentifierPrefixProperty extends Property<StringType> {
8
- readonly equalsFunction = "strictEquals";
9
- readonly mutable = false;
10
8
  private readonly own;
9
+ readonly declarationImports: readonly Import[];
10
+ readonly graphqlField: Property<StringType>["graphqlField"];
11
+ readonly propertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
12
+ readonly jsonPropertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
13
+ readonly mutable = false;
14
+ readonly recursive = false;
11
15
  constructor({ own, ...superParameters }: {
12
16
  own: boolean;
13
17
  type: StringType;
14
18
  } & ConstructorParameters<typeof Property>[0]);
15
- get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
16
- get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
17
19
  get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
18
- get declarationImports(): readonly Import[];
19
- get interfacePropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
20
- get jsonPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
21
- get snippetDeclarations(): readonly string[];
22
- classConstructorStatements({ variables, }: Parameters<Property<IdentifierType>["classConstructorStatements"]>[0]): readonly string[];
20
+ get equalsFunction(): Maybe<string>;
21
+ constructorStatements({ variables, }: Parameters<Property<IdentifierType>["constructorStatements"]>[0]): readonly string[];
23
22
  fromJsonStatements(): readonly string[];
24
23
  fromRdfStatements(): readonly string[];
24
+ get getAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
25
25
  hashStatements(): readonly string[];
26
- interfaceConstructorStatements(): readonly string[];
27
26
  jsonUiSchemaElement(): Maybe<string>;
28
27
  jsonZodSchema(): ReturnType<Property<IdentifierType>["jsonZodSchema"]>;
28
+ get propertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
29
+ snippetDeclarations(): readonly string[];
29
30
  sparqlConstructTemplateTriples(): readonly string[];
30
31
  sparqlWherePatterns(): readonly string[];
31
32
  toJsonObjectMember(): Maybe<string>;
@@ -1,38 +1,29 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import { Maybe } from "purify-ts";
2
8
  import { invariant } from "ts-invariant";
3
9
  import { Scope, } from "ts-morph";
10
+ import { Memoize } from "typescript-memoize";
4
11
  import { SnippetDeclarations } from "../SnippetDeclarations.js";
12
+ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
5
13
  import { Property } from "./Property.js";
6
14
  export class IdentifierPrefixProperty extends Property {
7
- equalsFunction = "strictEquals";
8
- mutable = false;
9
15
  own;
16
+ declarationImports = [];
17
+ graphqlField = Maybe.empty();
18
+ propertySignature = Maybe.empty();
19
+ jsonPropertySignature = Maybe.empty();
20
+ mutable = false;
21
+ recursive = false;
10
22
  constructor({ own, ...superParameters }) {
11
23
  super(superParameters);
12
24
  invariant(this.visibility === "protected");
13
25
  this.own = own;
14
26
  }
15
- get classGetAccessorDeclaration() {
16
- return Maybe.of({
17
- leadingTrivia: `protected ${!this.own ? "override " : ""}`,
18
- name: this.name,
19
- returnType: this.type.name,
20
- statements: [
21
- `return (typeof this._${this.name} !== "undefined") ? this._${this.name} : \`urn:shaclmate:\${this.type}:\``,
22
- ],
23
- });
24
- }
25
- get classPropertyDeclaration() {
26
- return this.own
27
- ? Maybe.of({
28
- hasQuestionToken: true,
29
- isReadonly: true,
30
- name: `_${this.name}`,
31
- scope: Scope.Protected,
32
- type: this.type.name,
33
- })
34
- : Maybe.empty();
35
- }
36
27
  get constructorParametersPropertySignature() {
37
28
  return Maybe.of({
38
29
  hasQuestionToken: true,
@@ -41,28 +32,22 @@ export class IdentifierPrefixProperty extends Property {
41
32
  type: this.type.name,
42
33
  });
43
34
  }
44
- get declarationImports() {
45
- return [];
46
- }
47
- get interfacePropertySignature() {
48
- return Maybe.empty();
49
- }
50
- get jsonPropertySignature() {
51
- return Maybe.empty();
35
+ get equalsFunction() {
36
+ return this.objectType.declarationType === "class"
37
+ ? Maybe.of(`${syntheticNamePrefix}strictEquals`)
38
+ : Maybe.empty();
52
39
  }
53
- get snippetDeclarations() {
54
- const snippetDeclarations = [];
55
- if (this.objectType.features.has("equals")) {
56
- snippetDeclarations.push(SnippetDeclarations.strictEquals);
40
+ constructorStatements({ variables, }) {
41
+ switch (this.objectType.declarationType) {
42
+ case "class":
43
+ return this.propertyDeclaration
44
+ .map((propertyDeclaration) => [
45
+ `this.${propertyDeclaration.name} = ${variables.parameter};`,
46
+ ])
47
+ .orDefault([]);
48
+ case "interface":
49
+ return [];
57
50
  }
58
- return snippetDeclarations;
59
- }
60
- classConstructorStatements({ variables, }) {
61
- return this.classPropertyDeclaration
62
- .map((classPropertyDeclaration) => [
63
- `this.${classPropertyDeclaration.name} = ${variables.parameter};`,
64
- ])
65
- .orDefault([]);
66
51
  }
67
52
  fromJsonStatements() {
68
53
  return [];
@@ -70,10 +55,17 @@ export class IdentifierPrefixProperty extends Property {
70
55
  fromRdfStatements() {
71
56
  return [];
72
57
  }
73
- hashStatements() {
74
- return [];
58
+ get getAccessorDeclaration() {
59
+ return Maybe.of({
60
+ leadingTrivia: `protected ${!this.own ? "override " : ""}`,
61
+ name: this.name,
62
+ returnType: this.type.name,
63
+ statements: [
64
+ `return (typeof this._${this.name} !== "undefined") ? this._${this.name} : \`urn:shaclmate:\${this.${syntheticNamePrefix}type}:\``,
65
+ ],
66
+ });
75
67
  }
76
- interfaceConstructorStatements() {
68
+ hashStatements() {
77
69
  return [];
78
70
  }
79
71
  jsonUiSchemaElement() {
@@ -82,6 +74,24 @@ export class IdentifierPrefixProperty extends Property {
82
74
  jsonZodSchema() {
83
75
  return Maybe.empty();
84
76
  }
77
+ get propertyDeclaration() {
78
+ return this.own
79
+ ? Maybe.of({
80
+ hasQuestionToken: true,
81
+ isReadonly: true,
82
+ name: `_${this.name}`,
83
+ scope: Scope.Protected,
84
+ type: this.type.name,
85
+ })
86
+ : Maybe.empty();
87
+ }
88
+ snippetDeclarations() {
89
+ const snippetDeclarations = [];
90
+ if (this.objectType.features.has("equals")) {
91
+ snippetDeclarations.push(SnippetDeclarations.strictEquals);
92
+ }
93
+ return snippetDeclarations;
94
+ }
85
95
  sparqlConstructTemplateTriples() {
86
96
  return [];
87
97
  }
@@ -95,4 +105,7 @@ export class IdentifierPrefixProperty extends Property {
95
105
  return [];
96
106
  }
97
107
  }
108
+ __decorate([
109
+ Memoize()
110
+ ], IdentifierPrefixProperty.prototype, "equalsFunction", null);
98
111
  //# sourceMappingURL=IdentifierPrefixProperty.js.map
@@ -1,37 +1,44 @@
1
1
  import { Maybe } from "purify-ts";
2
- import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure } from "ts-morph";
2
+ import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure, Scope } from "ts-morph";
3
3
  import type { IdentifierMintingStrategy, PropertyVisibility } from "../../../enums/index.js";
4
4
  import type { IdentifierType } from "../IdentifierType.js";
5
5
  import { Import } from "../Import.js";
6
6
  import { Property } from "./Property.js";
7
7
  export declare class IdentifierProperty extends Property<IdentifierType> {
8
- readonly abstract: boolean;
9
- readonly equalsFunction = "booleanEquals";
10
- readonly mutable = false;
11
- private readonly classDeclarationVisibility;
8
+ private readonly getAccessorScope;
12
9
  private readonly identifierMintingStrategy;
10
+ private readonly identifierPrefixPropertyName;
13
11
  private readonly override;
14
- constructor({ abstract, classDeclarationVisibility, identifierMintingStrategy, override, ...superParameters }: {
12
+ private readonly propertyDeclarationVisibility;
13
+ private readonly typeAlias;
14
+ readonly abstract: boolean;
15
+ readonly equalsFunction: Maybe<string>;
16
+ readonly mutable = false;
17
+ readonly recursive = false;
18
+ constructor({ abstract, getAccessorScope, identifierMintingStrategy, identifierPrefixPropertyName, override, propertyDeclarationVisibility, typeAlias, ...superParameters }: {
15
19
  abstract: boolean;
16
- classDeclarationVisibility: Maybe<PropertyVisibility>;
20
+ getAccessorScope: Maybe<Scope>;
21
+ propertyDeclarationVisibility: Maybe<PropertyVisibility>;
17
22
  identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
23
+ identifierPrefixPropertyName: string;
18
24
  override: boolean;
19
25
  type: IdentifierType;
26
+ typeAlias: string;
20
27
  } & ConstructorParameters<typeof Property>[0]);
21
- get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
22
- get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
23
28
  get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
24
29
  get declarationImports(): readonly Import[];
25
- get interfacePropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
30
+ get getAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
31
+ get graphqlField(): Property<IdentifierType>["graphqlField"];
26
32
  get jsonPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
27
- get snippetDeclarations(): readonly string[];
28
- classConstructorStatements({ variables, }: Parameters<Property<IdentifierType>["classConstructorStatements"]>[0]): readonly string[];
33
+ constructorStatements({ variables, }: Parameters<Property<IdentifierType>["constructorStatements"]>[0]): readonly string[];
29
34
  fromJsonStatements({ variables, }: Parameters<Property<IdentifierType>["fromJsonStatements"]>[0]): readonly string[];
30
35
  fromRdfStatements({ variables, }: Parameters<Property<IdentifierType>["fromRdfStatements"]>[0]): readonly string[];
31
36
  hashStatements({ variables, }: Parameters<Property<IdentifierType>["hashStatements"]>[0]): readonly string[];
32
- interfaceConstructorStatements({ variables, }: Parameters<Property<IdentifierType>["interfaceConstructorStatements"]>[0]): readonly string[];
33
37
  jsonUiSchemaElement({ variables, }: Parameters<Property<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<string>;
34
38
  jsonZodSchema({ variables, }: Parameters<Property<IdentifierType>["jsonZodSchema"]>[0]): ReturnType<Property<IdentifierType>["jsonZodSchema"]>;
39
+ get propertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
40
+ get propertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
41
+ snippetDeclarations(): readonly string[];
35
42
  sparqlConstructTemplateTriples(): readonly string[];
36
43
  sparqlWherePatterns(): readonly string[];
37
44
  toJsonObjectMember({ variables, }: Parameters<Property<IdentifierType>["toJsonObjectMember"]>[0]): Maybe<string>;