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