diff --git a/package-lock.json b/package-lock.json index 71b18af..0526a3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "configcat-react", - "version": "5.0.2", + "version": "5.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "configcat-react", - "version": "5.0.2", + "version": "5.0.3", "license": "MIT", "dependencies": { "@configcat/sdk": "^1.0.2", diff --git a/package.json b/package.json index e755b5e..10ca646 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "configcat-react", - "version": "5.0.2", + "version": "5.0.3", "scripts": { "build": "npm run build:esm && npm run build:cjs", "build:esm": "tsc -p tsconfig.build.esm.json && gulp esm", diff --git a/sandbox/src/stories/Hoc.tsx b/sandbox/src/stories/Hoc.tsx index b95889a..4ce418b 100644 --- a/sandbox/src/stories/Hoc.tsx +++ b/sandbox/src/stories/Hoc.tsx @@ -1,12 +1,12 @@ import React, { useState } from 'react'; -import { ConfigCatProvider, LogLevel, withConfigCatClient, type WithConfigCatClientProps, User } from 'configcat-react'; +import { ConfigCatProvider, LogLevel, withConfigCatClient, type WithConfigCatClientProps, type IUser } from 'configcat-react'; export class HocComponent extends React.Component< - { featureFlagKey: string, user?: User } & WithConfigCatClientProps, + { featureFlagKey: string, user?: IUser } & WithConfigCatClientProps, { isEnabled: boolean, loading: boolean } > { - constructor(props: { featureFlagKey: string, user?: User } & WithConfigCatClientProps) { + constructor(props: { featureFlagKey: string, user?: IUser } & WithConfigCatClientProps) { super(props); this.state = { isEnabled: false, loading: true }; diff --git a/sandbox/src/stories/Hook.tsx b/sandbox/src/stories/Hook.tsx index 34dbb88..f88e5ee 100644 --- a/sandbox/src/stories/Hook.tsx +++ b/sandbox/src/stories/Hook.tsx @@ -1,9 +1,9 @@ import { useCallback, useState } from 'react'; -import { useConfigCatClient, useFeatureFlag, ConfigCatProvider, LogLevel, User } from 'configcat-react'; +import { useConfigCatClient, useFeatureFlag, ConfigCatProvider, LogLevel, type IUser } from 'configcat-react'; export const HookComponent = (args: { featureFlagKey: string }) => { const client = useConfigCatClient(); - const userObject = new User('asdad121212sd'); + const userObject: IUser = { identifier: 'asdad121212sd' }; const { value: isFeatureEnabled, loading } = useFeatureFlag(args.featureFlagKey, false, userObject); return ( diff --git a/sandbox/src/stories/MultipleConfigCatConfigs.tsx b/sandbox/src/stories/MultipleConfigCatConfigs.tsx index 1261f45..6c755c7 100644 --- a/sandbox/src/stories/MultipleConfigCatConfigs.tsx +++ b/sandbox/src/stories/MultipleConfigCatConfigs.tsx @@ -1,4 +1,4 @@ -import { ConfigCatProvider, useFeatureFlag, User, withConfigCatClient } from 'configcat-react'; +import { ConfigCatProvider, useFeatureFlag, withConfigCatClient, type IUser } from 'configcat-react'; import { HocComponent} from './Hoc'; @@ -9,7 +9,7 @@ const CC_SDK = { SHARED:"TODO - INSERT SDKKEY" }; -const userObject = new User('microFrontendUser1'); +const userObject: IUser = { identifier: 'microFrontendUser1' }; export const C1 = (args: { featureFlagKey: string, providerId: string }) => { diff --git a/src/ConfigCatHOC.tsx b/src/ConfigCatHOC.tsx index a811c16..232dab3 100644 --- a/src/ConfigCatHOC.tsx +++ b/src/ConfigCatHOC.tsx @@ -1,6 +1,6 @@ "use client"; -import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "@configcat/sdk"; +import type { IConfigCatClient, SettingTypeOf, SettingValue, IUser } from "@configcat/sdk"; import React from "react"; import { type ConfigCatContextData, getConfigCatContext } from "./ConfigCatContext"; import { createConfigCatProviderError } from "./ConfigCatProvider"; @@ -8,11 +8,11 @@ import { createConfigCatProviderError } from "./ConfigCatProvider"; export type GetValueType = ( key: string, defaultValue: T, - user?: User + user?: IUser ) => Promise>; const getValueFunction = (client: IConfigCatClient) => { - return async function (key: string, defaultValue: T, user?: User) { + return async function (key: string, defaultValue: T, user?: IUser) { return await client.getValueAsync(key, defaultValue, user); }; }; diff --git a/src/ConfigCatHooks.tsx b/src/ConfigCatHooks.tsx index 59a203e..7abf554 100644 --- a/src/ConfigCatHooks.tsx +++ b/src/ConfigCatHooks.tsx @@ -1,11 +1,11 @@ "use client"; -import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "@configcat/sdk"; +import type { IConfigCatClient, SettingTypeOf, SettingValue, IUser } from "@configcat/sdk"; import { useContext, useEffect, useState } from "react"; import { getConfigCatContext } from "./ConfigCatContext"; import { createConfigCatProviderError } from "./ConfigCatProvider"; -function useFeatureFlag(key: string, defaultValue: T, user?: User, providerId?: string): { +function useFeatureFlag(key: string, defaultValue: T, user?: IUser, providerId?: string): { value: SettingTypeOf; loading: boolean; } { diff --git a/src/ConfigCatProvider.tsx b/src/ConfigCatProvider.tsx index 02aae21..d4fae31 100644 --- a/src/ConfigCatProvider.tsx +++ b/src/ConfigCatProvider.tsx @@ -1,6 +1,6 @@ "use client"; -import type { ClientCacheState, Config, EvaluationDetails, HookEvents, IAutoPollOptions, IConfigCatClient, IConfigCatClientSnapshot, ILazyLoadingOptions, IManualPollOptions, RefreshResult, SettingKeyValue, SettingTypeOf, SettingValue, User } from "@configcat/sdk"; +import type { ClientCacheState, Config, EvaluationDetails, HookEvents, IAutoPollOptions, IConfigCatClient, IConfigCatClientSnapshot, ILazyLoadingOptions, IManualPollOptions, IUser, RefreshResult, SettingKeyValue, SettingTypeOf, SettingValue } from "@configcat/sdk"; import { Internals, LocalStorageConfigCache, PollingMode, XmlHttpRequestConfigFetcher } from "@configcat/sdk"; import React, { Component, type PropsWithChildren } from "react"; import { type ConfigCatContextData, ensureConfigCatContext } from "./ConfigCatContext"; @@ -124,19 +124,19 @@ export function createConfigCatProviderError(methodName: string, providerId?: st class ConfigCatClientStub implements IConfigCatClient { readonly isOffline = true; - getValueAsync(_key: string, _defaultValue: T, _user?: User): Promise> { + getValueAsync(_key: string, _defaultValue: T, _user?: IUser): Promise> { throw serverContextNotSupported(); } - getValueDetailsAsync(_key: string, _defaultValue: T, _user?: User): Promise>> { + getValueDetailsAsync(_key: string, _defaultValue: T, _user?: IUser): Promise>> { throw serverContextNotSupported(); } getAllKeysAsync(): Promise { throw serverContextNotSupported(); } - getAllValuesAsync(_user?: User): Promise[]> { + getAllValuesAsync(_user?: IUser): Promise[]> { throw serverContextNotSupported(); } - getAllValueDetailsAsync(_user?: User): Promise[]> { + getAllValueDetailsAsync(_user?: IUser): Promise[]> { throw serverContextNotSupported(); } getKeyAndValueAsync(_variationId: string): Promise | null> { @@ -151,7 +151,7 @@ class ConfigCatClientStub implements IConfigCatClient { snapshot(): IConfigCatClientSnapshot { throw serverContextNotSupported(); } - setDefaultUser(_defaultUser: User): void { + setDefaultUser(_defaultUser: IUser): void { throw serverContextNotSupported(); } clearDefaultUser(): void {