@qrvey/utils 1.13.0-9 → 1.14.0-0
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 +5 -17
- package/dist/cache-managers/cache-chart-manager.js +25 -23
- package/dist/cache-managers/cache-manager.d.ts +25 -29
- package/dist/cache-managers/cache-manager.js +92 -32
- package/dist/cache-managers/cache-metric-manager.d.ts +6 -18
- package/dist/cache-managers/cache-metric-manager.js +26 -30
- package/dist/cache-managers/cache-model-manager.d.ts +5 -17
- package/dist/cache-managers/cache-model-manager.js +23 -25
- package/dist/cache-managers/cache-permissions-manager.d.ts +5 -18
- package/dist/cache-managers/cache-permissions-manager.js +22 -24
- package/dist/cache-managers/cache-theme-manager.d.ts +5 -18
- package/dist/cache-managers/cache-theme-manager.js +22 -24
- package/dist/cache-managers/clean-cache-managers.d.ts +1 -0
- package/dist/cache-managers/clean-cache-managers.js +26 -0
- package/dist/cache-managers/index.d.ts +7 -0
- package/dist/cache-managers/index.js +7 -0
- package/dist/cjs/cache-managers/cache-chart-manager.d.ts +5 -17
- package/dist/cjs/cache-managers/cache-chart-manager.js +25 -23
- package/dist/cjs/cache-managers/cache-manager.d.ts +25 -29
- package/dist/cjs/cache-managers/cache-manager.js +92 -32
- package/dist/cjs/cache-managers/cache-metric-manager.d.ts +6 -18
- package/dist/cjs/cache-managers/cache-metric-manager.js +26 -30
- package/dist/cjs/cache-managers/cache-model-manager.d.ts +5 -17
- package/dist/cjs/cache-managers/cache-model-manager.js +23 -25
- package/dist/cjs/cache-managers/cache-permissions-manager.d.ts +5 -18
- package/dist/cjs/cache-managers/cache-permissions-manager.js +22 -24
- package/dist/cjs/cache-managers/cache-theme-manager.d.ts +5 -18
- package/dist/cjs/cache-managers/cache-theme-manager.js +22 -24
- package/dist/cjs/cache-managers/clean-cache-managers.d.ts +1 -0
- package/dist/cjs/cache-managers/clean-cache-managers.js +30 -0
- package/dist/cjs/cache-managers/index.d.ts +7 -0
- package/dist/cjs/cache-managers/index.js +23 -0
- package/dist/cjs/globalization/interfaces/dashboard/II18nDashboardMessages.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/panel/II18nPanelTooltips.d.ts +1 -0
- package/dist/cjs/globalization/labels/dashboard/I18N_DASHBOARD.js +3 -1
- package/dist/cjs/globalization/labels/panel/I18N_PANEL.js +1 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/cjs/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +1 -0
- package/dist/cjs/services/api/metrics.api.js +1 -1
- package/dist/cjs/services/helpers/Request.js +5 -1
- package/dist/globalization/interfaces/dashboard/II18nDashboardMessages.d.ts +2 -0
- package/dist/globalization/interfaces/panel/II18nPanelTooltips.d.ts +1 -0
- package/dist/globalization/labels/dashboard/I18N_DASHBOARD.js +3 -1
- package/dist/globalization/labels/panel/I18N_PANEL.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +1 -0
- package/dist/services/api/metrics.api.js +1 -1
- package/dist/services/helpers/Request.js +5 -1
- package/package.json +1 -1
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
10
|
import { QrveyCacheManager } from "./cache-manager";
|
|
3
11
|
import { getCurrentTheme, getThemeById } from "../services/api/Themes.api";
|
|
4
12
|
export class ThemeCacheManager extends QrveyCacheManager {
|
|
5
13
|
static getInstance() {
|
|
6
|
-
if (!window.
|
|
7
|
-
window.
|
|
14
|
+
if (!window.qvThemeCacheManager) {
|
|
15
|
+
window.qvThemeCacheManager = new ThemeCacheManager();
|
|
8
16
|
}
|
|
9
|
-
return window.
|
|
17
|
+
return window.qvThemeCacheManager;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
getConfigEntityId() {
|
|
12
20
|
return "theme_id";
|
|
13
21
|
}
|
|
14
|
-
getStorePropertyName() {
|
|
15
|
-
return "theme";
|
|
16
|
-
}
|
|
17
22
|
buildStoreId({ theme_id, app_id }) {
|
|
18
23
|
return `${app_id}-${theme_id !== null && theme_id !== void 0 ? theme_id : "current"}`;
|
|
19
24
|
}
|
|
20
|
-
createStore() {
|
|
21
|
-
return createStore({
|
|
22
|
-
theme: null,
|
|
23
|
-
loading: true,
|
|
24
|
-
error: null,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
25
|
fetchDataAndUpdateStore(state, config) {
|
|
28
|
-
(
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return (config.theme_id ? getThemeById(config) : getCurrentTheme(config))
|
|
28
|
+
.then((theme) => {
|
|
29
|
+
state.entity = theme;
|
|
30
|
+
state.error = null;
|
|
31
|
+
})
|
|
32
|
+
.catch((e) => {
|
|
33
|
+
state.error = e;
|
|
34
|
+
});
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cleanCacheManagers: () => Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import { ChartCacheManager } from "./cache-chart-manager";
|
|
11
|
+
import { MetricCacheManager } from "./cache-metric-manager";
|
|
12
|
+
import { ModelCacheManager } from "./cache-model-manager";
|
|
13
|
+
import { PermissionsCacheManager } from "./cache-permissions-manager";
|
|
14
|
+
import { ThemeCacheManager } from "./cache-theme-manager";
|
|
15
|
+
export const cleanCacheManagers = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const chartManager = ChartCacheManager.getInstance();
|
|
17
|
+
yield chartManager.cleanAllStores();
|
|
18
|
+
const metricManager = MetricCacheManager.getInstance();
|
|
19
|
+
yield metricManager.cleanAllStores();
|
|
20
|
+
const modelManager = ModelCacheManager.getInstance();
|
|
21
|
+
yield modelManager.cleanAllStores();
|
|
22
|
+
const permissionsManager = PermissionsCacheManager.getInstance();
|
|
23
|
+
yield permissionsManager.cleanAllStores();
|
|
24
|
+
const themeManager = ThemeCacheManager.getInstance();
|
|
25
|
+
yield themeManager.cleanAllStores();
|
|
26
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./cache-chart-manager";
|
|
2
|
+
export * from "./cache-manager";
|
|
3
|
+
export * from "./cache-metric-manager";
|
|
4
|
+
export * from "./cache-model-manager";
|
|
5
|
+
export * from "./cache-permissions-manager";
|
|
6
|
+
export * from "./cache-theme-manager";
|
|
7
|
+
export * from "./clean-cache-managers";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./cache-chart-manager";
|
|
2
|
+
export * from "./cache-manager";
|
|
3
|
+
export * from "./cache-metric-manager";
|
|
4
|
+
export * from "./cache-model-manager";
|
|
5
|
+
export * from "./cache-permissions-manager";
|
|
6
|
+
export * from "./cache-theme-manager";
|
|
7
|
+
export * from "./clean-cache-managers";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
2
2
|
export interface IGetChartConfig {
|
|
3
3
|
qv_token?: string;
|
|
4
4
|
api_key?: string;
|
|
@@ -14,21 +14,9 @@ export interface IGetChartConfig {
|
|
|
14
14
|
"temporal-tokens"?: boolean;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
error: any;
|
|
21
|
-
}
|
|
22
|
-
export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreState, IGetChartConfig> {
|
|
23
|
-
static getInstance(): ChartCacheManager;
|
|
24
|
-
protected getConfigPropertyName(): keyof IGetChartConfig;
|
|
25
|
-
protected getStorePropertyName(): keyof IChartStoreState;
|
|
17
|
+
export declare class ChartCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetChartConfig> {
|
|
18
|
+
static getInstance(): any;
|
|
19
|
+
protected getConfigEntityId(): keyof IGetChartConfig;
|
|
26
20
|
protected buildStoreId({ chart_id }: IGetChartConfig): string;
|
|
27
|
-
protected
|
|
28
|
-
state: IChartStoreState;
|
|
29
|
-
onChange: OnChangeType;
|
|
30
|
-
set: (property: keyof IChartStoreState, value: unknown) => void;
|
|
31
|
-
};
|
|
32
|
-
protected fetchDataAndUpdateStore(state: IChartStoreState, config: IGetChartConfig): void;
|
|
21
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetChartConfig): Promise<void>;
|
|
33
22
|
}
|
|
34
|
-
export {};
|
|
@@ -1,44 +1,46 @@
|
|
|
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
exports.ChartCacheManager = void 0;
|
|
7
|
-
const store_1 = require("@stencil/store");
|
|
8
16
|
const cache_manager_1 = require("./cache-manager");
|
|
9
17
|
const Charts_api_1 = __importDefault(require("../services/api/Charts.api"));
|
|
10
18
|
class ChartCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
11
19
|
static getInstance() {
|
|
12
|
-
if (!window.
|
|
13
|
-
window.
|
|
20
|
+
if (!window.qvChartCacheManager) {
|
|
21
|
+
window.qvChartCacheManager = new ChartCacheManager();
|
|
14
22
|
}
|
|
15
|
-
return window.
|
|
23
|
+
return window.qvChartCacheManager;
|
|
16
24
|
}
|
|
17
|
-
|
|
25
|
+
getConfigEntityId() {
|
|
18
26
|
return "chart_id";
|
|
19
27
|
}
|
|
20
|
-
getStorePropertyName() {
|
|
21
|
-
return "chart";
|
|
22
|
-
}
|
|
23
28
|
buildStoreId({ chart_id }) {
|
|
24
29
|
return `${chart_id}`;
|
|
25
30
|
}
|
|
26
|
-
createStore(_initialState) {
|
|
27
|
-
return (0, store_1.createStore)(Object.assign({ chart: null, loading: true, error: null }, _initialState));
|
|
28
|
-
}
|
|
29
31
|
fetchDataAndUpdateStore(state, config) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const chartConfig = Object.assign(Object.assign({}, config), { translated: true });
|
|
34
|
+
const api = new Charts_api_1.default(chartConfig);
|
|
35
|
+
return api
|
|
36
|
+
.getChart(chartConfig)
|
|
37
|
+
.then((chart) => {
|
|
38
|
+
state.entity = chart;
|
|
39
|
+
state.error = null;
|
|
40
|
+
})
|
|
41
|
+
.catch((e) => {
|
|
42
|
+
state.error = e;
|
|
43
|
+
});
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -1,36 +1,32 @@
|
|
|
1
1
|
export type OnChangeType = (property: string | number | symbol, callback: (entity: unknown) => void) => () => void;
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export interface QvCacheStoreProperties {
|
|
3
|
+
entity: unknown;
|
|
4
|
+
error: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface QrveyCacheStore<T> {
|
|
7
|
+
state: T;
|
|
8
|
+
onChange: OnChangeType;
|
|
9
|
+
set: (property: keyof T, value: unknown) => void;
|
|
10
|
+
dispose: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class QrveyCacheManager<TStoreState extends QvCacheStoreProperties, TConfig> {
|
|
13
|
+
protected stores: Map<string, QrveyCacheStore<TStoreState> | Promise<QrveyCacheStore<TStoreState>>>;
|
|
14
|
+
operationLocks: Map<any, any>;
|
|
15
|
+
protected abstract getConfigEntityId(): keyof TConfig;
|
|
10
16
|
protected abstract buildStoreId(config: TConfig): string;
|
|
11
|
-
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): void
|
|
12
|
-
protected
|
|
13
|
-
|
|
14
|
-
onChange: OnChangeType;
|
|
15
|
-
set: (property: keyof TStoreState, value: unknown) => void;
|
|
16
|
-
};
|
|
17
|
-
protected getStoreFromPromise(config: TConfig, id: string): Promise<{
|
|
18
|
-
state: TStoreState;
|
|
19
|
-
onChange: OnChangeType;
|
|
20
|
-
set: (property: keyof TStoreState, value: unknown) => void;
|
|
21
|
-
}>;
|
|
17
|
+
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): Promise<void>;
|
|
18
|
+
protected createStore(_initialState?: Partial<TStoreState>): Promise<QrveyCacheStore<TStoreState>>;
|
|
19
|
+
getStoreFromPromise(config: TConfig, id: string): Promise<QrveyCacheStore<TStoreState>>;
|
|
22
20
|
private getCreatedStore;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
set: (property: keyof TStoreState, value: unknown) => void;
|
|
27
|
-
};
|
|
28
|
-
getMultipleStores(config: TConfig, ids: string[]): Promise<{
|
|
29
|
-
state: TStoreState;
|
|
30
|
-
onChange: OnChangeType;
|
|
31
|
-
}[]>;
|
|
21
|
+
private initializeStore;
|
|
22
|
+
getStore(config: TConfig): Promise<QrveyCacheStore<TStoreState>>;
|
|
23
|
+
getMultipleStores(config: TConfig, ids: string[]): Promise<QrveyCacheStore<TStoreState>[]>;
|
|
32
24
|
setStoresFromData(stores: {
|
|
33
25
|
storeId: string;
|
|
34
26
|
state: Partial<TStoreState>;
|
|
35
|
-
}[]): void
|
|
27
|
+
}[]): Promise<void[]>;
|
|
28
|
+
private deleteStoreRegister;
|
|
29
|
+
cleanStore(storeId: string): Promise<void>;
|
|
30
|
+
cleanAllStores(): Promise<void>;
|
|
36
31
|
}
|
|
32
|
+
export {};
|
|
@@ -1,57 +1,117 @@
|
|
|
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.QrveyCacheManager = void 0;
|
|
13
|
+
const store_1 = require("@stencil/store");
|
|
4
14
|
class QrveyCacheManager {
|
|
5
15
|
constructor() {
|
|
6
16
|
this.stores = new Map();
|
|
17
|
+
this.operationLocks = new Map();
|
|
18
|
+
}
|
|
19
|
+
createStore(_initialState) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const initialState = Object.assign({ entity: null, error: null }, _initialState);
|
|
22
|
+
return (0, store_1.createStore)(initialState);
|
|
23
|
+
});
|
|
7
24
|
}
|
|
8
25
|
getStoreFromPromise(config, id) {
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
const unsubscribe = store.onChange(storeProperty, (entity) => {
|
|
19
|
-
if (entity !== null) {
|
|
20
|
-
unsubscribe();
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const configEntityId = this.getConfigEntityId();
|
|
31
|
+
const extendedConfig = Object.assign(Object.assign({}, config), { [configEntityId]: id });
|
|
32
|
+
const store = yield this.getStore(extendedConfig);
|
|
21
33
|
resolve(store);
|
|
22
34
|
}
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
catch (error) {
|
|
36
|
+
reject(error);
|
|
37
|
+
}
|
|
38
|
+
}))();
|
|
39
|
+
});
|
|
25
40
|
});
|
|
26
41
|
}
|
|
27
42
|
getCreatedStore(storeId) {
|
|
28
|
-
return this
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return this.stores.get(storeId);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
initializeStore(config, storeId) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const newStore = yield this.createStore();
|
|
50
|
+
yield this.fetchDataAndUpdateStore(newStore.state, config);
|
|
51
|
+
this.stores.set(storeId, newStore);
|
|
52
|
+
return newStore;
|
|
53
|
+
});
|
|
29
54
|
}
|
|
30
55
|
getStore(config) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const storeId = this.buildStoreId(config);
|
|
58
|
+
while (this.operationLocks.has(storeId)) {
|
|
59
|
+
yield this.operationLocks.get(storeId);
|
|
60
|
+
}
|
|
61
|
+
let store = this.stores.get(storeId);
|
|
62
|
+
if (!store) {
|
|
63
|
+
let resolveLock;
|
|
64
|
+
const lockPromise = new Promise((resolve) => (resolveLock = resolve));
|
|
65
|
+
this.operationLocks.set(storeId, lockPromise);
|
|
66
|
+
try {
|
|
67
|
+
store = yield this.initializeStore(config, storeId);
|
|
68
|
+
this.stores.set(storeId, store);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
resolveLock();
|
|
72
|
+
this.operationLocks.delete(storeId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
34
75
|
return store;
|
|
35
|
-
}
|
|
36
|
-
const { state, onChange, set } = store !== null && store !== void 0 ? store : this.createStore();
|
|
37
|
-
this.stores.set(storeId, { state, onChange, set });
|
|
38
|
-
this.fetchDataAndUpdateStore(state, config);
|
|
39
|
-
return { state, onChange, set };
|
|
76
|
+
});
|
|
40
77
|
}
|
|
41
78
|
getMultipleStores(config, ids) {
|
|
42
|
-
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
79
|
+
const promises = ids.map((id) => __awaiter(this, void 0, void 0, function* () { return yield this.getStoreFromPromise(config, id); }));
|
|
43
80
|
return Promise.all(promises);
|
|
44
81
|
}
|
|
45
82
|
setStoresFromData(stores) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
return Promise.all(stores.map((store) => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
let createdStore = yield this.getCreatedStore(store.storeId);
|
|
86
|
+
if (!createdStore) {
|
|
87
|
+
createdStore = yield this.createStore();
|
|
88
|
+
this.stores.set(store.storeId, createdStore);
|
|
89
|
+
}
|
|
90
|
+
Object.entries(store.state).forEach(([key, value]) => {
|
|
91
|
+
createdStore.set(key, value);
|
|
92
|
+
});
|
|
93
|
+
})));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
deleteStoreRegister(storeId) {
|
|
97
|
+
this.stores.delete(storeId);
|
|
98
|
+
}
|
|
99
|
+
cleanStore(storeId) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const existingStore = yield this.getCreatedStore(storeId);
|
|
102
|
+
if (existingStore) {
|
|
103
|
+
const store = existingStore instanceof Promise ? yield existingStore : existingStore;
|
|
104
|
+
store.dispose();
|
|
105
|
+
this.deleteStoreRegister(storeId);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
cleanAllStores() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const storeIds = Array.from(this.stores.keys());
|
|
112
|
+
for (const storeId of storeIds) {
|
|
113
|
+
yield this.cleanStore(storeId);
|
|
51
114
|
}
|
|
52
|
-
Object.entries(store.state).forEach(([key, value]) => {
|
|
53
|
-
createdStore.set(key, value);
|
|
54
|
-
});
|
|
55
115
|
});
|
|
56
116
|
}
|
|
57
117
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
2
2
|
export interface IGetMetricConfig {
|
|
3
3
|
qv_token?: string;
|
|
4
4
|
api_key?: string;
|
|
@@ -15,21 +15,9 @@ export interface IGetMetricConfig {
|
|
|
15
15
|
"temporal-tokens"?: boolean;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export declare class MetricCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetMetricConfig> {
|
|
19
|
+
static getInstance(): any;
|
|
20
|
+
protected getConfigEntityId(): keyof IGetMetricConfig;
|
|
21
|
+
protected buildStoreId({ metric_id }: IGetMetricConfig): string;
|
|
22
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetMetricConfig): Promise<void>;
|
|
22
23
|
}
|
|
23
|
-
export declare class MetricCacheManager extends QrveyCacheManager<IMetricStoreState, IGetMetricConfig> {
|
|
24
|
-
static getInstance(): MetricCacheManager;
|
|
25
|
-
protected getConfigPropertyName(): keyof IGetMetricConfig;
|
|
26
|
-
protected getStorePropertyName(): keyof IMetricStoreState;
|
|
27
|
-
protected buildStoreId({ metric_id, translated }: IGetMetricConfig): string;
|
|
28
|
-
protected createStore(): {
|
|
29
|
-
state: IMetricStoreState;
|
|
30
|
-
onChange: OnChangeType;
|
|
31
|
-
set: (property: keyof IMetricStoreState, value: unknown) => void;
|
|
32
|
-
};
|
|
33
|
-
protected fetchDataAndUpdateStore(state: IMetricStoreState, config: IGetMetricConfig): void;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
@@ -1,49 +1,45 @@
|
|
|
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
exports.MetricCacheManager = void 0;
|
|
7
|
-
const store_1 = require("@stencil/store");
|
|
8
16
|
const cache_manager_1 = require("./cache-manager");
|
|
9
|
-
const isEmpty_1 = require("../general/mix/isEmpty");
|
|
10
17
|
const metrics_api_1 = __importDefault(require("../services/api/metrics.api"));
|
|
11
18
|
class MetricCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
12
19
|
static getInstance() {
|
|
13
|
-
if (!window.
|
|
14
|
-
window.
|
|
20
|
+
if (!window.qvMetricCacheManager) {
|
|
21
|
+
window.qvMetricCacheManager = new MetricCacheManager();
|
|
15
22
|
}
|
|
16
|
-
return window.
|
|
23
|
+
return window.qvMetricCacheManager;
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
getConfigEntityId() {
|
|
19
26
|
return "metric_id";
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
buildStoreId({ metric_id, translated }) {
|
|
25
|
-
const translate = (0, isEmpty_1.isEmpty)(translated) ? true : translated;
|
|
26
|
-
return `${metric_id}-${translate ? "translated" : ""}`;
|
|
27
|
-
}
|
|
28
|
-
createStore() {
|
|
29
|
-
return (0, store_1.createStore)({
|
|
30
|
-
metric: null,
|
|
31
|
-
loading: true,
|
|
32
|
-
error: null,
|
|
33
|
-
});
|
|
28
|
+
buildStoreId({ metric_id }) {
|
|
29
|
+
return `${metric_id}`;
|
|
34
30
|
}
|
|
35
31
|
fetchDataAndUpdateStore(state, config) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const api = new metrics_api_1.default();
|
|
34
|
+
return api
|
|
35
|
+
.getMetricConfig(config)
|
|
36
|
+
.then((metric) => {
|
|
37
|
+
state.entity = metric;
|
|
38
|
+
state.error = null;
|
|
39
|
+
})
|
|
40
|
+
.catch((e) => {
|
|
41
|
+
state.error = e;
|
|
42
|
+
});
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IModel } from "../qrvey";
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
3
2
|
interface IGetModelConfig {
|
|
4
3
|
qv_token?: string;
|
|
5
4
|
api_key?: string;
|
|
@@ -10,21 +9,10 @@ interface IGetModelConfig {
|
|
|
10
9
|
qrvey_id: string;
|
|
11
10
|
i18n?: any;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
error: any;
|
|
17
|
-
}
|
|
18
|
-
export declare class ModelCacheManager extends QrveyCacheManager<IModelStoreState, IGetModelConfig> {
|
|
19
|
-
static getInstance(): ModelCacheManager;
|
|
20
|
-
protected getConfigPropertyName(): keyof IGetModelConfig;
|
|
21
|
-
protected getStorePropertyName(): keyof IModelStoreState;
|
|
12
|
+
export declare class ModelCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetModelConfig> {
|
|
13
|
+
static getInstance(): any;
|
|
14
|
+
protected getConfigEntityId(): keyof IGetModelConfig;
|
|
22
15
|
protected buildStoreId({ qrvey_id }: IGetModelConfig): string;
|
|
23
|
-
protected
|
|
24
|
-
state: IModelStoreState;
|
|
25
|
-
onChange: OnChangeType;
|
|
26
|
-
set: (property: keyof IModelStoreState, value: unknown) => void;
|
|
27
|
-
};
|
|
28
|
-
protected fetchDataAndUpdateStore(state: IModelStoreState, config: IGetModelConfig): void;
|
|
16
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetModelConfig): Promise<void>;
|
|
29
17
|
}
|
|
30
18
|
export {};
|
|
@@ -1,43 +1,41 @@
|
|
|
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.ModelCacheManager = void 0;
|
|
4
|
-
const store_1 = require("@stencil/store");
|
|
5
13
|
const cache_manager_1 = require("./cache-manager");
|
|
6
14
|
const getModel_api_1 = require("../services/api/getModel.api");
|
|
7
15
|
class ModelCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
8
16
|
static getInstance() {
|
|
9
|
-
if (!window.
|
|
10
|
-
window.
|
|
17
|
+
if (!window.qvModelCacheManager) {
|
|
18
|
+
window.qvModelCacheManager = new ModelCacheManager();
|
|
11
19
|
}
|
|
12
|
-
return window.
|
|
20
|
+
return window.qvModelCacheManager;
|
|
13
21
|
}
|
|
14
|
-
|
|
22
|
+
getConfigEntityId() {
|
|
15
23
|
return "qrvey_id";
|
|
16
24
|
}
|
|
17
|
-
getStorePropertyName() {
|
|
18
|
-
return "model";
|
|
19
|
-
}
|
|
20
25
|
buildStoreId({ qrvey_id }) {
|
|
21
26
|
return `${qrvey_id}`;
|
|
22
27
|
}
|
|
23
|
-
createStore() {
|
|
24
|
-
return (0, store_1.createStore)({
|
|
25
|
-
model: null,
|
|
26
|
-
loading: true,
|
|
27
|
-
error: null,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
28
|
fetchDataAndUpdateStore(state, config) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const includeInfo = ["bucketsInfo", "formulaInfo", "colorByValueInfo"];
|
|
31
|
+
return (0, getModel_api_1.getModel)(config, { includeInfo })
|
|
32
|
+
.then((model) => {
|
|
33
|
+
state.entity = model;
|
|
34
|
+
state.error = null;
|
|
35
|
+
})
|
|
36
|
+
.catch((e) => {
|
|
37
|
+
state.error = e;
|
|
38
|
+
});
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
41
|
}
|