From 5a322fd3b33fa66c7304dab157bc0f4120a29214 Mon Sep 17 00:00:00 2001 From: Nathaniel Thorn Date: Thu, 13 Jul 2023 13:35:43 -0700 Subject: [PATCH 1/2] add defaultValue to SplitView returned by manager; update types --- src/sdkManager/index.ts | 3 ++- src/types.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sdkManager/index.ts b/src/sdkManager/index.ts index 71dc7716..12e07194 100644 --- a/src/sdkManager/index.ts +++ b/src/sdkManager/index.ts @@ -31,7 +31,8 @@ function objectToView(splitObject: ISplit | null): SplitIO.SplitView | null { killed: splitObject.killed, changeNumber: splitObject.changeNumber || 0, treatments: collectTreatments(splitObject), - configs: splitObject.configurations || {} + configs: splitObject.configurations || {}, + defaultTreatment: splitObject.defaultTreatment }; } diff --git a/src/types.ts b/src/types.ts index 5ecfa7ba..8b0f666d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -610,6 +610,11 @@ export namespace SplitIO { configs: { [treatmentName: string]: string } + /** + * Default treatment value for feature flag. + * @property {string} defaultTreatment + */ + defaultTreatment: string, }; /** * A promise that resolves to a feature flag view. From a7f8cc3497422d3005c8795898c65eda89e3c915 Mon Sep 17 00:00:00 2001 From: Nathaniel Thorn Date: Thu, 13 Jul 2023 13:50:56 -0700 Subject: [PATCH 2/2] update sdkManager test to expect newly added defaultValue in output --- src/sdkManager/__tests__/mocks/output.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdkManager/__tests__/mocks/output.json b/src/sdkManager/__tests__/mocks/output.json index c96c535f..9fe85c4a 100644 --- a/src/sdkManager/__tests__/mocks/output.json +++ b/src/sdkManager/__tests__/mocks/output.json @@ -6,5 +6,6 @@ "treatments": ["on", "off"], "configs": { "on": "\"color\": \"green\"" - } + }, + "defaultTreatment": "off" }