@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.
- package/dist/Compiler.d.ts +1 -1
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -1
- package/dist/ShapesGraphToAstTransformer.js +16 -16
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +6 -5
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/shapeOntology.js +4 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +11 -17
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +6 -11
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +21 -40
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
- package/dist/ast/AbstractCompoundType.d.ts +1 -1
- package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
- package/dist/ast/ListType.d.ts +1 -8
- package/dist/ast/ListType.js +1 -6
- package/dist/ast/ObjectType.d.ts +3 -30
- package/dist/ast/ObjectType.js +2 -26
- package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
- package/dist/generators/ts/AbstractContainerType.js +0 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +0 -1
- package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +1 -2
- package/dist/generators/ts/AbstractNamedUnionType.js +16 -19
- package/dist/generators/ts/AbstractTermType.d.ts +0 -1
- package/dist/generators/ts/AbstractTermType.js +0 -1
- package/dist/generators/ts/AbstractType.d.ts +0 -4
- package/dist/generators/ts/AbstractUnionType.d.ts +1 -10
- package/dist/generators/ts/AbstractUnionType.js +27 -40
- package/dist/generators/ts/LazyObjectOptionType.js +3 -2
- package/dist/generators/ts/LazyObjectSetType.js +2 -1
- package/dist/generators/ts/LazyObjectType.js +2 -1
- package/dist/generators/ts/ListType.d.ts +1 -5
- package/dist/generators/ts/ListType.js +8 -27
- package/dist/generators/ts/NamedObjectType.d.ts +2 -21
- package/dist/generators/ts/NamedObjectType.js +33 -132
- package/dist/generators/ts/NamedObjectUnionType.js +14 -25
- package/dist/generators/ts/TypeFactory.js +11 -67
- package/dist/generators/ts/ZodGenerator.js +2 -2
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +11 -17
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +7 -6
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +1 -4
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +19 -34
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +5 -15
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +31 -212
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +25 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +5 -13
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +49 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +0 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +41 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +8 -27
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +40 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/Property.d.ts +1 -2
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -3
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +8 -39
- package/dist/generators/ts/_snippets/snippets_LazyObject.js +2 -2
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +2 -2
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +2 -2
- package/dist/generators/ts/imports.d.ts +0 -2
- package/dist/generators/ts/imports.js +0 -2
- package/dist/generators/ts/objectSetDeclarations.js +1 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +4 -6
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +1 -1
- package/dist/input/generated.d.ts +10 -181
- package/dist/input/generated.js +116 -392
- package/package.json +2 -4
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +0 -32
- package/dist/enums/IdentifierMintingStrategy.d.ts +0 -9
- package/dist/enums/IdentifierMintingStrategy.js +0 -18
- package/dist/enums/TsObjectDeclarationType.d.ts +0 -9
- package/dist/enums/TsObjectDeclarationType.js +0 -16
- package/dist/enums/Visibility.d.ts +0 -6
- package/dist/enums/Visibility.js +0 -18
- package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.d.ts +0 -33
- package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.js +0 -92
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -62
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -51
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -73
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js +0 -59
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +0 -62
- /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
- /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
package/dist/ast/ObjectType.d.ts
CHANGED
|
@@ -2,10 +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 {
|
|
6
|
-
import type { TsFeature } from "../enums/TsFeature.js";
|
|
7
|
-
import type { TsObjectDeclarationType } from "../enums/TsObjectDeclarationType.js";
|
|
8
|
-
import type { Visibility } from "../enums/Visibility.js";
|
|
5
|
+
import type { TsFeature } from "../generators/ts/TsFeature.js";
|
|
9
6
|
import { AbstractType } from "./AbstractType.js";
|
|
10
7
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
11
8
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
@@ -13,12 +10,6 @@ import type { IriType } from "./IriType.js";
|
|
|
13
10
|
import { Type } from "./Type.js";
|
|
14
11
|
export declare class ObjectType extends AbstractType {
|
|
15
12
|
#private;
|
|
16
|
-
/**
|
|
17
|
-
* Classes generated from this type are abstract / cannot be instantiated themselves.
|
|
18
|
-
*
|
|
19
|
-
* Defaults to false.
|
|
20
|
-
*/
|
|
21
|
-
readonly abstract: boolean;
|
|
22
13
|
/**
|
|
23
14
|
* If true, the code for this ObjectType is defined externally and should not be generated.
|
|
24
15
|
*
|
|
@@ -32,10 +23,6 @@ export declare class ObjectType extends AbstractType {
|
|
|
32
23
|
* class targets).
|
|
33
24
|
*/
|
|
34
25
|
readonly fromRdfType: Maybe<NamedNode>;
|
|
35
|
-
/**
|
|
36
|
-
* Strategy for minting new object identifiers.
|
|
37
|
-
*/
|
|
38
|
-
readonly identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
|
|
39
26
|
/**
|
|
40
27
|
* Identifier type.
|
|
41
28
|
*/
|
|
@@ -69,21 +56,14 @@ export declare class ObjectType extends AbstractType {
|
|
|
69
56
|
* import { MyType } from "./MyType.js"
|
|
70
57
|
*/
|
|
71
58
|
readonly tsImports: readonly string[];
|
|
72
|
-
|
|
73
|
-
* Whether to generate a TypeScript class or interface for this type.
|
|
74
|
-
*/
|
|
75
|
-
readonly tsObjectDeclarationType: TsObjectDeclarationType;
|
|
76
|
-
constructor({ abstract, extern, fromRdfType, identifierMintingStrategy, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, tsObjectDeclarationType, ...superParameters }: {
|
|
77
|
-
abstract: boolean;
|
|
59
|
+
constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, ...superParameters }: {
|
|
78
60
|
extern: boolean;
|
|
79
61
|
fromRdfType: Maybe<NamedNode>;
|
|
80
|
-
identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
|
|
81
62
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
82
63
|
synthetic: boolean;
|
|
83
64
|
toRdfTypes: readonly NamedNode[];
|
|
84
65
|
tsFeatures: ReadonlySet<TsFeature>;
|
|
85
66
|
tsImports: readonly string[];
|
|
86
|
-
tsObjectDeclarationType: TsObjectDeclarationType;
|
|
87
67
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
88
68
|
get ancestorObjectTypes(): readonly ObjectType[];
|
|
89
69
|
get childObjectTypes(): readonly ObjectType[];
|
|
@@ -100,7 +80,6 @@ export declare class ObjectType extends AbstractType {
|
|
|
100
80
|
sortProperties(): void;
|
|
101
81
|
toJSON(): {
|
|
102
82
|
fromRdfType: NamedNode<string> | undefined;
|
|
103
|
-
identifierMintingStrategy: "blankNode" | "sha256" | "uuidv4" | undefined;
|
|
104
83
|
identifierType: {
|
|
105
84
|
hasValues: readonly NamedNode<string>[] | undefined;
|
|
106
85
|
in: readonly NamedNode<string>[] | undefined;
|
|
@@ -170,11 +149,7 @@ export declare namespace ObjectType {
|
|
|
170
149
|
* Type of this property.
|
|
171
150
|
*/
|
|
172
151
|
readonly type: Type;
|
|
173
|
-
|
|
174
|
-
* Visibility: private, protected, public.
|
|
175
|
-
*/
|
|
176
|
-
readonly visibility: Visibility;
|
|
177
|
-
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, }: {
|
|
178
153
|
comment: Maybe<string>;
|
|
179
154
|
description: Maybe<string>;
|
|
180
155
|
display: boolean;
|
|
@@ -186,7 +161,6 @@ export declare namespace ObjectType {
|
|
|
186
161
|
path: PropertyPath;
|
|
187
162
|
shapeIdentifier: BlankNode | NamedNode;
|
|
188
163
|
type: Type;
|
|
189
|
-
visibility: Visibility;
|
|
190
164
|
});
|
|
191
165
|
equals(other: Property): boolean;
|
|
192
166
|
/**
|
|
@@ -211,7 +185,6 @@ export declare namespace ObjectType {
|
|
|
211
185
|
recursive: boolean | undefined;
|
|
212
186
|
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
213
187
|
};
|
|
214
|
-
visibility: Visibility;
|
|
215
188
|
};
|
|
216
189
|
toString(): string;
|
|
217
190
|
}
|
package/dist/ast/ObjectType.js
CHANGED
|
@@ -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
|
*
|
|
@@ -62,10 +56,6 @@ export class ObjectType extends AbstractType {
|
|
|
62
56
|
* class targets).
|
|
63
57
|
*/
|
|
64
58
|
fromRdfType;
|
|
65
|
-
/**
|
|
66
|
-
* Strategy for minting new object identifiers.
|
|
67
|
-
*/
|
|
68
|
-
identifierMintingStrategy;
|
|
69
59
|
/**
|
|
70
60
|
* Identifier type.
|
|
71
61
|
*/
|
|
@@ -99,22 +89,15 @@ export class ObjectType extends AbstractType {
|
|
|
99
89
|
* import { MyType } from "./MyType.js"
|
|
100
90
|
*/
|
|
101
91
|
tsImports;
|
|
102
|
-
|
|
103
|
-
* Whether to generate a TypeScript class or interface for this type.
|
|
104
|
-
*/
|
|
105
|
-
tsObjectDeclarationType;
|
|
106
|
-
constructor({ abstract, extern, fromRdfType, identifierMintingStrategy, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, tsObjectDeclarationType, ...superParameters }) {
|
|
92
|
+
constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsFeatures, tsImports, ...superParameters }) {
|
|
107
93
|
super(superParameters);
|
|
108
|
-
this.abstract = abstract;
|
|
109
94
|
this.extern = extern;
|
|
110
95
|
this.fromRdfType = fromRdfType;
|
|
111
|
-
this.identifierMintingStrategy = identifierMintingStrategy;
|
|
112
96
|
this.identifierType = identifierType;
|
|
113
97
|
this.synthetic = synthetic;
|
|
114
98
|
this.toRdfTypes = toRdfTypes;
|
|
115
99
|
this.tsFeatures = tsFeatures;
|
|
116
100
|
this.tsImports = tsImports;
|
|
117
|
-
this.tsObjectDeclarationType = tsObjectDeclarationType;
|
|
118
101
|
}
|
|
119
102
|
get ancestorObjectTypes() {
|
|
120
103
|
return this.#ancestorObjectTypes;
|
|
@@ -171,7 +154,6 @@ export class ObjectType extends AbstractType {
|
|
|
171
154
|
return {
|
|
172
155
|
...super.toJSON(),
|
|
173
156
|
fromRdfType: this.fromRdfType.extract(),
|
|
174
|
-
identifierMintingStrategy: this.identifierMintingStrategy.extract(),
|
|
175
157
|
identifierType: this.identifierType.toJSON(),
|
|
176
158
|
parentObjectTypes: this.parentObjectTypes.length > 0
|
|
177
159
|
? this.parentObjectTypes.map((parentObjectType) => parentObjectType.name.extract() ??
|
|
@@ -230,11 +212,7 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
230
212
|
* Type of this property.
|
|
231
213
|
*/
|
|
232
214
|
type;
|
|
233
|
-
|
|
234
|
-
* Visibility: private, protected, public.
|
|
235
|
-
*/
|
|
236
|
-
visibility;
|
|
237
|
-
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, }) {
|
|
238
216
|
this.comment = comment;
|
|
239
217
|
this.description = description;
|
|
240
218
|
this.display = display;
|
|
@@ -246,7 +224,6 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
246
224
|
this.path = path;
|
|
247
225
|
this.shapeIdentifier = shapeIdentifier;
|
|
248
226
|
this.type = type;
|
|
249
|
-
this.visibility = visibility;
|
|
250
227
|
}
|
|
251
228
|
equals(other) {
|
|
252
229
|
return this.shapeIdentifier.equals(other.shapeIdentifier);
|
|
@@ -379,7 +356,6 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
379
356
|
recursive: this.recursive ? true : undefined,
|
|
380
357
|
shapeIdentifier: this.shapeIdentifier,
|
|
381
358
|
type: this.type.toJSON(),
|
|
382
|
-
visibility: this.visibility,
|
|
383
359
|
};
|
|
384
360
|
}
|
|
385
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.
|
|
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.
|
|
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.
|
|
40
|
+
return code `${this.name}.${syntheticNamePrefix}equals`;
|
|
41
41
|
}
|
|
42
42
|
return this.inlineEqualsFunction;
|
|
43
43
|
}
|
|
44
44
|
get filterFunction() {
|
|
45
|
-
return code `${this.
|
|
45
|
+
return code `${this.name}.${syntheticNamePrefix}filter`;
|
|
46
46
|
}
|
|
47
47
|
get filterType() {
|
|
48
|
-
return code `${this.
|
|
48
|
+
return code `${this.name}.${syntheticNamePrefix}Filter`;
|
|
49
49
|
}
|
|
50
50
|
get jsonSchemaFunctionDeclaration() {
|
|
51
51
|
const meta = {
|
|
52
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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
|