UNPKG

@sysdoc/sharepoint-utils

Version:

Sysdoc's core Sharepoint utilities

83 lines (82 loc) 2.86 kB
/*! * Copyright Sysdoc @ 2019 */ import { IWeb } from "@pnp/sp-commonjs/presets/all"; import { Dictionary } from "@sysdoc/utilities"; import { IPnPField } from "../jsom/IPnPField"; import { ISPBasicRestProvider } from "./ISPBasicRestProvider"; /** * Config object for Basic Rest Provider */ export interface ISPBasicRestProviderConfig { /** * @property {string} contentTypeId - Default Content Type of the list. */ contentTypeId: string; /** * @property {string} listTitle - The name of the target list. */ listTitle: string; /** * @property {string} webUrl - The absolute URL of the site collection the list belongs to. * @example * For a list created under a 'syskp-demo/en-gb' the webUrl is: https://sysdoc.sharepoint.com/sites/syskp-demo/en-gb */ webUrl: string; /** * @property {string[]} fields - The array of fields returned when getByQuery is called * @example ['KPUser', 'KPLink', 'Author'] */ fields?: string[]; /** * @property {string} [fieldPrefix] - The prefix used in the definitions of custom fields. * @example 'KP' is the prefix used for the KPOverview field */ fieldPrefix?: string; includeFields?: string[]; additionalFields?: string[]; expandFields?: string[]; } /** * Query Order interface * * @property { string } field - The field internal name to sort by. * @property { boolean } sortAsc - Set the result sorting as ascending * * @example { field: KPSortOrder, sortAsc: true } */ export interface ISPRestQueryOrder { field: string; sortAsc: boolean; } export interface ISPRestQueryConfig { limit?: number; orderBy?: ISPRestQueryOrder; } export declare class SPBasicRestProvider implements ISPBasicRestProvider { listTitle: string; web: IWeb; contentTypeId: string; fields: string[]; fieldPrefix: string; schema: Dictionary<IPnPField>; _ready: Promise<any>; includeFields: string[]; expandFields: string[]; additionalFields: string[]; constructor(cfg: ISPBasicRestProviderConfig); toItem(item: any): any; getSchema(): Promise<Dictionary<IPnPField>>; whenReady(): Promise<any>; createSchemaFromFields(fields: IPnPField[]): any; itemToRest(item: any): any; prepareObject(obj: any): any; create(obj: any): Promise<import("@pnp/sp-commonjs").IItemAddResult>; update(obj: any): Promise<import("@pnp/sp-commonjs").IItemUpdateResult>; updateBatch(objs: any[], updateKeys?: string[]): Promise<void>; delete(key: number): Promise<void>; deleteBatch(keys: number[]): Promise<void>; getAll(): Promise<any>; getByQuery(filter: string, config?: ISPRestQueryConfig): Promise<any>; get(key: number): Promise<any>; }