@qrvey/utils 1.13.0-8 → 1.13.0-9
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 +1 -0
- package/dist/cache-managers/cache-chart-manager.js +3 -2
- package/dist/cache-managers/cache-manager.d.ts +6 -5
- package/dist/cache-managers/cache-manager.js +8 -7
- package/dist/cache-managers/cache-metric-manager.d.ts +1 -0
- package/dist/cache-managers/cache-model-manager.d.ts +1 -0
- package/dist/cache-managers/cache-permissions-manager.d.ts +1 -0
- package/dist/cache-managers/cache-theme-manager.d.ts +1 -0
- package/dist/cjs/cache-managers/cache-chart-manager.d.ts +1 -0
- package/dist/cjs/cache-managers/cache-chart-manager.js +3 -2
- package/dist/cjs/cache-managers/cache-manager.d.ts +6 -5
- package/dist/cjs/cache-managers/cache-manager.js +8 -7
- package/dist/cjs/cache-managers/cache-metric-manager.d.ts +1 -0
- package/dist/cjs/cache-managers/cache-model-manager.d.ts +1 -0
- package/dist/cjs/cache-managers/cache-permissions-manager.d.ts +1 -0
- package/dist/cjs/cache-managers/cache-theme-manager.d.ts +1 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreStat
|
|
|
27
27
|
protected createStore(_initialState?: Partial<IChartStoreState>): {
|
|
28
28
|
state: IChartStoreState;
|
|
29
29
|
onChange: OnChangeType;
|
|
30
|
+
set: (property: keyof IChartStoreState, value: unknown) => void;
|
|
30
31
|
};
|
|
31
32
|
protected fetchDataAndUpdateStore(state: IChartStoreState, config: IGetChartConfig): void;
|
|
32
33
|
}
|
|
@@ -21,9 +21,10 @@ export class ChartCacheManager extends QrveyCacheManager {
|
|
|
21
21
|
return createStore(Object.assign({ chart: null, loading: true, error: null }, _initialState));
|
|
22
22
|
}
|
|
23
23
|
fetchDataAndUpdateStore(state, config) {
|
|
24
|
-
const
|
|
24
|
+
const chartConfig = Object.assign(Object.assign({}, config), { translated: true });
|
|
25
|
+
const api = new ChartsApi(chartConfig);
|
|
25
26
|
api
|
|
26
|
-
.getChart(
|
|
27
|
+
.getChart(chartConfig)
|
|
27
28
|
.then((chart) => {
|
|
28
29
|
state.chart = chart;
|
|
29
30
|
state.error = null;
|
|
@@ -3,6 +3,7 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
3
3
|
protected stores: Map<string, {
|
|
4
4
|
state: TStoreState;
|
|
5
5
|
onChange: OnChangeType;
|
|
6
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
6
7
|
}>;
|
|
7
8
|
protected abstract getConfigPropertyName(): keyof TConfig;
|
|
8
9
|
protected abstract getStorePropertyName(): keyof TStoreState;
|
|
@@ -11,25 +12,25 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
11
12
|
protected abstract createStore(_initialState?: Partial<TStoreState>): {
|
|
12
13
|
state: TStoreState;
|
|
13
14
|
onChange: OnChangeType;
|
|
15
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
14
16
|
};
|
|
15
17
|
protected getStoreFromPromise(config: TConfig, id: string): Promise<{
|
|
16
18
|
state: TStoreState;
|
|
17
19
|
onChange: OnChangeType;
|
|
20
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
18
21
|
}>;
|
|
19
22
|
private getCreatedStore;
|
|
20
23
|
getStore(config: TConfig): {
|
|
21
24
|
state: TStoreState;
|
|
22
25
|
onChange: OnChangeType;
|
|
26
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
23
27
|
};
|
|
24
28
|
getMultipleStores(config: TConfig, ids: string[]): Promise<{
|
|
25
29
|
state: TStoreState;
|
|
26
30
|
onChange: OnChangeType;
|
|
27
31
|
}[]>;
|
|
28
|
-
|
|
32
|
+
setStoresFromData(stores: {
|
|
29
33
|
storeId: string;
|
|
30
34
|
state: Partial<TStoreState>;
|
|
31
|
-
}[]):
|
|
32
|
-
state: TStoreState;
|
|
33
|
-
onChange: OnChangeType;
|
|
34
|
-
}>;
|
|
35
|
+
}[]): void;
|
|
35
36
|
}
|
|
@@ -30,24 +30,25 @@ export class QrveyCacheManager {
|
|
|
30
30
|
if (store) {
|
|
31
31
|
return store;
|
|
32
32
|
}
|
|
33
|
-
const { state, onChange } = store !== null && store !== void 0 ? store : this.createStore();
|
|
34
|
-
this.stores.set(storeId, { state, onChange });
|
|
33
|
+
const { state, onChange, set } = store !== null && store !== void 0 ? store : this.createStore();
|
|
34
|
+
this.stores.set(storeId, { state, onChange, set });
|
|
35
35
|
this.fetchDataAndUpdateStore(state, config);
|
|
36
|
-
return { state, onChange };
|
|
36
|
+
return { state, onChange, set };
|
|
37
37
|
}
|
|
38
38
|
getMultipleStores(config, ids) {
|
|
39
39
|
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
40
40
|
return Promise.all(promises);
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
setStoresFromData(stores) {
|
|
43
|
+
stores.forEach((store) => {
|
|
44
44
|
const createdStore = this.getCreatedStore(store.storeId);
|
|
45
45
|
if (!createdStore) {
|
|
46
46
|
const newStore = this.createStore(store.state);
|
|
47
47
|
this.stores.set(store.storeId, newStore);
|
|
48
|
-
return newStore;
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
Object.entries(store.state).forEach(([key, value]) => {
|
|
50
|
+
createdStore.set(key, value);
|
|
51
|
+
});
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -28,6 +28,7 @@ export declare class MetricCacheManager extends QrveyCacheManager<IMetricStoreSt
|
|
|
28
28
|
protected createStore(): {
|
|
29
29
|
state: IMetricStoreState;
|
|
30
30
|
onChange: OnChangeType;
|
|
31
|
+
set: (property: keyof IMetricStoreState, value: unknown) => void;
|
|
31
32
|
};
|
|
32
33
|
protected fetchDataAndUpdateStore(state: IMetricStoreState, config: IGetMetricConfig): void;
|
|
33
34
|
}
|
|
@@ -23,6 +23,7 @@ export declare class ModelCacheManager extends QrveyCacheManager<IModelStoreStat
|
|
|
23
23
|
protected createStore(): {
|
|
24
24
|
state: IModelStoreState;
|
|
25
25
|
onChange: OnChangeType;
|
|
26
|
+
set: (property: keyof IModelStoreState, value: unknown) => void;
|
|
26
27
|
};
|
|
27
28
|
protected fetchDataAndUpdateStore(state: IModelStoreState, config: IGetModelConfig): void;
|
|
28
29
|
}
|
|
@@ -20,6 +20,7 @@ export declare class PermissionsCacheManager extends QrveyCacheManager<IPermissi
|
|
|
20
20
|
protected createStore(): {
|
|
21
21
|
state: IPermissionsStoreState;
|
|
22
22
|
onChange: OnChangeType;
|
|
23
|
+
set: (property: keyof IPermissionsStoreState, value: unknown) => void;
|
|
23
24
|
};
|
|
24
25
|
protected fetchDataAndUpdateStore(state: IPermissionsStoreState, config: IGetPermissionsConfig): void;
|
|
25
26
|
}
|
|
@@ -21,6 +21,7 @@ export declare class ThemeCacheManager extends QrveyCacheManager<IThemeStoreStat
|
|
|
21
21
|
protected createStore(): {
|
|
22
22
|
state: IThemeStoreState;
|
|
23
23
|
onChange: OnChangeType;
|
|
24
|
+
set: (property: keyof IThemeStoreState, value: unknown) => void;
|
|
24
25
|
};
|
|
25
26
|
protected fetchDataAndUpdateStore(state: IThemeStoreState, config: IGetThemeConfig): void;
|
|
26
27
|
}
|
|
@@ -27,6 +27,7 @@ export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreStat
|
|
|
27
27
|
protected createStore(_initialState?: Partial<IChartStoreState>): {
|
|
28
28
|
state: IChartStoreState;
|
|
29
29
|
onChange: OnChangeType;
|
|
30
|
+
set: (property: keyof IChartStoreState, value: unknown) => void;
|
|
30
31
|
};
|
|
31
32
|
protected fetchDataAndUpdateStore(state: IChartStoreState, config: IGetChartConfig): void;
|
|
32
33
|
}
|
|
@@ -27,9 +27,10 @@ class ChartCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
|
27
27
|
return (0, store_1.createStore)(Object.assign({ chart: null, loading: true, error: null }, _initialState));
|
|
28
28
|
}
|
|
29
29
|
fetchDataAndUpdateStore(state, config) {
|
|
30
|
-
const
|
|
30
|
+
const chartConfig = Object.assign(Object.assign({}, config), { translated: true });
|
|
31
|
+
const api = new Charts_api_1.default(chartConfig);
|
|
31
32
|
api
|
|
32
|
-
.getChart(
|
|
33
|
+
.getChart(chartConfig)
|
|
33
34
|
.then((chart) => {
|
|
34
35
|
state.chart = chart;
|
|
35
36
|
state.error = null;
|
|
@@ -3,6 +3,7 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
3
3
|
protected stores: Map<string, {
|
|
4
4
|
state: TStoreState;
|
|
5
5
|
onChange: OnChangeType;
|
|
6
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
6
7
|
}>;
|
|
7
8
|
protected abstract getConfigPropertyName(): keyof TConfig;
|
|
8
9
|
protected abstract getStorePropertyName(): keyof TStoreState;
|
|
@@ -11,25 +12,25 @@ export declare abstract class QrveyCacheManager<TStoreState, TConfig> {
|
|
|
11
12
|
protected abstract createStore(_initialState?: Partial<TStoreState>): {
|
|
12
13
|
state: TStoreState;
|
|
13
14
|
onChange: OnChangeType;
|
|
15
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
14
16
|
};
|
|
15
17
|
protected getStoreFromPromise(config: TConfig, id: string): Promise<{
|
|
16
18
|
state: TStoreState;
|
|
17
19
|
onChange: OnChangeType;
|
|
20
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
18
21
|
}>;
|
|
19
22
|
private getCreatedStore;
|
|
20
23
|
getStore(config: TConfig): {
|
|
21
24
|
state: TStoreState;
|
|
22
25
|
onChange: OnChangeType;
|
|
26
|
+
set: (property: keyof TStoreState, value: unknown) => void;
|
|
23
27
|
};
|
|
24
28
|
getMultipleStores(config: TConfig, ids: string[]): Promise<{
|
|
25
29
|
state: TStoreState;
|
|
26
30
|
onChange: OnChangeType;
|
|
27
31
|
}[]>;
|
|
28
|
-
|
|
32
|
+
setStoresFromData(stores: {
|
|
29
33
|
storeId: string;
|
|
30
34
|
state: Partial<TStoreState>;
|
|
31
|
-
}[]):
|
|
32
|
-
state: TStoreState;
|
|
33
|
-
onChange: OnChangeType;
|
|
34
|
-
}>;
|
|
35
|
+
}[]): void;
|
|
35
36
|
}
|
|
@@ -33,24 +33,25 @@ class QrveyCacheManager {
|
|
|
33
33
|
if (store) {
|
|
34
34
|
return store;
|
|
35
35
|
}
|
|
36
|
-
const { state, onChange } = store !== null && store !== void 0 ? store : this.createStore();
|
|
37
|
-
this.stores.set(storeId, { state, onChange });
|
|
36
|
+
const { state, onChange, set } = store !== null && store !== void 0 ? store : this.createStore();
|
|
37
|
+
this.stores.set(storeId, { state, onChange, set });
|
|
38
38
|
this.fetchDataAndUpdateStore(state, config);
|
|
39
|
-
return { state, onChange };
|
|
39
|
+
return { state, onChange, set };
|
|
40
40
|
}
|
|
41
41
|
getMultipleStores(config, ids) {
|
|
42
42
|
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
43
43
|
return Promise.all(promises);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
setStoresFromData(stores) {
|
|
46
|
+
stores.forEach((store) => {
|
|
47
47
|
const createdStore = this.getCreatedStore(store.storeId);
|
|
48
48
|
if (!createdStore) {
|
|
49
49
|
const newStore = this.createStore(store.state);
|
|
50
50
|
this.stores.set(store.storeId, newStore);
|
|
51
|
-
return newStore;
|
|
52
51
|
}
|
|
53
|
-
|
|
52
|
+
Object.entries(store.state).forEach(([key, value]) => {
|
|
53
|
+
createdStore.set(key, value);
|
|
54
|
+
});
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -28,6 +28,7 @@ export declare class MetricCacheManager extends QrveyCacheManager<IMetricStoreSt
|
|
|
28
28
|
protected createStore(): {
|
|
29
29
|
state: IMetricStoreState;
|
|
30
30
|
onChange: OnChangeType;
|
|
31
|
+
set: (property: keyof IMetricStoreState, value: unknown) => void;
|
|
31
32
|
};
|
|
32
33
|
protected fetchDataAndUpdateStore(state: IMetricStoreState, config: IGetMetricConfig): void;
|
|
33
34
|
}
|
|
@@ -23,6 +23,7 @@ export declare class ModelCacheManager extends QrveyCacheManager<IModelStoreStat
|
|
|
23
23
|
protected createStore(): {
|
|
24
24
|
state: IModelStoreState;
|
|
25
25
|
onChange: OnChangeType;
|
|
26
|
+
set: (property: keyof IModelStoreState, value: unknown) => void;
|
|
26
27
|
};
|
|
27
28
|
protected fetchDataAndUpdateStore(state: IModelStoreState, config: IGetModelConfig): void;
|
|
28
29
|
}
|
|
@@ -20,6 +20,7 @@ export declare class PermissionsCacheManager extends QrveyCacheManager<IPermissi
|
|
|
20
20
|
protected createStore(): {
|
|
21
21
|
state: IPermissionsStoreState;
|
|
22
22
|
onChange: OnChangeType;
|
|
23
|
+
set: (property: keyof IPermissionsStoreState, value: unknown) => void;
|
|
23
24
|
};
|
|
24
25
|
protected fetchDataAndUpdateStore(state: IPermissionsStoreState, config: IGetPermissionsConfig): void;
|
|
25
26
|
}
|
|
@@ -21,6 +21,7 @@ export declare class ThemeCacheManager extends QrveyCacheManager<IThemeStoreStat
|
|
|
21
21
|
protected createStore(): {
|
|
22
22
|
state: IThemeStoreState;
|
|
23
23
|
onChange: OnChangeType;
|
|
24
|
+
set: (property: keyof IThemeStoreState, value: unknown) => void;
|
|
24
25
|
};
|
|
25
26
|
protected fetchDataAndUpdateStore(state: IThemeStoreState, config: IGetThemeConfig): void;
|
|
26
27
|
}
|