/** * 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 { Transformer } from '../../utils/type'; import { Maybe } from '../../utils/type'; import { OpType, OpValue } from '../../utils/type'; import { Platform } from '../../platform_support'; export interface OpStore { operation: OP; set(key: string, value: V): OpValue; get(key: string): OpValue>; remove(key: string): OpValue; getKeys(): OpValue; } export type SyncStore = OpStore<'sync', V>; export type AsyncStore = OpStore<'async', V>; export type Store = SyncStore | AsyncStore; export declare abstract class SyncStoreWithBatchedGet implements SyncStore { operation: "sync"; abstract set(key: string, value: V): unknown; abstract get(key: string): Maybe; abstract remove(key: string): unknown; abstract getKeys(): string[]; abstract getBatched(keys: string[]): Maybe[]; } export declare abstract class AsyncStoreWithBatchedGet implements AsyncStore { operation: "async"; abstract set(key: string, value: V): Promise; abstract get(key: string): Promise>; abstract remove(key: string): Promise; abstract getKeys(): Promise; abstract getBatched(keys: string[]): Promise[]>; } export type StoreWithBatchedGet = SyncStoreWithBatchedGet | AsyncStoreWithBatchedGet; export declare const getBatchedSync: (store: SyncStore, keys: string[]) => Maybe[]; export declare const getBatchedAsync: (store: AsyncStore, keys: string[]) => Promise[]>; export declare class SyncPrefixStore extends SyncStoreWithBatchedGet implements SyncStore { private store; private prefix; private transformGet; private transformSet; readonly operation = "sync"; constructor(store: SyncStore, prefix: string, transformGet: Transformer, transformSet: Transformer); private addPrefix; private removePrefix; set(key: string, value: V): unknown; get(key: string): V | undefined; remove(key: string): unknown; private getInternalKeys; getKeys(): string[]; getBatched(keys: string[]): Maybe[]; } export declare class AsyncPrefixStore implements AsyncStore { private cache; private prefix; private transformGet; private transformSet; readonly operation = "async"; constructor(cache: AsyncStore, prefix: string, transformGet: Transformer, transformSet: Transformer); private addPrefix; private removePrefix; set(key: string, value: V): Promise; get(key: string): Promise; remove(key: string): Promise; private getInternalKeys; getKeys(): Promise; getBatched(keys: string[]): Promise[]>; } export declare const __platforms: Platform[];