UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

154 lines (153 loc) 10 kB
import { IDictionary } from "../../types/common.types"; import { IContextWebInformation, IRententionLabel, ISiteGroupInfo, IUserCustomActionInfo, IWebInfo, SPBasePermissionKind } from "../../types/sharepoint.types"; import { IAppTile, IGroupInfo, IRestRoleDefinition, IRootWebInfo, ISiteInfo, ITimeZone, IUserInfo, IWebBasicInfo, IWebRegionalSettings, iContentType, iList } from "../../types/sharepoint.utils.types"; export declare function GetSiteInfo(siteUrl?: string): Promise<ISiteInfo>; export declare function GetSiteInfoSync(siteUrl?: string): ISiteInfo; /** Get tenant id lower case no {} */ export declare function GetTenantId(): string; /** Get tenant id lower case no {} */ export declare function GetPortalUrl(): string; /** Get site id lower case no {} */ export declare function GetSiteId(siteUrl?: string): Promise<string>; /** Get site id lower case no {} */ export declare function GetSiteIdSync(siteUrl?: string): string; /** Get root web id lower case no {} */ export declare function GetRootWebInfo(siteUrl?: string): Promise<IRootWebInfo>; /** Return the web Title */ export declare function GetWebTitle(siteUrl: string): Promise<string>; /** Return the web id */ export declare function GetWebId(siteUrl: string): Promise<string>; /** Return the web id */ export declare function GetWebIdSync(siteUrl: string): string; /** Return the web id */ export declare function IsRootWeb(siteUrl: string): Promise<boolean>; export declare function UserHasAllPermissions(siteUrl: string, permissions: SPBasePermissionKind[]): Promise<boolean>; export declare function UserHasManageSitePermissions(siteUrl: string): Promise<boolean>; export interface IGetContentTypesOptions { /** if you want content types for a specific list under site URL - ignores fromRootWeb */ listIdOrTitle?: string; /** if you want content types from the root web - ignores listIdOrTitle */ fromRootWeb?: boolean; ignoreFolders?: boolean; ignoreHidden?: boolean; /** Include fields associated with the content type */ includeFields?: boolean; } export declare function GetContentTypes(siteUrl: string, options?: IGetContentTypesOptions, refreshCache?: boolean): Promise<iContentType[]>; export declare function GetContentTypesSync(siteUrl: string, options?: IGetContentTypesOptions, refreshCache?: boolean): iContentType[]; interface IGetListsOptions { includeRootFolders?: boolean; includeViews?: boolean; } export declare function GetLists(siteUrl: string, options?: IGetListsOptions): Promise<iList[]>; export declare function GetListsSync(siteUrl: string, options?: IGetListsOptions): iList[]; /** * Get all sub webs. Results will be cached in memory and sorted * @param siteUrl the starting URL you want to get the sites for * @param allowAppWebs send true if you would like to inlucde app webs as well */ export declare function GetAllSubWebs(siteUrl: string, options?: { allSiteCollections?: boolean; allowAppWebs?: boolean; }): Promise<IWebBasicInfo[]>; export declare function __getSubSites(siteUrl: string, allowAppWebs?: boolean): Promise<IWebBasicInfo[]>; export declare function GetWebInfo(siteUrl: string, webId?: string, refreshCache?: boolean): Promise<IWebBasicInfo>; export declare function GetWebInfoSync(siteUrl: string, webId?: string): IWebBasicInfo; export declare function GetWebRoleDefinitions(siteUrl: string): Promise<IRestRoleDefinition[]>; export interface iRoleAssignment { Member: IGroupInfo | IUserInfo; RoleDefinitionBindings: IRestRoleDefinition[]; PrincipalId: 14; } /** get roles for site or list */ export declare function GetRoleAssignments(siteUrl: string, listIdOrTitle?: string, itemId?: number): Promise<iRoleAssignment[]>; /** Web sub webs for the selected site */ export declare function GetSubWebs(siteUrl: string, options?: { allowAppWebs?: boolean; }): Promise<IWebInfo[]>; /** Web sub webs for the selected site */ export declare function GetAppTiles(siteUrl: string): Promise<IAppTile[]>; /** Web sub webs for the selected site */ export declare function GetAppTilesSync(siteUrl: string): IAppTile[]; export declare function GetServerTimeZone(siteUrl: string): Promise<ITimeZone>; export declare function GetServerTimeZoneSync(siteUrl: string): ITimeZone; /** get date yyyy:MM:ddTHH:mm:ss NO ZED, or a date object created in the server local time, and return a date object of the corrected UTC time */ export declare function SPServerLocalTimeToUTCDate(siteUrl: string, date: string | Date): Promise<Date>; /** get date yyyy:MM:ddTHH:mm:ss NO ZED, or a date object created in the server local time, and return a date object of the corrected UTC time */ export declare function SPServerLocalTimeToUTCDateSync(siteUrl: string, date: string | Date): Date; /** get date yyyy:MM:ddTHH:mm:ss NO ZED * returns yyyy:MM:ddTHH:mm:ssZ * expensive, but works. for faster bulk parsing use toIsoDateFormat(new Date(GetServerTimeOffset + date.getTime())) * or: SPServerLocalTimeToUTCDate */ export declare function SPServerLocalTimeToUTC(siteUrl: string, date: string | Date): Promise<string>; /** * convert date in ISO format (yyyy:MM:ddTHH:mm:ss) or SPServerLocalTime (5/27/2020 11:34, 5-27-2020 11:34) * returns date in ISO UTC (yyyy:MM:ddTHH:mm:ssZ) * expensive, but works. for faster bulk parsing use toIsoDateFormat(new Date(GetServerTimeOffset + date.getTime())) * or: SPServerLocalTimeToUTCDateSync */ export declare function SPServerLocalTimeToUTCSync(siteUrl: string, date: string | Date): string; /** get utc date yyyy:MM:ddTHH:mm:ssZ * returns yyyy:MM:ddTHH:mm:ss NO ZED * expensive, but works. for faster bulk parsing use toIsoDateFormat(new Date(date.getTime()-GetServerTimeOffset,{omitZ:true})) */ export declare function UTCToSPServerLocalTime(siteUrl: string, date: string | Date): Promise<string>; /** get utc date yyyy:MM:ddTHH:mm:ssZ * returns yyyy:MM:ddTHH:mm:ss NO ZED * expensive, but works. for faster bulk parsing use toIsoDateFormat(new Date(date.getTime()-GetServerTimeOffset,{omitZ:true})) */ export declare function UTCToSPServerLocalTimeSync(siteUrl: string, date: string | Date): string; export declare function SPServerLocalTimeSync(siteUrl?: string): string; export declare function SPServerLocalTime(siteUrl: string): Promise<string>; export declare function SPServerLocalToday(siteUrl: string): Promise<string>; export declare function GetContextWebInformationSync(siteUrl: string): IContextWebInformation; /** Get UserCustomActions for web/list */ export declare function GetUserCustomActions(siteUrl: string, listId?: string, allowCache?: boolean): Promise<IUserCustomActionInfo[]>; /** Get UserCustomAction by id from web/list */ export declare function GetUserCustomActionById(siteUrl: string, customActionId: string, listId?: string, allowCache?: boolean): Promise<IUserCustomActionInfo>; /** Get UserCustomAction by name from web/list */ export declare function GetUserCustomActionByName(siteUrl: string, name: string, listId?: string, allowCache?: boolean): Promise<IUserCustomActionInfo[]>; /** Add UserCustomAction to web/list */ export declare function AddUserCustomAction(siteUrl: string, userCustomActionInfo: Omit<Partial<IUserCustomActionInfo>, "Id">, listId?: string): Promise<IUserCustomActionInfo>; /** Update UserCustomAction to web/list */ export declare function UpdateUserCustomAction(siteUrl: string, customActionId: string, userCustomActionInfo: Omit<Partial<IUserCustomActionInfo>, "Id">, listId?: string): Promise<boolean>; /** Delete UserCustomAction from web/list */ export declare function DeleteUserCustomAction(siteUrl: string, customActionId: string, listId?: string): Promise<boolean>; /** Get web regional settings */ export declare function GetRegionalSettings(siteUrl?: string): Promise<IWebRegionalSettings>; /** Get all web properties */ export declare function GetAllWebProperties(siteUrl?: string): Promise<IDictionary<string>>; /** Get web property by name */ export declare function GetWebPropertyByName(name: string, siteUrl?: string): Promise<string>; export declare function getFormDigest(serverRelativeWebUrl?: string): string; export interface spfxContext { legacyPageContext: typeof _spPageContextInfo; } export declare function ensureLegacyProps(pageContext: spfxContext): void; export declare function WebHasUniquePermissions(siteUrl: string): Promise<boolean>; export declare function RestoreWebPermissionInheritance(siteUrl: string): Promise<void>; export declare function BreakWebPermissionInheritance(siteUrl: string, clear?: boolean): Promise<void>; export declare function AssignWebPermission(siteUrl: string, principalId: number, roleId: number): Promise<void>; export declare function RemoveWebPermission(siteUrl: string, principalId: number, roleId: number): Promise<void>; /** set a user as site admin - rejects/throws if not successful */ export declare function SetUserAsSiteAdmin(siteUrl: string, userId: number): Promise<boolean>; /** get all the rentention labels (compliance tags) for a site */ export declare function GetAvailableTagsForSite(siteUrlOrId: string): Promise<IRententionLabel[]>; /** get all the rentention labels (compliance tags) for a site */ export declare function GetAvailableTagsForSiteSync(siteUrlOrId: string): IRententionLabel[]; export declare function GetActiveFeatures(siteUrlOrId: string, allowCache?: boolean): Promise<{ DisplayName: string; DefinitionId: string; }[]>; export declare function ActivateFeature(siteUrlOrId: string, id: string): Promise<boolean>; export declare function DectivateFeature(siteUrlOrId: string, id: string): Promise<boolean>; export declare function GetWelcomePage(siteUrlOrId: string): Promise<string>; export declare function SetWelcomePage(siteUrlOrId: string, welcomePage: string): Promise<boolean>; /** Get web associated groups */ export declare function GetWebAssociatedGroups(siteUrl?: string): Promise<{ AssociatedMemberGroup: ISiteGroupInfo; AssociatedOwnerGroup: ISiteGroupInfo; AssociatedVisitorGroup: ISiteGroupInfo; }>; export {};