@rh-support/utils 0.2.13 → 0.2.14

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.
@@ -1,7 +1,9 @@
1
1
  import { IApiCreateState, IApiDeleteState, IApiResponseDetails, IApiUpdateState } from '@rh-support/types/shared';
2
+ import { ITroubleshootProductResponse } from './productsUtils';
2
3
  export declare function getApiResourceObject<T>(data?: T, isFetching?: boolean, isError?: boolean, errorMessage?: string, error?: Error): IApiResponseDetails<T>;
3
4
  export declare function getApiCreationStatus(isCreating?: boolean, isError?: boolean, errorMessage?: string): IApiCreateState;
4
5
  export declare function getApiUpdationStatus(isUpdating?: boolean, isError?: boolean, errorMessage?: string): IApiUpdateState;
5
6
  export declare function getApiDeletionStatus(isDeleting?: boolean, isError?: boolean, errorMessage?: string): IApiDeleteState;
6
7
  export declare function haventLoadedMetadata<T>(apiResponse: IApiResponseDetails<T>, isEmptyCallback?: (data: T) => boolean): boolean;
8
+ export declare function haventLoadedProductsMetadata(apiResponse: IApiResponseDetails<ITroubleshootProductResponse>): boolean;
7
9
  //# sourceMappingURL=apiUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apiUtils.d.ts","sourceRoot":"","sources":["../../src/apiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGlH,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,IAAI,GAAE,CAAa,EACnB,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,EACzB,KAAK,GAAE,KAAY,GACpB,mBAAmB,CAAC,CAAC,CAAC,CAExB;AAED,wBAAgB,oBAAoB,CAChC,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AACD,wBAAgB,oBAAoB,CAChC,UAAU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,EAAE,CAAC,KAAK,OAAO,GACvC,OAAO,CAGT;AAED,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,GAAG,OAAO,CAEpH"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.haventLoadedMetadata = exports.getApiDeletionStatus = exports.getApiUpdationStatus = exports.getApiCreationStatus = exports.getApiResourceObject = void 0;
6
+ exports.haventLoadedProductsMetadata = exports.haventLoadedMetadata = exports.getApiDeletionStatus = exports.getApiUpdationStatus = exports.getApiCreationStatus = exports.getApiResourceObject = void 0;
7
7
  var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
8
8
  function getApiResourceObject(data, isFetching, isError, errorMessage, error) {
9
9
  if (data === void 0) { data = undefined; }
@@ -40,3 +40,7 @@ function haventLoadedMetadata(apiResponse, isEmptyCallback) {
40
40
  return isDataEmpty(apiResponse.data) && !apiResponse.isFetching && !apiResponse.isError;
41
41
  }
42
42
  exports.haventLoadedMetadata = haventLoadedMetadata;
43
+ function haventLoadedProductsMetadata(apiResponse) {
44
+ return isEmpty_1.default(apiResponse.data.productsResult) && !apiResponse.isFetching && !apiResponse.isError;
45
+ }
46
+ exports.haventLoadedProductsMetadata = haventLoadedProductsMetadata;
@@ -12,5 +12,5 @@ export declare function isOpenShiftOnlineProduct(product: string): boolean;
12
12
  export declare function isValidCaseNumber(caseNumber: string): boolean;
13
13
  export declare function areAllValidCaseNumbers(items: string[]): boolean;
14
14
  export declare function linkifyLinks(text?: string): string;
15
- export declare function severitySort(sevA: any, sevB: any): 1 | -1 | 0;
15
+ export declare function severitySort(sevA: any, sevB: any): 0 | 1 | -1;
16
16
  //# sourceMappingURL=caseUtils.d.ts.map
@@ -14,7 +14,7 @@ export declare function getTopProducts(products: Partial<ISEProduct>[]): Partial
14
14
  export declare function isOnlyVersion(versions: string[]): boolean;
15
15
  export declare function getVersionIfOnlyVersion(versions: string[]): string;
16
16
  export declare function getUniqueSortedVersions(versions: string[]): string[];
17
- export declare const versionSorter: (_a: string, _b: string) => 1 | -1 | 0;
17
+ export declare const versionSorter: (_a: string, _b: string) => 0 | 1 | -1;
18
18
  export declare const versionSort: (arr: string[]) => string[];
19
19
  interface IGetVersionReturnValue {
20
20
  major: string;
@@ -1,3 +1,8 @@
1
- declare const promiseReflection: (p: any) => any;
2
- export { promiseReflection };
1
+ interface IPromiseReflection<T> {
2
+ v?: T;
3
+ status: 'fulfilled' | 'rejected';
4
+ e?: Error;
5
+ }
6
+ declare const promiseReflection: <T>(p: Promise<T>) => Promise<IPromiseReflection<T>>;
7
+ export { promiseReflection, IPromiseReflection };
3
8
  //# sourceMappingURL=promiseUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promiseUtils.d.ts","sourceRoot":"","sources":["../../src/promiseUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB,iBAIlB,CAAC;AAEN,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"promiseUtils.d.ts","sourceRoot":"","sources":["../../src/promiseUtils.ts"],"names":[],"mappings":"AAAA,UAAU,kBAAkB,CAAC,CAAC;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;IACjC,CAAC,CAAC,EAAE,KAAK,CAAC;CACb;AAGD,QAAA,MAAM,iBAAiB,sDAOtB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,7 +1,58 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.promiseReflection = void 0;
4
- var promiseReflection = function (p) {
5
- return p.then(function (v) { return ({ v: v, status: 'fulfilled' }); }, function (e) { return ({ e: e, status: 'rejected' }); });
6
- };
40
+ // Promise.allSetteled is not supported in IE11. Here we use a helper function to mock the functionality
41
+ var promiseReflection = function (p) { return __awaiter(void 0, void 0, void 0, function () {
42
+ var v, e_1;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0:
46
+ _a.trys.push([0, 2, , 3]);
47
+ return [4 /*yield*/, p];
48
+ case 1:
49
+ v = _a.sent();
50
+ return [2 /*return*/, { v: v, status: 'fulfilled' }];
51
+ case 2:
52
+ e_1 = _a.sent();
53
+ return [2 /*return*/, { e: e_1, status: 'rejected' }];
54
+ case 3: return [2 /*return*/];
55
+ }
56
+ });
57
+ }); };
7
58
  exports.promiseReflection = promiseReflection;
@@ -1,7 +1,9 @@
1
1
  import { IApiCreateState, IApiDeleteState, IApiResponseDetails, IApiUpdateState } from '@rh-support/types/shared';
2
+ import { ITroubleshootProductResponse } from './productsUtils';
2
3
  export declare function getApiResourceObject<T>(data?: T, isFetching?: boolean, isError?: boolean, errorMessage?: string, error?: Error): IApiResponseDetails<T>;
3
4
  export declare function getApiCreationStatus(isCreating?: boolean, isError?: boolean, errorMessage?: string): IApiCreateState;
4
5
  export declare function getApiUpdationStatus(isUpdating?: boolean, isError?: boolean, errorMessage?: string): IApiUpdateState;
5
6
  export declare function getApiDeletionStatus(isDeleting?: boolean, isError?: boolean, errorMessage?: string): IApiDeleteState;
6
7
  export declare function haventLoadedMetadata<T>(apiResponse: IApiResponseDetails<T>, isEmptyCallback?: (data: T) => boolean): boolean;
8
+ export declare function haventLoadedProductsMetadata(apiResponse: IApiResponseDetails<ITroubleshootProductResponse>): boolean;
7
9
  //# sourceMappingURL=apiUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apiUtils.d.ts","sourceRoot":"","sources":["../../src/apiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EA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AAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AACD,wBAAgB,oBAAoB,CAChC,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AACD,wBAAgB,oBAAoB,CAChC,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACnC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GACvC,OAAO,CAGT;AAED,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,GAAG,OAAO,CAEpH"}
@@ -15,3 +15,6 @@ export function haventLoadedMetadata(apiResponse, isEmptyCallback) {
15
15
  const isDataEmpty = isEmptyCallback ? isEmptyCallback : isEmpty;
16
16
  return isDataEmpty(apiResponse.data) && !apiResponse.isFetching && !apiResponse.isError;
17
17
  }
18
+ export function haventLoadedProductsMetadata(apiResponse) {
19
+ return isEmpty(apiResponse.data.productsResult) && !apiResponse.isFetching && !apiResponse.isError;
20
+ }
@@ -12,5 +12,5 @@ export declare function isOpenShiftOnlineProduct(product: string): boolean;
12
12
  export declare function isValidCaseNumber(caseNumber: string): boolean;
13
13
  export declare function areAllValidCaseNumbers(items: string[]): boolean;
14
14
  export declare function linkifyLinks(text?: string): string;
15
- export declare function severitySort(sevA: any, sevB: any): 1 | -1 | 0;
15
+ export declare function severitySort(sevA: any, sevB: any): 0 | 1 | -1;
16
16
  //# sourceMappingURL=caseUtils.d.ts.map
@@ -14,7 +14,7 @@ export declare function getTopProducts(products: Partial<ISEProduct>[]): Partial
14
14
  export declare function isOnlyVersion(versions: string[]): boolean;
15
15
  export declare function getVersionIfOnlyVersion(versions: string[]): string;
16
16
  export declare function getUniqueSortedVersions(versions: string[]): string[];
17
- export declare const versionSorter: (_a: string, _b: string) => 1 | -1 | 0;
17
+ export declare const versionSorter: (_a: string, _b: string) => 0 | 1 | -1;
18
18
  export declare const versionSort: (arr: string[]) => string[];
19
19
  interface IGetVersionReturnValue {
20
20
  major: string;
@@ -1,3 +1,8 @@
1
- declare const promiseReflection: (p: any) => any;
2
- export { promiseReflection };
1
+ interface IPromiseReflection<T> {
2
+ v?: T;
3
+ status: 'fulfilled' | 'rejected';
4
+ e?: Error;
5
+ }
6
+ declare const promiseReflection: <T>(p: Promise<T>) => Promise<IPromiseReflection<T>>;
7
+ export { promiseReflection, IPromiseReflection };
3
8
  //# sourceMappingURL=promiseUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promiseUtils.d.ts","sourceRoot":"","sources":["../../src/promiseUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB,iBAIlB,CAAC;AAEN,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"promiseUtils.d.ts","sourceRoot":"","sources":["../../src/promiseUtils.ts"],"names":[],"mappings":"AAAA,UAAU,kBAAkB,CAAC,CAAC;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;IACjC,CAAC,CAAC,EAAE,KAAK,CAAC;CACb;AAGD,QAAA,MAAM,iBAAiB,sDAOtB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,2 +1,20 @@
1
- const promiseReflection = (p) => p.then((v) => ({ v, status: 'fulfilled' }), (e) => ({ e, status: 'rejected' }));
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ // Promise.allSetteled is not supported in IE11. Here we use a helper function to mock the functionality
11
+ const promiseReflection = (p) => __awaiter(void 0, void 0, void 0, function* () {
12
+ try {
13
+ const v = yield p;
14
+ return { v, status: 'fulfilled' };
15
+ }
16
+ catch (e) {
17
+ return { e, status: 'rejected' };
18
+ }
19
+ });
2
20
  export { promiseReflection };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -87,5 +87,5 @@
87
87
  "@types/react-dom": "^17.0.9",
88
88
  "moment-timezone": "^0.5.32"
89
89
  },
90
- "gitHead": "76d987895943b6cb401d9dae98424e50cdedb38f"
90
+ "gitHead": "f16c3e016d3cfc56fa94f1cb1a8f8ab2d3fe0a35"
91
91
  }