@trackunit/react-core-contexts-api 0.2.42 → 0.2.44

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 CHANGED
@@ -38,6 +38,42 @@ exports.AssetSortByProperty = void 0;
38
38
  AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
39
39
  AssetSortByProperty["Type"] = "TYPE";
40
40
  })(exports.AssetSortByProperty || (exports.AssetSortByProperty = {}));
41
+ /**
42
+ * Ensures that a string is a valid AssetSortByProperty enum value
43
+ *
44
+ * @param input A string to test against AssetSortByProperty
45
+ * @returns {AssetSortByProperty.Activity} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
46
+ */
47
+ const validateStringAsAssetSortByProperty = (input) => {
48
+ var _a;
49
+ const fallback = exports.AssetSortByProperty.Activity;
50
+ // The type [key in AssetSortByProperty] will insure that ALL keys are present
51
+ const stringToEnum = {
52
+ ACTIVITY: exports.AssetSortByProperty.Activity,
53
+ BRAND: exports.AssetSortByProperty.Brand,
54
+ CATEGORY: exports.AssetSortByProperty.Category,
55
+ CRITICALITY: exports.AssetSortByProperty.Criticality,
56
+ DIGITAL_KEY_MODE: exports.AssetSortByProperty.DigitalKeyMode,
57
+ EXTERNAL_REFERENCE: exports.AssetSortByProperty.ExternalReference,
58
+ LOCATION: exports.AssetSortByProperty.Location,
59
+ LOCATION_UPDATED_AT: exports.AssetSortByProperty.LocationUpdatedAt,
60
+ MODEL: exports.AssetSortByProperty.Model,
61
+ NAME: exports.AssetSortByProperty.Name,
62
+ OWNER_ACCOUNT_NAME: exports.AssetSortByProperty.OwnerAccountName,
63
+ PRODUCTION_YEAR: exports.AssetSortByProperty.ProductionYear,
64
+ SERIAL_NUMBER: exports.AssetSortByProperty.SerialNumber,
65
+ SERVICE_PLAN_ASSIGNMENT_STATUS: exports.AssetSortByProperty.ServicePlanAssignmentStatus,
66
+ SERVICE_PLAN_OVERDUENESS: exports.AssetSortByProperty.ServicePlanOverdueness,
67
+ SERVICE_PLAN_STATUS: exports.AssetSortByProperty.ServicePlanStatus,
68
+ TELEMATICS_DEVICE_SERIAL_NUMBER: exports.AssetSortByProperty.TelematicsDeviceSerialNumber,
69
+ TYPE: exports.AssetSortByProperty.Type,
70
+ };
71
+ if (!input) {
72
+ return fallback;
73
+ }
74
+ // Try to get the enum value from the string. -> Fallback to the default
75
+ return (_a = stringToEnum[input]) !== null && _a !== void 0 ? _a : fallback;
76
+ };
41
77
  exports.SortOrder = void 0;
42
78
  (function (SortOrder) {
43
79
  SortOrder["Asc"] = "ASC";
@@ -59,3 +95,4 @@ const UserSubscriptionPackage = {
59
95
 
60
96
  exports.UserSubscriptionPackage = UserSubscriptionPackage;
61
97
  exports.createEvent = createEvent;
98
+ exports.validateStringAsAssetSortByProperty = validateStringAsAssetSortByProperty;
package/index.js CHANGED
@@ -34,6 +34,42 @@ var AssetSortByProperty;
34
34
  AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
35
35
  AssetSortByProperty["Type"] = "TYPE";
36
36
  })(AssetSortByProperty || (AssetSortByProperty = {}));
37
+ /**
38
+ * Ensures that a string is a valid AssetSortByProperty enum value
39
+ *
40
+ * @param input A string to test against AssetSortByProperty
41
+ * @returns {AssetSortByProperty.Activity} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
42
+ */
43
+ const validateStringAsAssetSortByProperty = (input) => {
44
+ var _a;
45
+ const fallback = AssetSortByProperty.Activity;
46
+ // The type [key in AssetSortByProperty] will insure that ALL keys are present
47
+ const stringToEnum = {
48
+ ACTIVITY: AssetSortByProperty.Activity,
49
+ BRAND: AssetSortByProperty.Brand,
50
+ CATEGORY: AssetSortByProperty.Category,
51
+ CRITICALITY: AssetSortByProperty.Criticality,
52
+ DIGITAL_KEY_MODE: AssetSortByProperty.DigitalKeyMode,
53
+ EXTERNAL_REFERENCE: AssetSortByProperty.ExternalReference,
54
+ LOCATION: AssetSortByProperty.Location,
55
+ LOCATION_UPDATED_AT: AssetSortByProperty.LocationUpdatedAt,
56
+ MODEL: AssetSortByProperty.Model,
57
+ NAME: AssetSortByProperty.Name,
58
+ OWNER_ACCOUNT_NAME: AssetSortByProperty.OwnerAccountName,
59
+ PRODUCTION_YEAR: AssetSortByProperty.ProductionYear,
60
+ SERIAL_NUMBER: AssetSortByProperty.SerialNumber,
61
+ SERVICE_PLAN_ASSIGNMENT_STATUS: AssetSortByProperty.ServicePlanAssignmentStatus,
62
+ SERVICE_PLAN_OVERDUENESS: AssetSortByProperty.ServicePlanOverdueness,
63
+ SERVICE_PLAN_STATUS: AssetSortByProperty.ServicePlanStatus,
64
+ TELEMATICS_DEVICE_SERIAL_NUMBER: AssetSortByProperty.TelematicsDeviceSerialNumber,
65
+ TYPE: AssetSortByProperty.Type,
66
+ };
67
+ if (!input) {
68
+ return fallback;
69
+ }
70
+ // Try to get the enum value from the string. -> Fallback to the default
71
+ return (_a = stringToEnum[input]) !== null && _a !== void 0 ? _a : fallback;
72
+ };
37
73
  var SortOrder;
38
74
  (function (SortOrder) {
39
75
  SortOrder["Asc"] = "ASC";
@@ -53,4 +89,4 @@ const UserSubscriptionPackage = {
53
89
  NONE: "NONE",
54
90
  };
55
91
 
56
- export { AssetSortByProperty, SortOrder, UserSubscriptionPackage, createEvent };
92
+ export { AssetSortByProperty, SortOrder, UserSubscriptionPackage, createEvent, validateStringAsAssetSortByProperty };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-api",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -28,6 +28,13 @@ export declare enum AssetSortByProperty {
28
28
  TelematicsDeviceSerialNumber = "TELEMATICS_DEVICE_SERIAL_NUMBER",
29
29
  Type = "TYPE"
30
30
  }
31
+ /**
32
+ * Ensures that a string is a valid AssetSortByProperty enum value
33
+ *
34
+ * @param input A string to test against AssetSortByProperty
35
+ * @returns {AssetSortByProperty.Activity} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
36
+ */
37
+ export declare const validateStringAsAssetSortByProperty: (input?: string) => AssetSortByProperty;
31
38
  export declare enum SortOrder {
32
39
  Asc = "ASC",
33
40
  Desc = "DESC"