diff --git a/src/resources/HostedInterfacesCore/HostedInterfaceCoreConfig.model.ts b/src/resources/HostedInterfacesCore/HostedInterfaceCoreConfig.model.ts index d8ee698ce..2da1fbcea 100644 --- a/src/resources/HostedInterfacesCore/HostedInterfaceCoreConfig.model.ts +++ b/src/resources/HostedInterfacesCore/HostedInterfaceCoreConfig.model.ts @@ -155,7 +155,7 @@ export interface HostedInterfaceConfiguration { id: string; /** - * The name of the insight panel interface configuration. + * The name of the interface configuration. */ name: string; diff --git a/src/resources/HostedInterfacesCore/HostedInterfaceVersionsCore.ts b/src/resources/HostedInterfacesCore/HostedInterfaceVersionsCore.ts new file mode 100644 index 000000000..dd31d9623 --- /dev/null +++ b/src/resources/HostedInterfacesCore/HostedInterfaceVersionsCore.ts @@ -0,0 +1,128 @@ +import {Paginated} from '../BaseInterfaces.js'; + +export interface HostedInterfaceChangeInfo { + /** + * The change date and time in ISO-8601 format. + */ + date: string; + /** + * The user identity in the following form: `user@domain-provider`. + */ + by: string; + /** + * The user's first name specified in the provider's user profile (e.g., the Google account). + */ + firstName?: string; + /** + * The user's last name specified in the provider's user profile (e.g., the Google account). + */ + lastName?: string; +} + +export interface HostedInterfaceVersionInfo { + /** + * The version number. + */ + version: number; + /** + * The optional version label. + */ + label?: string; + /** + * The version creation information. + */ + created: HostedInterfaceChangeInfo; + /** + * The version update information. + */ + updated: HostedInterfaceChangeInfo; + /** + * Indicates whether the version is currently published. + */ + isPublished: boolean; +} + +/** + * @param - Hosted interface config model + */ +export interface HostedInterfaceVersion { + /** + * The version number. + */ + version: number; + /** + * The optional version label. + */ + label?: string; + /** + * The version creation information. + */ + created: HostedInterfaceChangeInfo; + /** + * The version update information. + */ + updated: HostedInterfaceChangeInfo; + /** + * Indicates whether the version is currently published. + */ + isPublished: boolean; + /** + * This version's interface config. + */ + configuration: T; + /** + * When an interface is restored, indicates the source version number. + */ + restoredFromVersion?: number; +} + +export interface ListHostedInterfaceVersionsParams extends Paginated { + /** + * The zero-based page to retrieve. + * + * @default `0` + */ + page?: number; + /** + * The number of versions to return per page. + * + * @default `10` + */ + perPage?: number; + /** + * A substring that must appear in a version label for this configuration to appear in results. + */ + filter?: string; + /** + * The sort order to apply on the interface version number. + * + * **Allowed values:** + * - `undefined`: Configurations are returned in no specific order. + * - `asc`: Sort version by number in ascending order. + * - `desc`: Sort version by number in descending order. + * + * @default `undefined` + */ + order?: 'asc' | 'desc'; +} + +export interface UpdateVersionedHostedInterfaceExtraParams { + /** + * The label to describe this particular interface version being created. + */ + versionLabel?: string; +} + +export interface UpdateInterfaceVersionLabelParams { + /** + * The optional version label. + */ + label?: string; +} + +export interface RestoreInterfaceVersionParams { + /** + * The optional version label. + */ + label?: string; +} diff --git a/src/resources/HostedInterfacesCore/index.ts b/src/resources/HostedInterfacesCore/index.ts index d3053ee86..005b106db 100644 --- a/src/resources/HostedInterfacesCore/index.ts +++ b/src/resources/HostedInterfacesCore/index.ts @@ -1 +1,2 @@ export * from './HostedInterfaceCoreConfig.model.js'; +export * from './HostedInterfaceVersionsCore.js'; diff --git a/src/resources/InsightPanelInterfaces/InsightPanelInterface.model.ts b/src/resources/InsightPanelInterfaces/InsightPanelInterface.model.ts index 8f8674eec..2622bf22d 100644 --- a/src/resources/InsightPanelInterfaces/InsightPanelInterface.model.ts +++ b/src/resources/InsightPanelInterfaces/InsightPanelInterface.model.ts @@ -8,7 +8,9 @@ import { HostedInterfaceResultTemplateBadge, HostedInterfaceResultTemplateDetail, HostedInterfaceTab, + HostedInterfaceVersion, ListHostedInterfacesParams, + UpdateVersionedHostedInterfaceExtraParams, } from '../HostedInterfacesCore/index.js'; export enum InsightPanelResultTemplateLayout { @@ -150,6 +152,10 @@ export interface InsightPanelSettings { * An option enabling the use of smart snippets. */ smartSnippets: InsightPanelOption; + /** + * Indicates whether dynamic facet navigation is disabled. + */ + disableDynamicNavigation: InsightPanelOption; } export interface InsightPanelInterfaceConfiguration extends HostedInterfaceConfiguration { @@ -172,14 +178,23 @@ export interface InsightPanelInterfaceConfiguration extends HostedInterfaceConfi * The insight panel settings. */ settings: InsightPanelSettings; + + /** + * This config's published version. + * This is usually the latest version. + */ + publishedVersion?: number; } export interface IListInsightPanelInterfacesParameters extends ListHostedInterfacesParams {} export interface InsightPanelInterfaceConfigurationUpdateParams - extends Omit { + extends Omit, + UpdateVersionedHostedInterfaceExtraParams { /** * The insight panel settings. */ - settings: WithOptional; + settings: WithOptional; } + +export interface InsightPanelInterfaceVersion extends HostedInterfaceVersion {} diff --git a/src/resources/InsightPanelInterfaces/InsightPanelInterface.ts b/src/resources/InsightPanelInterfaces/InsightPanelInterface.ts index 75c604c37..843defc2d 100644 --- a/src/resources/InsightPanelInterfaces/InsightPanelInterface.ts +++ b/src/resources/InsightPanelInterfaces/InsightPanelInterface.ts @@ -1,10 +1,16 @@ import API from '../../APICore.js'; import {New, PageModel} from '../BaseInterfaces.js'; -import {ListHostedInterfacesParams} from '../HostedInterfacesCore/index.js'; +import { + ListHostedInterfaceVersionsParams, + ListHostedInterfacesParams, + RestoreInterfaceVersionParams, + UpdateInterfaceVersionLabelParams, +} from '../HostedInterfacesCore/index.js'; import Resource from '../Resource.js'; import { InsightPanelInterfaceConfiguration, InsightPanelInterfaceConfigurationUpdateParams, + InsightPanelInterfaceVersion, } from './InsightPanelInterface.model.js'; export default class InsightPanelInterface extends Resource { @@ -38,4 +44,34 @@ export default class InsightPanelInterface extends Resource { body, ); } + + listVersions(insightPanelInterfaceId: string, options: ListHostedInterfaceVersionsParams) { + return this.api.get>( + this.buildPath(`${InsightPanelInterface.baseUrl}/${insightPanelInterfaceId}/versions`, options), + ); + } + + getVersion(insightPanelInterfaceId: string, versionNumber: number) { + return this.api.get( + `${InsightPanelInterface.baseUrl}/${insightPanelInterfaceId}/versions/${versionNumber}`, + ); + } + + restoreVersion(insightPanelInterfaceId: string, versionNumber: number, body: RestoreInterfaceVersionParams) { + return this.api.post( + `${InsightPanelInterface.baseUrl}/${insightPanelInterfaceId}/versions/${versionNumber}/restore`, + body, + ); + } + + updateVersionLabel( + insightPanelInterfaceId: string, + versionNumber: number, + body: UpdateInterfaceVersionLabelParams, + ) { + return this.api.put( + `${InsightPanelInterface.baseUrl}/${insightPanelInterfaceId}/versions/${versionNumber}/label`, + body, + ); + } } diff --git a/src/resources/InsightPanelInterfaces/tests/InsightPanelInterface.spec.ts b/src/resources/InsightPanelInterfaces/tests/InsightPanelInterface.spec.ts index d3325758b..2624ba9fb 100644 --- a/src/resources/InsightPanelInterfaces/tests/InsightPanelInterface.spec.ts +++ b/src/resources/InsightPanelInterfaces/tests/InsightPanelInterface.spec.ts @@ -105,6 +105,9 @@ describe('InsightPanelInterface', () => { smartSnippets: { enabled: false, }, + disableDynamicNavigation: { + enabled: false, + }, }, }; @@ -193,4 +196,97 @@ describe('InsightPanelInterface', () => { expect(api.delete).toHaveBeenCalledWith(`${InsightPanelInterface.baseUrl}/${id}`); }); }); + + describe('listVersions', () => { + const id = 'IPInterface-id-to-get'; + + it('should make a GET call with all parameters', () => { + insightPanelInterface.listVersions(id, {page: 2, perPage: 10, filter: 'Accounting', order: 'asc'}); + + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith( + `${InsightPanelInterface.baseUrl}/${id}/versions?page=2&perPage=10&filter=Accounting&order=asc`, + ); + }); + + it('should make a GET call with page', () => { + insightPanelInterface.listVersions(id, {page: 2}); + + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${InsightPanelInterface.baseUrl}/${id}/versions?page=2`); + }); + + it('should make a GET call with perPage', () => { + insightPanelInterface.listVersions(id, {perPage: 10}); + + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${InsightPanelInterface.baseUrl}/${id}/versions?perPage=10`); + }); + + it('should make a GET call with filter', () => { + insightPanelInterface.listVersions(id, {filter: 'Accounting'}); + + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${InsightPanelInterface.baseUrl}/${id}/versions?filter=Accounting`); + }); + + it('should make a GET call with order', () => { + insightPanelInterface.listVersions(id, {order: 'asc'}); + + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${InsightPanelInterface.baseUrl}/${id}/versions?order=asc`); + }); + }); + + describe('getVersion', () => { + it('should make a GET call to the InsightPanelInterface version url', () => { + const id = 'IPInterface-id-to-get'; + const versionNumber = 1; + + insightPanelInterface.getVersion(id, versionNumber); + + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${InsightPanelInterface.baseUrl}/${id}/versions/${versionNumber}`); + }); + }); + + describe('restoreVersion', () => { + it('should make a POST call to the InsightPanelInterface version restore url', () => { + const id = 'IPInterface-id-to-get'; + const versionNumber = 2; + const label = 'Some version label'; + + insightPanelInterface.restoreVersion(id, versionNumber, { + label, + }); + + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith( + `${InsightPanelInterface.baseUrl}/${id}/versions/${versionNumber}/restore`, + { + label, + }, + ); + }); + }); + + describe('updateVersionLabel', () => { + it('should make a PUT call to the InsightPanelInterface version label url', () => { + const id = 'IPInterface-id-to-get'; + const versionNumber = 3; + const label = 'some-label'; + + insightPanelInterface.updateVersionLabel(id, versionNumber, { + label, + }); + + expect(api.put).toHaveBeenCalledTimes(1); + expect(api.put).toHaveBeenCalledWith( + `${InsightPanelInterface.baseUrl}/${id}/versions/${versionNumber}/label`, + { + label, + }, + ); + }); + }); });