@datadog/openfeature-node-server 2.5.0 → 2.7.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/configuration/fetch-rules-configuration.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/provider.d.ts +3 -2
- package/cjs/provider.d.ts.map +1 -1
- package/cjs/provider.js +88 -18
- package/cjs/provider.js.map +1 -1
- package/esm/configuration/fetch-rules-configuration.js +1 -1
- package/esm/index.js +1 -1
- package/esm/provider.d.ts +3 -2
- package/esm/provider.d.ts.map +1 -1
- package/esm/provider.js +88 -18
- package/esm/provider.js.map +1 -1
- package/index.d.ts +33 -28
- package/package.json +2 -2
- package/rules-based.d.ts +78 -0
|
@@ -106,7 +106,7 @@ async function fetchRulesConfiguration(options) {
|
|
|
106
106
|
Accept: 'application/protobuf',
|
|
107
107
|
[distributionChannel === 'client' ? 'dd-client-token' : 'dd-api-key']: credential,
|
|
108
108
|
'DD-Client-Library-Language': 'nodejs',
|
|
109
|
-
'DD-Client-Library-Version': "2.
|
|
109
|
+
'DD-Client-Library-Version': "2.7.0",
|
|
110
110
|
},
|
|
111
111
|
signal: controller.signal,
|
|
112
112
|
// Never forward a credential to a redirect destination.
|
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 = "2.
|
|
19
|
+
const _SDK_VERSION = "2.7.0";
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/cjs/provider.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
30
30
|
*/
|
|
31
31
|
getConfiguration(): UniversalFlagConfigurationV1 | undefined;
|
|
32
32
|
/**
|
|
33
|
-
* Used by dd-source-js
|
|
33
|
+
* Used by dd-source-js. Pass null or undefined to withdraw the configuration.
|
|
34
34
|
*/
|
|
35
|
-
setConfiguration(configuration: UniversalFlagConfigurationV1): void;
|
|
35
|
+
setConfiguration(configuration: UniversalFlagConfigurationV1 | null | undefined): void;
|
|
36
36
|
/**
|
|
37
37
|
* Used by dd-source-js
|
|
38
38
|
*/
|
|
@@ -51,6 +51,7 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
51
51
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<string>>;
|
|
52
52
|
resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<number>>;
|
|
53
53
|
resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<T>>;
|
|
54
|
+
/** Prepares a verdict finalized by the provider hook after successful evaluation. */
|
|
54
55
|
private handleExposure;
|
|
55
56
|
}
|
|
56
57
|
//# sourceMappingURL=provider.d.ts.map
|
package/cjs/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAIL,KAAK,aAAa,EAOnB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAgB,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAC9F,OAAO,KAAK,EAGV,IAAI,EAEJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,gBAAgB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AAC;IAM/B,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAM/B,uBAAuB,CAAC,CAAC,SAAS,SAAS,EAC/C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAmBhC,qFAAqF;IACrF,OAAO,CAAC,cAAc;CAiBvB"}
|
package/cjs/provider.js
CHANGED
|
@@ -24,6 +24,9 @@ class DatadogNodeServerProvider {
|
|
|
24
24
|
this.hooks = [];
|
|
25
25
|
this.events = new provider_event_emitter_1.NodeProviderEventEmitter();
|
|
26
26
|
this.exposureCache = new flagging_core_1.LRUInMemoryAssignmentCache(50000);
|
|
27
|
+
// Runs in the final hook stage, where the SDK has turned any later hook error
|
|
28
|
+
// into an error result, so a failed evaluation is never published or recorded.
|
|
29
|
+
this.hooks.push(new ExposureLoggingHook(this.exposureCache, this.options.exposureChannel));
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* Used by dd-source-js
|
|
@@ -32,23 +35,32 @@ class DatadogNodeServerProvider {
|
|
|
32
35
|
return this.configuration;
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
|
-
* Used by dd-source-js
|
|
38
|
+
* Used by dd-source-js. Pass null or undefined to withdraw the configuration.
|
|
36
39
|
*/
|
|
37
40
|
setConfiguration(configuration) {
|
|
38
|
-
var _a, _b, _c;
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
|
+
if (configuration) {
|
|
43
|
+
(0, flagging_core_1.prepareUniversalFlagConfiguration)(configuration);
|
|
44
|
+
}
|
|
45
|
+
const previousConfiguration = this.configuration;
|
|
39
46
|
const prevCreatedAt = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.createdAt;
|
|
40
47
|
const hadConfiguration = !!this.configuration;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (prevCreatedAt !== newCreatedAt) {
|
|
48
|
+
this.configuration = configuration !== null && configuration !== void 0 ? configuration : undefined;
|
|
49
|
+
if (!configuration) {
|
|
50
|
+
if (hadConfiguration) {
|
|
45
51
|
(_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.clear();
|
|
52
|
+
this.setError(new Error('Flag configuration is unavailable'));
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (hadConfiguration && previousConfiguration !== configuration) {
|
|
57
|
+
if (prevCreatedAt !== configuration.createdAt) {
|
|
58
|
+
(_c = this.exposureCache) === null || _c === void 0 ? void 0 : _c.clear();
|
|
46
59
|
}
|
|
47
|
-
this.
|
|
60
|
+
this.events.emit(PROVIDER_EVENTS.ConfigurationChanged);
|
|
48
61
|
return;
|
|
49
62
|
}
|
|
50
|
-
this.
|
|
51
|
-
if ((_c = this.initController) === null || _c === void 0 ? void 0 : _c.isInitializing()) {
|
|
63
|
+
if ((_d = this.initController) === null || _d === void 0 ? void 0 : _d.isInitializing()) {
|
|
52
64
|
// First configuration during initialization - resolve the initialization promise
|
|
53
65
|
// This will cause OpenFeature SDK to emit PROVIDER_READY
|
|
54
66
|
this.initController.complete();
|
|
@@ -89,6 +101,9 @@ class DatadogNodeServerProvider {
|
|
|
89
101
|
this.initController = new initialization_controller_1.InitializationController(timeoutMs, () => this.setError(new Error(`Initialization timeout after ${timeoutMs}ms`)));
|
|
90
102
|
await this.initController.wait();
|
|
91
103
|
await ((_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.init());
|
|
104
|
+
if (!this.configuration) {
|
|
105
|
+
throw new Error('Flag configuration is unavailable');
|
|
106
|
+
}
|
|
92
107
|
}
|
|
93
108
|
async resolveBooleanEvaluation(flagKey, defaultValue, context, _logger) {
|
|
94
109
|
const resolutionDetails = (0, evaluation_1.evaluate)(this.configuration, 'boolean', flagKey, defaultValue, context, _logger);
|
|
@@ -116,27 +131,82 @@ class DatadogNodeServerProvider {
|
|
|
116
131
|
this.handleExposure(flagKey, context, resolutionDetails);
|
|
117
132
|
return resolutionDetails;
|
|
118
133
|
}
|
|
134
|
+
/** Prepares a verdict finalized by the provider hook after successful evaluation. */
|
|
119
135
|
handleExposure(flagKey, context, resolutionDetails) {
|
|
120
|
-
var _a
|
|
121
|
-
const
|
|
136
|
+
var _a;
|
|
137
|
+
const metadata = ((_a = resolutionDetails.flagMetadata) !== null && _a !== void 0 ? _a : {});
|
|
122
138
|
const evalutationDetails = {
|
|
123
139
|
...resolutionDetails,
|
|
124
140
|
flagKey: flagKey,
|
|
125
|
-
flagMetadata:
|
|
141
|
+
flagMetadata: metadata,
|
|
126
142
|
};
|
|
127
143
|
const exposureEvent = (0, flagging_core_1.createExposureEvent)(context, evalutationDetails);
|
|
128
144
|
if (!exposureEvent) {
|
|
129
145
|
return;
|
|
130
146
|
}
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
if (this.exposureCache)
|
|
148
|
+
(0, flagging_core_1.prepareExposureDecision)(metadata, this.exposureCache, exposureEvent);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.DatadogNodeServerProvider = DatadogNodeServerProvider;
|
|
152
|
+
/**
|
|
153
|
+
* Publishes and records the exposure once the evaluation has completed without an
|
|
154
|
+
* error. A cache entry is written even when nothing subscribes to the exposure
|
|
155
|
+
* channel, so the verdict stays correct with Datadog exposure logging off.
|
|
156
|
+
*/
|
|
157
|
+
class ExposureLoggingHook {
|
|
158
|
+
constructor(exposureCache, exposureChannel) {
|
|
159
|
+
this.exposureCache = exposureCache;
|
|
160
|
+
this.exposureChannel = exposureChannel;
|
|
161
|
+
this.pending = new WeakMap();
|
|
162
|
+
}
|
|
163
|
+
after(hookContext, evaluationDetails) {
|
|
164
|
+
this.pending.set(hookContext, evaluationDetails);
|
|
165
|
+
}
|
|
166
|
+
error(hookContext) {
|
|
167
|
+
this.pending.delete(hookContext);
|
|
168
|
+
}
|
|
169
|
+
finally(hookContext) {
|
|
170
|
+
var _a, _b, _c, _d;
|
|
171
|
+
// Older supported OpenFeature versions pass only hook hints to finally.
|
|
172
|
+
// Capture the successful result in after and discard it on any later error.
|
|
173
|
+
const evaluationDetails = this.pending.get(hookContext);
|
|
174
|
+
this.pending.delete(hookContext);
|
|
175
|
+
if (evaluationDetails == null || evaluationDetails.errorCode !== undefined) {
|
|
133
176
|
return;
|
|
134
177
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
178
|
+
// One check-and-record after successful finalization; concurrent or nested
|
|
179
|
+
// evaluations of the same assignment cannot both be admitted.
|
|
180
|
+
const sharedDecision = (0, flagging_core_1.completeExposureDecision)(evaluationDetails);
|
|
181
|
+
const metadata = evaluationDetails.flagMetadata;
|
|
182
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.__dd_do_log) !== true || metadata.__dd_exposure_cache_hit !== false) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const details = {
|
|
187
|
+
...evaluationDetails,
|
|
188
|
+
flagKey: (_b = (_a = evaluationDetails.flagKey) !== null && _a !== void 0 ? _a : hookContext === null || hookContext === void 0 ? void 0 : hookContext.flagKey) !== null && _b !== void 0 ? _b : '',
|
|
189
|
+
};
|
|
190
|
+
const exposureEvent = (0, flagging_core_1.createExposureEvent)((_c = hookContext === null || hookContext === void 0 ? void 0 : hookContext.context) !== null && _c !== void 0 ? _c : {}, details);
|
|
191
|
+
if (!exposureEvent) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (this.exposureChannel.hasSubscribers) {
|
|
195
|
+
// Features stay off the cache entry: a features change must not turn a
|
|
196
|
+
// repeat exposure into a new one.
|
|
197
|
+
const features = (0, flagging_core_1.featuresWithPrefix)(metadata, flagging_core_1.METADATA_EXPOSURE_FEATURE_PREFIX);
|
|
198
|
+
this.exposureChannel.publish({
|
|
199
|
+
...exposureEvent,
|
|
200
|
+
...(features && { features }),
|
|
201
|
+
timestamp: (0, flagging_core_1.timeStampNow)(),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (!sharedDecision)
|
|
205
|
+
(_d = this.exposureCache) === null || _d === void 0 ? void 0 : _d.set(exposureEvent);
|
|
206
|
+
}
|
|
207
|
+
catch (_e) {
|
|
208
|
+
// Exposure reporting must never break the evaluation.
|
|
138
209
|
}
|
|
139
210
|
}
|
|
140
211
|
}
|
|
141
|
-
exports.DatadogNodeServerProvider = DatadogNodeServerProvider;
|
|
142
212
|
//# sourceMappingURL=provider.js.map
|
package/cjs/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;AACA,0DAW+B;AAe/B,2DAAqD;AAErD,2EAAsE;AACtE,qEAAmE;AAEnE,MAAM,eAAe,GAAG;IACtB,oBAAoB,EAAE,gCAA6E;IACnG,KAAK,EAAE,gBAA8C;IACrD,KAAK,EAAE,gBAA8C;CACtD,CAAA;AAED;;GAEG;AACH,MAAM,iCAAiC,GAAG,KAAM,CAAA;AAehD,MAAa,yBAAyB;IAapC,YAA6B,OAAyC;QAAzC,YAAO,GAAP,OAAO,CAAkC;QAZ7D,aAAQ,GAAqB;YACpC,IAAI,EAAE,qBAAqB;SAC5B,CAAA;QACQ,WAAM,GAAa,QAAQ,CAAA;QAUlC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,iDAAwB,EAAE,CAAA;QAC5C,IAAI,CAAC,aAAa,GAAG,IAAI,0CAA0B,CAAC,KAAM,CAAC,CAAA;QAC3D,8EAA8E;QAC9E,+EAA+E;QAC/E,IAAI,CA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C;QAAC,WAAM,CAAC;YACP,sDAAsD;QACxD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -101,7 +101,7 @@ export async function fetchRulesConfiguration(options) {
|
|
|
101
101
|
Accept: 'application/protobuf',
|
|
102
102
|
[distributionChannel === 'client' ? 'dd-client-token' : 'dd-api-key']: credential,
|
|
103
103
|
'DD-Client-Library-Language': 'nodejs',
|
|
104
|
-
'DD-Client-Library-Version': "2.
|
|
104
|
+
'DD-Client-Library-Version': "2.7.0",
|
|
105
105
|
},
|
|
106
106
|
signal: controller.signal,
|
|
107
107
|
// Never forward a credential to a redirect destination.
|
package/esm/index.js
CHANGED
package/esm/provider.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
30
30
|
*/
|
|
31
31
|
getConfiguration(): UniversalFlagConfigurationV1 | undefined;
|
|
32
32
|
/**
|
|
33
|
-
* Used by dd-source-js
|
|
33
|
+
* Used by dd-source-js. Pass null or undefined to withdraw the configuration.
|
|
34
34
|
*/
|
|
35
|
-
setConfiguration(configuration: UniversalFlagConfigurationV1): void;
|
|
35
|
+
setConfiguration(configuration: UniversalFlagConfigurationV1 | null | undefined): void;
|
|
36
36
|
/**
|
|
37
37
|
* Used by dd-source-js
|
|
38
38
|
*/
|
|
@@ -51,6 +51,7 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
51
51
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<string>>;
|
|
52
52
|
resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<number>>;
|
|
53
53
|
resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<T>>;
|
|
54
|
+
/** Prepares a verdict finalized by the provider hook after successful evaluation. */
|
|
54
55
|
private handleExposure;
|
|
55
56
|
}
|
|
56
57
|
//# sourceMappingURL=provider.d.ts.map
|
package/esm/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAIL,KAAK,aAAa,EAOnB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAgB,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAC9F,OAAO,KAAK,EAGV,IAAI,EAEJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAe1E,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IACvC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC;AAED,qBAAa,yBAA0B,YAAW,QAAQ;IAa5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAElC;IACD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAW;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IAEvB,OAAO,CAAC,cAAc,CAAC,CAA0B;IACjD,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;IAC3D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAE3D,OAAO,CAAC,aAAa,CAAC,CAA0C;gBAEnC,OAAO,EAAE,gCAAgC;IAStE;;OAEG;IACH,gBAAgB;IAIhB;;OAEG;IACH,gBAAgB,CAAC,aAAa,EAAE,4BAA4B,GAAG,IAAI,GAAG,SAAS;IAoC/E;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO;IAQvB;;;;;;;;OAQG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB3B,wBAAwB,CAC5B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAMhC,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAM/B,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAM/B,uBAAuB,CAAC,CAAC,SAAS,SAAS,EAC/C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAmBhC,qFAAqF;IACrF,OAAO,CAAC,cAAc;CAiBvB"}
|
package/esm/provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createExposureEvent, LRUInMemoryAssignmentCache, timeStampNow, } from '@datadog/flagging-core';
|
|
1
|
+
import { completeExposureDecision, createExposureEvent, featuresWithPrefix, LRUInMemoryAssignmentCache, METADATA_EXPOSURE_FEATURE_PREFIX, prepareExposureDecision, prepareUniversalFlagConfiguration, timeStampNow, } from '@datadog/flagging-core';
|
|
2
2
|
import { evaluate } from './configuration/evaluation';
|
|
3
3
|
import { InitializationController } from './initialization-controller';
|
|
4
4
|
import { NodeProviderEventEmitter } from './provider-event-emitter';
|
|
@@ -21,6 +21,9 @@ export class DatadogNodeServerProvider {
|
|
|
21
21
|
this.hooks = [];
|
|
22
22
|
this.events = new NodeProviderEventEmitter();
|
|
23
23
|
this.exposureCache = new LRUInMemoryAssignmentCache(50000);
|
|
24
|
+
// Runs in the final hook stage, where the SDK has turned any later hook error
|
|
25
|
+
// into an error result, so a failed evaluation is never published or recorded.
|
|
26
|
+
this.hooks.push(new ExposureLoggingHook(this.exposureCache, this.options.exposureChannel));
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Used by dd-source-js
|
|
@@ -29,23 +32,32 @@ export class DatadogNodeServerProvider {
|
|
|
29
32
|
return this.configuration;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
|
-
* Used by dd-source-js
|
|
35
|
+
* Used by dd-source-js. Pass null or undefined to withdraw the configuration.
|
|
33
36
|
*/
|
|
34
37
|
setConfiguration(configuration) {
|
|
35
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
if (configuration) {
|
|
40
|
+
prepareUniversalFlagConfiguration(configuration);
|
|
41
|
+
}
|
|
42
|
+
const previousConfiguration = this.configuration;
|
|
36
43
|
const prevCreatedAt = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.createdAt;
|
|
37
44
|
const hadConfiguration = !!this.configuration;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (prevCreatedAt !== newCreatedAt) {
|
|
45
|
+
this.configuration = configuration !== null && configuration !== void 0 ? configuration : undefined;
|
|
46
|
+
if (!configuration) {
|
|
47
|
+
if (hadConfiguration) {
|
|
42
48
|
(_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.clear();
|
|
49
|
+
this.setError(new Error('Flag configuration is unavailable'));
|
|
43
50
|
}
|
|
44
|
-
this.configuration = configuration;
|
|
45
51
|
return;
|
|
46
52
|
}
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
if (hadConfiguration && previousConfiguration !== configuration) {
|
|
54
|
+
if (prevCreatedAt !== configuration.createdAt) {
|
|
55
|
+
(_c = this.exposureCache) === null || _c === void 0 ? void 0 : _c.clear();
|
|
56
|
+
}
|
|
57
|
+
this.events.emit(PROVIDER_EVENTS.ConfigurationChanged);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if ((_d = this.initController) === null || _d === void 0 ? void 0 : _d.isInitializing()) {
|
|
49
61
|
// First configuration during initialization - resolve the initialization promise
|
|
50
62
|
// This will cause OpenFeature SDK to emit PROVIDER_READY
|
|
51
63
|
this.initController.complete();
|
|
@@ -86,6 +98,9 @@ export class DatadogNodeServerProvider {
|
|
|
86
98
|
this.initController = new InitializationController(timeoutMs, () => this.setError(new Error(`Initialization timeout after ${timeoutMs}ms`)));
|
|
87
99
|
await this.initController.wait();
|
|
88
100
|
await ((_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.init());
|
|
101
|
+
if (!this.configuration) {
|
|
102
|
+
throw new Error('Flag configuration is unavailable');
|
|
103
|
+
}
|
|
89
104
|
}
|
|
90
105
|
async resolveBooleanEvaluation(flagKey, defaultValue, context, _logger) {
|
|
91
106
|
const resolutionDetails = evaluate(this.configuration, 'boolean', flagKey, defaultValue, context, _logger);
|
|
@@ -113,25 +128,80 @@ export class DatadogNodeServerProvider {
|
|
|
113
128
|
this.handleExposure(flagKey, context, resolutionDetails);
|
|
114
129
|
return resolutionDetails;
|
|
115
130
|
}
|
|
131
|
+
/** Prepares a verdict finalized by the provider hook after successful evaluation. */
|
|
116
132
|
handleExposure(flagKey, context, resolutionDetails) {
|
|
117
|
-
var _a
|
|
118
|
-
const
|
|
133
|
+
var _a;
|
|
134
|
+
const metadata = ((_a = resolutionDetails.flagMetadata) !== null && _a !== void 0 ? _a : {});
|
|
119
135
|
const evalutationDetails = {
|
|
120
136
|
...resolutionDetails,
|
|
121
137
|
flagKey: flagKey,
|
|
122
|
-
flagMetadata:
|
|
138
|
+
flagMetadata: metadata,
|
|
123
139
|
};
|
|
124
140
|
const exposureEvent = createExposureEvent(context, evalutationDetails);
|
|
125
141
|
if (!exposureEvent) {
|
|
126
142
|
return;
|
|
127
143
|
}
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
if (this.exposureCache)
|
|
145
|
+
prepareExposureDecision(metadata, this.exposureCache, exposureEvent);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Publishes and records the exposure once the evaluation has completed without an
|
|
150
|
+
* error. A cache entry is written even when nothing subscribes to the exposure
|
|
151
|
+
* channel, so the verdict stays correct with Datadog exposure logging off.
|
|
152
|
+
*/
|
|
153
|
+
class ExposureLoggingHook {
|
|
154
|
+
constructor(exposureCache, exposureChannel) {
|
|
155
|
+
this.exposureCache = exposureCache;
|
|
156
|
+
this.exposureChannel = exposureChannel;
|
|
157
|
+
this.pending = new WeakMap();
|
|
158
|
+
}
|
|
159
|
+
after(hookContext, evaluationDetails) {
|
|
160
|
+
this.pending.set(hookContext, evaluationDetails);
|
|
161
|
+
}
|
|
162
|
+
error(hookContext) {
|
|
163
|
+
this.pending.delete(hookContext);
|
|
164
|
+
}
|
|
165
|
+
finally(hookContext) {
|
|
166
|
+
var _a, _b, _c, _d;
|
|
167
|
+
// Older supported OpenFeature versions pass only hook hints to finally.
|
|
168
|
+
// Capture the successful result in after and discard it on any later error.
|
|
169
|
+
const evaluationDetails = this.pending.get(hookContext);
|
|
170
|
+
this.pending.delete(hookContext);
|
|
171
|
+
if (evaluationDetails == null || evaluationDetails.errorCode !== undefined) {
|
|
130
172
|
return;
|
|
131
173
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
174
|
+
// One check-and-record after successful finalization; concurrent or nested
|
|
175
|
+
// evaluations of the same assignment cannot both be admitted.
|
|
176
|
+
const sharedDecision = completeExposureDecision(evaluationDetails);
|
|
177
|
+
const metadata = evaluationDetails.flagMetadata;
|
|
178
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.__dd_do_log) !== true || metadata.__dd_exposure_cache_hit !== false) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
const details = {
|
|
183
|
+
...evaluationDetails,
|
|
184
|
+
flagKey: (_b = (_a = evaluationDetails.flagKey) !== null && _a !== void 0 ? _a : hookContext === null || hookContext === void 0 ? void 0 : hookContext.flagKey) !== null && _b !== void 0 ? _b : '',
|
|
185
|
+
};
|
|
186
|
+
const exposureEvent = createExposureEvent((_c = hookContext === null || hookContext === void 0 ? void 0 : hookContext.context) !== null && _c !== void 0 ? _c : {}, details);
|
|
187
|
+
if (!exposureEvent) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (this.exposureChannel.hasSubscribers) {
|
|
191
|
+
// Features stay off the cache entry: a features change must not turn a
|
|
192
|
+
// repeat exposure into a new one.
|
|
193
|
+
const features = featuresWithPrefix(metadata, METADATA_EXPOSURE_FEATURE_PREFIX);
|
|
194
|
+
this.exposureChannel.publish({
|
|
195
|
+
...exposureEvent,
|
|
196
|
+
...(features && { features }),
|
|
197
|
+
timestamp: timeStampNow(),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (!sharedDecision)
|
|
201
|
+
(_d = this.exposureCache) === null || _d === void 0 ? void 0 : _d.set(exposureEvent);
|
|
202
|
+
}
|
|
203
|
+
catch (_e) {
|
|
204
|
+
// Exposure reporting must never break the evaluation.
|
|
135
205
|
}
|
|
136
206
|
}
|
|
137
207
|
}
|
package/esm/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EAEnB,0BAA0B,EAC1B,YAAY,GACb,MAAM,wBAAwB,CAA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,CAAC;YACjF,OAAM;QACR,CAAC;QACD,IAAI,CAAC;YACH,MAAM,OAAO,GAAiC;gBAC5C,GAAG,iBAAiB;gBACpB,OAAO,EAAE,MAAA,MAAA,iBAAiB,CAAC,OAAO,mCAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,mCAAI,EAAE;aACjE,CAAA;YACD,MAAM,aAAa,GAAG,mBAAmB,CAAC,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,mCAAI,EAAE,EAAE,OAAO,CAAC,CAAA;YAC9E,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAM;YACR,CAAC;YACD,IAAI,IAAI,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC;gBACxC,uEAAuE;gBACvE,kCAAkC;gBAClC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAA;gBAC/E,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;oBAC3B,GAAG,aAAa;oBAChB,GAAG,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,CAAC;oBAC7B,SAAS,EAAE,YAAY,EAAE;iBAC1B,CAAC,CAAA;YACJ,CAAC;YACD,IAAI,CAAC,cAAc;gBAAE,MAAA,IAAI,CAAC,aAAa,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAA;QAC7D,CAAC;QAAC,WAAM,CAAC;YACP,sDAAsD;QACxD,CAAC;IACH,CAAC;CACF"}
|
package/index.d.ts
CHANGED
|
@@ -419,31 +419,6 @@ interface BaseHook<T extends FlagValue = FlagValue, TData = Record<string, unkno
|
|
|
419
419
|
*/
|
|
420
420
|
finally?(hookContext: Readonly<HookContext<T, TData>>, evaluationDetails: EvaluationDetails<T>, hookHints?: HookHints): HooksReturn;
|
|
421
421
|
}
|
|
422
|
-
interface ExposureEvent {
|
|
423
|
-
allocation: {
|
|
424
|
-
key: string;
|
|
425
|
-
};
|
|
426
|
-
flag: {
|
|
427
|
-
key: string;
|
|
428
|
-
};
|
|
429
|
-
variant: {
|
|
430
|
-
key: string;
|
|
431
|
-
};
|
|
432
|
-
serial_id?: number;
|
|
433
|
-
subject: {
|
|
434
|
-
id: string;
|
|
435
|
-
attributes: EvaluationContext;
|
|
436
|
-
};
|
|
437
|
-
service?: string;
|
|
438
|
-
rum?: {
|
|
439
|
-
application?: {
|
|
440
|
-
id?: string;
|
|
441
|
-
};
|
|
442
|
-
view?: {
|
|
443
|
-
url?: string;
|
|
444
|
-
};
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
422
|
declare enum OperatorType {
|
|
448
423
|
MATCHES = "MATCHES",
|
|
449
424
|
NOT_MATCHES = "NOT_MATCHES",
|
|
@@ -521,14 +496,17 @@ interface Split {
|
|
|
521
496
|
shards: Shard[];
|
|
522
497
|
extraLogging?: Record<string, string>;
|
|
523
498
|
serialId?: number;
|
|
499
|
+
features?: unknown;
|
|
524
500
|
}
|
|
525
501
|
interface Allocation {
|
|
526
502
|
key: string;
|
|
527
503
|
rules?: Rule[];
|
|
528
504
|
startAt?: Date;
|
|
529
505
|
endAt?: Date;
|
|
506
|
+
randomizationActivatedAt?: string;
|
|
530
507
|
splits: Split[];
|
|
531
|
-
|
|
508
|
+
/** Required by the UFC JSON schema; the producer always supplies an explicit boolean. */
|
|
509
|
+
doLog: boolean;
|
|
532
510
|
}
|
|
533
511
|
interface Flag {
|
|
534
512
|
key: string;
|
|
@@ -546,6 +524,32 @@ export interface UniversalFlagConfigurationV1 {
|
|
|
546
524
|
};
|
|
547
525
|
flags: Record<string, Flag>;
|
|
548
526
|
}
|
|
527
|
+
interface ExposureEvent {
|
|
528
|
+
allocation: {
|
|
529
|
+
key: string;
|
|
530
|
+
};
|
|
531
|
+
flag: {
|
|
532
|
+
key: string;
|
|
533
|
+
};
|
|
534
|
+
variant: {
|
|
535
|
+
key: string;
|
|
536
|
+
};
|
|
537
|
+
serial_id?: number;
|
|
538
|
+
features?: Record<string, string | number | boolean>;
|
|
539
|
+
subject: {
|
|
540
|
+
id: string;
|
|
541
|
+
attributes: EvaluationContext;
|
|
542
|
+
};
|
|
543
|
+
service?: string;
|
|
544
|
+
rum?: {
|
|
545
|
+
application?: {
|
|
546
|
+
id?: string;
|
|
547
|
+
};
|
|
548
|
+
view?: {
|
|
549
|
+
url?: string;
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
}
|
|
549
553
|
type Hook<TData = Record<string, unknown>> = BaseHook<FlagValue, TData, Promise<EvaluationContext | void> | EvaluationContext | void, Promise<void> | void>;
|
|
550
554
|
interface Provider extends CommonProvider<ServerProviderStatus> {
|
|
551
555
|
/**
|
|
@@ -599,9 +603,9 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
599
603
|
*/
|
|
600
604
|
getConfiguration(): UniversalFlagConfigurationV1 | undefined;
|
|
601
605
|
/**
|
|
602
|
-
* Used by dd-source-js
|
|
606
|
+
* Used by dd-source-js. Pass null or undefined to withdraw the configuration.
|
|
603
607
|
*/
|
|
604
|
-
setConfiguration(configuration: UniversalFlagConfigurationV1): void;
|
|
608
|
+
setConfiguration(configuration: UniversalFlagConfigurationV1 | null | undefined): void;
|
|
605
609
|
/**
|
|
606
610
|
* Used by dd-source-js
|
|
607
611
|
*/
|
|
@@ -620,6 +624,7 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
620
624
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<string>>;
|
|
621
625
|
resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<number>>;
|
|
622
626
|
resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext, _logger: Logger): Promise<ResolutionDetails<T>>;
|
|
627
|
+
/** Prepares a verdict finalized by the provider hook after successful evaluation. */
|
|
623
628
|
private handleExposure;
|
|
624
629
|
}
|
|
625
630
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/openfeature-node-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.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.
|
|
61
|
+
"@datadog/flagging-core": "3.4.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@openfeature/core": "1.11.0",
|
package/rules-based.d.ts
CHANGED
|
@@ -309,6 +309,12 @@ type Allocation = Message<"datadog.ffe.flagging.ufc.v1.Allocation"> & {
|
|
|
309
309
|
* @generated from field: bool log_exposure_event = 5;
|
|
310
310
|
*/
|
|
311
311
|
logExposureEvent: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* First randomization activation, independent of later allocation edits.
|
|
314
|
+
*
|
|
315
|
+
* @generated from field: google.protobuf.Timestamp randomization_activated_at = 6;
|
|
316
|
+
*/
|
|
317
|
+
randomizationActivatedAt?: Timestamp | undefined;
|
|
312
318
|
};
|
|
313
319
|
type AttributeReference = Message<"datadog.ffe.flagging.ufc.v1.AttributeReference"> & {
|
|
314
320
|
/**
|
|
@@ -663,6 +669,48 @@ type Split = Message<"datadog.ffe.flagging.ufc.v1.Split"> & {
|
|
|
663
669
|
* @generated from field: datadog.ffe.flagging.ufc.v1.Reason reason = 4;
|
|
664
670
|
*/
|
|
665
671
|
reason: Reason;
|
|
672
|
+
/**
|
|
673
|
+
* @generated from field: repeated datadog.ffe.flagging.ufc.v1.Feature features = 5;
|
|
674
|
+
*/
|
|
675
|
+
features: Feature[];
|
|
676
|
+
};
|
|
677
|
+
type Feature = Message<"datadog.ffe.flagging.ufc.v1.Feature"> & {
|
|
678
|
+
/**
|
|
679
|
+
* @generated from field: string key = 1;
|
|
680
|
+
*/
|
|
681
|
+
key: string;
|
|
682
|
+
/**
|
|
683
|
+
* @generated from oneof datadog.ffe.flagging.ufc.v1.Feature.value
|
|
684
|
+
*/
|
|
685
|
+
value: {
|
|
686
|
+
/**
|
|
687
|
+
* @generated from field: string string_value = 2;
|
|
688
|
+
*/
|
|
689
|
+
value: string;
|
|
690
|
+
case: "stringValue";
|
|
691
|
+
} | {
|
|
692
|
+
/**
|
|
693
|
+
* @generated from field: double number_value = 3;
|
|
694
|
+
*/
|
|
695
|
+
value: number;
|
|
696
|
+
case: "numberValue";
|
|
697
|
+
} | {
|
|
698
|
+
/**
|
|
699
|
+
* @generated from field: bool bool_value = 4;
|
|
700
|
+
*/
|
|
701
|
+
value: boolean;
|
|
702
|
+
case: "boolValue";
|
|
703
|
+
} | {
|
|
704
|
+
case: undefined;
|
|
705
|
+
value?: undefined;
|
|
706
|
+
};
|
|
707
|
+
/**
|
|
708
|
+
* Open strings such as HOOK, EXPOSURE or EVALUATION, not an enum: SDKs ignore destinations
|
|
709
|
+
* they do not know.
|
|
710
|
+
*
|
|
711
|
+
* @generated from field: repeated string destinations = 5;
|
|
712
|
+
*/
|
|
713
|
+
destinations: string[];
|
|
666
714
|
};
|
|
667
715
|
type PartitionRange = Message<"datadog.ffe.flagging.ufc.v1.PartitionRange"> & {
|
|
668
716
|
/**
|
|
@@ -806,6 +854,26 @@ declare enum Reason {
|
|
|
806
854
|
*/
|
|
807
855
|
DEFAULT = 4
|
|
808
856
|
}
|
|
857
|
+
interface OptOutInstant {
|
|
858
|
+
readonly seconds: number;
|
|
859
|
+
readonly fraction: string;
|
|
860
|
+
}
|
|
861
|
+
type RandomizationActivation = {
|
|
862
|
+
kind: "missing";
|
|
863
|
+
} | {
|
|
864
|
+
kind: "valid";
|
|
865
|
+
instant: OptOutInstant;
|
|
866
|
+
} | {
|
|
867
|
+
kind: "invalid";
|
|
868
|
+
};
|
|
869
|
+
type PreparedAllocations<T> = {
|
|
870
|
+
/** False when any activation is invalid, including on unreachable allocations. */
|
|
871
|
+
readonly valid: boolean;
|
|
872
|
+
readonly allocations: ReadonlyArray<{
|
|
873
|
+
allocation: T;
|
|
874
|
+
activation: RandomizationActivation;
|
|
875
|
+
}>;
|
|
876
|
+
};
|
|
809
877
|
type CachedJsonValue = {
|
|
810
878
|
valid: true;
|
|
811
879
|
value: FlagValue;
|
|
@@ -815,6 +883,8 @@ type CachedJsonValue = {
|
|
|
815
883
|
type PreparedRulesResponse = FlagsConfiguration & {
|
|
816
884
|
evaluationRegexCache: Map<number, RegExp | null>;
|
|
817
885
|
evaluationJsonCache: Map<number, CachedJsonValue>;
|
|
886
|
+
/** Validated once at decode time; evaluation must not read raw activation timestamps. */
|
|
887
|
+
randomizationActivations: ReadonlyMap<Flag, PreparedAllocations<Allocation>>;
|
|
818
888
|
};
|
|
819
889
|
/**
|
|
820
890
|
* Internal flags configuration for DatadogProvider.
|
|
@@ -855,6 +925,12 @@ type PrecomputedConfigurationResponse = {
|
|
|
855
925
|
attributes: {
|
|
856
926
|
/** When configuration was generated. */
|
|
857
927
|
createdAt: string;
|
|
928
|
+
/** Effective server evaluation options, retained in portable and persisted configurations. */
|
|
929
|
+
evaluation_options?: {
|
|
930
|
+
experimentation_opt_out?: boolean;
|
|
931
|
+
experimentation_opt_out_mode?: string;
|
|
932
|
+
dd_experimentation_opt_out_at?: string;
|
|
933
|
+
};
|
|
858
934
|
/** Absent or false for legacy plaintext assignments. */
|
|
859
935
|
obfuscated?: boolean;
|
|
860
936
|
/** Required when obfuscated is true; retained with the map in caches. */
|
|
@@ -871,6 +947,8 @@ type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
|
|
|
871
947
|
reason: ResolutionReason;
|
|
872
948
|
doLog: boolean;
|
|
873
949
|
serialId?: number | null;
|
|
950
|
+
/** Split features of the selected assignment; parsed leniently at evaluation time. */
|
|
951
|
+
features?: unknown;
|
|
874
952
|
};
|
|
875
953
|
export type FlagsConfigurationWire = string;
|
|
876
954
|
/**
|