@autofleet/settings 1.4.5 → 2.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/.eslintrc.json +3 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +49 -27
- package/package.json +11 -7
- package/src/alltypes.d.ts +0 -1
- package/src/index.ts +29 -31
package/.eslintrc.json
CHANGED
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
],
|
|
22
22
|
"@typescript-eslint/no-unused-vars": ["error"],
|
|
23
23
|
"@typescript-eslint/no-var-requires": ["off"],
|
|
24
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
24
25
|
"@typescript-eslint/camelcase": ["off"],
|
|
25
26
|
"max-len": ["off"],
|
|
26
|
-
"@typescript-eslint/explicit-function-return-type": ["off"]
|
|
27
|
+
"@typescript-eslint/explicit-function-return-type": ["off"],
|
|
28
|
+
"class-methods-use-this": "off"
|
|
27
29
|
},
|
|
28
30
|
"overrides": [
|
|
29
31
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import NodeCache from 'node-cache';
|
|
3
2
|
import EventEmitter from 'events';
|
|
4
3
|
interface SettingsClassOptions {
|
|
@@ -31,10 +30,10 @@ declare class SettingsManager {
|
|
|
31
30
|
network: any;
|
|
32
31
|
NEVER_DEFAULT_VALUE: string;
|
|
33
32
|
disableTestEnvCheck: boolean;
|
|
34
|
-
static get NEVER_DEFAULT_VALUE():
|
|
35
|
-
static readNetworkValue(networkValue: SettingValue, defaultValue: SettingValue): any;
|
|
33
|
+
static get NEVER_DEFAULT_VALUE(): 'NEVER_DEFAULT_VALUE';
|
|
34
|
+
static readNetworkValue(networkValue: SettingValue, defaultValue: SettingValue, key: string): any;
|
|
36
35
|
constructor({ serviceUrl, ttl, disableTestEnvCheck }?: SettingsClassOptions);
|
|
37
|
-
get(key: SettingValue, defaultValue?:
|
|
36
|
+
get(key: SettingValue, defaultValue?: SettingValue, labels?: LabelsArray, { timeout, rejectOnFail }?: GetSettingOption): Promise<SettingValue>;
|
|
38
37
|
getMultiple(settingsToGet: {
|
|
39
38
|
key: SettingValue;
|
|
40
39
|
defaultValue: any;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,19 +35,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
36
|
};
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
/* eslint-disable consistent-return */
|
|
16
|
-
/* eslint-disable array-callback-return */
|
|
17
38
|
// eslint-disable-next-line max-classes-per-file
|
|
18
39
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
19
40
|
const network_1 = __importDefault(require("@autofleet/network"));
|
|
20
41
|
const logger_1 = __importDefault(require("@autofleet/logger"));
|
|
21
42
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
22
|
-
const events_1 =
|
|
23
|
-
const util_1 = __importDefault(require("util"));
|
|
43
|
+
const events_1 = __importStar(require("events"));
|
|
24
44
|
const moment_1 = __importDefault(require("moment"));
|
|
25
45
|
const h3_js_1 = __importDefault(require("h3-js"));
|
|
26
46
|
dotenv_1.default.config();
|
|
27
|
-
const nextTick = util_1.default.promisify(process.nextTick);
|
|
28
47
|
const logger = (0, logger_1.default)();
|
|
29
48
|
const fiveMinutes = 60 * 5;
|
|
30
49
|
const waitingToNetwork = 'waitingToNetwork';
|
|
@@ -37,8 +56,12 @@ class SettingsManager {
|
|
|
37
56
|
static get NEVER_DEFAULT_VALUE() {
|
|
38
57
|
return 'NEVER_DEFAULT_VALUE';
|
|
39
58
|
}
|
|
40
|
-
static readNetworkValue(networkValue, defaultValue) {
|
|
41
|
-
|
|
59
|
+
static readNetworkValue(networkValue, defaultValue, key) {
|
|
60
|
+
let returnValue = networkValue;
|
|
61
|
+
if (typeof networkValue === 'undefined') {
|
|
62
|
+
returnValue = defaultValue;
|
|
63
|
+
logger.info('Setting falling back to default as network value was defined', { key, defaultValue });
|
|
64
|
+
}
|
|
42
65
|
if (returnValue === SettingsManager.NEVER_DEFAULT_VALUE) {
|
|
43
66
|
throw new Error('Cannot find value from network or cache, default value is set to never');
|
|
44
67
|
}
|
|
@@ -55,28 +78,27 @@ class SettingsManager {
|
|
|
55
78
|
serviceUrl: localServiceUrl,
|
|
56
79
|
});
|
|
57
80
|
}
|
|
58
|
-
get(
|
|
59
|
-
return __awaiter(this,
|
|
81
|
+
get(key_1, defaultValue_1) {
|
|
82
|
+
return __awaiter(this, arguments, void 0, function* (key, defaultValue, labels = [], { timeout = 5000, rejectOnFail = false } = {}) {
|
|
60
83
|
if (typeof defaultValue === 'undefined') {
|
|
61
84
|
throw new Error('Can\'t get a key without defaultValue');
|
|
62
85
|
}
|
|
63
86
|
const cacheKey = this.getCacheKey(key, labels);
|
|
64
87
|
const cacheValue = this.settingsCache.get(cacheKey);
|
|
65
88
|
if (cacheValue !== undefined) {
|
|
89
|
+
logger.info('setting found in cache', { cacheKey });
|
|
66
90
|
if (waitingToNetwork === cacheValue) {
|
|
67
|
-
yield
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
resolve(SettingsManager.readNetworkValue(networkValue, defaultValue));
|
|
74
|
-
});
|
|
75
|
-
});
|
|
91
|
+
yield Promise.resolve();
|
|
92
|
+
const [networkValue] = yield (0, events_1.once)(this.networkEvents, cacheKey);
|
|
93
|
+
if (networkValue instanceof Error && rejectOnFail) {
|
|
94
|
+
throw networkValue;
|
|
95
|
+
}
|
|
96
|
+
return SettingsManager.readNetworkValue(networkValue, defaultValue, key);
|
|
76
97
|
}
|
|
77
98
|
return cacheValue;
|
|
78
99
|
}
|
|
79
100
|
if (!this.disableTestEnvCheck && process.env.NODE_ENV === 'test') {
|
|
101
|
+
logger.info('returning default value setting in TEST mode', { cacheKey });
|
|
80
102
|
return defaultValue;
|
|
81
103
|
}
|
|
82
104
|
let networkValue;
|
|
@@ -101,7 +123,7 @@ class SettingsManager {
|
|
|
101
123
|
this.networkEvents.emit(cacheKey, networkValue);
|
|
102
124
|
let returnValue;
|
|
103
125
|
try {
|
|
104
|
-
returnValue = SettingsManager.readNetworkValue(networkValue, defaultValue);
|
|
126
|
+
returnValue = SettingsManager.readNetworkValue(networkValue, defaultValue, key);
|
|
105
127
|
}
|
|
106
128
|
catch (e) {
|
|
107
129
|
this.settingsCache.del(cacheKey);
|
|
@@ -111,11 +133,11 @@ class SettingsManager {
|
|
|
111
133
|
return returnValue;
|
|
112
134
|
});
|
|
113
135
|
}
|
|
114
|
-
getMultiple(
|
|
115
|
-
return __awaiter(this,
|
|
136
|
+
getMultiple(settingsToGet_1, labels_1) {
|
|
137
|
+
return __awaiter(this, arguments, void 0, function* (settingsToGet, labels, { timeout = 5000, rejectOnFail = false } = {}) {
|
|
116
138
|
const settingsToReturn = new Map();
|
|
117
139
|
const settingsToFetch = [];
|
|
118
|
-
settingsToGet.
|
|
140
|
+
settingsToGet.forEach((obj) => {
|
|
119
141
|
const cacheKey = this.getCacheKey(obj.key, labels);
|
|
120
142
|
const cacheValue = this.settingsCache.get(cacheKey);
|
|
121
143
|
if (cacheValue !== undefined && cacheValue !== waitingToNetwork) {
|
|
@@ -139,12 +161,12 @@ class SettingsManager {
|
|
|
139
161
|
timeout,
|
|
140
162
|
});
|
|
141
163
|
values = data;
|
|
142
|
-
settingsToFetch.
|
|
164
|
+
settingsToFetch.forEach((key, index) => {
|
|
143
165
|
settingsToReturn.set(key, values[index].value);
|
|
144
166
|
});
|
|
145
167
|
}
|
|
146
168
|
catch (err) {
|
|
147
|
-
logger.error('Cant get setting from network', { err });
|
|
169
|
+
logger.error('Cant get setting from network', { err, settingsToFetch, labels });
|
|
148
170
|
if (rejectOnFail) {
|
|
149
171
|
throw new CannotGetNetworkValueError();
|
|
150
172
|
}
|
|
@@ -154,7 +176,7 @@ class SettingsManager {
|
|
|
154
176
|
const cacheKey = this.getCacheKey(setting.key, labels);
|
|
155
177
|
let returnValue;
|
|
156
178
|
try {
|
|
157
|
-
returnValue = SettingsManager.readNetworkValue(settingsToReturn.get(setting.key), setting.defaultValue);
|
|
179
|
+
returnValue = SettingsManager.readNetworkValue(settingsToReturn.get(setting.key), setting.defaultValue, setting.key);
|
|
158
180
|
}
|
|
159
181
|
catch (err) {
|
|
160
182
|
this.settingsCache.del(cacheKey);
|
|
@@ -174,13 +196,13 @@ class SettingsManager {
|
|
|
174
196
|
flush() {
|
|
175
197
|
return this.settingsCache.flushAll();
|
|
176
198
|
}
|
|
177
|
-
// eslint-disable-next-line class-methods-use-this
|
|
178
199
|
getCacheKey(key, labels) {
|
|
179
200
|
const newLabels = labels.map((l) => {
|
|
201
|
+
var _a, _b;
|
|
180
202
|
if (l.time) {
|
|
181
203
|
return Object.assign(Object.assign({}, l), { time: (0, moment_1.default)(l.time).startOf('hour').format(), day: (0, moment_1.default)(l.time).day() });
|
|
182
204
|
}
|
|
183
|
-
if (l.location
|
|
205
|
+
if (((_a = l.location) === null || _a === void 0 ? void 0 : _a.lat) && ((_b = l.location) === null || _b === void 0 ? void 0 : _b.lng)) {
|
|
184
206
|
const h3Index = h3_js_1.default.latLngToCell(l.location.lat, l.location.lng, 8);
|
|
185
207
|
return Object.assign(Object.assign({}, l), { location: h3Index });
|
|
186
208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/settings",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
"coverage": "jest --coverage --forceExit --runInBand && rm -rf ./coverage",
|
|
14
14
|
"dev": "nodemon"
|
|
15
15
|
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16.0.0"
|
|
18
|
+
},
|
|
16
19
|
"peerDependencies": {
|
|
17
|
-
"@autofleet/logger": "
|
|
20
|
+
"@autofleet/logger": ">=4.0.0"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
23
|
"@autofleet/network": "^1.4.2",
|
|
@@ -27,15 +30,16 @@
|
|
|
27
30
|
"@autofleet/logger": "^4.0.6",
|
|
28
31
|
"@types/jest": "^29.5.12",
|
|
29
32
|
"@types/nock": "^10.0.3",
|
|
30
|
-
"@
|
|
31
|
-
"eslint": "^7.
|
|
32
|
-
"eslint
|
|
33
|
-
"eslint-
|
|
33
|
+
"@types/node": "^16.18.108",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
35
|
+
"eslint": "^8.56.0",
|
|
36
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
37
|
+
"eslint-plugin-import": "^2.30.0",
|
|
34
38
|
"jest": "^29.7.0",
|
|
35
39
|
"nock": "^10.0.2",
|
|
36
40
|
"ts-jest": "^29.2.3",
|
|
37
41
|
"ts-node": "^8.6.2",
|
|
38
|
-
"typescript": "^
|
|
42
|
+
"typescript": "^5.5.3"
|
|
39
43
|
},
|
|
40
44
|
"author": "",
|
|
41
45
|
"license": "ISC"
|
package/src/alltypes.d.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
/* eslint-disable array-callback-return */
|
|
3
1
|
// eslint-disable-next-line max-classes-per-file
|
|
4
2
|
import dotenv from 'dotenv';
|
|
5
3
|
import Network from '@autofleet/network';
|
|
6
4
|
import Logger from '@autofleet/logger';
|
|
7
5
|
import NodeCache from 'node-cache';
|
|
8
|
-
import EventEmitter from 'events';
|
|
9
|
-
import util from 'util';
|
|
6
|
+
import EventEmitter, { once } from 'events';
|
|
10
7
|
import moment from 'moment';
|
|
11
8
|
import h3 from 'h3-js';
|
|
12
9
|
|
|
13
10
|
dotenv.config();
|
|
14
11
|
|
|
15
|
-
const nextTick = util.promisify(process.nextTick);
|
|
16
12
|
const logger = Logger();
|
|
17
13
|
|
|
18
14
|
const fiveMinutes = 60 * 5;
|
|
@@ -66,12 +62,16 @@ class SettingsManager {
|
|
|
66
62
|
|
|
67
63
|
disableTestEnvCheck: boolean;
|
|
68
64
|
|
|
69
|
-
static get NEVER_DEFAULT_VALUE() {
|
|
65
|
+
static get NEVER_DEFAULT_VALUE(): 'NEVER_DEFAULT_VALUE' {
|
|
70
66
|
return 'NEVER_DEFAULT_VALUE';
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
static readNetworkValue(networkValue: SettingValue, defaultValue: SettingValue) {
|
|
74
|
-
|
|
69
|
+
static readNetworkValue(networkValue: SettingValue, defaultValue: SettingValue, key: string) {
|
|
70
|
+
let returnValue = networkValue;
|
|
71
|
+
if (typeof networkValue === 'undefined') {
|
|
72
|
+
returnValue = defaultValue;
|
|
73
|
+
logger.info('Setting falling back to default as network value was defined', { key, defaultValue });
|
|
74
|
+
}
|
|
75
75
|
|
|
76
76
|
if (returnValue === SettingsManager.NEVER_DEFAULT_VALUE) {
|
|
77
77
|
throw new Error('Cannot find value from network or cache, default value is set to never');
|
|
@@ -80,7 +80,7 @@ class SettingsManager {
|
|
|
80
80
|
return returnValue;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
constructor({ serviceUrl, ttl = fiveMinutes, disableTestEnvCheck = false }:SettingsClassOptions = {}) {
|
|
83
|
+
constructor({ serviceUrl, ttl = fiveMinutes, disableTestEnvCheck = false }: SettingsClassOptions = {}) {
|
|
84
84
|
const localServiceUrl = findUrl(serviceUrl);
|
|
85
85
|
|
|
86
86
|
this.NEVER_DEFAULT_VALUE = SettingsManager.NEVER_DEFAULT_VALUE;
|
|
@@ -95,10 +95,10 @@ class SettingsManager {
|
|
|
95
95
|
|
|
96
96
|
async get(
|
|
97
97
|
key: SettingValue,
|
|
98
|
-
defaultValue?:
|
|
99
|
-
labels:LabelsArray = [],
|
|
98
|
+
defaultValue?: SettingValue,
|
|
99
|
+
labels: LabelsArray = [],
|
|
100
100
|
{ timeout = 5000, rejectOnFail = false } : GetSettingOption = {},
|
|
101
|
-
) {
|
|
101
|
+
): Promise<SettingValue> {
|
|
102
102
|
if (typeof defaultValue === 'undefined') {
|
|
103
103
|
throw new Error('Can\'t get a key without defaultValue');
|
|
104
104
|
}
|
|
@@ -106,21 +106,20 @@ class SettingsManager {
|
|
|
106
106
|
const cacheKey = this.getCacheKey(key, labels);
|
|
107
107
|
const cacheValue = this.settingsCache.get(cacheKey);
|
|
108
108
|
if (cacheValue !== undefined) {
|
|
109
|
+
logger.info('setting found in cache', { cacheKey });
|
|
109
110
|
if (waitingToNetwork === cacheValue) {
|
|
110
|
-
await
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
resolve(SettingsManager.readNetworkValue(networkValue, defaultValue));
|
|
117
|
-
});
|
|
118
|
-
});
|
|
111
|
+
await Promise.resolve();
|
|
112
|
+
const [networkValue] = await once(this.networkEvents, cacheKey);
|
|
113
|
+
if (networkValue instanceof Error && rejectOnFail) {
|
|
114
|
+
throw networkValue;
|
|
115
|
+
}
|
|
116
|
+
return SettingsManager.readNetworkValue(networkValue, defaultValue, key);
|
|
119
117
|
}
|
|
120
118
|
return cacheValue;
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
if (!this.disableTestEnvCheck && process.env.NODE_ENV === 'test') {
|
|
122
|
+
logger.info('returning default value setting in TEST mode', { cacheKey });
|
|
124
123
|
return defaultValue;
|
|
125
124
|
}
|
|
126
125
|
|
|
@@ -146,7 +145,7 @@ class SettingsManager {
|
|
|
146
145
|
this.networkEvents.emit(cacheKey, networkValue);
|
|
147
146
|
let returnValue;
|
|
148
147
|
try {
|
|
149
|
-
returnValue = SettingsManager.readNetworkValue(networkValue, defaultValue);
|
|
148
|
+
returnValue = SettingsManager.readNetworkValue(networkValue, defaultValue, key);
|
|
150
149
|
} catch (e) {
|
|
151
150
|
this.settingsCache.del(cacheKey);
|
|
152
151
|
throw e;
|
|
@@ -166,7 +165,7 @@ class SettingsManager {
|
|
|
166
165
|
const settingsToReturn = new Map();
|
|
167
166
|
const settingsToFetch: any[] = [];
|
|
168
167
|
|
|
169
|
-
settingsToGet.
|
|
168
|
+
settingsToGet.forEach((obj) => {
|
|
170
169
|
const cacheKey = this.getCacheKey(obj.key, labels);
|
|
171
170
|
const cacheValue = this.settingsCache.get(cacheKey);
|
|
172
171
|
if (cacheValue !== undefined && cacheValue !== waitingToNetwork) {
|
|
@@ -192,11 +191,11 @@ class SettingsManager {
|
|
|
192
191
|
});
|
|
193
192
|
values = data;
|
|
194
193
|
|
|
195
|
-
settingsToFetch.
|
|
194
|
+
settingsToFetch.forEach((key, index) => {
|
|
196
195
|
settingsToReturn.set(key, values[index].value);
|
|
197
196
|
});
|
|
198
197
|
} catch (err) {
|
|
199
|
-
logger.error('Cant get setting from network', { err });
|
|
198
|
+
logger.error('Cant get setting from network', { err, settingsToFetch, labels });
|
|
200
199
|
if (rejectOnFail) {
|
|
201
200
|
throw new CannotGetNetworkValueError();
|
|
202
201
|
}
|
|
@@ -207,7 +206,7 @@ class SettingsManager {
|
|
|
207
206
|
const cacheKey = this.getCacheKey(setting.key, labels);
|
|
208
207
|
let returnValue;
|
|
209
208
|
try {
|
|
210
|
-
returnValue = SettingsManager.readNetworkValue(settingsToReturn.get(setting.key), setting.defaultValue);
|
|
209
|
+
returnValue = SettingsManager.readNetworkValue(settingsToReturn.get(setting.key), setting.defaultValue, setting.key);
|
|
211
210
|
} catch (err) {
|
|
212
211
|
this.settingsCache.del(cacheKey);
|
|
213
212
|
throw err;
|
|
@@ -219,17 +218,16 @@ class SettingsManager {
|
|
|
219
218
|
});
|
|
220
219
|
}
|
|
221
220
|
|
|
222
|
-
setLocal(key: string, labels: LabelsArray, value: SettingValue) {
|
|
221
|
+
setLocal(key: string, labels: LabelsArray, value: SettingValue): void {
|
|
223
222
|
const cacheKey = this.getCacheKey(key, labels);
|
|
224
223
|
this.settingsCache.set(cacheKey, value, this.ttl);
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
flush() {
|
|
226
|
+
flush(): void {
|
|
228
227
|
return this.settingsCache.flushAll();
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
|
|
232
|
-
getCacheKey(key: SettingValue, labels: LabelsArray) {
|
|
230
|
+
getCacheKey(key: SettingValue, labels: LabelsArray): string {
|
|
233
231
|
const newLabels = labels.map((l) => {
|
|
234
232
|
if (l.time) {
|
|
235
233
|
return {
|
|
@@ -239,7 +237,7 @@ class SettingsManager {
|
|
|
239
237
|
};
|
|
240
238
|
}
|
|
241
239
|
|
|
242
|
-
if (l.location
|
|
240
|
+
if (l.location?.lat && l.location?.lng) {
|
|
243
241
|
const h3Index = h3.latLngToCell(l.location.lat, l.location.lng, 8);
|
|
244
242
|
return {
|
|
245
243
|
...l,
|