@datadog/openfeature-node-server 2.7.0 → 2.8.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.
Files changed (100) hide show
  1. package/README.md +220 -1
  2. package/cjs/configuration/client-fingerprint.d.ts +3 -0
  3. package/cjs/configuration/client-fingerprint.d.ts.map +1 -0
  4. package/cjs/configuration/client-fingerprint.js +30 -0
  5. package/cjs/configuration/client-fingerprint.js.map +1 -0
  6. package/cjs/configuration/configuration-fetch.d.ts +21 -0
  7. package/cjs/configuration/configuration-fetch.d.ts.map +1 -0
  8. package/cjs/configuration/configuration-fetch.js +125 -0
  9. package/cjs/configuration/configuration-fetch.js.map +1 -0
  10. package/cjs/configuration/evaluation.d.ts +1 -1
  11. package/cjs/configuration/evaluation.d.ts.map +1 -1
  12. package/cjs/configuration/evaluation.js +2 -2
  13. package/cjs/configuration/evaluation.js.map +1 -1
  14. package/cjs/configuration/fetch-precomputed-configuration.d.ts +28 -0
  15. package/cjs/configuration/fetch-precomputed-configuration.d.ts.map +1 -0
  16. package/cjs/configuration/fetch-precomputed-configuration.js +192 -0
  17. package/cjs/configuration/fetch-precomputed-configuration.js.map +1 -0
  18. package/cjs/configuration/fetch-rules-configuration.d.ts +3 -9
  19. package/cjs/configuration/fetch-rules-configuration.d.ts.map +1 -1
  20. package/cjs/configuration/fetch-rules-configuration.js +65 -126
  21. package/cjs/configuration/fetch-rules-configuration.js.map +1 -1
  22. package/cjs/configuration/flag-selection.d.ts +17 -0
  23. package/cjs/configuration/flag-selection.d.ts.map +1 -0
  24. package/cjs/configuration/flag-selection.js +29 -0
  25. package/cjs/configuration/flag-selection.js.map +1 -0
  26. package/cjs/configuration/precompute-configuration.d.ts +10 -0
  27. package/cjs/configuration/precompute-configuration.d.ts.map +1 -0
  28. package/cjs/configuration/precompute-configuration.js +38 -0
  29. package/cjs/configuration/precompute-configuration.js.map +1 -0
  30. package/cjs/experimentation-opt-out.d.ts +6 -0
  31. package/cjs/experimentation-opt-out.d.ts.map +1 -0
  32. package/cjs/experimentation-opt-out.js +17 -0
  33. package/cjs/experimentation-opt-out.js.map +1 -0
  34. package/cjs/index.d.ts +6 -0
  35. package/cjs/index.d.ts.map +1 -1
  36. package/cjs/index.js +12 -1
  37. package/cjs/index.js.map +1 -1
  38. package/cjs/provider.d.ts +58 -2
  39. package/cjs/provider.d.ts.map +1 -1
  40. package/cjs/provider.js +289 -47
  41. package/cjs/provider.js.map +1 -1
  42. package/cjs/rules-based.d.ts +4 -2
  43. package/cjs/rules-based.d.ts.map +1 -1
  44. package/cjs/rules-based.js +6 -1
  45. package/cjs/rules-based.js.map +1 -1
  46. package/cjs/sdk-diagnostics.d.ts +65 -0
  47. package/cjs/sdk-diagnostics.d.ts.map +1 -0
  48. package/cjs/sdk-diagnostics.js +123 -0
  49. package/cjs/sdk-diagnostics.js.map +1 -0
  50. package/esm/configuration/client-fingerprint.d.ts +3 -0
  51. package/esm/configuration/client-fingerprint.d.ts.map +1 -0
  52. package/esm/configuration/client-fingerprint.js +27 -0
  53. package/esm/configuration/client-fingerprint.js.map +1 -0
  54. package/esm/configuration/configuration-fetch.d.ts +21 -0
  55. package/esm/configuration/configuration-fetch.d.ts.map +1 -0
  56. package/esm/configuration/configuration-fetch.js +117 -0
  57. package/esm/configuration/configuration-fetch.js.map +1 -0
  58. package/esm/configuration/evaluation.d.ts +1 -1
  59. package/esm/configuration/evaluation.d.ts.map +1 -1
  60. package/esm/configuration/evaluation.js +1 -1
  61. package/esm/configuration/evaluation.js.map +1 -1
  62. package/esm/configuration/fetch-precomputed-configuration.d.ts +28 -0
  63. package/esm/configuration/fetch-precomputed-configuration.d.ts.map +1 -0
  64. package/esm/configuration/fetch-precomputed-configuration.js +189 -0
  65. package/esm/configuration/fetch-precomputed-configuration.js.map +1 -0
  66. package/esm/configuration/fetch-rules-configuration.d.ts +3 -9
  67. package/esm/configuration/fetch-rules-configuration.d.ts.map +1 -1
  68. package/esm/configuration/fetch-rules-configuration.js +56 -117
  69. package/esm/configuration/fetch-rules-configuration.js.map +1 -1
  70. package/esm/configuration/flag-selection.d.ts +17 -0
  71. package/esm/configuration/flag-selection.d.ts.map +1 -0
  72. package/esm/configuration/flag-selection.js +25 -0
  73. package/esm/configuration/flag-selection.js.map +1 -0
  74. package/esm/configuration/precompute-configuration.d.ts +10 -0
  75. package/esm/configuration/precompute-configuration.d.ts.map +1 -0
  76. package/esm/configuration/precompute-configuration.js +35 -0
  77. package/esm/configuration/precompute-configuration.js.map +1 -0
  78. package/esm/experimentation-opt-out.d.ts +6 -0
  79. package/esm/experimentation-opt-out.d.ts.map +1 -0
  80. package/esm/experimentation-opt-out.js +13 -0
  81. package/esm/experimentation-opt-out.js.map +1 -0
  82. package/esm/index.d.ts +6 -0
  83. package/esm/index.d.ts.map +1 -1
  84. package/esm/index.js +5 -1
  85. package/esm/index.js.map +1 -1
  86. package/esm/provider.d.ts +58 -2
  87. package/esm/provider.d.ts.map +1 -1
  88. package/esm/provider.js +288 -47
  89. package/esm/provider.js.map +1 -1
  90. package/esm/rules-based.d.ts +4 -2
  91. package/esm/rules-based.d.ts.map +1 -1
  92. package/esm/rules-based.js +3 -1
  93. package/esm/rules-based.js.map +1 -1
  94. package/esm/sdk-diagnostics.d.ts +65 -0
  95. package/esm/sdk-diagnostics.d.ts.map +1 -0
  96. package/esm/sdk-diagnostics.js +119 -0
  97. package/esm/sdk-diagnostics.js.map +1 -0
  98. package/index.d.ts +1169 -9
  99. package/package.json +2 -2
  100. package/rules-based.d.ts +204 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/openfeature-node-server",
3
- "version": "2.7.0",
3
+ "version": "2.8.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",
@@ -58,7 +58,7 @@
58
58
  "typecheck": "tsc --noEmit"
59
59
  },
60
60
  "dependencies": {
61
- "@datadog/flagging-core": "3.4.0"
61
+ "@datadog/flagging-core": "3.5.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@openfeature/core": "1.11.0",
package/rules-based.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** Opaque SDK identity and capabilities. Forward unchanged; this is not user or device identity. */
2
+ export type ClientFingerprint = string;
1
3
  type PrimitiveValue = null | boolean | string | number;
2
4
  type JsonObject = {
3
5
  [key: string]: JsonValue;
@@ -58,13 +60,51 @@ declare const StandardResolutionReasons: {
58
60
  */
59
61
  readonly ERROR: "ERROR";
60
62
  };
63
+ declare enum ErrorCode {
64
+ /**
65
+ * The value was resolved before the provider was ready.
66
+ */
67
+ PROVIDER_NOT_READY = "PROVIDER_NOT_READY",
68
+ /**
69
+ * The provider has entered an irrecoverable error state.
70
+ */
71
+ PROVIDER_FATAL = "PROVIDER_FATAL",
72
+ /**
73
+ * The flag could not be found.
74
+ */
75
+ FLAG_NOT_FOUND = "FLAG_NOT_FOUND",
76
+ /**
77
+ * An error was encountered parsing data, such as a flag configuration.
78
+ */
79
+ PARSE_ERROR = "PARSE_ERROR",
80
+ /**
81
+ * The type of the flag value does not match the expected type.
82
+ */
83
+ TYPE_MISMATCH = "TYPE_MISMATCH",
84
+ /**
85
+ * The provider requires a targeting key and one was not provided in the evaluation context.
86
+ */
87
+ TARGETING_KEY_MISSING = "TARGETING_KEY_MISSING",
88
+ /**
89
+ * The evaluation context does not meet provider requirements.
90
+ */
91
+ INVALID_CONTEXT = "INVALID_CONTEXT",
92
+ /**
93
+ * An error with an unspecified code.
94
+ */
95
+ GENERAL = "GENERAL"
96
+ }
61
97
  type TimeStamp = number & {
62
98
  t: "Epoch time";
63
99
  };
64
100
  declare const SCHEME = "flag-key-sha256-v1";
101
+ declare const DEPENDENCY_KEY_ENCRYPTION_SCHEME = "dependency-key-hkdf-sha256-aes-256-gcm-v1";
65
102
  type FlagKeyObfuscation = {
66
103
  scheme: typeof SCHEME;
67
104
  salt: string;
105
+ dependencyKeyEncryption?: {
106
+ scheme: typeof DEPENDENCY_KEY_ENCRYPTION_SCHEME;
107
+ };
68
108
  };
69
109
  declare enum WireType {
70
110
  /**
@@ -191,6 +231,23 @@ type FlagsConfiguration = Message<"datadog.ffe.flagging.ufc.v1.FlagsConfiguratio
191
231
  * @generated from field: bool observe_full_evaluation_data = 10;
192
232
  */
193
233
  observeFullEvaluationData: boolean;
234
+ /**
235
+ * Optional evaluator behavior overrides. Evaluators use their hard-coded
236
+ * defaults when this message or one of its fields is absent.
237
+ *
238
+ * @generated from field: datadog.ffe.flagging.ufc.v1.EvaluatorParams evaluator_params = 11;
239
+ */
240
+ evaluatorParams?: EvaluatorParams | undefined;
241
+ };
242
+ type EvaluatorParams = Message<"datadog.ffe.flagging.ufc.v1.EvaluatorParams"> & {
243
+ /**
244
+ * Maximum dependency-edge depth, counted from a root flag at depth zero.
245
+ * The maximum is inclusive, and zero rejects every dependency edge. Values
246
+ * must not exceed 255.
247
+ *
248
+ * @generated from field: optional uint64 max_dependency_depth = 1;
249
+ */
250
+ maxDependencyDepth?: bigint | undefined;
194
251
  };
195
252
  type Version = Message<"datadog.ffe.flagging.ufc.v1.Version"> & {
196
253
  /**
@@ -438,11 +495,37 @@ type Condition = Message<"datadog.ffe.flagging.ufc.v1.Condition"> & {
438
495
  */
439
496
  value: Sha256StringComparisonCondition;
440
497
  case: "sha256StringComparison";
498
+ } | {
499
+ /**
500
+ * @generated from field: datadog.ffe.flagging.ufc.v1.FlagEvaluationStringMembershipCondition flag_evaluation_string_membership = 11;
501
+ */
502
+ value: FlagEvaluationStringMembershipCondition;
503
+ case: "flagEvaluationStringMembership";
441
504
  } | {
442
505
  case: undefined;
443
506
  value?: undefined;
444
507
  };
445
508
  };
509
+ type FlagEvaluationStringMembershipCondition = Message<"datadog.ffe.flagging.ufc.v1.FlagEvaluationStringMembershipCondition"> & {
510
+ /**
511
+ * Index into FlagsConfiguration.strings for the flag key.
512
+ *
513
+ * @generated from field: uint32 flag_key_string_index = 1;
514
+ */
515
+ flagKeyStringIndex: number;
516
+ /**
517
+ * Indices into FlagsConfiguration.strings for expected variant keys.
518
+ *
519
+ * @generated from field: repeated uint32 variant_key_string_indexes = 2;
520
+ */
521
+ variantKeyStringIndexes: number[];
522
+ /**
523
+ * True negates membership.
524
+ *
525
+ * @generated from field: bool negate = 3;
526
+ */
527
+ negate: boolean;
528
+ };
446
529
  type ConditionOperands = Message<"datadog.ffe.flagging.ufc.v1.ConditionOperands"> & {
447
530
  /**
448
531
  * Zero-based indexes into FlagsConfiguration.conditions.
@@ -854,6 +937,7 @@ declare enum Reason {
854
937
  */
855
938
  DEFAULT = 4
856
939
  }
940
+ type ExperimentationOptOutModeValue = "disabled" | "immediate" | "future_experiments_only";
857
941
  interface OptOutInstant {
858
942
  readonly seconds: number;
859
943
  readonly fraction: string;
@@ -925,6 +1009,12 @@ type PrecomputedConfigurationResponse = {
925
1009
  attributes: {
926
1010
  /** When configuration was generated. */
927
1011
  createdAt: string;
1012
+ format?: "PRECOMPUTED";
1013
+ environment?: {
1014
+ name: string;
1015
+ };
1016
+ /** Allows full evaluation details in telemetry only when explicitly true; absent defaults to false. */
1017
+ observeFullEvaluationData?: boolean;
928
1018
  /** Effective server evaluation options, retained in portable and persisted configurations. */
929
1019
  evaluation_options?: {
930
1020
  experimentation_opt_out?: boolean;
@@ -935,7 +1025,10 @@ type PrecomputedConfigurationResponse = {
935
1025
  obfuscated?: boolean;
936
1026
  /** Required when obfuscated is true; retained with the map in caches. */
937
1027
  obfuscation?: FlagKeyObfuscation;
1028
+ /** Complete successful assignments only. */
938
1029
  flags: Record<string, PrecomputedFlag>;
1030
+ /** Terminal per-flag evaluation failures for dependent-flags-capable clients. */
1031
+ flagEvaluationErrors?: Record<string, PrecomputedErrorFlag>;
939
1032
  };
940
1033
  };
941
1034
  };
@@ -947,10 +1040,65 @@ type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
947
1040
  reason: ResolutionReason;
948
1041
  doLog: boolean;
949
1042
  serialId?: number | null;
1043
+ dependencyEvaluations?: PrecomputedDependencyEvaluation[];
950
1044
  /** Split features of the selected assignment; parsed leniently at evaluation time. */
951
1045
  features?: unknown;
952
1046
  };
1047
+ type PrecomputedErrorFlag = {
1048
+ reason: "ERROR";
1049
+ errorCode: string;
1050
+ errorMessage?: string;
1051
+ dependencyEvaluations?: PrecomputedDependencyEvaluation[];
1052
+ };
1053
+ type PrecomputedDependencyEvaluation = {
1054
+ flagKey: string;
1055
+ /** Whether this dependency belongs to the root flag's selected assignment path. */
1056
+ isPresentInAssignment: boolean;
1057
+ } | {
1058
+ flagKey: string;
1059
+ /** Root-relative prerequisite failure; error entries never belong to an assignment. */
1060
+ reason: "ERROR";
1061
+ errorCode: string;
1062
+ errorMessage?: string;
1063
+ };
1064
+ export interface FlagSelection {
1065
+ tags?: readonly string[];
1066
+ keyPatterns?: readonly string[];
1067
+ }
953
1068
  export type FlagsConfigurationWire = string;
1069
+ export type ConfigurationPrecomputeErrorCode = "invalid_configuration" | "invalid_context" | "invalid_options";
1070
+ /** A top-level input error. Individual flag failures are reported separately. */
1071
+ export declare class ConfigurationPrecomputeError extends Error {
1072
+ readonly code: ConfigurationPrecomputeErrorCode;
1073
+ constructor(code: ConfigurationPrecomputeErrorCode);
1074
+ }
1075
+ export type PrecomputeEvaluationError = {
1076
+ flagKey: string;
1077
+ errorCode: ErrorCode;
1078
+ };
1079
+ type PrecomputeConfigurationOptions = {
1080
+ /**
1081
+ * Select initial root flags whose whole key matches any pattern; only `*` is special.
1082
+ * Tags are unsupported: any defined tags value, including [] or null, throws invalid_options.
1083
+ * Malformed or over-limit selections also throw invalid_options. With tags absent, omitted selections or no
1084
+ * nonempty keyPatterns include all assignments; a null selection is treated as absent at runtime.
1085
+ * Precomputation also includes transitive configured prerequisite assignments needed by selected roots,
1086
+ * even when their keys do not match.
1087
+ */
1088
+ flagSelection?: Pick<FlagSelection, "keyPatterns"> & {
1089
+ tags?: never;
1090
+ };
1091
+ /** Defaults to disabled. The receiving provider must use the same effective opt-out policy. */
1092
+ experimentationOptOutMode?: ExperimentationOptOutModeValue;
1093
+ /** Encode top-level keys and encrypt root-relative prerequisite keys using this descriptor. */
1094
+ obfuscation?: FlagKeyObfuscation;
1095
+ /**
1096
+ * Called for each evaluation error in the selected-root and prerequisite closure, after all flags have been evaluated.
1097
+ * Failed dependency graph roots are retained in the wire; ordinary failures are callback-only.
1098
+ * Contains no context, values, or raw error messages. Exceptions from this callback propagate.
1099
+ */
1100
+ onEvaluationError?: (error: PrecomputeEvaluationError) => void;
1101
+ };
954
1102
  /**
955
1103
  * Decode a binary flags configuration response.
956
1104
  */
@@ -964,7 +1112,55 @@ export declare function configurationFromString(wire: FlagsConfigurationWire): F
964
1112
  * `configurationFromString`.
965
1113
  */
966
1114
  export declare function configurationToString(configuration: FlagsConfiguration$1): FlagsConfigurationWire;
967
- interface ConfigurationFetchOptions {
1115
+ export type ConfigurationFetchErrorCode = "invalid_options" | "http" | "invalid_response" | "decode" | "transport" | "cancelled" | "timeout";
1116
+ /** A configuration-loading failure, not an OpenFeature evaluation error. */
1117
+ export declare class ConfigurationFetchError extends Error {
1118
+ readonly code: ConfigurationFetchErrorCode;
1119
+ readonly status?: number | undefined;
1120
+ constructor(code: ConfigurationFetchErrorCode, message: string, status?: number | undefined);
1121
+ }
1122
+ interface ConfigurationTransportOptions {
1123
+ /** Request and response-body deadline in milliseconds. Defaults to 5000. */
1124
+ timeoutMs?: number;
1125
+ signal?: AbortSignal;
1126
+ /** Fetch-compatible transport. Must honor the supplied signal and redirect policy. */
1127
+ fetch?: typeof globalThis.fetch;
1128
+ }
1129
+ interface ConfigurationSelectionOptions {
1130
+ /**
1131
+ * Request flags matching any of these tags or key patterns.
1132
+ * Best-effort: an invalid or over-limit selection is not sent.
1133
+ */
1134
+ flagSelection?: FlagSelection;
1135
+ /** Reports dropped or server-ignored selections. Defaults to console. */
1136
+ logger?: {
1137
+ error(message: string): void;
1138
+ };
1139
+ }
1140
+ export interface PrecomputedConfigurationFetchOptions extends ConfigurationTransportOptions, ConfigurationSelectionOptions {
1141
+ /** Required for now. Only client-distributed flags are supported by this endpoint. */
1142
+ distributionChannel: "client";
1143
+ clientToken: string;
1144
+ /** Reserved. API-key authentication is not supported for client distribution. */
1145
+ apiKey?: never;
1146
+ env: string;
1147
+ /** Datadog site. Defaults to datadoghq.com. */
1148
+ site?: string;
1149
+ applicationId?: string;
1150
+ /**
1151
+ * A detached snapshot is bound to the returned assignments. Only plain JSON values are accepted:
1152
+ * no Date, undefined, non-finite numbers, class instances, or cycles, including nested values.
1153
+ * Convert dates to strings before calling and use the same context in the receiving provider.
1154
+ */
1155
+ context: EvaluationContext;
1156
+ /** Opaque target SDK fingerprint. Forward unchanged from its getter; omission requests plaintext. */
1157
+ clientFingerprint?: ClientFingerprint;
1158
+ /** Defaults to disabled. The receiving provider must use the same effective opt-out policy. */
1159
+ experimentationOptOutMode?: ExperimentationOptOutModeValue;
1160
+ }
1161
+ /** Fetch assignments for one client context, without initializing a provider or emitting tracking events. */
1162
+ export declare function fetchPrecomputedConfiguration(options: PrecomputedConfigurationFetchOptions): Promise<FlagsConfiguration$1>;
1163
+ interface ConfigurationFetchOptions extends ConfigurationSelectionOptions {
968
1164
  env: string;
969
1165
  /** Datadog site. Defaults to datadoghq.com. */
970
1166
  site?: string;
@@ -983,21 +1179,21 @@ export type RulesConfigurationFetchOptions = ConfigurationFetchOptions & ({
983
1179
  clientToken: string;
984
1180
  apiKey?: never;
985
1181
  });
986
- export type ConfigurationFetchErrorCode = "invalid_options" | "http" | "invalid_response" | "decode" | "transport" | "cancelled" | "timeout";
987
- /** A configuration-loading failure, not an OpenFeature evaluation error. */
988
- export declare class ConfigurationFetchError extends Error {
989
- readonly code: ConfigurationFetchErrorCode;
990
- readonly status?: number | undefined;
991
- constructor(code: ConfigurationFetchErrorCode, message: string, status?: number | undefined);
992
- }
993
1182
  /**
994
1183
  * Fetch and parse context-independent rules without initializing a provider or tracer.
995
1184
  * Only client-distributed configurations are suitable for forwarding to a browser.
996
1185
  */
997
1186
  export declare function fetchRulesConfiguration(options: RulesConfigurationFetchOptions): Promise<FlagsConfiguration$1>;
1187
+ type PrecomputeConfigurationOptions$1 = Omit<PrecomputeConfigurationOptions, "obfuscation"> & {
1188
+ /** Opaque target SDK fingerprint. Forward unchanged from its getter; omission preserves plaintext keys. */
1189
+ clientFingerprint?: ClientFingerprint;
1190
+ };
1191
+ /** Resolve rules locally for one context, then encode keys for the target client without tracking or fetching. */
1192
+ export declare function precomputeConfiguration(configuration: FlagsConfiguration$1, context: EvaluationContext, options?: PrecomputeConfigurationOptions$1): FlagsConfiguration$1;
998
1193
 
999
1194
  export {
1000
1195
  FlagsConfiguration$1 as FlagsConfiguration,
1196
+ PrecomputeConfigurationOptions$1 as PrecomputeConfigurationOptions,
1001
1197
  };
1002
1198
 
1003
1199
  export {};