From 0ea135a1f9a0e4289117f62e04dd13f2447986f5 Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Thu, 9 Jan 2025 11:30:46 -0600 Subject: [PATCH] adding placeholder applyChanges to PersistentDataStoreWrapper --- .../shared/sdk-server/src/options/Configuration.ts | 2 -- .../src/store/PersistentDataStoreWrapper.ts | 14 +++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/shared/sdk-server/src/options/Configuration.ts b/packages/shared/sdk-server/src/options/Configuration.ts index cb4959d202..77baf0de39 100644 --- a/packages/shared/sdk-server/src/options/Configuration.ts +++ b/packages/shared/sdk-server/src/options/Configuration.ts @@ -59,8 +59,6 @@ const validations: Record = { hooks: TypeValidators.createTypeArray('Hook[]', {}), }; - - /** * @internal */ diff --git a/packages/shared/sdk-server/src/store/PersistentDataStoreWrapper.ts b/packages/shared/sdk-server/src/store/PersistentDataStoreWrapper.ts index 61878a0025..cdc8149149 100644 --- a/packages/shared/sdk-server/src/store/PersistentDataStoreWrapper.ts +++ b/packages/shared/sdk-server/src/store/PersistentDataStoreWrapper.ts @@ -258,7 +258,19 @@ export default class PersistentDataStoreWrapper implements LDFeatureStore { _selector: String | undefined, _callback: () => void, ): void { - // TODO: implement + // TODO: SDK-1029 - Transactional persistent store - update this to not iterate over items and instead send data to underlying PersistentDataStore + // no need for queue at the moment as init and upsert handle that, but as part of SDK-1029, queue may be needed + if (_basis) { + this.init(_data, _callback); + } else { + Object.entries(_data).forEach(([namespace, items]) => { + Object.keys(items || {}).forEach((key) => { + const item = items[key]; + this.upsert({ namespace }, { key, ...item }, () => {}); + }); + }); + _callback(); + } } close(): void {