@flagdeck/openfeature 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/web.ts","../src/context-converter.ts"],"sourcesContent":["import {\n type Provider,\n type ResolutionDetails,\n type EvaluationContext,\n type JsonValue,\n type ProviderMetadata,\n type Paradigm,\n ErrorCode,\n OpenFeatureEventEmitter,\n ProviderEvents,\n} from '@openfeature/web-sdk';\nimport {\n Flagdeck,\n type FlagdeckClient,\n type FlagdeckOptions,\n type EvaluationResult,\n} from '@flagdeck/js';\nimport {\n toFlagdeckContext,\n fromFlagdeckResult,\n matchesType,\n Reason,\n OpenFeatureErrorCode,\n type ValueKind,\n type OpenFeatureErrorCodeValue,\n type ResolutionDetailsLike,\n} from './context-converter';\n\nconst PROVIDER_NAME = 'flagdeck';\n\n/** Converter string error codes -> the OpenFeature web `ErrorCode` enum. */\nconst ERROR_CODE: Record<OpenFeatureErrorCodeValue, ErrorCode> = {\n [OpenFeatureErrorCode.FLAG_NOT_FOUND]: ErrorCode.FLAG_NOT_FOUND,\n [OpenFeatureErrorCode.TYPE_MISMATCH]: ErrorCode.TYPE_MISMATCH,\n [OpenFeatureErrorCode.INVALID_CONTEXT]: ErrorCode.INVALID_CONTEXT,\n [OpenFeatureErrorCode.GENERAL]: ErrorCode.GENERAL,\n};\n\nfunction toResolutionDetails<T>(\n like: ResolutionDetailsLike<T>\n): ResolutionDetails<T> {\n const details: ResolutionDetails<T> = { value: like.value };\n if (like.reason) details.reason = like.reason;\n if (like.variant) details.variant = like.variant;\n if (like.errorCode) details.errorCode = ERROR_CODE[like.errorCode];\n if (like.errorMessage) details.errorMessage = like.errorMessage;\n return details;\n}\n\nfunction isFlagdeckClient(\n init: FlagdeckClient | FlagdeckOptions\n): init is FlagdeckClient {\n return typeof (init as Partial<FlagdeckClient>).evaluateFlag === 'function';\n}\n\n/** Either a pre-built Flagdeck client or the options to construct one. */\nexport type FlagdeckWebProviderInit = FlagdeckClient | FlagdeckOptions;\n\ntype FlagChangeListener = (newValue: unknown, oldValue: unknown) => void;\n\ntype FlagdeckEvaluator = Pick<FlagdeckClient, 'evaluateFlag' | 'destroy'> & {\n onFlagChange?(flagKey: string, listener: FlagChangeListener): unknown;\n off?(event: string, listener: FlagChangeListener): unknown;\n};\n\n/**\n * OpenFeature web (client-side) provider backed by Flagdeck.\n *\n * OpenFeature's web paradigm resolves flags *synchronously* against\n * already-available state, while the Flagdeck client evaluates asynchronously.\n * The provider bridges the two: a resolver reads the in-memory cache and, on a\n * miss, returns the caller default while kicking off a background evaluation.\n * When that evaluation lands it populates the cache and emits\n * `ConfigurationChanged`, so the OpenFeature client re-evaluates and the real\n * value is returned. When the Flagdeck client reports a realtime change for a\n * cached flag, the provider re-evaluates it and emits `ConfigurationChanged`\n * again. The cache is cleared whenever the evaluation context changes. It\n * reuses the same context converter as the server provider.\n */\nexport class FlagdeckWebProvider implements Provider {\n readonly metadata: ProviderMetadata = { name: PROVIDER_NAME };\n readonly runsOn: Paradigm = 'client';\n readonly events = new OpenFeatureEventEmitter();\n\n private readonly client: FlagdeckEvaluator;\n private readonly cache = new Map<string, EvaluationResult>();\n private readonly inflight = new Set<string>();\n private readonly listeners = new Map<string, FlagChangeListener>();\n private lastContext: EvaluationContext = {};\n\n constructor(init: FlagdeckWebProviderInit) {\n this.client = isFlagdeckClient(init) ? init : new Flagdeck(init);\n }\n\n async initialize(context?: EvaluationContext): Promise<void> {\n if (context) this.lastContext = context;\n // Nothing to prefetch: OpenFeature does not hand the provider a flag list,\n // so flags are fetched lazily on first access (see resolve/prefetch).\n }\n\n async onContextChange(\n _oldContext: EvaluationContext,\n newContext: EvaluationContext\n ): Promise<void> {\n // The identity/attributes changed, so cached results and their realtime\n // subscriptions no longer apply.\n this.lastContext = newContext;\n this.unsubscribeAll();\n this.cache.clear();\n this.inflight.clear();\n this.events.emit(ProviderEvents.ConfigurationChanged, {\n message: 'evaluation context changed',\n });\n }\n\n async onClose(): Promise<void> {\n this.unsubscribeAll();\n await this.client.destroy();\n }\n\n resolveBooleanEvaluation(\n flagKey: string,\n defaultValue: boolean,\n context: EvaluationContext\n ): ResolutionDetails<boolean> {\n return this.resolve(flagKey, defaultValue, context, 'boolean');\n }\n\n resolveStringEvaluation(\n flagKey: string,\n defaultValue: string,\n context: EvaluationContext\n ): ResolutionDetails<string> {\n return this.resolve(flagKey, defaultValue, context, 'string');\n }\n\n resolveNumberEvaluation(\n flagKey: string,\n defaultValue: number,\n context: EvaluationContext\n ): ResolutionDetails<number> {\n return this.resolve(flagKey, defaultValue, context, 'number');\n }\n\n resolveObjectEvaluation<T extends JsonValue>(\n flagKey: string,\n defaultValue: T,\n context: EvaluationContext\n ): ResolutionDetails<T> {\n return this.resolve(flagKey, defaultValue, context, 'object');\n }\n\n private resolve<T>(\n flagKey: string,\n defaultValue: T,\n context: EvaluationContext,\n kind: ValueKind\n ): ResolutionDetails<T> {\n this.lastContext = context;\n const cached = this.cache.get(flagKey);\n if (!cached) {\n // Cold: fetch in the background and serve the default for now. The\n // ConfigurationChanged event fired on arrival makes the client re-resolve.\n this.prefetch(flagKey, context);\n return { value: defaultValue, reason: Reason.DEFAULT };\n }\n\n const details = fromFlagdeckResult(cached, defaultValue);\n if (details.errorCode) return toResolutionDetails(details);\n\n if (!matchesType(details.value, kind)) {\n return {\n value: defaultValue,\n reason: Reason.ERROR,\n errorCode: ErrorCode.TYPE_MISMATCH,\n errorMessage: `Flag \"${flagKey}\" did not resolve to a ${kind} value`,\n };\n }\n\n return toResolutionDetails(details);\n }\n\n private prefetch(flagKey: string, context: EvaluationContext): void {\n if (this.inflight.has(flagKey)) return;\n this.inflight.add(flagKey);\n\n this.client\n .evaluateFlag(flagKey, toFlagdeckContext(context))\n .then(result => {\n this.cache.set(flagKey, result);\n this.subscribe(flagKey);\n this.events.emit(ProviderEvents.ConfigurationChanged, {\n flagsChanged: [flagKey],\n });\n })\n .catch(() => {\n // Leave it uncached; the next resolve retries the fetch.\n })\n .finally(() => {\n this.inflight.delete(flagKey);\n });\n }\n\n /** Subscribe once per flag so realtime changes refresh the cached result. */\n private subscribe(flagKey: string): void {\n if (this.listeners.has(flagKey) || !this.client.onFlagChange) return;\n const listener: FlagChangeListener = () => this.refresh(flagKey);\n this.client.onFlagChange(flagKey, listener);\n this.listeners.set(flagKey, listener);\n }\n\n /** Re-evaluate a flag after a realtime change and notify OpenFeature. */\n private refresh(flagKey: string): void {\n this.client\n .evaluateFlag(flagKey, toFlagdeckContext(this.lastContext))\n .then(result => {\n this.cache.set(flagKey, result);\n this.events.emit(ProviderEvents.ConfigurationChanged, {\n flagsChanged: [flagKey],\n });\n })\n .catch(() => {\n // Keep the previous cached value; a later change retries.\n });\n }\n\n private unsubscribeAll(): void {\n if (this.client.off) {\n for (const [flagKey, listener] of this.listeners) {\n // Matches the SDK's per-flag change event name.\n this.client.off(`change:${flagKey}`, listener);\n }\n }\n this.listeners.clear();\n }\n}\n","import type {\n EvaluationContext as FlagdeckContext,\n EvaluationResult,\n EvaluationSource,\n EvaluationErrorCode,\n} from '@flagdeck/js';\n\n/**\n * Minimal structural shape of an OpenFeature `EvaluationContext`. The real\n * `EvaluationContext` from `@openfeature/server-sdk` is assignable to this, so\n * the provider passes its context straight through. Kept local so the converter\n * stays a pure unit that can be type-checked and tested without the OpenFeature\n * SDK installed.\n */\nexport interface OpenFeatureContextLike {\n targetingKey?: string;\n [key: string]: unknown;\n}\n\n/**\n * OpenFeature standard resolution reasons we emit. String values mirror\n * `StandardResolutionReasons` in `@openfeature/server-sdk`.\n */\nexport const Reason = {\n TARGETING_MATCH: 'TARGETING_MATCH',\n SPLIT: 'SPLIT',\n DEFAULT: 'DEFAULT',\n CACHED: 'CACHED',\n ERROR: 'ERROR',\n} as const;\nexport type ResolutionReason = (typeof Reason)[keyof typeof Reason];\n\n/**\n * OpenFeature error codes we emit. String values mirror `ErrorCode` in\n * `@openfeature/server-sdk`.\n */\nexport const OpenFeatureErrorCode = {\n FLAG_NOT_FOUND: 'FLAG_NOT_FOUND',\n TYPE_MISMATCH: 'TYPE_MISMATCH',\n INVALID_CONTEXT: 'INVALID_CONTEXT',\n GENERAL: 'GENERAL',\n} as const;\nexport type OpenFeatureErrorCodeValue =\n (typeof OpenFeatureErrorCode)[keyof typeof OpenFeatureErrorCode];\n\n/**\n * Structural mirror of OpenFeature's `ResolutionDetails<T>`. Values of this\n * shape are assignable to the real `ResolutionDetails<T>`, so the provider's\n * resolvers can return them directly.\n */\nexport interface ResolutionDetailsLike<T> {\n value: T;\n variant?: string;\n reason?: string;\n errorCode?: OpenFeatureErrorCodeValue;\n errorMessage?: string;\n}\n\nconst TARGETING_KEY = 'targetingKey';\nconst SESSION_ID_KEY = 'sessionId';\n\n/**\n * Flagdeck evaluation source -> OpenFeature resolution reason.\n *\n * - *_targeting -> TARGETING_MATCH (an explicit rule/segment/user match)\n * - *_rollout, variant, variant_fallback -> SPLIT (percentage bucketing)\n * - default -> DEFAULT\n * - offline -> CACHED (served from the SDK's offline store)\n * - error -> ERROR\n */\nconst SOURCE_TO_REASON: Record<EvaluationSource, ResolutionReason> = {\n user_targeting: Reason.TARGETING_MATCH,\n environment_targeting: Reason.TARGETING_MATCH,\n global_targeting: Reason.TARGETING_MATCH,\n environment_rollout: Reason.SPLIT,\n global_rollout: Reason.SPLIT,\n variant: Reason.SPLIT,\n variant_fallback: Reason.SPLIT,\n default: Reason.DEFAULT,\n offline: Reason.CACHED,\n error: Reason.ERROR,\n};\n\n/** Flagdeck error code -> OpenFeature error code; unmapped codes fall to GENERAL. */\nconst ERROR_CODE_TO_OPENFEATURE: Partial<\n Record<EvaluationErrorCode, OpenFeatureErrorCodeValue>\n> = {\n FLAG_NOT_FOUND: OpenFeatureErrorCode.FLAG_NOT_FOUND,\n INVALID_CONTEXT: OpenFeatureErrorCode.INVALID_CONTEXT,\n};\n\nfunction mapErrorCode(code?: EvaluationErrorCode): OpenFeatureErrorCodeValue {\n if (!code) return OpenFeatureErrorCode.GENERAL;\n return ERROR_CODE_TO_OPENFEATURE[code] ?? OpenFeatureErrorCode.GENERAL;\n}\n\n/**\n * Translate an OpenFeature `EvaluationContext` into Flagdeck's native context.\n *\n * - `targetingKey` -> `userId`. OpenFeature's bucketing identity is Flagdeck's\n * primary identity, so rollout and variant stickiness line up 1:1.\n * - a string `sessionId` attribute -> native `sessionId`. The engine buckets on\n * `userId || sessionId`, so promoting it preserves anonymous stickiness; a\n * non-string `sessionId` is left in `attributes` rather than dropped.\n * - every other entry -> `attributes[key]`, unchanged. Scalars and nested\n * objects pass through; the engine resolves dot-paths such as `account.id`.\n *\n * An empty or missing context yields an empty Flagdeck context.\n */\nexport function toFlagdeckContext(\n context?: OpenFeatureContextLike | null\n): FlagdeckContext {\n const result: FlagdeckContext = {};\n if (!context) return result;\n\n const attributes: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(context)) {\n if (key === TARGETING_KEY) continue; // mapped to userId below\n if (key === SESSION_ID_KEY && typeof value === 'string') {\n result.sessionId = value;\n continue;\n }\n if (value !== undefined) attributes[key] = value;\n }\n\n if (typeof context.targetingKey === 'string' && context.targetingKey) {\n result.userId = context.targetingKey;\n }\n\n if (Object.keys(attributes).length > 0) {\n result.attributes = attributes as FlagdeckContext['attributes'];\n }\n\n return result;\n}\n\n/**\n * Translate a Flagdeck `EvaluationResult` into an OpenFeature\n * `ResolutionDetails`. On an error result the caller's `defaultValue` is\n * returned with the mapped error code and `reason: ERROR` — OpenFeature never\n * throws to the caller.\n *\n * Runtime type checking (OpenFeature's `TYPE_MISMATCH`) is applied by the\n * provider's typed resolvers, not here; this function maps reason, variant and\n * error only.\n */\nexport function fromFlagdeckResult<T>(\n result: EvaluationResult,\n defaultValue: T\n): ResolutionDetailsLike<T> {\n if (result.source === 'error' || result.error) {\n const details: ResolutionDetailsLike<T> = {\n value: defaultValue,\n reason: Reason.ERROR,\n errorCode: mapErrorCode(result.error?.code),\n };\n if (result.error?.message) details.errorMessage = result.error.message;\n return details;\n }\n\n const details: ResolutionDetailsLike<T> = {\n value: result.value as T,\n reason: SOURCE_TO_REASON[result.source] ?? Reason.DEFAULT,\n };\n if (result.variant?.name) details.variant = result.variant.name;\n return details;\n}\n\n/** The value kinds OpenFeature's typed resolvers check against. */\nexport type ValueKind = 'boolean' | 'string' | 'number' | 'object';\n\n/**\n * Runtime type check both providers apply before returning a resolved value:\n * OpenFeature returns the caller default with TYPE_MISMATCH rather than coercing.\n */\nexport function matchesType(value: unknown, kind: ValueKind): boolean {\n switch (kind) {\n case 'boolean':\n return typeof value === 'boolean';\n case 'string':\n return typeof value === 'string';\n case 'number':\n return typeof value === 'number' && !Number.isNaN(value);\n case 'object':\n return typeof value === 'object' && value !== null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAUO;AACP,gBAKO;;;ACOA,IAAM,SAAS;AAAA,EACpB,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;AAOO,IAAM,uBAAuB;AAAA,EAClC,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,SAAS;AACX;AAiBA,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AAWvB,IAAM,mBAA+D;AAAA,EACnE,gBAAgB,OAAO;AAAA,EACvB,uBAAuB,OAAO;AAAA,EAC9B,kBAAkB,OAAO;AAAA,EACzB,qBAAqB,OAAO;AAAA,EAC5B,gBAAgB,OAAO;AAAA,EACvB,SAAS,OAAO;AAAA,EAChB,kBAAkB,OAAO;AAAA,EACzB,SAAS,OAAO;AAAA,EAChB,SAAS,OAAO;AAAA,EAChB,OAAO,OAAO;AAChB;AAGA,IAAM,4BAEF;AAAA,EACF,gBAAgB,qBAAqB;AAAA,EACrC,iBAAiB,qBAAqB;AACxC;AAEA,SAAS,aAAa,MAAuD;AAC3E,MAAI,CA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.ts
10
+ import {
11
+ ErrorCode,
12
+ OpenFeatureEventEmitter,
13
+ ProviderEvents
14
+ } from "@openfeature/web-sdk";
15
+ import {
16
+ Flagdeck
17
+ } from "@flagdeck/js";
18
+ var PROVIDER_NAME = "flagdeck";
19
+ var ERROR_CODE = {
20
+ [OpenFeatureErrorCode.FLAG_NOT_FOUND]: ErrorCode.FLAG_NOT_FOUND,
21
+ [OpenFeatureErrorCode.TYPE_MISMATCH]: ErrorCode.TYPE_MISMATCH,
22
+ [OpenFeatureErrorCode.INVALID_CONTEXT]: ErrorCode.INVALID_CONTEXT,
23
+ [OpenFeatureErrorCode.GENERAL]: ErrorCode.GENERAL
24
+ };
25
+ function toResolutionDetails(like) {
26
+ const details = { value: like.value };
27
+ if (like.reason) details.reason = like.reason;
28
+ if (like.variant) details.variant = like.variant;
29
+ if (like.errorCode) details.errorCode = ERROR_CODE[like.errorCode];
30
+ if (like.errorMessage) details.errorMessage = like.errorMessage;
31
+ return details;
32
+ }
33
+ function isFlagdeckClient(init) {
34
+ return typeof init.evaluateFlag === "function";
35
+ }
36
+ var FlagdeckWebProvider = class {
37
+ constructor(init) {
38
+ this.metadata = { name: PROVIDER_NAME };
39
+ this.runsOn = "client";
40
+ this.events = new OpenFeatureEventEmitter();
41
+ this.cache = /* @__PURE__ */ new Map();
42
+ this.inflight = /* @__PURE__ */ new Set();
43
+ this.listeners = /* @__PURE__ */ new Map();
44
+ this.lastContext = {};
45
+ this.client = isFlagdeckClient(init) ? init : new Flagdeck(init);
46
+ }
47
+ async initialize(context) {
48
+ if (context) this.lastContext = context;
49
+ }
50
+ async onContextChange(_oldContext, newContext) {
51
+ this.lastContext = newContext;
52
+ this.unsubscribeAll();
53
+ this.cache.clear();
54
+ this.inflight.clear();
55
+ this.events.emit(ProviderEvents.ConfigurationChanged, {
56
+ message: "evaluation context changed"
57
+ });
58
+ }
59
+ async onClose() {
60
+ this.unsubscribeAll();
61
+ await this.client.destroy();
62
+ }
63
+ resolveBooleanEvaluation(flagKey, defaultValue, context) {
64
+ return this.resolve(flagKey, defaultValue, context, "boolean");
65
+ }
66
+ resolveStringEvaluation(flagKey, defaultValue, context) {
67
+ return this.resolve(flagKey, defaultValue, context, "string");
68
+ }
69
+ resolveNumberEvaluation(flagKey, defaultValue, context) {
70
+ return this.resolve(flagKey, defaultValue, context, "number");
71
+ }
72
+ resolveObjectEvaluation(flagKey, defaultValue, context) {
73
+ return this.resolve(flagKey, defaultValue, context, "object");
74
+ }
75
+ resolve(flagKey, defaultValue, context, kind) {
76
+ this.lastContext = context;
77
+ const cached = this.cache.get(flagKey);
78
+ if (!cached) {
79
+ this.prefetch(flagKey, context);
80
+ return { value: defaultValue, reason: Reason.DEFAULT };
81
+ }
82
+ const details = fromFlagdeckResult(cached, defaultValue);
83
+ if (details.errorCode) return toResolutionDetails(details);
84
+ if (!matchesType(details.value, kind)) {
85
+ return {
86
+ value: defaultValue,
87
+ reason: Reason.ERROR,
88
+ errorCode: ErrorCode.TYPE_MISMATCH,
89
+ errorMessage: `Flag "${flagKey}" did not resolve to a ${kind} value`
90
+ };
91
+ }
92
+ return toResolutionDetails(details);
93
+ }
94
+ prefetch(flagKey, context) {
95
+ if (this.inflight.has(flagKey)) return;
96
+ this.inflight.add(flagKey);
97
+ this.client.evaluateFlag(flagKey, toFlagdeckContext(context)).then((result) => {
98
+ this.cache.set(flagKey, result);
99
+ this.subscribe(flagKey);
100
+ this.events.emit(ProviderEvents.ConfigurationChanged, {
101
+ flagsChanged: [flagKey]
102
+ });
103
+ }).catch(() => {
104
+ }).finally(() => {
105
+ this.inflight.delete(flagKey);
106
+ });
107
+ }
108
+ /** Subscribe once per flag so realtime changes refresh the cached result. */
109
+ subscribe(flagKey) {
110
+ if (this.listeners.has(flagKey) || !this.client.onFlagChange) return;
111
+ const listener = () => this.refresh(flagKey);
112
+ this.client.onFlagChange(flagKey, listener);
113
+ this.listeners.set(flagKey, listener);
114
+ }
115
+ /** Re-evaluate a flag after a realtime change and notify OpenFeature. */
116
+ refresh(flagKey) {
117
+ this.client.evaluateFlag(flagKey, toFlagdeckContext(this.lastContext)).then((result) => {
118
+ this.cache.set(flagKey, result);
119
+ this.events.emit(ProviderEvents.ConfigurationChanged, {
120
+ flagsChanged: [flagKey]
121
+ });
122
+ }).catch(() => {
123
+ });
124
+ }
125
+ unsubscribeAll() {
126
+ if (this.client.off) {
127
+ for (const [flagKey, listener] of this.listeners) {
128
+ this.client.off(`change:${flagKey}`, listener);
129
+ }
130
+ }
131
+ this.listeners.clear();
132
+ }
133
+ };
134
+ export {
135
+ FlagdeckWebProvider
136
+ };
137
+ //# sourceMappingURL=web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/web.ts"],"sourcesContent":["import {\n type Provider,\n type ResolutionDetails,\n type EvaluationContext,\n type JsonValue,\n type ProviderMetadata,\n type Paradigm,\n ErrorCode,\n OpenFeatureEventEmitter,\n ProviderEvents,\n} from '@openfeature/web-sdk';\nimport {\n Flagdeck,\n type FlagdeckClient,\n type FlagdeckOptions,\n type EvaluationResult,\n} from '@flagdeck/js';\nimport {\n toFlagdeckContext,\n fromFlagdeckResult,\n matchesType,\n Reason,\n OpenFeatureErrorCode,\n type ValueKind,\n type OpenFeatureErrorCodeValue,\n type ResolutionDetailsLike,\n} from './context-converter';\n\nconst PROVIDER_NAME = 'flagdeck';\n\n/** Converter string error codes -> the OpenFeature web `ErrorCode` enum. */\nconst ERROR_CODE: Record<OpenFeatureErrorCodeValue, ErrorCode> = {\n [OpenFeatureErrorCode.FLAG_NOT_FOUND]: ErrorCode.FLAG_NOT_FOUND,\n [OpenFeatureErrorCode.TYPE_MISMATCH]: ErrorCode.TYPE_MISMATCH,\n [OpenFeatureErrorCode.INVALID_CONTEXT]: ErrorCode.INVALID_CONTEXT,\n [OpenFeatureErrorCode.GENERAL]: ErrorCode.GENERAL,\n};\n\nfunction toResolutionDetails<T>(\n like: ResolutionDetailsLike<T>\n): ResolutionDetails<T> {\n const details: ResolutionDetails<T> = { value: like.value };\n if (like.reason) details.reason = like.reason;\n if (like.variant) details.variant = like.variant;\n if (like.errorCode) details.errorCode = ERROR_CODE[like.errorCode];\n if (like.errorMessage) details.errorMessage = like.errorMessage;\n return details;\n}\n\nfunction isFlagdeckClient(\n init: FlagdeckClient | FlagdeckOptions\n): init is FlagdeckClient {\n return typeof (init as Partial<FlagdeckClient>).evaluateFlag === 'function';\n}\n\n/** Either a pre-built Flagdeck client or the options to construct one. */\nexport type FlagdeckWebProviderInit = FlagdeckClient | FlagdeckOptions;\n\ntype FlagChangeListener = (newValue: unknown, oldValue: unknown) => void;\n\ntype FlagdeckEvaluator = Pick<FlagdeckClient, 'evaluateFlag' | 'destroy'> & {\n onFlagChange?(flagKey: string, listener: FlagChangeListener): unknown;\n off?(event: string, listener: FlagChangeListener): unknown;\n};\n\n/**\n * OpenFeature web (client-side) provider backed by Flagdeck.\n *\n * OpenFeature's web paradigm resolves flags *synchronously* against\n * already-available state, while the Flagdeck client evaluates asynchronously.\n * The provider bridges the two: a resolver reads the in-memory cache and, on a\n * miss, returns the caller default while kicking off a background evaluation.\n * When that evaluation lands it populates the cache and emits\n * `ConfigurationChanged`, so the OpenFeature client re-evaluates and the real\n * value is returned. When the Flagdeck client reports a realtime change for a\n * cached flag, the provider re-evaluates it and emits `ConfigurationChanged`\n * again. The cache is cleared whenever the evaluation context changes. It\n * reuses the same context converter as the server provider.\n */\nexport class FlagdeckWebProvider implements Provider {\n readonly metadata: ProviderMetadata = { name: PROVIDER_NAME };\n readonly runsOn: Paradigm = 'client';\n readonly events = new OpenFeatureEventEmitter();\n\n private readonly client: FlagdeckEvaluator;\n private readonly cache = new Map<string, EvaluationResult>();\n private readonly inflight = new Set<string>();\n private readonly listeners = new Map<string, FlagChangeListener>();\n private lastContext: EvaluationContext = {};\n\n constructor(init: FlagdeckWebProviderInit) {\n this.client = isFlagdeckClient(init) ? init : new Flagdeck(init);\n }\n\n async initialize(context?: EvaluationContext): Promise<void> {\n if (context) this.lastContext = context;\n // Nothing to prefetch: OpenFeature does not hand the provider a flag list,\n // so flags are fetched lazily on first access (see resolve/prefetch).\n }\n\n async onContextChange(\n _oldContext: EvaluationContext,\n newContext: EvaluationContext\n ): Promise<void> {\n // The identity/attributes changed, so cached results and their realtime\n // subscriptions no longer apply.\n this.lastContext = newContext;\n this.unsubscribeAll();\n this.cache.clear();\n this.inflight.clear();\n this.events.emit(ProviderEvents.ConfigurationChanged, {\n message: 'evaluation context changed',\n });\n }\n\n async onClose(): Promise<void> {\n this.unsubscribeAll();\n await this.client.destroy();\n }\n\n resolveBooleanEvaluation(\n flagKey: string,\n defaultValue: boolean,\n context: EvaluationContext\n ): ResolutionDetails<boolean> {\n return this.resolve(flagKey, defaultValue, context, 'boolean');\n }\n\n resolveStringEvaluation(\n flagKey: string,\n defaultValue: string,\n context: EvaluationContext\n ): ResolutionDetails<string> {\n return this.resolve(flagKey, defaultValue, context, 'string');\n }\n\n resolveNumberEvaluation(\n flagKey: string,\n defaultValue: number,\n context: EvaluationContext\n ): ResolutionDetails<number> {\n return this.resolve(flagKey, defaultValue, context, 'number');\n }\n\n resolveObjectEvaluation<T extends JsonValue>(\n flagKey: string,\n defaultValue: T,\n context: EvaluationContext\n ): ResolutionDetails<T> {\n return this.resolve(flagKey, defaultValue, context, 'object');\n }\n\n private resolve<T>(\n flagKey: string,\n defaultValue: T,\n context: EvaluationContext,\n kind: ValueKind\n ): ResolutionDetails<T> {\n this.lastContext = context;\n const cached = this.cache.get(flagKey);\n if (!cached) {\n // Cold: fetch in the background and serve the default for now. The\n // ConfigurationChanged event fired on arrival makes the client re-resolve.\n this.prefetch(flagKey, context);\n return { value: defaultValue, reason: Reason.DEFAULT };\n }\n\n const details = fromFlagdeckResult(cached, defaultValue);\n if (details.errorCode) return toResolutionDetails(details);\n\n if (!matchesType(details.value, kind)) {\n return {\n value: defaultValue,\n reason: Reason.ERROR,\n errorCode: ErrorCode.TYPE_MISMATCH,\n errorMessage: `Flag \"${flagKey}\" did not resolve to a ${kind} value`,\n };\n }\n\n return toResolutionDetails(details);\n }\n\n private prefetch(flagKey: string, context: EvaluationContext): void {\n if (this.inflight.has(flagKey)) return;\n this.inflight.add(flagKey);\n\n this.client\n .evaluateFlag(flagKey, toFlagdeckContext(context))\n .then(result => {\n this.cache.set(flagKey, result);\n this.subscribe(flagKey);\n this.events.emit(ProviderEvents.ConfigurationChanged, {\n flagsChanged: [flagKey],\n });\n })\n .catch(() => {\n // Leave it uncached; the next resolve retries the fetch.\n })\n .finally(() => {\n this.inflight.delete(flagKey);\n });\n }\n\n /** Subscribe once per flag so realtime changes refresh the cached result. */\n private subscribe(flagKey: string): void {\n if (this.listeners.has(flagKey) || !this.client.onFlagChange) return;\n const listener: FlagChangeListener = () => this.refresh(flagKey);\n this.client.onFlagChange(flagKey, listener);\n this.listeners.set(flagKey, listener);\n }\n\n /** Re-evaluate a flag after a realtime change and notify OpenFeature. */\n private refresh(flagKey: string): void {\n this.client\n .evaluateFlag(flagKey, toFlagdeckContext(this.lastContext))\n .then(result => {\n this.cache.set(flagKey, result);\n this.events.emit(ProviderEvents.ConfigurationChanged, {\n flagsChanged: [flagKey],\n });\n })\n .catch(() => {\n // Keep the previous cached value; a later change retries.\n });\n }\n\n private unsubscribeAll(): void {\n if (this.client.off) {\n for (const [flagKey, listener] of this.listeners) {\n // Matches the SDK's per-flag change event name.\n this.client.off(`change:${flagKey}`, listener);\n }\n }\n this.listeners.clear();\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAAA,EAOE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAIK;AAYP,IAAM,gBAAgB;AAGtB,IAAM,aAA2D;AAAA,EAC/D,CAAC,qBAAqB,cAAc,GAAG,UAAU;AAAA,EACjD,CAAC,qBAAqB,aAAa,GAAG,UAAU;AAAA,EAChD,CAAC,qBAAqB,eAAe,GAAG,UAAU;AAAA,EAClD,CAAC,qBAAqB,OAAO,GAAG,UAAU;AAC5C;AAEA,SAAS,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vC,QAAI,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,KAAK,OAAO,aAAc;AAC9D,UAAM,WAA+B,MAAM,KAAK,QAAQ,OAAO;AAC/D,SAAK,OAAO,aAAa,SAAS,QAAQ;AAC1C,SAAK,UAAU,IAAI,SAAS,QAAQ;AAAA,EACtC;AAAA;AAAA,EAGQ,QAAQ,SAAuB;AACrC,SAAK,OACF,aAAa,SAAS,kBAAkB,KAAK,WAAW,CAAC,EACzD,KAAK,YAAU;AACd,WAAK,MAAM,IAAI,SAAS,MAAM;AAC9B,WAAK,OAAO,KAAK,eAAe,sBAAsB;AAAA,QACpD,cAAc,CAAC,OAAO;AAAA,MACxB,CAAC;AAAA,IACH,CAAC,EACA,MAAM,MAAM;AAAA,IAEb,CAAC;AAAA,EACL;AAAA,EAEQ,iBAAuB;AAC7B,QAAI,KAAK,OAAO,KAAK;AACnB,iBAAW,CAAC,SAAS,QAAQ,KAAK,KAAK,WAAW;AAEhD,aAAK,OAAO,IAAI,UAAU,OAAO,IAAI,QAAQ;AAAA,MAC/C;AAAA,IACF;AACA,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@flagdeck/openfeature",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "OpenFeature provider for Flagdeck feature flags (server-side)",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./web": {
16
+ "types": "./dist/web.d.ts",
17
+ "import": "./dist/web.mjs",
18
+ "require": "./dist/web.js",
19
+ "default": "./dist/web.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE",
26
+ "CHANGELOG.md"
27
+ ],
28
+ "keywords": [
29
+ "openfeature",
30
+ "feature-flags",
31
+ "flagdeck",
32
+ "provider"
33
+ ],
34
+ "license": "MIT",
35
+ "author": "Flagdeck",
36
+ "dependencies": {
37
+ "@flagdeck/js": "1.0.0"
38
+ },
39
+ "peerDependencies": {
40
+ "@openfeature/server-sdk": "^1.13.0",
41
+ "@openfeature/web-sdk": "^1.6.0"
42
+ },
43
+ "devDependencies": {
44
+ "@flagdeck/js": "1.0.0",
45
+ "@openfeature/server-sdk": "^1.18.0",
46
+ "@types/jest": "^30.0.0",
47
+ "jest": "^30.2.0",
48
+ "ts-jest": "^29.4.6",
49
+ "tsup": "^8.0.0",
50
+ "typescript": "^5.0.0",
51
+ "@openfeature/web-sdk": "^1.6.0"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@openfeature/server-sdk": {
58
+ "optional": true
59
+ },
60
+ "@openfeature/web-sdk": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "scripts": {
65
+ "build": "npm run clean && tsup",
66
+ "clean": "rm -rf dist",
67
+ "typecheck": "tsc --noEmit",
68
+ "lint": "eslint \"src/**/*.ts\"",
69
+ "test": "jest"
70
+ }
6
71
  }