Skip to content

Commit

Permalink
style(web,client-http,examples): tidy imports and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Billlynch committed Oct 26, 2023
1 parent 1c02980 commit b011c53
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
22 changes: 11 additions & 11 deletions packages/client-http/src/client/ConfidenceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ type ResolveRequest = {
apply?: boolean;
flags?: string[];
};
type ResolveResponse = {
resolvedFlags: ResolvedFlag[];
resolveToken: string;
};
type ConfidenceSimpleTypes = { boolSchema: {} } | { doubleSchema: {} } | { intSchema: {} } | { stringSchema: {} };
type ConfidenceFlagSchema = {
schema: {
[key: string]: ConfidenceSimpleTypes | { structSchema: ConfidenceFlagSchema };
};
};

export type ResolvedFlag<T = any> = {
flag: string;
variant: string;
value?: T;
flagSchema?: ConfidenceFlagSchema;
reason: Configuration.ResolveReason;
};
type ResolveResponse = {
resolvedFlags: ResolvedFlag[];
resolveToken: string;
};

export type ConfidenceClientOptions = {
fetchImplementation: typeof fetch;
clientSecret: string;
Expand All @@ -35,12 +41,6 @@ export type AppliedFlag = {
flag: string;
applyTime: string;
};
type ConfidenceSimpleTypes = { boolSchema: {} } | { doubleSchema: {} } | { intSchema: {} } | { stringSchema: {} };
type ConfidenceFlagSchema = {
schema: {
[key: string]: ConfidenceSimpleTypes | { structSchema: ConfidenceFlagSchema };
};
};

export class ConfidenceClient {
private readonly backendApplyEnabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class ConfidenceWebProvider implements Provider {
}

const [flagName, ...pathParts] = flagKey.split('.');

try {
const flag = this.configuration.flags[flagName];

Expand All @@ -125,12 +126,14 @@ export class ConfidenceWebProvider implements Provider {
reason: 'ERROR',
};
}

if (flagValue.value === null) {
return {
value: defaultValue,
reason: mapConfidenceReason(flag.reason),
};
}

if (!Configuration.FlagValue.matches(flagValue, defaultValue)) {
logger.warn('Value for "%s" is of incorrect type', flagKey);
return {
Expand All @@ -141,6 +144,7 @@ export class ConfidenceWebProvider implements Provider {
}

this.applyManager.apply(this.configuration.resolveToken, flagName);

logger.info('Value for "%s" successfully evaluated', flagKey);
return {
value: flagValue.value as T,
Expand Down
5 changes: 3 additions & 2 deletions packages/openfeature-web-provider/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Provider } from '@openfeature/web-sdk';
import { ConfidenceWebProvider } from './ConfidenceWebProvider';
import { ConfidenceClient } from '@spotify-confidence/client-http';

export type ConfidenceWebProviderFactoryOptions = {
type ConfidenceWebProviderFactoryOptions = {
region: 'eu' | 'us';
fetchImplementation: typeof fetch;
clientSecret: string;
Expand All @@ -11,7 +12,7 @@ export type ConfidenceWebProviderFactoryOptions = {
};
};

export function createConfidenceWebProvider(options: ConfidenceWebProviderFactoryOptions): ConfidenceWebProvider {
export function createConfidenceWebProvider(options: ConfidenceWebProviderFactoryOptions): Provider {
const confidenceClient = new ConfidenceClient({
...options,
apply: !options.apply,
Expand Down
13 changes: 0 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2787,19 +2787,6 @@
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 b011c53

Please sign in to comment.