Skip to content

Commit

Permalink
fixup! fixup! refactor(client-http,web,server): use a serializable an…
Browse files Browse the repository at this point in the history
…d more simple configuration object
  • Loading branch information
Billlynch committed Oct 23, 2023
1 parent 83e3731 commit 9bf85c7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
25 changes: 13 additions & 12 deletions packages/client-http/src/client/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ export namespace Configuration {
}

export namespace FlagValue {
function valueMatchesSchema(value: any, schema: FlagSchema): boolean {
if (value === null || schema === null) {
return false;
}

if (typeof schema !== 'object') {
return typeof value === schema;
}

return Object.keys(value).every(key => valueMatchesSchema(value[key], schema[key]));
}

export function matches<T>({ schema }: FlagValue<T>, value: any): value is T {
return valueMatchesSchema(value, schema);
}
Expand Down Expand Up @@ -73,6 +61,19 @@ export namespace Configuration {
}
}
}

function valueMatchesSchema(value: any, schema: Configuration.FlagSchema): boolean {
if (value === null || schema === null) {
return false;
}

if (typeof schema !== 'object') {
return typeof value === schema;
}

return Object.keys(value).every(key => valueMatchesSchema(value[key], schema[key]));
}

export interface Configuration {
flags: Readonly<{
[name: string]: Configuration.Flag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function mapConfidenceReason(reason: Configuration.ResolveReason): ResolutionRea
return 'UNKNOWN';
case Configuration.ResolveReason.Match:
return 'TARGETING_MATCH';
default:
return 'DEFAULT';
}
return 'DEFAULT';
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function mapConfidenceReason(reason: Configuration.ResolveReason): ResolutionRea
return 'UNKNOWN';
case Configuration.ResolveReason.Match:
return 'TARGETING_MATCH';
default:
return 'DEFAULT';
}
return 'DEFAULT';
}
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,19 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@spotify-confidence/integration-react@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@spotify-confidence/integration-react/-/integration-react-0.0.4.tgz#383afc78c2db608b1bf75cb41c53d17512b6a77d"
integrity sha512-4NPbuMTweAz8sjsiEdFNBcB7im5XeETDc7ysyoLWw3vSN407fww+e3XDDhon+advI47TYvlUdvlEN75mOGnW4g==

"@spotify-confidence/openfeature-server-provider@^0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@spotify-confidence/openfeature-server-provider/-/openfeature-server-provider-0.0.3.tgz#e424b2626f291037c00133171a01c4915981b6d4"
integrity sha512-GaOyWe8yOC//LYHe+K3pn2wXUph88doXoLOz/6nup+J/xDc2F7kQIsFkA+TE+fI27CH8iaPUbO8ledTdKcYFjw==
dependencies:
"@spotify-confidence/client-http" "^0.0.2"
fast-deep-equal "^3.1.3"

"@spotify/eslint-config-base@^15.0.0":
version "15.0.0"
resolved "https://registry.yarnpkg.com/@spotify/eslint-config-base/-/eslint-config-base-15.0.0.tgz#fa8a003e656b1c14694528a487bb9e974e013e4d"
Expand Down

0 comments on commit 9bf85c7

Please sign in to comment.