@shaclmate/compiler 4.0.34 → 4.0.36
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/generators/ts/AbstractCollectionType.d.ts +2 -1
- package/dist/generators/ts/AbstractCollectionType.js +14 -13
- package/dist/generators/ts/AbstractContainerType.d.ts +2 -0
- package/dist/generators/ts/AbstractContainerType.js +20 -0
- package/dist/generators/ts/AbstractDateType.d.ts +1 -1
- package/dist/generators/ts/AbstractDateType.js +3 -3
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +1 -0
- package/dist/generators/ts/AbstractLazyObjectType.js +1 -0
- package/dist/generators/ts/AbstractLiteralType.d.ts +1 -1
- package/dist/generators/ts/AbstractLiteralType.js +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.js +33 -20
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -8
- package/dist/generators/ts/AbstractNumericType.js +2 -16
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
- package/dist/generators/ts/AbstractPrimitiveType.js +2 -1
- package/dist/generators/ts/AbstractTermType.d.ts +2 -1
- package/dist/generators/ts/AbstractTermType.js +3 -2
- package/dist/generators/ts/AbstractType.d.ts +19 -8
- package/dist/generators/ts/AbstractUnionType.d.ts +3 -2
- package/dist/generators/ts/AbstractUnionType.js +14 -13
- package/dist/generators/ts/BigDecimalType.d.ts +3 -2
- package/dist/generators/ts/BigDecimalType.js +5 -12
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +3 -2
- package/dist/generators/ts/BlankNodeType.js +6 -5
- package/dist/generators/ts/BooleanType.d.ts +1 -2
- package/dist/generators/ts/BooleanType.js +2 -16
- package/dist/generators/ts/DateTimeType.d.ts +0 -1
- package/dist/generators/ts/DateTimeType.js +0 -9
- package/dist/generators/ts/DateType.d.ts +0 -1
- package/dist/generators/ts/DateType.js +0 -9
- package/dist/generators/ts/DefaultValueType.d.ts +2 -1
- package/dist/generators/ts/DefaultValueType.js +5 -4
- package/dist/generators/ts/IdentifierType.d.ts +3 -2
- package/dist/generators/ts/IdentifierType.js +6 -5
- package/dist/generators/ts/IriType.d.ts +3 -11
- package/dist/generators/ts/IriType.js +6 -5
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +3 -3
- package/dist/generators/ts/LazyObjectSetType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectSetType.js +3 -3
- package/dist/generators/ts/LazyObjectType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectType.js +3 -3
- package/dist/generators/ts/LiteralType.d.ts +2 -1
- package/dist/generators/ts/LiteralType.js +4 -3
- package/dist/generators/ts/NamedObjectType.d.ts +2 -1
- package/dist/generators/ts/NamedObjectType.js +9 -16
- package/dist/generators/ts/NamedObjectUnionType.js +14 -5
- package/dist/generators/ts/OptionType.d.ts +4 -3
- package/dist/generators/ts/OptionType.js +20 -17
- package/dist/generators/ts/Snippets.d.ts +7 -11
- package/dist/generators/ts/Snippets.js +46 -74
- package/dist/generators/ts/StringType.d.ts +1 -2
- package/dist/generators/ts/StringType.js +2 -16
- package/dist/generators/ts/TermType.d.ts +2 -1
- package/dist/generators/ts/TermType.js +6 -16
- package/dist/generators/ts/TsFeature.d.ts +1 -1
- package/dist/generators/ts/TsFeature.js +25 -7
- package/dist/generators/ts/TsGenerator.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.js +66 -8
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +6 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +6 -2
- 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 +30 -9
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +6 -6
- 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 +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +6 -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_schemaVariableStatement.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +6 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +3 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +26 -4
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +3 -0
- 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_PropertyPath.js +12 -6
- 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.js +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +3 -3
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +4 -4
- 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_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.js +1 -1
- package/dist/generators/ts/objectSetDeclarations.js +7 -10
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +0 -6
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +0 -6
- package/dist/input/generated.d.ts +8 -8
- package/dist/input/generated.js +188 -191
- package/package.json +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToDate.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +0 -14
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToObject.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +0 -14
- package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToString.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToTerm.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToUnion.js +0 -6
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +0 -12
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +0 -21
|
@@ -29,9 +29,13 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
29
29
|
this.recursive = recursive;
|
|
30
30
|
}
|
|
31
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
|
+
}
|
|
32
36
|
let hasQuestionToken = false;
|
|
33
37
|
const typeNames = [];
|
|
34
|
-
for (const type of
|
|
38
|
+
for (const type of conversionFunction.sourceTypes) {
|
|
35
39
|
if (type.typeof === "undefined") {
|
|
36
40
|
hasQuestionToken = true;
|
|
37
41
|
}
|
|
@@ -98,7 +102,9 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
98
102
|
...super.schemaObject,
|
|
99
103
|
// comment: this.comment.map(JSON.stringify).extract(),
|
|
100
104
|
// description: this.description.map(JSON.stringify).extract(),
|
|
101
|
-
path: this.configuration.features.has("
|
|
105
|
+
path: this.configuration.features.has("Object.fromRdf") ||
|
|
106
|
+
this.configuration.features.has("Object.toRdf") ||
|
|
107
|
+
this.configuration.features.has("Object.SPARQL")
|
|
102
108
|
? this.propertyPathToCode(this.path)
|
|
103
109
|
: undefined,
|
|
104
110
|
// label: this.label.map(JSON.stringify).extract(),
|
|
@@ -111,7 +117,23 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
111
117
|
};
|
|
112
118
|
}
|
|
113
119
|
constructorInitializer({ variables, }) {
|
|
114
|
-
|
|
120
|
+
const parameterVariable = code `${variables.parameters}.${this.name}`;
|
|
121
|
+
const conversionFunction = this.type.conversionFunction.extract()?.code;
|
|
122
|
+
const validationFunction = this.type.validationFunction.extract();
|
|
123
|
+
let rhs;
|
|
124
|
+
if (conversionFunction && validationFunction) {
|
|
125
|
+
rhs = code `${conversionFunction}(${parameterVariable}).chain(value => ${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), value))`;
|
|
126
|
+
}
|
|
127
|
+
else if (conversionFunction) {
|
|
128
|
+
rhs = code `${conversionFunction}(${parameterVariable})`;
|
|
129
|
+
}
|
|
130
|
+
else if (validationFunction) {
|
|
131
|
+
rhs = code `${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), ${parameterVariable})`;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
rhs = code `${this.reusables.imports.Either}.of(${parameterVariable})`;
|
|
135
|
+
}
|
|
136
|
+
return Maybe.of(code `${this.name}: ${rhs}`);
|
|
115
137
|
}
|
|
116
138
|
fromJsonInitializer({ variables, }) {
|
|
117
139
|
return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
|
|
@@ -191,7 +213,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
191
213
|
default:
|
|
192
214
|
return [];
|
|
193
215
|
}
|
|
194
|
-
const propertyPath = this.
|
|
216
|
+
const propertyPath = code `${this.namedObjectType.name}.schema.properties.${this.name}.path`;
|
|
195
217
|
return [
|
|
196
218
|
code `${variables.resource}.add(${propertyPath}, ${this.type.toRdfResourceValuesExpression({
|
|
197
219
|
variables: { ...variables, propertyPath },
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { code } from "../ts-poet-wrapper.js";
|
|
2
2
|
export function identifierTypeDeclarations() {
|
|
3
|
+
if (!this.configuration.features.has("Object.type")) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
3
6
|
const ancestorObjectTypeWithSameIdentifierType = this.ancestorObjectTypes.find((ancestorObjectType) => ancestorObjectType.identifierType.name === this.identifierType.name);
|
|
4
7
|
if (ancestorObjectTypeWithSameIdentifierType) {
|
|
5
8
|
// This object type's identifier type has the same identifier type as an ancestor object type,
|
|
@@ -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
|
|
@@ -4,17 +4,19 @@ import { code, conditionalOutput, joinCode, } from "../ts-poet-wrapper.js";
|
|
|
4
4
|
*/
|
|
5
5
|
export const snippets_PropertyPath = ({ configuration, imports, snippets, syntheticNamePrefix, }) => {
|
|
6
6
|
const companionDeclarations = [];
|
|
7
|
-
if (configuration.features.has("equals")) {
|
|
7
|
+
if (configuration.features.has("Object.equals")) {
|
|
8
8
|
companionDeclarations.push(code `\
|
|
9
9
|
export function equals(left: ${syntheticNamePrefix}PropertyPath, right: ${syntheticNamePrefix}PropertyPath): ${snippets.EqualsResult} {
|
|
10
10
|
return ${snippets.EqualsResult}.fromBooleanEqualsResult(left, right, ${imports.RdfxResourcePropertyPath}.equals(left, right));
|
|
11
11
|
}`);
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
if (configuration.features.has("Object.filter")) {
|
|
14
|
+
companionDeclarations.push(code `export type Filter = object`, code `\
|
|
14
15
|
export function filter(_filter: Filter, _value: ${syntheticNamePrefix}PropertyPath): boolean {
|
|
15
16
|
return true;
|
|
16
17
|
}`);
|
|
17
|
-
|
|
18
|
+
}
|
|
19
|
+
if (configuration.features.has("Object.fromRdf")) {
|
|
18
20
|
companionDeclarations.push(code `\
|
|
19
21
|
export const fromRdfResource: ${snippets.FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;`, code `\
|
|
20
22
|
export const fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
|
|
@@ -26,12 +28,16 @@ export const fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${
|
|
|
26
28
|
),
|
|
27
29
|
);`);
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (configuration.features.has("Object.schema")) {
|
|
32
|
+
companionDeclarations.push(code `export const schema: Readonly<object> = {}`);
|
|
33
|
+
}
|
|
34
|
+
if (configuration.features.has("Object.toRdf")) {
|
|
31
35
|
companionDeclarations.push(code `\
|
|
32
36
|
export const toRdfResource: ${snippets.ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;`);
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
if (configuration.features.has("Object.toString")) {
|
|
39
|
+
companionDeclarations.push(code `export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;`);
|
|
40
|
+
}
|
|
35
41
|
return conditionalOutput(`${syntheticNamePrefix}PropertyPath`, code `\
|
|
36
42
|
export type ${syntheticNamePrefix}PropertyPath = ${imports.RdfxResourcePropertyPath};
|
|
37
43
|
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_convertToBlankNode = ({ imports,
|
|
3
|
-
function ${syntheticNamePrefix}convertToBlankNode(
|
|
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
4
|
switch (typeof value) {
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_convertToIdentifier = ({ imports,
|
|
3
|
-
function ${syntheticNamePrefix}convertToIdentifier(
|
|
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
4
|
switch (typeof value) {
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_convertToIri = ({ imports,
|
|
3
|
-
function ${syntheticNamePrefix}convertToIri<IriT extends string = string>(
|
|
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
4
|
switch (typeof value) {
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLazyObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLazyObject`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}convertToLazyObject<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }>(resolvedToPartial: (resolved: ResolvedObjectT) => PartialObjectT) {
|
|
4
|
-
return (
|
|
4
|
+
return (value: ${snippets.LazyObject}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT> | ResolvedObjectT): ${imports.Either}<Error, ${snippets.LazyObject}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT>> => {
|
|
5
5
|
if (value instanceof ${snippets.LazyObject}) {
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLazyObjectOption = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLazyObjectOption`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}convertToLazyObjectOption<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }>(resolvedToPartial: (resolved: ResolvedObjectT) => PartialObjectT) {
|
|
4
|
-
return (
|
|
4
|
+
return (value: ${snippets.LazyObjectOption}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT> | ${imports.Maybe}<ResolvedObjectT> | ResolvedObjectT | undefined): ${imports.Either}<Error, ${snippets.LazyObjectOption}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT>> => {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "object": {
|
|
7
7
|
if (value instanceof ${snippets.LazyObjectOption}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLazyObjectSet = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLazyObjectSet`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}convertToLazyObjectSet<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }>(resolvedToPartial: (resolved: ResolvedObjectT) => PartialObjectT) {
|
|
4
|
-
return (
|
|
4
|
+
return (value: ${snippets.LazyObjectSet}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT> | readonly ResolvedObjectT[] | undefined): ${imports.Either}<Error, ${snippets.LazyObjectSet}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT>> => {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "object": {
|
|
7
7
|
if (value instanceof ${snippets.LazyObjectSet}) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLiteral = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLiteral`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}convertToLiteral(
|
|
3
|
+
function ${syntheticNamePrefix}convertToLiteral(value: bigint | boolean | Date | number | string | ${imports.Literal}): ${imports.Either}<Error, ${imports.Literal}> {
|
|
4
4
|
if (typeof value === "object") {
|
|
5
5
|
if (value instanceof Date) {
|
|
6
6
|
return ${imports.Either}.of(${snippets.literalFactory}.date(value));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToMaybe = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToMaybe`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}convertToMaybe<
|
|
4
|
-
return (
|
|
3
|
+
function ${syntheticNamePrefix}convertToMaybe<ItemSourceT, ItemTargetT>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>) {
|
|
4
|
+
return (value: ItemSourceT | ${imports.Maybe}<ItemTargetT> | undefined): ${imports.Either}<Error, ${imports.Maybe}<ItemTargetT>> => {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "object": {
|
|
7
7
|
if (${imports.Maybe}.isMaybe(value)) {
|
|
@@ -13,7 +13,7 @@ function ${syntheticNamePrefix}convertToMaybe<ItemSchemaT, ItemSourceT, ItemTarg
|
|
|
13
13
|
return ${imports.Either}.of(${imports.Maybe}.empty());
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
return convertToItem(
|
|
16
|
+
return convertToItem(value).map(${imports.Maybe}.of);
|
|
17
17
|
}
|
|
18
18
|
}`);
|
|
19
19
|
//# sourceMappingURL=snippets_convertToMaybe.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertWithDefaultValue = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertWithDefaultValue`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}convertWithDefaultValue<
|
|
4
|
-
return (
|
|
3
|
+
function ${syntheticNamePrefix}convertWithDefaultValue<ItemSourceT, ItemTargetT>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, defaultValue: ItemSourceT) {
|
|
4
|
+
return (value: ItemSourceT | undefined): ${imports.Either}<Error, ItemTargetT> => {
|
|
5
5
|
if (typeof value === "undefined") {
|
|
6
|
-
return convertToItem(
|
|
6
|
+
return convertToItem(defaultValue);
|
|
7
7
|
}
|
|
8
|
-
return convertToItem(
|
|
8
|
+
return convertToItem(value);
|
|
9
9
|
}
|
|
10
10
|
}`);
|
|
11
11
|
//# sourceMappingURL=snippets_convertWithDefaultValue.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_identityConversionFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identityConversionFunction`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}identityConversionFunction<T>(value: T): ${imports.Either}<Error, T> {
|
|
4
|
+
return ${imports.Either}.of(value);
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_identityConversionFunction.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_identityValidationFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identityValidationFunction`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}identityValidationFunction<T>(_schema: unknown, value: T): ${imports.Either}<Error, T> {
|
|
4
|
+
return ${imports.Either}.of(value);
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_identityValidationFunction.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_validateArray = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}validateArray`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}validateArray<ItemSchemaT, ItemValueT, Readonly extends boolean>(validateItem: ${snippets.ValidationFunction}<ItemSchemaT, ItemValueT>, _readonly: Readonly) {
|
|
4
|
+
type EitherR = Readonly extends true ? ReadonlyArray<ItemValueT> : Array<ItemValueT>;
|
|
5
|
+
return (schema: ${snippets.CollectionSchema}<ItemSchemaT>, valueArray: readonly ItemValueT[]): ${imports.Either}<Error, EitherR> => {
|
|
6
|
+
if (schema.minCount !== undefined && valueArray.length < schema.minCount) {
|
|
7
|
+
return ${imports.Left}(new Error(\`value array has length (\${valueArray.length}) less than minCount (\${schema.minCount})\`)) as ${imports.Either}<Error, EitherR>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return ${imports.Either}.sequence(valueArray.map(value => validateItem(schema.item(), value))) as ${imports.Either}<Error, EitherR>;
|
|
11
|
+
}
|
|
12
|
+
}`);
|
|
13
|
+
//# sourceMappingURL=snippets_validateArray.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_validateMaybe = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}validateMaybe`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}validateMaybe<ItemSchemaT, ItemValueT>(validateItem: ${snippets.ValidationFunction}<ItemSchemaT, ItemValueT>) {
|
|
4
|
+
return (schema: ${snippets.MaybeSchema}<ItemSchemaT>, valueMaybe: ${imports.Maybe}<ItemValueT>): ${imports.Either}<Error, ${imports.Maybe}<ItemValueT>> =>
|
|
5
|
+
valueMaybe.map(value => validateItem(schema.item(), value).map(() => valueMaybe)).orDefault(${imports.Either}.of(valueMaybe));
|
|
6
|
+
}`);
|
|
7
|
+
//# sourceMappingURL=snippets_validateMaybe.js.map
|
|
@@ -69,7 +69,7 @@ async (_source, _args, { objectSet }): Promise<number> => (await objectSet.${nam
|
|
|
69
69
|
}, {})} })`;
|
|
70
70
|
}
|
|
71
71
|
export function graphqlSchemaVariableStatement({ namedObjectTypes, namedObjectUnionTypes, }) {
|
|
72
|
-
if (!this.configuration.features.has("
|
|
72
|
+
if (!this.configuration.features.has("GraphQL")) {
|
|
73
73
|
return Maybe.empty();
|
|
74
74
|
}
|
|
75
75
|
namedObjectTypes = namedObjectTypes.filter((namedObjectType) => !namedObjectType.synthetic);
|
|
@@ -3,23 +3,20 @@ import { rdfjsDatasetObjectSetClassDeclaration } from "./rdfjsDatasetObjectSetCl
|
|
|
3
3
|
import { sparqlObjectSetClassDeclaration } from "./sparqlObjectSetClassDeclaration.js";
|
|
4
4
|
export function objectSetDeclarations({ namedObjectUnionTypes, ...parameters }) {
|
|
5
5
|
const namedObjectTypes = parameters.namedObjectTypes.filter((namedObjectType) => !namedObjectType.extern && !namedObjectType.synthetic);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const declarations = [
|
|
11
|
-
objectSetInterfaceDeclaration.call(this, {
|
|
6
|
+
const declarations = [];
|
|
7
|
+
if (this.configuration.features.has("ObjectSet")) {
|
|
8
|
+
declarations.push(objectSetInterfaceDeclaration.call(this, {
|
|
12
9
|
namedObjectTypes: namedObjectTypes,
|
|
13
10
|
namedObjectUnionTypes,
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
if (this.configuration.features.has("
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
if (this.configuration.features.has("RdfjsDatasetObjectSet")) {
|
|
17
14
|
declarations.push(rdfjsDatasetObjectSetClassDeclaration.call(this, {
|
|
18
15
|
namedObjectTypes: namedObjectTypes,
|
|
19
16
|
namedObjectUnionTypes,
|
|
20
17
|
}));
|
|
21
18
|
}
|
|
22
|
-
if (this.configuration.features.has("
|
|
19
|
+
if (this.configuration.features.has("SparqlObjectSet")) {
|
|
23
20
|
declarations.push(sparqlObjectSetClassDeclaration.call(this, {
|
|
24
21
|
namedObjectTypes: namedObjectTypes,
|
|
25
22
|
namedObjectUnionTypes,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
|
|
2
2
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
3
|
-
import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
|
|
4
3
|
export function rdfjsDatasetObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
|
|
5
4
|
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
6
5
|
const namedObjectTypeType = code `\
|
|
@@ -40,11 +39,6 @@ export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticN
|
|
|
40
39
|
|
|
41
40
|
${joinCode([
|
|
42
41
|
...[...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
43
|
-
if (!this.configuration.features.has("rdf")) {
|
|
44
|
-
return Object.values(unsupportedObjectSetMethodDeclarations.call(this, {
|
|
45
|
-
namedObjectType,
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
42
|
const methodSignatures = objectSetMethodSignatures.call(this, {
|
|
49
43
|
namedObjectType,
|
|
50
44
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
|
|
2
2
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
3
|
-
import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
|
|
4
3
|
export function sparqlObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
|
|
5
4
|
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
6
5
|
const parameters = {
|
|
@@ -32,11 +31,6 @@ export class ${syntheticNamePrefix}SparqlObjectSet implements ${syntheticNamePre
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
${joinCode([...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
35
|
-
if (!this.configuration.features.has("sparql")) {
|
|
36
|
-
return Object.values(unsupportedObjectSetMethodDeclarations.call(this, {
|
|
37
|
-
namedObjectType,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
34
|
const methodSignatures = objectSetMethodSignatures.call(this, {
|
|
41
35
|
namedObjectType,
|
|
42
36
|
queryT: `${syntheticNamePrefix}SparqlObjectSet.Query`,
|
|
@@ -178,7 +178,7 @@ export interface PropertyShape {
|
|
|
178
178
|
}
|
|
179
179
|
export declare namespace PropertyShape {
|
|
180
180
|
function create(parameters: {
|
|
181
|
-
readonly $identifier?: (() => PropertyShape.Identifier) |
|
|
181
|
+
readonly $identifier?: (() => PropertyShape.Identifier) | BlankNode | NamedNode | string;
|
|
182
182
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
183
183
|
readonly classes?: readonly (string | NamedNode)[];
|
|
184
184
|
readonly comment?: string | Maybe<string>;
|
|
@@ -217,7 +217,7 @@ export declare namespace PropertyShape {
|
|
|
217
217
|
readonly xone?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
218
218
|
}): Either<Error, PropertyShape>;
|
|
219
219
|
function createUnsafe(parameters: {
|
|
220
|
-
readonly $identifier?: (() => PropertyShape.Identifier) |
|
|
220
|
+
readonly $identifier?: (() => PropertyShape.Identifier) | BlankNode | NamedNode | string;
|
|
221
221
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
222
222
|
readonly classes?: readonly (string | NamedNode)[];
|
|
223
223
|
readonly comment?: string | Maybe<string>;
|
|
@@ -708,12 +708,12 @@ export interface PropertyGroup {
|
|
|
708
708
|
}
|
|
709
709
|
export declare namespace PropertyGroup {
|
|
710
710
|
function create(parameters?: {
|
|
711
|
-
readonly $identifier?: (() => PropertyGroup.Identifier) |
|
|
711
|
+
readonly $identifier?: (() => PropertyGroup.Identifier) | BlankNode | NamedNode | string;
|
|
712
712
|
readonly comment?: string | Maybe<string>;
|
|
713
713
|
readonly label?: string | Maybe<string>;
|
|
714
714
|
}): Either<Error, PropertyGroup>;
|
|
715
715
|
function createUnsafe(parameters?: {
|
|
716
|
-
readonly $identifier?: (() => PropertyGroup.Identifier) |
|
|
716
|
+
readonly $identifier?: (() => PropertyGroup.Identifier) | BlankNode | NamedNode | string;
|
|
717
717
|
readonly comment?: string | Maybe<string>;
|
|
718
718
|
readonly label?: string | Maybe<string>;
|
|
719
719
|
}): PropertyGroup;
|
|
@@ -784,12 +784,12 @@ export interface Ontology {
|
|
|
784
784
|
}
|
|
785
785
|
export declare namespace Ontology {
|
|
786
786
|
function create(parameters?: {
|
|
787
|
-
readonly $identifier?: (() => Ontology.Identifier) |
|
|
787
|
+
readonly $identifier?: (() => Ontology.Identifier) | BlankNode | NamedNode | string;
|
|
788
788
|
readonly comment?: string | Maybe<string>;
|
|
789
789
|
readonly label?: string | Maybe<string>;
|
|
790
790
|
}): Either<Error, Ontology>;
|
|
791
791
|
function createUnsafe(parameters?: {
|
|
792
|
-
readonly $identifier?: (() => Ontology.Identifier) |
|
|
792
|
+
readonly $identifier?: (() => Ontology.Identifier) | BlankNode | NamedNode | string;
|
|
793
793
|
readonly comment?: string | Maybe<string>;
|
|
794
794
|
readonly label?: string | Maybe<string>;
|
|
795
795
|
}): Ontology;
|
|
@@ -896,7 +896,7 @@ export interface NodeShape {
|
|
|
896
896
|
}
|
|
897
897
|
export declare namespace NodeShape {
|
|
898
898
|
function create(parameters?: {
|
|
899
|
-
readonly $identifier?: (() => NodeShape.Identifier) |
|
|
899
|
+
readonly $identifier?: (() => NodeShape.Identifier) | BlankNode | NamedNode | string;
|
|
900
900
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
901
901
|
readonly classes?: readonly (string | NamedNode)[];
|
|
902
902
|
readonly closed?: boolean | Maybe<boolean>;
|
|
@@ -937,7 +937,7 @@ export declare namespace NodeShape {
|
|
|
937
937
|
readonly xone?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
938
938
|
}): Either<Error, NodeShape>;
|
|
939
939
|
function createUnsafe(parameters?: {
|
|
940
|
-
readonly $identifier?: (() => NodeShape.Identifier) |
|
|
940
|
+
readonly $identifier?: (() => NodeShape.Identifier) | BlankNode | NamedNode | string;
|
|
941
941
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
942
942
|
readonly classes?: readonly (string | NamedNode)[];
|
|
943
943
|
readonly closed?: boolean | Maybe<boolean>;
|