@shaclmate/compiler 4.0.33 → 4.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compiler.d.ts +0 -3
- package/dist/Compiler.js +0 -2
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
- package/dist/ShapesGraphToAstTransformer.js +1 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
- package/dist/ast/AbstractCompoundType.d.ts +6 -4
- package/dist/ast/AbstractCompoundType.js +4 -37
- package/dist/ast/ObjectType.d.ts +1 -7
- package/dist/ast/ObjectType.js +1 -6
- package/dist/generators/ts/AbstractCollectionType.d.ts +9 -8
- package/dist/generators/ts/AbstractCollectionType.js +38 -120
- package/dist/generators/ts/AbstractContainerType.d.ts +3 -1
- package/dist/generators/ts/AbstractContainerType.js +20 -0
- package/dist/generators/ts/AbstractDateType.d.ts +5 -10
- package/dist/generators/ts/AbstractDateType.js +5 -32
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
- package/dist/generators/ts/AbstractIdentifierType.js +0 -17
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -5
- package/dist/generators/ts/AbstractLazyObjectType.js +22 -21
- package/dist/generators/ts/AbstractLiteralType.d.ts +12 -4
- package/dist/generators/ts/AbstractLiteralType.js +3 -3
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
- package/dist/generators/ts/AbstractNumericType.d.ts +3 -9
- package/dist/generators/ts/AbstractNumericType.js +6 -13
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +9 -4
- package/dist/generators/ts/AbstractPrimitiveType.js +11 -18
- package/dist/generators/ts/AbstractTermType.d.ts +10 -5
- package/dist/generators/ts/AbstractTermType.js +14 -53
- package/dist/generators/ts/AbstractType.d.ts +39 -24
- package/dist/generators/ts/AbstractType.js +4 -2
- package/dist/generators/ts/AbstractUnionType.d.ts +3 -2
- package/dist/generators/ts/AbstractUnionType.js +29 -39
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +3 -3
- package/dist/generators/ts/BigDecimalType.d.ts +7 -4
- package/dist/generators/ts/BigDecimalType.js +11 -45
- package/dist/generators/ts/BigIntType.d.ts +3 -4
- package/dist/generators/ts/BigIntType.js +6 -17
- package/dist/generators/ts/BlankNodeType.d.ts +8 -7
- package/dist/generators/ts/BlankNodeType.js +18 -5
- package/dist/generators/ts/BooleanType.d.ts +6 -9
- package/dist/generators/ts/BooleanType.js +9 -16
- package/dist/generators/ts/DateTimeType.d.ts +4 -1
- package/dist/generators/ts/DateTimeType.js +6 -13
- package/dist/generators/ts/DateType.d.ts +4 -1
- package/dist/generators/ts/DateType.js +7 -14
- package/dist/generators/ts/DefaultValueType.d.ts +6 -6
- package/dist/generators/ts/DefaultValueType.js +30 -63
- package/dist/generators/ts/FloatType.d.ts +3 -3
- package/dist/generators/ts/FloatType.js +5 -5
- package/dist/generators/ts/IdentifierType.d.ts +7 -6
- package/dist/generators/ts/IdentifierType.js +26 -5
- package/dist/generators/ts/IntType.d.ts +3 -3
- package/dist/generators/ts/IntType.js +5 -5
- package/dist/generators/ts/IriType.d.ts +9 -12
- package/dist/generators/ts/IriType.js +43 -32
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectOptionType.js +23 -44
- package/dist/generators/ts/LazyObjectSetType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectSetType.js +19 -29
- package/dist/generators/ts/LazyObjectType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectType.js +18 -26
- package/dist/generators/ts/LiteralType.d.ts +6 -3
- package/dist/generators/ts/LiteralType.js +27 -13
- package/dist/generators/ts/NamedObjectType.d.ts +7 -9
- package/dist/generators/ts/NamedObjectType.js +24 -32
- package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
- package/dist/generators/ts/NamedObjectUnionType.js +21 -14
- package/dist/generators/ts/OptionType.d.ts +6 -5
- package/dist/generators/ts/OptionType.js +31 -51
- package/dist/generators/ts/Reusables.d.ts +3 -1
- package/dist/generators/ts/Reusables.js +2 -1
- package/dist/generators/ts/SetType.d.ts +0 -1
- package/dist/generators/ts/SetType.js +4 -22
- package/dist/generators/ts/SnippetFactory.d.ts +2 -0
- package/dist/generators/ts/Snippets.d.ts +36 -8
- package/dist/generators/ts/Snippets.js +207 -30
- package/dist/generators/ts/StringType.d.ts +6 -10
- package/dist/generators/ts/StringType.js +8 -21
- package/dist/generators/ts/TermType.d.ts +2 -4
- package/dist/generators/ts/TermType.js +6 -10
- package/dist/generators/ts/TsGenerator.d.ts +14 -1
- package/dist/generators/ts/TsGenerator.js +41 -12
- package/dist/generators/ts/TypeFactory.d.ts +8 -4
- package/dist/generators/ts/TypeFactory.js +73 -49
- package/dist/generators/ts/ZodGenerator.js +6 -3
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +36 -39
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +34 -31
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +31 -19
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +30 -36
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +41 -29
- package/dist/generators/ts/_snippets/snippets_ConversionFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ConversionFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
- package/dist/generators/ts/_snippets/snippets_ValidationFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ValidationFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
- package/dist/generators/ts/_snippets/snippets_identityConversionFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identityConversionFunction.js +6 -0
- package/dist/generators/ts/_snippets/snippets_identityValidationFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identityValidationFunction.js +6 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_validateArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_validateArray.js +13 -0
- package/dist/generators/ts/_snippets/snippets_validateMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_validateMaybe.js +7 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
- package/dist/generators/ts/objectSetDeclarations.js +4 -34
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
- package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +5 -8
- package/dist/input/ShapesGraph.js +5 -6
- package/dist/input/generated.d.ts +175 -230
- package/dist/input/generated.js +226 -1748
- package/package.json +2 -2
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
- package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
- package/dist/generators/ts/syntheticNamePrefix.js +0 -2
package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
let properties = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonTypeAliasDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
const members = [];
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonUiSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
const variables = { scopePrefix: code `scopePrefix` };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { camelCase, trainCase } from "change-case";
|
|
2
2
|
import plur from "plur";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
3
|
export function NamedObjectType_objectSetMethodNames() {
|
|
4
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
5
5
|
const prefixSingular = camelCase(this.name, {
|
|
6
6
|
prefixCharacters: syntheticNamePrefix,
|
|
7
7
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import type { Reusables } from "../Reusables.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TsGenerator } from "../TsGenerator.js";
|
|
4
4
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
5
5
|
export declare function NamedObjectType_sparqlConstructQueryFunctionDeclaration(this: {
|
|
6
|
-
readonly
|
|
6
|
+
readonly configuration: TsGenerator.Configuration;
|
|
7
7
|
readonly filterType: Code;
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly reusables: Reusables;
|
|
@@ -2,7 +2,7 @@ import { camelCase } from "change-case";
|
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import { code } from "../ts-poet-wrapper.js";
|
|
4
4
|
export function NamedObjectType_sparqlConstructQueryFunctionDeclaration() {
|
|
5
|
-
if (!this.features.has("sparql")) {
|
|
5
|
+
if (!this.configuration.features.has("sparql")) {
|
|
6
6
|
return Maybe.empty();
|
|
7
7
|
}
|
|
8
8
|
return Maybe.of(code `\
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import type { Reusables } from "../Reusables.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TsGenerator } from "../TsGenerator.js";
|
|
4
4
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
5
5
|
export declare function NamedObjectType_sparqlConstructQueryStringFunctionDeclaration(this: {
|
|
6
|
-
readonly
|
|
6
|
+
readonly configuration: TsGenerator.Configuration;
|
|
7
7
|
readonly filterType: Code;
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly reusables: Reusables;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_sparqlConstructQueryStringFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("sparql")) {
|
|
4
|
+
if (!this.configuration.features.has("sparql")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_toJsonFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
const jsonObjectMembers = [];
|
|
@@ -10,7 +10,7 @@ export function NamedObjectType_toJsonFunctionDeclaration() {
|
|
|
10
10
|
}
|
|
11
11
|
if (this.properties.length > 0) {
|
|
12
12
|
jsonObjectMembers.push(...this.properties.flatMap((property) => property
|
|
13
|
-
.
|
|
13
|
+
.toJsonInitializer({
|
|
14
14
|
variables: {
|
|
15
15
|
value: property.accessExpression({
|
|
16
16
|
variables: { object: this.thisVariable },
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
4
|
export function NamedObjectType_toRdfResourceFunctionDeclaration() {
|
|
5
|
-
if (!this.features.has("rdf")) {
|
|
5
|
+
if (!this.configuration.features.has("rdf")) {
|
|
6
6
|
return Maybe.empty();
|
|
7
7
|
}
|
|
8
8
|
const statements = this.parentObjectTypes.map((parentObjectType) => code `${parentObjectType.name}._toRdfResource({ ...parameters, ignoreRdfType: true });`);
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
1
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
2
|
export function NamedObjectType_toStringFunctionDeclarations() {
|
|
4
|
-
|
|
3
|
+
let propertiesToStringInitializers = [];
|
|
5
4
|
if (this.parentObjectTypes.length > 0) {
|
|
6
5
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
7
|
-
|
|
6
|
+
propertiesToStringInitializers.push(code `...${parentObjectType.name}._propertiesToStrings(${this.thisVariable})`);
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
propertiesToStringRecordProperties.push(code `${literalOf(property.name)}: ${propertyToStringExpression}`);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
const propertiesToStringsReturnExpression = code `${this.reusables.snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
|
|
9
|
+
propertiesToStringInitializers = propertiesToStringInitializers.concat(this.properties.flatMap((property) => property
|
|
10
|
+
.toStringInitializer({
|
|
11
|
+
variables: {
|
|
12
|
+
value: property.accessExpression({
|
|
13
|
+
variables: { object: this.thisVariable },
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
.toList()));
|
|
18
|
+
const propertiesToStringsReturnExpression = code `${this.reusables.snippets.compactRecord}({${joinCode(propertiesToStringInitializers, { on: "," })}})`;
|
|
24
19
|
const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
|
|
20
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
25
21
|
return [
|
|
26
22
|
// Use overloads to allow the function to be attached to an instance or used freestanding
|
|
27
23
|
code `\
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("sparql")) {
|
|
4
|
+
if (!this.configuration.features.has("sparql")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_valueSparqlWherePatternsFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("sparql")) {
|
|
4
|
+
if (!this.configuration.features.has("sparql")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
|
@@ -21,7 +21,7 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
|
|
|
21
21
|
path: PropertyPath;
|
|
22
22
|
recursive: boolean;
|
|
23
23
|
} & ConstructorParameters<typeof AbstractProperty<TypeT>>[0]);
|
|
24
|
-
get
|
|
24
|
+
get constructorParameter(): Maybe<Code>;
|
|
25
25
|
get declaration(): Code;
|
|
26
26
|
get filterProperty(): Maybe<{
|
|
27
27
|
name: string;
|
|
@@ -35,16 +35,16 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
|
|
|
35
35
|
kind: Code;
|
|
36
36
|
type: Code;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
hashStatements(
|
|
38
|
+
constructorInitializer({ variables, }: Parameters<AbstractProperty<TypeT>["constructorInitializer"]>[0]): Maybe<Code>;
|
|
39
|
+
fromJsonInitializer({ variables, }: Parameters<AbstractProperty<TypeT>["fromJsonInitializer"]>[0]): Maybe<Code>;
|
|
40
|
+
fromRdfResourceValuesInitializer({ variables, }: Parameters<AbstractProperty<TypeT>["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
|
|
41
|
+
hashStatements({ variables, }: Parameters<AbstractProperty<TypeT>["hashStatements"]>[0]): readonly Code[];
|
|
42
42
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<TypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
43
43
|
sparqlConstructTriplesExpression({ variables, }: Parameters<AbstractProperty<TypeT>["sparqlConstructTriplesExpression"]>[0]): Maybe<Code>;
|
|
44
44
|
sparqlWherePatternsExpression({ variables, }: Parameters<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>[0]): ReturnType<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>;
|
|
45
|
-
|
|
45
|
+
toJsonInitializer(parameters: Parameters<AbstractProperty<TypeT>["toJsonInitializer"]>[0]): Maybe<Code>;
|
|
46
46
|
toRdfRdfResourceValuesStatements({ variables, }: Parameters<AbstractProperty<TypeT>["toRdfRdfResourceValuesStatements"]>[0]): readonly Code[];
|
|
47
|
-
|
|
47
|
+
toStringInitializer(parameters: Parameters<AbstractProperty<TypeT>["toStringInitializer"]>[0]): Maybe<Code>;
|
|
48
48
|
private propertyPathToCode;
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=ShaclProperty.d.ts.map
|
|
@@ -6,7 +6,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
|
-
import { codeEquals } from "../codeEquals.js";
|
|
10
9
|
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
11
10
|
import { tsComment } from "../tsComment.js";
|
|
12
11
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
@@ -29,15 +28,19 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
29
28
|
this.path = path;
|
|
30
29
|
this.recursive = recursive;
|
|
31
30
|
}
|
|
32
|
-
get
|
|
31
|
+
get constructorParameter() {
|
|
32
|
+
const conversionFunction = this.type.conversionFunction.extract();
|
|
33
|
+
if (!conversionFunction) {
|
|
34
|
+
return Maybe.of(code `readonly ${this.name}: ${this.type.name};`);
|
|
35
|
+
}
|
|
33
36
|
let hasQuestionToken = false;
|
|
34
37
|
const typeNames = [];
|
|
35
|
-
for (const
|
|
36
|
-
if (
|
|
38
|
+
for (const type of conversionFunction.sourceTypes) {
|
|
39
|
+
if (type.typeof === "undefined") {
|
|
37
40
|
hasQuestionToken = true;
|
|
38
41
|
}
|
|
39
|
-
else
|
|
40
|
-
typeNames.push(code `${
|
|
42
|
+
else {
|
|
43
|
+
typeNames.push(code `${type.name}`);
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeNames, { on: "|" })};`);
|
|
@@ -99,7 +102,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
99
102
|
...super.schemaObject,
|
|
100
103
|
// comment: this.comment.map(JSON.stringify).extract(),
|
|
101
104
|
// description: this.description.map(JSON.stringify).extract(),
|
|
102
|
-
path: this.
|
|
105
|
+
path: this.configuration.features.has("rdf")
|
|
103
106
|
? this.propertyPathToCode(this.path)
|
|
104
107
|
: undefined,
|
|
105
108
|
// label: this.label.map(JSON.stringify).extract(),
|
|
@@ -111,28 +114,35 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
111
114
|
// : undefined,
|
|
112
115
|
};
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
constructorInitializer({ variables, }) {
|
|
118
|
+
const parameterVariable = code `${variables.parameters}.${this.name}`;
|
|
119
|
+
const conversionFunction = this.type.conversionFunction.extract()?.code;
|
|
120
|
+
const validationFunction = this.type.validationFunction.extract();
|
|
121
|
+
let rhs;
|
|
122
|
+
if (conversionFunction && validationFunction) {
|
|
123
|
+
rhs = code `${conversionFunction}(${parameterVariable}).chain(value => ${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), value))`;
|
|
124
|
+
}
|
|
125
|
+
else if (conversionFunction) {
|
|
126
|
+
rhs = code `${conversionFunction}(${parameterVariable})`;
|
|
127
|
+
}
|
|
128
|
+
else if (validationFunction) {
|
|
129
|
+
rhs = code `${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), ${parameterVariable})`;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
rhs = code `${this.reusables.imports.Either}.of(${parameterVariable})`;
|
|
118
133
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.concat(code `{ ${this.name} = (${variables.parameter}) satisfies never; }`), { on: " else " }));
|
|
124
|
-
return statements;
|
|
125
|
-
}
|
|
126
|
-
fromJsonExpression({ variables, }) {
|
|
127
|
-
return Maybe.of(this.type.fromJsonExpression({
|
|
134
|
+
return Maybe.of(code `${this.name}: ${rhs}`);
|
|
135
|
+
}
|
|
136
|
+
fromJsonInitializer({ variables, }) {
|
|
137
|
+
return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
|
|
128
138
|
variables: { value: code `${variables.jsonObject}["${this.name}"]` },
|
|
129
|
-
}));
|
|
139
|
+
})}`);
|
|
130
140
|
}
|
|
131
|
-
|
|
141
|
+
fromRdfResourceValuesInitializer({ variables, }) {
|
|
132
142
|
// Assume the property has the correct range and ignore the object's RDF type.
|
|
133
143
|
// This also accommodates the case where the object of a property is a dangling identifier that's not the
|
|
134
144
|
// subject of any statements.
|
|
135
|
-
return Maybe.of(code `${this.reusables.snippets.shaclPropertyFromRdf}(${{
|
|
145
|
+
return Maybe.of(code `${this.name}: ${this.reusables.snippets.shaclPropertyFromRdf}(${{
|
|
136
146
|
graph: variables.graph,
|
|
137
147
|
resource: variables.resource,
|
|
138
148
|
propertySchema: code `schema.properties.${this.name}`,
|
|
@@ -146,8 +156,10 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
146
156
|
})})`,
|
|
147
157
|
}})`);
|
|
148
158
|
}
|
|
149
|
-
hashStatements(
|
|
150
|
-
return
|
|
159
|
+
hashStatements({ variables, }) {
|
|
160
|
+
return [
|
|
161
|
+
code `${this.type.hashFunction}(${variables.hasher}, ${variables.value});`,
|
|
162
|
+
];
|
|
151
163
|
}
|
|
152
164
|
jsonUiSchemaElement({ variables, }) {
|
|
153
165
|
const scope = code `\`\${${variables.scopePrefix}}/properties/${this.name}\``;
|
|
@@ -184,7 +196,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
184
196
|
}})`,
|
|
185
197
|
});
|
|
186
198
|
}
|
|
187
|
-
|
|
199
|
+
toJsonInitializer(parameters) {
|
|
188
200
|
return Maybe.of(code `${this.name}: ${this.type.toJsonExpression(parameters)}`);
|
|
189
201
|
}
|
|
190
202
|
toRdfRdfResourceValuesStatements({ variables, }) {
|
|
@@ -206,11 +218,11 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
206
218
|
})}, ${variables.graph});`,
|
|
207
219
|
];
|
|
208
220
|
}
|
|
209
|
-
|
|
221
|
+
toStringInitializer(parameters) {
|
|
210
222
|
if (!this.display) {
|
|
211
223
|
return Maybe.empty();
|
|
212
224
|
}
|
|
213
|
-
return Maybe.of(this.type.toStringExpression(parameters));
|
|
225
|
+
return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression(parameters)}`);
|
|
214
226
|
}
|
|
215
227
|
propertyPathToCode(propertyPath) {
|
|
216
228
|
switch (propertyPath.termType) {
|
|
@@ -229,7 +241,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
229
241
|
}
|
|
230
242
|
__decorate([
|
|
231
243
|
Memoize()
|
|
232
|
-
], ShaclProperty.prototype, "
|
|
244
|
+
], ShaclProperty.prototype, "constructorParameter", null);
|
|
233
245
|
__decorate([
|
|
234
246
|
Memoize()
|
|
235
247
|
], ShaclProperty.prototype, "declaration", null);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_ConversionFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ConversionFunction`, code `\
|
|
3
|
+
type ${syntheticNamePrefix}ConversionFunction<SourceT, TargetT> = (source: SourceT) => ${imports.Either}<Error, TargetT>;`);
|
|
4
|
+
//# sourceMappingURL=snippets_ConversionFunction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_DefaultValueSchema = ({
|
|
3
|
-
interface ${syntheticNamePrefix}DefaultValueSchema<ItemSchemaT> {
|
|
4
|
-
readonly defaultValue:
|
|
2
|
+
export const snippets_DefaultValueSchema = ({ syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}DefaultValueSchema`, code `\
|
|
3
|
+
interface ${syntheticNamePrefix}DefaultValueSchema<DefaultValueT, ItemSchemaT> {
|
|
4
|
+
readonly defaultValue: DefaultValueT;
|
|
5
5
|
readonly item: () => ItemSchemaT;
|
|
6
6
|
readonly kind: "DefaultValue";
|
|
7
7
|
}`);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_HashFunction = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}HashFunction`, code `\
|
|
3
|
+
export type ${syntheticNamePrefix}HashFunction<HasherT extends ${snippets.Hasher}, ValueT> = (hasher: HasherT, value: ValueT) => HasherT;`);
|
|
4
|
+
//# sourceMappingURL=snippets_HashFunction.js.map
|
|
@@ -1,32 +1,42 @@
|
|
|
1
|
-
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
1
|
+
import { code, conditionalOutput, joinCode, } from "../ts-poet-wrapper.js";
|
|
2
2
|
/**
|
|
3
3
|
* Adapter between generated code and the rdfjs-resource PropertyPath.
|
|
4
4
|
*/
|
|
5
|
-
export const snippets_PropertyPath = ({ imports, snippets, syntheticNamePrefix, }) =>
|
|
5
|
+
export const snippets_PropertyPath = ({ configuration, imports, snippets, syntheticNamePrefix, }) => {
|
|
6
|
+
const companionDeclarations = [];
|
|
7
|
+
if (configuration.features.has("equals")) {
|
|
8
|
+
companionDeclarations.push(code `\
|
|
9
|
+
export function equals(left: ${syntheticNamePrefix}PropertyPath, right: ${syntheticNamePrefix}PropertyPath): ${snippets.EqualsResult} {
|
|
10
|
+
return ${snippets.EqualsResult}.fromBooleanEqualsResult(left, right, ${imports.RdfxResourcePropertyPath}.equals(left, right));
|
|
11
|
+
}`);
|
|
12
|
+
}
|
|
13
|
+
companionDeclarations.push(code `export type Filter = object`, code `\
|
|
14
|
+
export function filter(_filter: Filter, _value: ${syntheticNamePrefix}PropertyPath): boolean {
|
|
15
|
+
return true;
|
|
16
|
+
}`);
|
|
17
|
+
if (configuration.features.has("rdf")) {
|
|
18
|
+
companionDeclarations.push(code `\
|
|
19
|
+
export const fromRdfResource: ${snippets.FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;`, code `\
|
|
20
|
+
export const fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
|
|
21
|
+
values.chain((values) =>
|
|
22
|
+
values.chainMap((value) =>
|
|
23
|
+
value
|
|
24
|
+
.toResource()
|
|
25
|
+
.chain((resource) => fromRdfResource(resource, options)),
|
|
26
|
+
),
|
|
27
|
+
);`);
|
|
28
|
+
}
|
|
29
|
+
companionDeclarations.push(code `export const schema: Readonly<object> = {}`);
|
|
30
|
+
if (configuration.features.has("rdf")) {
|
|
31
|
+
companionDeclarations.push(code `\
|
|
32
|
+
export const toRdfResource: ${snippets.ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;`);
|
|
33
|
+
}
|
|
34
|
+
companionDeclarations.push(code `export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;`);
|
|
35
|
+
return conditionalOutput(`${syntheticNamePrefix}PropertyPath`, code `\
|
|
6
36
|
export type ${syntheticNamePrefix}PropertyPath = ${imports.RdfxResourcePropertyPath};
|
|
7
37
|
|
|
8
38
|
export namespace ${syntheticNamePrefix}PropertyPath {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export function filter(_filter: Filter, _value: ${syntheticNamePrefix}PropertyPath): boolean {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const fromRdfResource: ${snippets.FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;
|
|
16
|
-
|
|
17
|
-
export const fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
|
|
18
|
-
values.chain((values) =>
|
|
19
|
-
values.chainMap((value) =>
|
|
20
|
-
value
|
|
21
|
-
.toResource()
|
|
22
|
-
.chain((resource) => fromRdfResource(resource, options)),
|
|
23
|
-
),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const schema: Readonly<object> = {};
|
|
27
|
-
|
|
28
|
-
export const toRdfResource: ${snippets.ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;
|
|
29
|
-
|
|
30
|
-
export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;
|
|
39
|
+
${joinCode(companionDeclarations, { on: "\n\n" })}
|
|
31
40
|
}`);
|
|
41
|
+
};
|
|
32
42
|
//# sourceMappingURL=snippets_PropertyPath.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_ValidationFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ValidationFunction`, code `\
|
|
3
|
+
type ${syntheticNamePrefix}ValidationFunction<SchemaT, ValueT> = (schema: SchemaT, value: ValueT) => ${imports.Either}<Error, ValueT>;`);
|
|
4
|
+
//# sourceMappingURL=snippets_ValidationFunction.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToArray = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToArray`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToArray<ItemSourceT, ItemTargetT, Readonly extends boolean>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, _readonly: Readonly) {
|
|
4
|
+
type EitherR = Readonly extends true ? ReadonlyArray<ItemTargetT> : Array<ItemTargetT>;
|
|
5
|
+
return (value: readonly ItemSourceT[] | undefined): ${imports.Either}<Error, EitherR> =>
|
|
6
|
+
(typeof value === "undefined" ? ${imports.Either}.of([]) : ${imports.Either}.sequence(value.map(convertToItem))) as ${imports.Either}<Error, EitherR>;
|
|
7
|
+
}`);
|
|
8
|
+
//# sourceMappingURL=snippets_convertToArray.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToBlankNode = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBlankNode`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToBlankNode(value: ${imports.BlankNode} | undefined): ${imports.Either}<Error, ${imports.BlankNode}> {
|
|
4
|
+
switch (typeof value) {
|
|
5
|
+
case "object":
|
|
6
|
+
return ${imports.Either}.of(value);
|
|
7
|
+
case "undefined":
|
|
8
|
+
return ${imports.Either}.of(${imports.dataFactory}.blankNode());
|
|
9
|
+
}
|
|
10
|
+
}`);
|
|
11
|
+
//# sourceMappingURL=snippets_convertToBlankNode.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToBlankNodeIdentifierProperty = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBlankNodeIdentifierProperty`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToBlankNodeIdentifierProperty(identifier: (() => ${imports.BlankNode}) | ${imports.BlankNode} | undefined): ${imports.Either}<Error, (() => ${imports.BlankNode})> {
|
|
4
|
+
switch (typeof identifier) {
|
|
5
|
+
case "function":
|
|
6
|
+
return ${imports.Either}.of(identifier);
|
|
7
|
+
case "object": {
|
|
8
|
+
const captureIdentifier = identifier;
|
|
9
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
10
|
+
}
|
|
11
|
+
case "undefined": {
|
|
12
|
+
const captureIdentifier = ${imports.dataFactory}.blankNode();
|
|
13
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}`);
|
|
17
|
+
//# sourceMappingURL=snippets_convertToBlankNodeIdentifierProperty.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToIdentifier = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIdentifier`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIdentifier(value: ${imports.BlankNode} | ${imports.NamedNode} | string | undefined): ${imports.Either}<Error, ${imports.BlankNode} | ${imports.NamedNode}> {
|
|
4
|
+
switch (typeof value) {
|
|
5
|
+
case "object":
|
|
6
|
+
return ${imports.Either}.of(value);
|
|
7
|
+
case "string":
|
|
8
|
+
return ${imports.Either}.of(${imports.dataFactory}.namedNode(value));
|
|
9
|
+
case "undefined":
|
|
10
|
+
return ${imports.Either}.of(${imports.dataFactory}.blankNode());
|
|
11
|
+
}
|
|
12
|
+
}`);
|
|
13
|
+
//# sourceMappingURL=snippets_convertToIdentifier.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToIdentifierProperty = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIdentifierProperty`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIdentifierProperty(identifier: (() => ${imports.BlankNode} | ${imports.NamedNode}) | ${imports.BlankNode} | ${imports.NamedNode} | string | undefined): ${imports.Either}<Error, (() => ${imports.BlankNode} | ${imports.NamedNode})> {
|
|
4
|
+
switch (typeof identifier) {
|
|
5
|
+
case "function":
|
|
6
|
+
return ${imports.Either}.of(identifier);
|
|
7
|
+
case "object": {
|
|
8
|
+
const captureIdentifier = identifier;
|
|
9
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
10
|
+
}
|
|
11
|
+
case "string": {
|
|
12
|
+
const captureIdentifier = ${imports.dataFactory}.namedNode(identifier);
|
|
13
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
14
|
+
}
|
|
15
|
+
case "undefined": {
|
|
16
|
+
const captureIdentifier = ${imports.dataFactory}.blankNode();
|
|
17
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}`);
|
|
21
|
+
//# sourceMappingURL=snippets_convertToIdentifierProperty.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToIri = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIri`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIri<IriT extends string = string>(value: IriT | ${imports.NamedNode}<IriT>): ${imports.Either}<Error, ${imports.NamedNode}<IriT>> {
|
|
4
|
+
switch (typeof value) {
|
|
5
|
+
case "object":
|
|
6
|
+
return ${imports.Either}.of(value);
|
|
7
|
+
case "string":
|
|
8
|
+
return ${imports.Either}.of(${imports.dataFactory}.namedNode<IriT>(value));
|
|
9
|
+
}
|
|
10
|
+
}`);
|
|
11
|
+
//# sourceMappingURL=snippets_convertToIri.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToIriIdentifierProperty = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIriIdentifierProperty`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIriIdentifierProperty<IriT extends string = string>(identifier: (() => ${imports.NamedNode}<IriT>) | ${imports.NamedNode}<IriT> | IriT): ${imports.Either}<Error, (() => ${imports.NamedNode}<IriT>)> {
|
|
4
|
+
switch (typeof identifier) {
|
|
5
|
+
case "function":
|
|
6
|
+
return ${imports.Either}.of(identifier);
|
|
7
|
+
case "object": {
|
|
8
|
+
const captureIdentifier = identifier;
|
|
9
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
10
|
+
}
|
|
11
|
+
case "string": {
|
|
12
|
+
const captureIdentifier = ${imports.dataFactory}.namedNode<IriT>(identifier);
|
|
13
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}`);
|
|
17
|
+
//# sourceMappingURL=snippets_convertToIriIdentifierProperty.js.map
|