UNPKG

powerpagestoolkit

Version:

Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier.

72 lines (71 loc) 3.48 kB
/// <reference path="../globals.d.ts" /> interface ODataJSON extends Object { [key: `${string}@odata.bind` | string]: any; } /** * Options for a custom API request. Structurally compatible with `JQuery.AjaxSettings`. */ /** * Options for a custom API request. Structurally compatible with `JQuery.AjaxSettings`. * Note: `url`, `success`, and `error` are managed internally and cannot be overridden. */ export interface RequestOptions { type?: string; method?: string; data?: any; contentType?: string | false; headers?: Record<string, string>; dataType?: string; timeout?: number; async?: boolean; cache?: boolean; crossDomain?: boolean; processData?: boolean; beforeSend?: (jqXHR: any, settings: any) => false | void; complete?: (jqXHR: any, textStatus: string) => void; [key: string]: any; } /** * Provides abstract class `API` that allows basic create, read, and update operations in DataVerse via the PowerPages API * @method `createRecord` - Create a record in DataVerse * @method `getRecord<T>` - Get a record by ID from DataVerse * @method `getMultiple<T>` - Get multiple records from DataVerse; with optional OData filtering * @method `updateRecord` - Update a record by ID in DataVerse * @method `request<T>` - Build a custom request for advanced customizations */ declare abstract class API { /** * @param tableSetName The dataverse set name for the table that you are updati a record in * @param data The JSON of the fields and data that are to be updated on the targeted record * @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request. */ static createRecord(tableSetName: string, data: ODataJSON): Promise<string>; /** * * @param tableSetName The DataVerse SET name of the table being queried * @param recordID the GUID of the records to be retrieved * @param ODataQueryString *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. e.g.: $select=column1,column2,column3 * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request */ static getRecord<T>(tableSetName: string, recordID: string, ODataQueryString?: string): Promise<T>; /** * More flexible method for building completely custom queries */ static request<T>(query: string, options?: RequestOptions): Promise<T>; /** * * @param tableSetName The dataverse set name of the table being queried * @param queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=statecode eq 0&$select=column1,column2... * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request */ static getMultiple<T>(tableSetName: string, queryParameters?: string): Promise<T[]>; /** * * @param tableSetName The dataverse set name for the table that you are updating a record in * @param recordId The GUID of the record that is being updated * @param data The JSON of the fields and data that are to be updated on the targeted record * @returns A Promise with the results of the API execution */ static updateRecord<T>(tableSetName: string, recordId: string, data: ODataJSON): Promise<T>; } export default API;