export interface CapgoCapacitorDataStorageSqlitePlugin { /** * Open a store * @param options: capOpenStorageOptions * @returns Promise * @since 0.0.1 */ openStore(options: capOpenStorageOptions): Promise; /** * Close the Store * @param options: capStorageOptions * @returns Promise * @since 3.0.0 */ closeStore(options: capStorageOptions): Promise; /** * Check if the Store is opened * @param options: capStorageOptions * @returns Promise * @since 3.0.0 */ isStoreOpen(options: capStorageOptions): Promise; /** * Check if the Store exists * @param options: capStorageOptions * @returns Promise * @since 3.0.0 */ isStoreExists(options: capStorageOptions): Promise; /** * Delete a store * @param options: capOpenStorageOptions * @returns Promise * @since 0.0.1 */ deleteStore(options: capOpenStorageOptions): Promise; /** * Set or Add a table to an existing store * @param options: capTableStorageOptions * @returns Promise * @since 0.0.1 */ setTable(options: capTableStorageOptions): Promise; /** * Store a data with given key and value * @param options: capDataStorageOptions * @returns Promise * @since 0.0.1 */ set(options: capDataStorageOptions): Promise; /** * Retrieve a data value for a given data key * @param options: capDataStorageOptions * @returns Promise * @since 0.0.1 */ get(options: capDataStorageOptions): Promise; /** * Remove a data with given key * @param options: capDataStorageOptions * @returns Promise * @since 0.0.1 */ remove(options: capDataStorageOptions): Promise; /** * Clear the Data Store (delete all keys) * @returns Promise * @since 0.0.1 */ clear(): Promise; /** * Check if a data key exists * @param options: capDataStorageOptions * @returns Promise * @since 0.0.1 */ iskey(options: capDataStorageOptions): Promise; /** * Get the data key list * @returns Promise * @since 0.0.1 */ keys(): Promise; /** * Get the data value list * @returns Promise * @since 0.0.1 */ values(): Promise; /** * Get the data value list for filter keys * @param options: capFilterStorageOptions * @returns Promise * @since 2.4.2 */ filtervalues(options: capFilterStorageOptions): Promise; /** * Get the data key/value pair list * @returns Promise * @since 0.0.1 */ keysvalues(): Promise; /** * Check if a table exists * @param options: capTableStorageOptions * @returns Promise * @since 3.0.0 */ isTable(options: capTableStorageOptions): Promise; /** * Get the table list for the current store * @returns Promise * @since 3.0.0 */ tables(): Promise; /** * Delete a table * @param options: capTableStorageOptions * @returns Promise * @since 3.0.0 */ deleteTable(options: capTableStorageOptions): Promise; /** * Import a database From a JSON * @param jsonstring string * @returns Promise * @since 3.2.0 */ importFromJson(options: capStoreImportOptions): Promise; /** * Check the validity of a JSON Object * @param jsonstring string * @returns Promise * @since 3.2.0 */ isJsonValid(options: capStoreImportOptions): Promise; /** * Export the given database to a JSON Object * @returns Promise * @since 3.2.0 */ exportToJson(): Promise; /** * Rebuild the current SQLite store to reclaim unused disk space. * @returns Promise * @since 8.0.32 */ vacuum(): Promise; /** * Get the native Capacitor plugin version * * @returns {Promise<{ version: string }>} a Promise with version for this plugin * @throws An error if something went wrong */ getPluginVersion(): Promise<{ version: string; }>; } export interface capOpenStorageOptions { /** * The storage database name */ database?: string; /** * The storage table name */ table?: string; /** * Set to true for database encryption */ encrypted?: boolean; /** * Set the mode for database encryption on iOS and Android. * * - `encryption` — encrypt an existing plaintext database with the configured passphrase * - `secret` — open or create an encrypted database with the configured passphrase * - `newsecret` — rekey an encrypted database from `encryptionSecret` to `encryptionNewSecret` * * Passphrases are set in `capacitor.config` under `plugins.CapgoCapacitorDataStorageSqlite` * (see {@link CapgoCapacitorDataStorageSqliteConfig}). Defaults are defined in the plugin's * `Global` sources if you do not configure them. */ mode?: string; /** * Set the SQLite auto_vacuum mode for the store. * * Use `none`/`0`, `full`/`1`, or `incremental`/`2`. * iOS, Android, and Electron only. Web ignores this option. */ autoVacuum?: capSQLiteAutoVacuum; } export type capSQLiteAutoVacuum = 'none' | 'full' | 'incremental' | 0 | 1 | 2; export interface capDataStorageOptions { /** * The data name */ key: string; /** * The data value when required */ value?: string; } export interface capStorageOptions { /** * The storage name */ database: string; } export interface capTableStorageOptions { /** * The storage table name */ table: string; } export interface capFilterStorageOptions { /** * The filter data for filtering keys * * ['%filter', 'filter', 'filter%'] for * [starts with filter, contains filter, ends with filter] */ filter: string; } export interface capDataStorageResult { /** * result set to true when successful else false */ result?: boolean; /** * a returned message */ message?: string; } export interface capValueResult { /** * the data value for a given data key */ value: string; } export interface capKeysResult { /** * the data key list as an Array */ keys: string[]; } export interface capValuesResult { /** * the data values list as an Array */ values: string[]; } export interface capKeysValuesResult { /** * the data keys/values list as an Array of {key:string,value:string} */ keysvalues: any[]; } export interface capTablesResult { /** * the tables list as an Array */ tables: string[]; } export interface JsonStore { /** * The database name */ database: string; /** * Set to true (database encryption) / false * iOS & Android only */ encrypted: boolean; /*** * Array of Table (JsonTable) */ tables: JsonTable[]; } export interface JsonTable { /** * The database name */ name: string; /*** * Array of Values (capDataStorageOptions) */ values?: capDataStorageOptions[]; } export interface capDataStorageChanges { /** * the number of changes from an importFromJson command */ changes?: number; } export interface capStoreImportOptions { /** * Set the JSON object to import * */ jsonstring?: string; } export interface capStoreJson { /** * an export JSON object */ export?: JsonStore; } /** * Capacitor plugin configuration for `@capgo/capacitor-data-storage-sqlite`. * * Add under `plugins.CapgoCapacitorDataStorageSqlite` in `capacitor.config.ts`. * iOS and Android only (SQLCipher). * * @example * ```ts * plugins: { * CapgoCapacitorDataStorageSqlite: { * encryptionSecret: 'my-production-passphrase', * encryptionNewSecret: 'my-next-passphrase', * }, * }, * ``` */ export interface CapgoCapacitorDataStorageSqliteConfig { /** * SQLCipher passphrase used when `openStore` `mode` is `secret` or `encryption`. */ encryptionSecret?: string; /** * Target passphrase when `openStore` `mode` is `newsecret` (rekey from `encryptionSecret`). */ encryptionNewSecret?: string; }