@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.
- package/dist/ShapesGraphToAstTransformer.d.ts +6 -5
- package/dist/ShapesGraphToAstTransformer.js +61 -17
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
- package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
- package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
- package/dist/ast/Ast.d.ts +0 -1
- package/dist/ast/Curie.d.ts +14 -0
- package/dist/ast/Curie.js +21 -0
- package/dist/ast/IdentifierType.d.ts +3 -2
- package/dist/ast/ListType.d.ts +2 -1
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/Name.d.ts +40 -5
- package/dist/ast/ObjectCompositeType.d.ts +11 -0
- package/dist/ast/ObjectType.d.ts +18 -13
- package/dist/ast/ObjectUnionType.d.ts +0 -11
- package/dist/ast/OptionType.d.ts +2 -4
- package/dist/ast/SetType.d.ts +2 -7
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +26 -4
- package/dist/generators/ts/BooleanType.d.ts +4 -2
- package/dist/generators/ts/BooleanType.js +12 -3
- package/dist/generators/ts/DateTimeType.d.ts +9 -8
- package/dist/generators/ts/DateTimeType.js +32 -8
- package/dist/generators/ts/DateType.d.ts +5 -2
- package/dist/generators/ts/DateType.js +15 -1
- package/dist/generators/ts/DeclaredType.d.ts +2 -2
- package/dist/generators/ts/DeclaredType.js +2 -2
- package/dist/generators/ts/FloatType.d.ts +6 -0
- package/dist/generators/ts/FloatType.js +18 -0
- package/dist/generators/ts/IdentifierType.d.ts +17 -7
- package/dist/generators/ts/IdentifierType.js +112 -18
- package/dist/generators/ts/Import.d.ts +2 -0
- package/dist/generators/ts/Import.js +10 -0
- package/dist/generators/ts/IntType.d.ts +6 -0
- package/dist/generators/ts/IntType.js +18 -0
- package/dist/generators/ts/ListType.d.ts +15 -12
- package/dist/generators/ts/ListType.js +113 -61
- package/dist/generators/ts/LiteralType.d.ts +17 -9
- package/dist/generators/ts/LiteralType.js +92 -17
- package/dist/generators/ts/NumberType.d.ts +3 -2
- package/dist/generators/ts/NumberType.js +8 -3
- package/dist/generators/ts/ObjectType.d.ts +65 -43
- package/dist/generators/ts/ObjectType.js +143 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
- package/dist/generators/ts/ObjectUnionType.js +303 -101
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +62 -34
- package/dist/generators/ts/PrimitiveType.d.ts +23 -5
- package/dist/generators/ts/PrimitiveType.js +34 -6
- package/dist/generators/ts/SetType.d.ts +17 -13
- package/dist/generators/ts/SetType.js +76 -44
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +226 -101
- package/dist/generators/ts/StringType.d.ts +4 -2
- package/dist/generators/ts/StringType.js +20 -8
- package/dist/generators/ts/TermType.d.ts +29 -33
- package/dist/generators/ts/TermType.js +89 -68
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +26 -12
- package/dist/generators/ts/Type.d.ts +100 -32
- package/dist/generators/ts/Type.js +58 -54
- package/dist/generators/ts/TypeFactory.d.ts +12 -5
- package/dist/generators/ts/TypeFactory.js +380 -226
- package/dist/generators/ts/UnionType.d.ts +14 -10
- package/dist/generators/ts/UnionType.js +319 -142
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +31 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
- package/dist/generators/ts/_ObjectType/Property.js +1 -10
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +120 -85
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
- package/dist/generators/ts/_ObjectType/classDeclaration.js +22 -17
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +49 -0
- package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
- package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
- package/dist/generators/ts/_ObjectType/index.js +9 -7
- package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +144 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
- package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
- package/dist/generators/ts/objectSetDeclarations.js +59 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
- package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
- package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
- package/dist/generators/ts/rdfjsTermExpression.js +57 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
- package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
- package/dist/generators/ts/syntheticNamePrefix.js +2 -0
- package/dist/generators/ts/tsName.js +27 -13
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
- package/dist/input/NodeShape.d.ts +6 -8
- package/dist/input/NodeShape.js +20 -44
- package/dist/input/Ontology.d.ts +0 -3
- package/dist/input/Ontology.js +0 -9
- package/dist/input/PropertyPath.d.ts +5 -5
- package/dist/input/PropertyPath.js +14 -24
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -8
- package/dist/input/generated.d.ts +967 -107
- package/dist/input/generated.js +2548 -1046
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
- package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
import type { NamedNode } from "@rdfjs/types";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import { type ClassDeclarationStructure, type InterfaceDeclarationStructure, type ModuleDeclarationStructure } from "ts-morph";
|
|
4
|
-
import
|
|
4
|
+
import * as _ObjectType from "./_ObjectType/index.js";
|
|
5
|
+
import type { IdentifierMintingStrategy, TsObjectDeclarationType } from "../../enums/index.js";
|
|
5
6
|
import { DeclaredType } from "./DeclaredType.js";
|
|
6
7
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
7
8
|
import { Import } from "./Import.js";
|
|
8
|
-
import
|
|
9
|
-
import * as _ObjectType from "./_ObjectType/index.js";
|
|
9
|
+
import { Type } from "./Type.js";
|
|
10
10
|
export declare class ObjectType extends DeclaredType {
|
|
11
|
-
readonly
|
|
12
|
-
readonly declarationType: TsObjectDeclarationType;
|
|
13
|
-
readonly kind = "ObjectType";
|
|
11
|
+
private readonly imports;
|
|
14
12
|
protected readonly comment: Maybe<string>;
|
|
15
|
-
protected readonly extern: boolean;
|
|
16
|
-
protected readonly fromRdfType: Maybe<NamedNode>;
|
|
17
13
|
protected readonly label: Maybe<string>;
|
|
18
|
-
protected readonly identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
|
|
19
14
|
protected readonly toRdfTypes: readonly NamedNode[];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
readonly abstract: boolean;
|
|
16
|
+
readonly declarationType: TsObjectDeclarationType;
|
|
17
|
+
readonly extern: boolean;
|
|
18
|
+
readonly fromRdfType: Maybe<NamedNode>;
|
|
19
|
+
readonly kind = "ObjectType";
|
|
20
|
+
readonly staticModuleName: string;
|
|
21
|
+
readonly synthetic: boolean;
|
|
22
|
+
readonly typeof = "object";
|
|
23
|
+
constructor({ abstract, comment, declarationType, extern, fromRdfType, imports, label, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyParentObjectTypes, lazyProperties, staticModuleName, synthetic, toRdfTypes, ...superParameters }: {
|
|
26
24
|
abstract: boolean;
|
|
27
25
|
comment: Maybe<string>;
|
|
28
26
|
declarationType: TsObjectDeclarationType;
|
|
29
27
|
extern: boolean;
|
|
30
28
|
fromRdfType: Maybe<NamedNode>;
|
|
29
|
+
identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
|
|
31
30
|
imports: readonly string[];
|
|
32
31
|
label: Maybe<string>;
|
|
33
32
|
lazyAncestorObjectTypes: () => readonly ObjectType[];
|
|
33
|
+
lazyChildObjectTypes: () => readonly ObjectType[];
|
|
34
34
|
lazyDescendantObjectTypes: () => readonly ObjectType[];
|
|
35
35
|
lazyParentObjectTypes: () => readonly ObjectType[];
|
|
36
|
-
lazyProperties: () => readonly ObjectType.Property[];
|
|
37
|
-
|
|
36
|
+
lazyProperties: (objectType: ObjectType) => readonly ObjectType.Property[];
|
|
37
|
+
staticModuleName: string;
|
|
38
|
+
synthetic: boolean;
|
|
38
39
|
toRdfTypes: readonly NamedNode[];
|
|
39
40
|
} & ConstructorParameters<typeof DeclaredType>[0]);
|
|
40
41
|
get _discriminatorProperty(): Type.DiscriminatorProperty;
|
|
41
42
|
get ancestorObjectTypes(): readonly ObjectType[];
|
|
43
|
+
get childObjectTypes(): readonly ObjectType[];
|
|
42
44
|
get conversions(): readonly Type.Conversion[];
|
|
43
45
|
get declarationImports(): readonly Import[];
|
|
44
46
|
get declarations(): (ClassDeclarationStructure | InterfaceDeclarationStructure | ModuleDeclarationStructure)[];
|
|
@@ -46,52 +48,72 @@ export declare class ObjectType extends DeclaredType {
|
|
|
46
48
|
get discriminatorProperty(): Maybe<Type.DiscriminatorProperty>;
|
|
47
49
|
get discriminatorValue(): string;
|
|
48
50
|
get equalsFunction(): string;
|
|
49
|
-
get
|
|
50
|
-
get
|
|
51
|
+
get fromRdfTypeVariable(): Maybe<string>;
|
|
52
|
+
get graphqlName(): Type.GraphqlName;
|
|
51
53
|
get identifierProperty(): ObjectType.IdentifierProperty;
|
|
52
54
|
get identifierType(): IdentifierType;
|
|
53
|
-
get
|
|
54
|
-
get
|
|
55
|
-
get jsonZodSchemaFunctionName(): string;
|
|
55
|
+
get identifierTypeAlias(): string;
|
|
56
|
+
get jsonName(): Type.JsonName;
|
|
56
57
|
get mutable(): boolean;
|
|
58
|
+
newExpression({ parameters }: {
|
|
59
|
+
parameters: string;
|
|
60
|
+
}): string;
|
|
61
|
+
get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
|
|
57
62
|
get ownProperties(): readonly ObjectType.Property[];
|
|
58
63
|
get ownShaclProperties(): readonly ObjectType.Property[];
|
|
59
64
|
get parentObjectTypes(): readonly ObjectType[];
|
|
60
65
|
get properties(): readonly ObjectType.Property[];
|
|
66
|
+
get toRdfjsResourceType(): string;
|
|
61
67
|
protected get thisVariable(): string;
|
|
62
|
-
fromJsonExpression({ variables, }: Parameters<
|
|
63
|
-
fromRdfExpression({ variables, }: Parameters<
|
|
64
|
-
|
|
65
|
-
jsonUiSchemaElement({ variables, }: {
|
|
68
|
+
fromJsonExpression({ variables, }: Parameters<DeclaredType["fromJsonExpression"]>[0]): string;
|
|
69
|
+
fromRdfExpression({ variables, }: Parameters<DeclaredType["fromRdfExpression"]>[0]): string;
|
|
70
|
+
graphqlResolveExpression({ variables, }: {
|
|
66
71
|
variables: {
|
|
67
|
-
|
|
72
|
+
value: string;
|
|
68
73
|
};
|
|
69
|
-
}):
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}):
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
sparqlConstructTemplateTriples({ context, variables, }: Parameters<Type["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
80
|
-
sparqlWherePatterns({ context, variables, }: Parameters<Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
81
|
-
toJsonExpression({ variables, }: Parameters<Type["toJsonExpression"]>[0]): string;
|
|
82
|
-
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
83
|
-
useImports(_features: Set<TsFeature>): readonly Import[];
|
|
74
|
+
}): string;
|
|
75
|
+
hashStatements({ variables, }: Parameters<DeclaredType["hashStatements"]>[0]): readonly string[];
|
|
76
|
+
jsonUiSchemaElement({ variables, }: Parameters<DeclaredType["jsonUiSchemaElement"]>[0]): Maybe<string>;
|
|
77
|
+
jsonZodSchema({ context, variables, }: Parameters<DeclaredType["jsonZodSchema"]>[0]): ReturnType<DeclaredType["jsonZodSchema"]>;
|
|
78
|
+
snippetDeclarations({ recursionStack, }: Parameters<DeclaredType["snippetDeclarations"]>[0]): readonly string[];
|
|
79
|
+
sparqlConstructTemplateTriples(parameters: Parameters<DeclaredType["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
80
|
+
sparqlWherePatterns(parameters: Parameters<DeclaredType["sparqlWherePatterns"]>[0]): readonly string[];
|
|
81
|
+
toJsonExpression({ variables, }: Parameters<DeclaredType["toJsonExpression"]>[0]): string;
|
|
82
|
+
toRdfExpression({ variables, }: Parameters<DeclaredType["toRdfExpression"]>[0]): string;
|
|
83
|
+
useImports(): readonly Import[];
|
|
84
84
|
protected ensureAtMostOneSuperObjectType(): void;
|
|
85
|
+
private readonly lazyAncestorObjectTypes;
|
|
86
|
+
private readonly lazyChildObjectTypes;
|
|
87
|
+
private readonly lazyDescendantObjectTypes;
|
|
88
|
+
private readonly lazyParentObjectTypes;
|
|
89
|
+
private readonly lazyProperties;
|
|
85
90
|
}
|
|
86
91
|
export declare namespace ObjectType {
|
|
92
|
+
const EagerShaclProperty: typeof _ObjectType.EagerShaclProperty;
|
|
93
|
+
type EagerShaclProperty<TypeT extends Type = Type> = _ObjectType.EagerShaclProperty<TypeT>;
|
|
87
94
|
const IdentifierPrefixProperty: typeof _ObjectType.IdentifierPrefixProperty;
|
|
88
95
|
type IdentifierPrefixProperty = _ObjectType.IdentifierPrefixProperty;
|
|
89
96
|
const IdentifierProperty: typeof _ObjectType.IdentifierProperty;
|
|
90
97
|
type IdentifierProperty = _ObjectType.IdentifierProperty;
|
|
98
|
+
const LazyShaclProperty: typeof _ObjectType.LazyShaclProperty;
|
|
99
|
+
type LazyShaclProperty<LazyTypeT extends _ObjectType.LazyShaclProperty.Type<ResolvedTypeT, StubTypeT>, ResolvedTypeT extends _ObjectType.LazyShaclProperty.Type.ResolvedTypeConstraint, StubTypeT extends _ObjectType.LazyShaclProperty.Type.StubTypeConstraint> = _ObjectType.LazyShaclProperty<LazyTypeT, ResolvedTypeT, StubTypeT>;
|
|
100
|
+
namespace LazyShaclProperty {
|
|
101
|
+
type Type<ResolvedTypeT extends _ObjectType.LazyShaclProperty.Type.ResolvedTypeConstraint, StubTypeT extends _ObjectType.LazyShaclProperty.Type.StubTypeConstraint> = _ObjectType.LazyShaclProperty.Type<ResolvedTypeT, StubTypeT>;
|
|
102
|
+
namespace Type {
|
|
103
|
+
type ResolvedTypeConstraint = _ObjectType.LazyShaclProperty.Type.ResolvedTypeConstraint;
|
|
104
|
+
type StubTypeConstraint = _ObjectType.LazyShaclProperty.Type.StubTypeConstraint;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
type ObjectSetMethodNames = {
|
|
108
|
+
readonly object: string;
|
|
109
|
+
readonly objectsCount: string;
|
|
110
|
+
readonly objectIdentifiers: string;
|
|
111
|
+
readonly objects: string;
|
|
112
|
+
};
|
|
91
113
|
const Property: typeof _ObjectType.Property;
|
|
92
114
|
type Property = _ObjectType.Property<any>;
|
|
93
115
|
const ShaclProperty: typeof _ObjectType.ShaclProperty;
|
|
94
|
-
type ShaclProperty = _ObjectType.ShaclProperty
|
|
116
|
+
type ShaclProperty<TypeT extends Type> = _ObjectType.ShaclProperty<TypeT>;
|
|
95
117
|
const TypeDiscriminatorProperty: typeof _ObjectType.TypeDiscriminatorProperty;
|
|
96
118
|
type TypeDiscriminatorProperty = _ObjectType.TypeDiscriminatorProperty;
|
|
97
119
|
}
|
|
@@ -9,27 +9,27 @@ import { Maybe } from "purify-ts";
|
|
|
9
9
|
import { invariant } from "ts-invariant";
|
|
10
10
|
import { StructureKind, } from "ts-morph";
|
|
11
11
|
import { Memoize } from "typescript-memoize";
|
|
12
|
+
import * as _ObjectType from "./_ObjectType/index.js";
|
|
12
13
|
import { DeclaredType } from "./DeclaredType.js";
|
|
13
14
|
import { Import } from "./Import.js";
|
|
14
15
|
import { SnippetDeclarations } from "./SnippetDeclarations.js";
|
|
15
|
-
import
|
|
16
|
+
import { Type } from "./Type.js";
|
|
16
17
|
import { objectInitializer } from "./objectInitializer.js";
|
|
18
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
17
19
|
export class ObjectType extends DeclaredType {
|
|
20
|
+
imports;
|
|
21
|
+
comment;
|
|
22
|
+
label;
|
|
23
|
+
toRdfTypes;
|
|
18
24
|
abstract;
|
|
19
25
|
declarationType;
|
|
20
|
-
kind = "ObjectType";
|
|
21
|
-
comment;
|
|
22
26
|
extern;
|
|
23
27
|
fromRdfType;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
lazyAncestorObjectTypes
|
|
29
|
-
lazyDescendantObjectTypes;
|
|
30
|
-
lazyParentObjectTypes;
|
|
31
|
-
lazyProperties;
|
|
32
|
-
constructor({ abstract, comment, declarationType, extern, fromRdfType, label, lazyAncestorObjectTypes, lazyDescendantObjectTypes, lazyParentObjectTypes, lazyProperties, imports, identifierMintingStrategy, toRdfTypes, ...superParameters }) {
|
|
28
|
+
kind = "ObjectType";
|
|
29
|
+
staticModuleName;
|
|
30
|
+
synthetic;
|
|
31
|
+
typeof = "object";
|
|
32
|
+
constructor({ abstract, comment, declarationType, extern, fromRdfType, imports, label, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyParentObjectTypes, lazyProperties, staticModuleName, synthetic, toRdfTypes, ...superParameters }) {
|
|
33
33
|
super(superParameters);
|
|
34
34
|
this.abstract = abstract;
|
|
35
35
|
this.comment = comment;
|
|
@@ -40,10 +40,12 @@ export class ObjectType extends DeclaredType {
|
|
|
40
40
|
this.label = label;
|
|
41
41
|
// Lazily initialize some members in getters to avoid recursive construction
|
|
42
42
|
this.lazyAncestorObjectTypes = lazyAncestorObjectTypes;
|
|
43
|
+
this.lazyChildObjectTypes = lazyChildObjectTypes;
|
|
43
44
|
this.lazyDescendantObjectTypes = lazyDescendantObjectTypes;
|
|
44
45
|
this.lazyParentObjectTypes = lazyParentObjectTypes;
|
|
45
46
|
this.lazyProperties = lazyProperties;
|
|
46
|
-
this.
|
|
47
|
+
this.staticModuleName = staticModuleName;
|
|
48
|
+
this.synthetic = synthetic;
|
|
47
49
|
this.toRdfTypes = toRdfTypes;
|
|
48
50
|
}
|
|
49
51
|
get _discriminatorProperty() {
|
|
@@ -51,12 +53,16 @@ export class ObjectType extends DeclaredType {
|
|
|
51
53
|
invariant(discriminatorProperty);
|
|
52
54
|
return {
|
|
53
55
|
name: discriminatorProperty.name,
|
|
54
|
-
|
|
56
|
+
ownValues: discriminatorProperty.type.ownValues,
|
|
57
|
+
descendantValues: discriminatorProperty.type.descendantValues,
|
|
55
58
|
};
|
|
56
59
|
}
|
|
57
60
|
get ancestorObjectTypes() {
|
|
58
61
|
return this.lazyAncestorObjectTypes();
|
|
59
62
|
}
|
|
63
|
+
get childObjectTypes() {
|
|
64
|
+
return this.lazyChildObjectTypes();
|
|
65
|
+
}
|
|
60
66
|
get conversions() {
|
|
61
67
|
return [
|
|
62
68
|
{
|
|
@@ -71,13 +77,15 @@ export class ObjectType extends DeclaredType {
|
|
|
71
77
|
return [];
|
|
72
78
|
}
|
|
73
79
|
const imports = this.properties.flatMap((property) => property.declarationImports);
|
|
74
|
-
if (this.features.has("
|
|
75
|
-
imports.push(Import.
|
|
80
|
+
if (this.features.has("graphql")) {
|
|
81
|
+
imports.push(Import.GRAPHQL);
|
|
82
|
+
imports.push(Import.GRAPHQL_SCALARS);
|
|
76
83
|
}
|
|
77
|
-
if (this.features.has("
|
|
84
|
+
if (this.features.has("json")) {
|
|
85
|
+
imports.push(Import.ZOD);
|
|
78
86
|
imports.push(Import.ZOD_TO_JSON_SCHEMA);
|
|
79
87
|
}
|
|
80
|
-
if (this.features.has("
|
|
88
|
+
if (this.features.has("rdf")) {
|
|
81
89
|
imports.push(Import.PURIFY);
|
|
82
90
|
imports.push(Import.RDFJS_RESOURCE);
|
|
83
91
|
}
|
|
@@ -91,26 +99,25 @@ export class ObjectType extends DeclaredType {
|
|
|
91
99
|
..._ObjectType.classDeclaration.bind(this)().toList(),
|
|
92
100
|
..._ObjectType.interfaceDeclaration.bind(this)().toList(),
|
|
93
101
|
];
|
|
94
|
-
const
|
|
102
|
+
const staticModuleStatements = [
|
|
95
103
|
..._ObjectType.createFunctionDeclaration.bind(this)().toList(),
|
|
96
104
|
..._ObjectType.equalsFunctionDeclaration.bind(this)().toList(),
|
|
97
|
-
..._ObjectType.
|
|
98
|
-
..._ObjectType.
|
|
99
|
-
..._ObjectType.
|
|
100
|
-
..._ObjectType.
|
|
101
|
-
..._ObjectType.
|
|
102
|
-
..._ObjectType.jsonZodSchemaFunctionDeclaration.bind(this)().toList(),
|
|
105
|
+
..._ObjectType.fromRdfTypeVariableStatement.bind(this)().toList(),
|
|
106
|
+
..._ObjectType.graphqlTypeVariableStatement.bind(this)().toList(),
|
|
107
|
+
..._ObjectType.identifierTypeDeclarations.bind(this)(),
|
|
108
|
+
..._ObjectType.jsonTypeAliasDeclaration.bind(this)().toList(),
|
|
109
|
+
..._ObjectType.jsonFunctionDeclarations.bind(this)(),
|
|
103
110
|
..._ObjectType.hashFunctionDeclarations.bind(this)(),
|
|
111
|
+
..._ObjectType.rdfFunctionDeclarations.bind(this)(),
|
|
112
|
+
..._ObjectType.propertiesVariableStatement.bind(this)().toList(),
|
|
104
113
|
..._ObjectType.sparqlFunctionDeclarations.bind(this)(),
|
|
105
|
-
..._ObjectType.toJsonFunctionDeclaration.bind(this)().toList(),
|
|
106
|
-
..._ObjectType.toRdfFunctionDeclaration.bind(this)().toList(),
|
|
107
114
|
];
|
|
108
|
-
if (
|
|
115
|
+
if (staticModuleStatements.length > 0) {
|
|
109
116
|
declarations.push({
|
|
110
117
|
isExported: this.export,
|
|
111
118
|
kind: StructureKind.Module,
|
|
112
|
-
name: this.
|
|
113
|
-
statements:
|
|
119
|
+
name: this.staticModuleName,
|
|
120
|
+
statements: staticModuleStatements,
|
|
114
121
|
});
|
|
115
122
|
}
|
|
116
123
|
return declarations;
|
|
@@ -127,24 +134,18 @@ export class ObjectType extends DeclaredType {
|
|
|
127
134
|
get equalsFunction() {
|
|
128
135
|
switch (this.declarationType) {
|
|
129
136
|
case "class":
|
|
130
|
-
return
|
|
137
|
+
return `((left, right) => left.${syntheticNamePrefix}equals(right))`;
|
|
131
138
|
case "interface":
|
|
132
|
-
return `${this.
|
|
139
|
+
return `${this.staticModuleName}.${syntheticNamePrefix}equals`;
|
|
133
140
|
default:
|
|
134
141
|
throw new RangeError(this.declarationType);
|
|
135
142
|
}
|
|
136
143
|
}
|
|
137
|
-
get
|
|
138
|
-
|
|
139
|
-
this.descendantObjectTypes.length > 0)
|
|
140
|
-
return `hash${this.name}`;
|
|
141
|
-
return "hash";
|
|
144
|
+
get fromRdfTypeVariable() {
|
|
145
|
+
return this.fromRdfType.map(() => `${this.staticModuleName}.${syntheticNamePrefix}fromRdfType`);
|
|
142
146
|
}
|
|
143
|
-
get
|
|
144
|
-
|
|
145
|
-
this.descendantObjectTypes.length > 0)
|
|
146
|
-
return `_hash${this.name}ShaclProperties`;
|
|
147
|
-
return "_hashShaclProperties";
|
|
147
|
+
get graphqlName() {
|
|
148
|
+
return new Type.GraphqlName(`${this.staticModuleName}.${syntheticNamePrefix}GraphQL`);
|
|
148
149
|
}
|
|
149
150
|
get identifierProperty() {
|
|
150
151
|
const identifierProperty = this.properties.find((property) => property instanceof ObjectType.IdentifierProperty);
|
|
@@ -154,37 +155,26 @@ export class ObjectType extends DeclaredType {
|
|
|
154
155
|
get identifierType() {
|
|
155
156
|
return this.identifierProperty.type;
|
|
156
157
|
}
|
|
157
|
-
get
|
|
158
|
-
|
|
159
|
-
switch (this.declarationType) {
|
|
160
|
-
case "class":
|
|
161
|
-
return `ReturnType<${this.name}["toJson"]>`;
|
|
162
|
-
case "interface":
|
|
163
|
-
return `ReturnType<typeof ${this.name}.toJson>`;
|
|
164
|
-
default:
|
|
165
|
-
throw new RangeError(this.declarationType);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (this.features.has("fromJson")) {
|
|
169
|
-
return `Parameters<typeof ${this.name}.fromJson>[0]`;
|
|
170
|
-
}
|
|
171
|
-
throw new RangeError(`${this.name}: jsonName called when neither fromJson nor toJson features are enabled`);
|
|
158
|
+
get identifierTypeAlias() {
|
|
159
|
+
return `${this.staticModuleName}.${syntheticNamePrefix}Identifier`;
|
|
172
160
|
}
|
|
173
|
-
get
|
|
174
|
-
|
|
175
|
-
this.descendantObjectTypes.length > 0)
|
|
176
|
-
return `${camelCase(this.name)}JsonUiSchema`;
|
|
177
|
-
return "jsonUiSchema";
|
|
178
|
-
}
|
|
179
|
-
get jsonZodSchemaFunctionName() {
|
|
180
|
-
if (this.ancestorObjectTypes.length > 0 ||
|
|
181
|
-
this.descendantObjectTypes.length > 0)
|
|
182
|
-
return `${camelCase(this.name)}JsonZodSchema`;
|
|
183
|
-
return "jsonZodSchema";
|
|
161
|
+
get jsonName() {
|
|
162
|
+
return new Type.JsonName(`${this.staticModuleName}.${syntheticNamePrefix}Json`);
|
|
184
163
|
}
|
|
185
164
|
get mutable() {
|
|
186
165
|
return this.properties.some((property) => property.mutable);
|
|
187
166
|
}
|
|
167
|
+
newExpression({ parameters }) {
|
|
168
|
+
switch (this.declarationType) {
|
|
169
|
+
case "class":
|
|
170
|
+
return `new ${this.name}(${parameters})`;
|
|
171
|
+
case "interface":
|
|
172
|
+
return `${this.staticModuleName}.${syntheticNamePrefix}create(${parameters})`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
get objectSetMethodNames() {
|
|
176
|
+
return _ObjectType.objectSetMethodNames.bind(this)();
|
|
177
|
+
}
|
|
188
178
|
get ownProperties() {
|
|
189
179
|
if (this.parentObjectTypes.length === 0) {
|
|
190
180
|
// Consider that a root of the object type hierarchy "owns" the identifier and type discriminator properties
|
|
@@ -201,7 +191,7 @@ export class ObjectType extends DeclaredType {
|
|
|
201
191
|
return this.lazyParentObjectTypes();
|
|
202
192
|
}
|
|
203
193
|
get properties() {
|
|
204
|
-
const properties = this.lazyProperties();
|
|
194
|
+
const properties = this.lazyProperties(this);
|
|
205
195
|
const propertyNames = new Set();
|
|
206
196
|
for (const property of properties) {
|
|
207
197
|
if (propertyNames.has(property.name)) {
|
|
@@ -210,6 +200,12 @@ export class ObjectType extends DeclaredType {
|
|
|
210
200
|
}
|
|
211
201
|
return properties;
|
|
212
202
|
}
|
|
203
|
+
get toRdfjsResourceType() {
|
|
204
|
+
if (this.parentObjectTypes.length > 0) {
|
|
205
|
+
return this.parentObjectTypes[0].toRdfjsResourceType;
|
|
206
|
+
}
|
|
207
|
+
return `rdfjsResource.MutableResource${this.identifierType.isNamedNodeKind ? "<rdfjs.NamedNode>" : ""}`;
|
|
208
|
+
}
|
|
213
209
|
get thisVariable() {
|
|
214
210
|
switch (this.declarationType) {
|
|
215
211
|
case "class":
|
|
@@ -222,79 +218,90 @@ export class ObjectType extends DeclaredType {
|
|
|
222
218
|
}
|
|
223
219
|
fromJsonExpression({ variables, }) {
|
|
224
220
|
// Assumes the JSON object has been recursively validated already.
|
|
225
|
-
return `${this.
|
|
221
|
+
return `${this.staticModuleName}.${syntheticNamePrefix}fromJson(${variables.value}).unsafeCoerce()`;
|
|
226
222
|
}
|
|
227
223
|
fromRdfExpression({ variables, }) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return `${variables.resourceValues}.head().chain(value => value.to${this.rdfjsResourceType().named ? "Named" : ""}Resource()).chain(_resource => ${this.name}.fromRdf({ ...${variables.context}, ignoreRdfType: true, languageIn: ${variables.languageIn}, resource: _resource }))`;
|
|
224
|
+
return `${variables.resourceValues}.chain(values => values.chainMap(value => value.toResource().chain(resource => ${this.staticModuleName}.${syntheticNamePrefix}fromRdf(resource, { ...${variables.context}, ${variables.ignoreRdfType ? "ignoreRdfType: true, " : ""}languageIn: ${variables.languageIn}, objectSet: ${variables.objectSet} }))))`;
|
|
225
|
+
}
|
|
226
|
+
graphqlResolveExpression({ variables, }) {
|
|
227
|
+
return variables.value;
|
|
233
228
|
}
|
|
234
229
|
hashStatements({ variables, }) {
|
|
235
230
|
switch (this.declarationType) {
|
|
236
231
|
case "class":
|
|
237
|
-
return [
|
|
232
|
+
return [
|
|
233
|
+
`${variables.value}.${syntheticNamePrefix}hash(${variables.hasher});`,
|
|
234
|
+
];
|
|
238
235
|
case "interface":
|
|
239
236
|
return [
|
|
240
|
-
`${this.
|
|
237
|
+
`${this.staticModuleName}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
|
|
241
238
|
];
|
|
242
239
|
}
|
|
243
240
|
}
|
|
244
241
|
jsonUiSchemaElement({ variables, }) {
|
|
245
|
-
return Maybe.of(`${this.
|
|
246
|
-
}
|
|
247
|
-
jsonZodSchema(_parameters) {
|
|
248
|
-
return `${this.name}.${this.jsonZodSchemaFunctionName}()`;
|
|
242
|
+
return Maybe.of(`${this.staticModuleName}.${syntheticNamePrefix}jsonUiSchema({ scopePrefix: ${variables.scopePrefix} })`);
|
|
249
243
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
244
|
+
jsonZodSchema({ context, variables, }) {
|
|
245
|
+
let expression = `${this.staticModuleName}.${syntheticNamePrefix}jsonZodSchema()`;
|
|
246
|
+
if (context === "property" &&
|
|
247
|
+
this.properties.some((property) => property.recursive)) {
|
|
248
|
+
expression = `${variables.zod}.lazy((): ${variables.zod}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
|
|
253
249
|
}
|
|
254
|
-
return
|
|
255
|
-
mutable: !!options?.mutable,
|
|
256
|
-
name: `rdfjsResource.${options?.mutable ? "Mutable" : ""}Resource${this.identifierType.isNamedNodeKind ? "<rdfjs.NamedNode>" : ""}`,
|
|
257
|
-
named: this.identifierType.isNamedNodeKind,
|
|
258
|
-
};
|
|
250
|
+
return expression;
|
|
259
251
|
}
|
|
260
|
-
snippetDeclarations() {
|
|
252
|
+
snippetDeclarations({ recursionStack, }) {
|
|
253
|
+
if (recursionStack.some((type) => Object.is(type, this))) {
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
261
256
|
const snippetDeclarations = [];
|
|
262
257
|
if (this.features.has("equals")) {
|
|
263
258
|
snippetDeclarations.push(SnippetDeclarations.EqualsResult);
|
|
264
259
|
}
|
|
265
|
-
if (
|
|
260
|
+
if (this.features.has("rdf")) {
|
|
261
|
+
snippetDeclarations.push(SnippetDeclarations.RdfVocabularies);
|
|
262
|
+
}
|
|
263
|
+
if (this.features.has("sparql") && this.fromRdfType.isJust()) {
|
|
264
|
+
snippetDeclarations.push(SnippetDeclarations.sparqlInstancesOfPattern);
|
|
265
|
+
}
|
|
266
|
+
if ((this.features.has("json") || this.features.has("rdf")) &&
|
|
266
267
|
this.parentObjectTypes.length > 0) {
|
|
267
268
|
snippetDeclarations.push(SnippetDeclarations.UnwrapR);
|
|
268
269
|
}
|
|
270
|
+
recursionStack.push(this);
|
|
269
271
|
for (const property of this.ownProperties) {
|
|
270
|
-
snippetDeclarations.push(...property.snippetDeclarations
|
|
272
|
+
snippetDeclarations.push(...property.snippetDeclarations({
|
|
273
|
+
features: this.features,
|
|
274
|
+
recursionStack,
|
|
275
|
+
}));
|
|
271
276
|
}
|
|
277
|
+
invariant(Object.is(recursionStack.pop(), this));
|
|
272
278
|
return snippetDeclarations;
|
|
273
279
|
}
|
|
274
|
-
sparqlConstructTemplateTriples(
|
|
275
|
-
switch (context) {
|
|
276
|
-
case "
|
|
277
|
-
return super.sparqlConstructTemplateTriples(
|
|
278
|
-
case "
|
|
280
|
+
sparqlConstructTemplateTriples(parameters) {
|
|
281
|
+
switch (parameters.context) {
|
|
282
|
+
case "object":
|
|
283
|
+
return super.sparqlConstructTemplateTriples(parameters);
|
|
284
|
+
case "subject":
|
|
279
285
|
return [
|
|
280
|
-
`...${this.
|
|
281
|
-
ignoreRdfType: true, // Can ignore the rdf:type when the object is nested
|
|
282
|
-
subject: variables.subject,
|
|
283
|
-
variablePrefix: variables.variablePrefix,
|
|
286
|
+
`...${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructTemplateTriples(${objectInitializer({
|
|
287
|
+
ignoreRdfType: parameters.allowIgnoreRdfType ? true : undefined, // Can ignore the rdf:type when the object is nested
|
|
288
|
+
subject: parameters.variables.subject,
|
|
289
|
+
variablePrefix: parameters.variables.variablePrefix,
|
|
284
290
|
})})`,
|
|
285
291
|
];
|
|
286
292
|
}
|
|
287
293
|
}
|
|
288
|
-
sparqlWherePatterns(
|
|
289
|
-
switch (context) {
|
|
290
|
-
case "
|
|
291
|
-
return super.sparqlWherePatterns(
|
|
292
|
-
case "
|
|
294
|
+
sparqlWherePatterns(parameters) {
|
|
295
|
+
switch (parameters.context) {
|
|
296
|
+
case "object":
|
|
297
|
+
return super.sparqlWherePatterns(parameters);
|
|
298
|
+
case "subject":
|
|
293
299
|
return [
|
|
294
|
-
`...${this.
|
|
295
|
-
ignoreRdfType: true, // Can ignore the rdf:type when the object is nested
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
`...${this.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns(${objectInitializer({
|
|
301
|
+
ignoreRdfType: parameters.allowIgnoreRdfType ? true : undefined, // Can ignore the rdf:type when the object is nested
|
|
302
|
+
languageIn: parameters.variables.languageIn,
|
|
303
|
+
subject: parameters.variables.subject,
|
|
304
|
+
variablePrefix: parameters.variables.variablePrefix,
|
|
298
305
|
})})`,
|
|
299
306
|
];
|
|
300
307
|
}
|
|
@@ -302,20 +309,20 @@ export class ObjectType extends DeclaredType {
|
|
|
302
309
|
toJsonExpression({ variables, }) {
|
|
303
310
|
switch (this.declarationType) {
|
|
304
311
|
case "class":
|
|
305
|
-
return `${variables.value}
|
|
312
|
+
return `${variables.value}.${syntheticNamePrefix}toJson()`;
|
|
306
313
|
case "interface":
|
|
307
|
-
return `${this.
|
|
314
|
+
return `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
|
|
308
315
|
}
|
|
309
316
|
}
|
|
310
317
|
toRdfExpression({ variables, }) {
|
|
311
318
|
switch (this.declarationType) {
|
|
312
319
|
case "class":
|
|
313
|
-
return `${variables.value}
|
|
320
|
+
return `${variables.value}.${syntheticNamePrefix}toRdf({ mutateGraph: ${variables.mutateGraph}, resourceSet: ${variables.resourceSet} })`;
|
|
314
321
|
case "interface":
|
|
315
|
-
return `${this.
|
|
322
|
+
return `${this.staticModuleName}.${syntheticNamePrefix}toRdf(${variables.value}, { mutateGraph: ${variables.mutateGraph}, resourceSet: ${variables.resourceSet} })`;
|
|
316
323
|
}
|
|
317
324
|
}
|
|
318
|
-
useImports(
|
|
325
|
+
useImports() {
|
|
319
326
|
return this.imports;
|
|
320
327
|
}
|
|
321
328
|
ensureAtMostOneSuperObjectType() {
|
|
@@ -323,6 +330,11 @@ export class ObjectType extends DeclaredType {
|
|
|
323
330
|
throw new RangeError(`object type '${this.name}' has multiple super object types`);
|
|
324
331
|
}
|
|
325
332
|
}
|
|
333
|
+
lazyAncestorObjectTypes;
|
|
334
|
+
lazyChildObjectTypes;
|
|
335
|
+
lazyDescendantObjectTypes;
|
|
336
|
+
lazyParentObjectTypes;
|
|
337
|
+
lazyProperties;
|
|
326
338
|
}
|
|
327
339
|
__decorate([
|
|
328
340
|
Memoize()
|
|
@@ -332,10 +344,10 @@ __decorate([
|
|
|
332
344
|
], ObjectType.prototype, "ancestorObjectTypes", null);
|
|
333
345
|
__decorate([
|
|
334
346
|
Memoize()
|
|
335
|
-
], ObjectType.prototype, "
|
|
347
|
+
], ObjectType.prototype, "childObjectTypes", null);
|
|
336
348
|
__decorate([
|
|
337
349
|
Memoize()
|
|
338
|
-
], ObjectType.prototype, "
|
|
350
|
+
], ObjectType.prototype, "conversions", null);
|
|
339
351
|
__decorate([
|
|
340
352
|
Memoize()
|
|
341
353
|
], ObjectType.prototype, "descendantObjectTypes", null);
|
|
@@ -350,10 +362,10 @@ __decorate([
|
|
|
350
362
|
], ObjectType.prototype, "equalsFunction", null);
|
|
351
363
|
__decorate([
|
|
352
364
|
Memoize()
|
|
353
|
-
], ObjectType.prototype, "
|
|
365
|
+
], ObjectType.prototype, "fromRdfTypeVariable", null);
|
|
354
366
|
__decorate([
|
|
355
367
|
Memoize()
|
|
356
|
-
], ObjectType.prototype, "
|
|
368
|
+
], ObjectType.prototype, "graphqlName", null);
|
|
357
369
|
__decorate([
|
|
358
370
|
Memoize()
|
|
359
371
|
], ObjectType.prototype, "identifierProperty", null);
|
|
@@ -362,16 +374,16 @@ __decorate([
|
|
|
362
374
|
], ObjectType.prototype, "identifierType", null);
|
|
363
375
|
__decorate([
|
|
364
376
|
Memoize()
|
|
365
|
-
], ObjectType.prototype, "
|
|
377
|
+
], ObjectType.prototype, "identifierTypeAlias", null);
|
|
366
378
|
__decorate([
|
|
367
379
|
Memoize()
|
|
368
|
-
], ObjectType.prototype, "
|
|
380
|
+
], ObjectType.prototype, "jsonName", null);
|
|
369
381
|
__decorate([
|
|
370
382
|
Memoize()
|
|
371
|
-
], ObjectType.prototype, "
|
|
383
|
+
], ObjectType.prototype, "mutable", null);
|
|
372
384
|
__decorate([
|
|
373
385
|
Memoize()
|
|
374
|
-
], ObjectType.prototype, "
|
|
386
|
+
], ObjectType.prototype, "objectSetMethodNames", null);
|
|
375
387
|
__decorate([
|
|
376
388
|
Memoize()
|
|
377
389
|
], ObjectType.prototype, "ownProperties", null);
|
|
@@ -384,12 +396,20 @@ __decorate([
|
|
|
384
396
|
__decorate([
|
|
385
397
|
Memoize()
|
|
386
398
|
], ObjectType.prototype, "properties", null);
|
|
399
|
+
__decorate([
|
|
400
|
+
Memoize()
|
|
401
|
+
], ObjectType.prototype, "toRdfjsResourceType", null);
|
|
387
402
|
__decorate([
|
|
388
403
|
Memoize()
|
|
389
404
|
], ObjectType.prototype, "thisVariable", null);
|
|
405
|
+
__decorate([
|
|
406
|
+
Memoize()
|
|
407
|
+
], ObjectType.prototype, "useImports", null);
|
|
390
408
|
(function (ObjectType) {
|
|
409
|
+
ObjectType.EagerShaclProperty = _ObjectType.EagerShaclProperty;
|
|
391
410
|
ObjectType.IdentifierPrefixProperty = _ObjectType.IdentifierPrefixProperty;
|
|
392
411
|
ObjectType.IdentifierProperty = _ObjectType.IdentifierProperty;
|
|
412
|
+
ObjectType.LazyShaclProperty = _ObjectType.LazyShaclProperty;
|
|
393
413
|
ObjectType.Property = _ObjectType.Property;
|
|
394
414
|
ObjectType.ShaclProperty = _ObjectType.ShaclProperty;
|
|
395
415
|
ObjectType.TypeDiscriminatorProperty = _ObjectType.TypeDiscriminatorProperty;
|