import type { AccountKvstoreGetRequest, KvStoreDeleteRequest, KvStorePostRequest } from './apis'; import type { EliceCDK } from './EliceCDK'; import type { AnyObject, Primitive } from './typings'; /** * Key-value storage interface for persisting user data. * * Supports material-scoped storage (per user + material) and course-scoped storage (per user + course). * Keys must be camelCase and contain only alphanumeric characters. */ export declare class EliceCDKKvstore { private readonly ctx; constructor(ctx: EliceCDK); /** * Retrieves a value from the material-scoped key-value store. * * Data is scoped to the current user and material. Use dot notation to access nested values. * * @param params - Object containing the `key` to retrieve. * @param init - Optional fetch request configuration. * @returns The stored value, or `null` if not found. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * const data = await sdk.kvstore.get({ key: 'userProgress' }); * // { step: 3, completed: false } * * // Access nested value * const step = await sdk.kvstore.get({ key: 'userProgress.step' }); * // 3 * ``` */ get: (params: AccountKvstoreGetRequest, init?: RequestInit) => Promise; /** * Saves a value to the material-scoped key-value store. * * Data is scoped to the current user and material. * * @param params - Object containing `key` (camelCase, alphanumeric) and `value`. * @param init - Optional fetch request configuration. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * await sdk.kvstore.post({ * key: 'userProgress', * value: { step: 3, completed: false }, * }); * ``` */ post: (params: { key: KvStorePostRequest["key"]; value: Primitive | AnyObject; }, init?: RequestInit) => Promise; /** * Deletes a value from the material-scoped key-value store. * * @param key - The key to delete (camelCase, alphanumeric). * @param init - Optional fetch request configuration. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * await sdk.kvstore.delete('userProgress'); * ``` */ delete: (key: KvStoreDeleteRequest["key"], init?: RequestInit) => Promise; /** * Retrieves a value from the course-scoped key-value store. * * Data is scoped to the current user and course, shared across all materials in the course. * * @param params - Object containing the `key` to retrieve. * @param init - Optional fetch request configuration. * @returns The stored value, or `null` if not found. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * const settings = await sdk.kvstore.getGlobal({ key: 'courseSettings' }); * // { theme: 'dark', fontSize: 16 } * ``` */ getGlobal: (params: AccountKvstoreGetRequest, init?: RequestInit) => Promise; /** * Saves a value to the course-scoped key-value store. * * Data is scoped to the current user and course, shared across all materials in the course. * * @param params - Object containing `key` (camelCase, alphanumeric) and `value`. * @param init - Optional fetch request configuration. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * await sdk.kvstore.postGlobal({ * key: 'courseSettings', * value: { theme: 'dark', fontSize: 16 }, * }); * ``` */ postGlobal: (params: { key: KvStorePostRequest["key"]; value: Primitive | AnyObject; }, init?: RequestInit) => Promise; /** * Deletes a value from the course-scoped key-value store. * * @param key - The key to delete (camelCase, alphanumeric). * @param init - Optional fetch request configuration. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * await sdk.kvstore.deleteGlobal('courseSettings'); * ``` */ deleteGlobal: (key: KvStoreDeleteRequest["key"], init?: RequestInit) => Promise; }