diff --git a/.eslintignore b/.eslintignore index f8e66fae..a4fd9ee9 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,12 +4,3 @@ coverage **/*.js **/*.d.ts **/*.js.map - -engines/config-query-sparql-incremental/lib/index.ts -engines/query-sparql-incremental/bin/query.ts -engines/query-sparql-incremental/lib/QueryEngine.ts -**/test/** -**/test-browser/** - -packages/dev-tools/* -packages/incremental-jest/* diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 44eaee68..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,185 +0,0 @@ -module.exports = { - root: true, - parser: '@typescript-eslint/parser', - parserOptions: { - tsconfigRootDir: __dirname, // this is the reason this is a .js file - project: ['./tsconfig.eslint.json'], - }, - plugins: [ - 'eslint-plugin-tsdoc', - 'eslint-plugin-import', - 'eslint-plugin-jest', - 'eslint-plugin-unused-imports' - ], - extends: [ - 'es/node', - 'plugin:import/errors', - 'plugin:import/warnings', - 'plugin:import/typescript' - ], - settings: { - 'import/parsers': { - '@typescript-eslint/parser': ['.ts', '.tsx'] - }, - 'import/resolver': { - 'typescript': { - 'alwaysTryTypes': true // always try to resolve incremental-types under `@incremental-types` directory even it doesn't contain any source code, like `@incremental-types/rdf-js` - }, - } - }, - globals: { - window: false, - fetch: false, - Headers: false, - Request: false, - XMLHttpRequest: false, - }, - rules: { - // Default - 'import/group-exports': 'off', - 'class-methods-use-this': 'off', // Conflicts with functions from interfaces that sometimes don't require `this` - 'comma-dangle': ['error', 'always-multiline'], - 'dot-location': ['error', 'property'], - 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }], - 'no-underscore-dangle': 'off', // Conflicts with external libraries - 'padding-line-between-statements': 'off', - 'no-param-reassign': 'off', - 'func-style': 'off', - 'new-cap': 'off', - 'lines-around-comment': ['error', { - beforeBlockComment: false, - afterBlockComment: false, - beforeLineComment: false, - afterLineComment: false, - }], - 'no-multi-assign': 'off', - 'no-plusplus': 'off', - 'guard-for-in': 'off', - 'sort-imports': 'off', // Disabled in favor of eslint-plugin-import - 'prefer-named-capture-group': 'off', - 'max-len': ['error', { - code: 120, - ignoreTemplateLiterals: true, - }], - 'unicorn/consistent-function-scoping': 'off', - 'no-warning-comments': 'off', - 'no-mixed-operators': 'off', - 'prefer-destructuring': 'off', - 'default-case': 'off', // TSC already takes care of these checks - 'no-loop-func': 'off', - 'unicorn/no-fn-reference-in-iterator': 'off', - 'extended/consistent-err-names': 'off', - 'unicorn/prefer-replace-all': 'off', - 'unicorn/catch-error-name': ['error', { name: 'error' }], - 'unicorn/no-reduce': 'off', - 'no-duplicate-imports': 'off', // Incompatible with type imports - 'unicorn/consistent-destructuring': 'off', - 'unicorn/no-array-callback-reference': 'off', - 'unicorn/no-new-array': 'off', - - // TS - '@typescript-eslint/lines-between-class-members': ['error', { exceptAfterSingleLine: true }], - '@typescript-eslint/no-invalid-void-type': 'off', // breaks with default void in Asynchandler 2nd generic - '@typescript-eslint/array-type': ['error', { default: 'array' }], - '@typescript-eslint/generic-type-naming': 'off', - '@typescript-eslint/no-empty-interface': 'off', - '@typescript-eslint/no-unnecessary-condition': 'off', // Problems with optional parameters - '@typescript-eslint/space-before-function-paren': ['error', 'never'], - '@typescript-eslint/promise-function-async': 'off', - '@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'angle-bracket' }], - '@typescript-eslint/member-naming': 'off', - '@typescript-eslint/naming-convention': [ - 'error', - { - 'selector': 'interface', - 'format': ['PascalCase'], - 'custom': { - 'regex': '^I[A-Z]', - 'match': true - } - } - ], - '@typescript-eslint/no-dynamic-delete': 'off', - '@typescript-eslint/explicit-function-return-type': ['error', { - allowExpressions: true, - allowTypedFunctionExpressions: true, - allowHigherOrderFunctions: true, - allowConciseArrowFunctionExpressionsStartingWithVoid: true, - }], - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/prefer-nullish-coalescing': 'off', - '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }], - - // Import - 'import/order': ['error', { - alphabetize: { - order: 'asc', - caseInsensitive: true - } - }], - 'import/no-unused-modules': 'off', - 'unused-imports/no-unused-imports-ts': 'error', - 'import/no-extraneous-dependencies': 'error', - - // TODO: Try to re-enable the following rules in the future - 'global-require': 'off', - '@typescript-eslint/no-require-imports': 'off', - '@typescript-eslint/no-var-requires': 'off', - '@typescript-eslint/no-unused-vars': 'off', - 'tsdoc/syntax': 'off', - 'unicorn/expiring-todo-comments': 'off', - 'unicorn/import-style': 'off', - 'unicorn/prefer-at': 'off', - 'unicorn/prefer-string-replace-all': 'off', - }, - overrides: [ - { - // Specific rules for bin files - files: ['**/bin/*.ts'], - rules: { - 'unicorn/filename-case': ['error', { - 'case': 'kebabCase' - }], - 'no-process-env': 'off', - 'unicorn/no-process-exit': 'off', - } - }, - { - // Specific rules for test files - files: ['**/test/**/*.ts'], - env: { - 'jest/globals': true, - }, - globals: { - 'spyOn': false, - 'fail': false, - }, - rules: { - 'mocha/no-synchronous-tests': 'off', - 'mocha/valid-test-description': 'off', - 'mocha/no-sibling-hooks': 'off', - - 'max-statements-per-line': 'off', - 'id-length': 'off', - 'arrow-body-style': 'off', - 'line-comment-position': 'off', - 'no-inline-comments': 'off', - 'unicorn/filename-case': 'off', - 'no-new': 'off', - 'unicorn/no-nested-ternary': 'off', - 'no-return-assign': 'off', - 'no-useless-call': 'off', - 'no-sync': 'off', - - '@typescript-eslint/brace-style': 'off', - '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/ban-ts-ignore': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/unbound-method': 'off', - '@typescript-eslint/no-extra-parens': 'off', - '@typescript-eslint/restrict-plus-operands': 'off', - 'import/no-extraneous-dependencies': 'off', - } - } - ], -}; diff --git a/README.md b/README.md index 0db16006..2068470a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@

-This is a monorepo that builds upon the core comunica packages to allow for incremental query evaluation. +This is a monorepo that builds upon the core comunica packages to allow for incremental query evaluation. ## Querying with Incremunica diff --git a/engines/config-query-sparql-incremental/config/query-source-identify-hypermedia/actors.json b/engines/config-query-sparql-incremental/config/query-source-identify-hypermedia/actors.json index f7afd9d0..b2ffd0e0 100644 --- a/engines/config-query-sparql-incremental/config/query-source-identify-hypermedia/actors.json +++ b/engines/config-query-sparql-incremental/config/query-source-identify-hypermedia/actors.json @@ -10,7 +10,7 @@ { "@id": "urn:comunica:default:query-source-identify-hypermedia/actors#stream-none", "@type": "ActorQuerySourceIdentifyHypermediaStreamNone", - "mediatorGuard": { "@id": "urn:comunica:default:guard/mediators#main" }, + "mediatorGuard": { "@id": "urn:comunica:default:guard/mediators#main" }, "mediatorMergeBindingsContext": { "@id": "urn:comunica:default:merge-bindings-context/mediators#main" } } ] diff --git a/engines/config-query-sparql-incremental/config/rdf-metadata-extract/actors.json b/engines/config-query-sparql-incremental/config/rdf-metadata-extract/actors.json index ac21a4a8..9efba124 100644 --- a/engines/config-query-sparql-incremental/config/rdf-metadata-extract/actors.json +++ b/engines/config-query-sparql-incremental/config/rdf-metadata-extract/actors.json @@ -9,7 +9,7 @@ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-request-time/^3.0.0/components/context.jsonld", "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-allow-http-methods/^3.0.0/components/context.jsonld", "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-put-accepted/^3.0.0/components/context.jsonld", - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-patch-sparql-update/^3.0.0/components/context.jsonld", + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-patch-sparql-update/^3.0.0/components/context.jsonld" ], "@id": "urn:comunica:default:Runner", "@type": "Runner", diff --git a/engines/config-query-sparql-incremental/lib/index.ts b/engines/config-query-sparql-incremental/lib/index.ts index d15de7d9..e69de29b 100644 --- a/engines/config-query-sparql-incremental/lib/index.ts +++ b/engines/config-query-sparql-incremental/lib/index.ts @@ -1 +0,0 @@ -/* eslint-disable */ diff --git a/engines/config-query-sparql-incremental/package.json b/engines/config-query-sparql-incremental/package.json index 831dc8bb..ae0085d1 100644 --- a/engines/config-query-sparql-incremental/package.json +++ b/engines/config-query-sparql-incremental/package.json @@ -3,17 +3,16 @@ "version": "1.3.0", "description": "default configuration files for Comunica SPARQL Incremental", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica", "directory": "engines/config-query-sparql-incremental" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "sparql", @@ -23,11 +22,12 @@ "config", "incremental" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "config", diff --git a/engines/query-sparql-incremental/bin/http.ts b/engines/query-sparql-incremental/bin/http.ts deleted file mode 100644 index 49380f1e..00000000 --- a/engines/query-sparql-incremental/bin/http.ts +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env node -import { HttpServiceSparqlEndpoint } from '@comunica/actor-init-query'; - -const defaultConfigPath = `${__dirname}/../config/config-default.json`; - -HttpServiceSparqlEndpoint.runArgsInProcess(process.argv.slice(2), process.stdout, process.stderr, `${__dirname}/../`, process.env, defaultConfigPath, code => process.exit(code)) - .catch(error => process.stderr.write(`${error.message}/n`)); diff --git a/engines/query-sparql-incremental/bin/query-dynamic.ts b/engines/query-sparql-incremental/bin/query-dynamic.ts index 3290a83e..82815e38 100644 --- a/engines/query-sparql-incremental/bin/query-dynamic.ts +++ b/engines/query-sparql-incremental/bin/query-dynamic.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node import { runArgsInProcess } from '@comunica/runner-cli'; +// eslint-disable-next-line node/no-path-concat runArgsInProcess(`${__dirname}/../`, `${__dirname}/../config/config-default.json`); diff --git a/engines/query-sparql-incremental/bin/query.ts b/engines/query-sparql-incremental/bin/query.ts index 64147a19..a7fe01ed 100644 --- a/engines/query-sparql-incremental/bin/query.ts +++ b/engines/query-sparql-incremental/bin/query.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -/* eslint-disable */ import { runArgsInProcessStatic } from '@comunica/runner-cli'; +// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions runArgsInProcessStatic(require('../engine-default.js')); diff --git a/engines/query-sparql-incremental/lib/QueryEngine.ts b/engines/query-sparql-incremental/lib/QueryEngine.ts index 46597978..05220cc3 100644 --- a/engines/query-sparql-incremental/lib/QueryEngine.ts +++ b/engines/query-sparql-incremental/lib/QueryEngine.ts @@ -2,6 +2,7 @@ import { QueryEngineBase } from '@comunica/actor-init-query'; import type { ActorInitQueryBase } from '@comunica/actor-init-query'; import type { IQueryContextCommon } from '@comunica/types'; +// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions const engineDefault = require('../engine-default.js'); /** diff --git a/engines/query-sparql-incremental/lib/QueryEngineFactory.ts b/engines/query-sparql-incremental/lib/QueryEngineFactory.ts index d8b1a304..5365a0b6 100644 --- a/engines/query-sparql-incremental/lib/QueryEngineFactory.ts +++ b/engines/query-sparql-incremental/lib/QueryEngineFactory.ts @@ -1,3 +1,4 @@ +/* eslint-disable node/no-path-concat */ import { QueryEngineFactoryBase } from '@comunica/actor-init-query'; import { QueryEngine } from './QueryEngine'; diff --git a/engines/query-sparql-incremental/package.json b/engines/query-sparql-incremental/package.json index e63fed66..62b12c87 100644 --- a/engines/query-sparql-incremental/package.json +++ b/engines/query-sparql-incremental/package.json @@ -2,17 +2,16 @@ "name": "@incremunica/query-sparql-incremental", "version": "1.3.0", "description": "A SPARQL query engine for incremental querying over decentralized RDF knowledge graphs on the Web", - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "engines/query-sparql-incremental" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "sparql", @@ -24,27 +23,44 @@ "sparql update", "sparql 1.1" ], - "license": "MIT", + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" + }, "bin": { "comunica-sparql-incremental": "bin/query.js", "comunica-sparql-http-incremental": "bin/http.js", "comunica-dynamic-sparql-incremental": "bin/query-dynamic.js" }, - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" - }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ + "bin/**/*.d.ts", + "bin/**/*.js", "components", "config", + "engine-default.js", "lib/**/*.d.ts", - "lib/**/*.js", - "bin/**/*.d.ts", - "bin/**/*.js", - "engine-default.js" + "lib/**/*.js" ], - "devDependencies": { - "arrayify-stream": "^2.0.1" + "scripts": { + "build": "npm run build:ts", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "prepare": "comunica-compile-config config/config-default.json > engine-default.js", + "browser": "npm run prepare && \"../../node_modules/webpack/bin/webpack.js\" --config webpack.config.js --mode production", + "browser-profile": "\"../../node_modules/webpack/bin/webpack.js\" --config webpack.config.js --profile --mode production --json > stats.json && webpack-bundle-analyzer stats.json && rm stats.json", + "spec:base": "node ../../node_modules/rdf-test-suite/bin/Runner.js spec/sparql-engine.js http://w3c.github.io/rdf-tests/sparql11/data-sparql11/manifest-all.ttl -c ../../.rdf-test-suite-cache/", + "spec:query": "yarn run spec:base -s http://www.w3.org/TR/sparql11-query/", + "spec:update": "yarn run spec:base -s http://www.w3.org/TR/sparql11-update/ -e", + "spec:csv-tsv": "yarn run spec:base -s http://www.w3.org/TR/sparql11-results-csv-tsv/", + "spec:json": "yarn run spec:base -s http://www.w3.org/TR/sparql11-results-json/", + "spec:fed": "yarn run spec:base -s http://www.w3.org/TR/sparql11-federated-query/", + "spec:sd": "yarn run spec:base -s http://www.w3.org/TR/sparql11-service-description/", + "spec:prot": "yarn run spec:base -s http://www.w3.org/TR/sparql11-protocol/", + "spec:graphstore": "yarn run spec:base -s http://www.w3.org/TR/sparql11-http-rdf-update/", + "spec": "yarn run spec:query && yarn run spec:update", + "spec-earl": "yarn run spec:query -o earl -p spec/earl-meta.json > earl.ttl", + "integration": "rdf-test-suite-ldf spec/sparql-engine.js https://comunica.github.io/manifest-ldf-tests/next/sparql/sparql-manifest.ttl -d 200000 -c ../../.rdf-test-suite-ldf-cache/" }, "dependencies": { "@comunica/actor-context-preprocess-convert-shortcuts": "^3.2.1", @@ -157,6 +173,7 @@ "@comunica/actor-rdf-serialize-shaclc": "^3.2.1", "@comunica/bus-http-invalidate": "^3.2.1", "@comunica/bus-query-operation": "^3.2.2", + "@comunica/config-query-sparql": "^3.2.1", "@comunica/core": "^3.2.1", "@comunica/logger-void": "^3.2.1", "@comunica/mediator-all": "^3.2.1", @@ -168,9 +185,7 @@ "@comunica/runner": "^3.2.1", "@comunica/runner-cli": "^3.2.1", "@comunica/types": "^3.2.1", - "@comunica/config-query-sparql": "^3.2.1", - "@incremunica/config-query-sparql-incremental": "^1.3.0", "@incremunica/actor-guard-naive": "^1.3.0", "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/actor-query-operation-incremental-distinct-hash": "^1.3.0", @@ -185,30 +200,21 @@ "@incremunica/actor-resource-watch-solid-notification-websockets": "^1.3.0", "@incremunica/bus-guard": "^1.3.0", "@incremunica/bus-resource-watch": "^1.3.0", + "@incremunica/config-query-sparql-incremental": "^1.3.0", "@incremunica/context-entries": "^1.3.0", "@incremunica/hash-bindings": "^1.3.0", "@incremunica/incremental-inner-join": "^1.3.0", "@incremunica/incremental-rdf-streaming-store": "^1.3.0", "@incremunica/incremental-types": "^1.3.0" }, - "scripts": { - "build": "npm run build:ts", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "prepare": "comunica-compile-config config/config-default.json > engine-default.js", - "browser": "npm run prepare && \"../../node_modules/webpack/bin/webpack.js\" --config webpack.config.js --mode production", - "browser-profile": "\"../../node_modules/webpack/bin/webpack.js\" --config webpack.config.js --profile --mode production --json > stats.json && webpack-bundle-analyzer stats.json && rm stats.json", - "spec:base": "node ../../node_modules/rdf-test-suite/bin/Runner.js spec/sparql-engine.js http://w3c.github.io/rdf-tests/sparql11/data-sparql11/manifest-all.ttl -c ../../.rdf-test-suite-cache/", - "spec:query": "yarn run spec:base -s http://www.w3.org/TR/sparql11-query/", - "spec:update": "yarn run spec:base -s http://www.w3.org/TR/sparql11-update/ -e", - "spec:csv-tsv": "yarn run spec:base -s http://www.w3.org/TR/sparql11-results-csv-tsv/", - "spec:json": "yarn run spec:base -s http://www.w3.org/TR/sparql11-results-json/", - "spec:fed": "yarn run spec:base -s http://www.w3.org/TR/sparql11-federated-query/", - "spec:sd": "yarn run spec:base -s http://www.w3.org/TR/sparql11-service-description/", - "spec:prot": "yarn run spec:base -s http://www.w3.org/TR/sparql11-protocol/", - "spec:graphstore": "yarn run spec:base -s http://www.w3.org/TR/sparql11-http-rdf-update/", - "spec": "yarn run spec:query && yarn run spec:update", - "spec-earl": "yarn run spec:query -o earl -p spec/earl-meta.json > earl.ttl", - "integration": "rdf-test-suite-ldf spec/sparql-engine.js https://comunica.github.io/manifest-ldf-tests/next/sparql/sparql-manifest.ttl -d 200000 -c ../../.rdf-test-suite-ldf-cache/" + "devDependencies": { + "@incremunica/dev-tools": "^1.3.0", + "@incremunica/incremental-jest": "^1.3.0", + "@playwright/test": "^1.47.2", + "arrayify-stream": "^2.0.1", + "jest-rdf": "^1.7.1", + "rdf-data-factory": "^1.1.2", + "rdf-quad": "^1.5.0" }, "browser": { "./lib/index.js": "./lib/index-browser.js" diff --git a/engines/query-sparql-incremental/test-browser/QuerySparql-test.ts b/engines/query-sparql-incremental/test-browser/QuerySparql-test.ts index ae45de0e..1ff6df59 100644 --- a/engines/query-sparql-incremental/test-browser/QuerySparql-test.ts +++ b/engines/query-sparql-incremental/test-browser/QuerySparql-test.ts @@ -3,22 +3,22 @@ // Needed to undo automock from actor-http-native, cleaner workarounds do not appear to be working. import 'jest-rdf'; import '@incremunica/incremental-jest'; +import type { EventEmitter } from 'node:events'; +import type { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsStream, QueryStringContext } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { Quad } from '@incremunica/incremental-types'; +import { expect } from '@playwright/test'; import { DataFactory } from 'rdf-data-factory'; -import type { BindingsStream, QueryStringContext} from '@comunica/types'; -import {Factory} from 'sparqlalgebrajs'; -import {QueryEngine} from '../lib/QueryEngine'; -import {usePolly} from '../test/util'; -import {EventEmitter} from "events"; -import {StreamingStore} from "@incremunica/incremental-rdf-streaming-store"; -import {Quad} from "@incremunica/incremental-types"; -import {BindingsFactory} from "@comunica/bindings-factory"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; +import { QueryEngine } from '../lib/QueryEngine'; +import { usePolly } from '../test/util'; async function partialArrayifyStream(stream: EventEmitter, num: number): Promise { - let array: any[] = []; + const array: any[] = []; for (let i = 0; i < num; i++) { - await new Promise((resolve) => stream.once("data", (bindings: any) => { + await new Promise(resolve => stream.once('data', (bindings: any) => { array.push(bindings); resolve(); })); @@ -38,107 +38,107 @@ describe('System test: QuerySparql (without polly)', () => { let BF: BindingsFactory; let engine: QueryEngine; - beforeEach(async () => { + beforeEach(async() => { engine = new QueryEngine(); BF = await DevTools.createBindingsFactory(DF); }); - describe("using Streaming Store", () => { + describe('using Streaming Store', () => { let streamingStore: StreamingStore; - beforeEach(async () => { + beforeEach(async() => { streamingStore = new StreamingStore(); - }) + }); - it('simple query', async () => { - streamingStore.addQuad(quad("s1", "p1", "o1")); - streamingStore.addQuad(quad("s2", "p2", "o2")); + it('simple query', async() => { + streamingStore.addQuad(quad('s1', 'p1', 'o1')); + streamingStore.addQuad(quad('s2', 'p2', 'o2')); - let bindingStream = await engine.queryBindings(`SELECT * WHERE { + const bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { - sources: [streamingStore] + sources: [ streamingStore ], }); expect(await partialArrayifyStream(bindingStream, 2)).toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s1')], - [DF.variable('p'), DF.namedNode('p1')], - [DF.variable('o'), DF.namedNode('o1')], + [ DF.variable('s'), DF.namedNode('s1') ], + [ DF.variable('p'), DF.namedNode('p1') ], + [ DF.variable('o'), DF.namedNode('o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('s'), DF.namedNode('s2')], - [DF.variable('p'), DF.namedNode('p2')], - [DF.variable('o'), DF.namedNode('o2')], + [ DF.variable('s'), DF.namedNode('s2') ], + [ DF.variable('p'), DF.namedNode('p2') ], + [ DF.variable('o'), DF.namedNode('o2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - streamingStore.addQuad(quad("s3", "p3", "o3")); + streamingStore.addQuad(quad('s3', 'p3', 'o3')); expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s3')], - [DF.variable('p'), DF.namedNode('p3')], - [DF.variable('o'), DF.namedNode('o3')], - ]) + [ DF.variable('s'), DF.namedNode('s3') ], + [ DF.variable('p'), DF.namedNode('p3') ], + [ DF.variable('o'), DF.namedNode('o3') ], + ]), ]); - streamingStore.removeQuad(quad("s3", "p3", "o3")); + streamingStore.removeQuad(quad('s3', 'p3', 'o3')); expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s3')], - [DF.variable('p'), DF.namedNode('p3')], - [DF.variable('o'), DF.namedNode('o3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('s'), DF.namedNode('s3') ], + [ DF.variable('p'), DF.namedNode('p3') ], + [ DF.variable('o'), DF.namedNode('o3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); streamingStore.end(); }); - it('query with joins', async () => { - streamingStore.addQuad(quad("s1", "p1", "o1")); - streamingStore.addQuad(quad("o1", "p2", "o2")); + it('query with joins', async() => { + streamingStore.addQuad(quad('s1', 'p1', 'o1')); + streamingStore.addQuad(quad('o1', 'p2', 'o2')); - let bindingStream = await engine.queryBindings(`SELECT * WHERE { + const bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s1 ?p1 ?o1. ?o1 ?p2 ?o2. }`, { - sources: [streamingStore] + sources: [ streamingStore ], }); expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s1'), DF.namedNode('s1')], - [DF.variable('p1'), DF.namedNode('p1')], - [DF.variable('o1'), DF.namedNode('o1')], - [DF.variable('p2'), DF.namedNode('p2')], - [DF.variable('o2'), DF.namedNode('o2')], + [ DF.variable('s1'), DF.namedNode('s1') ], + [ DF.variable('p1'), DF.namedNode('p1') ], + [ DF.variable('o1'), DF.namedNode('o1') ], + [ DF.variable('p2'), DF.namedNode('p2') ], + [ DF.variable('o2'), DF.namedNode('o2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - streamingStore.addQuad(quad("o1", "p3", "o3")); + streamingStore.addQuad(quad('o1', 'p3', 'o3')); expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s1'), DF.namedNode('s1')], - [DF.variable('p1'), DF.namedNode('p1')], - [DF.variable('o1'), DF.namedNode('o1')], - [DF.variable('p2'), DF.namedNode('p3')], - [DF.variable('o2'), DF.namedNode('o3')], - ]) + [ DF.variable('s1'), DF.namedNode('s1') ], + [ DF.variable('p1'), DF.namedNode('p1') ], + [ DF.variable('o1'), DF.namedNode('o1') ], + [ DF.variable('p2'), DF.namedNode('p3') ], + [ DF.variable('o2'), DF.namedNode('o3') ], + ]), ]); - streamingStore.removeQuad(quad("o1", "p3", "o3")); + streamingStore.removeQuad(quad('o1', 'p3', 'o3')); expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s1'), DF.namedNode('s1')], - [DF.variable('p1'), DF.namedNode('p1')], - [DF.variable('o1'), DF.namedNode('o1')], - [DF.variable('p2'), DF.namedNode('p3')], - [DF.variable('o2'), DF.namedNode('o3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('s1'), DF.namedNode('s1') ], + [ DF.variable('p1'), DF.namedNode('p1') ], + [ DF.variable('o1'), DF.namedNode('o1') ], + [ DF.variable('p2'), DF.namedNode('p3') ], + [ DF.variable('o2'), DF.namedNode('o3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); streamingStore.end(); @@ -151,30 +151,22 @@ describe('System test: QuerySparql (with polly)', () => { let bindingStream: BindingsStream; let engine: QueryEngine; - beforeEach(() => { + beforeEach(async() => { engine = new QueryEngine(); - engine.invalidateHttpCache(); + await engine.invalidateHttpCache(); }); afterEach(() => { bindingStream.destroy(); - }) + }); describe('simple SPO on a raw RDF document', () => { it('with results', async() => { bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - let count = 0; - - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); }); it('repeated with the same engine', async() => { @@ -183,71 +175,23 @@ describe('System test: QuerySparql (with polly)', () => { }`; const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]}; - let count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); - - count = 0; + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); + bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); - - count = 0; + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); + bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); - - count = 0; + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); + bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); - - count = 0; + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); + bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); - - count = 0; + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); + bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); }); it('repeated with the same engine and wait a bit until the polling is removed', async() => { @@ -256,29 +200,13 @@ describe('System test: QuerySparql (with polly)', () => { }`; const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]}; - let count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); - - await new Promise((resolve) => setTimeout(()=>resolve(),10000)); - - count = 0; + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); + + await new Promise(resolve => setTimeout(() => resolve(), 10000)); + bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); }); describe('simple SPS', () => { @@ -287,11 +215,7 @@ describe('System test: QuerySparql (with polly)', () => { ?s ?p ?s. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - await new Promise((resolve) => bindingStream.on("data", async () => { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - })); + expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0); }); }); @@ -302,15 +226,7 @@ describe('System test: QuerySparql (with polly)', () => { ?v0 ?name. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - let count = 0; - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 20) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20); }); it('for the single source entry', async() => { @@ -319,37 +235,21 @@ describe('System test: QuerySparql (with polly)', () => { ?v0 ?name. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - let count = 0; - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 20) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20); }); describe('SHACL Compact Syntax Serialisation', () => { - it('handles the query with SHACL compact syntax as a source', async () => { + it('handles the query with SHACL compact syntax as a source', async() => { bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s a . }`, { sources: [ 'https://raw.githubusercontent.com/w3c/data-shapes/gh-pages/shacl-compact-syntax/' + 'tests/valid/basic-shape-iri.shaclc', - ] + ], }); - let count = 0; - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 0) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0); }); }); }); diff --git a/engines/query-sparql-incremental/test-browser/util-browser.js b/engines/query-sparql-incremental/test-browser/util-browser.js index fc493c8d..68363de3 100644 --- a/engines/query-sparql-incremental/test-browser/util-browser.js +++ b/engines/query-sparql-incremental/test-browser/util-browser.js @@ -1,3 +1,3 @@ export function usePolly() { - // No-op + // No-op } diff --git a/engines/query-sparql-incremental/test/QuerySparql-test.ts b/engines/query-sparql-incremental/test/QuerySparql-test.ts index d550222d..f4301dbc 100644 --- a/engines/query-sparql-incremental/test/QuerySparql-test.ts +++ b/engines/query-sparql-incremental/test/QuerySparql-test.ts @@ -3,22 +3,23 @@ // Needed to undo automock from actor-http-native, cleaner workarounds do not appear to be working. import 'jest-rdf'; import '@incremunica/incremental-jest'; +import type { EventEmitter } from 'node:events'; +import * as http from 'node:http'; +import type { BindingsFactory } from '@comunica/bindings-factory'; +import type { Bindings, BindingsStream, QueryStringContext } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { Quad } from '@incremunica/incremental-types'; +import { expect } from '@playwright/test'; import { DataFactory } from 'rdf-data-factory'; -import type {Bindings, BindingsStream, QueryStringContext} from '@comunica/types'; -import {QueryEngine} from '../lib/QueryEngine'; -import {usePolly} from './util'; -import {EventEmitter} from "events"; -import * as http from "http"; -import {StreamingStore} from "@incremunica/incremental-rdf-streaming-store"; -import {Quad} from "@incremunica/incremental-types"; -import {BindingsFactory} from "@comunica/bindings-factory"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; +import { QueryEngine } from '../lib/QueryEngine'; +import { usePolly } from './util'; async function partialArrayifyStream(stream: EventEmitter, num: number): Promise { - let array: any[] = []; + const array: any[] = []; for (let i = 0; i < num; i++) { - await new Promise((resolve) => stream.once("data", (bindings: any) => { + await new Promise(resolve => stream.once('data', (bindings: any) => { array.push(bindings); resolve(); })); @@ -38,107 +39,107 @@ describe('System test: QuerySparql (without polly)', () => { let BF: BindingsFactory; let engine: QueryEngine; - beforeEach(async () => { + beforeEach(async() => { engine = new QueryEngine(); BF = await DevTools.createBindingsFactory(DF); }); - describe("using Streaming Store", () => { + describe('using Streaming Store', () => { let streamingStore: StreamingStore; - beforeEach(async () => { + beforeEach(async() => { streamingStore = new StreamingStore(); - }) + }); - it('simple query', async () => { - streamingStore.addQuad(quad("s1", "p1", "o1")); - streamingStore.addQuad(quad("s2", "p2", "o2")); + it('simple query', async() => { + streamingStore.addQuad(quad('s1', 'p1', 'o1')); + streamingStore.addQuad(quad('s2', 'p2', 'o2')); - let bindingStream = await engine.queryBindings(`SELECT * WHERE { + const bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { - sources: [streamingStore] + sources: [ streamingStore ], }); - expect(await partialArrayifyStream(bindingStream, 2)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(bindingStream, 2)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s1')], - [DF.variable('p'), DF.namedNode('p1')], - [DF.variable('o'), DF.namedNode('o1')], + [ DF.variable('s'), DF.namedNode('s1') ], + [ DF.variable('p'), DF.namedNode('p1') ], + [ DF.variable('o'), DF.namedNode('o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('s'), DF.namedNode('s2')], - [DF.variable('p'), DF.namedNode('p2')], - [DF.variable('o'), DF.namedNode('o2')], + [ DF.variable('s'), DF.namedNode('s2') ], + [ DF.variable('p'), DF.namedNode('p2') ], + [ DF.variable('o'), DF.namedNode('o2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - streamingStore.addQuad(quad("s3", "p3", "o3")); + streamingStore.addQuad(quad('s3', 'p3', 'o3')); - expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(bindingStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s3')], - [DF.variable('p'), DF.namedNode('p3')], - [DF.variable('o'), DF.namedNode('o3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), true) + [ DF.variable('s'), DF.namedNode('s3') ], + [ DF.variable('p'), DF.namedNode('p3') ], + [ DF.variable('o'), DF.namedNode('o3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - streamingStore.removeQuad(quad("s3", "p3", "o3")); + streamingStore.removeQuad(quad('s3', 'p3', 'o3')); - expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(bindingStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s3')], - [DF.variable('p'), DF.namedNode('p3')], - [DF.variable('o'), DF.namedNode('o3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('s'), DF.namedNode('s3') ], + [ DF.variable('p'), DF.namedNode('p3') ], + [ DF.variable('o'), DF.namedNode('o3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); streamingStore.end(); }); - it('query with joins', async () => { - streamingStore.addQuad(quad("s1", "p1", "o1")); - streamingStore.addQuad(quad("o1", "p2", "o2")); + it('query with joins', async() => { + streamingStore.addQuad(quad('s1', 'p1', 'o1')); + streamingStore.addQuad(quad('o1', 'p2', 'o2')); - let bindingStream = await engine.queryBindings(`SELECT * WHERE { + const bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s1 ?p1 ?o1. ?o1 ?p2 ?o2. }`, { - sources: [streamingStore] + sources: [ streamingStore ], }); - expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(bindingStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s1'), DF.namedNode('s1')], - [DF.variable('p1'), DF.namedNode('p1')], - [DF.variable('o1'), DF.namedNode('o1')], - [DF.variable('p2'), DF.namedNode('p2')], - [DF.variable('o2'), DF.namedNode('o2')], + [ DF.variable('s1'), DF.namedNode('s1') ], + [ DF.variable('p1'), DF.namedNode('p1') ], + [ DF.variable('o1'), DF.namedNode('o1') ], + [ DF.variable('p2'), DF.namedNode('p2') ], + [ DF.variable('o2'), DF.namedNode('o2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - streamingStore.addQuad(quad("o1", "p3", "o3")); + streamingStore.addQuad(quad('o1', 'p3', 'o3')); - expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(bindingStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s1'), DF.namedNode('s1')], - [DF.variable('p1'), DF.namedNode('p1')], - [DF.variable('o1'), DF.namedNode('o1')], - [DF.variable('p2'), DF.namedNode('p3')], - [DF.variable('o2'), DF.namedNode('o3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), true) + [ DF.variable('s1'), DF.namedNode('s1') ], + [ DF.variable('p1'), DF.namedNode('p1') ], + [ DF.variable('o1'), DF.namedNode('o1') ], + [ DF.variable('p2'), DF.namedNode('p3') ], + [ DF.variable('o2'), DF.namedNode('o3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - streamingStore.removeQuad(quad("o1", "p3", "o3")); + streamingStore.removeQuad(quad('o1', 'p3', 'o3')); - expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(bindingStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s1'), DF.namedNode('s1')], - [DF.variable('p1'), DF.namedNode('p1')], - [DF.variable('o1'), DF.namedNode('o1')], - [DF.variable('p2'), DF.namedNode('p3')], - [DF.variable('o2'), DF.namedNode('o3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('s1'), DF.namedNode('s1') ], + [ DF.variable('p1'), DF.namedNode('p1') ], + [ DF.variable('o1'), DF.namedNode('o1') ], + [ DF.variable('p2'), DF.namedNode('p3') ], + [ DF.variable('o2'), DF.namedNode('o3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); streamingStore.end(); @@ -146,29 +147,29 @@ describe('System test: QuerySparql (without polly)', () => { }); describe('simple hypermedia queries', () => { - let fetchData = { - dataString: "", - etag: "0", - "cache-control": "max-age=2", - age: "1" - } + const fetchData = { + dataString: '', + etag: '0', + 'cache-control': 'max-age=2', + age: '1', + }; let server: http.Server; let bindingStream: BindingsStream; - beforeEach(async () => { + beforeEach(async() => { server = http.createServer((req, res) => { - if (req.method == "HEAD") { - res.writeHead(200, "OK", { - "etag": fetchData.etag, - "content-type": "text/turtle", - "cache-control": fetchData["cache-control"], - age: fetchData.age + if (req.method === 'HEAD') { + res.writeHead(200, 'OK', { + etag: fetchData.etag, + 'content-type': 'text/turtle', + 'cache-control': fetchData['cache-control'], + age: fetchData.age, }); } else { - res.setHeader("etag", fetchData.etag); - res.setHeader("content-type", "text/turtle"); - res.setHeader("cache-control", fetchData["cache-control"]); - res.setHeader("age", fetchData.age); + res.setHeader('etag', fetchData.etag); + res.setHeader('content-type', 'text/turtle'); + res.setHeader('cache-control', fetchData['cache-control']); + res.setHeader('age', fetchData.age); res.write(fetchData.dataString); } res.end(); @@ -179,121 +180,121 @@ describe('System test: QuerySparql (without polly)', () => { })); }); - afterEach(async () => { + afterEach(async() => { bindingStream.destroy(); await new Promise(resolve => server.close(() => { resolve(); })); await new Promise(resolve => setTimeout(() => resolve(), 500)); - }) + }); - it('simple query', async () => { - fetchData.dataString = " ."; - fetchData.etag = "0"; + it('simple query', async() => { + fetchData.dataString = ' .'; + fetchData.etag = '0'; bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { - sources: ['http://localhost:8787'] + sources: [ 'http://localhost:8787' ], }); - await expect(new Promise((resolve) => bindingStream.once("data", (bindings) => { + await expect(new Promise(resolve => bindingStream.once('data', (bindings) => { resolve(bindings); }))).resolves.toEqualBindings(BF.bindings([ - [DF.variable('s'), DF.namedNode('http://localhost:8787/s1')], - [DF.variable('p'), DF.namedNode('http://localhost:8787/p1')], - [DF.variable('o'), DF.namedNode('http://localhost:8787/o1')], + [ DF.variable('s'), DF.namedNode('http://localhost:8787/s1') ], + [ DF.variable('p'), DF.namedNode('http://localhost:8787/p1') ], + [ DF.variable('o'), DF.namedNode('http://localhost:8787/o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); }); - it('simple addition update query', async () => { - fetchData.dataString = " ."; - fetchData.etag = "0"; + it('simple addition update query', async() => { + fetchData.dataString = ' .'; + fetchData.etag = '0'; bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { - sources: ['http://localhost:8787'] + sources: [ 'http://localhost:8787' ], }); - await expect(new Promise((resolve) => bindingStream.once("data", (bindings) => { + await expect(new Promise(resolve => bindingStream.once('data', (bindings) => { resolve(bindings); }))).resolves.toEqualBindings(BF.bindings([ - [DF.variable('s'), DF.namedNode('http://localhost:8787/s1')], - [DF.variable('p'), DF.namedNode('http://localhost:8787/p1')], - [DF.variable('o'), DF.namedNode('http://localhost:8787/o1')], + [ DF.variable('s'), DF.namedNode('http://localhost:8787/s1') ], + [ DF.variable('p'), DF.namedNode('http://localhost:8787/p1') ], + [ DF.variable('o'), DF.namedNode('http://localhost:8787/o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); - fetchData.dataString += "\n ."; - fetchData.etag = "1"; + fetchData.dataString += '\n .'; + fetchData.etag = '1'; - await expect(new Promise((resolve) => bindingStream.once("data", (bindings) => { + await expect(new Promise(resolve => bindingStream.once('data', (bindings) => { resolve(bindings); }))).resolves.toEqualBindings(BF.bindings([ - [DF.variable('s'), DF.namedNode('http://localhost:8787/s2')], - [DF.variable('p'), DF.namedNode('http://localhost:8787/p2')], - [DF.variable('o'), DF.namedNode('http://localhost:8787/o2')], + [ DF.variable('s'), DF.namedNode('http://localhost:8787/s2') ], + [ DF.variable('p'), DF.namedNode('http://localhost:8787/p2') ], + [ DF.variable('o'), DF.namedNode('http://localhost:8787/o2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); }); - it('simple deletion update query', async () => { - fetchData.dataString = " ."; - fetchData.etag = "0"; + it('simple deletion update query', async() => { + fetchData.dataString = ' .'; + fetchData.etag = '0'; bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { - sources: ['http://localhost:8787'] + sources: [ 'http://localhost:8787' ], }); - await expect(new Promise((resolve) => bindingStream.once("data", (bindings) => { + await expect(new Promise(resolve => bindingStream.once('data', (bindings) => { resolve(bindings); }))).resolves.toEqualBindings(BF.bindings([ - [DF.variable('s'), DF.namedNode('http://localhost:8787/s1')], - [DF.variable('p'), DF.namedNode('http://localhost:8787/p1')], - [DF.variable('o'), DF.namedNode('http://localhost:8787/o1')], + [ DF.variable('s'), DF.namedNode('http://localhost:8787/s1') ], + [ DF.variable('p'), DF.namedNode('http://localhost:8787/p1') ], + [ DF.variable('o'), DF.namedNode('http://localhost:8787/o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); - fetchData.dataString = ""; - fetchData.etag = "1"; + fetchData.dataString = ''; + fetchData.etag = '1'; - await expect(new Promise((resolve) => bindingStream.once("data", (bindings) => { + await expect(new Promise(resolve => bindingStream.once('data', (bindings) => { resolve(bindings); }))).resolves.toEqualBindings(BF.bindings([ - [DF.variable('s'), DF.namedNode('http://localhost:8787/s1')], - [DF.variable('p'), DF.namedNode('http://localhost:8787/p1')], - [DF.variable('o'), DF.namedNode('http://localhost:8787/o1')], + [ DF.variable('s'), DF.namedNode('http://localhost:8787/s1') ], + [ DF.variable('p'), DF.namedNode('http://localhost:8787/p1') ], + [ DF.variable('o'), DF.namedNode('http://localhost:8787/o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false)); }); - /* - it('simple addition update query with optional', async () => { - fetchData.dataString = " ."; - fetchData.etag = "0"; - - bindingStream = await engine.queryBindings(`SELECT * WHERE { - ?s ?o . - OPTIONAL { ?s ?o . } - }`, { - sources: ['http://localhost:6565'] - }); - - await new Promise((resolve) => bindingStream.once("data", async (bindings) => { - console.log("s: ", bindings.get("s"), "p: ", bindings.get("p"), "o: ", bindings.get("o")); - expect(true).toEqual(true); - resolve(); - })); - - fetchData.dataString = " . ."; - fetchData.etag = "1"; - - await new Promise((resolve) => bindingStream.once("data", async (bindings) => { - console.log("s: ", bindings.get("s"), "p: ", bindings.get("p"), "o: ", bindings.get("o")); - expect(true).toEqual(true); - resolve(); - })); - }); - */ + // eslint-disable-next-line jest/no-commented-out-tests + // it('simple addition update query with optional', async () => { + // fetchData.dataString = " ."; + // fetchData.etag = "0"; + // + // bindingStream = await engine.queryBindings(`SELECT * WHERE { + // ?s ?o . + // OPTIONAL { ?s ?o . } + // }`, { + // sources: ['http://localhost:6565'] + // }); + // + // await new Promise((resolve) => bindingStream.once("data", async (bindings) => { + // console.log("s: ", bindings.get("s"), "p: ", bindings.get("p"), "o: ", bindings.get("o")); + // expect(true).toEqual(true); + // resolve(); + // })); + // + // fetchData.dataString = " . ."; + // fetchData.etag = "1"; + // + // await new Promise((resolve) => bindingStream.once("data", async (bindings) => { + // console.log("s: ", bindings.get("s"), "p: ", bindings.get("p"), "o: ", bindings.get("o")); + // expect(true).toEqual(true); + // resolve(); + // })); + // }); + // }); }); @@ -302,30 +303,22 @@ describe('System test: QuerySparql (with polly)', () => { let bindingStream: BindingsStream; let engine: QueryEngine; - beforeEach(() => { + beforeEach(async() => { engine = new QueryEngine(); - engine.invalidateHttpCache(); + await engine.invalidateHttpCache(); }); afterEach(() => { bindingStream.destroy(); - }) + }); describe('simple SPO on a raw RDF document', () => { it('with results', async() => { bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - let count = 0; - - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); }); it('repeated with the same engine', async() => { @@ -334,71 +327,23 @@ describe('System test: QuerySparql (with polly)', () => { }`; const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]}; - let count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); - count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); - count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); - count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); - count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); - count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); }); it('repeated with the same engine and wait a bit until the polling is removed', async() => { @@ -407,29 +352,13 @@ describe('System test: QuerySparql (with polly)', () => { }`; const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]}; - let count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); - await new Promise((resolve) => setTimeout(()=>resolve(),10000)); + await new Promise(resolve => setTimeout(() => resolve(), 10000)); - count = 0; bindingStream = await engine.queryBindings(query, context); - await new Promise(async (resolve) => bindingStream.on("data", async () => { - count++; - if (count > 100) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100); }); describe('simple SPS', () => { @@ -438,11 +367,7 @@ describe('System test: QuerySparql (with polly)', () => { ?s ?p ?s. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - await new Promise((resolve) => bindingStream.on("data", async () => { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - })); + expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0); }); }); @@ -453,15 +378,7 @@ describe('System test: QuerySparql (with polly)', () => { ?v0 ?name. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - let count = 0; - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 20) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20); }); it('for the single source entry', async() => { @@ -470,37 +387,21 @@ describe('System test: QuerySparql (with polly)', () => { ?v0 ?name. }`, { sources: [ 'https://www.rubensworks.net/' ]}); - let count = 0; - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 20) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20); }); describe('SHACL Compact Syntax Serialisation', () => { - it('handles the query with SHACL compact syntax as a source', async () => { + it('handles the query with SHACL compact syntax as a source', async() => { bindingStream = await engine.queryBindings(`SELECT * WHERE { ?s a . }`, { sources: [ 'https://raw.githubusercontent.com/w3c/data-shapes/gh-pages/shacl-compact-syntax/' + 'tests/valid/basic-shape-iri.shaclc', - ] + ], }); - let count = 0; - await new Promise((resolve) => bindingStream.on("data", async () => { - count++; - if (count > 0) { - expect(true).toEqual(true); - bindingStream.destroy(); - resolve(); - } - })); + expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0); }); }); }); diff --git a/engines/query-sparql-incremental/test/util.ts b/engines/query-sparql-incremental/test/util.ts index 4832d284..4a88a14f 100644 --- a/engines/query-sparql-incremental/test/util.ts +++ b/engines/query-sparql-incremental/test/util.ts @@ -1,4 +1,4 @@ -import { resolve } from 'path'; +import { resolve } from 'node:path'; import { Polly } from '@pollyjs/core'; import { setupPolly } from 'setup-polly-jest'; @@ -11,25 +11,23 @@ Polly.register(FSPersister); Polly.register(NodeHttpAdapter); // Configure everything related to PollyJS -// eslint-disable-next-line mocha/no-exports export function usePolly() { const pollyContext = mockHttp(); - // eslint-disable-next-line mocha/no-top-level-hooks + // eslint-disable-next-line jest/require-top-level-describe beforeEach(() => { pollyContext.polly.server.any().on('beforePersist', (req, recording) => { recording.request.headers = recording.request.headers.filter(({ name }: any) => name !== 'user-agent'); }); }); - // eslint-disable-next-line mocha/no-top-level-hooks + // eslint-disable-next-line jest/require-top-level-describe afterEach(async() => { await pollyContext.polly.flush(); }); } // Mocks HTTP requests using Polly.JS -// eslint-disable-next-line mocha/no-exports export function mockHttp() { return setupPolly({ adapters: [ NodeHttpAdapter ], diff --git a/engines/query-sparql-incremental/webpack.config.js b/engines/query-sparql-incremental/webpack.config.js index 3052f3bf..3e02c92b 100644 --- a/engines/query-sparql-incremental/webpack.config.js +++ b/engines/query-sparql-incremental/webpack.config.js @@ -1,5 +1,6 @@ -const path = require('path'); +const path = require('node:path'); const superConfig = require('@comunica/actor-init-query/webpack.config'); + superConfig.entry = [ '@babel/polyfill', path.resolve(__dirname, 'lib/index-browser.js') ]; superConfig.output.path = __dirname; module.exports = superConfig; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..d881d21d --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,96 @@ +const config = require('@rubensworks/eslint-config'); + +module.exports = config([ + { + files: [ '**/*.ts' ], + languageOptions: { + parserOptions: { + tsconfigRootDir: __dirname, + project: [ './tsconfig.eslint.json' ], + }, + }, + }, + { + rules: { + // Default + 'unicorn/consistent-destructuring': 'off', + 'unicorn/no-array-callback-reference': 'off', + + // TODO: check if these can be enabled + 'ts/naming-convention': 'off', + 'ts/no-unsafe-return': 'off', + 'ts/no-unsafe-argument': 'off', + 'ts/no-unsafe-assignment': 'off', + 'import/no-nodejs-modules': 'off', + + 'ts/no-require-imports': [ 'error', { allow: [ + 'process/', + 'web-streams-ponyfill', + 'is-stream', + 'readable-stream-node-to-web', + 'stream-to-string', + ]}], + 'ts/no-var-requires': [ 'error', { allow: [ + 'process/', + 'web-streams-ponyfill', + 'is-stream', + 'readable-stream-node-to-web', + 'stream-to-string', + ]}], + }, + }, + { + // Specific rules for NodeJS-specific files + files: [ + '**/test/**/*.ts', + '**/test-browser/*-test.ts', + ], + rules: { + 'import/no-nodejs-modules': 'off', + 'unused-imports/no-unused-vars': 'off', + 'ts/no-require-imports': 'off', + 'ts/no-var-requires': 'off', + 'unicorn/filename-case': 'off', + }, + }, + { + // The config packages use an empty index.ts + files: [ + 'engines/config-*/lib/index.ts', + ], + rules: { + 'import/unambiguous': 'off', + }, + }, + { + // Some test files import 'jest-rdf' which triggers this + // The http actors import 'cross-fetch/polyfill' which also triggers this + // Some jest tests import '../../lib' which triggers this + files: [ + '**/test/*-test.ts', + '**/test-browser/*-test.ts', + ], + rules: { + 'import/no-unassigned-import': 'off', + }, + }, + { + // Files that do not require linting + ignores: [ + 'setup-jest.js', + '**/engine-default.js', + '.github/**', + 'lerna.json', + ], + }, + { + files: [ '**/*.js' ], + rules: { + 'ts/no-require-imports': 'off', + 'ts/no-var-requires': 'off', + 'import/no-nodejs-modules': 'off', + 'import/no-extraneous-dependencies': 'off', + 'import/extensions': 'off', + }, + }, +]); diff --git a/jest.config.js b/jest.config.js index 7ba0809e..3726f7b9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,26 +1,26 @@ module.exports = { transform: { - '^.+\\.ts$': 'ts-jest' + '^.+\\.ts$': [ 'ts-jest', { + isolatedModules: true, + }], }, testRegex: '/test/.*-test.ts$', moduleFileExtensions: [ 'ts', - 'js' + 'js', ], globals: { - 'ts-jest': { - // Enabling this can fix issues when using prereleases of typings packages - //isolatedModules: true + window: { + location: new URL('http://localhost'), }, }, setupFilesAfterEnv: [ './setup-jest.js' ], collectCoverage: true, coveragePathIgnorePatterns: [ '/actor-query-operation-incremental-filter/', - 'util.ts', '/node_modules/', '/mocks/', - 'index.js' + 'index.js', ], testEnvironment: 'node', coverageThreshold: { @@ -28,7 +28,7 @@ module.exports = { branches: 100, functions: 100, lines: 100, - statements: 100 - } - } + statements: 100, + }, + }, }; diff --git a/karma-setup.js b/karma-setup.js index 1e1318ee..8c7dd191 100644 --- a/karma-setup.js +++ b/karma-setup.js @@ -1,15 +1,13 @@ -import jest from "jest-mock"; -import expect from "expect"; - -//change timeout to 20 seconds -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; +import expect from 'expect'; +import jest from 'jest-mock'; // Add missing Jest functions window.test = window.it; -window.test.each = (inputs) => (testName, test) => - inputs.forEach((args) => window.it(testName, () => test(...args))); -window.test.todo = function () { - return undefined; +window.test.each = inputs => (testName, test) => { + for (const args of inputs) { + window.it(testName, () => test(...args)); + } }; +window.test.todo = function() {}; window.jest = jest; window.expect = expect; diff --git a/karma.config.js b/karma.config.js index fd79af18..24b27723 100644 --- a/karma.config.js +++ b/karma.config.js @@ -1,94 +1,96 @@ +const Path = require('node:path'); const NodePolyfillPlugin = require('node-polyfill-webpack-plugin'); const webpack = require('webpack'); -const Path = require('path'); const testFiles = [ - 'engines/query-sparql-incremental/test-browser/QuerySparql-test.ts', + 'engines/query-sparql-incremental/test-browser/QuerySparql-test.ts', ]; // Based on https://github.com/tom-sherman/blog/blob/main/posts/02-running-jest-tests-in-a-browser.md -module.exports = function (config) { - config.set({ - basePath: '', - plugins: [ - 'karma-webpack', - 'karma-jasmine', - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-sourcemap-loader', - 'karma-jasmine-html-reporter', - ], - frameworks: ['jasmine', 'webpack'], +module.exports = function(config) { + config.set({ + basePath: '', + plugins: [ + 'karma-webpack', + 'karma-jasmine', + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-sourcemap-loader', + 'karma-jasmine-html-reporter', + ], + frameworks: [ 'jasmine', 'webpack' ], + + files: [ './karma-setup.js', ...testFiles ], + client: { + args: [ '--grep', '/^(?!.*no browser).*$/' ], + }, + preprocessors: { + './karma-setup.js': [ 'webpack' ], + ...Object.fromEntries(testFiles.map(key => [ key, [ 'webpack', 'sourcemap' ]])), + }, - files: ['./karma-setup.js', ...testFiles], - client: { - args: ['--grep', '/^(?!.*no browser).*$/'], + webpack: { + mode: 'production', + devtool: 'inline-source-map', + resolve: { + alias: { + fs: false, + module: false, + [Path.resolve(__dirname, 'engines/query-sparql-incremental/test/util.js')]: Path.resolve(__dirname, 'engines/query-sparql-incremental/test-browser/util-browser.js'), + 'jest.unmock': false, }, - preprocessors: { - './karma-setup.js': ['webpack'], - ...Object.fromEntries(testFiles.map(key => [ key, ['webpack', 'sourcemap'] ])) + extensions: [ '.js', '.jsx', '.ts', '.tsx' ], + }, + module: { + rules: [ + { + test: /\.tsx?$/u, + loader: 'ts-loader', + exclude: /node_modules/u, + options: { transpileOnly: true }, + }, + ], + }, + plugins: [ + new NodePolyfillPlugin({ + additionalAliases: [ 'process' ], + }), + new webpack.DefinePlugin({ + 'process.stdout.isTTY': false, + }), + ], + ignoreWarnings: [ + { + module: /jest/u, }, - - webpack: { - mode: 'production', - devtool: 'inline-source-map', - resolve: { - alias: { - fs: false, - module: false, - [Path.resolve(__dirname, 'engines/query-sparql-incremental/test/util.js')]: Path.resolve(__dirname, 'engines/query-sparql-incremental/test-browser/util-browser.js'), - 'jest.unmock': false, - }, - extensions: ['.js', '.jsx', '.ts', '.tsx'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - exclude: /node_modules/, - options: { transpileOnly: true }, - }, - ], - }, - plugins: [ - new NodePolyfillPlugin(), - new webpack.DefinePlugin({ - 'process.stdout.isTTY': false, - }), - ], - ignoreWarnings: [ - { - module: /jest/, - }, - { - module: /karma-setup/, - }, - ], - stats: { - colors: true, - hash: false, - version: false, - timings: false, - assets: false, - chunks: false, - modules: false, - reasons: false, - children: false, - source: false, - errors: false, - errorDetails: false, - warnings: false, - publicPath: false, - }, - performance: { - hints: false, - } + { + module: /karma-setup/u, }, + ], + stats: { + colors: true, + hash: false, + version: false, + timings: false, + assets: false, + chunks: false, + modules: false, + reasons: false, + children: false, + source: false, + errors: false, + errorDetails: false, + warnings: false, + publicPath: false, + }, + performance: { + hints: false, + }, + }, - browsers: [ - 'ChromeHeadless', - 'FirefoxHeadless', - ], - }); + browsers: [ + 'ChromeHeadless', + 'FirefoxHeadless', + ], + }); }; diff --git a/lerna.js b/lerna.js deleted file mode 100644 index e4b13734..00000000 --- a/lerna.js +++ /dev/null @@ -1,139 +0,0 @@ -const {loadPackages, exec, iter} = require('lerna-script') -const checkDeps = require('depcheck') -const path = require('path'); -const { readFileSync, writeFileSync, readdirSync, readdir } = require('fs'); - -async function depInfo({ location, name }, log) { - const folders = readdirSync(location, { withFileTypes: true }); - - const { files } = JSON.parse(readFileSync(path.join(location, 'package.json'), 'utf8')); - let ignore = files ? folders.filter(elem => files.every(file => !file.startsWith(elem.name))) : folders; - ignore = ignore.map(x => x.isDirectory() ? `${x.name}/**` : x.name) - - const {dependencies, devDependencies, missing, using} = await checkDeps(location, { ignorePatterns: ignore }, val => val); - - return { - unusedDeps: [...dependencies, ...devDependencies].filter(elem => !Object.keys(using).includes(elem)), - missingDeps: Object.keys(missing), - allDeps: Object.keys(using), - } -} - -async function depfixTask(log) { - const packages = (await (log.packages || loadPackages())).filter(package => package.location.startsWith(path.join(__dirname, '/packages'))); - const resolutions = Object.keys(JSON.parse(readFileSync(path.join(__dirname, 'package.json'), 'utf8')).resolutions ?? {}); - - await iter.forEach(packages, { log })(async package => { - log.info(package.name) - - const { missingDeps, unusedDeps, allDeps } = await depInfo(package); - - if (allDeps.includes(package.name)) - log.error(' package is a dependency of itself') - - if (missingDeps.length > 0) { - try { - log.info(' add:', missingDeps.join(', ')) - await exec.command(package)(`yarn add ${missingDeps.join(' ')}`); - } catch (e) { - for (const dep of missingDeps) { - try { - await exec.command(package)(`yarn add ${dep}`); - } catch (e) { - log.error(' CANNOT ADD:', dep); - } - } - } - } - - if (unusedDeps.length > 0) { - try { - log.info(' remove:', unusedDeps.join(', ')) - await exec.command(package)(`yarn remove ${unusedDeps.join(' ')}`); - } catch (e) { - for (const dep of unusedDeps) { - try { - await exec.command(package)(`yarn remove ${dep}`); - } catch (e) { - log.error(' CANNOT REMOVE:', dep); - } - } - } - } - - // Now fix up any resolutions to use a star ("*") import - const packageJson = JSON.parse(readFileSync(path.join(package.location, 'package.json'), 'utf8')); - for (const dep of Object.keys(packageJson.dependencies ?? {})) { - if (resolutions.includes(dep) && packageJson.dependencies[dep] !== '*') { - log.info(' converting to \'*\' import for', dep) - packageJson.dependencies[dep] = '*'; - } - } - writeFileSync(path.join(package.location, 'package.json'), JSON.stringify(packageJson, null, 2) + '\n'); - }) -} - -async function depcheckTask(log) { - const packages = (await (log.packages || loadPackages())).filter(package => package.location.startsWith(path.join(__dirname, '/packages'))); - const resolutions = Object.keys(JSON.parse(readFileSync(path.join(__dirname, 'package.json'), 'utf8')).resolutions ?? {}); - - return iter.forEach(packages, { log })(async package => { - const { missingDeps, unusedDeps, allDeps } = await depInfo(package) - - if (missingDeps.length > 0) { - throw new Error(`Missing dependencies: ${missingDeps.join(', ')} from ${package.name}`); - } - - if (unusedDeps.length > 0) { - throw new Error(`Extra dependencies: ${unusedDeps.join(', ')} in ${package.name}`); - } - - if (allDeps.includes(package.name)) - throw new Error(`${package.name} is a dependency of itself`); - - - // Now check all resolutions use a star ("*") import - const packageJson = JSON.parse(readFileSync(path.join(package.location, 'package.json'), 'utf8')); - for (const dep of Object.keys(packageJson.dependencies ?? {})) { - if (resolutions.includes(dep) && packageJson.dependencies[dep] !== '*') { - throw new Error(`Resolution not using \'*\' import for ${dep} in ${package.name}`); - } - } - }) -} - -module.exports.depfixTask = depfixTask -module.exports.depcheckTask = depcheckTask - -const ncu = require('npm-check-updates'); -async function updateTask(log) { - const packages = (await (log.packages || loadPackages())).filter( - package => package.location.startsWith(path.join(__dirname, '/packages')) || - package.location.startsWith(path.join(__dirname, '/engines')) - ); - - await iter.forEach(packages, { log })(async package => { - const upgraded = await ncu.run({ - // Pass any cli option - packageFile: path.join(package.location, 'package.json'), - upgrade: true, - target: 'minor' - }); - log.info(package.name, upgraded); - }) -} - -async function updateTaskMajor(log) { - const packages = (await (log.packages || loadPackages())).filter(package => package.location.startsWith(path.join(__dirname, '/packages'))); - - await iter.forEach(packages, { log })(async package => { - const upgraded = await ncu.run({ - // Pass any cli option - packageFile: path.join(package.location, 'package.json'), - }); - log.info(package.name, upgraded); - }) -} - -module.exports.updateTask = updateTask -module.exports.updateTaskMajor = updateTaskMajor diff --git a/lerna.json b/lerna.json index 55493d57..26048f5b 100644 --- a/lerna.json +++ b/lerna.json @@ -22,7 +22,5 @@ "loglevel": "success", "registry": "https://registry.npmjs.org/", "npmClient": "yarn", - "npmClientArgs": [ - "--pure-lockfile" - ] + "lerna-script-tasks": "./node_modules/@comunica/utils-monorepo/lib/depCheck.js" } diff --git a/package.json b/package.json index 0a2898b8..999d9458 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,42 @@ "engines/*", "packages/*" ], + "scripts": { + "pre-commit": "yarn run build && yarn run lint-no-cache && yarn run depcheck && yarn run test-browser && yarn run test", + "test-changed": "lerna run test --since HEAD", + "build-changed": "lerna run build --since HEAD", + "test": "jest", + "test-ci": "jest --ci --maxWorkers=4 --coverage", + "test-browser": "karma start karma.config.js --single-run", + "lint": "eslint . --cache", + "lint-no-cache": "eslint .", + "lint-fix": "eslint . --fix", + "build": "npm run build-ts && npm run build-components", + "build-ts": "tsc", + "build-components": "componentsjs-generator engines/* packages/*", + "build-watch": "nodemon -e ts --ignore '*.d.ts' --exec yarn run build", + "build-watch:ts": "tsc --watch", + "build-watch:components": "nodemon -e d.ts --exec yarn run build:components", + "publish": "yarn install && yarn pre-commit && yarn publish-release", + "publish-release": "lerna publish", + "publish-bare": "lerna exec -- npm publish --silent", + "publish-canary": "yarn run build && lerna version prerelease --preid alpha.$(.github/get-next-alpha-version.sh) --exact --ignore-scripts --force-publish --no-push --no-git-tag-version --yes && git update-index --assume-unchanged $(git ls-files | tr '\\n' ' ') && lerna publish from-package --no-git-reset --pre-dist-tag next --force-publish --no-push --no-git-tag-version --yes && git update-index --no-assume-unchanged $(git ls-files | tr '\\n' ' ') && git checkout .", + "doc": "typedoc", + "postinstall": "yarn run build && lerna run prepare", + "version": "manual-git-changelog onversion", + "depcheck": "lerna-script depcheckTask", + "depcheck-fix": "lerna-script depfixTask" + }, "devDependencies": { - "rdf-terms": "^1.9.1", - "sparqlalgebrajs": "^4.0.5", "@babel/core": "^7.20.2", "@babel/preset-env": "^7.20.2", + "@comunica/jest": "3.2.1", + "@comunica/utils-monorepo": "^4.0.1", + "@playwright/test": "^1.47.2", "@pollyjs/adapter-node-http": "^6.0.5", "@pollyjs/core": "^6.0.5", "@pollyjs/persister-fs": "^6.0.5", + "@rubensworks/eslint-config": "^3.0.0", "@strictsoftware/typedoc-plugin-monorepo": "^0.4.2", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", @@ -20,8 +48,6 @@ "@types/readable-stream": "^4.0.0", "@types/setup-polly-jest": "^0.5.2", "@types/ws": "^8.5.10", - "@typescript-eslint/eslint-plugin": "5.62.0", - "@typescript-eslint/parser": "^5.43.0", "abort-controller": "^3.0.0", "arrayify-stream": "^2.0.1", "asynciterator": "^3.9.0", @@ -43,15 +69,17 @@ "lerna-script": "^1.4.0", "manual-git-changelog": "^1.0.2", "memory-streams": "^0.1.3", - "node-polyfill-webpack-plugin": "^3.0.0", + "node-polyfill-webpack-plugin": "^4.0.0", "nodemon": "^3.0.0", "npm-check-updates": "^16.4.1", "pre-commit": "^1.2.2", "rdf-data-factory": "^1.1.1", "rdf-quad": "^1.5.0", + "rdf-terms": "^1.9.1", "rdf-test-suite": "^1.19.3", "rdf-test-suite-ldf": "^1.4.2", "setup-polly-jest": "^0.11.0", + "sparqlalgebrajs": "^4.0.5", "stream-to-string": "^1.2.0", "streamify-array": "^1.0.1", "streamify-string": "^1.0.1", @@ -59,11 +87,9 @@ "ts-loader": "^9.4.1", "typedoc": "^0.25.0", "typescript": "^5.0.0", - "webpack": "^5.75.0", - "webpack-cli": "^5.0.0", - "ws": "^8.14.2", - "@comunica/jest": "3.2.1", - "@rubensworks/eslint-config": "^3.0.0" + "webpack": "^5.88.2", + "webpack-cli": "^5.1.4", + "ws": "^8.14.2" }, "pre-commit": [ "build", @@ -72,34 +98,7 @@ "test", "test-browser" ], - "scripts": { - "pre-commit": "yarn run build && yarn run lint-no-cache && yarn run depcheck && yarn run test-browser && yarn run test", - "test-changed": "lerna run test --since HEAD", - "build-changed": "lerna run build --since HEAD", - "test": "jest", - "test-ci": "jest --ci --maxWorkers=4 --coverage", - "test-browser": "karma start karma.config.js --single-run", - "lint": "eslint . --ext .ts --cache", - "lint-no-cache": "eslint . --ext .ts", - "lint-fix": "eslint . --ext .ts --fix", - "build": "npm run build-ts && npm run build-components", - "build-ts": "tsc", - "build-components": "componentsjs-generator engines/* packages/*", - "build-watch": "nodemon -e ts --ignore '*.d.ts' --exec yarn run build", - "build-watch:ts": "tsc --watch", - "build-watch:components": "nodemon -e d.ts --exec yarn run build:components", - "publish": "yarn install && yarn pre-commit && yarn publish-release", - "publish-release": "lerna publish", - "publish-bare": "lerna exec -- npm publish --silent", - "publish-canary": "yarn run build && lerna version prerelease --preid alpha.$(.github/get-next-alpha-version.sh) --exact --ignore-scripts --force-publish --no-push --no-git-tag-version --yes && git update-index --assume-unchanged $(git ls-files | tr '\\n' ' ') && lerna publish from-package --no-git-reset --pre-dist-tag next --force-publish --no-push --no-git-tag-version --yes && git update-index --no-assume-unchanged $(git ls-files | tr '\\n' ' ') && git checkout .", - "doc": "typedoc", - "postinstall": "yarn run build && lerna run prepare", - "version": "manual-git-changelog onversion", - "depcheck": "lerna-script depcheckTask", - "depcheck-fix": "lerna-script depfixTask" - }, "resolutions": { "@rdfjs/types": "1.1.0" - }, - "dependencies": {} + } } diff --git a/packages/actor-guard-naive/README.md b/packages/actor-guard-naive/README.md index 63eb2e0f..42768372 100644 --- a/packages/actor-guard-naive/README.md +++ b/packages/actor-guard-naive/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-guard-naive/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-guard-naive/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-guard-naive/lib/ActorGuardNaive.ts b/packages/actor-guard-naive/lib/ActorGuardNaive.ts index 98533789..a6471838 100644 --- a/packages/actor-guard-naive/lib/ActorGuardNaive.ts +++ b/packages/actor-guard-naive/lib/ActorGuardNaive.ts @@ -1,4 +1,4 @@ -import { EventEmitter } from 'events'; +import { EventEmitter } from 'node:events'; import type { MediatorDereferenceRdf } from '@comunica/bus-dereference-rdf'; import type { IActorTest } from '@comunica/core'; import type { IActionGuard, IActorGuardOutput, IActorGuardArgs } from '@incremunica/bus-guard'; @@ -17,7 +17,7 @@ export class ActorGuardNaive extends ActorGuard { super(args); } - public async test(action: IActionGuard): Promise { + public async test(_action: IActionGuard): Promise { return true; } @@ -40,31 +40,34 @@ export class ActorGuardNaive extends ActorGuard { resourceWatch.stopFunction(); }); - resourceWatch.events.on('update', async() => { + resourceWatch.events.on('update', () => { guardEvents.emit('modified'); const deletionStore = action.streamingSource.store.copyOfStore(); const additionArray: Quad[] = []; - const responseGet = await this.mediatorDereferenceRdf.mediate({ + this.mediatorDereferenceRdf.mediate({ context: action.context, url: action.url, - }); - - responseGet.data.on('data', quad => { - if (deletionStore.has(quad)) { - deletionStore.delete(quad); - return; - } - additionArray.push(quad); - }); + }).then((responseGet) => { + responseGet.data.on('data', (quad) => { + if (deletionStore.has(quad)) { + deletionStore.delete(quad); + return; + } + additionArray.push(quad); + }); - responseGet.data.on('end', () => { - for (const quad of deletionStore) { - action.streamingSource.store.removeQuad(quad); - } - for (const quad of additionArray) { - action.streamingSource.store.addQuad(quad); - } - guardEvents.emit('up-to-date'); + responseGet.data.on('end', () => { + for (const quad of deletionStore) { + action.streamingSource.store.removeQuad(quad); + } + for (const quad of additionArray) { + action.streamingSource.store.addQuad(quad); + } + guardEvents.emit('up-to-date'); + }); + }).catch((error) => { + // eslint-disable-next-line no-console + console.warn(error); }); }); diff --git a/packages/actor-guard-naive/package.json b/packages/actor-guard-naive/package.json index 03da74b4..9e665b87 100644 --- a/packages/actor-guard-naive/package.json +++ b/packages/actor-guard-naive/package.json @@ -3,43 +3,43 @@ "version": "1.3.0", "description": "A naive guard actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-guard-naive" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "guard", "naive" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { "@comunica/bus-dereference-rdf": "^3.2.1", "@comunica/core": "^3.2.1", "@incremunica/bus-guard": "^1.3.0", "@incremunica/bus-resource-watch": "^1.3.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-guard-naive/test/ActorGuardNaive-test.ts b/packages/actor-guard-naive/test/ActorGuardNaive-test.ts index 95ec8526..fff17836 100644 --- a/packages/actor-guard-naive/test/ActorGuardNaive-test.ts +++ b/packages/actor-guard-naive/test/ActorGuardNaive-test.ts @@ -1,12 +1,16 @@ -import {Bus} from '@comunica/core'; -import {IActionDereferenceRdf, MediatorDereferenceRdf} from "@comunica/bus-dereference-rdf"; -import {IActionGuard} from "@incremunica/bus-guard"; -import {Transform} from "readable-stream"; +import EventEmitter = require('events'); +import type { IActionDereferenceRdf, MediatorDereferenceRdf } from '@comunica/bus-dereference-rdf'; +import { Bus } from '@comunica/core'; +import type { IActionGuard } from '@incremunica/bus-guard'; +import type { + IActionResourceWatch, + IActorResourceWatchOutput, + MediatorResourceWatch, +} from '@incremunica/bus-resource-watch'; +import { Store, DataFactory } from 'n3'; +import type { Transform } from 'readable-stream'; import 'jest-rdf'; -import { Store, DataFactory} from "n3"; -import EventEmitter = require("events"); -import {ActorGuardNaive} from "../lib"; -import {IActionResourceWatch, IActorResourceWatchOutput, MediatorResourceWatch} from "@incremunica/bus-resource-watch"; +import { ActorGuardNaive } from '../lib'; const quad = require('rdf-quad'); const streamifyArray = require('streamify-array'); @@ -16,7 +20,9 @@ function captureEvents(item: EventEmitter, ...events: string[]) { const counts = (item)._eventCounts = Object.create(null); for (const event of events) { counts[event] = 0; - item.on(event, () => { counts[event]++; }); + item.on(event, () => { + counts[event]++; + }); } return item; } @@ -41,7 +47,7 @@ describe('ActorGuardNaive', () => { let addQuadFn = jest.fn(); let stopFn = jest.fn(); let onFn: () => void; - let hasEnded: {value: boolean}; + let hasEnded: { value: boolean }; beforeEach(() => { quadArray = []; @@ -51,35 +57,35 @@ describe('ActorGuardNaive', () => { removeQuadFn = jest.fn(); addQuadFn = jest.fn(); stopFn = jest.fn(); - hasEnded = {value: false}; + hasEnded = { value: false }; mediatorDereferenceRdf = { - mediate: async (action: IActionDereferenceRdf) => { + mediate: async(action: IActionDereferenceRdf) => { return { - data: streamifyArray(quadArray) + data: streamifyArray(quadArray), }; - } - } + }, + }; mediatorResourceWatch = { - mediate: async (action: IActionResourceWatch): Promise => { + mediate: async(action: IActionResourceWatch): Promise => { return { events: changeNotificationEventEmitter, - stopFunction: stopFn + stopFunction: stopFn, }; - } - } + }, + }; actor = new ActorGuardNaive({ name: 'actor', bus, mediatorResourceWatch, - mediatorDereferenceRdf + mediatorDereferenceRdf, }); action = { context: {}, - url: "www.test.com", + url: 'www.test.com', metadata: {}, streamingSource: { store: { @@ -90,7 +96,7 @@ describe('ActorGuardNaive', () => { return hasEnded.value; }, import: (stream: Transform) => { - streamingStoreEventEmitter.emit("data", stream); + streamingStoreEventEmitter.emit('data', stream); return stream; }, copyOfStore: () => { @@ -101,139 +107,130 @@ describe('ActorGuardNaive', () => { }, removeQuad: (quad: any) => removeQuadFn(quad), addQuad: (quad: any) => addQuadFn(quad), - } - } - } + }, + }, + }; }); - it('should test', () => { - return expect(actor.test(action)).resolves.toBeTruthy(); + it('should test', async() => { + await expect(actor.test(action)).resolves.toBeTruthy(); }); - it('should stop resource watcher if store stops', async () => { + it('should stop resource watcher if store stops', async() => { await actor.run(action); onFn(); - expect(stopFn).toHaveBeenCalled(); + expect(stopFn).toHaveBeenCalledWith(); }); - - it('should stop resource when the store has stopped really early', async () => { + it('should stop resource when the store has stopped really early', async() => { hasEnded.value = true; await actor.run(action); - expect(stopFn).toHaveBeenCalled(); + expect(stopFn).toHaveBeenCalledWith(); }); - it('should attach a positive changes stream', async () => { + it('should attach a positive changes stream', async() => { quadArrayStore = [ quad('s1', 'p1', 'o1'), - quad('s2', 'p2', 'o2') + quad('s2', 'p2', 'o2'), ]; - let {guardEvents} = await actor.run(action); + const { guardEvents } = await actor.run(action); captureEvents(guardEvents, 'modified', 'up-to-date'); - expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'update')).toEqual(1); - expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'delete')).toEqual(1); + expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'update')).toBe(1); + expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'delete')).toBe(1); quadArray = [ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), - quad('s3', 'p3', 'o3') + quad('s3', 'p3', 'o3'), ]; - changeNotificationEventEmitter.emit("update"); + changeNotificationEventEmitter.emit('update'); await new Promise(resolve => guardEvents.once('up-to-date', resolve)); - expect((guardEvents)._eventCounts.modified).toEqual(1); - expect((guardEvents)._eventCounts['up-to-date']).toEqual(1); + expect((guardEvents)._eventCounts.modified).toBe(1); + expect((guardEvents)._eventCounts['up-to-date']).toBe(1); expect(addQuadFn).toHaveBeenCalledTimes(1); expect(addQuadFn).toHaveBeenCalledWith(quad('s3', 'p3', 'o3')); }); - it('should attach a negative changes stream', async () => { + it('should attach a negative changes stream', async() => { quadArrayStore = [ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), - quad('s3', 'p3', 'o3') + quad('s3', 'p3', 'o3'), ]; - let {guardEvents} = await actor.run(action); + const { guardEvents } = await actor.run(action); captureEvents(guardEvents, 'modified', 'up-to-date'); - expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'update')).toEqual(1); - expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'delete')).toEqual(1); + expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'update')).toBe(1); + expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'delete')).toBe(1); quadArray = [ quad('s1', 'p1', 'o1'), - quad('s2', 'p2', 'o2') + quad('s2', 'p2', 'o2'), ]; - changeNotificationEventEmitter.emit("update"); + changeNotificationEventEmitter.emit('update'); await new Promise(resolve => guardEvents.once('up-to-date', resolve)); - expect((guardEvents)._eventCounts.modified).toEqual(1); - expect((guardEvents)._eventCounts['up-to-date']).toEqual(1); + expect((guardEvents)._eventCounts.modified).toBe(1); + expect((guardEvents)._eventCounts['up-to-date']).toBe(1); expect(removeQuadFn).toHaveBeenCalledTimes(1); expect(removeQuadFn).toHaveBeenCalledWith( DataFactory.quad( DataFactory.namedNode('s3'), DataFactory.namedNode('p3'), - DataFactory.namedNode('o3') - ) + DataFactory.namedNode('o3'), + ), ); }); - it('should handle delete events', async () => { + it('should handle delete events', async() => { quadArrayStore = [ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), - quad('s3', 'p3', 'o3') + quad('s3', 'p3', 'o3'), ]; - let {guardEvents} = await actor.run(action); + const { guardEvents } = await actor.run(action); captureEvents(guardEvents, 'modified', 'up-to-date'); - expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'update')).toEqual(1); - expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'delete')).toEqual(1); + expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'update')).toBe(1); + expect(EventEmitter.listenerCount(changeNotificationEventEmitter, 'delete')).toBe(1); - let updatePromise = new Promise(resolve => guardEvents.once('up-to-date', resolve)); + const updatePromise = new Promise(resolve => guardEvents.once('up-to-date', resolve)); - changeNotificationEventEmitter.emit("delete"); + changeNotificationEventEmitter.emit('delete'); await updatePromise; - expect((guardEvents)._eventCounts.modified).toEqual(1); - expect((guardEvents)._eventCounts['up-to-date']).toEqual(1); + expect((guardEvents)._eventCounts.modified).toBe(1); + expect((guardEvents)._eventCounts['up-to-date']).toBe(1); expect(removeQuadFn).toHaveBeenCalledTimes(3); - expect(removeQuadFn).toHaveBeenNthCalledWith(1, - DataFactory.quad( - DataFactory.namedNode('s1'), - DataFactory.namedNode('p1'), - DataFactory.namedNode('o1') - ) - ); - expect(removeQuadFn).toHaveBeenNthCalledWith(2, - DataFactory.quad( - DataFactory.namedNode('s2'), - DataFactory.namedNode('p2'), - DataFactory.namedNode('o2') - ) - ); - expect(removeQuadFn).toHaveBeenNthCalledWith(3, - DataFactory.quad( - DataFactory.namedNode('s3'), - DataFactory.namedNode('p3'), - DataFactory.namedNode('o3') - ) - ); + expect(removeQuadFn).toHaveBeenNthCalledWith(1, DataFactory.quad( + DataFactory.namedNode('s1'), + DataFactory.namedNode('p1'), + DataFactory.namedNode('o1'), + )); + expect(removeQuadFn).toHaveBeenNthCalledWith(2, DataFactory.quad( + DataFactory.namedNode('s2'), + DataFactory.namedNode('p2'), + DataFactory.namedNode('o2'), + )); + expect(removeQuadFn).toHaveBeenNthCalledWith(3, DataFactory.quad( + DataFactory.namedNode('s3'), + DataFactory.namedNode('p3'), + DataFactory.namedNode('o3'), + )); }); }); }); - - diff --git a/packages/actor-merge-bindings-context-is-addition/README.md b/packages/actor-merge-bindings-context-is-addition/README.md index 067d0a78..0a2c5dcf 100644 --- a/packages/actor-merge-bindings-context-is-addition/README.md +++ b/packages/actor-merge-bindings-context-is-addition/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-merge-bindings-context-is-addition/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-merge-bindings-context-is-addition/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-merge-bindings-context-is-addition/lib/ActorMergeBindingsContextIsAddition.ts b/packages/actor-merge-bindings-context-is-addition/lib/ActorMergeBindingsContextIsAddition.ts index 1ba6dd60..cc908bd1 100644 --- a/packages/actor-merge-bindings-context-is-addition/lib/ActorMergeBindingsContextIsAddition.ts +++ b/packages/actor-merge-bindings-context-is-addition/lib/ActorMergeBindingsContextIsAddition.ts @@ -1,16 +1,18 @@ -import type { IActorTest } from '@comunica/core'; +import type { + IActorMergeBindingsContextOutput, + IActorMergeBindingsContextArgs, + IActionMergeBindingsContext, +} from '@comunica/bus-merge-bindings-context'; import { ActorMergeBindingsContext, - IActorMergeBindingsContextOutput, - IActorMergeBindingsContextArgs, IActionMergeBindingsContext } from '@comunica/bus-merge-bindings-context'; +import type { IActorTest } from '@comunica/core'; import type { IActionContextKey } from '@comunica/types'; /** * A incremunica actor for the creation of merge handlers for binding context keys. */ export class ActorMergeBindingsContextIsAddition extends ActorMergeBindingsContext { - public constructor(args: IActorMergeBindingsContextArgs) { super(args); } @@ -20,18 +22,18 @@ export class ActorMergeBindingsContextIsAddition extends ActorMergeBindingsConte } public async run(_action: IActionMergeBindingsContext): Promise { - //TODO change to boolean[] => boolean when comuncia V4 + // TODO change to boolean[] => boolean when comuncia V4 const handlerFunc: (...args: any[]) => any = (...args: boolean[]): boolean => args.reduce((acc, cur) => acc && cur); return { mergeHandlers: { - "isAddition": { - run: handlerFunc - } - } + isAddition: { + run: handlerFunc, + }, + }, }; } } export class ActionContextKeyIsAddition implements IActionContextKey { - readonly name = 'isAddition'; + public readonly name = 'isAddition'; } diff --git a/packages/actor-merge-bindings-context-is-addition/package.json b/packages/actor-merge-bindings-context-is-addition/package.json index 8a24b87f..2a1e9f3f 100644 --- a/packages/actor-merge-bindings-context-is-addition/package.json +++ b/packages/actor-merge-bindings-context-is-addition/package.json @@ -3,40 +3,42 @@ "version": "1.3.0", "description": "An incremunica Merge Bindings Context actor that merges the isAddition attribute.", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-merge-bindings-context-is-addition" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "merge-bindings-context", "isAddition" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@comunica/bus-merge-bindings-context": "^3.2.0" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/bus-merge-bindings-context": "^3.2.0", + "@comunica/core": "^3.2.0", + "@comunica/types": "^3.2.0" } } diff --git a/packages/actor-merge-bindings-context-is-addition/test/ActorMergeBindingsContextIsAddition-test.ts b/packages/actor-merge-bindings-context-is-addition/test/ActorMergeBindingsContextIsAddition-test.ts index f343963a..c9669875 100644 --- a/packages/actor-merge-bindings-context-is-addition/test/ActorMergeBindingsContextIsAddition-test.ts +++ b/packages/actor-merge-bindings-context-is-addition/test/ActorMergeBindingsContextIsAddition-test.ts @@ -1,21 +1,21 @@ +import type { BindingsFactory } from '@comunica/bindings-factory'; import { ActionContext, Bus } from '@comunica/core'; import type { IActionContext } from '@comunica/types'; -import {ActionContextKeyIsAddition, ActorMergeBindingsContextIsAddition} from "../lib"; -import {DataFactory} from "rdf-data-factory"; -import {BindingsFactory} from "@comunica/bindings-factory"; +import { DevTools } from '@incremunica/dev-tools'; +import { DataFactory } from 'rdf-data-factory'; +import { ActionContextKeyIsAddition, ActorMergeBindingsContextIsAddition } from '../lib'; import '@incremunica/incremental-jest'; -import {DevTools} from "@incremunica/dev-tools"; -let DF = new DataFactory(); +const DF = new DataFactory(); describe('ActorMergeBindingsContextIsAddition', () => { let bus: any; let actor: ActorMergeBindingsContextIsAddition; let context: IActionContext; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); - actor = new ActorMergeBindingsContextIsAddition({name: 'actor', bus}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); + actor = new ActorMergeBindingsContextIsAddition({ name: 'actor', bus }); context = new ActionContext(); }); @@ -25,70 +25,70 @@ describe('ActorMergeBindingsContextIsAddition', () => { it('should run', async() => { await expect(actor.run({ context })).resolves.toMatchObject( - { mergeHandlers: { "isAddition": { run: expect.any(Function) } } }, + { mergeHandlers: { isAddition: { run: expect.any(Function) }}}, ); }); describe('merge handler', () => { - //TODO when comuncia V4 change to boolean[] => boolean + // TODO when comuncia V4 change to boolean[] => boolean let mergeHandler: (...args: any) => any; - beforeEach(async () => { - mergeHandler = (await actor.run({context})).mergeHandlers["isAddition"].run; + beforeEach(async() => { + mergeHandler = (await actor.run({ context })).mergeHandlers.isAddition.run; }); - it('should return false if the first is false', async () => { - const inputSets = [false, true]; - expect(mergeHandler(...inputSets)).toStrictEqual(false); + it('should return false if the first is false', async() => { + const inputSets = [ false, true ]; + expect(mergeHandler(...inputSets)).toBe(false); }); - it('should return false if the second is false', async () => { - const inputSets = [true, false]; - expect(mergeHandler(...inputSets)).toStrictEqual(false); + it('should return false if the second is false', async() => { + const inputSets = [ true, false ]; + expect(mergeHandler(...inputSets)).toBe(false); }); - it('should return false if both are false', async () => { - const inputSets = [false, false]; - expect(mergeHandler(...inputSets)).toStrictEqual(false); + it('should return false if both are false', async() => { + const inputSets = [ false, false ]; + expect(mergeHandler(...inputSets)).toBe(false); }); - it('should return true if both are true', async () => { - const inputSets = [true, true]; - expect(mergeHandler(...inputSets)).toStrictEqual(true); + it('should return true if both are true', async() => { + const inputSets = [ true, true ]; + expect(mergeHandler(...inputSets)).toBe(true); }); - it('should work with multiple values', async () => { - const inputSets = [true, true, false, true]; - expect(mergeHandler(...inputSets)).toStrictEqual(false); + it('should work with multiple values', async() => { + const inputSets = [ true, true, false, true ]; + expect(mergeHandler(...inputSets)).toBe(false); }); }); describe('actual bindings', () => { let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { BF = await DevTools.createBindingsFactory(DF); }); - it('should work with addition bindings', async () => { + it('should work with addition bindings', async() => { const bindings1 = BF.bindings([ - [DF.variable('a'), DF.literal("1")], + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true); const bindings2 = BF.bindings([ - [DF.variable('a'), DF.literal("1")], + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true); expect(bindings1.merge(bindings2)).toEqualBindings(BF.bindings([ - [DF.variable('a'), DF.literal("1")], + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); }); - it('should work with deletion bindings', async () => { + it('should work with deletion bindings', async() => { const bindings1 = BF.bindings([ - [DF.variable('a'), DF.literal("1")], + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false); const bindings2 = BF.bindings([ - [DF.variable('a'), DF.literal("1")], + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true); expect(bindings1.merge(bindings2)).toEqualBindings(BF.bindings([ - [DF.variable('a'), DF.literal("1")], + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false)); }); }); diff --git a/packages/actor-query-operation-incremental-distinct-hash/README.md b/packages/actor-query-operation-incremental-distinct-hash/README.md index a571f9d9..fa2cfbd3 100644 --- a/packages/actor-query-operation-incremental-distinct-hash/README.md +++ b/packages/actor-query-operation-incremental-distinct-hash/README.md @@ -23,7 +23,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@Incremunica/actor-query-operation-incremental-distinct-hash/^2.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@Incremunica/actor-query-operation-incremental-distinct-hash/^2.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-query-operation-incremental-distinct-hash/lib/ActorQueryOperationIncrementalDistinctHash.ts b/packages/actor-query-operation-incremental-distinct-hash/lib/ActorQueryOperationIncrementalDistinctHash.ts index c53f630b..9ed54b28 100644 --- a/packages/actor-query-operation-incremental-distinct-hash/lib/ActorQueryOperationIncrementalDistinctHash.ts +++ b/packages/actor-query-operation-incremental-distinct-hash/lib/ActorQueryOperationIncrementalDistinctHash.ts @@ -1,16 +1,20 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation'; import { ActorQueryOperation, ActorQueryOperationTypedMediated, } from '@comunica/bus-query-operation'; import type { IActorTest } from '@comunica/core'; -import type { IActionContext, IQueryOperationResult, IQueryOperationResultBindings } from '@comunica/types'; +import type { + IActionContext, + IQueryOperationResult, + IQueryOperationResultBindings, + BindingsStream, +} from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { HashBindings } from '@incremunica/hash-bindings'; -import type { Bindings } from '@comunica/bindings-factory'; -import type { BindingsStream } from '@comunica/types'; +import type { AsyncIterator } from 'asynciterator'; import type { Algebra } from 'sparqlalgebrajs'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import type {AsyncIterator} from "asynciterator"; /** * An Incremunica Distinct Hash Query Operation Actor. @@ -20,7 +24,7 @@ export class ActorQueryOperationIncrementalDistinctHash extends ActorQueryOperat super(args, 'distinct'); } - public async testOperation(operation: Algebra.Distinct, context: IActionContext): Promise { + public async testOperation(_operation: Algebra.Distinct, _context: IActionContext): Promise { return true; } diff --git a/packages/actor-query-operation-incremental-distinct-hash/package.json b/packages/actor-query-operation-incremental-distinct-hash/package.json index f0e4aa52..bffff147 100644 --- a/packages/actor-query-operation-incremental-distinct-hash/package.json +++ b/packages/actor-query-operation-incremental-distinct-hash/package.json @@ -3,45 +3,46 @@ "version": "1.3.0", "description": "An incremental distinct-hash query-operation actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-query-operation-incremental-distinct-hash" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "incremunica", "actor", "query-operation", "distinct-hash" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { - "@incremunica/hash-bindings": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0", + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-query-operation": "^3.2.2", "@comunica/core": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", + "@incremunica/hash-bindings": "^1.3.0", "sparqlalgebrajs": "^4.2.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-query-operation-incremental-distinct-hash/test/ActorQueryOperationIncrementalDistinctHash-test.ts b/packages/actor-query-operation-incremental-distinct-hash/test/ActorQueryOperationIncrementalDistinctHash-test.ts index 29186c82..0e323c03 100644 --- a/packages/actor-query-operation-incremental-distinct-hash/test/ActorQueryOperationIncrementalDistinctHash-test.ts +++ b/packages/actor-query-operation-incremental-distinct-hash/test/ActorQueryOperationIncrementalDistinctHash-test.ts @@ -1,12 +1,11 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import { ActionContext, Bus } from '@comunica/core'; -import type { IQueryOperationResultBindings } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { ActorQueryOperationIncrementalDistinctHash } from '../lib'; import '@comunica/jest'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; const DF = new DataFactory(); @@ -15,19 +14,19 @@ describe('ActorQueryOperationIncrementalDistinctHash', () => { let mediatorQueryOperation: any; let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { BF = await DevTools.createBindingsFactory(DF); - bus = new Bus({name: 'bus'}); + bus = new Bus({ name: 'bus' }); mediatorQueryOperation = { mediate: (arg: any) => Promise.resolve({ bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), ]), - metadata: () => Promise.resolve({cardinality: 5, variables: [DF.variable('a')]}), + metadata: () => Promise.resolve({ cardinality: 5, variables: [ DF.variable('a') ]}), operated: arg, type: 'bindings', }), @@ -39,85 +38,179 @@ describe('ActorQueryOperationIncrementalDistinctHash', () => { beforeEach(() => { actor = new ActorQueryOperationIncrementalDistinctHash( - {name: 'actor', bus, mediatorQueryOperation}, + { name: 'actor', bus, mediatorQueryOperation }, ); }); - it('should create a filter', async () => { + it('should create a filter', async() => { expect(actor.newHashFilter()).toBeInstanceOf(Function); }); - it('should create a filter that is a predicate', async () => { + it('should create a filter that is a predicate', async() => { const filter = actor.newHashFilter(); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); }); - it('should create a filter that only returns true once for equal objects', async () => { + it('should create a filter that only returns true once for equal objects', async() => { const filter = actor.newHashFilter(); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); }); - it('should create a filters that are independent', async () => { + it('should create a filters that are independent', async() => { const filter1 = actor.newHashFilter(); const filter2 = actor.newHashFilter(); const filter3 = actor.newHashFilter(); - expect(filter1(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter1(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - - expect(filter2(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter2(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - - expect(filter3(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter3(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter1(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter1(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + + expect(filter2(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter2(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + + expect(filter3(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter3(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); }); - it('should create a filter that returns true if everything is deleted', async () => { + it('should create a filter that returns true if everything is deleted', async() => { const filter = actor.newHashFilter(); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); }); - it('should create a filter that returns false if too much is deleted', async () => { + it('should create a filter that returns false if too much is deleted', async() => { const filter = actor.newHashFilter(); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('a')]]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); - expect(filter(BF.bindings([[DF.variable('a'), DF.literal('b')]]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(true); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false))).toBe(false); + expect(filter(BF.bindings([ + [ DF.variable('a'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true))).toBe(true); }); }); @@ -125,31 +218,30 @@ describe('ActorQueryOperationIncrementalDistinctHash', () => { let actor: ActorQueryOperationIncrementalDistinctHash; beforeEach(() => { actor = new ActorQueryOperationIncrementalDistinctHash( - {name: 'actor', bus, mediatorQueryOperation}, + { name: 'actor', bus, mediatorQueryOperation }, ); }); - it('should test on distinct', () => { - const op: any = {operation: {type: 'distinct'}, context: new ActionContext()}; - return expect(actor.test(op)).resolves.toBeTruthy(); + it('should test on distinct', async() => { + const op: any = { operation: { type: 'distinct' }, context: new ActionContext() }; + await expect(actor.test(op)).resolves.toBeTruthy(); }); - it('should not test on non-distinct', () => { - const op: any = {operation: {type: 'some-other-type'}, context: new ActionContext()}; - return expect(actor.test(op)).rejects.toBeTruthy(); + it('should not test on non-distinct', async() => { + const op: any = { operation: { type: 'some-other-type' }, context: new ActionContext() }; + await expect(actor.test(op)).rejects.toBeTruthy(); }); - it('should run', () => { - const op: any = {operation: {type: 'distinct'}, context: new ActionContext()}; - return actor.run(op).then(async (output: IQueryOperationResultBindings) => { - expect(await output.metadata()).toEqual({cardinality: 5, variables: [DF.variable('a')]}); - expect(output.type).toEqual('bindings'); - await expect(output.bindingsStream).toEqualBindingsStream([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); + it('should run', async() => { + const op: any = { operation: { type: 'distinct' }, context: new ActionContext() }; + const output = await actor.run(op); + await expect(output.metadata()).resolves.toEqual({ cardinality: 5, variables: [ DF.variable('a') ]}); + expect(output.type).toBe('bindings'); + await expect(output.bindingsStream).toEqualBindingsStream([ + BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); }); }); }); diff --git a/packages/actor-query-operation-incremental-filter/README.md b/packages/actor-query-operation-incremental-filter/README.md index 473ce20f..e7ae1e1e 100644 --- a/packages/actor-query-operation-incremental-filter/README.md +++ b/packages/actor-query-operation-incremental-filter/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-query-operation-incremental-filter/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-query-operation-incremental-filter/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-query-operation-incremental-filter/lib/ActorQueryOperationIncrementalFilter.ts b/packages/actor-query-operation-incremental-filter/lib/ActorQueryOperationIncrementalFilter.ts index fde33b48..5eb8617d 100644 --- a/packages/actor-query-operation-incremental-filter/lib/ActorQueryOperationIncrementalFilter.ts +++ b/packages/actor-query-operation-incremental-filter/lib/ActorQueryOperationIncrementalFilter.ts @@ -1,19 +1,20 @@ +import type { Bindings } from '@comunica/bindings-factory'; +import { BindingsFactory, bindingsToString } from '@comunica/bindings-factory'; +import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context'; import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation'; -import { ActorQueryOperation, +import { + ActorQueryOperation, ActorQueryOperationTypedMediated, - materializeOperation } from '@comunica/bus-query-operation'; + materializeOperation, +} from '@comunica/bus-query-operation'; import type { IActorTest } from '@comunica/core'; import { AsyncEvaluator, isExpressionError } from '@comunica/expression-evaluator'; -import type {IActionContext, IQueryOperationResult} from '@comunica/types'; -import {Bindings, BindingsFactory} from '@comunica/bindings-factory'; -import { bindingsToString } from '@comunica/bindings-factory'; +import type { IActionContext, IQueryOperationResult, BindingsStream } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { HashBindings } from '@incremunica/hash-bindings'; -import type { BindingsStream } from '@comunica/types'; +import type { AsyncIterator } from 'asynciterator'; import { EmptyIterator, SingletonIterator, UnionIterator } from 'asynciterator'; import type { Algebra } from 'sparqlalgebrajs'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {MediatorMergeBindingsContext} from "@comunica/bus-merge-bindings-context"; -import {AsyncIterator} from "asynciterator"; /** * A comunica Filter Sparqlee Query Operation Actor. @@ -32,7 +33,11 @@ export class ActorQueryOperationIncrementalFilter extends ActorQueryOperationTyp return true; } if (operation.expression.expressionType === 'operator') { - const config = { ...ActorQueryOperation.getAsyncExpressionContext(context, this.mediatorQueryOperation, new BindingsFactory()) }; + const config = { ...ActorQueryOperation.getAsyncExpressionContext( + context, + this.mediatorQueryOperation, + await BindingsFactory.create(this.mediatorMergeBindingsContext, context), + ) }; const _ = new AsyncEvaluator(operation.expression, config); return true; } @@ -90,7 +95,7 @@ export class ActorQueryOperationIncrementalFilter extends ActorQueryOperationTyp bindings: bindingsToString(item), })); } else { - //TODO is this the correct way of making the bindingsStream emit an error? + // TODO is this the correct way of making the bindingsStream emit an error? bindingsStream.emit('error', error); } } @@ -109,7 +114,11 @@ export class ActorQueryOperationIncrementalFilter extends ActorQueryOperationTyp const hashBindings = new HashBindings(); - const binder = async(bindings: Bindings, done: () => void, push: (i: AsyncIterator) => void): Promise => { + const binder = async( + bindings: Bindings, + done: () => void, + push: (i: AsyncIterator) => void, + ): Promise => { const hash = hashBindings.hash(bindings); let hashData = transformMap.get(hash); if (bindings.getContextEntry(new ActionContextKeyIsAddition())) { @@ -209,10 +218,13 @@ export class ActorQueryOperationIncrementalFilter extends ActorQueryOperationTyp done(); }; - const bindingsStream = new UnionIterator((>output.bindingsStream) - .transform({ - transform: binder, - }), { autoStart: false }); + const bindingsStream = new UnionIterator( + (>output.bindingsStream) + .transform({ + transform: binder, + }), + { autoStart: false }, + ); return { type: 'bindings', bindingsStream, metadata: output.metadata }; } } diff --git a/packages/actor-query-operation-incremental-filter/package.json b/packages/actor-query-operation-incremental-filter/package.json index fa0de0d0..e128e086 100644 --- a/packages/actor-query-operation-incremental-filter/package.json +++ b/packages/actor-query-operation-incremental-filter/package.json @@ -3,46 +3,49 @@ "version": "1.3.0", "description": "An incremental-filter query-operation actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-query-operation-incremental-filter" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "query-operation", "incremental-filter" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", + "@comunica/bus-merge-bindings-context": "^3.3.0", "@comunica/bus-query-operation": "^3.2.2", "@comunica/core": "^3.2.1", "@comunica/expression-evaluator": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/hash-bindings": "^1.3.0", "asynciterator": "^3.9.0", "sparqlalgebrajs": "^4.2.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-query-operation-incremental-filter/test/ActorQueryOperationIncrementalFilter-test.ts b/packages/actor-query-operation-incremental-filter/test/ActorQueryOperationIncrementalFilter-test.ts index 5ba01e58..90d64c58 100644 --- a/packages/actor-query-operation-incremental-filter/test/ActorQueryOperationIncrementalFilter-test.ts +++ b/packages/actor-query-operation-incremental-filter/test/ActorQueryOperationIncrementalFilter-test.ts @@ -1,10 +1,15 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import { ActorQueryOperation } from '@comunica/bus-query-operation'; import { KeysInitQuery } from '@comunica/context-entries'; import { ActionContext, Bus } from '@comunica/core'; import * as sparqlee from '@comunica/expression-evaluator'; import { isExpressionError } from '@comunica/expression-evaluator'; import type { IQueryOperationResultBindings, Bindings } from '@comunica/types'; +import { + ActionContextKeyIsAddition, + ActorMergeBindingsContextIsAddition, +} from '@incremunica/actor-merge-bindings-context-is-addition'; +import {DevTools} from "@incremunica/dev-tools"; import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import type { Algebra } from 'sparqlalgebrajs'; @@ -13,12 +18,7 @@ import { ActorQueryOperationIncrementalFilter } from '../lib'; import '@comunica/jest'; import '@incremunica/incremental-jest'; import {EventEmitter} from "events"; -import {DevTools} from "@incremunica/dev-tools"; -import { - ActionContextKeyIsAddition, - ActorMergeBindingsContextIsAddition -} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {MediatorMergeBindingsContext} from "@comunica/bus-merge-bindings-context"; +import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context'; const DF = new DataFactory(); @@ -40,9 +40,9 @@ function parse(query: string): Algebra.Expression { } async function partialArrayifyStream(stream: EventEmitter, num: number): Promise { - let array: V[] = []; + const array: V[] = []; for (let i = 0; i < num; i++) { - await new Promise((resolve) => stream.once("data", (bindings: V) => { + await new Promise(resolve => stream.once('data', (bindings: V) => { array.push(bindings); resolve(); })); @@ -69,17 +69,17 @@ describe('ActorQueryOperationFilterSparqlee', () => { }; let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { BF = await DevTools.createBindingsFactory(DF); - bus = new Bus({name: 'bus'}); + bus = new Bus({ name: 'bus' }); mediatorQueryOperation = { mediate: (arg: any) => Promise.resolve({ bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), - metadata: () => Promise.resolve({cardinality: 3, canContainUndefs: false, variables: [DF.variable('a')]}), + BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), + metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}), operated: arg, type: 'bindings', }), @@ -99,7 +99,9 @@ describe('ActorQueryOperationFilterSparqlee', () => { }); it('should not be able to create new ActorQueryOperationFilterSparqlee objects without \'new\'', () => { - expect(() => { ( ActorQueryOperationIncrementalFilter)(); }).toThrow(); + expect(() => { + ( ActorQueryOperationIncrementalFilter)(); + }).toThrow(); }); }); @@ -108,12 +110,12 @@ describe('ActorQueryOperationFilterSparqlee', () => { let factory: Factory; beforeEach(() => { - let mediatorMergeBindingsContext: MediatorMergeBindingsContext = { - mediate: async () => Promise.resolve((await new ActorMergeBindingsContextIsAddition({ + const mediatorMergeBindingsContext: MediatorMergeBindingsContext = { + mediate: async() => (await new ActorMergeBindingsContextIsAddition({ bus: new Bus({name: 'bus'}), name: 'actor' - }).run({})).mergeHandlers), - } + }).run({})).mergeHandlers, + }; actor = new ActorQueryOperationIncrementalFilter({ name: 'actor', bus, mediatorQueryOperation, mediatorMergeBindingsContext }); factory = new Factory(); }); @@ -124,7 +126,7 @@ describe('ActorQueryOperationFilterSparqlee', () => { }); it('should test on filter existence', () => { - const op: any = { operation: { type: 'filter', expression: {expressionType: 'existence'} }, context: new ActionContext() }; + const op: any = { operation: { type: 'filter', expression: { expressionType: 'existence' }}, context: new ActionContext() }; return expect(actor.test(op)).resolves.toBeTruthy(); }); @@ -144,68 +146,62 @@ describe('ActorQueryOperationFilterSparqlee', () => { }); it('should return the full stream for a truthy filter', async() => { - const op: any = { operation: { type: 'filter', input: {}, expression: truthyExpression }, - context: new ActionContext() }; + const op: any = { operation: { type: 'filter', input: {}, expression: truthyExpression }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); - expect(await partialArrayifyStream(output.bindingsStream, 3)).toEqualBindingsArray([ + await expect(partialArrayifyStream(output.bindingsStream, 3)).resolves.toEqualBindingsArray([ BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(output.type).toEqual('bindings'); - expect(await output.metadata()) + expect(output.type).toBe('bindings'); + await expect(output.metadata()).resolves .toMatchObject({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); }); it('should return an empty stream for a falsy filter', async() => { - const op: any = { operation: { type: 'filter', input: {}, expression: falsyExpression }, - context: new ActionContext() }; + const op: any = { operation: { type: 'filter', input: {}, expression: falsyExpression }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); await expect(output.bindingsStream).toEqualBindingsStream([]); - expect(await output.metadata()) + await expect(output.metadata()).resolves .toMatchObject({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); - expect(output.type).toEqual('bindings'); + expect(output.type).toBe('bindings'); }); it('should return an empty stream when the expressions error', async() => { - const op: any = { operation: { type: 'filter', input: {}, expression: erroringExpression }, - context: new ActionContext() }; + const op: any = { operation: { type: 'filter', input: {}, expression: erroringExpression }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); await expect(output.bindingsStream).toEqualBindingsStream([]); - expect(await output.metadata()) + await expect(output.metadata()).resolves .toMatchObject({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); - expect(output.type).toEqual('bindings'); + expect(output.type).toBe('bindings'); }); it('Should log warning for an expressionError', async() => { // The order is very important. This item requires isExpressionError to still have it's right definition. const logWarnSpy = jest.spyOn( actor, 'logWarn'); - const op: any = { operation: { type: 'filter', input: {}, expression: erroringExpression }, - context: new ActionContext() }; + const op: any = { operation: { type: 'filter', input: {}, expression: erroringExpression }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); output.bindingsStream.on('data', () => { // This is here to force the stream to start. }); await new Promise(resolve => output.bindingsStream.on('end', resolve)); expect(logWarnSpy).toHaveBeenCalledTimes(3); - logWarnSpy.mock.calls.forEach((call, index) => { + for (const [ index, call ] of logWarnSpy.mock.calls) { if (index === 0) { const dataCB = <() => { error: any; bindings: Bindings }>call[2]; const { error, bindings } = dataCB(); expect(isExpressionError(error)).toBeTruthy(); - expect(bindings).toEqual(`{ + expect(bindings).toBe(`{ "a": "\\"1\\"" }`); } - }); + } }); it('should emit an error for a hard erroring filter', async() => { - // eslint-disable-next-line no-import-assign Object.defineProperty(sparqlee, 'isExpressionError', { writable: true }); - ( sparqlee).isExpressionError = jest.fn(() => false); - const op: any = { operation: { type: 'filter', input: {}, expression: erroringExpression }, - context: new ActionContext() }; + jest.spyOn(( sparqlee, 'isExpressionError').mockImplementation(() => false); + const op: any = { operation: { type: 'filter', input: {}, expression: erroringExpression }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); output.bindingsStream.on('data', () => { // This is here to force the stream to start. @@ -225,33 +221,31 @@ describe('ActorQueryOperationFilterSparqlee', () => { BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(output.type).toEqual('bindings'); - expect(await output.metadata()) + expect(output.type).toBe('bindings'); + await expect(output.metadata()).resolves .toMatchObject({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); }); describe('should be able to handle EXIST filters', () => { it('like a simple EXIST that is true', async() => { // The actual bgp isn't used - const op: any = { operation: { type: 'filter', input: {}, expression: parse("EXISTS {?a a ?a}") }, - context: new ActionContext() }; + const op: any = { operation: { type: 'filter', input: {}, expression: parse('EXISTS {?a a ?a}') }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); - expect(await partialArrayifyStream(output.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(output.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(await output.metadata()) + await expect(output.metadata()).resolves .toMatchObject({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); - expect(output.type).toEqual('bindings'); + expect(output.type).toBe('bindings'); }); it('like a simple NOT EXIST that is true', async() => { // The actual bgp isn't used - const op: any = { operation: { type: 'filter', input: {}, expression: parse("NOT EXISTS {?a a ?a}") }, - context: new ActionContext() }; + const op: any = { operation: { type: 'filter', input: {}, expression: parse('NOT EXISTS {?a a ?a}') }, context: new ActionContext() }; const output: IQueryOperationResultBindings = await actor.run(op); - expect(await partialArrayifyStream(output.bindingsStream, 6)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(output.bindingsStream, 6)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), @@ -259,9 +253,9 @@ describe('ActorQueryOperationFilterSparqlee', () => { BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); - expect(await output.metadata()) + await expect(output.metadata()).resolves .toMatchObject({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); - expect(output.type).toEqual('bindings'); + expect(output.type).toBe('bindings'); }); }); }); diff --git a/packages/actor-query-source-identify-hypermedia-stream-none/README.md b/packages/actor-query-source-identify-hypermedia-stream-none/README.md index 3ec9deb6..518e2bb6 100644 --- a/packages/actor-query-source-identify-hypermedia-stream-none/README.md +++ b/packages/actor-query-source-identify-hypermedia-stream-none/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-query-source-identify-hypermedia-stream-none/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-query-source-identify-hypermedia-stream-none/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-query-source-identify-hypermedia-stream-none/lib/ActorQuerySourceIdentifyHypermediaStreamNone.ts b/packages/actor-query-source-identify-hypermedia-stream-none/lib/ActorQuerySourceIdentifyHypermediaStreamNone.ts index e5ed69b3..7263b44c 100644 --- a/packages/actor-query-source-identify-hypermedia-stream-none/lib/ActorQuerySourceIdentifyHypermediaStreamNone.ts +++ b/packages/actor-query-source-identify-hypermedia-stream-none/lib/ActorQuerySourceIdentifyHypermediaStreamNone.ts @@ -1,9 +1,3 @@ -import { ActionContext } from '@comunica/core'; -import type { MediatorGuard } from '@incremunica/bus-guard'; -import { KeysGuard } from '@incremunica/context-entries'; -import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; -import type { Quad } from '@incremunica/incremental-types'; -import type * as RDF from '@rdfjs/types'; import { BindingsFactory } from '@comunica/bindings-factory'; import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context'; import type { @@ -13,7 +7,13 @@ import type { IActorQuerySourceIdentifyHypermediaTest, } from '@comunica/bus-query-source-identify-hypermedia'; import { ActorQuerySourceIdentifyHypermedia } from '@comunica/bus-query-source-identify-hypermedia'; -import {StreamingQuerySourceRdfJs} from "@incremunica/actor-query-source-identify-streaming-rdfjs"; +import { ActionContext } from '@comunica/core'; +import { StreamingQuerySourceRdfJs } from '@incremunica/actor-query-source-identify-streaming-rdfjs'; +import type { MediatorGuard } from '@incremunica/bus-guard'; +import { KeysGuard } from '@incremunica/context-entries'; +import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { Quad } from '@incremunica/incremental-types'; +import type * as RDF from '@rdfjs/types'; /** * An incremunica Stream None Query Source Identify Hypermedia Actor. diff --git a/packages/actor-query-source-identify-hypermedia-stream-none/package.json b/packages/actor-query-source-identify-hypermedia-stream-none/package.json index 7a052bd0..602f8199 100644 --- a/packages/actor-query-source-identify-hypermedia-stream-none/package.json +++ b/packages/actor-query-source-identify-hypermedia-stream-none/package.json @@ -3,44 +3,47 @@ "version": "1.3.0", "description": "A stream none query-source-identify-hypermedia actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-query-source-identify-hypermedia-stream-none" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "incremunica", "actor", "query-source-identify-hypermedia", "stream-none" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { - "asynciterator": "^3.9.0", + "@comunica/bindings-factory": "^3.3.0", + "@comunica/bus-merge-bindings-context": "^3.3.0", + "@comunica/bus-query-source-identify-hypermedia": "^3.3.0", "@comunica/core": "^3.2.1", + "@incremunica/actor-query-source-identify-streaming-rdfjs": "^1.3.0", "@incremunica/bus-guard": "^1.3.0", "@incremunica/context-entries": "^1.3.0", "@incremunica/incremental-rdf-streaming-store": "^1.3.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-query-source-identify-hypermedia-stream-none/test/ActorQuerySourceIdentifyHypermediaStreamNone-test.ts b/packages/actor-query-source-identify-hypermedia-stream-none/test/ActorQuerySourceIdentifyHypermediaStreamNone-test.ts index a0f0cc4e..6f09fae6 100644 --- a/packages/actor-query-source-identify-hypermedia-stream-none/test/ActorQuerySourceIdentifyHypermediaStreamNone-test.ts +++ b/packages/actor-query-source-identify-hypermedia-stream-none/test/ActorQuerySourceIdentifyHypermediaStreamNone-test.ts @@ -1,20 +1,20 @@ -import {ActionContext, Bus} from '@comunica/core'; -import { ActorQuerySourceIdentifyHypermediaStreamNone } from '../lib'; -import {IActionGuard, MediatorGuard} from "@incremunica/bus-guard"; -import {DataFactory} from "rdf-data-factory"; -import arrayifyStream from "arrayify-stream"; -import 'jest-rdf' -import '@incremunica/incremental-jest' -import {EventEmitter} from "events"; -import {KeysGuard} from "@incremunica/context-entries"; -import { Factory } from 'sparqlalgebrajs'; -import {IGuardEvents} from "@incremunica/incremental-types"; +import 'jest-rdf'; +import '@incremunica/incremental-jest'; +import { EventEmitter } from 'node:events'; +import type { BindingsFactory } from '@comunica/bindings-factory'; +import { ActionContext, Bus } from '@comunica/core'; import { ActionContextKeyIsAddition, - ActorMergeBindingsContextIsAddition -} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {BindingsFactory} from "@comunica/bindings-factory"; -import {DevTools} from "@incremunica/dev-tools"; + ActorMergeBindingsContextIsAddition, +} from '@incremunica/actor-merge-bindings-context-is-addition'; +import type { IActionGuard, MediatorGuard } from '@incremunica/bus-guard'; +import { KeysGuard } from '@incremunica/context-entries'; +import { DevTools } from '@incremunica/dev-tools'; +import type { IGuardEvents } from '@incremunica/incremental-types'; +import arrayifyStream from 'arrayify-stream'; +import { DataFactory } from 'rdf-data-factory'; +import { Factory } from 'sparqlalgebrajs'; +import { ActorQuerySourceIdentifyHypermediaStreamNone } from '../lib'; const DF = new DataFactory(); const AF = new Factory(); @@ -25,7 +25,9 @@ function captureEvents(item: EventEmitter, ...events: string[]) { const counts = (item)._eventCounts = Object.create(null); for (const event of events) { counts[event] = 0; - item.on(event, () => { counts[event]++; }); + item.on(event, () => { + counts[event]++; + }); } return item; } @@ -34,8 +36,8 @@ describe('ActorRdfResolveHypermediaStreamNone', () => { let bus: any; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); BF = await DevTools.createBindingsFactory(DF); }); @@ -53,117 +55,122 @@ describe('ActorRdfResolveHypermediaStreamNone', () => { mediatorGuard = { mediate: (action: IActionGuard) => { mediatorFn(action); - return { guardEvents } - } + return { guardEvents }; + }, }; mediatorMergeBindingsContext = { - mediate: async (action: any) => { + mediate: async(action: any) => { return (await new ActorMergeBindingsContextIsAddition({ - bus: new Bus({name: 'bus'}), - name: 'actor' + bus: new Bus({ name: 'bus' }), + name: 'actor', }).run({})).mergeHandlers; - } - } - actor = new ActorQuerySourceIdentifyHypermediaStreamNone({ name: 'actor', bus, mediatorGuard, mediatorMergeBindingsContext}); + }, + }; + actor = new ActorQuerySourceIdentifyHypermediaStreamNone({ + name: 'actor', + bus, + mediatorGuard, + mediatorMergeBindingsContext, + }); }); - it('should test', async () => { - let action = {}; - expect(await actor.test(action)).toMatchObject({filterFactor: 0}); + it('should test', async() => { + const action = {}; + await expect(actor.test(action)).resolves.toMatchObject({ filterFactor: 0 }); }); - it('should run and make a streaming store', async () => { - let deletedQuad = quad("s1","p1","o1"); - deletedQuad.diff = false - let action = { + it('should run and make a streaming store', async() => { + const deletedQuad = quad('s1', 'p1', 'o1'); + deletedQuad.diff = false; + const action = { context: { get: () => { - return "" - } + return ''; + }, }, - url: "http://test.com", + url: 'http://test.com', quads: streamifyArray([ - quad("s1","p1","o1"), - quad("s2","p2","o2"), - deletedQuad - ]) + quad('s1', 'p1', 'o1'), + quad('s2', 'p2', 'o2'), + deletedQuad, + ]), }; - let result = (await actor.run(action)) - let stream = result.source.queryBindings( + const result = (await actor.run(action)); + const stream = result.source.queryBindings( AF.createPattern(DF.variable('s'), DF.variable('p'), DF.variable('o')), - new ActionContext() + new ActionContext(), ); - let number = 2 - stream.on("data", () => { + let number = 2; + stream.on('data', () => { number--; - if (number == 0) { + if (number === 0) { stream.close(); } - }) - expect(await arrayifyStream(stream)).toBeIsomorphicBindingsArray([ + }); + await expect(arrayifyStream(stream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('s'), DF.namedNode('s1')], - [DF.variable('p'), DF.namedNode('p1')], - [DF.variable('o'), DF.namedNode('o1')], + [ DF.variable('s'), DF.namedNode('s1') ], + [ DF.variable('p'), DF.namedNode('p1') ], + [ DF.variable('o'), DF.namedNode('o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('s'), DF.namedNode('s2')], - [DF.variable('p'), DF.namedNode('p2')], - [DF.variable('o'), DF.namedNode('o2')], + [ DF.variable('s'), DF.namedNode('s2') ], + [ DF.variable('p'), DF.namedNode('p2') ], + [ DF.variable('o'), DF.namedNode('o2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('s'), DF.namedNode('s1')], - [DF.variable('p'), DF.namedNode('p1')], - [DF.variable('o'), DF.namedNode('o1')], + [ DF.variable('s'), DF.namedNode('s1') ], + [ DF.variable('p'), DF.namedNode('p1') ], + [ DF.variable('o'), DF.namedNode('o1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); }); - it('should run and add a guard', async () => { - let action = { + it('should run and add a guard', async() => { + const action = { context: { get: () => { - return "" - } + return ''; + }, }, - url: "http://test.com", - quads: streamifyArray([]) + url: 'http://test.com', + quads: streamifyArray([]), }; await actor.run(action); expect(mediatorFn).toHaveBeenCalledTimes(1); }); - it('should add the guard events to the source', async () => { - let action = { + it('should add the guard events to the source', async() => { + const action = { context: { get: () => { - return "" - } + return ''; + }, }, - url: "http://test.com", - quads: streamifyArray([]) + url: 'http://test.com', + quads: streamifyArray([]), }; - let result = await actor.run(action); - let events = ( result.source).context.get(KeysGuard.events); + const result = await actor.run(action); + const events = ( result.source).context.get(KeysGuard.events); expect(events).toEqual(guardEvents); - guardEvents.emit("modified"); - expect((guardEvents)._eventCounts.modified).toEqual(1); + guardEvents.emit('modified'); + expect((guardEvents)._eventCounts.modified).toBe(1); }); - it('should add the guard events to the source even if the source has no context', async () => { + it('should add the guard events to the source even if the source has no context', async() => { mediatorFn = jest.fn((action: IActionGuard) => { action.streamingSource.context = undefined; }); - let action = { + const action = { context: { get: () => { - return "" - } + return ''; + }, }, - url: "http://test.com", - quads: streamifyArray([]) + url: 'http://test.com', + quads: streamifyArray([]), }; - let result = await actor.run(action); + const result = await actor.run(action); expect(mediatorFn).toHaveBeenCalledTimes(1); expect(( result.source).context.get(KeysGuard.events)).toEqual(guardEvents); }); diff --git a/packages/actor-query-source-identify-streaming-rdfjs/README.md b/packages/actor-query-source-identify-streaming-rdfjs/README.md index 5e888aab..02e725cf 100644 --- a/packages/actor-query-source-identify-streaming-rdfjs/README.md +++ b/packages/actor-query-source-identify-streaming-rdfjs/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-query-source-identify-streaming-rdfjs/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-query-source-identify-streaming-rdfjs/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-query-source-identify-streaming-rdfjs/lib/ActorQuerySourceIdentifyStreamingRdfJs.ts b/packages/actor-query-source-identify-streaming-rdfjs/lib/ActorQuerySourceIdentifyStreamingRdfJs.ts index 04ae39d8..d5979e2f 100644 --- a/packages/actor-query-source-identify-streaming-rdfjs/lib/ActorQuerySourceIdentifyStreamingRdfJs.ts +++ b/packages/actor-query-source-identify-streaming-rdfjs/lib/ActorQuerySourceIdentifyStreamingRdfJs.ts @@ -1,15 +1,16 @@ -import {ActionContext, IActorTest} from '@comunica/core' -import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import { BindingsFactory } from '@comunica/bindings-factory'; +import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context'; import type { IActionQuerySourceIdentify, IActorQuerySourceIdentifyOutput, IActorQuerySourceIdentifyArgs, } from '@comunica/bus-query-source-identify'; import { ActorQuerySourceIdentify } from '@comunica/bus-query-source-identify'; -import {MediatorMergeBindingsContext} from "@comunica/bus-merge-bindings-context"; -import {StreamingQuerySourceRdfJs} from "./StreamingQuerySourceRdfJs"; -import {BindingsFactory} from "@comunica/bindings-factory"; -import {Quad} from "@incremunica/incremental-types"; +import type { IActorTest } from '@comunica/core'; +import { ActionContext } from '@comunica/core'; +import type { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { Quad } from '@incremunica/incremental-types'; +import { StreamingQuerySourceRdfJs } from './StreamingQuerySourceRdfJs'; /** * An incremunica Streaming RDFJS Query Source Identify Actor. @@ -29,10 +30,11 @@ export class ActorQuerySourceIdentifyStreamingRdfJs extends ActorQuerySourceIden if (typeof source.value === 'string' || !('match' in source.value)) { throw new Error(`${this.name} actor received an invalid streaming rdfjs query source.`); } - //TODO add check to make sure the store is a streaming store - //if (!(source.value instanceof StreamingStore) && !(!('match' in source) && (source.value instanceof StreamingStore))) { + // TODO add check to make sure the store is a streaming store + // if (!(source.value instanceof StreamingStore) + // && !(!('match' in source) && (source.value instanceof StreamingStore))) { // throw new Error(`${this.name} didn't receive a StreamingStore.`); - //} + // } return true; } diff --git a/packages/actor-query-source-identify-streaming-rdfjs/lib/IRdfJsSourceExtended.ts b/packages/actor-query-source-identify-streaming-rdfjs/lib/IRdfJsSourceExtended.ts index 671753eb..619dc9b2 100644 --- a/packages/actor-query-source-identify-streaming-rdfjs/lib/IRdfJsSourceExtended.ts +++ b/packages/actor-query-source-identify-streaming-rdfjs/lib/IRdfJsSourceExtended.ts @@ -1,6 +1,6 @@ +import type { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { Quad } from '@incremunica/incremental-types'; import type * as RDF from '@rdfjs/types'; -import {StreamingStore} from "@incremunica/incremental-rdf-streaming-store"; -import {Quad} from "@incremunica/incremental-types"; export interface IIncementalRdfJsSourceExtended extends RDF.Source { /** @@ -17,7 +17,7 @@ export interface IIncementalRdfJsSourceExtended extends RDF.Source { /** * */ - streamingStore: StreamingStore + streamingStore: StreamingStore; /** * Return an estimated count of the number of quads matching the given pattern. * diff --git a/packages/actor-query-source-identify-streaming-rdfjs/lib/StreamingQuerySourceRdfJs.ts b/packages/actor-query-source-identify-streaming-rdfjs/lib/StreamingQuerySourceRdfJs.ts index f8f143a5..d3ca0238 100644 --- a/packages/actor-query-source-identify-streaming-rdfjs/lib/StreamingQuerySourceRdfJs.ts +++ b/packages/actor-query-source-identify-streaming-rdfjs/lib/StreamingQuerySourceRdfJs.ts @@ -1,27 +1,34 @@ +import type { BindingsFactory } from '@comunica/bindings-factory'; +import { ClosableIterator } from '@comunica/bus-query-operation'; +import { + filterMatchingQuotedQuads, + getVariables, + getDuplicateElementLinks, + setMetadata, +} from '@comunica/bus-query-source-identify'; +import { KeysQueryOperation } from '@comunica/context-entries'; import { MetadataValidationState } from '@comunica/metadata'; -import type {IQuerySource, BindingsStream, IActionContext, FragmentSelectorShape, Bindings} from '@comunica/types'; +import type { IQuerySource, BindingsStream, IActionContext, FragmentSelectorShape, Bindings } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { KeysGuard, KeysStreamingSource } from '@incremunica/context-entries'; -import {IGuardEvents, Quad} from '@incremunica/incremental-types'; +import type { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { IGuardEvents, Quad } from '@incremunica/incremental-types'; import type * as RDF from '@rdfjs/types'; +import type { AsyncIterator } from 'asynciterator'; import { wrap as wrapAsyncIterator } from 'asynciterator'; -import { AsyncIterator } from 'asynciterator'; -import {Algebra, Factory} from 'sparqlalgebrajs'; import { DataFactory } from 'rdf-data-factory'; -import {BindingsFactory} from "@comunica/bindings-factory"; +import type { + QuadTermName, +} from 'rdf-terms'; import { filterTermsNested, getValueNestedPath, - QuadTermName, reduceTermsNested, someTermsNested, - uniqTerms -} from "rdf-terms"; -import { filterMatchingQuotedQuads, getVariables, getDuplicateElementLinks, setMetadata } from '@comunica/bus-query-source-identify'; -import {KeysQueryOperation} from "@comunica/context-entries"; -import {StreamingStore} from "@incremunica/incremental-rdf-streaming-store"; -import { ClosableIterator } from '@comunica/bus-query-operation'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {Duplex, Transform} from "readable-stream"; + uniqTerms, +} from 'rdf-terms'; +import { Factory } from 'sparqlalgebrajs'; +import type { Algebra } from 'sparqlalgebrajs'; const AF = new Factory(); const DF = new DataFactory(); @@ -85,7 +92,7 @@ export class StreamingQuerySourceRdfJs implements IQuerySource { StreamingQuerySourceRdfJs.nullifyVariables(operation.object, false), StreamingQuerySourceRdfJs.nullifyVariables(operation.graph, false), matchOptions, - ) + ); if (context) { const matchOptionsArray: ({ stopMatch: () => void })[] | undefined = context.get( @@ -96,7 +103,7 @@ export class StreamingQuerySourceRdfJs implements IQuerySource { } } - let quads = filterMatchingQuotedQuads(operation, wrapAsyncIterator(rawStream, { autoStart: false })); + const quads = filterMatchingQuotedQuads(operation, wrapAsyncIterator(rawStream, { autoStart: false })); // Set up-to-date property quads.setProperty('up-to-date', true); @@ -129,7 +136,7 @@ export class StreamingQuerySourceRdfJs implements IQuerySource { // TODO implement setMetadata make a proper estimation for the cardinality protected async setMetadata( it: AsyncIterator, - operation: Algebra.Pattern, + _operation: Algebra.Pattern, ): Promise { const cardinality = 1; @@ -165,7 +172,7 @@ export class StreamingQuerySourceRdfJs implements IQuerySource { return `StreamingQuerySourceRdfJs(${this.store.constructor.name})`; } - static quadsToBindings( + private static quadsToBindings( quads: AsyncIterator, pattern: Algebra.Pattern, bindingsFactory: BindingsFactory, @@ -174,8 +181,8 @@ export class StreamingQuerySourceRdfJs implements IQuerySource { const variables = getVariables(pattern); // If non-default-graph triples need to be filtered out - const filterNonDefaultQuads = pattern.graph.termType === 'Variable' - && !unionDefaultGraph; + const filterNonDefaultQuads = pattern.graph.termType === 'Variable' && + !unionDefaultGraph; // Detect duplicate variables in the pattern const duplicateElementLinks: Record | undefined = getDuplicateElementLinks(pattern); @@ -220,21 +227,28 @@ export class StreamingQuerySourceRdfJs implements IQuerySource { } // Wrap it in a ClosableIterator, so we can propagate destroy calls - const bindingsStream = new ClosableIterator(filteredOutput.map(quad => { - return bindingsFactory - .bindings(Object.keys(elementVariables).map((key) => { - const keys: QuadTermName[] = key.split('_'); - const variable = elementVariables[key]; - const term = getValueNestedPath(quad, keys); - return [ DF.variable(variable), term ]; - //TODO write a test for this - })).setContextEntry(new ActionContextKeyIsAddition(), ((quad).diff == undefined)? true : (quad).diff); - }), { + const bindingsStream = new ClosableIterator(filteredOutput.map(quad => bindingsFactory + .bindings(Object.keys(elementVariables).map((key) => { + const keys: QuadTermName[] = key.split('_'); + const variable = elementVariables[key]; + const term = getValueNestedPath(quad, keys); + return [ DF.variable(variable), term ]; + // TODO write a test for this + })).setContextEntry( + new ActionContextKeyIsAddition(), + ((quad).diff === undefined) ? true : (quad).diff, + )), { onClose: () => quads.destroy(), }); // Set the metadata property - setMetadata(bindingsStream, quads, elementVariables, variables, filterNonDefaultQuads || Boolean(duplicateElementLinks)); + setMetadata( + bindingsStream, + quads, + elementVariables, + variables, + filterNonDefaultQuads || Boolean(duplicateElementLinks), + ); return bindingsStream; } diff --git a/packages/actor-query-source-identify-streaming-rdfjs/package.json b/packages/actor-query-source-identify-streaming-rdfjs/package.json index 83f0b39d..1214d6dc 100644 --- a/packages/actor-query-source-identify-streaming-rdfjs/package.json +++ b/packages/actor-query-source-identify-streaming-rdfjs/package.json @@ -3,47 +3,56 @@ "version": "1.3.0", "description": "A Streaming rdfjs query-source-identify actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-query-source-identify-streaming-rdfjs" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "query-source-identify", "streaming-rdfjs" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", + "@comunica/bus-merge-bindings-context": "^3.3.0", + "@comunica/bus-query-operation": "^3.3.0", + "@comunica/bus-query-source-identify": "^3.3.0", + "@comunica/context-entries": "^3.3.0", "@comunica/core": "^3.2.1", "@comunica/metadata": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/context-entries": "^1.3.0", "@incremunica/incremental-rdf-streaming-store": "^1.3.0", "@incremunica/incremental-types": "^1.3.0", "@rdfjs/types": "*", - "asynciterator": "^3.9.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" + "asynciterator": "^3.9.0", + "rdf-data-factory": "^1.1.2", + "rdf-terms": "^1.11.0", + "sparqlalgebrajs": "^4.3.8" } } diff --git a/packages/actor-query-source-identify-streaming-rdfjs/test/StreamingQuerySourceRdfJs-test.ts b/packages/actor-query-source-identify-streaming-rdfjs/test/StreamingQuerySourceRdfJs-test.ts index 8db13b4b..b23126df 100644 --- a/packages/actor-query-source-identify-streaming-rdfjs/test/StreamingQuerySourceRdfJs-test.ts +++ b/packages/actor-query-source-identify-streaming-rdfjs/test/StreamingQuerySourceRdfJs-test.ts @@ -1,20 +1,20 @@ import { Readable } from 'node:stream'; -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import { KeysQueryOperation } from '@comunica/context-entries'; import { ActionContext } from '@comunica/core'; import { MetadataValidationState } from '@comunica/metadata'; import type { IActionContext } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store'; +import type { Quad } from '@incremunica/incremental-types'; import arrayifyStream from 'arrayify-stream'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { Factory } from 'sparqlalgebrajs'; import { StreamingQuerySourceRdfJs } from '../lib'; import '@incremunica/incremental-jest'; -import {StreamingStore} from "@incremunica/incremental-rdf-streaming-store"; -import {Quad} from "@incremunica/incremental-types"; import 'jest-rdf'; -import {DevTools} from "@incremunica/dev-tools"; -import {ArrayIterator} from "asynciterator"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; const quad = require('rdf-quad'); @@ -26,8 +26,8 @@ describe('StreamingQuerySourceRdfJs', () => { let store: StreamingStore; let source: StreamingQuerySourceRdfJs; - let BF: BindingsFactory - beforeEach(async () => { + let BF: BindingsFactory; + beforeEach(async() => { ctx = new ActionContext({}); store = new StreamingStore(); BF = await DevTools.createBindingsFactory(DF); @@ -85,15 +85,15 @@ describe('StreamingQuerySourceRdfJs', () => { o: DF.namedNode('o1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'exact', value: 2 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'exact', value: 2 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o') ], + // }); + // }); it('should return triples in a named graph', async() => { @@ -138,15 +138,15 @@ describe('StreamingQuerySourceRdfJs', () => { g: DF.namedNode('g1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'estimate', value: 2 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o'), DF.variable('g') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'estimate', value: 2 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o'), DF.variable('g') ], + // }); + // }); it('should return quads in named graphs and the default graph with union default graph', async() => { @@ -173,15 +173,15 @@ describe('StreamingQuerySourceRdfJs', () => { g: DF.namedNode('g1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'exact', value: 2 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o'), DF.variable('g') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'exact', value: 2 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o'), DF.variable('g') ], + // }); + // }); it('should use countQuads if available', async() => { @@ -206,15 +206,15 @@ describe('StreamingQuerySourceRdfJs', () => { o: DF.namedNode('o1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'exact', value: 123 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'exact', value: 123 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o') ], + // }); + // }); it('should fallback to match if countQuads is not available', async() => { @@ -241,15 +241,15 @@ describe('StreamingQuerySourceRdfJs', () => { o: DF.namedNode('o1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'exact', value: 2 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'exact', value: 2 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o') ], + // }); + // }); it('should delegate errors', async() => { @@ -312,15 +312,15 @@ describe('StreamingQuerySourceRdfJs', () => { o: DF.namedNode('o1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'exact', value: 3 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'exact', value: 3 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o') ], + // }); + // }); it('should run when containing quoted triples with a quoted pattern (1)', async() => { @@ -513,15 +513,15 @@ describe('StreamingQuerySourceRdfJs', () => { o: DF.namedNode('o1'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'exact', value: 3 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('o') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'exact', value: 3 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('o') ], + // }); + // }); it('should run when containing quoted triples with a quoted pattern (1)', async() => { @@ -556,16 +556,16 @@ describe('StreamingQuerySourceRdfJs', () => { o1: DF.namedNode('oa3'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'estimate', value: 3 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('s1'), DF.variable('p1'), DF.variable('o1') ], - }); - - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'estimate', value: 3 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('s1'), DF.variable('p1'), DF.variable('o1') ], + // }); + // + // }); it('should run when containing quoted triples with a quoted pattern (2)', async() => { @@ -600,15 +600,15 @@ describe('StreamingQuerySourceRdfJs', () => { o1: DF.namedNode('ob3'), }).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - /* - await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves - .toEqual({ - cardinality: { type: 'estimate', value: 5 }, - canContainUndefs: false, - state: expect.any(MetadataValidationState), - variables: [ DF.variable('s'), DF.variable('p'), DF.variable('s1'), DF.variable('o1') ], - }); - */ + // + // await expect(new Promise(resolve => data.getProperty('metadata', resolve))).resolves + // .toEqual({ + // cardinality: { type: 'estimate', value: 5 }, + // canContainUndefs: false, + // state: expect.any(MetadataValidationState), + // variables: [ DF.variable('s'), DF.variable('p'), DF.variable('s1'), DF.variable('o1') ], + // }); + // }); }); }); diff --git a/packages/actor-rdf-join-incremental-minus-hash/README.md b/packages/actor-rdf-join-incremental-minus-hash/README.md index 04a248c5..144b5cdf 100644 --- a/packages/actor-rdf-join-incremental-minus-hash/README.md +++ b/packages/actor-rdf-join-incremental-minus-hash/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-rdf-join-incremental-minus-hash/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-rdf-join-incremental-minus-hash/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-incremental-minus-hash/lib/ActorRdfJoinIncrementalMinusHash.ts b/packages/actor-rdf-join-incremental-minus-hash/lib/ActorRdfJoinIncrementalMinusHash.ts index 2013cd95..80421e4a 100644 --- a/packages/actor-rdf-join-incremental-minus-hash/lib/ActorRdfJoinIncrementalMinusHash.ts +++ b/packages/actor-rdf-join-incremental-minus-hash/lib/ActorRdfJoinIncrementalMinusHash.ts @@ -1,11 +1,11 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { IActionRdfJoin, IActorRdfJoinArgs, IActorRdfJoinOutputInner } from '@comunica/bus-rdf-join'; import { ActorRdfJoin } from '@comunica/bus-rdf-join'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; -import type {BindingsStream, MetadataBindings} from '@comunica/types'; +import type { BindingsStream, MetadataBindings } from '@comunica/types'; import type * as RDF from '@rdfjs/types'; -import { IncrementalMinusHash } from './IncrementalMinusHash'; -import type { Bindings } from '@comunica/bindings-factory'; import type { AsyncIterator } from 'asynciterator'; +import { IncrementalMinusHash } from './IncrementalMinusHash'; /** * An Incremunica Minus Hash RDF Join Actor. @@ -27,7 +27,7 @@ export class ActorRdfJoinIncrementalMinusHash extends ActorRdfJoin { const metadatas = await ActorRdfJoin.getMetadatas(action.entries); const commonVariables: RDF.Variable[] = ActorRdfJoin.overlappingVariables(metadatas); if (commonVariables.length > 0) { - const bindingsStream = new IncrementalMinusHash( + const bindingsStream = new IncrementalMinusHash( >output.bindingsStream, >buffer.bindingsStream, commonVariables, @@ -46,8 +46,8 @@ export class ActorRdfJoinIncrementalMinusHash extends ActorRdfJoin { } protected async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-incremental-minus-hash/lib/IncrementalMinusHash.ts b/packages/actor-rdf-join-incremental-minus-hash/lib/IncrementalMinusHash.ts index df088054..8ced5c2f 100644 --- a/packages/actor-rdf-join-incremental-minus-hash/lib/IncrementalMinusHash.ts +++ b/packages/actor-rdf-join-incremental-minus-hash/lib/IncrementalMinusHash.ts @@ -1,8 +1,8 @@ -import { HashBindings } from '@incremunica/hash-bindings'; import type { Bindings } from '@comunica/bindings-factory'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { HashBindings } from '@incremunica/hash-bindings'; import type * as RDF from '@rdfjs/types'; import { AsyncIterator } from 'asynciterator'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; export class IncrementalMinusHash extends AsyncIterator { private readonly leftIterator: AsyncIterator; @@ -94,7 +94,7 @@ export class IncrementalMinusHash extends AsyncIterator { const matchingBindings = this.leftMemory.get(hash); if (matchingBindings !== undefined) { for (let matchingBinding of matchingBindings) { - //TODO check if the 2 bindings are equal for common variables + // TODO check if the 2 bindings are equal for common variables matchingBinding = matchingBinding.setContextEntry(new ActionContextKeyIsAddition(), false); this.bindingBuffer.push(matchingBinding); } @@ -145,7 +145,7 @@ export class IncrementalMinusHash extends AsyncIterator { } else { for (let i = 0; i < currentArray.length; i++) { if (currentArray[i].equals(element)) { - currentArray[i] = currentArray[currentArray.length - 1]; + currentArray[i] = currentArray.at(-1)!; currentArray.pop(); break; } diff --git a/packages/actor-rdf-join-incremental-minus-hash/package.json b/packages/actor-rdf-join-incremental-minus-hash/package.json index db3c9dc7..9b67954f 100644 --- a/packages/actor-rdf-join-incremental-minus-hash/package.json +++ b/packages/actor-rdf-join-incremental-minus-hash/package.json @@ -3,47 +3,47 @@ "version": "1.3.0", "description": "An incremental-minus-hash rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-incremental-minus-hash" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "incremental-minus-hash" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { "@comunica/bindings-factory": "^3.2.1", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/hash-bindings": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0", "@rdfjs/types": "*", "asynciterator": "^3.9.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-rdf-join-incremental-minus-hash/test/ActorRdfJoinIncrementalMinusHash-test.ts b/packages/actor-rdf-join-incremental-minus-hash/test/ActorRdfJoinIncrementalMinusHash-test.ts index 71ee9120..787843e4 100644 --- a/packages/actor-rdf-join-incremental-minus-hash/test/ActorRdfJoinIncrementalMinusHash-test.ts +++ b/packages/actor-rdf-join-incremental-minus-hash/test/ActorRdfJoinIncrementalMinusHash-test.ts @@ -1,17 +1,17 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; import type { IActionContext } from '@comunica/types'; -import {ArrayIterator} from 'asynciterator'; +import { + ActionContextKeyIsAddition, +} from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { ActorRdfJoinIncrementalMinusHash } from '../lib/ActorRdfJoinIncrementalMinusHash'; import '@comunica/jest'; -import { - ActionContextKeyIsAddition -} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; const DF = new DataFactory(); @@ -20,8 +20,8 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { let context: IActionContext; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); context = new ActionContext(); BF = await DevTools.createBindingsFactory(DF); }); @@ -29,18 +29,21 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { describe('An ActorRdfJoinIncrementalMinusHash instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, +IActorTest, +IActorRdfJoinSelectivityOutput +>; let actor: ActorRdfJoinIncrementalMinusHash; beforeEach(() => { mediatorJoinSelectivity = { - mediate: async () => ({selectivity: 1}), + mediate: async() => ({ selectivity: 1 }), }; - actor = new ActorRdfJoinIncrementalMinusHash({name: 'actor', bus, mediatorJoinSelectivity}); + actor = new ActorRdfJoinIncrementalMinusHash({ name: 'actor', bus, mediatorJoinSelectivity }); }); describe('test', () => { - it('should not test on zero entries', async () => { + it('should not test on zero entries', async() => { await expect(actor.test({ type: 'minus', entries: [], @@ -48,7 +51,7 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { })).rejects.toThrow('actor requires at least two join entries.'); }); - it('should not test on one entry', async () => { + it('should not test on one entry', async() => { await expect(actor.test({ type: 'minus', entries: [{}], @@ -56,7 +59,7 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { })).rejects.toThrow('actor requires at least two join entries.'); }); - it('should not test on three entries', async () => { + it('should not test on three entries', async() => { await expect(actor.test({ type: 'minus', entries: [{}, {}, {}], @@ -64,7 +67,7 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { })).rejects.toThrow('actor requires 2 join entries at most. The input contained 3.'); }); - it('should not test on a non-minus operation', async () => { + it('should not test on a non-minus operation', async() => { await expect(actor.test({ type: 'inner', entries: [{}, {}], @@ -72,15 +75,15 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { })).rejects.toThrow(`actor can only handle logical joins of type 'minus', while 'inner' was given.`); }); - it('should test on two entries with undefs', async () => { - expect(await actor.test({ + it('should test on two entries with undefs', async() => { + await expect(actor.test({ type: 'minus', entries: [ { output: { type: 'bindings', metadata: () => Promise.resolve( - {cardinality: 4, pageSize: 100, requestTime: 10, canContainUndefs: true}, + { cardinality: 4, pageSize: 100, requestTime: 10, canContainUndefs: true }, ), }, }, @@ -88,13 +91,13 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { output: { type: 'bindings', metadata: () => Promise.resolve( - {cardinality: 4, pageSize: 100, requestTime: 10, canContainUndefs: true}, + { cardinality: 4, pageSize: 100, requestTime: 10, canContainUndefs: true }, ), }, }, ], context, - })).toEqual({ + })).resolves.toEqual({ iterations: 0, blockingItems: 0, persistedItems: 0, @@ -102,15 +105,15 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }); }); - it('should test on two entries', async () => { - expect(await actor.test({ + it('should test on two entries', async() => { + await expect(actor.test({ type: 'minus', entries: [ { output: { type: 'bindings', metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, pageSize: 100, requestTime: 10, canContainUndefs: false, @@ -121,7 +124,7 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { output: { type: 'bindings', metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, pageSize: 100, requestTime: 10, canContainUndefs: false, @@ -130,7 +133,7 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }, ], context, - })).toEqual({ + })).resolves.toEqual({ iterations: 0, blockingItems: 0, persistedItems: 0, @@ -140,21 +143,27 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }); describe('getOutput', () => { - it('should handle entries with common variables', async () => { + it('should handle entries with common variables', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -163,13 +172,17 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -178,32 +191,40 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await result.metadata()) - .toEqual({cardinality: 3, canContainUndefs: false, variables: [DF.variable('a')]}); + expect(result.type).toBe('bindings'); + await expect(result.metadata()).resolves + .toEqual({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); await expect(result.bindingsStream).toEqualBindingsStream([ - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); }); - it('should handle entries with common variables and deletions', async () => { + it('should handle entries with common variables and deletions', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -212,19 +233,29 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), null, null, - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), null, - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([[DF.variable('a'), DF.literal('0')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('0') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -233,48 +264,62 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); + expect(result.type).toBe('bindings'); await expect(result.bindingsStream).toEqualBindingsStream([ BF.bindings([ - [DF.variable('a'), DF.literal('2')] + [ DF.variable('a'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('2')] + [ DF.variable('a'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('a'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('3')] + [ DF.variable('a'), DF.literal('3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('2')] + [ DF.variable('a'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); }); - it('should handle entries with common variables and deletions II', async () => { + it('should handle entries with common variables and deletions II', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('0')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('0') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -283,14 +328,18 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), null, - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -299,21 +348,21 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); + expect(result.type).toBe('bindings'); await expect(result.bindingsStream).toEqualBindingsStream([ BF.bindings([ - [DF.variable('a'), DF.literal('3')] + [ DF.variable('a'), DF.literal('3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('3')] + [ DF.variable('a'), DF.literal('3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); }); - it('should handle entries with common variables and deletions III', async () => { + it('should handle entries with common variables and deletions III', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ @@ -321,22 +370,22 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('2')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -348,15 +397,23 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { null, null, null, - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -365,43 +422,45 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); + expect(result.type).toBe('bindings'); await expect(result.bindingsStream).toEqualBindingsStream([ BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('2')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('a'), DF.literal('1')], - [DF.variable('b'), DF.literal('2')] + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); }); - it('should return null on ended', async () => { + it('should return null on ended', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -410,12 +469,14 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -424,28 +485,32 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); + expect(result.type).toBe('bindings'); await expect(result.bindingsStream).toEqualBindingsStream([]); - await expect(result.bindingsStream.read()).toEqual(null); + expect(result.bindingsStream.read()).toBeNull(); }); - it('should be able to end when buffer is full', async () => { + it('should be able to end when buffer is full', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -454,15 +519,19 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), null, null, - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -471,18 +540,18 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(action.entries[0].output.bindingsStream.readable = false); - expect(action.entries[1].output.bindingsStream.readable = false); + expect(action.entries[0].output.bindingsStream.readable).toBeFalsy(); + expect(action.entries[1].output.bindingsStream.readable).toBeFalsy(); await new Promise(resolve => setTimeout(resolve, 0)); - expect(action.entries[0].output.bindingsStream.readable = true); - expect(action.entries[1].output.bindingsStream.readable = true); + expect(action.entries[0].output.bindingsStream.readable).toBeTruthy(); + expect(action.entries[1].output.bindingsStream.readable).toBeTruthy(); await new Promise(resolve => setTimeout(resolve, 0)); expect(result.bindingsStream.read()) .toEqualBindings(BF.bindings([ - [DF.variable('a'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); action.entries[0].output.bindingsStream.close(); action.entries[1].output.bindingsStream.close(); @@ -492,25 +561,25 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { expect(result.bindingsStream.ended).toBeFalsy(); expect(result.bindingsStream.read()) .toEqualBindings(BF.bindings([ - [DF.variable('a'), DF.literal('1')] + [ DF.variable('a'), DF.literal('1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)); - expect(result.bindingsStream.read()).toEqual(null); + expect(result.bindingsStream.read()).toBeNull(); expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); expect(result.bindingsStream.ended).toBeTruthy(); }); - it('should be not readable if both inputs are not readable', async () => { + it('should be not readable if both inputs are not readable', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -518,11 +587,11 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }, { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -533,22 +602,22 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }; action.entries[0].output.bindingsStream.readable = false; action.entries[1].output.bindingsStream.readable = false; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); await new Promise(resolve => setTimeout(resolve, 0)); expect(result.bindingsStream.readable).toBeFalsy(); }); - it('should be readable if input 1 is readable', async () => { + it('should be readable if input 1 is readable', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -556,11 +625,11 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }, { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -571,22 +640,22 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }; action.entries[0].output.bindingsStream.readable = true; action.entries[1].output.bindingsStream.readable = false; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); await new Promise(resolve => setTimeout(resolve, 0)); expect(result.bindingsStream.readable).toBeTruthy(); }); - it('should be readable if input 2 is readable', async () => { + it('should be readable if input 2 is readable', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -594,11 +663,11 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }, { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -609,22 +678,22 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }; action.entries[0].output.bindingsStream.readable = false; action.entries[1].output.bindingsStream.readable = true; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); await new Promise(resolve => setTimeout(resolve, 0)); expect(result.bindingsStream.readable).toBeTruthy(); }); - it('should handle errors from right iterator', async () => { + it('should handle errors from right iterator', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -632,11 +701,11 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }, { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -645,26 +714,26 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); - let promise = new Promise(resolve => result.bindingsStream.on("error", (e) => { - expect(e.message).toEqual("Test error"); + const { result } = await actor.getOutput(action); + const promise = new Promise(resolve => result.bindingsStream.on('error', (e) => { + expect(e.message).toBe('Test error'); resolve(); })); - action.entries[0].output.bindingsStream.destroy(new Error("Test error")); + action.entries[0].output.bindingsStream.destroy(new Error('Test error')); await promise; }); - it('should handle errors from left iterator', async () => { + it('should handle errors from left iterator', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -672,11 +741,11 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { }, { output: { - bindingsStream: new ArrayIterator([], {autoStart: false}), + bindingsStream: new ArrayIterator([], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -685,30 +754,36 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); - let promise = new Promise(resolve => result.bindingsStream.on("error", (e) => { - expect(e.message).toEqual("Test error"); + const { result } = await actor.getOutput(action); + const promise = new Promise(resolve => result.bindingsStream.on('error', (e) => { + expect(e.message).toBe('Test error'); resolve(); })); - action.entries[1].output.bindingsStream.destroy(new Error("Test error")); + action.entries[1].output.bindingsStream.destroy(new Error('Test error')); await promise; }); - it('should handle entries without common variables', async () => { + it('should handle entries without common variables', async() => { const action: IActionRdfJoin = { type: 'minus', entries: [ { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -717,13 +792,17 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { { output: { bindingsStream: new ArrayIterator([ - BF.bindings([[DF.variable('b'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('b'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + BF.bindings([ + [ DF.variable('b'), DF.literal('1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: 2, canContainUndefs: false, - variables: [DF.variable('b')], + variables: [ DF.variable('b') ], }), type: 'bindings', }, @@ -732,20 +811,18 @@ describe('ActorRdfJoinIncrementalMinusHash', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await result.metadata()) - .toEqual({cardinality: 3, canContainUndefs: false, variables: [DF.variable('a')]}); + expect(result.type).toBe('bindings'); + await expect(result.metadata()).resolves + .toEqual({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('a') ]}); await expect(result.bindingsStream).toEqualBindingsStream([ - BF.bindings([[DF.variable('a'), DF.literal('1')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('2')]]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([[DF.variable('a'), DF.literal('3')]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('1') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('2') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([[ DF.variable('a'), DF.literal('3') ]]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); }); - - }); }); }); diff --git a/packages/actor-rdf-join-incremental-optional-hash/README.md b/packages/actor-rdf-join-incremental-optional-hash/README.md index d1dd8bb9..93b3639e 100644 --- a/packages/actor-rdf-join-incremental-optional-hash/README.md +++ b/packages/actor-rdf-join-incremental-optional-hash/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-rdf-join-incremental-optional-hash/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-rdf-join-incremental-optional-hash/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-incremental-optional-hash/lib/ActorRdfJoinIncrementalOptionalHash.ts b/packages/actor-rdf-join-incremental-optional-hash/lib/ActorRdfJoinIncrementalOptionalHash.ts index 74755ec8..c09f00b8 100644 --- a/packages/actor-rdf-join-incremental-optional-hash/lib/ActorRdfJoinIncrementalOptionalHash.ts +++ b/packages/actor-rdf-join-incremental-optional-hash/lib/ActorRdfJoinIncrementalOptionalHash.ts @@ -1,11 +1,10 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { IActionRdfJoin, IActorRdfJoinArgs, IActorRdfJoinOutputInner } from '@comunica/bus-rdf-join'; import { ActorRdfJoin } from '@comunica/bus-rdf-join'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; -import type { MetadataBindings } from '@comunica/types'; -import { IncrementalOptionalHash } from './IncrementalOptionalHash'; -import type { Bindings } from '@comunica/bindings-factory'; +import type { MetadataBindings, BindingsStream } from '@comunica/types'; import type { AsyncIterator } from 'asynciterator'; -import type {BindingsStream} from '@comunica/types'; +import { IncrementalOptionalHash } from './IncrementalOptionalHash'; /** * An Incremunica Optional Hash RDF Join Actor. @@ -23,7 +22,7 @@ export class ActorRdfJoinIncrementalOptionalHash extends ActorRdfJoin { protected async getOutput(action: IActionRdfJoin): Promise { const metadatas = await ActorRdfJoin.getMetadatas(action.entries); const variables = ActorRdfJoin.overlappingVariables(metadatas); - const bindingsStream = new IncrementalOptionalHash( + const bindingsStream = new IncrementalOptionalHash( >action.entries[0].output.bindingsStream, >action.entries[1].output.bindingsStream, entry => ActorRdfJoinIncrementalOptionalHash.hash(entry, variables), @@ -43,8 +42,8 @@ export class ActorRdfJoinIncrementalOptionalHash extends ActorRdfJoin { } protected async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-incremental-optional-hash/lib/IncrementalOptionalHash.ts b/packages/actor-rdf-join-incremental-optional-hash/lib/IncrementalOptionalHash.ts index 2a158c97..03462ad3 100644 --- a/packages/actor-rdf-join-incremental-optional-hash/lib/IncrementalOptionalHash.ts +++ b/packages/actor-rdf-join-incremental-optional-hash/lib/IncrementalOptionalHash.ts @@ -1,6 +1,7 @@ +import type { Bindings } from '@comunica/bindings-factory'; +import { BindingsFactory } from '@comunica/bindings-factory'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { IncrementalInnerJoin } from '@incremunica/incremental-inner-join'; -import {Bindings, BindingsFactory} from '@comunica/bindings-factory'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; import type { AsyncIterator } from 'asynciterator'; export class IncrementalOptionalHash extends IncrementalInnerJoin { @@ -58,7 +59,7 @@ export class IncrementalOptionalHash extends IncrementalInnerJoin { const index = array.findIndex((bindings: Bindings) => item.equals(bindings)); if (index !== -1) { - array[index] = array[array.length - 1]; + array[index] = array.at(-1)!; array.pop(); return true; } @@ -66,7 +67,6 @@ export class IncrementalOptionalHash extends IncrementalInnerJoin { } public read(): Bindings | null { - // eslint-disable-next-line no-constant-condition while (true) { if (this.ended) { return null; @@ -125,7 +125,9 @@ export class IncrementalOptionalHash extends IncrementalInnerJoin { if (this.addOrDeleteFromMemory(item, hash, this.rightMemory)) { const otherArray = this.leftMemory.get(hash); if (otherArray !== undefined) { - if (item.getContextEntry(new ActionContextKeyIsAddition()) && (rightMemEl === undefined || rightMemEl.length === 0)) { + if ( + item.getContextEntry(new ActionContextKeyIsAddition()) && + (rightMemEl === undefined || rightMemEl.length === 0)) { this.prependArray = true; } if (!item.getContextEntry(new ActionContextKeyIsAddition()) && this.rightMemory.get(hash)?.length === 1) { @@ -143,12 +145,11 @@ export class IncrementalOptionalHash extends IncrementalInnerJoin { const hash = this.funHash(item); if (this.addOrDeleteFromMemory(item, hash, this.leftMemory)) { const otherArray = this.rightMemory.get(hash); - if (otherArray !== undefined) { - this.activeElement = item; - this.otherArray = otherArray; - } else { + if (otherArray === undefined) { return item; } + this.activeElement = item; + this.otherArray = otherArray; } continue; } diff --git a/packages/actor-rdf-join-incremental-optional-hash/package.json b/packages/actor-rdf-join-incremental-optional-hash/package.json index 2b6f2231..6fc4e20e 100644 --- a/packages/actor-rdf-join-incremental-optional-hash/package.json +++ b/packages/actor-rdf-join-incremental-optional-hash/package.json @@ -3,44 +3,46 @@ "version": "1.3.0", "description": "An incremental-optional-hash rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-incremental-optional-hash" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "incremental-optional-hash" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/incremental-inner-join": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" + "asynciterator": "^3.9.0" } } diff --git a/packages/actor-rdf-join-incremental-optional-hash/test/ActorRdfJoinIncrementalOptionalHash-test.ts b/packages/actor-rdf-join-incremental-optional-hash/test/ActorRdfJoinIncrementalOptionalHash-test.ts index c0d1de26..aff96fae 100644 --- a/packages/actor-rdf-join-incremental-optional-hash/test/ActorRdfJoinIncrementalOptionalHash-test.ts +++ b/packages/actor-rdf-join-incremental-optional-hash/test/ActorRdfJoinIncrementalOptionalHash-test.ts @@ -1,21 +1,21 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import { ActorRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; import type { IQueryOperationResultBindings, Bindings, IActionContext } from '@comunica/types'; +import { + ActionContextKeyIsAddition, +} from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; import type * as RDF from '@rdfjs/types'; import arrayifyStream from 'arrayify-stream'; -import {ArrayIterator} from 'asynciterator'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import '@incremunica/incremental-jest'; -import { MetadataValidationState } from '@comunica/metadata'; -import {ActorRdfJoinIncrementalOptionalHash} from "../lib/ActorRdfJoinIncrementalOptionalHash"; -import { - ActionContextKeyIsAddition -} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; +import { ActorRdfJoinIncrementalOptionalHash } from '../lib/ActorRdfJoinIncrementalOptionalHash'; const DF = new DataFactory(); @@ -24,8 +24,8 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { let context: IActionContext; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); context = new ActionContext(); BF = await DevTools.createBindingsFactory(DF); }); @@ -36,19 +36,26 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { }); it('should be a ActorRdfJoinIncrementalOptionalHash constructor', () => { - expect(new ( ActorRdfJoinIncrementalOptionalHash)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoinIncrementalOptionalHash); - expect(new ( ActorRdfJoinIncrementalOptionalHash)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoin); + expect(new ( ActorRdfJoinIncrementalOptionalHash)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoinIncrementalOptionalHash); + expect(new ( ActorRdfJoinIncrementalOptionalHash)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoin); }); it('should not be able to create new ActorRdfJoinIncrementalOptionalHash objects without \'new\'', () => { - expect(() => { ( ActorRdfJoinIncrementalOptionalHash)(); }).toThrow(); + expect(() => { + ( ActorRdfJoinIncrementalOptionalHash)(); + }).toThrow(''); }); }); describe('An ActorRdfJoinIncrementalOptionalHash instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, +IActorTest, +IActorRdfJoinSelectivityOutput +>; let actor: ActorRdfJoinIncrementalOptionalHash; let action: IActionRdfJoin; let variables0: RDF.Variable[]; @@ -101,37 +108,39 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { describe('should test', () => { afterEach(() => { - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } }); - it('should only handle 2 streams', () => { - action.entries.push( {}); - return expect(actor.test(action)).rejects.toBeTruthy(); + it('should only handle 2 streams', async() => { + action.entries.push({}); + await expect(actor.test(action)).rejects.toBeTruthy(); }); - it('should fail on undefs in left stream', () => { + it('should fail on undefs in left stream', async() => { action.entries[0].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); - it('should fail on undefs in right stream', () => { + it('should fail on undefs in right stream', async() => { action.entries[1].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); - it('should fail on undefs in left and right stream', () => { + it('should fail on undefs in left and right stream', async() => { action.entries[0].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, @@ -144,7 +153,7 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); @@ -155,34 +164,38 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { it('should generate correct metadata', async() => { await actor.run(action).then(async(result: IQueryOperationResultBindings) => { - await expect(( result).metadata()).resolves.toHaveProperty('cardinality', - { type: 'estimate', + await expect(( result).metadata()).resolves.toHaveProperty( + 'cardinality', + { + type: 'estimate', value: (await ( action.entries[0].output).metadata()).cardinality.value * - (await ( action.entries[1].output).metadata()).cardinality.value }); + (await ( action.entries[1].output).metadata()).cardinality.value, + }, + ); await expect(result.bindingsStream).toEqualBindingsStream([]); }); }); - it('should return an empty stream for empty input', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + it('should return an empty stream for empty input', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should return null on read if join has ended', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - expect(output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.read()).toBeNull(); - }); + it('should return null on read if join has ended', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); + expect(output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.read()).toBeNull(); }); - it('should end after both streams are ended and no new elements can be generated', () => { + it('should end after both streams are ended and no new elements can be generated', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -202,21 +215,22 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - output.bindingsStream.read(); - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); - expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.ended).toBeFalsy(); - await arrayifyStream(output.bindingsStream) - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(output.bindingsStream.ended).toBeTruthy(); - }); + const output = await actor.run(action); + output.bindingsStream.read(); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); + expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.ended).toBeFalsy(); + await arrayifyStream(output.bindingsStream); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(output.bindingsStream.ended).toBeTruthy(); }); - it('should join bindings with matching values', () => { + it('should join bindings with matching values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -232,21 +246,22 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([ - BF.bindings([ - [ DF.variable('a'), DF.literal('a') ], - [ DF.variable('b'), DF.literal('b') ], - [ DF.variable('c'), DF.literal('c') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([ + BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + [ DF.variable('b'), DF.literal('b') ], + [ DF.variable('c'), DF.literal('c') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); }); - it('should return bindings from input 1 if incompatible values', () => { + it('should return bindings from input 1 if incompatible values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -262,20 +277,21 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([ - BF.bindings([ - [ DF.variable('a'), DF.literal('a') ], - [ DF.variable('b'), DF.literal('b') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([ + BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + [ DF.variable('b'), DF.literal('b') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); }); - it('should join multiple bindings', () => { + it('should join multiple bindings', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -331,61 +347,61 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('4') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('4') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (left) right first', () => { + it('should join multiple bindings with negative bindings (left) right first', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -425,53 +441,54 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (left) left first', () => { + it('should join multiple bindings with negative bindings (left) left first', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -516,49 +533,50 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (right) right first', () => { + it('should join multiple bindings with negative bindings (right) right first', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -598,33 +616,34 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (right) left first', () => { + it('should join multiple bindings with negative bindings (right) left first', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -667,97 +686,98 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (left)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -789,30 +809,31 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (right)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -844,35 +865,36 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('b') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('b') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should be symmetric', () => { + it('should be symmetric', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -885,8 +907,8 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { setTimeout(() => { push(item); done(); - }, 100) - } + }, 100); + }, }); variables0 = [ DF.variable('a'), DF.variable('b') ]; action.entries[1].output.bindingsStream = new ArrayIterator([ @@ -896,26 +918,23 @@ describe('ActorRdfJoinIncrementalOptionalHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - }); }); diff --git a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/README.md b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/README.md index 4e4be4c5..a89f1c24 100644 --- a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/README.md +++ b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-computational-multi-bind/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-computational-multi-bind/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/lib/ActorRdfJoinInnerIncrementalComputationalMultiBind.ts b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/lib/ActorRdfJoinInnerIncrementalComputationalMultiBind.ts index 3e6efca9..d16162a6 100644 --- a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/lib/ActorRdfJoinInnerIncrementalComputationalMultiBind.ts +++ b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/lib/ActorRdfJoinInnerIncrementalComputationalMultiBind.ts @@ -1,3 +1,5 @@ +import type { Bindings } from '@comunica/bindings-factory'; +import { BindingsFactory } from '@comunica/bindings-factory'; import type { MediatorQueryOperation } from '@comunica/bus-query-operation'; import { ActorQueryOperation, materializeOperation } from '@comunica/bus-query-operation'; import type { IActionRdfJoin, IActorRdfJoinArgs, IActorRdfJoinOutputInner } from '@comunica/bus-rdf-join'; @@ -13,14 +15,13 @@ import type { IQueryOperationResultBindings, MetadataBindings, } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { KeysStreamingSource } from '@incremunica/context-entries'; import { HashBindings } from '@incremunica/hash-bindings'; import { TransformIterator, UnionIterator } from 'asynciterator'; +import type { AsyncIterator } from 'asynciterator'; import type { Algebra } from 'sparqlalgebrajs'; import { Factory } from 'sparqlalgebrajs'; -import {BindingsFactory, Bindings} from "@comunica/bindings-factory"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import type { AsyncIterator } from 'asynciterator'; /** * A comunica Multi-way Bind RDF Join Actor. @@ -75,7 +76,7 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf optional: boolean, sources: any, ): Promise> { - //TODO change to BindingsFactory.create() + // TODO change to BindingsFactory.create() const bindingsFactory = new BindingsFactory(); const transformMap = new Map< string, @@ -85,12 +86,17 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf stopFunction: (() => void); }[]; subOperations: Algebra.Operation[]; - }>(); + } +>(); const hashBindings = new HashBindings(); // Create bindings function - const binder = async(bindings: Bindings, done: () => void, push: (i: AsyncIterator) => void): Promise => { + const binder = async( + bindings: Bindings, + done: () => void, + push: (i: AsyncIterator) => void, + ): Promise => { const hash = hashBindings.hash(bindings); let hashData = transformMap.get(hash); if (bindings.getContextEntry(new ActionContextKeyIsAddition())) { @@ -109,7 +115,7 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf const bindingsMerger = (subBindings: Bindings): Bindings | null => { const subBindingsOrUndefined = subBindings.merge(bindings); - return subBindingsOrUndefined === undefined ? null : subBindingsOrUndefined; + return subBindingsOrUndefined ?? null; }; const [ bindingStream, stopFunction ] = await operationBinder(hashData.subOperations, bindings); @@ -118,12 +124,12 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf iterator: bindingStream.map(bindingsMerger), }); - push(hashData.elements[hashData.elements.length - 1].iterator); + push(hashData.elements.at(-1)!.iterator); done(); return; } if (hashData !== undefined && hashData.elements.length > 0) { - const activeElement = hashData.elements[hashData.elements.length - 1]; + const activeElement = hashData.elements.at(-1)!; hashData.elements.pop(); ActorRdfJoinInnerIncrementalComputationalMultiBind.haltSources(sources); @@ -238,7 +244,7 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf } return leftWithoutCommonVariables ? 1 : - -1; + -1; }); } @@ -264,7 +270,8 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf const subContext = action.context .set(KeysQueryOperation.joinLeftMetadata, entries[0].metadata) .set(KeysQueryOperation.joinRightMetadatas, remainingEntries.map(entry => entry.metadata)); - const bindingsStream = await ActorRdfJoinInnerIncrementalComputationalMultiBind.createBindStream( + const bindingsStream = await ActorRdfJoinInnerIncrementalComputationalMultiBind + .createBindStream( >smallestStream.bindingsStream, remainingEntries.map(entry => entry.operation), async(operations: Algebra.Operation[], operationBindings: Bindings) => { @@ -288,8 +295,8 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf return [ >output.bindingsStream, stopFunction ]; }, false, - sources === undefined ? [] : sources, - ); + sources ?? [], + ); return { result: { @@ -304,8 +311,8 @@ export class ActorRdfJoinInnerIncrementalComputationalMultiBind extends ActorRdf } public async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/package.json b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/package.json index 9fb13f15..4893d3f5 100644 --- a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/package.json +++ b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/package.json @@ -3,50 +3,51 @@ "version": "1.3.0", "description": "A inner-incremental-computational-multi-bind rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-inner-incremental-computational-multi-bind" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "inner-incremental-computational-multi-bind" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-query-operation": "^3.2.2", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/bus-rdf-join-entries-sort": "^3.2.1", - "@comunica/bus-query-source-identify": "^3.2.2", "@comunica/context-entries": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/context-entries": "^1.3.0", "@incremunica/hash-bindings": "^1.3.0", "asynciterator": "^3.9.0", "sparqlalgebrajs": "^4.0.5" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/test/ActorRdfJoinInnerIncrementalComputationalMultiBindJoin-test.ts b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/test/ActorRdfJoinInnerIncrementalComputationalMultiBindJoin-test.ts index 50272318..35ec2ba3 100644 --- a/packages/actor-rdf-join-inner-incremental-computational-multi-bind/test/ActorRdfJoinInnerIncrementalComputationalMultiBindJoin-test.ts +++ b/packages/actor-rdf-join-inner-incremental-computational-multi-bind/test/ActorRdfJoinInnerIncrementalComputationalMultiBindJoin-test.ts @@ -1,37 +1,40 @@ -import { BindingsFactory} from '@comunica/bindings-factory'; +import type { EventEmitter } from 'node:events'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionQueryOperation } from '@comunica/bus-query-operation'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinEntriesSort, MediatorRdfJoinEntriesSort } from '@comunica/bus-rdf-join-entries-sort'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import 'jest-rdf'; +import { KeysQueryOperation } from '@comunica/context-entries'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; -import type {BindingsStream, IActionContext, IQueryOperationResultBindings} from '@comunica/types'; -import {ArrayIterator, WrappingIterator} from 'asynciterator'; +import { MetadataValidationState } from '@comunica/metadata'; +import type { BindingsStream, IActionContext, IQueryOperationResultBindings } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { KeysStreamingSource } from '@incremunica/context-entries'; +import { DevTools } from '@incremunica/dev-tools'; +import arrayifyStream from 'arrayify-stream'; +import { ArrayIterator, WrappingIterator } from 'asynciterator'; +import { promisifyEventEmitter } from 'event-emitter-promisify/dist'; import { DataFactory } from 'rdf-data-factory'; +import type { Stream } from 'readable-stream'; +import { PassThrough } from 'readable-stream'; import { Factory } from 'sparqlalgebrajs'; -import { ActorRdfJoinInnerIncrementalComputationalMultiBind } from '../lib/ActorRdfJoinInnerIncrementalComputationalMultiBind'; +import { + ActorRdfJoinInnerIncrementalComputationalMultiBind, +} from '../lib/ActorRdfJoinInnerIncrementalComputationalMultiBind'; import Mock = jest.Mock; import '@incremunica/incremental-jest'; -import arrayifyStream from "arrayify-stream"; -import {KeysQueryOperation} from "@comunica/context-entries"; -import {EventEmitter} from "events"; -import {PassThrough, Stream} from "readable-stream"; -import {promisifyEventEmitter} from "event-emitter-promisify/dist"; -import { MetadataValidationState } from '@comunica/metadata'; -import {KeysStreamingSource} from "@incremunica/context-entries"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; - const streamifyArray = require('streamify-array'); + const DF = new DataFactory(); const FACTORY = new Factory(); async function partialArrayifyStream(stream: EventEmitter, num: number): Promise { - let array: any[] = []; + const array: any[] = []; for (let i = 0; i < num; i++) { - await new Promise((resolve) => stream.once("data", (bindings: any) => { + await new Promise(resolve => stream.once('data', (bindings: any) => { array.push(bindings); resolve(); })); @@ -39,24 +42,30 @@ async function partialArrayifyStream(stream: EventEmitter, num: number): Promise return array; } - describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { let bus: any; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); BF = await DevTools.createBindingsFactory(DF); }); describe('An ActorRdfJoinIncrementalComputationalMultiBind instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, +IActorTest, +IActorRdfJoinSelectivityOutput +>; let mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort; let context: IActionContext; - let mediatorQueryOperation: Mediator, - IActionQueryOperation, IActorTest, IQueryOperationResultBindings>; + let mediatorQueryOperation: Mediator< + Actor, + IActionQueryOperation, + IActorTest, + IQueryOperationResultBindings + >; let actor: ActorRdfJoinInnerIncrementalComputationalMultiBind; beforeEach(() => { @@ -107,7 +116,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { describe('getJoinCoefficients', () => { it('should handle three entries', async() => { - expect(await actor.getJoinCoefficients( + await expect(actor.getJoinCoefficients( { type: 'inner', entries: [ @@ -152,7 +161,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { variables: [ DF.variable('a') ], }, ], - )).toEqual({ + )).resolves.toEqual({ iterations: 0, persistedItems: 0, blockingItems: 0, @@ -160,194 +169,195 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); }); - /* - it('should handle three entries with a lower variable overlap', async() => { - expect(await actor.getJoinCoefficients( - { - type: 'inner', - entries: [ - { - output: {}, - operation: {}, - }, - { - output: {}, - operation: {}, - }, - { - output: {}, - operation: {}, - }, - ], - context: new ActionContext(), - }, - [ - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a'), DF.variable('b') ], - }, - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a'), DF.variable('b') ], - }, - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 5 }, - pageSize: 100, - requestTime: 30, - canContainUndefs: false, - variables: [ DF.variable('a'), DF.variable('b') ], - }, - ], - )).toEqual({ - iterations: 1.280_000_000_000_000_2, - persistedItems: 0, - blockingItems: 0, - requestTime: 0.440_96, - }); - }); - - it('should reject on a right stream of type extend', async() => { - await expect(actor.getJoinCoefficients( - { - type: 'inner', - entries: [ - { - output: { - metadata: () => Promise.resolve({ - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - canContainUndefs: false, - }), - - }, - operation: { type: Algebra.types.EXTEND }, - }, - { - output: { - metadata: () => Promise.resolve({ - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - canContainUndefs: false, - }), - }, - operation: {}, - }, - ], - context: new ActionContext(), - }, - [ - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, - ], - )).rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); - }); - - it('should reject on a right stream of type group', async() => { - await expect(actor.getJoinCoefficients( - { - type: 'inner', - entries: [ - { - output: {}, - operation: { type: Algebra.types.GROUP }, - }, - { - output: {}, - operation: {}, - }, - ], - context: new ActionContext(), - }, - [ - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a') ]}, - ], - )).rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); - }); - - it('should not reject on a left stream of type group', async() => { - expect(await actor.getJoinCoefficients( - { - type: 'inner', - entries: [ - { - output: {}, - operation: {}, - }, - { - output: {}, - operation: { type: Algebra.types.GROUP }, - }, - ], - context: new ActionContext(), - }, - [ - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, - ], - )).toEqual({ - iterations: 0.480_000_000_000_000_1, - persistedItems: 0, - blockingItems: 0, - requestTime: 0.403_840_000_000_000_03, - }); - }); - */ + // TODO re-enable these tests + // eslint-disable-next-line jest/no-commented-out-tests + // it('should handle three entries with a lower variable overlap', async() => { + // expect(await actor.getJoinCoefficients( + // { + // type: 'inner', + // entries: [ + // { + // output: {}, + // operation: {}, + // }, + // { + // output: {}, + // operation: {}, + // }, + // { + // output: {}, + // operation: {}, + // }, + // ], + // context: new ActionContext(), + // }, + // [ + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 3 }, + // pageSize: 100, + // requestTime: 10, + // canContainUndefs: false, + // variables: [ DF.variable('a'), DF.variable('b') ], + // }, + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 2 }, + // pageSize: 100, + // requestTime: 20, + // canContainUndefs: false, + // variables: [ DF.variable('a'), DF.variable('b') ], + // }, + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 5 }, + // pageSize: 100, + // requestTime: 30, + // canContainUndefs: false, + // variables: [ DF.variable('a'), DF.variable('b') ], + // }, + // ], + // )).toEqual({ + // iterations: 1.280_000_000_000_000_2, + // persistedItems: 0, + // blockingItems: 0, + // requestTime: 0.440_96, + // }); + // }); + // eslint-disable-next-line jest/no-commented-out-tests + // it('should reject on a right stream of type extend', async() => { + // await expect(actor.getJoinCoefficients( + // { + // type: 'inner', + // entries: [ + // { + // output: { + // metadata: () => Promise.resolve({ + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 3 }, + // canContainUndefs: false, + // }), + // + // }, + // operation: { type: Algebra.types.EXTEND }, + // }, + // { + // output: { + // metadata: () => Promise.resolve({ + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 2 }, + // canContainUndefs: false, + // }), + // }, + // operation: {}, + // }, + // ], + // context: new ActionContext(), + // }, + // [ + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 3 }, + // pageSize: 100, + // requestTime: 10, + // canContainUndefs: false, + // variables: [ DF.variable('a') ], + // }, + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 2 }, + // pageSize: 100, + // requestTime: 20, + // canContainUndefs: false, + // variables: [ DF.variable('a') ], + // }, + // ], + // )).rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); + // }); + // eslint-disable-next-line jest/no-commented-out-tests + // it('should reject on a right stream of type group', async() => { + // await expect(actor.getJoinCoefficients( + // { + // type: 'inner', + // entries: [ + // { + // output: {}, + // operation: { type: Algebra.types.GROUP }, + // }, + // { + // output: {}, + // operation: {}, + // }, + // ], + // context: new ActionContext(), + // }, + // [ + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 3 }, + // pageSize: 100, + // requestTime: 10, + // canContainUndefs: false, + // variables: [ DF.variable('a') ], + // }, + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 2 }, + // pageSize: 100, + // requestTime: 20, + // canContainUndefs: false, + // variables: [ DF.variable('a') ]}, + // ], + // )).rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); + // }); + // eslint-disable-next-line jest/no-commented-out-tests + // it('should not reject on a left stream of type group', async() => { + // expect(await actor.getJoinCoefficients( + // { + // type: 'inner', + // entries: [ + // { + // output: {}, + // operation: {}, + // }, + // { + // output: {}, + // operation: { type: Algebra.types.GROUP }, + // }, + // ], + // context: new ActionContext(), + // }, + // [ + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 3 }, + // pageSize: 100, + // requestTime: 10, + // canContainUndefs: false, + // variables: [ DF.variable('a') ], + // }, + // { + // state: new MetadataValidationState(), + // cardinality: { type: 'estimate', value: 2 }, + // pageSize: 100, + // requestTime: 20, + // canContainUndefs: false, + // variables: [ DF.variable('a') ], + // }, + // ], + // )).toEqual({ + // iterations: 0.480_000_000_000_000_1, + // persistedItems: 0, + // blockingItems: 0, + // requestTime: 0.403_840_000_000_000_03, + // }); + // }); + // }); describe('sortJoinEntries', () => { it('sorts 2 entries', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -371,7 +381,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -396,39 +406,38 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); it('sorts 3 entries', async() => { - expect(await actor.sortJoinEntries([ - { - output: {}, - operation: {}, - metadata: { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, + await expect(actor.sortJoinEntries([ + { + output: {}, + operation: {}, + metadata: { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 3 }, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - { - output: {}, - operation: {}, - metadata: { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, + }, + { + output: {}, + operation: {}, + metadata: { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 2 }, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - { - output: {}, - operation: {}, - metadata: { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 5 }, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, + }, + { + output: {}, + operation: {}, + metadata: { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 5 }, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - ], - context)).toEqual([ + }, + ], context)).resolves.toEqual([ { output: {}, operation: {}, @@ -463,7 +472,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); it('sorts 3 equal entries', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -497,7 +506,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -532,7 +541,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); it('does not sort if there is an undef', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -566,7 +575,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -629,7 +638,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); it('sorts entries without common variables in the back', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -663,7 +672,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -698,7 +707,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); it('sorts several entries without variables in the back', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -772,7 +781,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -848,7 +857,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); describe('getOutput', () => { - it('should handle two entries without context', async () => { + it('should handle two entries without context', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -856,20 +865,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], + [ DF.variable('b'), DF.namedNode('ex:b3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -879,17 +888,17 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -898,45 +907,45 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + expect(result.type).toBe('bindings'); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(await result.metadata()).toEqual({ + await expect(result.metadata()).resolves.toEqual({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 2.400_000_000_000_000_4}, + cardinality: { type: 'estimate', value: 2.400_000_000_000_000_4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }); }); - it('should handle three entries', async () => { + it('should handle three entries', async() => { const action: IActionRdfJoin = { context, type: 'inner', @@ -945,20 +954,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], + [ DF.variable('b'), DF.namedNode('ex:b3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -968,20 +977,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:c1')], + [ DF.variable('c'), DF.namedNode('ex:c1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:c2')], + [ DF.variable('c'), DF.namedNode('ex:c2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:c3')], + [ DF.variable('c'), DF.namedNode('ex:c3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('c')], + variables: [ DF.variable('a'), DF.variable('c') ], }), type: 'bindings', }, @@ -991,17 +1000,17 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -1009,41 +1018,41 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }, ], }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + expect(result.type).toBe('bindings'); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(await result.metadata()).toEqual({ + await expect(result.metadata()).resolves.toEqual({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 9.600_000_000_000_001}, + cardinality: { type: 'estimate', value: 9.600_000_000_000_001 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b'), DF.variable('c')], + variables: [ DF.variable('a'), DF.variable('b'), DF.variable('c') ], }); // Validate mock calls @@ -1058,26 +1067,26 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { [KeysStreamingSource.matchOptions.name]: [], [KeysQueryOperation.joinLeftMetadata.name]: { state: expect.any(MetadataValidationState), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }, [KeysQueryOperation.joinRightMetadatas.name]: [ { state: expect.any(MetadataValidationState), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }, { state: expect.any(MetadataValidationState), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('c')], + variables: [ DF.variable('a'), DF.variable('c') ], }, ], [KeysQueryOperation.joinBindings.name]: BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), }), }); @@ -1091,26 +1100,26 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { [KeysStreamingSource.matchOptions.name]: [], [KeysQueryOperation.joinLeftMetadata.name]: { state: expect.any(MetadataValidationState), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }, [KeysQueryOperation.joinRightMetadatas.name]: [ { state: expect.any(MetadataValidationState), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }, { state: expect.any(MetadataValidationState), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('c')], + variables: [ DF.variable('a'), DF.variable('c') ], }, ], [KeysQueryOperation.joinBindings.name]: BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), }), }); @@ -1131,7 +1140,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), @@ -1167,47 +1176,42 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([]); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([]); }); - it("should work if the active iterator ends first", async () => { - let haltMock: Mock; - let resumeMock: Mock; + it('should work if the active iterator ends first', async() => { + const haltMock = jest.fn(); + const resumeMock = jest.fn(); let iterator: BindingsStream; - let stopMatchJest: Mock; - let streams: PassThrough[] = []; + const stopMatchJest = jest.fn(); + const streams: PassThrough[] = []; let num = 0; - haltMock = jest.fn(); - resumeMock = jest.fn(); - - let mockStreamingStore = { + const mockStreamingStore = { halt: haltMock, - resume: resumeMock - } - - stopMatchJest = jest.fn(); + resume: resumeMock, + }; mediatorQueryOperation = { - mediate: jest.fn(async (arg: IActionQueryOperation): Promise => { - const unionStream = new PassThrough({objectMode: true}); + mediate: jest.fn(async(arg: IActionQueryOperation): Promise => { + const unionStream = new PassThrough({ objectMode: true }); const tempStream: Stream = streamifyArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - tempStream.pipe(unionStream, {end: false}); + tempStream.pipe(unionStream, { end: false }); - let stream = new PassThrough({ - objectMode: true + const stream = new PassThrough({ + objectMode: true, }); - stream.pipe(unionStream, {end: false}); + stream.pipe(unionStream, { end: false }); streams.push(stream); let tempEnd = false; @@ -1229,12 +1233,12 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { iterator = new WrappingIterator(unionStream); - let streamNum = num; + const streamNum = num; num++; - let stopMatchfn = () => { - if (streamNum == 0) { + const stopMatchfn = () => { + if (streamNum === 0) { iterator.close(); - iterator.on("end", () => { + iterator.on('end', () => { for (const streami of streams) { if (!streami.closed) { streami.end(); @@ -1243,21 +1247,21 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { }); } stopMatchJest(); - } - let matchOptions = arg.context.get(KeysStreamingSource.matchOptions); - -expect(matchOptions).not.toBeUndefined() + }; + const matchOptions = arg.context.get(KeysStreamingSource.matchOptions); + expect(matchOptions).toBeDefined(); if (matchOptions !== undefined) { (<({ stopMatch: () => void })[]>matchOptions).push({ - stopMatch: stopMatchfn + stopMatch: stopMatchfn, }); } return { bindingsStream: iterator, metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('bound')], + variables: [ DF.variable('bound') ], }), type: 'bindings', }; @@ -1275,13 +1279,13 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { const tempStream: Stream = streamifyArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - let alteringStream = tempStream.pipe(new PassThrough({ - objectMode: true - }), {end: false}); - let wrapIterator = new WrappingIterator(alteringStream); + const alteringStream = tempStream.pipe(new PassThrough({ + objectMode: true, + }), { end: false }); + const wrapIterator = new WrappingIterator(alteringStream); const action: IActionRdfJoin = { type: 'inner', @@ -1290,20 +1294,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -1314,9 +1318,9 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { bindingsStream: wrapIterator, metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -1328,63 +1332,63 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { action.entries[0].operation.metadata.scopedSource = mockStreamingStore; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); alteringStream.push( BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); alteringStream.end(); - await promisifyEventEmitter(result.bindingsStream) + await promisifyEventEmitter(result.bindingsStream); expect(haltMock).toHaveBeenCalledTimes(1); expect(resumeMock).toHaveBeenCalledTimes(1); expect(stopMatchJest).toHaveBeenCalledTimes(2); - }) + }); - describe("with mock store", () => { + describe('with mock store', () => { let haltMock: Mock; let resumeMock: Mock; let iterator: BindingsStream; let stopMatchJest: Mock; - let streams: PassThrough[] = []; - let mockStreamingStore = { + const streams: PassThrough[] = []; + const mockStreamingStore = { halt: haltMock, - resume: resumeMock - } + resume: resumeMock, + }; beforeEach(() => { haltMock = jest.fn(); @@ -1405,12 +1409,12 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { [ DF.variable('bound'), DF.namedNode('ex:bound3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - tempStream.pipe(unionStream, {end: false}); + tempStream.pipe(unionStream, { end: false }); - let stream = new PassThrough({ - objectMode: true + const stream = new PassThrough({ + objectMode: true, }); - stream.pipe(unionStream, {end: false}); + stream.pipe(unionStream, { end: false }); streams.push(stream); let tempEnd = false; @@ -1432,15 +1436,17 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { iterator = new WrappingIterator(unionStream); - let stopMatchfn = () => { + const stopMatchfn = () => { stream.end(); stopMatchJest(); - } - let matchOptions = arg.context.get(KeysStreamingSource.matchOptions); -- expect(matchOptions).not.toBeUndefined() + }; + const matchOptions = arg.context.get(KeysStreamingSource.matchOptions); + + // TODO check if this check is needed + // expect(matchOptions).toBeDefined(); if (matchOptions !== undefined) { (<({ stopMatch: () => void })[]> matchOptions).push({ - stopMatch: stopMatchfn + stopMatch: stopMatchfn, }); } return { @@ -1464,9 +1470,9 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { mediatorJoinSelectivity, mediatorJoinEntriesSort, }); - }) + }); - it('should handle entries', async () => { + it('should handle entries', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -1474,20 +1480,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -1497,14 +1503,14 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -1516,35 +1522,35 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { action.entries[0].operation.metadata.scopedSource = mockStreamingStore; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); for (const stream of streams) { stream.push( BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound4')], - ]) + [ DF.variable('bound'), DF.namedNode('ex:bound4') ], + ]), ); } - expect(await partialArrayifyStream(result.bindingsStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound4')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound4') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); expect(haltMock).toHaveBeenCalledTimes(0); @@ -1553,15 +1559,15 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { for (const stream of streams) { stream.push( BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound4')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('bound'), DF.namedNode('ex:bound4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ); } - expect(await partialArrayifyStream(result.bindingsStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound4')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound4') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); expect(haltMock).toHaveBeenCalledTimes(0); @@ -1569,16 +1575,16 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { expect(stopMatchJest).toHaveBeenCalledTimes(0); }); - it('should handle entries with deletions', async () => { + it('should handle entries with deletions', async() => { const tempStream: Stream = streamifyArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - let alteringStream = tempStream.pipe(new PassThrough({ - objectMode: true - }), {end: false}); - let iterator = new WrappingIterator(alteringStream); + const alteringStream = tempStream.pipe(new PassThrough({ + objectMode: true, + }), { end: false }); + const iterator = new WrappingIterator(alteringStream); const action: IActionRdfJoin = { type: 'inner', @@ -1587,20 +1593,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -1611,9 +1617,9 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { bindingsStream: iterator, metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -1625,41 +1631,41 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { action.entries[0].operation.metadata.scopedSource = mockStreamingStore; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); alteringStream.push( BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - ]) + [ DF.variable('a'), DF.namedNode('ex:a2') ], + ]), ); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); expect(haltMock).toHaveBeenCalledTimes(0); @@ -1667,41 +1673,41 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { alteringStream.push( BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); for (const stream of streams) { stream.push( BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ); } - expect(await partialArrayifyStream(result.bindingsStream, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); - let promisses = []; + const promisses = []; alteringStream.end(); for (const stream of streams) { if (!stream.closed) { @@ -1710,25 +1716,25 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { } } - //await Promise.all(promisses); + // Await Promise.all(promisses); - await promisifyEventEmitter(result.bindingsStream) + await promisifyEventEmitter(result.bindingsStream); expect(haltMock).toHaveBeenCalledTimes(1); expect(resumeMock).toHaveBeenCalledTimes(1); expect(stopMatchJest).toHaveBeenCalledTimes(2); }); - it('should handle entries with too many deletions', async () => { + it('should handle entries with too many deletions', async() => { const tempStream: Stream = streamifyArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - let alteringStream = tempStream.pipe(new PassThrough({ - objectMode: true - }), {end: false}); - let iterator = new WrappingIterator(alteringStream); + const alteringStream = tempStream.pipe(new PassThrough({ + objectMode: true, + }), { end: false }); + const iterator = new WrappingIterator(alteringStream); const action: IActionRdfJoin = { type: 'inner', @@ -1737,20 +1743,20 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -1761,9 +1767,9 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { bindingsStream: iterator, metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -1775,51 +1781,51 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { action.entries[0].operation.metadata.scopedSource = mockStreamingStore; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); alteringStream.push( BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ); - expect(await partialArrayifyStream(result.bindingsStream, 3)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(result.bindingsStream, 3)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); alteringStream.push( BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - ]).setContextEntry(new ActionContextKeyIsAddition(), false) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), ); - let promisses = []; + const promisses = []; alteringStream.end(); for (const stream of streams) { if (!stream.closed) { @@ -1829,7 +1835,7 @@ describe('ActorRdfJoinIncrementalComputationalMultiBind', () => { } await Promise.all(promisses); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ ]); diff --git a/packages/actor-rdf-join-inner-incremental-full-hash/README.md b/packages/actor-rdf-join-inner-incremental-full-hash/README.md index bab93112..b9a1ddb1 100644 --- a/packages/actor-rdf-join-inner-incremental-full-hash/README.md +++ b/packages/actor-rdf-join-inner-incremental-full-hash/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-full-hash/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-full-hash/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-inner-incremental-full-hash/lib/ActorRdfJoinInnerIncrementalFullHash.ts b/packages/actor-rdf-join-inner-incremental-full-hash/lib/ActorRdfJoinInnerIncrementalFullHash.ts index e230dfa6..669df249 100644 --- a/packages/actor-rdf-join-inner-incremental-full-hash/lib/ActorRdfJoinInnerIncrementalFullHash.ts +++ b/packages/actor-rdf-join-inner-incremental-full-hash/lib/ActorRdfJoinInnerIncrementalFullHash.ts @@ -1,3 +1,4 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { IActionRdfJoin, IActorRdfJoinArgs, @@ -7,11 +8,9 @@ import { ActorRdfJoin, } from '@comunica/bus-rdf-join'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; -import type {MetadataBindings} from '@comunica/types'; -import type {Bindings} from '@comunica/bindings-factory'; -import type { BindingsStream } from '@comunica/types'; +import type { MetadataBindings, BindingsStream } from '@comunica/types'; +import type { AsyncIterator } from 'asynciterator'; import { IncrementalFullHashJoin } from './IncrementalFullHashJoin'; -import type { AsyncIterator } from "asynciterator"; /** * A comunica Inner Incremental Full Hash RDF Join Actor. @@ -29,7 +28,7 @@ export class ActorRdfJoinInnerIncrementalFullHash extends ActorRdfJoin { protected async getOutput(action: IActionRdfJoin): Promise { const metadatas = await ActorRdfJoin.getMetadatas(action.entries); const variables = ActorRdfJoin.overlappingVariables(metadatas); - const bindingsStream = new IncrementalFullHashJoin( + const bindingsStream = new IncrementalFullHashJoin( >action.entries[0].output.bindingsStream, >action.entries[1].output.bindingsStream, entry => ActorRdfJoinInnerIncrementalFullHash.hash(entry, variables), @@ -49,8 +48,8 @@ export class ActorRdfJoinInnerIncrementalFullHash extends ActorRdfJoin { } protected async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-inner-incremental-full-hash/lib/IncrementalFullHashJoin.ts b/packages/actor-rdf-join-inner-incremental-full-hash/lib/IncrementalFullHashJoin.ts index 8cc15622..19217b11 100644 --- a/packages/actor-rdf-join-inner-incremental-full-hash/lib/IncrementalFullHashJoin.ts +++ b/packages/actor-rdf-join-inner-incremental-full-hash/lib/IncrementalFullHashJoin.ts @@ -1,10 +1,10 @@ +import type { Bindings } from '@comunica/bindings-factory'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { HashBindings } from '@incremunica/hash-bindings'; import { IncrementalInnerJoin } from '@incremunica/incremental-inner-join'; -import type { Bindings } from '@comunica/bindings-factory'; +import type { AsyncIterator } from 'asynciterator'; import type { IMapObject } from './DualKeyHashMap'; import { DualKeyHashMap } from './DualKeyHashMap'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {AsyncIterator} from "asynciterator"; export class IncrementalFullHashJoin extends IncrementalInnerJoin { private readonly rightMemory: DualKeyHashMap = new DualKeyHashMap(); @@ -47,7 +47,6 @@ export class IncrementalFullHashJoin extends IncrementalInnerJoin { } public read(): Bindings | null { - // eslint-disable-next-line no-constant-condition while (true) { if (this.ended) { return null; diff --git a/packages/actor-rdf-join-inner-incremental-full-hash/package.json b/packages/actor-rdf-join-inner-incremental-full-hash/package.json index 519c3d49..df9a025f 100644 --- a/packages/actor-rdf-join-inner-incremental-full-hash/package.json +++ b/packages/actor-rdf-join-inner-incremental-full-hash/package.json @@ -3,45 +3,47 @@ "version": "1.3.0", "description": "A inner-incremental-full-hash rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-inner-incremental-full-hash" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "inner-incremental-full-hash" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/hash-bindings": "^1.3.0", "@incremunica/incremental-inner-join": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" + "asynciterator": "^3.9.0" } } diff --git a/packages/actor-rdf-join-inner-incremental-full-hash/test/ActorRdfJoinInnerIncrementalFullHash-test.ts b/packages/actor-rdf-join-inner-incremental-full-hash/test/ActorRdfJoinInnerIncrementalFullHash-test.ts index e150b30e..17214a98 100644 --- a/packages/actor-rdf-join-inner-incremental-full-hash/test/ActorRdfJoinInnerIncrementalFullHash-test.ts +++ b/packages/actor-rdf-join-inner-incremental-full-hash/test/ActorRdfJoinInnerIncrementalFullHash-test.ts @@ -1,19 +1,19 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import { ActorRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; import type { IQueryOperationResultBindings, Bindings, IActionContext } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; import type * as RDF from '@rdfjs/types'; import arrayifyStream from 'arrayify-stream'; -import {ArrayIterator} from 'asynciterator'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { ActorRdfJoinInnerIncrementalFullHash } from '../lib'; import '@incremunica/incremental-jest'; -import { MetadataValidationState } from '@comunica/metadata'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; const DF = new DataFactory(); @@ -22,8 +22,8 @@ describe('ActorRdfJoinFullHash', () => { let context: IActionContext; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); context = new ActionContext(); BF = await DevTools.createBindingsFactory(DF); }); @@ -34,19 +34,26 @@ describe('ActorRdfJoinFullHash', () => { }); it('should be a ActorRdfJoinFullHash constructor', () => { - expect(new ( ActorRdfJoinInnerIncrementalFullHash)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoinInnerIncrementalFullHash); - expect(new ( ActorRdfJoinInnerIncrementalFullHash)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoin); + expect(new ( ActorRdfJoinInnerIncrementalFullHash)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoinInnerIncrementalFullHash); + expect(new ( ActorRdfJoinInnerIncrementalFullHash)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoin); }); it('should not be able to create new ActorRdfJoinFullHash objects without \'new\'', () => { - expect(() => { ( ActorRdfJoinInnerIncrementalFullHash)(); }).toThrow(); + expect(() => { + ( ActorRdfJoinInnerIncrementalFullHash)(); + }).toThrow(''); }); }); describe('An ActorRdfJoinFullHash instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, +IActorTest, +IActorRdfJoinSelectivityOutput +>; let actor: ActorRdfJoinInnerIncrementalFullHash; let action: IActionRdfJoin; let variables0: RDF.Variable[]; @@ -99,37 +106,39 @@ describe('ActorRdfJoinFullHash', () => { describe('should test', () => { afterEach(() => { - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } }); - it('should only handle 2 streams', () => { - action.entries.push( {}); - return expect(actor.test(action)).rejects.toBeTruthy(); + it('should only handle 2 streams', async() => { + action.entries.push({}); + await expect(actor.test(action)).rejects.toBeTruthy(); }); - it('should fail on undefs in left stream', () => { + it('should fail on undefs in left stream', async() => { action.entries[0].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); - it('should fail on undefs in right stream', () => { + it('should fail on undefs in right stream', async() => { action.entries[1].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); - it('should fail on undefs in left and right stream', () => { + it('should fail on undefs in left and right stream', async() => { action.entries[0].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, @@ -142,45 +151,50 @@ describe('ActorRdfJoinFullHash', () => { canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); it('should generate correct test metadata', async() => { - await expect(actor.test(action)).resolves.toHaveProperty('iterations',0); + await expect(actor.test(action)).resolves.toHaveProperty('iterations', 0); }); }); it('should generate correct metadata', async() => { await actor.run(action).then(async(result: IQueryOperationResultBindings) => { - await expect(( result).metadata()).resolves.toHaveProperty('cardinality', - { type: 'estimate', - value: (await ( action.entries[0].output).metadata()).cardinality.value * - (await ( action.entries[1].output).metadata()).cardinality.value }); + await expect(( result).metadata()).resolves + .toHaveProperty( + 'cardinality', + { + type: 'estimate', + value: (await ( action.entries[0].output).metadata()).cardinality.value * + (await ( action.entries[1].output).metadata()).cardinality.value, + }, + ); await expect(result.bindingsStream).toEqualBindingsStream([]); }); }); - it('should return an empty stream for empty input', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + it('should return an empty stream for empty input', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should return null on read if join has ended', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - expect(output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.read()).toBeNull(); - }); + it('should return null on read if join has ended', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); + expect(output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.read()).toBeNull(); }); - it('should end after both streams are ended and no new elements can be generated', () => { + it('should end after both streams are ended and no new elements can be generated', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -200,21 +214,22 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - output.bindingsStream.read() - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); - expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.ended).toBeFalsy(); - await arrayifyStream(output.bindingsStream) - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(output.bindingsStream.ended).toBeTruthy(); - }); + const output = await actor.run(action); + output.bindingsStream.read(); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); + expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.ended).toBeFalsy(); + await arrayifyStream(output.bindingsStream); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(output.bindingsStream.ended).toBeTruthy(); }); - it('should join bindings with matching values', () => { + it('should join bindings with matching values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -230,21 +245,22 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([ - BF.bindings([ - [ DF.variable('a'), DF.literal('a') ], - [ DF.variable('b'), DF.literal('b') ], - [ DF.variable('c'), DF.literal('c') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([ + BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + [ DF.variable('b'), DF.literal('b') ], + [ DF.variable('c'), DF.literal('c') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); }); - it('should not join bindings with incompatible values', () => { + it('should not join bindings with incompatible values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -260,15 +276,16 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should join multiple bindings', () => { + it('should join multiple bindings', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -324,61 +341,61 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('4') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('4') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (left)', () => { + it('should join multiple bindings with negative bindings (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -418,25 +435,26 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (right)', () => { + it('should join multiple bindings with negative bindings (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -476,65 +494,66 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (left)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -566,30 +585,31 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (right)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -621,35 +641,36 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('b') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('b') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should be symmetric', () => { + it('should be symmetric', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -662,8 +683,8 @@ describe('ActorRdfJoinFullHash', () => { setTimeout(() => { push(item); done(); - }, 100) - } + }, 100); + }, }); variables0 = [ DF.variable('a'), DF.variable('b') ]; action.entries[1].output.bindingsStream = new ArrayIterator([ @@ -673,27 +694,23 @@ describe('ActorRdfJoinFullHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - - }); }); diff --git a/packages/actor-rdf-join-inner-incremental-full-hash/test/DualKeyHashMap-test.ts b/packages/actor-rdf-join-inner-incremental-full-hash/test/DualKeyHashMap-test.ts index 9aaf232f..00cc2f57 100644 --- a/packages/actor-rdf-join-inner-incremental-full-hash/test/DualKeyHashMap-test.ts +++ b/packages/actor-rdf-join-inner-incremental-full-hash/test/DualKeyHashMap-test.ts @@ -1,41 +1,57 @@ import '@incremunica/incremental-jest'; -import {DualKeyHashMap} from "../lib/DualKeyHashMap"; +import { DualKeyHashMap } from '../lib/DualKeyHashMap'; class TestObject { - constructor(public readonly id: number) {} + public constructor(public readonly id: number) {} - equals(item: TestObject): boolean { + public equals(item: TestObject): boolean { return this.id === item.id; } } describe('DualKeyHashMap with equality checks', () => { - let map: DualKeyHashMap<{ num: number, str: string, equals: (item: { num: number, str: string }) => boolean }>; + let map: DualKeyHashMap<{ num: number; str: string; equals: (item: { num: number; str: string }) => boolean }>; beforeEach(() => { - map = new DualKeyHashMap<{ num: number, str: string, equals: (item: { num: number, str: string }) => boolean }>(); + map = new DualKeyHashMap<{ num: number; str: string; equals: (item: { num: number; str: string }) => boolean }>(); }); it('sets and gets values with equality checks', () => { - const item1 = {num: 1, str: 'foo', equals: (other: { num: number; str: string; }) => other.num === 1 && other.str === 'foo'}; - const item2 = {num: 2, str: 'bar', equals: (other: { num: number; str: string; }) => other.num === 2 && other.str === 'bar'}; + const item1 = { + num: 1, + str: 'foo', + equals: (other: { num: number; str: string }) => other.num === 1 && other.str === 'foo', + }; + const item2 = { + num: 2, + str: 'bar', + equals: (other: { num: number; str: string }) => other.num === 2 && other.str === 'bar', + }; map.set('key1', 'secondaryKey1', item1); - expect(map.get('key1', 'secondaryKey1')).toEqual({value: item1, count: 1}); + expect(map.get('key1', 'secondaryKey1')).toEqual({ value: item1, count: 1 }); expect(map.get('key1', 'secondaryKey2')).toBeUndefined(); map.set('key1', 'secondaryKey1', item1); - expect(map.get('key1', 'secondaryKey1')).toEqual({value: item1, count: 2}); + expect(map.get('key1', 'secondaryKey1')).toEqual({ value: item1, count: 2 }); map.set('key1', 'secondaryKey2', item2); - expect(map.get('key1', 'secondaryKey2')).toEqual({value: item2, count: 1}); + expect(map.get('key1', 'secondaryKey2')).toEqual({ value: item2, count: 1 }); - expect([...map.getAll('secondaryKey1')]).toEqual([{value: item1, count: 2}]); + expect([ ...map.getAll('secondaryKey1') ]).toEqual([{ value: item1, count: 2 }]); }); it('deletes values with equality checks', () => { - const item1 = {num: 1, str: 'foo', equals: (other: { num: number; str: string; }) => other.num === 1 && other.str === 'foo'}; - const item2 = {num: 2, str: 'bar', equals: (other: { num: number; str: string; }) => other.num === 2 && other.str === 'bar'}; + const item1 = { + num: 1, + str: 'foo', + equals: (other: { num: number; str: string }) => other.num === 1 && other.str === 'foo', + }; + const item2 = { + num: 2, + str: 'bar', + equals: (other: { num: number; str: string }) => other.num === 2 && other.str === 'bar', + }; map.set('key1', 'secondaryKey1', item1); map.set('key1', 'secondaryKey2', item2); @@ -45,16 +61,16 @@ describe('DualKeyHashMap with equality checks', () => { expect(map.delete('key1', 'secondaryKey1')).toBe(true); expect(map.has('secondaryKey1')).toBe(true); expect(map.get('key1', 'secondaryKey1')).toBeUndefined(); - expect(map.get('key2', 'secondaryKey1')).toEqual({value: item1, count: 1}); + expect(map.get('key2', 'secondaryKey1')).toEqual({ value: item1, count: 1 }); expect(map.delete('key1', 'secondaryKey1')).toBe(false); - expect(map.get('key1', 'secondaryKey2')).toEqual({value: item2, count: 1}); - expect(map.get('key2', 'secondaryKey2')).toEqual({value: item2, count: 1}); + expect(map.get('key1', 'secondaryKey2')).toEqual({ value: item2, count: 1 }); + expect(map.get('key2', 'secondaryKey2')).toEqual({ value: item2, count: 1 }); expect(map.delete('key1', 'secondaryKey2')).toBe(true); expect(map.has('secondaryKey2')).toBe(true); expect(map.get('key1', 'secondaryKey2')).toBeUndefined(); - expect([...map.getAll('secondaryKey2')]).toEqual([{value: item2, count: 1}]); + expect([ ...map.getAll('secondaryKey2') ]).toEqual([{ value: item2, count: 1 }]); }); }); describe('DualKeyHashMap', () => { @@ -67,14 +83,14 @@ describe('DualKeyHashMap', () => { it('sets and gets a value', () => { const value = new TestObject(10); map.set('key1', 'secondaryKey1', value); - expect(map.get('key1', 'secondaryKey1')).toEqual({value, count: 1}); + expect(map.get('key1', 'secondaryKey1')).toEqual({ value, count: 1 }); }); it('increments count when setting the same value', () => { const value = new TestObject(10); map.set('key1', 'secondaryKey1', value); map.set('key1', 'secondaryKey1', value); - expect(map.get('key1', 'secondaryKey1')).toEqual({value, count: 2}); + expect(map.get('key1', 'secondaryKey1')).toEqual({ value, count: 2 }); }); it('throws error when setting different value with same key', () => { @@ -83,7 +99,7 @@ describe('DualKeyHashMap', () => { expect(() => { map.set('key1', 'secondaryKey1', value1); map.set('key1', 'secondaryKey1', value2); - }).toThrowError(`Current value: ${JSON.stringify(value1)} and given value: ${JSON.stringify(value2)} are different. With hash functions mainKey: key1, secondary key: secondaryKey1!`); + }).toThrow(`Current value: ${JSON.stringify(value1)} and given value: ${JSON.stringify(value2)} are different. With hash functions mainKey: key1, secondary key: secondaryKey1!`); }); it('returns undefined when getting non-existing value', () => { @@ -95,7 +111,7 @@ describe('DualKeyHashMap', () => { map.set('key1', 'secondaryKey1', value); map.set('key1', 'secondaryKey1', value); expect(map.delete('key1', 'secondaryKey1')).toBe(true); - expect(map.get('key1', 'secondaryKey1')).toEqual({value, count: 1}); + expect(map.get('key1', 'secondaryKey1')).toEqual({ value, count: 1 }); }); it('deletes value when count is equal to 1', () => { @@ -114,7 +130,7 @@ describe('DualKeyHashMap', () => { const value2 = new TestObject(20); map.set('key1', 'secondaryKey1', value1); map.set('key2', 'secondaryKey1', value2); - expect([...map.getAll('secondaryKey1')]).toEqual([{value: value1, count: 1}, {value: value2, count: 1}]); + expect([ ...map.getAll('secondaryKey1') ]).toEqual([{ value: value1, count: 1 }, { value: value2, count: 1 }]); }); it('returns true when the secondary key exists', () => { @@ -127,7 +143,7 @@ describe('DualKeyHashMap', () => { }); it('returns an empty iterator;', () => { - expect([...map.getAll('secondaryKey1')]).toEqual([]); + expect([ ...map.getAll('secondaryKey1') ]).toEqual([]); }); it('should clear', () => { @@ -135,7 +151,7 @@ describe('DualKeyHashMap', () => { const value2 = new TestObject(20); map.set('key1', 'secondaryKey1', value1); map.set('key2', 'secondaryKey1', value2); - map.clear() - expect([...map.getAll('secondaryKey1')]).toEqual([]); + map.clear(); + expect([ ...map.getAll('secondaryKey1') ]).toEqual([]); }); }); diff --git a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/README.md b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/README.md index 44b5bb1f..fd451b8d 100644 --- a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/README.md +++ b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-memory-multi-bind/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-memory-multi-bind/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/lib/ActorRdfJoinInnerIncrementalMemoryMultiBind.ts b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/lib/ActorRdfJoinInnerIncrementalMemoryMultiBind.ts index 0f950a6a..c51d4966 100644 --- a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/lib/ActorRdfJoinInnerIncrementalMemoryMultiBind.ts +++ b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/lib/ActorRdfJoinInnerIncrementalMemoryMultiBind.ts @@ -1,3 +1,5 @@ +import type { Bindings } from '@comunica/bindings-factory'; +import { BindingsFactory } from '@comunica/bindings-factory'; import type { MediatorQueryOperation } from '@comunica/bus-query-operation'; import { ActorQueryOperation, materializeOperation } from '@comunica/bus-query-operation'; import type { @@ -10,20 +12,22 @@ import type { MediatorRdfJoinEntriesSort } from '@comunica/bus-rdf-join-entries- import { KeysQueryOperation } from '@comunica/context-entries'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; import type { - BindingsStream, IQueryOperationResultBindings, - MetadataBindings, IActionContext, IJoinEntryWithMetadata + BindingsStream, + IQueryOperationResultBindings, + MetadataBindings, + IActionContext, + IJoinEntryWithMetadata, } from '@comunica/types'; -import { BindingsFactory, Bindings} from "@comunica/bindings-factory"; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { HashBindings } from '@incremunica/hash-bindings'; import { ArrayIterator, EmptyIterator, UnionIterator, } from 'asynciterator'; +import type { AsyncIterator } from 'asynciterator'; import type { Algebra } from 'sparqlalgebrajs'; import { Factory } from 'sparqlalgebrajs'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import type { AsyncIterator } from 'asynciterator'; /** * A comunica Multi-way Bind RDF Join Actor. @@ -60,7 +64,7 @@ export class ActorRdfJoinInnerIncrementalMemoryMultiBind extends ActorRdfJoin { => Promise>, optional: boolean, ): Promise> { - //TODO change to BindingsFactory.create() + // TODO change to BindingsFactory.create() const bindingsFactory = new BindingsFactory(); const transformMap = new Map< string, @@ -71,9 +75,11 @@ export class ActorRdfJoinInnerIncrementalMemoryMultiBind extends ActorRdfJoin { { bindings: Bindings; count: number; - }>; + } +>; count: number; - }>(); + } +>(); const hashBindings = new HashBindings(); const hashSubBindings = new HashBindings(); @@ -126,8 +132,8 @@ export class ActorRdfJoinInnerIncrementalMemoryMultiBind extends ActorRdfJoin { subDone(); }; - // eslint-disable-next-line @typescript-eslint/no-floating-promises - operationBinder(subOperations, bindings).then(bindingStream => { + // eslint-disable-next-line ts/no-floating-promises + operationBinder(subOperations, bindings).then((bindingStream) => { const transformIterator = bindingStream.transform({ transform: transformFunc, }); @@ -259,7 +265,7 @@ export class ActorRdfJoinInnerIncrementalMemoryMultiBind extends ActorRdfJoin { } return leftWithoutCommonVariables ? 1 : - -1; + -1; }); } @@ -283,7 +289,7 @@ export class ActorRdfJoinInnerIncrementalMemoryMultiBind extends ActorRdfJoin { const subContext = action.context .set(KeysQueryOperation.joinLeftMetadata, entries[0].metadata) .set(KeysQueryOperation.joinRightMetadatas, remainingEntries.map(entry => entry.metadata)); - const bindingsStream = await ActorRdfJoinInnerIncrementalMemoryMultiBind.createBindStream( + const bindingsStream = await ActorRdfJoinInnerIncrementalMemoryMultiBind.createBindStream( >smallestStream.bindingsStream, remainingEntries.map(entry => entry.operation), async(operations: Algebra.Operation[], operationBindings: Bindings) => { @@ -312,8 +318,8 @@ export class ActorRdfJoinInnerIncrementalMemoryMultiBind extends ActorRdfJoin { } public async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/package.json b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/package.json index 859ca406..0ec2c9f6 100644 --- a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/package.json +++ b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/package.json @@ -3,48 +3,50 @@ "version": "1.3.0", "description": "A inner-incremental-memory-multi-bind rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-inner-incremental-memory-multi-bind" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "inner-incremental-memory-multi-bind" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-query-operation": "^3.2.2", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/bus-rdf-join-entries-sort": "^3.2.1", "@comunica/context-entries": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/hash-bindings": "^1.3.0", "asynciterator": "^3.9.0", "sparqlalgebrajs": "^4.0.5" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/test/ActorRdfJoinInnerIncrementalMemoryMultiBindJoin-test.ts b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/test/ActorRdfJoinInnerIncrementalMemoryMultiBindJoin-test.ts index d4e7a195..408afa23 100644 --- a/packages/actor-rdf-join-inner-incremental-memory-multi-bind/test/ActorRdfJoinInnerIncrementalMemoryMultiBindJoin-test.ts +++ b/packages/actor-rdf-join-inner-incremental-memory-multi-bind/test/ActorRdfJoinInnerIncrementalMemoryMultiBindJoin-test.ts @@ -1,22 +1,22 @@ -import {BindingsFactory} from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionQueryOperation } from '@comunica/bus-query-operation'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinEntriesSort, MediatorRdfJoinEntriesSort } from '@comunica/bus-rdf-join-entries-sort'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import 'jest-rdf'; +import { KeysQueryOperation } from '@comunica/context-entries'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; import type { IActionContext, IQueryOperationResultBindings } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import arrayifyStream from 'arrayify-stream'; import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { Factory, Algebra } from 'sparqlalgebrajs'; import { ActorRdfJoinInnerIncrementalMemoryMultiBind } from '../lib/ActorRdfJoinInnerIncrementalMemoryMultiBind'; import '@incremunica/incremental-jest'; -import arrayifyStream from "arrayify-stream"; -import {KeysQueryOperation} from "@comunica/context-entries"; -import { MetadataValidationState } from '@comunica/metadata'; -import {DevTools} from "@incremunica/dev-tools"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; const DF = new DataFactory(); const FACTORY = new Factory(); @@ -25,19 +25,26 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { let bus: any; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); BF = await DevTools.createBindingsFactory(DF); }); describe('An ActorRdfJoinIncrementalMemoryMultiBind instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, + IActorTest, + IActorRdfJoinSelectivityOutput + >; let mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort; let context: IActionContext; - let mediatorQueryOperation: Mediator, - IActionQueryOperation, IActorTest, IQueryOperationResultBindings>; + let mediatorQueryOperation: Mediator< + Actor, + IActionQueryOperation, + IActorTest, + IQueryOperationResultBindings + >; let actor: ActorRdfJoinInnerIncrementalMemoryMultiBind; beforeEach(() => { @@ -88,7 +95,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { describe('getJoinCoefficients', () => { it('should handle three entries', async() => { - expect(await actor.getJoinCoefficients( + await expect(actor.getJoinCoefficients( { type: 'inner', entries: [ @@ -133,7 +140,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { variables: [ DF.variable('a') ], }, ], - )).toEqual({ + )).resolves.toEqual({ iterations: 0, persistedItems: 0, blockingItems: 0, @@ -141,203 +148,204 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }); }); - it('should handle three entries with a lower variable overlap', async() => { - expect(await actor.getJoinCoefficients( - { - type: 'inner', - entries: [ - { - output: {}, - operation: {}, - }, - { - output: {}, - operation: {}, - }, - { - output: {}, - operation: {}, - }, - ], - context: new ActionContext(), - }, - [ + it('should handle three entries with a lower variable overlap', async() => { + await expect(actor.getJoinCoefficients( + { + type: 'inner', + entries: [ { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a'), DF.variable('b') ], + output: {}, + operation: {}, }, { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a'), DF.variable('b') ], + output: {}, + operation: {}, }, { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 5 }, - pageSize: 100, - requestTime: 30, - canContainUndefs: false, - variables: [ DF.variable('a'), DF.variable('b') ], + output: {}, + operation: {}, }, ], - )).toEqual({ - iterations: 0, - persistedItems: 0, - blockingItems: 0, - requestTime: 0, - }); + context: new ActionContext(), + }, + [ + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 3 }, + pageSize: 100, + requestTime: 10, + canContainUndefs: false, + variables: [ DF.variable('a'), DF.variable('b') ], + }, + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 2 }, + pageSize: 100, + requestTime: 20, + canContainUndefs: false, + variables: [ DF.variable('a'), DF.variable('b') ], + }, + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 5 }, + pageSize: 100, + requestTime: 30, + canContainUndefs: false, + variables: [ DF.variable('a'), DF.variable('b') ], + }, + ], + )).resolves.toEqual({ + iterations: 0, + persistedItems: 0, + blockingItems: 0, + requestTime: 0, }); + }); - it('should reject on a right stream of type extend', async() => { - expect(await actor.getJoinCoefficients( - { - type: 'inner', - entries: [ - { - output: { - metadata: () => Promise.resolve({ - cardinality: { type: 'estimate', value: 3 }, - canContainUndefs: false, - }), + it('should reject on a right stream of type extend', async() => { + await expect(actor.getJoinCoefficients( + { + type: 'inner', + entries: [ + { + output: { + metadata: () => Promise.resolve({ + cardinality: { type: 'estimate', value: 3 }, + canContainUndefs: false, + }), - }, - operation: { type: Algebra.types.EXTEND }, }, - { - output: { - metadata: () => Promise.resolve({ - cardinality: { type: 'estimate', value: 2 }, - canContainUndefs: false, - }), - }, - operation: {}, - }, - ], - context: new ActionContext(), - }, - [ - { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a') ], + operation: { type: Algebra.types.EXTEND }, }, { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a') ], + output: { + metadata: () => Promise.resolve({ + cardinality: { type: 'estimate', value: 2 }, + canContainUndefs: false, + }), + }, + operation: {}, }, ], - )).toEqual({ - iterations: 0, - persistedItems: 0, - blockingItems: 0, - requestTime: 0, - }); - //.rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); - }); - - it('should reject on a right stream of type group', async() => { - expect(await actor.getJoinCoefficients( + context: new ActionContext(), + }, + [ { - type: 'inner', - entries: [ - { - output: {}, - operation: { type: Algebra.types.GROUP }, - }, - { - output: {}, - operation: {}, - }, - ], - context: new ActionContext(), + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 3 }, + pageSize: 100, + requestTime: 10, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - [ + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 2 }, + pageSize: 100, + requestTime: 20, + canContainUndefs: false, + variables: [ DF.variable('a') ], + }, + ], + )).resolves.toEqual({ + iterations: 0, + persistedItems: 0, + blockingItems: 0, + requestTime: 0, + }); + // .rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); + }); + + it('should reject on a right stream of type group', async() => { + await expect(actor.getJoinCoefficients( + { + type: 'inner', + entries: [ { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a') ], + output: {}, + operation: { type: Algebra.types.GROUP }, }, { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a') ]}, + output: {}, + operation: {}, + }, ], - )).toEqual({ - iterations: 0, - persistedItems: 0, - blockingItems: 0, - requestTime: 0, - }); - - //.rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); - }); - - it('should not reject on a left stream of type group', async() => { - expect(await actor.getJoinCoefficients( + context: new ActionContext(), + }, + [ { - type: 'inner', - entries: [ - { - output: {}, - operation: {}, - }, - { - output: {}, - operation: { type: Algebra.types.GROUP }, - }, - ], - context: new ActionContext(), + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 3 }, + pageSize: 100, + requestTime: 10, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - [ + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 2 }, + pageSize: 100, + requestTime: 20, + canContainUndefs: false, + variables: [ DF.variable('a') ], + }, + ], + )).resolves.toEqual({ + iterations: 0, + persistedItems: 0, + blockingItems: 0, + requestTime: 0, + }); + + // .rejects.toThrowError('Actor actor can not bind on Extend and Group operations'); + }); + + it('should not reject on a left stream of type group', async() => { + await expect(actor.getJoinCoefficients( + { + type: 'inner', + entries: [ { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - pageSize: 100, - requestTime: 10, - canContainUndefs: false, - variables: [ DF.variable('a') ], + output: {}, + operation: {}, }, { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - pageSize: 100, - requestTime: 20, - canContainUndefs: false, - variables: [ DF.variable('a') ], + output: {}, + operation: { type: Algebra.types.GROUP }, }, ], - )).toEqual({ - iterations: 0, - persistedItems: 0, - blockingItems: 0, - requestTime: 0, - }); + context: new ActionContext(), + }, + [ + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 3 }, + pageSize: 100, + requestTime: 10, + canContainUndefs: false, + variables: [ DF.variable('a') ], + }, + { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 2 }, + pageSize: 100, + requestTime: 20, + canContainUndefs: false, + variables: [ DF.variable('a') ], + }, + ], + )).resolves.toEqual({ + iterations: 0, + persistedItems: 0, + blockingItems: 0, + requestTime: 0, }); }); + }); describe('sortJoinEntries', () => { it('sorts 2 entries', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -361,7 +369,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -386,39 +394,38 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }); it('sorts 3 entries', async() => { - expect(await actor.sortJoinEntries([ - { - output: {}, - operation: {}, - metadata: { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 3 }, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, + await expect(actor.sortJoinEntries([ + { + output: {}, + operation: {}, + metadata: { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 3 }, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - { - output: {}, - operation: {}, - metadata: { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 2 }, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, + }, + { + output: {}, + operation: {}, + metadata: { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 2 }, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - { - output: {}, - operation: {}, - metadata: { - state: new MetadataValidationState(), - cardinality: { type: 'estimate', value: 5 }, - canContainUndefs: false, - variables: [ DF.variable('a') ], - }, + }, + { + output: {}, + operation: {}, + metadata: { + state: new MetadataValidationState(), + cardinality: { type: 'estimate', value: 5 }, + canContainUndefs: false, + variables: [ DF.variable('a') ], }, - ], - context)).toEqual([ + }, + ], context)).resolves.toEqual([ { output: {}, operation: {}, @@ -453,7 +460,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }); it('sorts 3 equal entries', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, @@ -487,7 +494,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -522,13 +529,13 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }); it('does not sort if there is an undef', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -538,7 +545,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 2 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -548,7 +555,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 5 }, canContainUndefs: true, variables: [ DF.variable('a') ], @@ -556,7 +563,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -597,7 +604,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, variables: [ DF.variable('a1'), DF.variable('b1') ], @@ -607,7 +614,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 2 }, canContainUndefs: false, variables: [ DF.variable('a2'), DF.variable('b2') ], @@ -619,13 +626,13 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }); it('sorts entries without common variables in the back', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, variables: [ DF.variable('b') ], @@ -635,7 +642,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -645,7 +652,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 2 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -653,7 +660,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -688,13 +695,13 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }); it('sorts several entries without variables in the back', async() => { - expect(await actor.sortJoinEntries( + await expect(actor.sortJoinEntries( [ { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -704,7 +711,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, variables: [ DF.variable('b') ], @@ -714,7 +721,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 20 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -724,7 +731,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 20 }, canContainUndefs: false, variables: [ DF.variable('c') ], @@ -734,7 +741,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 2 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -744,7 +751,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 10 }, canContainUndefs: false, variables: [ DF.variable('d') ], @@ -754,7 +761,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { output: {}, operation: {}, metadata: { - state: new MetadataValidationState(), + state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 10 }, canContainUndefs: false, variables: [ DF.variable('a') ], @@ -762,7 +769,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { }, ], context, - )).toEqual([ + )).resolves.toEqual([ { output: {}, operation: {}, @@ -891,8 +898,8 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + expect(result.type).toBe('bindings'); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -918,7 +925,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(await result.metadata()).toEqual({ + await expect(result.metadata()).resolves.toEqual({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 2.400_000_000_000_000_4 }, canContainUndefs: false, @@ -1002,8 +1009,8 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + expect(result.type).toBe('bindings'); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1029,7 +1036,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(await result.metadata()).toEqual({ + await expect(result.metadata()).resolves.toEqual({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 9.600_000_000_000_001 }, canContainUndefs: false, @@ -1119,7 +1126,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: { type: 'estimate', value: 4 }, @@ -1153,7 +1160,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ ]); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ ]); }); it('should handle two entries with immediate deletions', async() => { @@ -1171,7 +1178,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: { type: 'estimate', value: 4 }, @@ -1210,7 +1217,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1241,7 +1248,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: { type: 'estimate', value: 4 }, @@ -1283,7 +1290,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1350,7 +1357,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: { type: 'estimate', value: 4 }, @@ -1395,7 +1402,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1549,7 +1556,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1634,7 +1641,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), @@ -1672,7 +1679,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1732,7 +1739,6 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { mediatorJoinEntriesSort, }); - const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -1747,7 +1753,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b3') ], - ]) + ]), ], { autoStart: false }), metadata: () => Promise.resolve({ cardinality: { type: 'estimate', value: 4 }, @@ -1783,7 +1789,7 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ [ DF.variable('bound'), DF.namedNode('ex:bound1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], @@ -1803,23 +1809,22 @@ describe('ActorRdfJoinIncrementalMemoryMultiBind', () => { ]); }); - /* - it('should throw if operationBinder throws error', async() => { - await expect(await arrayifyStream(await ActorRdfJoinInnerIncrementalMemoryMultiBind.createBindStream( - new ArrayIterator([ - BF.bindings([ - [ DF.variable('bound'), DF.namedNode('ex:bound1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], { autoStart: false }), - [FACTORY.createPattern(DF.variable('a'), DF.namedNode('ex:p1'), DF.variable('b'))], - (boundOperations: Algebra.Operation[], operationBindings: Bindings) => {throw new Error("throw test")}, - false - )) - ).toThrow('throw test'); - }); - */ - - + // TODO re-enable these tests + // eslint-disable-next-line jest/no-commented-out-tests + // it('should throw if operationBinder throws error', async() => { + // await expect(await arrayifyStream(await ActorRdfJoinInnerIncrementalMemoryMultiBind.createBindStream( + // new ArrayIterator([ + // BF.bindings([ + // [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + // ]).setContextEntry(new ActionContextKeyIsAddition(), true), + // ], { autoStart: false }), + // [FACTORY.createPattern(DF.variable('a'), DF.namedNode('ex:p1'), DF.variable('b'))], + // (boundOperations: Algebra.Operation[], operationBindings: Bindings) => {throw new Error("throw test")}, + // false + // )) + // ).toThrow('throw test'); + // }); + // }); }); }); diff --git a/packages/actor-rdf-join-inner-incremental-multi-delta-query/README.md b/packages/actor-rdf-join-inner-incremental-multi-delta-query/README.md index b75077ab..2bca2e2a 100644 --- a/packages/actor-rdf-join-inner-incremental-multi-delta-query/README.md +++ b/packages/actor-rdf-join-inner-incremental-multi-delta-query/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-multi-delta-query/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-multi-delta-query/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/ActorRdfJoinInnerIncrementalMultiDeltaQuery.ts b/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/ActorRdfJoinInnerIncrementalMultiDeltaQuery.ts index 7200633f..77ffe260 100644 --- a/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/ActorRdfJoinInnerIncrementalMultiDeltaQuery.ts +++ b/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/ActorRdfJoinInnerIncrementalMultiDeltaQuery.ts @@ -8,7 +8,7 @@ import { ActorRdfJoin, } from '@comunica/bus-rdf-join'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; -import type {BindingsStream, MetadataBindings} from '@comunica/types'; +import type { BindingsStream, MetadataBindings } from '@comunica/types'; import { KeysDeltaQueryJoin } from '@incremunica/context-entries'; import { DeltaQueryIterator } from './DeltaQueryIterator'; @@ -27,7 +27,7 @@ export class ActorRdfJoinInnerIncrementalMultiDeltaQuery extends ActorRdfJoin { } public async getOutput(action: IActionRdfJoin): Promise { - const bindingsStream = new DeltaQueryIterator( + const bindingsStream = new DeltaQueryIterator( action.entries, action.context, this.mediatorQueryOperation, @@ -48,7 +48,7 @@ export class ActorRdfJoinInnerIncrementalMultiDeltaQuery extends ActorRdfJoin { public async getJoinCoefficients( action: IActionRdfJoin, - metadatas: MetadataBindings[], + _metadatas: MetadataBindings[], ): Promise { // Throw when the previous join was a delta query join or when it is a static query if (action.context diff --git a/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/DeltaQueryIterator.ts b/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/DeltaQueryIterator.ts index ecbd58e6..c8705c8c 100644 --- a/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/DeltaQueryIterator.ts +++ b/packages/actor-rdf-join-inner-incremental-multi-delta-query/lib/DeltaQueryIterator.ts @@ -1,16 +1,17 @@ import { BindingsToQuadsIterator } from '@comunica/actor-query-operation-construct'; +import type { Bindings } from '@comunica/bindings-factory'; +import { BindingsFactory } from '@comunica/bindings-factory'; import { ActorQueryOperation, materializeOperation } from '@comunica/bus-query-operation'; import type { MediatorQueryOperation } from '@comunica/bus-query-operation'; +import { KeysQueryOperation } from '@comunica/context-entries'; import { ActionContext } from '@comunica/core'; import type { IActionContext, IJoinEntry } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import { KeysDeltaQueryJoin } from '@incremunica/context-entries'; import type { Quad } from '@incremunica/incremental-types'; -import {Bindings, BindingsFactory} from '@comunica/bindings-factory'; import { AsyncIterator } from 'asynciterator'; import { Store } from 'n3'; import { Factory } from 'sparqlalgebrajs'; -import {KeysQueryOperation} from "@comunica/context-entries"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; export class DeltaQueryIterator extends AsyncIterator { private count = 0; @@ -22,7 +23,7 @@ export class DeltaQueryIterator extends AsyncIterator { private readonly subContext: IActionContext; private readonly store = new Store(); private pending = false; - //TODO change to BindingsFactory.create() + // TODO change to BindingsFactory.create() private readonly bindingsFactory = new BindingsFactory(); public constructor( @@ -86,7 +87,7 @@ export class DeltaQueryIterator extends AsyncIterator { ) { return; } - for (const nonUsedVar of this.entries) { + for (const _nonUsedVar of this.entries) { this.count++; this.count %= this.entries.length; @@ -100,7 +101,7 @@ export class DeltaQueryIterator extends AsyncIterator { if (bindings === null) { continue; } - //TODO check if this casting is correct + // TODO check if this casting is correct let quad = BindingsToQuadsIterator.bindQuad(bindings, source.operation); while (quad === undefined) { @@ -117,13 +118,14 @@ export class DeltaQueryIterator extends AsyncIterator { const constBindings = bindings; const constQuad = quad; const subEntries = [ ...this.entries ]; - subEntries[this.count] = subEntries[subEntries.length - 1]; + subEntries[this.count] = subEntries.at(-1)!; subEntries.pop(); // Do query this.pending = true; const subOperations = subEntries - .map(entry => materializeOperation(entry.operation, constBindings, this.bindingsFactory, { bindFilter: false })); + .map(entry => + materializeOperation(entry.operation, constBindings, this.bindingsFactory, { bindFilter: false })); const operation = subOperations.length === 1 ? subOperations[0] : @@ -131,20 +133,23 @@ export class DeltaQueryIterator extends AsyncIterator { this.mediatorQueryOperation.mediate( { operation, context: this.subContext }, - ).then(unsafeOutput => { + ).then((unsafeOutput) => { const output = ActorQueryOperation.getSafeBindings(unsafeOutput); // Figure out diff (change diff if needed) - let bindingsStream: AsyncIterator | undefined = (>output.bindingsStream).map( - (resultBindings) => { - let tempBindings = resultBindings.merge(constBindings); - if (tempBindings === undefined) { - return null; - } - //TODO I don't think this is needed - //tempBindings = tempBindings.setContextEntry(new ActionContextKeyIsAddition(), constBindings.getContextEntry(new ActionContextKeyIsAddition())); - return tempBindings; - }, - ); + let bindingsStream: AsyncIterator | undefined = + (>output.bindingsStream).map( + (resultBindings) => { + const tempBindings = resultBindings.merge(constBindings); + if (tempBindings === undefined) { + return null; + } + // TODO I don't think this is needed + // tempBindings = tempBindings.setContextEntry( + // new ActionContextKeyIsAddition(), constBindings.getContextEntry(new ActionContextKeyIsAddition()) + // ); + return tempBindings; + }, + ); this.pending = false; @@ -157,7 +162,7 @@ export class DeltaQueryIterator extends AsyncIterator { this.store.delete(constQuad); } this.currentSource = undefined; - //TODO why set it to undefined? + // TODO why set it to undefined? bindingsStream = undefined; this.readable = true; }); @@ -187,4 +192,3 @@ export class DeltaQueryIterator extends AsyncIterator { } } } - diff --git a/packages/actor-rdf-join-inner-incremental-multi-delta-query/package.json b/packages/actor-rdf-join-inner-incremental-multi-delta-query/package.json index 7cb23d68..901c9b7a 100644 --- a/packages/actor-rdf-join-inner-incremental-multi-delta-query/package.json +++ b/packages/actor-rdf-join-inner-incremental-multi-delta-query/package.json @@ -3,51 +3,52 @@ "version": "1.3.0", "description": "A inner-incremental-multi-delta-query rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-inner-incremental-multi-delta-query" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "inner-incremental-multi-delta-query" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { "@comunica/actor-query-operation-construct": "^3.2.2", + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-query-operation": "^3.2.2", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/context-entries": "^3.2.1", "@comunica/core": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/context-entries": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0", "asynciterator": "^3.9.0", "n3": "^1.16.4", "sparqlalgebrajs": "^4.1.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/ActorRdfJoinInnerIncrementalMultiDeltaQuery-test.ts b/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/ActorRdfJoinInnerIncrementalMultiDeltaQuery-test.ts index df28a53e..596509fd 100644 --- a/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/ActorRdfJoinInnerIncrementalMultiDeltaQuery-test.ts +++ b/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/ActorRdfJoinInnerIncrementalMultiDeltaQuery-test.ts @@ -1,21 +1,21 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; -import {ActionContext, Bus} from '@comunica/core'; +import type { BindingsFactory } from '@comunica/bindings-factory'; +import type { IActionQueryOperation, MediatorQueryOperation } from '@comunica/bus-query-operation'; +import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; +import type { + MediatorRdfJoinSelectivity, +} from '@comunica/bus-rdf-join-selectivity'; +import { ActionContext, Bus } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; +import type { IActionContext, IQueryOperationResultBindings } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { KeysDeltaQueryJoin } from '@incremunica/context-entries'; +import { DevTools } from '@incremunica/dev-tools'; +import arrayifyStream from 'arrayify-stream'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import '@incremunica/incremental-jest'; -import {Factory} from "sparqlalgebrajs"; -import { - MediatorRdfJoinSelectivity -} from "@comunica/bus-rdf-join-selectivity"; -import {IActionContext, IQueryOperationResultBindings} from "@comunica/types"; -import {IActionQueryOperation, MediatorQueryOperation} from "@comunica/bus-query-operation"; -import {ArrayIterator} from "asynciterator"; -import {IActionRdfJoin} from "@comunica/bus-rdf-join"; -import arrayifyStream from "arrayify-stream"; -import {ActorRdfJoinInnerIncrementalMultiDeltaQuery} from "../lib"; -import { MetadataValidationState } from '@comunica/metadata'; -import {KeysDeltaQueryJoin} from "@incremunica/context-entries"; -import {DevTools} from "@incremunica/dev-tools"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; +import { Factory } from 'sparqlalgebrajs'; +import { ActorRdfJoinInnerIncrementalMultiDeltaQuery } from '../lib'; const DF = new DataFactory(); const FACTORY = new Factory(); @@ -24,8 +24,8 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { let bus: any; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); BF = await DevTools.createBindingsFactory(DF); }); @@ -37,28 +37,28 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { beforeEach(() => { mediatorJoinSelectivity = { - mediate: async () => ({selectivity: 0.8}), + mediate: async() => ({ selectivity: 0.8 }), }; - context = new ActionContext({a: 'b'}); + context = new ActionContext({ a: 'b' }); mediatorQueryOperation = { - mediate: jest.fn(async (arg: IActionQueryOperation): Promise => { + mediate: jest.fn(async(arg: IActionQueryOperation): Promise => { return { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('bound')], + variables: [ DF.variable('bound') ], }), type: 'bindings', }; @@ -74,8 +74,8 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { }); describe('getJoinCoefficients', () => { - it('should handle three entries', async () => { - expect(await actor.getJoinCoefficients( + it('should handle three entries', async() => { + await expect(actor.getJoinCoefficients( { type: 'inner', entries: [ @@ -97,31 +97,31 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { [ { state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, pageSize: 100, requestTime: 10, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }, { state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 2}, + cardinality: { type: 'estimate', value: 2 }, pageSize: 100, requestTime: 20, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }, { state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 5}, + cardinality: { type: 'estimate', value: 5 }, pageSize: 100, requestTime: 30, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }, ], - //TODO - )).toEqual({ + // TODO + )).resolves.toEqual({ iterations: 0, persistedItems: 0, blockingItems: 0, @@ -129,7 +129,7 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { }); }); - it('should fail if previous join was a delta query join', async () => { + it('should fail if previous join was a delta query join', async() => { await expect(actor.getJoinCoefficients( { type: 'inner', @@ -145,19 +145,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { [ { state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, pageSize: 100, requestTime: 10, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }, ], - )).rejects.toEqual(new Error("Can't do two delta query joins after each other")) + )).rejects.toEqual(new Error('Can\'t do two delta query joins after each other')); }); }); describe('getOutput', () => { - it('should handle two entries without context', async () => { + it('should handle two entries without context', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -165,20 +165,20 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], + [ DF.variable('b'), DF.namedNode('ex:b3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -188,17 +188,17 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -207,45 +207,45 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + expect(result.type).toBe('bindings'); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(await result.metadata()).toEqual({ + await expect(result.metadata()).resolves.toEqual({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 2.400_000_000_000_000_4}, + cardinality: { type: 'estimate', value: 2.400_000_000_000_000_4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }); }); - it('should handle three entries', async () => { + it('should handle three entries', async() => { const action: IActionRdfJoin = { context, type: 'inner', @@ -254,19 +254,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], + [ DF.variable('b'), DF.namedNode('ex:b3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -276,19 +276,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:c1')], + [ DF.variable('c'), DF.namedNode('ex:c1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:c2')], + [ DF.variable('c'), DF.namedNode('ex:c2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:c3')], + [ DF.variable('c'), DF.namedNode('ex:c3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('c')], + variables: [ DF.variable('a'), DF.variable('c') ], }), type: 'bindings', }, @@ -298,16 +298,16 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -315,39 +315,39 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { }, ], }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(result.type).toEqual('bindings'); - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + expect(result.type).toBe('bindings'); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); }); - it('should handle two entries with one wrong binding (should not happen)', async () => { + it('should handle two entries with one wrong binding (should not happen)', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -355,19 +355,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -377,14 +377,14 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound4')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound4') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('bound')], + variables: [ DF.variable('a'), DF.variable('bound') ], }), type: 'bindings', }, @@ -393,13 +393,13 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([]); + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([]); }); - it('should handle two entries with immediate deletions', async () => { + it('should handle two entries with immediate deletions', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -407,19 +407,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -429,19 +429,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -450,50 +450,50 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); }); - it('should handle two entries with deletions', async () => { + it('should handle two entries with deletions', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -501,19 +501,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -523,22 +523,22 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a3')], + [ DF.variable('a'), DF.namedNode('ex:a3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -547,62 +547,62 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a3')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a3')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a3')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a3') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); }); - it('should handle two entries with multiple identical bindings and removal', async () => { + it('should handle two entries with multiple identical bindings and removal', async() => { const action: IActionRdfJoin = { type: 'inner', entries: [ @@ -610,19 +610,19 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b3')], - ]) - ], {autoStart: false}), + [ DF.variable('b'), DF.namedNode('ex:b3') ], + ]), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 4}, + cardinality: { type: 'estimate', value: 4 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -632,25 +632,25 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -659,69 +659,69 @@ describe('ActorRdfJoinInnerIncrementalMultiDeltaQuery', () => { ], context, }; - const {result} = await actor.getOutput(action); + const { result } = await actor.getOutput(action); // Validate output - expect(await arrayifyStream(result.bindingsStream)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(result.bindingsStream)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound1')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound1') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound2')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound2') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('bound'), DF.namedNode('ex:bound3')], - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('bound'), DF.namedNode('ex:bound3') ], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); }); diff --git a/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/DeltaQueryIterator-test.ts b/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/DeltaQueryIterator-test.ts index 659dfd94..cee26201 100644 --- a/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/DeltaQueryIterator-test.ts +++ b/packages/actor-rdf-join-inner-incremental-multi-delta-query/test/DeltaQueryIterator-test.ts @@ -1,31 +1,32 @@ import '@incremunica/incremental-jest'; -import {BindingsStream, IActionContext, IJoinEntry, IQueryOperationResultBindings} from "@comunica/types"; -import {ActionContext} from "@comunica/core"; -import {IActionQueryOperation, MediatorQueryOperation} from "@comunica/bus-query-operation"; -import {ArrayIterator, EmptyIterator, WrappingIterator} from "asynciterator"; -import {DataFactory} from "rdf-data-factory"; -import {BindingsFactory} from "@comunica/bindings-factory"; -import {Factory} from "sparqlalgebrajs"; -import {DeltaQueryIterator} from "../lib/DeltaQueryIterator"; -import {getContextSources} from "@comunica/bus-rdf-resolve-quad-pattern"; -import {Store} from "n3"; -import arrayifyStream from "arrayify-stream"; -import {promisifyEventEmitter} from "event-emitter-promisify/dist"; -import * as RDF from "@rdfjs/types"; -import {Transform} from "readable-stream"; -import EventEmitter = require("events"); -import {MetadataValidationState} from "@comunica/metadata"; +import EventEmitter = require('events'); +import type { BindingsFactory } from '@comunica/bindings-factory'; +import type { IActionQueryOperation, MediatorQueryOperation } from '@comunica/bus-query-operation'; +import { getContextSources } from '@comunica/bus-rdf-resolve-quad-pattern'; +import { ActionContext } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; +import type { BindingsStream, IActionContext, IJoinEntry, IQueryOperationResultBindings } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import type * as RDF from '@rdfjs/types'; +import arrayifyStream from 'arrayify-stream'; +import { ArrayIterator, EmptyIterator, WrappingIterator } from 'asynciterator'; +import { promisifyEventEmitter } from 'event-emitter-promisify/dist'; +import type { Store } from 'n3'; +import { DataFactory } from 'rdf-data-factory'; +import { Transform } from 'readable-stream'; +import { Factory } from 'sparqlalgebrajs'; +import { DeltaQueryIterator } from '../lib/DeltaQueryIterator'; + const streamifyArray = require('streamify-array'); -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; const DF = new DataFactory(); const FACTORY = new Factory(); async function partialArrayifyStream(stream: EventEmitter, num: number): Promise { - let array: any[] = []; + const array: any[] = []; for (let i = 0; i < num; i++) { - await new Promise((resolve) => stream.once("data", (bindings: any) => { + await new Promise(resolve => stream.once('data', (bindings: any) => { array.push(bindings); resolve(); })); @@ -37,84 +38,84 @@ function nullifyVariables(term?: RDF.Term): RDF.Term | undefined { return !term || term.termType === 'Variable' ? undefined : term; } -describe("DeltaQueryIterator", () => { +describe('DeltaQueryIterator', () => { let context: IActionContext; let mediatorQueryOperation: MediatorQueryOperation; let mediateFunc: jest.Mock; let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { context = new ActionContext(); BF = await DevTools.createBindingsFactory(DF); - mediateFunc = jest.fn(async (arg: IActionQueryOperation): Promise => { + mediateFunc = jest.fn(async(arg: IActionQueryOperation): Promise => { const sources = getContextSources(arg.context); - expect(sources).not.toBeUndefined(); + // TODO check if this is needed + // expect(sources).toBeDefined(); if (sources === undefined) { return { bindingsStream: new EmptyIterator(), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 0}, + cardinality: { type: 'estimate', value: 0 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('a')], + variables: [ DF.variable('a'), DF.variable('a') ], }), type: 'bindings', - } + }; } const bindingstream: BindingsStream = new ArrayIterator((sources[0]).match( - // @ts-ignore + // @ts-expect-error nullifyVariables(arg.operation.subject), nullifyVariables(arg.operation.predicate), nullifyVariables(arg.operation.object), null, )).map((quad) => { - if (quad.predicate.value === "ex:p2") { + if (quad.predicate.value === 'ex:p2') { return BF.bindings([]); - } else { - return BF.bindings([ - [DF.variable('b'), quad.object], - ]); } - }) + return BF.bindings([ + [ DF.variable('b'), quad.object ], + ]); + }); return { bindingsStream: bindingstream, metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('bound')], + variables: [ DF.variable('bound') ], }), type: 'bindings', }; }); mediatorQueryOperation = { - mediate: mediateFunc + mediate: mediateFunc, }; }); - it('should join two entries', async () => { + it('should join two entries', async() => { const action: IJoinEntry[] = [ { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -124,16 +125,16 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -141,48 +142,48 @@ describe("DeltaQueryIterator", () => { }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - expect(await arrayifyStream(delta)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(delta)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(mediateFunc).toBeCalledTimes(4); + expect(mediateFunc).toHaveBeenCalledTimes(4); }); - it('should join two entries with deletions', async () => { + it('should join two entries with deletions', async() => { const action: IJoinEntry[] = [ { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -192,19 +193,19 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -212,36 +213,35 @@ describe("DeltaQueryIterator", () => { }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - expect(await arrayifyStream(delta)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(delta)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); - expect(mediateFunc).toBeCalledTimes(6); + expect(mediateFunc).toHaveBeenCalledTimes(6); }); - it('should join two slow entries', async () => { + it('should join two slow entries', async() => { const transform = new Transform({ transform(quad: any, _encoding: any, callback: (arg0: null, arg1: any) => any) { return callback(null, quad); @@ -249,32 +249,32 @@ describe("DeltaQueryIterator", () => { objectMode: true, }); - let stream = streamifyArray([ + const stream = streamifyArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], - ]) - ], {autoStart: false}).pipe(transform, {end: false}); + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], + ]), + ], { autoStart: false }).pipe(transform, { end: false }); - let it1 = new WrappingIterator(stream); + const it1 = new WrappingIterator(stream); - let it2 = new ArrayIterator([ + const it2 = new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}); + ], { autoStart: false }); const action: IJoinEntry[] = [ { output: { bindingsStream: it1, metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -284,9 +284,9 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: it2, metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -297,48 +297,48 @@ describe("DeltaQueryIterator", () => { const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - expect(await partialArrayifyStream(delta, 1)).toBeIsomorphicBindingsArray([ + await expect(partialArrayifyStream(delta, 1)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], - ]) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], + ]), ]); stream.push( BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], - ]) + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], + ]), ); stream.end(); - expect(await arrayifyStream(delta)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(delta)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); - expect(mediateFunc).toBeCalledTimes(4); + expect(mediateFunc).toHaveBeenCalledTimes(4); }); - it('should keep reading the bindingsStream if the bindings can\'t be bound to the quad', async () => { + it('should keep reading the bindingsStream if the bindings can\'t be bound to the quad', async() => { const action: IJoinEntry[] = [ { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -348,19 +348,19 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:a1')], + [ DF.variable('c'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('d'), DF.namedNode('ex:a1')], + [ DF.variable('d'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -368,37 +368,36 @@ describe("DeltaQueryIterator", () => { }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - expect(await arrayifyStream(delta)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(delta)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], - ]) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], + ]), ]); - expect(mediateFunc).toBeCalledTimes(2); + expect(mediateFunc).toHaveBeenCalledTimes(2); }); - it('should keep reading the bindingsSteam and break if it has a null', async () => { + it('should keep reading the bindingsSteam and break if it has a null', async() => { const action: IJoinEntry[] = [ { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -408,17 +407,17 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('c'), DF.namedNode('ex:a1')], + [ DF.variable('c'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), null, BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -426,52 +425,51 @@ describe("DeltaQueryIterator", () => { }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - expect(await arrayifyStream(delta)).toBeIsomorphicBindingsArray([ + await expect(arrayifyStream(delta)).resolves.toBeIsomorphicBindingsArray([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], - ]) + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], + ]), ]); - expect(mediateFunc).toBeCalledTimes(2); + expect(mediateFunc).toHaveBeenCalledTimes(2); }); - it('should destroy entries on end', async () => { - let it1 = new ArrayIterator([ + it('should destroy entries on end', async() => { + const it1 = new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}); + ], { autoStart: false }); - let it2 = new ArrayIterator([ + const it2 = new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}); + ], { autoStart: false }); const action: IJoinEntry[] = [ { output: { bindingsStream: it1, metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -481,9 +479,9 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: it2, metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -494,46 +492,46 @@ describe("DeltaQueryIterator", () => { const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); delta.close(); - await new Promise((resolve) => setTimeout(() => resolve(), 100)) + await new Promise(resolve => setTimeout(() => resolve(), 100)); expect(it1.destroyed).toBeTruthy(); expect(it2.destroyed).toBeTruthy(); }); - it('should handle destroyed entry', async () => { - let it1 = new ArrayIterator([ + it('should handle destroyed entry', async() => { + const it1 = new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], - [DF.variable('b'), DF.namedNode('ex:b2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], + [ DF.variable('b'), DF.namedNode('ex:b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}); + ], { autoStart: false }); - let it2 = new ArrayIterator([ + const it2 = new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}); + ], { autoStart: false }); const action: IJoinEntry[] = [ { output: { bindingsStream: it1, metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -543,9 +541,9 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: it2, metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -556,34 +554,34 @@ describe("DeltaQueryIterator", () => { const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); expect(() => { - it1.destroy(new Error("test")) - }).toThrow("test") + it1.destroy(new Error('test')); + }).toThrow('test'); }); - it('should internally return null when the bindings can\'t be merged', async () => { - let mediateFunc = jest.fn(async (arg: IActionQueryOperation): Promise => { + it('should internally return null when the bindings can\'t be merged', async() => { + const mediateFunc = jest.fn(async(arg: IActionQueryOperation): Promise => { return { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a2')], + [ DF.variable('a'), DF.namedNode('ex:a2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('bound')], + variables: [ DF.variable('bound') ], }), type: 'bindings', }; }); mediatorQueryOperation = { - mediate: mediateFunc + mediate: mediateFunc, }; const action: IJoinEntry[] = [ @@ -591,14 +589,14 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -608,13 +606,13 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -622,34 +620,33 @@ describe("DeltaQueryIterator", () => { }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - expect(await arrayifyStream(delta)).toBeIsomorphicBindingsArray([]); + await expect(arrayifyStream(delta)).resolves.toBeIsomorphicBindingsArray([]); - expect(mediateFunc).toBeCalledTimes(2); + expect(mediateFunc).toHaveBeenCalledTimes(2); }); - it('should join three entries', async () => { - mediateFunc = jest.fn(async (arg: IActionQueryOperation): Promise => { + it('should join three entries', async() => { + mediateFunc = jest.fn(async(arg: IActionQueryOperation): Promise => { return { bindingsStream: new EmptyIterator(), metadata: () => Promise.resolve({ state: new MetadataValidationState(), - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('bound')], + variables: [ DF.variable('bound') ], }), type: 'bindings', }; }); mediatorQueryOperation = { - mediate: mediateFunc + mediate: mediateFunc, }; const action: IJoinEntry[] = [ @@ -657,14 +654,14 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -674,13 +671,13 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -690,13 +687,13 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, @@ -704,28 +701,26 @@ describe("DeltaQueryIterator", () => { }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - delta.on("data", () => { - }) + delta.on('data', () => {}); await promisifyEventEmitter(delta); - expect(mediateFunc).toBeCalledTimes(3); + expect(mediateFunc).toHaveBeenCalledTimes(3); }); - it('should handle a failed sub query', async () => { - mediateFunc = jest.fn(async (arg: IActionQueryOperation): Promise => { - throw new Error("test") + it('should handle a failed sub query', async() => { + mediateFunc = jest.fn(async(arg: IActionQueryOperation): Promise => { + throw new Error('test'); }); mediatorQueryOperation = { - mediate: mediateFunc + mediate: mediateFunc, }; const action: IJoinEntry[] = [ @@ -733,14 +728,14 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], - [DF.variable('b'), DF.namedNode('ex:b1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], + [ DF.variable('b'), DF.namedNode('ex:b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 3}, + cardinality: { type: 'estimate', value: 3 }, canContainUndefs: false, - variables: [DF.variable('a'), DF.variable('b')], + variables: [ DF.variable('a'), DF.variable('b') ], }), type: 'bindings', }, @@ -750,32 +745,30 @@ describe("DeltaQueryIterator", () => { output: { bindingsStream: new ArrayIterator([ BF.bindings([ - [DF.variable('a'), DF.namedNode('ex:a1')], + [ DF.variable('a'), DF.namedNode('ex:a1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ], {autoStart: false}), + ], { autoStart: false }), metadata: () => Promise.resolve({ - cardinality: {type: 'estimate', value: 1}, + cardinality: { type: 'estimate', value: 1 }, canContainUndefs: false, - variables: [DF.variable('a')], + variables: [ DF.variable('a') ], }), type: 'bindings', }, operation: FACTORY.createPattern(DF.variable('a'), DF.namedNode('ex:p2'), DF.namedNode('ex:o')), - } + }, ]; - const delta = new DeltaQueryIterator( action, context, - mediatorQueryOperation + mediatorQueryOperation, ); - delta.on("data", () => { - }) + delta.on('data', () => {}); await promisifyEventEmitter(delta); - expect(mediateFunc).toBeCalledTimes(2); + expect(mediateFunc).toHaveBeenCalledTimes(2); }); -}) +}); diff --git a/packages/actor-rdf-join-inner-incremental-nestedloop/README.md b/packages/actor-rdf-join-inner-incremental-nestedloop/README.md index 1e1e998e..8e812442 100644 --- a/packages/actor-rdf-join-inner-incremental-nestedloop/README.md +++ b/packages/actor-rdf-join-inner-incremental-nestedloop/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-nestedloop/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-nestedloop/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-inner-incremental-nestedloop/lib/ActorRdfJoinInnerIncrementalNestedloop.ts b/packages/actor-rdf-join-inner-incremental-nestedloop/lib/ActorRdfJoinInnerIncrementalNestedloop.ts index b3c6dd66..ebdb8faa 100644 --- a/packages/actor-rdf-join-inner-incremental-nestedloop/lib/ActorRdfJoinInnerIncrementalNestedloop.ts +++ b/packages/actor-rdf-join-inner-incremental-nestedloop/lib/ActorRdfJoinInnerIncrementalNestedloop.ts @@ -1,3 +1,4 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { IActionRdfJoin, IActorRdfJoinArgs, @@ -7,11 +8,9 @@ import { ActorRdfJoin, } from '@comunica/bus-rdf-join'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; -import type { MetadataBindings } from '@comunica/types'; -import type { BindingsStream } from '@comunica/types'; -import { IncrementalNestedLoopJoin } from './IncrementalNestedLoopJoin'; -import type { Bindings } from '@comunica/bindings-factory'; +import type { MetadataBindings, BindingsStream } from '@comunica/types'; import type { AsyncIterator } from 'asynciterator'; +import { IncrementalNestedLoopJoin } from './IncrementalNestedLoopJoin'; /** * A comunica Inner Incremental Nestedloop RDF Join Actor. @@ -27,7 +26,7 @@ export class ActorRdfJoinInnerIncrementalNestedloop extends ActorRdfJoin { } protected async getOutput(action: IActionRdfJoin): Promise { - const bindingsStream = new IncrementalNestedLoopJoin( + const bindingsStream = new IncrementalNestedLoopJoin( >action.entries[0].output.bindingsStream, >action.entries[1].output.bindingsStream, <(...bindings: Bindings[]) => Bindings | null>ActorRdfJoin.joinBindings, @@ -46,8 +45,8 @@ export class ActorRdfJoinInnerIncrementalNestedloop extends ActorRdfJoin { } protected async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-inner-incremental-nestedloop/lib/IncrementalNestedLoopJoin.ts b/packages/actor-rdf-join-inner-incremental-nestedloop/lib/IncrementalNestedLoopJoin.ts index 2bab2a88..92a99aa6 100644 --- a/packages/actor-rdf-join-inner-incremental-nestedloop/lib/IncrementalNestedLoopJoin.ts +++ b/packages/actor-rdf-join-inner-incremental-nestedloop/lib/IncrementalNestedLoopJoin.ts @@ -1,6 +1,6 @@ -import { IncrementalInnerJoin, Side } from '@incremunica/incremental-inner-join'; import type { Bindings } from '@comunica/bindings-factory'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { IncrementalInnerJoin, Side } from '@incremunica/incremental-inner-join'; export class IncrementalNestedLoopJoin extends IncrementalInnerJoin { private readonly rightMemory: Bindings[] = []; @@ -26,7 +26,7 @@ export class IncrementalNestedLoopJoin extends IncrementalInnerJoin { } const index = memory.findIndex((bindings: Bindings) => item.equals(bindings)); if (index !== -1) { - memory[index] = memory[memory.length - 1]; + memory[index] = memory.at(-1)!; memory.pop(); return true; } @@ -40,7 +40,7 @@ export class IncrementalNestedLoopJoin extends IncrementalInnerJoin { } else { otherArray = this.rightMemory; } - // eslint-disable-next-line no-constant-condition + while (true) { if (this.ended) { return null; diff --git a/packages/actor-rdf-join-inner-incremental-nestedloop/package.json b/packages/actor-rdf-join-inner-incremental-nestedloop/package.json index 9b7a757a..474786a5 100644 --- a/packages/actor-rdf-join-inner-incremental-nestedloop/package.json +++ b/packages/actor-rdf-join-inner-incremental-nestedloop/package.json @@ -3,44 +3,45 @@ "version": "1.3.0", "description": "A inner-incremental-nestedloop rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-inner-incremental-nestedloop" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "inner-incremental-nestedloop" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@comunica/bus-rdf-join": "^3.2.1", - "@comunica/mediatortype-join-coefficients": "^3.2.1", - "@comunica/types": "^3.2.1", - "@incremunica/incremental-inner-join": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/bindings-factory": "^3.3.0", + "@comunica/bus-rdf-join": "^3.2.1", + "@comunica/mediatortype-join-coefficients": "^3.2.1", + "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", + "@incremunica/incremental-inner-join": "^1.3.0" } } diff --git a/packages/actor-rdf-join-inner-incremental-nestedloop/test/ActorRdfJoinInnerIncrementalNestedloop-test.ts b/packages/actor-rdf-join-inner-incremental-nestedloop/test/ActorRdfJoinInnerIncrementalNestedloop-test.ts index 40021044..cb9cba58 100644 --- a/packages/actor-rdf-join-inner-incremental-nestedloop/test/ActorRdfJoinInnerIncrementalNestedloop-test.ts +++ b/packages/actor-rdf-join-inner-incremental-nestedloop/test/ActorRdfJoinInnerIncrementalNestedloop-test.ts @@ -1,19 +1,19 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import { ActorRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; import type { IQueryOperationResultBindings, Bindings, IActionContext } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; import type * as RDF from '@rdfjs/types'; import arrayifyStream from 'arrayify-stream'; -import {ArrayIterator} from 'asynciterator'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { ActorRdfJoinInnerIncrementalNestedloop } from '../lib/ActorRdfJoinInnerIncrementalNestedloop'; import '@incremunica/incremental-jest'; -import { MetadataValidationState } from '@comunica/metadata'; -import {DevTools} from "@incremunica/dev-tools"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; const DF = new DataFactory(); @@ -22,8 +22,8 @@ describe('ActorRdfJoinNestedLoop', () => { let context: IActionContext; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); context = new ActionContext(); BF = await DevTools.createBindingsFactory(DF); }); @@ -34,19 +34,26 @@ describe('ActorRdfJoinNestedLoop', () => { }); it('should be a ActorRdfJoinNestedLoop constructor', () => { - expect(new ( ActorRdfJoinInnerIncrementalNestedloop)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoinInnerIncrementalNestedloop); - expect(new ( ActorRdfJoinInnerIncrementalNestedloop)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoin); + expect(new ( ActorRdfJoinInnerIncrementalNestedloop)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoinInnerIncrementalNestedloop); + expect(new ( ActorRdfJoinInnerIncrementalNestedloop)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoin); }); it('should not be able to create new ActorRdfJoinNestedLoop objects without \'new\'', () => { - expect(() => { ( ActorRdfJoinInnerIncrementalNestedloop)(); }).toThrow(); + expect(() => { + ( ActorRdfJoinInnerIncrementalNestedloop)(); + }).toThrow(''); }); }); describe('An ActorRdfJoinNestedLoop instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, +IActorTest, +IActorRdfJoinSelectivityOutput +>; let actor: ActorRdfJoinInnerIncrementalNestedloop; let action: IActionRdfJoin; let variables0: RDF.Variable[]; @@ -99,15 +106,17 @@ describe('ActorRdfJoinNestedLoop', () => { describe('should test', () => { afterEach(() => { - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } }); - it('should only handle 2 streams', () => { - action.entries.push( {}); - return expect(actor.test(action)).rejects.toBeTruthy(); + it('should only handle 2 streams', async() => { + action.entries.push({}); + await expect(actor.test(action)).rejects.toBeTruthy(); }); - it('should handle undefs in left stream', () => { + it('should handle undefs in left stream', async() => { action.entries[0].output.metadata = async() => ({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, @@ -116,7 +125,7 @@ describe('ActorRdfJoinNestedLoop', () => { canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).resolves + await expect(actor.test(action)).resolves .toEqual({ iterations: 0, persistedItems: 0, @@ -125,7 +134,7 @@ describe('ActorRdfJoinNestedLoop', () => { }); }); - it('should handle undefs in right stream', () => { + it('should handle undefs in right stream', async() => { action.entries[1].output.metadata = async() => ({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 5 }, @@ -134,7 +143,7 @@ describe('ActorRdfJoinNestedLoop', () => { canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).resolves + await expect(actor.test(action)).resolves .toEqual({ iterations: 0, persistedItems: 0, @@ -143,7 +152,7 @@ describe('ActorRdfJoinNestedLoop', () => { }); }); - it('should handle undefs in left and right stream', () => { + it('should handle undefs in left and right stream', async() => { action.entries[0].output.metadata = async() => ({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, @@ -160,7 +169,7 @@ describe('ActorRdfJoinNestedLoop', () => { canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).resolves + await expect(actor.test(action)).resolves .toEqual({ iterations: 0, persistedItems: 0, @@ -176,34 +185,36 @@ describe('ActorRdfJoinNestedLoop', () => { it('should generate correct metadata', async() => { await actor.run(action).then(async(result: IQueryOperationResultBindings) => { - await expect(( result).metadata()).resolves.toHaveProperty('cardinality', - { type: 'estimate', - value: (await ( action.entries[0].output).metadata()).cardinality.value * - (await ( action.entries[1].output).metadata()).cardinality.value }); + await expect(( result).metadata()).resolves + .toHaveProperty( + 'cardinality', + { type: 'estimate', value: (await ( action.entries[0].output).metadata()).cardinality.value * + (await ( action.entries[1].output).metadata()).cardinality.value }, + ); await expect(result.bindingsStream).toEqualBindingsStream([]); }); }); - it('should return an empty stream for empty input', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + it('should return an empty stream for empty input', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should return null on read if join has ended', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - expect(output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.read()).toBeNull(); - }); + it('should return null on read if join has ended', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); + expect(output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.read()).toBeNull(); }); - it('should end after both streams are ended and no new elements can be generated', () => { + it('should end after both streams are ended and no new elements can be generated', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -223,21 +234,22 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - output.bindingsStream.read() - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); - expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.ended).toBeFalsy(); - await arrayifyStream(output.bindingsStream) - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(output.bindingsStream.ended).toBeTruthy(); - }); + const output = await actor.run(action); + output.bindingsStream.read(); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); + expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.ended).toBeFalsy(); + await arrayifyStream(output.bindingsStream); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(output.bindingsStream.ended).toBeTruthy(); }); - it('should join bindings with matching values', () => { + it('should join bindings with matching values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -253,21 +265,22 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([ - BF.bindings([ - [ DF.variable('a'), DF.literal('a') ], - [ DF.variable('b'), DF.literal('b') ], - [ DF.variable('c'), DF.literal('c') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([ + BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + [ DF.variable('b'), DF.literal('b') ], + [ DF.variable('c'), DF.literal('c') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); }); - it('should not join bindings with incompatible values', () => { + it('should not join bindings with incompatible values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -283,15 +296,16 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should join multiple bindings', () => { + it('should join multiple bindings', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -347,61 +361,61 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('4') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('4') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with undefs', () => { + it('should join multiple bindings with undefs', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -432,36 +446,36 @@ describe('ActorRdfJoinNestedLoop', () => { variables: variables1, }); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (left)', () => { + it('should join multiple bindings with negative bindings (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -501,25 +515,26 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (right)', () => { + it('should join multiple bindings with negative bindings (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -559,65 +574,66 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (left)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -649,30 +665,31 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (right)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -704,30 +721,31 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should be symmetric', () => { + it('should be symmetric', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -735,13 +753,13 @@ describe('ActorRdfJoinNestedLoop', () => { [ DF.variable('b'), DF.literal('2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]).transform({ - transform: (item: Bindings, done: () => void, push: (i: RDF.Bindings) => void) => { + transform: (item: Bindings, done: () => void, push: (i: RDF.Bindings) => void) => { push(item); setTimeout(() => { push(item); done(); - }, 100) - } + }, 100); + }, }); variables0 = [ DF.variable('a'), DF.variable('b') ]; action.entries[1].output.bindingsStream = new ArrayIterator([ @@ -751,26 +769,23 @@ describe('ActorRdfJoinNestedLoop', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - }); }); diff --git a/packages/actor-rdf-join-inner-incremental-partial-hash/README.md b/packages/actor-rdf-join-inner-incremental-partial-hash/README.md index b359e9de..0e7c8bcb 100644 --- a/packages/actor-rdf-join-inner-incremental-partial-hash/README.md +++ b/packages/actor-rdf-join-inner-incremental-partial-hash/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-partial-hash/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-incremental-partial-hash/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-join-inner-incremental-partial-hash/lib/ActorRdfJoinInnerIncrementalPartialHash.ts b/packages/actor-rdf-join-inner-incremental-partial-hash/lib/ActorRdfJoinInnerIncrementalPartialHash.ts index 6759ee2e..99c59185 100644 --- a/packages/actor-rdf-join-inner-incremental-partial-hash/lib/ActorRdfJoinInnerIncrementalPartialHash.ts +++ b/packages/actor-rdf-join-inner-incremental-partial-hash/lib/ActorRdfJoinInnerIncrementalPartialHash.ts @@ -1,3 +1,4 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { IActionRdfJoin, IActorRdfJoinArgs, @@ -7,11 +8,9 @@ import { ActorRdfJoin, } from '@comunica/bus-rdf-join'; import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients'; -import type { MetadataBindings } from '@comunica/types'; -import type { BindingsStream } from '@comunica/types'; -import { IncrementalPartialHashJoin } from './IncrementalPartialHashJoin'; -import type { Bindings } from '@comunica/bindings-factory'; +import type { MetadataBindings, BindingsStream } from '@comunica/types'; import type { AsyncIterator } from 'asynciterator'; +import { IncrementalPartialHashJoin } from './IncrementalPartialHashJoin'; /** * A comunica Inner Incremental Partial Hash RDF Join Actor. @@ -29,7 +28,7 @@ export class ActorRdfJoinInnerIncrementalPartialHash extends ActorRdfJoin { protected async getOutput(action: IActionRdfJoin): Promise { const metadatas = await ActorRdfJoin.getMetadatas(action.entries); const variables = ActorRdfJoin.overlappingVariables(metadatas); - const bindingsStream = new IncrementalPartialHashJoin( + const bindingsStream = new IncrementalPartialHashJoin( >action.entries[0].output.bindingsStream, >action.entries[1].output.bindingsStream, <(...bindings: Bindings[]) => Bindings | null>ActorRdfJoin.joinBindings, @@ -49,8 +48,8 @@ export class ActorRdfJoinInnerIncrementalPartialHash extends ActorRdfJoin { } protected async getJoinCoefficients( - action: IActionRdfJoin, - metadatas: MetadataBindings[], + _action: IActionRdfJoin, + _metadatas: MetadataBindings[], ): Promise { return { iterations: 0, diff --git a/packages/actor-rdf-join-inner-incremental-partial-hash/lib/IncrementalPartialHashJoin.ts b/packages/actor-rdf-join-inner-incremental-partial-hash/lib/IncrementalPartialHashJoin.ts index 1a4591da..9ef2b8af 100644 --- a/packages/actor-rdf-join-inner-incremental-partial-hash/lib/IncrementalPartialHashJoin.ts +++ b/packages/actor-rdf-join-inner-incremental-partial-hash/lib/IncrementalPartialHashJoin.ts @@ -1,6 +1,6 @@ -import { IncrementalInnerJoin } from '@incremunica/incremental-inner-join'; import type { Bindings } from '@comunica/bindings-factory'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { IncrementalInnerJoin } from '@incremunica/incremental-inner-join'; import type { AsyncIterator } from 'asynciterator'; export class IncrementalPartialHashJoin extends IncrementalInnerJoin { @@ -55,7 +55,7 @@ export class IncrementalPartialHashJoin extends IncrementalInnerJoin { const index = array.findIndex((bindings: Bindings) => item.equals(bindings)); if (index !== -1) { - array[index] = array[array.length - 1]; + array[index] = array.at(-1)!; array.pop(); return true; } @@ -63,7 +63,6 @@ export class IncrementalPartialHashJoin extends IncrementalInnerJoin { } public read(): Bindings | null { - // eslint-disable-next-line no-constant-condition while (true) { if (this.ended) { return null; diff --git a/packages/actor-rdf-join-inner-incremental-partial-hash/package.json b/packages/actor-rdf-join-inner-incremental-partial-hash/package.json index d57ecb70..d0960e67 100644 --- a/packages/actor-rdf-join-inner-incremental-partial-hash/package.json +++ b/packages/actor-rdf-join-inner-incremental-partial-hash/package.json @@ -3,44 +3,46 @@ "version": "1.3.0", "description": "A inner-incremental-partial-hash rdf-join actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-join-inner-incremental-partial-hash" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "inner-incremental-partial-hash" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", "@comunica/bus-rdf-join": "^3.2.1", "@comunica/mediatortype-join-coefficients": "^3.2.1", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@incremunica/incremental-inner-join": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" + "asynciterator": "^3.9.0" } } diff --git a/packages/actor-rdf-join-inner-incremental-partial-hash/test/ActorRdfJoinInnerIncrementalPartialHash-test.ts b/packages/actor-rdf-join-inner-incremental-partial-hash/test/ActorRdfJoinInnerIncrementalPartialHash-test.ts index 3507b599..50cecaec 100644 --- a/packages/actor-rdf-join-inner-incremental-partial-hash/test/ActorRdfJoinInnerIncrementalPartialHash-test.ts +++ b/packages/actor-rdf-join-inner-incremental-partial-hash/test/ActorRdfJoinInnerIncrementalPartialHash-test.ts @@ -1,19 +1,19 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import type { IActionRdfJoin } from '@comunica/bus-rdf-join'; import { ActorRdfJoin } from '@comunica/bus-rdf-join'; import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity'; import type { Actor, IActorTest, Mediator } from '@comunica/core'; import { ActionContext, Bus } from '@comunica/core'; +import { MetadataValidationState } from '@comunica/metadata'; import type { IQueryOperationResultBindings, Bindings, IActionContext } from '@comunica/types'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; import type * as RDF from '@rdfjs/types'; import arrayifyStream from 'arrayify-stream'; -import {ArrayIterator} from 'asynciterator'; +import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; import { ActorRdfJoinInnerIncrementalPartialHash } from '../lib/ActorRdfJoinInnerIncrementalPartialHash'; import '@incremunica/incremental-jest'; -import { MetadataValidationState } from '@comunica/metadata'; -import {DevTools} from "@incremunica/dev-tools"; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; const DF = new DataFactory(); @@ -22,8 +22,8 @@ describe('ActorRdfJoinPartialHash', () => { let context: IActionContext; let BF: BindingsFactory; - beforeEach(async () => { - bus = new Bus({name: 'bus'}); + beforeEach(async() => { + bus = new Bus({ name: 'bus' }); context = new ActionContext(); BF = await DevTools.createBindingsFactory(DF); }); @@ -34,19 +34,26 @@ describe('ActorRdfJoinPartialHash', () => { }); it('should be a ActorRdfJoinPartialHash constructor', () => { - expect(new ( ActorRdfJoinInnerIncrementalPartialHash)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoinInnerIncrementalPartialHash); - expect(new ( ActorRdfJoinInnerIncrementalPartialHash)({ name: 'actor', bus })).toBeInstanceOf(ActorRdfJoin); + expect(new ( ActorRdfJoinInnerIncrementalPartialHash)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoinInnerIncrementalPartialHash); + expect(new ( ActorRdfJoinInnerIncrementalPartialHash)({ name: 'actor', bus })) + .toBeInstanceOf(ActorRdfJoin); }); it('should not be able to create new ActorRdfJoinPartialHash objects without \'new\'', () => { - expect(() => { ( ActorRdfJoinInnerIncrementalPartialHash)(); }).toThrow(); + expect(() => { + ( ActorRdfJoinInnerIncrementalPartialHash)(); + }).toThrow(''); }); }); describe('An ActorRdfJoinPartialHash instance', () => { let mediatorJoinSelectivity: Mediator< Actor, - IActionRdfJoinSelectivity, IActorTest, IActorRdfJoinSelectivityOutput>; + IActionRdfJoinSelectivity, +IActorTest, +IActorRdfJoinSelectivityOutput +>; let actor: ActorRdfJoinInnerIncrementalPartialHash; let action: IActionRdfJoin; let variables0: RDF.Variable[]; @@ -99,37 +106,39 @@ describe('ActorRdfJoinPartialHash', () => { describe('should test', () => { afterEach(() => { - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } }); - it('should only handle 2 streams', () => { - action.entries.push( {}); - return expect(actor.test(action)).rejects.toBeTruthy(); + it('should only handle 2 streams', async() => { + action.entries.push({}); + await expect(actor.test(action)).rejects.toBeTruthy(); }); - it('should fail on undefs in left stream', () => { + it('should fail on undefs in left stream', async() => { action.entries[0].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); - it('should fail on undefs in right stream', () => { + it('should fail on undefs in right stream', async() => { action.entries[1].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); - it('should fail on undefs in left and right stream', () => { + it('should fail on undefs in left and right stream', async() => { action.entries[0].output.metadata = () => Promise.resolve({ state: new MetadataValidationState(), cardinality: { type: 'estimate', value: 4 }, @@ -142,7 +151,7 @@ describe('ActorRdfJoinPartialHash', () => { canContainUndefs: true, variables: [], }); - return expect(actor.test(action)).rejects + await expect(actor.test(action)).rejects .toThrow(new Error('Actor actor can not join streams containing undefs')); }); @@ -152,35 +161,39 @@ describe('ActorRdfJoinPartialHash', () => { }); it('should generate correct metadata', async() => { - await actor.run(action).then(async(result: IQueryOperationResultBindings) => { - await expect(( result).metadata()).resolves.toHaveProperty('cardinality', - { type: 'estimate', + const result = await actor.run(action); + await expect(( result).metadata()).resolves + .toHaveProperty( + 'cardinality', + { + type: 'estimate', value: (await ( action.entries[0].output).metadata()).cardinality.value * - (await ( action.entries[1].output).metadata()).cardinality.value }); + (await ( action.entries[1].output).metadata()).cardinality.value, + }, + ); - await expect(result.bindingsStream).toEqualBindingsStream([]); - }); + await expect(result.bindingsStream).toEqualBindingsStream([]); }); - it('should return an empty stream for empty input', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + it('should return an empty stream for empty input', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should return null on read if join has ended', () => { - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - expect(output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.read()).toBeNull(); - }); + it('should return null on read if join has ended', async() => { + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([]); + await expect(output.bindingsStream).toEqualBindingsStream([]); + expect(output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.read()).toBeNull(); }); - it('should end after both streams are ended and no new elements can be generated', () => { + it('should end after both streams are ended and no new elements can be generated', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -200,21 +213,22 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - output.bindingsStream.read() - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); - expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); - expect(output.bindingsStream.ended).toBeFalsy(); - await arrayifyStream(output.bindingsStream) - await new Promise((resolve) => setTimeout(() => resolve(), 100)); - expect(output.bindingsStream.ended).toBeTruthy(); - }); + const output = await actor.run(action); + output.bindingsStream.read(); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(action.entries[0].output.bindingsStream.ended).toBeTruthy(); + expect(action.entries[1].output.bindingsStream.ended).toBeTruthy(); + expect(output.bindingsStream.ended).toBeFalsy(); + await arrayifyStream(output.bindingsStream); + await new Promise(resolve => setTimeout(() => resolve(), 100)); + expect(output.bindingsStream.ended).toBeTruthy(); }); - it('should join bindings with matching values', () => { + it('should join bindings with matching values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -230,21 +244,22 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([ - BF.bindings([ - [ DF.variable('a'), DF.literal('a') ], - [ DF.variable('b'), DF.literal('b') ], - [ DF.variable('c'), DF.literal('c') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([ + BF.bindings([ + [ DF.variable('a'), DF.literal('a') ], + [ DF.variable('b'), DF.literal('b') ], + [ DF.variable('c'), DF.literal('c') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); }); - it('should not join bindings with incompatible values', () => { + it('should not join bindings with incompatible values', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -260,15 +275,16 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - await expect(output.bindingsStream).toEqualBindingsStream([]); - }); + const output = await actor.run(action); + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + await expect(output.bindingsStream).toEqualBindingsStream([]); }); - it('should join multiple bindings', () => { + it('should join multiple bindings', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -324,61 +340,61 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('5') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('3') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('3') ], - [ DF.variable('b'), DF.literal('4') ], - [ DF.variable('c'), DF.literal('7') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('5') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('3') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('3') ], + [ DF.variable('b'), DF.literal('4') ], + [ DF.variable('c'), DF.literal('7') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (left)', () => { + it('should join multiple bindings with negative bindings (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -418,25 +434,26 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings (right)', () => { + it('should join multiple bindings with negative bindings (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -476,65 +493,67 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (left)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (left)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -566,30 +585,31 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { - const expected = [ - BF.bindings([ - [ DF.variable('a'), DF.literal('1') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('4') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.literal('2') ], - [ DF.variable('b'), DF.literal('2') ], - [ DF.variable('c'), DF.literal('6') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]; - expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); - // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected - ); - }); + const output = await actor.run(action); + const expected = [ + BF.bindings([ + [ DF.variable('a'), DF.literal('1') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('4') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.literal('2') ], + [ DF.variable('b'), DF.literal('2') ], + [ DF.variable('c'), DF.literal('6') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]; + expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); + // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, + ); }); - it('should join multiple bindings with negative bindings that are not in the result set (right)', () => { + it('should join multiple bindings with negative bindings that are not in the result set (right)', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -621,7 +641,7 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), false), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { + await actor.run(action).then(async(output: IQueryOperationResultBindings) => { const expected = [ BF.bindings([ [ DF.variable('a'), DF.literal('1') ], @@ -641,15 +661,17 @@ describe('ActorRdfJoinPartialHash', () => { ]; expect((await output.metadata()).variables).toEqual([ DF.variable('a'), DF.variable('b'), DF.variable('c') ]); // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - expect(await arrayifyStream(output.bindingsStream)).toBeIsomorphicBindingsArray( - expected + await expect(arrayifyStream(output.bindingsStream)).resolves.toBeIsomorphicBindingsArray( + expected, ); }); }); - it('should be symmetric', () => { + it('should be symmetric', async() => { // Clean up the old bindings - action.entries.forEach(output => output.output?.bindingsStream?.destroy()); + for (const output of action.entries) { + output.output?.bindingsStream?.destroy(); + } action.entries[0].output.bindingsStream = new ArrayIterator([ BF.bindings([ @@ -662,8 +684,8 @@ describe('ActorRdfJoinPartialHash', () => { setTimeout(() => { push(item); done(); - }, 100) - } + }, 100); + }, }); variables0 = [ DF.variable('a'), DF.variable('b') ]; action.entries[1].output.bindingsStream = new ArrayIterator([ @@ -673,7 +695,7 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]); variables1 = [ DF.variable('a'), DF.variable('c') ]; - return actor.run(action).then(async(output: IQueryOperationResultBindings) => { + await actor.run(action).then(async(output: IQueryOperationResultBindings) => { const expected = [ BF.bindings([ [ DF.variable('a'), DF.literal('1') ], @@ -687,12 +709,10 @@ describe('ActorRdfJoinPartialHash', () => { ]).setContextEntry(new ActionContextKeyIsAddition(), true), ]; // Mapping to string and sorting since we don't know order (well, we sort of know, but we might not!) - // eslint-disable-next-line @typescript-eslint/require-array-sort-compare - expect((await arrayifyStream(output.bindingsStream))).toBeIsomorphicBindingsArray( - expected + await expect((arrayifyStream(output.bindingsStream))).resolves.toBeIsomorphicBindingsArray( + expected, ); }); }); - }); }); diff --git a/packages/actor-rdf-metadata-extract-guard-data/README.md b/packages/actor-rdf-metadata-extract-guard-data/README.md index 9cee0e64..d716f258 100644 --- a/packages/actor-rdf-metadata-extract-guard-data/README.md +++ b/packages/actor-rdf-metadata-extract-guard-data/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-guard-data/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-metadata-extract-guard-data/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-rdf-metadata-extract-guard-data/lib/ActorRdfMetadataExtractGuardData.ts b/packages/actor-rdf-metadata-extract-guard-data/lib/ActorRdfMetadataExtractGuardData.ts index 2c0e0e98..0f20d166 100644 --- a/packages/actor-rdf-metadata-extract-guard-data/lib/ActorRdfMetadataExtractGuardData.ts +++ b/packages/actor-rdf-metadata-extract-guard-data/lib/ActorRdfMetadataExtractGuardData.ts @@ -14,7 +14,7 @@ export class ActorRdfMetadataExtractGuardData extends ActorRdfMetadataExtract { super(args); } - public async test(action: IActionRdfMetadataExtract): Promise { + public async test(_action: IActionRdfMetadataExtract): Promise { return true; } diff --git a/packages/actor-rdf-metadata-extract-guard-data/package.json b/packages/actor-rdf-metadata-extract-guard-data/package.json index 83ffa3f2..814ac404 100644 --- a/packages/actor-rdf-metadata-extract-guard-data/package.json +++ b/packages/actor-rdf-metadata-extract-guard-data/package.json @@ -3,41 +3,41 @@ "version": "1.3.0", "description": "A guard-data rdf-metadata-extract actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-rdf-metadata-extract-guard-data" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-metadata-extract", "guard-data" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@comunica/bus-rdf-metadata-extract": "^3.2.1", - "@comunica/core": "^3.2.1" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/bus-rdf-metadata-extract": "^3.2.1", + "@comunica/core": "^3.2.1" } } diff --git a/packages/actor-rdf-metadata-extract-guard-data/test/ActorRdfMetadataExtractGuardData-test.ts b/packages/actor-rdf-metadata-extract-guard-data/test/ActorRdfMetadataExtractGuardData-test.ts index e308949a..eb3c2652 100644 --- a/packages/actor-rdf-metadata-extract-guard-data/test/ActorRdfMetadataExtractGuardData-test.ts +++ b/packages/actor-rdf-metadata-extract-guard-data/test/ActorRdfMetadataExtractGuardData-test.ts @@ -15,57 +15,57 @@ describe('ActorRdfMetadataExtractGuardData', () => { actor = new ActorRdfMetadataExtractGuardData({ name: 'actor', bus }); }); - it('should test', () => { - return expect(actor.test({})).resolves.toBeTruthy(); + it('should test', async() => { + await expect(actor.test({})).resolves.toBeTruthy(); }); - it('should run and extract data from headers', () => { - return expect(actor.run({ + it('should run and extract data from headers', async() => { + await expect(actor.run({ metadata: {}, context: {}, requestTime: 0, - url: "http://test.com", + url: 'http://test.com', headers: { get: (key: string) => { - if (key === "etag") { - return "123"; + if (key === 'etag') { + return '123'; } - if (key === "cache-control") { - return "max-age:20"; + if (key === 'cache-control') { + return 'max-age:20'; } - if (key === "age") { - return "5"; + if (key === 'age') { + return '5'; } - return null - } - } + return null; + }, + }, })).resolves.toMatchObject({ metadata: { - etag: "123", - "cache-control": "max-age:20", - age: "5" - } + etag: '123', + 'cache-control': 'max-age:20', + age: '5', + }, }); }); - it('should run with not all headers available', () => { - return expect(actor.run({ + it('should run with not all headers available', async() => { + await expect(actor.run({ metadata: {}, context: {}, requestTime: 0, - url: "http://test.com", - headers: { + url: 'http://test.com', + headers: { get: (key: string) => { - if (key === "etag") { - return "123"; + if (key === 'etag') { + return '123'; } - return null - } - } + return null; + }, + }, })).resolves.toMatchObject({ metadata: { - etag: "123" - } + etag: '123', + }, }); }); }); diff --git a/packages/actor-resource-watch-polling/README.md b/packages/actor-resource-watch-polling/README.md index ca0ebc11..64716311 100644 --- a/packages/actor-resource-watch-polling/README.md +++ b/packages/actor-resource-watch-polling/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-resource-watch-polling/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-resource-watch-polling/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-resource-watch-polling/lib/ActorResourceWatchPolling.ts b/packages/actor-resource-watch-polling/lib/ActorResourceWatchPolling.ts index 3d6e98d0..23d674e5 100644 --- a/packages/actor-resource-watch-polling/lib/ActorResourceWatchPolling.ts +++ b/packages/actor-resource-watch-polling/lib/ActorResourceWatchPolling.ts @@ -1,10 +1,11 @@ -import { EventEmitter } from 'events'; +import { EventEmitter } from 'node:events'; import type { MediatorHttp } from '@comunica/bus-http'; import type { IActorTest } from '@comunica/core'; import type { IActionResourceWatch, IActorResourceWatchArgs, - IActorResourceWatchOutput, IResourceWatchEventEmitter, + IActorResourceWatchOutput, + IResourceWatchEventEmitter, } from '@incremunica/bus-resource-watch'; import { ActorResourceWatch, @@ -23,7 +24,7 @@ export class ActorResourceWatchPolling extends ActorResourceWatch { super(args); } - public async test(action: IActionResourceWatch): Promise { + public async test(_action: IActionResourceWatch): Promise { return { priority: this.priority }; } @@ -32,6 +33,7 @@ export class ActorResourceWatchPolling extends ActorResourceWatch { let etag = action.metadata.etag; const checkForChanges = async(): Promise => { + // TODO maybe add a log if something goes wrong const responseHead = await this.mediatorHttp.mediate( { context: action.context, @@ -56,7 +58,9 @@ export class ActorResourceWatchPolling extends ActorResourceWatch { const startCheckLoop = (maxAge: number): void => { timeoutId = setInterval( - checkForChanges, + () => { + checkForChanges().catch(() => {}); + }, maxAge * 1_000, ); }; @@ -72,12 +76,15 @@ export class ActorResourceWatchPolling extends ActorResourceWatch { const age = Number.parseInt(action.metadata.age, 10); if (age) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - new Promise(resolve => { + // eslint-disable-next-line ts/no-floating-promises + new Promise((resolve) => { timeoutId = setTimeout( - async() => { - await checkForChanges(); - resolve(); + () => { + checkForChanges().then( + () => resolve(), + ).catch( + () => resolve(), + ); }, (pollingFrequency - age) * 1_000, ); diff --git a/packages/actor-resource-watch-polling/package.json b/packages/actor-resource-watch-polling/package.json index 336fe93c..3dc41116 100644 --- a/packages/actor-resource-watch-polling/package.json +++ b/packages/actor-resource-watch-polling/package.json @@ -3,42 +3,42 @@ "version": "1.3.0", "description": "A polling-diff guard actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-resource-watch-polling" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "guard", "polling-diff" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@comunica/bus-http": "^3.2.1", - "@comunica/core": "^3.2.1", - "@incremunica/bus-resource-watch": "^1.3.0" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/bus-http": "^3.2.1", + "@comunica/core": "^3.2.1", + "@incremunica/bus-resource-watch": "^1.3.0" } } diff --git a/packages/actor-resource-watch-polling/test/ActorResourceWatchPolling-test.ts b/packages/actor-resource-watch-polling/test/ActorResourceWatchPolling-test.ts index 6f75aaca..49d5be5f 100644 --- a/packages/actor-resource-watch-polling/test/ActorResourceWatchPolling-test.ts +++ b/packages/actor-resource-watch-polling/test/ActorResourceWatchPolling-test.ts @@ -1,8 +1,9 @@ -import { Actor, Bus, IActorTest, Mediator} from '@comunica/core'; +import type { IActionHttp, IActorHttpOutput } from '@comunica/bus-http'; +import type { Actor, IActorTest, Mediator } from '@comunica/core'; +import { Bus } from '@comunica/core'; +import type { IActionResourceWatch } from '@incremunica/bus-resource-watch'; import { ActorResourceWatchPolling } from '../lib/ActorResourceWatchPolling'; -import {IActionHttp, IActorHttpOutput } from "@comunica/bus-http"; import 'jest-rdf'; -import {IActionResourceWatch} from "@incremunica/bus-resource-watch"; describe('ActorGuardPolling', () => { let bus: any; @@ -15,14 +16,17 @@ describe('ActorGuardPolling', () => { let actor: ActorResourceWatchPolling; let mediatorHttp: Mediator< Actor, - IActionHttp, IActorTest, IActorHttpOutput>; + IActionHttp, +IActorTest, +IActorHttpOutput +>; let priority: number; let action: IActionResourceWatch; let headersObject: { - age: string | undefined, - 'cache-control': string | undefined, - etag: number, + age: string | undefined; + 'cache-control': string | undefined; + etag: number; }; beforeEach(() => { @@ -34,55 +38,55 @@ describe('ActorGuardPolling', () => { }; mediatorHttp = { - mediate: async (action: IActionHttp) => { + mediate: async(action: IActionHttp) => { return { headers: { age: headersObject.age, - 'cache-control': headersObject["cache-control"], + 'cache-control': headersObject['cache-control'], etag: headersObject.etag, get: (key: string) => { - if (key == "etag") { + if (key === 'etag') { return headersObject.etag; } return undefined; - } - } - } + }, + }, + }; }, }; actor = new ActorResourceWatchPolling({ beforeActors: [], - mediatorHttp: mediatorHttp, + mediatorHttp, defaultPollingFrequency: 1, - priority: priority, + priority, name: 'actor', - bus + bus, }); action = { context: {}, - url: "www.test.com", + url: 'www.test.com', metadata: { etag: 0, - "cache-control": undefined, - age: undefined + 'cache-control': undefined, + age: undefined, }, - } + }; }); - it('should test', () => { - return expect(actor.test(action)).resolves.toEqual({ priority: priority }); + it('should test', async() => { + await expect(actor.test(action)).resolves.toEqual({ priority }); }); - it('should get an update if the etag changes', async () => { + it('should get an update if the etag changes', async() => { headersObject.etag = 0; - let result = await actor.run(action); + const result = await actor.run(action); headersObject.etag = 1; - await new Promise(resolve => result.events.on("update", () => { + await new Promise(resolve => result.events.on('update', () => { resolve(); })); @@ -91,20 +95,20 @@ describe('ActorGuardPolling', () => { result.stopFunction(); }); - it('should use cache control', async () => { - //set data of file by setting etag and store + it('should use cache control', async() => { + // Set data of file by setting etag and store action.metadata = { etag: 0, - "cache-control": "max-age=5", - age: "0" - } + 'cache-control': 'max-age=5', + age: '0', + }; - let result = await actor.run(action); + const result = await actor.run(action); headersObject.etag = 1; - let time = process.hrtime(); - await new Promise(resolve => result.events.on("update", () => { + const time = process.hrtime(); + await new Promise(resolve => result.events.on('update', () => { resolve(); })); expect(process.hrtime(time)[0]).toBeGreaterThanOrEqual(3); @@ -112,20 +116,20 @@ describe('ActorGuardPolling', () => { result.stopFunction(); }); - it('should use age', async () => { - //set data of file by setting etag and store + it('should use age', async() => { + // Set data of file by setting etag and store action.metadata = { etag: 0, - "cache-control": "max-age=30", - age: "25" - } + 'cache-control': 'max-age=30', + age: '25', + }; - let result = await actor.run(action); + const result = await actor.run(action); headersObject.etag = 1; - let time = process.hrtime(); - await new Promise(resolve => result.events.on("update", () => { + const time = process.hrtime(); + await new Promise(resolve => result.events.on('update', () => { resolve(); })); expect(process.hrtime(time)[0]).toBeGreaterThanOrEqual(3); diff --git a/packages/actor-resource-watch-solid-notification-websockets/README.md b/packages/actor-resource-watch-solid-notification-websockets/README.md index 811300d2..098d4d45 100644 --- a/packages/actor-resource-watch-solid-notification-websockets/README.md +++ b/packages/actor-resource-watch-solid-notification-websockets/README.md @@ -17,7 +17,7 @@ After installing, this package can be added to your engine's configuration as fo { "@context": [ ... - "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-resource-watch-solid-notification-websockets/^1.0.0/components/context.jsonld" + "https://linkedsoftwaredependencies.org/bundles/npm/@incremunica/actor-resource-watch-solid-notification-websockets/^1.0.0/components/context.jsonld" ], "actors": [ ... diff --git a/packages/actor-resource-watch-solid-notification-websockets/lib/ActorResourceWatchSolidNotificationWebsockets.ts b/packages/actor-resource-watch-solid-notification-websockets/lib/ActorResourceWatchSolidNotificationWebsockets.ts index 31cedf6f..4c276ea5 100644 --- a/packages/actor-resource-watch-solid-notification-websockets/lib/ActorResourceWatchSolidNotificationWebsockets.ts +++ b/packages/actor-resource-watch-solid-notification-websockets/lib/ActorResourceWatchSolidNotificationWebsockets.ts @@ -1,8 +1,9 @@ -import { EventEmitter } from 'events'; +import { EventEmitter } from 'node:events'; import type { MediatorHttp } from '@comunica/bus-http'; import type { IActorTest } from '@comunica/core'; import type { - IActionResourceWatch, IActorResourceWatchArgs, + IActionResourceWatch, + IActorResourceWatchArgs, IActorResourceWatchOutput, IResourceWatchEventEmitter, } from '@incremunica/bus-resource-watch'; @@ -11,7 +12,7 @@ import { } from '@incremunica/bus-resource-watch'; import { SubscriptionClient } from '@solid-notifications/subscription'; import { ChannelType } from '@solid-notifications/types'; -// eslint-disable-next-line import/no-unassigned-import + import 'websocket-polyfill'; /** @@ -62,7 +63,7 @@ export class ActorResourceWatchSolidNotificationWebsockets extends ActorResource const events: IResourceWatchEventEmitter = new EventEmitter(); - socket.onmessage = message => { + socket.onmessage = (message) => { // TODO: For now ignoring the Buffer options => tests? // let data: string | Buffer | ArrayBuffer | Buffer[] = message.data; // if (Array.isArray(data)) { diff --git a/packages/actor-resource-watch-solid-notification-websockets/package.json b/packages/actor-resource-watch-solid-notification-websockets/package.json index aca91934..95f6a6c0 100644 --- a/packages/actor-resource-watch-solid-notification-websockets/package.json +++ b/packages/actor-resource-watch-solid-notification-websockets/package.json @@ -3,34 +3,39 @@ "version": "1.3.0", "description": "An incremunica solid notification resource watch actor", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/actor-resource-watch-solid-notification-websockets" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "resource-watch", "solid-notification-websockets" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { "@comunica/bus-http": "^3.2.1", "@comunica/core": "^3.2.1", @@ -38,10 +43,5 @@ "@solid-notifications/subscription": "^0.1.0", "@solid-notifications/types": "^0.1.0", "websocket-polyfill": "^0.0.3" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/actor-resource-watch-solid-notification-websockets/test/ActorResourceWatchSolidNotificationWebsockets-test.ts b/packages/actor-resource-watch-solid-notification-websockets/test/ActorResourceWatchSolidNotificationWebsockets-test.ts index 4f8a3ed6..cd34d090 100644 --- a/packages/actor-resource-watch-solid-notification-websockets/test/ActorResourceWatchSolidNotificationWebsockets-test.ts +++ b/packages/actor-resource-watch-solid-notification-websockets/test/ActorResourceWatchSolidNotificationWebsockets-test.ts @@ -1,68 +1,73 @@ -import {Actor, Bus, IActorTest, Mediator} from '@comunica/core'; -import {ActorResourceWatchSolidNotificationWebsockets} from '../lib/ActorResourceWatchSolidNotificationWebsockets'; -import {IActionHttp, IActorHttpOutput} from "@comunica/bus-http"; +import type { IActionHttp, IActorHttpOutput } from '@comunica/bus-http'; +import type { Actor, IActorTest, Mediator } from '@comunica/core'; +import { Bus } from '@comunica/core'; import 'jest-rdf'; -import {IActionResourceWatch} from "@incremunica/bus-resource-watch"; +import type { IActionResourceWatch } from '@incremunica/bus-resource-watch'; +import type { Server } from 'ws'; +import { WebSocket } from 'ws'; +import { ActorResourceWatchSolidNotificationWebsockets } from '../lib/ActorResourceWatchSolidNotificationWebsockets'; import { createChannelDescriptionRequest, createDescriptionResourceRequest, createEmptyChannelDescriptionRequest, createEmptyResourceRequest, createFailedRequest, - createResourceRequest -} from "./mocks/HTTPMock"; -import {Server, WebSocket} from 'ws'; - -let message: any = { - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://www.w3.org/ns/solid/notification/v1" - ], - "id": "urn:1700310987535:http://localhost:3000/pod1/container/", - "object": "http://localhost:3000/pod1/container/test", - "target": "http://localhost:3000/pod1/container/", - "published": "2023-11-18T12:36:27.535Z" -} - -/* -let AddMessage = { - "type": "Add", - "object": "http://localhost:3000/pod1/test", - "target": "http://localhost:3000/pod1/", - "state": "1700310987000-text/turtle", -}; - -let RemoveMessage = { - "type":"Remove", - "object":"http://localhost:3000/pod1/test", - "target":"http://localhost:3000/pod1/", - "state":"1700311266000-text/turtle", -} - -let UpdateMessage = { - "type":"Update", - "object":"http://localhost:3000/pod1/test", - "state":"1700311389000-text/turtle", -}; + createResourceRequest, +} from './mocks/HTTPMock'; -let DeleteMessage = { - "type":"Delete", - "object":"http://localhost:3000/pod1/test2", +const message: any = { + '@context': [ + 'https://www.w3.org/ns/activitystreams', + 'https://www.w3.org/ns/solid/notification/v1', + ], + id: 'urn:1700310987535:http://localhost:3000/pod1/container/', + object: 'http://localhost:3000/pod1/container/test', + target: 'http://localhost:3000/pod1/container/', + published: '2023-11-18T12:36:27.535Z', }; -let CreateMessage = { - "type":"Create", - "object":"http://localhost:3000/pod1/test2", - "state":"1700311525000-text/turtle", -}; -*/ +// +// let AddMessage = { +// "type": "Add", +// "object": "http://localhost:3000/pod1/test", +// "target": "http://localhost:3000/pod1/", +// "state": "1700310987000-text/turtle", +// }; +// +// let RemoveMessage = { +// "type":"Remove", +// "object":"http://localhost:3000/pod1/test", +// "target":"http://localhost:3000/pod1/", +// "state":"1700311266000-text/turtle", +// } +// +// let UpdateMessage = { +// "type":"Update", +// "object":"http://localhost:3000/pod1/test", +// "state":"1700311389000-text/turtle", +// }; +// +// let DeleteMessage = { +// "type":"Delete", +// "object":"http://localhost:3000/pod1/test2", +// }; +// +// let CreateMessage = { +// "type":"Create", +// "object":"http://localhost:3000/pod1/test2", +// "state":"1700311525000-text/turtle", +// }; +// describe('ActorResourceWatchSolidNotificationWebsockets', () => { let bus: any; let actor: ActorResourceWatchSolidNotificationWebsockets; let mediatorHttp: Mediator< Actor, - IActionHttp, IActorTest, IActorHttpOutput>; + IActionHttp, +IActorTest, +IActorHttpOutput +>; let action: IActionResourceWatch; let priority: number; let createResourceRequestFn: (url: string) => any; @@ -70,128 +75,129 @@ describe('ActorResourceWatchSolidNotificationWebsockets', () => { let createChannelDescriptionRequestFn: (url: string) => any; beforeEach(() => { - bus = new Bus({name: 'bus'}); + bus = new Bus({ name: 'bus' }); priority = 0; createResourceRequestFn = (url: string): any => { - throw Error("createResourceRequestFn not set"); - } + throw new Error('createResourceRequestFn not set'); + }; createDescriptionResourceRequestFn = (url: string): any => { - throw Error("createDescriptionResourceRequestFn not set"); - } + throw new Error('createDescriptionResourceRequestFn not set'); + }; createChannelDescriptionRequestFn = (url: string): any => { - throw Error("createChannelDescriptionRequestFn not set"); - } + throw new Error('createChannelDescriptionRequestFn not set'); + }; mediatorHttp = { - mediate: async (action: IActionHttp) => { - if (action.input === "www.test.com") { - return createResourceRequestFn("www.test.com"); - } else if (action.input === "http://localhost:3000/.well-known/solid") { + mediate: async(action: IActionHttp) => { + if (action.input === 'www.test.com') { + return createResourceRequestFn('www.test.com'); + } + if (action.input === 'http://localhost:3000/.well-known/solid') { return createDescriptionResourceRequestFn(action.input); - } else if (action.input === "http://localhost:3000/.notifications/WebSocketChannel2023/") { + } + if (action.input === 'http://localhost:3000/.notifications/WebSocketChannel2023/') { return createChannelDescriptionRequestFn(action.input); } - throw new Error("Unknown URL"); + throw new Error('Unknown URL'); }, }; actor = new ActorResourceWatchSolidNotificationWebsockets({ beforeActors: [], - mediatorHttp: mediatorHttp, + mediatorHttp, name: 'actor', bus, - priority: priority, + priority, }); action = { context: {}, - url: "www.test.com", + url: 'www.test.com', metadata: { etag: 0, - "cache-control": undefined, - age: undefined + 'cache-control': undefined, + age: undefined, }, - } + }; }); describe('ActorResourceWatchSolidNotificationWebsockets test', () => { - it('should test', async () => { + it('should test', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - let result = await actor.test(action); + const result = await actor.test(action); - expect(result).toEqual({priority: priority}); + expect(result).toEqual({ priority }); }); - it('should not test if first get fails', async () => { + it('should not test if first get fails', async() => { createResourceRequestFn = createFailedRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - await expect(actor.test(action)).rejects.toThrowError(); + await expect(actor.test(action)).rejects.toThrow(''); }); - it('should not test if second get fails', async () => { + it('should not test if second get fails', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createFailedRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - await expect(actor.test(action)).rejects.toThrowError(); + await expect(actor.test(action)).rejects.toThrow(''); }); - it('should not test if third get fails', async () => { + it('should not test if third get fails', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createFailedRequest; - await expect(actor.test(action)).rejects.toThrowError(); + await expect(actor.test(action)).rejects.toThrow(''); }); - it('should not test if subscriptionService is undefined', async () => { + it('should not test if subscriptionService is undefined', async() => { createResourceRequestFn = createEmptyResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - await expect(actor.test(action)).rejects.toThrowError(); + await expect(actor.test(action)).rejects.toThrow(''); }); - - it('should not test if notificationChannel.receiveFrom is undefined', async () => { + it('should not test if notificationChannel.receiveFrom is undefined', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createEmptyChannelDescriptionRequest; - await expect(actor.test(action)).rejects.toThrowError(); + await expect(actor.test(action)).rejects.toThrow(''); }); }); describe('ActorResourceWatchSolidNotificationWebsockets run', () => { - let websocket: Server; + let websocket: Server; beforeEach(() => { - websocket = new WebSocket.WebSocketServer({port: 4015}); + websocket = new WebSocket.WebSocketServer({ port: 4015 }); }); afterEach(() => { websocket.close(); }); - it('should support ADD', async () => { + it('should support ADD', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - let result = await actor.run(action); + const result = await actor.run(action); websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Add"; + message.type = 'Add'; ws.send(JSON.stringify(message)); }); - await new Promise(resolve => result.events.on("update", () => { + await new Promise(resolve => result.events.on('update', () => { resolve(); })); @@ -200,19 +206,19 @@ describe('ActorResourceWatchSolidNotificationWebsockets', () => { result.stopFunction(); }); - it('should support Remove', async () => { + it('should support Remove', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - let result = await actor.run(action); + const result = await actor.run(action); websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Remove"; + message.type = 'Remove'; ws.send(JSON.stringify(message)); }); - await new Promise(resolve => result.events.on("update", () => { + await new Promise(resolve => result.events.on('update', () => { resolve(); })); @@ -221,19 +227,19 @@ describe('ActorResourceWatchSolidNotificationWebsockets', () => { result.stopFunction(); }); - it('should support Create', async () => { + it('should support Create', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - let result = await actor.run(action); + const result = await actor.run(action); websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Create"; + message.type = 'Create'; ws.send(JSON.stringify(message)); }); - await new Promise(resolve => result.events.on("update", () => { + await new Promise(resolve => result.events.on('update', () => { resolve(); })); @@ -242,19 +248,19 @@ describe('ActorResourceWatchSolidNotificationWebsockets', () => { result.stopFunction(); }); - it('should support Update', async () => { + it('should support Update', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - let result = await actor.run(action); + const result = await actor.run(action); websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Update"; + message.type = 'Update'; ws.send(JSON.stringify(message)); }); - await new Promise(resolve => result.events.on("update", () => { + await new Promise(resolve => result.events.on('update', () => { resolve(); })); @@ -263,95 +269,19 @@ describe('ActorResourceWatchSolidNotificationWebsockets', () => { result.stopFunction(); }); - it('should support Delete', async () => { + it('should support Delete', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createChannelDescriptionRequest; - let result = await actor.run(action); + const result = await actor.run(action); websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Delete"; + message.type = 'Delete'; ws.send(JSON.stringify(message)); }); - await new Promise(resolve => result.events.on("delete", () => { - resolve(); - })); - - expect(true).toBeTruthy(); - - result.stopFunction(); - }); - - /* - it('should support Buffer messages', async () => { - createResourceRequestFn = createResourceRequest; - createDescriptionResourceRequestFn = createDescriptionResourceRequest; - createChannelDescriptionRequestFn = createChannelDescriptionRequest; - - let result = await actor.run(action); - - websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Delete"; - ws.send(Buffer.from(JSON.stringify(message))); - }); - - await new Promise(resolve => result.events.on("delete", () => { - resolve(); - })); - - expect(true).toBeTruthy(); - - result.stopFunction(); - }); - - it('should support Buffer[] messages', async () => { - createResourceRequestFn = createResourceRequest; - createDescriptionResourceRequestFn = createDescriptionResourceRequest; - createChannelDescriptionRequestFn = createChannelDescriptionRequest; - - let result = await actor.run(action); - - websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Delete"; - let start = JSON.stringify(message).substring(0,1) - let end = JSON.stringify(message).substring(1) - ws.send([Buffer.from(start), Buffer.from(end)]); - }); - - await new Promise(resolve => result.events.on("delete", () => { - resolve(); - })); - - expect(true).toBeTruthy(); - - result.stopFunction(); - }); - - it('should support ArrayBuffer messages', async () => { - createResourceRequestFn = createResourceRequest; - createDescriptionResourceRequestFn = createDescriptionResourceRequest; - createChannelDescriptionRequestFn = createChannelDescriptionRequest; - - let result = await actor.run(action); - - function stringToUint(string: string) { - string = JSON.stringify(string); - let charList = string.split(''); - let uintArray = []; - for (let i = 0; i < charList.length; i++) { - uintArray.push(charList[i].charCodeAt(0)); - } - return new Uint8Array(uintArray); - } - - websocket.on('connection', (ws: WebSocket) => { - message["type"] = "Delete"; - ws.send(stringToUint(message)); - }); - - await new Promise(resolve => result.events.on("delete", () => { + await new Promise(resolve => result.events.on('delete', () => { resolve(); })); @@ -359,15 +289,93 @@ describe('ActorResourceWatchSolidNotificationWebsockets', () => { result.stopFunction(); }); - */ - it('should fail if websocket is not working', async () => { + // TODO re-enable these tests + // eslint-disable-next-line jest/no-commented-out-tests + // it('should support Buffer messages', async () => { + // createResourceRequestFn = createResourceRequest; + // createDescriptionResourceRequestFn = createDescriptionResourceRequest; + // createChannelDescriptionRequestFn = createChannelDescriptionRequest; + // + // let result = await actor.run(action); + // + // websocket.on('connection', (ws: WebSocket) => { + // message["type"] = "Delete"; + // ws.send(Buffer.from(JSON.stringify(message))); + // }); + // + // await new Promise(resolve => result.events.on("delete", () => { + // resolve(); + // })); + // + // expect(true).toBeTruthy(); + // + // result.stopFunction(); + // }); + + // eslint-disable-next-line jest/no-commented-out-tests + // it('should support Buffer[] messages', async () => { + // createResourceRequestFn = createResourceRequest; + // createDescriptionResourceRequestFn = createDescriptionResourceRequest; + // createChannelDescriptionRequestFn = createChannelDescriptionRequest; + // + // let result = await actor.run(action); + // + // websocket.on('connection', (ws: WebSocket) => { + // message["type"] = "Delete"; + // let start = JSON.stringify(message).substring(0,1) + // let end = JSON.stringify(message).substring(1) + // ws.send([Buffer.from(start), Buffer.from(end)]); + // }); + // + // await new Promise(resolve => result.events.on("delete", () => { + // resolve(); + // })); + // + // expect(true).toBeTruthy(); + // + // result.stopFunction(); + // }); + + // eslint-disable-next-line jest/no-commented-out-tests + // it('should support ArrayBuffer messages', async () => { + // createResourceRequestFn = createResourceRequest; + // createDescriptionResourceRequestFn = createDescriptionResourceRequest; + // createChannelDescriptionRequestFn = createChannelDescriptionRequest; + // + // let result = await actor.run(action); + // + // function stringToUint(string: string) { + // string = JSON.stringify(string); + // let charList = string.split(''); + // let uintArray = []; + // for (let i = 0; i < charList.length; i++) { + // uintArray.push(charList[i].charCodeAt(0)); + // } + // return new Uint8Array(uintArray); + // } + // + // websocket.on('connection', (ws: WebSocket) => { + // message["type"] = "Delete"; + // ws.send(stringToUint(message)); + // }); + // + // await new Promise(resolve => result.events.on("delete", () => { + // resolve(); + // })); + // + // expect(true).toBeTruthy(); + // + // result.stopFunction(); + // }); + // + + it('should fail if websocket is not working', async() => { createResourceRequestFn = createResourceRequest; createDescriptionResourceRequestFn = createDescriptionResourceRequest; createChannelDescriptionRequestFn = createEmptyChannelDescriptionRequest; - await expect(actor.run(action)).rejects.toThrowError(); + await expect(actor.run(action)).rejects.toThrow(''); }); }); }); - diff --git a/packages/actor-resource-watch-solid-notification-websockets/test/mocks/HTTPMock.ts b/packages/actor-resource-watch-solid-notification-websockets/test/mocks/HTTPMock.ts index 40f9b63f..536c5bfb 100644 --- a/packages/actor-resource-watch-solid-notification-websockets/test/mocks/HTTPMock.ts +++ b/packages/actor-resource-watch-solid-notification-websockets/test/mocks/HTTPMock.ts @@ -1,152 +1,146 @@ -import {PassThrough} from "readable-stream"; - +import { PassThrough } from 'readable-stream'; export function createFailedRequest(url: string) { - let headersObj: any = {} - headersObj['vary'] = 'Accept,Authorization,Origin'; + const headersObj: any = {}; + headersObj.vary = 'Accept,Authorization,Origin'; headersObj['x-powered-by'] = 'Community Solid Server'; headersObj['access-control-allow-origin'] = '*'; headersObj['access-control-allow-credentials'] = 'true'; - headersObj['access-control-expose-headers'] = - 'Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate'; + headersObj['access-control-expose-headers'] = `Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate`; headersObj['content-type'] = 'application/json'; - headersObj['date'] = 'Fri, 17 Nov 2023 17:15:00 GMT'; - headersObj['connection'] = 'close'; + headersObj.date = 'Fri, 17 Nov 2023 17:15:00 GMT'; + headersObj.connection = 'close'; headersObj['transfer-encoding'] = 'chunked'; - headersObj['allow'] = 'PATCH, PUT'; + headersObj.allow = 'PATCH, PUT'; headersObj['accept-patch'] = 'text/n3, application/sparql-update'; headersObj['accept-put'] = '*/*'; + const headers = new Headers(); - let headers = new Headers(); - - for (let key in headersObj) { + for (const key in headersObj) { headers.set(key, headersObj[key]); } - let body = `{"name":"NotFoundHttpError","message":"","statusCode":404,"errorCode":"H404","details":{}}`; + const body = `{"name":"NotFoundHttpError","message":"","statusCode":404,"errorCode":"H404","details":{}}`; return { body: new PassThrough({ - read: function () { + read() { this.push(body); this.push(null); - } + }, }), - headers: headers, + headers, status: 404, - statusText: "Not Found", + statusText: 'Not Found', ok: false, - url: url, + url, clone: jest.fn(), error: jest.fn(), json: () => ({}), redirect: jest.fn(), - text: () => body + text: () => body, }; } export function createEmptyResourceRequest(url: string) { - let headersObj: any = {} - headersObj['vary'] = 'Accept,Authorization,Origin'; + const headersObj: any = {}; + headersObj.vary = 'Accept,Authorization,Origin'; headersObj['x-powered-by'] = 'Community Solid Server'; headersObj['access-control-allow-origin'] = '*'; headersObj['access-control-allow-credentials'] = 'true'; - headersObj['access-control-expose-headers'] = - 'Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate'; + headersObj['access-control-expose-headers'] = `Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate`; headersObj['wac-allow'] = 'user="read",public="read"'; - headersObj['allow'] = 'OPTIONS, HEAD, GET, PATCH, POST'; + headersObj.allow = 'OPTIONS, HEAD, GET, PATCH, POST'; headersObj['accept-patch'] = 'text/n3, application/sparql-update'; headersObj['accept-post'] = '*/*'; headersObj['content-type'] = 'text/turtle'; headersObj['last-modified'] = 'Fri, 17 Nov 2023 10:06:41 GMT'; - headersObj['etag'] = '"1700215601000-text/turtle"'; - headersObj['date'] = 'Fri, 17 Nov 2023 17:15:00 GMT'; - headersObj['connection'] = 'close'; + headersObj.etag = '"1700215601000-text/turtle"'; + headersObj.date = 'Fri, 17 Nov 2023 17:15:00 GMT'; + headersObj.connection = 'close'; - let headers = new Headers(); + const headers = new Headers(); - for (let key in headersObj) { + for (const key in headersObj) { headers.set(key, headersObj[key]); } return { body: new PassThrough(), - headers: headers, + headers, status: 200, - statusText: "OK", + statusText: 'OK', ok: true, - url: url, + url, clone: jest.fn(), error: jest.fn(), json: () => ({}), redirect: jest.fn(), - text: () => "" + text: () => '', }; } export function createResourceRequest(url: string) { - let headersObj: any = {} - headersObj['vary'] = 'Accept,Authorization,Origin'; + const headersObj: any = {}; + headersObj.vary = 'Accept,Authorization,Origin'; headersObj['x-powered-by'] = 'Community Solid Server'; headersObj['access-control-allow-origin'] = '*'; headersObj['access-control-allow-credentials'] = 'true'; - headersObj['access-control-expose-headers'] = - 'Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate'; + headersObj['access-control-expose-headers'] = `Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate`; headersObj['wac-allow'] = 'user="read",public="read"'; - headersObj['allow'] = 'OPTIONS, HEAD, GET, PATCH, POST'; + headersObj.allow = 'OPTIONS, HEAD, GET, PATCH, POST'; headersObj['accept-patch'] = 'text/n3, application/sparql-update'; headersObj['accept-post'] = '*/*'; headersObj['content-type'] = 'text/turtle'; - headersObj['link'] = + headersObj.link = '; rel="type", ; rel="type", ; rel="type", ; rel="type", ; rel="describedby", ; rel="acl", ; rel="http://www.w3.org/ns/solid/terms#storageDescription"'; headersObj['last-modified'] = 'Fri, 17 Nov 2023 10:06:41 GMT'; - headersObj['etag'] = '"1700215601000-text/turtle"'; - headersObj['date'] = 'Fri, 17 Nov 2023 17:15:00 GMT'; - headersObj['connection'] = 'close'; + headersObj.etag = '"1700215601000-text/turtle"'; + headersObj.date = 'Fri, 17 Nov 2023 17:15:00 GMT'; + headersObj.connection = 'close'; - let headers = new Headers(); + const headers = new Headers(); - for (let key in headersObj) { + for (const key in headersObj) { headers.set(key, headersObj[key]); } return { body: new PassThrough(), - headers: headers, + headers, status: 200, - statusText: "OK", + statusText: 'OK', ok: true, - url: url, + url, clone: jest.fn(), error: jest.fn(), json: () => ({}), redirect: jest.fn(), - text: () => "" + text: () => '', }; } export function createDescriptionResourceRequest(url: string) { - let headersObj: any = {} - headersObj['vary'] = 'Accept,Authorization,Origin'; + const headersObj: any = {}; + headersObj.vary = 'Accept,Authorization,Origin'; headersObj['x-powered-by'] = 'Community Solid Server'; headersObj['access-control-allow-origin'] = '*'; headersObj['access-control-allow-credentials'] = 'true'; - headersObj['access-control-expose-headers'] = - 'Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate'; + headersObj['access-control-expose-headers'] = `Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate`; headersObj['content-type'] = 'text/turtle'; - headersObj['etag'] = '"1700215601000-text/turtle"'; - headersObj['date'] = 'Fri, 17 Nov 2023 17:15:00 GMT'; - headersObj['connection'] = 'close'; + headersObj.etag = '"1700215601000-text/turtle"'; + headersObj.date = 'Fri, 17 Nov 2023 17:15:00 GMT'; + headersObj.connection = 'close'; headersObj['transfer-encoding'] = 'chunked'; - let headers = new Headers(); + const headers = new Headers(); - for (let key in headersObj) { + for (const key in headersObj) { headers.set(key, headersObj[key]); } - let body = ` + const body = ` @prefix notify: . @prefix pim: . @prefix rdf: . @@ -168,115 +162,113 @@ notify:endAt , notify:rate , notify:startAt , notify:state . -` +`; return { body: new PassThrough({ - read: function () { + read() { this.push(body); this.push(null); - } + }, }), - headers: headers, + headers, status: 200, - statusText: "OK", + statusText: 'OK', ok: true, - url: url, + url, clone: jest.fn(), error: jest.fn(), json: () => ({}), redirect: jest.fn(), - text: () => body + text: () => body, }; } export function createChannelDescriptionRequest(url: string) { - let headersObj: any = {} - headersObj['vary'] = 'Accept,Authorization,Origin'; + const headersObj: any = {}; + headersObj.vary = 'Accept,Authorization,Origin'; headersObj['x-powered-by'] = 'Community Solid Server'; headersObj['access-control-allow-origin'] = '*'; headersObj['access-control-allow-credentials'] = 'true'; - headersObj['access-control-expose-headers'] = - 'Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate'; + headersObj['access-control-expose-headers'] = `Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate`; headersObj['content-type'] = 'text/turtle'; - headersObj['date'] = 'Fri, 17 Nov 2023 17:15:00 GMT'; - headersObj['connection'] = 'close'; + headersObj.date = 'Fri, 17 Nov 2023 17:15:00 GMT'; + headersObj.connection = 'close'; headersObj['transfer-encoding'] = 'chunked'; - let headers = new Headers(); + const headers = new Headers(); - for (let key in headersObj) { + for (const key in headersObj) { headers.set(key, headersObj[key]); } - let body = ` + const body = ` <> ; ; "2023-12-02T11:36:15.651Z"^^; a . -` +`; return { body: new PassThrough({ - read: function () { + read() { this.push(body); this.push(null); - } + }, }), - headers: headers, + headers, status: 200, - statusText: "OK", + statusText: 'OK', ok: true, - url: url, + url, clone: jest.fn(), error: jest.fn(), json: () => ({}), redirect: jest.fn(), - text: () => body + text: () => body, }; } export function createEmptyChannelDescriptionRequest(url: string) { - let headersObj: any = {} - headersObj['vary'] = 'Accept,Authorization,Origin'; + const headersObj: any = {}; + headersObj.vary = 'Accept,Authorization,Origin'; headersObj['x-powered-by'] = 'Community Solid Server'; headersObj['access-control-allow-origin'] = '*'; headersObj['access-control-allow-credentials'] = 'true'; - headersObj['access-control-expose-headers'] = - 'Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate'; + headersObj['access-control-expose-headers'] = `Accept-Patch,Accept-Post,Accept-Put,Allow,Content-Range,ETag,Last-Modified,Link,Location,Updates-Via,WAC-Allow,Www-Authenticate`; headersObj['content-type'] = 'text/turtle'; - headersObj['date'] = 'Fri, 17 Nov 2023 17:15:00 GMT'; - headersObj['connection'] = 'close'; + headersObj.date = 'Fri, 17 Nov 2023 17:15:00 GMT'; + headersObj.connection = 'close'; headersObj['transfer-encoding'] = 'chunked'; - let headers = new Headers(); + const headers = new Headers(); - for (let key in headersObj) { + for (const key in headersObj) { headers.set(key, headersObj[key]); } - let body = ` + const body = ` ; "2023-12-02T11:36:15.651Z"^^; a . -` +`; return { body: new PassThrough({ - read: function () { + read() { this.push(body); this.push(null); - } + }, }), - headers: headers, + headers, status: 200, - statusText: "OK", + statusText: 'OK', ok: true, - url: url, + url, clone: jest.fn(), error: jest.fn(), json: () => ({}), redirect: jest.fn(), - text: () => body + text: () => body, }; } diff --git a/packages/bus-guard/README.md b/packages/bus-guard/README.md index fbb037d2..76477a15 100644 --- a/packages/bus-guard/README.md +++ b/packages/bus-guard/README.md @@ -2,7 +2,7 @@ [![npm version](https://badge.fury.io/js/@incremunica%2Fbus-guard.svg)](https://badge.fury.io/js/@incremunica%2Fbus-guard) -A comunica bus for guard events. +A comunica bus for guard events. ## Install diff --git a/packages/bus-guard/lib/ActorGuard.ts b/packages/bus-guard/lib/ActorGuard.ts index 8c09b8b9..fb165ebc 100644 --- a/packages/bus-guard/lib/ActorGuard.ts +++ b/packages/bus-guard/lib/ActorGuard.ts @@ -1,8 +1,7 @@ import type { IAction, IActorArgs, IActorOutput, IActorTest, Mediate } from '@comunica/core'; import { Actor } from '@comunica/core'; +import type { StreamingQuerySourceRdfJs } from '@incremunica/actor-query-source-identify-streaming-rdfjs'; import type { IGuardEvents } from '@incremunica/incremental-types/lib/GuardEvents'; -import {IQuerySource} from "@comunica/types"; -import {StreamingQuerySourceRdfJs} from "@incremunica/actor-query-source-identify-streaming-rdfjs"; /** * A comunica actor for guard events. @@ -47,8 +46,12 @@ export interface IActorGuardOutput extends IActorOutput { } export type IActorGuardArgs = IActorArgs< -IActionGuard, IActorTest, IActorGuardOutput>; +IActionGuard, +IActorTest, +IActorGuardOutput +>; export type MediatorGuard = Mediate< -IActionGuard, IActorGuardOutput>; - +IActionGuard, +IActorGuardOutput +>; diff --git a/packages/bus-guard/package.json b/packages/bus-guard/package.json index 3a9670e8..0b5b3bd7 100644 --- a/packages/bus-guard/package.json +++ b/packages/bus-guard/package.json @@ -3,41 +3,41 @@ "version": "1.3.0", "description": "A comunica bus for guard events.", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/bus-guard" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "bus", "guard" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@comunica/core": "^3.2.1", - "@incremunica/actor-rdf-resolve-quad-pattern-rdfjs-streaming-source": "^1.3.0", - "@incremunica/incremental-types": "^1.3.0" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/core": "^3.2.1", + "@incremunica/actor-query-source-identify-streaming-rdfjs": "^1.3.0", + "@incremunica/incremental-types": "^1.3.0" } } diff --git a/packages/bus-resource-watch/lib/ActorResourceWatch.ts b/packages/bus-resource-watch/lib/ActorResourceWatch.ts index 8928e21e..3b231f1b 100644 --- a/packages/bus-resource-watch/lib/ActorResourceWatch.ts +++ b/packages/bus-resource-watch/lib/ActorResourceWatch.ts @@ -1,4 +1,4 @@ -import type { EventEmitter } from 'events'; +import type { EventEmitter } from 'node:events'; import type { IAction, IActorArgs, IActorOutput, IActorTest, Mediate } from '@comunica/core'; import { Actor } from '@comunica/core'; @@ -16,8 +16,8 @@ import { Actor } from '@comunica/core'; export abstract class ActorResourceWatch extends Actor { public readonly priority: number; /** - * @param args - @defaultNested { a } bus - */ + * @param args - @defaultNested { a } bus + */ public constructor(args: IActorResourceWatchArgs) { super(args); } @@ -51,7 +51,10 @@ export interface IActorResourceWatchOutput extends IActorOutput { } export interface IActorResourceWatchArgs extends IActorArgs< -IActionResourceWatch, IActorTest, IActorResourceWatchOutput> { +IActionResourceWatch, +IActorTest, +IActorResourceWatchOutput +> { /** * The priority of the actor. */ @@ -59,4 +62,6 @@ IActionResourceWatch, IActorTest, IActorResourceWatchOutput> { } export type MediatorResourceWatch = Mediate< -IActionResourceWatch, IActorResourceWatchOutput>; +IActionResourceWatch, +IActorResourceWatchOutput +>; diff --git a/packages/bus-resource-watch/package.json b/packages/bus-resource-watch/package.json index 7bd4043d..cfd838d8 100644 --- a/packages/bus-resource-watch/package.json +++ b/packages/bus-resource-watch/package.json @@ -3,39 +3,39 @@ "version": "1.3.0", "description": "An incremunica bus for resource-watch events.", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/bus-resource-watch" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "incremunica", "bus", "resource-watch" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@comunica/core": "^3.2.1" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/core": "^3.2.1" } } diff --git a/packages/context-entries/package.json b/packages/context-entries/package.json index 728b5c6b..7fe7e6a7 100644 --- a/packages/context-entries/package.json +++ b/packages/context-entries/package.json @@ -2,39 +2,39 @@ "name": "@incremunica/context-entries", "version": "1.3.0", "description": "A collection of reusable Incremunica context key definitions.", - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/context-entries" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "incremunica", "context", "entries", "keys" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "node \"../../node_modules/typescript/bin/tsc\"" + }, "dependencies": { "@comunica/core": "^3.2.1", "@incremunica/incremental-types": "^1.3.0" - }, - "scripts": { - "build": "node \"../../node_modules/typescript/bin/tsc\"" } } diff --git a/packages/dev-tools/README.md b/packages/dev-tools/README.md index 8ca91998..683d401d 100644 --- a/packages/dev-tools/README.md +++ b/packages/dev-tools/README.md @@ -4,7 +4,6 @@ A collection of reusable incremunica Typescript functions for debugging. - ## Install ```bash diff --git a/packages/dev-tools/lib/DevTools.ts b/packages/dev-tools/lib/DevTools.ts index 82927a17..78228166 100644 --- a/packages/dev-tools/lib/DevTools.ts +++ b/packages/dev-tools/lib/DevTools.ts @@ -1,48 +1,50 @@ -import {Bindings, BindingsFactory} from '@comunica/bindings-factory'; -import type {BindingsStream} from '@comunica/types'; +import type { Bindings } from '@comunica/bindings-factory'; +import { BindingsFactory } from '@comunica/bindings-factory'; +import { Bus } from '@comunica/core'; +import type { BindingsStream } from '@comunica/types'; import { ActionContextKeyIsAddition, - ActorMergeBindingsContextIsAddition -} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {Bus} from "@comunica/core"; -import {DataFactory} from "rdf-data-factory"; + ActorMergeBindingsContextIsAddition, +} from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DataFactory } from 'rdf-data-factory'; export const DevTools = { bindingsToString(bindings: Bindings) { - let string = `bindings, ${bindings.getContextEntry(new ActionContextKeyIsAddition())} :`; - bindings.forEach((value, key) => { + let string = `bindings, ${bindings.getContextEntry(new ActionContextKeyIsAddition())} :`; + for (const [ key, value ] of bindings) { string += `\n\t${key.value}: ${value.value}`; - }); + } return string; }, printBindings(bindings: Bindings) { - let string = `bindings, ${bindings.getContextEntry(new ActionContextKeyIsAddition())} :`; - bindings.forEach((value, key) => { + let string = `bindings, ${bindings.getContextEntry(new ActionContextKeyIsAddition())} :`; + for (const [ key, value ] of bindings) { string += `\n\t${key.value}: ${value.value}`; - }); + } // eslint-disable-next-line no-console console.log(string); }, printBindingsStream(bindingsStream: BindingsStream) { return bindingsStream.map((bindings) => { - if (bindings == undefined) - // eslint-disable-next-line no-console - console.log(undefined); - else + if (bindings) { this.printBindings(bindings); + } else { + // eslint-disable-next-line no-console + console.log(bindings); + } return bindings; }); }, async createBindingsFactory(DF?: DataFactory): Promise { return new BindingsFactory( - DF? DF : new DataFactory(), + DF ?? new DataFactory(), (await new ActorMergeBindingsContextIsAddition({ - bus: new Bus({name: 'bus'}), - name: 'actor' - }).run({})).mergeHandlers + bus: new Bus({ name: 'bus' }), + name: 'actor', + }).run({})).mergeHandlers, ); - } + }, }; diff --git a/packages/dev-tools/package.json b/packages/dev-tools/package.json index a69cbc8c..d2e0afc5 100644 --- a/packages/dev-tools/package.json +++ b/packages/dev-tools/package.json @@ -3,26 +3,26 @@ "version": "1.3.0", "description": "Development tools for comunica/incremunica.", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://github.com/comunica", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/dev-tools" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/comunica/issues" }, - "sideEffects": false, "keywords": [ "dev", "utils" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/comunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://github.com/comunica", "files": [ "components", "lib/**/*.d.ts", @@ -35,6 +35,10 @@ "build:components": "componentsjs-generator" }, "dependencies": { - "@incremunica/incremental-types": "^1.3.0" + "@comunica/bindings-factory": "^3.3.0", + "@comunica/core": "^3.3.0", + "@comunica/types": "3.3.0", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", + "rdf-data-factory": "^1.1.2" } } diff --git a/packages/hash-bindings/package.json b/packages/hash-bindings/package.json index f516bc5f..e9577cef 100644 --- a/packages/hash-bindings/package.json +++ b/packages/hash-bindings/package.json @@ -3,40 +3,40 @@ "version": "1.3.0", "description": "A hash bindings class", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/hash-bindings" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "incremunica", "hash-bindings" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@incremunica/incremental-types": "^1.3.0", - "@rdfjs/types": "*", - "rdf-string": "^1.6.3" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/types": "^3.3.0", + "@rdfjs/types": "*", + "rdf-string": "^1.6.3" } } diff --git a/packages/hash-bindings/test/HashBindings-test.ts b/packages/hash-bindings/test/HashBindings-test.ts index 8e47acc2..7b867f37 100644 --- a/packages/hash-bindings/test/HashBindings-test.ts +++ b/packages/hash-bindings/test/HashBindings-test.ts @@ -1,9 +1,9 @@ import '@incremunica/incremental-jest'; import 'jest-rdf'; -import {HashBindings} from "../lib"; -import {Bindings, BindingsFactory} from "@comunica/bindings-factory"; -import {DataFactory} from "rdf-data-factory"; -import {DevTools} from "@incremunica/dev-tools"; +import type { Bindings, BindingsFactory } from '@comunica/bindings-factory'; +import { DevTools } from '@incremunica/dev-tools'; +import { DataFactory } from 'rdf-data-factory'; +import { HashBindings } from '../lib'; const DF = new DataFactory(); @@ -11,104 +11,100 @@ describe('HashBindings', () => { let hashBindings: HashBindings; let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { hashBindings = new HashBindings(); BF = await DevTools.createBindingsFactory(DF); }); it('should hash bindings', () => { - let bindings: Bindings = BF.bindings([ + const bindings: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], ]); - let hash = hashBindings.hash(bindings); + const hash = hashBindings.hash(bindings); - expect(hash).toEqual('a:\n'); + expect(hash).toBe('a:\n'); }); it('should hash deterministically', () => { - let bindings1: Bindings = BF.bindings([ + const bindings1: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('b'), DF.namedNode('ex:b1') ], ]); - let bindings2: Bindings = BF.bindings([ + const bindings2: Bindings = BF.bindings([ [ DF.variable('b'), DF.namedNode('ex:b1') ], [ DF.variable('a'), DF.namedNode('ex:a1') ], ]); - let hash1 = hashBindings.hash(bindings1); - let hash2 = hashBindings.hash(bindings2); + const hash1 = hashBindings.hash(bindings1); + const hash2 = hashBindings.hash(bindings2); - expect(hash1).toEqual('a:\nb:\n'); - expect(hash2).toEqual('a:\nb:\n'); + expect(hash1).toBe('a:\nb:\n'); + expect(hash2).toBe('a:\nb:\n'); }); it('should hash if value is undefined', () => { - let bindings1: Bindings = BF.bindings([ + const bindings1: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('b'), DF.namedNode('ex:b1') ], [ DF.variable('c'), DF.namedNode('ex:c1') ], ]); - let bindings2: Bindings = BF.bindings([ + const bindings2: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('c'), DF.namedNode('ex:c1') ], ]); - let hash1 = hashBindings.hash(bindings1); - let hash2 = hashBindings.hash(bindings2); + const hash1 = hashBindings.hash(bindings1); + const hash2 = hashBindings.hash(bindings2); - expect(hash1).toEqual('a:\nb:\nc:\n'); - expect(hash2).toEqual('a:\nc:\n'); + expect(hash1).toBe('a:\nb:\nc:\n'); + expect(hash2).toBe('a:\nc:\n'); }); - - it('should hash if value is undefined and should be the same before and after', () => { - let bindings1: Bindings = BF.bindings([ + const bindings1: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('c'), DF.namedNode('ex:c1') ], ]); - let bindings2: Bindings = BF.bindings([ + const bindings2: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('b'), DF.namedNode('ex:b1') ], [ DF.variable('c'), DF.namedNode('ex:c1') ], ]); - let bindings3: Bindings = BF.bindings([ + const bindings3: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('c'), DF.namedNode('ex:c1') ], ]); - let hash1 = hashBindings.hash(bindings1); - let hash2 = hashBindings.hash(bindings2); - let hash3 = hashBindings.hash(bindings3); + const hash1 = hashBindings.hash(bindings1); + const hash2 = hashBindings.hash(bindings2); + const hash3 = hashBindings.hash(bindings3); - expect(hash1).toEqual('a:\nc:\n'); - expect(hash2).toEqual('a:\nc:\nb:\n'); - expect(hash3).toEqual('a:\nc:\n'); + expect(hash1).toBe('a:\nc:\n'); + expect(hash2).toBe('a:\nc:\nb:\n'); + expect(hash3).toBe('a:\nc:\n'); }); it('should hash with the initialization variables', () => { hashBindings = new HashBindings([ DF.variable('a'), DF.variable('b') ]); - let bindings1: Bindings = BF.bindings([ + const bindings1: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], [ DF.variable('b'), DF.namedNode('ex:b1') ], ]); - let bindings2: Bindings = BF.bindings([ + const bindings2: Bindings = BF.bindings([ [ DF.variable('a'), DF.namedNode('ex:a1') ], ]); - let hash1 = hashBindings.hash(bindings1); - let hash2 = hashBindings.hash(bindings2); + const hash1 = hashBindings.hash(bindings1); + const hash2 = hashBindings.hash(bindings2); - expect(hash1).toEqual('a:\nb:\n'); - expect(hash2).toEqual('a:\n'); + expect(hash1).toBe('a:\nb:\n'); + expect(hash2).toBe('a:\n'); }); }); - - diff --git a/packages/incremental-inner-join/lib/IncrementalInnerJoin.ts b/packages/incremental-inner-join/lib/IncrementalInnerJoin.ts index 35399ad7..148be57b 100644 --- a/packages/incremental-inner-join/lib/IncrementalInnerJoin.ts +++ b/packages/incremental-inner-join/lib/IncrementalInnerJoin.ts @@ -1,4 +1,4 @@ -import type {Bindings} from "@comunica/bindings-factory"; +import type { Bindings } from '@comunica/bindings-factory'; import { AsyncIterator } from 'asynciterator'; export abstract class IncrementalInnerJoin extends AsyncIterator { @@ -59,5 +59,5 @@ export abstract class IncrementalInnerJoin extends AsyncIterator { export enum Side { right, - left + left, } diff --git a/packages/incremental-inner-join/package.json b/packages/incremental-inner-join/package.json index 7bdfd34c..ec778e0d 100644 --- a/packages/incremental-inner-join/package.json +++ b/packages/incremental-inner-join/package.json @@ -3,41 +3,41 @@ "version": "1.3.0", "description": "An incremental-inner-join base class", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/incremental-inner-join" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "actor", "rdf-join", "incremental-inner-join" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], - "dependencies": { - "@incremunica/incremental-types": "^1.3.0", - "asynciterator": "^3.9.0" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "@comunica/bindings-factory": "^3.3.0", + "asynciterator": "^3.9.0" } } diff --git a/packages/incremental-inner-join/test/IncrementalInnerJoin-test.ts b/packages/incremental-inner-join/test/IncrementalInnerJoin-test.ts index a1d1119d..2c785d56 100644 --- a/packages/incremental-inner-join/test/IncrementalInnerJoin-test.ts +++ b/packages/incremental-inner-join/test/IncrementalInnerJoin-test.ts @@ -1,24 +1,26 @@ -import {ArrayIterator, AsyncIterator} from 'asynciterator'; +import type { Bindings } from '@comunica/bindings-factory'; +import type { AsyncIterator } from 'asynciterator'; +import { ArrayIterator } from 'asynciterator'; import '@incremunica/incremental-jest'; -import {IncrementalInnerJoin} from "../lib"; -import { Bindings } from '@comunica/bindings-factory'; +import { IncrementalInnerJoin } from '../lib'; -let cleanupMock = jest.fn(); -let hasResultMock = jest.fn(); -let readMock = jest.fn(); +const cleanupMock = jest.fn(); +const hasResultMock = jest.fn(); +const readMock = jest.fn(); let results = false; class ExtendedClass extends IncrementalInnerJoin { - read(): Bindings | null { + public read(): Bindings | null { readMock(); return null; } - _cleanup(): void { + + public _cleanup(): void { cleanupMock(); } - hasResults(): boolean { + public hasResults(): boolean { hasResultMock(); return results; } @@ -28,23 +30,23 @@ describe('IncrementalInnerJoin', () => { describe('The HashBindings module', () => { let leftIterator: AsyncIterator; let rightIterator: AsyncIterator; - let funJoin = () => null; + const funJoin = () => null; beforeEach(() => { - leftIterator = new ArrayIterator([{}], {autoStart: false}); - rightIterator = new ArrayIterator([{}], {autoStart: false}); + leftIterator = new ArrayIterator([ {} ], { autoStart: false }); + rightIterator = new ArrayIterator([ {} ], { autoStart: false }); }); it('should be a HashBindings constructor', () => { expect(new ( ExtendedClass)( leftIterator, rightIterator, - funJoin + funJoin, )).toBeInstanceOf(IncrementalInnerJoin); expect(new ( ExtendedClass)( leftIterator, rightIterator, - funJoin + funJoin, )).toBeInstanceOf(ExtendedClass); }); }); @@ -52,18 +54,18 @@ describe('IncrementalInnerJoin', () => { describe('An HashBindings instance', () => { let leftIterator: AsyncIterator; let rightIterator: AsyncIterator; - let funJoin = () => null; + const funJoin = () => null; beforeEach(() => { - leftIterator = new ArrayIterator([{}], {autoStart: false}); - rightIterator = new ArrayIterator([{}], {autoStart: false}); + leftIterator = new ArrayIterator([ {} ], { autoStart: false }); + rightIterator = new ArrayIterator([ {} ], { autoStart: false }); }); it('should be readable if one of the iterators is readable', () => { - let extendedClass = new ExtendedClass( - new ArrayIterator([{}], {autoStart: false}), - new ArrayIterator([], {autoStart: false}), - funJoin + const extendedClass = new ExtendedClass( + new ArrayIterator([ {} ], { autoStart: false }), + new ArrayIterator([], { autoStart: false }), + funJoin, ); expect(extendedClass.readable).toBeTruthy(); }); @@ -72,50 +74,50 @@ describe('IncrementalInnerJoin', () => { leftIterator.readable = false; rightIterator.readable = false; - let extendedClass = new ExtendedClass( + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); expect(extendedClass.readable).toBeFalsy(); }); - it('should be destroyed if the left iterator throws an error', async () => { - let extendedClass = new ExtendedClass( + it('should be destroyed if the left iterator throws an error', async() => { + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); - let error = new Promise((resolve) => { - extendedClass.once("error", (error) => { + const error = new Promise((resolve) => { + extendedClass.once('error', (error) => { resolve(error); }); }); - leftIterator.emit("error", "test error"); + leftIterator.emit('error', 'test error'); - expect(await error).toEqual("test error"); + await expect(error).resolves.toBe('test error'); expect(extendedClass.ended).toBeTruthy(); }); - it('should be destroyed if the right iterator throws an error', async () => { - let extendedClass = new ExtendedClass( + it('should be destroyed if the right iterator throws an error', async() => { + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); - let error = new Promise((resolve) => { - extendedClass.once("error", (error) => { + const error = new Promise((resolve) => { + extendedClass.once('error', (error) => { resolve(error); }); }); - rightIterator.emit("error", "test error"); + rightIterator.emit('error', 'test error'); - expect(await error).toEqual("test error"); + await expect(error).resolves.toBe('test error'); expect(extendedClass.ended).toBeTruthy(); }); @@ -123,89 +125,87 @@ describe('IncrementalInnerJoin', () => { leftIterator.readable = false; rightIterator.readable = false; - let extendedClass = new ExtendedClass( + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); expect(extendedClass.readable).toBeFalsy(); - leftIterator.emit("readable") - + leftIterator.emit('readable'); expect(extendedClass.readable).toBeTruthy(); }); - it('should destroy left and right iterator if no results and end left', async () => { - let extendedClass = new ExtendedClass( + it('should destroy left and right iterator if no results and end left', async() => { + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); - leftIterator.emit("end") + leftIterator.emit('end'); - expect(leftIterator.done).toBeTruthy() - expect(rightIterator.done).toBeTruthy() + expect(leftIterator.done).toBeTruthy(); + expect(rightIterator.done).toBeTruthy(); }); it('should destroy left and right iterator if no results and end right', () => { - let extendedClass = new ExtendedClass( + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); - rightIterator.emit("end") + rightIterator.emit('end'); - expect(leftIterator.done).toBeTruthy() - expect(rightIterator.done).toBeTruthy() + expect(leftIterator.done).toBeTruthy(); + expect(rightIterator.done).toBeTruthy(); }); it('should not end if results', () => { - results = true + results = true; - let extendedClass = new ExtendedClass( + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); - leftIterator.close() + leftIterator.close(); expect(extendedClass.ended).toBeFalsy(); }); it('should destroy iterators if end', () => { - let extendedClass = new ExtendedClass( + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); - extendedClass._end() + extendedClass._end(); expect(leftIterator.destroyed).toBeTruthy(); expect(rightIterator.destroyed).toBeTruthy(); }); it('should have all abstract functions', () => { - let extendedClass = new ExtendedClass( + const extendedClass = new ExtendedClass( leftIterator, rightIterator, - funJoin + funJoin, ); extendedClass._cleanup(); - expect(cleanupMock).toBeCalled(); + expect(cleanupMock).toHaveBeenCalledWith(); extendedClass.hasResults(); - expect(hasResultMock).toBeCalled(); + expect(hasResultMock).toHaveBeenCalledWith(); extendedClass.read(); - expect(readMock).toBeCalled(); + expect(readMock).toHaveBeenCalledWith(); }); - }); }); diff --git a/packages/incremental-jest/README.md b/packages/incremental-jest/README.md index 152273bb..a3d98548 100644 --- a/packages/incremental-jest/README.md +++ b/packages/incremental-jest/README.md @@ -2,8 +2,8 @@ [![npm version](https://badge.fury.io/js/@incremunica%2Fincremental-jest.svg)](https://badge.fury.io/js/@incremunica%2Fincremental-jest) -Jest test helpers for Comunica. -This package is similar to the original one, +Jest test helpers for Comunica. +This package is similar to the original one, it adds support for checking the diff boolean in incremunica bindings. ## Install @@ -18,15 +18,16 @@ In order to use matchers in your tests, you'll have to make sure that they are imported. This can be done by adding the following entry to your Jest configuration: ```json -"jest": { - "setupFilesAfterEnv": [ "@comunica/incremental-jest" ] +{ + "jest": { + "setupFilesAfterEnv": ["@comunica/incremental-jest"] + } } ``` If you are already using an existing test framework script file, make sure to add @comunica/jest as follows to your file: ```javascript -... require('@comunica/incremental-jest'); ``` @@ -58,11 +59,11 @@ Check if two Bindings are equal. ```js expect(BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], ])).toEqualBindings(BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], ])); ``` @@ -72,23 +73,23 @@ Check if two Bindings arrays are equal. ```js expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]), ]).toEqualBindingsArray([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]), ]); ``` @@ -100,22 +101,22 @@ Check if a Bindings stream equals a Bindings array. import { ArrayIterator } from 'asynciterator'; expect(new ArrayIterator([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]), ], { autoStart: false })).toEqualBindingsStream([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]), ]); ``` diff --git a/packages/incremental-jest/lib/index.ts b/packages/incremental-jest/lib/index.ts index 8dee0c81..c2064fb2 100644 --- a/packages/incremental-jest/lib/index.ts +++ b/packages/incremental-jest/lib/index.ts @@ -2,9 +2,8 @@ import type * as RDF from '@rdfjs/types'; import matchers from './matchers'; declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace + // eslint-disable-next-line ts/no-namespace namespace jest { - // eslint-disable-next-line @typescript-eslint/naming-convention interface Matchers { toEqualBindings: (actual: RDF.Bindings) => R; toEqualBindingsArray: (actual: RDF.Bindings[]) => R; diff --git a/packages/incremental-jest/lib/matchers/index.ts b/packages/incremental-jest/lib/matchers/index.ts index cb6e4eaa..421ab122 100644 --- a/packages/incremental-jest/lib/matchers/index.ts +++ b/packages/incremental-jest/lib/matchers/index.ts @@ -1,6 +1,6 @@ +import toBeIsomorphicBindingsArray from './toBeIsomorphicBindingsArray'; import toEqualBindings from './toEqualBindings'; import toEqualBindingsArray from './toEqualBindingsArray'; -import toBeIsomorphicBindingsArray from './toEqualBindingsArray'; import toEqualBindingsStream from './toEqualBindingsStream'; export default [ @@ -8,5 +8,4 @@ export default [ toEqualBindingsArray, toBeIsomorphicBindingsArray, toEqualBindingsStream, -// eslint-disable-next-line unicorn/prefer-object-from-entries ].reduce((acc, matcher) => ({ ...acc, ...matcher }), {}); diff --git a/packages/incremental-jest/lib/matchers/toBeIsomorphicBindingsArray.ts b/packages/incremental-jest/lib/matchers/toBeIsomorphicBindingsArray.ts new file mode 100644 index 00000000..351d83df --- /dev/null +++ b/packages/incremental-jest/lib/matchers/toBeIsomorphicBindingsArray.ts @@ -0,0 +1,41 @@ +import type { Bindings } from '@comunica/bindings-factory'; +import toEqualBindings from './toEqualBindings'; +import { bindingsArrayToString } from './toEqualBindingsArray'; + +export default { + toBeIsomorphicBindingsArray(received: Bindings[], actual: Bindings[]) { + if (received.length !== actual.length) { + return { + message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, + pass: false, + }; + } + + const actualCopy = []; + for (const [ _aI, aElement ] of actual.entries()) { + actualCopy.push(aElement); + } + + for (const [ _i, element ] of received.entries()) { + for (const [ aI, aElement ] of actualCopy.entries()) { + const sub = toEqualBindings.toEqualBindings(element, aElement); + if (sub.pass) { + actualCopy[aI] = actualCopy.at(-1)!; + actualCopy.pop(); + break; + } + } + } + if (actualCopy.length > 0) { + return { + message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, + pass: false, + }; + } + + return { + message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, + pass: true, + }; + }, +}; diff --git a/packages/incremental-jest/lib/matchers/toEqualBindings.ts b/packages/incremental-jest/lib/matchers/toEqualBindings.ts index 23ab3a79..93619dd3 100644 --- a/packages/incremental-jest/lib/matchers/toEqualBindings.ts +++ b/packages/incremental-jest/lib/matchers/toEqualBindings.ts @@ -1,17 +1,17 @@ import type { Bindings } from '@comunica/bindings-factory'; import { bindingsToString } from '@comunica/bindings-factory'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; function fail(received: Bindings, actual: Bindings): any { return { - message: () => `\nExpected:\n${bindingsToString(actual)}, isAddition: ${actual.getContextEntry(new ActionContextKeyIsAddition())}\nReceived:\n${bindingsToString(received)}, isAddition: ${received.getContextEntry(new ActionContextKeyIsAddition())}`, + message: () => `\nExpected:\n${bindingsToString(actual)}, isAddition: ${actual.getContextEntry(new ActionContextKeyIsAddition())}\nReceived:\n${bindingsToString(received)}, isAddition: ${received.getContextEntry(new ActionContextKeyIsAddition())}`, pass: false, }; } function succeed(received: Bindings, actual: Bindings): any { return { - message: () => `\nExpected:\n${bindingsToString(actual)}, isAddition: ${actual.getContextEntry(new ActionContextKeyIsAddition())}\nReceived:\n${bindingsToString(received)}, isAddition: ${received.getContextEntry(new ActionContextKeyIsAddition())}`, + message: () => `\nExpected:\n${bindingsToString(actual)}, isAddition: ${actual.getContextEntry(new ActionContextKeyIsAddition())}\nReceived:\n${bindingsToString(received)}, isAddition: ${received.getContextEntry(new ActionContextKeyIsAddition())}`, pass: true, }; } @@ -21,7 +21,8 @@ export default { if (!received.equals(actual)) { return fail(received, actual); } - if (received.getContextEntry(new ActionContextKeyIsAddition()) !== actual.getContextEntry(new ActionContextKeyIsAddition())) { + if (received.getContextEntry(new ActionContextKeyIsAddition()) !== + actual.getContextEntry(new ActionContextKeyIsAddition())) { return fail(received, actual); } diff --git a/packages/incremental-jest/lib/matchers/toEqualBindingsArray.ts b/packages/incremental-jest/lib/matchers/toEqualBindingsArray.ts index d0bc54ea..34809695 100644 --- a/packages/incremental-jest/lib/matchers/toEqualBindingsArray.ts +++ b/packages/incremental-jest/lib/matchers/toEqualBindingsArray.ts @@ -1,12 +1,13 @@ -import {Bindings, bindingsToString} from '@comunica/bindings-factory'; +import type { Bindings } from '@comunica/bindings-factory'; +import { bindingsToString } from '@comunica/bindings-factory'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; import toEqualBindings from './toEqualBindings'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -function bindingsArrayToString(bindings: Bindings[]): string { - if (bindings.length > 0){ - return `[${bindings.map(term => ("\n\t" + bindingsToString(term).replaceAll("\n", "\n\t") + ", isAddition: " + term.getContextEntry(new ActionContextKeyIsAddition()))).join('')}\n]`; +export function bindingsArrayToString(bindings: Bindings[]): string { + if (bindings.length > 0) { + return `[${bindings.map(term => (`\n\t${bindingsToString(term).replaceAll('\n', '\n\t')}, isAddition: ${term.getContextEntry(new ActionContextKeyIsAddition())}`)).join('')}\n]`; } - return `[ ]` + return `[ ]`; } export default { @@ -28,41 +29,6 @@ export default { } } - return { - message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, - pass: true, - }; - }, - toBeIsomorphicBindingsArray(received: Bindings[], actual: Bindings[]) { - if (received.length !== actual.length) { - return { - message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, - pass: false, - }; - } - - let actualCopy = []; - for (const [ aI, aElement ] of actual.entries()) { - actualCopy.push(aElement); - } - - for (const [ i, element ] of received.entries()) { - for (const [ aI, aElement ] of actualCopy.entries()) { - const sub = toEqualBindings.toEqualBindings(element, aElement); - if (sub.pass) { - actualCopy[aI] = actualCopy[actualCopy.length-1]; - actualCopy.pop(); - break; - } - } - } - if (actualCopy.length != 0) { - return { - message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, - pass: false, - }; - } - return { message: () => `\nExpected:\n${bindingsArrayToString(actual)}\nReceived:\n${bindingsArrayToString(received)}`, pass: true, diff --git a/packages/incremental-jest/lib/matchers/toEqualBindingsStream.ts b/packages/incremental-jest/lib/matchers/toEqualBindingsStream.ts index 15211fcc..2ccaab15 100644 --- a/packages/incremental-jest/lib/matchers/toEqualBindingsStream.ts +++ b/packages/incremental-jest/lib/matchers/toEqualBindingsStream.ts @@ -1,7 +1,7 @@ +import type { Bindings } from '@comunica/bindings-factory'; import type { BindingsStream } from '@comunica/types'; import arrayifyStream from 'arrayify-stream'; import toEqualBindingsArray from './toEqualBindingsArray'; -import { Bindings } from "@comunica/bindings-factory"; export default { async toEqualBindingsStream(received: BindingsStream, actual: Bindings[]) { diff --git a/packages/incremental-jest/package.json b/packages/incremental-jest/package.json index dfb74fac..9141d4de 100644 --- a/packages/incremental-jest/package.json +++ b/packages/incremental-jest/package.json @@ -2,17 +2,16 @@ "name": "@incremunica/incremental-jest", "version": "1.3.0", "description": "Jest utilities for incremunica", - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/incremental-jest" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "jest", "rdf", @@ -22,24 +21,27 @@ "matchers", "extend" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"" + }, "dependencies": { + "@comunica/bindings-factory": "^3.3.0", "@comunica/types": "^3.2.1", + "@incremunica/actor-merge-bindings-context-is-addition": "^1.3.0", "@rdfjs/types": "*", "arrayify-stream": "^2.0.1" - }, - "scripts": { - "build": "npm run build:ts", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"" } } diff --git a/packages/incremental-jest/test/matchers/toBeIsomorphicBindingsArray-test.ts b/packages/incremental-jest/test/matchers/toBeIsomorphicBindingsArray-test.ts new file mode 100644 index 00000000..bf8b6c31 --- /dev/null +++ b/packages/incremental-jest/test/matchers/toBeIsomorphicBindingsArray-test.ts @@ -0,0 +1,262 @@ +import type { BindingsFactory } from '@comunica/bindings-factory'; +import '../../lib'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { DataFactory } from 'rdf-data-factory'; + +const DF = new DataFactory(); + +// TODO check if all test still do what they are supposed to do +describe('toBeIsomorphicBindingsArray', () => { + let BF: BindingsFactory; + + beforeEach(async() => { + BF = await DevTools.createBindingsFactory(DF); + }); + + it('should succeed for equal empty bindings', () => { + expect([]).toBeIsomorphicBindingsArray([]); + }); + + it('should succeed for equal non-empty bindings', () => { + expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); + }); + + it('should not succeed for non-equal bindings', () => { + expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).not.toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b2') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); + }); + + it('should not succeed for non-equal bindings due to different length', () => { + expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).not.toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]); + }); + + it('should not fail for equal empty bindings', () => { + expect(() => expect([]).not.toBeIsomorphicBindingsArray([])) + .toThrow(` +Expected: +[ ] +Received: +[ ]`); + }); + + it('should not fail for equal non-empty bindings', () => { + expect(() => expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).not.toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ])) + .toThrow(` +Expected: +[ +\t{ +\t "b": "b1", +\t "c": "c1" +\t}, isAddition: true +\t{ +\t "a": "a1", +\t "b": "b1" +\t}, isAddition: true +] +Received: +[ +\t{ +\t "a": "a1", +\t "b": "b1" +\t}, isAddition: true +\t{ +\t "b": "b1", +\t "c": "c1" +\t}, isAddition: true +]`); + }); + + it('should fail for non-equal non-empty bindings', () => { + expect(() => expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b2') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a2') ], + [ DF.variable('b'), DF.namedNode('b2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ])) + .toThrow(` +Expected: +[ +\t{ +\t "b": "b2", +\t "c": "c1" +\t}, isAddition: true +\t{ +\t "a": "a2", +\t "b": "b2" +\t}, isAddition: true +] +Received: +[ +\t{ +\t "a": "a1", +\t "b": "b1" +\t}, isAddition: true +\t{ +\t "b": "b1", +\t "c": "c1" +\t}, isAddition: true +]`); + }); + + it('should fail for non-equal non-empty bindings due to different length', () => { + expect(() => expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a2') ], + [ DF.variable('b'), DF.namedNode('b2') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ])) + .toThrow(` +Expected: +[ +\t{ +\t "a": "a2", +\t "b": "b2" +\t}, isAddition: true +] +Received: +[ +\t{ +\t "a": "a1", +\t "b": "b1" +\t}, isAddition: true +\t{ +\t "b": "b1", +\t "c": "c1" +\t}, isAddition: true +]`); + }); + + it('should succeed for equal non-empty false bindings', () => { + expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ]); + }); + + it('should not succeed for equal non-empty bindings with different diffs', () => { + expect([ + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + ]).not.toBeIsomorphicBindingsArray([ + BF.bindings([ + [ DF.variable('b'), DF.namedNode('b1') ], + [ DF.variable('c'), DF.namedNode('c1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), true), + BF.bindings([ + [ DF.variable('a'), DF.namedNode('a1') ], + [ DF.variable('b'), DF.namedNode('b1') ], + ]).setContextEntry(new ActionContextKeyIsAddition(), false), + ]); + }); +}); diff --git a/packages/incremental-jest/test/matchers/toEqualBindings-test.ts b/packages/incremental-jest/test/matchers/toEqualBindings-test.ts index dc76e8e3..e6007f8c 100644 --- a/packages/incremental-jest/test/matchers/toEqualBindings-test.ts +++ b/packages/incremental-jest/test/matchers/toEqualBindings-test.ts @@ -1,24 +1,25 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; -import { DataFactory } from 'rdf-data-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import '../../lib'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { DataFactory } from 'rdf-data-factory'; const DF = new DataFactory(); +// TODO check if all test still do what they are supposed to do describe('toEqualBindings', () => { let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { BF = await DevTools.createBindingsFactory(DF); }); it('should succeed for equal empty bindings', () => { - return expect(BF.bindings()).toEqualBindings(BF.bindings()); + expect(BF.bindings()).toEqualBindings(BF.bindings()); }); it('should succeed for equal non-empty bindings', () => { - return expect(BF.bindings([ + expect(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)).toEqualBindings(BF.bindings([ @@ -28,7 +29,7 @@ describe('toEqualBindings', () => { }); it('should not succeed for non-equal bindings', () => { - return expect(BF.bindings([ + expect(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)).not.toEqualBindings(BF.bindings([ @@ -38,8 +39,8 @@ describe('toEqualBindings', () => { }); it('should not fail for equal empty bindings', () => { - return expect(() => expect(BF.bindings()).not.toEqualBindings(BF.bindings())) - .toThrowError(` + expect(() => expect(BF.bindings()).not.toEqualBindings(BF.bindings())) + .toThrow(` Expected: {}, isAddition: undefined Received: @@ -47,14 +48,14 @@ Received: }); it('should not fail for equal non-empty bindings', () => { - return expect(() => expect(BF.bindings([ + expect(() => expect(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)).not.toEqualBindings(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true))) - .toThrowError(` + .toThrow(` Expected: { "a": "a1", @@ -68,14 +69,14 @@ Received: }); it('should fail for non-equal non-empty bindings', () => { - return expect(() => expect(BF.bindings([ + expect(() => expect(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true)).toEqualBindings(BF.bindings([ [ DF.variable('a'), DF.namedNode('a2') ], [ DF.variable('b'), DF.namedNode('b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true))) - .toThrowError(` + .toThrow(` { "a": "a2", "b": "b2" @@ -88,7 +89,7 @@ Received: }); it('should succeed for equal non-empty false bindings', () => { - return expect(BF.bindings([ + expect(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false)).toEqualBindings(BF.bindings([ @@ -98,7 +99,7 @@ Received: }); it('should not succeed for equal bindings with different diffs', () => { - return expect(BF.bindings([ + expect(BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), false)).not.toEqualBindings(BF.bindings([ diff --git a/packages/incremental-jest/test/matchers/toEqualBindingsArray-test.ts b/packages/incremental-jest/test/matchers/toEqualBindingsArray-test.ts index fba9ec4b..f20d66e4 100644 --- a/packages/incremental-jest/test/matchers/toEqualBindingsArray-test.ts +++ b/packages/incremental-jest/test/matchers/toEqualBindingsArray-test.ts @@ -1,24 +1,25 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; -import { DataFactory } from 'rdf-data-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; import '../../lib'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; +import { DataFactory } from 'rdf-data-factory'; const DF = new DataFactory(); +// TODO check if all test still do what they are supposed to do describe('toEqualBindingsArray', () => { let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { BF = await DevTools.createBindingsFactory(DF); }); it('should succeed for equal empty bindings', () => { - return expect([]).toEqualBindingsArray([]); + expect([]).toEqualBindingsArray([]); }); it('should succeed for equal non-empty bindings', () => { - return expect([ + expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -40,7 +41,7 @@ describe('toEqualBindingsArray', () => { }); it('should not succeed for non-equal bindings', () => { - return expect([ + expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -62,7 +63,7 @@ describe('toEqualBindingsArray', () => { }); it('should not succeed for non-equal bindings due to different length', () => { - return expect([ + expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -80,8 +81,8 @@ describe('toEqualBindingsArray', () => { }); it('should not fail for equal empty bindings', () => { - return expect(() => expect([]).not.toEqualBindingsArray([])) - .toThrowError(` + expect(() => expect([]).not.toEqualBindingsArray([])) + .toThrow(` Expected: [ ] Received: @@ -89,7 +90,7 @@ Received: }); it('should not fail for equal non-empty bindings', () => { - return expect(() => expect([ + expect(() => expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -108,7 +109,7 @@ Received: [ DF.variable('c'), DF.namedNode('c1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ])) - .toThrowError(` + .toThrow(` Expected: [ \t{ @@ -134,7 +135,7 @@ Received: }); it('should fail for non-equal non-empty bindings', () => { - return expect(() => expect([ + expect(() => expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -153,7 +154,7 @@ Received: [ DF.variable('c'), DF.namedNode('c1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ])) - .toThrowError(` + .toThrow(` Expected: [ \t{ @@ -180,7 +181,7 @@ Index 0 is different.`); }); it('should fail for non-equal non-empty bindings due to different length', () => { - return expect(() => expect([ + expect(() => expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -195,7 +196,7 @@ Index 0 is different.`); [ DF.variable('b'), DF.namedNode('b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ])) - .toThrowError(` + .toThrow(` Expected: [ \t{ @@ -217,7 +218,7 @@ Received: }); it('should succeed for equal non-empty false bindings', () => { - return expect([ + expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -239,7 +240,7 @@ Received: }); it('should not succeed for equal non-empty bindings with different diffs', () => { - return expect([ + expect([ BF.bindings([ [ DF.variable('a'), DF.namedNode('a1') ], [ DF.variable('b'), DF.namedNode('b1') ], @@ -260,257 +261,3 @@ Received: ]); }); }); - -describe('toBeIsomorphicBindingsArray', () => { - let BF: BindingsFactory; - - beforeEach(async () => { - BF = await DevTools.createBindingsFactory(DF); - }); - - it('should succeed for equal empty bindings', () => { - return expect([]).toBeIsomorphicBindingsArray([]); - }); - - it('should succeed for equal non-empty bindings', () => { - return expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); - - it('should not succeed for non-equal bindings', () => { - return expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).not.toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b2') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); - - it('should not succeed for non-equal bindings due to different length', () => { - return expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).not.toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]); - }); - - it('should not fail for equal empty bindings', () => { - return expect(() => expect([]).not.toBeIsomorphicBindingsArray([])) - .toThrowError(` -Expected: -[ ] -Received: -[ ]`); - }); - - it('should not fail for equal non-empty bindings', () => { - return expect(() => expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).not.toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ])) - .toThrowError(` -Expected: -[ -\t{ -\t "b": "b1", -\t "c": "c1" -\t}, isAddition: true -\t{ -\t "a": "a1", -\t "b": "b1" -\t}, isAddition: true -] -Received: -[ -\t{ -\t "a": "a1", -\t "b": "b1" -\t}, isAddition: true -\t{ -\t "b": "b1", -\t "c": "c1" -\t}, isAddition: true -]`); - }); - - it('should fail for non-equal non-empty bindings', () => { - return expect(() => expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b2') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a2') ], - [ DF.variable('b'), DF.namedNode('b2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ])) - .toThrowError(` -Expected: -[ -\t{ -\t "b": "b2", -\t "c": "c1" -\t}, isAddition: true -\t{ -\t "a": "a2", -\t "b": "b2" -\t}, isAddition: true -] -Received: -[ -\t{ -\t "a": "a1", -\t "b": "b1" -\t}, isAddition: true -\t{ -\t "b": "b1", -\t "c": "c1" -\t}, isAddition: true -]`); - }); - - it('should fail for non-equal non-empty bindings due to different length', () => { - return expect(() => expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a2') ], - [ DF.variable('b'), DF.namedNode('b2') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ])) - .toThrowError(` -Expected: -[ -\t{ -\t "a": "a2", -\t "b": "b2" -\t}, isAddition: true -] -Received: -[ -\t{ -\t "a": "a1", -\t "b": "b1" -\t}, isAddition: true -\t{ -\t "b": "b1", -\t "c": "c1" -\t}, isAddition: true -]`); - }); - - it('should succeed for equal non-empty false bindings', () => { - return expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ]); - }); - - it('should not succeed for equal non-empty bindings with different diffs', () => { - return expect([ - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - ]).not.toBeIsomorphicBindingsArray([ - BF.bindings([ - [ DF.variable('b'), DF.namedNode('b1') ], - [ DF.variable('c'), DF.namedNode('c1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), true), - BF.bindings([ - [ DF.variable('a'), DF.namedNode('a1') ], - [ DF.variable('b'), DF.namedNode('b1') ], - ]).setContextEntry(new ActionContextKeyIsAddition(), false), - ]); - }); -}); diff --git a/packages/incremental-jest/test/matchers/toEqualBindingsStream-test.ts b/packages/incremental-jest/test/matchers/toEqualBindingsStream-test.ts index 2ec08933..5d90d527 100644 --- a/packages/incremental-jest/test/matchers/toEqualBindingsStream-test.ts +++ b/packages/incremental-jest/test/matchers/toEqualBindingsStream-test.ts @@ -1,16 +1,16 @@ -import { BindingsFactory } from '@comunica/bindings-factory'; +import type { BindingsFactory } from '@comunica/bindings-factory'; +import '../../lib'; +import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition'; +import { DevTools } from '@incremunica/dev-tools'; import { ArrayIterator } from 'asynciterator'; import { DataFactory } from 'rdf-data-factory'; -import '../../lib'; -import {ActionContextKeyIsAddition} from "@incremunica/actor-merge-bindings-context-is-addition"; -import {DevTools} from "@incremunica/dev-tools"; const DF = new DataFactory(); describe('toEqualBindingsStream', () => { let BF: BindingsFactory; - beforeEach(async () => { + beforeEach(async() => { BF = await DevTools.createBindingsFactory(DF); }); @@ -82,7 +82,7 @@ describe('toEqualBindingsStream', () => { it('should not fail for equal empty bindings', async() => { await expect(() => expect(new ArrayIterator([], { autoStart: false })).not.toEqualBindingsStream([])) - .rejects.toThrowError(` + .rejects.toThrow(` Expected: [ ] Received: @@ -109,7 +109,7 @@ Received: [ DF.variable('c'), DF.namedNode('c1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ])) - .rejects.toThrowError(` + .rejects.toThrow(` Expected: [ \t{ @@ -154,7 +154,7 @@ Received: [ DF.variable('c'), DF.namedNode('c1') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ])) - .rejects.toThrowError(` + .rejects.toThrow(` Expected: [ \t{ @@ -196,7 +196,7 @@ Index 0 is different.`); [ DF.variable('b'), DF.namedNode('b2') ], ]).setContextEntry(new ActionContextKeyIsAddition(), true), ])) - .rejects.toThrowError(` + .rejects.toThrow(` Expected: [ \t{ diff --git a/packages/incremental-rdf-streaming-store/lib/PendingStreamsIndex.ts b/packages/incremental-rdf-streaming-store/lib/PendingStreamsIndex.ts index 8112da34..a9bac791 100644 --- a/packages/incremental-rdf-streaming-store/lib/PendingStreamsIndex.ts +++ b/packages/incremental-rdf-streaming-store/lib/PendingStreamsIndex.ts @@ -63,7 +63,7 @@ export class PendingStreamsIndex { } for (let i = 0; i < existingListeners.length; i++) { if (existingListeners[i].closed) { - existingListeners[i] = existingListeners[existingListeners.length - 1]; + existingListeners[i] = existingListeners.at(-1)!; existingListeners.pop(); } } diff --git a/packages/incremental-rdf-streaming-store/lib/StreamingStore.ts b/packages/incremental-rdf-streaming-store/lib/StreamingStore.ts index ddc6f2c1..5b41225d 100644 --- a/packages/incremental-rdf-streaming-store/lib/StreamingStore.ts +++ b/packages/incremental-rdf-streaming-store/lib/StreamingStore.ts @@ -1,4 +1,4 @@ -import { EventEmitter } from 'events'; +import { EventEmitter } from 'node:events'; import type { Quad } from '@incremunica/incremental-types'; import type * as RDF from '@rdfjs/types'; import type { Term } from 'n3'; @@ -53,7 +53,7 @@ export class StreamingStore } private handleQuad(quad: Q): void { - if ((quad.diff && this.store.has(quad)) || (!quad.diff && !this.store.has(quad))) { + if (quad.diff ? this.store.has(quad) : !this.store.has(quad)) { return; } for (const pendingStream of this.pendingStreams.getPendingStreamsForQuad(quad)) { @@ -85,9 +85,9 @@ export class StreamingStore public copyOfStore(): Store { const newStore = new Store(); - this.store.forEach(quad => { + for (const quad of this.store) { newStore.add(quad); - }, null, null, null, null); + } return newStore; } @@ -188,7 +188,11 @@ export class StreamingStore storeResult.pipe(unionStream, { end: false }); // If the store hasn't ended yet, also create a new pendingStream - if (!this.ended) { + if (this.ended) { + storeResult.on('close', () => { + unionStream.end(); + }); + } else { // The new pendingStream remains open, until the store is ended. const pendingStream = new PassThrough({ objectMode: true }); if (options) { @@ -216,10 +220,6 @@ export class StreamingStore unionStream.end(); } }); - } else { - storeResult.on('close', () => { - unionStream.end(); - }); } unionStream.on('close', () => { diff --git a/packages/incremental-rdf-streaming-store/package.json b/packages/incremental-rdf-streaming-store/package.json index d9a10fc1..45fa40df 100644 --- a/packages/incremental-rdf-streaming-store/package.json +++ b/packages/incremental-rdf-streaming-store/package.json @@ -3,17 +3,16 @@ "version": "1.3.0", "description": "An RDF Store where the match function gives a stream.", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://github.com/comunica", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/incremental-rdf-streaming-store" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/comunica/issues" }, - "sideEffects": false, "keywords": [ "rdf", "rdfjs", @@ -22,17 +21,23 @@ "stream", "streaming" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/comunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://github.com/comunica", "files": [ "components", "lib/**/*.d.ts", "lib/**/*.js", "lib/**/*.js.map" ], + "scripts": { + "build": "npm run build:ts && npm run build:components", + "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", + "build:components": "componentsjs-generator" + }, "dependencies": { "@rdfjs/types": "*", "@types/n3": "^1.10.4", @@ -44,10 +49,5 @@ }, "devDependencies": { "@incremunica/incremental-types": "^1.3.0" - }, - "scripts": { - "build": "npm run build:ts && npm run build:components", - "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", - "build:components": "componentsjs-generator" } } diff --git a/packages/incremental-rdf-streaming-store/test/StreamingStore-test.ts b/packages/incremental-rdf-streaming-store/test/StreamingStore-test.ts index 59c9edb7..93481549 100644 --- a/packages/incremental-rdf-streaming-store/test/StreamingStore-test.ts +++ b/packages/incremental-rdf-streaming-store/test/StreamingStore-test.ts @@ -1,14 +1,15 @@ import 'jest-rdf'; +import type { Quad } from '@incremunica/incremental-types'; import arrayifyStream from 'arrayify-stream'; import { promisifyEventEmitter } from 'event-emitter-promisify/dist'; import { Store } from 'n3'; import { DataFactory } from 'rdf-data-factory'; import { Readable } from 'readable-stream'; import { StreamingStore } from '../lib/StreamingStore'; -import {Quad} from '@incremunica/incremental-types'; const quad = require('rdf-quad'); const streamifyArray = require('streamify-array'); + const DF = new DataFactory(); describe('StreamStore', () => { @@ -24,7 +25,7 @@ describe('StreamStore', () => { it('handles an empty ended store', async() => { store.end(); - expect(await arrayifyStream(store.match())) + await expect(arrayifyStream(store.match())).resolves .toEqual([]); }); @@ -50,10 +51,10 @@ describe('StreamStore', () => { quad('s', 'p', 'o'), ]))); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ - quad("s","p","o") + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ + quad('s', 'p', 'o'), ]); }); @@ -64,26 +65,26 @@ describe('StreamStore', () => { }); it('should end if match stream is destroyed', async() => { - let stream = store.match(); + const stream = store.match(); expect(store.hasEnded()).toBeFalsy(); stream.destroy(); - await new Promise((resolve) => stream.on("close", () => resolve())) + await new Promise(resolve => stream.on('close', () => resolve())); expect(store.hasEnded()).toBeTruthy(); }); it('should only end if all match streams are destroyed', async() => { - let stream1 = store.match(); - let stream2 = store.match(); - let stream3 = store.match(); + const stream1 = store.match(); + const stream2 = store.match(); + const stream3 = store.match(); expect(store.hasEnded()).toBeFalsy(); stream1.destroy(); - await new Promise((resolve) => stream1.on("close", () => resolve())); + await new Promise(resolve => stream1.on('close', () => resolve())); expect(store.hasEnded()).toBeFalsy(); stream2.destroy(); - await new Promise((resolve) => stream2.on("close", () => resolve())); + await new Promise(resolve => stream2.on('close', () => resolve())); expect(store.hasEnded()).toBeFalsy(); stream3.destroy(); - await new Promise((resolve) => stream3.on("close", () => resolve())); + await new Promise(resolve => stream3.on('close', () => resolve())); expect(store.hasEnded()).toBeTruthy(); }); @@ -91,23 +92,23 @@ describe('StreamStore', () => { await promisifyEventEmitter(store.import(streamifyArray([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), - quad('s3', 'p3', 'o3') + quad('s3', 'p3', 'o3'), ]))); - let quad1 = quad('s1', 'p1', 'o1') - let quad2 = quad('s2', 'p2', 'o2') - quad1.diff = false - quad2.diff = false + const quad1 = quad('s1', 'p1', 'o1'); + const quad2 = quad('s2', 'p2', 'o2'); + quad1.diff = false; + quad2.diff = false; await promisifyEventEmitter(store.import(streamifyArray([ quad1, - quad2 + quad2, ]))); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ - quad('s3', 'p3', 'o3') + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ + quad('s3', 'p3', 'o3'), ]); }); @@ -165,7 +166,7 @@ describe('StreamStore', () => { ]))); store.end(); - expect(await arrayifyStream(store.match())) + await expect(arrayifyStream(store.match())).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -185,7 +186,7 @@ describe('StreamStore', () => { ]))); store.end(); - expect(await arrayifyStream(store.match())) + await expect(arrayifyStream(store.match())).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -202,7 +203,7 @@ describe('StreamStore', () => { const match1 = store.match(); store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -223,7 +224,7 @@ describe('StreamStore', () => { const match1 = store.match(); store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -242,17 +243,17 @@ describe('StreamStore', () => { const match2 = store.match(); const match3 = store.match(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); - expect(await arrayifyStream(match2)) + await expect(arrayifyStream(match2)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); - expect(await arrayifyStream(match3)) + await expect(arrayifyStream(match3)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -275,21 +276,21 @@ describe('StreamStore', () => { const match2 = store.match(); const match3 = store.match(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match2)) + await expect(arrayifyStream(match2)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match3)) + await expect(arrayifyStream(match3)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -308,17 +309,17 @@ describe('StreamStore', () => { const match3 = store.match(); store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); - expect(await arrayifyStream(match2)) + await expect(arrayifyStream(match2)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); - expect(await arrayifyStream(match3)) + await expect(arrayifyStream(match3)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -341,21 +342,21 @@ describe('StreamStore', () => { const match3 = store.match(); store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match2)) + await expect(arrayifyStream(match2)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match3)) + await expect(arrayifyStream(match3)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -385,7 +386,7 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -413,7 +414,7 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -421,7 +422,7 @@ describe('StreamStore', () => { quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match2)) + await expect(arrayifyStream(match2)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -447,7 +448,7 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(store.match())) + await expect(arrayifyStream(store.match())).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -455,7 +456,7 @@ describe('StreamStore', () => { quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -487,7 +488,7 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(m1)) + await expect(arrayifyStream(m1)).resolves .toBeRdfIsomorphic([ quad('s', 'p1', 'o1'), quad('s', 'p', 'o2'), @@ -495,43 +496,43 @@ describe('StreamStore', () => { quad('s4', 'p4', 'o', 'g'), ]); - expect(await arrayifyStream(ms1)) + await expect(arrayifyStream(ms1)).resolves .toBeRdfIsomorphic([ quad('s', 'p1', 'o1'), quad('s', 'p', 'o2'), ]); - expect(await arrayifyStream(ms2)) + await expect(arrayifyStream(ms2)).resolves .toBeRdfIsomorphic([ quad('s', 'p', 'o2'), ]); - expect(await arrayifyStream(ms3)) + await expect(arrayifyStream(ms3)).resolves .toBeRdfIsomorphic([]); - expect(await arrayifyStream(ms4)) + await expect(arrayifyStream(ms4)).resolves .toBeRdfIsomorphic([]); - expect(await arrayifyStream(mp1)) + await expect(arrayifyStream(mp1)).resolves .toBeRdfIsomorphic([ quad('s', 'p', 'o2'), quad('s3', 'p', 'o'), ]); - expect(await arrayifyStream(mp2)) + await expect(arrayifyStream(mp2)).resolves .toBeRdfIsomorphic([ quad('s3', 'p', 'o'), ]); - expect(await arrayifyStream(mp3)) + await expect(arrayifyStream(mp3)).resolves .toBeRdfIsomorphic([]); - expect(await arrayifyStream(mo1)) + await expect(arrayifyStream(mo1)).resolves .toBeRdfIsomorphic([ quad('s3', 'p', 'o'), quad('s4', 'p4', 'o', 'g'), ]); - expect(await arrayifyStream(mo2)) + await expect(arrayifyStream(mo2)).resolves .toBeRdfIsomorphic([ quad('s4', 'p4', 'o', 'g'), ]); - expect(await arrayifyStream(mg1)) + await expect(arrayifyStream(mg1)).resolves .toBeRdfIsomorphic([ quad('s4', 'p4', 'o', 'g'), ]); @@ -550,7 +551,7 @@ describe('StreamStore', () => { const match1 = store.match(); const match2 = store.match(); const posQuad = quad('s5', 'p5', 'o5'); - posQuad.diff = true + posQuad.diff = true; await promisifyEventEmitter(store.remove(streamifyArray([ quad('s2', 'p2', 'o2'), @@ -559,12 +560,12 @@ describe('StreamStore', () => { await promisifyEventEmitter(store.remove(streamifyArray([ quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), - posQuad + posQuad, ]))); store.end(); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -574,7 +575,7 @@ describe('StreamStore', () => { quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(match2)) + await expect(arrayifyStream(match2)).resolves .toBeRdfIsomorphic([ quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -608,10 +609,10 @@ describe('StreamStore', () => { ]))); store.end(); - expect(await arrayifyStream(store.match())) + await expect(arrayifyStream(store.match())).resolves .toBeRdfIsomorphic([]); - expect(await arrayifyStream(match1)) + await expect(arrayifyStream(match1)).resolves .toBeRdfIsomorphic([ quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -626,10 +627,10 @@ describe('StreamStore', () => { store.remove(streamifyArray([ quad('s1', 'p1', 'o1'), ])); - }).toThrow("Attempted to remove out of an ended StreamingStore") + }).toThrow('Attempted to remove out of an ended StreamingStore'); }); - it('handles halting', async () => { + it('handles halting', async() => { await promisifyEventEmitter(store.import(streamifyArray([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -637,9 +638,9 @@ describe('StreamStore', () => { const matchStream = store.match(); - expect(store.isHalted()).toBeFalsy() + expect(store.isHalted()).toBeFalsy(); store.halt(); - expect(store.isHalted()).toBeTruthy() + expect(store.isHalted()).toBeTruthy(); await promisifyEventEmitter(store.import(streamifyArray([ quad('s3', 'p3', 'o3'), @@ -650,14 +651,14 @@ describe('StreamStore', () => { quad('s4', 'p4', 'o4'), ]))); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); store.resume(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -665,16 +666,16 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic([ + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), quad('s4', 'p4', 'o4'), - ]) + ]); }); - it('handles end during halting', async () => { + it('handles end during halting', async() => { await promisifyEventEmitter(store.import(streamifyArray([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), @@ -682,32 +683,32 @@ describe('StreamStore', () => { const matchStream = store.match(); - expect(store.isHalted()).toBeFalsy() + expect(store.isHalted()).toBeFalsy(); store.halt(); - expect(store.isHalted()).toBeTruthy() + expect(store.isHalted()).toBeTruthy(); await promisifyEventEmitter(store.import(streamifyArray([ quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]))); - store.end() + store.end(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); store.resume(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), quad('s4', 'p4', 'o4'), ]); - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic([ + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); @@ -719,31 +720,31 @@ describe('StreamStore', () => { quad('s2', 'p2', 'o2'), ]))); - let options = {stopMatch: () => {}}; + const options = { stopMatch: () => {} }; const matchStream = store.match( null, null, null, null, - options + options, ); options.stopMatch(); await promisifyEventEmitter(store.import(streamifyArray([ quad('s3', 'p3', 'o3'), - quad('s4', 'p4', 'o4') + quad('s4', 'p4', 'o4'), ]))); - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic([ - quad('s1', 'p1', 'o1'), - quad('s2', 'p2', 'o2'), - ]); + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic([ + quad('s1', 'p1', 'o1'), + quad('s2', 'p2', 'o2'), + ]); store.end(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -756,22 +757,22 @@ describe('StreamStore', () => { quad('s1', 'p1', 'o1'), ]))); - let options1 = {stopMatch: () => {}}; + const options1 = { stopMatch: () => {} }; const matchStream1 = store.match( null, null, null, null, - options1 + options1, ); - let options2 = {stopMatch: () => {}}; + const options2 = { stopMatch: () => {} }; const matchStream2 = store.match( null, null, null, null, - options2 + options2, ); options1.stopMatch(); @@ -786,18 +787,18 @@ describe('StreamStore', () => { quad('s3', 'p3', 'o3'), ]))); - expect(await arrayifyStream(matchStream1)).toBeRdfIsomorphic([ + await expect(arrayifyStream(matchStream1)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), ]); - expect(await arrayifyStream(matchStream2)).toBeRdfIsomorphic([ + await expect(arrayifyStream(matchStream2)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); store.end(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -812,19 +813,19 @@ describe('StreamStore', () => { store.end(); - let options = {stopMatch: () => {}}; + const options = { stopMatch: () => {} }; const matchStream = store.match( null, null, null, null, - options + options, ); - options.stopMatch(); //does noting + options.stopMatch(); // Does noting - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic([ + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); @@ -836,14 +837,14 @@ describe('StreamStore', () => { quad('s2', 'p2', 'o2'), ]))); - let options = {stopMatch: () => {}}; + const options = { stopMatch: () => {} }; const matchStream = store.match( null, null, null, null, - options + options, ); store.halt(); @@ -854,14 +855,14 @@ describe('StreamStore', () => { quad('s4', 'p4', 'o4'), ]))); - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic( - await arrayifyStream(store.copyOfStore().match()) + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic( + await arrayifyStream(store.copyOfStore().match()), ); store.resume(); - store.end() + store.end(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -875,165 +876,165 @@ describe('StreamStore', () => { quad('s2', 'p2', 'o2'), ]))); - let options = {stopMatch: () => {}}; + const options = { stopMatch: () => {} }; const matchStream = store.match( null, null, null, null, - options + options, ); store.halt(); options.stopMatch(); - let quad1 = quad('s1', 'p1', 'o1'); - let quad2 = quad('s2', 'p2', 'o2'); + const quad1 = quad('s1', 'p1', 'o1'); + const quad2 = quad('s2', 'p2', 'o2'); quad1.diff = false; quad2.diff = false; await promisifyEventEmitter(store.import(streamifyArray([ quad1, - quad2 + quad2, ]))); - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic( - await arrayifyStream(store.copyOfStore().match()) + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic( + await arrayifyStream(store.copyOfStore().match()), ); store.resume(); - store.end() + store.end(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([]); + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([]); }); it('should handle single quad insertions', async() => { store.addQuad(quad('s1', 'p1', 'o1')); - let match = store.match(); + const match = store.match(); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ - quad('s1', 'p1', 'o1') + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ + quad('s1', 'p1', 'o1'), ]); - let quad1 = quad('s2', 'p2', 'o2'); - quad1.diff = true + const quad1 = quad('s2', 'p2', 'o2'); + quad1.diff = true; store.addQuad(quad1); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), - quad('s2', 'p2', 'o2') + quad('s2', 'p2', 'o2'), ]); - let quad2 = quad('s2', 'p2', 'o2'); - quad2.diff = false + const quad2 = quad('s2', 'p2', 'o2'); + quad2.diff = false; store.addQuad(quad2); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ - quad('s1', 'p1', 'o1') + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ + quad('s1', 'p1', 'o1'), ]); store.end(); - expect(await arrayifyStream(match)).toBeRdfIsomorphic([ + await expect(arrayifyStream(match)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), - quad('s2', 'p2', 'o2') - ]) + quad('s2', 'p2', 'o2'), + ]); }); it('should handle single quad removals', async() => { - let quad1 = quad('s1', 'p1', 'o1'); - quad1.diff = true + const quad1 = quad('s1', 'p1', 'o1'); + quad1.diff = true; store.removeQuad(quad1); - let quad2 = quad('s2', 'p2', 'o2'); - quad2.diff = true + const quad2 = quad('s2', 'p2', 'o2'); + quad2.diff = true; store.removeQuad(quad2); - let match = store.match(); + const match = store.match(); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), - quad('s2', 'p2', 'o2') + quad('s2', 'p2', 'o2'), ]); store.removeQuad(quad('s1', 'p1', 'o1')); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ - quad('s2', 'p2', 'o2') + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ + quad('s2', 'p2', 'o2'), ]); - let quad3 = quad('s2', 'p2', 'o2') - quad3.diff = false + const quad3 = quad('s2', 'p2', 'o2'); + quad3.diff = false; store.addQuad(quad3); - expect( - await arrayifyStream(store.copyOfStore().match()) - ).toBeRdfIsomorphic([ + await expect( + arrayifyStream(store.copyOfStore().match()), + ).resolves.toBeRdfIsomorphic([ ]); store.end(); - expect(await arrayifyStream(match)).toBeRdfIsomorphic([ + await expect(arrayifyStream(match)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s1', 'p1', 'o1'), - quad('s2', 'p2', 'o2') - ]) + quad('s2', 'p2', 'o2'), + ]); }); it('should throw error if addQuad after end', async() => { store.end(); expect(() => { - store.addQuad(quad('s1', 'p1', 'o1')) - }).toThrow("Attempted to add a quad into an ended StreamingStore.") + store.addQuad(quad('s1', 'p1', 'o1')); + }).toThrow('Attempted to add a quad into an ended StreamingStore.'); }); it('should throw error if removeQuad after end', async() => { store.end(); expect(() => { - store.removeQuad(quad('s1', 'p1', 'o1')) - }).toThrow("Attempted to remove a quad of an ended StreamingStore.") + store.removeQuad(quad('s1', 'p1', 'o1')); + }).toThrow('Attempted to remove a quad of an ended StreamingStore.'); }); - it('handles halting with addQuad', async () => { + it('handles halting with addQuad', async() => { store.addQuad(quad('s1', 'p1', 'o1')); store.addQuad(quad('s2', 'p2', 'o2')); const matchStream = store.match(); - expect(store.isHalted()).toBeFalsy() + expect(store.isHalted()).toBeFalsy(); store.halt(); - expect(store.isHalted()).toBeTruthy() + expect(store.isHalted()).toBeTruthy(); store.addQuad(quad('s3', 'p3', 'o3')); store.addQuad(quad('s4', 'p4', 'o4')); store.removeQuad(quad('s4', 'p4', 'o4')); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), ]); store.resume(); - expect(await arrayifyStream(store.copyOfStore().match())).toBeRdfIsomorphic([ + await expect(arrayifyStream(store.copyOfStore().match())).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -1041,7 +1042,7 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(matchStream)).toBeRdfIsomorphic([ + await expect(arrayifyStream(matchStream)).resolves.toBeRdfIsomorphic([ quad('s1', 'p1', 'o1'), quad('s2', 'p2', 'o2'), quad('s3', 'p3', 'o3'), @@ -1050,7 +1051,7 @@ describe('StreamStore', () => { ]); }); - it('should be set semantics', async () => { + it('should be set semantics', async() => { store.addQuad(quad('s1', 'p1', 'o1')); store.addQuad(quad('s1', 'p1', 'o1')); @@ -1058,8 +1059,8 @@ describe('StreamStore', () => { store.end(); - expect(await arrayifyStream(store.match())).toBeRdfIsomorphic([ - quad('s1', 'p1', 'o1') + await expect(arrayifyStream(store.match())).resolves.toBeRdfIsomorphic([ + quad('s1', 'p1', 'o1'), ]); }); }); diff --git a/packages/incremental-types/lib/GuardEvents.ts b/packages/incremental-types/lib/GuardEvents.ts index fa01d89e..f3e6d585 100644 --- a/packages/incremental-types/lib/GuardEvents.ts +++ b/packages/incremental-types/lib/GuardEvents.ts @@ -1,4 +1,4 @@ -import type { EventEmitter } from 'events'; +import type { EventEmitter } from 'node:events'; export interface IGuardEvents extends EventEmitter { emit: ((event: 'modified') => boolean) & ((event: 'up-to-date') => boolean); diff --git a/packages/incremental-types/package.json b/packages/incremental-types/package.json index 88e35d94..4600c23d 100644 --- a/packages/incremental-types/package.json +++ b/packages/incremental-types/package.json @@ -3,43 +3,41 @@ "version": "1.3.0", "description": "Types module for incremental Comunica", "lsd:module": true, - "main": "lib/index.js", - "typings": "lib/index", + "license": "MIT", + "homepage": "https://maartyman.github.io/incremunica/", "repository": { "type": "git", "url": "https://github.com/maartyman/incremunica.git", "directory": "packages/incremental-types" }, - "publishConfig": { - "access": "public" + "bugs": { + "url": "https://github.com/maartyman/incremunica/issues" }, - "sideEffects": false, "keywords": [ "comunica", "types" ], - "license": "MIT", - "bugs": { - "url": "https://github.com/maartyman/incremunica/issues" + "sideEffects": false, + "main": "lib/index.js", + "typings": "lib/index", + "publishConfig": { + "access": "public" }, - "homepage": "https://maartyman.github.io/incremunica/", "files": [ + "bin/**/*.d.ts", + "bin/**/*.js", + "bin/**/*.js.map", "components", "lib/**/*.d.ts", "lib/**/*.js", - "lib/**/*.js.map", - "bin/**/*.d.ts", - "bin/**/*.js", - "bin/**/*.js.map" + "lib/**/*.js.map" ], - "dependencies": { - "@rdfjs/types": "*", - "asynciterator": "^3.9.0", - "n3": "^1.16.3" - }, "scripts": { "build": "npm run build:ts && npm run build:components", "build:ts": "node \"../../node_modules/typescript/bin/tsc\"", "build:components": "componentsjs-generator" + }, + "dependencies": { + "n3": "^1.16.3" } } diff --git a/renovate.json b/renovate.json index d98161ad..efe49867 100644 --- a/renovate.json +++ b/renovate.json @@ -1,67 +1,19 @@ { "extends": [ - "config:base", + "github>rubensworks/renovate-presets:js", "docker:disable" ], - "description": "Based on: https://github.com/rubensworks/renovate-presets.", - - "prCreation": "not-pending", - "stabilityDays": 1, - "statusCheckVerify": true, - "schedule": "before 7am every weekday", - "timezone": "Europe/Brussels", - "unicodeEmoji": true, - "vulnerabilityAlerts": { - "enabled": false - }, "rangeStrategy": "replace", - "ignoreDeps": [ - "eslint", - "eslint-config-es", - "eslint-import-resolver-typescript", - "eslint-plugin-eslint-comments", - "eslint-plugin-extended", - "eslint-plugin-import", - "eslint-plugin-jest", - "eslint-plugin-mocha", - "eslint-plugin-react", - "eslint-plugin-react-hooks", - "eslint-plugin-tsdoc", - "eslint-plugin-unicorn", - "eslint-plugin-unused-imports" - ], - "packageRules": [ { "matchSourceUrlPrefixes": ["https://github.com/comunica/comunica"], - "groupName": "Comunica monorepo packages" - }, - { - "matchSourceUrlPrefixes": ["https://github.com/LinkedDataFragments/Server.js"], - "groupName": "LDF server monorepo packages" - }, - { - "matchDepTypes": ["dependencies"], - "matchUpdateTypes": ["minor", "patch"], - "matchCurrentVersion": "!/^0/", + "groupName": "Comunica monorepo packages", + "rangeStrategy": "bump", "automerge": false, - "automergeType": "branch" - }, - { - "matchDepTypes": ["devDependencies"], - "automerge": false, - "automergeType": "branch" + "stabilityDays": 0, + "schedule": null, + "prConcurrentLimit": 0, + "branchConcurrentLimit": 0 } - ], - - "devDependencies": { - "rangeStrategy": "replace" - }, - - "dockerfile": { - "enabled": false - }, - "github-actions": { - "enabled": false - } + ] } diff --git a/tsconfig.json b/tsconfig.json index 9f38d57b..9e58641f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,8 @@ "inlineSources": true, "preserveConstEnums": true, "removeComments": false, - "sourceMap": true + "sourceMap": true, + "esModuleInterop": true }, "include": [ "engines/*/bin/**/*", diff --git a/typedoc.js b/typedoc.js index 2eb1abcb..fdd862c5 100644 --- a/typedoc.js +++ b/typedoc.js @@ -3,5 +3,5 @@ module.exports = { out: 'documentation', theme: 'default', entryPointStrategy: 'packages', - entryPoints: [ 'engines/*', 'packages/*' ] -} + entryPoints: [ 'engines/*', 'packages/*' ], +}; diff --git a/yarn.lock b/yarn.lock index 6ad6f35e..ee7a70ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2473,6 +2473,19 @@ rdf-data-factory "^1.1.1" rdf-string "^1.6.1" +"@comunica/bindings-factory@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/bindings-factory/-/bindings-factory-3.3.0.tgz#8d705d5f4eea35111ea9b0e0cbf85ede67dfd1e9" + integrity sha512-twvdBRASI2yaROGEMmscgzN8UTFUbxR/R0D1kzkZmdAKAA5MPAudL/VzgF0H/5K6uGAXaueKp4VjLgvT/XbSXw== + dependencies: + "@comunica/bus-merge-bindings-context" "^3.3.0" + "@comunica/core" "^3.3.0" + "@comunica/types" "^3.3.0" + "@rdfjs/types" "*" + immutable "^4.1.0" + rdf-data-factory "^1.1.1" + rdf-string "^1.6.1" + "@comunica/bus-context-preprocess@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/bus-context-preprocess/-/bus-context-preprocess-3.2.1.tgz#3ff584a280713f9ce05ada2dc3fa49a319e8bb6f" @@ -2573,6 +2586,14 @@ "@comunica/core" "^3.2.1" "@comunica/types" "^3.2.1" +"@comunica/bus-merge-bindings-context@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/bus-merge-bindings-context/-/bus-merge-bindings-context-3.3.0.tgz#a5e1f10f027ad3e5141270c842c56914eb44cbcb" + integrity sha512-SFlb5LlVtI8GOj1C6tEMZsav9M1ptHiMq9qAoJel7+Ov2Xrpu0u4KSQVOTENSsSRokHzuzEwQ4uOBZGVmXulRA== + dependencies: + "@comunica/core" "^3.3.0" + "@comunica/types" "^3.3.0" + "@comunica/bus-optimize-query-operation@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/bus-optimize-query-operation/-/bus-optimize-query-operation-3.2.1.tgz#a964cf0c78d5a6db8137825d114f765132a2d399" @@ -2600,6 +2621,24 @@ rdf-terms "^1.11.0" sparqlalgebrajs "^4.3.7" +"@comunica/bus-query-operation@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/bus-query-operation/-/bus-query-operation-3.3.0.tgz#faea1370d5a886bb2ba1da255e9c7a13828f51fc" + integrity sha512-MWn9BUgd9M+tQLzcm18rICVINocHgYHfdqwZ9b6r7RO/Y2p3NU3BgXPgr33FfvdzBTGWFlWdk7KUPMA5SqR+SQ== + dependencies: + "@comunica/bindings-factory" "^3.3.0" + "@comunica/context-entries" "^3.3.0" + "@comunica/core" "^3.3.0" + "@comunica/data-factory" "^3.1.0" + "@comunica/metadata" "^3.3.0" + "@comunica/types" "^3.3.0" + "@rdfjs/types" "*" + asynciterator "^3.9.0" + rdf-data-factory "^1.1.2" + rdf-string "^1.6.1" + rdf-terms "^1.11.0" + sparqlalgebrajs "^4.3.7" + "@comunica/bus-query-parse@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/bus-query-parse/-/bus-query-parse-3.2.1.tgz#5d20ae3c63257e2326634d231b475995b95c4c6a" @@ -2636,6 +2675,15 @@ "@comunica/types" "^3.2.1" "@rdfjs/types" "*" +"@comunica/bus-query-source-identify-hypermedia@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/bus-query-source-identify-hypermedia/-/bus-query-source-identify-hypermedia-3.3.0.tgz#cdba5282568bd9f151cfa423b616540c22c74020" + integrity sha512-/qM5VhHwqDQD/m2CYX3n3zJ+cRMvMTjkhXzEvJIuUVuQfxvuEDK0a5tEbUr2cf0nkVbV0B2r0Ps5aMtj1g2kdQ== + dependencies: + "@comunica/core" "^3.3.0" + "@comunica/types" "^3.3.0" + "@rdfjs/types" "*" + "@comunica/bus-query-source-identify@^3.2.2": version "3.2.2" resolved "https://registry.yarnpkg.com/@comunica/bus-query-source-identify/-/bus-query-source-identify-3.2.2.tgz#02e906aebc0f50d12622fafa220bdf42f01c2f4d" @@ -2653,6 +2701,23 @@ rdf-terms "^1.11.0" sparqlalgebrajs "^4.3.7" +"@comunica/bus-query-source-identify@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/bus-query-source-identify/-/bus-query-source-identify-3.3.0.tgz#24040229d9d3715a52c31f8084b8bcb0f125ccf6" + integrity sha512-34SYIbPXvujvEiw5w3UM+SNZ5yLd/wquBHzS2XGDaJP7mle1xH1LLg9uSzBS5kCvR2zgjMUutEoc4jMwCQNsnw== + dependencies: + "@comunica/bindings-factory" "^3.3.0" + "@comunica/bus-query-operation" "^3.3.0" + "@comunica/core" "^3.3.0" + "@comunica/metadata" "^3.3.0" + "@comunica/types" "^3.3.0" + "@rdfjs/types" "*" + asynciterator "^3.9.0" + rdf-data-factory "^1.1.2" + rdf-string "^1.6.3" + rdf-terms "^1.11.0" + sparqlalgebrajs "^4.3.7" + "@comunica/bus-rdf-join-entries-sort@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/bus-rdf-join-entries-sort/-/bus-rdf-join-entries-sort-3.2.1.tgz#5b23d25fa355573099e4bc6f41f16382ad6e1ad4" @@ -2764,18 +2829,6 @@ "@comunica/types" "^3.2.1" "@rdfjs/types" "*" -"@comunica/bus-rdf-resolve-quad-pattern@^2.10.0": - version "2.10.0" - resolved "https://registry.yarnpkg.com/@comunica/bus-rdf-resolve-quad-pattern/-/bus-rdf-resolve-quad-pattern-2.10.0.tgz#44f386724f37131bee534f4923650ce9884ce2e1" - integrity sha512-JEI4DqSprGmrbfmiIwc8PbS+HCoxXwmMtp7gDpoB1HyYKIHzzu9DOIiwmYEDRO5dwV+uTwaYKZz/mUPm2U6EEg== - dependencies: - "@comunica/context-entries" "^2.10.0" - "@comunica/core" "^2.10.0" - "@comunica/types" "^2.10.0" - "@rdfjs/types" "*" - asynciterator "^3.8.1" - sparqlalgebrajs "^4.2.0" - "@comunica/bus-rdf-serialize@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/bus-rdf-serialize/-/bus-rdf-serialize-3.2.1.tgz#7bdfe72995e83d8c389f876a1739e37778d80cdf" @@ -2829,6 +2882,17 @@ jsonld-context-parser "^2.2.2" sparqlalgebrajs "^4.3.7" +"@comunica/context-entries@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/context-entries/-/context-entries-3.3.0.tgz#80e1263493b68808896f41f43daa622a9bd819be" + integrity sha512-6kJGlAF5t/kNm+tejinqsryyzxYeSppWQ5ODF1j6IM5LLueMS7/3SZzNuA0zR6QmxJkRLDcZG0fYWn4mxjFjGw== + dependencies: + "@comunica/core" "^3.3.0" + "@comunica/types" "^3.3.0" + "@rdfjs/types" "*" + jsonld-context-parser "^2.2.2" + sparqlalgebrajs "^4.3.7" + "@comunica/core@^2.0.1", "@comunica/core@^2.10.0": version "2.10.0" resolved "https://registry.yarnpkg.com/@comunica/core/-/core-2.10.0.tgz#198c176443d03d6b374ee2b11fdd862b4b7c2b63" @@ -2837,6 +2901,14 @@ "@comunica/types" "^2.10.0" immutable "^4.1.0" +"@comunica/core@^3.2.0", "@comunica/core@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/core/-/core-3.3.0.tgz#dd38aedc038ecaed507b04bf2326bd2a458c03fe" + integrity sha512-asLXeydYjcQdMPlHDWjvFsmIwY0LOegM7D8KkTNRW6w+u/+mgwnfj8L0r9/AqfrbJyJNEmrgZJSlY/aBntwZ5Q== + dependencies: + "@comunica/types" "^3.3.0" + immutable "^4.1.0" + "@comunica/core@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/core/-/core-3.2.1.tgz#673fe1c395b8adfbd69e17af3d488a53d604d032" @@ -3001,13 +3073,6 @@ dependencies: "@comunica/core" "^3.2.1" -"@comunica/metadata@^2.10.0": - version "2.10.0" - resolved "https://registry.yarnpkg.com/@comunica/metadata/-/metadata-2.10.0.tgz#9e057db8573001ea60e00938e6ba35dce54970fe" - integrity sha512-PF7TKhuDIO4GE9tzuAkTxarQV5cmwXZ64hp0qm8Ql/V+dVHu/3xLL9v/Q67ZX26GF9hOyr7cdpNI08M7DHc86g== - dependencies: - "@comunica/types" "^2.10.0" - "@comunica/metadata@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/metadata/-/metadata-3.2.1.tgz#0745d5b0ec515d86661daefd4a7f5f728fd6af72" @@ -3017,6 +3082,15 @@ "@rdfjs/types" "*" asynciterator "^3.9.0" +"@comunica/metadata@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/metadata/-/metadata-3.3.0.tgz#05a469c61422b846c74b9bb45b74df500cc6909d" + integrity sha512-TPRm2Z3ecDRxUAKbp4ZYhTTGvR4dclXB+K7QRYjf3aeokexWDm+Tpyac/zA3JdOEcfAkV7tfmn5Xz/m8ytiUDw== + dependencies: + "@comunica/types" "^3.3.0" + "@rdfjs/types" "*" + asynciterator "^3.9.0" + "@comunica/runner-cli@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@comunica/runner-cli/-/runner-cli-3.2.1.tgz#c0cc2e75548e39e68585c6834d7a86bed236cdac" @@ -3037,6 +3111,16 @@ componentsjs "^6.0.1" process "^0.11.10" +"@comunica/types@3.3.0", "@comunica/types@^3.2.0", "@comunica/types@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@comunica/types/-/types-3.3.0.tgz#b3288314ee511bc3c8889f4d1f2f0aa04df7a138" + integrity sha512-Z6RtAzvcUvBzIyG5lzMWfGF9ODIJQ2SETA8dW6MWMmttJgYe6xRpUjTKzvhnEs3vcleDD5AutL7tZ7vx50NELg== + dependencies: + "@rdfjs/types" "*" + "@types/yargs" "^17.0.24" + asynciterator "^3.9.0" + sparqlalgebrajs "^4.3.7" + "@comunica/types@^2.10.0": version "2.10.0" resolved "https://registry.yarnpkg.com/@comunica/types/-/types-2.10.0.tgz#fbb4968734e4297eb116a7fa836ca0362d0cba89" @@ -3057,6 +3141,11 @@ asynciterator "^3.9.0" sparqlalgebrajs "^4.3.7" +"@comunica/utils-monorepo@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@comunica/utils-monorepo/-/utils-monorepo-4.0.1.tgz#176a849b423b2cf196f883e65e92dedba8edd0cb" + integrity sha512-QZUYqoyQcicrLF/ZDsoEjK0C6puoGP8vFO8/VL0IhIaWJvDv/okO9GQzkTaPlkUqVGr5VAZghfdW1EV56JsN/g== + "@dabh/diagnostics@^2.0.2": version "2.0.3" resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.3.tgz#7f7e97ee9a725dffc7808d93668cc984e1dc477a" @@ -3092,11 +3181,6 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.11.1.tgz#a547badfc719eb3e5f4b556325e542fbe9d7a18f" integrity sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q== -"@eslint-community/regexpp@^4.4.0": - version "4.10.0" - resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" - integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== - "@eslint-types/jsdoc@46.8.2-1": version "46.8.2-1" resolved "https://registry.yarnpkg.com/@eslint-types/jsdoc/-/jsdoc-46.8.2-1.tgz#c1d9ec9ce032f0ad3a943613c346a648bcad9063" @@ -3161,21 +3245,6 @@ resolved "https://registry.yarnpkg.com/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340" integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q== -"@incremunica/actor-rdf-resolve-quad-pattern-rdfjs-streaming-source@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@incremunica/actor-rdf-resolve-quad-pattern-rdfjs-streaming-source/-/actor-rdf-resolve-quad-pattern-rdfjs-streaming-source-1.3.0.tgz#6242722feef35df82b92e2744a2f9a87f96cd1e3" - integrity sha512-7Ozs4ojqET8XryTGE2JKGaNAeAYBG0HOsAtI8BM7xidpoi2EpRe3u0nzikuKPUvEAp3ojb3RdD+fIZGaBLz8Ow== - dependencies: - "@comunica/bus-rdf-resolve-quad-pattern" "^2.10.0" - "@comunica/core" "^2.10.0" - "@comunica/metadata" "^2.10.0" - "@comunica/types" "^2.10.0" - "@incremunica/context-entries" "^1.3.0" - "@incremunica/incremental-rdf-streaming-store" "^1.3.0" - "@incremunica/incremental-types" "^1.3.0" - "@rdfjs/types" "*" - asynciterator "^3.8.1" - "@isaacs/cliui@^8.0.2": version "8.0.2" resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" @@ -3466,6 +3535,14 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@jridgewell/trace-mapping@^0.3.20": + version "0.3.25" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + "@jsdevtools/ez-spawn@^3.0.4": version "3.0.4" resolved "https://registry.yarnpkg.com/@jsdevtools/ez-spawn/-/ez-spawn-3.0.4.tgz#5641eb26fee6d31ec29f6788eba849470c52c7ff" @@ -4148,6 +4225,13 @@ resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== +"@playwright/test@^1.47.2": + version "1.48.0" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.48.0.tgz#4b81434a3ca75e2a6f82a645287784223a45434c" + integrity sha512-W5lhqPUVPqhtc/ySvZI5Q8X2ztBOUgZ8LbAFy0JQgrXZs2xaILrUcNO3rQjwbLPfGK13+rZsDa1FpG+tqYkT5w== + dependencies: + playwright "1.48.0" + "@pnpm/config.env-replace@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz#ab29da53df41e8948a00f2433f085f54de8b3a4c" @@ -4498,22 +4582,6 @@ dependencies: "@types/node" "*" -"@types/eslint-scope@^3.7.3": - version "3.7.7" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" - integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "8.44.7" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.44.7.tgz#430b3cc96db70c81f405e6a08aebdb13869198f5" - integrity sha512-f5ORu2hcBbKei97U73mf+l9t4zTGl74IqZ0GQk4oVea/VS8tQZYkUveSYojk+frraAVYId0V2WC9O4PTNru2FQ== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - "@types/eslint@^8.56.10": version "8.56.12" resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.12.tgz#1657c814ffeba4d2f84c0d4ba0f44ca7ea1ca53a" @@ -4522,11 +4590,16 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^1.0.0": +"@types/estree@*": version "1.0.5" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/estree@^1.0.5": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== + "@types/fs-extra@^8.0.0": version "8.1.5" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.5.tgz#33aae2962d3b3ec9219b5aca2555ee00274f5927" @@ -4788,22 +4861,6 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz#aeef0328d172b9e37d9bab6dbc13b87ed88977db" - integrity sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag== - dependencies: - "@eslint-community/regexpp" "^4.4.0" - "@typescript-eslint/scope-manager" "5.62.0" - "@typescript-eslint/type-utils" "5.62.0" - "@typescript-eslint/utils" "5.62.0" - debug "^4.3.4" - graphemer "^1.4.0" - ignore "^5.2.0" - natural-compare-lite "^1.4.0" - semver "^7.3.7" - tsutils "^3.21.0" - "@typescript-eslint/eslint-plugin@^6.20.0": version "6.21.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz#30830c1ca81fd5f3c2714e524c4303e0194f9cd3" @@ -4821,16 +4878,6 @@ semver "^7.5.4" ts-api-utils "^1.0.1" -"@typescript-eslint/parser@^5.43.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.62.0.tgz#1b63d082d849a2fcae8a569248fbe2ee1b8a56c7" - integrity sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA== - dependencies: - "@typescript-eslint/scope-manager" "5.62.0" - "@typescript-eslint/types" "5.62.0" - "@typescript-eslint/typescript-estree" "5.62.0" - debug "^4.3.4" - "@typescript-eslint/parser@^6.20.0": version "6.21.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.21.0.tgz#af8fcf66feee2edc86bc5d1cf45e33b0630bf35b" @@ -4866,16 +4913,6 @@ "@typescript-eslint/types" "7.18.0" "@typescript-eslint/visitor-keys" "7.18.0" -"@typescript-eslint/type-utils@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz#286f0389c41681376cdad96b309cedd17d70346a" - integrity sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew== - dependencies: - "@typescript-eslint/typescript-estree" "5.62.0" - "@typescript-eslint/utils" "5.62.0" - debug "^4.3.4" - tsutils "^3.21.0" - "@typescript-eslint/type-utils@6.21.0": version "6.21.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz#6473281cfed4dacabe8004e8521cee0bd9d4c01e" @@ -4942,20 +4979,6 @@ semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/utils@5.62.0", "@typescript-eslint/utils@^5.10.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86" - integrity sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ== - dependencies: - "@eslint-community/eslint-utils" "^4.2.0" - "@types/json-schema" "^7.0.9" - "@types/semver" "^7.3.12" - "@typescript-eslint/scope-manager" "5.62.0" - "@typescript-eslint/types" "5.62.0" - "@typescript-eslint/typescript-estree" "5.62.0" - eslint-scope "^5.1.1" - semver "^7.3.7" - "@typescript-eslint/utils@6.21.0", "@typescript-eslint/utils@^6.21.0": version "6.21.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.21.0.tgz#4714e7a6b39e773c1c8e97ec587f520840cd8134" @@ -4969,6 +4992,20 @@ "@typescript-eslint/typescript-estree" "6.21.0" semver "^7.5.4" +"@typescript-eslint/utils@^5.10.0": + version "5.62.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86" + integrity sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.62.0" + "@typescript-eslint/types" "5.62.0" + "@typescript-eslint/typescript-estree" "5.62.0" + eslint-scope "^5.1.1" + semver "^7.3.7" + "@typescript-eslint/utils@^6.13.0 || ^7.0.0", "@typescript-eslint/utils@^7.1.1": version "7.18.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.18.0.tgz#bca01cde77f95fc6a8d5b0dbcbfb3d6ca4be451f" @@ -5066,10 +5103,10 @@ resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.3.9.tgz#df740d26d338faf03e09ca662a8031acf66051db" integrity sha512-ZE0VTIR0LmYgeyhurPTpy4KzKsuDyQbMSdM49eKkMnT5X4VfFBLysMzjIZhLEFQYjjOVVfbvUDHckwjDFiO2eA== -"@webassemblyjs/ast@1.11.6", "@webassemblyjs/ast@^1.11.5": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.6.tgz#db046555d3c413f8966ca50a95176a0e2c642e24" - integrity sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q== +"@webassemblyjs/ast@1.12.1", "@webassemblyjs/ast@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.12.1.tgz#bb16a0e8b1914f979f45864c23819cc3e3f0d4bb" + integrity sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg== dependencies: "@webassemblyjs/helper-numbers" "1.11.6" "@webassemblyjs/helper-wasm-bytecode" "1.11.6" @@ -5084,10 +5121,10 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz#6132f68c4acd59dcd141c44b18cbebbd9f2fa768" integrity sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q== -"@webassemblyjs/helper-buffer@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz#b66d73c43e296fd5e88006f18524feb0f2c7c093" - integrity sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA== +"@webassemblyjs/helper-buffer@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz#6df20d272ea5439bf20ab3492b7fb70e9bfcb3f6" + integrity sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw== "@webassemblyjs/helper-numbers@1.11.6": version "1.11.6" @@ -5103,15 +5140,15 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz#bb2ebdb3b83aa26d9baad4c46d4315283acd51e9" integrity sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA== -"@webassemblyjs/helper-wasm-section@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz#ff97f3863c55ee7f580fd5c41a381e9def4aa577" - integrity sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g== +"@webassemblyjs/helper-wasm-section@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz#3da623233ae1a60409b509a52ade9bc22a37f7bf" + integrity sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g== dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-buffer" "1.11.6" + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" "@webassemblyjs/helper-wasm-bytecode" "1.11.6" - "@webassemblyjs/wasm-gen" "1.11.6" + "@webassemblyjs/wasm-gen" "1.12.1" "@webassemblyjs/ieee754@1.11.6": version "1.11.6" @@ -5132,59 +5169,59 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.6.tgz#90f8bc34c561595fe156603be7253cdbcd0fab5a" integrity sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA== -"@webassemblyjs/wasm-edit@^1.11.5": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz#c72fa8220524c9b416249f3d94c2958dfe70ceab" - integrity sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw== +"@webassemblyjs/wasm-edit@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz#9f9f3ff52a14c980939be0ef9d5df9ebc678ae3b" + integrity sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g== dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-buffer" "1.11.6" + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" "@webassemblyjs/helper-wasm-bytecode" "1.11.6" - "@webassemblyjs/helper-wasm-section" "1.11.6" - "@webassemblyjs/wasm-gen" "1.11.6" - "@webassemblyjs/wasm-opt" "1.11.6" - "@webassemblyjs/wasm-parser" "1.11.6" - "@webassemblyjs/wast-printer" "1.11.6" - -"@webassemblyjs/wasm-gen@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz#fb5283e0e8b4551cc4e9c3c0d7184a65faf7c268" - integrity sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA== - dependencies: - "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/helper-wasm-section" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-opt" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + "@webassemblyjs/wast-printer" "1.12.1" + +"@webassemblyjs/wasm-gen@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz#a6520601da1b5700448273666a71ad0a45d78547" + integrity sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w== + dependencies: + "@webassemblyjs/ast" "1.12.1" "@webassemblyjs/helper-wasm-bytecode" "1.11.6" "@webassemblyjs/ieee754" "1.11.6" "@webassemblyjs/leb128" "1.11.6" "@webassemblyjs/utf8" "1.11.6" -"@webassemblyjs/wasm-opt@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz#d9a22d651248422ca498b09aa3232a81041487c2" - integrity sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g== +"@webassemblyjs/wasm-opt@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz#9e6e81475dfcfb62dab574ac2dda38226c232bc5" + integrity sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg== dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-buffer" "1.11.6" - "@webassemblyjs/wasm-gen" "1.11.6" - "@webassemblyjs/wasm-parser" "1.11.6" + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" -"@webassemblyjs/wasm-parser@1.11.6", "@webassemblyjs/wasm-parser@^1.11.5": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz#bb85378c527df824004812bbdb784eea539174a1" - integrity sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ== +"@webassemblyjs/wasm-parser@1.12.1", "@webassemblyjs/wasm-parser@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz#c47acb90e6f083391e3fa61d113650eea1e95937" + integrity sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ== dependencies: - "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/ast" "1.12.1" "@webassemblyjs/helper-api-error" "1.11.6" "@webassemblyjs/helper-wasm-bytecode" "1.11.6" "@webassemblyjs/ieee754" "1.11.6" "@webassemblyjs/leb128" "1.11.6" "@webassemblyjs/utf8" "1.11.6" -"@webassemblyjs/wast-printer@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz#a7bf8dd7e362aeb1668ff43f35cb849f188eff20" - integrity sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A== +"@webassemblyjs/wast-printer@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz#bcecf661d7d1abdaf989d8341a4833e33e2b31ac" + integrity sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA== dependencies: - "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/ast" "1.12.1" "@xtuc/long" "4.2.2" "@webpack-cli/configtest@^2.1.1": @@ -5265,10 +5302,10 @@ accepts@~1.3.4, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -acorn-import-assertions@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" - integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== +acorn-import-attributes@^1.9.5: + version "1.9.5" + resolved "https://registry.yarnpkg.com/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz#7eb1557b1ba05ef18b5ed0ec67591bfab04688ef" + integrity sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ== acorn-jsx@^5.3.2: version "5.3.2" @@ -6110,17 +6147,7 @@ browserify-zlib@^0.2.0: dependencies: pako "~1.0.5" -browserslist@^4.14.5, browserslist@^4.21.9, browserslist@^4.22.1: - version "4.22.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.1.tgz#ba91958d1a59b87dab6fed8dfbcb3da5e2e9c619" - integrity sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ== - dependencies: - caniuse-lite "^1.0.30001541" - electron-to-chromium "^1.4.535" - node-releases "^2.0.13" - update-browserslist-db "^1.0.13" - -browserslist@^4.23.3: +browserslist@^4.21.10, browserslist@^4.23.3: version "4.24.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.0.tgz#a1325fe4bc80b64fda169629fc01b3d6cecd38d4" integrity sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A== @@ -6130,6 +6157,16 @@ browserslist@^4.23.3: node-releases "^2.0.18" update-browserslist-db "^1.1.0" +browserslist@^4.21.9, browserslist@^4.22.1: + version "4.22.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.1.tgz#ba91958d1a59b87dab6fed8dfbcb3da5e2e9c619" + integrity sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ== + dependencies: + caniuse-lite "^1.0.30001541" + electron-to-chromium "^1.4.535" + node-releases "^2.0.13" + update-browserslist-db "^1.0.13" + bs-logger@0.x: version "0.2.6" resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" @@ -7579,10 +7616,10 @@ dom-walk@^0.1.0: resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== -domain-browser@^4.22.0: - version "4.23.0" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-4.23.0.tgz#427ebb91efcb070f05cffdfb8a4e9a6c25f8c94b" - integrity sha512-ArzcM/II1wCCujdCNyQjXrAFwS4mrLh4C7DZWlaI8mdh7h3BfKdNd3bKXITfl2PT9FtfQqaGvhi1vPRQPimjGA== +domain-browser@^5.7.0: + version "5.7.0" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-5.7.0.tgz#81b942459672e3c7ed8f721fe31135a5628f31cf" + integrity sha512-edTFu0M/7wO1pXY6GDxVNVW086uqwWYIHP98txhcPyV995X21JIH2DtYp33sQJOupYoXKe9RwTw2Ya2vWaquTQ== domelementtype@^2.3.0: version "2.3.0" @@ -7752,6 +7789,14 @@ enhanced-resolve@^5.0.0, enhanced-resolve@^5.15.0: graceful-fs "^4.2.4" tapable "^2.2.0" +enhanced-resolve@^5.17.1: + version "5.17.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15" + integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + enquirer@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" @@ -9085,6 +9130,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + fsevents@^2.3.2, fsevents@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" @@ -9522,7 +9572,7 @@ graceful-fs@4.2.10: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.10, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.10, graceful-fs@^4.2.11, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -12527,10 +12577,10 @@ node-int64@^0.4.0: resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== -node-polyfill-webpack-plugin@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/node-polyfill-webpack-plugin/-/node-polyfill-webpack-plugin-3.0.0.tgz#296b8235d081af368cd413f4c77e68c98919d99c" - integrity sha512-QpG496dDBiaelQZu9wDcVvpLbtk7h9Ctz693RaUMZBgl8DUoFToO90ZTLKq57gP7rwKqYtGbMBXkcEgLSag2jQ== +node-polyfill-webpack-plugin@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/node-polyfill-webpack-plugin/-/node-polyfill-webpack-plugin-4.0.0.tgz#99c4e4a0b41073b65aa8c584b0d195798aed2c76" + integrity sha512-WLk77vLpbcpmTekRj6s6vYxk30XoyaY5MDZ4+9g8OaKoG3Ij+TjOqhpQjVUlfDZBPBgpNATDltaQkzuXSnnkwg== dependencies: assert "^2.1.0" browserify-zlib "^0.2.0" @@ -12538,21 +12588,21 @@ node-polyfill-webpack-plugin@^3.0.0: console-browserify "^1.2.0" constants-browserify "^1.0.0" crypto-browserify "^3.12.0" - domain-browser "^4.22.0" + domain-browser "^5.7.0" events "^3.3.0" https-browserify "^1.0.0" os-browserify "^0.3.0" path-browserify "^1.0.1" process "^0.11.10" - punycode "^2.3.0" + punycode "^2.3.1" querystring-es3 "^0.2.1" - readable-stream "^4.4.2" + readable-stream "^4.5.2" stream-browserify "^3.0.0" stream-http "^3.2.0" string_decoder "^1.3.0" timers-browserify "^2.0.12" tty-browserify "^0.0.1" - type-fest "^4.4.0" + type-fest "^4.18.2" url "^0.11.3" util "^0.12.5" vm-browserify "^1.1.2" @@ -13633,6 +13683,20 @@ pkg-types@^1.0.3, pkg-types@^1.2.0: mlly "^1.7.2" pathe "^1.1.2" +playwright-core@1.48.0: + version "1.48.0" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.48.0.tgz#34d209dd4aba8fccd4a96116f1c4f7630f868722" + integrity sha512-RBvzjM9rdpP7UUFrQzRwR8L/xR4HyC1QXMzGYTbf1vjw25/ya9NRAVnXi/0fvFopjebvyPzsmoK58xxeEOaVvA== + +playwright@1.48.0: + version "1.48.0" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.48.0.tgz#00855d9a25f1991d422867f1c32af5d90f457b48" + integrity sha512-qPqFaMEHuY/ug8o0uteYJSRfMGFikhUysk8ZvAtfKmUK3kc/6oNl/y3EczF8OFGYIi/Ex2HspMfzYArk6+XQSA== + dependencies: + playwright-core "1.48.0" + optionalDependencies: + fsevents "2.3.2" + please-upgrade-node@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942" @@ -13865,7 +13929,7 @@ punycode@^1.4.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== -punycode@^2.1.0, punycode@^2.1.1, punycode@^2.3.0: +punycode@^2.1.0, punycode@^2.1.1, punycode@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== @@ -15893,21 +15957,21 @@ tempy@1.0.0: type-fest "^0.16.0" unique-string "^2.0.0" -terser-webpack-plugin@^5.3.7: - version "5.3.9" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz#832536999c51b46d468067f9e37662a3b96adfe1" - integrity sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA== +terser-webpack-plugin@^5.3.10: + version "5.3.10" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz#904f4c9193c6fd2a03f693a2150c62a92f40d199" + integrity sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w== dependencies: - "@jridgewell/trace-mapping" "^0.3.17" + "@jridgewell/trace-mapping" "^0.3.20" jest-worker "^27.4.5" schema-utils "^3.1.1" serialize-javascript "^6.0.1" - terser "^5.16.8" + terser "^5.26.0" -terser@^5.16.8: - version "5.24.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.24.0.tgz#4ae50302977bca4831ccc7b4fef63a3c04228364" - integrity sha512-ZpGR4Hy3+wBEzVEnHvstMvqpD/nABNelQn/z2r0fjVWGQsN3bpOLzQlqDxmb4CDZnXq5lpjnQ+mHQLAOpfM5iw== +terser@^5.26.0: + version "5.34.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.34.1.tgz#af40386bdbe54af0d063e0670afd55c3105abeb6" + integrity sha512-FsJZ7iZLd/BXkz+4xrRTGJ26o/6VTjQytUk8b8OxkwcD2I+79VPJlz7qss1+zE7h8GNIScFqXcDyJ/KqBYZFVA== dependencies: "@jridgewell/source-map" "^0.3.3" acorn "^8.8.2" @@ -16249,10 +16313,10 @@ type-fest@^2.13.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz#88068015bb33036a598b952e55e9311a60fd3a9b" integrity sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA== -type-fest@^4.4.0: - version "4.8.3" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.8.3.tgz#6db08d9f44d596cd953f83020c7c56310c368d1c" - integrity sha512-//BaTm14Q/gHBn09xlnKNqfI8t6bmdzx2DXYfPBNofN0WUybCEUDcbCWcTa0oF09lzLjZgPphXAsvRiMK0V6Bw== +type-fest@^4.18.2: + version "4.26.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.26.1.tgz#a4a17fa314f976dd3e6d6675ef6c775c16d7955e" + integrity sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg== type-is@~1.6.18: version "1.6.18" @@ -16783,10 +16847,10 @@ walker@^1.0.8: dependencies: makeerror "1.0.12" -watchpack@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" - integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== +watchpack@^2.4.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.2.tgz#2feeaed67412e7c33184e5a79ca738fbd38564da" + integrity sha512-TnbFSbcOCcDgjZ4piURLCbJ3nJhznVh9kw6F6iokjiFPl8ONxe9A6nMDVXDiNbrSfLILs6vB07F7wLBrwPYzJw== dependencies: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" @@ -16808,7 +16872,7 @@ webidl-conversions@^3.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== -webpack-cli@^5.0.0: +webpack-cli@^5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" integrity sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg== @@ -16848,34 +16912,33 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@^5.75.0: - version "5.89.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.89.0.tgz#56b8bf9a34356e93a6625770006490bf3a7f32dc" - integrity sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw== +webpack@^5.88.2: + version "5.95.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.95.0.tgz#8fd8c454fa60dad186fbe36c400a55848307b4c0" + integrity sha512-2t3XstrKULz41MNMBF+cJ97TyHdyQ8HCt//pqErqDvNjU9YQBnZxIHa11VXsi7F3mb5/aO2tuDxdeTPdU7xu9Q== dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^1.0.0" - "@webassemblyjs/ast" "^1.11.5" - "@webassemblyjs/wasm-edit" "^1.11.5" - "@webassemblyjs/wasm-parser" "^1.11.5" + "@types/estree" "^1.0.5" + "@webassemblyjs/ast" "^1.12.1" + "@webassemblyjs/wasm-edit" "^1.12.1" + "@webassemblyjs/wasm-parser" "^1.12.1" acorn "^8.7.1" - acorn-import-assertions "^1.9.0" - browserslist "^4.14.5" + acorn-import-attributes "^1.9.5" + browserslist "^4.21.10" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.15.0" + enhanced-resolve "^5.17.1" es-module-lexer "^1.2.1" eslint-scope "5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" - graceful-fs "^4.2.9" + graceful-fs "^4.2.11" json-parse-even-better-errors "^2.3.1" loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" schema-utils "^3.2.0" tapable "^2.1.1" - terser-webpack-plugin "^5.3.7" - watchpack "^2.4.0" + terser-webpack-plugin "^5.3.10" + watchpack "^2.4.1" webpack-sources "^3.2.3" websocket-polyfill@^0.0.3: