Skip to content

Commit

Permalink
Add backbone compatibility check on startup (#284)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people authored Oct 16, 2024
1 parent 5d54a15 commit 5d6e4a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 0 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
13 changes: 13 additions & 0 deletions src/ConnectorRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export class ConnectorRuntime extends Runtime<ConnectorRuntimeConfig> {
const runtime = new ConnectorRuntime(connectorConfig, loggerFactory);
await runtime.init();

await this.runBackboneCompatibilityCheck(runtime);

runtime.scheduleKillTask();
runtime.setupGlobalExceptionHandling();

Expand All @@ -96,6 +98,17 @@ export class ConnectorRuntime extends Runtime<ConnectorRuntimeConfig> {
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<IDatabaseConnection> {
if (this.runtimeConfig.database.driver === "lokijs") {
if (!this.runtimeConfig.debug) throw new Error("LokiJS is only available in debug mode.");
Expand Down

0 comments on commit 5d6e4a3

Please sign in to comment.