@datadog/openfeature-node-server 2.2.0 → 2.4.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.
package/cjs/index.js CHANGED
@@ -16,5 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./provider"), exports);
18
18
  // Build environment placeholder for testing
19
- const _SDK_VERSION = "dev";
19
+ const _SDK_VERSION = "2.4.0";
20
20
  //# sourceMappingURL=index.js.map
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './provider';
2
2
  // Build environment placeholder for testing
3
- const _SDK_VERSION = "dev";
3
+ const _SDK_VERSION = "2.4.0";
4
4
  //# sourceMappingURL=index.js.map
package/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { Channel } from 'node:diagnostics_channel';
2
2
 
3
- type Metadata = Record<string, string>;
4
- type Paradigm = "server" | "client";
5
3
  type PrimitiveValue = null | boolean | string | number;
6
4
  type JsonObject = {
7
5
  [key: string]: JsonValue;
@@ -19,8 +17,155 @@ type EvaluationContext = {
19
17
  */
20
18
  targetingKey?: string;
21
19
  } & Record<string, EvaluationContextValue>;
22
- type FlagValueType = "boolean" | "string" | "number" | "object";
23
20
  type FlagValue = boolean | string | number | JsonValue;
21
+ interface ExposureEvent {
22
+ allocation: {
23
+ key: string;
24
+ };
25
+ flag: {
26
+ key: string;
27
+ };
28
+ variant: {
29
+ key: string;
30
+ };
31
+ serial_id?: number;
32
+ subject: {
33
+ id: string;
34
+ attributes: EvaluationContext;
35
+ };
36
+ service?: string;
37
+ rum?: {
38
+ application?: {
39
+ id?: string;
40
+ };
41
+ view?: {
42
+ url?: string;
43
+ };
44
+ };
45
+ }
46
+ declare enum OperatorType {
47
+ MATCHES = "MATCHES",
48
+ NOT_MATCHES = "NOT_MATCHES",
49
+ GTE = "GTE",
50
+ GT = "GT",
51
+ LTE = "LTE",
52
+ LT = "LT",
53
+ ONE_OF = "ONE_OF",
54
+ NOT_ONE_OF = "NOT_ONE_OF",
55
+ IS_NULL = "IS_NULL",
56
+ SEMVER_EQ = "SEMVER_EQ",
57
+ SEMVER_NEQ = "SEMVER_NEQ",
58
+ SEMVER_LT = "SEMVER_LT",
59
+ SEMVER_LTE = "SEMVER_LTE",
60
+ SEMVER_GT = "SEMVER_GT",
61
+ SEMVER_GTE = "SEMVER_GTE"
62
+ }
63
+ type NumericOperator = OperatorType.GTE | OperatorType.GT | OperatorType.LTE | OperatorType.LT;
64
+ type SemVerOperator = OperatorType.SEMVER_EQ | OperatorType.SEMVER_NEQ | OperatorType.SEMVER_GTE | OperatorType.SEMVER_GT | OperatorType.SEMVER_LTE | OperatorType.SEMVER_LT;
65
+ type MatchesCondition = {
66
+ operator: OperatorType.MATCHES;
67
+ attribute: string;
68
+ value: string;
69
+ };
70
+ type NotMatchesCondition = {
71
+ operator: OperatorType.NOT_MATCHES;
72
+ attribute: string;
73
+ value: string;
74
+ };
75
+ type OneOfCondition = {
76
+ operator: OperatorType.ONE_OF;
77
+ attribute: string;
78
+ value: string[];
79
+ };
80
+ type NotOneOfCondition = {
81
+ operator: OperatorType.NOT_ONE_OF;
82
+ attribute: string;
83
+ value: string[];
84
+ };
85
+ type NumericCondition = {
86
+ operator: NumericOperator;
87
+ attribute: string;
88
+ value: number;
89
+ };
90
+ type NullCondition = {
91
+ operator: OperatorType.IS_NULL;
92
+ attribute: string;
93
+ value: boolean;
94
+ };
95
+ type SemVerCondition = {
96
+ operator: SemVerOperator;
97
+ attribute: string;
98
+ value: string;
99
+ };
100
+ type Condition = MatchesCondition | NotMatchesCondition | OneOfCondition | NotOneOfCondition | NumericCondition | NullCondition | SemVerCondition;
101
+ interface Rule {
102
+ conditions: Condition[];
103
+ }
104
+ type VariantType = "BOOLEAN" | "INTEGER" | "NUMERIC" | "STRING" | "JSON";
105
+ interface VariantConfiguration {
106
+ key: string;
107
+ value: FlagValue;
108
+ }
109
+ interface ShardRange {
110
+ start: number;
111
+ end: number;
112
+ }
113
+ interface Shard {
114
+ salt: string;
115
+ ranges: ShardRange[];
116
+ totalShards: number;
117
+ }
118
+ interface Split {
119
+ variationKey: string;
120
+ shards: Shard[];
121
+ extraLogging?: Record<string, string>;
122
+ serialId?: number;
123
+ }
124
+ interface Allocation {
125
+ key: string;
126
+ rules?: Rule[];
127
+ startAt?: Date;
128
+ endAt?: Date;
129
+ splits: Split[];
130
+ doLog?: boolean;
131
+ }
132
+ interface Flag {
133
+ key: string;
134
+ enabled: boolean;
135
+ variationType: VariantType;
136
+ variations: Record<string, VariantConfiguration>;
137
+ allocations: Allocation[];
138
+ }
139
+ export interface UniversalFlagConfigurationV1 {
140
+ createdAt: string;
141
+ format: string;
142
+ observeFullEvaluationData?: boolean;
143
+ environment: {
144
+ name: string;
145
+ };
146
+ flags: Record<string, Flag>;
147
+ }
148
+ type Metadata = Record<string, string>;
149
+ type Paradigm = "server" | "client";
150
+ type PrimitiveValue$1 = null | boolean | string | number;
151
+ type JsonObject$1 = {
152
+ [key: string]: JsonValue$1;
153
+ };
154
+ type JsonArray$1 = JsonValue$1[];
155
+ type JsonValue$1 = PrimitiveValue$1 | JsonObject$1 | JsonArray$1;
156
+ type EvaluationContextValue$1 = PrimitiveValue$1 | Date | {
157
+ [key: string]: EvaluationContextValue$1;
158
+ } | EvaluationContextValue$1[];
159
+ type EvaluationContext$1 = {
160
+ /**
161
+ * A string uniquely identifying the subject (end-user, or client service) of a flag evaluation.
162
+ * Providers may require this field for fractional flag evaluation, rules, or overrides targeting specific users.
163
+ * Such providers may behave unpredictably if a targeting key is not specified at flag resolution.
164
+ */
165
+ targetingKey?: string;
166
+ } & Record<string, EvaluationContextValue$1>;
167
+ type FlagValueType = "boolean" | "string" | "number" | "object";
168
+ type FlagValue$1 = boolean | string | number | JsonValue$1;
24
169
  type ResolutionReason = keyof typeof StandardResolutionReasons | (string & Record<never, never>);
25
170
  type FlagMetadata = Record<string, string | number | boolean>;
26
171
  type ResolutionDetails<U> = {
@@ -31,7 +176,7 @@ type ResolutionDetails<U> = {
31
176
  errorCode?: ErrorCode;
32
177
  errorMessage?: string;
33
178
  };
34
- type EvaluationDetails<T extends FlagValue> = {
179
+ type EvaluationDetails<T extends FlagValue$1> = {
35
180
  flagKey: string;
36
181
  flagMetadata: Readonly<FlagMetadata>;
37
182
  } & ResolutionDetails<T>;
@@ -217,7 +362,7 @@ interface ProviderEventEmitter<E extends AnyProviderEvent, AdditionalContext ext
217
362
  removeAllHandlers(eventType?: AnyProviderEvent): void;
218
363
  getHandlers(eventType: AnyProviderEvent): EventHandler[];
219
364
  }
220
- type TrackingEventValue = PrimitiveValue | Date | {
365
+ type TrackingEventValue = PrimitiveValue$1 | Date | {
221
366
  [key: string]: TrackingEventValue;
222
367
  } | TrackingEventValue[];
223
368
  type TrackingEventDetails = {
@@ -309,14 +454,14 @@ interface CommonProvider<S extends ClientProviderStatus | ServerProviderStatus>
309
454
  * Use this function to perform any context-dependent setup within the provider.
310
455
  * @param context
311
456
  */
312
- initialize?(context?: EvaluationContext): Promise<void>;
457
+ initialize?(context?: EvaluationContext$1): Promise<void>;
313
458
  /**
314
459
  * Track a user action or application state, usually representing a business objective or outcome.
315
460
  * @param trackingEventName
316
461
  * @param context
317
462
  * @param trackingEventDetails
318
463
  */
319
- track?(trackingEventName: string, context: EvaluationContext, trackingEventDetails: TrackingEventDetails): void;
464
+ track?(trackingEventName: string, context: EvaluationContext$1, trackingEventDetails: TrackingEventDetails): void;
320
465
  }
321
466
  interface ClientMetadata {
322
467
  /**
@@ -325,6 +470,20 @@ interface ClientMetadata {
325
470
  readonly name?: string;
326
471
  readonly domain?: string;
327
472
  readonly version?: string;
473
+ readonly sdk?: "js-web" | "js-server";
474
+ readonly paradigm?: Paradigm;
475
+ /**
476
+ * Identifies the OpenFeature framework SDK the client was obtained through.
477
+ *
478
+ * This field is only populated when the client is accessed through the
479
+ * corresponding framework wrapper (e.g. `<OpenFeatureProvider>` for React,
480
+ * `FeatureFlagService` / the `*FeatureFlag` directives for Angular, or
481
+ * Nest's `@OpenFeatureClient()` injection). Clients obtained by calling
482
+ * `OpenFeature.getClient(...)` directly from `@openfeature/web-sdk` or
483
+ * `@openfeature/server-sdk` will leave `framework` undefined, even when
484
+ * used inside a framework application.
485
+ */
486
+ readonly framework?: "react" | "angular" | "nest";
328
487
  readonly providerMetadata: ProviderMetadata;
329
488
  }
330
489
  interface HookData<TData = Record<string, unknown>> {
@@ -362,20 +521,20 @@ interface HookData<TData = Record<string, unknown>> {
362
521
  clear(): void;
363
522
  }
364
523
  type HookHints = Readonly<Record<string, unknown>>;
365
- interface HookContext<T extends FlagValue = FlagValue, TData = Record<string, unknown>> {
524
+ interface HookContext<T extends FlagValue$1 = FlagValue$1, TData = Record<string, unknown>> {
366
525
  readonly flagKey: string;
367
526
  readonly defaultValue: T;
368
527
  readonly flagValueType: FlagValueType;
369
- readonly context: Readonly<EvaluationContext>;
528
+ readonly context: Readonly<EvaluationContext$1>;
370
529
  readonly clientMetadata: ClientMetadata;
371
530
  readonly providerMetadata: ProviderMetadata;
372
531
  readonly logger: Logger;
373
532
  readonly hookData: HookData<TData>;
374
533
  }
375
- interface BeforeHookContext<T extends FlagValue = FlagValue, TData = Record<string, unknown>> extends HookContext<T, TData> {
376
- context: EvaluationContext;
534
+ interface BeforeHookContext<T extends FlagValue$1 = FlagValue$1, TData = Record<string, unknown>> extends HookContext<T, TData> {
535
+ context: EvaluationContext$1;
377
536
  }
378
- interface BaseHook<T extends FlagValue = FlagValue, TData = Record<string, unknown>, BeforeHookReturn = unknown, HooksReturn = unknown> {
537
+ interface BaseHook<T extends FlagValue$1 = FlagValue$1, TData = Record<string, unknown>, BeforeHookReturn = unknown, HooksReturn = unknown> {
379
538
  /**
380
539
  * Runs before flag values are resolved from the provider.
381
540
  * If an EvaluationContext is returned, it will be merged with the pre-existing EvaluationContext.
@@ -405,133 +564,7 @@ interface BaseHook<T extends FlagValue = FlagValue, TData = Record<string, unkno
405
564
  */
406
565
  finally?(hookContext: Readonly<HookContext<T, TData>>, evaluationDetails: EvaluationDetails<T>, hookHints?: HookHints): HooksReturn;
407
566
  }
408
- interface ExposureEvent {
409
- allocation: {
410
- key: string;
411
- };
412
- flag: {
413
- key: string;
414
- };
415
- variant: {
416
- key: string;
417
- };
418
- serial_id?: number;
419
- subject: {
420
- id: string;
421
- attributes: EvaluationContext;
422
- };
423
- service?: string;
424
- rum?: {
425
- application?: {
426
- id?: string;
427
- };
428
- view?: {
429
- url?: string;
430
- };
431
- };
432
- }
433
- declare enum OperatorType {
434
- MATCHES = "MATCHES",
435
- NOT_MATCHES = "NOT_MATCHES",
436
- GTE = "GTE",
437
- GT = "GT",
438
- LTE = "LTE",
439
- LT = "LT",
440
- ONE_OF = "ONE_OF",
441
- NOT_ONE_OF = "NOT_ONE_OF",
442
- IS_NULL = "IS_NULL",
443
- SEMVER_EQ = "SEMVER_EQ",
444
- SEMVER_NEQ = "SEMVER_NEQ",
445
- SEMVER_LT = "SEMVER_LT",
446
- SEMVER_LTE = "SEMVER_LTE",
447
- SEMVER_GT = "SEMVER_GT",
448
- SEMVER_GTE = "SEMVER_GTE"
449
- }
450
- type NumericOperator = OperatorType.GTE | OperatorType.GT | OperatorType.LTE | OperatorType.LT;
451
- type MatchesCondition = {
452
- operator: OperatorType.MATCHES;
453
- attribute: string;
454
- value: string;
455
- };
456
- type NotMatchesCondition = {
457
- operator: OperatorType.NOT_MATCHES;
458
- attribute: string;
459
- value: string;
460
- };
461
- type OneOfCondition = {
462
- operator: OperatorType.ONE_OF;
463
- attribute: string;
464
- value: string[];
465
- };
466
- type NotOneOfCondition = {
467
- operator: OperatorType.NOT_ONE_OF;
468
- attribute: string;
469
- value: string[];
470
- };
471
- type NumericCondition = {
472
- operator: NumericOperator;
473
- attribute: string;
474
- value: number;
475
- };
476
- type NullCondition = {
477
- operator: OperatorType.IS_NULL;
478
- attribute: string;
479
- value: boolean;
480
- };
481
- type SemverOperator = OperatorType.SEMVER_EQ | OperatorType.SEMVER_NEQ | OperatorType.SEMVER_LT | OperatorType.SEMVER_LTE | OperatorType.SEMVER_GT | OperatorType.SEMVER_GTE;
482
- type SemverCondition = {
483
- operator: SemverOperator;
484
- attribute: string;
485
- value: string;
486
- };
487
- type Condition = MatchesCondition | NotMatchesCondition | OneOfCondition | NotOneOfCondition | NumericCondition | NullCondition | SemverCondition;
488
- interface Rule {
489
- conditions: Condition[];
490
- }
491
- type VariantType = "BOOLEAN" | "INTEGER" | "NUMERIC" | "STRING" | "JSON";
492
- interface VariantConfiguration {
493
- key: string;
494
- value: FlagValue;
495
- }
496
- interface ShardRange {
497
- start: number;
498
- end: number;
499
- }
500
- interface Shard {
501
- salt: string;
502
- ranges: ShardRange[];
503
- totalShards: number;
504
- }
505
- interface Split {
506
- variationKey: string;
507
- shards: Shard[];
508
- extraLogging?: Record<string, string>;
509
- serialId?: number;
510
- }
511
- interface Allocation {
512
- key: string;
513
- rules?: Rule[];
514
- startAt?: Date;
515
- endAt?: Date;
516
- splits: Split[];
517
- doLog?: boolean;
518
- }
519
- interface Flag {
520
- key: string;
521
- enabled: boolean;
522
- variationType: VariantType;
523
- variations: Record<string, VariantConfiguration>;
524
- allocations: Allocation[];
525
- }
526
- export interface UniversalFlagConfigurationV1 {
527
- createdAt: string;
528
- format: string;
529
- environment: {
530
- name: string;
531
- };
532
- flags: Record<string, Flag>;
533
- }
534
- type Hook<TData = Record<string, unknown>> = BaseHook<FlagValue, TData, Promise<EvaluationContext | void> | EvaluationContext | void, Promise<void> | void>;
567
+ type Hook<TData = Record<string, unknown>> = BaseHook<FlagValue$1, TData, Promise<EvaluationContext$1 | void> | EvaluationContext$1 | void, Promise<void> | void>;
535
568
  interface Provider extends CommonProvider<ServerProviderStatus> {
536
569
  /**
537
570
  * A provider hook exposes a mechanism for provider authors to register hooks
@@ -543,19 +576,19 @@ interface Provider extends CommonProvider<ServerProviderStatus> {
543
576
  /**
544
577
  * Resolve a boolean flag and its evaluation details.
545
578
  */
546
- resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>;
579
+ resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext$1, logger: Logger): Promise<ResolutionDetails<boolean>>;
547
580
  /**
548
581
  * Resolve a string flag and its evaluation details.
549
582
  */
550
- resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>;
583
+ resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext$1, logger: Logger): Promise<ResolutionDetails<string>>;
551
584
  /**
552
585
  * Resolve a numeric flag and its evaluation details.
553
586
  */
554
- resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<number>>;
587
+ resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext$1, logger: Logger): Promise<ResolutionDetails<number>>;
555
588
  /**
556
589
  * Resolve and parse an object flag and its evaluation details.
557
590
  */
558
- resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<T>>;
591
+ resolveObjectEvaluation<T extends JsonValue$1>(flagKey: string, defaultValue: T, context: EvaluationContext$1, logger: Logger): Promise<ResolutionDetails<T>>;
559
592
  }
560
593
  export interface DatadogNodeServerProviderOptions {
561
594
  /**
@@ -601,10 +634,10 @@ export declare class DatadogNodeServerProvider implements Provider {
601
634
  * See setConfiguration and setError for more details.
602
635
  */
603
636
  initialize(): Promise<void>;
604
- resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<boolean>>;
605
- resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<string>>;
606
- resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<number>>;
607
- resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<T>>;
637
+ resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext$1, _logger: Logger): Promise<ResolutionDetails<boolean>>;
638
+ resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext$1, _logger: Logger): Promise<ResolutionDetails<string>>;
639
+ resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext$1, _logger: Logger): Promise<ResolutionDetails<number>>;
640
+ resolveObjectEvaluation<T extends JsonValue$1>(flagKey: string, defaultValue: T, context: EvaluationContext$1, _logger: Logger): Promise<ResolutionDetails<T>>;
608
641
  private handleExposure;
609
642
  }
610
643
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/openfeature-node-server",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Node.js server bindings for OpenFeature (wraps @datadog/flagging-core)",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/DataDog/openfeature-js-client#readme",
@@ -38,13 +38,13 @@
38
38
  "typecheck": "tsc --noEmit"
39
39
  },
40
40
  "dependencies": {
41
- "@datadog/flagging-core": "2.1.0"
41
+ "@datadog/flagging-core": "3.1.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@openfeature/core": "1.9.2",
45
- "@openfeature/server-sdk": "1.20.2",
44
+ "@openfeature/core": "1.11.0",
45
+ "@openfeature/server-sdk": "1.22.0",
46
46
  "@types/jest": "^30.0.0",
47
- "@types/node": "^18.19.130",
47
+ "@types/node": "^25.6.0",
48
48
  "dts-bundle-generator": "^9.0.0",
49
49
  "jest": "^30.0.5",
50
50
  "npm-run-all": "^4.1.5",