@traqula/rules-sparql-1-1 0.0.23 → 0.0.25
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/README.md +2 -0
- package/dist/cjs/lib/MinimalSparqlParser.js +66 -58
- package/dist/cjs/lib/MinimalSparqlParser.js.map +1 -0
- package/dist/cjs/lib/Sparql11types.js +2 -15
- package/dist/cjs/lib/Sparql11types.js.map +1 -0
- package/dist/cjs/lib/astFactory.js +110 -119
- package/dist/cjs/lib/astFactory.js.map +1 -0
- package/dist/cjs/lib/expressionHelpers.js +181 -191
- package/dist/cjs/lib/expressionHelpers.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/ContextFactory.js +30 -52
- package/dist/cjs/lib/factoryMixins/ContextFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/ExpressionFactory.js +83 -102
- package/dist/cjs/lib/factoryMixins/ExpressionFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/GraphRefFactory.js +51 -73
- package/dist/cjs/lib/factoryMixins/GraphRefFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/PathFactory.js +68 -87
- package/dist/cjs/lib/factoryMixins/PathFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/Patternfactory.js +98 -120
- package/dist/cjs/lib/factoryMixins/Patternfactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/QueryFactory.js +43 -65
- package/dist/cjs/lib/factoryMixins/QueryFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/SolutionModifiersFactory.js +55 -77
- package/dist/cjs/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/TermFactory.js +81 -102
- package/dist/cjs/lib/factoryMixins/TermFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/UpdateOperationFactory.js +126 -147
- package/dist/cjs/lib/factoryMixins/UpdateOperationFactory.js.map +1 -0
- package/dist/cjs/lib/factoryMixins/mixins.js +21 -38
- package/dist/cjs/lib/factoryMixins/mixins.js.map +1 -0
- package/dist/cjs/lib/grammar/builtIn.js +277 -377
- package/dist/cjs/lib/grammar/builtIn.js.map +1 -0
- package/dist/cjs/lib/grammar/dataSetClause.js +110 -109
- package/dist/cjs/lib/grammar/dataSetClause.js.map +1 -0
- package/dist/cjs/lib/grammar/expression.js +387 -358
- package/dist/cjs/lib/grammar/expression.js.map +1 -0
- package/dist/cjs/lib/grammar/general.js +173 -158
- package/dist/cjs/lib/grammar/general.js.map +1 -0
- package/dist/cjs/lib/grammar/index.js +94 -111
- package/dist/cjs/lib/grammar/index.js.map +1 -0
- package/dist/cjs/lib/grammar/literals.js +292 -266
- package/dist/cjs/lib/grammar/literals.js.map +1 -0
- package/dist/cjs/lib/grammar/propertyPaths.js +206 -193
- package/dist/cjs/lib/grammar/propertyPaths.js.map +1 -0
- package/dist/cjs/lib/grammar/queryUnit.js +395 -372
- package/dist/cjs/lib/grammar/queryUnit.js.map +1 -0
- package/dist/cjs/lib/grammar/solutionModifier.js +281 -265
- package/dist/cjs/lib/grammar/solutionModifier.js.map +1 -0
- package/dist/cjs/lib/grammar/tripleBlock.js +396 -355
- package/dist/cjs/lib/grammar/tripleBlock.js.map +1 -0
- package/dist/cjs/lib/grammar/updateUnit.js +551 -519
- package/dist/cjs/lib/grammar/updateUnit.js.map +1 -0
- package/dist/cjs/lib/grammar/whereClause.js +486 -459
- package/dist/cjs/lib/grammar/whereClause.js.map +1 -0
- package/dist/cjs/lib/index.js +47 -54
- package/dist/cjs/lib/index.js.map +1 -0
- package/dist/cjs/lib/lexer/BuiltInCalls.js +188 -333
- package/dist/cjs/lib/lexer/BuiltInCalls.js.map +1 -0
- package/dist/cjs/lib/lexer/graph.js +10 -40
- package/dist/cjs/lib/lexer/graph.js.map +1 -0
- package/dist/cjs/lib/lexer/index.js +43 -48
- package/dist/cjs/lib/lexer/index.js.map +1 -0
- package/dist/cjs/lib/lexer/lexer.js +84 -195
- package/dist/cjs/lib/lexer/lexer.js.map +1 -0
- package/dist/cjs/lib/lexer/lexerPatterns.js +40 -132
- package/dist/cjs/lib/lexer/lexerPatterns.js.map +1 -0
- package/dist/cjs/lib/lexer/symbols.js +31 -106
- package/dist/cjs/lib/lexer/symbols.js.map +1 -0
- package/dist/cjs/lib/lexer/terminals.js +100 -102
- package/dist/cjs/lib/lexer/terminals.js.map +1 -0
- package/dist/cjs/lib/sparql11HelperTypes.js +2 -15
- package/dist/cjs/lib/sparql11HelperTypes.js.map +1 -0
- package/dist/cjs/lib/utils.js +40 -58
- package/dist/cjs/lib/utils.js.map +1 -0
- package/dist/cjs/lib/validation/validators.js +217 -196
- package/dist/cjs/lib/validation/validators.js.map +1 -0
- package/dist/esm/lib/MinimalSparqlParser.d.ts +26 -8
- package/dist/esm/lib/MinimalSparqlParser.js +40 -11
- package/dist/esm/lib/MinimalSparqlParser.js.map +1 -1
- package/dist/esm/lib/astFactory.d.ts +66 -45
- package/dist/esm/lib/astFactory.js +3 -0
- package/dist/esm/lib/astFactory.js.map +1 -1
- package/dist/esm/lib/factoryMixins/ContextFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/ExpressionFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/GraphRefFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/PathFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/Patternfactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/QueryFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/SolutionModifiersFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/TermFactory.d.ts +7 -5
- package/dist/esm/lib/factoryMixins/UpdateOperationFactory.d.ts +7 -5
- package/dist/esm/lib/grammar/index.js +1 -1
- package/dist/esm/lib/grammar/index.js.map +1 -1
- package/dist/esm/lib/grammar/literals.js +23 -13
- package/dist/esm/lib/grammar/literals.js.map +1 -1
- package/dist/esm/lib/grammar/propertyPaths.d.ts +2 -2
- package/dist/esm/lib/grammar/tripleBlock.d.ts +4 -4
- package/dist/esm/lib/grammar/tripleBlock.js +18 -12
- package/dist/esm/lib/grammar/tripleBlock.js.map +1 -1
- package/dist/esm/lib/grammar/updateUnit.js +2 -2
- package/dist/esm/lib/grammar/updateUnit.js.map +1 -1
- package/dist/esm/lib/lexer/BuiltInCalls.d.ts +1 -1
- package/dist/esm/lib/lexer/graph.d.ts +1 -1
- package/dist/esm/lib/lexer/lexer.d.ts +2 -2
- package/dist/esm/lib/lexer/lexerPatterns.d.ts +1 -1
- package/dist/esm/lib/lexer/lexerPatterns.js +1 -1
- package/dist/esm/lib/lexer/lexerPatterns.js.map +1 -1
- package/dist/esm/lib/lexer/symbols.d.ts +1 -1
- package/dist/esm/lib/lexer/terminals.d.ts +2 -2
- package/dist/esm/lib/lexer/terminals.js +3 -3
- package/dist/esm/lib/lexer/terminals.js.map +1 -1
- package/dist/esm/lib/sparql11HelperTypes.d.ts +1 -1
- package/dist/esm/lib/sparql11HelperTypes.js.map +1 -1
- package/dist/esm/lib/validation/validators.d.ts +2 -2
- package/dist/esm/lib/validation/validators.js +61 -51
- package/dist/esm/lib/validation/validators.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Traqula Rules SPARQL 1.1
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@traqula/rules-sparql-1-1)
|
|
4
|
+
|
|
3
5
|
Traqula rules SPARQL 1.1 contains rules required for creating a parser for SPARQL 1.1.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -1,64 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var MinimalSparqlParser_exports = {};
|
|
20
|
-
__export(MinimalSparqlParser_exports, {
|
|
21
|
-
MinimalSparqlParser: () => MinimalSparqlParser,
|
|
22
|
-
completeParseContext: () => completeParseContext
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(MinimalSparqlParser_exports);
|
|
25
|
-
var import_core = require("@traqula/core");
|
|
26
|
-
var import_astFactory = require("./astFactory.js");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MinimalSparqlParser = void 0;
|
|
4
|
+
exports.completeParseContext = completeParseContext;
|
|
5
|
+
exports.completeGeneratorContext = completeGeneratorContext;
|
|
6
|
+
exports.copyParseContext = copyParseContext;
|
|
7
|
+
const core_1 = require("@traqula/core");
|
|
8
|
+
const astFactory_js_1 = require("./astFactory.js");
|
|
27
9
|
function completeParseContext(context) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
10
|
+
return {
|
|
11
|
+
astFactory: context.astFactory ?? new astFactory_js_1.AstFactory({ tracksSourceLocation: false }),
|
|
12
|
+
baseIRI: context.baseIRI,
|
|
13
|
+
prefixes: { ...context.prefixes },
|
|
14
|
+
parseMode: context.parseMode ? new Set(context.parseMode) : new Set(['canParseVars', 'canCreateBlankNodes']),
|
|
15
|
+
skipValidation: context.skipValidation ?? false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function completeGeneratorContext(context) {
|
|
19
|
+
return {
|
|
20
|
+
astFactory: context.astFactory ?? new astFactory_js_1.AstFactory(),
|
|
21
|
+
origSource: context.origSource ?? '',
|
|
22
|
+
offset: context.offset,
|
|
23
|
+
[core_1.traqulaIndentation]: context[core_1.traqulaIndentation] ?? 0,
|
|
24
|
+
indentInc: context.indentInc ?? 2,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function copyParseContext(context) {
|
|
28
|
+
return {
|
|
29
|
+
...context,
|
|
30
|
+
prefixes: { ...context.prefixes },
|
|
31
|
+
parseMode: new Set(context.parseMode),
|
|
32
|
+
};
|
|
39
33
|
}
|
|
40
34
|
class MinimalSparqlParser {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
parser;
|
|
36
|
+
defaultContext;
|
|
37
|
+
coreTransformer = new core_1.TransformerObject();
|
|
38
|
+
constructor(parser, defaultContext = {}) {
|
|
39
|
+
this.parser = parser;
|
|
40
|
+
this.defaultContext = completeParseContext(defaultContext);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parse a query string starting from the
|
|
44
|
+
* [QueryUnit](https://www.w3.org/TR/sparql11-query/#rQueryUnit)
|
|
45
|
+
* or [QueryUpdate](https://www.w3.org/TR/sparql11-query/#rUpdateUnit) rules.
|
|
46
|
+
* @param query
|
|
47
|
+
* @param context
|
|
48
|
+
*/
|
|
49
|
+
parse(query, context = {}) {
|
|
50
|
+
const ast = this.parser.queryOrUpdate(query, copyParseContext({ ...this.defaultContext, ...context }));
|
|
51
|
+
ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);
|
|
52
|
+
return ast;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parse a query string starting from the [Path](https://www.w3.org/TR/sparql11-query/#rPath) grammar rule.
|
|
56
|
+
* @param query
|
|
57
|
+
* @param context
|
|
58
|
+
*/
|
|
59
|
+
parsePath(query, context = {}) {
|
|
60
|
+
const ast = this.parser.path(query, copyParseContext({ ...this.defaultContext, ...context }));
|
|
61
|
+
ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);
|
|
62
|
+
if (this.defaultContext.astFactory.isPathPure(ast)) {
|
|
63
|
+
return {
|
|
64
|
+
...ast,
|
|
65
|
+
prefixes: {},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return ast;
|
|
56
69
|
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
70
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
MinimalSparqlParser,
|
|
63
|
-
completeParseContext
|
|
64
|
-
});
|
|
71
|
+
exports.MinimalSparqlParser = MinimalSparqlParser;
|
|
72
|
+
//# sourceMappingURL=MinimalSparqlParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["../../../lib/MinimalSparqlParser.ts"],"names":[],"mappings":";;;AAWA,oDAUC;AAED,4DAUC;AAED,4CASC;AA3CD,wCAAsE;AACtE,mDAA6C;AAS7C,SAAgB,oBAAoB,CAClC,OAA+B;IAE/B,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,0BAAU,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QACjF,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAE,cAAc,EAAE,qBAAqB,CAAE,CAAC;QAC9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H,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAa,EAAE,UAAkC,EAAE;QAElE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9F,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO;gBACL,GAAG,GAAG;gBACN,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["import type { Localized } from '@traqula/core';\nimport { TransformerObject, traqulaIndentation } from '@traqula/core';\nimport { AstFactory } from './astFactory.js';\nimport type { SparqlContext, SparqlGeneratorContext } from './sparql11HelperTypes.js';\nimport type { Path, TermIri } from './Sparql11types.js';\n\ninterface Parser<ParseRet> {\n queryOrUpdate: (input: string, context: SparqlContext) => ParseRet;\n path: (input: string, context: SparqlContext) => TermIri | Path;\n}\n\nexport function completeParseContext(\n context: Partial<SparqlContext>,\n): SparqlContext {\n return {\n astFactory: context.astFactory ?? new AstFactory({ tracksSourceLocation: false }),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport function completeGeneratorContext(\n context: Partial<SparqlGeneratorContext & { offset?: number }>,\n): SparqlGeneratorContext & { offset?: number } {\n return {\n astFactory: context.astFactory ?? new AstFactory(),\n origSource: context.origSource ?? '',\n offset: context.offset,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n indentInc: context.indentInc ?? 2,\n };\n}\n\nexport function copyParseContext<T extends\nPartial<SparqlContext & SparqlGeneratorContext & { origSource: string; offset?: number }>>(\n context: T,\n): T {\n return {\n ...context,\n prefixes: { ...context.prefixes },\n parseMode: new Set(context.parseMode),\n };\n}\n\nexport class MinimalSparqlParser<ParseRet extends Localized> {\n protected readonly defaultContext: SparqlContext;\n protected readonly coreTransformer = new TransformerObject();\n\n public constructor(protected readonly parser: Parser<ParseRet>, defaultContext: Partial<SparqlContext> = {}) {\n this.defaultContext = completeParseContext(defaultContext);\n }\n\n /**\n * Parse a query string starting from the\n * [QueryUnit](https://www.w3.org/TR/sparql11-query/#rQueryUnit)\n * or [QueryUpdate](https://www.w3.org/TR/sparql11-query/#rUpdateUnit) rules.\n * @param query\n * @param context\n */\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n const ast = this.parser.queryOrUpdate(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n return ast;\n }\n\n /**\n * Parse a query string starting from the [Path](https://www.w3.org/TR/sparql11-query/#rPath) grammar rule.\n * @param query\n * @param context\n */\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const ast = this.parser.path(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n if (this.defaultContext.astFactory.isPathPure(ast)) {\n return {\n ...ast,\n prefixes: {},\n };\n }\n return ast;\n }\n}\n"]}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var Sparql11types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(Sparql11types_exports);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=Sparql11types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sparql11types.js","sourceRoot":"","sources":["../../../lib/Sparql11types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Localized, Node } from '@traqula/core';\n\nexport type Sparql11Nodes =\n | GraphRef\n | GraphQuads\n | UpdateOperation\n | Update\n | Query\n | DatasetClauses\n | TripleCollection\n | TripleNesting\n | Pattern\n | SolutionModifier\n | Expression\n | Path\n | ContextDefinition\n | Wildcard\n | Term;\n\nexport type GraphRefBase = Node & {\n type: 'graphRef';\n subType: string;\n};\nexport type GraphRefDefault = GraphRefBase & {\n subType: 'default';\n};\nexport type GraphRefNamed = GraphRefBase & {\n subType: 'named';\n};\nexport type GraphRefAll = GraphRefBase & {\n subType: 'all';\n};\nexport type GraphRefSpecific = GraphRefBase & {\n subType: 'specific';\n graph: TermIri;\n};\nexport type GraphRef =\n | GraphRefDefault\n | GraphRefNamed\n | GraphRefAll\n | GraphRefSpecific;\n\nexport type Quads = PatternBgp | GraphQuads;\n\nexport type GraphQuads = Node & {\n type: 'graph';\n graph: TermIri | TermVariable;\n triples: PatternBgp;\n};\n\n// https://www.w3.org/TR/sparql11-query/#rUpdate1\nexport type UpdateOperationBase = Node & { type: 'updateOperation'; subType: string };\nexport type UpdateOperationLoad = UpdateOperationBase & {\n subType: 'load';\n silent: boolean;\n source: TermIri;\n destination?: GraphRefSpecific;\n};\ntype UpdateOperationClearDropCreateBase = UpdateOperationBase & {\n subType: 'clear' | 'drop' | 'create';\n silent: boolean;\n destination: GraphRef;\n};\nexport type UpdateOperationClear = UpdateOperationClearDropCreateBase & { subType: 'clear' };\nexport type UpdateOperationDrop = UpdateOperationClearDropCreateBase & { subType: 'drop' };\nexport type UpdateOperationCreate = UpdateOperationClearDropCreateBase & {\n subType: 'create';\n destination: GraphRefSpecific;\n};\ntype UpdateOperationAddMoveCopy = UpdateOperationBase & {\n subType: 'add' | 'move' | 'copy';\n silent: boolean;\n source: GraphRefDefault | GraphRefSpecific;\n destination: GraphRefDefault | GraphRefSpecific;\n};\nexport type UpdateOperationAdd = UpdateOperationAddMoveCopy & { subType: 'add' };\nexport type UpdateOperationMove = UpdateOperationAddMoveCopy & { subType: 'move' };\nexport type UpdateOperationCopy = UpdateOperationAddMoveCopy & { subType: 'copy' };\ntype UpdateOperationInsertDeleteDelWhere = UpdateOperationBase & {\n subType: 'insertdata' | 'deletedata' | 'deletewhere';\n data: Quads[];\n};\nexport type UpdateOperationInsertData = UpdateOperationInsertDeleteDelWhere & { subType: 'insertdata' };\nexport type UpdateOperationDeleteData = UpdateOperationInsertDeleteDelWhere & { subType: 'deletedata' };\nexport type UpdateOperationDeleteWhere = UpdateOperationInsertDeleteDelWhere & { subType: 'deletewhere' };\nexport type UpdateOperationModify = UpdateOperationBase & {\n subType: 'modify';\n graph: TermIri | undefined;\n insert: Quads[];\n delete: Quads[];\n from: DatasetClauses;\n where: PatternGroup;\n};\nexport type UpdateOperation =\n | UpdateOperationLoad\n | UpdateOperationClear\n | UpdateOperationDrop\n | UpdateOperationCreate\n | UpdateOperationAdd\n | UpdateOperationMove\n | UpdateOperationCopy\n | UpdateOperationInsertData\n | UpdateOperationDeleteData\n | UpdateOperationDeleteWhere\n | UpdateOperationModify;\n\n// https://www.w3.org/TR/sparql11-query/#rUpdate\nexport type Update = Node & {\n type: 'update';\n updates: {\n operation?: UpdateOperation;\n context: ContextDefinition[];\n }[];\n};\n\n// https://www.w3.org/TR/sparql11-query/#rQueryUnit\nexport type QueryBase = Node & {\n type: 'query';\n subType: string;\n\n context: ContextDefinition[];\n values?: PatternValues;\n solutionModifiers: SolutionModifiers;\n datasets: DatasetClauses;\n where?: PatternGroup;\n};\nexport type QuerySelect = QueryBase & {\n subType: 'select';\n variables: (TermVariable | PatternBind)[] | [Wildcard];\n distinct?: true;\n reduced?: true;\n where: PatternGroup;\n};\nexport type QueryConstruct = QueryBase & {\n subType: 'construct';\n template: PatternBgp;\n where: PatternGroup;\n};\nexport type QueryDescribe = QueryBase & {\n subType: 'describe';\n variables: (TermVariable | TermIri)[] | [Wildcard];\n};\nexport type QueryAsk = QueryBase & {\n subType: 'ask';\n where: PatternGroup;\n};\nexport type Query =\n | QuerySelect\n | QueryConstruct\n | QueryDescribe\n | QueryAsk;\n\nexport type SparqlQuery = Query | Update;\n\n// https://www.w3.org/TR/sparql11-query/#rDatasetClause\nexport type DatasetClauses = Node & {\n type: 'datasetClauses';\n clauses: { clauseType: 'default' | 'named'; value: TermIri }[];\n};\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type TripleCollectionBase = Node & {\n type: 'tripleCollection';\n subType: string;\n triples: TripleNesting[];\n identifier: Term;\n};\n/**\n * The subject of the triples does not have a string manifestation.\n */\nexport type TripleCollectionList = TripleCollectionBase & {\n subType: 'list';\n identifier: TermBlank;\n};\n/**\n * Bot subject and predicate of the triples do not have a string manifestation.\n */\nexport type TripleCollectionBlankNodeProperties = TripleCollectionBase & {\n subType: 'blankNodeProperties';\n identifier: TermBlank;\n};\nexport type TripleCollection =\n | TripleCollectionList\n | TripleCollectionBlankNodeProperties;\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type GraphNode = Term | TripleCollection;\n\n// https://www.w3.org/TR/sparql11-query/#rTriplesBlock\nexport type TripleNesting = Node & {\n type: 'triple';\n subject: GraphNode;\n predicate: TermIri | TermVariable | Path;\n object: GraphNode;\n};\n\nexport type PatternBase = Node & { type: 'pattern'; subType: string };\nexport type PatternFilter = PatternBase & {\n subType: 'filter';\n expression: Expression;\n};\nexport type PatternMinus = PatternBase & {\n subType: 'minus';\n patterns: Pattern[];\n};\n\nexport type PatternGroup = PatternBase & {\n subType: 'group';\n patterns: Pattern[];\n};\nexport type PatternOptional = PatternBase & {\n subType: 'optional';\n patterns: Pattern[];\n};\nexport type PatternGraph = PatternBase & {\n subType: 'graph';\n name: TermIri | TermVariable;\n patterns: Pattern[];\n};\nexport type PatternUnion = PatternBase & {\n subType: 'union';\n patterns: PatternGroup[];\n};\nexport type BasicGraphPattern = (TripleNesting | TripleCollection)[];\nexport type PatternBgp = PatternBase & {\n subType: 'bgp';\n /**\n * Only the first appearance of a subject and predicate have a string manifestation\n */\n triples: BasicGraphPattern;\n};\nexport type PatternBind = PatternBase & {\n subType: 'bind';\n expression: Expression;\n variable: TermVariable;\n};\nexport type PatternService = PatternBase & {\n subType: 'service';\n name: TermIri | TermVariable;\n silent: boolean;\n patterns: Pattern[];\n};\n/**\n * A single list of assignments maps the variable identifier to the value\n */\nexport type ValuePatternRow = Record<string, TermIri | TermLiteral | undefined>;\nexport type PatternValues = PatternBase & {\n subType: 'values';\n variables: TermVariable[];\n values: ValuePatternRow[];\n};\nexport type SubSelect = QuerySelect;\n\nexport type Pattern =\n | PatternBgp\n | PatternGroup\n | PatternUnion\n | PatternOptional\n | PatternMinus\n | PatternGraph\n | PatternService\n | PatternFilter\n | PatternBind\n | PatternValues\n | SubSelect;\n\nexport type SolutionModifiers = {\n group?: SolutionModifierGroup;\n having?: SolutionModifierHaving;\n order?: SolutionModifierOrder;\n limitOffset?: SolutionModifierLimitOffset;\n};\nexport type SolutionModifierBase = Node & { type: 'solutionModifier'; subType: string };\nexport type SolutionModifierGroupBind = Localized & {\n variable: TermVariable;\n value: Expression;\n};\nexport type SolutionModifierGroup = SolutionModifierBase & {\n subType: 'group';\n groupings: (Expression | SolutionModifierGroupBind)[];\n};\nexport type SolutionModifierHaving = SolutionModifierBase & {\n subType: 'having';\n having: Expression[];\n};\nexport type Ordering = Localized & {\n descending: boolean;\n expression: Expression;\n};\nexport type SolutionModifierOrder = SolutionModifierBase & {\n subType: 'order';\n orderDefs: Ordering[];\n};\nexport type SolutionModifierLimitOffset = SolutionModifierBase\n & { subType: 'limitOffset'; limit: number | undefined; offset: number | undefined };\n\nexport type SolutionModifier =\n | SolutionModifierGroup\n | SolutionModifierHaving\n | SolutionModifierOrder\n | SolutionModifierLimitOffset;\n\nexport type ExpressionBase = Node & { type: 'expression'; subType: string };\n\ntype ExpressionAggregateBase = ExpressionBase & {\n subType: 'aggregate';\n distinct: boolean;\n expression: [Expression | Wildcard];\n};\nexport type ExpressionAggregateDefault = ExpressionAggregateBase & {\n expression: [Expression];\n aggregation: string;\n};\nexport type ExpressionAggregateOnWildcard = ExpressionAggregateBase & {\n expression: [Wildcard];\n aggregation: string;\n};\nexport type ExpressionAggregateSeparator = ExpressionAggregateBase & {\n expression: [Expression];\n aggregation: string;\n separator: string;\n};\nexport type ExpressionAggregate =\n | ExpressionAggregateDefault\n | ExpressionAggregateOnWildcard\n | ExpressionAggregateSeparator;\n\nexport type ExpressionOperation = ExpressionBase & {\n subType: 'operation';\n operator: string;\n args: Expression[];\n};\n\nexport type ExpressionPatternOperation = ExpressionBase & {\n subType: 'patternOperation';\n operator: string;\n // Can be a pattern in case of exists and not exists\n args: PatternGroup;\n};\n\nexport type ExpressionFunctionCall = ExpressionBase & {\n subType: 'functionCall';\n function: TermIri;\n distinct: boolean;\n args: Expression[];\n};\n\nexport type Expression =\n | ExpressionOperation\n | ExpressionPatternOperation\n | ExpressionFunctionCall\n | ExpressionAggregate\n | TermIri\n | TermVariable\n | TermLiteral;\n\nexport type PropertyPathBase = Node & { type: 'path'; subType: string };\nexport type PropertyPathChain = PropertyPathBase & {\n subType: '|' | '/';\n items: Path[];\n};\n\nexport type PathModified = PropertyPathBase & {\n subType: '?' | '*' | '+' | '^';\n items: [Path];\n};\n\nexport type PathNegatedElt = PropertyPathBase & {\n subType: '^';\n items: [TermIri];\n};\n\nexport type PathAlternativeLimited = PropertyPathBase & {\n subType: '|';\n items: (TermIri | PathNegatedElt)[];\n};\n\nexport type PathNegated = PropertyPathBase & {\n subType: '!';\n items: [TermIri | PathNegatedElt | PathAlternativeLimited];\n};\n\n// [[88]](https://www.w3.org/TR/sparql11-query/#rPath)\nexport type Path =\n | TermIri\n | PropertyPathChain\n | PathModified\n | PathNegated;\nexport type PathPure = PropertyPathChain | PathModified | PathNegated;\n\nexport type ContextDefinitionBase_ = Node & { type: 'contextDef'; subType: string };\nexport type ContextDefinitionPrefix = ContextDefinitionBase_ & {\n subType: 'prefix';\n key: string;\n value: TermIriFull;\n};\nexport type ContextDefinitionBase = ContextDefinitionBase_ & {\n subType: 'base';\n value: TermIriFull;\n};\nexport type ContextDefinition = ContextDefinitionPrefix | ContextDefinitionBase;\n\nexport type Wildcard = Node & {\n type: 'wildcard';\n};\n\nexport type TermBase = Node & { type: 'term'; subType: string };\nexport type TermLiteralBase = TermBase & {\n subType: 'literal';\n value: string;\n};\nexport type TermLiteralStr = TermLiteralBase & { langOrIri: undefined };\nexport type TermLiteralLangStr = TermLiteralBase & { langOrIri: string };\nexport type TermLiteralTyped = TermLiteralBase & { langOrIri: TermIri };\nexport type TermLiteral = TermLiteralStr | TermLiteralLangStr | TermLiteralTyped;\n\nexport type TermVariable = TermBase & {\n subType: 'variable';\n value: string;\n};\n\nexport type TermIriBase = TermBase & { subType: 'namedNode' };\nexport type TermIriFull = TermIriBase & { value: string };\nexport type TermIriPrefixed = TermIriBase & {\n value: string;\n prefix: string;\n};\nexport type TermIri = TermIriFull | TermIriPrefixed;\n\nexport type TermBlank = TermBase & { subType: 'blankNode' } & { label: string };\n\nexport type GraphTerm = TermIri | TermBlank | TermLiteral;\nexport type Term = GraphTerm | TermVariable;\n"]}
|
|
@@ -1,121 +1,112 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
isGraphQuads(obj) {
|
|
112
|
-
return super.isOfType(obj, "graph");
|
|
113
|
-
}
|
|
114
|
-
isUpdate(obj) {
|
|
115
|
-
return super.isOfType(obj, "update");
|
|
116
|
-
}
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AstFactory = void 0;
|
|
4
|
+
const core_1 = require("@traqula/core");
|
|
5
|
+
const ContextFactory_js_1 = require("./factoryMixins/ContextFactory.js");
|
|
6
|
+
const ExpressionFactory_js_1 = require("./factoryMixins/ExpressionFactory.js");
|
|
7
|
+
const GraphRefFactory_js_1 = require("./factoryMixins/GraphRefFactory.js");
|
|
8
|
+
const mixins_js_1 = require("./factoryMixins/mixins.js");
|
|
9
|
+
const PathFactory_js_1 = require("./factoryMixins/PathFactory.js");
|
|
10
|
+
const Patternfactory_js_1 = require("./factoryMixins/Patternfactory.js");
|
|
11
|
+
const QueryFactory_js_1 = require("./factoryMixins/QueryFactory.js");
|
|
12
|
+
const SolutionModifiersFactory_js_1 = require("./factoryMixins/SolutionModifiersFactory.js");
|
|
13
|
+
const TermFactory_js_1 = require("./factoryMixins/TermFactory.js");
|
|
14
|
+
const UpdateOperationFactory_js_1 = require("./factoryMixins/UpdateOperationFactory.js");
|
|
15
|
+
/**
|
|
16
|
+
* A factory that helps you create, and check types for AST nodes for SPARQL 1.1
|
|
17
|
+
*/
|
|
18
|
+
class AstFactory extends (0, mixins_js_1.asArg)(core_1.AstCoreFactory)
|
|
19
|
+
.call(ContextFactory_js_1.ContextFactoryMixin)
|
|
20
|
+
.call(ExpressionFactory_js_1.ExpressionFactoryMixin)
|
|
21
|
+
.call(GraphRefFactory_js_1.GraphRefFactoryMixin)
|
|
22
|
+
.call(PathFactory_js_1.PathFactoryMixin)
|
|
23
|
+
.call(Patternfactory_js_1.PatternFactoryMixin)
|
|
24
|
+
.call(QueryFactory_js_1.QueryFactoryMixin)
|
|
25
|
+
.call(SolutionModifiersFactory_js_1.SolutionModifiersFactoryMixin)
|
|
26
|
+
.call(TermFactory_js_1.TermFactoryMixin)
|
|
27
|
+
.call(UpdateOperationFactory_js_1.UpdateOperationFactoryMixin)
|
|
28
|
+
.returns() {
|
|
29
|
+
alwaysSparql11(obj) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
isPath(obj) {
|
|
33
|
+
return this.isPathPure(obj) || this.isTermNamed(obj);
|
|
34
|
+
}
|
|
35
|
+
isExpression(obj) {
|
|
36
|
+
return this.isExpressionPure(obj) || this.isTermNamed(obj) || this.isTermVariable(obj) || this.isTermLiteral(obj);
|
|
37
|
+
}
|
|
38
|
+
graphNodeIdentifier(graphNode) {
|
|
39
|
+
return graphNode.type === 'tripleCollection' ? graphNode.identifier : graphNode;
|
|
40
|
+
}
|
|
41
|
+
triple(subject, predicate, object, loc) {
|
|
42
|
+
return {
|
|
43
|
+
type: 'triple',
|
|
44
|
+
subject,
|
|
45
|
+
predicate,
|
|
46
|
+
object,
|
|
47
|
+
loc: loc ?? this.sourceLocation(subject, predicate, object),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
isTriple(obj) {
|
|
51
|
+
return this.isOfType(obj, 'triple');
|
|
52
|
+
}
|
|
53
|
+
datasetClauses(clauses, loc) {
|
|
54
|
+
return {
|
|
55
|
+
type: 'datasetClauses',
|
|
56
|
+
clauses,
|
|
57
|
+
loc,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
isDatasetClauses(obj) {
|
|
61
|
+
return this.isOfType(obj, 'datasetClauses');
|
|
62
|
+
}
|
|
63
|
+
wildcard(loc) {
|
|
64
|
+
return { type: 'wildcard', loc };
|
|
65
|
+
}
|
|
66
|
+
isWildcard(obj) {
|
|
67
|
+
return this.isOfType(obj, 'wildcard');
|
|
68
|
+
}
|
|
69
|
+
isTripleCollection(obj) {
|
|
70
|
+
return this.isOfType(obj, 'tripleCollection');
|
|
71
|
+
}
|
|
72
|
+
tripleCollectionBlankNodeProperties(identifier, triples, loc) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'tripleCollection',
|
|
75
|
+
subType: 'blankNodeProperties',
|
|
76
|
+
identifier,
|
|
77
|
+
triples,
|
|
78
|
+
loc,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
isTripleCollectionBlankNodeProperties(obj) {
|
|
82
|
+
return this.isOfSubType(obj, 'tripleCollection', 'blankNodeProperties');
|
|
83
|
+
}
|
|
84
|
+
tripleCollectionList(identifier, triples, loc) {
|
|
85
|
+
return {
|
|
86
|
+
type: 'tripleCollection',
|
|
87
|
+
subType: 'list',
|
|
88
|
+
identifier,
|
|
89
|
+
triples,
|
|
90
|
+
loc,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
isTripleCollectionList(obj) {
|
|
94
|
+
return this.isOfSubType(obj, 'tripleCollection', 'list');
|
|
95
|
+
}
|
|
96
|
+
graphQuads(graph, triples, loc) {
|
|
97
|
+
return {
|
|
98
|
+
type: 'graph',
|
|
99
|
+
graph,
|
|
100
|
+
triples,
|
|
101
|
+
loc,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
isGraphQuads(obj) {
|
|
105
|
+
return super.isOfType(obj, 'graph');
|
|
106
|
+
}
|
|
107
|
+
isUpdate(obj) {
|
|
108
|
+
return super.isOfType(obj, 'update');
|
|
109
|
+
}
|
|
117
110
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
AstFactory
|
|
121
|
-
});
|
|
111
|
+
exports.AstFactory = AstFactory;
|
|
112
|
+
//# sourceMappingURL=astFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astFactory.js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AO,EAAE,MAAM;YACf,UAAU;YACV,OAAO;YACP,GAAG;SACJ,CAAC;IACJ,CAAC;IAEM,sBAAsB,CAAC,GAAW;QAEvC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAEM,UAAU,CAAC,KAA6B,EAAE,OAAmB,EAAE,GAAmB;QACvF,OAAO;YACL,IAAI,EAAE,OAAO;YACb,KAAK;YACL,OAAO;YACP,GAAG;SACJ,CAAC;IACJ,CAAC;IAEM,YAAY,CAAC,GAAW;QAC7B,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAEM,QAAQ,CAAC,GAAW;QACzB,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF;AA7HD,gCA6HC","sourcesContent":["import type { SourceLocation, SubTyped, Typed } from '@traqula/core';\nimport { AstCoreFactory } from '@traqula/core';\nimport { ContextFactoryMixin } from './factoryMixins/ContextFactory.js';\nimport { ExpressionFactoryMixin } from './factoryMixins/ExpressionFactory.js';\nimport { GraphRefFactoryMixin } from './factoryMixins/GraphRefFactory.js';\nimport { asArg } from './factoryMixins/mixins.js';\nimport { PathFactoryMixin } from './factoryMixins/PathFactory.js';\nimport { PatternFactoryMixin } from './factoryMixins/Patternfactory.js';\nimport { QueryFactoryMixin } from './factoryMixins/QueryFactory.js';\nimport { SolutionModifiersFactoryMixin } from './factoryMixins/SolutionModifiersFactory.js';\nimport { TermFactoryMixin } from './factoryMixins/TermFactory.js';\nimport { UpdateOperationFactoryMixin } from './factoryMixins/UpdateOperationFactory.js';\nimport type {\n DatasetClauses,\n GraphNode,\n GraphQuads,\n PatternBgp,\n Sparql11Nodes,\n Term,\n TermBlank,\n TermIri,\n TermVariable,\n TripleCollectionBlankNodeProperties,\n TripleCollectionList,\n TripleNesting,\n Update,\n Wildcard,\n} from './Sparql11types.js';\n\n/**\n * A factory that helps you create, and check types for AST nodes for SPARQL 1.1\n */\nexport class AstFactory extends asArg(AstCoreFactory)\n .call(ContextFactoryMixin)\n .call(ExpressionFactoryMixin)\n .call(GraphRefFactoryMixin)\n .call(PathFactoryMixin)\n .call(PatternFactoryMixin)\n .call(QueryFactoryMixin)\n .call(SolutionModifiersFactoryMixin)\n .call(TermFactoryMixin)\n .call(UpdateOperationFactoryMixin)\n .returns() {\n public alwaysSparql11(obj: object): obj is Sparql11Nodes {\n return true;\n }\n\n public isPath(obj: object): obj is SubTyped<'term', 'namedNode'> | Typed<'path'> {\n return this.isPathPure(obj) || this.isTermNamed(obj);\n }\n\n public isExpression(obj: object):\n obj is SubTyped<'term', 'namedNode' | 'variable' | 'literal'> | Typed<'expression'> {\n return this.isExpressionPure(obj) || this.isTermNamed(obj) || this.isTermVariable(obj) || this.isTermLiteral(obj);\n }\n\n public graphNodeIdentifier(graphNode: GraphNode): Term {\n return graphNode.type === 'tripleCollection' ? graphNode.identifier : graphNode;\n }\n\n public triple(\n subject: TripleNesting['subject'],\n predicate: TripleNesting['predicate'],\n object: TripleNesting['object'],\n loc?: SourceLocation,\n ): TripleNesting {\n return {\n type: 'triple',\n subject,\n predicate,\n object,\n loc: loc ?? this.sourceLocation(subject, predicate, object),\n };\n }\n\n public isTriple(obj: object): obj is Typed<'triple'> {\n return this.isOfType(obj, 'triple');\n }\n\n public datasetClauses(clauses: DatasetClauses['clauses'], loc: SourceLocation): DatasetClauses {\n return {\n type: 'datasetClauses',\n clauses,\n loc,\n };\n }\n\n public isDatasetClauses(obj: object): obj is Typed<'datasetClauses'> {\n return this.isOfType(obj, 'datasetClauses');\n }\n\n public wildcard(loc: SourceLocation): Wildcard {\n return { type: 'wildcard', loc };\n }\n\n public isWildcard(obj: object): obj is Typed<'wildcard'> {\n return this.isOfType(obj, 'wildcard');\n }\n\n public isTripleCollection(obj: object): obj is Typed<'tripleCollection'> {\n return this.isOfType(obj, 'tripleCollection');\n }\n\n public tripleCollectionBlankNodeProperties(\n identifier: TermBlank,\n triples: TripleNesting[],\n loc: SourceLocation,\n ): TripleCollectionBlankNodeProperties {\n return {\n type: 'tripleCollection',\n subType: 'blankNodeProperties',\n identifier,\n triples,\n loc,\n };\n }\n\n public isTripleCollectionBlankNodeProperties(obj: object):\n obj is SubTyped<'tripleCollection', 'blankNodeProperties'> {\n return this.isOfSubType(obj, 'tripleCollection', 'blankNodeProperties');\n }\n\n public tripleCollectionList(\n identifier: TermBlank,\n triples: TripleNesting[],\n loc: SourceLocation,\n ): TripleCollectionList {\n return {\n type: 'tripleCollection',\n subType: 'list',\n identifier,\n triples,\n loc,\n };\n }\n\n public isTripleCollectionList(obj: object):\n obj is SubTyped<'tripleCollection', 'list'> {\n return this.isOfSubType(obj, 'tripleCollection', 'list');\n }\n\n public graphQuads(graph: TermIri | TermVariable, triples: PatternBgp, loc: SourceLocation): GraphQuads {\n return {\n type: 'graph',\n graph,\n triples,\n loc,\n };\n }\n\n public isGraphQuads(obj: object): obj is GraphQuads {\n return super.isOfType(obj, 'graph');\n }\n\n public isUpdate(obj: object): obj is Update {\n return super.isOfType(obj, 'update');\n }\n}\n"]}
|