Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ngsp): add POST /manifest #790

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/resources/BaseInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ export type PageModel<T = any, TItemsKey extends string = 'items'> = {

export type New<T, K extends keyof T | null = null> = Omit<T, 'id' | NonNullable<K>>;

export type NewHostedInterface<T, K extends keyof T | null = null> = Omit<
Partial<T> & {name: string},
'id' | 'created' | 'createdBy' | 'updated' | 'updatedBy' | NonNullable<K>
>;
export type ExistingHostedInterface<T, K extends keyof T | null = null> = Omit<
T,
'id' | 'created' | 'createdBy' | 'updated' | 'updatedBy' | NonNullable<K>
>;

export interface IdAndDisplayNameModel {
id: string;
displayName?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,59 @@ export interface HostedInterfaceConfiguration {
*/
tabs: HostedInterfaceTab[];
}

export interface IManifestResponse<Configuration> {
/**
* The HTML markup of the search interface along with configured placeholders.
*/
markup: string;
/**
* The Atomic results configuration information.
*/
results: IPageManifestResults;
/**
* The Atomic related styling in CSS format.
*/
style: IPageManifestStyle;
/**
* The complete search interface configuration.
*/
config: Configuration;
}

export interface IPageManifestResultTemplate {
/**
* The HTML markup of the content of the result template.
*/
markup: string;
/**
* The Atomic [result template component](https://docs.coveo.com/en/atomic/latest/reference/components/atomic-result-template/)'s properties.
louis-bompart marked this conversation as resolved.
Show resolved Hide resolved
*/
attributes: Record<string, string>;
}

export interface IPageManifestResults {
/**
* The placeholder for the result list and result templates.
*/
placeholder?: string;
/**
* The Atomic [result list component](https://docs.coveo.com/en/atomic/latest/reference/components/atomic-result-list/#properties)'s properties.
*/
attributes: Record<string, string>;
/**
* The Atomic result template configuration information.
*/
templates: IPageManifestResultTemplate[];
}

export interface IPageManifestStyle {
/**
* The CSS to set [Atomic theme variables](https://docs.coveo.com/en/atomic/latest/usage/themes-and-visual-customization/#theme-variables).
*/
theme: string;
/**
* The page layout CSS.
*/
layout: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Paginated} from '../BaseInterfaces.js';
import {SortingBy, SortingOrder} from '../Enums.js';

export interface HostedInterfaceChangeInfo {
/**
Expand Down Expand Up @@ -126,3 +127,75 @@ export interface RestoreInterfaceVersionParams {
*/
label?: string;
}

export type NewHostedInterface<T, K extends keyof T | null = null> = Omit<
Partial<T> & {name: string},
'id' | 'created' | 'createdBy' | 'updated' | 'updatedBy' | NonNullable<K>
>;
export type ExistingHostedInterface<T, K extends keyof T | null = null> = Omit<
T,
'id' | 'created' | 'createdBy' | 'updated' | 'updatedBy' | NonNullable<K>
>;

export interface IAccesses {
/**
* The list of users that are allowed to access the search interface.
*/
users: string[];

/**
* The list of domains that are allowed to access the search interface.
*/
domains: string[];

/**
* When set to true, all users can share and see the search page.
*/
sharingLinkEnabled?: boolean;

/**
* When set to true, the domain sharing is enabled. Otherwise, only users that have explicitly access to the search page can access it.
*/
sharingDomainEnabled?: boolean;
}
louis-bompart marked this conversation as resolved.
Show resolved Hide resolved

export interface ISortCriteria {
/**
* Indicates the kind of sort criterion.
*/
by: SortingBy;

/**
* Label of the sort criterion.
*/
label: string;

/**
* Specify the sort order if applicable.
* Default value when sorting by date is descending.
* Default value when sorting by field is ascending.
* No sort order value is applicable when sorting by relevancy.
*/
order?: SortingOrder;

/**
* The [field](https://docs.coveo.com/en/200) on which the sort is based on. For example: filetype.
* Required when sorting by field.
* This property is ignored unless you are sorting by field.
*/
field?: string;
}

export interface IManifestParameters {
/**
* The placeholders for the page.
*/
pagePlaceholders?: IPagePlaceholders;
}

export interface IPagePlaceholders {
/**
* A placeholder for the result list and result templates.
*/
results?: string;
}
louis-bompart marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 6 additions & 2 deletions src/resources/IPXInterfaces/IPXInterface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import API from '../../APICore.js';
import {ExistingHostedInterface, NewHostedInterface, PageModel} from '../BaseInterfaces.js';
import {ListHostedInterfacesParams} from '../HostedInterfacesCore/index.js';
import {PageModel} from '../BaseInterfaces.js';
import {
ExistingHostedInterface,
ListHostedInterfacesParams,
NewHostedInterface,
} from '../HostedInterfacesCore/index.js';
import Resource from '../Resource.js';
import {IPXInterfaceConfiguration} from './IPXInterface.model.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
HostedInterfaceResultTemplateBadge,
IAccesses,
ISortCriteria,
} from '../index.js';
} from '../HostedInterfacesCore/index.js';

export enum SearchPageResultActions {
copyToClipboard = 'copyToClipboard',
Expand Down
13 changes: 11 additions & 2 deletions src/resources/NextGenSearchPages/NextGenSearchPages.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import API from '../../APICore.js';
import Resource from '../Resource.js';
import {PageModel} from '../BaseInterfaces.js';
import {
ExistingHostedInterface,
IAccesses,
IManifestParameters,
IManifestResponse,
ListHostedInterfacesParams,
NewHostedInterface,
PageModel,
} from '../index.js';
} from '../HostedInterfacesCore/index.js';
import {SearchPageInterfaceConfiguration} from './NextGenSearchPages.model.js';

export default class NextGenSearchPages extends Resource {
Expand Down Expand Up @@ -107,4 +109,11 @@ export default class NextGenSearchPages extends Resource {
requestAccess(searchPageId: string): Promise<void> {
return this.api.post<void>(`${NextGenSearchPages.baseUrl}/${searchPageId}/accesses/request`);
}

manifest(
interfaceId: string,
options?: IManifestParameters,
): Promise<IManifestResponse<SearchPageInterfaceConfiguration>> {
return this.api.post(`${NextGenSearchPages.baseUrl}/${interfaceId}/manifest`, options);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import API from '../../../APICore.js';
import {SortingBy} from '../../Enums.js';
import {
ExistingHostedInterface,
HostedInterfaceConditionOperator,
SearchPageInterfaceConfiguration,
SearchPageLayout,
SortingBy,
} from '../../../Entry.js';
IManifestParameters,
} from '../../HostedInterfacesCore/index.js';
import NextGenSearchPages from '../NextGenSearchPages.js';
import {SearchPageInterfaceConfiguration, SearchPageLayout} from '../NextGenSearchPages.model.js';
jest.mock('../../../APICore.js');

const APIMock: jest.Mock<API> = API as any;
Expand Down Expand Up @@ -327,4 +327,24 @@ describe('NextGenSearchPages', () => {
expect(api.post).toHaveBeenCalledWith(`${NextGenSearchPages.baseUrl}/${id}/accesses/request`);
});
});

describe('manifest', () => {
it('makes a POST call (without a body) to the searchInterfaces accesses manifest url based on the interfaceId', () => {
const id = 'search-interface-id';

nextGenSearchPages.manifest(id);

expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(`${NextGenSearchPages.baseUrl}/${id}/manifest`, undefined);
});

it('makes a POST call (with a body) to the searchInterfaces accesses manifest url based on the interfaceId', () => {
const id = 'search-interface-id';
const options: IManifestParameters = {pagePlaceholders: {results: 'myresults'}};
nextGenSearchPages.manifest(id, options);

expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(`${NextGenSearchPages.baseUrl}/${id}/manifest`, options);
});
});
});
121 changes: 1 addition & 120 deletions src/resources/SearchInterfaces/SearchInterfaces.model.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
import {Paginated} from '../BaseInterfaces.js';
import {SortingBy, SortingOrder} from '../Enums.js';

export interface IAccesses {
/**
* The list of users that are allowed to access the search interface.
*/
users: string[];

/**
* The list of domains that are allowed to access the search interface.
*/
domains: string[];

/**
* When set to true, all users can share and see the search page.
*/
sharingLinkEnabled?: boolean;

/**
* When set to true, the domain sharing is enabled. Otherwise, only users that have explicitly access to the search page can access it.
*/
sharingDomainEnabled?: boolean;
}
import {IAccesses, ISortCriteria} from '../HostedInterfacesCore/index.js';

export interface IFacet {
/**
Expand All @@ -35,33 +13,6 @@ export interface IFacet {
label: string;
}

export interface ISortCriteria {
/**
* Indicates the kind of sort criterion.
*/
by: SortingBy;

/**
* Label of the sort criterion.
*/
label: string;

/**
* Specify the sort order if applicable.
* Default value when sorting by date is descending.
* Default value when sorting by field is ascending.
* No sort order value is applicable when sorting by relevancy.
*/
order?: SortingOrder;

/**
* The [field](https://docs.coveo.com/en/200) on which the sort is based on. For example: filetype.
* Required when sorting by field.
* This property is ignored unless you are sorting by field.
*/
field?: string;
}

export interface ISearchInterfaceConfiguration {
/**
* The configuration identifier.
Expand Down Expand Up @@ -137,73 +88,3 @@ export interface IListSearchInterfacesParameters extends Paginated {
*/
perPage?: number;
}

export interface IManifestParameters {
/**
* The placeholders for the page.
*/
pagePlaceholders?: IPagePlaceholders;
}

export interface IPagePlaceholders {
/**
* A placeholder for the result list and result templates.
*/
results?: string;
}

export interface IManifestResponse {
/**
* The HTML markup of the search interface along with configured placeholders.
*/
markup: string;
/**
* The Atomic results configuration information.
*/
results: IPageManifestResults;
/**
* The Atomic related styling in CSS format.
*/
style: IPageManifestStyle;
/**
* The complete search interface configuration.
*/
config: ISearchInterfaceConfigurationResponse;
}

export interface IPageManifestResultTemplate {
/**
* The HTML markup of the content of the result template.
*/
markup: string;
/**
* The Atomic [result template component](https://docs.coveo.com/en/atomic/latest/reference/components/atomic-result-template/)'s properties.
*/
attributes: Record<string, string>;
}

export interface IPageManifestResults {
/**
* The placeholder for the result list and result templates.
*/
placeholder?: string;
/**
* The Atomic [result list component](https://docs.coveo.com/en/atomic/latest/reference/components/atomic-result-list/#properties)'s properties.
*/
attributes: Record<string, string>;
/**
* The Atomic result template configuration information.
*/
templates: IPageManifestResultTemplate[];
}

export interface IPageManifestStyle {
/**
* The CSS to set [Atomic theme variables](https://docs.coveo.com/en/atomic/latest/usage/themes-and-visual-customization/#theme-variables).
*/
theme: string;
/**
* The page layout CSS.
*/
layout: string;
}
Loading
Loading