UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

38 lines (37 loc) 3.21 kB
import { IDictionary } from "../../types/common.types"; import { IRestError } from "../../types/rest.types"; import { FieldTypeAsString, IFieldInfoEX } from "../../types/sharepoint.types"; import { ISPRestError } from "../../types/sharepoint.utils.types"; export declare const LIST_SELECT = "ListExperienceOptions,EffectiveBasePermissions,Description,Title,EnableAttachments,EnableModeration,BaseTemplate,BaseType,Id,Hidden,IsApplicationList,IsPrivate,IsCatalog,ImageUrl,ItemCount,ParentWebUrl,EntityTypeName,DefaultViewUrl,ParentWeb/Id,ParentWeb/Title"; export declare const LIST_EXPAND = "ParentWeb/Id,ParentWeb/Title"; export declare const WEB_SELECT = "Title,ServerRelativeUrl,Id,WebTemplate,Description,SiteLogoUrl"; export declare const CONTENT_TYPES_SELECT = "Name,Description,StringId,Group,Hidden,ReadOnly,NewFormUrl,DisplayFormUrl,EditFormUrl,Sealed,MobileDisplayFormUrl,MobileNewFormUrl,MobileEditFormUrl,NewFormTemplateName,DisplayFormTemplateName,EditFormTemplateName"; export declare const CONTENT_TYPES_SELECT_WITH_FIELDS = "Name,Description,StringId,Group,Hidden,ReadOnly,NewFormUrl,DisplayFormUrl,EditFormUrl,Sealed,MobileDisplayFormUrl,MobileNewFormUrl,MobileEditFormUrl,NewFormTemplateName,DisplayFormTemplateName,EditFormTemplateName,Fields"; export declare function hasGlobalContext(): boolean; export declare function GetFileSiteUrl(fileUrl: string): string; /** gets a site URL or null, returns the current web URL or siteUrl as relative URL - end with / * If you send a guid - it will look for a site with that ID in the current context site collection */ export declare function GetSiteUrl(siteUrlOrId?: string): string; /** gets a site url, returns its REST _api url */ export declare function GetRestBaseUrl(siteUrl: string): string; /** Get the field internal name as you can find it in item.FieldValuesAsText[name] (Or FieldValuesForEdit) */ export declare function DecodeFieldValuesAsTextKey(key: string): string; /** Replaces _ with _x005f_, except OData_ at the start */ export declare function EncodeFieldValuesAsTextKey(key: string): string; /** Gets REST FieldValuesAsText or FieldValuesForEdit and fix their column names so that you can get a field value by its internal name */ export declare function DecodeFieldValuesAsText(FieldValuesAsText: IDictionary<string>): IDictionary<string>; /** Gets REST FieldValuesAsText or FieldValuesForEdit and fix their column names so that you can get a field value by its internal name */ export declare function DecodeFieldValuesForEdit(FieldValuesForEdit: IDictionary<string>): IDictionary<string>; /** Get the field internal name as you can find it in the item[name] to get raw values */ export declare function GetFieldNameFromRawValues(field: { InternalName: string; TypeAsString: FieldTypeAsString; }, options?: { excludeIdFromName: boolean; }): string; /** Get the field name to set on the item update REST request */ export declare function getFieldNameForUpdate(field: IFieldInfoEX): string; export declare function __isIRestError(e: any): e is IRestError; /** extract the error message from a SharePoint REST failed request */ export declare function __getSPRestErrorData(restError: IRestError): ISPRestError;