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