Reduce deprecated API and dependency warnings

This commit is contained in:
vorotamoroz
2026-08-25 10:29:21 +00:00
parent f6eefed97c
commit 3ea8eac212
14 changed files with 256 additions and 576 deletions
+32
View File
@@ -0,0 +1,32 @@
type LegacyLocalDatabaseSelection = {
useIndexedDBAdapter: boolean;
};
type LegacyBulkChunkPreSendSettings = {
sendChunksBulk: boolean;
sendChunksBulkMaxSize: number;
};
/**
* Returns whether persisted settings select the legacy PouchDB IndexedDB adapter.
*
* New local databases use IDB. Existing devices must retain this operative value until their local database has
* been explicitly migrated, so compatibility code must not treat the setting as inert.
*/
export function usesLegacyIndexedDBAdapter(settings: LegacyLocalDatabaseSelection): boolean {
return settings.useIndexedDBAdapter;
}
/**
* Disables the removed automatic bulk chunk pre-send option in persisted settings.
*
* The field remains readable only so older settings and Setup URIs can be migrated to the supported behaviour.
*
* @returns `true` when the legacy setting was enabled and has been changed.
*/
export function disableLegacyBulkChunkPreSend(settings: LegacyBulkChunkPreSendSettings): boolean {
if (!settings.sendChunksBulk) return false;
settings.sendChunksBulk = false;
settings.sendChunksBulkMaxSize = 1;
return true;
}
@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import { disableLegacyBulkChunkPreSend, usesLegacyIndexedDBAdapter } from "./compatibilitySettings.ts";
describe("compatibility settings", () => {
it.each([true, false])("preserves the operative legacy adapter selection (%s)", (useIndexedDBAdapter) => {
expect(usesLegacyIndexedDBAdapter({ useIndexedDBAdapter })).toBe(useIndexedDBAdapter);
});
it("disables automatic bulk chunk pre-send and restores its inert size value", () => {
const settings = { sendChunksBulk: true, sendChunksBulkMaxSize: 16 };
expect(disableLegacyBulkChunkPreSend(settings)).toBe(true);
expect(settings).toEqual({ sendChunksBulk: false, sendChunksBulkMaxSize: 1 });
});
it("leaves an already migrated bulk chunk setting unchanged", () => {
const settings = { sendChunksBulk: false, sendChunksBulkMaxSize: 4 };
expect(disableLegacyBulkChunkPreSend(settings)).toBe(false);
expect(settings).toEqual({ sendChunksBulk: false, sendChunksBulkMaxSize: 4 });
});
});