@shaclmate/compiler 4.0.9 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapesGraphToAstTransformer.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +4 -1
- package/dist/ast/AbstractCompoundType.js +0 -2
- package/dist/ast/Ast.d.ts +1 -1
- package/dist/ast/IntersectionType.js +4 -3
- package/dist/ast/UnionType.js +3 -2
- package/dist/generators/json/AstJsonGenerator.js +1 -1
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +2 -2
- package/dist/generators/ts/AbstractContainerType.d.ts +2 -2
- package/dist/generators/ts/AbstractContainerType.js +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +3 -3
- package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.js +17 -15
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractNumericType.js +1 -1
- package/dist/generators/ts/AbstractType.d.ts +5 -5
- package/dist/generators/ts/AbstractUnionType.d.ts +1 -1
- package/dist/generators/ts/AbstractUnionType.js +6 -6
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +2 -2
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +2 -2
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +1 -1
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +1 -1
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +1 -1
- package/dist/generators/ts/DefaultValueType.js +3 -3
- package/dist/generators/ts/IdentifierType.d.ts +1 -1
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +1 -1
- package/dist/generators/ts/IriType.js +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +1 -1
- package/dist/generators/ts/LazyObjectType.js +2 -2
- package/dist/generators/ts/ListType.d.ts +2 -2
- package/dist/generators/ts/ListType.js +1 -1
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +1 -1
- package/dist/generators/ts/{ObjectType.d.ts → NamedObjectType.d.ts} +28 -28
- package/dist/generators/ts/{ObjectType.js → NamedObjectType.js} +105 -97
- package/dist/generators/ts/NamedObjectUnionType.d.ts +4 -4
- package/dist/generators/ts/NamedObjectUnionType.js +8 -12
- package/dist/generators/ts/OptionType.d.ts +1 -1
- package/dist/generators/ts/OptionType.js +2 -2
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/StringType.js +1 -1
- package/dist/generators/ts/TermType.d.ts +1 -1
- package/dist/generators/ts/TermType.js +1 -1
- package/dist/generators/ts/TsGenerator.js +8 -8
- package/dist/generators/ts/Type.d.ts +2 -2
- package/dist/generators/ts/TypeFactory.d.ts +2 -2
- package/dist/generators/ts/TypeFactory.js +36 -36
- package/dist/generators/ts/ZodGenerator.js +14 -12
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.d.ts +6 -6
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/DiscriminantProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/DiscriminantProperty.js +13 -11
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.js +4 -4
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.js +24 -24
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_classDeclaration.js → _NamedObjectType/NamedObjectType_classDeclaration.js} +14 -14
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_createFunctionDeclaration.js → _NamedObjectType/NamedObjectType_createFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterFunctionDeclaration.js → _NamedObjectType/NamedObjectType_filterFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterTypeDeclaration.js → _NamedObjectType/NamedObjectType_filterTypeDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromJsonFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfTypeVariableStatement.js → _NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_graphqlTypeVariableStatement.js → _NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.js → _NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_interfaceDeclaration.js → _NamedObjectType/NamedObjectType_interfaceDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_isTypeFunctionDeclaration.js → _NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonTypeAliasDeclaration.js → _NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_objectSetMethodNames.js → _NamedObjectType/NamedObjectType_objectSetMethodNames.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.js → _NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.js → _NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_schemaVariableStatement.js → _NamedObjectType/NamedObjectType_schemaVariableStatement.js} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.d.ts +1 -1
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.js +8 -8
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +23 -23
- package/dist/generators/ts/objectSetDeclarations.d.ts +2 -2
- package/dist/generators/ts/objectSetDeclarations.js +19 -16
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +3 -3
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +6 -4
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +4 -4
- package/dist/generators/ts/objectSetMethodSignatures.js +9 -9
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +47 -45
- package/dist/generators/ts/singleEntryRecord.d.ts +2 -0
- package/dist/generators/ts/singleEntryRecord.js +6 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +17 -17
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -2
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +8 -8
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +5 -5
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +2 -2
- package/package.json +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +0 -9
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.d.ts +0 -0
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/identifierTypeDeclarations.js +0 -0
|
@@ -2,30 +2,30 @@ import { imports } from "./imports.js";
|
|
|
2
2
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
3
3
|
import { code } from "./ts-poet-wrapper.js";
|
|
4
4
|
export function objectSetMethodSignatures(parameters) {
|
|
5
|
-
const {
|
|
5
|
+
const { namedObjectType } = parameters;
|
|
6
6
|
const parameterNamePrefix = parameters?.parameterNamePrefix ?? "";
|
|
7
7
|
const queryT = parameters.queryT ?? `${syntheticNamePrefix}ObjectSet.Query`;
|
|
8
|
-
const methodNames =
|
|
8
|
+
const methodNames = namedObjectType.objectSetMethodNames;
|
|
9
9
|
return {
|
|
10
10
|
object: {
|
|
11
11
|
name: methodNames.object,
|
|
12
|
-
parameters: code `${parameterNamePrefix}identifier: ${
|
|
13
|
-
returnType: code `Promise<${imports.Either}<Error, ${
|
|
12
|
+
parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
|
|
13
|
+
returnType: code `Promise<${imports.Either}<Error, ${namedObjectType.name}>>`,
|
|
14
14
|
},
|
|
15
15
|
objectCount: {
|
|
16
16
|
name: methodNames.objectCount,
|
|
17
|
-
parameters: code `${parameterNamePrefix}query?: Pick<${queryT}<${
|
|
17
|
+
parameters: code `${parameterNamePrefix}query?: Pick<${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>, "filter">`,
|
|
18
18
|
returnType: code `Promise<${imports.Either}<Error, number>>`,
|
|
19
19
|
},
|
|
20
20
|
objectIdentifiers: {
|
|
21
21
|
name: methodNames.objectIdentifiers,
|
|
22
|
-
parameters: code `${parameterNamePrefix}query?: ${queryT}<${
|
|
23
|
-
returnType: code `Promise<${imports.Either}<Error, readonly ${
|
|
22
|
+
parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
|
|
23
|
+
returnType: code `Promise<${imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]>>`,
|
|
24
24
|
},
|
|
25
25
|
objects: {
|
|
26
26
|
name: methodNames.objects,
|
|
27
|
-
parameters: code `${parameterNamePrefix}query?: ${queryT}<${
|
|
28
|
-
returnType: code `Promise<${imports.Either}<Error, readonly ${
|
|
27
|
+
parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
|
|
28
|
+
returnType: code `Promise<${imports.Either}<Error, readonly ${namedObjectType.name}[]>>`,
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
1
2
|
import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
2
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
3
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
|
-
export declare function rdfjsDatasetObjectSetClassDeclaration({
|
|
5
|
-
|
|
4
|
+
export declare function rdfjsDatasetObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }: {
|
|
5
|
+
namedObjectTypes: readonly NamedObjectType[];
|
|
6
6
|
namedObjectUnionTypes: readonly NamedObjectUnionType[];
|
|
7
7
|
}): Code;
|
|
8
8
|
//# sourceMappingURL=rdfjsDatasetObjectSetClassDeclaration.d.ts.map
|
|
@@ -4,8 +4,8 @@ import { snippets } from "./snippets.js";
|
|
|
4
4
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
5
5
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
6
6
|
import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
|
|
7
|
-
export function rdfjsDatasetObjectSetClassDeclaration({
|
|
8
|
-
const
|
|
7
|
+
export function rdfjsDatasetObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
|
|
8
|
+
const namedObjectTypeType = code `\
|
|
9
9
|
{
|
|
10
10
|
${syntheticNamePrefix}filter: (filter: ObjectFilterT, value: ObjectT) => boolean;
|
|
11
11
|
${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<ObjectT>;
|
|
@@ -41,13 +41,15 @@ export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticN
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
${joinCode([
|
|
44
|
-
...[...
|
|
45
|
-
if (!
|
|
44
|
+
...[...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
45
|
+
if (!namedObjectType.features.has("rdf")) {
|
|
46
46
|
return Object.values(unsupportedObjectSetMethodDeclarations({
|
|
47
|
-
|
|
47
|
+
namedObjectType,
|
|
48
48
|
}));
|
|
49
49
|
}
|
|
50
|
-
const methodSignatures = objectSetMethodSignatures({
|
|
50
|
+
const methodSignatures = objectSetMethodSignatures({
|
|
51
|
+
namedObjectType,
|
|
52
|
+
});
|
|
51
53
|
const delegatingMethods = [
|
|
52
54
|
// object
|
|
53
55
|
code `\
|
|
@@ -56,7 +58,7 @@ async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${
|
|
|
56
58
|
}`,
|
|
57
59
|
// objectSync
|
|
58
60
|
code `\
|
|
59
|
-
${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${imports.Either}<Error, ${
|
|
61
|
+
${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${imports.Either}<Error, ${namedObjectType.name}> {
|
|
60
62
|
return this.${methodSignatures.objects.name}Sync({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages }).map(objects => objects[0]);
|
|
61
63
|
}`,
|
|
62
64
|
// objectCount
|
|
@@ -76,7 +78,7 @@ async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdenti
|
|
|
76
78
|
}`,
|
|
77
79
|
// objectIdentifiersSync
|
|
78
80
|
code `\
|
|
79
|
-
${methodSignatures.objectIdentifiers.name}Sync(${methodSignatures.objectIdentifiers.parameters}): ${imports.Either}<Error, readonly ${
|
|
81
|
+
${methodSignatures.objectIdentifiers.name}Sync(${methodSignatures.objectIdentifiers.parameters}): ${imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]> {
|
|
80
82
|
return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.map(object => object.${syntheticNamePrefix}identifier));
|
|
81
83
|
}`,
|
|
82
84
|
// objects
|
|
@@ -86,37 +88,37 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
86
88
|
}`,
|
|
87
89
|
// objectsSync has per-object type logic, not just forwarding
|
|
88
90
|
];
|
|
89
|
-
const runtimeObjectType = (filterFunction,
|
|
90
|
-
const fromRdfTypes =
|
|
91
|
+
const runtimeObjectType = (filterFunction, namedObjectType) => {
|
|
92
|
+
const fromRdfTypes = namedObjectType.fromRdfTypeVariable
|
|
91
93
|
.toList()
|
|
92
|
-
.concat(
|
|
93
|
-
return code `{ ${syntheticNamePrefix}filter: ${filterFunction}, ${syntheticNamePrefix}fromRdfResource: ${
|
|
94
|
+
.concat(namedObjectType.descendantFromRdfTypeVariables);
|
|
95
|
+
return code `{ ${syntheticNamePrefix}filter: ${filterFunction}, ${syntheticNamePrefix}fromRdfResource: ${namedObjectType.staticModuleName}.${syntheticNamePrefix}fromRdfResource, ${syntheticNamePrefix}fromRdfTypes: ${fromRdfTypes.length > 0 ? code `[${joinCode(fromRdfTypes, { on: ", " })}]` : "[]"} }`;
|
|
94
96
|
};
|
|
95
|
-
switch (
|
|
96
|
-
case "
|
|
97
|
+
switch (namedObjectType.kind) {
|
|
98
|
+
case "NamedObjectType": {
|
|
97
99
|
return delegatingMethods.concat(code `\
|
|
98
|
-
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${imports.Either}<Error, readonly ${
|
|
99
|
-
return this.${syntheticNamePrefix}objectsSync<${
|
|
100
|
+
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${imports.Either}<Error, readonly ${namedObjectType.name}[]> {
|
|
101
|
+
return this.${syntheticNamePrefix}objectsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType.filterFunction, namedObjectType)}, query);
|
|
100
102
|
}`);
|
|
101
103
|
}
|
|
102
104
|
case "NamedObjectUnionType":
|
|
103
105
|
return delegatingMethods.concat(code `\
|
|
104
|
-
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${imports.Either}<Error, readonly ${
|
|
105
|
-
return this.${syntheticNamePrefix}objectUnionsSync<${
|
|
106
|
-
${joinCode(
|
|
106
|
+
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${imports.Either}<Error, readonly ${namedObjectType.name}[]> {
|
|
107
|
+
return this.${syntheticNamePrefix}objectUnionsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>([
|
|
108
|
+
${joinCode(namedObjectType.members
|
|
107
109
|
.filter((member) => !member.type.abstract)
|
|
108
|
-
.map((member) => runtimeObjectType(
|
|
110
|
+
.map((member) => runtimeObjectType(namedObjectType.filterFunction, member.type)), { on: ", " })}
|
|
109
111
|
], query);
|
|
110
112
|
}`);
|
|
111
113
|
default:
|
|
112
|
-
|
|
114
|
+
namedObjectType;
|
|
113
115
|
return [];
|
|
114
116
|
}
|
|
115
117
|
}),
|
|
116
|
-
...(
|
|
118
|
+
...(namedObjectTypes.length > 0
|
|
117
119
|
? [
|
|
118
120
|
code `\
|
|
119
|
-
protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(
|
|
121
|
+
protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(namedObjectType: ${namedObjectTypeType}, ${parameters.query}): ${imports.Either}<Error, readonly ObjectT[]> {
|
|
120
122
|
const graph = query?.graph ?? this.${syntheticNamePrefix}graph;
|
|
121
123
|
|
|
122
124
|
const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -133,11 +135,11 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
133
135
|
if (query?.identifiers) {
|
|
134
136
|
resources = query.identifiers.map(identifier => ({ resource: resourceSet.resource(identifier) }));
|
|
135
137
|
sortResources = false;
|
|
136
|
-
} else if (
|
|
138
|
+
} else if (namedObjectType.${syntheticNamePrefix}fromRdfTypes.length > 0) {
|
|
137
139
|
const identifierSet = new ${snippets.IdentifierSet}();
|
|
138
140
|
resources = [];
|
|
139
141
|
sortResources = true;
|
|
140
|
-
for (const fromRdfType of
|
|
142
|
+
for (const fromRdfType of namedObjectType.${syntheticNamePrefix}fromRdfTypes) {
|
|
141
143
|
for (const resource of resourceSet.instancesOf(fromRdfType, { graph })) {
|
|
142
144
|
if (!identifierSet.has(resource.identifier)) {
|
|
143
145
|
identifierSet.add(resource.identifier);
|
|
@@ -168,7 +170,7 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
168
170
|
identifierSet.add(quad.subject);
|
|
169
171
|
const resource = resourceSet.resource(quad.subject);
|
|
170
172
|
// Eagerly eliminate the majority of resources that won't match the object type
|
|
171
|
-
|
|
173
|
+
namedObjectType.${syntheticNamePrefix}fromRdfResource(resource, fromRdfResourceOptions).ifRight(object => {
|
|
172
174
|
resources.push({ object, resource });
|
|
173
175
|
});
|
|
174
176
|
}
|
|
@@ -183,14 +185,14 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
183
185
|
const objects: ObjectT[] = [];
|
|
184
186
|
for (let { object, resource } of resources) {
|
|
185
187
|
if (!object) {
|
|
186
|
-
const objectEither =
|
|
188
|
+
const objectEither = namedObjectType.${syntheticNamePrefix}fromRdfResource(resource, fromRdfResourceOptions);
|
|
187
189
|
if (objectEither.isLeft()) {
|
|
188
190
|
return objectEither;
|
|
189
191
|
}
|
|
190
192
|
object = objectEither.unsafeCoerce();
|
|
191
193
|
}
|
|
192
194
|
|
|
193
|
-
if (query?.filter && !
|
|
195
|
+
if (query?.filter && !namedObjectType.${syntheticNamePrefix}filter(query.filter, object)) {
|
|
194
196
|
continue;
|
|
195
197
|
}
|
|
196
198
|
|
|
@@ -208,7 +210,7 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
208
210
|
...(namedObjectUnionTypes.length > 0
|
|
209
211
|
? [
|
|
210
212
|
code `\
|
|
211
|
-
protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(
|
|
213
|
+
protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(namedObjectTypes: readonly ${namedObjectTypeType}[], ${parameters.query}): ${imports.Either}<Error, readonly ObjectT[]> {
|
|
212
214
|
const graph = query?.graph ?? this.${syntheticNamePrefix}graph;
|
|
213
215
|
|
|
214
216
|
const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -219,22 +221,22 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
219
221
|
|
|
220
222
|
const fromRdfResourceOptions: Parameters<${snippets.FromRdfResourceFunction}<ObjectT>>[1] = { graph, objectSet: this, preferredLanguages: query?.preferredLanguages };
|
|
221
223
|
|
|
222
|
-
let resources: { object?: ObjectT,
|
|
224
|
+
let resources: { object?: ObjectT, namedObjectType?: ${namedObjectTypeType}, resource: ${imports.Resource} }[];
|
|
223
225
|
const resourceSet = this.${syntheticNamePrefix}resourceSet(); // Access once, in case it's instantiated lazily
|
|
224
226
|
let sortResources: boolean;
|
|
225
227
|
if (query?.identifiers) {
|
|
226
228
|
resources = query.identifiers.map(identifier => ({ resource: resourceSet.resource(identifier) }));
|
|
227
229
|
sortResources = false;
|
|
228
|
-
} else if (
|
|
230
|
+
} else if (namedObjectTypes.every(namedObjectType => namedObjectType.${syntheticNamePrefix}fromRdfTypes.length > 0)) {
|
|
229
231
|
const identifierSet = new ${snippets.IdentifierSet}();
|
|
230
232
|
resources = [];
|
|
231
233
|
sortResources = true;
|
|
232
|
-
for (const
|
|
233
|
-
for (const fromRdfType of
|
|
234
|
+
for (const namedObjectType of namedObjectTypes) {
|
|
235
|
+
for (const fromRdfType of namedObjectType.${syntheticNamePrefix}fromRdfTypes) {
|
|
234
236
|
for (const resource of resourceSet.instancesOf(fromRdfType, { graph })) {
|
|
235
237
|
if (!identifierSet.has(resource.identifier)) {
|
|
236
238
|
identifierSet.add(resource.identifier);
|
|
237
|
-
resources.push({
|
|
239
|
+
resources.push({ namedObjectType, resource });
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
242
|
}
|
|
@@ -262,9 +264,9 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
262
264
|
identifierSet.add(quad.subject);
|
|
263
265
|
// Eagerly eliminate the majority of resources that won't match the object types
|
|
264
266
|
const resource = resourceSet.resource(quad.subject);
|
|
265
|
-
for (const
|
|
266
|
-
if (
|
|
267
|
-
resources.push({ object,
|
|
267
|
+
for (const namedObjectType of namedObjectTypes) {
|
|
268
|
+
if (namedObjectType.${syntheticNamePrefix}fromRdfResource(resource, fromRdfResourceOptions).ifRight(object => {
|
|
269
|
+
resources.push({ object, namedObjectType, resource });
|
|
268
270
|
}).isRight()) {
|
|
269
271
|
break;
|
|
270
272
|
}
|
|
@@ -279,17 +281,17 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
279
281
|
|
|
280
282
|
let objectI = 0;
|
|
281
283
|
const objects: ObjectT[] = [];
|
|
282
|
-
for (let { object,
|
|
284
|
+
for (let { object, namedObjectType, resource } of resources) {
|
|
283
285
|
if (!object) {
|
|
284
286
|
let objectEither: ${imports.Either}<Error, ObjectT>;
|
|
285
|
-
if (
|
|
286
|
-
objectEither =
|
|
287
|
+
if (namedObjectType) {
|
|
288
|
+
objectEither = namedObjectType.${syntheticNamePrefix}fromRdfResource(resource, fromRdfResourceOptions);
|
|
287
289
|
} else {
|
|
288
290
|
objectEither = ${imports.Left}(new Error("no object types"));
|
|
289
|
-
for (const tryObjectType of
|
|
291
|
+
for (const tryObjectType of namedObjectTypes) {
|
|
290
292
|
objectEither = tryObjectType.${syntheticNamePrefix}fromRdfResource(resource, fromRdfResourceOptions);
|
|
291
293
|
if (objectEither.isRight()) {
|
|
292
|
-
|
|
294
|
+
namedObjectType = tryObjectType;
|
|
293
295
|
break;
|
|
294
296
|
}
|
|
295
297
|
}
|
|
@@ -299,11 +301,11 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
299
301
|
}
|
|
300
302
|
object = objectEither.unsafeCoerce();
|
|
301
303
|
}
|
|
302
|
-
if (!
|
|
303
|
-
throw new Error("
|
|
304
|
+
if (!namedObjectType) {
|
|
305
|
+
throw new Error("namedObjectType should be set here");
|
|
304
306
|
}
|
|
305
307
|
|
|
306
|
-
if (query?.filter && !
|
|
308
|
+
if (query?.filter && !namedObjectType.${syntheticNamePrefix}filter(query.filter, object)) {
|
|
307
309
|
continue;
|
|
308
310
|
}
|
|
309
311
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
1
2
|
import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
2
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
3
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
|
-
export declare function sparqlObjectSetClassDeclaration({
|
|
5
|
-
|
|
4
|
+
export declare function sparqlObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }: {
|
|
5
|
+
namedObjectTypes: readonly NamedObjectType[];
|
|
6
6
|
namedObjectUnionTypes: readonly NamedObjectUnionType[];
|
|
7
7
|
}): Code;
|
|
8
8
|
//# sourceMappingURL=sparqlObjectSetClassDeclaration.d.ts.map
|
|
@@ -4,15 +4,15 @@ import { snippets } from "./snippets.js";
|
|
|
4
4
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
5
5
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
6
6
|
import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
|
|
7
|
-
export function sparqlObjectSetClassDeclaration({
|
|
7
|
+
export function sparqlObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
|
|
8
8
|
const parameters = {
|
|
9
|
-
constructObjectType: code `
|
|
9
|
+
constructObjectType: code `namedObjectType: {\
|
|
10
10
|
${syntheticNamePrefix}focusSparqlWherePatterns: ${snippets.FocusSparqlWherePatternsFunction}<ObjectFilterT>;
|
|
11
11
|
${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<ObjectT>;
|
|
12
12
|
${syntheticNamePrefix}sparqlConstructQueryString: (parameters: { filter?: ObjectFilterT; subject: ${imports.NamedNode} | ${imports.Variable}; } & Omit<${imports.sparqljs}.ConstructQuery, "prefixes" | "queryType" | "type"> & ${imports.sparqljs}.GeneratorOptions) => string;
|
|
13
13
|
}`,
|
|
14
14
|
query: code `query?: ${syntheticNamePrefix}SparqlObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
|
|
15
|
-
selectObjectTypeType: code `
|
|
15
|
+
selectObjectTypeType: code `namedObjectType: { ${syntheticNamePrefix}focusSparqlWherePatterns: ${snippets.FocusSparqlWherePatternsFunction}<ObjectFilterT> }`,
|
|
16
16
|
};
|
|
17
17
|
const typeParameters = {
|
|
18
18
|
ObjectT: code `ObjectT extends { readonly $identifier: ObjectIdentifierT }`,
|
|
@@ -30,17 +30,17 @@ export class ${syntheticNamePrefix}SparqlObjectSet implements ${syntheticNamePre
|
|
|
30
30
|
this.graph = options?.graph;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
${joinCode([...
|
|
34
|
-
if (!
|
|
33
|
+
${joinCode([...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
34
|
+
if (!namedObjectType.features.has("sparql")) {
|
|
35
35
|
return Object.values(unsupportedObjectSetMethodDeclarations({
|
|
36
|
-
|
|
36
|
+
namedObjectType,
|
|
37
37
|
}));
|
|
38
38
|
}
|
|
39
39
|
const methodSignatures = objectSetMethodSignatures({
|
|
40
|
-
|
|
40
|
+
namedObjectType,
|
|
41
41
|
queryT: `${syntheticNamePrefix}SparqlObjectSet.Query`,
|
|
42
42
|
});
|
|
43
|
-
const runtimeObjectType =
|
|
43
|
+
const runtimeObjectType = namedObjectType.staticModuleName;
|
|
44
44
|
return [
|
|
45
45
|
code `\
|
|
46
46
|
async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
|
|
@@ -48,15 +48,15 @@ async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${
|
|
|
48
48
|
}`,
|
|
49
49
|
code `\
|
|
50
50
|
async ${methodSignatures.objectCount.name}(${methodSignatures.objectCount.parameters}): ${methodSignatures.objectCount.returnType} {
|
|
51
|
-
return this.${syntheticNamePrefix}objectCount<${
|
|
51
|
+
return this.${syntheticNamePrefix}objectCount<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
52
52
|
}`,
|
|
53
53
|
code `\
|
|
54
54
|
async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdentifiers.parameters}): ${methodSignatures.objectIdentifiers.returnType} {
|
|
55
|
-
return this.${syntheticNamePrefix}objectIdentifiers<${
|
|
55
|
+
return this.${syntheticNamePrefix}objectIdentifiers<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
56
56
|
}`,
|
|
57
57
|
code `\
|
|
58
58
|
async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}): ${methodSignatures.objects.returnType} {
|
|
59
|
-
return this.${syntheticNamePrefix}objects<${
|
|
59
|
+
return this.${syntheticNamePrefix}objects<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
60
60
|
}`,
|
|
61
61
|
];
|
|
62
62
|
}), { on: "\n\n" })}
|
|
@@ -111,7 +111,7 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
111
111
|
offset = 0;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const wherePatterns = this.${syntheticNamePrefix}wherePatterns(
|
|
114
|
+
const wherePatterns = this.${syntheticNamePrefix}wherePatterns(namedObjectType, query);
|
|
115
115
|
if (wherePatterns.length === 0) {
|
|
116
116
|
return ${imports.Left}(new Error("no SPARQL WHERE patterns for identifiers"));
|
|
117
117
|
}
|
|
@@ -139,12 +139,12 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
139
139
|
|
|
140
140
|
protected async ${syntheticNamePrefix}objects<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(${parameters.constructObjectType}, ${parameters.query}): Promise<${imports.Either}<Error, readonly ObjectT[]>> {
|
|
141
141
|
return ${imports.EitherAsync}(async ({ liftEither }) => {
|
|
142
|
-
const identifiers = await liftEither(await this.${syntheticNamePrefix}objectIdentifiers<ObjectFilterT, ObjectIdentifierT>(
|
|
142
|
+
const identifiers = await liftEither(await this.${syntheticNamePrefix}objectIdentifiers<ObjectFilterT, ObjectIdentifierT>(namedObjectType, query));
|
|
143
143
|
if (identifiers.length === 0) {
|
|
144
144
|
return [];
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
const constructQueryString =
|
|
147
|
+
const constructQueryString = namedObjectType.${syntheticNamePrefix}sparqlConstructQueryString({
|
|
148
148
|
subject: this.${syntheticNamePrefix}objectVariable,
|
|
149
149
|
where: [{
|
|
150
150
|
type: "values" as const,
|
|
@@ -161,14 +161,14 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
161
161
|
const dataset = ${imports.datasetFactory}.dataset(quads.concat());
|
|
162
162
|
const objects: ObjectT[] = [];
|
|
163
163
|
for (const identifier of identifiers) {
|
|
164
|
-
objects.push(await liftEither(
|
|
164
|
+
objects.push(await liftEither(namedObjectType.${syntheticNamePrefix}fromRdfResource(new ${imports.Resource}(dataset, identifier as ${imports.NamedNode}), { objectSet: this, preferredLanguages: query?.preferredLanguages })));
|
|
165
165
|
}
|
|
166
166
|
return objects;
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
protected async ${syntheticNamePrefix}objectCount<${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(${parameters.selectObjectTypeType}, ${parameters.query}): Promise<${imports.Either}<Error, number>> {
|
|
171
|
-
const wherePatterns = this.${syntheticNamePrefix}wherePatterns(
|
|
171
|
+
const wherePatterns = this.${syntheticNamePrefix}wherePatterns(namedObjectType, query);
|
|
172
172
|
if (wherePatterns.length === 0) {
|
|
173
173
|
return ${imports.Left}(new Error("no SPARQL WHERE patterns for count"));
|
|
174
174
|
}
|
|
@@ -210,7 +210,7 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
210
210
|
patterns = patterns.concat(query.where(this.${syntheticNamePrefix}objectVariable));
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
patterns = patterns.concat(
|
|
213
|
+
patterns = patterns.concat(namedObjectType.${syntheticNamePrefix}focusSparqlWherePatterns({ filter: query?.filter, focusIdentifier: this.${syntheticNamePrefix}objectVariable, ignoreRdfType: false, preferredLanguages: query?.preferredLanguages, variablePrefix: this.${syntheticNamePrefix}objectVariable.value }));
|
|
214
214
|
|
|
215
215
|
patterns = ${snippets.normalizeSparqlWherePatterns}(patterns).concat();
|
|
216
216
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
1
2
|
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
2
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
3
3
|
/**
|
|
4
4
|
* Synthesize the $Object union.
|
|
5
5
|
*/
|
|
6
6
|
export declare function synthesizeUberObjectUnionType(parameters: {
|
|
7
|
-
|
|
7
|
+
namedObjectTypes: readonly NamedObjectType[];
|
|
8
8
|
}): NamedObjectUnionType;
|
|
9
9
|
//# sourceMappingURL=synthesizeUberObjectUnionType.d.ts.map
|
|
@@ -9,10 +9,10 @@ import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
|
9
9
|
* Synthesize the $Object union.
|
|
10
10
|
*/
|
|
11
11
|
export function synthesizeUberObjectUnionType(parameters) {
|
|
12
|
-
const
|
|
13
|
-
invariant(
|
|
14
|
-
const nodeKinds =
|
|
15
|
-
for (const nodeKind of
|
|
12
|
+
const namedObjectTypes = parameters.namedObjectTypes.filter((namedObjectType) => !namedObjectType.extern);
|
|
13
|
+
invariant(namedObjectTypes.length > 0);
|
|
14
|
+
const nodeKinds = namedObjectTypes.reduce((nodeKinds, namedObjectType) => {
|
|
15
|
+
for (const nodeKind of namedObjectType.identifierType.nodeKinds) {
|
|
16
16
|
nodeKinds.add(nodeKind);
|
|
17
17
|
}
|
|
18
18
|
return nodeKinds;
|
|
@@ -44,8 +44,8 @@ export function synthesizeUberObjectUnionType(parameters) {
|
|
|
44
44
|
}
|
|
45
45
|
return new NamedObjectUnionType({
|
|
46
46
|
comment: Maybe.empty(),
|
|
47
|
-
features:
|
|
48
|
-
for (const feature of
|
|
47
|
+
features: namedObjectTypes.reduce((features, namedObjectType) => {
|
|
48
|
+
for (const feature of namedObjectType.features) {
|
|
49
49
|
features.add(feature);
|
|
50
50
|
}
|
|
51
51
|
features.delete("graphql");
|
|
@@ -53,9 +53,9 @@ export function synthesizeUberObjectUnionType(parameters) {
|
|
|
53
53
|
}, new Set()),
|
|
54
54
|
identifierType,
|
|
55
55
|
label: Maybe.empty(),
|
|
56
|
-
members:
|
|
56
|
+
members: namedObjectTypes.map((namedObjectType) => ({
|
|
57
57
|
discriminantValue: Maybe.empty(),
|
|
58
|
-
type:
|
|
58
|
+
type: namedObjectType,
|
|
59
59
|
})),
|
|
60
60
|
name: `${syntheticNamePrefix}Object`,
|
|
61
61
|
recursive: false,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
2
2
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
|
-
export declare function unsupportedObjectSetMethodDeclarations({
|
|
4
|
-
|
|
3
|
+
export declare function unsupportedObjectSetMethodDeclarations({ namedObjectType, }: {
|
|
4
|
+
namedObjectType: {
|
|
5
5
|
readonly filterType: Code;
|
|
6
6
|
readonly identifierTypeAlias: Code;
|
|
7
|
-
readonly objectSetMethodNames:
|
|
7
|
+
readonly objectSetMethodNames: NamedObjectType.ObjectSetMethodNames;
|
|
8
8
|
readonly name: string;
|
|
9
9
|
};
|
|
10
|
-
}): Readonly<Record<keyof
|
|
10
|
+
}): Readonly<Record<keyof NamedObjectType.ObjectSetMethodNames, Code>>;
|
|
11
11
|
//# sourceMappingURL=unsupportedObjectSetMethodDeclarations.d.ts.map
|
|
@@ -7,9 +7,9 @@ async ${name}(${parameters}): ${returnType} {
|
|
|
7
7
|
return ${imports.Left}(new Error("${name}: not supported")) satisfies Awaited<${returnType}>;
|
|
8
8
|
}`;
|
|
9
9
|
}
|
|
10
|
-
export function unsupportedObjectSetMethodDeclarations({
|
|
10
|
+
export function unsupportedObjectSetMethodDeclarations({ namedObjectType, }) {
|
|
11
11
|
const methodSignatures = objectSetMethodSignatures({
|
|
12
|
-
|
|
12
|
+
namedObjectType,
|
|
13
13
|
parameterNamePrefix: "_",
|
|
14
14
|
});
|
|
15
15
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "4.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "4.0.11",
|
|
4
4
|
"@rdfjs/data-model": "~2.1.1",
|
|
5
5
|
"@rdfjs/dataset": "~2.0.2",
|
|
6
6
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"dist/generators/json/*.js",
|
|
52
52
|
"dist/generators/ts/*.d.ts",
|
|
53
53
|
"dist/generators/ts/*.js",
|
|
54
|
-
"dist/generators/ts/
|
|
55
|
-
"dist/generators/ts/
|
|
54
|
+
"dist/generators/ts/_NamedObjectType/*.d.ts",
|
|
55
|
+
"dist/generators/ts/_NamedObjectType/*.js",
|
|
56
56
|
"dist/generators/ts/_snippets/*.d.ts",
|
|
57
57
|
"dist/generators/ts/_snippets/*.js",
|
|
58
58
|
"dist/input/*.d.ts",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
},
|
|
79
79
|
"type": "module",
|
|
80
80
|
"types": "./dist/index.d.ts",
|
|
81
|
-
"version": "4.0.
|
|
81
|
+
"version": "4.0.11"
|
|
82
82
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
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_createFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_createFunctionDeclaration.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
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_equalsFunctionOrMethodDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_equalsFunctionOrMethodDeclaration.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
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_focusSparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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_focusSparqlWherePatternsFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
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_fromJsonFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_fromJsonFunctionDeclaration.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
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_fromRdfResourceFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_fromRdfResourceFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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_fromRdfResourceValuesFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
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_fromRdfTypeVariableStatement(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_fromRdfTypeVariableStatement.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
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_graphqlTypeVariableStatement(this: ObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=ObjectType_graphqlTypeVariableStatement.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ObjectType } from "../ObjectType.js";
|
|
2
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export declare function ObjectType_hashFunctionOrMethodDeclarations(this: ObjectType): readonly Code[];
|
|
4
|
-
//# sourceMappingURL=ObjectType_hashFunctionOrMethodDeclarations.d.ts.map
|