@traqula/rules-sparql-1-1 0.0.22 → 0.0.24

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.
Files changed (76) hide show
  1. package/dist/cjs/lib/MinimalSparqlParser.js +35 -58
  2. package/dist/cjs/lib/MinimalSparqlParser.js.map +1 -0
  3. package/dist/cjs/lib/Sparql11types.js +2 -15
  4. package/dist/cjs/lib/Sparql11types.js.map +1 -0
  5. package/dist/cjs/lib/astFactory.js +107 -119
  6. package/dist/cjs/lib/astFactory.js.map +1 -0
  7. package/dist/cjs/lib/expressionHelpers.js +181 -191
  8. package/dist/cjs/lib/expressionHelpers.js.map +1 -0
  9. package/dist/cjs/lib/factoryMixins/ContextFactory.js +30 -52
  10. package/dist/cjs/lib/factoryMixins/ContextFactory.js.map +1 -0
  11. package/dist/cjs/lib/factoryMixins/ExpressionFactory.js +83 -102
  12. package/dist/cjs/lib/factoryMixins/ExpressionFactory.js.map +1 -0
  13. package/dist/cjs/lib/factoryMixins/GraphRefFactory.js +51 -73
  14. package/dist/cjs/lib/factoryMixins/GraphRefFactory.js.map +1 -0
  15. package/dist/cjs/lib/factoryMixins/PathFactory.js +68 -87
  16. package/dist/cjs/lib/factoryMixins/PathFactory.js.map +1 -0
  17. package/dist/cjs/lib/factoryMixins/Patternfactory.js +98 -120
  18. package/dist/cjs/lib/factoryMixins/Patternfactory.js.map +1 -0
  19. package/dist/cjs/lib/factoryMixins/QueryFactory.js +43 -65
  20. package/dist/cjs/lib/factoryMixins/QueryFactory.js.map +1 -0
  21. package/dist/cjs/lib/factoryMixins/SolutionModifiersFactory.js +55 -77
  22. package/dist/cjs/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -0
  23. package/dist/cjs/lib/factoryMixins/TermFactory.js +81 -102
  24. package/dist/cjs/lib/factoryMixins/TermFactory.js.map +1 -0
  25. package/dist/cjs/lib/factoryMixins/UpdateOperationFactory.js +126 -147
  26. package/dist/cjs/lib/factoryMixins/UpdateOperationFactory.js.map +1 -0
  27. package/dist/cjs/lib/factoryMixins/mixins.js +21 -38
  28. package/dist/cjs/lib/factoryMixins/mixins.js.map +1 -0
  29. package/dist/cjs/lib/grammar/builtIn.js +277 -377
  30. package/dist/cjs/lib/grammar/builtIn.js.map +1 -0
  31. package/dist/cjs/lib/grammar/dataSetClause.js +110 -109
  32. package/dist/cjs/lib/grammar/dataSetClause.js.map +1 -0
  33. package/dist/cjs/lib/grammar/expression.js +387 -358
  34. package/dist/cjs/lib/grammar/expression.js.map +1 -0
  35. package/dist/cjs/lib/grammar/general.js +173 -158
  36. package/dist/cjs/lib/grammar/general.js.map +1 -0
  37. package/dist/cjs/lib/grammar/index.js +94 -111
  38. package/dist/cjs/lib/grammar/index.js.map +1 -0
  39. package/dist/cjs/lib/grammar/literals.js +282 -266
  40. package/dist/cjs/lib/grammar/literals.js.map +1 -0
  41. package/dist/cjs/lib/grammar/propertyPaths.js +206 -193
  42. package/dist/cjs/lib/grammar/propertyPaths.js.map +1 -0
  43. package/dist/cjs/lib/grammar/queryUnit.js +395 -372
  44. package/dist/cjs/lib/grammar/queryUnit.js.map +1 -0
  45. package/dist/cjs/lib/grammar/solutionModifier.js +281 -265
  46. package/dist/cjs/lib/grammar/solutionModifier.js.map +1 -0
  47. package/dist/cjs/lib/grammar/tripleBlock.js +390 -355
  48. package/dist/cjs/lib/grammar/tripleBlock.js.map +1 -0
  49. package/dist/cjs/lib/grammar/updateUnit.js +551 -519
  50. package/dist/cjs/lib/grammar/updateUnit.js.map +1 -0
  51. package/dist/cjs/lib/grammar/whereClause.js +486 -459
  52. package/dist/cjs/lib/grammar/whereClause.js.map +1 -0
  53. package/dist/cjs/lib/index.js +47 -54
  54. package/dist/cjs/lib/index.js.map +1 -0
  55. package/dist/cjs/lib/lexer/BuiltInCalls.js +188 -333
  56. package/dist/cjs/lib/lexer/BuiltInCalls.js.map +1 -0
  57. package/dist/cjs/lib/lexer/graph.js +10 -40
  58. package/dist/cjs/lib/lexer/graph.js.map +1 -0
  59. package/dist/cjs/lib/lexer/index.js +43 -48
  60. package/dist/cjs/lib/lexer/index.js.map +1 -0
  61. package/dist/cjs/lib/lexer/lexer.js +84 -195
  62. package/dist/cjs/lib/lexer/lexer.js.map +1 -0
  63. package/dist/cjs/lib/lexer/lexerPatterns.js +40 -132
  64. package/dist/cjs/lib/lexer/lexerPatterns.js.map +1 -0
  65. package/dist/cjs/lib/lexer/symbols.js +31 -106
  66. package/dist/cjs/lib/lexer/symbols.js.map +1 -0
  67. package/dist/cjs/lib/lexer/terminals.js +100 -102
  68. package/dist/cjs/lib/lexer/terminals.js.map +1 -0
  69. package/dist/cjs/lib/sparql11HelperTypes.js +2 -15
  70. package/dist/cjs/lib/sparql11HelperTypes.js.map +1 -0
  71. package/dist/cjs/lib/utils.js +40 -58
  72. package/dist/cjs/lib/utils.js.map +1 -0
  73. package/dist/cjs/lib/validation/validators.js +197 -186
  74. package/dist/cjs/lib/validation/validators.js.map +1 -0
  75. package/dist/cjs/package.json +1 -0
  76. package/package.json +10 -9
@@ -1,105 +1,86 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
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 ExpressionFactory_exports = {};
20
- __export(ExpressionFactory_exports, {
21
- ExpressionFactoryMixin: () => ExpressionFactoryMixin
22
- });
23
- module.exports = __toCommonJS(ExpressionFactory_exports);
24
- const nodeType = "expression";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressionFactoryMixin = ExpressionFactoryMixin;
4
+ const nodeType = 'expression';
5
+ // eslint-disable-next-line ts/explicit-function-return-type
25
6
  function ExpressionFactoryMixin(Base) {
26
- return class ExpressionFactory extends Base {
27
- isExpressionPure(obj) {
28
- return this.isOfType(obj, nodeType);
29
- }
30
- formatOperator(operator) {
31
- return operator.toLowerCase().replaceAll(" ", "");
32
- }
33
- expressionOperation(operator, args, loc) {
34
- return {
35
- type: nodeType,
36
- subType: "operation",
37
- operator: this.formatOperator(operator),
38
- args,
39
- loc
40
- };
41
- }
42
- isExpressionOperator(obj) {
43
- return this.isOfSubType(obj, nodeType, "operation");
44
- }
45
- expressionFunctionCall(functionOp, args, distinct, loc) {
46
- return {
47
- type: "expression",
48
- subType: "functionCall",
49
- function: functionOp,
50
- args,
51
- distinct,
52
- loc
53
- };
54
- }
55
- isExpressionFunctionCall(obj) {
56
- return this.isOfSubType(obj, nodeType, "functionCall");
57
- }
58
- expressionPatternOperation(operator, args, loc) {
59
- return {
60
- type: nodeType,
61
- subType: "patternOperation",
62
- operator: this.formatOperator(operator),
63
- args,
64
- loc
65
- };
66
- }
67
- isExpressionPatternOperation(obj) {
68
- return this.isOfSubType(obj, nodeType, "patternOperation");
69
- }
70
- aggregate(aggregation, distinct, arg, separator, loc) {
71
- const base = {
72
- type: "expression",
73
- subType: "aggregate",
74
- aggregation: this.formatOperator(aggregation),
75
- distinct,
76
- loc
77
- };
78
- if (this.isOfType(arg, "wildcard")) {
79
- return { ...base, expression: [arg] };
80
- }
81
- if (separator === void 0) {
82
- return { ...base, expression: [arg] };
83
- }
84
- return { ...base, expression: [arg], separator };
85
- }
86
- isExpressionAggregate(obj) {
87
- return this.isOfSubType(obj, nodeType, "aggregate");
88
- }
89
- isExpressionAggregateSeparator(obj) {
90
- return this.isOfSubType(obj, nodeType, "aggregate") && typeof obj.separator === "string";
91
- }
92
- isExpressionAggregateOnWildcard(obj) {
93
- const casted = obj;
94
- return this.isOfSubType(obj, nodeType, "aggregate") && Array.isArray(casted.expression) && casted.expression.length === 1 && this.isOfType(casted.expression[0], "wildcard");
95
- }
96
- isExpressionAggregateDefault(obj) {
97
- const casted = obj;
98
- return this.isOfSubType(obj, nodeType, "operation") && Array.isArray(casted.expression) && casted.expression.length === 1 && !this.isOfType(casted.expression[0], "wildcard");
99
- }
100
- };
7
+ return class ExpressionFactory extends Base {
8
+ isExpressionPure(obj) {
9
+ return this.isOfType(obj, nodeType);
10
+ }
11
+ formatOperator(operator) {
12
+ return operator.toLowerCase().replaceAll(' ', '');
13
+ }
14
+ expressionOperation(operator, args, loc) {
15
+ return {
16
+ type: nodeType,
17
+ subType: 'operation',
18
+ operator: this.formatOperator(operator),
19
+ args,
20
+ loc,
21
+ };
22
+ }
23
+ isExpressionOperator(obj) {
24
+ return this.isOfSubType(obj, nodeType, 'operation');
25
+ }
26
+ expressionFunctionCall(functionOp, args, distinct, loc) {
27
+ return {
28
+ type: 'expression',
29
+ subType: 'functionCall',
30
+ function: functionOp,
31
+ args,
32
+ distinct,
33
+ loc,
34
+ };
35
+ }
36
+ isExpressionFunctionCall(obj) {
37
+ return this.isOfSubType(obj, nodeType, 'functionCall');
38
+ }
39
+ expressionPatternOperation(operator, args, loc) {
40
+ return {
41
+ type: nodeType,
42
+ subType: 'patternOperation',
43
+ operator: this.formatOperator(operator),
44
+ args,
45
+ loc,
46
+ };
47
+ }
48
+ isExpressionPatternOperation(obj) {
49
+ return this.isOfSubType(obj, nodeType, 'patternOperation');
50
+ }
51
+ aggregate(aggregation, distinct, arg, separator, loc) {
52
+ const base = {
53
+ type: 'expression',
54
+ subType: 'aggregate',
55
+ aggregation: this.formatOperator(aggregation),
56
+ distinct,
57
+ loc,
58
+ };
59
+ if (this.isOfType(arg, 'wildcard')) {
60
+ return { ...base, expression: [arg] };
61
+ }
62
+ if (separator === undefined) {
63
+ return { ...base, expression: [arg] };
64
+ }
65
+ return { ...base, expression: [arg], separator };
66
+ }
67
+ isExpressionAggregate(obj) {
68
+ return this.isOfSubType(obj, nodeType, 'aggregate');
69
+ }
70
+ isExpressionAggregateSeparator(obj) {
71
+ return this.isOfSubType(obj, nodeType, 'aggregate') &&
72
+ typeof obj.separator === 'string';
73
+ }
74
+ isExpressionAggregateOnWildcard(obj) {
75
+ const casted = obj;
76
+ return this.isOfSubType(obj, nodeType, 'aggregate') && Array.isArray(casted.expression) &&
77
+ casted.expression.length === 1 && this.isOfType(casted.expression[0], 'wildcard');
78
+ }
79
+ isExpressionAggregateDefault(obj) {
80
+ const casted = obj;
81
+ return this.isOfSubType(obj, nodeType, 'operation') && Array.isArray(casted.expression) &&
82
+ casted.expression.length === 1 && !this.isOfType(casted.expression[0], 'wildcard');
83
+ }
84
+ };
101
85
  }
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- ExpressionFactoryMixin
105
- });
86
+ //# sourceMappingURL=ExpressionFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["../../../../lib/factoryMixins/ExpressionFactory.ts"],"names":[],"mappings":";;AAoBA,wDA6IC;AAhJD,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,4DAA4D;AAC5D,SAAgB,sBAAsB,CAA4C,IAAW;IAC3F,OAAO,MAAM,iBAAkB,SAAQ,IAAI;QAClC,gBAAgB,CAAC,GAAW;YACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QAEM,cAAc,CAAC,QAAgB;YACpC,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACpD,CAAC;QAEM,mBAAmB,CACxB,QAAgB,EAChB,IAAU,EACV,GAAmB;YAEnB,OAAO;gBACL,IAAI,EAAE,QAAQ;g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C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACvF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';\nimport type {\n Expression,\n ExpressionAggregate,\n ExpressionAggregateDefault,\n ExpressionAggregateOnWildcard,\n ExpressionAggregateSeparator,\n ExpressionFunctionCall,\n ExpressionOperation,\n ExpressionPatternOperation,\n PatternGroup,\n TermIri,\n Wildcard,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'expression';\nconst nodeType: NodeType = 'expression';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function ExpressionFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class ExpressionFactory extends Base {\n public isExpressionPure(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public formatOperator(operator: string): string {\n return operator.toLowerCase().replaceAll(' ', '');\n }\n\n public expressionOperation<Args extends Expression[]>(\n operator: string,\n args: Args,\n loc: SourceLocation,\n ): ExpressionOperation & { args: Args } {\n return {\n type: nodeType,\n subType: 'operation',\n operator: this.formatOperator(operator),\n args,\n loc,\n };\n }\n\n public isExpressionOperator(obj: object): obj is SubTyped<NodeType, 'operation'> {\n return this.isOfSubType(obj, nodeType, 'operation');\n }\n\n public expressionFunctionCall<Args extends Expression[]>(\n functionOp: TermIri,\n args: Args,\n distinct: boolean,\n loc: SourceLocation,\n ): ExpressionFunctionCall & { args: Args } {\n return {\n type: 'expression',\n subType: 'functionCall',\n function: functionOp,\n args,\n distinct,\n loc,\n };\n }\n\n public isExpressionFunctionCall(obj: object): obj is SubTyped<NodeType, 'functionCall'> {\n return this.isOfSubType(obj, nodeType, 'functionCall');\n }\n\n public expressionPatternOperation(\n operator: string,\n args: PatternGroup,\n loc: SourceLocation,\n ): ExpressionPatternOperation {\n return {\n type: nodeType,\n subType: 'patternOperation',\n operator: this.formatOperator(operator),\n args,\n loc,\n };\n }\n\n public isExpressionPatternOperation(obj: object): obj is SubTyped<NodeType, 'patternOperation'> {\n return this.isOfSubType(obj, nodeType, 'patternOperation');\n }\n\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression,\n separator: undefined,\n loc: SourceLocation\n ): ExpressionAggregateDefault;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Wildcard,\n separator: undefined,\n loc: SourceLocation\n ): ExpressionAggregateOnWildcard;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression,\n separator: string,\n loc: SourceLocation\n ): ExpressionAggregateSeparator;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression | Wildcard,\n separator: string | undefined,\n loc: SourceLocation,\n ): ExpressionAggregate;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression | Wildcard,\n separator: string | undefined,\n loc: SourceLocation,\n ): ExpressionAggregate {\n const base = <const> {\n type: 'expression',\n subType: 'aggregate',\n aggregation: this.formatOperator(aggregation),\n distinct,\n loc,\n };\n if (this.isOfType(arg, 'wildcard')) {\n return { ...base, expression: [ arg ]} satisfies ExpressionAggregateOnWildcard;\n }\n if (separator === undefined) {\n return { ...base, expression: [ arg ]} satisfies ExpressionAggregateDefault;\n }\n return { ...base, expression: [ arg ], separator } satisfies ExpressionAggregateSeparator;\n }\n\n public isExpressionAggregate(obj: object): obj is SubTyped<NodeType, 'aggregate'> {\n return this.isOfSubType(obj, nodeType, 'aggregate');\n }\n\n public isExpressionAggregateSeparator(obj: object): obj is SubTyped<NodeType, 'aggregate'> & { separator: string } {\n return this.isOfSubType(obj, nodeType, 'aggregate') &&\n typeof (<{ separator?: unknown }> obj).separator === 'string';\n }\n\n public isExpressionAggregateOnWildcard(obj: object):\n obj is SubTyped<NodeType, 'aggregate'> & { expression: [Typed<'wildcard'>]} {\n const casted = <{ expression?: unknown }> obj;\n return this.isOfSubType(obj, nodeType, 'aggregate') && Array.isArray(casted.expression) &&\n casted.expression.length === 1 && this.isOfType(casted.expression[0], 'wildcard');\n }\n\n public isExpressionAggregateDefault(obj: object):\n obj is SubTyped<NodeType, 'aggregate'> & { expression: [Expression]} {\n const casted = <{ expression?: unknown }> obj;\n\n return this.isOfSubType(obj, nodeType, 'operation') && Array.isArray(casted.expression) &&\n casted.expression.length === 1 && !this.isOfType(casted.expression[0], 'wildcard');\n }\n };\n}\n"]}
@@ -1,76 +1,54 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
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 GraphRefFactory_exports = {};
20
- __export(GraphRefFactory_exports, {
21
- GraphRefFactoryMixin: () => GraphRefFactoryMixin
22
- });
23
- module.exports = __toCommonJS(GraphRefFactory_exports);
24
- const nodeType = "graphRef";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphRefFactoryMixin = GraphRefFactoryMixin;
4
+ const nodeType = 'graphRef';
5
+ // eslint-disable-next-line ts/explicit-function-return-type
25
6
  function GraphRefFactoryMixin(Base) {
26
- return class GraphRefFactory extends Base {
27
- isGraphRef(obj) {
28
- return this.isOfType(obj, nodeType);
29
- }
30
- graphRefDefault(loc) {
31
- return {
32
- type: nodeType,
33
- subType: "default",
34
- loc
35
- };
36
- }
37
- isGraphRefDefault(graphRef) {
38
- return this.isOfSubType(graphRef, nodeType, "default");
39
- }
40
- graphRefNamed(loc) {
41
- return {
42
- type: nodeType,
43
- subType: "named",
44
- loc
45
- };
46
- }
47
- isGraphRefNamed(graphRef) {
48
- return this.isOfSubType(graphRef, nodeType, "named");
49
- }
50
- graphRefAll(loc) {
51
- return {
52
- type: nodeType,
53
- subType: "all",
54
- loc
55
- };
56
- }
57
- isGraphRefAll(graphRef) {
58
- return this.isOfSubType(graphRef, nodeType, "all");
59
- }
60
- graphRefSpecific(graph, loc) {
61
- return {
62
- type: nodeType,
63
- subType: "specific",
64
- graph,
65
- loc
66
- };
67
- }
68
- isGraphRefSpecific(graphRef) {
69
- return this.isOfSubType(graphRef, nodeType, "specific");
70
- }
71
- };
7
+ return class GraphRefFactory extends Base {
8
+ isGraphRef(obj) {
9
+ return this.isOfType(obj, nodeType);
10
+ }
11
+ graphRefDefault(loc) {
12
+ return {
13
+ type: nodeType,
14
+ subType: 'default',
15
+ loc,
16
+ };
17
+ }
18
+ isGraphRefDefault(graphRef) {
19
+ return this.isOfSubType(graphRef, nodeType, 'default');
20
+ }
21
+ graphRefNamed(loc) {
22
+ return {
23
+ type: nodeType,
24
+ subType: 'named',
25
+ loc,
26
+ };
27
+ }
28
+ isGraphRefNamed(graphRef) {
29
+ return this.isOfSubType(graphRef, nodeType, 'named');
30
+ }
31
+ graphRefAll(loc) {
32
+ return {
33
+ type: nodeType,
34
+ subType: 'all',
35
+ loc,
36
+ };
37
+ }
38
+ isGraphRefAll(graphRef) {
39
+ return this.isOfSubType(graphRef, nodeType, 'all');
40
+ }
41
+ graphRefSpecific(graph, loc) {
42
+ return {
43
+ type: nodeType,
44
+ subType: 'specific',
45
+ graph,
46
+ loc,
47
+ };
48
+ }
49
+ isGraphRefSpecific(graphRef) {
50
+ return this.isOfSubType(graphRef, nodeType, 'specific');
51
+ }
52
+ };
72
53
  }
73
- // Annotate the CommonJS export names for ESM import in node:
74
- 0 && (module.exports = {
75
- GraphRefFactoryMixin
76
- });
54
+ //# sourceMappingURL=GraphRefFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphRefFactory.js","sourceRoot":"","sources":["../../../../lib/factoryMixins/GraphRefFactory.ts"],"names":[],"mappings":";;AAcA,oDAuDC;AA1DD,MAAM,QAAQ,GAAa,UAAU,CAAC;AAEtC,4DAA4D;AAC5D,SAAgB,oBAAoB,CAA4C,IAAW;IACzF,OAAO,MAAM,eAAgB,SAAQ,IAAI;QAChC,UAAU,CAAC,GAAW;YAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QAEM,eAAe,CAAC,GAAmB;YACxC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,SAAS;gBAClB,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,iBAAiB,CAAC,QAAgB;YACvC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACzD,CAAC;QAEM,aAAa,CAAC,GAAmB;YACtC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,OAAO;gBAChB,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,eAAe,CAAC,QAAgB;YACrC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QAEM,WAAW,CAAC,GAAmB;YACpC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,KAAK;gBACd,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,aAAa,CAAC,QAAgB;YACnC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;QAEM,gBAAgB,CAAC,KAAc,EAAE,GAAmB;YACzD,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,UAAU;gBACnB,KAAK;gBACL,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,kBAAkB,CAAC,QAAgB;YACxC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AstCoreFactory, SubTyped, SourceLocation, Typed } from '@traqula/core';\nimport type {\n GraphRefAll,\n GraphRefDefault,\n GraphRefNamed,\n GraphRefSpecific,\n TermIri,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'graphRef';\nconst nodeType: NodeType = 'graphRef';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function GraphRefFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class GraphRefFactory extends Base {\n public isGraphRef(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public graphRefDefault(loc: SourceLocation): GraphRefDefault {\n return {\n type: nodeType,\n subType: 'default',\n loc,\n };\n }\n\n public isGraphRefDefault(graphRef: object): graphRef is SubTyped<NodeType, 'default'> {\n return this.isOfSubType(graphRef, nodeType, 'default');\n }\n\n public graphRefNamed(loc: SourceLocation): GraphRefNamed {\n return {\n type: nodeType,\n subType: 'named',\n loc,\n };\n }\n\n public isGraphRefNamed(graphRef: object): graphRef is SubTyped<NodeType, 'named'> {\n return this.isOfSubType(graphRef, nodeType, 'named');\n }\n\n public graphRefAll(loc: SourceLocation): GraphRefAll {\n return {\n type: nodeType,\n subType: 'all',\n loc,\n };\n }\n\n public isGraphRefAll(graphRef: object): graphRef is SubTyped<NodeType, 'all'> {\n return this.isOfSubType(graphRef, nodeType, 'all');\n }\n\n public graphRefSpecific(graph: TermIri, loc: SourceLocation): GraphRefSpecific {\n return {\n type: nodeType,\n subType: 'specific',\n graph,\n loc,\n };\n }\n\n public isGraphRefSpecific(graphRef: object): graphRef is SubTyped<NodeType, 'specific'> {\n return this.isOfSubType(graphRef, nodeType, 'specific');\n }\n };\n}\n"]}
@@ -1,90 +1,71 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
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 PathFactory_exports = {};
20
- __export(PathFactory_exports, {
21
- PathFactoryMixin: () => PathFactoryMixin
22
- });
23
- module.exports = __toCommonJS(PathFactory_exports);
24
- const nodeType = "path";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathFactoryMixin = PathFactoryMixin;
4
+ const nodeType = 'path';
5
+ // eslint-disable-next-line ts/explicit-function-return-type
25
6
  function PathFactoryMixin(Base) {
26
- return class PathFactory extends Base {
27
- isPathPure(obj) {
28
- return this.isOfType(obj, nodeType);
29
- }
30
- path(subType, items, loc) {
31
- const base = {
32
- type: nodeType,
33
- loc,
34
- items
35
- };
36
- if (subType === "|" || subType === "/") {
37
- return {
38
- ...base,
39
- subType
40
- };
41
- }
42
- if ((subType === "?" || subType === "*" || subType === "+" || subType === "^") && items.length === 1) {
43
- return {
44
- ...base,
45
- subType,
46
- items
47
- };
48
- }
49
- if (subType === "^" && items.length === 1 && !this.isPathPure(items[0])) {
50
- return {
51
- ...base,
52
- subType,
53
- items
54
- };
55
- }
56
- if (subType === "!" && items.length === 1 && (this.isPathAlternativeLimited(items[0]) || !this.isPathPure(items[0]) || this.isPathNegatedElt(items[0]))) {
57
- return {
58
- ...base,
59
- subType,
60
- items
61
- };
62
- }
63
- throw new Error("Invalid path type");
64
- }
65
- isPathOfType(obj, subTypes) {
66
- return this.isOfType(obj, nodeType) && subTypes.includes(obj.subType);
67
- }
68
- isPathChain(obj) {
69
- return this.isOfSubType(obj, nodeType, "/") || this.isOfSubType(obj, nodeType, "|");
70
- }
71
- isPathModified(obj) {
72
- return this.isOfSubType(obj, nodeType, "?") || this.isOfSubType(obj, nodeType, "*") || this.isOfSubType(obj, nodeType, "+") || this.isOfSubType(obj, nodeType, "^");
73
- }
74
- isPathNegatedElt(obj) {
75
- const casted = obj;
76
- return this.isOfSubType(obj, nodeType, "^") && Array.isArray(casted.items) && casted.items.length === 1 && typeof casted.items[0] === "object" && (casted.items[0] ?? false) && !this.isPathPure(casted.items[0]);
77
- }
78
- isPathNegated(obj) {
79
- return this.isOfSubType(obj, nodeType, "!");
80
- }
81
- isPathAlternativeLimited(obj) {
82
- const casted = obj;
83
- return this.isOfSubType(obj, nodeType, "|") && Array.isArray(casted.items) && casted.items.every((item) => !this.isPathPure(item) || this.isPathNegatedElt(item));
84
- }
85
- };
7
+ return class PathFactory extends Base {
8
+ isPathPure(obj) {
9
+ return this.isOfType(obj, nodeType);
10
+ }
11
+ path(subType, items, loc) {
12
+ const base = {
13
+ type: nodeType,
14
+ loc,
15
+ items,
16
+ };
17
+ if (subType === '|' || subType === '/') {
18
+ return {
19
+ ...base,
20
+ subType,
21
+ };
22
+ }
23
+ if ((subType === '?' || subType === '*' || subType === '+' || subType === '^') && items.length === 1) {
24
+ return {
25
+ ...base,
26
+ subType,
27
+ items: items,
28
+ };
29
+ }
30
+ if (subType === '^' && items.length === 1 && !this.isPathPure(items[0])) {
31
+ return {
32
+ ...base,
33
+ subType,
34
+ items: items,
35
+ };
36
+ }
37
+ if (subType === '!' && items.length === 1 && (this.isPathAlternativeLimited(items[0]) || !this.isPathPure(items[0]) || this.isPathNegatedElt(items[0]))) {
38
+ return {
39
+ ...base,
40
+ subType,
41
+ items: items,
42
+ };
43
+ }
44
+ throw new Error('Invalid path type');
45
+ }
46
+ isPathOfType(obj, subTypes) {
47
+ return this.isOfType(obj, nodeType) && subTypes.includes(obj.subType);
48
+ }
49
+ isPathChain(obj) {
50
+ return this.isOfSubType(obj, nodeType, '/') || this.isOfSubType(obj, nodeType, '|');
51
+ }
52
+ isPathModified(obj) {
53
+ return this.isOfSubType(obj, nodeType, '?') || this.isOfSubType(obj, nodeType, '*') ||
54
+ this.isOfSubType(obj, nodeType, '+') || this.isOfSubType(obj, nodeType, '^');
55
+ }
56
+ isPathNegatedElt(obj) {
57
+ const casted = obj;
58
+ return this.isOfSubType(obj, nodeType, '^') && Array.isArray(casted.items) && casted.items.length === 1 &&
59
+ typeof casted.items[0] === 'object' && (casted.items[0] ?? false) && !this.isPathPure(casted.items[0]);
60
+ }
61
+ isPathNegated(obj) {
62
+ return this.isOfSubType(obj, nodeType, '!');
63
+ }
64
+ isPathAlternativeLimited(obj) {
65
+ const casted = obj;
66
+ return this.isOfSubType(obj, nodeType, '|') && Array.isArray(casted.items) &&
67
+ casted.items.every(item => !this.isPathPure(item) || this.isPathNegatedElt(item));
68
+ }
69
+ };
86
70
  }
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- PathFactoryMixin
90
- });
71
+ //# sourceMappingURL=PathFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathFactory.js","sourceRoot":"","sources":["../../../../lib/factoryMixins/PathFactory.ts"],"names":[],"mappings":";;AAkBA,4CA2FC;AAhGD,MAAM,QAAQ,GAAa,MAAM,CAAC;AAIlC,4DAA4D;AAC5D,SAAgB,gBAAgB,CAA4C,IAAW;IACrF,OAAO,MAAM,WAAY,SAAQ,IAAI;QAC5B,UAAU,CAAC,GAAW;YAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,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AAC;QAC9C,CAAC;QAEM,wBAAwB,CAAC,GAAW;YAEzC,MAAM,MAAM,GAAwB,GAAG,CAAC;YACxC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBACxE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';\nimport type {\n Path,\n PathAlternativeLimited,\n PathModified,\n PathNegated,\n PathNegatedElt,\n PropertyPathChain,\n TermIri,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'path';\nconst nodeType: NodeType = 'path';\n\ntype RawNegatedElt = SubTyped<NodeType, '^'> & { items: [SubTyped<'term', 'namedNode'>]};\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function PathFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class PathFactory extends Base {\n public isPathPure(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public path(\n subType: '|',\n items: (TermIri | PathNegatedElt)[],\n loc: SourceLocation\n ): PathAlternativeLimited;\n public path(\n subType: '!',\n items: [TermIri | PathNegatedElt | PathAlternativeLimited],\n loc: SourceLocation\n ): PathNegated;\n public path(subType: '^', items: [TermIri], loc: SourceLocation): PathNegatedElt;\n public path(subType: PathModified['subType'], item: [Path], loc: SourceLocation): PathModified;\n public path(subType: '|' | '/', items: Path[], loc: SourceLocation):\n PropertyPathChain;\n public path(\n subType: (PropertyPathChain | PathModified | PathNegated)['subType'],\n items: Path[],\n loc: SourceLocation,\n ): Path {\n const base = <const>{\n type: nodeType,\n loc,\n items,\n };\n if (subType === '|' || subType === '/') {\n return {\n ...base,\n subType,\n } satisfies PropertyPathChain;\n }\n if ((subType === '?' || subType === '*' || subType === '+' || subType === '^') && items.length === 1) {\n return {\n ...base,\n subType,\n items: <[Path]>items,\n } satisfies PathModified;\n }\n if (subType === '^' && items.length === 1 && !this.isPathPure(items[0])) {\n return {\n ...base,\n subType,\n items: <[TermIri]>items,\n } satisfies PathNegatedElt;\n }\n if (subType === '!' && items.length === 1 && (\n this.isPathAlternativeLimited(items[0]) || !this.isPathPure(items[0]) || this.isPathNegatedElt(items[0]))) {\n return {\n ...base,\n subType,\n items: <[TermIri | PathNegatedElt | PathAlternativeLimited]>items,\n } satisfies PathNegated;\n }\n throw new Error('Invalid path type');\n }\n\n public isPathOfType<T extends U[], U extends string>(obj: object, subTypes: T): obj is SubTyped<NodeType, U> {\n return this.isOfType(obj, nodeType) && subTypes.includes(<any>(<{ subType?: unknown }>obj).subType);\n }\n\n public isPathChain(obj: object): obj is SubTyped<NodeType, '|' | '/'> {\n return this.isOfSubType(obj, nodeType, '/') || this.isOfSubType(obj, nodeType, '|');\n }\n\n public isPathModified(obj: object): obj is SubTyped<NodeType, '?' | '*' | '+' | '^'> {\n return this.isOfSubType(obj, nodeType, '?') || this.isOfSubType(obj, nodeType, '*') ||\n this.isOfSubType(obj, nodeType, '+') || this.isOfSubType(obj, nodeType, '^');\n }\n\n public isPathNegatedElt(obj: object): obj is RawNegatedElt {\n const casted: { items?: unknown } = obj;\n return this.isOfSubType(obj, nodeType, '^') && Array.isArray(casted.items) && casted.items.length === 1 &&\n typeof casted.items[0] === 'object' && (casted.items[0] ?? false) && !this.isPathPure(casted.items[0]);\n }\n\n public isPathNegated(obj: object): obj is SubTyped<NodeType, '!'> {\n return this.isOfSubType(obj, nodeType, '!');\n }\n\n public isPathAlternativeLimited(obj: object):\n obj is SubTyped<NodeType, '|'> & { items: (SubTyped<'term', 'namedNode'> | RawNegatedElt)[] } {\n const casted: { items?: unknown } = obj;\n return this.isOfSubType(obj, nodeType, '|') && Array.isArray(casted.items) &&\n casted.items.every(item => !this.isPathPure(item) || this.isPathNegatedElt(item));\n }\n };\n}\n"]}