@rh-support/utils 0.2.48 → 0.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ export declare const getAccessHostname: () => string;
2
+ export declare const getAppVersion: () => any;
3
+ export interface IStrataHeaders {
4
+ redhat_client?: string;
5
+ account_number?: string;
6
+ }
7
+ export declare const getStrataHeaders: (appName: string, accountNumber: string) => IStrataHeaders;
8
+ export declare const setStrataHeaders: (appName: string, accountNumber: string) => void;
9
+ export declare const getUserAgentForCaseMode: (isCaseCreate: boolean) => string;
10
+ export declare const setSecuredSupport: (isGs4?: boolean) => void;
11
+ //# sourceMappingURL=appUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appUtils.d.ts","sourceRoot":"","sources":["../../src/appUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,cAe7B,CAAC;AAEF,eAAO,MAAM,aAAa,WAEzB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,KAAG,cAGxE,CAAC;AAEH,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,SAItE,CAAC;AAgBF,eAAO,MAAM,uBAAuB,iBAAkB,OAAO,WAE5D,CAAC;AAGF,eAAO,MAAM,iBAAiB,WAAW,OAAO,SAG/C,CAAC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setSecuredSupport = exports.getUserAgentForCaseMode = exports.setStrataHeaders = exports.getStrataHeaders = exports.getAppVersion = exports.getAccessHostname = void 0;
7
+ var get_1 = __importDefault(require("lodash/get"));
8
+ var getAccessHostname = function () {
9
+ // returns the current access.redhat.com hostname (e.g if qa then would return access.qa.redhat.com)
10
+ if (typeof window !== 'undefined' && window) {
11
+ if (prodHostNames.indexOf(window.location.hostname) !== -1) {
12
+ return prodHostNames[0];
13
+ }
14
+ else if (qaHostNames.indexOf(window.location.hostname) !== -1) {
15
+ return qaHostNames[0];
16
+ }
17
+ else if (fteHostNames.indexOf(window.location.hostname) !== -1) {
18
+ return fteHostNames[0];
19
+ }
20
+ else if (ciHostNames.indexOf(window.location.hostname) !== -1) {
21
+ return ciHostNames[0];
22
+ }
23
+ else if (stageHostNames.indexOf(window.location.hostname) !== -1) {
24
+ return stageHostNames[0];
25
+ }
26
+ }
27
+ };
28
+ exports.getAccessHostname = getAccessHostname;
29
+ var getAppVersion = function () {
30
+ return get_1.default(window.seVersionInfo || window.supportVersionInfo || {}, 'packageVersion');
31
+ };
32
+ exports.getAppVersion = getAppVersion;
33
+ var strataHeaders = {};
34
+ var getStrataHeaders = function (appName, accountNumber) { return ({
35
+ redhat_client: appName + " " + exports.getAppVersion(),
36
+ account_number: accountNumber,
37
+ }); };
38
+ exports.getStrataHeaders = getStrataHeaders;
39
+ var setStrataHeaders = function (appName, accountNumber) {
40
+ var newStrataHeaders = exports.getStrataHeaders(appName, accountNumber);
41
+ strataHeaders.redhat_client = newStrataHeaders.redhat_client;
42
+ strataHeaders.account_number = newStrataHeaders.account_number;
43
+ };
44
+ exports.setStrataHeaders = setStrataHeaders;
45
+ // Host names for all the app's different environments.
46
+ // the actual redhat url needs to always be in the first position of the arrays
47
+ // because the getAccessHostname function depends on that being the case for getting the current access hostname.
48
+ var prodHostNames = [
49
+ 'access.redhat.com',
50
+ 'prod.foo.redhat.com',
51
+ 'fooprod.redhat.com',
52
+ 'attachment-viewer.cee.redhat.com',
53
+ ];
54
+ var qaHostNames = ['access.qa.redhat.com', 'qa.foo.redhat.com', 'fooqa.redhat.com', 'sos-viewer.corp.qa.redhat.com'];
55
+ var fteHostNames = ['access.devgssfte.devlab.phx1.redhat.com', 'fte.foo.redhat.com', 'foofte.redhat.com'];
56
+ var ciHostNames = ['access.devgssci.devlab.phx1.redhat.com', 'ci.foo.redhat.com', 'fooci.redhat.com'];
57
+ var stageHostNames = ['access.stage.redhat.com', 'stage.foo.redhat.com', 'foostage.redhat.com'];
58
+ var getUserAgentForCaseMode = function (isCaseCreate) {
59
+ return isCaseCreate ? "Portal Case Management " + exports.getAppVersion() : "Solution Engine " + exports.getAppVersion();
60
+ };
61
+ exports.getUserAgentForCaseMode = getUserAgentForCaseMode;
62
+ var securedSupport = { pathPrefix: '', isGs4: false };
63
+ var setSecuredSupport = function (isGs4) {
64
+ if (isGs4 === void 0) { isGs4 = false; }
65
+ securedSupport.isGs4 = isGs4;
66
+ securedSupport.pathPrefix = isGs4 ? '/secure-support' : '';
67
+ };
68
+ exports.setSecuredSupport = setSecuredSupport;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.dtmTrackEvent = exports.pendoTrackEvent = exports.haltEvent = void 0;
7
- var api_1 = require("@rh-support/api");
7
+ var hydrajs_1 = require("@cee-eng/hydrajs");
8
8
  var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
9
9
  function haltEvent(event) {
10
10
  if (event) {
@@ -20,13 +20,13 @@ function pendoTrackEvent(name, properties) {
20
20
  if (properties === void 0) { properties = {}; }
21
21
  var pendo = window.pendo;
22
22
  // log the event for prod and local envirnoment
23
- if (!isEmpty_1.default(pendo) && (api_1.getEnvName() === api_1.EnvNames.PROD || api_1.isLocalEnv())) {
23
+ if (!isEmpty_1.default(pendo) && (hydrajs_1.Env.getEnvName() === hydrajs_1.Env.EnvNames.PROD || hydrajs_1.Env.isLocalEnv())) {
24
24
  pendo.track(name, properties);
25
25
  }
26
26
  }
27
27
  exports.pendoTrackEvent = pendoTrackEvent;
28
28
  function dtmTrackEvent(elemRef, eventName, event) {
29
- if (elemRef.current && (api_1.getEnvName() === api_1.EnvNames.PROD || api_1.isLocalEnv())) {
29
+ if (elemRef.current && (hydrajs_1.Env.getEnvName() === hydrajs_1.Env.EnvNames.PROD || hydrajs_1.Env.isLocalEnv())) {
30
30
  elemRef.current.dispatchEvent(new CustomEvent(eventName, event));
31
31
  }
32
32
  }
@@ -1,4 +1,5 @@
1
1
  export * from './apiUtils';
2
+ export * from './appUtils';
2
3
  export * from './browserDetectionUtils';
3
4
  export * from './caseUtils';
4
5
  export * from './cacheUtils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./apiUtils"), exports);
14
+ __exportStar(require("./appUtils"), exports);
14
15
  __exportStar(require("./browserDetectionUtils"), exports);
15
16
  __exportStar(require("./caseUtils"), exports);
16
17
  __exportStar(require("./cacheUtils"), exports);
@@ -8,6 +8,7 @@ export declare type IRecommendationAdditionalFilters = {
8
8
  exclude: true;
9
9
  };
10
10
  };
11
+ export declare function addFiltersToFieldQueries(fqArray: string[], additionalFilters: any): void;
11
12
  export declare function getSolrParams(rows: number, highlighted_fragment_size: number, additionalFilters?: IRecommendationAdditionalFilters, QueryFields?: boolean): {
12
13
  rows: number;
13
14
  'hl.fragsize': number;
@@ -1 +1 @@
1
- {"version":3,"file":"searchApiUtils.d.ts","sourceRoot":"","sources":["../../src/searchApiUtils.ts"],"names":[],"mappings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;;;;;;;;;;;;;;;;;;;EAWxB"}
@@ -11,8 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.getSolrParams = exports.issuesDefaultParamsObj = exports.documentKindToInclude = void 0;
15
- var api_1 = require("@rh-support/api");
14
+ exports.getSolrParams = exports.addFiltersToFieldQueries = exports.issuesDefaultParamsObj = exports.documentKindToInclude = void 0;
16
15
  var lodash_1 = require("lodash");
17
16
  exports.documentKindToInclude = 'documentKind:("Solution" OR "Video" OR "CertifiedSoftware" OR "CertifiedCloudPartner" OR "Article" OR "Errata" OR "Vulnerability" OR "CertifiedHardware" OR "Cve" OR "LabInfo")';
18
17
  exports.issuesDefaultParamsObj = {
@@ -29,10 +28,29 @@ exports.issuesDefaultParamsObj = {
29
28
  'hl.snippets': 1,
30
29
  'hl.fragsize': 0,
31
30
  };
31
+ function addFiltersToFieldQueries(fqArray, additionalFilters) {
32
+ Object.keys(additionalFilters).forEach(function (_key) {
33
+ var _a;
34
+ var val = additionalFilters[_key];
35
+ if (Array.isArray(val) && val.length > 0) {
36
+ var query = _key + ":(" + val.join(' OR ') + ")";
37
+ query && fqArray.push(query);
38
+ }
39
+ else if (typeof val === 'object') {
40
+ var excludeFlag = val === null || val === void 0 ? void 0 : val.exclude;
41
+ var values = (_a = val === null || val === void 0 ? void 0 : val.values) !== null && _a !== void 0 ? _a : [];
42
+ if (values.length < 1)
43
+ return;
44
+ var query = _key + ":(" + values.join(' OR ') + ")";
45
+ query && fqArray.push("" + (excludeFlag ? '-' : '') + query);
46
+ }
47
+ });
48
+ }
49
+ exports.addFiltersToFieldQueries = addFiltersToFieldQueries;
32
50
  function getSolrParams(rows, highlighted_fragment_size, additionalFilters, QueryFields) {
33
51
  var cloneIssueParams = lodash_1.cloneDeep(exports.issuesDefaultParamsObj);
34
52
  var issueParamsObj = __assign(__assign({}, cloneIssueParams), { rows: rows, 'hl.fragsize': highlighted_fragment_size, seQueryFields: QueryFields || false });
35
- additionalFilters && api_1.addFiltersToFieldQueries(issueParamsObj.fq, additionalFilters);
53
+ additionalFilters && addFiltersToFieldQueries(issueParamsObj.fq, additionalFilters);
36
54
  return issueParamsObj;
37
55
  }
38
56
  exports.getSolrParams = getSolrParams;
@@ -0,0 +1,11 @@
1
+ export declare const getAccessHostname: () => string;
2
+ export declare const getAppVersion: () => any;
3
+ export interface IStrataHeaders {
4
+ redhat_client?: string;
5
+ account_number?: string;
6
+ }
7
+ export declare const getStrataHeaders: (appName: string, accountNumber: string) => IStrataHeaders;
8
+ export declare const setStrataHeaders: (appName: string, accountNumber: string) => void;
9
+ export declare const getUserAgentForCaseMode: (isCaseCreate: boolean) => string;
10
+ export declare const setSecuredSupport: (isGs4?: boolean) => void;
11
+ //# sourceMappingURL=appUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appUtils.d.ts","sourceRoot":"","sources":["../../src/appUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,cAe7B,CAAC;AAEF,eAAO,MAAM,aAAa,WAEzB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,KAAG,cAGxE,CAAC;AAEH,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,SAItE,CAAC;AAgBF,eAAO,MAAM,uBAAuB,iBAAkB,OAAO,WAE5D,CAAC;AAGF,eAAO,MAAM,iBAAiB,WAAW,OAAO,SAG/C,CAAC"}
@@ -0,0 +1,55 @@
1
+ import get from 'lodash/get';
2
+ export const getAccessHostname = () => {
3
+ // returns the current access.redhat.com hostname (e.g if qa then would return access.qa.redhat.com)
4
+ if (typeof window !== 'undefined' && window) {
5
+ if (prodHostNames.indexOf(window.location.hostname) !== -1) {
6
+ return prodHostNames[0];
7
+ }
8
+ else if (qaHostNames.indexOf(window.location.hostname) !== -1) {
9
+ return qaHostNames[0];
10
+ }
11
+ else if (fteHostNames.indexOf(window.location.hostname) !== -1) {
12
+ return fteHostNames[0];
13
+ }
14
+ else if (ciHostNames.indexOf(window.location.hostname) !== -1) {
15
+ return ciHostNames[0];
16
+ }
17
+ else if (stageHostNames.indexOf(window.location.hostname) !== -1) {
18
+ return stageHostNames[0];
19
+ }
20
+ }
21
+ };
22
+ export const getAppVersion = () => {
23
+ return get(window.seVersionInfo || window.supportVersionInfo || {}, 'packageVersion');
24
+ };
25
+ const strataHeaders = {};
26
+ export const getStrataHeaders = (appName, accountNumber) => ({
27
+ redhat_client: `${appName} ${getAppVersion()}`,
28
+ account_number: accountNumber,
29
+ });
30
+ export const setStrataHeaders = (appName, accountNumber) => {
31
+ const newStrataHeaders = getStrataHeaders(appName, accountNumber);
32
+ strataHeaders.redhat_client = newStrataHeaders.redhat_client;
33
+ strataHeaders.account_number = newStrataHeaders.account_number;
34
+ };
35
+ // Host names for all the app's different environments.
36
+ // the actual redhat url needs to always be in the first position of the arrays
37
+ // because the getAccessHostname function depends on that being the case for getting the current access hostname.
38
+ const prodHostNames = [
39
+ 'access.redhat.com',
40
+ 'prod.foo.redhat.com',
41
+ 'fooprod.redhat.com',
42
+ 'attachment-viewer.cee.redhat.com',
43
+ ];
44
+ const qaHostNames = ['access.qa.redhat.com', 'qa.foo.redhat.com', 'fooqa.redhat.com', 'sos-viewer.corp.qa.redhat.com'];
45
+ const fteHostNames = ['access.devgssfte.devlab.phx1.redhat.com', 'fte.foo.redhat.com', 'foofte.redhat.com'];
46
+ const ciHostNames = ['access.devgssci.devlab.phx1.redhat.com', 'ci.foo.redhat.com', 'fooci.redhat.com'];
47
+ const stageHostNames = ['access.stage.redhat.com', 'stage.foo.redhat.com', 'foostage.redhat.com'];
48
+ export const getUserAgentForCaseMode = (isCaseCreate) => {
49
+ return isCaseCreate ? `Portal Case Management ${getAppVersion()}` : `Solution Engine ${getAppVersion()}`;
50
+ };
51
+ const securedSupport = { pathPrefix: '', isGs4: false };
52
+ export const setSecuredSupport = (isGs4 = false) => {
53
+ securedSupport.isGs4 = isGs4;
54
+ securedSupport.pathPrefix = isGs4 ? '/secure-support' : '';
55
+ };
@@ -1,4 +1,4 @@
1
- import { EnvNames, getEnvName, isLocalEnv } from '@rh-support/api';
1
+ import { Env } from '@cee-eng/hydrajs';
2
2
  import isEmpty from 'lodash/isEmpty';
3
3
  function haltEvent(event) {
4
4
  if (event) {
@@ -12,12 +12,12 @@ function haltEvent(event) {
12
12
  function pendoTrackEvent(name, properties = {}) {
13
13
  const pendo = window.pendo;
14
14
  // log the event for prod and local envirnoment
15
- if (!isEmpty(pendo) && (getEnvName() === EnvNames.PROD || isLocalEnv())) {
15
+ if (!isEmpty(pendo) && (Env.getEnvName() === Env.EnvNames.PROD || Env.isLocalEnv())) {
16
16
  pendo.track(name, properties);
17
17
  }
18
18
  }
19
19
  function dtmTrackEvent(elemRef, eventName, event) {
20
- if (elemRef.current && (getEnvName() === EnvNames.PROD || isLocalEnv())) {
20
+ if (elemRef.current && (Env.getEnvName() === Env.EnvNames.PROD || Env.isLocalEnv())) {
21
21
  elemRef.current.dispatchEvent(new CustomEvent(eventName, event));
22
22
  }
23
23
  }
@@ -1,4 +1,5 @@
1
1
  export * from './apiUtils';
2
+ export * from './appUtils';
2
3
  export * from './browserDetectionUtils';
3
4
  export * from './caseUtils';
4
5
  export * from './cacheUtils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,C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GED
@@ -1,4 +1,5 @@
1
1
  export * from './apiUtils';
2
+ export * from './appUtils';
2
3
  export * from './browserDetectionUtils';
3
4
  export * from './caseUtils';
4
5
  export * from './cacheUtils';
@@ -8,6 +8,7 @@ export declare type IRecommendationAdditionalFilters = {
8
8
  exclude: true;
9
9
  };
10
10
  };
11
+ export declare function addFiltersToFieldQueries(fqArray: string[], additionalFilters: any): void;
11
12
  export declare function getSolrParams(rows: number, highlighted_fragment_size: number, additionalFilters?: IRecommendationAdditionalFilters, QueryFields?: boolean): {
12
13
  rows: number;
13
14
  'hl.fragsize': number;
@@ -1 +1 @@
1
- {"version":3,"file":"searchApiUtils.d.ts","sourceRoot":"","sources":["../../src/searchApiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAI/E,eAAO,MAAM,qBAAqB,wMACmJ,CAAC;AAEtL,eAAO,MAAM,sBAAsB,EAAE,gBAapC,CAAC;AAMF,oBAAY,gCAAgC,GAAG;KAC1C,GAAG,IAAI,MAAM,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE;CACtF,CAAC;AAEF,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,EACZ,yBAAyB,EAAE,MAAM,EACjC,iBAAiB,CAAC,EAAE,gCAAgC,EACpD,WAAW,CAAC,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;EAWxB"}
1
+ {"version":3,"file":"searchApiUtils.d.ts","sourceRoot":"","sources":["../../src/searchApiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAG/E,eAAO,MAAM,qBAAqB,wMACmJ,CAAC;AAEtL,eAAO,MAAM,sBAAsB,EAAE,gBAapC,CAAC;AAMF,oBAAY,gCAAgC,GAAG;KAC1C,GAAG,IAAI,MAAM,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE;CACtF,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,iBAAiB,KAAA,QAc5E;AAED,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,EACZ,yBAAyB,EAAE,MAAM,EACjC,iBAAiB,CAAC,EAAE,gCAAgC,EACpD,WAAW,CAAC,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;EAWxB"}
@@ -1,4 +1,3 @@
1
- import { addFiltersToFieldQueries } from '@rh-support/api';
2
1
  import { cloneDeep } from 'lodash';
3
2
  export const documentKindToInclude = 'documentKind:("Solution" OR "Video" OR "CertifiedSoftware" OR "CertifiedCloudPartner" OR "Article" OR "Errata" OR "Vulnerability" OR "CertifiedHardware" OR "Cve" OR "LabInfo")';
4
3
  export const issuesDefaultParamsObj = {
@@ -15,6 +14,24 @@ export const issuesDefaultParamsObj = {
15
14
  'hl.snippets': 1,
16
15
  'hl.fragsize': 0,
17
16
  };
17
+ export function addFiltersToFieldQueries(fqArray, additionalFilters) {
18
+ Object.keys(additionalFilters).forEach((_key) => {
19
+ var _a;
20
+ const val = additionalFilters[_key];
21
+ if (Array.isArray(val) && val.length > 0) {
22
+ const query = `${_key}:(${val.join(' OR ')})`;
23
+ query && fqArray.push(query);
24
+ }
25
+ else if (typeof val === 'object') {
26
+ const excludeFlag = val === null || val === void 0 ? void 0 : val.exclude;
27
+ const values = (_a = val === null || val === void 0 ? void 0 : val.values) !== null && _a !== void 0 ? _a : [];
28
+ if (values.length < 1)
29
+ return;
30
+ const query = `${_key}:(${values.join(' OR ')})`;
31
+ query && fqArray.push(`${excludeFlag ? '-' : ''}${query}`);
32
+ }
33
+ });
34
+ }
18
35
  export function getSolrParams(rows, highlighted_fragment_size, additionalFilters, QueryFields) {
19
36
  const cloneIssueParams = cloneDeep(issuesDefaultParamsObj);
20
37
  const issueParamsObj = Object.assign(Object.assign({}, cloneIssueParams), { rows, 'hl.fragsize': highlighted_fragment_size, seQueryFields: QueryFields || false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "0.2.48",
3
+ "version": "0.2.49",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -47,7 +47,6 @@
47
47
  "peerDependencies": {
48
48
  "@cee-eng/hydrajs": "4.12.7",
49
49
  "@cee-eng/ui-toolkit": "1.1.6",
50
- "@rh-support/api": "0.3.9",
51
50
  "@rh-support/types": "0.2.0",
52
51
  "dompurify": "^2.2.6",
53
52
  "i18next": "^19.0.1",
@@ -63,7 +62,6 @@
63
62
  "dependencies": {
64
63
  "@cee-eng/hydrajs": "4.12.7",
65
64
  "@cee-eng/ui-toolkit": "1.1.6",
66
- "@rh-support/api": "0.3.25",
67
65
  "@rh-support/types": "0.2.0",
68
66
  "dompurify": "^2.2.6",
69
67
  "dot": "^1.1.3",
@@ -87,5 +85,5 @@
87
85
  "@types/react-dom": "^17.0.9",
88
86
  "moment-timezone": "^0.5.32"
89
87
  },
90
- "gitHead": "e4bbdcf60f5ca9c6427a3655a7d264680c692b37"
88
+ "gitHead": "f69fb5ac2a9d8561d300a9e7f02456268d1e2fc7"
91
89
  }