coveo-search-ui
Version:
Coveo JavaScript Search Framework
995 lines (962 loc) • 181 kB
JavaScript
webpackJsonpplayground([0],{
/***/ 121:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var RankingInfoTable_1 = __webpack_require__(340);
var MetaDataTable_1 = __webpack_require__(346);
var Dom_1 = __webpack_require__(1);
var ExternalModulesShim_1 = __webpack_require__(43);
var Core_1 = __webpack_require__(42);
var RelevanceInspectorTabs_1 = __webpack_require__(347);
__webpack_require__(348);
var ExecutionReport_1 = __webpack_require__(335);
var AvailableFieldsTable_1 = __webpack_require__(356);
var underscore_1 = __webpack_require__(0);
var InlineRankingInfo_1 = __webpack_require__(357);
var RelevanceInspector = /** @class */ (function () {
function RelevanceInspector(element, bindings) {
var _this = this;
this.element = element;
this.bindings = bindings;
this.opened = false;
this.modalBoxModule = ExternalModulesShim_1.ModalBox;
Dom_1.$$(this.element).text('Relevance Inspector');
Dom_1.$$(this.element).addClass('coveo-button coveo-relevance-inspector');
Dom_1.$$(this.bindings.root).on(this.bindings.queryStateModel.getEventName(Core_1.QueryStateModel.eventTypes.changeOne + Core_1.QueryStateModel.attributesEnum.debug), function (e, args) { return _this.toggleFromState(args.value); });
Dom_1.$$(this.element).on('click', function () { return _this.open(); });
Dom_1.$$(this.bindings.root).on(Core_1.ResultListEvents.newResultDisplayed, function (e, args) {
return _this.handleNewResultDisplayed(args);
});
this.bindings.queryStateModel.get(Core_1.QueryStateModel.attributesEnum.debug) ? this.show() : this.hide();
}
Object.defineProperty(RelevanceInspector.prototype, "modalBox", {
get: function () {
return this.modalBoxModule;
},
set: function (modalBoxModule) {
this.modalBoxModule = modalBoxModule;
},
enumerable: true,
configurable: true
});
RelevanceInspector.prototype.hide = function () {
Dom_1.$$(this.element).addClass('coveo-hidden');
};
RelevanceInspector.prototype.show = function () {
Dom_1.$$(this.element).removeClass('coveo-hidden');
};
RelevanceInspector.prototype.open = function () {
return __awaiter(this, void 0, void 0, function () {
var content, animation, rows;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.opened) {
return [2 /*return*/];
}
this.opened = true;
content = Dom_1.$$('div');
animation = Core_1.DomUtils.getBasicLoadingAnimation();
content.append(animation);
this.modalBox.open(content.el, this.modalBoxOptions);
return [4 /*yield*/, this.buildTabs()];
case 1:
rows = _a.sent();
if (rows) {
animation.remove();
content.append(rows.el);
}
else {
this.modalBox.close();
}
return [2 /*return*/];
}
});
});
};
RelevanceInspector.prototype.handleNewResultDisplayed = function (args) {
if (this.bindings.queryStateModel.get(Core_1.QueryStateModel.attributesEnum.debug)) {
Dom_1.$$(args.item).addClass('coveo-with-inline-ranking-info');
if (Dom_1.$$(args.item).hasClass('coveo-table-layout')) {
Dom_1.$$(args.item).append(new InlineRankingInfo_1.InlineRankingInfo(args.result).build().el);
}
else {
Dom_1.$$(args.item).prepend(new InlineRankingInfo_1.InlineRankingInfo(args.result).build().el);
}
}
};
Object.defineProperty(RelevanceInspector.prototype, "modalBoxOptions", {
get: function () {
var _this = this;
return {
title: 'Relevance Inspector',
titleClose: false,
overlayClose: true,
sizeMod: 'big',
className: 'relevance-inspector-modal',
validation: function () {
_this.opened = false;
return true;
},
body: document.getElementsByClassName('CoveoSearchInterface')[0] // Will return undefined if no CoveoSearchInterface is present
};
},
enumerable: true,
configurable: true
});
RelevanceInspector.prototype.toggleFromState = function (stateValue) {
stateValue != 0 ? this.show() : this.hide();
this.modalBox.close();
};
RelevanceInspector.prototype.buildTabs = function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
var lastResults, container, rankingInfoTable, metadataTable, executionReport, availableFields, inspectorTabs, debouncedResize, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
return __generator(this, function (_o) {
switch (_o.label) {
case 0:
lastResults = this.bindings.queryController.getLastResults().results;
if (!lastResults || lastResults.length == 0) {
new Core_1.Logger(this).error('Could not open Relevance Inspector because there is no results to display. Please execute a query beforehand', lastResults);
return [2 /*return*/];
}
if (!lastResults[0].rankingInfo) {
new Core_1.Logger(this).error('Could not open Relevance Inspector because there is no ranking info returned on the results. Please execute a query in debug mode beforehad', lastResults);
return [2 /*return*/];
}
container = Dom_1.$$('div');
rankingInfoTable = new RankingInfoTable_1.RankingInfoTable(lastResults, this.bindings);
metadataTable = new MetaDataTable_1.MetaDataTable(lastResults, this.bindings);
executionReport = new ExecutionReport_1.ExecutionReport(this.bindings.queryController.getLastResults(), this.bindings);
availableFields = new AvailableFieldsTable_1.AvailableFieldsTable(this.bindings);
this.tabs = {
relevanceInspectorRankingInfo: rankingInfoTable,
relevanceInspectorMetadata: metadataTable,
relevanceInspectorExecutionReport: executionReport,
relevanceInspectorAvailableFields: availableFields
};
inspectorTabs = new RelevanceInspectorTabs_1.RelevanceInspectorTabs(function (tabChangedTo) {
_this.activeTab = tabChangedTo;
_this.resize();
});
debouncedResize = underscore_1.debounce(function () { return _this.resize(); }, 100);
window.addEventListener('resize', debouncedResize);
_b = (_a = inspectorTabs).addSection;
_c = ['Ranking Information'];
return [4 /*yield*/, rankingInfoTable.build()];
case 1:
_b.apply(_a, _c.concat([_o.sent(), 'relevanceInspectorRankingInfo']));
_e = (_d = inspectorTabs).addSection;
_f = ['Metadata'];
return [4 /*yield*/, metadataTable.build()];
case 2:
_e.apply(_d, _f.concat([_o.sent(), 'relevanceInspectorMetadata']));
_h = (_g = inspectorTabs).addSection;
_j = ['Execution Report'];
return [4 /*yield*/, executionReport.build()];
case 3:
_h.apply(_g, _j.concat([_o.sent(), 'relevanceInspectorExecutionReport']));
_l = (_k = inspectorTabs).addSection;
_m = ['Available Fields'];
return [4 /*yield*/, availableFields.build()];
case 4:
_l.apply(_k, _m.concat([_o.sent(), 'relevanceInspectorAvailableFields']));
inspectorTabs.select('relevanceInspectorRankingInfo');
container.append(inspectorTabs.navigationSection.el);
container.append(inspectorTabs.tabContentSection.el);
return [2 /*return*/, container];
}
});
});
};
RelevanceInspector.prototype.resize = function () {
if (!this.activeTab) {
return;
}
if (!this.tabs[this.activeTab]) {
return;
}
this.tabs[this.activeTab].gridOptions.api.sizeColumnsToFit();
};
return RelevanceInspector;
}());
exports.RelevanceInspector = RelevanceInspector;
/***/ }),
/***/ 334:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var AgGrid_1 = __webpack_require__(341);
var underscore_1 = __webpack_require__(0);
var UtilsModules_1 = __webpack_require__(81);
var ResultLink_1 = __webpack_require__(342);
exports.defaultGridOptions = {
domLayout: 'autoHeight',
enableColResize: true,
rowHeight: 100,
enableRangeSelection: true,
suppressRowClickSelection: true,
suppressCellSelection: true,
defaultColDef: {
width: 100
},
enableSorting: true,
autoSizePadding: 10
};
var TableBuilder = /** @class */ (function () {
function TableBuilder() {
}
TableBuilder.prototype.build = function (sources, table, gridOptions) {
if (gridOptions === void 0) { gridOptions = exports.defaultGridOptions; }
return __awaiter(this, void 0, void 0, function () {
var firstData, mapToAgGridFormat, columnDefs, rowData, grid;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
firstData = underscore_1.first(sources) || {};
mapToAgGridFormat = function (value, key) {
if (value.children) {
return {
field: key,
headerName: key,
marryChildren: true,
children: underscore_1.flatten(value.children.map(function (child) {
return underscore_1.map(child, mapToAgGridFormat);
}))
};
}
else {
return __assign({ field: key, headerName: key }, value);
}
};
columnDefs = underscore_1.map(firstData, mapToAgGridFormat);
rowData = underscore_1.map(sources, function (source) {
var merged = {};
var extractContent = function (value, key) {
if (value.content) {
merged[key] = value.content;
}
else if (value.children) {
underscore_1.each(value.children, function (child) {
underscore_1.each(child, extractContent);
});
}
};
underscore_1.each(source, extractContent);
return merged;
});
this.gridOptions = __assign({}, exports.defaultGridOptions, { columnDefs: columnDefs,
rowData: rowData }, gridOptions);
return [4 /*yield*/, AgGrid_1.loadAgGridLibrary()];
case 1:
_a.sent();
grid = new agGrid.Grid(table.el, this.gridOptions);
return [2 /*return*/, { grid: grid, gridOptions: this.gridOptions }];
}
});
});
};
TableBuilder.thumbnailCell = function (result, bindings) {
return {
Document: {
content: { result: result, bindings: bindings },
cellRenderer: ThumbnailHtmlRenderer,
width: 550,
getQuickFilterText: function (params) {
return '';
}
}
};
};
return TableBuilder;
}());
exports.TableBuilder = TableBuilder;
var ThumbnailHtmlRenderer = /** @class */ (function () {
function ThumbnailHtmlRenderer() {
}
ThumbnailHtmlRenderer.prototype.init = function (params) {
if (params) {
this.element = params.value;
this.currentFilter = params.api.filterManager.quickFilter;
}
};
ThumbnailHtmlRenderer.prototype.getGui = function () {
var cell = UtilsModules_1.$$('div', { className: 'coveo-relevance-inspector-thumbnail-cell' });
if (this.element) {
var thumbnail = this.thumbnail(this.element.result, this.element.bindings);
cell.append(thumbnail.el);
}
else {
cell.append(UtilsModules_1.$$('p', undefined, '-- NULL --').el);
}
return cell.el;
};
ThumbnailHtmlRenderer.prototype.thumbnail = function (result, bindings) {
var dom;
if (bindings && result) {
var resultLists = bindings.searchInterface.getComponents('ResultList');
var firstActiveResultList = underscore_1.find(resultLists, function (resultList) { return !resultList.disabled; });
if (firstActiveResultList) {
dom = UtilsModules_1.$$('div', {
className: 'coveo-relevance-inspector-result-thumbnail'
});
firstActiveResultList.buildResult(result).then(function (builtResult) {
dom.append(builtResult);
});
}
else {
dom = UtilsModules_1.$$('a', {
className: 'CoveoResultLink'
});
new ResultLink_1.ResultLink(dom.el, { alwaysOpenInNewWindow: true }, bindings, result);
}
if (this.currentFilter) {
this.highlightSearch(dom.el, this.currentFilter);
}
}
else {
dom = UtilsModules_1.$$('div', undefined, '-- NULL --');
}
return dom;
};
ThumbnailHtmlRenderer.prototype.refresh = function (params) {
return true;
};
ThumbnailHtmlRenderer.prototype.highlightSearch = function (elementToSearch, search) {
var asHTMLElement = elementToSearch;
if (asHTMLElement != null && asHTMLElement.innerText != null) {
var match = asHTMLElement.innerText.split(new RegExp('(?=' + UtilsModules_1.StringUtils.regexEncode(search) + ')', 'gi'));
asHTMLElement.innerHTML = '';
match.forEach(function (value) {
var regex = new RegExp('(' + UtilsModules_1.StringUtils.regexEncode(search) + ')', 'i');
var group = value.match(regex);
var span;
if (group != null) {
span = UtilsModules_1.$$('span', {
className: 'coveo-relevance-inspector-highlight'
});
span.text(group[1]);
asHTMLElement.appendChild(span.el);
span = UtilsModules_1.$$('span');
span.text(value.substr(group[1].length));
asHTMLElement.appendChild(span.el);
}
else {
span = UtilsModules_1.$$('span');
span.text(value);
asHTMLElement.appendChild(span.el);
}
});
}
};
return ThumbnailHtmlRenderer;
}());
exports.ThumbnailHtmlRenderer = ThumbnailHtmlRenderer;
var GenericHtmlRenderer = /** @class */ (function () {
function GenericHtmlRenderer() {
}
GenericHtmlRenderer.prototype.init = function (params) {
if (params && params.api) {
this.element = params.value;
this.currentFilter = params.api.filterManager.quickFilter;
}
};
GenericHtmlRenderer.prototype.getGui = function () {
if (this.element && this.currentFilter) {
return UtilsModules_1.$$('div', undefined, UtilsModules_1.StreamHighlightUtils.highlightStreamHTML(this.element, { Precision: ['precision'] }, {})).el;
}
else if (this.element) {
return UtilsModules_1.$$('div', undefined, this.element).el;
}
else {
return UtilsModules_1.$$('div', undefined, '-- NULL --').el;
}
};
GenericHtmlRenderer.prototype.refresh = function (params) {
return true;
};
return GenericHtmlRenderer;
}());
exports.GenericHtmlRenderer = GenericHtmlRenderer;
/***/ }),
/***/ 335:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var ExecutionReportAuthenticationSection_1 = __webpack_require__(350);
var ExecutionReportResolvedPipelineSection_1 = __webpack_require__(351);
var ExecutionReportQueryOverrideSection_1 = __webpack_require__(352);
var ExecutionReportSimpleSection_1 = __webpack_require__(339);
var ExecutionReportEffectiveIndexQuerySection_1 = __webpack_require__(353);
var UtilsModules_1 = __webpack_require__(81);
var ExecutionReportRankingModifiers_1 = __webpack_require__(354);
var Core_1 = __webpack_require__(42);
var ExecutionReportITDSection_1 = __webpack_require__(355);
var EXECUTION_REPORT_SECTION;
(function (EXECUTION_REPORT_SECTION) {
EXECUTION_REPORT_SECTION["PERFORM_AUTHENTICATION"] = "PerformAuthentication";
EXECUTION_REPORT_SECTION["RESOLVE_PIPELINE"] = "ResolvePipeline";
EXECUTION_REPORT_SECTION["QUERY_PARAM_OVERRIDE"] = "ApplyQueryParamOverrideFeature";
EXECUTION_REPORT_SECTION["THESAURUS"] = "ApplyThesaurusFeature";
EXECUTION_REPORT_SECTION["PREPROCESS_QUERY_EXPRESSION"] = "PreprocessQueryExpression";
EXECUTION_REPORT_SECTION["PREPROCESS_QUERY"] = "PreprocessQuery";
EXECUTION_REPORT_SECTION["STOP_WORDS"] = "ApplyStopWordFeature";
EXECUTION_REPORT_SECTION["FILTERS"] = "ApplyFilterFeature";
EXECUTION_REPORT_SECTION["RANKING"] = "ApplyRankingFeature";
EXECUTION_REPORT_SECTION["TOP_RESULT"] = "ApplyTopResultFeature";
EXECUTION_REPORT_SECTION["RANKING_WEIGHT"] = "ApplyRankingWeightFeature";
EXECUTION_REPORT_SECTION["INDEX_QUERY"] = "Send query to index";
EXECUTION_REPORT_SECTION["TOP_CLICKS"] = "EvaluatingTopClicks";
EXECUTION_REPORT_SECTION["PARTIAL_MATCH"] = "PartialMatch";
EXECUTION_REPORT_SECTION["NONE"] = "NONE";
})(EXECUTION_REPORT_SECTION = exports.EXECUTION_REPORT_SECTION || (exports.EXECUTION_REPORT_SECTION = {}));
var ExecutionReport = /** @class */ (function () {
function ExecutionReport(results, bindings) {
this.results = results;
this.bindings = bindings;
}
ExecutionReport.standardSectionHeader = function (title) {
var container = UtilsModules_1.$$('div');
container.append(UtilsModules_1.$$('h4', undefined, title).el);
var agGridElement = UtilsModules_1.$$('div', {
className: 'ag-theme-fresh'
});
container.append(agGridElement.el);
return {
container: container,
agGridElement: agGridElement
};
};
ExecutionReport.prototype.build = function () {
return __awaiter(this, void 0, void 0, function () {
var container, gridOptions, authenticationSection, resolvedPipelineSection, resolvedRankingModifiers, queryParamOverrideSection, thesaurusSection, stopWordsSection, filtersSection, rankingSection, topResultsSection, itdSection, rankingWeightsSection, indexQuerySection;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.results.executionReport) {
new Core_1.Logger(this).error('Could not open execution report : Missing execution report on results. Try executing the query in debug mode.');
return [2 /*return*/, UtilsModules_1.$$('div')];
}
container = UtilsModules_1.$$('div', {
className: 'execution-report-debug'
});
gridOptions = [];
return [4 /*yield*/, new ExecutionReportAuthenticationSection_1.ExecutionReportAuthenticationSection().build(this.results.executionReport)];
case 1:
authenticationSection = _a.sent();
container.append(authenticationSection.container.el);
if (authenticationSection.gridOptions) {
gridOptions.push(authenticationSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportResolvedPipelineSection_1.ExecutionReportResolvedPipelineSection().build(this.results.executionReport)];
case 2:
resolvedPipelineSection = _a.sent();
container.append(resolvedPipelineSection.container.el);
if (resolvedPipelineSection.gridOptions) {
gridOptions.push(resolvedPipelineSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportRankingModifiers_1.ExecutionReportRankingModifiers().build(this.results.results, this.results.rankingExpressions, this.bindings)];
case 3:
resolvedRankingModifiers = _a.sent();
container.append(resolvedRankingModifiers.container.el);
if (resolvedRankingModifiers.gridOptions) {
gridOptions.push(resolvedRankingModifiers.gridOptions);
}
return [4 /*yield*/, new ExecutionReportQueryOverrideSection_1.ExecutionReportQueryOverrideSection().build(this.results.executionReport)];
case 4:
queryParamOverrideSection = _a.sent();
container.append(queryParamOverrideSection.container.el);
if (queryParamOverrideSection.gridOptions) {
gridOptions.push(queryParamOverrideSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportSimpleSection_1.ExecutionReportSimpleSection(EXECUTION_REPORT_SECTION.PREPROCESS_QUERY_EXPRESSION, EXECUTION_REPORT_SECTION.THESAURUS, 'Thesaurus').build(this.results.executionReport)];
case 5:
thesaurusSection = _a.sent();
container.append(thesaurusSection.container.el);
if (thesaurusSection.gridOptions) {
gridOptions.push(thesaurusSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportSimpleSection_1.ExecutionReportSimpleSection(EXECUTION_REPORT_SECTION.PREPROCESS_QUERY_EXPRESSION, EXECUTION_REPORT_SECTION.STOP_WORDS, 'Stop words').build(this.results.executionReport)];
case 6:
stopWordsSection = _a.sent();
container.append(stopWordsSection.container.el);
if (stopWordsSection.gridOptions) {
gridOptions.push(stopWordsSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportSimpleSection_1.ExecutionReportSimpleSection(EXECUTION_REPORT_SECTION.PREPROCESS_QUERY, EXECUTION_REPORT_SECTION.FILTERS, 'Filters').build(this.results.executionReport)];
case 7:
filtersSection = _a.sent();
container.append(filtersSection.container.el);
if (filtersSection.gridOptions) {
gridOptions.push(filtersSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportSimpleSection_1.ExecutionReportSimpleSection(EXECUTION_REPORT_SECTION.PREPROCESS_QUERY, EXECUTION_REPORT_SECTION.RANKING, 'Ranking').build(this.results.executionReport)];
case 8:
rankingSection = _a.sent();
container.append(rankingSection.container.el);
if (rankingSection.gridOptions) {
gridOptions.push(rankingSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportSimpleSection_1.ExecutionReportSimpleSection(EXECUTION_REPORT_SECTION.PREPROCESS_QUERY, EXECUTION_REPORT_SECTION.TOP_RESULT, 'Featured Results').build(this.results.executionReport)];
case 9:
topResultsSection = _a.sent();
container.append(topResultsSection.container.el);
if (topResultsSection.gridOptions) {
gridOptions.push(topResultsSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportITDSection_1.ExecutionReportITDSection().build(this.results.executionReport)];
case 10:
itdSection = _a.sent();
container.append(itdSection.container.el);
if (itdSection.gridOptions) {
gridOptions.push(itdSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportSimpleSection_1.ExecutionReportSimpleSection(EXECUTION_REPORT_SECTION.PREPROCESS_QUERY, EXECUTION_REPORT_SECTION.RANKING_WEIGHT, 'Ranking weights').build(this.results.executionReport)];
case 11:
rankingWeightsSection = _a.sent();
container.append(rankingWeightsSection.container.el);
if (rankingWeightsSection.gridOptions) {
gridOptions.push(rankingWeightsSection.gridOptions);
}
return [4 /*yield*/, new ExecutionReportEffectiveIndexQuerySection_1.ExecutionReportEffectiveIndexQuerySection().build(this.results.executionReport)];
case 12:
indexQuerySection = _a.sent();
container.append(indexQuerySection.container.el);
this.gridOptions = {
api: {
sizeColumnsToFit: function () {
gridOptions.forEach(function (option) { return (option.api ? option.api.sizeColumnsToFit() : null); });
}
}
};
return [2 /*return*/, container];
}
});
});
};
return ExecutionReport;
}());
exports.ExecutionReport = ExecutionReport;
/***/ }),
/***/ 336:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TableBuilder_1 = __webpack_require__(334);
var underscore_1 = __webpack_require__(0);
var Dom_1 = __webpack_require__(1);
var defaultNullOutput = '-- NULL --';
var GenericValueOutput = /** @class */ (function () {
function GenericValueOutput() {
}
GenericValueOutput.prototype.output = function (section) {
if (underscore_1.isArray(section)) {
return this.arrayJoined(section);
}
if (underscore_1.isObject(section)) {
return this.objectJoined(section);
}
return this.simpleValue(section);
};
GenericValueOutput.prototype.simpleValue = function (section) {
return {
content: this.valueOrNullOutput(section)
};
};
GenericValueOutput.prototype.objectJoined = function (section) {
var _this = this;
var content = '';
underscore_1.each(section, function (value, key) {
if (underscore_1.isArray(value)) {
var list = Dom_1.$$('dl');
list.append(Dom_1.$$('dt', undefined, key).el);
var innerList = Dom_1.$$('dd', undefined, _this.arrayJoined(value).content);
list.append(innerList.el);
content += list.el.outerHTML;
}
else if (underscore_1.isObject(value)) {
content += _this.objectJoined(value).content;
}
else {
var list = Dom_1.$$('dl');
list.append(Dom_1.$$('dt', undefined, key).el);
list.append(Dom_1.$$('dd', undefined, _this.valueOrNullOutput(value)).el);
content += list.el.outerHTML;
}
});
return {
content: content,
cellRenderer: TableBuilder_1.GenericHtmlRenderer
};
};
GenericValueOutput.prototype.arrayJoined = function (section) {
var _this = this;
if (!section || section.length == 0) {
return {
content: defaultNullOutput
};
}
var list = Dom_1.$$('ul', {
className: 'relevance-inspector-list-output'
});
section.forEach(function (sectionValue) {
if (underscore_1.isObject(sectionValue)) {
list.append(Dom_1.$$('li', undefined, _this.objectJoined(sectionValue).content).el);
}
else {
list.append(Dom_1.$$('li', undefined, _this.valueOrNullOutput(sectionValue)).el);
}
});
return {
content: list.el.outerHTML,
cellRenderer: TableBuilder_1.GenericHtmlRenderer
};
};
GenericValueOutput.prototype.valueOrNullOutput = function (value) {
if (value != null && value !== '') {
return value.toString();
}
return defaultNullOutput;
};
return GenericValueOutput;
}());
exports.GenericValueOutput = GenericValueOutput;
/***/ }),
/***/ 337:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var GenericValueOutput_1 = __webpack_require__(336);
var ExecutionReportGenericSection = /** @class */ (function () {
function ExecutionReportGenericSection() {
}
ExecutionReportGenericSection.prototype.build = function (executionReportSection) {
return __assign({}, this.descriptionSection(executionReportSection), this.durationSection(executionReportSection));
};
ExecutionReportGenericSection.prototype.descriptionSection = function (executionReportSection) {
return {
Description: new GenericValueOutput_1.GenericValueOutput().output(executionReportSection.description)
};
};
ExecutionReportGenericSection.prototype.durationSection = function (executionReportSection) {
return {
Duration: new GenericValueOutput_1.GenericValueOutput().output(executionReportSection.duration + " ms")
};
};
return ExecutionReportGenericSection;
}());
exports.ExecutionReportGenericSection = ExecutionReportGenericSection;
/***/ }),
/***/ 338:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var underscore_1 = __webpack_require__(0);
var StringUtils_1 = __webpack_require__(20);
var Dom_1 = __webpack_require__(1);
exports.buildListOfTermsElement = function (weightPerTerm) {
var listItems = underscore_1.map(weightPerTerm, function (value, key) {
return {
dt: Dom_1.$$('dt', {
className: 'coveo-relevance-inspector-dt'
}, "" + key),
dd: Dom_1.$$('dd', {
className: 'coveo-relevance-inspector-dd'
}, "" + value)
};
});
var total = underscore_1.reduce(weightPerTerm, function (memo, value) { return memo + value; }, 0);
var list = Dom_1.$$('dl');
listItems.forEach(function (item) {
list.append(item.dt.el);
list.append(item.dd.el);
});
list.append(Dom_1.$$('dt', { className: 'coveo-relevance-inspector-dt' }, "Total").el);
list.append(Dom_1.$$('dd', { className: 'coveo-relevance-inspector-dd coveo-relevance-inspector-highlight' }, "" + total).el);
return list;
};
exports.parseRankingInfo = function (value) {
var REGEX_EXTRACT_DOCUMENT_WEIGHTS = /Document weights:\n((?:.)*?)\n+/g;
var REGEX_EXTRACT_TERMS_WEIGHTS = /Terms weights:\n((?:.|\n)*)\n+/g;
var REGEX_EXTRACT_TOTAL_WEIGHTS = /Total weight: ([0-9]+)/g;
if (value) {
var docWeightsRegexResult = REGEX_EXTRACT_DOCUMENT_WEIGHTS.exec(value);
var termsWeightRegexResult = REGEX_EXTRACT_TERMS_WEIGHTS.exec(value);
var totalWeigthRegexResult = REGEX_EXTRACT_TOTAL_WEIGHTS.exec(value);
var qreWeights = parseQREWeights(value);
var documentWeights = parseWeights(docWeightsRegexResult ? docWeightsRegexResult[1] : null);
var termsWeight = parseTermsWeights(termsWeightRegexResult);
var totalWeight = totalWeigthRegexResult ? Number(totalWeigthRegexResult[1]) : null;
return {
documentWeights: documentWeights,
termsWeight: termsWeight,
totalWeight: totalWeight,
qreWeights: qreWeights
};
}
return null;
};
var parseWeights = function (value) {
var REGEX_EXTRACT_LIST_OF_WEIGHTS = /(\w+(?:\s\w+)*): ([-0-9]+)/g;
var REGEX_EXTRACT_WEIGHT_GROUP = /^(\w+(?:\s\w+)*): ([-0-9]+)$/;
if (value) {
var listOfWeight = value.match(REGEX_EXTRACT_LIST_OF_WEIGHTS);
if (listOfWeight) {
return underscore_1.object(listOfWeight.map(function (weight) {
var weightGroup = weight.match(REGEX_EXTRACT_WEIGHT_GROUP);
if (weightGroup) {
var weightAppliedOn = weightGroup[1];
var weightValue = weightGroup[2];
return [weightAppliedOn, Number(weightValue)];
}
return null;
}));
}
}
return null;
};
var parseTermsWeights = function (termsWeight) {
var REGEX_EXTRACT_GROUP_OF_TERMS = /((?:[^:]+: [0-9]+, [0-9]+; )+)\n((?:\w+: [0-9]+; )+)/g;
var REGEX_EXTRACT_SINGLE_TERM = /([^:]+): ([0-9]+), ([0-9]+); /g;
if (termsWeight && termsWeight[1]) {
var terms = StringUtils_1.StringUtils.match(termsWeight[1], REGEX_EXTRACT_GROUP_OF_TERMS);
return underscore_1.object(underscore_1.map(terms, function (term) {
var words = underscore_1.object(underscore_1.map(StringUtils_1.StringUtils.match(term[1], REGEX_EXTRACT_SINGLE_TERM), function (word) {
return [
word[1],
{
Correlation: Number(word[2]),
'TF-IDF': Number(word[3])
}
];
}));
var weights = parseWeights(term[2]);
return [
underscore_1.keys(words).join(', '),
{
terms: words,
Weights: weights
}
];
}));
}
return null;
};
var parseQREWeights = function (value) {
var REGEX_EXTRACT_QRE_WEIGHTS = /(Expression:\s".*")\sScore:\s(?!0)([-0-9]+)\n+/g;
var qreWeightsRegexResult = REGEX_EXTRACT_QRE_WEIGHTS.exec(value);
var qreWeights = [];
while (qreWeightsRegexResult) {
qreWeights.push({
expression: qreWeightsRegexResult[1],
score: parseInt(qreWeightsRegexResult[2], 10)
});
qreWeightsRegexResult = REGEX_EXTRACT_QRE_WEIGHTS.exec(value);
}
return qreWeights;
};
/***/ }),
/***/ 339:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var ExecutionReport_1 = __webpack_require__(335);
var underscore_1 = __webpack_require__(0);
var ExecutionReportGenericSection_1 = __webpack_require__(337);
var GenericValueOutput_1 = __webpack_require__(336);
var TableBuilder_1 = __webpack_require__(334);
var ExecutionReportSimpleSection = /** @class */ (function () {
function ExecutionReportSimpleSection(topLevelProperty, secondLevelProperty, sectionTitle) {
this.topLevelProperty = topLevelProperty;
this.secondLevelProperty = secondLevelProperty;
this.sectionTitle = sectionTitle;
}
ExecutionReportSimpleSection.prototype.build = function (executionReport) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
var _a, container, agGridElement, gridOptions, topLevelProperty, secondLevelProperty, dataSource, tableBuilder, tableBuilder, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = ExecutionReport_1.ExecutionReport.standardSectionHeader(this.sectionTitle), container = _a.container, agGridElement = _a.agGridElement;
topLevelProperty = underscore_1.find(executionReport.children, function (child) {
return child.name == _this.topLevelProperty && child.children && underscore_1.findWhere(child.children, { name: _this.secondLevelProperty });
});
if (!(topLevelProperty && topLevelProperty.children)) return [3 /*break*/, 3];
secondLevelProperty = underscore_1.findWhere(topLevelProperty.children, { name: this.secondLevelProperty });
if (!secondLevelProperty) return [3 /*break*/, 2];
dataSource = [
__assign({}, new ExecutionReportGenericSection_1.ExecutionReportGenericSection().build(secondLevelProperty), { Applied: new GenericValueOutput_1.GenericValueOutput().output(secondLevelProperty.applied) })
];
return [4 /*yield*/, new TableBuilder_1.TableBuilder().build(dataSource, agGridElement)];
case 1:
tableBuilder = _c.sent();
gridOptions = tableBuilder.gridOptions;
_c.label = 2;
case 2: return [3 /*break*/, 5];
case 3: return [4 /*yield*/, new TableBuilder_1.TableBuilder().build([