UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

221 lines (220 loc) 13.3 kB
import { Dictionary } from '../typings/dictionary'; import { BreadcrumbItem } from './dto/breadcrumb-item'; import { CollectionResponse } from './dto/collection-response'; import { GenericContentItem } from './dto/generic-content-item'; import { NavigationItem } from './dto/navigation-item'; import { SdkItem } from './dto/sdk-item'; import { Widget } from './dto/widget'; import { CreateArgs } from './args/create.args'; import { CreateWidgetArgs } from './args/create-widget.args'; import { DeleteArgs } from './args/delete.args'; import { GetAllArgs } from './args/get-all.args'; import { GetBreadcrumbArgs } from './args/get-breadcrumb.args'; import { GetPageLayoutArgs } from './args/get-page-layout.args'; import { GetNavigationArgs } from './args/get-navigation.args'; import { ItemArgs } from './args/item.args'; import { LockArgs } from './args/lock-page.args'; import { PublishArgs } from './args/publish.args'; import { RelateArgs } from './args/relate.args'; import { ScheduleArgs } from './args/schedule.args'; import { UpdateArgs } from './args/update.args'; import { UploadMediaArgs } from './args/upload.args'; import { LayoutResponse, LayoutServiceResponse } from './dto/layout-service.response'; import { GetFormLayoutArgs } from './args/get-form-layout.args'; import { UserDto } from './dto/user-item'; import { ExternalProvider } from './dto/external-provider'; import { RegistrationSettingsDto } from './dto/registration-settings'; import { FacetsViewModelDto } from './dto/facets/facets-viewmodel-dto'; import { GetFacetsArgs } from './args/get-facets.args'; import { FacetFlatResponseDto } from './dto/facets/facet-flat-dto'; import { SearchArgs } from './args/perform-search.args'; import { SuggestionsArgs } from './args/get-search-suggestions.args'; import { SearchResultDocumentDto } from './dto/search-results-document-dto'; import { GetTaxonArgs } from './args/get-taxon.args'; import { TaxonDto } from './dto/taxon-dto'; import { GetTemplatesArgs } from './args/get-templates-args'; import { PageTemplateCategoryDto } from './dto/page-template-category.dto'; import { PageTemplateStatisticsDto } from './dto/page-template-statistics.dto'; import { WidgetModel } from '../editor/widget-framework/widget-model'; import { GetHierarchicalWidgetModelArgs } from './args/get-hierarchical-widget-model.args'; import { CommonArgs } from './args/common.args'; import { GetLazyWidgetsArgs } from './args/get-lazy-widgets.args'; import { SiteDto } from './dto/site-item'; import { ChangeLocationPriorityArgs } from './args/change-location-priority.args'; import { RequestArgs } from './args/request.args'; import { GetFacatebleFieldsArgs } from './args/get-facateble-fields.args'; import { GetSharedContentArgs } from './args/get-shared-content.args'; import { GetTemplatesStatisticsArgs } from './args/get-templates-statistics-args'; import { SearchMetadataDto } from './dto/search-metadata-dto'; import { ChangeTemplateArgs } from './args/change-template-args'; import { State } from './dto/state'; /** * Provides implementation for communicating with the Sitefinity REST API services. * This class is used to perform CRUD operations on items, search for items, and manage content in Sitefinity. */ export declare class RestClient { static contextQueryParams: { [key: string]: string; }; /** * Gets a media item with extended properties by type and id. * @param {ItemArgs} args The arguments for the request. *@param {string} args.type The type name of the item to retrieve. *@param {string} args.id The id of the item to retrieve. *@param {string} [args.culture] The culture for the request. *@param {string} [args.provider] The provider for the item if it is a part of non-default provider for the site and type. * @returns {Promise<T>} The requested item. */ static getItemWithFallback<T extends SdkItem>(args: ItemArgs): Promise<T>; /** * Gets a collection of taxons based on request arguments. * @param {GetTaxonArgs}args The arguments for the request. * @param {string} args.taxonomyId The taxonomy type id to retrieve taxons from. * @param {string[]} args.taxaIds The ids of the taxons to retrieve. Used when selection mode is "Selected" or "UnderParent". * @param {'All' | 'TopLevel' | 'UnderParent' | 'Selected' | 'ByContentType'} args.selectionMode The selection mode for the taxons. * @param {string} args.contentType Filter taxons that refer a specific content type. Used when selection mode is "ByContentType". * @param {boolean} args.showEmpty Whether to show taxons that have no related content items. * @param {string} args.orderBy The order by clause for the taxons. * @returns {Promise<Array<TaxonDto>>} A collection of matching taxons. */ static getTaxons(args: GetTaxonArgs): Promise<TaxonDto[]>; static getSearchMetadata(args: RequestArgs): Promise<SearchMetadataDto>; static getItemWithStatus<T extends SdkItem>(args: ItemArgs): Promise<T>; /** * Gets a content item by type and id. * @param {ItemArgs} args The arguments for the request. * @param {string} args.type The type name of the item to retrieve. * @param {string} args.id The id of the item to retrieve. * @param {string} [args.culture] The culture for the request. * @param {string[]} [args.fields] The fields to include in the response. By default the '*' wildcard is used and related fields are excluded. * @param {string} [args.provider] The provider for the item if it is a part of non-default provider for the site and type. * @param {Dictionary} [args.additionalQueryParams] Additional query parameters to include in the request. * @param {Dictionary} [args.additionalHeaders] Additional headers to include in the request. * @param {any} [args.additionalFetchData] Additional fetch data to include in the request. * @param {any} [args.traceContext] The current OpenTelemetry trace context for the request if such is available. It could be found in the WidgetContext. * @returns {Promise<T>} The requested item. */ static getItem<T extends SdkItem>(args: ItemArgs): Promise<T>; /** * Gets a shared content block by id. * @param args The arguments for the request. * @param {string} args.id The id of the shared content block to retrieve. * @param {string} [args.cultureName] The culture for the request and the version of the shared content block content to retrieve. * @returns {Promise<GenericContentItem>} The requested content block. */ static getSharedContent(args: GetSharedContentArgs): Promise<GenericContentItem>; /** * Gets a collection of items based on the provided arguments. * @param {GetAllArgs}args The get multiple items args. * @param {string} args.type The type name of the items to retrieve. * @param {number} [args.skip] The number of items to skip in the response. * @param {number} [args.take] The maximum number of items to return in the response. * @param {OrderBy} [args.orderBy] The order by clause to apply to the request. * @param {string} [args.provider] The provider for the items if they are part of a non-default provider for the site and type. * @param {string} [args.culture] The culture for the request. * @param {string[]} [args.fields] The fields to include in the response. By default the '*' wildcard is used and related fields are excluded. * @param {FilterClause | CombinedFilter | RelationFilter | DateOffsetPeriod | null} [args.filter] The filter to apply to the collection request. * @param {boolean} [args.count] Whether to include the total count of items in the response. * @param {Dictionary} [args.additionalQueryParams] Additional query parameters to include in the request. * @param {Dictionary} [args.additionalHeaders] Additional headers to include in the request. * @param {any} [args.additionalFetchData] Additional fetch data to include in the request. * @param {any} [args.traceContext] The current OpenTelemetry trace context for the request if such is available. It could be found in the WidgetContext. * @returns {Promise<CollectionResponse>} The wrepper object with a collection of the matched items if such exist. Otherwise an empty collection. */ static getItems<T extends SdkItem>(args: GetAllArgs): Promise<CollectionResponse<T>>; static createItem<T extends SdkItem>(args: CreateArgs): Promise<T>; static scheduleItem(args: ScheduleArgs): Promise<void>; static updateItem(args: UpdateArgs): Promise<void>; static deleteItem<T extends SdkItem>(args: DeleteArgs): Promise<T>; static publishItem(args: PublishArgs): Promise<void>; static saveDraftItem(args: PublishArgs): Promise<void>; static syncPage(args: UpdateArgs): Promise<void>; static lockItem(args: UpdateArgs): Promise<void>; static relateItem(args: RelateArgs): Promise<void>; static lockPage(args: LockArgs): Promise<void>; static createWidget(args: CreateWidgetArgs): Promise<Widget>; static updateWidget(page: SdkItem, propertyValues: any): Promise<unknown>; static uploadItem(args: UploadMediaArgs): Promise<SdkItem>; static performSearch(args: SearchArgs): Promise<{ totalCount: number; searchResults: SearchResultDocumentDto[]; }>; static getSearchSuggestions(args: SuggestionsArgs): Promise<{ value: string[]; }>; static getFacatebleFields(args: GetFacatebleFieldsArgs): Promise<FacetsViewModelDto[]>; static getFacets(args: GetFacetsArgs): Promise<FacetFlatResponseDto[]>; static getResetPasswordModel(token: string, traceContext?: any, headers?: Dictionary): Promise<RegistrationSettingsDto>; static getRegistrationSettings(args: RequestArgs): Promise<RegistrationSettingsDto>; static activateAccount(encryptedParam: string, traceContext?: any, headers?: Dictionary): Promise<void>; static getExternalProviders(args: RequestArgs): Promise<ExternalProvider[]>; static getCurrentUser(args?: RequestArgs): Promise<UserDto>; static getCurrentSite(args?: RequestArgs): Promise<SiteDto>; static getSites(args?: RequestArgs): Promise<SiteDto[]>; static getNavigation(args: GetNavigationArgs): Promise<NavigationItem[]>; static getBreadcrumb(args: GetBreadcrumbArgs): Promise<BreadcrumbItem[]>; static setHomePage(args: ItemArgs): Promise<void>; static getPreviewLink(args: ItemArgs): Promise<any>; static getPageSharePreviewLink(pageId: string): Promise<any>; static getContentLocations(args: CommonArgs): Promise<any>; static getDisplayPages(args: ItemArgs): Promise<any>; static getProviders(args: CommonArgs): Promise<any>; static changeLocationPriority(args: ChangeLocationPriorityArgs): Promise<any>; static getFormLayout(args: GetFormLayoutArgs): Promise<LayoutServiceResponse>; static getWidgetModel(args: GetHierarchicalWidgetModelArgs): Promise<WidgetModel<any>>; static getLazyWidget(args: GetHierarchicalWidgetModelArgs): Promise<WidgetModel<any> | undefined>; static getLazyWidgets(args: GetLazyWidgetsArgs): Promise<Array<WidgetModel<any>>>; static getPageLayout(args: GetPageLayoutArgs): Promise<LayoutResponse>; static getTemplates(args: GetTemplatesArgs): Promise<PageTemplateCategoryDto[]>; static getState(args: ItemArgs): Promise<State>; static changeTemplate(args: ChangeTemplateArgs): Promise<void>; static getTemplatesStatistics(args: GetTemplatesStatisticsArgs): Promise<PageTemplateStatisticsDto[]>; private static getSimpleFields; private static getRelatedFields; private static parseInnerFields; static buildQueryParams(queryParams: { [key: string]: string | undefined; } | undefined): string; static addAuthHeaders(cookie: string | undefined, headers: { [key: string]: string; }): void; private static getQueryParams; private static buildHeaders; static sendRequest<T>(request: RequestData, throwErrorAsJson?: boolean): Promise<T>; static buildItemBaseUrl(itemType: string): string; private static handleApiResponse; private static getSystemRoutePath; } export declare class RestSdkTypes { static readonly Video: string; static readonly Image: string; static readonly Document: string; static readonly DocumentLibrary: string; static readonly News: string; static readonly Taxonomies: string; static readonly Tags: string; static readonly Categories: string; static readonly GenericContent: string; static readonly Pages: string; static readonly PageTemplates: string; static readonly Form: string; static readonly Site: string; static readonly Blog: string; static readonly Event: string; static readonly Calendar: string; static readonly BlogPost: string; static readonly Author: string; static readonly List: string; static readonly ListItem: string; } interface RequestData { url: string; method?: string; headers?: { [key: string]: string; }; data?: any; additionalFetchData?: any; traceContext?: any; } export {};