@devcycle/nodejs-server-sdk
Version:
The DevCycle NodeJS Server SDK used for feature management.
24 lines • 1.16 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DevCycleMigrationStrategy = void 0;
const server_sdk_1 = require("@openfeature/server-sdk");
const multi_provider_1 = require("@openfeature/multi-provider");
/**
* Extends FirstMatchStrategy to handle the DevCycle Provider, which returns DEFAULT for the "flag not found" case.
* Return the first result that did not return a default value or indicate "flag not found".
*
* Note: To use this strategy with DevCycle features, ensure all targeting rules include an "All Users" rule
* to avoid returning DEFAULT for known keys.
*/
class DevCycleMigrationStrategy extends multi_provider_1.FirstMatchStrategy {
shouldEvaluateNextProvider(strategyContext, context, result) {
if (this.hasErrorWithCode(result, server_sdk_1.ErrorCode.FLAG_NOT_FOUND) ||
('details' in result &&
result.details.reason === server_sdk_1.StandardResolutionReasons.DEFAULT)) {
return true;
}
return false;
}
}
exports.DevCycleMigrationStrategy = DevCycleMigrationStrategy;
//# sourceMappingURL=DevCycleMigrationStrategy.js.map
;