@comunica/actor-function-factory-expression-in 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.
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,35 @@
1
+ # Comunica Expression Function In Function Factory Actor
2
+
3
+ [![npm version](https://badge.fury.io/js/%40comunica%2Factor-function-factory-expression-function-in.svg)](https://www.npmjs.com/package/@comunica/actor-function-factory-expression-in)
4
+
5
+ A comunica Expression Function In Function Factory Actor.
6
+
7
+ This module is part of the [Comunica framework](https://github.com/comunica/comunica),
8
+ and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
9
+
10
+ [Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ $ yarn add @comunica/actor-function-factory-expression-in
16
+ ```
17
+
18
+ ## Configure
19
+
20
+ After installing, this package can be added to your engine's configuration as follows:
21
+ ```text
22
+ {
23
+ "@context": [
24
+ ...
25
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-expression-in/^3.0.0/components/context.jsonld"
26
+ ],
27
+ "actors": [
28
+ ...
29
+ {
30
+ "@id": "urn:comunica:default:function-factory/actors#expression-function-in",
31
+ "@type": "ActorFunctionFactoryExpressionIn"
32
+ }
33
+ ]
34
+ }
35
+ ```
@@ -0,0 +1,186 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-expression-in/^3.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^3.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-function-factory/^3.0.0/components/context.jsonld"
6
+ ],
7
+ "@id": "npmd:@comunica/actor-function-factory-expression-in",
8
+ "components": [
9
+ {
10
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn",
11
+ "@type": "Class",
12
+ "requireElement": "ActorFunctionFactoryExpressionIn",
13
+ "extends": [
14
+ "cbff:components/ActorFunctionFactoryDedicated.jsonld#ActorFunctionFactoryDedicated"
15
+ ],
16
+ "comment": "A comunica ExpressionFunctionIn Function Factory Actor.",
17
+ "parameters": [
18
+ {
19
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_mediatorFunctionFactory",
20
+ "range": "cc:components/Mediator.jsonld#Mediator"
21
+ },
22
+ {
23
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_name",
24
+ "range": "xsd:string",
25
+ "default": {
26
+ "@id": "rdf:subject"
27
+ },
28
+ "comment": "The name for this actor."
29
+ },
30
+ {
31
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_bus",
32
+ "range": {
33
+ "@type": "ParameterRangeGenericComponent",
34
+ "component": "cc:components/Bus.jsonld#Bus",
35
+ "genericTypeInstances": [
36
+ {
37
+ "@type": "ParameterRangeGenericComponent",
38
+ "component": "cc:components/Actor.jsonld#Actor",
39
+ "genericTypeInstances": [
40
+ {
41
+ "@type": "ParameterRangeGenericTypeReference",
42
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
43
+ },
44
+ {
45
+ "@type": "ParameterRangeGenericTypeReference",
46
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
47
+ },
48
+ {
49
+ "@type": "ParameterRangeGenericTypeReference",
50
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
51
+ },
52
+ {
53
+ "@type": "ParameterRangeGenericTypeReference",
54
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "@type": "ParameterRangeGenericTypeReference",
60
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
61
+ },
62
+ {
63
+ "@type": "ParameterRangeGenericTypeReference",
64
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
65
+ },
66
+ {
67
+ "@type": "ParameterRangeGenericTypeReference",
68
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
69
+ },
70
+ {
71
+ "@type": "ParameterRangeGenericTypeReference",
72
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
73
+ }
74
+ ]
75
+ },
76
+ "default": {
77
+ "@id": "cbff:components/ActorFunctionFactory.jsonld#ActorFunctionFactory_default_bus",
78
+ "@type": "cbff:components/BusFunctionFactory.jsonld#BusFunctionFactory"
79
+ },
80
+ "comment": "The bus this actor subscribes to."
81
+ },
82
+ {
83
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_busFailMessage",
84
+ "range": {
85
+ "@type": "ParameterRangeUnion",
86
+ "parameterRangeElements": [
87
+ "xsd:string",
88
+ {
89
+ "@type": "ParameterRangeUndefined"
90
+ }
91
+ ]
92
+ },
93
+ "comment": "The message that will be configured in the bus for reporting failures. This message may be a template string that contains references to the executed `action`. For example, the following templated string is allowed: \"RDF dereferencing failed: no actors could handle ${action.handle.mediaType}\""
94
+ },
95
+ {
96
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_beforeActors",
97
+ "range": {
98
+ "@type": "ParameterRangeUnion",
99
+ "parameterRangeElements": [
100
+ {
101
+ "@type": "ParameterRangeArray",
102
+ "parameterRangeValue": {
103
+ "@type": "ParameterRangeGenericComponent",
104
+ "component": "cc:components/Actor.jsonld#Actor",
105
+ "genericTypeInstances": [
106
+ {
107
+ "@type": "ParameterRangeGenericTypeReference",
108
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
109
+ },
110
+ {
111
+ "@type": "ParameterRangeGenericTypeReference",
112
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
113
+ },
114
+ {
115
+ "@type": "ParameterRangeGenericTypeReference",
116
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
117
+ },
118
+ {
119
+ "@type": "ParameterRangeGenericTypeReference",
120
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
121
+ }
122
+ ]
123
+ }
124
+ },
125
+ {
126
+ "@type": "ParameterRangeUndefined"
127
+ }
128
+ ]
129
+ },
130
+ "comment": "Actor that must be registered in the bus before this actor."
131
+ }
132
+ ],
133
+ "memberFields": [
134
+ {
135
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn__member_mediatorFunctionFactory",
136
+ "memberFieldName": "mediatorFunctionFactory"
137
+ },
138
+ {
139
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn__member_constructor",
140
+ "memberFieldName": "constructor"
141
+ },
142
+ {
143
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn__member_run",
144
+ "memberFieldName": "run"
145
+ }
146
+ ],
147
+ "constructorArguments": [
148
+ {
149
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args__constructorArgument",
150
+ "fields": [
151
+ {
152
+ "keyRaw": "mediatorFunctionFactory",
153
+ "value": {
154
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_mediatorFunctionFactory"
155
+ }
156
+ },
157
+ {
158
+ "keyRaw": "name",
159
+ "value": {
160
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_name"
161
+ }
162
+ },
163
+ {
164
+ "keyRaw": "bus",
165
+ "value": {
166
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_bus"
167
+ }
168
+ },
169
+ {
170
+ "keyRaw": "busFailMessage",
171
+ "value": {
172
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_busFailMessage"
173
+ }
174
+ },
175
+ {
176
+ "keyRaw": "beforeActors",
177
+ "value": {
178
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_beforeActors"
179
+ }
180
+ }
181
+ ]
182
+ }
183
+ ]
184
+ }
185
+ ]
186
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-expression-in/^3.0.0/components/context.jsonld"
4
+ ],
5
+ "@id": "npmd:@comunica/actor-function-factory-expression-in",
6
+ "@type": "Module",
7
+ "requireName": "@comunica/actor-function-factory-expression-in",
8
+ "import": [
9
+ "caffei:components/ActorFunctionFactoryExpressionIn.jsonld"
10
+ ]
11
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
4
+ {
5
+ "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
+ "caffei": "npmd:@comunica/actor-function-factory-expression-in/^3.0.0/",
7
+ "ActorFunctionFactoryExpressionIn": {
8
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn",
9
+ "@prefix": true,
10
+ "@context": {
11
+ "args_mediatorFunctionFactory": {
12
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_mediatorFunctionFactory"
13
+ },
14
+ "args_name": {
15
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_name"
16
+ },
17
+ "args_bus": {
18
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_bus"
19
+ },
20
+ "args_busFailMessage": {
21
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_busFailMessage"
22
+ },
23
+ "args_beforeActors": {
24
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_beforeActors",
25
+ "@container": "@list"
26
+ },
27
+ "mediatorFunctionFactory": {
28
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_mediatorFunctionFactory"
29
+ },
30
+ "name": {
31
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_name"
32
+ },
33
+ "bus": {
34
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_bus"
35
+ },
36
+ "busFailMessage": {
37
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_busFailMessage"
38
+ },
39
+ "beforeActors": {
40
+ "@id": "caffei:components/ActorFunctionFactoryExpressionIn.jsonld#ActorFunctionFactoryExpressionIn_args_beforeActors",
41
+ "@container": "@list"
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,16 @@
1
+ import type { IActionFunctionFactory, IActorFunctionFactoryArgs, IActorFunctionFactoryOutput, IActorFunctionFactoryOutputTerm, MediatorFunctionFactoryUnsafe } from '@comunica/bus-function-factory';
2
+ import { ActorFunctionFactoryDedicated } from '@comunica/bus-function-factory';
3
+ interface IActorFunctionFactoryExpressionFunctionInArgs extends IActorFunctionFactoryArgs {
4
+ mediatorFunctionFactory: MediatorFunctionFactoryUnsafe;
5
+ }
6
+ /**
7
+ * A comunica ExpressionFunctionIn Function Factory Actor.
8
+ */
9
+ export declare class ActorFunctionFactoryExpressionIn extends ActorFunctionFactoryDedicated {
10
+ private readonly mediatorFunctionFactory;
11
+ constructor(args: IActorFunctionFactoryExpressionFunctionInArgs);
12
+ run<T extends IActionFunctionFactory>(args: T): Promise<T extends {
13
+ requireTermExpression: true;
14
+ } ? IActorFunctionFactoryOutputTerm : IActorFunctionFactoryOutput>;
15
+ }
16
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActorFunctionFactoryExpressionIn = void 0;
4
+ const bus_function_factory_1 = require("@comunica/bus-function-factory");
5
+ const utils_expression_evaluator_1 = require("@comunica/utils-expression-evaluator");
6
+ const ExpressionFunctionIn_1 = require("./ExpressionFunctionIn");
7
+ /**
8
+ * A comunica ExpressionFunctionIn Function Factory Actor.
9
+ */
10
+ class ActorFunctionFactoryExpressionIn extends bus_function_factory_1.ActorFunctionFactoryDedicated {
11
+ constructor(args) {
12
+ super({
13
+ ...args,
14
+ functionNames: [utils_expression_evaluator_1.SparqlOperator.IN],
15
+ termFunction: false,
16
+ });
17
+ this.mediatorFunctionFactory = args.mediatorFunctionFactory;
18
+ }
19
+ async run(args) {
20
+ const equalityFunction = await this.mediatorFunctionFactory.mediate({
21
+ functionName: utils_expression_evaluator_1.SparqlOperator.EQUAL,
22
+ requireTermExpression: true,
23
+ context: args.context,
24
+ arguments: args.arguments,
25
+ });
26
+ return new ExpressionFunctionIn_1.ExpressionFunctionIn(equalityFunction);
27
+ }
28
+ }
29
+ exports.ActorFunctionFactoryExpressionIn = ActorFunctionFactoryExpressionIn;
30
+ //# sourceMappingURL=ActorFunctionFactoryExpressionIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorFunctionFactoryExpressionIn.js","sourceRoot":"","sources":["ActorFunctionFactoryExpressionIn.ts"],"names":[],"mappings":";;;AASA,yEAEwC;AAExC,qFAAsE;AACtE,iEAA8D;AAM9D;;GAEG;AACH,MAAa,gCAAiC,SAAQ,oDAA6B;IAGjF,YAAmB,IAAmD;QACpE,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,aAAa,EAAE,CAAE,2CAAc,CAAC,EAAE,CAAE;YACpC,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,uBAAuB,GAA6B,IAAI,CAAC,uBAAuB,CAAC;IACxF,CAAC;IAEM,KAAK,CAAC,GAAG,CAAmC,IAAO;QAExD,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC;YAClE,YAAY,EAAE,2CAAc,CAAC,KAAK;YAClC,qBAAqB,EAAE,IAAI;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;QAEH,OAGwB,IAAI,2CAAoB,CAAC,gBAAgB,CAAC,CAAC;IACrE,CAAC;CACF;AA1BD,4EA0BC","sourcesContent":["import type {\n IActionFunctionFactory,\n IActorFunctionFactoryArgs,\n IActorFunctionFactoryOutput,\n IActorFunctionFactoryOutputTerm,\n IExpressionFunction,\n MediatorFunctionFactory,\n MediatorFunctionFactoryUnsafe,\n} from '@comunica/bus-function-factory';\nimport {\n ActorFunctionFactoryDedicated,\n} from '@comunica/bus-function-factory';\n\nimport { SparqlOperator } from '@comunica/utils-expression-evaluator';\nimport { ExpressionFunctionIn } from './ExpressionFunctionIn';\n\ninterface IActorFunctionFactoryExpressionFunctionInArgs extends IActorFunctionFactoryArgs {\n mediatorFunctionFactory: MediatorFunctionFactoryUnsafe;\n}\n\n/**\n * A comunica ExpressionFunctionIn Function Factory Actor.\n */\nexport class ActorFunctionFactoryExpressionIn extends ActorFunctionFactoryDedicated {\n private readonly mediatorFunctionFactory: MediatorFunctionFactory;\n\n public constructor(args: IActorFunctionFactoryExpressionFunctionInArgs) {\n super({\n ...args,\n functionNames: [ SparqlOperator.IN ],\n termFunction: false,\n });\n this.mediatorFunctionFactory = <MediatorFunctionFactory> args.mediatorFunctionFactory;\n }\n\n public async run<T extends IActionFunctionFactory>(args: T):\n Promise<T extends { requireTermExpression: true } ? IActorFunctionFactoryOutputTerm : IActorFunctionFactoryOutput> {\n const equalityFunction = await this.mediatorFunctionFactory.mediate({\n functionName: SparqlOperator.EQUAL,\n requireTermExpression: true,\n context: args.context,\n arguments: args.arguments,\n });\n\n return <T extends { requireTermExpression: true } ?\n IActorFunctionFactoryOutputTerm :\n IActorFunctionFactoryOutput>\n <IExpressionFunction> new ExpressionFunctionIn(equalityFunction);\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { ITermFunction } from '@comunica/bus-function-factory';
2
+ import { ExpressionFunctionBase } from '@comunica/bus-function-factory';
3
+ import type { Expression } from '@comunica/types';
4
+ /**
5
+ * https://www.w3.org/TR/sparql11-query/#func-in
6
+ * This function doesn't require type promotion or subtype-substitution, everything works on TermExpression
7
+ */
8
+ export declare class ExpressionFunctionIn extends ExpressionFunctionBase {
9
+ private readonly equalityFunction;
10
+ constructor(equalityFunction: ITermFunction);
11
+ checkArity(args: Expression[]): boolean;
12
+ private inRecursive;
13
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressionFunctionIn = void 0;
4
+ const bus_function_factory_1 = require("@comunica/bus-function-factory");
5
+ const utils_expression_evaluator_1 = require("@comunica/utils-expression-evaluator");
6
+ /**
7
+ * https://www.w3.org/TR/sparql11-query/#func-in
8
+ * This function doesn't require type promotion or subtype-substitution, everything works on TermExpression
9
+ */
10
+ class ExpressionFunctionIn extends bus_function_factory_1.ExpressionFunctionBase {
11
+ constructor(equalityFunction) {
12
+ super({
13
+ arity: Number.POSITIVE_INFINITY,
14
+ operator: utils_expression_evaluator_1.SparqlOperator.IN,
15
+ apply: async (context) => {
16
+ const { args, mapping, exprEval } = context;
17
+ const [leftExpr, ...remaining] = args;
18
+ const left = await exprEval.evaluatorExpressionEvaluation(leftExpr, mapping);
19
+ return await this.inRecursive(left, { ...context, args: remaining }, []);
20
+ },
21
+ });
22
+ this.equalityFunction = equalityFunction;
23
+ }
24
+ checkArity(args) {
25
+ return args.length > 0;
26
+ }
27
+ async inRecursive(needle, context, results) {
28
+ const { args, mapping, exprEval } = context;
29
+ if (args.length === 0) {
30
+ const noErrors = results.every(val => !val);
31
+ return noErrors ? (0, utils_expression_evaluator_1.bool)(false) : Promise.reject(new utils_expression_evaluator_1.InError(results));
32
+ }
33
+ try {
34
+ // We know this will not be undefined because we check args.length === 0
35
+ const nextExpression = args.shift();
36
+ const next = await exprEval.evaluatorExpressionEvaluation(nextExpression, mapping);
37
+ if (this.equalityFunction.applyOnTerms([needle, next], exprEval).typedValue) {
38
+ return (0, utils_expression_evaluator_1.bool)(true);
39
+ }
40
+ return this.inRecursive(needle, context, [...results, false]);
41
+ }
42
+ catch (error) {
43
+ return this.inRecursive(needle, context, [...results, error]);
44
+ }
45
+ }
46
+ }
47
+ exports.ExpressionFunctionIn = ExpressionFunctionIn;
48
+ //# sourceMappingURL=ExpressionFunctionIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionFunctionIn.js","sourceRoot":"","sources":["ExpressionFunctionIn.ts"],"names":[],"mappings":";;;AACA,yEAAwE;AAKxE,qFAI8C;AAE9C;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,6CAAsB;IAC9D,YAAoC,gBAA+B;QACjE,KAAK,CAAC;YACJ,KAAK,EAAE,MAAM,CAAC,iBAAiB;YAC/B,QAAQ,EAAE,2CAAc,CAAC,EAAE;YAC3B,KAAK,EAAE,KAAK,EAAC,OAAqB,EAA2B,EAAE;gBAC7D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;gBAC5C,MAAM,CAAE,QAAQ,EAAE,GAAG,SAAS,CAAE,GAAG,IAAI,CAAC;gBACxC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,6BAA6B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAC7E,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;YAC3E,CAAC;SACF,CAAC,CAAC;QAV+B,qBAAgB,GAAhB,gBAAgB,CAAe;IAWnE,CAAC;IAEe,UAAU,CAAC,IAAkB;QAC3C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,MAAsB,EACtB,OAAqB,EACrB,OAA0B;QAE1B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAC5C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YAC5C,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,iCAAI,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,oCAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,CAAC;YACH,wEAAwE;YACxE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,EAAG,CAAC;YACrC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,6BAA6B,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YACnF,IAAsB,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAE,MAAM,EAAE,IAAI,CAAE,EAAE,QAAQ,CAAE,CAAC,UAAU,EAAE,CAAC;gBACjG,OAAO,IAAA,iCAAI,EAAC,IAAI,CAAC,CAAC;YACpB,CAAC;YACD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,CAAE,GAAG,OAAO,EAAE,KAAK,CAAE,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,CAAE,GAAG,OAAO,EAAU,KAAK,CAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF;AAzCD,oDAyCC","sourcesContent":["import type { ITermFunction } from '@comunica/bus-function-factory';\nimport { ExpressionFunctionBase } from '@comunica/bus-function-factory';\nimport type { Expression, IEvalContext, TermExpression } from '@comunica/types';\nimport type {\n BooleanLiteral,\n} from '@comunica/utils-expression-evaluator';\nimport {\n bool,\n InError,\n SparqlOperator,\n} from '@comunica/utils-expression-evaluator';\n\n/**\n * https://www.w3.org/TR/sparql11-query/#func-in\n * This function doesn't require type promotion or subtype-substitution, everything works on TermExpression\n */\nexport class ExpressionFunctionIn extends ExpressionFunctionBase {\n public constructor(private readonly equalityFunction: ITermFunction) {\n super({\n arity: Number.POSITIVE_INFINITY,\n operator: SparqlOperator.IN,\n apply: async(context: IEvalContext): Promise<TermExpression> => {\n const { args, mapping, exprEval } = context;\n const [ leftExpr, ...remaining ] = args;\n const left = await exprEval.evaluatorExpressionEvaluation(leftExpr, mapping);\n return await this.inRecursive(left, { ...context, args: remaining }, []);\n },\n });\n }\n\n public override checkArity(args: Expression[]): boolean {\n return args.length > 0;\n }\n\n private async inRecursive(\n needle: TermExpression,\n context: IEvalContext,\n results: (Error | false)[],\n ): Promise<TermExpression> {\n const { args, mapping, exprEval } = context;\n if (args.length === 0) {\n const noErrors = results.every(val => !val);\n return noErrors ? bool(false) : Promise.reject(new InError(results));\n }\n\n try {\n // We know this will not be undefined because we check args.length === 0\n const nextExpression = args.shift()!;\n const next = await exprEval.evaluatorExpressionEvaluation(nextExpression, mapping);\n if ((<BooleanLiteral> this.equalityFunction.applyOnTerms([ needle, next ], exprEval)).typedValue) {\n return bool(true);\n }\n return this.inRecursive(needle, context, [ ...results, false ]);\n } catch (error: unknown) {\n return this.inRecursive(needle, context, [ ...results, <Error> error ]);\n }\n }\n}\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './ActorFunctionFactoryExpressionIn';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ActorFunctionFactoryExpressionIn"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmD","sourcesContent":["export * from './ActorFunctionFactoryExpressionIn';\n"]}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@comunica/actor-function-factory-expression-in",
3
+ "version": "3.2.4-alpha.47.0",
4
+ "description": "A expression-in function-factory actor",
5
+ "lsd:module": true,
6
+ "license": "MIT",
7
+ "homepage": "https://comunica.dev/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/comunica/comunica.git",
11
+ "directory": "packages/actor-function-factory-expression-in"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/comunica/comunica/issues"
15
+ },
16
+ "keywords": [
17
+ "comunica",
18
+ "actor",
19
+ "function-factory",
20
+ "expression-function-in"
21
+ ],
22
+ "sideEffects": false,
23
+ "main": "lib/index.js",
24
+ "typings": "lib/index",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "components",
30
+ "lib/**/*.d.ts",
31
+ "lib/**/*.js",
32
+ "lib/**/*.js.map"
33
+ ],
34
+ "scripts": {
35
+ "build": "yarn run build:ts && yarn run build:components",
36
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
37
+ "build:components": "componentsjs-generator"
38
+ },
39
+ "dependencies": {
40
+ "@comunica/bus-function-factory": "3.2.4-alpha.47.0",
41
+ "@comunica/types": "3.2.4-alpha.47.0",
42
+ "@comunica/utils-expression-evaluator": "3.2.4-alpha.47.0"
43
+ },
44
+ "gitHead": "85bd4c5cf07dfc293ebbc3a1416b70e2db8bfc48"
45
+ }