@shaclmate/compiler 4.0.9 → 4.0.11
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.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +4 -1
- package/dist/ast/AbstractCompoundType.js +0 -2
- package/dist/ast/Ast.d.ts +1 -1
- package/dist/ast/IntersectionType.js +4 -3
- package/dist/ast/UnionType.js +3 -2
- package/dist/generators/json/AstJsonGenerator.js +1 -1
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +2 -2
- package/dist/generators/ts/AbstractContainerType.d.ts +2 -2
- package/dist/generators/ts/AbstractContainerType.js +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +3 -3
- package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.js +17 -15
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractNumericType.js +1 -1
- package/dist/generators/ts/AbstractType.d.ts +5 -5
- package/dist/generators/ts/AbstractUnionType.d.ts +1 -1
- package/dist/generators/ts/AbstractUnionType.js +6 -6
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +2 -2
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +2 -2
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +1 -1
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +1 -1
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +1 -1
- package/dist/generators/ts/DefaultValueType.js +3 -3
- package/dist/generators/ts/IdentifierType.d.ts +1 -1
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +1 -1
- package/dist/generators/ts/IriType.js +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +1 -1
- package/dist/generators/ts/LazyObjectType.js +2 -2
- package/dist/generators/ts/ListType.d.ts +2 -2
- package/dist/generators/ts/ListType.js +1 -1
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +1 -1
- package/dist/generators/ts/{ObjectType.d.ts → NamedObjectType.d.ts} +28 -28
- package/dist/generators/ts/{ObjectType.js → NamedObjectType.js} +105 -97
- package/dist/generators/ts/NamedObjectUnionType.d.ts +4 -4
- package/dist/generators/ts/NamedObjectUnionType.js +8 -12
- package/dist/generators/ts/OptionType.d.ts +1 -1
- package/dist/generators/ts/OptionType.js +2 -2
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/StringType.js +1 -1
- package/dist/generators/ts/TermType.d.ts +1 -1
- package/dist/generators/ts/TermType.js +1 -1
- package/dist/generators/ts/TsGenerator.js +8 -8
- package/dist/generators/ts/Type.d.ts +2 -2
- package/dist/generators/ts/TypeFactory.d.ts +2 -2
- package/dist/generators/ts/TypeFactory.js +36 -36
- package/dist/generators/ts/ZodGenerator.js +14 -12
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.d.ts +6 -6
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/DiscriminantProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/DiscriminantProperty.js +13 -11
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.js +4 -4
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.js +24 -24
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_classDeclaration.js → _NamedObjectType/NamedObjectType_classDeclaration.js} +14 -14
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_createFunctionDeclaration.js → _NamedObjectType/NamedObjectType_createFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterFunctionDeclaration.js → _NamedObjectType/NamedObjectType_filterFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterTypeDeclaration.js → _NamedObjectType/NamedObjectType_filterTypeDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromJsonFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfTypeVariableStatement.js → _NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_graphqlTypeVariableStatement.js → _NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.js → _NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_interfaceDeclaration.js → _NamedObjectType/NamedObjectType_interfaceDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_isTypeFunctionDeclaration.js → _NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonTypeAliasDeclaration.js → _NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_objectSetMethodNames.js → _NamedObjectType/NamedObjectType_objectSetMethodNames.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.js → _NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.js → _NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_schemaVariableStatement.js → _NamedObjectType/NamedObjectType_schemaVariableStatement.js} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.js +8 -8
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +23 -23
- package/dist/generators/ts/objectSetDeclarations.d.ts +2 -2
- package/dist/generators/ts/objectSetDeclarations.js +19 -16
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +3 -3
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +6 -4
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +4 -4
- package/dist/generators/ts/objectSetMethodSignatures.js +9 -9
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +47 -45
- package/dist/generators/ts/singleEntryRecord.d.ts +2 -0
- package/dist/generators/ts/singleEntryRecord.js +6 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +17 -17
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -2
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +8 -8
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +5 -5
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +2 -2
- package/package.json +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +0 -9
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.d.ts +0 -0
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/identifierTypeDeclarations.js +0 -0
|
@@ -74,7 +74,7 @@ export class ShapesGraphToAstTransformer {
|
|
|
74
74
|
}
|
|
75
75
|
return Either.of({
|
|
76
76
|
namedIntersectionTypes: astNamedIntersectionTypes,
|
|
77
|
-
|
|
77
|
+
namedObjectTypes: astObjectTypes.concat(Object.values(syntheticAstObjectTypesByName)),
|
|
78
78
|
namedUnionTypes: astNamedUnionTypes,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
@@ -137,7 +137,10 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
137
137
|
case "ObjectType":
|
|
138
138
|
return Either.of(astResolveType);
|
|
139
139
|
case "UnionType":
|
|
140
|
-
if (
|
|
140
|
+
if (
|
|
141
|
+
// This check relies on .members being populated, which may not happen in cycles
|
|
142
|
+
astResolveType.members.length > 0 &&
|
|
143
|
+
!astResolveType.isObjectUnionType()) {
|
|
141
144
|
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-ObjectType members`));
|
|
142
145
|
}
|
|
143
146
|
return Either.of(astResolveType);
|
|
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { invariant } from "ts-invariant";
|
|
8
7
|
import { Memoize } from "typescript-memoize";
|
|
9
8
|
import { AbstractType } from "./AbstractType.js";
|
|
10
9
|
/**
|
|
@@ -29,7 +28,6 @@ export class AbstractCompoundType extends AbstractType {
|
|
|
29
28
|
this.#tsFeatures = tsFeatures;
|
|
30
29
|
}
|
|
31
30
|
get members() {
|
|
32
|
-
invariant(this.#members.length > 0);
|
|
33
31
|
return this.#members;
|
|
34
32
|
}
|
|
35
33
|
get recursive() {
|
package/dist/ast/Ast.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ObjectType } from "./ObjectType.js";
|
|
|
3
3
|
import type { UnionType } from "./UnionType.js";
|
|
4
4
|
export interface Ast {
|
|
5
5
|
readonly namedIntersectionTypes: readonly IntersectionType[];
|
|
6
|
+
readonly namedObjectTypes: readonly ObjectType[];
|
|
6
7
|
readonly namedUnionTypes: readonly UnionType[];
|
|
7
|
-
readonly objectTypes: readonly ObjectType[];
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=Ast.d.ts.map
|
|
@@ -5,9 +5,10 @@ import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
|
5
5
|
export class IntersectionType extends AbstractCompoundType {
|
|
6
6
|
kind = "IntersectionType";
|
|
7
7
|
isObjectIntersectionType() {
|
|
8
|
-
return this.members.
|
|
9
|
-
(member.type.kind === "
|
|
10
|
-
member.type.
|
|
8
|
+
return (this.members.length > 0 &&
|
|
9
|
+
this.members.every((member) => member.type.kind === "ObjectType" ||
|
|
10
|
+
(member.type.kind === "IntersectionType" &&
|
|
11
|
+
member.type.isObjectIntersectionType())));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
(function (IntersectionType) {
|
package/dist/ast/UnionType.js
CHANGED
|
@@ -5,8 +5,9 @@ import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
|
5
5
|
export class UnionType extends AbstractCompoundType {
|
|
6
6
|
kind = "UnionType";
|
|
7
7
|
isObjectUnionType() {
|
|
8
|
-
return this.members.
|
|
9
|
-
(member.type.kind === "
|
|
8
|
+
return (this.members.length > 0 &&
|
|
9
|
+
this.members.every((member) => member.type.kind === "ObjectType" ||
|
|
10
|
+
(member.type.kind === "UnionType" && member.type.isObjectUnionType())));
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
(function (UnionType) {
|
|
@@ -116,7 +116,7 @@ function typeToJson(type) {
|
|
|
116
116
|
export class AstJsonGenerator {
|
|
117
117
|
generate(ast) {
|
|
118
118
|
return JSON.stringify({
|
|
119
|
-
objectTypes: ast.
|
|
119
|
+
objectTypes: ast.namedObjectTypes.map((objectType) => ({
|
|
120
120
|
kind: objectType.kind,
|
|
121
121
|
comment: objectType.comment.extract(),
|
|
122
122
|
identifierMintingStrategy: objectType.identifierMintingStrategy.extract(),
|
|
@@ -31,7 +31,7 @@ export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractC
|
|
|
31
31
|
graphqlResolveExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
|
|
32
32
|
hashStatements({ depth, variables, }: Parameters<AbstractContainerType<ItemTypeT>["hashStatements"]>[0]): readonly Code[];
|
|
33
33
|
jsonUiSchemaElement(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
34
|
-
|
|
34
|
+
jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
|
|
35
35
|
toJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["toJsonExpression"]>[0]): Code;
|
|
36
36
|
}
|
|
37
37
|
export declare namespace AbstractCollectionType {
|
|
@@ -190,8 +190,8 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
190
190
|
jsonUiSchemaElement(parameters) {
|
|
191
191
|
return this.itemType.jsonUiSchemaElement(parameters);
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
let schema = code `${this.itemType.
|
|
193
|
+
jsonSchema(parameters) {
|
|
194
|
+
let schema = code `${this.itemType.jsonSchema(parameters)}.array()`;
|
|
195
195
|
if (this.minCount > 0) {
|
|
196
196
|
schema = code `${schema}.nonempty().min(${this.minCount})`;
|
|
197
197
|
}
|
|
@@ -13,9 +13,9 @@ import type { IntType } from "./IntType.js";
|
|
|
13
13
|
import type { IriType } from "./IriType.js";
|
|
14
14
|
import type { ListType } from "./ListType.js";
|
|
15
15
|
import type { LiteralType } from "./LiteralType.js";
|
|
16
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
16
17
|
import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
17
18
|
import type { NamedUnionType } from "./NamedUnionType.js";
|
|
18
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
19
19
|
import type { StringType } from "./StringType.js";
|
|
20
20
|
import type { TermType } from "./TermType.js";
|
|
21
21
|
import type { Type } from "./Type.js";
|
|
@@ -48,7 +48,7 @@ export declare namespace AbstractContainerType {
|
|
|
48
48
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
49
49
|
const GraphqlType: typeof AbstractType.GraphqlType;
|
|
50
50
|
type GraphqlType = AbstractType.GraphqlType;
|
|
51
|
-
type ItemType = AnonymousUnionType | BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | NamedObjectUnionType | NamedUnionType |
|
|
51
|
+
type ItemType = AnonymousUnionType | BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | NamedObjectUnionType | NamedUnionType | NamedObjectType | StringType | TermType;
|
|
52
52
|
function isItemType(type: Type): type is ItemType;
|
|
53
53
|
const JsonType: typeof AbstractType.JsonType;
|
|
54
54
|
type JsonType = AbstractType.JsonType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe, NonEmptyList } from "purify-ts";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
3
4
|
import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
4
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
5
5
|
import type { OptionType } from "./OptionType.js";
|
|
6
6
|
import type { SetType } from "./SetType.js";
|
|
7
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
@@ -41,7 +41,7 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
41
41
|
hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
42
42
|
jsonType(parameters?: Parameters<AbstractType["jsonType"]>[0]): AbstractType.JsonType;
|
|
43
43
|
jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
44
|
-
|
|
44
|
+
jsonSchema(parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
45
45
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
46
46
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
47
47
|
protected resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }: {
|
|
@@ -53,7 +53,7 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
53
53
|
}): Code;
|
|
54
54
|
}
|
|
55
55
|
export declare namespace AbstractLazyObjectType {
|
|
56
|
-
type ObjectTypeConstraint =
|
|
56
|
+
type ObjectTypeConstraint = NamedObjectType | NamedObjectUnionType;
|
|
57
57
|
type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
|
|
58
58
|
type ResolveTypeConstraint = PartialTypeConstraint;
|
|
59
59
|
type Conversion = AbstractType.Conversion;
|
|
@@ -92,8 +92,8 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
92
92
|
jsonUiSchemaElement(parameters) {
|
|
93
93
|
return this.partialType.jsonUiSchemaElement(parameters);
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
return this.partialType.
|
|
95
|
+
jsonSchema(parameters) {
|
|
96
|
+
return this.partialType.jsonSchema(parameters);
|
|
97
97
|
}
|
|
98
98
|
toJsonExpression({ variables, }) {
|
|
99
99
|
return this.partialType.toJsonExpression({
|
|
@@ -16,7 +16,7 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
|
|
|
16
16
|
get filterFunction(): Code;
|
|
17
17
|
get filterType(): Code;
|
|
18
18
|
get jsonTypeAliasDeclaration(): Code;
|
|
19
|
-
get
|
|
19
|
+
get jsonSchemaFunctionDeclaration(): Code;
|
|
20
20
|
get name(): string;
|
|
21
21
|
get staticModuleName(): string;
|
|
22
22
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
@@ -26,7 +26,7 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
|
|
|
26
26
|
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
27
27
|
hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
28
28
|
jsonType(): AbstractType.JsonType;
|
|
29
|
-
|
|
29
|
+
jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
30
30
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
31
31
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
32
32
|
}
|
|
@@ -50,8 +50,8 @@ ${joinCode(staticModuleDeclarations
|
|
|
50
50
|
get jsonTypeAliasDeclaration() {
|
|
51
51
|
return code `export type ${syntheticNamePrefix}Json = ${this.inlineJsonType.name}`;
|
|
52
52
|
}
|
|
53
|
-
get
|
|
54
|
-
return code `export const
|
|
53
|
+
get jsonSchemaFunctionDeclaration() {
|
|
54
|
+
return code `export const schema = () => ${this.inlineJsonSchema};`;
|
|
55
55
|
}
|
|
56
56
|
get name() {
|
|
57
57
|
return this._name;
|
|
@@ -86,18 +86,20 @@ ${joinCode(staticModuleDeclarations
|
|
|
86
86
|
code `export function ${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(value: ${this._name}, hasher: HasherT): HasherT { ${this.inlineHashStatements({ depth: 0, variables: { hasher: code `hasher`, value: code `value` } })} return hasher; }`;
|
|
87
87
|
}
|
|
88
88
|
if (this.features.has("json")) {
|
|
89
|
-
staticModuleDeclarations[`${syntheticNamePrefix}Json`] =
|
|
90
|
-
|
|
89
|
+
staticModuleDeclarations[`${syntheticNamePrefix}Json`] = code `\
|
|
90
|
+
${this.jsonTypeAliasDeclaration}
|
|
91
|
+
|
|
92
|
+
export namespace ${syntheticNamePrefix}Json {
|
|
93
|
+
${this.jsonSchemaFunctionDeclaration}
|
|
94
|
+
|
|
95
|
+
export function ${syntheticNamePrefix}parse(json: unknown): ${imports.Either}<Error, ${syntheticNamePrefix}Json> {
|
|
96
|
+
const jsonSafeParseResult = schema().safeParse(json);
|
|
97
|
+
if (!jsonSafeParseResult.success) { return ${imports.Left}(jsonSafeParseResult.error); }
|
|
98
|
+
return ${imports.Right}(jsonSafeParseResult.data);
|
|
99
|
+
}
|
|
100
|
+
}`;
|
|
91
101
|
staticModuleDeclarations[`${syntheticNamePrefix}fromJson`] =
|
|
92
102
|
code `export const ${syntheticNamePrefix}fromJson = ${this.inlineFromJsonFunction};`;
|
|
93
|
-
staticModuleDeclarations[`${syntheticNamePrefix}jsonZodSchema`] =
|
|
94
|
-
this.jsonZodSchemaFunctionDeclaration;
|
|
95
|
-
staticModuleDeclarations[`${syntheticNamePrefix}parseJson`] = code `\
|
|
96
|
-
export function ${syntheticNamePrefix}parseJson(json: unknown): ${imports.Either}<Error, ${this.name}> {
|
|
97
|
-
const ${syntheticNamePrefix}jsonSafeParseResult = ${syntheticNamePrefix}jsonZodSchema().safeParse(json);
|
|
98
|
-
if (!${syntheticNamePrefix}jsonSafeParseResult.success) { return ${imports.Left}(${syntheticNamePrefix}jsonSafeParseResult.error); }
|
|
99
|
-
return ${imports.Right}(${syntheticNamePrefix}fromJson(${syntheticNamePrefix}jsonSafeParseResult.data));
|
|
100
|
-
}`;
|
|
101
103
|
staticModuleDeclarations[`${syntheticNamePrefix}toJson`] =
|
|
102
104
|
code `export const ${syntheticNamePrefix}toJson = ${this.inlineToJsonFunction};`;
|
|
103
105
|
}
|
|
@@ -142,15 +144,15 @@ export function ${syntheticNamePrefix}parseJson(json: unknown): ${imports.Either
|
|
|
142
144
|
}
|
|
143
145
|
return this.inlineJsonType;
|
|
144
146
|
}
|
|
145
|
-
|
|
147
|
+
jsonSchema({ context, }) {
|
|
146
148
|
if (this.features.has("json")) {
|
|
147
|
-
const expression = code `${this.staticModuleName}.${syntheticNamePrefix}
|
|
149
|
+
const expression = code `${this.staticModuleName}.${syntheticNamePrefix}Json.schema()`;
|
|
148
150
|
if (context === "property" && this.recursive) {
|
|
149
151
|
return code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
|
|
150
152
|
}
|
|
151
153
|
return expression;
|
|
152
154
|
}
|
|
153
|
-
return this.
|
|
155
|
+
return this.inlineJsonSchema;
|
|
154
156
|
}
|
|
155
157
|
toJsonExpression({ variables, }) {
|
|
156
158
|
if (this.features.has("json")) {
|
|
@@ -15,7 +15,7 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
|
|
|
15
15
|
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
16
16
|
kind: Code;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
|
|
19
19
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
20
20
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>;
|
|
21
21
|
protected abstract fromRdfResourceValueExpression(variables: {
|
|
@@ -127,7 +127,7 @@ export declare abstract class AbstractType {
|
|
|
127
127
|
* An expression that converts a Either<Error, rdfjsResource.Resource.Values> to a
|
|
128
128
|
* Either<Error, rdfjsResource.Resource.Values<this type>>.
|
|
129
129
|
*
|
|
130
|
-
* These expressions are used to deserialize property values in an
|
|
130
|
+
* These expressions are used to deserialize property values in an NamedObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
|
|
131
131
|
* that has a type parameter of this Type).
|
|
132
132
|
*
|
|
133
133
|
* Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
|
|
@@ -136,7 +136,7 @@ export declare abstract class AbstractType {
|
|
|
136
136
|
* Values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
|
|
137
137
|
* (if it exists) is always of the first preferred language.
|
|
138
138
|
*
|
|
139
|
-
* variables are runtime variables, most derived from the parameters of the
|
|
139
|
+
* variables are runtime variables, most derived from the parameters of the NamedObjectType's fromRdf function:
|
|
140
140
|
* context: unanticipated properties (...) passed to Object.fromRdf
|
|
141
141
|
* graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
|
|
142
142
|
* ignoreRdfType: whether the RDF type of objects/object unions should be ignored
|
|
@@ -195,12 +195,12 @@ export declare abstract class AbstractType {
|
|
|
195
195
|
* Zod schema for the JSON type of this type.
|
|
196
196
|
*
|
|
197
197
|
* This method is called in two contexts:
|
|
198
|
-
* "property": from a ShaclProperty, while generating the z.object properties of an
|
|
198
|
+
* "property": from a ShaclProperty, while generating the z.object properties of an NamedObjectType
|
|
199
199
|
* "type": from another Type e.g., an OptionType or UnionType
|
|
200
200
|
*
|
|
201
201
|
* z.lazy() should only be returned for "property".
|
|
202
202
|
*/
|
|
203
|
-
abstract
|
|
203
|
+
abstract jsonSchema(parameters: {
|
|
204
204
|
includeDiscriminantProperty?: boolean;
|
|
205
205
|
context: "property" | "type";
|
|
206
206
|
}): Code;
|
|
@@ -218,7 +218,7 @@ export declare abstract class AbstractType {
|
|
|
218
218
|
* An expression that converts a property value of this type to a value or an array of values that can be .add'd to a Resource with
|
|
219
219
|
* resource.add(predicate, convertedValue, graph)
|
|
220
220
|
*
|
|
221
|
-
* variables are runtime variables, most derived from the parameters of the
|
|
221
|
+
* variables are runtime variables, most derived from the parameters of the NamedObjectType's fromRdf function:
|
|
222
222
|
* graph: DefaultGraph | NamedNode | undefined to .add to; if undefined, add to the default graph
|
|
223
223
|
* propertyPath: predicate path (NamedNode) or InversePath on a predicate path
|
|
224
224
|
* resource: the Resource to .add to
|
|
@@ -32,7 +32,7 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
|
|
|
32
32
|
protected get inlineFromJsonFunction(): Code;
|
|
33
33
|
protected get inlineFromRdfResourceValuesFunction(): Code;
|
|
34
34
|
protected get inlineJsonType(): AbstractType.JsonType;
|
|
35
|
-
protected get
|
|
35
|
+
protected get inlineJsonSchema(): Code;
|
|
36
36
|
protected get inlineName(): Code;
|
|
37
37
|
protected get inlineValueSparqlConstructTriplesFunction(): Code;
|
|
38
38
|
protected get inlineValueSparqlWherePatternsFunction(): Code;
|
|
@@ -87,7 +87,7 @@ export class AbstractUnionType extends AbstractType {
|
|
|
87
87
|
switch (member.type.kind) {
|
|
88
88
|
case "NamedObjectUnionType":
|
|
89
89
|
case "NamedUnionType":
|
|
90
|
-
case "
|
|
90
|
+
case "NamedObjectType":
|
|
91
91
|
return code `${member.type.staticModuleName}.is${member.type.name}(${instance})`;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -288,17 +288,17 @@ ${joinCode(this.concreteMembers.map(({ jsonTypeCheck, type, unwrap, wrap }) => c
|
|
|
288
288
|
throw this.discriminant;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
get
|
|
291
|
+
get inlineJsonSchema() {
|
|
292
292
|
switch (this.discriminant.kind) {
|
|
293
293
|
case "envelope":
|
|
294
|
-
return code `${imports.z}.discriminatedUnion("${this.discriminant.name}", [${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `${imports.z}.object({ ${this.discriminant.name}: ${imports.z}.literal(${literalOf(primaryDiscriminantValue)}), value: ${type.
|
|
294
|
+
return code `${imports.z}.discriminatedUnion("${this.discriminant.name}", [${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `${imports.z}.object({ ${this.discriminant.name}: ${imports.z}.literal(${literalOf(primaryDiscriminantValue)}), value: ${type.jsonSchema({ context: "type" })} })`), { on: "," })}])`;
|
|
295
295
|
case "inline":
|
|
296
|
-
return code `${imports.z}.discriminatedUnion("${this.discriminant.name}", [${joinCode(this.concreteMembers.map(({ type }) => type.
|
|
296
|
+
return code `${imports.z}.discriminatedUnion("${this.discriminant.name}", [${joinCode(this.concreteMembers.map(({ type }) => type.jsonSchema({
|
|
297
297
|
includeDiscriminantProperty: true,
|
|
298
298
|
context: "type",
|
|
299
299
|
})), { on: "," })}])`;
|
|
300
300
|
case "typeof":
|
|
301
|
-
return code `${imports.z}.union([${joinCode(this.concreteMembers.map(({ type }) => type.
|
|
301
|
+
return code `${imports.z}.union([${joinCode(this.concreteMembers.map(({ type }) => type.jsonSchema({ context: "type" })), { on: "," })}])`;
|
|
302
302
|
default:
|
|
303
303
|
throw this.discriminant;
|
|
304
304
|
}
|
|
@@ -308,7 +308,7 @@ ${joinCode(this.concreteMembers.map(({ jsonTypeCheck, type, unwrap, wrap }) => c
|
|
|
308
308
|
case "envelope":
|
|
309
309
|
return code `(${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `{ ${this.discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.name} }`), { on: "|" })})`;
|
|
310
310
|
case "inline":
|
|
311
|
-
// If every type shares a discriminant (e.g., RDF/JS "termType" or generated
|
|
311
|
+
// If every type shares a discriminant (e.g., RDF/JS "termType" or generated NamedObjectType "type"),
|
|
312
312
|
// just join their names with "|"
|
|
313
313
|
return code `(${joinCode(this.members.map(({ type }) => code `${type.name}`), { on: "|" })})`;
|
|
314
314
|
case "typeof":
|
|
@@ -19,7 +19,7 @@ export declare class AnonymousUnionType extends AbstractUnionType<Type> {
|
|
|
19
19
|
graphqlResolveExpression(_parameters: Parameters<AbstractType["graphqlResolveExpression"]>[0]): Code;
|
|
20
20
|
hashStatements(parameters: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
21
21
|
jsonType(): AbstractType.JsonType;
|
|
22
|
-
|
|
22
|
+
jsonSchema(_parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
23
23
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
24
24
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
25
25
|
}
|
|
@@ -42,8 +42,8 @@ export class AnonymousUnionType extends AbstractUnionType {
|
|
|
42
42
|
jsonType() {
|
|
43
43
|
return this.inlineJsonType;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
return this.
|
|
45
|
+
jsonSchema(_parameters) {
|
|
46
|
+
return this.inlineJsonSchema;
|
|
47
47
|
}
|
|
48
48
|
toJsonExpression({ variables, }) {
|
|
49
49
|
return code `${this.inlineToJsonFunction}(${variables.value})`;
|
|
@@ -13,7 +13,7 @@ export declare class BigDecimalType extends AbstractLiteralType {
|
|
|
13
13
|
graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
14
14
|
hashStatements({ variables, }: Parameters<AbstractLiteralType["hashStatements"]>[0]): readonly Code[];
|
|
15
15
|
jsonType(): AbstractLiteralType.JsonType;
|
|
16
|
-
|
|
16
|
+
jsonSchema(): Code;
|
|
17
17
|
toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
18
18
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractLiteralType["fromRdfExpressionChain"]>[0]): ReturnType<AbstractLiteralType["fromRdfExpressionChain"]>;
|
|
19
19
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractLiteralType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
@@ -63,7 +63,7 @@ export class BigDecimalType extends AbstractLiteralType {
|
|
|
63
63
|
jsonType() {
|
|
64
64
|
return new AbstractLiteralType.JsonType("string");
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
jsonSchema() {
|
|
67
67
|
return code `${imports.z}.string()`;
|
|
68
68
|
}
|
|
69
69
|
toJsonExpression({ variables, }) {
|
|
@@ -87,5 +87,5 @@ __decorate([
|
|
|
87
87
|
], BigDecimalType.prototype, "jsonType", null);
|
|
88
88
|
__decorate([
|
|
89
89
|
Memoize()
|
|
90
|
-
], BigDecimalType.prototype, "
|
|
90
|
+
], BigDecimalType.prototype, "jsonSchema", null);
|
|
91
91
|
//# sourceMappingURL=BigDecimalType.js.map
|
|
@@ -6,7 +6,7 @@ export declare class BigIntType extends AbstractNumericType<bigint> {
|
|
|
6
6
|
readonly kind = "BigIntType";
|
|
7
7
|
readonly typeofs: NonEmptyList<"bigint">;
|
|
8
8
|
fromJsonExpression({ variables, }: Parameters<AbstractNumericType<bigint>["fromJsonExpression"]>[0]): Code;
|
|
9
|
-
|
|
9
|
+
jsonSchema(_parameters: Parameters<AbstractNumericType<bigint>["jsonSchema"]>[0]): Code;
|
|
10
10
|
jsonType(): AbstractNumericType.JsonType;
|
|
11
11
|
toJsonExpression({ variables, }: Parameters<AbstractNumericType<bigint>["toJsonExpression"]>[0]): Code;
|
|
12
12
|
protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractNumericType<bigint>["fromRdfResourceValueExpression"]>[0]): Code;
|
|
@@ -14,7 +14,7 @@ export declare class BlankNodeType extends AbstractIdentifierType<BlankNode> {
|
|
|
14
14
|
constructor(superParameters: Pick<ConstructorParameters<typeof AbstractIdentifierType<BlankNode>>[0], "comment" | "label">);
|
|
15
15
|
fromJsonExpression({ variables, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["fromJsonExpression"]>[0]): Code;
|
|
16
16
|
jsonType(parameters?: Parameters<AbstractTermType["jsonType"]>[0]): AbstractTermType.JsonType;
|
|
17
|
-
|
|
17
|
+
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["jsonSchema"]>[0]): Code;
|
|
18
18
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["toJsonExpression"]>[0]): Code;
|
|
19
19
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractTermType["fromRdfExpressionChain"]>[0]): {
|
|
20
20
|
valueTo: Code;
|
|
@@ -35,7 +35,7 @@ export class BlankNodeType extends AbstractIdentifierType {
|
|
|
35
35
|
: "";
|
|
36
36
|
return new AbstractTermType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
jsonSchema({ includeDiscriminantProperty, }) {
|
|
39
39
|
const discriminantProperty = includeDiscriminantProperty
|
|
40
40
|
? code `, termType: ${imports.z}.literal("BlankNode")`
|
|
41
41
|
: "";
|
|
@@ -15,7 +15,7 @@ export declare class BooleanType extends AbstractPrimitiveType<boolean> {
|
|
|
15
15
|
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
16
16
|
kind: Code;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
jsonSchema(_parameters: Parameters<AbstractPrimitiveType<number>["jsonSchema"]>[0]): Code;
|
|
19
19
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<boolean>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
20
20
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<boolean>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<boolean>["fromRdfExpressionChain"]>;
|
|
21
21
|
}
|
|
@@ -31,7 +31,7 @@ export class BooleanType extends AbstractPrimitiveType {
|
|
|
31
31
|
in: this.primitiveIn.length > 0 ? this.primitiveIn.concat() : undefined,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
jsonSchema(_parameters) {
|
|
35
35
|
if (this.primitiveIn.length === 1) {
|
|
36
36
|
return code `${imports.z}.literal(${this.primitiveIn[0]})`;
|
|
37
37
|
}
|
|
@@ -3,7 +3,7 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
3
3
|
export declare class DateTimeType extends AbstractDateType {
|
|
4
4
|
readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
|
|
5
5
|
readonly kind = "DateTimeType";
|
|
6
|
-
|
|
6
|
+
jsonSchema(_parameters: Parameters<AbstractDateType["jsonSchema"]>[0]): Code;
|
|
7
7
|
toJsonExpression({ variables, }: Parameters<AbstractDateType["toJsonExpression"]>[0]): Code;
|
|
8
8
|
protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractDateType["fromRdfResourceValueExpression"]>[0]): Code;
|
|
9
9
|
}
|
|
@@ -4,7 +4,7 @@ import { code } from "./ts-poet-wrapper.js";
|
|
|
4
4
|
export class DateTimeType extends AbstractDateType {
|
|
5
5
|
graphqlType = new AbstractDateType.GraphqlType(code `${imports.GraphQLDateTime}`);
|
|
6
6
|
kind = "DateTimeType";
|
|
7
|
-
|
|
7
|
+
jsonSchema(_parameters) {
|
|
8
8
|
return code `${imports.z}.iso.datetime()`;
|
|
9
9
|
}
|
|
10
10
|
toJsonExpression({ variables, }) {
|
|
@@ -4,7 +4,7 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
4
4
|
export declare class DateType extends AbstractDateType {
|
|
5
5
|
readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
|
|
6
6
|
readonly kind = "DateType";
|
|
7
|
-
|
|
7
|
+
jsonSchema(_parameters: Parameters<DateTimeType["jsonSchema"]>[0]): Code;
|
|
8
8
|
toJsonExpression({ variables, }: Parameters<AbstractDateType["toJsonExpression"]>[0]): Code;
|
|
9
9
|
protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractDateType["fromRdfResourceValueExpression"]>[0]): Code;
|
|
10
10
|
}
|
|
@@ -5,7 +5,7 @@ import { code } from "./ts-poet-wrapper.js";
|
|
|
5
5
|
export class DateType extends AbstractDateType {
|
|
6
6
|
graphqlType = new DateTimeType.GraphqlType(code `${imports.GraphQLDate}`);
|
|
7
7
|
kind = "DateType";
|
|
8
|
-
|
|
8
|
+
jsonSchema(_parameters) {
|
|
9
9
|
return code `${imports.z}.iso.date()`;
|
|
10
10
|
}
|
|
11
11
|
toJsonExpression({ variables, }) {
|
|
@@ -37,7 +37,7 @@ export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemTyp
|
|
|
37
37
|
hashStatements(parameters: Parameters<AbstractContainerType<ItemTypeT>["hashStatements"]>[0]): readonly Code[];
|
|
38
38
|
jsonType(parameters?: Parameters<AbstractContainerType<ItemTypeT>["jsonType"]>[0]): AbstractType.JsonType;
|
|
39
39
|
jsonUiSchemaElement(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
40
|
-
|
|
40
|
+
jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
|
|
41
41
|
toJsonExpression(parameters: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
42
42
|
toRdfResourceValuesExpression(parameters: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
43
43
|
}
|
|
@@ -104,7 +104,7 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
104
104
|
return Maybe.of(this.defaultValueTermExpression);
|
|
105
105
|
case "AnonymousUnionType":
|
|
106
106
|
case "ListType":
|
|
107
|
-
case "
|
|
107
|
+
case "NamedObjectType":
|
|
108
108
|
case "NamedObjectUnionType":
|
|
109
109
|
case "NamedUnionType":
|
|
110
110
|
return Maybe.empty();
|
|
@@ -139,8 +139,8 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
139
139
|
jsonUiSchemaElement(parameters) {
|
|
140
140
|
return this.itemType.jsonUiSchemaElement(parameters);
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
return this.itemType.
|
|
142
|
+
jsonSchema(parameters) {
|
|
143
|
+
return this.itemType.jsonSchema(parameters);
|
|
144
144
|
}
|
|
145
145
|
toJsonExpression(parameters) {
|
|
146
146
|
return this.itemType.toJsonExpression(parameters);
|
|
@@ -15,7 +15,7 @@ export declare class IdentifierType extends AbstractIdentifierType<BlankNode | N
|
|
|
15
15
|
constructor(parameters: Pick<ConstructorParameters<typeof AbstractIdentifierType<BlankNode | NamedNode>>[0], "comment" | "label">);
|
|
16
16
|
fromJsonExpression({ variables, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["fromJsonExpression"]>[0]): Code;
|
|
17
17
|
jsonType(parameters?: Parameters<AbstractTermType["jsonType"]>[0]): AbstractTermType.JsonType;
|
|
18
|
-
|
|
18
|
+
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["jsonSchema"]>[0]): Code;
|
|
19
19
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["toJsonExpression"]>[0]): Code;
|
|
20
20
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractTermType["fromRdfExpressionChain"]>[0]): ReturnType<AbstractTermType["fromRdfExpressionChain"]>;
|
|
21
21
|
}
|
|
@@ -36,7 +36,7 @@ export class IdentifierType extends AbstractIdentifierType {
|
|
|
36
36
|
: "";
|
|
37
37
|
return new AbstractTermType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
jsonSchema({ includeDiscriminantProperty, }) {
|
|
40
40
|
const discriminantProperty = includeDiscriminantProperty
|
|
41
41
|
? code `, termType: ${imports.z}.enum(${arrayOf(...this.nodeKinds)})`
|
|
42
42
|
: "";
|
|
@@ -17,7 +17,7 @@ export declare class IriType extends AbstractIdentifierType<NamedNode> {
|
|
|
17
17
|
};
|
|
18
18
|
fromJsonExpression({ variables, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["fromJsonExpression"]>[0]): Code;
|
|
19
19
|
jsonType(parameters?: Parameters<AbstractTermType["jsonType"]>[0]): AbstractTermType.JsonType;
|
|
20
|
-
|
|
20
|
+
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["jsonSchema"]>[0]): Code;
|
|
21
21
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractTermType<NamedNode, BlankNode | NamedNode>["toJsonExpression"]>[0]): Code;
|
|
22
22
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractTermType["fromRdfExpressionChain"]>[0]): ReturnType<AbstractTermType["fromRdfExpressionChain"]>;
|
|
23
23
|
}
|
|
@@ -63,7 +63,7 @@ export function fromString(identifier: string): ${imports.Either}<Error, ${this.
|
|
|
63
63
|
}
|
|
64
64
|
return new AbstractTermType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
jsonSchema({ includeDiscriminantProperty, }) {
|
|
67
67
|
let idSchema;
|
|
68
68
|
if (this.in_.length > 0) {
|
|
69
69
|
// Treat sh:in as a union of the IRIs
|