@comunica/actor-query-operation-slice 2.4.0 → 2.5.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorQueryOperationSlice.js","sourceRoot":"","sources":["ActorQueryOperationSlice.ts"],"names":[],"mappings":";;;AACA,uEAEuC;AACvC,+DAA+D;AAW/D;;GAEG;AACH,MAAa,wBAAyB,SAAQ,sDAA+C;IAC3F,YAAmB,IAA2C;QAC5D,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,SAAwB,EAAE,OAAuB;QAC1E,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAAwB,EAAE,OAAuB;QAEzE,2EAA2E;QAC3E,yDAAyD;QACzD,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAkB,CAAC,cAAc,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;SAC5E;QAED,oBAAoB;QACpB,MAAM,MAAM,GAA0B,MAAM,IAAI,CAAC,sBAAsB;aACpE,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAEpD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9B,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;YAC1E,OAAuC;gBACrC,IAAI,EAAE,UAAU;gBAChB,cAAc;gBACd,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC;aAChD,CAAC;SACH;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE;YAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAA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AC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;gBACnE,IAAI,SAAS,EAAE;oBACb,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,MAAO,CAAC,CAAC;iBAClE;aACF;YACD,OAAO,EAAE,GAAG,WAAW,EAAE,WAAW,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AAtED,4DAsEC","sourcesContent":["import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';\nimport {\n ActorQueryOperationTypedMediated,\n} from '@comunica/bus-query-operation';\nimport { KeysQueryOperation } from '@comunica/context-entries';\nimport type { IActorTest } from '@comunica/core';\nimport type {\n IQueryOperationResult,\n IQueryOperationResultBindings,\n IQueryOperationResultQuads,\n IQueryOperationResultStream, IMetadata, IActionContext,\n} from '@comunica/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport type { Algebra } from 'sparqlalgebrajs';\n\n/**\n * A comunica Slice Query Operation Actor.\n */\nexport class ActorQueryOperationSlice extends ActorQueryOperationTypedMediated<Algebra.Slice> {\n public constructor(args: IActorQueryOperationTypedMediatedArgs) {\n super(args, 'slice');\n }\n\n public async testOperation(operation: Algebra.Slice, context: IActionContext): Promise<IActorTest> {\n return true;\n }\n\n public async runOperation(operation: Algebra.Slice, context: IActionContext):\n Promise<IQueryOperationResult> {\n // Add limit indicator to the context, which can be used for query planning\n // eslint-disable-next-line unicorn/explicit-length-check\n if (operation.length) {\n context = context.set(KeysQueryOperation.limitIndicator, operation.length);\n }\n\n // Resolve the input\n const output: IQueryOperationResult = await this.mediatorQueryOperation\n .mediate({ operation: operation.input, context });\n\n if (output.type === 'bindings') {\n const bindingsStream = this.sliceStream(output.bindingsStream, operation);\n return <IQueryOperationResultBindings> {\n type: 'bindings',\n bindingsStream,\n metadata: this.sliceMetadata(output, operation),\n };\n }\n\n if (output.type === 'quads') {\n const quadStream = this.sliceStream(output.quadStream, operation);\n return <IQueryOperationResultQuads> {\n type: 'quads',\n quadStream,\n metadata: this.sliceMetadata(output, operation),\n };\n }\n\n throw new Error(`Invalid query output type: Expected 'bindings' or 'quads' but got '${output.type}'`);\n }\n\n // Slice the stream based on the pattern values\n private sliceStream(stream: AsyncIterator<any>, pattern: Algebra.Slice): AsyncIterator<any> {\n // eslint-disable-next-line unicorn/explicit-length-check\n const hasLength: boolean = Boolean(pattern.length) || pattern.length === 0;\n const { start } = pattern;\n const end = hasLength ? pattern.start + pattern.length! - 1 : Number.POSITIVE_INFINITY;\n return stream.transform({ offset: start, limit: Math.max(end - start + 1, 0), autoStart: false });\n }\n\n // If we find metadata, apply slicing on the total number of items\n private sliceMetadata(\n output: IQueryOperationResultStream<any, any>,\n pattern: Algebra.Slice,\n ): () => Promise<IMetadata<any>> {\n // eslint-disable-next-line unicorn/explicit-length-check\n const hasLength: boolean = Boolean(pattern.length) || pattern.length === 0;\n return () => (<() => Promise<IMetadata<any>>>output.metadata)()\n .then(subMetadata => {\n const cardinality = { ...subMetadata.cardinality };\n if (Number.isFinite(cardinality.value)) {\n cardinality.value = Math.max(0, cardinality.value - pattern.start);\n if (hasLength) {\n cardinality.value = Math.min(cardinality.value, pattern.length!);\n }\n }\n return { ...subMetadata, cardinality };\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C","sourcesContent":["export * from './ActorQueryOperationSlice';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-query-operation-slice",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "A slice query-operation actor",
5
5
  "lsd:module": true,
6
6
  "main": "lib/index.js",
@@ -28,13 +28,14 @@
28
28
  "files": [
29
29
  "components",
30
30
  "lib/**/*.d.ts",
31
- "lib/**/*.js"
31
+ "lib/**/*.js",
32
+ "lib/**/*.js.map"
32
33
  ],
33
34
  "dependencies": {
34
- "@comunica/bus-query-operation": "^2.4.0",
35
- "@comunica/context-entries": "^2.4.0",
36
- "@comunica/core": "^2.4.0",
37
- "@comunica/types": "^2.4.0",
35
+ "@comunica/bus-query-operation": "^2.5.0",
36
+ "@comunica/context-entries": "^2.5.0",
37
+ "@comunica/core": "^2.5.0",
38
+ "@comunica/types": "^2.5.0",
38
39
  "sparqlalgebrajs": "^4.0.0"
39
40
  },
40
41
  "scripts": {
@@ -42,5 +43,5 @@
42
43
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
43
44
  "build:components": "componentsjs-generator"
44
45
  },
45
- "gitHead": "cb5a1560c9ab9ebaf3335888a1411a7e1654de1e"
46
+ "gitHead": "349d57f5d1e539200e980bdff96973c2e0b66caa"
46
47
  }
package/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
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.