@shaclmate/compiler 4.0.18 → 4.0.20
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 +4 -1
- package/dist/Compiler.js +4 -1
- package/dist/ShapesGraphToAstTransformer.d.ts +4 -1
- package/dist/ShapesGraphToAstTransformer.js +9 -6
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
- package/dist/ast/AbstractCollectionType.d.ts +10 -0
- package/dist/ast/AbstractCollectionType.js +6 -0
- package/dist/ast/AbstractCompoundType.d.ts +0 -1
- package/dist/ast/AbstractCompoundType.js +0 -3
- package/dist/ast/AbstractContainerType.d.ts +9 -1
- package/dist/ast/AbstractContainerType.js +5 -2
- package/dist/ast/AbstractLazyObjectType.d.ts +94 -1
- package/dist/ast/AbstractLazyObjectType.js +6 -2
- package/dist/ast/AbstractTermType.d.ts +11 -1
- package/dist/ast/AbstractTermType.js +7 -2
- package/dist/ast/AbstractType.d.ts +13 -1
- package/dist/ast/AbstractType.js +13 -0
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/DefaultValueType.d.ts +10 -0
- package/dist/ast/DefaultValueType.js +6 -0
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/LiteralType.d.ts +17 -1
- package/dist/ast/LiteralType.js +10 -2
- package/dist/ast/ObjectCompoundType.js +1 -2
- package/dist/ast/ObjectType.d.ts +44 -1
- package/dist/ast/ObjectType.js +33 -10
- package/dist/ast/SetType.d.ts +11 -0
- package/dist/ast/SetType.js +6 -0
- package/dist/ast/UnionType.d.ts +12 -0
- package/dist/ast/UnionType.js +11 -0
- package/dist/generators/AstJsonGenerator.d.ts +6 -0
- package/dist/generators/AstJsonGenerator.js +11 -0
- package/dist/generators/Cx2Generator.d.ts +10 -0
- package/dist/generators/Cx2Generator.js +140 -0
- package/dist/generators/LabeledPropertyGraph.d.ts +42 -0
- package/dist/generators/LabeledPropertyGraph.js +2 -0
- package/dist/generators/index.d.ts +4 -2
- package/dist/generators/index.js +4 -2
- package/dist/generators/transformAstToLabeledPropertyGraph.d.ts +4 -0
- package/dist/generators/transformAstToLabeledPropertyGraph.js +75 -0
- package/dist/generators/ts/AbstractDateType.js +1 -1
- package/dist/generators/ts/AbstractIdentifierType.d.ts +2 -2
- package/dist/generators/ts/AbstractIdentifierType.js +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +1 -1
- package/dist/generators/ts/AbstractNumericType.js +1 -1
- package/dist/generators/ts/AbstractTermType.js +2 -2
- package/dist/generators/ts/AbstractType.d.ts +17 -14
- package/dist/generators/ts/AbstractType.js +3 -1
- package/dist/generators/ts/BlankNodeType.d.ts +2 -2
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.js +1 -1
- package/dist/generators/ts/DefaultValueType.js +1 -1
- package/dist/generators/ts/IdentifierType.d.ts +2 -2
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +1 -1
- package/dist/generators/ts/IriType.js +8 -13
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -0
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectType.js +1 -1
- package/dist/generators/ts/ListType.js +5 -5
- package/dist/generators/ts/NamedObjectUnionType.js +4 -1
- package/dist/generators/ts/SetType.js +1 -1
- package/dist/generators/ts/StringType.js +1 -1
- package/dist/generators/ts/TermType.js +3 -1
- package/dist/generators/ts/TsGenerator.d.ts +5 -0
- package/dist/generators/ts/TsGenerator.js +7 -1
- package/dist/generators/ts/TypeFactory.d.ts +5 -0
- package/dist/generators/ts/TypeFactory.js +35 -5
- package/dist/generators/ts/ZodGenerator.d.ts +4 -0
- package/dist/generators/ts/ZodGenerator.js +4 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +4 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +3 -1
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -0
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +16 -16
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +6 -2
- package/dist/generators/ts/_snippets/parseIri.d.ts +2 -0
- package/dist/generators/ts/_snippets/parseIri.js +12 -0
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +7 -5
- package/dist/generators/ts/_snippets/snippets_parseBlankNode.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_parseBlankNode.js +12 -0
- package/dist/generators/ts/_snippets/snippets_parseIdentifier.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_parseIdentifier.js +6 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +3 -3
- package/dist/generators/ts/imports.d.ts +2 -0
- package/dist/generators/ts/imports.js +3 -1
- package/dist/generators/ts/rdfjsTermExpression.d.ts +4 -1
- package/dist/generators/ts/rdfjsTermExpression.js +2 -3
- package/dist/generators/ts/snippets.d.ts +3 -2
- package/dist/generators/ts/snippets.js +6 -4
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -0
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +4 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -3
- package/dist/input/ShapesGraph.d.ts +4 -1
- package/dist/input/ShapesGraph.js +3 -2
- package/dist/input/generated.d.ts +323 -323
- package/dist/input/generated.js +19 -20
- package/package.json +6 -9
- package/dist/generators/json/AstJsonGenerator.d.ts +0 -6
- package/dist/generators/json/AstJsonGenerator.js +0 -144
- package/dist/generators/json/index.d.ts +0 -2
- package/dist/generators/json/index.js +0 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeFromString.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeFromString.js +0 -11
- package/dist/generators/ts/_snippets/snippets_identifierFromString.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_identifierFromString.js +0 -8
- package/dist/generators/ts/index.d.ts +0 -2
- package/dist/generators/ts/index.js +0 -2
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -8
|
@@ -13,20 +13,6 @@ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
|
13
13
|
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
14
14
|
import { tsComment } from "../tsComment.js";
|
|
15
15
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
16
|
-
function propertyPathToCode(propertyPath) {
|
|
17
|
-
switch (propertyPath.termType) {
|
|
18
|
-
case "AlternativePath":
|
|
19
|
-
case "SequencePath":
|
|
20
|
-
return code `{ members: [${joinCode(propertyPath.members.map(propertyPathToCode), { on: "," })}] as const, termType: ${literalOf(propertyPath.termType)} as const }`;
|
|
21
|
-
case "InversePath":
|
|
22
|
-
case "OneOrMorePath":
|
|
23
|
-
case "ZeroOrMorePath":
|
|
24
|
-
case "ZeroOrOnePath":
|
|
25
|
-
return code `{ path: ${propertyPathToCode(propertyPath.path)}, termType: ${literalOf(propertyPath.termType)} as const }`;
|
|
26
|
-
case "NamedNode":
|
|
27
|
-
return rdfjsTermExpression(propertyPath);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
16
|
export class ShaclProperty extends AbstractProperty {
|
|
31
17
|
comment;
|
|
32
18
|
description;
|
|
@@ -121,7 +107,7 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
121
107
|
// comment: this.comment.map(JSON.stringify).extract(),
|
|
122
108
|
// description: this.description.map(JSON.stringify).extract(),
|
|
123
109
|
path: this.namedObjectType.features.has("rdf")
|
|
124
|
-
? propertyPathToCode(this.path)
|
|
110
|
+
? this.propertyPathToCode(this.path)
|
|
125
111
|
: undefined,
|
|
126
112
|
// label: this.label.map(JSON.stringify).extract(),
|
|
127
113
|
// mutable: this.mutable ? true : undefined,
|
|
@@ -235,13 +221,27 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
235
221
|
default:
|
|
236
222
|
return [];
|
|
237
223
|
}
|
|
238
|
-
const propertyPath = propertyPathToCode(this.path);
|
|
224
|
+
const propertyPath = this.propertyPathToCode(this.path);
|
|
239
225
|
return [
|
|
240
226
|
code `${variables.resource}.add(${propertyPath}, ${this.type.toRdfResourceValuesExpression({
|
|
241
227
|
variables: { ...variables, propertyPath },
|
|
242
228
|
})}, ${variables.graph});`,
|
|
243
229
|
];
|
|
244
230
|
}
|
|
231
|
+
propertyPathToCode(propertyPath) {
|
|
232
|
+
switch (propertyPath.termType) {
|
|
233
|
+
case "AlternativePath":
|
|
234
|
+
case "SequencePath":
|
|
235
|
+
return code `{ members: [${joinCode(propertyPath.members.map((member) => this.propertyPathToCode(member)), { on: "," })}] as const, termType: ${literalOf(propertyPath.termType)} as const }`;
|
|
236
|
+
case "InversePath":
|
|
237
|
+
case "OneOrMorePath":
|
|
238
|
+
case "ZeroOrMorePath":
|
|
239
|
+
case "ZeroOrOnePath":
|
|
240
|
+
return code `{ path: ${this.propertyPathToCode(propertyPath.path)}, termType: ${literalOf(propertyPath.termType)} as const }`;
|
|
241
|
+
case "NamedNode":
|
|
242
|
+
return rdfjsTermExpression(propertyPath, { logger: this.logger });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
245
|
}
|
|
246
246
|
__decorate([
|
|
247
247
|
Memoize()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
2
|
-
import { code
|
|
2
|
+
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function identifierTypeDeclarations() {
|
|
4
4
|
const ancestorObjectTypeWithSameIdentifierType = this.ancestorObjectTypes.find((ancestorObjectType) => ancestorObjectType.identifierType.name === this.identifierType.name);
|
|
5
5
|
if (ancestorObjectTypeWithSameIdentifierType) {
|
|
@@ -13,7 +13,11 @@ export function identifierTypeDeclarations() {
|
|
|
13
13
|
// Bespoke identifier type and associated functions
|
|
14
14
|
return [
|
|
15
15
|
code `export type ${syntheticNamePrefix}Identifier = ${this.identifierType.name};`,
|
|
16
|
-
code
|
|
16
|
+
code `\
|
|
17
|
+
export namespace ${syntheticNamePrefix}Identifier {
|
|
18
|
+
export const parse = ${this.identifierType.parseFunction};
|
|
19
|
+
export const stringify = ${this.identifierType.stringifyFunction};
|
|
20
|
+
}`,
|
|
17
21
|
];
|
|
18
22
|
}
|
|
19
23
|
//# sourceMappingURL=identifierTypeDeclarations.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { imports } from "../imports.js";
|
|
2
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
4
|
+
import { snippets_parseIdentifier } from "./snippets_parseIdentifier.js";
|
|
5
|
+
export const snippets_parseIri = conditionalOutput(`${syntheticNamePrefix}parseIri`, code `\
|
|
6
|
+
export function ${syntheticNamePrefix}parseIri(identifier: string): ${imports.Either}<Error, ${imports.NamedNode}> {
|
|
7
|
+
return \
|
|
8
|
+
${snippets_parseIdentifier}(identifier)\
|
|
9
|
+
.chain((identifier) => (identifier.termType === "NamedNode") ? ${imports.Right}(identifier) : ${imports.Left}(new Error("expected identifier to be NamedNode"))) \
|
|
10
|
+
as ${imports.Either}<Error, ${imports.NamedNode}>;
|
|
11
|
+
}`);
|
|
12
|
+
//# sourceMappingURL=parseIri.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
2
|
+
import { dummyLogger } from "ts-log";
|
|
2
3
|
import { imports } from "../imports.js";
|
|
3
4
|
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
4
5
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
@@ -7,6 +8,7 @@ import { snippets_CollectionFilter } from "./snippets_CollectionFilter.js";
|
|
|
7
8
|
import { snippets_CollectionSchema } from "./snippets_CollectionSchema.js";
|
|
8
9
|
import { snippets_SparqlPattern } from "./snippets_SparqlPattern.js";
|
|
9
10
|
import { snippets_ValueSparqlWherePatternsFunction } from "./snippets_ValueSparqlWherePatternsFunction.js";
|
|
11
|
+
const logger = dummyLogger;
|
|
10
12
|
export const snippets_listSparqlWherePatterns = conditionalOutput(`${syntheticNamePrefix}listSparqlWherePatterns`, code `\
|
|
11
13
|
function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>(itemSparqlWherePatternsFunction: ${snippets_ValueSparqlWherePatternsFunction}<ItemFilterT, ItemSchemaT>): ${snippets_ValueSparqlWherePatternsFunction}<${snippets_CollectionFilter}<ItemFilterT>, ${snippets_CollectionSchema}<ItemSchemaT>> {
|
|
12
14
|
return (parameters) => {
|
|
@@ -28,7 +30,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
28
30
|
triples: [
|
|
29
31
|
{
|
|
30
32
|
subject: listVariable,
|
|
31
|
-
predicate: ${rdfjsTermExpression(rdf.first)},
|
|
33
|
+
predicate: ${rdfjsTermExpression(rdf.first, { logger })},
|
|
32
34
|
object: item0Variable,
|
|
33
35
|
},
|
|
34
36
|
],
|
|
@@ -53,7 +55,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
53
55
|
triples: [
|
|
54
56
|
{
|
|
55
57
|
subject: listVariable,
|
|
56
|
-
predicate: ${rdfjsTermExpression(rdf.rest)},
|
|
58
|
+
predicate: ${rdfjsTermExpression(rdf.rest, { logger })},
|
|
57
59
|
object: rest0Variable,
|
|
58
60
|
},
|
|
59
61
|
],
|
|
@@ -70,7 +72,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
70
72
|
triples: [
|
|
71
73
|
{
|
|
72
74
|
subject: listVariable,
|
|
73
|
-
predicate: { type: "path", pathType: "*", items: [${rdfjsTermExpression(rdf.rest)}] },
|
|
75
|
+
predicate: { type: "path", pathType: "*", items: [${rdfjsTermExpression(rdf.rest, { logger })}] },
|
|
74
76
|
object: restNVariable,
|
|
75
77
|
},
|
|
76
78
|
],
|
|
@@ -84,7 +86,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
84
86
|
triples: [
|
|
85
87
|
{
|
|
86
88
|
subject: restNVariable,
|
|
87
|
-
predicate: ${rdfjsTermExpression(rdf.first)},
|
|
89
|
+
predicate: ${rdfjsTermExpression(rdf.first, { logger })},
|
|
88
90
|
object: itemNVariable,
|
|
89
91
|
},
|
|
90
92
|
],
|
|
@@ -107,7 +109,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
107
109
|
triples: [
|
|
108
110
|
{
|
|
109
111
|
subject: restNVariable,
|
|
110
|
-
predicate: ${rdfjsTermExpression(rdf.rest)},
|
|
112
|
+
predicate: ${rdfjsTermExpression(rdf.rest, { logger })},
|
|
111
113
|
object: variable("RestNBasic"),
|
|
112
114
|
},
|
|
113
115
|
],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { imports } from "../imports.js";
|
|
2
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
4
|
+
import { snippets_parseIdentifier } from "./snippets_parseIdentifier.js";
|
|
5
|
+
export const snippets_parseBlankNode = conditionalOutput(`${syntheticNamePrefix}parseBlankNode`, code `\
|
|
6
|
+
export function ${syntheticNamePrefix}parseBlankNode(identifier: string): ${imports.Either}<Error, ${imports.BlankNode}> {
|
|
7
|
+
return \
|
|
8
|
+
${snippets_parseIdentifier}(identifier)\
|
|
9
|
+
.chain((identifier) => (identifier.termType === "BlankNode") ? ${imports.Right}(identifier) : ${imports.Left}(new Error("expected identifier to be BlankNode"))) \
|
|
10
|
+
as ${imports.Either}<Error, ${imports.BlankNode}>;
|
|
11
|
+
}`);
|
|
12
|
+
//# sourceMappingURL=snippets_parseBlankNode.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { imports } from "../imports.js";
|
|
2
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
4
|
+
export const snippets_parseIdentifier = conditionalOutput(`${syntheticNamePrefix}parseIdentifier`, code `\
|
|
5
|
+
const ${syntheticNamePrefix}parseIdentifier = ${imports.NTriplesIdentifier}.parser(${imports.dataFactory});`);
|
|
6
|
+
//# sourceMappingURL=snippets_parseIdentifier.js.map
|
|
@@ -16,7 +16,7 @@ function graphqlQueryObjectType({ namedObjectTypes, namedObjectUnionTypes, }) {
|
|
|
16
16
|
resolve: code `\
|
|
17
17
|
async (_source, args: { identifier: string }, { objectSet }): Promise<${namedObjectType.name}> =>
|
|
18
18
|
(await ${imports.EitherAsync}<Error, ${namedObjectType.name}>(async ({ liftEither }) =>
|
|
19
|
-
liftEither(await objectSet.${namedObjectType.objectSetMethodNames.object}(await liftEither(${namedObjectType.identifierTypeAlias}.
|
|
19
|
+
liftEither(await objectSet.${namedObjectType.objectSetMethodNames.object}(await liftEither(${namedObjectType.identifierTypeAlias}.parse(args.identifier))))
|
|
20
20
|
)).unsafeCoerce()`,
|
|
21
21
|
type: namedObjectType.graphqlType.name,
|
|
22
22
|
};
|
|
@@ -31,7 +31,7 @@ async (_source, args: { identifier: string }, { objectSet }): Promise<${namedObj
|
|
|
31
31
|
},
|
|
32
32
|
resolve: code `\
|
|
33
33
|
async (_source, args: { limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly string[]> =>
|
|
34
|
-
(await objectSet.${namedObjectType.objectSetMethodNames.objectIdentifiers}({ limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined })).unsafeCoerce().map(${namedObjectType.identifierTypeAlias}.
|
|
34
|
+
(await objectSet.${namedObjectType.objectSetMethodNames.objectIdentifiers}({ limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined })).unsafeCoerce().map(${namedObjectType.identifierTypeAlias}.stringify)`,
|
|
35
35
|
type: code `new ${imports.GraphQLNonNull}(new ${imports.GraphQLList}(${imports.GraphQLString}))`,
|
|
36
36
|
};
|
|
37
37
|
fields[namedObjectType.objectSetMethodNames.objects] = {
|
|
@@ -53,7 +53,7 @@ async (_source, args: { identifiers: readonly string[] | null; limit: number | n
|
|
|
53
53
|
if (args.identifiers) {
|
|
54
54
|
const identifiers: ${namedObjectType.identifierTypeAlias}[] = [];
|
|
55
55
|
for (const identifierArg of args.identifiers) {
|
|
56
|
-
identifiers.push(await liftEither(${namedObjectType.identifierTypeAlias}.
|
|
56
|
+
identifiers.push(await liftEither(${namedObjectType.identifierTypeAlias}.parse(identifierArg)));
|
|
57
57
|
}
|
|
58
58
|
filter = { ${syntheticNamePrefix}identifier: { in: identifiers } };
|
|
59
59
|
}
|
|
@@ -25,6 +25,8 @@ export declare const imports: {
|
|
|
25
25
|
readonly Maybe: import("ts-poet/build/Import.js").Import;
|
|
26
26
|
readonly NamedNode: import("ts-poet/build/Import.js").Import;
|
|
27
27
|
readonly NonEmptyList: import("ts-poet/build/Import.js").Import;
|
|
28
|
+
readonly NTriplesIdentifier: import("ts-poet/build/Import.js").Import;
|
|
29
|
+
readonly NTriplesTerm: import("ts-poet/build/Import.js").Import;
|
|
28
30
|
readonly Quad: import("ts-poet/build/Import.js").Import;
|
|
29
31
|
readonly Quad_Graph: import("ts-poet/build/Import.js").Import;
|
|
30
32
|
readonly RdfjsResourcePropertyPath: import("ts-poet/build/Import.js").Import;
|
|
@@ -2,7 +2,7 @@ import { imp } from "./ts-poet-wrapper.js";
|
|
|
2
2
|
export const imports = {
|
|
3
3
|
BigDecimal: imp("Decimal:BigDecimal@decimal.js"),
|
|
4
4
|
BlankNode: imp("BlankNode@@rdfjs/types"),
|
|
5
|
-
dataFactory: imp("dataFactory=@
|
|
5
|
+
dataFactory: imp("dataFactory=@rdfx/data-factory"),
|
|
6
6
|
DatasetCore: imp("DatasetCore@@rdfjs/types"),
|
|
7
7
|
datasetFactory: imp("datasetFactory=@rdfjs/dataset"),
|
|
8
8
|
Either: imp("Either@purify-ts"),
|
|
@@ -26,6 +26,8 @@ export const imports = {
|
|
|
26
26
|
Maybe: imp("Maybe@purify-ts"),
|
|
27
27
|
NamedNode: imp("NamedNode@@rdfjs/types"),
|
|
28
28
|
NonEmptyList: imp("NonEmptyList@purify-ts"),
|
|
29
|
+
NTriplesIdentifier: imp("NTriplesIdentifier@@rdfx/string"),
|
|
30
|
+
NTriplesTerm: imp("NTriplesTerm@@rdfx/string"),
|
|
29
31
|
Quad: imp("Quad@@rdfjs/types"),
|
|
30
32
|
Quad_Graph: imp("Quad_Graph@@rdfjs/types"),
|
|
31
33
|
RdfjsResourcePropertyPath: imp("PropertyPath:RdfjsResourcePropertyPath@@rdfx/resource"),
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { BlankNode, Literal, NamedNode, Variable } from "@rdfjs/types";
|
|
2
|
+
import type { Logger } from "ts-log";
|
|
2
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
|
-
export declare function rdfjsTermExpression(rdfjsTerm: Omit<BlankNode, "equals"> | Omit<Literal, "equals"> | Omit<NamedNode, "equals"> | Omit<Variable, "equals"
|
|
4
|
+
export declare function rdfjsTermExpression(rdfjsTerm: Omit<BlankNode, "equals"> | Omit<Literal, "equals"> | Omit<NamedNode, "equals"> | Omit<Variable, "equals">, { logger }: {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
}): Code;
|
|
4
7
|
//# sourceMappingURL=rdfjsTermExpression.d.ts.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { rdf, rdfs, xsd } from "@tpluscode/rdf-ns-builders";
|
|
2
|
-
import { logger } from "../../logger.js";
|
|
3
2
|
import { snippets_RdfVocabularies } from "./_snippets/snippets_RdfVocabularies.js";
|
|
4
3
|
import { imports } from "./imports.js";
|
|
5
4
|
import { code, literalOf } from "./ts-poet-wrapper.js";
|
|
6
|
-
export function rdfjsTermExpression(rdfjsTerm) {
|
|
5
|
+
export function rdfjsTermExpression(rdfjsTerm, { logger }) {
|
|
7
6
|
switch (rdfjsTerm.termType) {
|
|
8
7
|
case "BlankNode":
|
|
9
8
|
return code `${imports.dataFactory}.blankNode(${literalOf(rdfjsTerm.value)})`;
|
|
@@ -14,7 +13,7 @@ export function rdfjsTermExpression(rdfjsTerm) {
|
|
|
14
13
|
}
|
|
15
14
|
return code `${imports.dataFactory}.literal(${literalOf(rdfjsTerm.value)}, ${literalOf(rdfjsTerm.language)})`;
|
|
16
15
|
}
|
|
17
|
-
return code `${imports.dataFactory}.literal(${literalOf(rdfjsTerm.value)}, ${rdfjsTermExpression(rdfjsTerm.datatype)})`;
|
|
16
|
+
return code `${imports.dataFactory}.literal(${literalOf(rdfjsTerm.value)}, ${rdfjsTermExpression(rdfjsTerm.datatype, { logger })})`;
|
|
18
17
|
case "NamedNode": {
|
|
19
18
|
if (rdfjsTerm.value.startsWith(rdf[""].value)) {
|
|
20
19
|
const unqualifiedName = rdfjsTerm.value.substring(rdf[""].value.length);
|
|
@@ -5,7 +5,6 @@ export declare const snippets: {
|
|
|
5
5
|
bigDecimalSparqlWherePatterns: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
6
6
|
BlankNodeFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
7
7
|
BlankNodeSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
8
|
-
blankNodeFromString: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
9
8
|
blankNodeSparqlWherePatterns: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
10
9
|
booleanEquals: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
11
10
|
BooleanFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
@@ -42,7 +41,6 @@ export declare const snippets: {
|
|
|
42
41
|
FromRdfResourceValuesFunction: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
43
42
|
Hasher: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
44
43
|
IdentifierFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
45
|
-
identifierFromString: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
46
44
|
IdentifierSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
47
45
|
IdentifierSet: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
48
46
|
identifierSparqlWherePatterns: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
@@ -74,6 +72,9 @@ export declare const snippets: {
|
|
|
74
72
|
NumericFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
75
73
|
NumericSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
76
74
|
numericSparqlWherePatterns: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
75
|
+
parseBlankNode: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
76
|
+
parseIdentifier: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
77
|
+
parseIri: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
77
78
|
PropertiesFromRdfResourceFunction: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
78
79
|
PropertyPath: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
79
80
|
RdfVocabularies: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { snippets_parseIri } from "./_snippets/parseIri.js";
|
|
1
2
|
import { snippets_arrayEquals } from "./_snippets/snippets_arrayEquals.js";
|
|
2
3
|
import { snippets_arrayIntersection } from "./_snippets/snippets_arrayIntersection.js";
|
|
3
4
|
import { snippets_BlankNodeFilter } from "./_snippets/snippets_BlankNodeFilter.js";
|
|
@@ -6,7 +7,6 @@ import { snippets_BooleanFilter } from "./_snippets/snippets_BooleanFilter.js";
|
|
|
6
7
|
import { snippets_BooleanSchema } from "./_snippets/snippets_BooleanSchema.js";
|
|
7
8
|
import { snippets_bigDecimalLiteral } from "./_snippets/snippets_bigDecimalLiteral.js";
|
|
8
9
|
import { snippets_bigDecimalSparqlWherePatterns } from "./_snippets/snippets_bigDecimalSparqlWherePatterns.js";
|
|
9
|
-
import { snippets_blankNodeFromString } from "./_snippets/snippets_blankNodeFromString.js";
|
|
10
10
|
import { snippets_blankNodeSparqlWherePatterns } from "./_snippets/snippets_blankNodeSparqlWherePatterns.js";
|
|
11
11
|
import { snippets_booleanEquals } from "./_snippets/snippets_booleanEquals.js";
|
|
12
12
|
import { snippets_booleanSparqlWherePatterns } from "./_snippets/snippets_booleanSparqlWherePatterns.js";
|
|
@@ -45,7 +45,6 @@ import { snippets_IdentifierSchema } from "./_snippets/snippets_IdentifierSchema
|
|
|
45
45
|
import { snippets_IdentifierSet } from "./_snippets/snippets_IdentifierSet.js";
|
|
46
46
|
import { snippets_IriFilter } from "./_snippets/snippets_IriFilter.js";
|
|
47
47
|
import { snippets_IriSchema } from "./_snippets/snippets_IriSchema.js";
|
|
48
|
-
import { snippets_identifierFromString } from "./_snippets/snippets_identifierFromString.js";
|
|
49
48
|
import { snippets_identifierSparqlWherePatterns } from "./_snippets/snippets_identifierSparqlWherePatterns.js";
|
|
50
49
|
import { snippets_iriSparqlWherePatterns } from "./_snippets/snippets_iriSparqlWherePatterns.js";
|
|
51
50
|
import { snippets_isReadonlyBigIntArray } from "./_snippets/snippets_isReadonlyBigIntArray.js";
|
|
@@ -75,6 +74,8 @@ import { snippets_normalizeSparqlWherePatterns } from "./_snippets/snippets_norm
|
|
|
75
74
|
import { snippets_numericSparqlWherePatterns } from "./_snippets/snippets_numericSparqlWherePatterns.js";
|
|
76
75
|
import { snippets_PropertiesFromRdfResourceFunction } from "./_snippets/snippets_PropertiesFromRdfResourceFunction.js";
|
|
77
76
|
import { snippets_PropertyPath } from "./_snippets/snippets_PropertyPath.js";
|
|
77
|
+
import { snippets_parseBlankNode } from "./_snippets/snippets_parseBlankNode.js";
|
|
78
|
+
import { snippets_parseIdentifier } from "./_snippets/snippets_parseIdentifier.js";
|
|
78
79
|
import { snippets_RdfVocabularies } from "./_snippets/snippets_RdfVocabularies.js";
|
|
79
80
|
import { snippets_ShaclPropertySchema } from "./_snippets/snippets_ShaclPropertySchema.js";
|
|
80
81
|
import { snippets_SparqlFilterPattern } from "./_snippets/snippets_SparqlFilterPattern.js";
|
|
@@ -110,7 +111,6 @@ export const snippets = {
|
|
|
110
111
|
bigDecimalSparqlWherePatterns: snippets_bigDecimalSparqlWherePatterns,
|
|
111
112
|
BlankNodeFilter: snippets_BlankNodeFilter,
|
|
112
113
|
BlankNodeSchema: snippets_BlankNodeSchema,
|
|
113
|
-
blankNodeFromString: snippets_blankNodeFromString,
|
|
114
114
|
blankNodeSparqlWherePatterns: snippets_blankNodeSparqlWherePatterns,
|
|
115
115
|
booleanEquals: snippets_booleanEquals,
|
|
116
116
|
BooleanFilter: snippets_BooleanFilter,
|
|
@@ -147,7 +147,6 @@ export const snippets = {
|
|
|
147
147
|
FromRdfResourceValuesFunction: snippets_FromRdfResourceValuesFunction,
|
|
148
148
|
Hasher: snippets_Hasher,
|
|
149
149
|
IdentifierFilter: snippets_IdentifierFilter,
|
|
150
|
-
identifierFromString: snippets_identifierFromString,
|
|
151
150
|
IdentifierSchema: snippets_IdentifierSchema,
|
|
152
151
|
IdentifierSet: snippets_IdentifierSet,
|
|
153
152
|
identifierSparqlWherePatterns: snippets_identifierSparqlWherePatterns,
|
|
@@ -179,6 +178,9 @@ export const snippets = {
|
|
|
179
178
|
NumericFilter: snippets_NumericFilter,
|
|
180
179
|
NumericSchema: snippets_NumericSchema,
|
|
181
180
|
numericSparqlWherePatterns: snippets_numericSparqlWherePatterns,
|
|
181
|
+
parseBlankNode: snippets_parseBlankNode,
|
|
182
|
+
parseIdentifier: snippets_parseIdentifier,
|
|
183
|
+
parseIri: snippets_parseIri,
|
|
182
184
|
PropertiesFromRdfResourceFunction: snippets_PropertiesFromRdfResourceFunction,
|
|
183
185
|
PropertyPath: snippets_PropertyPath,
|
|
184
186
|
RdfVocabularies: snippets_RdfVocabularies,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { Logger } from "ts-log";
|
|
1
2
|
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
2
3
|
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
3
4
|
/**
|
|
4
5
|
* Synthesize the $Object union.
|
|
5
6
|
*/
|
|
6
7
|
export declare function synthesizeUberObjectUnionType(parameters: {
|
|
8
|
+
logger: Logger;
|
|
7
9
|
namedObjectTypes: readonly NamedObjectType[];
|
|
8
10
|
}): NamedObjectUnionType;
|
|
9
11
|
//# sourceMappingURL=synthesizeUberObjectUnionType.d.ts.map
|
|
@@ -22,6 +22,7 @@ export function synthesizeUberObjectUnionType(parameters) {
|
|
|
22
22
|
identifierType = new IdentifierType({
|
|
23
23
|
comment: Maybe.empty(),
|
|
24
24
|
label: Maybe.empty(),
|
|
25
|
+
logger: parameters.logger,
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
@@ -30,6 +31,7 @@ export function synthesizeUberObjectUnionType(parameters) {
|
|
|
30
31
|
identifierType = new BlankNodeType({
|
|
31
32
|
comment: Maybe.empty(),
|
|
32
33
|
label: Maybe.empty(),
|
|
34
|
+
logger: parameters.logger,
|
|
33
35
|
});
|
|
34
36
|
break;
|
|
35
37
|
case "IRI":
|
|
@@ -38,6 +40,7 @@ export function synthesizeUberObjectUnionType(parameters) {
|
|
|
38
40
|
hasValues: [],
|
|
39
41
|
in_: [],
|
|
40
42
|
label: Maybe.empty(),
|
|
43
|
+
logger: parameters.logger,
|
|
41
44
|
});
|
|
42
45
|
break;
|
|
43
46
|
}
|
|
@@ -53,6 +56,7 @@ export function synthesizeUberObjectUnionType(parameters) {
|
|
|
53
56
|
}, new Set()),
|
|
54
57
|
identifierType,
|
|
55
58
|
label: Maybe.empty(),
|
|
59
|
+
logger: parameters.logger,
|
|
56
60
|
members: namedObjectTypes.map((namedObjectType) => ({
|
|
57
61
|
discriminantValue: Maybe.empty(),
|
|
58
62
|
type: namedObjectType,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export * as ast from "./ast/index.js";
|
|
2
2
|
export * from "./Compiler.js";
|
|
3
|
-
export
|
|
4
|
-
export { AstJsonGenerator } from "./generators/json/AstJsonGenerator.js";
|
|
5
|
-
export { TsGenerator } from "./generators/ts/TsGenerator.js";
|
|
6
|
-
export { ZodGenerator } from "./generators/ts/ZodGenerator.js";
|
|
3
|
+
export * from "./generators/index.js";
|
|
7
4
|
export * from "./input/ShapesGraph.js";
|
|
8
5
|
export * from "./ShapesGraphToAstTransformer.js";
|
|
9
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * as ast from "./ast/index.js";
|
|
2
2
|
export * from "./Compiler.js";
|
|
3
|
-
export
|
|
4
|
-
export { TsGenerator } from "./generators/ts/TsGenerator.js";
|
|
5
|
-
export { ZodGenerator } from "./generators/ts/ZodGenerator.js";
|
|
3
|
+
export * from "./generators/index.js";
|
|
6
4
|
export * from "./input/ShapesGraph.js";
|
|
7
5
|
export * from "./ShapesGraphToAstTransformer.js";
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractShapesGraph } from "@shaclmate/shacl-ast";
|
|
2
2
|
import type { Either } from "purify-ts";
|
|
3
|
+
import type { Logger } from "ts-log";
|
|
3
4
|
import type { Ast } from "../ast/Ast.js";
|
|
4
5
|
import type { TsFeature } from "../enums/TsFeature.js";
|
|
5
6
|
import type { Generator } from "../generators/Generator.js";
|
|
@@ -16,13 +17,15 @@ export declare class ShapesGraph extends AbstractShapesGraph<generated.NodeShape
|
|
|
16
17
|
*/
|
|
17
18
|
compile(parameters: {
|
|
18
19
|
generator: Generator;
|
|
20
|
+
logger: Logger;
|
|
19
21
|
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
20
22
|
}): Either<Error, string>;
|
|
21
23
|
static builder(): ShapesGraph.Builder;
|
|
22
24
|
/**
|
|
23
25
|
* Transform the shapes graph to an AST.
|
|
24
26
|
*/
|
|
25
|
-
toAst(
|
|
27
|
+
toAst({ logger, tsFeaturesDefault, }: {
|
|
28
|
+
logger: Logger;
|
|
26
29
|
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
27
30
|
}): Either<Error, Ast>;
|
|
28
31
|
}
|
|
@@ -22,10 +22,11 @@ export class ShapesGraph extends AbstractShapesGraph {
|
|
|
22
22
|
/**
|
|
23
23
|
* Transform the shapes graph to an AST.
|
|
24
24
|
*/
|
|
25
|
-
toAst(
|
|
25
|
+
toAst({ logger, tsFeaturesDefault, }) {
|
|
26
26
|
return new ShapesGraphToAstTransformer({
|
|
27
|
-
|
|
27
|
+
logger,
|
|
28
28
|
shapesGraph: this,
|
|
29
|
+
tsFeaturesDefault,
|
|
29
30
|
}).transform();
|
|
30
31
|
}
|
|
31
32
|
}
|