@trackunit/filters-graphql-hook 2.1.33 → 2.1.35
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/index.cjs.js +102 -461
- package/index.esm.js +104 -462
- package/package.json +9 -9
- package/src/index.d.ts +0 -1
- package/src/convertAssetFiltersInputToFilterBarValues.d.ts +0 -14
- package/src/parseAssetFiltersInput.d.ts +0 -650
- package/src/useAssetFiltersInputToFilterBarValues.d.ts +0 -11
package/index.cjs.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
require('react/jsx-runtime');
|
|
4
4
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
5
|
-
var react = require('react');
|
|
6
5
|
var filtersFilterBar = require('@trackunit/filters-filter-bar');
|
|
6
|
+
var sharedUtils = require('@trackunit/shared-utils');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var reactCoreHooks = require('@trackunit/react-core-hooks');
|
|
9
|
-
var
|
|
9
|
+
var react = require('react');
|
|
10
10
|
var irisAppRuntimeCoreApi = require('@trackunit/iris-app-runtime-core-api');
|
|
11
11
|
|
|
12
12
|
var defaultTranslations = {
|
|
@@ -51,249 +51,6 @@ const setupLibraryTranslations = () => {
|
|
|
51
51
|
i18nLibraryTranslation.registerTranslations(translations);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const accessManagementMode = {
|
|
55
|
-
LOCKED_FOR_ALL: "LOCKED_FOR_ALL",
|
|
56
|
-
UNKNOWN: "UNKNOWN",
|
|
57
|
-
UNLOCKED_FOR_ALL: "UNLOCKED_FOR_ALL",
|
|
58
|
-
UNLOCKED_FOR_KEY: "UNLOCKED_FOR_KEY",
|
|
59
|
-
UNSUPPORTED: "UNSUPPORTED",
|
|
60
|
-
};
|
|
61
|
-
const assetActivityState = {
|
|
62
|
-
IDLING: "IDLING",
|
|
63
|
-
STOPPED: "STOPPED",
|
|
64
|
-
UNKNOWN: "UNKNOWN",
|
|
65
|
-
WORKING: "WORKING",
|
|
66
|
-
};
|
|
67
|
-
const assetCriticalityState = {
|
|
68
|
-
CRITICAL: "CRITICAL",
|
|
69
|
-
LOW: "LOW",
|
|
70
|
-
NONE: "NONE",
|
|
71
|
-
};
|
|
72
|
-
const assetLastSeen = {
|
|
73
|
-
LAST_7_DAYS: "LAST_7_DAYS",
|
|
74
|
-
LAST_24_HOURS: "LAST_24_HOURS",
|
|
75
|
-
LAST_30_DAYS: "LAST_30_DAYS",
|
|
76
|
-
LAST_HOUR: "LAST_HOUR",
|
|
77
|
-
OLDER_THAN_30_DAYS: "OLDER_THAN_30_DAYS",
|
|
78
|
-
};
|
|
79
|
-
const assetType = {
|
|
80
|
-
ATTACHMENT: "ATTACHMENT",
|
|
81
|
-
EQUIPMENT: "EQUIPMENT",
|
|
82
|
-
GATEWAY: "GATEWAY",
|
|
83
|
-
MACHINE: "MACHINE",
|
|
84
|
-
OTHER: "OTHER",
|
|
85
|
-
TOOL: "TOOL",
|
|
86
|
-
VEHICLE: "VEHICLE",
|
|
87
|
-
};
|
|
88
|
-
const fleetDataHealthDeviceStatus = {
|
|
89
|
-
CRITICAL: "CRITICAL",
|
|
90
|
-
LOW: "LOW",
|
|
91
|
-
};
|
|
92
|
-
const fleetDataHealthIssueCategory = {
|
|
93
|
-
COVERAGE: "COVERAGE",
|
|
94
|
-
DEVICE_BATTERY: "DEVICE_BATTERY",
|
|
95
|
-
INSTALL_AND_CONFIGURATION: "INSTALL_AND_CONFIGURATION",
|
|
96
|
-
NON_REPORTING_DEVICE: "NON_REPORTING_DEVICE",
|
|
97
|
-
};
|
|
98
|
-
const fleetDataHealthIssueState = {
|
|
99
|
-
OPEN: "OPEN",
|
|
100
|
-
RESOLVED: "RESOLVED",
|
|
101
|
-
};
|
|
102
|
-
const fleetDataHealthIssueType = {
|
|
103
|
-
DATA_NOT_RECEIVED: "DATA_NOT_RECEIVED",
|
|
104
|
-
DEVICE_BATTERY_APPROACHING_END_OF_LIFE: "DEVICE_BATTERY_APPROACHING_END_OF_LIFE",
|
|
105
|
-
LOW_CELLULAR_COVERAGE: "LOW_CELLULAR_COVERAGE",
|
|
106
|
-
LOW_DEVICE_BATTERY: "LOW_DEVICE_BATTERY",
|
|
107
|
-
LOW_DEVICE_INPUT_VOLTAGE: "LOW_DEVICE_INPUT_VOLTAGE",
|
|
108
|
-
LOW_GPS_COVERAGE: "LOW_GPS_COVERAGE",
|
|
109
|
-
NO_CAN_DATA_CONFIGURATION: "NO_CAN_DATA_CONFIGURATION",
|
|
110
|
-
OPERATING_HOURS_FROM_CAN_MODIFIED: "OPERATING_HOURS_FROM_CAN_MODIFIED",
|
|
111
|
-
OPERATING_HOURS_REPORTING_0_HOURS_PER_DAY: "OPERATING_HOURS_REPORTING_0_HOURS_PER_DAY",
|
|
112
|
-
OPERATING_HOURS_REPORTING_24_HOURS_PER_DAY: "OPERATING_HOURS_REPORTING_24_HOURS_PER_DAY",
|
|
113
|
-
UNUSUAL_OPERATING_HOURS: "UNUSUAL_OPERATING_HOURS",
|
|
114
|
-
};
|
|
115
|
-
const metadataCompleteness = {
|
|
116
|
-
COMPLETE: "COMPLETE",
|
|
117
|
-
PARTIAL: "PARTIAL",
|
|
118
|
-
};
|
|
119
|
-
const rentalStatus = {
|
|
120
|
-
AVAILABLE: "AVAILABLE",
|
|
121
|
-
IN_REPAIR: "IN_REPAIR",
|
|
122
|
-
NOT_ON_CONTRACT: "NOT_ON_CONTRACT",
|
|
123
|
-
OFF_RENT: "OFF_RENT",
|
|
124
|
-
ON_RENT: "ON_RENT",
|
|
125
|
-
OTHER: "OTHER",
|
|
126
|
-
PICK_UP_READY: "PICK_UP_READY",
|
|
127
|
-
RESERVED: "RESERVED",
|
|
128
|
-
RETURNED: "RETURNED",
|
|
129
|
-
TRANSFER: "TRANSFER",
|
|
130
|
-
};
|
|
131
|
-
const servicePlanStatus = {
|
|
132
|
-
COMPLETE: "COMPLETE",
|
|
133
|
-
DRAFT: "DRAFT",
|
|
134
|
-
FULLY_CONFIGURED: "FULLY_CONFIGURED",
|
|
135
|
-
HAS_PLAN: "HAS_PLAN",
|
|
136
|
-
HAS_SERVICE_PROVIDER: "HAS_SERVICE_PROVIDER",
|
|
137
|
-
MISSING_PLAN: "MISSING_PLAN",
|
|
138
|
-
MISSING_PROVIDER: "MISSING_PROVIDER",
|
|
139
|
-
OVERDUE: "OVERDUE",
|
|
140
|
-
PLANNED: "PLANNED",
|
|
141
|
-
UNKNOWN: "UNKNOWN",
|
|
142
|
-
UPCOMING: "UPCOMING",
|
|
143
|
-
};
|
|
144
|
-
const siteTypeSFS = {
|
|
145
|
-
AREA: "AREA",
|
|
146
|
-
CLASSIC_POI: "CLASSIC_POI",
|
|
147
|
-
CLASSIC_ZONE: "CLASSIC_ZONE",
|
|
148
|
-
CONSTRUCTION_SITE: "CONSTRUCTION_SITE",
|
|
149
|
-
DEPOT: "DEPOT",
|
|
150
|
-
NOT_ON_SITE: "NOT_ON_SITE",
|
|
151
|
-
WORK_PLACE: "WORK_PLACE",
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const numberRangeSchema = zod.z.object({
|
|
155
|
-
min: zod.z.number().optional(),
|
|
156
|
-
max: zod.z.number().optional(),
|
|
157
|
-
});
|
|
158
|
-
const aggregatedNumberRangeSchema = zod.z.object({
|
|
159
|
-
period: zod.z.literal("LIFETIME"),
|
|
160
|
-
range: numberRangeSchema,
|
|
161
|
-
});
|
|
162
|
-
const customFieldSchema = zod.z
|
|
163
|
-
.object({
|
|
164
|
-
booleanValue: zod.z.boolean().optional(),
|
|
165
|
-
dateRange: filtersFilterBar.dateRangeSchema.optional(),
|
|
166
|
-
definitionId: zod.z.string().optional(),
|
|
167
|
-
numberRange: zod.z
|
|
168
|
-
.object({
|
|
169
|
-
from: zod.z.number().optional(),
|
|
170
|
-
to: zod.z.number().optional(),
|
|
171
|
-
})
|
|
172
|
-
.optional(),
|
|
173
|
-
stringArrayValue: zod.z.array(zod.z.string()).optional(),
|
|
174
|
-
stringWildcardValue: zod.z.string().optional(),
|
|
175
|
-
})
|
|
176
|
-
.strip();
|
|
177
|
-
/**
|
|
178
|
-
* Drift guard: keying the supported subset to `keyof AssetFiltersInput` forces a
|
|
179
|
-
* compile error if the generated GraphQL schema renames or removes a field we map.
|
|
180
|
-
* Enum-value drift is already caught because every `z.nativeEnum(...)` references a
|
|
181
|
-
* generated GraphQL enum, so a removed enum breaks the import.
|
|
182
|
-
*/
|
|
183
|
-
const assetFiltersInputSchema = zod.z
|
|
184
|
-
.object({
|
|
185
|
-
accessManagementDesiredModes: zod.z.array(zod.z.nativeEnum(accessManagementMode)).optional(),
|
|
186
|
-
activeFilter: zod.z.boolean().optional(),
|
|
187
|
-
activities: zod.z.array(zod.z.nativeEnum(assetActivityState)).optional(),
|
|
188
|
-
area: filtersFilterBar.areaFilterGeoJsonGeometrySchema.optional(),
|
|
189
|
-
assetIds: zod.z.array(zod.z.string()).optional(),
|
|
190
|
-
assetTypes: zod.z.array(zod.z.nativeEnum(assetType)).optional(),
|
|
191
|
-
brands: zod.z.array(zod.z.string()).optional(),
|
|
192
|
-
criticalities: zod.z.array(zod.z.nativeEnum(assetCriticalityState)).optional(),
|
|
193
|
-
customerIds: zod.z.array(zod.z.string()).optional(),
|
|
194
|
-
deviceTypes: zod.z.array(zod.z.string()).optional(),
|
|
195
|
-
fleetHealthCategories: zod.z.array(zod.z.nativeEnum(fleetDataHealthIssueCategory)).optional(),
|
|
196
|
-
fleetHealthDeviceStatuses: zod.z.array(zod.z.nativeEnum(fleetDataHealthDeviceStatus)).optional(),
|
|
197
|
-
fleetHealthTypes: zod.z.array(zod.z.nativeEnum(fleetDataHealthIssueType)).optional(),
|
|
198
|
-
groups: zod.z.array(zod.z.string()).optional(),
|
|
199
|
-
customFields: zod.z.array(customFieldSchema).optional(),
|
|
200
|
-
insightsFilters: zod.z
|
|
201
|
-
.object({
|
|
202
|
-
afterTreatmentDieselExhaustFluidTankLevel: numberRangeSchema.optional(),
|
|
203
|
-
batteryChargerState: zod.z.array(zod.z.boolean()).optional(),
|
|
204
|
-
batteryPotential: numberRangeSchema.optional(),
|
|
205
|
-
batteryStateOfChargePercent: numberRangeSchema.optional(),
|
|
206
|
-
cumulativeIdleHours: aggregatedNumberRangeSchema.optional(),
|
|
207
|
-
cumulativeOperatingHours: aggregatedNumberRangeSchema.optional(),
|
|
208
|
-
fuelLevel: numberRangeSchema.optional(),
|
|
209
|
-
})
|
|
210
|
-
.strip()
|
|
211
|
-
.optional(),
|
|
212
|
-
lastSeen: zod.z.nativeEnum(assetLastSeen).optional(),
|
|
213
|
-
metadataCompleteness: zod.z.nativeEnum(metadataCompleteness).optional(),
|
|
214
|
-
models: zod.z.array(zod.z.string()).optional(),
|
|
215
|
-
ownerAccountIds: zod.z.array(zod.z.string()).optional(),
|
|
216
|
-
owningDepotSiteIds: zod.z.array(zod.z.string()).optional(),
|
|
217
|
-
partnerId: zod.z.string().optional(),
|
|
218
|
-
pendingTelematicsDevices: zod.z.array(zod.z.string()).optional(),
|
|
219
|
-
rentalActiveContractFilters: zod.z
|
|
220
|
-
.object({
|
|
221
|
-
customerExternalReferences: zod.z.array(zod.z.string()).optional(),
|
|
222
|
-
customerParentExternalReferences: zod.z.array(zod.z.string()).optional(),
|
|
223
|
-
customerParentNames: zod.z.array(zod.z.string()).optional(),
|
|
224
|
-
offRentDatesDateRange: filtersFilterBar.dateRangeSchema.optional(),
|
|
225
|
-
onRentDatesDateRange: filtersFilterBar.dateRangeSchema.optional(),
|
|
226
|
-
})
|
|
227
|
-
.optional(),
|
|
228
|
-
rentalContractOrderNumbers: zod.z.array(zod.z.string()).optional(),
|
|
229
|
-
rentalContractReferenceCodeDescriptionQuery: zod.z.string().optional(),
|
|
230
|
-
rentalContractReferenceCodes: zod.z.array(zod.z.string()).optional(),
|
|
231
|
-
rentalStatuses: zod.z.array(zod.z.nativeEnum(rentalStatus)).optional(),
|
|
232
|
-
searchQuery: zod.z.string().optional(),
|
|
233
|
-
serviceBooked: zod.z.array(zod.z.boolean()).optional(),
|
|
234
|
-
servicePlanAssignments: zod.z.array(zod.z.nativeEnum(servicePlanStatus)).optional(),
|
|
235
|
-
servicePlanIds: zod.z.array(zod.z.string()).optional(),
|
|
236
|
-
servicePlanStatuses: zod.z.array(zod.z.nativeEnum(servicePlanStatus)).optional(),
|
|
237
|
-
serviceProviderIds: zod.z.array(zod.z.string()).optional(),
|
|
238
|
-
siteIds: zod.z.array(zod.z.string()).optional(),
|
|
239
|
-
siteTypes: zod.z.array(zod.z.nativeEnum(siteTypeSFS)).optional(),
|
|
240
|
-
sustainabilityExcluded: zod.z.boolean().optional(),
|
|
241
|
-
telematicsDeviceIsConnected: zod.z.boolean().optional(),
|
|
242
|
-
types: zod.z.array(zod.z.string()).optional(),
|
|
243
|
-
})
|
|
244
|
-
.strip();
|
|
245
|
-
/**
|
|
246
|
-
* Type guard for plain (non-array) objects so unknown payloads can be traversed safely.
|
|
247
|
-
*
|
|
248
|
-
* @param value - Unknown value to test.
|
|
249
|
-
* @returns {boolean} True when the value is a non-null, non-array object.
|
|
250
|
-
*/
|
|
251
|
-
const isPlainObject = (value) => {
|
|
252
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* Recursively strips properties whose value is `null` so they are treated as omitted.
|
|
256
|
-
*
|
|
257
|
-
* The generated `AssetFiltersInput` uses InputMaybe (`T | null | undefined`), and
|
|
258
|
-
* `useActiveAssetFilters` emits `null` for unset fields. The zod schema rejects `null`,
|
|
259
|
-
* so this deep-strips `null`-valued properties from plain objects, recursing into nested
|
|
260
|
-
* plain objects and arrays of plain objects. Non-null values are returned unchanged.
|
|
261
|
-
*
|
|
262
|
-
* @param value - Unknown payload to normalize.
|
|
263
|
-
* @returns {unknown} The payload with all `null`-valued properties removed.
|
|
264
|
-
*/
|
|
265
|
-
const stripNullProperties = (value) => {
|
|
266
|
-
if (Array.isArray(value)) {
|
|
267
|
-
return value.map(stripNullProperties);
|
|
268
|
-
}
|
|
269
|
-
if (isPlainObject(value)) {
|
|
270
|
-
const result = {};
|
|
271
|
-
for (const [key, propertyValue] of Object.entries(value)) {
|
|
272
|
-
if (propertyValue === null) {
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
result[key] = stripNullProperties(propertyValue);
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
return value;
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Validates an unknown payload against the supported public GraphQL AssetFiltersInput subset.
|
|
283
|
-
*
|
|
284
|
-
* Unknown/unsupported keys are stripped; invalid values for supported fields produce an error.
|
|
285
|
-
*
|
|
286
|
-
* @param input - Unknown hash payload supplied to /goto/assets or /goto/map.
|
|
287
|
-
* @returns {ParseAssetFiltersInputResult} The stripped, validated subset or a validation error.
|
|
288
|
-
*/
|
|
289
|
-
const parseAssetFiltersInput = (input) => {
|
|
290
|
-
const parsed = assetFiltersInputSchema.safeParse(stripNullProperties(input));
|
|
291
|
-
if (!parsed.success) {
|
|
292
|
-
return { success: false, error: parsed.error.message };
|
|
293
|
-
}
|
|
294
|
-
return { success: true, data: parsed.data };
|
|
295
|
-
};
|
|
296
|
-
|
|
297
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
298
55
|
const isStringFilterValue = (value) => {
|
|
299
56
|
return typeof value === "string";
|
|
@@ -528,6 +285,106 @@ value) => {
|
|
|
528
285
|
return { period: "LIFETIME", range: { min, max } };
|
|
529
286
|
};
|
|
530
287
|
|
|
288
|
+
const accessManagementMode = {
|
|
289
|
+
LOCKED_FOR_ALL: "LOCKED_FOR_ALL",
|
|
290
|
+
UNKNOWN: "UNKNOWN",
|
|
291
|
+
UNLOCKED_FOR_ALL: "UNLOCKED_FOR_ALL",
|
|
292
|
+
UNLOCKED_FOR_KEY: "UNLOCKED_FOR_KEY",
|
|
293
|
+
UNSUPPORTED: "UNSUPPORTED",
|
|
294
|
+
};
|
|
295
|
+
const assetActivityState = {
|
|
296
|
+
IDLING: "IDLING",
|
|
297
|
+
STOPPED: "STOPPED",
|
|
298
|
+
UNKNOWN: "UNKNOWN",
|
|
299
|
+
WORKING: "WORKING",
|
|
300
|
+
};
|
|
301
|
+
const assetCriticalityState = {
|
|
302
|
+
CRITICAL: "CRITICAL",
|
|
303
|
+
LOW: "LOW",
|
|
304
|
+
NONE: "NONE",
|
|
305
|
+
};
|
|
306
|
+
const assetLastSeen = {
|
|
307
|
+
LAST_7_DAYS: "LAST_7_DAYS",
|
|
308
|
+
LAST_24_HOURS: "LAST_24_HOURS",
|
|
309
|
+
LAST_30_DAYS: "LAST_30_DAYS",
|
|
310
|
+
LAST_HOUR: "LAST_HOUR",
|
|
311
|
+
OLDER_THAN_30_DAYS: "OLDER_THAN_30_DAYS",
|
|
312
|
+
};
|
|
313
|
+
const assetType = {
|
|
314
|
+
ATTACHMENT: "ATTACHMENT",
|
|
315
|
+
EQUIPMENT: "EQUIPMENT",
|
|
316
|
+
GATEWAY: "GATEWAY",
|
|
317
|
+
MACHINE: "MACHINE",
|
|
318
|
+
OTHER: "OTHER",
|
|
319
|
+
TOOL: "TOOL",
|
|
320
|
+
VEHICLE: "VEHICLE",
|
|
321
|
+
};
|
|
322
|
+
const fleetDataHealthDeviceStatus = {
|
|
323
|
+
CRITICAL: "CRITICAL",
|
|
324
|
+
LOW: "LOW",
|
|
325
|
+
};
|
|
326
|
+
const fleetDataHealthIssueCategory = {
|
|
327
|
+
COVERAGE: "COVERAGE",
|
|
328
|
+
DEVICE_BATTERY: "DEVICE_BATTERY",
|
|
329
|
+
INSTALL_AND_CONFIGURATION: "INSTALL_AND_CONFIGURATION",
|
|
330
|
+
NON_REPORTING_DEVICE: "NON_REPORTING_DEVICE",
|
|
331
|
+
};
|
|
332
|
+
const fleetDataHealthIssueState = {
|
|
333
|
+
OPEN: "OPEN",
|
|
334
|
+
RESOLVED: "RESOLVED",
|
|
335
|
+
};
|
|
336
|
+
const fleetDataHealthIssueType = {
|
|
337
|
+
DATA_NOT_RECEIVED: "DATA_NOT_RECEIVED",
|
|
338
|
+
DEVICE_BATTERY_APPROACHING_END_OF_LIFE: "DEVICE_BATTERY_APPROACHING_END_OF_LIFE",
|
|
339
|
+
LOW_CELLULAR_COVERAGE: "LOW_CELLULAR_COVERAGE",
|
|
340
|
+
LOW_DEVICE_BATTERY: "LOW_DEVICE_BATTERY",
|
|
341
|
+
LOW_DEVICE_INPUT_VOLTAGE: "LOW_DEVICE_INPUT_VOLTAGE",
|
|
342
|
+
LOW_GPS_COVERAGE: "LOW_GPS_COVERAGE",
|
|
343
|
+
NO_CAN_DATA_CONFIGURATION: "NO_CAN_DATA_CONFIGURATION",
|
|
344
|
+
OPERATING_HOURS_FROM_CAN_MODIFIED: "OPERATING_HOURS_FROM_CAN_MODIFIED",
|
|
345
|
+
OPERATING_HOURS_REPORTING_0_HOURS_PER_DAY: "OPERATING_HOURS_REPORTING_0_HOURS_PER_DAY",
|
|
346
|
+
OPERATING_HOURS_REPORTING_24_HOURS_PER_DAY: "OPERATING_HOURS_REPORTING_24_HOURS_PER_DAY",
|
|
347
|
+
UNUSUAL_OPERATING_HOURS: "UNUSUAL_OPERATING_HOURS",
|
|
348
|
+
};
|
|
349
|
+
const metadataCompleteness = {
|
|
350
|
+
COMPLETE: "COMPLETE",
|
|
351
|
+
PARTIAL: "PARTIAL",
|
|
352
|
+
};
|
|
353
|
+
const rentalStatus = {
|
|
354
|
+
AVAILABLE: "AVAILABLE",
|
|
355
|
+
IN_REPAIR: "IN_REPAIR",
|
|
356
|
+
NOT_ON_CONTRACT: "NOT_ON_CONTRACT",
|
|
357
|
+
OFF_RENT: "OFF_RENT",
|
|
358
|
+
ON_RENT: "ON_RENT",
|
|
359
|
+
OTHER: "OTHER",
|
|
360
|
+
PICK_UP_READY: "PICK_UP_READY",
|
|
361
|
+
RESERVED: "RESERVED",
|
|
362
|
+
RETURNED: "RETURNED",
|
|
363
|
+
TRANSFER: "TRANSFER",
|
|
364
|
+
};
|
|
365
|
+
const servicePlanStatus = {
|
|
366
|
+
COMPLETE: "COMPLETE",
|
|
367
|
+
DRAFT: "DRAFT",
|
|
368
|
+
FULLY_CONFIGURED: "FULLY_CONFIGURED",
|
|
369
|
+
HAS_PLAN: "HAS_PLAN",
|
|
370
|
+
HAS_SERVICE_PROVIDER: "HAS_SERVICE_PROVIDER",
|
|
371
|
+
MISSING_PLAN: "MISSING_PLAN",
|
|
372
|
+
MISSING_PROVIDER: "MISSING_PROVIDER",
|
|
373
|
+
OVERDUE: "OVERDUE",
|
|
374
|
+
PLANNED: "PLANNED",
|
|
375
|
+
UNKNOWN: "UNKNOWN",
|
|
376
|
+
UPCOMING: "UPCOMING",
|
|
377
|
+
};
|
|
378
|
+
const siteTypeSFS = {
|
|
379
|
+
AREA: "AREA",
|
|
380
|
+
CLASSIC_POI: "CLASSIC_POI",
|
|
381
|
+
CLASSIC_ZONE: "CLASSIC_ZONE",
|
|
382
|
+
CONSTRUCTION_SITE: "CONSTRUCTION_SITE",
|
|
383
|
+
DEPOT: "DEPOT",
|
|
384
|
+
NOT_ON_SITE: "NOT_ON_SITE",
|
|
385
|
+
WORK_PLACE: "WORK_PLACE",
|
|
386
|
+
};
|
|
387
|
+
|
|
531
388
|
const CustomFieldPrefix$1 = "cf__";
|
|
532
389
|
/**
|
|
533
390
|
* Converts custom field filters to a format that can be used by the GraphQL API
|
|
@@ -705,221 +562,6 @@ const useActiveAssetFilters = (filters) => {
|
|
|
705
562
|
};
|
|
706
563
|
const booleanArraySchema = zod.z.array(zod.z.boolean());
|
|
707
564
|
|
|
708
|
-
/**
|
|
709
|
-
* Map plain strings to ValueName objects (inverse of valueNameArrayOrUndefined).
|
|
710
|
-
*/
|
|
711
|
-
const toValueNameArray = (values) => {
|
|
712
|
-
return values.map(value => ({ name: value, value }));
|
|
713
|
-
};
|
|
714
|
-
/**
|
|
715
|
-
* Wrap a boolean in a boolean filter value (inverse of valueBooleanOrUndefined).
|
|
716
|
-
*/
|
|
717
|
-
const toBooleanFilterValue = (booleanValue) => {
|
|
718
|
-
return { booleanValue };
|
|
719
|
-
};
|
|
720
|
-
/**
|
|
721
|
-
* Map a number range to a min/max filter value (inverse of minMaxFilterValueToNumberRange).
|
|
722
|
-
*/
|
|
723
|
-
const toMinMaxFilterValue = (range) => {
|
|
724
|
-
return { min: range.min, max: range.max };
|
|
725
|
-
};
|
|
726
|
-
/**
|
|
727
|
-
* Converts a public GraphQL AssetFiltersInput-shaped object to Manager filter-bar values.
|
|
728
|
-
*
|
|
729
|
-
* @param input - Unknown hash payload supplied to /goto/assets or /goto/map.
|
|
730
|
-
* @returns {AssetFiltersInputToFilterBarValuesResult} A conversion result with stripped unsupported fields or validation errors for invalid supported fields.
|
|
731
|
-
*/
|
|
732
|
-
const convertAssetFiltersInputToFilterBarValues = (input) => {
|
|
733
|
-
const parsed = parseAssetFiltersInput(input);
|
|
734
|
-
if (!parsed.success) {
|
|
735
|
-
return { success: false, error: parsed.error };
|
|
736
|
-
}
|
|
737
|
-
const filterBarValues = {};
|
|
738
|
-
if (parsed.data.searchQuery !== undefined) {
|
|
739
|
-
filterBarValues.search = parsed.data.searchQuery;
|
|
740
|
-
}
|
|
741
|
-
if (parsed.data.assetIds !== undefined) {
|
|
742
|
-
filterBarValues.assetIds = parsed.data.assetIds;
|
|
743
|
-
}
|
|
744
|
-
if (parsed.data.siteIds !== undefined) {
|
|
745
|
-
filterBarValues.siteIds = toValueNameArray(parsed.data.siteIds);
|
|
746
|
-
}
|
|
747
|
-
if (parsed.data.groups !== undefined) {
|
|
748
|
-
filterBarValues.groups = toValueNameArray(parsed.data.groups);
|
|
749
|
-
}
|
|
750
|
-
if (parsed.data.ownerAccountIds !== undefined) {
|
|
751
|
-
filterBarValues.ownerAccountIds = toValueNameArray(parsed.data.ownerAccountIds);
|
|
752
|
-
}
|
|
753
|
-
if (parsed.data.customerIds !== undefined) {
|
|
754
|
-
filterBarValues.customerIds = toValueNameArray(parsed.data.customerIds);
|
|
755
|
-
}
|
|
756
|
-
if (parsed.data.owningDepotSiteIds !== undefined) {
|
|
757
|
-
filterBarValues.siteDepotOwnershipIds = toValueNameArray(parsed.data.owningDepotSiteIds);
|
|
758
|
-
}
|
|
759
|
-
if (parsed.data.brands !== undefined) {
|
|
760
|
-
filterBarValues.brands = parsed.data.brands;
|
|
761
|
-
}
|
|
762
|
-
if (parsed.data.types !== undefined) {
|
|
763
|
-
filterBarValues.types = parsed.data.types;
|
|
764
|
-
}
|
|
765
|
-
if (parsed.data.models !== undefined) {
|
|
766
|
-
filterBarValues.models = parsed.data.models;
|
|
767
|
-
}
|
|
768
|
-
if (parsed.data.pendingTelematicsDevices !== undefined) {
|
|
769
|
-
filterBarValues.pendingTelematicsDevices = parsed.data.pendingTelematicsDevices;
|
|
770
|
-
}
|
|
771
|
-
if (parsed.data.deviceTypes !== undefined) {
|
|
772
|
-
filterBarValues.deviceTypes = toValueNameArray(parsed.data.deviceTypes);
|
|
773
|
-
}
|
|
774
|
-
if (parsed.data.activities !== undefined) {
|
|
775
|
-
filterBarValues.activity = parsed.data.activities;
|
|
776
|
-
}
|
|
777
|
-
if (parsed.data.assetTypes !== undefined) {
|
|
778
|
-
filterBarValues.assetType = parsed.data.assetTypes;
|
|
779
|
-
}
|
|
780
|
-
if (parsed.data.criticalities !== undefined) {
|
|
781
|
-
filterBarValues.criticality = parsed.data.criticalities;
|
|
782
|
-
}
|
|
783
|
-
if (parsed.data.rentalStatuses !== undefined) {
|
|
784
|
-
filterBarValues.rentalStatuses = parsed.data.rentalStatuses;
|
|
785
|
-
}
|
|
786
|
-
if (parsed.data.siteTypes !== undefined) {
|
|
787
|
-
filterBarValues.siteType = parsed.data.siteTypes;
|
|
788
|
-
}
|
|
789
|
-
if (parsed.data.fleetHealthTypes !== undefined) {
|
|
790
|
-
filterBarValues.fleetHealthTypes = toValueNameArray(parsed.data.fleetHealthTypes);
|
|
791
|
-
}
|
|
792
|
-
if (parsed.data.fleetHealthCategories !== undefined) {
|
|
793
|
-
filterBarValues.fleetHealthCategories = toValueNameArray(parsed.data.fleetHealthCategories);
|
|
794
|
-
}
|
|
795
|
-
if (parsed.data.fleetHealthDeviceStatuses !== undefined) {
|
|
796
|
-
filterBarValues.fleetHealthStatus = toValueNameArray(parsed.data.fleetHealthDeviceStatuses);
|
|
797
|
-
}
|
|
798
|
-
if (parsed.data.accessManagementDesiredModes !== undefined) {
|
|
799
|
-
filterBarValues.accessManagementMode = parsed.data.accessManagementDesiredModes;
|
|
800
|
-
}
|
|
801
|
-
if (parsed.data.activeFilter !== undefined) {
|
|
802
|
-
filterBarValues.activeFilter = toBooleanFilterValue(parsed.data.activeFilter);
|
|
803
|
-
}
|
|
804
|
-
if (parsed.data.telematicsDeviceIsConnected !== undefined) {
|
|
805
|
-
filterBarValues.telematicsConnected = toBooleanFilterValue(parsed.data.telematicsDeviceIsConnected);
|
|
806
|
-
}
|
|
807
|
-
if (parsed.data.sustainabilityExcluded !== undefined) {
|
|
808
|
-
filterBarValues.assetVisibility = toBooleanFilterValue(parsed.data.sustainabilityExcluded);
|
|
809
|
-
}
|
|
810
|
-
if (parsed.data.area !== undefined) {
|
|
811
|
-
filterBarValues.area = parsed.data.area;
|
|
812
|
-
}
|
|
813
|
-
if (parsed.data.lastSeen !== undefined) {
|
|
814
|
-
filterBarValues.lastSeen = parsed.data.lastSeen;
|
|
815
|
-
}
|
|
816
|
-
if (parsed.data.metadataCompleteness !== undefined) {
|
|
817
|
-
filterBarValues.metadataCompleteness = { name: parsed.data.metadataCompleteness, value: parsed.data.metadataCompleteness };
|
|
818
|
-
}
|
|
819
|
-
if (parsed.data.serviceBooked !== undefined) {
|
|
820
|
-
filterBarValues.serviceBooked = parsed.data.serviceBooked;
|
|
821
|
-
}
|
|
822
|
-
if (parsed.data.servicePlanAssignments !== undefined) {
|
|
823
|
-
filterBarValues.servicePlanStatus = parsed.data.servicePlanAssignments;
|
|
824
|
-
}
|
|
825
|
-
if (parsed.data.servicePlanIds !== undefined) {
|
|
826
|
-
filterBarValues.servicePlan = toValueNameArray(parsed.data.servicePlanIds);
|
|
827
|
-
}
|
|
828
|
-
if (parsed.data.servicePlanStatuses !== undefined) {
|
|
829
|
-
filterBarValues.serviceStatus = parsed.data.servicePlanStatuses;
|
|
830
|
-
}
|
|
831
|
-
if (parsed.data.serviceProviderIds !== undefined) {
|
|
832
|
-
filterBarValues.serviceProvider = toValueNameArray(parsed.data.serviceProviderIds);
|
|
833
|
-
}
|
|
834
|
-
if (parsed.data.partnerId !== undefined) {
|
|
835
|
-
filterBarValues.partner = toValueNameArray([parsed.data.partnerId]);
|
|
836
|
-
}
|
|
837
|
-
if (parsed.data.rentalContractOrderNumbers !== undefined) {
|
|
838
|
-
filterBarValues.rentalContractOrderNumber = parsed.data.rentalContractOrderNumbers;
|
|
839
|
-
}
|
|
840
|
-
if (parsed.data.rentalContractReferenceCodes !== undefined) {
|
|
841
|
-
filterBarValues.rentalContractReferenceCode = parsed.data.rentalContractReferenceCodes;
|
|
842
|
-
}
|
|
843
|
-
if (parsed.data.rentalContractReferenceCodeDescriptionQuery !== undefined) {
|
|
844
|
-
filterBarValues.rentalContractReferenceCodeDescriptionQuery =
|
|
845
|
-
parsed.data.rentalContractReferenceCodeDescriptionQuery;
|
|
846
|
-
}
|
|
847
|
-
if (parsed.data.rentalActiveContractFilters?.onRentDatesDateRange !== undefined) {
|
|
848
|
-
filterBarValues.rentalActiveContractItemOnRentDatesDateRange =
|
|
849
|
-
parsed.data.rentalActiveContractFilters.onRentDatesDateRange;
|
|
850
|
-
}
|
|
851
|
-
if (parsed.data.rentalActiveContractFilters?.offRentDatesDateRange !== undefined) {
|
|
852
|
-
filterBarValues.rentalActiveContractItemOffRentDatesDateRange =
|
|
853
|
-
parsed.data.rentalActiveContractFilters.offRentDatesDateRange;
|
|
854
|
-
}
|
|
855
|
-
if (parsed.data.rentalActiveContractFilters?.customerExternalReferences !== undefined) {
|
|
856
|
-
filterBarValues.rentalContractCustomerExternalReference =
|
|
857
|
-
parsed.data.rentalActiveContractFilters.customerExternalReferences;
|
|
858
|
-
}
|
|
859
|
-
if (parsed.data.rentalActiveContractFilters?.customerParentExternalReferences !== undefined) {
|
|
860
|
-
filterBarValues.rentalContractCustomerParentExternalReference =
|
|
861
|
-
parsed.data.rentalActiveContractFilters.customerParentExternalReferences;
|
|
862
|
-
}
|
|
863
|
-
if (parsed.data.rentalActiveContractFilters?.customerParentNames !== undefined) {
|
|
864
|
-
filterBarValues.rentalContractCustomerParentName = parsed.data.rentalActiveContractFilters.customerParentNames;
|
|
865
|
-
}
|
|
866
|
-
if (parsed.data.insightsFilters?.fuelLevel !== undefined) {
|
|
867
|
-
filterBarValues.insightsFuelLevel = toMinMaxFilterValue(parsed.data.insightsFilters.fuelLevel);
|
|
868
|
-
}
|
|
869
|
-
if (parsed.data.insightsFilters?.afterTreatmentDieselExhaustFluidTankLevel !== undefined) {
|
|
870
|
-
filterBarValues.insightsAfterTreatmentDieselExhaustFluidTankLevel = toMinMaxFilterValue(parsed.data.insightsFilters.afterTreatmentDieselExhaustFluidTankLevel);
|
|
871
|
-
}
|
|
872
|
-
if (parsed.data.insightsFilters?.batteryPotential !== undefined) {
|
|
873
|
-
filterBarValues.insightsBatteryPotential = toMinMaxFilterValue(parsed.data.insightsFilters.batteryPotential);
|
|
874
|
-
}
|
|
875
|
-
if (parsed.data.insightsFilters?.batteryStateOfChargePercent !== undefined) {
|
|
876
|
-
filterBarValues.insightsBatteryStateOfChargePercent = toMinMaxFilterValue(parsed.data.insightsFilters.batteryStateOfChargePercent);
|
|
877
|
-
}
|
|
878
|
-
if (parsed.data.insightsFilters?.cumulativeIdleHours !== undefined) {
|
|
879
|
-
filterBarValues.insightsCumulativeIdleHours = toMinMaxFilterValue(parsed.data.insightsFilters.cumulativeIdleHours.range);
|
|
880
|
-
}
|
|
881
|
-
if (parsed.data.insightsFilters?.cumulativeOperatingHours !== undefined) {
|
|
882
|
-
filterBarValues.insightsCumulativeOperatingHours = toMinMaxFilterValue(parsed.data.insightsFilters.cumulativeOperatingHours.range);
|
|
883
|
-
}
|
|
884
|
-
if (parsed.data.insightsFilters?.batteryChargerState?.[0] !== undefined) {
|
|
885
|
-
const value = String(parsed.data.insightsFilters.batteryChargerState[0]);
|
|
886
|
-
filterBarValues.insightsBatteryChargerState = { name: value, value };
|
|
887
|
-
}
|
|
888
|
-
parsed.data.customFields?.forEach(customField => {
|
|
889
|
-
if (!customField.definitionId) {
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
const key = `${CustomFieldPrefix}${customField.definitionId}`;
|
|
893
|
-
if (customField.stringWildcardValue !== undefined) {
|
|
894
|
-
filterBarValues[key] = customField.stringWildcardValue;
|
|
895
|
-
}
|
|
896
|
-
else if (customField.stringArrayValue !== undefined) {
|
|
897
|
-
filterBarValues[key] = customField.stringArrayValue;
|
|
898
|
-
}
|
|
899
|
-
else if (customField.numberRange !== undefined) {
|
|
900
|
-
filterBarValues[key] = { min: customField.numberRange.from, max: customField.numberRange.to };
|
|
901
|
-
}
|
|
902
|
-
else if (customField.dateRange !== undefined) {
|
|
903
|
-
filterBarValues[key] = customField.dateRange;
|
|
904
|
-
}
|
|
905
|
-
else if (customField.booleanValue !== undefined) {
|
|
906
|
-
filterBarValues[key] = toBooleanFilterValue(customField.booleanValue);
|
|
907
|
-
}
|
|
908
|
-
});
|
|
909
|
-
return { success: true, filterBarValues };
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
* Exposes the AssetFiltersInput converter through a stable hook API.
|
|
914
|
-
*
|
|
915
|
-
* @returns {{ assetFiltersInputToFilterBarValues: (input: unknown) => AssetFiltersInputToFilterBarValuesResult }} Stable converter API.
|
|
916
|
-
*/
|
|
917
|
-
const useAssetFiltersInputToFilterBarValues = () => {
|
|
918
|
-
return react.useMemo(() => ({
|
|
919
|
-
assetFiltersInputToFilterBarValues: convertAssetFiltersInputToFilterBarValues,
|
|
920
|
-
}), []);
|
|
921
|
-
};
|
|
922
|
-
|
|
923
565
|
/**
|
|
924
566
|
* Sort properties that require an aggregation period
|
|
925
567
|
*/
|
|
@@ -1003,7 +645,6 @@ exports.minMaxFilterValueToNumberRange = minMaxFilterValueToNumberRange;
|
|
|
1003
645
|
exports.positiveValueBooleanOrNull = positiveValueBooleanOrNull;
|
|
1004
646
|
exports.stringArrayOrUndefined = stringArrayOrUndefined;
|
|
1005
647
|
exports.useActiveAssetFilters = useActiveAssetFilters;
|
|
1006
|
-
exports.useAssetFiltersInputToFilterBarValues = useAssetFiltersInputToFilterBarValues;
|
|
1007
648
|
exports.useAssetQueryFilters = useAssetQueryFilters;
|
|
1008
649
|
exports.useAssetSortInput = useAssetSortInput;
|
|
1009
650
|
exports.useCustomFieldFilters = useCustomFieldFilters;
|