import type { PageDataAsyncOptions, DataStore, Parameters, Query, Paging, SharedDataObject, Subscribers, DataStoreMeta, DataPageSubscribers } from './types'; /** The Datapage Class contains utility APIs to retrieve data from data pages. */ declare class DataPageUtils { isCacheEnabled: boolean; subscribers: Subscribers; dataPageSubscribers: DataPageSubscribers; dataStore: DataStore; dataStoreMeta: DataStoreMeta; subscribedDataPageNames: Set; SUBSCRIPTION_STATUS_FAILED: string; SUBSCRIPTION_STATUS_SUCCESS: string; DATAPAGE_NOT_CACHED: string; DUPLICATE_SUBSCRIPTION_ID: string; MISSING_MANDATORY_FIELD: string; constructor(); /** * API to get data page results from cache * @param dataPageName data page name * @param parameters parameters associated to it. * parameters: { * "paramName": "paramValue" * } * @param paging object containing information about the paging * paging: { * "pageNumber": 2, * "pageSize": 60 * } * @param query object containing information about the list of columns, filters * @private */ getData(dataPageName: string, parameters: Parameters, paging: Paging, query: Query): any[]; /** * API to get list type of data page results * @param dataPageName name of the list type of data page whose results to be fetched * @param context context name * @param parameters object containing parameters associated to the datapage. * @param paging object containing information about the paging * @param query object containing information about the list of columns, filters * @param options Javascript object containing optional preferences for fetching data page results
* { * invalidateCache: true, * purgeDataPageCache: true * } * @returns response object with list type datapage results * @example In the example below, the API retrieves the first 10 records of D_EmployeeList * const dataViewName = "D_EmployeeList"; * const parameters = { * "dept": "Engineering" * }; * const paging = { * "pageNumber":1, * "pageSize":10 * };
* const query = { * "distinctResultsOnly": true, * "select": [ * { * "field": "Name" * }, * { * "field": "Role" * }, * { * "field": "Gender" * } * ] * }; * const context = "app/primary_1"; * PCore.getDataPageUtils().getDataAsync(dataViewName, context, parameters, paging, query); * .then(response => { * // The response of this API is as shown below: * { * data: [ * { * "Name" : "Mark D", * "Role" : "Software Engineer", * "Gender" "Male" * }, * { * "Name" : "Lara", * "Role" : "Electrician", * "Gender" "Female" * } * ] * fetchDateTime: "2020-06-29T11:06:24.329Z" * pageNumber: 1 * pageSize: 10 * } * }) * .catch(error => { * console.log(error); * }); * */ getDataAsync(dataPageName: string, context: string | undefined, parameters?: Parameters, paging?: Paging, query?: Query, options?: PageDataAsyncOptions): Promise<{ data: any[]; } | { data: { [key: string]: any; }[]; pageNumber: number | undefined; pageSize: number | undefined; queryStats: any; status: number; fetchDateTime?: string; }>; /** * API to get page type of data page results * @param dataPageName name of the page type of data page whose results to be fetched * @param context name of the context * "app/primary_1" * @param parameters object containing parameters associated to data page. * parameters: { * "paramName": "paramValue" * } * @param options Javascript object containing optional preferences for fetching data page results * { * invalidateCache: true * } * @returns response object with page type datapage result * @example In the example below, the API retrieves the D_FollowedBugsCount page type datapage result * const dataViewName = "D_FollowedBugsCount"; * const parameters = { * "ID": "12311" *` }; * const context = "app/primary_1"; * const options = { * invalidateCache: true; * } * PCore.getDataPageUtils().getPageDataAsync(dataViewName, context, parameters, options); * .then(response => { * // The response of this API is as shown below: * { * "MyFollowedBugsCount":16, * "pzLoadTime":"August 25, 2022 9:50:59 PM UTC", * "pzPageNameHash":"_pa42316787137117pz"} * }) * .catch(error => { * console.log(error); * }); */ getPageDataAsync(dataPageName: string, context?: string, parameters?: Parameters, options?: PageDataAsyncOptions): Promise; /** * Subscribes to updates to a data page * @param {string} subscriptionId Unique ID assigned to a subscription * @param {Function} callback callback Function to be executed whenever a data page is updated * @param {string} dataPageName dataPageName Name of the data page that is being subscribed to * @param {object} [parameters = {}] (Optional), object containing parameters associated with the data page * @returns {boolean} Returns the Boolean value true if the data page is subscribed to successfully * @example In the example below, the API subscribes to any updates to the D_EmployeeList data page for the Engineering department * const subscriptionId = "900150983cd24fb0d6963f7d28e17f72"; * const callback = function () { * const updatedEmployeesList = PCore.getDataPageUtils().getDataAsync("D_EmployeeList", "app/primary_1", {"dept": "Engineering"}); * } * const dataPageName = "D_EmployeeList"; * const parameters = { * "department": "Engineering" * }; * const isSubscribed = PCore.getDataPageUtils().subscribeToDataPageUpdates(subscriptionId, callback, dataViewName, parameters); * if(isSubscribed){ * console.info('Subscription successful'); * }else{ * console.info('Subscription failure'); * } */ subscribeToDataPageUpdates(subscriptionId: string, callback: (...args: any) => any, dataPageName: string, parameters?: Parameters): boolean; /** * Unsubscribes to updates to a data page * @param {string} subscriptionId Unique ID assigned to a subscription * @param {string} dataPageName Name of the data page that is being unsubscribed from * @param {object} [parameters = {}] (Optional), object containing parameters associated with the data page * @returns {boolean} Returns the Boolean value true if the data page is unsubscribed from successfully * @example In the example below, the API unsubscribes to updates to the D_EmployeeList data page for the Engineering department * const subscriptionId = "900150983cd24fb0d6963f7d28e17f72"; * const dataPageName = "D_EmployeeList"; * const parameters = { * "dept": "Engineering" * }; * const isUnsubscribed = PCore.getDataPageUtils().unsubscribeToDataPageUpdates(subscriptionId, dataPageName, parameters); * if(isUnsubscribed){ * console.info('Successfully unsubscribed '); * }else{ * console.info('Failure during unsubscription'); * } */ unsubscribeToDataPageUpdates(subscriptionId: string, dataPageName: string, parameters?: Parameters): boolean; _isDataPageCached(dataPageName: string, parameters: Parameters): boolean; updateDataPageStore(sharedDataPages?: SharedDataObject): void; _addDataStoreMetaEntry(dataPageName: string, parameters: Parameters, dataPageWithHash: string): void; _removeDataStoreMetaEntry(dataPageName: string, parameters?: Parameters, dataPageWithHash?: string): void; mergeDataStore(dataPageName: string, parameters: Parameters, paging?: Paging, query?: Query, results?: { data?: { data: { [key: string]: any; }[]; }; }): { [key: string]: any; }[]; isDataPage(propertyRef?: string): boolean; subscribeToUpdate(dataPageName: string, dependentFields: string[], context: string, pageReference: string, callback: any, subscriptionId: string): void; unsubscribe(dataPageName: string, dependentFields: string[], context: string, pageReference: string, subscriptionId: string): void; /** * Message received from web socket service. * @param data = {message, msgId} format * { * matcher: "DATAPAGE_UPDATED", * message: { * "datapage": "D_Test" * } * } * @private */ handleMessage(data: { msgId?: string; message: { datapage: string; parameters: string; }; }): void; markDataInstanceDirty(dataPageName: string, parameters: Parameters): void; _executeDataPageSubscriptions(data: { msgId?: string; message: { datapage: string; parameters: string; }; }): void; isPerInteraction(dataPageName: string): boolean; /** * disable or enable the cache for * @param cacheDisable value whether Cache Should be disabled or enabled * @example In the example below, the API set the value to disable or enable the cache. * PCore.getDataPageUtils().disableCache(true) * @private */ disableCache(cacheDisable: boolean): void; private generateHash; private fetchData; private handleCascadeUpdate; private subscribeToCascadeUpdates; private subscribeToMessageService; private isCacheable; } declare const _default: DataPageUtils; export default _default;