Skip to content

Commit 88985a5

Browse files
committed
Fix @openfeature imports and runtime errors
Signed-off-by: marcozabel <[email protected]>
1 parent aed7272 commit 88985a5

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

libs/providers/flagd/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
},
99
"peerDependencies": {
1010
"@grpc/grpc-js": "~1.8.0 || ~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0 || ~1.13.0 || ~1.14.0",
11-
"@openfeature/server-sdk": "^1.17.0",
12-
"@openfeature/web-sdk": "^1.6.0",
13-
"@openfeature/core": "^1.9.0"
11+
"@openfeature/server-sdk": "^1.17.0"
1412
},
1513
"dependencies": {
1614
"lru-cache": "^11.0.0",
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { Hook } from '@openfeature/web-sdk';
2-
import type { EvaluationContext } from '@openfeature/server-sdk';
3-
import type { BeforeHookContext, HookHints } from '@openfeature/core';
1+
import type { Hook, EvaluationContext, BeforeHookContext, HookHints } from '@openfeature/server-sdk';
42

53
export class SyncMetadataHook implements Hook {
64
enrichedContext: () => EvaluationContext;
@@ -9,7 +7,7 @@ export class SyncMetadataHook implements Hook {
97
this.enrichedContext = enrichedContext;
108
}
119

12-
public before(): EvaluationContext {
13-
return this.enrichedContext.apply(this);
10+
public before(hookContext: BeforeHookContext, hookHints?: HookHints): EvaluationContext {
11+
return this.enrichedContext();
1412
}
1513
}

libs/providers/flagd/src/lib/configuration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DEFAULT_MAX_CACHE_SIZE } from './constants';
2-
import type { EvaluationContext } from '@openfeature/core';
2+
import type { EvaluationContext } from '@openfeature/server-sdk';
33

44
export type CacheOption = 'lru' | 'disabled';
55
export type ResolverType = 'rpc' | 'in-process';
@@ -92,7 +92,7 @@ interface FlagdConfig extends Config {
9292
* represented as a {@link dev.openfeature.sdk.Structure}, is passed as an argument.
9393
*
9494
* This function runs every time the provider (re)connects, and its result is cached and used in every evaluation.
95-
* By default, the entire sync response (converted to a Structure) is used.
95+
* By default, the entire sync response (as a JSON Object) is used.
9696
*/
9797
contextEnricher: (syncContext: { [key: string]: string } | null) => EvaluationContext;
9898
}
@@ -106,7 +106,7 @@ const DEFAULT_CONFIG: Omit<FlagdConfig, 'port' | 'resolverType'> = {
106106
selector: '',
107107
cache: 'lru',
108108
maxCacheSize: DEFAULT_MAX_CACHE_SIZE,
109-
contextEnricher: (syncContext: { [key: string]: string } | null) => syncContext as EvaluationContext,
109+
contextEnricher: (syncContext: { [key: string]: string } | null) => syncContext ?? {},
110110
};
111111

112112
const DEFAULT_RPC_CONFIG: FlagdConfig = { ...DEFAULT_CONFIG, resolverType: 'rpc', port: 8013 };

libs/providers/flagd/src/lib/flagd-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getConfig } from './configuration';
55
import { GRPCService } from './service/grpc/grpc-service';
66
import type { Service } from './service/service';
77
import { InProcessService } from './service/in-process/in-process-service';
8-
import type { Hook } from '@openfeature/web-sdk';
8+
import type { Hook } from '@openfeature/server-sdk';
99
import { SyncMetadataHook } from './SyncMetadataHook';
1010

1111
export class FlagdProvider implements Provider {
@@ -36,7 +36,7 @@ export class FlagdProvider implements Provider {
3636

3737
if (service === undefined) {
3838
if (config.resolverType === 'in-process') {
39-
this._service = new InProcessService(config, this.setSyncContext, undefined, logger);
39+
this._service = new InProcessService(config, this.setSyncContext.bind(this), undefined, logger);
4040

4141
if (config?.offlineFlagSourcePath === undefined) {
4242
this.hooks = [new SyncMetadataHook(() => config.contextEnricher(this.getSyncContext()))];

0 commit comments

Comments
 (0)