From 5d6e4a331fd446e49f32303738cce8ee9cc2643f Mon Sep 17 00:00:00 2001 From: Sebastian Mahr Date: Wed, 16 Oct 2024 17:18:49 +0200 Subject: [PATCH] Add backbone compatibility check on startup (#284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add backbone compatibility check * chore: compatible * chore: remove unused dependency * chore: make readable * chore: re-add removed code --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Julian König --- package-lock.json | 12 ------------ packages/sdk/package.json | 1 - src/ConnectorRuntime.ts | 13 +++++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80ffbada..e8fdabe6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3109,17 +3109,6 @@ "@types/send": "*" } }, - "node_modules/@types/form-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.5.0.tgz", - "integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==", - "deprecated": "This is a stub types definition. form-data provides its own type definitions, so you do not need this installed.", - "dev": true, - "license": "MIT", - "dependencies": { - "form-data": "*" - } - }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -14031,7 +14020,6 @@ "qs": "^6.13.0" }, "devDependencies": { - "@types/form-data": "^2.5.0", "@types/qs": "^6.9.16", "ts-json-schema-generator": "^2.3.0" } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8056b599..40bf3114 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -36,7 +36,6 @@ "qs": "^6.13.0" }, "devDependencies": { - "@types/form-data": "^2.5.0", "@types/qs": "^6.9.16", "ts-json-schema-generator": "^2.3.0" }, diff --git a/src/ConnectorRuntime.ts b/src/ConnectorRuntime.ts index 39b1418c..830fab8e 100644 --- a/src/ConnectorRuntime.ts +++ b/src/ConnectorRuntime.ts @@ -84,6 +84,8 @@ export class ConnectorRuntime extends Runtime { const runtime = new ConnectorRuntime(connectorConfig, loggerFactory); await runtime.init(); + await this.runBackboneCompatibilityCheck(runtime); + runtime.scheduleKillTask(); runtime.setupGlobalExceptionHandling(); @@ -96,6 +98,17 @@ export class ConnectorRuntime extends Runtime { connectorConfig.modules.attributeListener.enabled = true; } + private static async runBackboneCompatibilityCheck(runtime: ConnectorRuntime) { + const compatibilityResult = await runtime.anonymousServices.backboneCompatibility.checkBackboneCompatibility(); + if (compatibilityResult.isError) throw compatibilityResult.error; + + if (compatibilityResult.value.isCompatible) return; + + throw new Error( + `The given backbone is not compatible with this connector version. The version of the configured backbone is '${compatibilityResult.value.backboneVersion}' the supported min/max version is '${compatibilityResult.value.supportedMinBackboneVersion}/${compatibilityResult.value.supportedMaxBackboneVersion}'.` + ); + } + protected async createDatabaseConnection(): Promise { if (this.runtimeConfig.database.driver === "lokijs") { if (!this.runtimeConfig.debug) throw new Error("LokiJS is only available in debug mode.");