@trackunit/custom-field-api 0.1.83 → 0.1.86
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 +202 -28
- package/index.esm.js +203 -30
- package/package.json +1 -1
- package/src/generated/graphql-api/gql.d.ts +2 -2
- package/src/generated/graphql-api/graphql.d.ts +145 -28
- package/src/index.d.ts +1 -1
- package/src/useCustomFieldDefinitions.d.ts +5 -8
package/index.cjs.js
CHANGED
|
@@ -22,13 +22,13 @@ const CustomFieldValueAndDefinitionFragmentDoc = {
|
|
|
22
22
|
kind: "SelectionSet",
|
|
23
23
|
selections: [
|
|
24
24
|
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
25
|
-
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
26
25
|
{
|
|
27
26
|
kind: "Field",
|
|
28
27
|
name: { kind: "Name", value: "definition" },
|
|
29
28
|
selectionSet: {
|
|
30
29
|
kind: "SelectionSet",
|
|
31
30
|
selections: [
|
|
31
|
+
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
32
32
|
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
33
33
|
{
|
|
34
34
|
kind: "Field",
|
|
@@ -36,6 +36,7 @@ const CustomFieldValueAndDefinitionFragmentDoc = {
|
|
|
36
36
|
selectionSet: {
|
|
37
37
|
kind: "SelectionSet",
|
|
38
38
|
selections: [
|
|
39
|
+
{ kind: "Field", name: { kind: "Name", value: "ownerType" } },
|
|
39
40
|
{ kind: "Field", name: { kind: "Name", value: "irisAppId" } },
|
|
40
41
|
{
|
|
41
42
|
kind: "Field",
|
|
@@ -257,11 +258,97 @@ const CustomFieldDefinitionFragmentDoc = {
|
|
|
257
258
|
name: { kind: "Name", value: "owner" },
|
|
258
259
|
selectionSet: {
|
|
259
260
|
kind: "SelectionSet",
|
|
260
|
-
selections: [
|
|
261
|
+
selections: [
|
|
262
|
+
{ kind: "Field", name: { kind: "Name", value: "ownerType" } },
|
|
263
|
+
{ kind: "Field", name: { kind: "Name", value: "irisAppId" } },
|
|
264
|
+
{
|
|
265
|
+
kind: "Field",
|
|
266
|
+
name: { kind: "Name", value: "marketplaceEntry" },
|
|
267
|
+
selectionSet: {
|
|
268
|
+
kind: "SelectionSet",
|
|
269
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "name" } }],
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
],
|
|
261
273
|
},
|
|
262
274
|
},
|
|
263
275
|
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
276
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
277
|
+
{ kind: "Field", name: { kind: "Name", value: "title" } },
|
|
278
|
+
{ kind: "Field", name: { kind: "Name", value: "description" } },
|
|
264
279
|
{ kind: "Field", name: { kind: "Name", value: "uiEditable" } },
|
|
280
|
+
{ kind: "Field", name: { kind: "Name", value: "uiVisible" } },
|
|
281
|
+
{ kind: "Field", name: { kind: "Name", value: "key" } },
|
|
282
|
+
{ kind: "Field", name: { kind: "Name", value: "entityType" } },
|
|
283
|
+
{
|
|
284
|
+
kind: "InlineFragment",
|
|
285
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "DropDownFieldDefinition" } },
|
|
286
|
+
selectionSet: {
|
|
287
|
+
kind: "SelectionSet",
|
|
288
|
+
selections: [
|
|
289
|
+
{ kind: "Field", name: { kind: "Name", value: "allValues" } },
|
|
290
|
+
{ kind: "Field", name: { kind: "Name", value: "multiSelect" } },
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
kind: "InlineFragment",
|
|
296
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "NumberFieldDefinition" } },
|
|
297
|
+
selectionSet: {
|
|
298
|
+
kind: "SelectionSet",
|
|
299
|
+
selections: [
|
|
300
|
+
{
|
|
301
|
+
kind: "Field",
|
|
302
|
+
name: { kind: "Name", value: "minimumNumber" },
|
|
303
|
+
arguments: [
|
|
304
|
+
{
|
|
305
|
+
kind: "Argument",
|
|
306
|
+
name: { kind: "Name", value: "systemOfMeasurement" },
|
|
307
|
+
value: { kind: "Variable", name: { kind: "Name", value: "systemOfMeasurement" } },
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
kind: "Field",
|
|
313
|
+
name: { kind: "Name", value: "maximumNumber" },
|
|
314
|
+
arguments: [
|
|
315
|
+
{
|
|
316
|
+
kind: "Argument",
|
|
317
|
+
name: { kind: "Name", value: "systemOfMeasurement" },
|
|
318
|
+
value: { kind: "Variable", name: { kind: "Name", value: "systemOfMeasurement" } },
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
},
|
|
322
|
+
{ kind: "Field", name: { kind: "Name", value: "unitSi" } },
|
|
323
|
+
{ kind: "Field", name: { kind: "Name", value: "unitUs" } },
|
|
324
|
+
{ kind: "Field", name: { kind: "Name", value: "isInteger" } },
|
|
325
|
+
],
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
kind: "InlineFragment",
|
|
330
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "MonetaryFieldDefinition" } },
|
|
331
|
+
selectionSet: {
|
|
332
|
+
kind: "SelectionSet",
|
|
333
|
+
selections: [
|
|
334
|
+
{ kind: "Field", name: { kind: "Name", value: "minimumNumber" } },
|
|
335
|
+
{ kind: "Field", name: { kind: "Name", value: "maximumNumber" } },
|
|
336
|
+
{ kind: "Field", name: { kind: "Name", value: "currency" } },
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
kind: "InlineFragment",
|
|
342
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "StringFieldDefinition" } },
|
|
343
|
+
selectionSet: {
|
|
344
|
+
kind: "SelectionSet",
|
|
345
|
+
selections: [
|
|
346
|
+
{ kind: "Field", name: { kind: "Name", value: "maximumLength" } },
|
|
347
|
+
{ kind: "Field", name: { kind: "Name", value: "minimumLength" } },
|
|
348
|
+
{ kind: "Field", name: { kind: "Name", value: "pattern" } },
|
|
349
|
+
],
|
|
350
|
+
},
|
|
351
|
+
},
|
|
265
352
|
],
|
|
266
353
|
},
|
|
267
354
|
},
|
|
@@ -347,13 +434,13 @@ const GetCustomFieldsForAssetDocument = {
|
|
|
347
434
|
kind: "SelectionSet",
|
|
348
435
|
selections: [
|
|
349
436
|
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
350
|
-
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
351
437
|
{
|
|
352
438
|
kind: "Field",
|
|
353
439
|
name: { kind: "Name", value: "definition" },
|
|
354
440
|
selectionSet: {
|
|
355
441
|
kind: "SelectionSet",
|
|
356
442
|
selections: [
|
|
443
|
+
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
357
444
|
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
358
445
|
{
|
|
359
446
|
kind: "Field",
|
|
@@ -361,6 +448,7 @@ const GetCustomFieldsForAssetDocument = {
|
|
|
361
448
|
selectionSet: {
|
|
362
449
|
kind: "SelectionSet",
|
|
363
450
|
selections: [
|
|
451
|
+
{ kind: "Field", name: { kind: "Name", value: "ownerType" } },
|
|
364
452
|
{ kind: "Field", name: { kind: "Name", value: "irisAppId" } },
|
|
365
453
|
{
|
|
366
454
|
kind: "Field",
|
|
@@ -634,13 +722,13 @@ const GetCustomFieldsForSiteDocument = {
|
|
|
634
722
|
kind: "SelectionSet",
|
|
635
723
|
selections: [
|
|
636
724
|
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
637
|
-
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
638
725
|
{
|
|
639
726
|
kind: "Field",
|
|
640
727
|
name: { kind: "Name", value: "definition" },
|
|
641
728
|
selectionSet: {
|
|
642
729
|
kind: "SelectionSet",
|
|
643
730
|
selections: [
|
|
731
|
+
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
644
732
|
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
645
733
|
{
|
|
646
734
|
kind: "Field",
|
|
@@ -648,6 +736,7 @@ const GetCustomFieldsForSiteDocument = {
|
|
|
648
736
|
selectionSet: {
|
|
649
737
|
kind: "SelectionSet",
|
|
650
738
|
selections: [
|
|
739
|
+
{ kind: "Field", name: { kind: "Name", value: "ownerType" } },
|
|
651
740
|
{ kind: "Field", name: { kind: "Name", value: "irisAppId" } },
|
|
652
741
|
{
|
|
653
742
|
kind: "Field",
|
|
@@ -855,6 +944,11 @@ const GetCustomFieldDefinitionsDocument = {
|
|
|
855
944
|
type: { kind: "NamedType", name: { kind: "Name", value: "CustomFieldEntityType" } },
|
|
856
945
|
defaultValue: { kind: "EnumValue", value: "ASSET" },
|
|
857
946
|
},
|
|
947
|
+
{
|
|
948
|
+
kind: "VariableDefinition",
|
|
949
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "systemOfMeasurement" } },
|
|
950
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "SystemOfMeasurement" } },
|
|
951
|
+
},
|
|
858
952
|
],
|
|
859
953
|
selectionSet: {
|
|
860
954
|
kind: "SelectionSet",
|
|
@@ -897,20 +991,6 @@ const GetCustomFieldDefinitionsDocument = {
|
|
|
897
991
|
],
|
|
898
992
|
},
|
|
899
993
|
},
|
|
900
|
-
{
|
|
901
|
-
kind: "Field",
|
|
902
|
-
name: { kind: "Name", value: "pageInfo" },
|
|
903
|
-
selectionSet: {
|
|
904
|
-
kind: "SelectionSet",
|
|
905
|
-
selections: [
|
|
906
|
-
{ kind: "Field", name: { kind: "Name", value: "count" } },
|
|
907
|
-
{ kind: "Field", name: { kind: "Name", value: "endCursor" } },
|
|
908
|
-
{ kind: "Field", name: { kind: "Name", value: "hasNextPage" } },
|
|
909
|
-
{ kind: "Field", name: { kind: "Name", value: "hasPreviousPage" } },
|
|
910
|
-
{ kind: "Field", name: { kind: "Name", value: "startCursor" } },
|
|
911
|
-
],
|
|
912
|
-
},
|
|
913
|
-
},
|
|
914
994
|
],
|
|
915
995
|
},
|
|
916
996
|
},
|
|
@@ -942,11 +1022,97 @@ const GetCustomFieldDefinitionsDocument = {
|
|
|
942
1022
|
name: { kind: "Name", value: "owner" },
|
|
943
1023
|
selectionSet: {
|
|
944
1024
|
kind: "SelectionSet",
|
|
945
|
-
selections: [
|
|
1025
|
+
selections: [
|
|
1026
|
+
{ kind: "Field", name: { kind: "Name", value: "ownerType" } },
|
|
1027
|
+
{ kind: "Field", name: { kind: "Name", value: "irisAppId" } },
|
|
1028
|
+
{
|
|
1029
|
+
kind: "Field",
|
|
1030
|
+
name: { kind: "Name", value: "marketplaceEntry" },
|
|
1031
|
+
selectionSet: {
|
|
1032
|
+
kind: "SelectionSet",
|
|
1033
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "name" } }],
|
|
1034
|
+
},
|
|
1035
|
+
},
|
|
1036
|
+
],
|
|
946
1037
|
},
|
|
947
1038
|
},
|
|
948
1039
|
{ kind: "Field", name: { kind: "Name", value: "type" } },
|
|
1040
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
1041
|
+
{ kind: "Field", name: { kind: "Name", value: "title" } },
|
|
1042
|
+
{ kind: "Field", name: { kind: "Name", value: "description" } },
|
|
949
1043
|
{ kind: "Field", name: { kind: "Name", value: "uiEditable" } },
|
|
1044
|
+
{ kind: "Field", name: { kind: "Name", value: "uiVisible" } },
|
|
1045
|
+
{ kind: "Field", name: { kind: "Name", value: "key" } },
|
|
1046
|
+
{ kind: "Field", name: { kind: "Name", value: "entityType" } },
|
|
1047
|
+
{
|
|
1048
|
+
kind: "InlineFragment",
|
|
1049
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "DropDownFieldDefinition" } },
|
|
1050
|
+
selectionSet: {
|
|
1051
|
+
kind: "SelectionSet",
|
|
1052
|
+
selections: [
|
|
1053
|
+
{ kind: "Field", name: { kind: "Name", value: "allValues" } },
|
|
1054
|
+
{ kind: "Field", name: { kind: "Name", value: "multiSelect" } },
|
|
1055
|
+
],
|
|
1056
|
+
},
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
kind: "InlineFragment",
|
|
1060
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "NumberFieldDefinition" } },
|
|
1061
|
+
selectionSet: {
|
|
1062
|
+
kind: "SelectionSet",
|
|
1063
|
+
selections: [
|
|
1064
|
+
{
|
|
1065
|
+
kind: "Field",
|
|
1066
|
+
name: { kind: "Name", value: "minimumNumber" },
|
|
1067
|
+
arguments: [
|
|
1068
|
+
{
|
|
1069
|
+
kind: "Argument",
|
|
1070
|
+
name: { kind: "Name", value: "systemOfMeasurement" },
|
|
1071
|
+
value: { kind: "Variable", name: { kind: "Name", value: "systemOfMeasurement" } },
|
|
1072
|
+
},
|
|
1073
|
+
],
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
kind: "Field",
|
|
1077
|
+
name: { kind: "Name", value: "maximumNumber" },
|
|
1078
|
+
arguments: [
|
|
1079
|
+
{
|
|
1080
|
+
kind: "Argument",
|
|
1081
|
+
name: { kind: "Name", value: "systemOfMeasurement" },
|
|
1082
|
+
value: { kind: "Variable", name: { kind: "Name", value: "systemOfMeasurement" } },
|
|
1083
|
+
},
|
|
1084
|
+
],
|
|
1085
|
+
},
|
|
1086
|
+
{ kind: "Field", name: { kind: "Name", value: "unitSi" } },
|
|
1087
|
+
{ kind: "Field", name: { kind: "Name", value: "unitUs" } },
|
|
1088
|
+
{ kind: "Field", name: { kind: "Name", value: "isInteger" } },
|
|
1089
|
+
],
|
|
1090
|
+
},
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
kind: "InlineFragment",
|
|
1094
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "MonetaryFieldDefinition" } },
|
|
1095
|
+
selectionSet: {
|
|
1096
|
+
kind: "SelectionSet",
|
|
1097
|
+
selections: [
|
|
1098
|
+
{ kind: "Field", name: { kind: "Name", value: "minimumNumber" } },
|
|
1099
|
+
{ kind: "Field", name: { kind: "Name", value: "maximumNumber" } },
|
|
1100
|
+
{ kind: "Field", name: { kind: "Name", value: "currency" } },
|
|
1101
|
+
],
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
kind: "InlineFragment",
|
|
1106
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "StringFieldDefinition" } },
|
|
1107
|
+
selectionSet: {
|
|
1108
|
+
kind: "SelectionSet",
|
|
1109
|
+
selections: [
|
|
1110
|
+
{ kind: "Field", name: { kind: "Name", value: "maximumLength" } },
|
|
1111
|
+
{ kind: "Field", name: { kind: "Name", value: "minimumLength" } },
|
|
1112
|
+
{ kind: "Field", name: { kind: "Name", value: "pattern" } },
|
|
1113
|
+
],
|
|
1114
|
+
},
|
|
1115
|
+
},
|
|
950
1116
|
],
|
|
951
1117
|
},
|
|
952
1118
|
},
|
|
@@ -961,11 +1127,12 @@ const getCustomFieldDefinitionFromRelevantNode = (node) => getFragmentData(Custo
|
|
|
961
1127
|
* @param {SupportedEntityTypes} [props.entityType] - The type of the entity (e.g., 'ASSET' or 'SITE').
|
|
962
1128
|
* @returns {UseCustomFieldDefinitionsReturnValue} An object containing a loading state and an array of custom field definitions.
|
|
963
1129
|
*/
|
|
964
|
-
const useCustomFieldDefinitions = ({ entityType, filterQuery, owners, onlyEditable }) => {
|
|
1130
|
+
const useCustomFieldDefinitions = ({ entityType, filterQuery, owners, systemOfMeasurement, onlyEditable, }) => {
|
|
965
1131
|
var _a;
|
|
966
1132
|
const { data: definitions, loading } = client.useQuery(GetCustomFieldDefinitionsDocument, {
|
|
967
1133
|
variables: {
|
|
968
1134
|
entityType,
|
|
1135
|
+
systemOfMeasurement,
|
|
969
1136
|
},
|
|
970
1137
|
context: {
|
|
971
1138
|
headers: {
|
|
@@ -984,16 +1151,22 @@ const useCustomFieldDefinitions = ({ entityType, filterQuery, owners, onlyEditab
|
|
|
984
1151
|
.filter(def => { var _a; return (owners && ((_a = def.owner) === null || _a === void 0 ? void 0 : _a.ownerType) ? owners.includes(def.owner.ownerType) : true); })
|
|
985
1152
|
.filter(def => (onlyEditable ? def.uiEditable : true))
|
|
986
1153
|
.map(def => {
|
|
987
|
-
var _a, _b, _c
|
|
988
|
-
return ({
|
|
989
|
-
id: def.id,
|
|
990
|
-
title: (_c = (_b = (_a = def.translations) === null || _a === void 0 ? void 0 : _a.find(t => (t === null || t === void 0 ? void 0 : t.language) === language || (t === null || t === void 0 ? void 0 : t.language) === "en")) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : "",
|
|
991
|
-
type: def.type,
|
|
992
|
-
owner: (_d = def.owner) === null || _d === void 0 ? void 0 : _d.ownerType,
|
|
993
|
-
});
|
|
1154
|
+
var _a, _b, _c;
|
|
1155
|
+
return (Object.assign(Object.assign({}, def), { title: (_c = (_b = (_a = def.translations) === null || _a === void 0 ? void 0 : _a.find(t => (t === null || t === void 0 ? void 0 : t.language) === language || (t === null || t === void 0 ? void 0 : t.language) === "en")) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : "" }));
|
|
994
1156
|
})
|
|
995
1157
|
.filter(def => (filterQuery ? def.title.toLowerCase().includes(filterQuery.toLowerCase()) : true)), [definitionsArray, filterQuery, language, owners, onlyEditable]);
|
|
996
|
-
|
|
1158
|
+
const appNameFromId = react.useCallback((appId) => {
|
|
1159
|
+
var _a, _b, _c, _d;
|
|
1160
|
+
if (!appId) {
|
|
1161
|
+
return undefined;
|
|
1162
|
+
}
|
|
1163
|
+
const matching = filteredDefinitions.find(definition => { var _a; return ((_a = definition.owner) === null || _a === void 0 ? void 0 : _a.irisAppId) === appId; });
|
|
1164
|
+
if (!matching) {
|
|
1165
|
+
return undefined;
|
|
1166
|
+
}
|
|
1167
|
+
return (_c = (_b = (_a = matching.owner) === null || _a === void 0 ? void 0 : _a.marketplaceEntry) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : (_d = matching.owner) === null || _d === void 0 ? void 0 : _d.irisAppId;
|
|
1168
|
+
}, [filteredDefinitions]);
|
|
1169
|
+
return react.useMemo(() => ({ definitions: filteredDefinitions, loading, appNameFromId }), [filteredDefinitions, loading, appNameFromId]);
|
|
997
1170
|
};
|
|
998
1171
|
|
|
999
1172
|
/**
|
|
@@ -1098,6 +1271,7 @@ const customFieldHasValue = (field) => {
|
|
|
1098
1271
|
}
|
|
1099
1272
|
};
|
|
1100
1273
|
|
|
1274
|
+
exports.GetCustomFieldDefinitionsDocument = GetCustomFieldDefinitionsDocument;
|
|
1101
1275
|
exports.GetCustomFieldsForAssetDocument = GetCustomFieldsForAssetDocument;
|
|
1102
1276
|
exports.GetCustomFieldsForSiteDocument = GetCustomFieldsForSiteDocument;
|
|
1103
1277
|
exports.customFieldHasValue = customFieldHasValue;
|