/** * Page context services for the SharePoint Framework * * @remarks * The page context allows an application and its web parts to share common * data about the current page, such as its contents, URL, list, user, permissions, * navigation menu, etc. * * @packagedocumentation */ import { Guid } from '@microsoft/sp-core-library'; import type { IODataBasePermission } from '@microsoft/sp-odata-types'; import type { _IODataPageContextInfo } from '@microsoft/sp-odata-types'; import { ServiceKey } from '@microsoft/sp-core-library'; import { ServiceScope } from '@microsoft/sp-core-library'; /* Excluded from this release type: AzureActiveDirectoryInfo */ /** * This class is primarily used with the `PageContext` class. It provides culture info * for the current user of the application. * * @public */ export declare class CultureInfo { /** * This string determines the language default format for dates, times, numbers, currency values, * the sorting order of text, casing conventions, and string comparisons. * * @remarks * * This property may be an empty string, but it will never be undefined. * * Example: If the currentCultureName is `"en-AU"` then the application could use this information * to display the date as 1/8 instead of 8/1. */ readonly currentCultureName: string; /** * This string determines the default user interface language. This used for localization and * translation of text. * * @remarks * This property may have an empty string, but will never be undefined. * * Example: If the currentUICultureName is `"es-MX"`, then the application could use this * information to translate the word "hello" to "hola". */ readonly currentUICultureName: string; /** * This boolean represents the dominant direction of written text for the default user * interface language. */ readonly isRightToLeft: boolean; /* Excluded from this release type: __constructor */ } /* Excluded from this release type: _IAzureActiveDirectoryInfoParameters */ /* Excluded from this release type: _ICultureInfoData */ /* Excluded from this release type: _IO365GroupAssociationData */ /* Excluded from this release type: _IODataPageContextInfo */ /* Excluded from this release type: _IPageContextData */ /* Excluded from this release type: _IPageData */ /* Excluded from this release type: _ISearchData */ /* Excluded from this release type: _ISPFeatureData */ /* Excluded from this release type: _ISPFeatureInfoData */ /* Excluded from this release type: _ISPFieldData */ /* Excluded from this release type: _ISPListData */ /* Excluded from this release type: _ISPListItemData */ /* Excluded from this release type: _ISPSiteData */ /* Excluded from this release type: ISPSystemTime */ /* Excluded from this release type: ISPTimeZoneData */ /* Excluded from this release type: _ISPUserData */ /* Excluded from this release type: _ISPWebData */ /* Excluded from this release type: O365GroupAssociation */ /* Excluded from this release type: O365GroupAssociationType */ /* Excluded from this release type: Page */ /** * The SharePoint page context object. * * @remarks * The page context provides standard definitions for common SharePoint objects * that need to be shared between the client-side application, web parts, and other * components. Typically the data is fetched via REST queries when navigating to a * new page, but it can also be preloaded by the web server, or filled from a custom * application cache. * @public */ export declare class PageContext { /** * The service key for PageContext. */ static readonly serviceKey: ServiceKey; private static _logSource; private static _pageContextInfoId; private static _pageContextUserDynamicProperty; private static _pageContextSiteDataDynamicProperty; private static _pageContextUrlDataDynamicProperty; private static _pageContextSearchDataDynamicProperty; private _aadInfo; private _cultureInfo; private _list; private _listItem; private _page; private _site; private _user; private _web; private _spFeatureInfo; private _legacyPageContext; private _isInitialized; private _serviceScope; private _pageContextDataSource; private _searchData; private _initializationData; constructor(serviceScope: ServiceScope); /* Excluded from this release type: initialize */ /* Excluded from this release type: _setSearchQuery */ /* Excluded from this release type: _setSearchData */ /** * Contextual information for communicating with Azure Active Directory. * If the current page doesn't have an associated Azure Active Directory tenant, this * property will be undefined. */ get aadInfo(): AzureActiveDirectoryInfo | undefined; /** * It provides culture info for the current user of the application. * This class is primarily used with the `PageContext` class. */ get cultureInfo(): CultureInfo; /** * Contextual information for the SharePoint list that is hosting the page. * If there is no list associated to the current page, this property will be undefined. */ get list(): SPList | undefined; /** * Contextual information for the SharePoint list item that is hosting the page. * If there is no list item associated to the current page, this property will be undefined. */ get listItem(): SPListItem | undefined; /* Excluded from this release type: page */ /** * Contextual information for the SharePoint site collection ("SPSite") that is hosting the page. */ get site(): SPSite; /** * It provides contextual information for the SharePoint user that is accessing the page. * This class is primarily used with the `PageContext` class. */ get user(): SPUser; /** * Contextual information for the SharePoint site ("SPWeb") that is hosting the page. */ get web(): SPWeb; /* Excluded from this release type: _featureInfo */ /** * An object providing classic SharePoint properties that may be required by certain legacy scripts. * * @remarks * This property is provided to facilitate migration of legacy code. It returns a JavaScript * object whose contents are similar to the `_spPageContextInfo` window variable from classic pages. * The contents of this variable may change in future releases of SharePoint. For this reason, * new projects are encouraged to use the SharePoint Framework TypeScript APIs instead, since they * are fully documented and provide reliable backwards compatibility guarantees. * * NOTE: If certain functionality is exposed in the `legacyPageContext` but does not seem to have * a proper TypeScript API, please file an issue on GitHub. The intention is that no modern application * should need to rely on the `legacyPageContext` object. */ get legacyPageContext(): any; /** * Returns whether the `PageContext` has been initialized. */ get isInitialized(): boolean; /* Excluded from this release type: _initData */ private _getPropertyDefinitions; private _getPropertyValue; private _getAnnotatedPropertyValue; /** * Returns decoded key-value pair collection for the current page's query parameters. * * @remarks * If the key or value doesn't exist, it adds an empty string instead. */ private _getUrlQueryParameterCollection; /** * Returns the fragment identifier for the current page's url. */ private _getUrlFragmentIdentifier; } /* Excluded from this release type: SharePointPageContextDataProvider */ /* Excluded from this release type: SPDayOfWeek */ /* Excluded from this release type: _SPFeatureInfo */ /** * A field represents the data model for a column in SharePoint list view. * @remarks * * This is the client-side equivalent for SharePoint `SPField` class. It is used with the * `@microsoft/sp-listview-extensibility` package. * * @public */ export declare class SPField { /** * The GUID identifier for this field. */ readonly id: Guid; /** * The internal name of the field. This name is usually used to find the field. */ readonly internalName: string; /** * The type of the field represented as a string */ readonly fieldType: string; /** * Whether the field is required for each list item in the list */ readonly isRequired: boolean; /** * The display name of the field. This name is shown as column name in UI. */ readonly displayName: string; /** * The unique identifier of the client-side component associated with the field. */ readonly clientSideComponentId: Guid | undefined; /** * This property is only used when a `ClientSideComponentId` is specified. It is optional. * * @remarks * If non-empty, the string must contain a JSON object with custom initialization properties * whose format and meaning are defined by the client-side component. */ readonly clientSideComponentProperties: string; /* Excluded from this release type: __constructor */ } /** * This class is primarily used with the `PageContext` class. It provides contextual * information for the SharePoint list that hosts the page. * * @public */ export declare class SPList { /** * The GUID that identifies the SPList on the server. This property could be undefined * if the information isn't available. */ readonly id: Guid; /** * Return the SPPermission object that represents the set of permissions that the * current user has for interacting with the list. */ readonly permissions: SPPermission; /** * Returns the server-relative URL for this `SPList`. * * @remarks * Example: "/sites/PubSite" */ readonly serverRelativeUrl: string; /** * Returns the title for this `SPList`. */ readonly title: string; /* Excluded from this release type: __constructor */ } /** * This class is primarily used with the `PageContext` class. It provides contextual * information for the SharePoint list item that hosts the page. * * @public */ export declare class SPListItem { /** * The number that identifies the `SPListItem` on the server. * */ readonly id: number; /* Excluded from this release type: uniqueId */ /* Excluded from this release type: __constructor */ } /** * Used to test whether the current user has a requested set of permissions. * * @remarks * * Specifies the built-in permissions available in SharePoint Foundation * * For more information, see: * {@link https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx} * * @public */ export declare class SPPermission { /** * Has no permissions on the Web site. Not available through the user interface. */ static readonly emptyMask: SPPermission; /** * View items in lists, documents in document libraries, and view Web discussion comments. */ static readonly viewListItems: SPPermission; /** * Add items to lists, add documents to document libraries, and add Web discussion comments. */ static readonly addListItems: SPPermission; /** * Edit items in lists, edit documents in document libraries, edit Web discussion comments in documents, * and customize web part Pages in document libraries. */ static readonly editListItems: SPPermission; /** * Delete items from a list, documents from a document library, and Web discussion comments in documents. */ static readonly deleteListItems: SPPermission; /** * Approve a minor version of a list item or document. */ static readonly approveItems: SPPermission; /** * View the source of documents with server-side file handlers. */ static readonly openItems: SPPermission; /** * View past versions of a list item or document. */ static readonly viewVersions: SPPermission; /** * Delete past versions of a list item or document. */ static readonly deleteVersions: SPPermission; /** * Discard or check in a document which is checked out to another user. */ static readonly cancelCheckout: SPPermission; /** * Create, change, and delete personal views of lists. */ static readonly managePersonalViews: SPPermission; /** * Create and delete lists, add or remove columns in a list, and add or remove public views of a list. */ static readonly manageLists: SPPermission; /** * View forms, views, and application pages, and enumerate lists. */ static readonly viewFormPages: SPPermission; /** * Allow users to open a Web site, list, or folder to access items inside that container. */ static readonly open: SPPermission; /** * View pages in a Web site. */ static readonly viewPages: SPPermission; /** * View the layouts page? */ static readonly layoutsPage: SPPermission; /** * Add, change, or delete HTML pages or web part Pages, and edit the Web site using a SharePoint * Foundation-compatible editor. */ static readonly addAndCustomizePages: SPPermission; /** * Apply a theme or borders to the entire Web site. */ static readonly applyThemeAndBorder: SPPermission; /** * Apply a style sheet (.css file) to the Web site. */ static readonly applyStyleSheets: SPPermission; /** * View reports on Web site usage. */ static readonly viewUsageData: SPPermission; /** * Create a Web site using Self-Service Site Creation. */ static readonly createSSCSite: SPPermission; /** * Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites. */ static readonly manageSubwebs: SPPermission; /** * Create a group of users that can be used anywhere within the site collection. */ static readonly createGroups: SPPermission; /** * Create and change permission levels on the Web site and assign permissions to users and groups. */ static readonly managePermissions: SPPermission; /** * Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces. */ static readonly browseDirectories: SPPermission; /** * View information about users of the Web site. */ static readonly browserUserInfo: SPPermission; /** * Add or remove personal web parts on a web part Page. */ static readonly addDelPrivateWebParts: SPPermission; /** * Update web parts to display personalized information. */ static readonly updatePersonalWebParts: SPPermission; /** * Grant the ability to perform all administration tasks for the Web site as well as manage content. * * @remarks * Activate, deactivate, or edit properties of Web site scoped Features through the object model or * through the user interface (UI). When granted on the root Web site of a site collection, activate, * deactivate, or edit properties of site collection scoped Features through the object model. To * browse to the Site Collection Features page and activate or deactivate site collection scoped * Features through the UI, you must be a site collection administrator. */ static readonly manageWeb: SPPermission; /** * Use features that launch client applications; otherwise, users must work on documents locally and upload changes. */ static readonly useClientIntegration: SPPermission; /** * Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007 interfaces to access the Web site. */ static readonly useRemoteAPIs: SPPermission; /** * Manage alerts for all users of the Web site. */ static readonly manageAlerts: SPPermission; /** * Create e-mail alerts. */ static readonly createAlerts: SPPermission; /** * Allows a user to change his or her user information, such as adding a picture. */ static readonly editMyUserInfo: SPPermission; /** * Enumerate permissions on the Web site, list, folder, document, or list item. */ static readonly enumeratePermissions: SPPermission; /** * Has all permissions on the Web site. Not available through the user interface. */ static readonly fullMask: SPPermission; private _value; constructor(value: IODataBasePermission); /** * Returns the value of this SPPermission object */ get value(): IODataBasePermission; /** * Function for testing whether a given permission mask has any of the requested permissions. * @param requestedPerms - Any number of SPPermission objects to be compared against the original */ hasAnyPermissions(...requestedPerms: SPPermission[]): boolean; /** * Function for testing whether a given permission mask has all of the requested permissions. * @param requestedPerms - Any number of SPPermission objects to be compared against the original */ hasAllPermissions(...requestedPerms: SPPermission[]): boolean; /** * Function for testing whether a given permission mask has the requested permission. * @param requestedPerm - The SPPermission object to be compared against the original */ hasPermission(requestedPerm: SPPermission): boolean; } /** * This class is primarily used with the `PageContext` class. It provides contextual * information for the SharePoint site collection ("SPSite") that hosts the page. * * @public */ export declare class SPSite { /** * Returns the absolute URL for this SPSite. * * @remarks * Example: "https://example.com/sites/PubSite" */ readonly absoluteUrl: string; /** * Returns the prefix of the application's specified cdn or an empty string if there isn't one. */ readonly cdnPrefix: string; /** * Returns the classification of the site. */ readonly classification: string; /** * Returns the correlation id to the current server request. */ readonly correlationId: Guid; /** * Contextual information about the O365 Group associated with this site. * If there is no O365Group associated with the current site, this property will be undefined. */ readonly group: O365GroupAssociation | undefined; /** * The GUID that identifies the SPSite on the server. */ readonly id: Guid; /** * Returns true if isNoScript has been enabled on the SPSite. */ readonly isNoScriptEnabled: boolean; /** * The amount of items in the recycle bin. */ readonly recycleBinItemCount: number; /** * Returns the server-relative URL for this SPSite. * * @remarks * Example: "/sites/PubSite" */ readonly serverRelativeUrl: string; /** * Returns serverRelativeUrl of the original request. * * @remarks * Example: "/teams/SPClientTest/SitePages/Home.aspx" */ readonly serverRequestPath: string; /** * Returns true if SitePages are enabled on this SPSite. */ readonly sitePagesEnabled: boolean; /* Excluded from this release type: sitePagesFeatureVersion */ /* Excluded from this release type: __constructor */ } /* Excluded from this release type: SPTimeZone */ /** * This class is primarily used with the `PageContext` class. It provides contextual information * for the SharePoint user that is accessing the page. * * @public */ export declare class SPUser { /** * The display name for the current user. * * @remarks * Example: `"John Doe"` */ readonly displayName: string; /** * The email address for the current user. * * @remarks * Example: `"example@contoso.com"` */ readonly email: string; /** * Returns if the current user is an anonymous guest. */ readonly isAnonymousGuestUser: boolean; /** * Returns true if the current user is an external guest. */ readonly isExternalGuestUser: boolean; /** * The login name for current user. * * @remarks * Example: on-premise user: `"domain\user"`, online user: `"user@domain.com"` */ readonly loginName: string; /** * This boolean represents if a the user or web's time zone settings should be used * to display the current time. */ readonly preferUserTimeZone: boolean; /* Excluded from this release type: timeZoneInfo */ /* Excluded from this release type: firstDayOfWeek */ /* Excluded from this release type: __constructor */ } /** * This class is primarily used with the `PageContext` class. It provides contextual * information for the SharePoint site ("SPWeb") that hosts the page. * * @public */ export declare class SPWeb { /** * Returns the absolute URL for this SPWeb. * Example: `"https://example.com/sites/PubSite/SubWeb"` */ readonly absoluteUrl: string; /** * The GUID that identifies the SPWeb on the server. */ readonly id: Guid; /** * Returns true if this `SPWeb` the container web for an `SPApp`. */ readonly isAppWeb: boolean; /** * Returns the locale identifier (LCID) for the default language of the website. * * @remarks * Example: 1033 represents the locale identifier for en-US. */ readonly language: number; /** * Returns the language name for the default language of the website. * * @remarks * Example: en-US represents the English language in the US locale. */ readonly languageName: string; /** * Returns the absolute URL of the website logo. * * @remarks * Example:` https://example.com/sites/PubSite/SubWeb/logo.jpg` */ readonly logoUrl: string; /** * Return the SPPermission object that represents the set of permissions that the * current user has for interacting with the web. */ readonly permissions: SPPermission; /* Excluded from this release type: timeZoneInfo */ /* Excluded from this release type: firstDayOfWeek */ /** * Returns the server-relative URL for this SPWeb. * * @remarks * Example: `"/sites/PubSite/SubWeb"` */ readonly serverRelativeUrl: string; /** * Returns the string representing the numeric identifier for the site definition or * site template that was used to create the site. * * @remarks * Example: `"1"` represents the team site template when creating a new site on SharePoint. */ readonly templateName: string; /** * Returns the title of the current SPWeb. */ readonly title: string; /** * Returns the description of the current SPWeb. */ readonly description: string; /* Excluded from this release type: __constructor */ } export { }