UNPKG

@optimizely/optimizely-sdk

Version:

JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts

61 lines (60 loc) 2.31 kB
/** * Copyright 2025, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { LoggerFacade } from "../../../logging/logger"; import { IOptimizelyUserContext } from "../../../optimizely_user_context"; import { ProjectConfig } from "../../../project_config/project_config"; import { CacheWithRemove } from "../../../utils/cache/cache"; import { CmabClient } from "./cmab_client"; import { DecideOptionsMap } from ".."; import { Platform } from '../../../platform_support'; export type CmabDecision = { variationId: string; cmabUuid: string; }; export interface CmabService { /** * Get variation id for the user * @param {IOptimizelyUserContext} userContext * @param {string} ruleId * @param {OptimizelyDecideOption[]} options * @return {Promise<CmabDecision>} */ getDecision(projectConfig: ProjectConfig, userContext: IOptimizelyUserContext, ruleId: string, options: DecideOptionsMap): Promise<CmabDecision>; } export type CmabCacheValue = { attributesHash: string; variationId: string; cmabUuid: string; }; export type CmabServiceOptions = { logger?: LoggerFacade; cmabCache: CacheWithRemove<CmabCacheValue>; cmabClient: CmabClient; }; export declare class DefaultCmabService implements CmabService { private cmabCache; private cmabClient; private logger?; private serializers; constructor(options: CmabServiceOptions); private getSerializerIndex; getDecision(projectConfig: ProjectConfig, userContext: IOptimizelyUserContext, ruleId: string, options: DecideOptionsMap): Promise<CmabDecision>; private getDecisionInternal; private fetchDecision; private filterAttributes; private getCacheKey; } export declare const __platforms: Platform[];