UNPKG

@hot-updater/plugin-core

Version:

React Native OTA solution for self-hosted

45 lines (44 loc) 1.56 kB
import type { Bundle } from "@hot-updater/core"; import type { BasePluginArgs, DatabasePlugin, DatabasePluginHooks } from "./types"; export interface BaseDatabaseUtils { cwd: string; } export interface AbstractDatabasePlugin extends Pick<DatabasePlugin, "getBundleById" | "getBundles" | "getChannels" | "onUnmount"> { commitBundle: ({ changedSets, }: { changedSets: { operation: "insert" | "update" | "delete"; data: Bundle; }[]; }) => Promise<void>; } /** * Creates a database plugin with the given implementation. * * @example * ```ts * const myDatabasePlugin = createDatabasePlugin("myDatabase", (utils) => { * return { * async getBundleById(bundleId) { * // Implementation to get a bundle by ID * return bundle; * }, * async getBundles(options) { * // Implementation to get bundles with options * return bundles; * }, * async getChannels() { * // Implementation to get available channels * return channels; * }, * async commitBundle({ changedMap }) { * // Implementation to commit changed bundles * } * }; * }); * ``` * * @param name - The name of the database plugin * @param initializer - A function that initializes the database plugin implementation * @returns A function that creates a database plugin instance */ export declare function createDatabasePlugin(name: string, abstractPlugin: AbstractDatabasePlugin, hooks?: DatabasePluginHooks): (options: BasePluginArgs) => DatabasePlugin;