@comunica/utils-expression-evaluator 3.2.4-alpha.47.0

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 (60) hide show
  1. package/LICENSE.txt +22 -0
  2. package/README.md +102 -0
  3. package/lib/expressions/Aggregate.d.ts +9 -0
  4. package/lib/expressions/Aggregate.js +13 -0
  5. package/lib/expressions/Aggregate.js.map +1 -0
  6. package/lib/expressions/Existence.d.ts +8 -0
  7. package/lib/expressions/Existence.js +12 -0
  8. package/lib/expressions/Existence.js.map +1 -0
  9. package/lib/expressions/Expressions.d.ts +2 -0
  10. package/lib/expressions/Expressions.js +11 -0
  11. package/lib/expressions/Expressions.js.map +1 -0
  12. package/lib/expressions/Operator.d.ts +9 -0
  13. package/lib/expressions/Operator.js +14 -0
  14. package/lib/expressions/Operator.js.map +1 -0
  15. package/lib/expressions/Term.d.ts +180 -0
  16. package/lib/expressions/Term.js +348 -0
  17. package/lib/expressions/Term.js.map +1 -0
  18. package/lib/expressions/Variable.d.ts +7 -0
  19. package/lib/expressions/Variable.js +12 -0
  20. package/lib/expressions/Variable.js.map +1 -0
  21. package/lib/expressions/index.d.ts +6 -0
  22. package/lib/expressions/index.js +23 -0
  23. package/lib/expressions/index.js.map +1 -0
  24. package/lib/functions/Helpers.d.ts +81 -0
  25. package/lib/functions/Helpers.js +218 -0
  26. package/lib/functions/Helpers.js.map +1 -0
  27. package/lib/functions/OverloadTree.d.ts +45 -0
  28. package/lib/functions/OverloadTree.js +196 -0
  29. package/lib/functions/OverloadTree.js.map +1 -0
  30. package/lib/index.d.ts +12 -0
  31. package/lib/index.js +99 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/transformers/TermTransformer.d.ts +24 -0
  34. package/lib/transformers/TermTransformer.js +133 -0
  35. package/lib/transformers/TermTransformer.js.map +1 -0
  36. package/lib/util/Consts.d.ts +136 -0
  37. package/lib/util/Consts.js +171 -0
  38. package/lib/util/Consts.js.map +1 -0
  39. package/lib/util/Context.d.ts +2 -0
  40. package/lib/util/Context.js +32 -0
  41. package/lib/util/Context.js.map +1 -0
  42. package/lib/util/DateTimeHelpers.d.ts +19 -0
  43. package/lib/util/DateTimeHelpers.js +166 -0
  44. package/lib/util/DateTimeHelpers.js.map +1 -0
  45. package/lib/util/Errors.d.ts +130 -0
  46. package/lib/util/Errors.js +194 -0
  47. package/lib/util/Errors.js.map +1 -0
  48. package/lib/util/Parsing.d.ts +25 -0
  49. package/lib/util/Parsing.js +166 -0
  50. package/lib/util/Parsing.js.map +1 -0
  51. package/lib/util/Serialization.d.ts +5 -0
  52. package/lib/util/Serialization.js +54 -0
  53. package/lib/util/Serialization.js.map +1 -0
  54. package/lib/util/SpecAlgos.d.ts +4 -0
  55. package/lib/util/SpecAlgos.js +81 -0
  56. package/lib/util/SpecAlgos.js.map +1 -0
  57. package/lib/util/TypeHandling.d.ts +56 -0
  58. package/lib/util/TypeHandling.js +216 -0
  59. package/lib/util/TypeHandling.js.map +1 -0
  60. package/package.json +50 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
4
+ Comunica Association and Ghent University – imec, Belgium
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Comunica Expression Evaluator
2
+
3
+ [![npm version](https://badge.fury.io/js/%40comunica%2Fexpression-evaluator.svg)](https://www.npmjs.com/package/@comunica/expression-evaluator)
4
+
5
+ Previously called sparqlee - sparql expression evaluator. A simple spec-compliant SPARQL 1.1 expression evaluator package.
6
+
7
+ **[Learn more about the expression evaluator](https://comunica.dev/docs/modify/advanced/expression-evaluator/).**
8
+
9
+ This module is part of the [Comunica framework](https://github.com/comunica/comunica),
10
+ and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
11
+
12
+ [Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ $ yarn add @comunica/utils-expression-evaluator
18
+ ```
19
+
20
+ ## Exposed classes
21
+
22
+ * [`ExpressionEvaluator`](https://comunica.github.io/comunica/classes/_comunica_expression_evaluator.AsyncEvaluator.html): An evaluator for SPARQL expressions working with Promises.
23
+ * [`IAsyncEvaluatorContext`](https://comunica.github.io/comunica/classes/_comunica_expression_evaluator.IAsyncEvaluatorContext.html): Context used to configure the `ExpressionEvaluator`. See [Config](https://comunica.dev/docs/modify/advanced/expression-evaluator/#config).
24
+ * [`SyncEvaluator`](https://comunica.github.io/comunica/classes/_comunica_expression_evaluator.SyncEvaluator.html): An evaluator for SPARQL expressions working without Promises.
25
+ * [`ISyncEvaluatorContext`](https://comunica.github.io/comunica/interfaces/_comunica_expression_evaluator.ISyncEvaluatorContext.html): Context used to configure the `SyncEvaluator`. See [Config](https://comunica.dev/docs/modify/advanced/expression-evaluator/#config).
26
+ * [`AggregateEvaluator`](https://comunica.github.io/comunica/classes/_comunica_expression_evaluator.AggregateEvaluator.html): An evaluator for SPARQL aggregate expressions working without promises. See [Aggregates](https://comunica.dev/docs/modify/advanced/expression-evaluator/#aggregates).
27
+ * [`ExpressionError`](https://comunica.github.io/comunica/classes/_comunica_expression_evaluator.ExpressionError.html): An error class for SPARQL expression errors as defined in the [error section](https://comunica.dev/docs/modify/advanced/expression-evaluator/#errors).
28
+ * [`isExpressionError`](https://comunica.github.io/comunica/functions/_comunica_expression_evaluator.isExpressionError.html): A way to check if an error is of type `ExpressionError`.
29
+ * [`orderTypes`](https://comunica.github.io/comunica/functions/_comunica_expression_evaluator.orderTypes.html): A function to order types according to the [SPARQL ORDER BY specification](https://www.w3.org/TR/sparql11-query/#modOrderBy).
30
+ * [`AsyncAggregateEvaluator`](https://comunica.github.io/comunica/classes/_comunica_expression_evaluator.AsyncAggregateEvaluator.html): An evaluator for SPARQL aggregate expressions working with promises. See [Aggregates](https://comunica.dev/docs/modify/advanced/expression-evaluator/#aggregates).
31
+
32
+ ## Development
33
+
34
+ ## Setup locally
35
+
36
+ 1. Install `yarn` and `node`.
37
+ 2. Run `yarn install`.
38
+ 3. Use these evident commands (or check `package.json`):
39
+ - building once: `yarn run build`
40
+
41
+ ### Layout and control flow
42
+
43
+ SPARQL Algebra expression can be transformed to an internal representation (see [AlgebraTransformer.ts](../actor-expression-evaluator-factory-default/lib/AlgebraTransformer.ts)).
44
+ This will build objects (see [expressions module](./lib/expressions)) that contain all the logic and data for evaluation.
45
+ After transformation, the evaluator will recursively evaluate all the expressions.
46
+
47
+ ### Testing
48
+
49
+ The testing environment is set up to do a lot of tests with little code.
50
+ The files responsible for fluent behaviour reside in the [`test/util`](./test/util) module.
51
+ Most tests can be run by running the `runTestTable` method in [utils](test/util/utils.ts).
52
+ This method expects a TestTable. Multiple test are run over a TestTable (one for every line).
53
+ A TestTable may contain aliases if the aliases are also provided
54
+ (Some handy aliases reside in [Aliases.ts](test/util/Aliases.ts)).
55
+ This means that when testing something like `"3"^^xsd:integer equals "3"^^xsd:integer` is `"true"^^xsd:boolean`.
56
+ We would write a small table (for this example some more tests are added) and test it like this:
57
+ ```js
58
+ import { bool, merge, numeric } from './util/Aliases';
59
+ import { Notation } from './util/TruthTable';
60
+ import { runTestTable } from './util/utils';
61
+ runTestTable({
62
+ testTable: `
63
+ 3i 3i = true
64
+ 3i -5i = false
65
+ -0f 0f = true
66
+ NaN NaN = false
67
+ `,
68
+ arity: 2,
69
+ operation: '=',
70
+ aliases: merge(numeric, bool),
71
+ notation: Notation.Infix,
72
+ });
73
+ ```
74
+ More options can be provided and are explained with the type definition of the argument of `runTestTable`.
75
+
76
+ We can also provide an `errorTable` to the `runTestTable` method.
77
+ This is used when we want to test if calling certain functions on certain arguments throws the error we want.
78
+ An example is testing whether `Unknown named operator` error is thrown when
79
+ we don't provide the implementation for an extension function.
80
+ ```js
81
+ import { bool, merge, numeric } from './util/Aliases';
82
+ import { Notation } from './util/TruthTable';
83
+ import { runTestTable } from './util/utils';
84
+ runTestTable({
85
+ errorTable: `
86
+ 3i 3i = 'Unknown named operator'
87
+ 3i -5i = 'Unknown named operator'
88
+ -0f 0f = 'Unknown named operator'
89
+ NaN NaN = 'Unknown named operator'
90
+ `,
91
+ arity: 2,
92
+ operation: '<https://example.org/functions#equal>',
93
+ aliases: merge(numeric, bool),
94
+ notation: Notation.Infix,
95
+ });
96
+ ```
97
+ When you don't care what the error is, you can just test for `''`.
98
+
99
+ In case the tables are too restrictive for your test, and you need an evaluation.
100
+ You should still use the `generalEvaluate` function from [generalEvaluation.ts](test/util/generalEvaluation.ts).
101
+ This function will automatically run both async and sync when possible.
102
+ This increases your tests' coverage.
@@ -0,0 +1,9 @@
1
+ import type { AggregateExpression } from '@comunica/types';
2
+ import { ExpressionType } from '@comunica/types';
3
+ import type { Algebra as Alg } from 'sparqlalgebrajs';
4
+ export declare class Aggregate implements AggregateExpression {
5
+ name: string;
6
+ expression: Alg.AggregateExpression;
7
+ expressionType: ExpressionType.Aggregate;
8
+ constructor(name: string, expression: Alg.AggregateExpression);
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Aggregate = void 0;
4
+ const types_1 = require("@comunica/types");
5
+ class Aggregate {
6
+ constructor(name, expression) {
7
+ this.name = name;
8
+ this.expression = expression;
9
+ this.expressionType = types_1.ExpressionType.Aggregate;
10
+ }
11
+ }
12
+ exports.Aggregate = Aggregate;
13
+ //# sourceMappingURL=Aggregate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Aggregate.js","sourceRoot":"","sources":["Aggregate.ts"],"names":[],"mappings":";;;AACA,2CAAiD;AAGjD,MAAa,SAAS;IAGpB,YACS,IAAY,EACZ,UAAmC;QADnC,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAyB;QAJrC,mBAAc,GAA6B,sBAAc,CAAC,SAAS,CAAC;IAKxE,CAAC;CACL;AAPD,8BAOC","sourcesContent":["import type { AggregateExpression } from '@comunica/types';\nimport { ExpressionType } from '@comunica/types';\nimport type { Algebra as Alg } from 'sparqlalgebrajs';\n\nexport class Aggregate implements AggregateExpression {\n public expressionType: ExpressionType.Aggregate = ExpressionType.Aggregate;\n\n public constructor(\n public name: string,\n public expression: Alg.AggregateExpression,\n ) {}\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ExistenceExpression } from '@comunica/types';
2
+ import { ExpressionType } from '@comunica/types';
3
+ import type { Algebra as Alg } from 'sparqlalgebrajs';
4
+ export declare class Existence implements ExistenceExpression {
5
+ expression: Alg.ExistenceExpression;
6
+ expressionType: ExpressionType.Existence;
7
+ constructor(expression: Alg.ExistenceExpression);
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Existence = void 0;
4
+ const types_1 = require("@comunica/types");
5
+ class Existence {
6
+ constructor(expression) {
7
+ this.expression = expression;
8
+ this.expressionType = types_1.ExpressionType.Existence;
9
+ }
10
+ }
11
+ exports.Existence = Existence;
12
+ //# sourceMappingURL=Existence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Existence.js","sourceRoot":"","sources":["Existence.ts"],"names":[],"mappings":";;;AACA,2CAAiD;AAGjD,MAAa,SAAS;IAEpB,YAA0B,UAAmC;QAAnC,eAAU,GAAV,UAAU,CAAyB;QADtD,mBAAc,GAA6B,sBAAc,CAAC,SAAS,CAAC;IACX,CAAC;CAClE;AAHD,8BAGC","sourcesContent":["import type { ExistenceExpression } from '@comunica/types';\nimport { ExpressionType } from '@comunica/types';\nimport type { Algebra as Alg } from 'sparqlalgebrajs';\n\nexport class Existence implements ExistenceExpression {\n public expressionType: ExpressionType.Existence = ExpressionType.Existence;\n public constructor(public expression: Alg.ExistenceExpression) {}\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { TermType } from '@comunica/types';
2
+ export declare function asTermType(type: string): TermType | undefined;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asTermType = void 0;
4
+ function asTermType(type) {
5
+ if (type === 'namedNode' || type === 'literal' || type === 'blankNode' || type === 'quad') {
6
+ return type;
7
+ }
8
+ return undefined;
9
+ }
10
+ exports.asTermType = asTermType;
11
+ //# sourceMappingURL=Expressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Expressions.js","sourceRoot":"","sources":["Expressions.ts"],"names":[],"mappings":";;;AAGA,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AALD,gCAKC","sourcesContent":["// TODO: Create alias Term = TermExpression\nimport type { TermType } from '@comunica/types';\n\nexport function asTermType(type: string): TermType | undefined {\n if (type === 'namedNode' || type === 'literal' || type === 'blankNode' || type === 'quad') {\n return type;\n }\n return undefined;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { Expression, FunctionApplication, OperatorExpression } from '@comunica/types';
2
+ import { ExpressionType } from '@comunica/types';
3
+ export declare class Operator implements OperatorExpression {
4
+ name: string;
5
+ args: Expression[];
6
+ apply: FunctionApplication;
7
+ expressionType: ExpressionType.Operator;
8
+ constructor(name: string, args: Expression[], apply: FunctionApplication);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Operator = void 0;
4
+ const types_1 = require("@comunica/types");
5
+ class Operator {
6
+ constructor(name, args, apply) {
7
+ this.name = name;
8
+ this.args = args;
9
+ this.apply = apply;
10
+ this.expressionType = types_1.ExpressionType.Operator;
11
+ }
12
+ }
13
+ exports.Operator = Operator;
14
+ //# sourceMappingURL=Operator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Operator.js","sourceRoot":"","sources":["Operator.ts"],"names":[],"mappings":";;;AACA,2CAAiD;AAEjD,MAAa,QAAQ;IAGnB,YAA0B,IAAY,EAAS,IAAkB,EAAS,KAA0B;QAA1E,SAAI,GAAJ,IAAI,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAc;QAAS,UAAK,GAAL,KAAK,CAAqB;QAF7F,mBAAc,GAA4B,sBAAc,CAAC,QAAQ,CAAC;IAE8B,CAAC;CACzG;AAJD,4BAIC","sourcesContent":["import type { Expression, FunctionApplication, OperatorExpression } from '@comunica/types';\nimport { ExpressionType } from '@comunica/types';\n\nexport class Operator implements OperatorExpression {\n public expressionType: ExpressionType.Operator = ExpressionType.Operator;\n\n public constructor(public name: string, public args: Expression[], public apply: FunctionApplication) {}\n}\n"]}
@@ -0,0 +1,180 @@
1
+ import type { ComunicaDataFactory, IDateRepresentation, IDateTimeRepresentation, IDurationRepresentation, ISuperTypeProvider, ITimeRepresentation, IYearMonthDurationRepresentation, TermExpression, TermType } from '@comunica/types';
2
+ import { ExpressionType } from '@comunica/types';
3
+ import type * as RDF from '@rdfjs/types';
4
+ export declare abstract class Term implements TermExpression {
5
+ expressionType: ExpressionType.Term;
6
+ abstract termType: TermType;
7
+ abstract toRDF(dataFactory: ComunicaDataFactory): RDF.Term;
8
+ str(): string;
9
+ coerceEBV(): boolean;
10
+ }
11
+ export declare class NamedNode extends Term {
12
+ value: string;
13
+ termType: TermType;
14
+ constructor(value: string);
15
+ toRDF(dataFactory: ComunicaDataFactory): RDF.Term;
16
+ str(): string;
17
+ }
18
+ export declare class BlankNode extends Term {
19
+ value: RDF.BlankNode | string;
20
+ termType: TermType;
21
+ constructor(value: RDF.BlankNode | string);
22
+ toRDF(dataFactory: ComunicaDataFactory): RDF.Term;
23
+ }
24
+ export declare class Quad extends Term {
25
+ readonly subject: Term;
26
+ readonly predicate: Term;
27
+ readonly object: Term;
28
+ readonly graph: Term;
29
+ termType: TermType;
30
+ constructor(subject: Term, predicate: Term, object: Term, graph: Term);
31
+ toRDF(dataFactory: ComunicaDataFactory): RDF.BaseQuad;
32
+ str(): string;
33
+ }
34
+ export declare class DefaultGraph extends Term {
35
+ termType: TermType;
36
+ constructor();
37
+ toRDF(dataFactory: ComunicaDataFactory): RDF.DefaultGraph;
38
+ str(): string;
39
+ }
40
+ export declare function isLiteralTermExpression(expr: TermExpression): Literal<any> | undefined;
41
+ export interface ISerializable {
42
+ toString: () => string;
43
+ }
44
+ export declare class Literal<T extends ISerializable> extends Term {
45
+ typedValue: T;
46
+ dataType: string;
47
+ strValue?: string | undefined;
48
+ language?: string | undefined;
49
+ termType: "literal";
50
+ /**
51
+ * @param typedValue internal representation of this literal's value
52
+ * @param dataType a string representing the datatype. Can be of type @see LiteralTypes or any URI
53
+ * @param strValue the string value of this literal. In other words, the string representing the RDF.literal value.
54
+ * @param language the language, mainly for language enabled strings like RDF_LANG_STRING
55
+ */
56
+ constructor(typedValue: T, dataType: string, strValue?: string | undefined, language?: string | undefined);
57
+ toRDF(dataFactory: ComunicaDataFactory): RDF.Literal;
58
+ str(): string;
59
+ }
60
+ export declare abstract class NumericLiteral extends Literal<number> {
61
+ typedValue: number;
62
+ strValue?: string | undefined;
63
+ language?: string | undefined;
64
+ protected constructor(typedValue: number, dataType: string, strValue?: string | undefined, language?: string | undefined);
65
+ protected abstract specificFormatter(val: number): string;
66
+ coerceEBV(): boolean;
67
+ toRDF(dataFactory: ComunicaDataFactory): RDF.Literal;
68
+ str(): string;
69
+ }
70
+ export declare class IntegerLiteral extends NumericLiteral {
71
+ typedValue: number;
72
+ strValue?: string | undefined;
73
+ language?: string | undefined;
74
+ constructor(typedValue: number, dataType?: string, strValue?: string | undefined, language?: string | undefined);
75
+ protected specificFormatter(val: number): string;
76
+ }
77
+ export declare class DecimalLiteral extends NumericLiteral {
78
+ typedValue: number;
79
+ strValue?: string | undefined;
80
+ language?: string | undefined;
81
+ constructor(typedValue: number, dataType?: string, strValue?: string | undefined, language?: string | undefined);
82
+ protected specificFormatter(val: number): string;
83
+ }
84
+ export declare class FloatLiteral extends NumericLiteral {
85
+ typedValue: number;
86
+ strValue?: string | undefined;
87
+ language?: string | undefined;
88
+ constructor(typedValue: number, dataType?: string, strValue?: string | undefined, language?: string | undefined);
89
+ protected specificFormatter(val: number): string;
90
+ }
91
+ export declare class DoubleLiteral extends NumericLiteral {
92
+ typedValue: number;
93
+ strValue?: string | undefined;
94
+ language?: string | undefined;
95
+ constructor(typedValue: number, dataType?: string, strValue?: string | undefined, language?: string | undefined);
96
+ protected specificFormatter(val: number): string;
97
+ }
98
+ export declare class BooleanLiteral extends Literal<boolean> {
99
+ typedValue: boolean;
100
+ strValue?: string | undefined;
101
+ constructor(typedValue: boolean, strValue?: string | undefined, dataType?: string);
102
+ coerceEBV(): boolean;
103
+ }
104
+ export declare class LangStringLiteral extends Literal<string> {
105
+ typedValue: string;
106
+ language: string;
107
+ constructor(typedValue: string, language: string, dataType?: string);
108
+ coerceEBV(): boolean;
109
+ }
110
+ export declare class StringLiteral extends Literal<string> {
111
+ typedValue: string;
112
+ /**
113
+ * @param typedValue
114
+ * @param dataType Should be type that implements XSD_STRING
115
+ */
116
+ constructor(typedValue: string, dataType?: string);
117
+ coerceEBV(): boolean;
118
+ }
119
+ export declare class DateTimeLiteral extends Literal<IDateTimeRepresentation> {
120
+ typedValue: IDateTimeRepresentation;
121
+ strValue?: string | undefined;
122
+ constructor(typedValue: IDateTimeRepresentation, strValue?: string | undefined, dataType?: string);
123
+ str(): string;
124
+ }
125
+ export declare class TimeLiteral extends Literal<ITimeRepresentation> {
126
+ typedValue: ITimeRepresentation;
127
+ strValue?: string | undefined;
128
+ constructor(typedValue: ITimeRepresentation, strValue?: string | undefined, dataType?: string);
129
+ str(): string;
130
+ }
131
+ export declare class DateLiteral extends Literal<IDateRepresentation> {
132
+ typedValue: IDateRepresentation;
133
+ strValue?: string | undefined;
134
+ constructor(typedValue: IDateRepresentation, strValue?: string | undefined, dataType?: string);
135
+ str(): string;
136
+ }
137
+ export declare class DurationLiteral extends Literal<Partial<IDurationRepresentation>> {
138
+ typedValue: Partial<IDurationRepresentation>;
139
+ strValue?: string | undefined;
140
+ constructor(typedValue: Partial<IDurationRepresentation>, strValue?: string | undefined, dataType?: string);
141
+ str(): string;
142
+ }
143
+ export declare class DayTimeDurationLiteral extends DurationLiteral {
144
+ typedValue: Partial<IDurationRepresentation>;
145
+ strValue?: string | undefined;
146
+ constructor(typedValue: Partial<IDurationRepresentation>, strValue?: string | undefined, dataType?: string);
147
+ }
148
+ export declare class YearMonthDurationLiteral extends Literal<Partial<IYearMonthDurationRepresentation>> {
149
+ typedValue: Partial<IYearMonthDurationRepresentation>;
150
+ strValue?: string | undefined;
151
+ constructor(typedValue: Partial<IYearMonthDurationRepresentation>, strValue?: string | undefined, dataType?: string);
152
+ str(): string;
153
+ }
154
+ /**
155
+ * This class is used when a literal is parsed, and it's value is
156
+ * an invalid lexical form for it's datatype. The spec defines value with
157
+ * invalid lexical form are still valid terms, and as such we can not error
158
+ * immediately. This class makes sure that the typedValue will remain undefined,
159
+ * and the category 'nonlexical'. This way, only when operators apply to the
160
+ * 'nonlexical' category, they will keep working, otherwise they will throw a
161
+ * type error.
162
+ * This seems to match the spec, except maybe for functions that accept
163
+ * non-lexical values for their datatype.
164
+ *
165
+ * See:
166
+ * - https://www.w3.org/TR/xquery/#dt-type-error
167
+ * - https://www.w3.org/TR/rdf-concepts/#section-Literal-Value
168
+ * - https://www.w3.org/TR/xquery/#dt-ebv
169
+ * - ... some other more precise thing i can't find...
170
+ */
171
+ export declare class NonLexicalLiteral extends Literal<{
172
+ toString: () => 'undefined';
173
+ }> {
174
+ private readonly openWorldType;
175
+ constructor(typedValue: undefined, dataType: string, openWorldType: ISuperTypeProvider, strValue?: string, language?: string);
176
+ coerceEBV(): boolean;
177
+ toRDF(dataFactory: ComunicaDataFactory): RDF.Literal;
178
+ str(): string;
179
+ }
180
+ export declare function isNonLexicalLiteral(lit: Literal<any>): NonLexicalLiteral | undefined;