@qrvey/utils 1.13.0-7.performance.0 → 1.13.0-8
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.
- package/dist/cache-managers/cache-chart-manager.d.ts +2 -3
- package/dist/cache-managers/cache-chart-manager.js +4 -10
- package/dist/cache-managers/cache-manager.d.ts +9 -1
- package/dist/cache-managers/cache-manager.js +15 -1
- package/dist/cjs/cache-managers/cache-chart-manager.d.ts +2 -3
- package/dist/cjs/cache-managers/cache-chart-manager.js +4 -10
- package/dist/cjs/cache-managers/cache-manager.d.ts +9 -1
- package/dist/cjs/cache-managers/cache-manager.js +15 -1
- package/dist/cjs/filters/helpers/common/getFiltersByScopesIds.d.ts +1 -0
- package/dist/cjs/filters/helpers/common/getFiltersByScopesIds.js +3 -3
- package/dist/cjs/filters/helpers/common/getFiltersByVisibility.d.ts +1 -1
- package/dist/cjs/filters/helpers/common/getFiltersByVisibility.js +1 -1
- package/dist/filters/helpers/common/getFiltersByScopesIds.d.ts +1 -0
- package/dist/filters/helpers/common/getFiltersByScopesIds.js +3 -3
- package/dist/filters/helpers/common/getFiltersByVisibility.d.ts +1 -1
- package/dist/filters/helpers/common/getFiltersByVisibility.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,6 @@ export interface IGetChartConfig {
|
|
|
10
10
|
i18n?: any;
|
|
11
11
|
chart_id?: string;
|
|
12
12
|
lang?: string;
|
|
13
|
-
translated?: boolean;
|
|
14
13
|
headers?: {
|
|
15
14
|
"temporal-tokens"?: boolean;
|
|
16
15
|
};
|
|
@@ -24,8 +23,8 @@ export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreStat
|
|
|
24
23
|
static getInstance(): ChartCacheManager;
|
|
25
24
|
protected getConfigPropertyName(): keyof IGetChartConfig;
|
|
26
25
|
protected getStorePropertyName(): keyof IChartStoreState;
|
|
27
|
-
protected buildStoreId({ chart_id
|
|
28
|
-
protected createStore(): {
|
|
26
|
+
protected buildStoreId({ chart_id }: IGetChartConfig): string;
|
|
27
|
+
protected createStore(_initialState?: Partial<IChartStoreState>): {
|
|
29
28
|
state: IChartStoreState;
|
|
30
29
|
onChange: OnChangeType;
|
|
31
30
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createStore } from "@stencil/store";
|
|
2
2
|
import { QrveyCacheManager } from "./cache-manager";
|
|
3
3
|
import ChartsApi from "../services/api/Charts.api";
|
|
4
|
-
import { isEmpty } from "../general/mix/isEmpty";
|
|
5
4
|
export class ChartCacheManager extends QrveyCacheManager {
|
|
6
5
|
static getInstance() {
|
|
7
6
|
if (!window.chartCacheManager) {
|
|
@@ -15,16 +14,11 @@ export class ChartCacheManager extends QrveyCacheManager {
|
|
|
15
14
|
getStorePropertyName() {
|
|
16
15
|
return "chart";
|
|
17
16
|
}
|
|
18
|
-
buildStoreId({ chart_id
|
|
19
|
-
|
|
20
|
-
return `${chart_id}-${translate ? "translated" : ""}`;
|
|
17
|
+
buildStoreId({ chart_id }) {
|
|
18
|
+
return `${chart_id}`;
|
|
21
19
|
}
|
|
22
|
-
createStore() {
|
|
23
|
-
return createStore({
|
|
24
|
-
chart: null,
|
|
25
|
-
loading: true,
|
|
26
|
-
error: null,
|
|
27
|
-
});
|
|
20
|
+
createStore(_initialState) {
|
|
21
|
+
return createStore(Object.assign({ chart: null, loading: true, error: null }, _initialState));
|
|
28
22
|
}
|
|
29
23
|
fetchDataAndUpdateStore(state, config) {
|
|
30
24
|
const api = new ChartsApi(config);
|
|
@@ -8,7 +8,7 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
8
8
|
protected abstract getStorePropertyName(): keyof TStoreState;
|
|
9
9
|
protected abstract buildStoreId(config: TConfig): string;
|
|
10
10
|
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): void;
|
|
11
|
-
protected abstract createStore(): {
|
|
11
|
+
protected abstract createStore(_initialState?: Partial<TStoreState>): {
|
|
12
12
|
state: TStoreState;
|
|
13
13
|
onChange: OnChangeType;
|
|
14
14
|
};
|
|
@@ -16,6 +16,7 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
16
16
|
state: TStoreState;
|
|
17
17
|
onChange: OnChangeType;
|
|
18
18
|
}>;
|
|
19
|
+
private getCreatedStore;
|
|
19
20
|
getStore(config: TConfig): {
|
|
20
21
|
state: TStoreState;
|
|
21
22
|
onChange: OnChangeType;
|
|
@@ -24,4 +25,11 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
24
25
|
state: TStoreState;
|
|
25
26
|
onChange: OnChangeType;
|
|
26
27
|
}[]>;
|
|
28
|
+
createStoresFromData(stores: {
|
|
29
|
+
storeId: string;
|
|
30
|
+
state: Partial<TStoreState>;
|
|
31
|
+
}[]): Array<{
|
|
32
|
+
state: TStoreState;
|
|
33
|
+
onChange: OnChangeType;
|
|
34
|
+
}>;
|
|
27
35
|
}
|
|
@@ -21,9 +21,12 @@ export class QrveyCacheManager {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
getCreatedStore(storeId) {
|
|
25
|
+
return this.stores.get(storeId);
|
|
26
|
+
}
|
|
24
27
|
getStore(config) {
|
|
25
28
|
const storeId = this.buildStoreId(config);
|
|
26
|
-
const store = this.
|
|
29
|
+
const store = this.getCreatedStore(storeId);
|
|
27
30
|
if (store) {
|
|
28
31
|
return store;
|
|
29
32
|
}
|
|
@@ -36,4 +39,15 @@ export class QrveyCacheManager {
|
|
|
36
39
|
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
37
40
|
return Promise.all(promises);
|
|
38
41
|
}
|
|
42
|
+
createStoresFromData(stores) {
|
|
43
|
+
return stores.map((store) => {
|
|
44
|
+
const createdStore = this.getCreatedStore(store.storeId);
|
|
45
|
+
if (!createdStore) {
|
|
46
|
+
const newStore = this.createStore(store.state);
|
|
47
|
+
this.stores.set(store.storeId, newStore);
|
|
48
|
+
return newStore;
|
|
49
|
+
}
|
|
50
|
+
return createdStore;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
39
53
|
}
|
|
@@ -10,7 +10,6 @@ export interface IGetChartConfig {
|
|
|
10
10
|
i18n?: any;
|
|
11
11
|
chart_id?: string;
|
|
12
12
|
lang?: string;
|
|
13
|
-
translated?: boolean;
|
|
14
13
|
headers?: {
|
|
15
14
|
"temporal-tokens"?: boolean;
|
|
16
15
|
};
|
|
@@ -24,8 +23,8 @@ export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreStat
|
|
|
24
23
|
static getInstance(): ChartCacheManager;
|
|
25
24
|
protected getConfigPropertyName(): keyof IGetChartConfig;
|
|
26
25
|
protected getStorePropertyName(): keyof IChartStoreState;
|
|
27
|
-
protected buildStoreId({ chart_id
|
|
28
|
-
protected createStore(): {
|
|
26
|
+
protected buildStoreId({ chart_id }: IGetChartConfig): string;
|
|
27
|
+
protected createStore(_initialState?: Partial<IChartStoreState>): {
|
|
29
28
|
state: IChartStoreState;
|
|
30
29
|
onChange: OnChangeType;
|
|
31
30
|
};
|
|
@@ -7,7 +7,6 @@ exports.ChartCacheManager = void 0;
|
|
|
7
7
|
const store_1 = require("@stencil/store");
|
|
8
8
|
const cache_manager_1 = require("./cache-manager");
|
|
9
9
|
const Charts_api_1 = __importDefault(require("../services/api/Charts.api"));
|
|
10
|
-
const isEmpty_1 = require("../general/mix/isEmpty");
|
|
11
10
|
class ChartCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
12
11
|
static getInstance() {
|
|
13
12
|
if (!window.chartCacheManager) {
|
|
@@ -21,16 +20,11 @@ class ChartCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
|
21
20
|
getStorePropertyName() {
|
|
22
21
|
return "chart";
|
|
23
22
|
}
|
|
24
|
-
buildStoreId({ chart_id
|
|
25
|
-
|
|
26
|
-
return `${chart_id}-${translate ? "translated" : ""}`;
|
|
23
|
+
buildStoreId({ chart_id }) {
|
|
24
|
+
return `${chart_id}`;
|
|
27
25
|
}
|
|
28
|
-
createStore() {
|
|
29
|
-
return (0, store_1.createStore)({
|
|
30
|
-
chart: null,
|
|
31
|
-
loading: true,
|
|
32
|
-
error: null,
|
|
33
|
-
});
|
|
26
|
+
createStore(_initialState) {
|
|
27
|
+
return (0, store_1.createStore)(Object.assign({ chart: null, loading: true, error: null }, _initialState));
|
|
34
28
|
}
|
|
35
29
|
fetchDataAndUpdateStore(state, config) {
|
|
36
30
|
const api = new Charts_api_1.default(config);
|
|
@@ -8,7 +8,7 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
8
8
|
protected abstract getStorePropertyName(): keyof TStoreState;
|
|
9
9
|
protected abstract buildStoreId(config: TConfig): string;
|
|
10
10
|
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): void;
|
|
11
|
-
protected abstract createStore(): {
|
|
11
|
+
protected abstract createStore(_initialState?: Partial<TStoreState>): {
|
|
12
12
|
state: TStoreState;
|
|
13
13
|
onChange: OnChangeType;
|
|
14
14
|
};
|
|
@@ -16,6 +16,7 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
16
16
|
state: TStoreState;
|
|
17
17
|
onChange: OnChangeType;
|
|
18
18
|
}>;
|
|
19
|
+
private getCreatedStore;
|
|
19
20
|
getStore(config: TConfig): {
|
|
20
21
|
state: TStoreState;
|
|
21
22
|
onChange: OnChangeType;
|
|
@@ -24,4 +25,11 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
24
25
|
state: TStoreState;
|
|
25
26
|
onChange: OnChangeType;
|
|
26
27
|
}[]>;
|
|
28
|
+
createStoresFromData(stores: {
|
|
29
|
+
storeId: string;
|
|
30
|
+
state: Partial<TStoreState>;
|
|
31
|
+
}[]): Array<{
|
|
32
|
+
state: TStoreState;
|
|
33
|
+
onChange: OnChangeType;
|
|
34
|
+
}>;
|
|
27
35
|
}
|
|
@@ -24,9 +24,12 @@ class QrveyCacheManager {
|
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
getCreatedStore(storeId) {
|
|
28
|
+
return this.stores.get(storeId);
|
|
29
|
+
}
|
|
27
30
|
getStore(config) {
|
|
28
31
|
const storeId = this.buildStoreId(config);
|
|
29
|
-
const store = this.
|
|
32
|
+
const store = this.getCreatedStore(storeId);
|
|
30
33
|
if (store) {
|
|
31
34
|
return store;
|
|
32
35
|
}
|
|
@@ -39,5 +42,16 @@ class QrveyCacheManager {
|
|
|
39
42
|
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
40
43
|
return Promise.all(promises);
|
|
41
44
|
}
|
|
45
|
+
createStoresFromData(stores) {
|
|
46
|
+
return stores.map((store) => {
|
|
47
|
+
const createdStore = this.getCreatedStore(store.storeId);
|
|
48
|
+
if (!createdStore) {
|
|
49
|
+
const newStore = this.createStore(store.state);
|
|
50
|
+
this.stores.set(store.storeId, newStore);
|
|
51
|
+
return newStore;
|
|
52
|
+
}
|
|
53
|
+
return createdStore;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
exports.QrveyCacheManager = QrveyCacheManager;
|
|
@@ -3,6 +3,7 @@ import { IFSScopeID } from "../../interfaces/common/IFSScopeID";
|
|
|
3
3
|
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
4
4
|
/**
|
|
5
5
|
* Gets filters from Filter Data by Scopes/Scope IDs.
|
|
6
|
+
* If some scope Id property is not recieved into the collection, the filter is skipped.
|
|
6
7
|
* @param filterData The filter data
|
|
7
8
|
* @param scopes The collection of Scopes/Scope IDs
|
|
8
9
|
* @returns a new Filter Data
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFiltersByScopesIds = void 0;
|
|
4
4
|
const isEmpty_1 = require("../../../general/mix/isEmpty");
|
|
5
|
+
const hasProperty_1 = require("../../../general/object/hasProperty");
|
|
5
6
|
const objectCopy_1 = require("../../../general/object/objectCopy");
|
|
6
|
-
const FILTER_SCOPE_1 = require("../../constants/common/FILTER_SCOPE");
|
|
7
7
|
/**
|
|
8
8
|
* Gets filters from Filter Data by Scopes/Scope IDs.
|
|
9
|
+
* If some scope Id property is not recieved into the collection, the filter is skipped.
|
|
9
10
|
* @param filterData The filter data
|
|
10
11
|
* @param scopes The collection of Scopes/Scope IDs
|
|
11
12
|
* @returns a new Filter Data
|
|
@@ -16,8 +17,7 @@ function getFiltersByScopesIds(filterData, scopes = []) {
|
|
|
16
17
|
const _filterData = (0, objectCopy_1.objectCopy)(filterData);
|
|
17
18
|
_filterData.scopes = scopes.reduce((newScopes, scope) => {
|
|
18
19
|
const filteredScopes = _filterData.scopes.filter((fScope) => scope.label === fScope.scope &&
|
|
19
|
-
(scope.id === fScope.scopeid ||
|
|
20
|
-
(fScope.scope === FILTER_SCOPE_1.FILTER_SCOPE.GLOBAL && fScope.scopeid == null)) &&
|
|
20
|
+
(scope.id === fScope.scopeid || !(0, hasProperty_1._hasProperty)(scope, "id")) &&
|
|
21
21
|
fScope.datasets.length > 0);
|
|
22
22
|
return newScopes.concat(filteredScopes);
|
|
23
23
|
}, []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IFSData } from "../../interfaces/common/IFSData";
|
|
2
|
-
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
3
2
|
import { IFSScopeID } from "../../interfaces/common/IFSScopeID";
|
|
3
|
+
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
4
4
|
/**
|
|
5
5
|
* Get a new Filter Data by filtering scopes/scope IDs and enabled flags
|
|
6
6
|
* @param filterData a Filter Data or UI Filter Data
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFiltersByVisibility = void 0;
|
|
4
|
-
const getFiltersByScopesIds_1 = require("./getFiltersByScopesIds");
|
|
5
4
|
const getFiltersByParams_1 = require("./getFiltersByParams");
|
|
5
|
+
const getFiltersByScopesIds_1 = require("./getFiltersByScopesIds");
|
|
6
6
|
const isEmpty_1 = require("../../../general/mix/isEmpty");
|
|
7
7
|
const objectCopy_1 = require("../../../general/object/objectCopy");
|
|
8
8
|
/**
|
|
@@ -3,6 +3,7 @@ import { IFSScopeID } from "../../interfaces/common/IFSScopeID";
|
|
|
3
3
|
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
4
4
|
/**
|
|
5
5
|
* Gets filters from Filter Data by Scopes/Scope IDs.
|
|
6
|
+
* If some scope Id property is not recieved into the collection, the filter is skipped.
|
|
6
7
|
* @param filterData The filter data
|
|
7
8
|
* @param scopes The collection of Scopes/Scope IDs
|
|
8
9
|
* @returns a new Filter Data
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
2
|
+
import { _hasProperty } from "../../../general/object/hasProperty";
|
|
2
3
|
import { objectCopy } from "../../../general/object/objectCopy";
|
|
3
|
-
import { FILTER_SCOPE } from "../../constants/common/FILTER_SCOPE";
|
|
4
4
|
/**
|
|
5
5
|
* Gets filters from Filter Data by Scopes/Scope IDs.
|
|
6
|
+
* If some scope Id property is not recieved into the collection, the filter is skipped.
|
|
6
7
|
* @param filterData The filter data
|
|
7
8
|
* @param scopes The collection of Scopes/Scope IDs
|
|
8
9
|
* @returns a new Filter Data
|
|
@@ -13,8 +14,7 @@ export function getFiltersByScopesIds(filterData, scopes = []) {
|
|
|
13
14
|
const _filterData = objectCopy(filterData);
|
|
14
15
|
_filterData.scopes = scopes.reduce((newScopes, scope) => {
|
|
15
16
|
const filteredScopes = _filterData.scopes.filter((fScope) => scope.label === fScope.scope &&
|
|
16
|
-
(scope.id === fScope.scopeid ||
|
|
17
|
-
(fScope.scope === FILTER_SCOPE.GLOBAL && fScope.scopeid == null)) &&
|
|
17
|
+
(scope.id === fScope.scopeid || !_hasProperty(scope, "id")) &&
|
|
18
18
|
fScope.datasets.length > 0);
|
|
19
19
|
return newScopes.concat(filteredScopes);
|
|
20
20
|
}, []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IFSData } from "../../interfaces/common/IFSData";
|
|
2
|
-
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
3
2
|
import { IFSScopeID } from "../../interfaces/common/IFSScopeID";
|
|
3
|
+
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
4
4
|
/**
|
|
5
5
|
* Get a new Filter Data by filtering scopes/scope IDs and enabled flags
|
|
6
6
|
* @param filterData a Filter Data or UI Filter Data
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getFiltersByScopesIds } from "./getFiltersByScopesIds";
|
|
2
1
|
import { getFiltersByParams } from "./getFiltersByParams";
|
|
2
|
+
import { getFiltersByScopesIds } from "./getFiltersByScopesIds";
|
|
3
3
|
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
4
4
|
import { objectCopy } from "../../../general/object/objectCopy";
|
|
5
5
|
/**
|
package/package.json
CHANGED