UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

131 lines (130 loc) 7.06 kB
import { IDictionary } from "../../types/common.types"; import { IRequestBody, IRestResponseType } from "../../types/rest.types"; import { IFolderBasicInfo, IFolderInfo } from "../../types/sharepoint.types"; import { FileLevel, IFileInfoWithModerationStatus, ModerationStatus } from "../../types/sharepoint.utils.types"; export declare function EnsureFolderPath(siteUrl: string, folderServerRelativeUrl: string): Promise<boolean>; export declare function EnsureFolderPathSync(siteUrl: string, folderServerRelativeUrl: string): boolean; export declare function EnsureFolder(siteUrl: string, parentFolderServerRelativeUrl: string, folderName: string): Promise<{ Exists: boolean; ServerRelativeUrl?: string; }>; export declare function EnsureFolderSync(siteUrl: string, parentFolderServerRelativeUrl: string, folderName: string): { Exists: boolean; ServerRelativeUrl?: string; }; export declare function DeleteFolder(siteUrl: string, folderUrl: string): Promise<boolean>; export declare function GetFolderFiles(siteUrl: string, folderUrl: string): Promise<IFileInfoWithModerationStatus[]>; export declare function UploadFileSync(siteUrl: string, folderServerRelativeUrl: string, fileName: string, fileContent: IRequestBody): { Exists: boolean; ServerRelativeUrl?: string; ListItemAllFields?: { [fieldInternalName: string]: any; }; }; export declare function UploadFile(siteUrl: string, folderServerRelativeUrl: string, fileName: string, fileContent: IRequestBody, /** default options: { overwrite: true } */ options?: { overwrite?: boolean; /** set to true to automatically find the next available file name. uploading file.ext to a folder that has that file will upload a file named file.1.ext instead */ autoRename?: boolean; }): Promise<{ Exists: boolean; ServerRelativeUrl?: string; [fieldInternalName: string]: any; }>; export declare function PublishFile(siteUrl: string, fileUrl: string, comment?: string): Promise<boolean>; export declare function UnpublishFile(siteUrl: string, fileUrl: string, comment?: string): Promise<boolean>; export declare function ApproveFile(siteUrl: string, fileUrl: string, comment?: string): Promise<boolean>; export declare function RejectFile(siteUrl: string, fileUrl: string, comment?: string): Promise<boolean>; export declare function RecycleFile(siteUrl: string, fileServerRelativeUrl: string): Promise<boolean>; export declare function DeleteFile(siteUrl: string, fileServerRelativeUrl: string): Promise<boolean>; export declare function GetFileSync<T>(siteUrl: string, fileServerRelativeUrl: string, responseType?: IRestResponseType, options?: { /** default, short cache. */ cache?: "long" | "short" | "nocache"; }): { Exists: boolean; Content?: T; }; /** @deprecated use GetFileEx */ export declare function GetFile<T>(siteUrl: string, fileServerRelativeUrl: string, allowCache?: boolean, responseType?: IRestResponseType): Promise<{ Exists: boolean; Content?: T; }>; export declare function GetFileEx<T>(siteUrl: string, fileServerRelativeUrl: string, options?: { allowCache?: boolean; responseType?: IRestResponseType; /** version #.# or version ID as number */ version?: string | number; }): Promise<{ Exists: boolean; Content?: T; }>; export interface iFileVersionInfo { CheckInComment: string; Created: Date; /** version ID: major*512 + minor */ ID: number; IsCurrentVersion: boolean; Length: string; Size: number; /** site relative _vti_history link. Better use /getFile..../versions(id)/$value */ Url: string; /** version format #.# */ VersionLabel: string; } /** get file version history olders version first with correct check in comment, does NOT include current version */ export declare function GetFileVersionHistory(siteUrl: string, fileServerRelativeUrl: string, options?: { refreshCache?: boolean; }): Promise<iFileVersionInfo[]>; /** @deprecated use SPVersionToVersionId instead -- version: 1.5 >> version ID for history */ export declare function FileVersionToVersionId(version: string | number): number; /** Get file size (bytes) by file server relative url - can also get this by selecting FileSizeDisplay field on the item */ export declare function GetFileSize(siteUrl: string, fileServerRelativeUrl: string, allowCache?: boolean): any; /** Get file size (bytes) by list item - can also get this by selecting FileSizeDisplay field on the item */ export declare function GetFileSize(siteUrl: string, listId: string, itemId: number, allowCache?: boolean): any; export declare function GetListFolders(siteUrl: string, listIdOrTitle: string): Promise<IFolderBasicInfo[]>; export declare function GetFolder(siteUrl: string, folderUrl: string, options?: { allowCache?: boolean; includeFolders?: boolean; includeFiles?: boolean; }): Promise<IFolderInfo>; export declare function GetFileItemId(siteUrl: string, fileServerRelativeUrl: string): Promise<number>; export declare function GetFileModerationStatus(siteUrl: string, fileServerRelativeUrl: string): Promise<ModerationStatus>; export declare function GetFilePublishingStatus(siteUrl: string, fileServerRelativeUrl: string): Promise<FileLevel>; export declare function GetFileItemInfo(siteUrl: string, fileServerRelativeUrl: string): Promise<{ listId: string; itemId: number; }>; export declare function GetFolderItemInfo(siteUrl: string, folderServerRelativeUrl: string): Promise<{ listId: string; itemId: number; }>; interface iWebPartPageProps { /** webpart id */ id: string; /** unique instance id - random guid, or blank to auto-generate */ instanceId?: string; title: string; description: string; dataVersion?: "1.0"; properties: IDictionary<string | boolean>; } /** Creates a modern single app page and return its URL. if a file in that name exists, it will return one with (1) appended to it. */ export declare function CreateAppPage(siteUrl: string, info: { /** file name, without extension */ name: string; webPartDataAsJson: iWebPartPageProps; }): Promise<string>; /** Move a file to a new name/url, this API allows for changing file extension as well */ export declare function MoveFile(siteUrl: string, currentServerRelativeUrl: string, targetServerRelativeUrl: string, options?: { overwrite?: boolean; /** set to true to automatically find the next available file name. uploading file.ext to a folder that has that file will upload a file named file.1.ext instead */ autoRename?: boolean; }): Promise<boolean>; /** Copy a file to a new name/url, this API allows for changing file extension as well */ export declare function CopyFile(siteUrl: string, currentServerRelativeUrl: string, targetServerRelativeUrl: string, options?: { overwrite?: boolean; /** set to true to automatically find the next available file name. uploading file.ext to a folder that has that file will upload a file named file.1.ext instead */ autoRename?: boolean; }): Promise<boolean>; export {};