import type { AccountGetResponse, AccountKvstoreGetRequest, KvStorePostRequest, ProgressPostRequest } from "./apis"; type AnyObject = Record; type Primitive = string | number | boolean; export interface EliceContentsMetadata { materialId: number; } export interface EliceContentsOptions { /** * Base url of the elice external contents server. * * @default 'https://api-external-contents.elice.io' */ baseUrl?: string; } export interface EliceContentsInitOptions { /** * The value that returned from window.location.search is used to initialize the elice external contents configuration. * * @default {window.location.search} */ search?: string; } export declare class EliceContents { #private; constructor(options?: EliceContentsOptions); /** * Initialize the elice external contents configuration. * * This function should be called when the window is loaded. * * If you pass the initial search params, it will be used to initialize the configuration. * * If you do not pass the initial search params, it will be resolved from the url. * * @example * ```ts * import { eliceContents } from 'src/constants'; * * const searchParams = myStore.getState().searchParams; // { extToken: '...', materialId: 1 } * * eliceContents.init({ * searchParams, * }); * ``` */ init(options?: EliceContentsInitOptions): Promise; /** * Get the current account information. * * @example * ```ts * import { eliceContents } from 'src/constants'; * * const account = eliceContents.account; // { accountId: 1, fullname: 'elice' } * * ``` */ get account(): AccountGetResponse | null; /** * Get a key-value entry from kvstore. * * If the key does not exist, it returns null. * * If the key exists, it returns the value. * * @example * ```ts * import { eliceContents } from 'src/constants'; * * const studentAnswers = await eliceContents.getKeyValue({ key: 'math.studentAnswers' }); // { question1: '1', question2: '2' } * ``` */ getKeyValue(params: AccountKvstoreGetRequest, init?: RequestInit): Promise; /** * Create new key-value entry in kvstore. * * The key must always be written in camelCase and must contain only English letters and numbers. ([a-zA-Z0-9]+]) * * Possible types of value are string, number, boolean, object, and array, and the key of an object must always be written in camelCase. * * @example * ```ts * import { eliceContents } from 'src/constants'; * * const handleSave = async () => { * await eliceContents.postKeyValue({ key: 'math.studentAnswers', value: { question1: '1', question2: '2' } }); * }; * ``` */ postKeyValue(params: Omit, 'value'> & { value: any; }, init?: RequestInit): Promise; /** * Configure the score to be passed to the Ellis platform when the user completes the content. * * Function requires an argument value called score, which is typically 100 to send when the content is completed. * * @example * ```ts * import { eliceContents } from 'src/constants'; * * const handleComplete = async () => { * await eliceContents.sendScore({ score: 100 }); * }; * ``` */ sendScore(params: ProgressPostRequest, init?: RequestInit): Promise; /** * Get the metadata of the current external content. * * This object contains materialId. * * This values are used to identify the current content. * * @example * ```ts * import { eliceContents } from 'src/constants'; * * const metadata = eliceContents.metadata; // { materialId: 1 } * ``` */ get metadata(): EliceContentsMetadata | null; } export {};