UNPKG

@cordova-plugin-agconnect/clouddb

Version:
89 lines (88 loc) 4.26 kB
/* * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. */ import AGCCloudDBZone from "./AGCCloudDBZone"; import { CloudDBZoneConfig } from "./interfaces"; import AGCCloudDBQuery from './AGCCloudDBQuery'; import AGCCloudDBTransaction from './AGCCloudDBTransaction'; import { AGCCloudDBEventType } from "./enums"; export * from './interfaces'; export * from './enums'; export { AGCCloudDBQuery, AGCCloudDBTransaction }; /** * Initializes AGConnectCloudDB. */ export declare function initialize(): Promise<void>; /** * This method is called to create or modify an object type, * define a set of CloudDBZoneObject storage objects, * and store data generated by the application. */ export declare function createObjectType(): Promise<void>; /** * Obtains all CloudDBZoneConfig lists in the AGConnectCloudDB instance on the device. * @returns CloudDBZoneConfig object and configure Cloud DB zone information * such as the synchronization property, access property, encrypted storage property, * and data persistency property. */ export declare function getCloudDBZoneConfigs(): Promise<CloudDBZoneConfig[]>; /** * Asynchronously creates or opens an object of a Cloud DB zone which represents a unique data storage zone. * @param config The callback to execute when the Promise is rejected. * @param isAllowToCreate Specifies whether to allow Cloud DB zone object creation. * @returns Cloud DB zone object. Developers can use this object to add, delete, modify, query, and listen on data. */ export declare function openCloudDBZone2(config: CloudDBZoneConfig, isAllowToCreate: boolean): Promise<AGCCloudDBZone>; /** * Asynchronously creates or opens an object of a Cloud DB zone which represents a unique data storage zone. * @param config The callback to execute when the Promise is rejected. * @param isAllowToCreate Specifies whether to allow Cloud DB zone object creation. * @returns Cloud DB zone object. Developers can use this object to add, delete, modify, query, and listen on data. */ export declare function openCloudDBZone(config: CloudDBZoneConfig, isAllowToCreate: boolean): Promise<AGCCloudDBZone>; /** * Listens to registered user key change events. * @param callback Callback function to be called when listener is triggered. */ export declare function addEventListener(callback: (eventType: AGCCloudDBEventType) => void): Promise<void>; /** * Registers a listener for data key changes. * @param needFetchDataEncryptionKey Checks whether to update the data key. * If the value is true: update is required, the value is false: update is not required. * @param callback The callback to execute when the Promise is rejected. */ export declare function addDataEncryptionKeyListener(needFetchDataEncryptionKey: boolean, callback: (isDataKeyChange: boolean) => void): Promise<void>; /** * Deletes the Cloud DB zone object that is no longer used on the device. * @param zoneName The callback to execute when the Promise is rejected. */ export declare function deleteCloudDBZone(zoneName: string): Promise<void>; /** * Closes the Cloud DB zone object opened on the device. * @param id An id of Cloud DB zone to be closed. */ export declare function closeCloudDBZone(id: string): Promise<void>; /** * Enables data synchronization between the device and cloud. * @param zoneName Cloud DB zone name */ export declare function enableNetwork(zoneName: string): Promise<void>; /** * Disables data synchronization between the device and cloud. * @param zoneName Cloud DB zone name */ export declare function disableNetwork(zoneName: string): Promise<void>; /** * A data key used to encrypt user data, which is automatically generated by the system. * To prevent from being cracked when using one key for a long time, * you can call this method to update the data key. * @returns True if operation successful, otherwise false. */ export declare function updateDataEncryptionKey(): Promise<boolean>; /** * Sets or modifies the user password for Cloud DB full encryption. * @param userKey User password. * @param userReKey New user password. * @returns True if operation successful, otherwise false. */ export declare function setUserKey(userKey: string, userReKey: string): Promise<boolean>;