Skip to content

Commit

Permalink
Merge branch 'master' into JSUI-3152
Browse files Browse the repository at this point in the history
  • Loading branch information
nafeesrawji committed Nov 17, 2020
2 parents 071dd9c + 3afa5f0 commit fd7676b
Show file tree
Hide file tree
Showing 37 changed files with 485 additions and 245 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Expand Up @@ -117,9 +117,10 @@ deploy:
all_branches: true
condition: "$HAS_RELEASE_TAG == true"
- provider: s3
access_key_id: AKIAQ6FOLK5RDONGHVBY
access_key_id:
secure: "QHenZfIwQHlgIAj0MVHmBk9hfAF5cYzvl9z2WiA2SC9YBbpfc5coyVeHwviE3gqb2kPSKujSZA7/GexmJuWvJMrOuuVTPtK9vJualXxntFK6pj3wLnxbsa3KEZu7ntcbuQwRy3i4QelTs5JswHJLLNsz/yh6JnI74j0DGNUu/oIBD/ZiWEqxQXwxme0/6MLZAidE4RvWvVfcME0JbIBCkUvUsJe3wZg/ftdGRyONImRn5w19hrkZHReFIA7uTjljRrxJlAvhJK1eKUJEEFe7N4LEzAYsO8i3yL5YhQWhuYYxDtOh+nq2Eb63VFMW0kFwSQB+Gu9YlA7x4vM+NxM6SRL2NdywILsmcoVpgJXXl4viOd3mIY1GK0ulafUx9Q3T+GTN/gJopziS3aTZntRq+6xdj5QR437f51W4Yjqjn8dBDopmv+jFx2flaHWPNcAee+YThK/p8WVqboRQqIDi50J8OslaDF1ALsygRQFEwPy6FK5U9z16KstN+DQ9QoAwBUIw9e5NWZE+pKA4SEsvlSFVGEeM+IiudaUoG/Bs4qgkmFpWvaCCk0Ki1dS4VdaTIp7M7hbY3Ad6Dy+aU279I5+iDUx1y2wMEknsbGzKNDFeimcdSxdLRElFoLP7l1UJjyH/wxazCxRfG8oCCQPFEivgLT7XYyf+4IHLnBhg3yw="
secret_access_key:
secure: XL74wJ5088h082Ev6ZwPdEInliIF7/Dqvqz4rJYaXS3CU/KpsoeDhtV4wnF7Dr6P61AF6x8B4Q4uJKnOYBpg7oBjY7efsCDTJo2FeGx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H+OOZpsm7kdlcyG6zkmd5UeUxvmz7zW+Ff27NA1ElyCHNFrYgJoWD+ceL8wNyg8KBlubu33+FU04wagNCK/5OxSFgAVsPztTkWaIeAmoVK033QgSOho+LCEFIMe1e0+lV8b5lF+P3nh9KtJgZJqQ/W1SNhMPsZtUJX5wrPQnXNUVxRs/QubB3rz4KiI="
bucket: coveo-ndev-binaries
local-dir: bin
upload-dir: proda/StaticCDN/searchui/nightly
Expand All @@ -131,9 +132,10 @@ deploy:
all_branches: true
condition: "$IS_NIGHTLY == true"
- provider: s3
access_key_id: AKIAQ6FOLK5RDONGHVBY
access_key_id:
secure: "QHenZfIwQHlgIAj0MVHmBk9hfAF5cYzvl9z2WiA2SC9YBbpfc5coyVeHwviE3gqb2kPSKujSZA7/GexmJuWvJMrOuuVTPtK9vJualXxntFK6pj3wLnxbsa3KEZu7ntcbuQwRy3i4QelTs5JswHJLLNsz/yh6JnI74j0DGNUu/oIBD/ZiWEqxQXwxme0/6MLZAidE4RvWvVfcME0JbIBCkUvUsJe3wZg/ftdGRyONImRn5w19hrkZHReFIA7uTjljRrxJlAvhJK1eKUJEEFe7N4LEzAYsO8i3yL5YhQWhuYYxDtOh+nq2Eb63VFMW0kFwSQB+Gu9YlA7x4vM+NxM6SRL2NdywILsmcoVpgJXXl4viOd3mIY1GK0ulafUx9Q3T+GTN/gJopziS3aTZntRq+6xdj5QR437f51W4Yjqjn8dBDopmv+jFx2flaHWPNcAee+YThK/p8WVqboRQqIDi50J8OslaDF1ALsygRQFEwPy6FK5U9z16KstN+DQ9QoAwBUIw9e5NWZE+pKA4SEsvlSFVGEeM+IiudaUoG/Bs4qgkmFpWvaCCk0Ki1dS4VdaTIp7M7hbY3Ad6Dy+aU279I5+iDUx1y2wMEknsbGzKNDFeimcdSxdLRElFoLP7l1UJjyH/wxazCxRfG8oCCQPFEivgLT7XYyf+4IHLnBhg3yw="
secret_access_key:
secure: XL74wJ5088h082Ev6ZwPdEInliIF7/Dqvqz4rJYaXS3C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SznrDLtVD7W8CQWRWdoyQvikb52vtuljpDcq7SKERNGaGYziXUsPrEtAhRj7+K7VRH+OOZpsm7kdlcyG6zkmd5UeUxvmz7zW+Ff27NA1ElyCHNFrYgJoWD+ceL8wNyg8KBlubu33+FU04wagNCK/5OxSFgAVsPztTkWaIeAmoVK033QgSOho+LCEFIMe1e0+lV8b5lF+P3nh9KtJgZJqQ/W1SNhMPsZtUJX5wrPQnXNUVxRs/QubB3rz4KiI="
bucket: coveo-ndev-binaries
local-dir: bin
upload-dir: proda/StaticCDN/searchui/pr/$TRAVIS_BRANCH
Expand Down
4 changes: 2 additions & 2 deletions deploy.beta.js
Expand Up @@ -19,8 +19,8 @@ if (travisBranchName) {
}

console.log('executing deploy script beta');
setTimeout(function() {
exec(`npm publish --tag beta${branchToTag}`, function(error, stdout, stderr) {
setTimeout(function () {
exec(`npm publish --tag beta${branchToTag}`, function (error, stdout, stderr) {
if (error) {
console.log(error, stdout, stderr);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion karma.accessibility.test.conf.js
Expand Up @@ -37,6 +37,6 @@ const configuration = {
}
};

module.exports = function(config) {
module.exports = function (config) {
config.set(configuration);
};
2 changes: 1 addition & 1 deletion karma.unit.test.conf.js
Expand Up @@ -47,6 +47,6 @@ const configuration = {
}
};

module.exports = function(config) {
module.exports = function (config) {
config.set(configuration);
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "coveo-search-ui",
"version": "2.0.746",
"version": "2.0.764",
"description": "Coveo JavaScript Search Framework",
"main": "./bin/js/CoveoJsSearch.js",
"types": "./bin/ts/CoveoJsSearch.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion sass/_ResponsiveFacets.scss
Expand Up @@ -97,12 +97,15 @@
#{$allDynamicFacetsType} {
margin: 0;

.coveo-dynamic-facet-header,
.coveo-dynamic-facet-values,
.coveo-dynamic-hierarchical-facet-values {
padding: 5px;
}

.coveo-dynamic-facet-header {
padding: 0 5px;
}

.coveo-dynamic-facet-search {
margin: 10px 5px 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rest/AnalyticsEndpoint.ts
Expand Up @@ -16,6 +16,7 @@ import { IAPIAnalyticsVisitResponseRest } from './APIAnalyticsVisitResponse';
import { ICustomEvent } from './CustomEvent';
import { ITopQueries } from './TopQueries';
import { SearchEndpoint } from '../rest/SearchEndpoint';
import { AnalyticsInformation } from '../ui/Analytics/AnalyticsInformation';

export interface IAnalyticsEndpointOptions {
accessToken: AccessToken;
Expand Down Expand Up @@ -104,8 +105,7 @@ export class AnalyticsEndpoint {
}

public clearCookies() {
Cookie.erase('visitorId');
Cookie.erase('visitId');
new AnalyticsInformation().clearCookies();
}

private async sendToService(data: Record<string, any>, path: string, paramName: string): Promise<any> {
Expand Down
4 changes: 4 additions & 0 deletions src/rest/AnalyticsEvent.ts
Expand Up @@ -125,4 +125,8 @@ export interface IAnalyticsEvent {
* **Example:** `{ "currentResultsPerPage": 25, "userRole": "developer" }`
*/
customData?: { [key: string]: any };
/**
* A GUID representing the current user. This GUID is generated locally and stored in a non-expiring browser cookie.
*/
clientId: string;
}
1 change: 1 addition & 0 deletions src/rest/QuerySuggest.ts
Expand Up @@ -98,6 +98,7 @@ export interface IQuerySuggestRequest {

/**
* A GUID representing the current user, who can be authenticated or anonymous. This GUID is normally generated by the usage analytics service and stored in a non-expiring browser cookie.
* @deprecated
*/
visitorId?: string;

Expand Down
142 changes: 54 additions & 88 deletions src/rest/SearchEndpoint.ts
Expand Up @@ -32,7 +32,6 @@ import { QueryError } from '../rest/QueryError';
import { Utils } from '../utils/Utils';
import * as _ from 'underscore';
import { buildHistoryStore } from '../utils/HistoryStore';
import { Cookie } from '../utils/CookieUtils';
import { TimeSpan } from '../utils/TimeSpanUtils';
import { UrlUtils } from '../utils/UrlUtils';
import { IGroupByResult } from './GroupByResult';
Expand All @@ -41,6 +40,8 @@ import { BackOffRequest, IBackOffRequest } from './BackOffRequest';
import { IFacetSearchRequest } from './Facet/FacetSearchRequest';
import { IFacetSearchResponse } from './Facet/FacetSearchResponse';
import { IPlanResponse, ExecutionPlan } from './Plan';
import { mapObject } from 'underscore';
import { AnalyticsInformation } from '../ui/Analytics/AnalyticsInformation';

export class DefaultSearchEndpointOptions implements ISearchEndpointOptions {
restUri: string;
Expand Down Expand Up @@ -167,8 +168,9 @@ export class SearchEndpoint implements ISearchEndpoint {
* **Allowed values:**
*
* - `https://platform.cloud.coveo.com/rest/search` (for organizations in the standard Coveo Cloud V2 environment)
* - `https://platform-eu.cloud.coveo.com/rest/search` (for organizations with European [data residency](https://docs.coveo.com/en/2976/#data-residency-configuration))
* - `https://platform-au.cloud.coveo.com/rest/search` (for organizations with Australian data residency)
* - `https://platformhipaa.cloud.coveo.com/rest/search` (for [HIPAA](https://docs.coveo.com/1853/) organizations)
* - `https://globalplatform.cloud.coveo.com/rest/search` (for [multi-region](https://docs.coveo.com/2976/) organizations)
*
* **Default:** `https://platform.cloud.coveo.com/rest/search`
* @param otherOptions Additional options to apply for this endpoint (e.g., a [`renewAccessToken`]{@link ISearchEndpointOptions.renewAccessToken} function).
Expand Down Expand Up @@ -332,6 +334,7 @@ export class SearchEndpoint implements ISearchEndpoint {

@includeActionsHistory()
@includeReferrer()
@includeAnalytics()
@includeVisitorId()
@includeIsGuestUser()
private buildCompleteCall(request: any, callOptions?: IEndpointCallOptions, callParams?: IEndpointCallParameters) {
Expand Down Expand Up @@ -876,10 +879,6 @@ export class SearchEndpoint implements ISearchEndpoint {
@method('POST')
@requestDataType('application/json')
@responseType('text')
@includeActionsHistory()
@includeReferrer()
@includeVisitorId()
@includeIsGuestUser()
public async facetSearch(
request: IFacetSearchRequest,
callOptions?: IEndpointCallOptions,
Expand Down Expand Up @@ -1081,7 +1080,7 @@ export class SearchEndpoint implements ISearchEndpoint {
this.isRedirecting = true;
}

private buildBaseUri(path: string): string {
public buildBaseUri(path: string): string {
Assert.isString(path);

return UrlUtils.normalizeAsString({
Expand Down Expand Up @@ -1275,18 +1274,19 @@ function defaultDecoratorEndpointCallParameters() {
return params;
}

function getEndpointCallParameters(nbParams: number, args: any[]) {
if (!args[nbParams - 1]) {
args[nbParams - 1] = defaultDecoratorEndpointCallParameters();
}
return args[nbParams - 1] as IEndpointCallParameters;
}

function path(path: string) {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);

descriptor.value = function (...args: any[]) {
const url = this.buildBaseUri(path);
if (args[nbParams - 1]) {
args[nbParams - 1].url = url;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), { url: url });
args[nbParams - 1] = endpointCallParams;
}
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
getEndpointCallParameters(nbParams, args).url = this.buildBaseUri(path);
return originalMethod.apply(this, args);
};

Expand All @@ -1298,14 +1298,8 @@ function alertsPath(path: string) {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);

descriptor.value = function (...args: any[]) {
const url = this.buildSearchAlertsUri(path);
if (args[nbParams - 1]) {
args[nbParams - 1].url = url;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), { url: url });
args[nbParams - 1] = endpointCallParams;
}
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
getEndpointCallParameters(nbParams, args).url = this.buildSearchAlertsUri(path);
return originalMethod.apply(this, args);
};

Expand All @@ -1317,13 +1311,8 @@ function requestDataType(type: string) {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);

descriptor.value = function (...args: any[]) {
if (args[nbParams - 1]) {
args[nbParams - 1].requestDataType = type;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), { requestDataType: type });
args[nbParams - 1] = endpointCallParams;
}
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
getEndpointCallParameters(nbParams, args).requestDataType = type;
return originalMethod.apply(this, args);
};
return descriptor;
Expand All @@ -1334,13 +1323,8 @@ function method(met: string) {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);

descriptor.value = function (...args: any[]) {
if (args[nbParams - 1]) {
args[nbParams - 1].method = met;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), { method: met });
args[nbParams - 1] = endpointCallParams;
}
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
getEndpointCallParameters(nbParams, args).method = met;
return originalMethod.apply(this, args);
};

Expand All @@ -1352,13 +1336,8 @@ function responseType(resp: string) {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);

descriptor.value = function (...args: any[]) {
if (args[nbParams - 1]) {
args[nbParams - 1].responseType = resp;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), { responseType: resp });
args[nbParams - 1] = endpointCallParams;
}
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
getEndpointCallParameters(nbParams, args).responseType = resp;
return originalMethod.apply(this, args);
};

Expand All @@ -1379,14 +1358,10 @@ function accessTokenInUrl(tokenKey: string = 'access_token') {
return queryString;
};

descriptor.value = function (...args: any[]) {
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
const queryString = buildAccessToken(tokenKey, this);
if (args[nbParams - 1]) {
args[nbParams - 1].queryString = args[nbParams - 1].queryString.concat(queryString);
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), { queryString: queryString });
args[nbParams - 1] = endpointCallParams;
}
const params = getEndpointCallParameters(nbParams, args);
params.queryString = [...(params.queryString || []), ...queryString];
return originalMethod.apply(this, args);
};

Expand All @@ -1398,20 +1373,13 @@ function includeActionsHistory(historyStore = buildHistoryStore()) {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);

descriptor.value = function (...args: any[]) {
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
let historyFromStore = historyStore.getHistory();
if (historyFromStore == null) {
historyFromStore = [];
}

if (args[nbParams - 1]) {
args[nbParams - 1].requestData.actionsHistory = historyFromStore;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), {
requestData: { actionsHistory: historyFromStore }
});
args[nbParams - 1] = endpointCallParams;
}
getEndpointCallParameters(nbParams, args).requestData.actionsHistory = historyFromStore;
return originalMethod.apply(this, args);
};

Expand All @@ -1422,20 +1390,32 @@ function includeActionsHistory(historyStore = buildHistoryStore()) {
function includeReferrer() {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);
descriptor.value = function (...args: any[]) {
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
let referrer = document.referrer;
if (referrer == null) {
referrer = '';
}

if (args[nbParams - 1]) {
args[nbParams - 1].requestData.referrer = referrer;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), {
requestData: { referrer: referrer }
});
args[nbParams - 1] = endpointCallParams;
}
getEndpointCallParameters(nbParams, args).requestData.referrer = referrer;
return originalMethod.apply(this, args);
};

return descriptor;
};
}

function includeAnalytics() {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
const analyticsInstance = new AnalyticsInformation();
const analytics = {
clientId: analyticsInstance.clientId,
documentLocation: analyticsInstance.location,
documentReferrer: analyticsInstance.referrer,
pageId: analyticsInstance.lastPageId
};
getEndpointCallParameters(nbParams, args).requestData.analytics = mapObject(analytics, value => value || '');
return originalMethod.apply(this, args);
};

Expand All @@ -1446,20 +1426,13 @@ function includeReferrer() {
function includeVisitorId() {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);
descriptor.value = function (...args: any[]) {
let visitorId = Cookie.get('visitorId');
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
let visitorId = new AnalyticsInformation().visitorId;
if (visitorId == null) {
visitorId = '';
}

if (args[nbParams - 1]) {
args[nbParams - 1].requestData.visitorId = visitorId;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), {
requestData: { visitorId: visitorId }
});
args[nbParams - 1] = endpointCallParams;
}
getEndpointCallParameters(nbParams, args).requestData.visitorId = visitorId;
return originalMethod.apply(this, args);
};

Expand All @@ -1470,17 +1443,10 @@ function includeVisitorId() {
function includeIsGuestUser() {
return function (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
const { originalMethod, nbParams } = decoratorSetup(target, key, descriptor);
descriptor.value = function (...args: any[]) {
descriptor.value = function (this: SearchEndpoint, ...args: any[]) {
let isGuestUser = this.options.isGuestUser;

if (args[nbParams - 1]) {
args[nbParams - 1].requestData.isGuestUser = isGuestUser;
} else {
const endpointCallParams = _.extend(defaultDecoratorEndpointCallParameters(), {
requestData: { isGuestUser: isGuestUser }
});
args[nbParams - 1] = endpointCallParams;
}
getEndpointCallParameters(nbParams, args).requestData.isGuestUser = isGuestUser;
return originalMethod.apply(this, args);
};

Expand Down

0 comments on commit fd7676b

Please sign in to comment.