From 5a70d2bbd8bbc89b0106d6f7c1ba9f8980f6a8bd Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 15:44:02 +0100 Subject: [PATCH 1/9] feat: type declarations in core package --- .changeset/beige-ladybugs-pay.md | 5 + .changeset/flat-baboons-happen.md | 5 + .changeset/fuzzy-meals-check.md | 7 + .changeset/heavy-planes-grin.md | 5 + .changeset/tricky-apes-appear.md | 6 + .eslintrc.json | 5 +- .gitignore | 1 + package-lock.json | 849 +++++++----------- package.json | 10 +- packages/core/.npmignore | 2 + packages/core/index.js | 11 - packages/core/index.ts | 36 + .../core/lib/{Pipeline.js => Pipeline.ts} | 69 +- .../{PipelineError.js => PipelineError.ts} | 2 +- packages/core/lib/{Step.js => Step.ts} | 33 +- packages/core/lib/StreamObject.js | 27 - packages/core/lib/StreamObject.ts | 54 ++ .../lib/{VariableMap.js => VariableMap.ts} | 15 +- packages/core/lib/cloneTerm.js | 21 - packages/core/lib/cloneTerm.ts | 24 + ...erRegistry.js => defaultLoaderRegistry.ts} | 5 +- .../{defaultLogger.js => defaultLogger.ts} | 15 +- .../factory/{arguments.js => arguments.ts} | 10 +- packages/core/lib/factory/operation.js | 13 - packages/core/lib/factory/operation.ts | 27 + .../lib/factory/{pipeline.js => pipeline.ts} | 75 +- .../core/lib/factory/{step.js => step.ts} | 9 +- packages/core/lib/factory/stream.js | 35 - packages/core/lib/factory/stream.ts | 48 + packages/core/lib/factory/variables.js | 23 - packages/core/lib/factory/variables.ts | 33 + packages/core/lib/isStream.js | 17 - packages/core/lib/isStream.ts | 18 + packages/core/lib/loader/{file.js => file.ts} | 8 +- packages/core/lib/loader/pipeline.js | 15 - packages/core/lib/loader/pipeline.ts | 26 + .../lib/loader/{variable.js => variable.ts} | 12 +- .../core/lib/{metadata.js => metadata.ts} | 5 +- .../core/lib/{nextLoop.js => nextLoop.ts} | 0 packages/core/lib/{run.js => run.ts} | 11 +- packages/core/lib/{tracer.js => tracer.ts} | 0 packages/core/lib/{utils.js => utils.ts} | 0 packages/core/package.json | 13 +- packages/core/tsconfig.json | 4 + packages/env/.npmignore | 1 + packages/env/index.js | 5 - packages/env/index.ts | 8 + packages/env/lib/Constants.js | 5 - packages/env/lib/Constants.ts | 11 + packages/env/lib/Namespaces.js | 12 - packages/env/lib/Namespaces.ts | 26 + packages/env/package.json | 6 +- packages/env/tsconfig.json | 4 + packages/validation/package.json | 2 +- test/e2e/package.json | 2 +- tsconfig.json | 16 + 56 files changed, 927 insertions(+), 780 deletions(-) create mode 100644 .changeset/beige-ladybugs-pay.md create mode 100644 .changeset/flat-baboons-happen.md create mode 100644 .changeset/fuzzy-meals-check.md create mode 100644 .changeset/heavy-planes-grin.md create mode 100644 .changeset/tricky-apes-appear.md create mode 100644 packages/core/.npmignore delete mode 100644 packages/core/index.js create mode 100644 packages/core/index.ts rename packages/core/lib/{Pipeline.js => Pipeline.ts} (63%) rename packages/core/lib/{PipelineError.js => PipelineError.ts} (77%) rename packages/core/lib/{Step.js => Step.ts} (55%) delete mode 100644 packages/core/lib/StreamObject.js create mode 100644 packages/core/lib/StreamObject.ts rename packages/core/lib/{VariableMap.js => VariableMap.ts} (61%) delete mode 100644 packages/core/lib/cloneTerm.js create mode 100644 packages/core/lib/cloneTerm.ts rename packages/core/lib/{defaultLoaderRegistry.js => defaultLoaderRegistry.ts} (84%) rename packages/core/lib/{defaultLogger.js => defaultLogger.ts} (72%) rename packages/core/lib/factory/{arguments.js => arguments.ts} (51%) delete mode 100644 packages/core/lib/factory/operation.js create mode 100644 packages/core/lib/factory/operation.ts rename packages/core/lib/factory/{pipeline.js => pipeline.ts} (51%) rename packages/core/lib/factory/{step.js => step.ts} (70%) delete mode 100644 packages/core/lib/factory/stream.js create mode 100644 packages/core/lib/factory/stream.ts delete mode 100644 packages/core/lib/factory/variables.js create mode 100644 packages/core/lib/factory/variables.ts delete mode 100644 packages/core/lib/isStream.js create mode 100644 packages/core/lib/isStream.ts rename packages/core/lib/loader/{file.js => file.ts} (51%) delete mode 100644 packages/core/lib/loader/pipeline.js create mode 100644 packages/core/lib/loader/pipeline.ts rename packages/core/lib/loader/{variable.js => variable.ts} (71%) rename packages/core/lib/{metadata.js => metadata.ts} (76%) rename packages/core/lib/{nextLoop.js => nextLoop.ts} (100%) rename packages/core/lib/{run.js => run.ts} (67%) rename packages/core/lib/{tracer.js => tracer.ts} (100%) rename packages/core/lib/{utils.js => utils.ts} (100%) create mode 100644 packages/core/tsconfig.json create mode 100644 packages/env/.npmignore delete mode 100644 packages/env/index.js create mode 100644 packages/env/index.ts delete mode 100644 packages/env/lib/Constants.js create mode 100644 packages/env/lib/Constants.ts delete mode 100644 packages/env/lib/Namespaces.js create mode 100644 packages/env/lib/Namespaces.ts create mode 100644 packages/env/tsconfig.json create mode 100644 tsconfig.json diff --git a/.changeset/beige-ladybugs-pay.md b/.changeset/beige-ladybugs-pay.md new file mode 100644 index 00000000..e5754e0f --- /dev/null +++ b/.changeset/beige-ladybugs-pay.md @@ -0,0 +1,5 @@ +--- +"barnard59-env": minor +--- + +Added type namespace builders of Zazuko vocabularies diff --git a/.changeset/flat-baboons-happen.md b/.changeset/flat-baboons-happen.md new file mode 100644 index 00000000..b7335783 --- /dev/null +++ b/.changeset/flat-baboons-happen.md @@ -0,0 +1,5 @@ +--- +"barnard59-core": patch +--- + +Updated `rdf-loaders-registry` diff --git a/.changeset/fuzzy-meals-check.md b/.changeset/fuzzy-meals-check.md new file mode 100644 index 00000000..e002c2ce --- /dev/null +++ b/.changeset/fuzzy-meals-check.md @@ -0,0 +1,7 @@ +--- +"barnard59-validation": patch +"barnard59-core": patch +"barnard59-test-e2e": patch +--- + +Updated `rdf-loader-code` diff --git a/.changeset/heavy-planes-grin.md b/.changeset/heavy-planes-grin.md new file mode 100644 index 00000000..7b6615b3 --- /dev/null +++ b/.changeset/heavy-planes-grin.md @@ -0,0 +1,5 @@ +--- +"barnard59-core": patch +--- + +Replace `lodash/once` with `onetime` diff --git a/.changeset/tricky-apes-appear.md b/.changeset/tricky-apes-appear.md new file mode 100644 index 00000000..83e23d00 --- /dev/null +++ b/.changeset/tricky-apes-appear.md @@ -0,0 +1,6 @@ +--- +"barnard59-core": minor +"barnard59-env": minor +--- + +Bundle type declarations (source migrated to TypeScript) diff --git a/.eslintrc.json b/.eslintrc.json index 84c57f37..1246cb7e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,8 @@ { - "extends": [ "@tpluscode/eslint-config/js" ], + "extends": [ "@tpluscode" ], + "parserOptions": { + "project": "./tsconfig.json" + }, "env": { "mocha": true }, diff --git a/.gitignore b/.gitignore index 14daba84..afe1f1d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ coverage node_modules *.tgz +*.d.ts diff --git a/package-lock.json b/package-lock.json index 7b943840..1761403a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,12 +14,18 @@ "devDependencies": { "@changesets/cli": "^2.26.1", "@tpluscode/eslint-config": "^0.4.3", + "@types/node": "^18", + "@typescript-eslint/eslint-plugin": "^6.13.2", + "@typescript-eslint/parser": "^6.13.2", "c8": "^7.6.0", "chai": "^4.3.10", + "eslint-import-resolver-typescript": "^3.6.1", "husky": "^8.0.3", "lint-staged": "^13.2.2", "mocha": "^10.2.0", "sinon-chai": "^3.7.0", + "ts-node": "^10.9.1", + "typescript": "^5.3.2", "wsrun": "^5.2.4" }, "engines": { @@ -1496,6 +1502,28 @@ "node": ">=0.1.90" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@dabh/diagnostics": { "version": "2.0.3", "license": "MIT", @@ -4228,6 +4256,12 @@ "fs-extra": "^8.1.0" } }, + "node_modules/@manypkg/find-root/node_modules/@types/node": { + "version": "12.20.55", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", + "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==", + "dev": true + }, "node_modules/@manypkg/find-root/node_modules/fs-extra": { "version": "8.1.0", "dev": true, @@ -4627,26 +4661,6 @@ "node": ">=14" } }, - "node_modules/@pkgr/utils": { - "version": "2.4.1", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "fast-glob": "^3.2.12", - "is-glob": "^4.0.3", - "open": "^9.1.0", - "picocolors": "^1.0.0", - "tslib": "^2.5.0" - }, - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/@rdfjs/data-model": { "version": "2.0.1", "license": "MIT", @@ -5795,14 +5809,15 @@ } }, "node_modules/@tpluscode/rdf-ns-builders": { - "version": "4.1.0", - "license": "MIT", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tpluscode/rdf-ns-builders/-/rdf-ns-builders-4.3.0.tgz", + "integrity": "sha512-x3uh9mYwAU+PrALaDKhVjml1TCCWWduo6J8rybd9SMEEAoooXq1MYb13MRputjRT/kYaFyCND7LMobzhxZ/+bg==", "dependencies": { "@rdfjs/data-model": "^2", "@rdfjs/namespace": "^2", "@rdfjs/types": "*", "@types/rdfjs__namespace": "^2.0.2", - "@zazuko/prefixes": "^2.0.0" + "@zazuko/prefixes": "^2.0.1" } }, "node_modules/@tpluscode/rdf-string": { @@ -5816,6 +5831,30 @@ "@zazuko/prefixes": ">=1" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/babel__core": { "version": "7.20.1", "dev": true, @@ -5906,10 +5945,10 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.12", - "dev": true, - "license": "MIT", - "optional": true + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true }, "node_modules/@types/json5": { "version": "0.0.29", @@ -5934,8 +5973,12 @@ "dev": true }, "node_modules/@types/node": { - "version": "12.20.55", - "license": "MIT" + "version": "18.19.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.2.tgz", + "integrity": "sha512-6wzfBdbWpe8QykUkXBjtmO3zITA0A3FIjoy+in0Y2K4KrCiRhNYJIdwAPDffZ3G6GnaKaSLSEa9ZuORLfEoiwg==", + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", @@ -5989,6 +6032,17 @@ "@types/rdfjs__term-set": "*" } }, + "node_modules/@types/rdfjs__fetch-lite": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/rdfjs__fetch-lite/-/rdfjs__fetch-lite-3.0.7.tgz", + "integrity": "sha512-xqxtNe01Z3kkzXQMbb8IhqzyMbP073sTFkegjlABOyTIwHQtAM5lgQiAunrtGpAnLdsD1Qp2qunxvB+WssFl2A==", + "peer": true, + "dependencies": { + "@rdfjs/types": "*", + "@types/node": "*", + "@types/rdfjs__formats-common": "*" + } + }, "node_modules/@types/rdfjs__formats-common": { "version": "3.1.0", "license": "MIT", @@ -6155,32 +6209,33 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.2.tgz", + "integrity": "sha512-3+9OGAWHhk4O1LlcwLBONbdXsAhLjyCFogJY/cWy2lxdVJ2JrcTF2pTGMaLl2AE7U1l31n8Py4a8bx5DLf/0dQ==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.11", - "@typescript-eslint/type-utils": "5.59.11", - "@typescript-eslint/utils": "5.59.11", + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.13.2", + "@typescript-eslint/type-utils": "6.13.2", + "@typescript-eslint/utils": "6.13.2", + "@typescript-eslint/visitor-keys": "6.13.2", "debug": "^4.3.4", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -6192,7 +6247,6 @@ "version": "7.5.4", "dev": true, "license": "ISC", - "optional": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -6204,25 +6258,26 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.13.2.tgz", + "integrity": "sha512-MUkcC+7Wt/QOGeVlM8aGGJZy1XV5YKjTpq9jK6r6/iLsGXhBVaGP5N0UYvFsu9BFlSpwY9kMretzdBH01rkRXg==", "dev": true, - "license": "BSD-2-Clause", - "optional": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.59.11", - "@typescript-eslint/types": "5.59.11", - "@typescript-eslint/typescript-estree": "5.59.11", + "@typescript-eslint/scope-manager": "6.13.2", + "@typescript-eslint/types": "6.13.2", + "@typescript-eslint/typescript-estree": "6.13.2", + "@typescript-eslint/visitor-keys": "6.13.2", "debug": "^4.3.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -6231,16 +6286,16 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.13.2.tgz", + "integrity": "sha512-CXQA0xo7z6x13FeDYCgBkjWzNqzBn8RXaE3QVQVIUm74fWJLkJkaHmHdKStrxQllGh6Q4eUGyNpMe0b1hMkXFA==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "@typescript-eslint/types": "5.59.11", - "@typescript-eslint/visitor-keys": "5.59.11" + "@typescript-eslint/types": "6.13.2", + "@typescript-eslint/visitor-keys": "6.13.2" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -6248,25 +6303,25 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.13.2.tgz", + "integrity": "sha512-Qr6ssS1GFongzH2qfnWKkAQmMUyZSyOr0W54nZNU1MDfo+U4Mv3XveeLZzadc/yq8iYhQZHYT+eoXJqnACM1tw==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.11", - "@typescript-eslint/utils": "5.59.11", + "@typescript-eslint/typescript-estree": "6.13.2", + "@typescript-eslint/utils": "6.13.2", "debug": "^4.3.4", - "tsutils": "^3.21.0" + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "*" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -6275,12 +6330,12 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.13.2.tgz", + "integrity": "sha512-7sxbQ+EMRubQc3wTfTsycgYpSujyVbI1xw+3UMRUcrhSy+pN09y/lWzeKDbvhoqcRbHdc+APLs/PWYi/cisLPg==", "dev": true, - "license": "MIT", - "optional": true, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -6288,21 +6343,21 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.2.tgz", + "integrity": "sha512-SuD8YLQv6WHnOEtKv8D6HZUzOub855cfPnPMKvdM/Bh1plv1f7Q/0iFUDLKKlxHcEstQnaUU4QZskgQq74t+3w==", "dev": true, - "license": "BSD-2-Clause", - "optional": true, "dependencies": { - "@typescript-eslint/types": "5.59.11", - "@typescript-eslint/visitor-keys": "5.59.11", + "@typescript-eslint/types": "6.13.2", + "@typescript-eslint/visitor-keys": "6.13.2", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -6316,9 +6371,9 @@ }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, - "license": "ISC", - "optional": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -6330,42 +6385,41 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.13.2.tgz", + "integrity": "sha512-b9Ptq4eAZUym4idijCRzl61oPCwwREcfDI8xGk751Vhzig5fFZR9CyzDz4Sp/nxSLBYxUPyh4QdIDqWykFhNmQ==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.11", - "@typescript-eslint/types": "5.59.11", - "@typescript-eslint/typescript-estree": "5.59.11", - "eslint-scope": "^5.1.1", - "semver": "^7.3.7" + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.13.2", + "@typescript-eslint/types": "6.13.2", + "@typescript-eslint/typescript-estree": "6.13.2", + "semver": "^7.5.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" } }, "node_modules/@typescript-eslint/utils/node_modules/@types/semver": { - "version": "7.5.0", - "dev": true, - "license": "MIT", - "optional": true + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", + "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "dev": true }, "node_modules/@typescript-eslint/utils/node_modules/semver": { "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, - "license": "ISC", - "optional": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -6377,16 +6431,16 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.11", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.2.tgz", + "integrity": "sha512-OGznFs0eAQXJsp+xSd6k/O1UbFi/K/L7WjqeRoFE7vadjAF9y0uppXhYNQNEqygjou782maGClOoZwPqF0Drlw==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "@typescript-eslint/types": "5.59.11", - "eslint-visitor-keys": "^3.3.0" + "@typescript-eslint/types": "6.13.2", + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -6404,9 +6458,9 @@ "integrity": "sha512-1hXJe79ipXJbo/ywVGdefEcHPutedK2ilZv9G6op71wTibeUlCe1ik9OvnSeyH42RfLHqDs2vLvK3zH50RZS+w==" }, "node_modules/@zazuko/env": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@zazuko/env/-/env-1.10.1.tgz", - "integrity": "sha512-+2O/hJVBQbwhDaB0+5XHevSsVAjLQEx/Au5eE4WhS9BIDBg1kG+F3UpGjFyHnWrzL7luFdysA32g+lzgEmXz7w==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@zazuko/env/-/env-1.11.0.tgz", + "integrity": "sha512-NztltXvbai2IWx9Sf91/PNi7Gdac2imIJ3ygUtQTUG9nnwaJcujFFIZTnRUwUYo9OqGzZG2UCxi7mwZtcKIeag==", "dependencies": { "@rdfjs/dataset": "^2.0.1", "@rdfjs/environment": "^0.1.2", @@ -6426,9 +6480,9 @@ } }, "node_modules/@zazuko/env-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@zazuko/env-node/-/env-node-1.0.0.tgz", - "integrity": "sha512-FDwIbWbyWOEw4vHd4vbyXCEpRsRXQ497V0K3swh6StO1R06cTyqW0z4vbNJsHRBkMYQLS7xfDlzWSUrHa+owsw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@zazuko/env-node/-/env-node-1.0.3.tgz", + "integrity": "sha512-VI5vxzqRAFcwiTKtgn8D+6sx2rm7ow9kLTlOr/xMZXn5iD7HtNnJYrsI9mZYEcu3iqt8anq7rWZFulMmikgPRg==", "dependencies": { "@rdfjs/dataset": "^2.0.1", "@rdfjs/environment": "^0.1.2", @@ -6436,9 +6490,12 @@ "@rdfjs/formats-common": "^3.1.0", "@rdfjs/traverser": "^0.1.2", "@tpluscode/rdf-ns-builders": "^4.1.0", - "@zazuko/env": "^1.9.0", - "@zazuko/rdf-utils-fs": "^3.0.2", + "@zazuko/env": "^1.11.0", + "@zazuko/rdf-utils-fs": "^3.2.0", "clownface": "^2.0.1" + }, + "peerDependencies": { + "@types/rdfjs__fetch-lite": "^3.0.6" } }, "node_modules/@zazuko/env-node/node_modules/@rdfjs/formats-common": { @@ -6511,9 +6568,9 @@ "integrity": "sha512-dm0/YBNzuwJUm8cXoF3Dn9DfQetnRDaOJ8NdlgLY645OaUddCzUAAYcanm+xZmEo1SWX+/Tp3jbScwCaN2b/aQ==" }, "node_modules/@zazuko/rdf-utils-fs": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@zazuko/rdf-utils-fs/-/rdf-utils-fs-3.0.2.tgz", - "integrity": "sha512-27okMMO6qlNqBScdM4r4oorZZvGirT1O7yf29pdyCEF86PkztTfLbIQt/s82nVHQXsyIpLPbkGBoSEaFi9cWfg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@zazuko/rdf-utils-fs/-/rdf-utils-fs-3.2.0.tgz", + "integrity": "sha512-SqRddafcPHAc3YL4p5awMrKhYg/UTV3+Q0LFGvmp6IlOXrIOu1NuYfmxUrb4EBxVB1ri8/IOXWxY4+XeGw5QKg==", "dependencies": { "readable-stream": ">=3.6.0" }, @@ -6522,6 +6579,17 @@ "@types/rdfjs__environment": "^0.1.8" } }, + "node_modules/@zazuko/vocabulary-extras-builders": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@zazuko/vocabulary-extras-builders/-/vocabulary-extras-builders-1.1.0.tgz", + "integrity": "sha512-VMiLl2KHz/lwmMIFELensBKSxtbzfjmpqefvSmbkp0Ko1abTXf9HTLklPnLc0KXGRo1wKujDW9js2r7srGfL6A==", + "dependencies": { + "@rdfjs/namespace": "^2.0.0" + }, + "peerDependencies": { + "@rdfjs/types": ">=1" + } + }, "node_modules/abab": { "version": "2.0.6", "dev": true, @@ -8136,6 +8204,12 @@ "node": ">=12" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "dev": true, @@ -8874,15 +8948,6 @@ "node": ">=4" } }, - "node_modules/big-integer": { - "version": "1.6.51", - "dev": true, - "license": "Unlicense", - "optional": true, - "engines": { - "node": ">=0.6" - } - }, "node_modules/bignumber.js": { "version": "9.1.1", "license": "MIT", @@ -8943,18 +9008,6 @@ "version": "2.11.0", "license": "MIT" }, - "node_modules/bplist-parser": { - "version": "0.2.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "big-integer": "^1.6.44" - }, - "engines": { - "node": ">= 5.10.0" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "license": "MIT", @@ -9099,21 +9152,6 @@ "node": ">=10" } }, - "node_modules/bundle-name": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "run-applescript": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/bunyan": { "version": "1.8.15", "dev": true, @@ -10737,6 +10775,12 @@ "node": ">=8" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-fetch": { "version": "3.1.6", "license": "MIT", @@ -11000,40 +11044,6 @@ "node": ">=0.10.0" } }, - "node_modules/default-browser": { - "version": "4.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "bundle-name": "^3.0.0", - "default-browser-id": "^3.0.0", - "execa": "^7.1.1", - "titleize": "^3.0.0" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/default-browser-id": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "bplist-parser": "^0.2.0", - "untildify": "^4.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/defaults": { "version": "1.0.4", "dev": true, @@ -11045,18 +11055,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/define-lazy-prop": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/define-properties": { "version": "1.2.0", "dev": true, @@ -11269,7 +11267,6 @@ "version": "5.15.0", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -11583,19 +11580,18 @@ } }, "node_modules/eslint-import-resolver-typescript": { - "version": "3.5.5", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.1.tgz", + "integrity": "sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg==", "dev": true, - "license": "ISC", - "optional": true, "dependencies": { "debug": "^4.3.4", "enhanced-resolve": "^5.12.0", "eslint-module-utils": "^2.7.4", + "fast-glob": "^3.3.1", "get-tsconfig": "^4.5.0", - "globby": "^13.1.3", "is-core-module": "^2.11.0", - "is-glob": "^4.0.3", - "synckit": "^0.8.5" + "is-glob": "^4.0.3" }, "engines": { "node": "^14.18.0 || >=16.0.0" @@ -11608,37 +11604,6 @@ "eslint-plugin-import": "*" } }, - "node_modules/eslint-import-resolver-typescript/node_modules/globby": { - "version": "13.1.4", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.11", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint-import-resolver-typescript/node_modules/slash": { - "version": "4.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint-module-utils": { "version": "2.8.0", "dev": true, @@ -11929,19 +11894,6 @@ "eslint": "*" } }, - "node_modules/eslint-scope": { - "version": "5.1.1", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/eslint-utils": { "version": "2.1.0", "dev": true, @@ -12225,6 +12177,7 @@ "version": "4.3.0", "dev": true, "license": "BSD-2-Clause", + "peer": true, "dependencies": { "estraverse": "^5.2.0" }, @@ -12236,15 +12189,7 @@ "version": "5.3.0", "dev": true, "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "4.3.0", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, + "peer": true, "engines": { "node": ">=4.0" } @@ -12659,9 +12604,10 @@ "peer": true }, "node_modules/fast-glob": { - "version": "3.2.12", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -13503,7 +13449,6 @@ "version": "4.6.0", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "resolve-pkg-maps": "^1.0.0" }, @@ -13621,8 +13566,7 @@ "node_modules/graphemer": { "version": "1.4.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/growl": { "version": "1.10.5", @@ -14195,23 +14139,8 @@ "node": ">=0.10.0" } }, - "node_modules/is-docker": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-extendable": { - "version": "1.0.1", + "node_modules/is-extendable": { + "version": "1.0.1", "dev": true, "license": "MIT", "dependencies": { @@ -14266,24 +14195,6 @@ "@types/clownface": "^2.0.0" } }, - "node_modules/is-inside-container": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "is-docker": "^3.0.0" - }, - "bin": { - "is-inside-container": "cli.js" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-map": { "version": "2.0.2", "dev": true, @@ -19535,10 +19446,6 @@ "jsonld-context-parse": "bin/jsonld-context-parse.js" } }, - "node_modules/jsonld-context-parser/node_modules/@types/node": { - "version": "18.16.18", - "license": "MIT" - }, "node_modules/jsonld-streaming-parser": { "version": "3.2.0", "license": "MIT", @@ -20977,12 +20884,6 @@ "dev": true, "license": "MIT" }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "dev": true, - "license": "MIT", - "optional": true - }, "node_modules/ncp": { "version": "2.0.0", "dev": true, @@ -21473,24 +21374,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/open": { - "version": "9.1.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "default-browser": "^4.0.0", - "define-lazy-prop": "^3.0.0", - "is-inside-container": "^1.0.0", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/optionator": { "version": "0.9.1", "dev": true, @@ -22264,30 +22147,23 @@ } }, "node_modules/rdf-loader-code": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/rdf-loader-code/-/rdf-loader-code-2.0.0.tgz", - "integrity": "sha512-dzKcal+rjSmcNeE64lhOn4yyTFwGJdP+XQhFAlfmqltFCWwR4tLec58Rjbz1P0kwogwBTCNDl7Vm8c8tYLyOKg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/rdf-loader-code/-/rdf-loader-code-2.1.1.tgz", + "integrity": "sha512-JR49VuWX5VHQv7a/ZUOsUHs85IuI7dBotWuI0Obtu8vauSQkTwl5E7fhyz6aFq0j6DVTNIt5N76meUrmZwxybw==", "dependencies": { "@rdfjs/namespace": "^2.0.0", "clownface": "^2.0.0", + "is-graph-pointer": "^2.1.0", "rdf-literal": "^1.3.1" } }, "node_modules/rdf-loaders-registry": { - "version": "0.3.0", - "license": "MIT", - "dependencies": { - "@rdfjs/data-model": "^1.1.2" - } - }, - "node_modules/rdf-loaders-registry/node_modules/@rdfjs/data-model": { - "version": "1.3.4", - "license": "MIT", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rdf-loaders-registry/-/rdf-loaders-registry-1.0.1.tgz", + "integrity": "sha512-tmFG53SDk1y7o0oLk5LhWyyijKFI5mxS08D+kir8XNTXl5dKwUY55UcvD1au4P4ClMtj00U7sNOqghYlccJwsA==", "dependencies": { - "@rdfjs/types": ">=1.0.1" - }, - "bin": { - "rdfjs-data-model-test": "bin/test.js" + "@rdfjs/data-model": "^2", + "is-graph-pointer": "^2.1.0" } }, "node_modules/rdf-parser-csvw": { @@ -22722,7 +22598,6 @@ "version": "1.0.0", "dev": true, "license": "MIT", - "optional": true, "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } @@ -22825,110 +22700,6 @@ "node": "6.* || >= 7.*" } }, - "node_modules/run-applescript": { - "version": "5.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "execa": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/run-applescript/node_modules/execa": { - "version": "5.1.1", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/run-applescript/node_modules/human-signals": { - "version": "2.1.0", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "engines": { - "node": ">=10.17.0" - } - }, - "node_modules/run-applescript/node_modules/is-stream": { - "version": "2.0.1", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/run-applescript/node_modules/mimic-fn": { - "version": "2.1.0", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/run-applescript/node_modules/npm-run-path": { - "version": "4.0.1", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/run-applescript/node_modules/onetime": { - "version": "5.1.2", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/run-applescript/node_modules/strip-final-newline": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=6" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "dev": true, @@ -24847,27 +24618,10 @@ "dev": true, "license": "MIT" }, - "node_modules/synckit": { - "version": "0.8.5", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@pkgr/utils": "^2.3.1", - "tslib": "^2.5.0" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/tapable": { "version": "2.2.1", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">=6" } @@ -24961,18 +24715,6 @@ "readable-stream": "3" } }, - "node_modules/titleize": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/tmp": { "version": "0.0.33", "dev": true, @@ -25094,6 +24836,79 @@ "version": "1.2.1", "license": "MIT" }, + "node_modules/ts-api-utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", + "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.1.tgz", + "integrity": "sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tsconfig-paths": { "version": "3.14.2", "dev": true, @@ -25110,27 +24925,6 @@ "version": "2.5.3", "license": "0BSD" }, - "node_modules/tsutils": { - "version": "3.21.0", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "dev": true, - "license": "0BSD", - "optional": true - }, "node_modules/tty-table": { "version": "4.2.1", "dev": true, @@ -25355,10 +25149,10 @@ } }, "node_modules/typescript": { - "version": "5.1.3", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", + "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", "dev": true, - "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -25381,6 +25175,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/union-value": { "version": "1.0.1", "dev": true, @@ -25463,15 +25262,6 @@ "node": ">=0.10.0" } }, - "node_modules/untildify": { - "version": "4.0.0", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=8" - } - }, "node_modules/update-browserslist-db": { "version": "1.0.11", "dev": true, @@ -25556,6 +25346,12 @@ "uuid": "bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/v8-to-istanbul": { "version": "9.1.0", "dev": true, @@ -26311,6 +26107,15 @@ "node": ">=8" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "dev": true, @@ -26716,15 +26521,16 @@ "duplexify": "^4.1.1", "is-graph-pointer": "^2.1.0", "is-stream": "^3.0.0", - "lodash": "^4.17.21", - "rdf-loader-code": "^2.0.0", - "rdf-loaders-registry": "^0.3.0", + "onetime": "^6.0.0", + "rdf-loader-code": "^2.1.1", + "rdf-loaders-registry": "^1.0.1", "readable-stream": "^3.6.0", "untildify": "^5.0.0", "winston": "^3.3.3" }, "devDependencies": { "@rdfjs/namespace": "^2.0.0", + "@types/readable-stream": "^4.0.9", "barnard59-env": "^1.1.0", "barnard59-http": "^2.0.0", "barnard59-test-support": "^0.0.3", @@ -26737,6 +26543,16 @@ "sinon": "^15.0.4" } }, + "packages/core/node_modules/@types/readable-stream": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.9.tgz", + "integrity": "sha512-4cwuvrmNF96M4Nrx0Eep37RwPB1Mth+nCSezsGRv5+PsFyRvDdLd0pil6gVLcWD/bh69INNdwZ98dJwfHpLohA==", + "dev": true, + "dependencies": { + "@types/node": "*", + "safe-buffer": "~5.1.1" + } + }, "packages/core/node_modules/untildify": { "version": "5.0.0", "license": "MIT", @@ -26824,7 +26640,8 @@ "version": "1.1.0", "license": "MIT", "dependencies": { - "@zazuko/env-node": "^1.0.0" + "@zazuko/env-node": "^1.0.3", + "@zazuko/vocabulary-extras-builders": "^1.1.0" } }, "packages/formats": { @@ -27525,7 +27342,7 @@ "barnard59-env": "^1.1.0", "chalk": "^4.1.0", "commander": "^11.0.0", - "rdf-loader-code": "^2.0.0" + "rdf-loader-code": "^2.1.1" }, "bin": { "barnard59-validate": "cli.js" @@ -27613,7 +27430,7 @@ "get-stream": "^6.0.0", "nock": "^13.3.1", "rdf-dataset-ext": "^1.0.1", - "rdf-loader-code": "^2.0.0", + "rdf-loader-code": "^2.1.1", "rdf-utils-fs": "^2.3.0", "readable-stream": "^3", "string-to-stream": "^3.0.1" diff --git a/package.json b/package.json index 2d03f72f..2761c6e0 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,19 @@ "devDependencies": { "@changesets/cli": "^2.26.1", "@tpluscode/eslint-config": "^0.4.3", + "@types/node": "^18", + "@typescript-eslint/eslint-plugin": "^6.13.2", + "@typescript-eslint/parser": "^6.13.2", "c8": "^7.6.0", "chai": "^4.3.10", + "eslint-import-resolver-typescript": "^3.6.1", "husky": "^8.0.3", "lint-staged": "^13.2.2", "mocha": "^10.2.0", - "wsrun": "^5.2.4", - "sinon-chai": "^3.7.0" + "sinon-chai": "^3.7.0", + "ts-node": "^10.9.1", + "typescript": "^5.3.2", + "wsrun": "^5.2.4" }, "lint-staged": { "*.js": [ diff --git a/packages/core/.npmignore b/packages/core/.npmignore new file mode 100644 index 00000000..f0e06b3b --- /dev/null +++ b/packages/core/.npmignore @@ -0,0 +1,2 @@ +*.ts +!*.d.ts diff --git a/packages/core/index.js b/packages/core/index.js deleted file mode 100644 index 2d064873..00000000 --- a/packages/core/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import defaultLoaderRegistry from './lib/defaultLoaderRegistry.js' -import defaultLogger from './lib/defaultLogger.js' -import createPipeline from './lib/factory/pipeline.js' -import run from './lib/run.js' - -export { - createPipeline, - defaultLoaderRegistry, - defaultLogger, - run, -} diff --git a/packages/core/index.ts b/packages/core/index.ts new file mode 100644 index 00000000..7891f4e5 --- /dev/null +++ b/packages/core/index.ts @@ -0,0 +1,36 @@ +import type { Logger } from 'winston' +import type { Environment } from 'barnard59-env' +import type { GraphPointer } from 'clownface' +import defaultLoaderRegistry from './lib/defaultLoaderRegistry.js' +import defaultLogger from './lib/defaultLogger.js' +import createPipeline from './lib/factory/pipeline.js' +import run from './lib/run.js' +import Pipeline, { PipelineOptions } from './lib/Pipeline.js' + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface Variables {} + +type Keys = keyof Variables extends never ? string : keyof Variables; + +interface TypedMap extends Map { + get(key: K): Variables[typeof key] + set(key: K, value: Variables[typeof key] | undefined): this +} + +export type VariableMap = (keyof Variables extends never ? Map : TypedMap) + +export interface Context { + env: Environment + logger: Logger + variables: VariableMap + basePath: string + createPipeline(ptr: GraphPointer, arg?: Partial): Pipeline + error(err: Error): void +} + +export { + createPipeline, + defaultLoaderRegistry, + defaultLogger, + run, +} diff --git a/packages/core/lib/Pipeline.js b/packages/core/lib/Pipeline.ts similarity index 63% rename from packages/core/lib/Pipeline.js rename to packages/core/lib/Pipeline.ts index 8fc39adc..70a56afa 100644 --- a/packages/core/lib/Pipeline.js +++ b/packages/core/lib/Pipeline.ts @@ -1,15 +1,40 @@ import * as otel from '@opentelemetry/api' -import once from 'lodash/once.js' -import streams from 'readable-stream' -import createStream from './factory/stream.js' +import once from 'onetime' +import streams, { Stream } from 'readable-stream' +import createStream, { assertWritable } from './factory/stream.js' import { isReadable } from './isStream.js' import nextLoop from './nextLoop.js' -import StreamObject from './StreamObject.js' +import StreamObject, { Options as BaseOptions } from './StreamObject.js' import tracer from './tracer.js' const { finished } = streams -class Pipeline extends StreamObject { +export interface PipelineOptions extends BaseOptions { + // eslint-disable-next-line no-use-before-define + onInit?: (pipeline: Pipeline) => Promise + readable?: boolean + readableObjectMode?: boolean + writable?: boolean + writableObjectMode?: boolean +} + +// eslint-disable-next-line no-use-before-define +class Pipeline extends StreamObject { + public readonly readable: boolean | undefined + public readonly readableObjectMode: boolean | undefined + public readonly writable: boolean | undefined + public readonly writableObjectMode: boolean | undefined + private readonly onInit: ((pipeline: typeof this) => Promise) | (() => void) + private _chunks: number + private readonly ctx: otel.Context + private readonly init: () => void + public readonly read: (size: number) => Promise + public readonly write: (chunk: unknown, encoding: string, callback: (error?: (Error | null)) => void) => Promise + public readonly final: (callback: (error?: (Error | null)) => void) => Promise + public error: Error | undefined + // eslint-disable-next-line no-use-before-define + private readonly _stream: Stream & { pipeline: Pipeline } + constructor({ basePath, children, @@ -23,7 +48,7 @@ class Pipeline extends StreamObject { variables, writable, writableObjectMode, - }) { + }: PipelineOptions) { super({ basePath, children, context, loaderRegistry, logger, ptr, variables }) this.logger.trace({ iri: this.ptr.value, message: 'create new Pipeline' }) @@ -44,8 +69,8 @@ class Pipeline extends StreamObject { this.write = otel.context.bind(this.ctx, this._write.bind(this)) this.final = otel.context.bind(this.ctx, this._final.bind(this)) - this.stream = createStream(this) - this.stream.pipeline = this + this._stream = createStream(this) as unknown as Stream & { pipeline: Pipeline } + this._stream.pipeline = this this.onInit = onInit || (() => { }) this.init = once(otel.context.bind(this.ctx, this._init.bind(this))) @@ -55,6 +80,10 @@ class Pipeline extends StreamObject { this.logger.trace({ iri: this.ptr.value, message: 'created new Pipeline' }) } + get stream() { + return this._stream + } + get firstChild() { return this.children[0] } @@ -63,7 +92,7 @@ class Pipeline extends StreamObject { return this.children[this.children.length - 1] } - addChild(step) { + addChild(step: StreamObject) { step.stream.on('error', err => this.destroy(err)) this.children.push(step) } @@ -80,7 +109,9 @@ class Pipeline extends StreamObject { // connect all steps for (let index = 0; index < this.children.length - 1; index++) { - this.children[index].stream.pipe(this.children[index + 1].stream) + const child = this.children[index + 1] + assertWritable(child) + this.children[index].stream.pipe(child.stream) } finished(this.lastChild.stream, err => { @@ -90,7 +121,8 @@ class Pipeline extends StreamObject { this.logger.error(err) } }) - } catch (err) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (err: any) { this.destroy(err) this.logger.error(err, { iri: this.ptr.value }) @@ -99,7 +131,7 @@ class Pipeline extends StreamObject { this.logger.trace({ iri: this.ptr.value, message: 'initialized Pipeline' }) } - destroy(err) { + destroy(err: Error) { this._span.setStatus({ code: otel.SpanStatusCode.ERROR }) this._span.end() this.stream.destroy(err) @@ -115,7 +147,7 @@ class Pipeline extends StreamObject { // stream interface - async _read(size) { + async _read(size: number) { try { await this.init() @@ -144,22 +176,27 @@ class Pipeline extends StreamObject { this._span.setAttribute('stream.chunks', this._chunks) } } - } catch (err) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (err: any) { this._span.recordException(err) this.lastChild.stream.destroy(err) } } - async _write(chunk, encoding, callback) { + async _write(chunk: unknown, encoding: string, callback: (error?: Error | null) => void) { await this.init() + assertWritable(this.firstChild) + this._span.addEvent('write') return this.firstChild.stream.write(chunk, encoding, callback) } - async _final(callback) { + async _final(callback: (error?: Error | null) => void) { await this.init() + assertWritable(this.firstChild) + finished(this.lastChild.stream, callback) this.firstChild.stream.end() diff --git a/packages/core/lib/PipelineError.js b/packages/core/lib/PipelineError.ts similarity index 77% rename from packages/core/lib/PipelineError.js rename to packages/core/lib/PipelineError.ts index f1e456d0..4dee10e3 100644 --- a/packages/core/lib/PipelineError.js +++ b/packages/core/lib/PipelineError.ts @@ -1,5 +1,5 @@ class PipelineError extends Error { - constructor(message, cause) { + constructor(message: string, cause: Error) { super(message) if (cause) { diff --git a/packages/core/lib/Step.js b/packages/core/lib/Step.ts similarity index 55% rename from packages/core/lib/Step.js rename to packages/core/lib/Step.ts index 20fdfd72..ec6d8542 100644 --- a/packages/core/lib/Step.js +++ b/packages/core/lib/Step.ts @@ -1,8 +1,22 @@ -import once from 'lodash/once.js' -import StreamObject from './StreamObject.js' +import once from 'onetime' +import { Stream } from 'readable-stream' +import StreamObject, { Options as BaseOptions } from './StreamObject.js' import tracer from './tracer.js' +import type { Operation } from './factory/operation.js' + +export interface StepOptions extends BaseOptions { + args: unknown[] + operation: Operation + stream: Stream +} + +// eslint-disable-next-line no-use-before-define +class Step extends StreamObject { + private args: unknown[] + private operation: Operation + // eslint-disable-next-line no-use-before-define + private readonly _stream: Stream & { step: Step } -class Step extends StreamObject { constructor({ args, basePath, @@ -14,14 +28,15 @@ class Step extends StreamObject { ptr, stream, variables, - }) { - super({ basePath, children, context, loaderRegistry, logger, ptr, stream, variables }) + }: StepOptions) { + super({ basePath, children, context, loaderRegistry, logger, ptr, variables }) this.args = args this.operation = operation + this._stream = stream as unknown as Stream & { step: Step } - if (typeof stream.step === 'undefined') { - stream.step = this + if (typeof this._stream.step === 'undefined') { + this._stream.step = this } // Create a span for this step @@ -42,6 +57,10 @@ class Step extends StreamObject { this.logger.trace({ iri: this.ptr.value, message: 'created new Step' }) } + + get stream() { + return this._stream + } } export default Step diff --git a/packages/core/lib/StreamObject.js b/packages/core/lib/StreamObject.js deleted file mode 100644 index 597e773d..00000000 --- a/packages/core/lib/StreamObject.js +++ /dev/null @@ -1,27 +0,0 @@ -import { VariableMap } from './VariableMap.js' - -class StreamObject { - constructor({ - basePath, - children = [], - context = {}, - loaderRegistry, - logger, - ptr, - variables = new VariableMap(), - stream, - }) { - this.basePath = basePath - this.children = children - this.context = context - this.loaderRegistry = loaderRegistry - this.logger = logger - this.ptr = ptr - this.variables = variables - this.stream = stream - - this.logger.trace({ iri: this.ptr.value, message: 'created new StreamObject' }) - } -} - -export default StreamObject diff --git a/packages/core/lib/StreamObject.ts b/packages/core/lib/StreamObject.ts new file mode 100644 index 00000000..6e2978ca --- /dev/null +++ b/packages/core/lib/StreamObject.ts @@ -0,0 +1,54 @@ +import { Stream } from 'readable-stream' +import { LoaderRegistry } from 'rdf-loaders-registry' +import { Logger } from 'winston' +import type { GraphPointer } from 'clownface' +import * as otel from '@opentelemetry/api' +import { Context, VariableMap } from '../index.js' +import { VariableMap as VariableMapImpl } from './VariableMap.js' + +export interface Options { + basePath: string + // eslint-disable-next-line no-use-before-define + children?: StreamObject[] + context?: Partial + loaderRegistry: LoaderRegistry + logger: Logger + ptr: GraphPointer + variables?: VariableMap +} + +abstract class StreamObject { + public basePath: string + // eslint-disable-next-line no-use-before-define + public readonly children: StreamObject[] + public context: Context + public readonly loaderRegistry: LoaderRegistry + public variables: VariableMap + public readonly logger: Logger + public readonly ptr: GraphPointer + protected _span!: otel.Span + + protected constructor({ + basePath, + children = [], + context = {}, + loaderRegistry, + logger, + ptr, + variables = new VariableMapImpl(), + }: Options) { + this.basePath = basePath + this.children = children + this.context = context as unknown as Context + this.loaderRegistry = loaderRegistry + this.logger = logger + this.ptr = ptr + this.variables = variables + + this.logger.trace({ iri: this.ptr.value, message: 'created new StreamObject' }) + } + + public abstract get stream(): S +} + +export default StreamObject diff --git a/packages/core/lib/VariableMap.js b/packages/core/lib/VariableMap.ts similarity index 61% rename from packages/core/lib/VariableMap.js rename to packages/core/lib/VariableMap.ts index 04407853..cc403201 100644 --- a/packages/core/lib/VariableMap.js +++ b/packages/core/lib/VariableMap.ts @@ -1,11 +1,14 @@ -export class VariableMap extends Map { - constructor(...args) { +/* eslint-disable @typescript-eslint/no-explicit-any */ +export class VariableMap extends Map { + private optionalVariables: Set + + constructor(...args: ReadonlyArray) { super(...args) this.optionalVariables = new Set() } - get(key, { allowMissing } = {}) { + get(key: string, { allowMissing = false } = {}) { if (!this.has(key) && !this.optionalVariables.has(key) && !allowMissing) { throw new Error(`Undefined variable '${key}'`) } @@ -13,7 +16,7 @@ export class VariableMap extends Map { return super.get(key) } - set(key, value, { optional = false } = {}) { + set(key: string, value: unknown, { optional = false } = {}) { if (typeof value !== 'undefined') { super.set(key, value) } @@ -21,9 +24,11 @@ export class VariableMap extends Map { if (optional) { this.optionalVariables.add(key) } + + return this } - static merge(left, right) { + static merge(left: Iterable<[string, unknown]>, right: Iterable<[string, unknown]>) { const merged = new VariableMap([...left, ...right]) if (left instanceof VariableMap) { diff --git a/packages/core/lib/cloneTerm.js b/packages/core/lib/cloneTerm.js deleted file mode 100644 index 59f3e575..00000000 --- a/packages/core/lib/cloneTerm.js +++ /dev/null @@ -1,21 +0,0 @@ -function cloneTerm(rdf, term) { - if (!term) { - return null - } - - if (term.termType === 'BlankNode') { - return rdf.blankNode(term.value) - } - - if (term.termType === 'Literal') { - return rdf.literal(term.value, term.language || term.datatype) - } - - if (term.termType === 'NamedNode') { - return rdf.namedNode(term.value) - } - - throw new Error(`unknown termType: ${term.termType}`) -} - -export default cloneTerm diff --git a/packages/core/lib/cloneTerm.ts b/packages/core/lib/cloneTerm.ts new file mode 100644 index 00000000..0f5c1d54 --- /dev/null +++ b/packages/core/lib/cloneTerm.ts @@ -0,0 +1,24 @@ +import type { Term } from 'rdf-js' +import type { Environment } from 'barnard59-env' + +function cloneTerm(rdf: Environment, term: T | null | undefined): T | null { + if (!term) { + return null + } + + if (term.termType === 'BlankNode') { + return rdf.blankNode(term.value) + } + + if (term.termType === 'Literal') { + return rdf.literal(term.value, term.language || term.datatype) + } + + if (term.termType === 'NamedNode') { + return rdf.namedNode(term.value) + } + + throw new Error(`unknown termType: ${term.termType}`) +} + +export default cloneTerm diff --git a/packages/core/lib/defaultLoaderRegistry.js b/packages/core/lib/defaultLoaderRegistry.ts similarity index 84% rename from packages/core/lib/defaultLoaderRegistry.js rename to packages/core/lib/defaultLoaderRegistry.ts index 38fec9d9..cc2539e0 100644 --- a/packages/core/lib/defaultLoaderRegistry.js +++ b/packages/core/lib/defaultLoaderRegistry.ts @@ -3,16 +3,17 @@ import ecmaScriptLiteralLoader from 'rdf-loader-code/ecmaScriptLiteral.js' // eslint-disable-next-line import/default import ecmaScriptModuleLoader from 'rdf-loader-code/ecmaScriptModule.js' import LoaderRegistry from 'rdf-loaders-registry' +import type { Environment } from 'barnard59-env' import pipelineLoader from './loader/pipeline.js' import variableLoader from './loader/variable.js' import fileLoader from './loader/file.js' -function factory(rdf) { +function factory(rdf: Environment) { const registry = new LoaderRegistry() ecmaScriptLoader.register(registry) ecmaScriptLiteralLoader.register(registry) - ecmaScriptModuleLoader.register(registry, rdf) + ecmaScriptModuleLoader.register(registry) pipelineLoader.register(registry, rdf) variableLoader.register(registry, rdf) fileLoader.register(registry, rdf) diff --git a/packages/core/lib/defaultLogger.js b/packages/core/lib/defaultLogger.ts similarity index 72% rename from packages/core/lib/defaultLogger.js rename to packages/core/lib/defaultLogger.ts index a56056e5..cfee27e1 100644 --- a/packages/core/lib/defaultLogger.js +++ b/packages/core/lib/defaultLogger.ts @@ -1,4 +1,4 @@ -import winston from 'winston' +import * as winston from 'winston' const { createLogger, format, transports } = winston const { Console, File } = transports @@ -12,7 +12,18 @@ const levels = { trace: 5, } -function factory({ console = true, errorFilename = null, filename = null, level = 'error', quiet } = {}) { +declare module 'winston' { + export interface Logger { + error: winston.LeveledLogMethod + warn: winston.LeveledLogMethod + info: winston.LeveledLogMethod + verbose: winston.LeveledLogMethod + debug: winston.LeveledLogMethod + trace: winston.LeveledLogMethod + } +} + +function factory({ console = true, errorFilename = null, filename = null, level = 'error', quiet = false } = {}) { const transports = [] if (console) { diff --git a/packages/core/lib/factory/arguments.js b/packages/core/lib/factory/arguments.ts similarity index 51% rename from packages/core/lib/factory/arguments.js rename to packages/core/lib/factory/arguments.ts index dcd164aa..a6c23f9f 100644 --- a/packages/core/lib/factory/arguments.js +++ b/packages/core/lib/factory/arguments.ts @@ -1,8 +1,14 @@ +import { Context } from 'vm' import parseArguments from 'rdf-loader-code/arguments.js' +import type { GraphPointer } from 'clownface' +import { Logger } from 'winston' +import { LoaderRegistry } from 'rdf-loaders-registry' import { unknownVariable } from '../loader/variable.js' +import { VariableMap } from '../../index.js' -async function createArguments(ptr, { basePath, context, loaderRegistry, logger, variables }) { - const args = await parseArguments(ptr, { basePath, context, loaderRegistry, logger, variables }) +async function createArguments(ptr: GraphPointer, { basePath, context, loaderRegistry, variables }: { basePath: string; context: Pick; loaderRegistry: LoaderRegistry; logger: Logger; variables: VariableMap }) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const args: any[] = await parseArguments(ptr, { basePath, context, loaderRegistry, variables }) // The variable loader returns the symbol unknownVariable for all unknown variables. // This code maps the unknownVariable symbols to undefined for both kinds of arguments: diff --git a/packages/core/lib/factory/operation.js b/packages/core/lib/factory/operation.js deleted file mode 100644 index b938f80d..00000000 --- a/packages/core/lib/factory/operation.js +++ /dev/null @@ -1,13 +0,0 @@ -async function createOperation(ptr, { basePath, context, loaderRegistry, logger, variables }) { - const result = await loaderRegistry.load(ptr, { basePath, context, loaderRegistry, logger, variables }) - - if (typeof result !== 'function') { - const links = ptr.out(context.env.ns.code.link).values.join(', ') - - throw new Error(`Failed to load operation ${ptr.value} (${links})`) - } - - return result -} - -export default createOperation diff --git a/packages/core/lib/factory/operation.ts b/packages/core/lib/factory/operation.ts new file mode 100644 index 00000000..69c75b35 --- /dev/null +++ b/packages/core/lib/factory/operation.ts @@ -0,0 +1,27 @@ +import { Context } from 'vm' +import type { MultiPointer } from 'clownface' +import { Logger } from 'winston' +import { LoaderRegistry } from 'rdf-loaders-registry' +import { isGraphPointer } from 'is-graph-pointer' +import { Stream } from 'readable-stream' +import { VariableMap } from '../../index.js' + +export type Operation = (this: Context, ...args: unknown[]) => Promise | Stream + +async function createOperation(ptr: MultiPointer, { basePath, context, loaderRegistry, logger, variables }: { basePath: string; context: Pick; loaderRegistry: LoaderRegistry; logger: Logger; variables: VariableMap }) { + if (!isGraphPointer(ptr)) { + throw new Error(`Expected a single node, got ${ptr.values.join(', ')}`) + } + + const result = await loaderRegistry.load(ptr, { basePath, context, loaderRegistry, logger, variables }) + + if (typeof result !== 'function') { + const links = ptr.out(context.env.ns.code.link).values.join(', ') + + throw new Error(`Failed to load operation ${ptr.value} (${links})`) + } + + return result +} + +export default createOperation diff --git a/packages/core/lib/factory/pipeline.js b/packages/core/lib/factory/pipeline.ts similarity index 51% rename from packages/core/lib/factory/pipeline.js rename to packages/core/lib/factory/pipeline.ts index b49a4b3a..81c8e32f 100644 --- a/packages/core/lib/factory/pipeline.js +++ b/packages/core/lib/factory/pipeline.ts @@ -1,41 +1,73 @@ +import type { GraphPointer } from 'clownface' +import { Logger } from 'winston' +import { LoaderRegistry } from 'rdf-loaders-registry' +import type { Environment } from 'barnard59-env' import defaultLoaderRegistry from '../defaultLoaderRegistry.js' import defaultLogger from '../defaultLogger.js' import metadata from '../metadata.js' import Pipeline from '../Pipeline.js' -import { VariableMap } from '../VariableMap.js' +import { VariableMap as VariableMapImpl } from '../VariableMap.js' +import { Context, VariableMap } from '../../index.js' import createStep from './step.js' import createVariables from './variables.js' -async function createPipelineContext(ptr, { basePath, context, logger, variables, error }) { - return { error, ...context, basePath, logger, variables } +function createPipelineContext( + ptr: GraphPointer, + { basePath, context, logger, variables, error }: { + basePath: string + context: Pick + logger: Logger + variables: VariableMap + error: (err: Error) => void + }) { + return { error, ...context, basePath, logger, variables } as unknown as Context } -async function createPipelineVariables(ptr, { basePath, context, loaderRegistry, logger, variables }) { - let localVariables = [] +async function createPipelineVariables( + ptr: GraphPointer, + { basePath, context, loaderRegistry, logger, variables } :{ + basePath: string + context: Pick + loaderRegistry: LoaderRegistry + logger: Logger + variables: VariableMap + }) { + let localVariables: VariableMap | never[] = [] if (ptr) { - localVariables = await createVariables(ptr.out(context.env.ns.p.variables), { basePath, context, loaderRegistry, logger, variables }) + localVariables = await createVariables(ptr.out(context.env.ns.p.variables), { basePath, context, loaderRegistry, logger }) } - return VariableMap.merge(localVariables, variables) + return VariableMapImpl.merge(localVariables, variables) } -function createPipeline(ptr, { - basePath, - env, - context = { env }, - loaderRegistry = defaultLoaderRegistry(context.env), - logger = defaultLogger(), - variables = new VariableMap(), -} = {}) { +type CreatePipeline = { + basePath: string + loaderRegistry?: LoaderRegistry + logger?: Logger + variables?: VariableMap + env?: Environment + context?: Context +} + +function createPipeline(ptr: GraphPointer, init: CreatePipeline) { + let context: Context = init.context || { env: init.env! } as Context + + let { + basePath, + loaderRegistry = defaultLoaderRegistry(context.env), + logger = defaultLogger(), + variables = new VariableMapImpl(), + } = init + if (!ptr.term || !ptr.dataset) { throw new Error('the given graph pointer is invalid') } ptr = context.env.clownface({ dataset: ptr.dataset, term: ptr.term }) - const onInit = async pipeline => { - function error(err) { + const onInit = async (pipeline: Pipeline) => { + function error(err: Error) { logger.error(err) if (!pipeline.error) { pipeline.error = err @@ -49,12 +81,13 @@ function createPipeline(ptr, { // add pipeline factory with current values as defaults const defaults = { basePath, context, loaderRegistry, logger, variables } - context.createPipeline = (ptr, args) => createPipeline(ptr, { ...defaults, ...args }) + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context.createPipeline = (ptr, { context, ...args } = {}) => createPipeline(ptr, { ...defaults, ...args }) pipeline.variables = variables pipeline.context = context - for (const stepPtr of ptr.out(context.env.ns.p.steps).out(context.env.ns.p.stepList).list()) { + for (const stepPtr of ptr.out(context.env.ns.p.steps).out(context.env.ns.p.stepList).list()!) { if (stepPtr.has(context.env.ns.rdf.type, context.env.ns.p.Pipeline).terms.length > 0) { pipeline.addChild(createPipeline(stepPtr, { basePath, context, loaderRegistry, logger, variables })) } else { @@ -66,10 +99,10 @@ function createPipeline(ptr, { return new Pipeline({ basePath, loaderRegistry, logger, onInit, ptr, ...metadata(context.env, ptr) }) } -function logVariables(ptr, { env, logger }, variables) { +function logVariables(ptr: GraphPointer, { env, logger }: Pick, variables: VariableMap) { if (variables.size) { for (const [key, value] of variables) { - let level = 'verbose' + let level : 'verbose' | 'info' = 'verbose' if (ptr.out(env.ns.p.variables).out(env.ns.p.variable).has(env.ns.p.name, key).term) { level = 'info' } diff --git a/packages/core/lib/factory/step.js b/packages/core/lib/factory/step.ts similarity index 70% rename from packages/core/lib/factory/step.js rename to packages/core/lib/factory/step.ts index 344621d0..b9915882 100644 --- a/packages/core/lib/factory/step.js +++ b/packages/core/lib/factory/step.ts @@ -1,12 +1,16 @@ import { SpanStatusCode } from '@opentelemetry/api' +import type { GraphPointer } from 'clownface' +import { Logger } from 'winston' +import { LoaderRegistry } from 'rdf-loaders-registry' import { isStream } from '../isStream.js' import PipelineError from '../PipelineError.js' import Step from '../Step.js' import tracer from '../tracer.js' +import { Context, VariableMap } from '../../index.js' import createArguments from './arguments.js' import createOperation from './operation.js' -async function createStep(ptr, { basePath, context, loaderRegistry, logger, variables }) { +async function createStep(ptr: GraphPointer, { basePath, context, loaderRegistry, logger, variables }: { basePath: string; context: Pick; loaderRegistry: LoaderRegistry; logger: Logger; variables: VariableMap }) { return tracer.startActiveSpan('createStep', { attributes: { iri: ptr.value } }, async span => { try { const args = await createArguments(ptr, { basePath, context, loaderRegistry, logger, variables }) @@ -18,7 +22,8 @@ async function createStep(ptr, { basePath, context, loaderRegistry, logger, vari } return new Step({ args, basePath, context, loaderRegistry, logger, operation, ptr, stream, variables }) - } catch (cause) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (cause: any) { span.recordException(cause) span.setStatus({ code: SpanStatusCode.ERROR, message: cause.message }) throw new PipelineError(`could not load step ${ptr.value}`, cause) diff --git a/packages/core/lib/factory/stream.js b/packages/core/lib/factory/stream.js deleted file mode 100644 index 00a0eb70..00000000 --- a/packages/core/lib/factory/stream.js +++ /dev/null @@ -1,35 +0,0 @@ -import streams from 'readable-stream' - -const { Duplex, Readable, Writable } = streams - -function createStream({ readable, readableObjectMode, read, writable, writableObjectMode, write, final }) { - if (readable && writable) { - return new Duplex({ - readableObjectMode, - writableObjectMode, - read, - write, - final, - }) - } - - if (readable) { - return new Readable({ - objectMode: readableObjectMode, - read, - }) - } - - if (writable) { - return new Writable({ - objectMode: writableObjectMode, - write, - final, - }) - } - - // dummy, just for the events - return new Readable({ read }) -} - -export default createStream diff --git a/packages/core/lib/factory/stream.ts b/packages/core/lib/factory/stream.ts new file mode 100644 index 00000000..d01cedff --- /dev/null +++ b/packages/core/lib/factory/stream.ts @@ -0,0 +1,48 @@ +import { Readable, Writable, Duplex } from 'readable-stream' +import Pipeline from '../Pipeline.js' +import StreamObject from '../StreamObject.js' +import { isWritable as streamIsWritable } from '../isStream.js' + +export function isWritable(arg: StreamObject): arg is StreamObject { + return streamIsWritable(arg.stream) +} + +export function assertWritable(arg: StreamObject): asserts arg is StreamObject { + if (!isWritable(arg)) { + throw new Error('Stream is not writable') + } +} + +type Arg = Pick + +function createStream({ readable, readableObjectMode, read, writable, writableObjectMode, write, final }: Arg) { + if (readable && writable) { + return new Duplex({ + readableObjectMode, + writableObjectMode, + read, + write, + final, + }) + } + + if (readable) { + return new Readable({ + objectMode: readableObjectMode, + read, + }) + } + + if (writable) { + return new Writable({ + objectMode: writableObjectMode, + write, + final, + }) + } + + // dummy, just for the events + return new Readable({ read }) +} + +export default createStream diff --git a/packages/core/lib/factory/variables.js b/packages/core/lib/factory/variables.js deleted file mode 100644 index 120e7fba..00000000 --- a/packages/core/lib/factory/variables.js +++ /dev/null @@ -1,23 +0,0 @@ -import { VariableMap } from '../VariableMap.js' - -async function createVariables(ptr, { basePath, context, loaderRegistry, logger }) { - const variables = new VariableMap() - - for (const variablePtr of ptr.out(context.env.ns.p.variable).toArray()) { - let variable - if (variablePtr.out(context.env.ns.p.value).term) { - variable = await loaderRegistry.load(variablePtr, { basePath, context, logger, variables }) - - if (!variable) { - throw new Error(`Failed to load variable ${variablePtr.value}`) - } - } - - const optional = variablePtr.out(context.env.ns.p.required).term?.equals(context.env.FALSE) || false - variables.set(variablePtr.out(context.env.ns.p.name).value, variable?.value, { optional }) - } - - return variables -} - -export default createVariables diff --git a/packages/core/lib/factory/variables.ts b/packages/core/lib/factory/variables.ts new file mode 100644 index 00000000..e0171dc8 --- /dev/null +++ b/packages/core/lib/factory/variables.ts @@ -0,0 +1,33 @@ +import type { MultiPointer } from 'clownface' +import { Logger } from 'winston' +import { LoaderRegistry } from 'rdf-loaders-registry' +import { isGraphPointer } from 'is-graph-pointer' +import { VariableMap } from '../VariableMap.js' +import { Context } from '../../index.js' + +async function createVariables(ptr: MultiPointer, { basePath, context, loaderRegistry, logger }: { basePath: string; context: Pick; loaderRegistry: LoaderRegistry; logger: Logger }) { + const variables = new VariableMap() + + for (const variablePtr of ptr.out(context.env.ns.p.variable).toArray()) { + let variable + if (variablePtr.out(context.env.ns.p.value).term) { + variable = await loaderRegistry.load(variablePtr, { basePath, context, logger, variables }) + + if (!variable) { + throw new Error(`Failed to load variable ${variablePtr.value}`) + } + } + + const optional = variablePtr.out(context.env.ns.p.required).term?.equals(context.env.FALSE) || false + const variableName = variablePtr.out(context.env.ns.p.name) + if (!isGraphPointer(variableName)) { + throw new Error(`Invalid variable name '${variableName.value}'`) + } + + variables.set(variableName.value, variable?.value, { optional }) + } + + return variables +} + +export default createVariables diff --git a/packages/core/lib/isStream.js b/packages/core/lib/isStream.js deleted file mode 100644 index 1598843e..00000000 --- a/packages/core/lib/isStream.js +++ /dev/null @@ -1,17 +0,0 @@ -import { - isReadableStream as isReadable, - isWritableStream as isWritable, - isDuplexStream as isDuplex, -} from 'is-stream' - -const isReadableObjectMode = stream => isReadable(stream) && stream._readableState.objectMode -const isWritableObjectMode = stream => isWritable(stream) && stream._writableState.objectMode - -export { isStream } from 'is-stream' -export { - isReadable, - isReadableObjectMode, - isWritable, - isWritableObjectMode, - isDuplex, -} diff --git a/packages/core/lib/isStream.ts b/packages/core/lib/isStream.ts new file mode 100644 index 00000000..78af7ada --- /dev/null +++ b/packages/core/lib/isStream.ts @@ -0,0 +1,18 @@ +import { + isReadableStream as isReadable, + isWritableStream as isWritable, + isDuplexStream as isDuplex, +} from 'is-stream' +import { Stream, Writable } from 'readable-stream' + +const isReadableObjectMode = (stream: Stream) => isReadable(stream) && stream._readableState.objectMode +const isWritableObjectMode = (stream: Stream) => isWritable(stream) && (stream as Writable)._writableState.objectMode + +export { isStream } from 'is-stream' +export { + isReadable, + isReadableObjectMode, + isWritable, + isWritableObjectMode, + isDuplex, +} diff --git a/packages/core/lib/loader/file.js b/packages/core/lib/loader/file.ts similarity index 51% rename from packages/core/lib/loader/file.js rename to packages/core/lib/loader/file.ts index 891ee3c6..e6e2bc30 100644 --- a/packages/core/lib/loader/file.js +++ b/packages/core/lib/loader/file.ts @@ -2,8 +2,12 @@ import { resolve } from 'path' import * as fs from 'fs' import { isLiteral } from 'is-graph-pointer' import untildify from 'untildify' +import type { GraphPointer } from 'clownface' +import LoaderRegistry from 'rdf-loaders-registry' +import type { Environment } from 'barnard59-env' +import { VariableMap } from '../VariableMap.js' -export default function loader(ptr, { basePath, variables }) { +export default function loader(ptr: GraphPointer, { basePath, variables }: { basePath: string; variables: VariableMap }) { if (isLiteral(ptr)) { const { value } = ptr const path = untildify(variables.get(value, { allowMissing: true }) || value) @@ -12,6 +16,6 @@ export default function loader(ptr, { basePath, variables }) { } } -loader.register = (registry, rdf) => { +loader.register = (registry: LoaderRegistry, rdf: Environment) => { registry.registerLiteralLoader(rdf.ns.p.FileContents, loader) } diff --git a/packages/core/lib/loader/pipeline.js b/packages/core/lib/loader/pipeline.js deleted file mode 100644 index defdaff5..00000000 --- a/packages/core/lib/loader/pipeline.js +++ /dev/null @@ -1,15 +0,0 @@ -import createPipeline from '../factory/pipeline.js' - -async function loader(ptr, { basePath, context = {}, loaderRegistry, variables } = {}) { - if (ptr.has(context.env.ns.rdf.type, context.env.ns.p.Pipeline).terms.length > 0) { - return createPipeline(ptr, { basePath, context, loaderRegistry, logger: context.logger, variables }).stream - } - - throw new Error('Unrecognized or missing pipeline type') -} - -loader.register = (registry, env) => { - registry.registerNodeLoader(env.ns.p.Pipeline, loader) -} - -export default loader diff --git a/packages/core/lib/loader/pipeline.ts b/packages/core/lib/loader/pipeline.ts new file mode 100644 index 00000000..447738aa --- /dev/null +++ b/packages/core/lib/loader/pipeline.ts @@ -0,0 +1,26 @@ +import { LoaderRegistry } from 'rdf-loaders-registry' +import type { Environment } from 'barnard59-env' +import type { GraphPointer } from 'clownface' +import createPipeline from '../factory/pipeline.js' +import { Context, VariableMap } from '../../index.js' + +interface Options { + basePath: string + context: Context + loaderRegistry: LoaderRegistry + variables: VariableMap +} + +async function loader(ptr: GraphPointer, { basePath, context, loaderRegistry, variables }: Options) { + if (ptr.has(context.env.ns.rdf.type, context.env.ns.p.Pipeline).terms.length > 0) { + return createPipeline(ptr, { basePath, context, loaderRegistry, logger: context.logger, variables }).stream + } + + throw new Error('Unrecognized or missing pipeline type') +} + +loader.register = (registry: LoaderRegistry, env: Environment) => { + registry.registerNodeLoader(env.ns.p.Pipeline, loader) +} + +export default loader diff --git a/packages/core/lib/loader/variable.js b/packages/core/lib/loader/variable.ts similarity index 71% rename from packages/core/lib/loader/variable.js rename to packages/core/lib/loader/variable.ts index d0944314..8c85fb31 100644 --- a/packages/core/lib/loader/variable.js +++ b/packages/core/lib/loader/variable.ts @@ -1,9 +1,13 @@ +import type { Term } from '@rdfjs/types' +import type { Environment } from 'barnard59-env' +import type { GraphPointer } from 'clownface' +import LoaderRegistry from 'rdf-loaders-registry' import cloneTerm from '../cloneTerm.js' import { VariableMap } from '../VariableMap.js' const unknownVariable = Symbol('unknown-variable') -function loader(rdf, ptr, { variables = new VariableMap() } = {}) { +function loader(rdf: Environment, ptr: GraphPointer, { variables = new VariableMap() } = {}) { if (ptr.term.termType === 'Literal') { const value = variables.get(ptr.value) @@ -16,8 +20,8 @@ function loader(rdf, ptr, { variables = new VariableMap() } = {}) { return value } - const name = ptr.out(rdf.ns.p.name).value - let term + const name = ptr.out(rdf.ns.p.name).value as string + let term: null | (Term & { name?: string }) // if the variables from the arguments contains it ... if (variables.has(name)) { @@ -36,7 +40,7 @@ function loader(rdf, ptr, { variables = new VariableMap() } = {}) { return term } -loader.register = (registry, rdf) => { +loader.register = (registry: LoaderRegistry, rdf: Environment) => { registry.registerNodeLoader(rdf.ns.p.Variable, loader.bind(null, rdf)) registry.registerLiteralLoader(rdf.ns.p.VariableName, loader.bind(null, rdf)) } diff --git a/packages/core/lib/metadata.js b/packages/core/lib/metadata.ts similarity index 76% rename from packages/core/lib/metadata.js rename to packages/core/lib/metadata.ts index df169ed9..e99f0c44 100644 --- a/packages/core/lib/metadata.js +++ b/packages/core/lib/metadata.ts @@ -1,4 +1,7 @@ -function metadata(rdf, ptr) { +import type { Environment } from 'barnard59-env' +import type { GraphPointer } from 'clownface' + +function metadata(rdf: Environment, ptr: GraphPointer) { const readableObjectMode = Boolean(ptr.has(rdf.ns.rdf.type, rdf.ns.p.ReadableObjectMode).term) const readable = Boolean(ptr.has(rdf.ns.rdf.type, rdf.ns.p.Readable).term) || readableObjectMode const writableObjectMode = Boolean(ptr.has(rdf.ns.rdf.type, rdf.ns.p.WritableObjectMode).term) diff --git a/packages/core/lib/nextLoop.js b/packages/core/lib/nextLoop.ts similarity index 100% rename from packages/core/lib/nextLoop.js rename to packages/core/lib/nextLoop.ts diff --git a/packages/core/lib/run.js b/packages/core/lib/run.ts similarity index 67% rename from packages/core/lib/run.js rename to packages/core/lib/run.ts index 3944b39c..b0add26a 100644 --- a/packages/core/lib/run.js +++ b/packages/core/lib/run.ts @@ -2,11 +2,13 @@ import { promisify } from 'util' import { SpanStatusCode } from '@opentelemetry/api' import { finished } from 'readable-stream' import tracer from './tracer.js' +import type Pipeline from './Pipeline.js' +import { isWritable } from './factory/stream.js' -async function run(pipeline, { end = false, resume = false } = {}) { +async function run(pipeline: Pipeline, { end = false, resume = false } = {}) { await tracer.startActiveSpan('run', async span => { try { - if (end) { + if (end && isWritable(pipeline)) { pipeline.stream.end() } @@ -16,7 +18,7 @@ async function run(pipeline, { end = false, resume = false } = {}) { await promisify(finished)(pipeline.stream) - const p = new Promise(resolve => { + const p = new Promise(resolve => { pipeline.logger.on('finish', () => resolve()) }) @@ -25,7 +27,8 @@ async function run(pipeline, { end = false, resume = false } = {}) { } pipeline.logger.end() await p - } catch (err) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (err: any) { span.recordException(err) span.setStatus({ code: SpanStatusCode.ERROR, message: err.message }) throw err diff --git a/packages/core/lib/tracer.js b/packages/core/lib/tracer.ts similarity index 100% rename from packages/core/lib/tracer.js rename to packages/core/lib/tracer.ts diff --git a/packages/core/lib/utils.js b/packages/core/lib/utils.ts similarity index 100% rename from packages/core/lib/utils.js rename to packages/core/lib/utils.ts diff --git a/packages/core/package.json b/packages/core/package.json index 274728f3..9f7c76e9 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -5,7 +5,8 @@ "type": "module", "main": "index.js", "scripts": { - "test": "mocha" + "test": "mocha", + "prepack": "tsc" }, "repository": { "type": "git", @@ -25,15 +26,16 @@ "duplexify": "^4.1.1", "is-graph-pointer": "^2.1.0", "is-stream": "^3.0.0", - "lodash": "^4.17.21", - "rdf-loader-code": "^2.0.0", - "rdf-loaders-registry": "^0.3.0", + "onetime": "^6.0.0", + "rdf-loader-code": "^2.1.1", + "rdf-loaders-registry": "^1.0.1", "readable-stream": "^3.6.0", "untildify": "^5.0.0", "winston": "^3.3.3" }, "devDependencies": { "@rdfjs/namespace": "^2.0.0", + "@types/readable-stream": "^4.0.9", "barnard59-env": "^1.1.0", "barnard59-http": "^2.0.0", "barnard59-test-support": "^0.0.3", @@ -46,6 +48,7 @@ "sinon": "^15.0.4" }, "mocha": { - "require": "../../test/mocha-setup.cjs" + "require": "../../test/mocha-setup.cjs", + "loader": "ts-node/esm" } } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json new file mode 100644 index 00000000..773edd42 --- /dev/null +++ b/packages/core/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "files": ["./index.ts"], +} diff --git a/packages/env/.npmignore b/packages/env/.npmignore new file mode 100644 index 00000000..6461deec --- /dev/null +++ b/packages/env/.npmignore @@ -0,0 +1 @@ +*.ts diff --git a/packages/env/index.js b/packages/env/index.js deleted file mode 100644 index 91fcb65f..00000000 --- a/packages/env/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { create } from '@zazuko/env-node' -import NamespacesFactory from './lib/Namespaces.js' -import ConstantsFactory from './lib/Constants.js' - -export default create(NamespacesFactory, ConstantsFactory) diff --git a/packages/env/index.ts b/packages/env/index.ts new file mode 100644 index 00000000..718a1dbf --- /dev/null +++ b/packages/env/index.ts @@ -0,0 +1,8 @@ +import { create } from '@zazuko/env-node' +import type { DefaultEnv, DerivedEnvironment } from '@zazuko/env' +import NamespacesFactory from './lib/Namespaces.js' +import ConstantsFactory from './lib/Constants.js' + +export type Environment = DerivedEnvironment + +export default create(NamespacesFactory, ConstantsFactory) diff --git a/packages/env/lib/Constants.js b/packages/env/lib/Constants.js deleted file mode 100644 index 3a4afa3f..00000000 --- a/packages/env/lib/Constants.js +++ /dev/null @@ -1,5 +0,0 @@ -export default class ConstantsFactory { - init() { - this.FALSE = this.literal('false', this.ns.xsd.boolean) - } -} diff --git a/packages/env/lib/Constants.ts b/packages/env/lib/Constants.ts new file mode 100644 index 00000000..d0e9c7d9 --- /dev/null +++ b/packages/env/lib/Constants.ts @@ -0,0 +1,11 @@ +import type { Literal, DataFactory } from '@rdfjs/types' +import type { Environment } from '@rdfjs/environment/Environment.js' +import type { NsBuildersFactory } from '@tpluscode/rdf-ns-builders/Factory.js' + +export default class ConstantsFactory { + FALSE!: Literal + + init(this: Environment) { + this.FALSE = this.literal('false', this.ns.xsd.boolean) + } +} diff --git a/packages/env/lib/Namespaces.js b/packages/env/lib/Namespaces.js deleted file mode 100644 index 921ee73c..00000000 --- a/packages/env/lib/Namespaces.js +++ /dev/null @@ -1,12 +0,0 @@ -export default class NamespacesFactory { - init() { - this.ns = { - ...this.ns, - p: this.namespace('https://pipeline.described.at/'), - code: this.namespace('https://code.described.at/'), - cube: this.namespace('https://cube.link/'), - meta: this.namespace('https://cube.link/meta/'), - b59: this.namespace('https://barnard59.zazuko.com/vocab#'), - } - } -} diff --git a/packages/env/lib/Namespaces.ts b/packages/env/lib/Namespaces.ts new file mode 100644 index 00000000..85fcf971 --- /dev/null +++ b/packages/env/lib/Namespaces.ts @@ -0,0 +1,26 @@ +import type { NsBuildersFactory } from '@tpluscode/rdf-ns-builders/Factory.js' +import type { Environment } from '@rdfjs/environment/Environment.js' +import type { NamespaceFactory } from '@rdfjs/namespace/Factory.js' +import * as Builders from '@zazuko/vocabulary-extras-builders' + +declare module '@tpluscode/rdf-ns-builders' { + interface CustomNamespaces { + b59: typeof Builders.b59 + p: typeof Builders.pipeline + pipeline: typeof Builders.pipeline + code: typeof Builders.code + cube: typeof Builders.cube + meta: typeof Builders.meta + relation: typeof Builders.relation + } +} + +export default class NamespacesFactory { + init(this: Environment) { + this.ns = { + ...this.ns, + ...Builders, + p: Builders.pipeline, + } + } +} diff --git a/packages/env/package.json b/packages/env/package.json index 00a7ae76..d09916be 100644 --- a/packages/env/package.json +++ b/packages/env/package.json @@ -3,8 +3,12 @@ "version": "1.1.0", "type": "module", "main": "index.js", + "scripts": { + "prepack": "tsc" + }, "dependencies": { - "@zazuko/env-node": "^1.0.0" + "@zazuko/env-node": "^1.0.3", + "@zazuko/vocabulary-extras-builders": "^1.1.0" }, "repository": { "type": "git", diff --git a/packages/env/tsconfig.json b/packages/env/tsconfig.json new file mode 100644 index 00000000..773edd42 --- /dev/null +++ b/packages/env/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "files": ["./index.ts"], +} diff --git a/packages/validation/package.json b/packages/validation/package.json index d9d10bd2..fb7d70b7 100644 --- a/packages/validation/package.json +++ b/packages/validation/package.json @@ -39,7 +39,7 @@ "anylogger-console": "^1.0.0", "chalk": "^4.1.0", "commander": "^11.0.0", - "rdf-loader-code": "^2.0.0" + "rdf-loader-code": "^2.1.1" }, "mocha": { "loader": "esmock" diff --git a/test/e2e/package.json b/test/e2e/package.json index 430dabf8..fec69cc3 100644 --- a/test/e2e/package.json +++ b/test/e2e/package.json @@ -18,7 +18,7 @@ "barnard59-test-support": "^0.0.3", "readable-stream": "^3", "rdf-dataset-ext": "^1.0.1", - "rdf-loader-code": "^2.0.0", + "rdf-loader-code": "^2.1.1", "rdf-utils-fs": "^2.3.0", "string-to-stream": "^3.0.1" } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..36545f99 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "ES2022", + "target": "ES2022", + "moduleResolution": "Node", + "declaration": true, + "strict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "allowSyntheticDefaultImports": true + }, + "files": [ + "packages/core/index.ts", + "packages/env/index.ts" + ] +} From bdb5c7f4e9696d8abc5fbf4c6dfa4150d2a229b2 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 16:17:20 +0100 Subject: [PATCH 2/9] chore: ignore compiled in TS packages --- packages/core/.gitignore | 2 ++ packages/env/.gitignore | 1 + 2 files changed, 3 insertions(+) create mode 100644 packages/core/.gitignore create mode 100644 packages/env/.gitignore diff --git a/packages/core/.gitignore b/packages/core/.gitignore new file mode 100644 index 00000000..a399595b --- /dev/null +++ b/packages/core/.gitignore @@ -0,0 +1,2 @@ +*.js +!test/**/*.js diff --git a/packages/env/.gitignore b/packages/env/.gitignore new file mode 100644 index 00000000..a6c7c285 --- /dev/null +++ b/packages/env/.gitignore @@ -0,0 +1 @@ +*.js From 851b484879eaecda56bd9712845beb2a67076643 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 16:28:05 +0100 Subject: [PATCH 3/9] test: use ts-node loader for all packages --- packages/base/package.json | 3 ++- packages/csvw/package.json | 3 +++ packages/cube/package.json | 3 +++ packages/formats/package.json | 3 +++ packages/ftp/package.json | 3 +++ packages/graph-store/package.json | 3 +++ packages/http/package.json | 3 +++ packages/rdf/package.json | 3 ++- packages/s3/package.json | 3 +++ packages/shacl/package.json | 3 ++- packages/sparql/package.json | 3 +++ 11 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/base/package.json b/packages/base/package.json index 2566855d..5e148aa4 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -42,6 +42,7 @@ "node": ">= 14.0.0" }, "mocha": { - "require": "../../test/mocha-setup.cjs" + "require": "../../test/mocha-setup.cjs", + "loader": "ts-node/esm" } } diff --git a/packages/csvw/package.json b/packages/csvw/package.json index d8675ef9..d14f6cfd 100644 --- a/packages/csvw/package.json +++ b/packages/csvw/package.json @@ -35,5 +35,8 @@ }, "engines": { "node": ">= 14.0.0" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/cube/package.json b/packages/cube/package.json index 940b06d5..df40955e 100644 --- a/packages/cube/package.json +++ b/packages/cube/package.json @@ -39,5 +39,8 @@ "is-stream": "^3.0.0", "get-stream": "^6.0.1", "shelljs": "^0.8.5" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/formats/package.json b/packages/formats/package.json index 5ca22d1b..1bcd8640 100644 --- a/packages/formats/package.json +++ b/packages/formats/package.json @@ -37,5 +37,8 @@ }, "engines": { "node": ">= 14.0.0" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/ftp/package.json b/packages/ftp/package.json index 1dcc473d..6ab60269 100644 --- a/packages/ftp/package.json +++ b/packages/ftp/package.json @@ -32,5 +32,8 @@ "rimraf": "^5.0.1", "sftp-fs": "^0.0.7", "ssh2": "^1.14.0" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/graph-store/package.json b/packages/graph-store/package.json index a30141aa..84dca657 100644 --- a/packages/graph-store/package.json +++ b/packages/graph-store/package.json @@ -37,5 +37,8 @@ }, "engines": { "node": ">= 14.0.0" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/http/package.json b/packages/http/package.json index 03303b11..e057a1c3 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -30,5 +30,8 @@ "express-as-promise": "^1.2.0", "get-stream": "^6.0.1", "is-stream": "^3.0.0" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/rdf/package.json b/packages/rdf/package.json index dd2565fc..6d85fc7c 100644 --- a/packages/rdf/package.json +++ b/packages/rdf/package.json @@ -50,6 +50,7 @@ "node": ">= 14.0.0" }, "mocha": { - "require": "../../test/mocha-setup.cjs" + "require": "../../test/mocha-setup.cjs", + "loader": "ts-node/esm" } } diff --git a/packages/s3/package.json b/packages/s3/package.json index 4b6a0fd8..57443dbe 100644 --- a/packages/s3/package.json +++ b/packages/s3/package.json @@ -40,5 +40,8 @@ "@types/mocha": "^10.0.2", "aws-sdk-client-mock": "^3.0.0", "rimraf": "^5.0.5" + }, + "mocha": { + "loader": "ts-node/esm" } } diff --git a/packages/shacl/package.json b/packages/shacl/package.json index 6105bfae..3f64f110 100644 --- a/packages/shacl/package.json +++ b/packages/shacl/package.json @@ -44,6 +44,7 @@ "string-to-stream": "^3.0.1" }, "mocha": { - "require": "../../test/mocha-setup.cjs" + "require": "../../test/mocha-setup.cjs", + "loader": "ts-node/esm" } } diff --git a/packages/sparql/package.json b/packages/sparql/package.json index e87e3f76..f56136d5 100644 --- a/packages/sparql/package.json +++ b/packages/sparql/package.json @@ -31,5 +31,8 @@ }, "engines": { "node": ">= 14.0.0" + }, + "mocha": { + "loader": "ts-node/esm" } } From 019e4e310b7b30b4e3a18512358cda76c73547de Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 16:28:21 +0100 Subject: [PATCH 4/9] ci: compile TS to fix e2e test running shell --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2b201264..8ebc92fb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,6 +29,8 @@ jobs: with: node-version: ${{ matrix.node }} - run: npm install + - name: Compile TypeScript packages + run: npx wsrun -mc prepack - run: npx c8 --all --src packages/${{ matrix.package }} -x "packages/!(${{ matrix.package }})" --reporter lcovonly --reporter text wsrun --no-prefix -p barnard59-${{ matrix.package }} -c test - name: Codecov uses: codecov/codecov-action@v3 From b63449e60d11695462e35281c4c523c6045cf186 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 16:37:59 +0100 Subject: [PATCH 5/9] style: configure lint for dual source code --- .eslintrc.json | 11 +++++++---- tsconfig.json | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1246cb7e..10ca1029 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,5 @@ { - "extends": [ "@tpluscode" ], - "parserOptions": { - "project": "./tsconfig.json" - }, + "extends": [ "@tpluscode/eslint-config/js" ], "env": { "mocha": true }, @@ -11,5 +8,11 @@ "rules": { "no-console": "off" } + }, { + "files": "**/*.ts", + "extends": "@tpluscode", + "parserOptions": { + "project": "./tsconfig.json" + } }] } diff --git a/tsconfig.json b/tsconfig.json index 36545f99..231f3a71 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ }, "files": [ "packages/core/index.ts", + "packages/core/lib/utils.ts", "packages/env/index.ts" ] } From 1253a3f9b7854ddf1263e64589d51c12e7ba09b0 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 16:39:25 +0100 Subject: [PATCH 6/9] ci: compile source maps (and ignore them) --- .github/workflows/ci.yaml | 2 +- .gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8ebc92fb..c437227c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,7 @@ jobs: node-version: ${{ matrix.node }} - run: npm install - name: Compile TypeScript packages - run: npx wsrun -mc prepack + run: npx wsrun -mc prepack --sourceMap - run: npx c8 --all --src packages/${{ matrix.package }} -x "packages/!(${{ matrix.package }})" --reporter lcovonly --reporter text wsrun --no-prefix -p barnard59-${{ matrix.package }} -c test - name: Codecov uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index afe1f1d8..18e45321 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ coverage node_modules *.tgz *.d.ts +*.js.map From 3485994de0706c03f0bc96467f0123c263520a1c Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 16:40:45 +0100 Subject: [PATCH 7/9] ci: compile before CLI test --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c437227c..d90a3d1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,6 +52,8 @@ jobs: with: node-version: ${{ matrix.node }} - run: npm install + - name: Compile TypeScript packages + run: npx wsrun -mc prepack --sourceMap - run: npx c8 --all --src packages/cli -x "packages/!(cli)" --reporter lcovonly --reporter text wsrun --no-prefix -p barnard59 -c test - name: Codecov uses: codecov/codecov-action@v3 From b33d5888f1009321704249461dd8b4962d9b6e2b Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Mon, 11 Dec 2023 17:04:48 +0100 Subject: [PATCH 8/9] style: only warna bout no-unresolved --- .eslintrc.json | 3 +++ package-lock.json | 7 ++++--- package.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 10ca1029..3c6115f2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,6 +3,9 @@ "env": { "mocha": true }, + "rules": { + "import/no-unresolved": "warn" + }, "overrides": [{ "files": "**/test/**", "rules": { diff --git a/package-lock.json b/package-lock.json index 1761403a..56385309 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ ], "devDependencies": { "@changesets/cli": "^2.26.1", - "@tpluscode/eslint-config": "^0.4.3", + "@tpluscode/eslint-config": "^0.4.4", "@types/node": "^18", "@typescript-eslint/eslint-plugin": "^6.13.2", "@typescript-eslint/parser": "^6.13.2", @@ -5789,9 +5789,10 @@ } }, "node_modules/@tpluscode/eslint-config": { - "version": "0.4.3", + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@tpluscode/eslint-config/-/eslint-config-0.4.4.tgz", + "integrity": "sha512-pAGt5d+ISIuM9TYcTVhNstYezg98cpCxF8Sk3dHtgneKPysJPaLHRsD246KZW4bwfQ4lZUOKFircyJVjHX6Pwg==", "dev": true, - "license": "MIT", "optionalDependencies": { "@typescript-eslint/eslint-plugin": ">=2", "@typescript-eslint/parser": ">=2", diff --git a/package.json b/package.json index 2761c6e0..212b9571 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ ], "devDependencies": { "@changesets/cli": "^2.26.1", - "@tpluscode/eslint-config": "^0.4.3", + "@tpluscode/eslint-config": "^0.4.4", "@types/node": "^18", "@typescript-eslint/eslint-plugin": "^6.13.2", "@typescript-eslint/parser": "^6.13.2", From 132ca52cf6d4447965929986bdfb5d23bbb9a89b Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Tue, 12 Dec 2023 13:31:09 +0100 Subject: [PATCH 9/9] fix: wrong declared type --- packages/core/lib/Pipeline.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/lib/Pipeline.ts b/packages/core/lib/Pipeline.ts index 70a56afa..a77fe71b 100644 --- a/packages/core/lib/Pipeline.ts +++ b/packages/core/lib/Pipeline.ts @@ -27,7 +27,7 @@ class Pipeline extends StreamObject { private readonly onInit: ((pipeline: typeof this) => Promise) | (() => void) private _chunks: number private readonly ctx: otel.Context - private readonly init: () => void + private readonly init: () => Promise public readonly read: (size: number) => Promise public readonly write: (chunk: unknown, encoding: string, callback: (error?: (Error | null)) => void) => Promise public readonly final: (callback: (error?: (Error | null)) => void) => Promise