@fleetbase/ember-core 0.3.17 → 0.3.19
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.
|
@@ -64,7 +64,7 @@ export default class SubjectCustomFields {
|
|
|
64
64
|
this.setFieldValue(value, customField);
|
|
65
65
|
|
|
66
66
|
const fieldId = typeof customField === 'string' ? customField : customField?.id;
|
|
67
|
-
const valueType = typeof customField === 'string' ? null : customField?.valueType ?? customField?.value_type ?? null;
|
|
67
|
+
const valueType = typeof customField === 'string' ? null : (customField?.valueType ?? customField?.value_type ?? null);
|
|
68
68
|
if (!fieldId || !resource) return;
|
|
69
69
|
|
|
70
70
|
let rec = this.#getLocalValueRecord(resource, fieldId);
|
|
@@ -91,7 +91,7 @@ export default class SubjectCustomFields {
|
|
|
91
91
|
let { value_type } = entry;
|
|
92
92
|
if (!value_type) {
|
|
93
93
|
const cf = this.store.peekRecord?.('custom-field', fieldId);
|
|
94
|
-
value_type = cf ? cf.valueType ?? cf.value_type ?? null : null;
|
|
94
|
+
value_type = cf ? (cf.valueType ?? cf.value_type ?? null) : null;
|
|
95
95
|
}
|
|
96
96
|
next[fieldId] = { value, value_type };
|
|
97
97
|
}
|
|
@@ -253,7 +253,7 @@ export default class SubjectCustomFields {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
// Normalize to array
|
|
256
|
-
const existing = isArray(existingMany) ? existingMany : existingMany?.toArray?.() ?? [];
|
|
256
|
+
const existing = isArray(existingMany) ? existingMany : (existingMany?.toArray?.() ?? []);
|
|
257
257
|
|
|
258
258
|
const byFieldId = new Map();
|
|
259
259
|
for (let i = 0; i < existing.length; i++) {
|
|
@@ -8,7 +8,7 @@ import { isBlank } from '@ember/utils';
|
|
|
8
8
|
import { alias } from '@ember/object/computed';
|
|
9
9
|
import { storageFor } from 'ember-local-storage';
|
|
10
10
|
import { debug } from '@ember/debug';
|
|
11
|
-
import lookupUserIp from '../utils/lookup-user-ip';
|
|
11
|
+
import lookupUserIp, { getBrowserTimezone } from '../utils/lookup-user-ip';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* CurrentUserService
|
|
@@ -84,6 +84,10 @@ export default class CurrentUserService extends Service.extend(Evented) {
|
|
|
84
84
|
return this.whois('country_code');
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
get timezone() {
|
|
88
|
+
return this.whois('timezone') || getBrowserTimezone();
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
async load() {
|
|
88
92
|
if (this.session.isAuthenticated) {
|
|
89
93
|
const user = await this.store.findRecord('user', 'me');
|
|
@@ -180,7 +184,7 @@ export default class CurrentUserService extends Service.extend(Evented) {
|
|
|
180
184
|
const fallback = {
|
|
181
185
|
city: null,
|
|
182
186
|
country_code: null,
|
|
183
|
-
timezone:
|
|
187
|
+
timezone: getBrowserTimezone(),
|
|
184
188
|
_source: 'fallback',
|
|
185
189
|
};
|
|
186
190
|
|
|
@@ -9,6 +9,10 @@ export default async function loadInstalledExtensions(additionalCoreEngines = []
|
|
|
9
9
|
'@fleetbase/registry-bridge-engine',
|
|
10
10
|
'@fleetbase/dev-engine',
|
|
11
11
|
'@fleetbase/iam-engine',
|
|
12
|
+
'@fleetbase/ledger-engine',
|
|
13
|
+
'@fleetbase/pallet-engine',
|
|
14
|
+
'@fleetbase/vroom-engine',
|
|
15
|
+
'@fleetbase/valhalla-engine',
|
|
12
16
|
...additionalCoreEngines,
|
|
13
17
|
];
|
|
14
18
|
const INDEXED_ENGINES = await loadExtensions();
|
|
@@ -59,13 +59,14 @@ export default async function lookupUserIp(options = {}) {
|
|
|
59
59
|
|
|
60
60
|
const data = await response.json();
|
|
61
61
|
const normalized = api.normalize(data);
|
|
62
|
+
const normalizedWithTimezone = ensureWhoisTimezone(normalized);
|
|
62
63
|
|
|
63
64
|
// Cache the result if enabled
|
|
64
65
|
if (cache) {
|
|
65
|
-
cacheWhois(
|
|
66
|
+
cacheWhois(normalizedWithTimezone);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
return
|
|
69
|
+
return normalizedWithTimezone;
|
|
69
70
|
} catch (error) {
|
|
70
71
|
console.warn(`[lookupUserIp] ${api.url} failed:`, error.message);
|
|
71
72
|
// Continue to next API
|
|
@@ -92,7 +93,7 @@ function normalizeGeoIPLookup(data) {
|
|
|
92
93
|
latitude: data.latitude,
|
|
93
94
|
longitude: data.longitude,
|
|
94
95
|
postal_code: data.postal_code,
|
|
95
|
-
timezone: data.timezone_name,
|
|
96
|
+
timezone: data.timezone_name || getBrowserTimezone(),
|
|
96
97
|
currency: {
|
|
97
98
|
code: data.currency_code,
|
|
98
99
|
name: data.currency_name,
|
|
@@ -128,7 +129,7 @@ function normalizeIPApi(data) {
|
|
|
128
129
|
latitude: data.latitude,
|
|
129
130
|
longitude: data.longitude,
|
|
130
131
|
postal_code: data.postal,
|
|
131
|
-
timezone: data.timezone,
|
|
132
|
+
timezone: data.timezone || getBrowserTimezone(),
|
|
132
133
|
currency: {
|
|
133
134
|
code: data.currency,
|
|
134
135
|
name: data.currency_name,
|
|
@@ -163,7 +164,12 @@ function getCachedWhois() {
|
|
|
163
164
|
return null;
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
|
|
167
|
+
const normalized = ensureWhoisTimezone(data);
|
|
168
|
+
if (normalized.timezone !== data.timezone) {
|
|
169
|
+
cacheWhois(normalized);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return normalized;
|
|
167
173
|
} catch (error) {
|
|
168
174
|
console.error('[getCachedWhois] Error reading cache:', error);
|
|
169
175
|
return null;
|
|
@@ -187,7 +193,7 @@ function cacheWhois(data) {
|
|
|
187
193
|
function getFallbackWhois() {
|
|
188
194
|
// Try to get browser language and timezone as fallback
|
|
189
195
|
const browserLang = navigator.language || 'en-US';
|
|
190
|
-
const timezone =
|
|
196
|
+
const timezone = getBrowserTimezone();
|
|
191
197
|
|
|
192
198
|
return {
|
|
193
199
|
ip: null,
|
|
@@ -219,3 +225,20 @@ function getFallbackWhois() {
|
|
|
219
225
|
_timestamp: Date.now(),
|
|
220
226
|
};
|
|
221
227
|
}
|
|
228
|
+
|
|
229
|
+
export function getBrowserTimezone() {
|
|
230
|
+
try {
|
|
231
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function ensureWhoisTimezone(whois = {}) {
|
|
238
|
+
whois = whois || {};
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
...whois,
|
|
242
|
+
timezone: whois.timezone || getBrowserTimezone(),
|
|
243
|
+
};
|
|
244
|
+
}
|
package/package.json
CHANGED