@qrvey/utils 1.18.17 → 1.18.18-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/README.md +2 -2
- package/dist/cache-managers/cache-application-null-handling-manager.d.ts +13 -0
- package/dist/cache-managers/cache-application-null-handling-manager.js +74 -0
- package/dist/cache-managers/clean-cache-managers.js +3 -0
- package/dist/cache-managers/index.d.ts +1 -0
- package/dist/cache-managers/index.js +1 -0
- package/dist/cjs/cache-managers/cache-application-null-handling-manager.js +78 -0
- package/dist/cjs/cache-managers/clean-cache-managers.js +3 -0
- package/dist/cjs/cache-managers/index.js +1 -0
- package/dist/cjs/interfaces/ApplicationNullHandling.Interface.js +2 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/services/api/applicationNullHandling.api.js +28 -0
- package/dist/cjs/services/api/index.js +1 -0
- package/dist/cjs/services/constants/APPLICATION_NULL_HANDLING.js +16 -0
- package/dist/interfaces/ApplicationNullHandling.Interface.d.ts +39 -0
- package/dist/interfaces/ApplicationNullHandling.Interface.js +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/services/api/applicationNullHandling.api.d.ts +2 -0
- package/dist/services/api/applicationNullHandling.api.js +25 -0
- package/dist/services/api/index.d.ts +1 -0
- package/dist/services/api/index.js +1 -0
- package/dist/services/constants/APPLICATION_NULL_HANDLING.d.ts +7 -0
- package/dist/services/constants/APPLICATION_NULL_HANDLING.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.
|
|
1
|
+
# [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.18-0*
|
|
2
2
|
|
|
3
3
|
> Helper, Utils for all Qrvey Projects
|
|
4
4
|
|
|
@@ -55,7 +55,7 @@ const { formatDate } = require("@qrvey/utils/format/format");
|
|
|
55
55
|
|
|
56
56
|
| Module | Description | Subpath import | API docs |
|
|
57
57
|
| ------ | ----------- | -------------- | -------- |
|
|
58
|
-
| `cache-managers` | Managers for caching chart, metric, model, theme, platform-config and permissions data. Provides a centralised in-memory caching layer used across Qrvey widgets. | `@qrvey/utils/cache-managers/index` | [docs](docs/cache-managers/index.md) |
|
|
58
|
+
| `cache-managers` | Managers for caching chart, metric, model, theme, platform-config, application null-handling and permissions data. Provides a centralised in-memory caching layer used across Qrvey widgets. | `@qrvey/utils/cache-managers/index` | [docs](docs/cache-managers/index.md) |
|
|
59
59
|
| `charts` | Constants, interfaces, adapters and helpers for chart types, aggregations, request adapters and chart configuration objects. | `@qrvey/utils/charts/index` | [docs](docs/charts/index.md) |
|
|
60
60
|
| `column_format` | Helpers and constants for column display formatting: string formats, date groups, duration parts, chart groups, shelf types and table types. | `@qrvey/utils/column_format/index` | [docs](docs/column_format/index.md) |
|
|
61
61
|
| `columns` | Interfaces, constants and helpers for dataset column definitions, compound columns and column property descriptors. | `@qrvey/utils/columns/index` | [docs](docs/columns/index.md) |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QrveyCacheManager } from "./cache-manager";
|
|
2
|
+
import { ApplicationNullHandlingStore, IApplicationNullHandlingConfig, IApplicationNullHandlingStoreState } from "../interfaces/ApplicationNullHandling.Interface";
|
|
3
|
+
export declare class ApplicationNullHandlingCacheManager extends QrveyCacheManager<IApplicationNullHandlingStoreState, IApplicationNullHandlingConfig> {
|
|
4
|
+
private readonly reads;
|
|
5
|
+
static getInstance(): ApplicationNullHandlingCacheManager;
|
|
6
|
+
getStore(config: IApplicationNullHandlingConfig): Promise<ApplicationNullHandlingStore>;
|
|
7
|
+
getStoreFromPromise(config: IApplicationNullHandlingConfig, id?: string): Promise<ApplicationNullHandlingStore>;
|
|
8
|
+
protected getConfigEntityId(): keyof IApplicationNullHandlingConfig;
|
|
9
|
+
protected buildStoreId(config: IApplicationNullHandlingConfig): string;
|
|
10
|
+
protected fetchDataAndUpdateStore(state: IApplicationNullHandlingStoreState, config: IApplicationNullHandlingConfig): Promise<void>;
|
|
11
|
+
private readStore;
|
|
12
|
+
private fallback;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { QrveyCacheManager } from "./cache-manager";
|
|
2
|
+
import { getApplicationNullHandling } from "../services/api/applicationNullHandling.api";
|
|
3
|
+
import { APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS, APPLICATION_NULL_HANDLING_FALLBACK, APPLICATION_NULL_HANDLING_MANAGER_KEY, } from "../services/constants/APPLICATION_NULL_HANDLING";
|
|
4
|
+
export class ApplicationNullHandlingCacheManager extends QrveyCacheManager {
|
|
5
|
+
reads = new Map();
|
|
6
|
+
static getInstance() {
|
|
7
|
+
const host = window;
|
|
8
|
+
const existing = host[APPLICATION_NULL_HANDLING_MANAGER_KEY];
|
|
9
|
+
if (existing)
|
|
10
|
+
return existing;
|
|
11
|
+
const created = new ApplicationNullHandlingCacheManager();
|
|
12
|
+
host[APPLICATION_NULL_HANDLING_MANAGER_KEY] = created;
|
|
13
|
+
return created;
|
|
14
|
+
}
|
|
15
|
+
getStore(config) {
|
|
16
|
+
if (!config.qv_token && !config.api_key) {
|
|
17
|
+
return this.createStore({
|
|
18
|
+
entity: this.fallback(),
|
|
19
|
+
error: false,
|
|
20
|
+
expiresAt: 0,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const storeId = this.buildStoreId(config);
|
|
24
|
+
const pending = this.reads.get(storeId);
|
|
25
|
+
if (pending)
|
|
26
|
+
return pending;
|
|
27
|
+
const read = this.readStore(storeId, config).finally(() => this.reads.delete(storeId));
|
|
28
|
+
this.reads.set(storeId, read);
|
|
29
|
+
return read;
|
|
30
|
+
}
|
|
31
|
+
getStoreFromPromise(config, id) {
|
|
32
|
+
return this.getStore(id === undefined ? config : { ...config, app_id: id });
|
|
33
|
+
}
|
|
34
|
+
getConfigEntityId() {
|
|
35
|
+
return "app_id";
|
|
36
|
+
}
|
|
37
|
+
buildStoreId(config) {
|
|
38
|
+
const { app_id, qv_token, user_id } = config;
|
|
39
|
+
const pair = `${user_id || "undefined"}:${app_id || "undefined"}`;
|
|
40
|
+
return qv_token && (!user_id || !app_id) ? `${pair}:${qv_token}` : pair;
|
|
41
|
+
}
|
|
42
|
+
async fetchDataAndUpdateStore(state, config) {
|
|
43
|
+
try {
|
|
44
|
+
const response = await getApplicationNullHandling(config);
|
|
45
|
+
state.entity = response.effective;
|
|
46
|
+
state.error = false;
|
|
47
|
+
state.expiresAt = Date.now() + response.maxAgeSeconds * 1000;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.warn(`Null-handling configuration unavailable for user_id ${config.user_id} and app_id ${config.app_id}; using Blank / Ignore for ${APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS} s.`, error);
|
|
51
|
+
state.entity = this.fallback();
|
|
52
|
+
state.error = true;
|
|
53
|
+
state.expiresAt =
|
|
54
|
+
Date.now() + APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS * 1000;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async readStore(storeId, config) {
|
|
58
|
+
const cached = await this.stores.get(storeId);
|
|
59
|
+
if (cached && Date.now() < cached.state.expiresAt)
|
|
60
|
+
return cached;
|
|
61
|
+
const store = cached ?? (await this.createStore({ expiresAt: 0 }));
|
|
62
|
+
await this.fetchDataAndUpdateStore(store.state, config);
|
|
63
|
+
this.stores.set(storeId, store);
|
|
64
|
+
return store;
|
|
65
|
+
}
|
|
66
|
+
fallback() {
|
|
67
|
+
return {
|
|
68
|
+
visualIndicator: {
|
|
69
|
+
...APPLICATION_NULL_HANDLING_FALLBACK.visualIndicator,
|
|
70
|
+
},
|
|
71
|
+
nullHandling: { ...APPLICATION_NULL_HANDLING_FALLBACK.nullHandling },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApplicationNullHandlingCacheManager } from "./cache-application-null-handling-manager";
|
|
1
2
|
import { ChartCacheManager } from "./cache-chart-manager";
|
|
2
3
|
import { MetricCacheManager } from "./cache-metric-manager";
|
|
3
4
|
import { ModelCacheManager } from "./cache-model-manager";
|
|
@@ -17,4 +18,6 @@ export const cleanCacheManagers = async () => {
|
|
|
17
18
|
await themeManager.cleanAllStores();
|
|
18
19
|
const platformConfigManager = PlatformConfigCacheManager.getInstance();
|
|
19
20
|
await platformConfigManager.cleanAllStores();
|
|
21
|
+
const applicationNullHandlingManager = ApplicationNullHandlingCacheManager.getInstance();
|
|
22
|
+
await applicationNullHandlingManager.cleanAllStores();
|
|
20
23
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationNullHandlingCacheManager = void 0;
|
|
4
|
+
const cache_manager_1 = require("./cache-manager");
|
|
5
|
+
const applicationNullHandling_api_1 = require("../services/api/applicationNullHandling.api");
|
|
6
|
+
const APPLICATION_NULL_HANDLING_1 = require("../services/constants/APPLICATION_NULL_HANDLING");
|
|
7
|
+
class ApplicationNullHandlingCacheManager extends cache_manager_1.QrveyCacheManager {
|
|
8
|
+
reads = new Map();
|
|
9
|
+
static getInstance() {
|
|
10
|
+
const host = window;
|
|
11
|
+
const existing = host[APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_MANAGER_KEY];
|
|
12
|
+
if (existing)
|
|
13
|
+
return existing;
|
|
14
|
+
const created = new ApplicationNullHandlingCacheManager();
|
|
15
|
+
host[APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_MANAGER_KEY] = created;
|
|
16
|
+
return created;
|
|
17
|
+
}
|
|
18
|
+
getStore(config) {
|
|
19
|
+
if (!config.qv_token && !config.api_key) {
|
|
20
|
+
return this.createStore({
|
|
21
|
+
entity: this.fallback(),
|
|
22
|
+
error: false,
|
|
23
|
+
expiresAt: 0,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const storeId = this.buildStoreId(config);
|
|
27
|
+
const pending = this.reads.get(storeId);
|
|
28
|
+
if (pending)
|
|
29
|
+
return pending;
|
|
30
|
+
const read = this.readStore(storeId, config).finally(() => this.reads.delete(storeId));
|
|
31
|
+
this.reads.set(storeId, read);
|
|
32
|
+
return read;
|
|
33
|
+
}
|
|
34
|
+
getStoreFromPromise(config, id) {
|
|
35
|
+
return this.getStore(id === undefined ? config : { ...config, app_id: id });
|
|
36
|
+
}
|
|
37
|
+
getConfigEntityId() {
|
|
38
|
+
return "app_id";
|
|
39
|
+
}
|
|
40
|
+
buildStoreId(config) {
|
|
41
|
+
const { app_id, qv_token, user_id } = config;
|
|
42
|
+
const pair = `${user_id || "undefined"}:${app_id || "undefined"}`;
|
|
43
|
+
return qv_token && (!user_id || !app_id) ? `${pair}:${qv_token}` : pair;
|
|
44
|
+
}
|
|
45
|
+
async fetchDataAndUpdateStore(state, config) {
|
|
46
|
+
try {
|
|
47
|
+
const response = await (0, applicationNullHandling_api_1.getApplicationNullHandling)(config);
|
|
48
|
+
state.entity = response.effective;
|
|
49
|
+
state.error = false;
|
|
50
|
+
state.expiresAt = Date.now() + response.maxAgeSeconds * 1000;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.warn(`Null-handling configuration unavailable for user_id ${config.user_id} and app_id ${config.app_id}; using Blank / Ignore for ${APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS} s.`, error);
|
|
54
|
+
state.entity = this.fallback();
|
|
55
|
+
state.error = true;
|
|
56
|
+
state.expiresAt =
|
|
57
|
+
Date.now() + APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS * 1000;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async readStore(storeId, config) {
|
|
61
|
+
const cached = await this.stores.get(storeId);
|
|
62
|
+
if (cached && Date.now() < cached.state.expiresAt)
|
|
63
|
+
return cached;
|
|
64
|
+
const store = cached ?? (await this.createStore({ expiresAt: 0 }));
|
|
65
|
+
await this.fetchDataAndUpdateStore(store.state, config);
|
|
66
|
+
this.stores.set(storeId, store);
|
|
67
|
+
return store;
|
|
68
|
+
}
|
|
69
|
+
fallback() {
|
|
70
|
+
return {
|
|
71
|
+
visualIndicator: {
|
|
72
|
+
...APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_FALLBACK.visualIndicator,
|
|
73
|
+
},
|
|
74
|
+
nullHandling: { ...APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_FALLBACK.nullHandling },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.ApplicationNullHandlingCacheManager = ApplicationNullHandlingCacheManager;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cleanCacheManagers = void 0;
|
|
4
|
+
const cache_application_null_handling_manager_1 = require("./cache-application-null-handling-manager");
|
|
4
5
|
const cache_chart_manager_1 = require("./cache-chart-manager");
|
|
5
6
|
const cache_metric_manager_1 = require("./cache-metric-manager");
|
|
6
7
|
const cache_model_manager_1 = require("./cache-model-manager");
|
|
@@ -20,5 +21,7 @@ const cleanCacheManagers = async () => {
|
|
|
20
21
|
await themeManager.cleanAllStores();
|
|
21
22
|
const platformConfigManager = cache_platform_config_manager_1.PlatformConfigCacheManager.getInstance();
|
|
22
23
|
await platformConfigManager.cleanAllStores();
|
|
24
|
+
const applicationNullHandlingManager = cache_application_null_handling_manager_1.ApplicationNullHandlingCacheManager.getInstance();
|
|
25
|
+
await applicationNullHandlingManager.cleanAllStores();
|
|
23
26
|
};
|
|
24
27
|
exports.cleanCacheManagers = cleanCacheManagers;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./cache-application-null-handling-manager"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./cache-chart-manager"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./cache-manager"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./cache-metric-manager"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./ApplicationNullHandling.Interface"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./Chart.Interface"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./IChartBuilder.Interface"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./general"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getApplicationNullHandling = getApplicationNullHandling;
|
|
4
|
+
const APPLICATION_NULL_HANDLING_1 = require("../constants/APPLICATION_NULL_HANDLING");
|
|
5
|
+
const Request_1 = require("../helpers/Request");
|
|
6
|
+
function getApplicationNullHandling(config) {
|
|
7
|
+
const controller = new AbortController();
|
|
8
|
+
const requestConfig = {
|
|
9
|
+
apiKey: config.api_key,
|
|
10
|
+
app_id: config.app_id || "undefined",
|
|
11
|
+
domain: config.domain,
|
|
12
|
+
endpoint: APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_ENDPOINT,
|
|
13
|
+
qvToken: config.qv_token,
|
|
14
|
+
signal: controller.signal,
|
|
15
|
+
user_id: config.user_id || "undefined",
|
|
16
|
+
};
|
|
17
|
+
const request = fetch(Request_1.Request.makeUrl(requestConfig, ""), Request_1.Request.requestConfig({ config: requestConfig, type: "GET", url: "" }))
|
|
18
|
+
.then((response) => Request_1.Request.checkStatus(response))
|
|
19
|
+
.then((response) => response.json());
|
|
20
|
+
let timer;
|
|
21
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
22
|
+
timer = setTimeout(() => {
|
|
23
|
+
controller.abort();
|
|
24
|
+
reject(new Error(`No answer within ${APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_TIMEOUT_MS} ms`));
|
|
25
|
+
}, APPLICATION_NULL_HANDLING_1.APPLICATION_NULL_HANDLING_TIMEOUT_MS);
|
|
26
|
+
});
|
|
27
|
+
return Promise.race([request, timeout]).finally(() => clearTimeout(timer));
|
|
28
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./applicationNullHandling.api"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./getAllDatasets.api"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./getAllQrveys.api"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./getDatasetColumns.api"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APPLICATION_NULL_HANDLING_MANAGER_KEY = exports.APPLICATION_NULL_HANDLING_FALLBACK = exports.APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS = exports.APPLICATION_NULL_HANDLING_TIMEOUT_MS = exports.APPLICATION_NULL_HANDLING_ENDPOINT = void 0;
|
|
4
|
+
exports.APPLICATION_NULL_HANDLING_ENDPOINT = {
|
|
5
|
+
devApi: true,
|
|
6
|
+
noUser: true,
|
|
7
|
+
uri: "/user/:user_id/app/:app_id/config/null-handling",
|
|
8
|
+
version: 4,
|
|
9
|
+
};
|
|
10
|
+
exports.APPLICATION_NULL_HANDLING_TIMEOUT_MS = 2000;
|
|
11
|
+
exports.APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS = 30;
|
|
12
|
+
exports.APPLICATION_NULL_HANDLING_FALLBACK = {
|
|
13
|
+
visualIndicator: { type: "BLANK", value: "" },
|
|
14
|
+
nullHandling: { analytics: "IGNORE" },
|
|
15
|
+
};
|
|
16
|
+
exports.APPLICATION_NULL_HANDLING_MANAGER_KEY = "qvApplicationNullHandlingCacheManager";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { QrveyCacheManager } from "../cache-managers/cache-manager";
|
|
2
|
+
export type NullVisualIndicatorType = "BLANK" | "NULLABLE" | "OTHER";
|
|
3
|
+
export type NullAnalyticsHandling = "IGNORE" | "INCLUDE";
|
|
4
|
+
export type NullHandlingSource = "ENFORCED" | "APPLICATION" | "GLOBAL" | "DEFAULT";
|
|
5
|
+
export interface INullVisualIndicator {
|
|
6
|
+
type: NullVisualIndicatorType;
|
|
7
|
+
value?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface INullHandlingBehavior {
|
|
10
|
+
analytics?: NullAnalyticsHandling;
|
|
11
|
+
}
|
|
12
|
+
export interface INullHandlingValues {
|
|
13
|
+
visualIndicator: INullVisualIndicator;
|
|
14
|
+
nullHandling: INullHandlingBehavior;
|
|
15
|
+
}
|
|
16
|
+
export interface IApplicationNullHandlingState extends Partial<INullHandlingValues> {
|
|
17
|
+
followGlobalSettings: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface IApplicationNullHandlingResponse {
|
|
20
|
+
effective: INullHandlingValues;
|
|
21
|
+
source: NullHandlingSource;
|
|
22
|
+
enforceForAllApplications: boolean;
|
|
23
|
+
application: IApplicationNullHandlingState;
|
|
24
|
+
global?: INullHandlingValues;
|
|
25
|
+
maxAgeSeconds: number;
|
|
26
|
+
}
|
|
27
|
+
export interface IApplicationNullHandlingConfig {
|
|
28
|
+
domain?: string;
|
|
29
|
+
api_key?: string;
|
|
30
|
+
qv_token?: string;
|
|
31
|
+
user_id?: string;
|
|
32
|
+
app_id?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface IApplicationNullHandlingStoreState {
|
|
35
|
+
entity: INullHandlingValues | null;
|
|
36
|
+
error: boolean;
|
|
37
|
+
expiresAt: number;
|
|
38
|
+
}
|
|
39
|
+
export type ApplicationNullHandlingStore = Awaited<ReturnType<QrveyCacheManager<IApplicationNullHandlingStoreState, IApplicationNullHandlingConfig>["getStore"]>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/interfaces/index.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { APPLICATION_NULL_HANDLING_ENDPOINT, APPLICATION_NULL_HANDLING_TIMEOUT_MS, } from "../constants/APPLICATION_NULL_HANDLING";
|
|
2
|
+
import { Request } from "../helpers/Request";
|
|
3
|
+
export function getApplicationNullHandling(config) {
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
const requestConfig = {
|
|
6
|
+
apiKey: config.api_key,
|
|
7
|
+
app_id: config.app_id || "undefined",
|
|
8
|
+
domain: config.domain,
|
|
9
|
+
endpoint: APPLICATION_NULL_HANDLING_ENDPOINT,
|
|
10
|
+
qvToken: config.qv_token,
|
|
11
|
+
signal: controller.signal,
|
|
12
|
+
user_id: config.user_id || "undefined",
|
|
13
|
+
};
|
|
14
|
+
const request = fetch(Request.makeUrl(requestConfig, ""), Request.requestConfig({ config: requestConfig, type: "GET", url: "" }))
|
|
15
|
+
.then((response) => Request.checkStatus(response))
|
|
16
|
+
.then((response) => response.json());
|
|
17
|
+
let timer;
|
|
18
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
19
|
+
timer = setTimeout(() => {
|
|
20
|
+
controller.abort();
|
|
21
|
+
reject(new Error(`No answer within ${APPLICATION_NULL_HANDLING_TIMEOUT_MS} ms`));
|
|
22
|
+
}, APPLICATION_NULL_HANDLING_TIMEOUT_MS);
|
|
23
|
+
});
|
|
24
|
+
return Promise.race([request, timeout]).finally(() => clearTimeout(timer));
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { INullHandlingValues } from "../../interfaces/ApplicationNullHandling.Interface";
|
|
2
|
+
import { IEndpointConfig } from "../interfaces/IEndpointConfig";
|
|
3
|
+
export declare const APPLICATION_NULL_HANDLING_ENDPOINT: IEndpointConfig;
|
|
4
|
+
export declare const APPLICATION_NULL_HANDLING_TIMEOUT_MS = 2000;
|
|
5
|
+
export declare const APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS = 30;
|
|
6
|
+
export declare const APPLICATION_NULL_HANDLING_FALLBACK: INullHandlingValues;
|
|
7
|
+
export declare const APPLICATION_NULL_HANDLING_MANAGER_KEY = "qvApplicationNullHandlingCacheManager";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const APPLICATION_NULL_HANDLING_ENDPOINT = {
|
|
2
|
+
devApi: true,
|
|
3
|
+
noUser: true,
|
|
4
|
+
uri: "/user/:user_id/app/:app_id/config/null-handling",
|
|
5
|
+
version: 4,
|
|
6
|
+
};
|
|
7
|
+
export const APPLICATION_NULL_HANDLING_TIMEOUT_MS = 2000;
|
|
8
|
+
export const APPLICATION_NULL_HANDLING_FAILURE_TTL_SECONDS = 30;
|
|
9
|
+
export const APPLICATION_NULL_HANDLING_FALLBACK = {
|
|
10
|
+
visualIndicator: { type: "BLANK", value: "" },
|
|
11
|
+
nullHandling: { analytics: "IGNORE" },
|
|
12
|
+
};
|
|
13
|
+
export const APPLICATION_NULL_HANDLING_MANAGER_KEY = "qvApplicationNullHandlingCacheManager";
|