@qrvey/utils 1.13.0-4 → 1.13.0-5.performance.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 +34 -0
- package/dist/cache-managers/cache-chart-manager.js +43 -0
- package/dist/cache-managers/cache-manager.d.ts +27 -0
- package/dist/cache-managers/cache-manager.js +39 -0
- package/dist/cache-managers/cache-model-manager.d.ts +29 -0
- package/dist/cache-managers/cache-model-manager.js +40 -0
- package/dist/cache-managers/cache-permissions-manager.d.ts +26 -0
- package/dist/cache-managers/cache-permissions-manager.js +39 -0
- package/dist/cjs/cache-managers/cache-chart-manager.d.ts +34 -0
- package/dist/cjs/cache-managers/cache-chart-manager.js +50 -0
- package/dist/cjs/cache-managers/cache-manager.d.ts +27 -0
- package/dist/cjs/cache-managers/cache-manager.js +43 -0
- package/dist/cjs/cache-managers/cache-model-manager.d.ts +29 -0
- package/dist/cjs/cache-managers/cache-model-manager.js +44 -0
- package/dist/cjs/cache-managers/cache-permissions-manager.d.ts +26 -0
- package/dist/cjs/cache-managers/cache-permissions-manager.js +43 -0
- package/dist/cjs/filters/constants/settings/FILTER_SETTINGS_DEFAULT.js +23 -0
- package/dist/cjs/interfaces/AdminPermissions.interface.d.ts +53 -0
- package/dist/cjs/interfaces/AdminPermissions.interface.js +7 -0
- package/dist/cjs/services/api/Charts.api.d.ts +2 -0
- package/dist/cjs/services/api/Charts.api.js +22 -0
- package/dist/cjs/services/api/adminPermissions.api.d.ts +2 -0
- package/dist/cjs/services/api/adminPermissions.api.js +20 -0
- package/dist/cjs/services/api/getModel.api.d.ts +1 -1
- package/dist/cjs/services/api/getModel.api.js +1 -2
- package/dist/filters/constants/settings/FILTER_SETTINGS_DEFAULT.js +23 -0
- package/dist/interfaces/AdminPermissions.interface.d.ts +53 -0
- package/dist/interfaces/AdminPermissions.interface.js +4 -0
- package/dist/services/api/Charts.api.d.ts +2 -0
- package/dist/services/api/Charts.api.js +22 -0
- package/dist/services/api/adminPermissions.api.d.ts +2 -0
- package/dist/services/api/adminPermissions.api.js +16 -0
- package/dist/services/api/getModel.api.d.ts +1 -1
- package/dist/services/api/getModel.api.js +1 -2
- package/package.json +2 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
2
|
+
interface IGetChartConfig {
|
|
3
|
+
qv_token?: string;
|
|
4
|
+
api_key?: string;
|
|
5
|
+
app_id?: string;
|
|
6
|
+
user_id?: string;
|
|
7
|
+
domain?: string;
|
|
8
|
+
timezone?: any;
|
|
9
|
+
qrvey_id?: string;
|
|
10
|
+
i18n?: any;
|
|
11
|
+
chart_id?: string;
|
|
12
|
+
lang?: string;
|
|
13
|
+
translated?: boolean;
|
|
14
|
+
headers?: {
|
|
15
|
+
"temporal-tokens"?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface IChartStoreState {
|
|
19
|
+
chart: any;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: any;
|
|
22
|
+
}
|
|
23
|
+
export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreState, IGetChartConfig> {
|
|
24
|
+
static getInstance(): ChartCacheManager;
|
|
25
|
+
protected getConfigPropertyName(): keyof IGetChartConfig;
|
|
26
|
+
protected getStorePropertyName(): keyof IChartStoreState;
|
|
27
|
+
protected buildStoreId({ chart_id, translated }: IGetChartConfig): string;
|
|
28
|
+
protected createStore(): {
|
|
29
|
+
state: IChartStoreState;
|
|
30
|
+
onChange: OnChangeType;
|
|
31
|
+
};
|
|
32
|
+
protected fetchDataAndUpdateStore(state: IChartStoreState, config: IGetChartConfig): void;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
import { QrveyCacheManager } from "./cache-manager";
|
|
3
|
+
import ChartsApi from "../services/api/Charts.api";
|
|
4
|
+
import { isEmpty } from "../general/mix/isEmpty";
|
|
5
|
+
export class ChartCacheManager extends QrveyCacheManager {
|
|
6
|
+
static getInstance() {
|
|
7
|
+
if (!window.chartCacheManager) {
|
|
8
|
+
window.chartCacheManager = new ChartCacheManager();
|
|
9
|
+
}
|
|
10
|
+
return window.chartCacheManager;
|
|
11
|
+
}
|
|
12
|
+
getConfigPropertyName() {
|
|
13
|
+
return "chart_id";
|
|
14
|
+
}
|
|
15
|
+
getStorePropertyName() {
|
|
16
|
+
return "chart";
|
|
17
|
+
}
|
|
18
|
+
buildStoreId({ chart_id, translated }) {
|
|
19
|
+
const translate = isEmpty(translated) ? true : translated;
|
|
20
|
+
return `${chart_id}-${translate ? "translated" : ""}`;
|
|
21
|
+
}
|
|
22
|
+
createStore() {
|
|
23
|
+
return createStore({
|
|
24
|
+
chart: null,
|
|
25
|
+
loading: true,
|
|
26
|
+
error: null,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
fetchDataAndUpdateStore(state, config) {
|
|
30
|
+
const api = new ChartsApi(config);
|
|
31
|
+
api
|
|
32
|
+
.getChart(config)
|
|
33
|
+
.then((chart) => {
|
|
34
|
+
state.chart = chart;
|
|
35
|
+
state.error = null;
|
|
36
|
+
state.loading = false;
|
|
37
|
+
})
|
|
38
|
+
.catch((e) => {
|
|
39
|
+
state.error = e;
|
|
40
|
+
state.loading = false;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}>;
|
|
7
|
+
protected abstract getConfigPropertyName(): keyof TConfig;
|
|
8
|
+
protected abstract getStorePropertyName(): keyof TStoreState;
|
|
9
|
+
protected abstract buildStoreId(config: TConfig): string;
|
|
10
|
+
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): void;
|
|
11
|
+
protected abstract createStore(): {
|
|
12
|
+
state: TStoreState;
|
|
13
|
+
onChange: OnChangeType;
|
|
14
|
+
};
|
|
15
|
+
protected getStoreFromPromise(config: TConfig, id: string): Promise<{
|
|
16
|
+
state: TStoreState;
|
|
17
|
+
onChange: OnChangeType;
|
|
18
|
+
}>;
|
|
19
|
+
getStore(config: TConfig): {
|
|
20
|
+
state: TStoreState;
|
|
21
|
+
onChange: OnChangeType;
|
|
22
|
+
};
|
|
23
|
+
getMultipleStores(config: TConfig, ids: string[]): Promise<{
|
|
24
|
+
state: TStoreState;
|
|
25
|
+
onChange: OnChangeType;
|
|
26
|
+
}[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class QrveyCacheManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.stores = new Map();
|
|
4
|
+
}
|
|
5
|
+
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();
|
|
18
|
+
resolve(store);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
getStore(config) {
|
|
25
|
+
const storeId = this.buildStoreId(config);
|
|
26
|
+
const store = this.stores.get(storeId);
|
|
27
|
+
if (store) {
|
|
28
|
+
return store;
|
|
29
|
+
}
|
|
30
|
+
const { state, onChange } = store !== null && store !== void 0 ? store : this.createStore();
|
|
31
|
+
this.stores.set(storeId, { state, onChange });
|
|
32
|
+
this.fetchDataAndUpdateStore(state, config);
|
|
33
|
+
return { state, onChange };
|
|
34
|
+
}
|
|
35
|
+
getMultipleStores(config, ids) {
|
|
36
|
+
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
37
|
+
return Promise.all(promises);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
2
|
+
import { IModel } from "../qrvey";
|
|
3
|
+
interface IGetModelConfig {
|
|
4
|
+
qv_token?: string;
|
|
5
|
+
api_key?: string;
|
|
6
|
+
app_id?: string;
|
|
7
|
+
user_id?: string;
|
|
8
|
+
domain?: string;
|
|
9
|
+
timezone?: any;
|
|
10
|
+
qrvey_id: string;
|
|
11
|
+
i18n?: any;
|
|
12
|
+
}
|
|
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;
|
|
22
|
+
protected buildStoreId({ qrvey_id }: IGetModelConfig): string;
|
|
23
|
+
protected createStore(): {
|
|
24
|
+
state: IModelStoreState;
|
|
25
|
+
onChange: OnChangeType;
|
|
26
|
+
};
|
|
27
|
+
protected fetchDataAndUpdateStore(state: IModelStoreState, config: IGetModelConfig): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
import { QrveyCacheManager } from "./cache-manager";
|
|
3
|
+
import { getModel } from "../services/api/getModel.api";
|
|
4
|
+
export class ModelCacheManager extends QrveyCacheManager {
|
|
5
|
+
static getInstance() {
|
|
6
|
+
if (!window.modelCacheManager) {
|
|
7
|
+
window.modelCacheManager = new ModelCacheManager();
|
|
8
|
+
}
|
|
9
|
+
return window.modelCacheManager;
|
|
10
|
+
}
|
|
11
|
+
getConfigPropertyName() {
|
|
12
|
+
return "qrvey_id";
|
|
13
|
+
}
|
|
14
|
+
getStorePropertyName() {
|
|
15
|
+
return "model";
|
|
16
|
+
}
|
|
17
|
+
buildStoreId({ qrvey_id }) {
|
|
18
|
+
return `${qrvey_id}`;
|
|
19
|
+
}
|
|
20
|
+
createStore() {
|
|
21
|
+
return createStore({
|
|
22
|
+
model: null,
|
|
23
|
+
loading: true,
|
|
24
|
+
error: null,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
fetchDataAndUpdateStore(state, config) {
|
|
28
|
+
const includeInfo = ["bucketsInfo", "formulaInfo"];
|
|
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;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AdminPermissions } from "../interfaces/AdminPermissions.interface";
|
|
2
|
+
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
3
|
+
export interface IGetPermissionsConfig {
|
|
4
|
+
qv_token?: string;
|
|
5
|
+
api_key?: string;
|
|
6
|
+
app_id?: string;
|
|
7
|
+
user_id?: string;
|
|
8
|
+
domain?: string;
|
|
9
|
+
}
|
|
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;
|
|
19
|
+
protected buildStoreId({ user_id }: IGetPermissionsConfig): string;
|
|
20
|
+
protected createStore(): {
|
|
21
|
+
state: IPermissionsStoreState;
|
|
22
|
+
onChange: OnChangeType;
|
|
23
|
+
};
|
|
24
|
+
protected fetchDataAndUpdateStore(state: IPermissionsStoreState, config: IGetPermissionsConfig): void;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
import { QrveyCacheManager } from "./cache-manager";
|
|
3
|
+
import { getAdminPermissions } from "../services/api/adminPermissions.api";
|
|
4
|
+
export class PermissionsCacheManager extends QrveyCacheManager {
|
|
5
|
+
static getInstance() {
|
|
6
|
+
if (!window.permissionsCacheManager) {
|
|
7
|
+
window.permissionsCacheManager = new PermissionsCacheManager();
|
|
8
|
+
}
|
|
9
|
+
return window.permissionsCacheManager;
|
|
10
|
+
}
|
|
11
|
+
getConfigPropertyName() {
|
|
12
|
+
return "user_id";
|
|
13
|
+
}
|
|
14
|
+
getStorePropertyName() {
|
|
15
|
+
return "permissions";
|
|
16
|
+
}
|
|
17
|
+
buildStoreId({ user_id }) {
|
|
18
|
+
return `${user_id}`;
|
|
19
|
+
}
|
|
20
|
+
createStore() {
|
|
21
|
+
return createStore({
|
|
22
|
+
permissions: null,
|
|
23
|
+
loading: true,
|
|
24
|
+
error: null,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
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;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
2
|
+
interface IGetChartConfig {
|
|
3
|
+
qv_token?: string;
|
|
4
|
+
api_key?: string;
|
|
5
|
+
app_id?: string;
|
|
6
|
+
user_id?: string;
|
|
7
|
+
domain?: string;
|
|
8
|
+
timezone?: any;
|
|
9
|
+
qrvey_id?: string;
|
|
10
|
+
i18n?: any;
|
|
11
|
+
chart_id?: string;
|
|
12
|
+
lang?: string;
|
|
13
|
+
translated?: boolean;
|
|
14
|
+
headers?: {
|
|
15
|
+
"temporal-tokens"?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface IChartStoreState {
|
|
19
|
+
chart: any;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: any;
|
|
22
|
+
}
|
|
23
|
+
export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreState, IGetChartConfig> {
|
|
24
|
+
static getInstance(): ChartCacheManager;
|
|
25
|
+
protected getConfigPropertyName(): keyof IGetChartConfig;
|
|
26
|
+
protected getStorePropertyName(): keyof IChartStoreState;
|
|
27
|
+
protected buildStoreId({ chart_id, translated }: IGetChartConfig): string;
|
|
28
|
+
protected createStore(): {
|
|
29
|
+
state: IChartStoreState;
|
|
30
|
+
onChange: OnChangeType;
|
|
31
|
+
};
|
|
32
|
+
protected fetchDataAndUpdateStore(state: IChartStoreState, config: IGetChartConfig): void;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ChartCacheManager = void 0;
|
|
7
|
+
const store_1 = require("@stencil/store");
|
|
8
|
+
const cache_manager_1 = require("./cache-manager");
|
|
9
|
+
const Charts_api_1 = __importDefault(require("../services/api/Charts.api"));
|
|
10
|
+
const isEmpty_1 = require("../general/mix/isEmpty");
|
|
11
|
+
class ChartCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
12
|
+
static getInstance() {
|
|
13
|
+
if (!window.chartCacheManager) {
|
|
14
|
+
window.chartCacheManager = new ChartCacheManager();
|
|
15
|
+
}
|
|
16
|
+
return window.chartCacheManager;
|
|
17
|
+
}
|
|
18
|
+
getConfigPropertyName() {
|
|
19
|
+
return "chart_id";
|
|
20
|
+
}
|
|
21
|
+
getStorePropertyName() {
|
|
22
|
+
return "chart";
|
|
23
|
+
}
|
|
24
|
+
buildStoreId({ chart_id, translated }) {
|
|
25
|
+
const translate = (0, isEmpty_1.isEmpty)(translated) ? true : translated;
|
|
26
|
+
return `${chart_id}-${translate ? "translated" : ""}`;
|
|
27
|
+
}
|
|
28
|
+
createStore() {
|
|
29
|
+
return (0, store_1.createStore)({
|
|
30
|
+
chart: null,
|
|
31
|
+
loading: true,
|
|
32
|
+
error: null,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
fetchDataAndUpdateStore(state, config) {
|
|
36
|
+
const api = new Charts_api_1.default(config);
|
|
37
|
+
api
|
|
38
|
+
.getChart(config)
|
|
39
|
+
.then((chart) => {
|
|
40
|
+
state.chart = chart;
|
|
41
|
+
state.error = null;
|
|
42
|
+
state.loading = false;
|
|
43
|
+
})
|
|
44
|
+
.catch((e) => {
|
|
45
|
+
state.error = e;
|
|
46
|
+
state.loading = false;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.ChartCacheManager = ChartCacheManager;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}>;
|
|
7
|
+
protected abstract getConfigPropertyName(): keyof TConfig;
|
|
8
|
+
protected abstract getStorePropertyName(): keyof TStoreState;
|
|
9
|
+
protected abstract buildStoreId(config: TConfig): string;
|
|
10
|
+
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): void;
|
|
11
|
+
protected abstract createStore(): {
|
|
12
|
+
state: TStoreState;
|
|
13
|
+
onChange: OnChangeType;
|
|
14
|
+
};
|
|
15
|
+
protected getStoreFromPromise(config: TConfig, id: string): Promise<{
|
|
16
|
+
state: TStoreState;
|
|
17
|
+
onChange: OnChangeType;
|
|
18
|
+
}>;
|
|
19
|
+
getStore(config: TConfig): {
|
|
20
|
+
state: TStoreState;
|
|
21
|
+
onChange: OnChangeType;
|
|
22
|
+
};
|
|
23
|
+
getMultipleStores(config: TConfig, ids: string[]): Promise<{
|
|
24
|
+
state: TStoreState;
|
|
25
|
+
onChange: OnChangeType;
|
|
26
|
+
}[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QrveyCacheManager = void 0;
|
|
4
|
+
class QrveyCacheManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.stores = new Map();
|
|
7
|
+
}
|
|
8
|
+
getStoreFromPromise(config, id) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const configProperty = this.getConfigPropertyName();
|
|
11
|
+
const storeProperty = this.getStorePropertyName();
|
|
12
|
+
const extendedConfig = Object.assign(Object.assign({}, config), { [configProperty]: id });
|
|
13
|
+
const store = this.getStore(extendedConfig);
|
|
14
|
+
if (store.state[storeProperty] !== null) {
|
|
15
|
+
resolve(store);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const unsubscribe = store.onChange(storeProperty, (entity) => {
|
|
19
|
+
if (entity !== null) {
|
|
20
|
+
unsubscribe();
|
|
21
|
+
resolve(store);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getStore(config) {
|
|
28
|
+
const storeId = this.buildStoreId(config);
|
|
29
|
+
const store = this.stores.get(storeId);
|
|
30
|
+
if (store) {
|
|
31
|
+
return store;
|
|
32
|
+
}
|
|
33
|
+
const { state, onChange } = store !== null && store !== void 0 ? store : this.createStore();
|
|
34
|
+
this.stores.set(storeId, { state, onChange });
|
|
35
|
+
this.fetchDataAndUpdateStore(state, config);
|
|
36
|
+
return { state, onChange };
|
|
37
|
+
}
|
|
38
|
+
getMultipleStores(config, ids) {
|
|
39
|
+
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
40
|
+
return Promise.all(promises);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.QrveyCacheManager = QrveyCacheManager;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
2
|
+
import { IModel } from "../qrvey";
|
|
3
|
+
interface IGetModelConfig {
|
|
4
|
+
qv_token?: string;
|
|
5
|
+
api_key?: string;
|
|
6
|
+
app_id?: string;
|
|
7
|
+
user_id?: string;
|
|
8
|
+
domain?: string;
|
|
9
|
+
timezone?: any;
|
|
10
|
+
qrvey_id: string;
|
|
11
|
+
i18n?: any;
|
|
12
|
+
}
|
|
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;
|
|
22
|
+
protected buildStoreId({ qrvey_id }: IGetModelConfig): string;
|
|
23
|
+
protected createStore(): {
|
|
24
|
+
state: IModelStoreState;
|
|
25
|
+
onChange: OnChangeType;
|
|
26
|
+
};
|
|
27
|
+
protected fetchDataAndUpdateStore(state: IModelStoreState, config: IGetModelConfig): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModelCacheManager = void 0;
|
|
4
|
+
const store_1 = require("@stencil/store");
|
|
5
|
+
const cache_manager_1 = require("./cache-manager");
|
|
6
|
+
const getModel_api_1 = require("../services/api/getModel.api");
|
|
7
|
+
class ModelCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
8
|
+
static getInstance() {
|
|
9
|
+
if (!window.modelCacheManager) {
|
|
10
|
+
window.modelCacheManager = new ModelCacheManager();
|
|
11
|
+
}
|
|
12
|
+
return window.modelCacheManager;
|
|
13
|
+
}
|
|
14
|
+
getConfigPropertyName() {
|
|
15
|
+
return "qrvey_id";
|
|
16
|
+
}
|
|
17
|
+
getStorePropertyName() {
|
|
18
|
+
return "model";
|
|
19
|
+
}
|
|
20
|
+
buildStoreId({ qrvey_id }) {
|
|
21
|
+
return `${qrvey_id}`;
|
|
22
|
+
}
|
|
23
|
+
createStore() {
|
|
24
|
+
return (0, store_1.createStore)({
|
|
25
|
+
model: null,
|
|
26
|
+
loading: true,
|
|
27
|
+
error: null,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
fetchDataAndUpdateStore(state, config) {
|
|
31
|
+
const includeInfo = ["bucketsInfo", "formulaInfo"];
|
|
32
|
+
(0, getModel_api_1.getModel)(config, { includeInfo })
|
|
33
|
+
.then((model) => {
|
|
34
|
+
state.model = model;
|
|
35
|
+
state.error = null;
|
|
36
|
+
state.loading = false;
|
|
37
|
+
})
|
|
38
|
+
.catch((e) => {
|
|
39
|
+
state.error = e;
|
|
40
|
+
state.loading = false;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ModelCacheManager = ModelCacheManager;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AdminPermissions } from "../interfaces/AdminPermissions.interface";
|
|
2
|
+
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
3
|
+
export interface IGetPermissionsConfig {
|
|
4
|
+
qv_token?: string;
|
|
5
|
+
api_key?: string;
|
|
6
|
+
app_id?: string;
|
|
7
|
+
user_id?: string;
|
|
8
|
+
domain?: string;
|
|
9
|
+
}
|
|
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;
|
|
19
|
+
protected buildStoreId({ user_id }: IGetPermissionsConfig): string;
|
|
20
|
+
protected createStore(): {
|
|
21
|
+
state: IPermissionsStoreState;
|
|
22
|
+
onChange: OnChangeType;
|
|
23
|
+
};
|
|
24
|
+
protected fetchDataAndUpdateStore(state: IPermissionsStoreState, config: IGetPermissionsConfig): void;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionsCacheManager = void 0;
|
|
4
|
+
const store_1 = require("@stencil/store");
|
|
5
|
+
const cache_manager_1 = require("./cache-manager");
|
|
6
|
+
const adminPermissions_api_1 = require("../services/api/adminPermissions.api");
|
|
7
|
+
class PermissionsCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
8
|
+
static getInstance() {
|
|
9
|
+
if (!window.permissionsCacheManager) {
|
|
10
|
+
window.permissionsCacheManager = new PermissionsCacheManager();
|
|
11
|
+
}
|
|
12
|
+
return window.permissionsCacheManager;
|
|
13
|
+
}
|
|
14
|
+
getConfigPropertyName() {
|
|
15
|
+
return "user_id";
|
|
16
|
+
}
|
|
17
|
+
getStorePropertyName() {
|
|
18
|
+
return "permissions";
|
|
19
|
+
}
|
|
20
|
+
buildStoreId({ user_id }) {
|
|
21
|
+
return `${user_id}`;
|
|
22
|
+
}
|
|
23
|
+
createStore() {
|
|
24
|
+
return (0, store_1.createStore)({
|
|
25
|
+
permissions: null,
|
|
26
|
+
loading: true,
|
|
27
|
+
error: null,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
fetchDataAndUpdateStore(state, config) {
|
|
31
|
+
(0, adminPermissions_api_1.getAdminPermissions)(config)
|
|
32
|
+
.then((permissions) => {
|
|
33
|
+
state.permissions = permissions;
|
|
34
|
+
state.error = null;
|
|
35
|
+
state.loading = false;
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => {
|
|
38
|
+
state.error = e;
|
|
39
|
+
state.loading = false;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.PermissionsCacheManager = PermissionsCacheManager;
|
|
@@ -235,5 +235,28 @@ exports.FILTER_SETTINGS_DEFAULT = {
|
|
|
235
235
|
label: undefined,
|
|
236
236
|
readonly: false,
|
|
237
237
|
},
|
|
238
|
+
[FILTER_SCOPE_1.FILTER_SCOPE.FLOW]: {
|
|
239
|
+
canCollapse: true,
|
|
240
|
+
collapsed: false,
|
|
241
|
+
color: "#C0C0C0",
|
|
242
|
+
colorized: true,
|
|
243
|
+
colorPickerDisplayed: true,
|
|
244
|
+
displayed: true,
|
|
245
|
+
enabled: true,
|
|
246
|
+
icon: "ico_workflows",
|
|
247
|
+
iconsDisplayed: true,
|
|
248
|
+
interaction: {
|
|
249
|
+
createDisplayed: true,
|
|
250
|
+
createEnabled: true,
|
|
251
|
+
deleteDisplayed: true,
|
|
252
|
+
deleteEnabled: true,
|
|
253
|
+
editDisplayed: true,
|
|
254
|
+
editEnabled: true,
|
|
255
|
+
enableDisplayed: true,
|
|
256
|
+
enableEnabled: true,
|
|
257
|
+
},
|
|
258
|
+
label: undefined,
|
|
259
|
+
readonly: false,
|
|
260
|
+
},
|
|
238
261
|
},
|
|
239
262
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type QrveyLicense = "TEAM" | "EXPRESS";
|
|
2
|
+
export declare const QRVEY_LICENSE: {
|
|
3
|
+
[key in QrveyLicense]: QrveyLicense;
|
|
4
|
+
};
|
|
5
|
+
export interface AdminPermissions {
|
|
6
|
+
publishing: Publishing;
|
|
7
|
+
userManagement: UserManagement;
|
|
8
|
+
pageBuilderSection: boolean;
|
|
9
|
+
licenseType: QrveyLicense;
|
|
10
|
+
settings: AdminSettings;
|
|
11
|
+
datasets: Datasets;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Internal Interfaces
|
|
15
|
+
*/
|
|
16
|
+
interface Datasets {
|
|
17
|
+
datasetsSection: boolean;
|
|
18
|
+
managedDataset: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface Publishing {
|
|
21
|
+
navigation: boolean;
|
|
22
|
+
publishApplication: boolean;
|
|
23
|
+
publishSection: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface UserManagement {
|
|
26
|
+
generalSection: GeneralSection;
|
|
27
|
+
users: Users;
|
|
28
|
+
permissions: Permissions;
|
|
29
|
+
usersSection: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface GeneralSection {
|
|
32
|
+
authenticationUsers: boolean;
|
|
33
|
+
groups: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface Users {
|
|
36
|
+
add: boolean;
|
|
37
|
+
delete: boolean;
|
|
38
|
+
edit: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface Permissions {
|
|
41
|
+
data: boolean;
|
|
42
|
+
pages: boolean;
|
|
43
|
+
actions: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type AdminSettings = {
|
|
46
|
+
downloadManager?: boolean;
|
|
47
|
+
embedLink?: boolean;
|
|
48
|
+
exporting?: boolean;
|
|
49
|
+
settingsSection?: boolean;
|
|
50
|
+
schedulingExport?: boolean;
|
|
51
|
+
subscribingOtherUsers?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -12,4 +12,6 @@ export default class ChartsApi {
|
|
|
12
12
|
createSignal(): AbortSignal;
|
|
13
13
|
getResults(data: any, ignoreSignal?: boolean, newEndpoint?: boolean): Promise<any>;
|
|
14
14
|
getResultsPagination(data: any, ignoreSignal?: boolean): Promise<any>;
|
|
15
|
+
getChart(config: any): Promise<any>;
|
|
16
|
+
static transformDataByTimezone(data: any, config: any): any;
|
|
15
17
|
}
|
|
@@ -4,6 +4,8 @@ const Request_1 = require("../helpers/Request");
|
|
|
4
4
|
const CHART_ENDPOINT_1 = require("../constants/CHART_ENDPOINT");
|
|
5
5
|
const UCHART_ENDPOINT_1 = require("../constants/UCHART_ENDPOINT");
|
|
6
6
|
const UCHART_PAGINATION_ENDPOINT_1 = require("../constants/UCHART_PAGINATION_ENDPOINT");
|
|
7
|
+
const general_1 = require("../../general");
|
|
8
|
+
const filters_1 = require("../../filters");
|
|
7
9
|
class ChartsApi {
|
|
8
10
|
constructor(config) {
|
|
9
11
|
this.config = config;
|
|
@@ -30,5 +32,25 @@ class ChartsApi {
|
|
|
30
32
|
}
|
|
31
33
|
return Request_1.Request.post(Object.assign(Object.assign({}, this.config), { endpoint: UCHART_PAGINATION_ENDPOINT_1.UCHART_PAGINATION_ENDPOINT, signal }), "", data);
|
|
32
34
|
}
|
|
35
|
+
getChart(config) {
|
|
36
|
+
const translated = (0, general_1.isEmpty)(config.translated) ? true : config.translated;
|
|
37
|
+
const lang = (0, general_1._get)(this.config, "lang");
|
|
38
|
+
const timezone = (0, general_1._get)(this.config, "timezone");
|
|
39
|
+
const connector = lang ? "&" : "?";
|
|
40
|
+
let params = lang ? `?lang=${lang}` : "";
|
|
41
|
+
params += `${connector}translated=${translated}`;
|
|
42
|
+
params += (timezone === null || timezone === void 0 ? void 0 : timezone.offset) ? `&tzoffset=${timezone.offset}` : "";
|
|
43
|
+
return Request_1.Request.get(Object.assign(Object.assign({}, this.config), config), "/:chart_id" + params).then((response) => ChartsApi.transformDataByTimezone(response, this.config));
|
|
44
|
+
}
|
|
45
|
+
static transformDataByTimezone(data, config) {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
if (!(0, general_1.isEmpty)((_b = (_a = data === null || data === void 0 ? void 0 : data.v2) === null || _a === void 0 ? void 0 : _a.defaultFilters) === null || _b === void 0 ? void 0 : _b.data)) {
|
|
48
|
+
data.v2.defaultFilters = Object.assign(Object.assign({}, data.v2.defaultFilters), { data: (0, filters_1.getFiltersByTimezone)(data.v2.defaultFilters.data, config.timezone) });
|
|
49
|
+
}
|
|
50
|
+
if (!(0, general_1.isEmpty)((_c = data === null || data === void 0 ? void 0 : data.defaultFilters) === null || _c === void 0 ? void 0 : _c.data)) {
|
|
51
|
+
data.defaultFilters = Object.assign(Object.assign({}, data.defaultFilters), { data: (0, filters_1.getFiltersByTimezone)(data.defaultFilters.data, config.timezone) });
|
|
52
|
+
}
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
33
55
|
}
|
|
34
56
|
exports.default = ChartsApi;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAdminPermissions = void 0;
|
|
4
|
+
const Request_1 = require("../helpers/Request");
|
|
5
|
+
const ADMIN_PERMISSIONS_ENDPOINT = {
|
|
6
|
+
admin: true,
|
|
7
|
+
devApi: false,
|
|
8
|
+
uri: "/permissions",
|
|
9
|
+
version: 5,
|
|
10
|
+
};
|
|
11
|
+
function getAdminPermissions(config) {
|
|
12
|
+
return Request_1.Request.get({
|
|
13
|
+
apiKey: config.api_key,
|
|
14
|
+
domain: config.domain,
|
|
15
|
+
endpoint: ADMIN_PERMISSIONS_ENDPOINT,
|
|
16
|
+
qvToken: config.qv_token,
|
|
17
|
+
userId: config.user_id,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.getAdminPermissions = getAdminPermissions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getModel(config: any, params?: any): Promise<
|
|
1
|
+
export declare function getModel(config: any, params?: any): Promise<any>;
|
|
@@ -4,10 +4,9 @@ exports.getModel = void 0;
|
|
|
4
4
|
const Request_1 = require("../helpers/Request");
|
|
5
5
|
const localization_1 = require("../../format/localization");
|
|
6
6
|
const MODEL_ENDPOINT_1 = require("../constants/MODEL_ENDPOINT");
|
|
7
|
-
const BModelToUIModel_adapter_1 = require("../adapters/BModelToUIModel.adapter");
|
|
8
7
|
function getModel(config, params) {
|
|
9
8
|
const lang = (0, localization_1.chooseLang)(config);
|
|
10
9
|
const data = { lang, logic: config.logic || [] };
|
|
11
|
-
return Request_1.Request.post(Object.assign(Object.assign({}, config), { endpoint: MODEL_ENDPOINT_1.ANALYTIQ_ENDPOINT }), "", data, Object.assign(Object.assign({}, params), { lang }))
|
|
10
|
+
return Request_1.Request.post(Object.assign(Object.assign({}, config), { endpoint: MODEL_ENDPOINT_1.ANALYTIQ_ENDPOINT }), "", data, Object.assign(Object.assign({}, params), { lang }));
|
|
12
11
|
}
|
|
13
12
|
exports.getModel = getModel;
|
|
@@ -232,5 +232,28 @@ export const FILTER_SETTINGS_DEFAULT = {
|
|
|
232
232
|
label: undefined,
|
|
233
233
|
readonly: false,
|
|
234
234
|
},
|
|
235
|
+
[FILTER_SCOPE.FLOW]: {
|
|
236
|
+
canCollapse: true,
|
|
237
|
+
collapsed: false,
|
|
238
|
+
color: "#C0C0C0",
|
|
239
|
+
colorized: true,
|
|
240
|
+
colorPickerDisplayed: true,
|
|
241
|
+
displayed: true,
|
|
242
|
+
enabled: true,
|
|
243
|
+
icon: "ico_workflows",
|
|
244
|
+
iconsDisplayed: true,
|
|
245
|
+
interaction: {
|
|
246
|
+
createDisplayed: true,
|
|
247
|
+
createEnabled: true,
|
|
248
|
+
deleteDisplayed: true,
|
|
249
|
+
deleteEnabled: true,
|
|
250
|
+
editDisplayed: true,
|
|
251
|
+
editEnabled: true,
|
|
252
|
+
enableDisplayed: true,
|
|
253
|
+
enableEnabled: true,
|
|
254
|
+
},
|
|
255
|
+
label: undefined,
|
|
256
|
+
readonly: false,
|
|
257
|
+
},
|
|
235
258
|
},
|
|
236
259
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type QrveyLicense = "TEAM" | "EXPRESS";
|
|
2
|
+
export declare const QRVEY_LICENSE: {
|
|
3
|
+
[key in QrveyLicense]: QrveyLicense;
|
|
4
|
+
};
|
|
5
|
+
export interface AdminPermissions {
|
|
6
|
+
publishing: Publishing;
|
|
7
|
+
userManagement: UserManagement;
|
|
8
|
+
pageBuilderSection: boolean;
|
|
9
|
+
licenseType: QrveyLicense;
|
|
10
|
+
settings: AdminSettings;
|
|
11
|
+
datasets: Datasets;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Internal Interfaces
|
|
15
|
+
*/
|
|
16
|
+
interface Datasets {
|
|
17
|
+
datasetsSection: boolean;
|
|
18
|
+
managedDataset: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface Publishing {
|
|
21
|
+
navigation: boolean;
|
|
22
|
+
publishApplication: boolean;
|
|
23
|
+
publishSection: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface UserManagement {
|
|
26
|
+
generalSection: GeneralSection;
|
|
27
|
+
users: Users;
|
|
28
|
+
permissions: Permissions;
|
|
29
|
+
usersSection: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface GeneralSection {
|
|
32
|
+
authenticationUsers: boolean;
|
|
33
|
+
groups: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface Users {
|
|
36
|
+
add: boolean;
|
|
37
|
+
delete: boolean;
|
|
38
|
+
edit: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface Permissions {
|
|
41
|
+
data: boolean;
|
|
42
|
+
pages: boolean;
|
|
43
|
+
actions: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type AdminSettings = {
|
|
46
|
+
downloadManager?: boolean;
|
|
47
|
+
embedLink?: boolean;
|
|
48
|
+
exporting?: boolean;
|
|
49
|
+
settingsSection?: boolean;
|
|
50
|
+
schedulingExport?: boolean;
|
|
51
|
+
subscribingOtherUsers?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -12,4 +12,6 @@ export default class ChartsApi {
|
|
|
12
12
|
createSignal(): AbortSignal;
|
|
13
13
|
getResults(data: any, ignoreSignal?: boolean, newEndpoint?: boolean): Promise<any>;
|
|
14
14
|
getResultsPagination(data: any, ignoreSignal?: boolean): Promise<any>;
|
|
15
|
+
getChart(config: any): Promise<any>;
|
|
16
|
+
static transformDataByTimezone(data: any, config: any): any;
|
|
15
17
|
}
|
|
@@ -2,6 +2,8 @@ import { Request } from "../helpers/Request";
|
|
|
2
2
|
import { CHART_ENDPOINT } from "../constants/CHART_ENDPOINT";
|
|
3
3
|
import { UCHART_ENDPOINT } from "../constants/UCHART_ENDPOINT";
|
|
4
4
|
import { UCHART_PAGINATION_ENDPOINT } from "../constants/UCHART_PAGINATION_ENDPOINT";
|
|
5
|
+
import { _get, isEmpty } from "../../general";
|
|
6
|
+
import { getFiltersByTimezone } from "../../filters";
|
|
5
7
|
export default class ChartsApi {
|
|
6
8
|
constructor(config) {
|
|
7
9
|
this.config = config;
|
|
@@ -28,4 +30,24 @@ export default class ChartsApi {
|
|
|
28
30
|
}
|
|
29
31
|
return Request.post(Object.assign(Object.assign({}, this.config), { endpoint: UCHART_PAGINATION_ENDPOINT, signal }), "", data);
|
|
30
32
|
}
|
|
33
|
+
getChart(config) {
|
|
34
|
+
const translated = isEmpty(config.translated) ? true : config.translated;
|
|
35
|
+
const lang = _get(this.config, "lang");
|
|
36
|
+
const timezone = _get(this.config, "timezone");
|
|
37
|
+
const connector = lang ? "&" : "?";
|
|
38
|
+
let params = lang ? `?lang=${lang}` : "";
|
|
39
|
+
params += `${connector}translated=${translated}`;
|
|
40
|
+
params += (timezone === null || timezone === void 0 ? void 0 : timezone.offset) ? `&tzoffset=${timezone.offset}` : "";
|
|
41
|
+
return Request.get(Object.assign(Object.assign({}, this.config), config), "/:chart_id" + params).then((response) => ChartsApi.transformDataByTimezone(response, this.config));
|
|
42
|
+
}
|
|
43
|
+
static transformDataByTimezone(data, config) {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
if (!isEmpty((_b = (_a = data === null || data === void 0 ? void 0 : data.v2) === null || _a === void 0 ? void 0 : _a.defaultFilters) === null || _b === void 0 ? void 0 : _b.data)) {
|
|
46
|
+
data.v2.defaultFilters = Object.assign(Object.assign({}, data.v2.defaultFilters), { data: getFiltersByTimezone(data.v2.defaultFilters.data, config.timezone) });
|
|
47
|
+
}
|
|
48
|
+
if (!isEmpty((_c = data === null || data === void 0 ? void 0 : data.defaultFilters) === null || _c === void 0 ? void 0 : _c.data)) {
|
|
49
|
+
data.defaultFilters = Object.assign(Object.assign({}, data.defaultFilters), { data: getFiltersByTimezone(data.defaultFilters.data, config.timezone) });
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
31
53
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Request } from "../helpers/Request";
|
|
2
|
+
const ADMIN_PERMISSIONS_ENDPOINT = {
|
|
3
|
+
admin: true,
|
|
4
|
+
devApi: false,
|
|
5
|
+
uri: "/permissions",
|
|
6
|
+
version: 5,
|
|
7
|
+
};
|
|
8
|
+
export function getAdminPermissions(config) {
|
|
9
|
+
return Request.get({
|
|
10
|
+
apiKey: config.api_key,
|
|
11
|
+
domain: config.domain,
|
|
12
|
+
endpoint: ADMIN_PERMISSIONS_ENDPOINT,
|
|
13
|
+
qvToken: config.qv_token,
|
|
14
|
+
userId: config.user_id,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getModel(config: any, params?: any): Promise<
|
|
1
|
+
export declare function getModel(config: any, params?: any): Promise<any>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Request } from "../helpers/Request";
|
|
2
2
|
import { chooseLang } from "../../format/localization";
|
|
3
3
|
import { ANALYTIQ_ENDPOINT } from "../constants/MODEL_ENDPOINT";
|
|
4
|
-
import { BModelToUIModel } from "../adapters/BModelToUIModel.adapter";
|
|
5
4
|
export function getModel(config, params) {
|
|
6
5
|
const lang = chooseLang(config);
|
|
7
6
|
const data = { lang, logic: config.logic || [] };
|
|
8
|
-
return Request.post(Object.assign(Object.assign({}, config), { endpoint: ANALYTIQ_ENDPOINT }), "", data, Object.assign(Object.assign({}, params), { lang }))
|
|
7
|
+
return Request.post(Object.assign(Object.assign({}, config), { endpoint: ANALYTIQ_ENDPOINT }), "", data, Object.assign(Object.assign({}, params), { lang }));
|
|
9
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qrvey/utils",
|
|
3
|
-
"version": "1.13.0-
|
|
3
|
+
"version": "1.13.0-5.performance.0",
|
|
4
4
|
"description": "Helper, Utils for all Qrvey Projects",
|
|
5
5
|
"homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"typescript": "5.3.3"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@stencil/store": "2.0.13",
|
|
50
51
|
"d3-format": "2.0.0",
|
|
51
52
|
"dayjs": "1.11.10",
|
|
52
53
|
"i18next": "23.7.16"
|