@trackunit/filters-graphql-hook 0.0.478 → 0.0.480
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 +27 -7
- package/index.esm.js +26 -8
- package/package.json +1 -1
- package/src/fixTypes.d.ts +10 -1
package/index.cjs.js
CHANGED
|
@@ -141,12 +141,20 @@ value) => {
|
|
|
141
141
|
return undefined;
|
|
142
142
|
};
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* Type guard to check if a value is a single ValueName object
|
|
145
145
|
*/
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
146
|
const isValueName = (value) => {
|
|
148
|
-
return (
|
|
149
|
-
value
|
|
147
|
+
return (typeof value === "object" &&
|
|
148
|
+
value !== null &&
|
|
149
|
+
// eslint-disable-next-line no-autofix/local-rules/prefer-custom-object-keys
|
|
150
|
+
Object.keys(value).includes("name") &&
|
|
151
|
+
Object.keys(value).includes("value"));
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Check if value is ValueName[]
|
|
155
|
+
*/
|
|
156
|
+
const isValueNameArray = (value) => {
|
|
157
|
+
return Array.isArray(value) && value.every(isValueName);
|
|
150
158
|
};
|
|
151
159
|
/**
|
|
152
160
|
* Check if value is ValueName[] or undefined
|
|
@@ -154,11 +162,20 @@ const isValueName = (value) => {
|
|
|
154
162
|
const valueNameArrayOrUndefined = (
|
|
155
163
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
164
|
input) => {
|
|
157
|
-
if (
|
|
165
|
+
if (isValueNameArray(input) && input.length > 0) {
|
|
158
166
|
return input.map(item => item.value);
|
|
159
167
|
}
|
|
160
168
|
return undefined;
|
|
161
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Check if value is ValueName or undefined
|
|
172
|
+
*/
|
|
173
|
+
const valueNameOrUndefined = (
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
+
input) => {
|
|
176
|
+
return isValueName(input) ? input : undefined;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
162
179
|
/**
|
|
163
180
|
* Check if value is boolean or undefined
|
|
164
181
|
*/
|
|
@@ -350,9 +367,10 @@ const useActiveAssetFilters = (filters) => {
|
|
|
350
367
|
models: stringArrayOrUndefined(filters.models),
|
|
351
368
|
ownerAccountIds: valueNameArrayOrUndefined(filters.ownerAccountIds),
|
|
352
369
|
assetTypes: fixTypes(filters.assetType, assetType),
|
|
353
|
-
metadataCompleteness: (
|
|
370
|
+
metadataCompleteness: !valueNameOrUndefined(filters.metadataCompleteness) ||
|
|
371
|
+
((_b = valueNameOrUndefined(filters.metadataCompleteness)) === null || _b === void 0 ? void 0 : _b.value) === "ALL"
|
|
354
372
|
? undefined
|
|
355
|
-
: (_c =
|
|
373
|
+
: fixType((_c = valueNameOrUndefined(filters.metadataCompleteness)) === null || _c === void 0 ? void 0 : _c.value, metadataCompleteness),
|
|
356
374
|
serviceBooked: parsedServiceBooked.success ? parsedServiceBooked.data : undefined,
|
|
357
375
|
servicePlanAssignments: fixTypes(filters.servicePlanStatus, servicePlanStatus),
|
|
358
376
|
servicePlanIds: valueNameArrayOrUndefined(filters.servicePlan),
|
|
@@ -443,6 +461,7 @@ exports.fixTypes = fixTypes;
|
|
|
443
461
|
exports.geoJsonSimplifiedPolygonSchema = geoJsonSimplifiedPolygonSchema;
|
|
444
462
|
exports.isStringArrayValue = isStringArrayValue;
|
|
445
463
|
exports.isValueName = isValueName;
|
|
464
|
+
exports.isValueNameArray = isValueNameArray;
|
|
446
465
|
exports.positiveValueBooleanOrNull = positiveValueBooleanOrNull;
|
|
447
466
|
exports.stringArrayOrUndefined = stringArrayOrUndefined;
|
|
448
467
|
exports.useActiveAssetFilters = useActiveAssetFilters;
|
|
@@ -451,4 +470,5 @@ exports.useAssetSortInput = useAssetSortInput;
|
|
|
451
470
|
exports.useCustomFieldFilters = useCustomFieldFilters;
|
|
452
471
|
exports.valueBooleanOrUndefined = valueBooleanOrUndefined;
|
|
453
472
|
exports.valueNameArrayOrUndefined = valueNameArrayOrUndefined;
|
|
473
|
+
exports.valueNameOrUndefined = valueNameOrUndefined;
|
|
454
474
|
exports.valuesIfNotEmpty = valuesIfNotEmpty;
|
package/index.esm.js
CHANGED
|
@@ -139,12 +139,20 @@ value) => {
|
|
|
139
139
|
return undefined;
|
|
140
140
|
};
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
142
|
+
* Type guard to check if a value is a single ValueName object
|
|
143
143
|
*/
|
|
144
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
144
|
const isValueName = (value) => {
|
|
146
|
-
return (
|
|
147
|
-
value
|
|
145
|
+
return (typeof value === "object" &&
|
|
146
|
+
value !== null &&
|
|
147
|
+
// eslint-disable-next-line no-autofix/local-rules/prefer-custom-object-keys
|
|
148
|
+
Object.keys(value).includes("name") &&
|
|
149
|
+
Object.keys(value).includes("value"));
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Check if value is ValueName[]
|
|
153
|
+
*/
|
|
154
|
+
const isValueNameArray = (value) => {
|
|
155
|
+
return Array.isArray(value) && value.every(isValueName);
|
|
148
156
|
};
|
|
149
157
|
/**
|
|
150
158
|
* Check if value is ValueName[] or undefined
|
|
@@ -152,11 +160,20 @@ const isValueName = (value) => {
|
|
|
152
160
|
const valueNameArrayOrUndefined = (
|
|
153
161
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
162
|
input) => {
|
|
155
|
-
if (
|
|
163
|
+
if (isValueNameArray(input) && input.length > 0) {
|
|
156
164
|
return input.map(item => item.value);
|
|
157
165
|
}
|
|
158
166
|
return undefined;
|
|
159
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Check if value is ValueName or undefined
|
|
170
|
+
*/
|
|
171
|
+
const valueNameOrUndefined = (
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
+
input) => {
|
|
174
|
+
return isValueName(input) ? input : undefined;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
160
177
|
/**
|
|
161
178
|
* Check if value is boolean or undefined
|
|
162
179
|
*/
|
|
@@ -348,9 +365,10 @@ const useActiveAssetFilters = (filters) => {
|
|
|
348
365
|
models: stringArrayOrUndefined(filters.models),
|
|
349
366
|
ownerAccountIds: valueNameArrayOrUndefined(filters.ownerAccountIds),
|
|
350
367
|
assetTypes: fixTypes(filters.assetType, assetType),
|
|
351
|
-
metadataCompleteness: (
|
|
368
|
+
metadataCompleteness: !valueNameOrUndefined(filters.metadataCompleteness) ||
|
|
369
|
+
((_b = valueNameOrUndefined(filters.metadataCompleteness)) === null || _b === void 0 ? void 0 : _b.value) === "ALL"
|
|
352
370
|
? undefined
|
|
353
|
-
: (_c =
|
|
371
|
+
: fixType((_c = valueNameOrUndefined(filters.metadataCompleteness)) === null || _c === void 0 ? void 0 : _c.value, metadataCompleteness),
|
|
354
372
|
serviceBooked: parsedServiceBooked.success ? parsedServiceBooked.data : undefined,
|
|
355
373
|
servicePlanAssignments: fixTypes(filters.servicePlanStatus, servicePlanStatus),
|
|
356
374
|
servicePlanIds: valueNameArrayOrUndefined(filters.servicePlan),
|
|
@@ -434,4 +452,4 @@ const useAssetQueryFilters = (props) => {
|
|
|
434
452
|
*/
|
|
435
453
|
setupLibraryTranslations();
|
|
436
454
|
|
|
437
|
-
export { CustomFieldPrefix, convertToAssetSortInput, fixType, fixTypes, geoJsonSimplifiedPolygonSchema, isStringArrayValue, isValueName, positiveValueBooleanOrNull, stringArrayOrUndefined, useActiveAssetFilters, useAssetQueryFilters, useAssetSortInput, useCustomFieldFilters, valueBooleanOrUndefined, valueNameArrayOrUndefined, valuesIfNotEmpty };
|
|
455
|
+
export { CustomFieldPrefix, convertToAssetSortInput, fixType, fixTypes, geoJsonSimplifiedPolygonSchema, isStringArrayValue, isValueName, isValueNameArray, positiveValueBooleanOrNull, stringArrayOrUndefined, useActiveAssetFilters, useAssetQueryFilters, useAssetSortInput, useCustomFieldFilters, valueBooleanOrUndefined, valueNameArrayOrUndefined, valueNameOrUndefined, valuesIfNotEmpty };
|
package/package.json
CHANGED
package/src/fixTypes.d.ts
CHANGED
|
@@ -28,14 +28,23 @@ export declare const isStringArrayValue: (value: any) => value is string[];
|
|
|
28
28
|
* Check if value is string array or undefined
|
|
29
29
|
*/
|
|
30
30
|
export declare const stringArrayOrUndefined: (value: any) => string[] | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Type guard to check if a value is a single ValueName object
|
|
33
|
+
*/
|
|
34
|
+
export declare const isValueName: (value: unknown) => value is ValueName;
|
|
31
35
|
/**
|
|
32
36
|
* Check if value is ValueName[]
|
|
33
37
|
*/
|
|
34
|
-
export declare const
|
|
38
|
+
export declare const isValueNameArray: (value: unknown) => value is ValueName[];
|
|
35
39
|
/**
|
|
36
40
|
* Check if value is ValueName[] or undefined
|
|
37
41
|
*/
|
|
38
42
|
export declare const valueNameArrayOrUndefined: (input: any) => string[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Check if value is ValueName or undefined
|
|
45
|
+
*/
|
|
46
|
+
export declare const valueNameOrUndefined: (input: any) => ValueName | undefined;
|
|
47
|
+
/**
|
|
39
48
|
/**
|
|
40
49
|
* Check if value is boolean or undefined
|
|
41
50
|
*/
|