@shaclmate/compiler 4.0.39 → 4.0.41
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 +0 -8
- package/dist/ShapesGraphToAstTransformer.js +5 -85
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +0 -16
- package/dist/ast/AbstractCompoundType.d.ts +2 -1
- package/dist/ast/AbstractCompoundType.js +1 -1
- package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
- package/dist/ast/Ast.d.ts +1 -3
- package/dist/ast/ListType.d.ts +1 -1
- package/dist/ast/ListType.js +1 -1
- package/dist/ast/ObjectType.d.ts +0 -12
- package/dist/ast/ObjectType.js +0 -78
- package/dist/generators/AstJsonGenerator.js +7 -3
- package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
- package/dist/generators/ts/AbstractCollectionType.d.ts +5 -12
- package/dist/generators/ts/AbstractCollectionType.js +9 -68
- package/dist/generators/ts/AbstractContainerType.d.ts +4 -6
- package/dist/generators/ts/AbstractContainerType.js +5 -9
- package/dist/generators/ts/AbstractDateType.d.ts +6 -3
- package/dist/generators/ts/AbstractDateType.js +7 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
- package/dist/generators/ts/AbstractIdentifierType.js +3 -0
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -9
- package/dist/generators/ts/AbstractLazyObjectType.js +30 -19
- package/dist/generators/ts/AbstractLiteralType.d.ts +1 -0
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractNumericType.js +9 -9
- package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
- package/dist/generators/ts/AbstractObjectSetType.js +2 -2
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
- package/dist/generators/ts/AbstractPrimitiveType.js +2 -2
- package/dist/generators/ts/AbstractTermType.d.ts +1 -2
- package/dist/generators/ts/AbstractTermType.js +3 -5
- package/dist/generators/ts/AbstractType.d.ts +61 -26
- package/dist/generators/ts/AbstractType.js +37 -17
- package/dist/generators/ts/BigDecimalType.d.ts +5 -1
- package/dist/generators/ts/BigDecimalType.js +6 -3
- package/dist/generators/ts/BigIntType.d.ts +3 -1
- package/dist/generators/ts/BigIntType.js +3 -3
- package/dist/generators/ts/BlankNodeType.d.ts +3 -3
- package/dist/generators/ts/BlankNodeType.js +13 -13
- package/dist/generators/ts/BooleanType.d.ts +5 -3
- package/dist/generators/ts/BooleanType.js +11 -6
- package/dist/generators/ts/DefaultValueType.d.ts +40 -2
- package/dist/generators/ts/DefaultValueType.js +14 -12
- package/dist/generators/ts/FloatType.d.ts +3 -1
- package/dist/generators/ts/FloatType.js +1 -1
- package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
- package/dist/generators/ts/GraphqlSchema.js +6 -6
- package/dist/generators/ts/IdentifierType.d.ts +3 -3
- package/dist/generators/ts/IdentifierType.js +19 -17
- package/dist/generators/ts/IntType.d.ts +3 -1
- package/dist/generators/ts/IntType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +21 -19
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -0
- package/dist/generators/ts/LazyObjectOptionType.js +14 -10
- package/dist/generators/ts/LazyObjectSetType.js +14 -8
- package/dist/generators/ts/LazyObjectType.js +9 -6
- package/dist/generators/ts/ListType.d.ts +13 -5
- package/dist/generators/ts/ListType.js +48 -12
- package/dist/generators/ts/LiteralType.d.ts +5 -1
- package/dist/generators/ts/LiteralType.js +11 -8
- package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +19 -34
- package/dist/generators/ts/ObjectType.js +282 -0
- package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
- package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +52 -60
- package/dist/generators/ts/OptionType.d.ts +6 -2
- package/dist/generators/ts/OptionType.js +20 -15
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -11
- package/dist/generators/ts/SetType.d.ts +16 -1
- package/dist/generators/ts/SetType.js +80 -2
- package/dist/generators/ts/Snippets.d.ts +3 -1
- package/dist/generators/ts/Snippets.js +18 -4
- package/dist/generators/ts/SparqlObjectSetType.js +2 -2
- package/dist/generators/ts/StringType.d.ts +5 -3
- package/dist/generators/ts/StringType.js +15 -6
- package/dist/generators/ts/TermType.d.ts +6 -2
- package/dist/generators/ts/TermType.js +15 -12
- package/dist/generators/ts/TsGenerator.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.js +60 -32
- package/dist/generators/ts/Type.d.ts +4 -5
- package/dist/generators/ts/TypeFactory.d.ts +7 -8
- package/dist/generators/ts/TypeFactory.js +62 -76
- package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +36 -11
- package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +296 -105
- package/dist/generators/ts/ZodGenerator.d.ts +1 -1
- package/dist/generators/ts/ZodGenerator.js +21 -16
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +9 -6
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +9 -13
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +22 -39
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +1 -5
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +18 -13
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +44 -0
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +3 -7
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -6
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +2 -5
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +2 -6
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -24
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +51 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +41 -0
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +5 -11
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +9 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -6
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +12 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +7 -14
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +12 -12
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +16 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
- package/dist/input/generated.d.ts +758 -117
- package/dist/input/generated.js +636 -128
- package/package.json +4 -6
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
- package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
- package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
- package/dist/generators/ts/AnonymousUnionType.js +0 -59
- package/dist/generators/ts/NamedObjectType.js +0 -342
- package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
- package/dist/generators/ts/NamedUnionType.d.ts +0 -11
- package/dist/generators/ts/NamedUnionType.js +0 -13
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +0 -65
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +0 -43
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +0 -45
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +0 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +0 -17
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +0 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +0 -41
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +0 -25
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
4
|
-
export function
|
|
4
|
+
export function ObjectType_toRdfResourceFunctionDeclaration() {
|
|
5
5
|
if (!this.configuration.features.has("Object.toRdf")) {
|
|
6
6
|
return Maybe.empty();
|
|
7
7
|
}
|
|
8
|
-
const statements =
|
|
8
|
+
const statements = [];
|
|
9
9
|
if (this.toRdfTypes.length > 0) {
|
|
10
10
|
statements.push(code `if (!${variables.ignoreRdfType}) { ${joinCode(this.toRdfTypes.map((toRdfType) => code `${variables.resource}.add(${this.rdfjsTermExpression(rdf.type)}, ${this.reusables.imports.dataFactory}.namedNode("${toRdfType.value}"), ${variables.graph});`), { on: " " })} }`);
|
|
11
11
|
}
|
|
@@ -23,7 +23,7 @@ export function NamedObjectType_toRdfResourceFunctionDeclaration() {
|
|
|
23
23
|
}
|
|
24
24
|
statements.push(code `return ${variables.resource};`);
|
|
25
25
|
return Maybe.of(code `\
|
|
26
|
-
export const _toRdfResource: ${this.reusables.snippets._ToRdfResourceFunction}<${this.identifierTypeAlias}, ${this.
|
|
26
|
+
export const _toRdfResource: ${this.reusables.snippets._ToRdfResourceFunction}<${this.identifierTypeAlias}, ${this.expression}> = (parameters) => {
|
|
27
27
|
${joinCode(statements)}
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -36,4 +36,4 @@ const variables = {
|
|
|
36
36
|
resource: code `parameters.resource`,
|
|
37
37
|
resourceSet: code `parameters.resourceSet`,
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=
|
|
39
|
+
//# sourceMappingURL=ObjectType_toRdfResourceFunctionDeclaration.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
2
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
+
export declare function ObjectType_toStringFunctionDeclarations(this: ObjectType): readonly Code[];
|
|
4
|
+
//# sourceMappingURL=ObjectType_toStringFunctionDeclarations.d.ts.map
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
2
|
-
export function
|
|
2
|
+
export function ObjectType_toStringFunctionDeclarations() {
|
|
3
3
|
if (!this.configuration.features.has("Object.toString")) {
|
|
4
4
|
return [];
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
if (this.parentObjectTypes.length > 0) {
|
|
8
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
9
|
-
propertiesToStringInitializers.push(code `...${parentObjectType.name}._propertiesToStrings(${this.thisVariable})`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
propertiesToStringInitializers = propertiesToStringInitializers.concat(this.properties.flatMap((property) => property
|
|
6
|
+
const propertiesToStringsReturnExpression = code `${this.reusables.snippets.compactRecord}({${joinCode(this.properties.flatMap((property) => property
|
|
13
7
|
.toStringInitializer({
|
|
14
8
|
variables: {
|
|
15
9
|
value: property.accessExpression({
|
|
@@ -17,20 +11,19 @@ export function NamedObjectType_toStringFunctionDeclarations() {
|
|
|
17
11
|
}),
|
|
18
12
|
},
|
|
19
13
|
})
|
|
20
|
-
.toList()))
|
|
21
|
-
const
|
|
22
|
-
const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
|
|
14
|
+
.toList()), { on: "," })}})`;
|
|
15
|
+
const toStringReturnExpression = (propertiesToStrings) => code `\`${this.alias.unsafeCoerce()}(\${JSON.stringify(${propertiesToStrings})})\``;
|
|
23
16
|
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
24
17
|
return [
|
|
25
18
|
// Use overloads to allow the function to be attached to an instance or used freestanding
|
|
26
19
|
code `\
|
|
27
|
-
export function _propertiesToStrings(${this.thisVariable}: ${this.
|
|
20
|
+
export function _propertiesToStrings(${this.thisVariable}: ${this.expression}): Record<string, string> {
|
|
28
21
|
return ${propertiesToStringsReturnExpression};
|
|
29
22
|
}`,
|
|
30
23
|
code `\
|
|
31
|
-
export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.
|
|
24
|
+
export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.expression}): string {
|
|
32
25
|
return ${toStringReturnExpression(code `_propertiesToStrings(${this.thisVariable})`)};
|
|
33
26
|
}`,
|
|
34
27
|
];
|
|
35
28
|
}
|
|
36
|
-
//# sourceMappingURL=
|
|
29
|
+
//# sourceMappingURL=ObjectType_toStringFunctionDeclarations.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_valueSparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export function
|
|
3
|
+
export function ObjectType_valueSparqlConstructTriplesFunctionDeclaration() {
|
|
4
4
|
if (!this.configuration.features.has("Object.SPARQL")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
|
8
8
|
export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ({ filter, ignoreRdfType, valueVariable, variablePrefix }) =>
|
|
9
|
-
${this.
|
|
9
|
+
${this.alias.unsafeCoerce()}.focusSparqlConstructTriples({ filter, focusIdentifier: valueVariable, ignoreRdfType, variablePrefix });`);
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_valueSparqlWherePatternsFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export function
|
|
3
|
+
export function ObjectType_valueSparqlWherePatternsFunctionDeclaration() {
|
|
4
4
|
if (!this.configuration.features.has("Object.SPARQL")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
|
8
8
|
export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ({ filter, ignoreRdfType, preferredLanguages, propertyPatterns, valueVariable, variablePrefix }) =>
|
|
9
9
|
(propertyPatterns as readonly ${this.reusables.snippets.SparqlPattern}[]).concat(
|
|
10
|
-
${this.
|
|
10
|
+
${this.alias.unsafeCoerce()}.focusSparqlWherePatterns({ filter, focusIdentifier: valueVariable, ignoreRdfType, preferredLanguages, variablePrefix })
|
|
11
11
|
);`);
|
|
12
12
|
}
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=ObjectType_valueSparqlWherePatternsFunctionDeclaration.js.map
|
|
@@ -31,19 +31,19 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
31
31
|
get constructorParameter() {
|
|
32
32
|
const conversionFunction = this.type.conversionFunction.extract();
|
|
33
33
|
if (!conversionFunction) {
|
|
34
|
-
return Maybe.of(code `readonly ${this.name}: ${this.type.
|
|
34
|
+
return Maybe.of(code `readonly ${this.name}: ${this.type.expression};`);
|
|
35
35
|
}
|
|
36
36
|
let hasQuestionToken = false;
|
|
37
|
-
const
|
|
37
|
+
const typeExpressions = [];
|
|
38
38
|
for (const type of conversionFunction.sourceTypes) {
|
|
39
|
-
if (type.typeof === "undefined") {
|
|
39
|
+
if (type.jsType.typeof === "undefined") {
|
|
40
40
|
hasQuestionToken = true;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
|
|
43
|
+
typeExpressions.push(code `${type.expression}`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(
|
|
46
|
+
return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeExpressions, { on: "|" })};`);
|
|
47
47
|
}
|
|
48
48
|
get declaration() {
|
|
49
49
|
const lhs = [];
|
|
@@ -55,7 +55,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
55
55
|
.alt(this.description)
|
|
56
56
|
.alt(this.label)
|
|
57
57
|
.map(tsComment)
|
|
58
|
-
.orDefault("")}${joinCode(lhs, { on: " " })}: ${this.type.
|
|
58
|
+
.orDefault("")}${joinCode(lhs, { on: " " })}: ${this.type.expression};`;
|
|
59
59
|
}
|
|
60
60
|
get filterProperty() {
|
|
61
61
|
return Maybe.of({
|
|
@@ -71,7 +71,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
71
71
|
description: this.comment.map(JSON.stringify),
|
|
72
72
|
name: this.name,
|
|
73
73
|
resolve: code `(source, ${argsVariable}) => ${this.type.graphqlResolveExpression({ variables: { args: argsVariable, value: code `source.${this.name}` } })}`,
|
|
74
|
-
type: this.type.graphqlType.
|
|
74
|
+
type: this.type.graphqlType.expression,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
get jsonSchema() {
|
|
@@ -95,7 +95,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
95
95
|
}
|
|
96
96
|
get jsonSignature() {
|
|
97
97
|
const typeJsonType = this.type.jsonType();
|
|
98
|
-
return Maybe.of(code `${!this.mutable ? "readonly " : ""}${this.name}${typeJsonType.optional ? "?" : ""}: ${typeJsonType.
|
|
98
|
+
return Maybe.of(code `${!this.mutable ? "readonly " : ""}${this.name}${typeJsonType.optional ? "?" : ""}: ${typeJsonType.requiredExpression}`);
|
|
99
99
|
}
|
|
100
100
|
get schemaInitializers() {
|
|
101
101
|
const initializers = super.schemaInitializers.concat();
|
|
@@ -118,13 +118,13 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
118
118
|
const validationFunction = this.type.validationFunction.extract();
|
|
119
119
|
let rhs;
|
|
120
120
|
if (conversionFunction && validationFunction) {
|
|
121
|
-
rhs = code `${conversionFunction}(${parameterVariable}).chain(value => ${validationFunction}(${this.
|
|
121
|
+
rhs = code `${conversionFunction}(${parameterVariable}).chain(value => ${validationFunction}(${this.objectType.alias.unsafeCoerce()}.schema.properties.${this.name}.type, value))`;
|
|
122
122
|
}
|
|
123
123
|
else if (conversionFunction) {
|
|
124
124
|
rhs = code `${conversionFunction}(${parameterVariable})`;
|
|
125
125
|
}
|
|
126
126
|
else if (validationFunction) {
|
|
127
|
-
rhs = code `${validationFunction}(${this.
|
|
127
|
+
rhs = code `${validationFunction}(${this.objectType.alias.unsafeCoerce()}.schema.properties.${this.name}.type, ${parameterVariable})`;
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
130
|
rhs = code `${this.reusables.imports.Either}.of(${parameterVariable})`;
|
|
@@ -148,7 +148,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
148
148
|
variables: {
|
|
149
149
|
...variables,
|
|
150
150
|
ignoreRdfType: true,
|
|
151
|
-
propertyPath: code `${this.
|
|
151
|
+
propertyPath: code `${this.objectType.alias.unsafeCoerce()}.schema.properties.${this.name}.path`,
|
|
152
152
|
resourceValues: code `resourceValues`,
|
|
153
153
|
},
|
|
154
154
|
})})`,
|
|
@@ -209,7 +209,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
209
209
|
default:
|
|
210
210
|
return [];
|
|
211
211
|
}
|
|
212
|
-
const propertyPath = code `${this.
|
|
212
|
+
const propertyPath = code `${this.objectType.alias.unsafeCoerce()}.schema.properties.${this.name}.path`;
|
|
213
213
|
return [
|
|
214
214
|
code `${variables.resource}.add(${propertyPath}, ${this.type.toRdfResourceValuesExpression({
|
|
215
215
|
variables: { ...variables, propertyPath },
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { code } from "../ts-poet-wrapper.js";
|
|
2
|
+
export function identifierTypeDeclarations() {
|
|
3
|
+
if (!this.configuration.features.has("Object.type")) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
// Bespoke identifier type and associated functions
|
|
7
|
+
return [
|
|
8
|
+
code `export type Identifier = ${this.identifierType.expression};`,
|
|
9
|
+
code `\
|
|
10
|
+
export namespace Identifier {
|
|
11
|
+
export const parse = ${this.identifierType.parseFunction};
|
|
12
|
+
export const stringify = ${this.identifierType.stringifyFunction};
|
|
13
|
+
}`,
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=identifierTypeDeclarations.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToArraySet = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToArraySet`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToArraySet<ItemSourceT, ItemTargetT, Readonly extends boolean>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, _readonly: Readonly) {
|
|
4
|
+
type ItemTargetArrayT = Readonly extends true ? ReadonlyArray<ItemTargetT> : Array<ItemTargetT>;
|
|
5
|
+
return (value: readonly ItemSourceT[] | undefined): ${imports.Either}<Error, ItemTargetArrayT> =>
|
|
6
|
+
(typeof value === "undefined" ? ${imports.Either}.of([]) : ${imports.Either}.sequence(value.map(convertToItem))) as ${imports.Either}<Error, ItemTargetArrayT>;
|
|
7
|
+
}`);
|
|
8
|
+
//# sourceMappingURL=snippets_convertToArraySet.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToList = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToList`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToList<ItemSourceT, ItemTargetT, Readonly extends boolean>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, _readonly: Readonly) {
|
|
4
|
+
type ItemTargetArrayT = Readonly extends true ? ReadonlyArray<ItemTargetT> : Array<ItemTargetT>;
|
|
5
|
+
return (value: readonly ItemSourceT[]): ${imports.Either}<Error, ItemTargetArrayT> => ${imports.Either}.sequence(value.map(convertToItem)) as ${imports.Either}<Error, ItemTargetArrayT>;
|
|
6
|
+
}`);
|
|
7
|
+
//# sourceMappingURL=snippets_convertToList.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToScalarSet = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToScalarSet`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToScalarSet<ItemSourceT, ItemTargetT, Readonly extends boolean>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, _readonly: Readonly) {
|
|
4
|
+
type ItemTargetArrayT = Readonly extends true ? ReadonlyArray<ItemTargetT> : Array<ItemTargetT>;
|
|
5
|
+
return (value: ItemSourceT | readonly ItemSourceT[] | undefined): ${imports.Either}<Error, ItemTargetArrayT> => {
|
|
6
|
+
if (typeof value === "undefined") {
|
|
7
|
+
return ${imports.Either}.of<Error, ItemTargetArrayT>([] as unknown as ItemTargetArrayT);
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return ${imports.Either}.sequence(value.map(convertToItem)) as ${imports.Either}<Error, ItemTargetArrayT>;
|
|
11
|
+
}
|
|
12
|
+
return convertToItem(value as ItemSourceT).map(value => [value]) as ${imports.Either}<Error, ItemTargetArrayT>;
|
|
13
|
+
};
|
|
14
|
+
}`);
|
|
15
|
+
//# sourceMappingURL=snippets_convertToScalarSet.js.map
|