@trackunit/iris-app-runtime-core-api 1.7.76 → 1.7.78

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 CHANGED
@@ -1,5 +1,111 @@
1
1
  'use strict';
2
2
 
3
+ var sharedUtils = require('@trackunit/shared-utils');
4
+
5
+ /**
6
+ * Takes an event type and a description and returns an event
7
+ *
8
+ * @template TEventType The event type.
9
+ * Use existing from EventTypes.ts or make custom inline for one offs.
10
+ * Defaults to BaseEvent
11
+ * @param {{ description: string }} event with the interface of the event type to be filled later
12
+ * @returns {*} {Event<T>}
13
+ */
14
+ const createEvent = (event) => ({
15
+ description: event?.description,
16
+ properties: {},
17
+ });
18
+
19
+ exports.AssetSortByProperty = void 0;
20
+ (function (AssetSortByProperty) {
21
+ AssetSortByProperty["Activity"] = "ACTIVITY";
22
+ AssetSortByProperty["Brand"] = "BRAND";
23
+ AssetSortByProperty["Category"] = "CATEGORY";
24
+ AssetSortByProperty["Criticality"] = "CRITICALITY";
25
+ AssetSortByProperty["CustomField"] = "CUSTOM_FIELD";
26
+ AssetSortByProperty["CustomerName"] = "CUSTOMER_NAME";
27
+ AssetSortByProperty["AccessManagement"] = "ACCESS_MANAGEMENT";
28
+ AssetSortByProperty["ExternalReference"] = "EXTERNAL_REFERENCE";
29
+ AssetSortByProperty["Location"] = "LOCATION";
30
+ AssetSortByProperty["LocationUpdatedAt"] = "LOCATION_UPDATED_AT";
31
+ AssetSortByProperty["Model"] = "MODEL";
32
+ AssetSortByProperty["Name"] = "NAME";
33
+ AssetSortByProperty["OwnerAccountName"] = "OWNER_ACCOUNT_NAME";
34
+ AssetSortByProperty["ProductionYear"] = "PRODUCTION_YEAR";
35
+ AssetSortByProperty["SerialNumber"] = "SERIAL_NUMBER";
36
+ AssetSortByProperty["ServicePlanAssignmentStatus"] = "SERVICE_PLAN_ASSIGNMENT_STATUS";
37
+ AssetSortByProperty["ServicePlanOverdueness"] = "SERVICE_PLAN_OVERDUENESS";
38
+ AssetSortByProperty["ServicePlanStatus"] = "SERVICE_PLAN_STATUS";
39
+ AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
40
+ AssetSortByProperty["Type"] = "TYPE";
41
+ AssetSortByProperty["PlannedServiceBooked"] = "PLANNED_SERVICE_BOOKED";
42
+ AssetSortByProperty["PlannedServiceBookingDate"] = "PLANNED_SERVICE_BOOKING_DATE";
43
+ AssetSortByProperty["ServicePlanPrediction"] = "SERVICE_PLAN_PREDICTION";
44
+ AssetSortByProperty["IssueCreatedAt"] = "ISSUE_CREATED_AT";
45
+ })(exports.AssetSortByProperty || (exports.AssetSortByProperty = {}));
46
+ // The type [key in AssetSortByProperty] will ensure that ALL keys are present
47
+ const stringToEnum = {
48
+ ACTIVITY: exports.AssetSortByProperty.Activity,
49
+ BRAND: exports.AssetSortByProperty.Brand,
50
+ CATEGORY: exports.AssetSortByProperty.Category,
51
+ CUSTOM_FIELD: exports.AssetSortByProperty.CustomField,
52
+ CRITICALITY: exports.AssetSortByProperty.Criticality,
53
+ CUSTOMER_NAME: exports.AssetSortByProperty.CustomerName,
54
+ ACCESS_MANAGEMENT: exports.AssetSortByProperty.AccessManagement,
55
+ EXTERNAL_REFERENCE: exports.AssetSortByProperty.ExternalReference,
56
+ LOCATION: exports.AssetSortByProperty.Location,
57
+ LOCATION_UPDATED_AT: exports.AssetSortByProperty.LocationUpdatedAt,
58
+ MODEL: exports.AssetSortByProperty.Model,
59
+ NAME: exports.AssetSortByProperty.Name,
60
+ OWNER_ACCOUNT_NAME: exports.AssetSortByProperty.OwnerAccountName,
61
+ PRODUCTION_YEAR: exports.AssetSortByProperty.ProductionYear,
62
+ SERIAL_NUMBER: exports.AssetSortByProperty.SerialNumber,
63
+ SERVICE_PLAN_ASSIGNMENT_STATUS: exports.AssetSortByProperty.ServicePlanAssignmentStatus,
64
+ SERVICE_PLAN_OVERDUENESS: exports.AssetSortByProperty.ServicePlanOverdueness,
65
+ SERVICE_PLAN_STATUS: exports.AssetSortByProperty.ServicePlanStatus,
66
+ TELEMATICS_DEVICE_SERIAL_NUMBER: exports.AssetSortByProperty.TelematicsDeviceSerialNumber,
67
+ TYPE: exports.AssetSortByProperty.Type,
68
+ PLANNED_SERVICE_BOOKED: exports.AssetSortByProperty.PlannedServiceBooked,
69
+ PLANNED_SERVICE_BOOKING_DATE: exports.AssetSortByProperty.PlannedServiceBookingDate,
70
+ SERVICE_PLAN_PREDICTION: exports.AssetSortByProperty.ServicePlanPrediction,
71
+ ISSUE_CREATED_AT: exports.AssetSortByProperty.IssueCreatedAt,
72
+ };
73
+ /**
74
+ * Ensures that a string is a valid AssetSortByProperty enum value
75
+ *
76
+ * @param input A string to test against AssetSortByProperty
77
+ * @returns {AssetSortByProperty} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
78
+ */
79
+ const validateStringAsAssetSortByProperty = (input) => {
80
+ const fallback = exports.AssetSortByProperty.Activity;
81
+ if (!input) {
82
+ return { sortBy: fallback };
83
+ }
84
+ // Try to get the enum value from the string. -> Fallback to the default
85
+ if (sharedUtils.isUUID(input)) {
86
+ return {
87
+ sortBy: exports.AssetSortByProperty.CustomField,
88
+ customFieldDefinitionId: input,
89
+ };
90
+ }
91
+ return { sortBy: stringToEnum[input] ?? fallback };
92
+ };
93
+ exports.SortOrder = void 0;
94
+ (function (SortOrder) {
95
+ SortOrder["Asc"] = "ASC";
96
+ SortOrder["Desc"] = "DESC";
97
+ })(exports.SortOrder || (exports.SortOrder = {}));
98
+
99
+ const SystemOfMeasurement = {
100
+ Si: "SI",
101
+ UsCustomary: "US_CUSTOMARY",
102
+ };
103
+ const TimeZonePreference = {
104
+ CustomTimeZone: "CUSTOM_TIME_ZONE",
105
+ LocalTimeZone: "LOCAL_TIME_ZONE",
106
+ MachineTimeZone: "MACHINE_TIME_ZONE",
107
+ };
108
+
3
109
  const UnitOfMeasurement = {
4
110
  NEWTON: "NEWTON",
5
111
  PASCAL: "PASCAL",
@@ -117,12 +223,68 @@ const UnitSi = {
117
223
  hour: "HOUR",
118
224
  };
119
225
 
226
+ const assetHomePageIds = [
227
+ "status",
228
+ "movement",
229
+ "events",
230
+ "insights",
231
+ "specification",
232
+ "telematics",
233
+ "contracts",
234
+ ];
235
+ const siteHomePageIds = ["overview", "assets", "asset-visibility"];
236
+ const groupHomePageIds = ["assets", "users", "details"];
237
+ const customerHomePageIds = ["info", "assets", "contact-list"];
238
+ /**
239
+ * type guard for IrisAppOptions
240
+ */
241
+ const isIrisOptions = (options) => {
242
+ if (!options) {
243
+ return false;
244
+ }
245
+ return (typeof options === "object" &&
246
+ "irisAppId" in options &&
247
+ Boolean(options.irisAppId) &&
248
+ "extensionId" in options);
249
+ };
250
+
120
251
  exports.BodyType = void 0;
121
252
  (function (BodyType) {
122
253
  BodyType[BodyType["Json"] = 0] = "Json";
123
254
  BodyType[BodyType["FormData"] = 1] = "FormData";
124
255
  })(exports.BodyType || (exports.BodyType = {}));
125
256
 
257
+ const UserSubscriptionPackage = {
258
+ ENTRY_FLEET_OWNER: "Entry (Fleet Owner)",
259
+ EXPLORE_FLEET_OWNER: "Explore (Fleet Owner)",
260
+ EVOLVE_FLEET_OWNER: "Evolve (Fleet Owner)",
261
+ EXPAND_FLEET_OWNER: "Expand (Fleet Owner)",
262
+ EXPLORE_OEM: "Explore (OEM)",
263
+ EVOLVE_OEM: "Evolve (OEM)",
264
+ EXPAND_OEM: "Expand (OEM)",
265
+ COLLECT: "COLLECT",
266
+ INSIGHT: "INSIGHT",
267
+ VIEW: "VIEW",
268
+ NONE: "NONE",
269
+ EXPLORE: "Explore",
270
+ EVOLVE: "Evolve",
271
+ EXPAND: "Expand",
272
+ LINK: "Link",
273
+ LIFT: "Lift",
274
+ LEAP: "Leap",
275
+ CUSTOMER_PORTAL: "Customer Portal",
276
+ };
277
+
278
+ exports.SystemOfMeasurement = SystemOfMeasurement;
279
+ exports.TimeZonePreference = TimeZonePreference;
126
280
  exports.UnitOfMeasurement = UnitOfMeasurement;
127
281
  exports.UnitSi = UnitSi;
128
282
  exports.UnitUs = UnitUs;
283
+ exports.UserSubscriptionPackage = UserSubscriptionPackage;
284
+ exports.assetHomePageIds = assetHomePageIds;
285
+ exports.createEvent = createEvent;
286
+ exports.customerHomePageIds = customerHomePageIds;
287
+ exports.groupHomePageIds = groupHomePageIds;
288
+ exports.isIrisOptions = isIrisOptions;
289
+ exports.siteHomePageIds = siteHomePageIds;
290
+ exports.validateStringAsAssetSortByProperty = validateStringAsAssetSortByProperty;
package/index.esm.js CHANGED
@@ -1,3 +1,109 @@
1
+ import { isUUID } from '@trackunit/shared-utils';
2
+
3
+ /**
4
+ * Takes an event type and a description and returns an event
5
+ *
6
+ * @template TEventType The event type.
7
+ * Use existing from EventTypes.ts or make custom inline for one offs.
8
+ * Defaults to BaseEvent
9
+ * @param {{ description: string }} event with the interface of the event type to be filled later
10
+ * @returns {*} {Event<T>}
11
+ */
12
+ const createEvent = (event) => ({
13
+ description: event?.description,
14
+ properties: {},
15
+ });
16
+
17
+ var AssetSortByProperty;
18
+ (function (AssetSortByProperty) {
19
+ AssetSortByProperty["Activity"] = "ACTIVITY";
20
+ AssetSortByProperty["Brand"] = "BRAND";
21
+ AssetSortByProperty["Category"] = "CATEGORY";
22
+ AssetSortByProperty["Criticality"] = "CRITICALITY";
23
+ AssetSortByProperty["CustomField"] = "CUSTOM_FIELD";
24
+ AssetSortByProperty["CustomerName"] = "CUSTOMER_NAME";
25
+ AssetSortByProperty["AccessManagement"] = "ACCESS_MANAGEMENT";
26
+ AssetSortByProperty["ExternalReference"] = "EXTERNAL_REFERENCE";
27
+ AssetSortByProperty["Location"] = "LOCATION";
28
+ AssetSortByProperty["LocationUpdatedAt"] = "LOCATION_UPDATED_AT";
29
+ AssetSortByProperty["Model"] = "MODEL";
30
+ AssetSortByProperty["Name"] = "NAME";
31
+ AssetSortByProperty["OwnerAccountName"] = "OWNER_ACCOUNT_NAME";
32
+ AssetSortByProperty["ProductionYear"] = "PRODUCTION_YEAR";
33
+ AssetSortByProperty["SerialNumber"] = "SERIAL_NUMBER";
34
+ AssetSortByProperty["ServicePlanAssignmentStatus"] = "SERVICE_PLAN_ASSIGNMENT_STATUS";
35
+ AssetSortByProperty["ServicePlanOverdueness"] = "SERVICE_PLAN_OVERDUENESS";
36
+ AssetSortByProperty["ServicePlanStatus"] = "SERVICE_PLAN_STATUS";
37
+ AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
38
+ AssetSortByProperty["Type"] = "TYPE";
39
+ AssetSortByProperty["PlannedServiceBooked"] = "PLANNED_SERVICE_BOOKED";
40
+ AssetSortByProperty["PlannedServiceBookingDate"] = "PLANNED_SERVICE_BOOKING_DATE";
41
+ AssetSortByProperty["ServicePlanPrediction"] = "SERVICE_PLAN_PREDICTION";
42
+ AssetSortByProperty["IssueCreatedAt"] = "ISSUE_CREATED_AT";
43
+ })(AssetSortByProperty || (AssetSortByProperty = {}));
44
+ // The type [key in AssetSortByProperty] will ensure that ALL keys are present
45
+ const stringToEnum = {
46
+ ACTIVITY: AssetSortByProperty.Activity,
47
+ BRAND: AssetSortByProperty.Brand,
48
+ CATEGORY: AssetSortByProperty.Category,
49
+ CUSTOM_FIELD: AssetSortByProperty.CustomField,
50
+ CRITICALITY: AssetSortByProperty.Criticality,
51
+ CUSTOMER_NAME: AssetSortByProperty.CustomerName,
52
+ ACCESS_MANAGEMENT: AssetSortByProperty.AccessManagement,
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
+ PLANNED_SERVICE_BOOKED: AssetSortByProperty.PlannedServiceBooked,
67
+ PLANNED_SERVICE_BOOKING_DATE: AssetSortByProperty.PlannedServiceBookingDate,
68
+ SERVICE_PLAN_PREDICTION: AssetSortByProperty.ServicePlanPrediction,
69
+ ISSUE_CREATED_AT: AssetSortByProperty.IssueCreatedAt,
70
+ };
71
+ /**
72
+ * Ensures that a string is a valid AssetSortByProperty enum value
73
+ *
74
+ * @param input A string to test against AssetSortByProperty
75
+ * @returns {AssetSortByProperty} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
76
+ */
77
+ const validateStringAsAssetSortByProperty = (input) => {
78
+ const fallback = AssetSortByProperty.Activity;
79
+ if (!input) {
80
+ return { sortBy: fallback };
81
+ }
82
+ // Try to get the enum value from the string. -> Fallback to the default
83
+ if (isUUID(input)) {
84
+ return {
85
+ sortBy: AssetSortByProperty.CustomField,
86
+ customFieldDefinitionId: input,
87
+ };
88
+ }
89
+ return { sortBy: stringToEnum[input] ?? fallback };
90
+ };
91
+ var SortOrder;
92
+ (function (SortOrder) {
93
+ SortOrder["Asc"] = "ASC";
94
+ SortOrder["Desc"] = "DESC";
95
+ })(SortOrder || (SortOrder = {}));
96
+
97
+ const SystemOfMeasurement = {
98
+ Si: "SI",
99
+ UsCustomary: "US_CUSTOMARY",
100
+ };
101
+ const TimeZonePreference = {
102
+ CustomTimeZone: "CUSTOM_TIME_ZONE",
103
+ LocalTimeZone: "LOCAL_TIME_ZONE",
104
+ MachineTimeZone: "MACHINE_TIME_ZONE",
105
+ };
106
+
1
107
  const UnitOfMeasurement = {
2
108
  NEWTON: "NEWTON",
3
109
  PASCAL: "PASCAL",
@@ -115,10 +221,56 @@ const UnitSi = {
115
221
  hour: "HOUR",
116
222
  };
117
223
 
224
+ const assetHomePageIds = [
225
+ "status",
226
+ "movement",
227
+ "events",
228
+ "insights",
229
+ "specification",
230
+ "telematics",
231
+ "contracts",
232
+ ];
233
+ const siteHomePageIds = ["overview", "assets", "asset-visibility"];
234
+ const groupHomePageIds = ["assets", "users", "details"];
235
+ const customerHomePageIds = ["info", "assets", "contact-list"];
236
+ /**
237
+ * type guard for IrisAppOptions
238
+ */
239
+ const isIrisOptions = (options) => {
240
+ if (!options) {
241
+ return false;
242
+ }
243
+ return (typeof options === "object" &&
244
+ "irisAppId" in options &&
245
+ Boolean(options.irisAppId) &&
246
+ "extensionId" in options);
247
+ };
248
+
118
249
  var BodyType;
119
250
  (function (BodyType) {
120
251
  BodyType[BodyType["Json"] = 0] = "Json";
121
252
  BodyType[BodyType["FormData"] = 1] = "FormData";
122
253
  })(BodyType || (BodyType = {}));
123
254
 
124
- export { BodyType, UnitOfMeasurement, UnitSi, UnitUs };
255
+ const UserSubscriptionPackage = {
256
+ ENTRY_FLEET_OWNER: "Entry (Fleet Owner)",
257
+ EXPLORE_FLEET_OWNER: "Explore (Fleet Owner)",
258
+ EVOLVE_FLEET_OWNER: "Evolve (Fleet Owner)",
259
+ EXPAND_FLEET_OWNER: "Expand (Fleet Owner)",
260
+ EXPLORE_OEM: "Explore (OEM)",
261
+ EVOLVE_OEM: "Evolve (OEM)",
262
+ EXPAND_OEM: "Expand (OEM)",
263
+ COLLECT: "COLLECT",
264
+ INSIGHT: "INSIGHT",
265
+ VIEW: "VIEW",
266
+ NONE: "NONE",
267
+ EXPLORE: "Explore",
268
+ EVOLVE: "Evolve",
269
+ EXPAND: "Expand",
270
+ LINK: "Link",
271
+ LIFT: "Lift",
272
+ LEAP: "Leap",
273
+ CUSTOMER_PORTAL: "Customer Portal",
274
+ };
275
+
276
+ export { AssetSortByProperty, BodyType, SortOrder, SystemOfMeasurement, TimeZonePreference, UnitOfMeasurement, UnitSi, UnitUs, UserSubscriptionPackage, assetHomePageIds, createEvent, customerHomePageIds, groupHomePageIds, isIrisOptions, siteHomePageIds, validateStringAsAssetSortByProperty };
package/package.json CHANGED
@@ -1,17 +1,15 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-runtime-core-api",
3
- "version": "1.7.76",
3
+ "version": "1.7.78",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=22.x"
8
8
  },
9
9
  "dependencies": {
10
- "jest-fetch-mock": "^3.0.3",
11
- "@trackunit/react-core-contexts-api": "1.8.75",
12
- "@trackunit/react-test-setup": "1.4.70",
13
10
  "@graphql-typed-document-node/core": "^3.2.0",
14
- "@trackunit/shared-utils": "1.9.70"
11
+ "@trackunit/shared-utils": "1.9.72",
12
+ "@trackunit/geo-json-utils": "1.7.72"
15
13
  },
16
14
  "module": "./index.esm.js",
17
15
  "main": "./index.cjs.js",
@@ -0,0 +1,42 @@
1
+ export type AdditionalProperties = Record<string, string | number | boolean | null | undefined | Array<string | number>>;
2
+ export interface BaseEvent {
3
+ additionalProperties?: AdditionalProperties;
4
+ }
5
+ /**
6
+ * Takes an event type and a description and returns an event
7
+ *
8
+ * @template TEventType The event type.
9
+ * Use existing from EventTypes.ts or make custom inline for one offs.
10
+ * Defaults to BaseEvent
11
+ * @param {{ description: string }} event with the interface of the event type to be filled later
12
+ * @returns {*} {Event<T>}
13
+ */
14
+ export declare const createEvent: <TEventType extends object = BaseEvent>(event?: {
15
+ description?: string;
16
+ }) => Event<TEventType>;
17
+ export type UnspecifiedEvent = AdditionalProperties;
18
+ export type Event<T> = {
19
+ description?: string;
20
+ properties: T;
21
+ };
22
+ export type EventDictionary = Record<string, Event<BaseEvent | UnspecifiedEvent>>;
23
+ export interface IAnalyticsContext<Events extends EventDictionary> {
24
+ logEvent<T extends keyof Events>(eventName: T, details: Events[T]["properties"], nameSupplement?: {
25
+ prefix?: string;
26
+ postfix?: string;
27
+ }): void;
28
+ logPageView(details: {
29
+ pageName: string;
30
+ } & BaseEvent): void;
31
+ logError(details: UnspecifiedEvent): void;
32
+ setUserProperty(name: string, data: string | number): void;
33
+ }
34
+ type PromisifyMethod<T> = T extends (...args: infer U) => infer V ? (...args: U) => Promise<V> : T;
35
+ type PromisifyObject<T> = {
36
+ [K in keyof T]: PromisifyMethod<T[K]>;
37
+ };
38
+ export interface IAnalyticsContextAsync<T extends EventDictionary> extends PromisifyObject<IAnalyticsContext<T>> {
39
+ }
40
+ export interface AnalyticsRuntimeApi extends IAnalyticsContextAsync<Record<string, never>> {
41
+ }
42
+ export {};
@@ -1,3 +1,6 @@
1
1
  export interface AssetInfo {
2
2
  assetId: string;
3
3
  }
4
+ export interface AssetRuntimeApi {
5
+ getAssetInfo: () => Promise<AssetInfo>;
6
+ }
@@ -0,0 +1,53 @@
1
+ export declare enum AssetSortByProperty {
2
+ Activity = "ACTIVITY",
3
+ Brand = "BRAND",
4
+ Category = "CATEGORY",
5
+ Criticality = "CRITICALITY",
6
+ CustomField = "CUSTOM_FIELD",
7
+ CustomerName = "CUSTOMER_NAME",
8
+ AccessManagement = "ACCESS_MANAGEMENT",
9
+ ExternalReference = "EXTERNAL_REFERENCE",
10
+ Location = "LOCATION",
11
+ LocationUpdatedAt = "LOCATION_UPDATED_AT",
12
+ Model = "MODEL",
13
+ Name = "NAME",
14
+ OwnerAccountName = "OWNER_ACCOUNT_NAME",
15
+ ProductionYear = "PRODUCTION_YEAR",
16
+ SerialNumber = "SERIAL_NUMBER",
17
+ ServicePlanAssignmentStatus = "SERVICE_PLAN_ASSIGNMENT_STATUS",
18
+ ServicePlanOverdueness = "SERVICE_PLAN_OVERDUENESS",
19
+ ServicePlanStatus = "SERVICE_PLAN_STATUS",
20
+ TelematicsDeviceSerialNumber = "TELEMATICS_DEVICE_SERIAL_NUMBER",
21
+ Type = "TYPE",
22
+ PlannedServiceBooked = "PLANNED_SERVICE_BOOKED",
23
+ PlannedServiceBookingDate = "PLANNED_SERVICE_BOOKING_DATE",
24
+ ServicePlanPrediction = "SERVICE_PLAN_PREDICTION",
25
+ IssueCreatedAt = "ISSUE_CREATED_AT"
26
+ }
27
+ /**
28
+ * Ensures that a string is a valid AssetSortByProperty enum value
29
+ *
30
+ * @param input A string to test against AssetSortByProperty
31
+ * @returns {AssetSortByProperty} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
32
+ */
33
+ export declare const validateStringAsAssetSortByProperty: (input?: string) => {
34
+ sortBy: AssetSortByProperty;
35
+ customFieldDefinitionId?: string;
36
+ };
37
+ export declare enum SortOrder {
38
+ Asc = "ASC",
39
+ Desc = "DESC"
40
+ }
41
+ export interface SortingState {
42
+ customFieldDefinitionId?: string;
43
+ sortBy: AssetSortByProperty;
44
+ order: SortOrder;
45
+ }
46
+ export interface AssetSortingContextValue {
47
+ sortingState: SortingState;
48
+ setSortBy: (sortBy: AssetSortByProperty, order?: SortOrder, customFieldDefinitionId?: string) => void;
49
+ }
50
+ export interface AssetSortingRuntimeApi {
51
+ getAssetSortingState: () => Promise<AssetSortingContextValue["sortingState"]>;
52
+ setAssetSortingState: (...args: Parameters<AssetSortingContextValue["setSortBy"]>) => Promise<void>;
53
+ }
@@ -1,4 +1,7 @@
1
- import { AssetSortingContextValue, FilterBarValues, ITokenContext, TemporalPeriod, TimeRange } from "@trackunit/react-core-contexts-api";
1
+ import { AssetSortingContextValue } from "./AssetSortingRuntime";
2
+ import { FilterBarValues } from "./FilterBarRuntime";
3
+ import { TemporalPeriod, TimeRange } from "./TimeRangeRuntime";
4
+ import { ITokenContext } from "./TokenRuntime";
2
5
  export interface ChildConnectorApi {
3
6
  /**
4
7
  * Gets called when the token changes.
@@ -0,0 +1,13 @@
1
+ export type UserInteractionType = "PRIMARY" | "SECONDARY" | "CLOSE";
2
+ export interface ConfirmationDialogProps {
3
+ title: string;
4
+ message: string | React.ReactNode;
5
+ primaryActionType: "primary" | "primary-danger";
6
+ primaryActionLabel: string;
7
+ secondaryActionLabel?: string;
8
+ }
9
+ export interface ConfirmationDialogContextValue {
10
+ confirm: (props: ConfirmationDialogProps) => Promise<UserInteractionType>;
11
+ }
12
+ export interface ConfirmationDialogRuntimeApi extends ConfirmationDialogContextValue {
13
+ }
@@ -0,0 +1,26 @@
1
+ export declare const SystemOfMeasurement: {
2
+ readonly Si: "SI";
3
+ readonly UsCustomary: "US_CUSTOMARY";
4
+ };
5
+ export declare const TimeZonePreference: {
6
+ readonly CustomTimeZone: "CUSTOM_TIME_ZONE";
7
+ readonly LocalTimeZone: "LOCAL_TIME_ZONE";
8
+ readonly MachineTimeZone: "MACHINE_TIME_ZONE";
9
+ };
10
+ export type SystemOfMeasurementType = (typeof SystemOfMeasurement)[keyof typeof SystemOfMeasurement];
11
+ export type TimeZonePreferenceType = (typeof TimeZonePreference)[keyof typeof TimeZonePreference];
12
+ export interface IUserPreferencesContext {
13
+ language?: string;
14
+ setLanguage?: (language: string) => void;
15
+ timeZonePreference?: TimeZonePreferenceType;
16
+ setTimeZonePreference?: (timeZonePreference: TimeZonePreferenceType) => void;
17
+ systemOfMeasurement?: SystemOfMeasurementType;
18
+ setSystemOfMeasurement?: (systemOfMeasurement: SystemOfMeasurementType) => void;
19
+ }
20
+ export interface ICurrentUserPreferenceContext {
21
+ getCurrentUserLanguage: () => Promise<string>;
22
+ getCurrentUserTimeZonePreference: () => Promise<TimeZonePreferenceType>;
23
+ getCurrentUserSystemOfMeasurement: () => Promise<SystemOfMeasurementType>;
24
+ }
25
+ export interface CurrentUserPreferenceRuntimeApi extends ICurrentUserPreferenceContext {
26
+ }
@@ -6,3 +6,29 @@ export interface CurrentUserRole {
6
6
  name: string;
7
7
  };
8
8
  }
9
+ export interface CurrentUserContextInterface {
10
+ clientSideUserId: string | undefined;
11
+ tasUserId: string | undefined;
12
+ userName: string | undefined;
13
+ userRole: string | undefined;
14
+ userId: number | undefined;
15
+ customerId: number | undefined;
16
+ accountId: string | undefined;
17
+ assumedUser: {
18
+ userId: number;
19
+ customerId: number;
20
+ accountId: string;
21
+ tasUserId: string | undefined;
22
+ } | null;
23
+ email: string | undefined;
24
+ name: string | undefined;
25
+ jobTitle: string | undefined;
26
+ isAssuming: boolean;
27
+ isTrackunitUser: boolean;
28
+ isAuthenticated: boolean;
29
+ isVerified: boolean | undefined;
30
+ isAccountOwner: boolean | undefined;
31
+ }
32
+ export interface CurrentUserRuntimeApi {
33
+ getCurrentUserContext: () => Promise<CurrentUserContextInterface>;
34
+ }
@@ -1,3 +1,6 @@
1
1
  export interface CustomerInfo {
2
2
  customerId: string;
3
3
  }
4
+ export interface CustomerRuntimeApi {
5
+ getCustomerInfo: () => Promise<CustomerInfo>;
6
+ }
@@ -0,0 +1,36 @@
1
+ export interface ITracingHeaders {
2
+ "X-TrackunitAppVersion": string;
3
+ "session-id": string;
4
+ "commit-number": number;
5
+ }
6
+ export interface IEnvironmentContext {
7
+ auth: {
8
+ url: string;
9
+ clientId: string;
10
+ issuer: string;
11
+ };
12
+ tracingHeaders: ITracingHeaders;
13
+ managerClassicUrl: string;
14
+ googleMapsApiKey: string;
15
+ amplitudeApiKey: string;
16
+ amplitudeApiEndpoint: string;
17
+ graphqlPublicUrl: string;
18
+ graphqlInternalUrl: string;
19
+ graphqlReportUrl: string;
20
+ buildVersion: string;
21
+ commitNumber: number;
22
+ publicUrl: string;
23
+ irisAppSdkServerUrl: string;
24
+ isFeatureBranch: boolean;
25
+ environment: "dev" | "stage" | "prod";
26
+ sentryDsn: string;
27
+ sessionId: string;
28
+ uptimeId: string;
29
+ trackunitRestApiUrl: string;
30
+ hubspotRequestAppAccessFormId: string;
31
+ reportAccessCallback: string;
32
+ reportAccessClientId: string;
33
+ }
34
+ export interface EnvironmentRuntimeApi {
35
+ getEnvironmentContext: () => Promise<IEnvironmentContext>;
36
+ }
@@ -0,0 +1,26 @@
1
+ export type Severity = "fatal" | "error" | "warning" | "log" | "info" | "debug";
2
+ export interface Breadcrumb {
3
+ type?: string;
4
+ level?: Severity;
5
+ event_id?: string;
6
+ category?: string;
7
+ message?: string;
8
+ data?: {
9
+ [key: string]: any;
10
+ };
11
+ timestamp?: number;
12
+ }
13
+ export interface CaptureExceptionsOptions {
14
+ fingerprint?: Array<string>;
15
+ level: Severity;
16
+ }
17
+ export interface ErrorHandlingContextValue {
18
+ /**
19
+ * Captures an error event.
20
+ *
21
+ * @param details The error event to capture.
22
+ */
23
+ captureException(details: unknown, options?: CaptureExceptionsOptions): void;
24
+ addBreadcrumb(breadcrumb: Breadcrumb): void;
25
+ setTag(key: string, value?: string | number | bigint | symbol | boolean | null): void;
26
+ }
@@ -1,3 +1,6 @@
1
1
  export interface EventInfo {
2
2
  eventId: string;
3
3
  }
4
+ export interface EventRuntimeApi {
5
+ getEventInfo: () => Promise<EventInfo>;
6
+ }
@@ -0,0 +1,46 @@
1
+ import { GeoJsonMultiPolygon, GeoJsonPolygon } from "@trackunit/geo-json-utils";
2
+ export type ValueName = {
3
+ value: string;
4
+ name: string;
5
+ };
6
+ export type BooleanValue = {
7
+ booleanValue?: boolean;
8
+ };
9
+ export type MinMaxFilterValue = {
10
+ min?: number;
11
+ max?: number;
12
+ };
13
+ export type DateRangeFilterValue = {
14
+ from?: string;
15
+ to?: string;
16
+ };
17
+ export type AreaFilterGeoJsonGeometryType = GeoJsonPolygon | GeoJsonMultiPolygon;
18
+ export type FilterValueType = Array<string> | Array<ValueName> | ValueName | AreaFilterGeoJsonGeometryType | MinMaxFilterValue | DateRangeFilterValue | string | number | BooleanValue | undefined;
19
+ export type FilterBarValues = Record<string, FilterValueType>;
20
+ export interface FilterBarContext {
21
+ /**
22
+ * The filter bar values for assets, keyed by filter key.
23
+ */
24
+ assetsFilterBarValues: FilterBarValues | null;
25
+ /**
26
+ * The filter bar values for customers, keyed by filter key.
27
+ */
28
+ customersFilterBarValues: FilterBarValues | null;
29
+ /**
30
+ * The filter bar values for sites, keyed by filter key.
31
+ */
32
+ sitesFilterBarValues: FilterBarValues | null;
33
+ /**
34
+ * Whether the filter bar values are loading, true if any of the filter bar values are not loaded yet.
35
+ */
36
+ isLoading: boolean;
37
+ }
38
+ export interface FilterBarRuntimeApi {
39
+ /**
40
+ * @deprecated Use getAssetsFilterBarValues instead.
41
+ */
42
+ getFilterBarValues: () => Promise<FilterBarValues | null>;
43
+ getAssetsFilterBarValues: () => Promise<FilterBarValues | null>;
44
+ getCustomersFilterBarValues: () => Promise<FilterBarValues | null>;
45
+ getSitesFilterBarValues: () => Promise<FilterBarValues | null>;
46
+ }
@@ -1,118 +1,25 @@
1
- import { AssetSortingContextValue, ConfirmationDialogContextValue, CurrentUserContextInterface, FilterBarValues, IAnalyticsContextAsync, ICurrentUserPreferenceContext, IEnvironmentContext, INavigationContext, ITokenContext, IUserSubscriptionContext, LoadingState, ModalDialogContextValue, OemBrandingContext, TemporalPeriod, TimeRange } from "@trackunit/react-core-contexts-api";
2
- import { AssetInfo } from "./AssetRuntime";
3
- import { CustomerInfo } from "./CustomerRuntime";
4
- import { EventInfo } from "./EventRuntime";
1
+ import { AnalyticsRuntimeApi } from "./AnalyticsRuntime";
2
+ import { AssetRuntimeApi } from "./AssetRuntime";
3
+ import { AssetSortingRuntimeApi } from "./AssetSortingRuntime";
4
+ import { ConfirmationDialogRuntimeApi } from "./ConfirmationDialogRuntime";
5
+ import { CurrentUserPreferenceRuntimeApi } from "./CurrentUserPreferenceRuntime";
6
+ import { CurrentUserRuntimeApi } from "./CurrentUserRuntime";
7
+ import { CustomerRuntimeApi } from "./CustomerRuntime";
8
+ import { EnvironmentRuntimeApi } from "./EnvironmentRuntime";
9
+ import { EventRuntimeApi } from "./EventRuntime";
5
10
  import { ExportDataRuntimeApi } from "./ExportDataRuntime";
6
- import { BodyType, HttpResponse, RequestParams } from "./RestRuntime";
7
- import { SiteInfo } from "./SiteRuntime";
8
- import { ThemeCssProperties } from "./ThemeCssProperties";
9
- import { PublicToast } from "./ToastRuntime";
10
- export interface HostConnectorApi extends IAnalyticsContextAsync<Record<string, never>>, ExportDataRuntimeApi, INavigationContext, OemBrandingContext, ICurrentUserPreferenceContext, ConfirmationDialogContextValue, ModalDialogContextValue {
11
- getAssetSortingState(): Promise<AssetSortingContextValue["sortingState"]>;
12
- setAssetSortingState(...args: Parameters<AssetSortingContextValue["setSortBy"]>): Promise<void>;
13
- getEnvironmentContext(): Promise<IEnvironmentContext>;
14
- getTokenContext(): Promise<ITokenContext>;
15
- getCurrentUserContext(): Promise<CurrentUserContextInterface>;
16
- getUserSubscriptionContext(): Promise<IUserSubscriptionContext>;
17
- /**
18
- * Used to get the current time range, only if the host page has a time range.
19
- */
20
- getTimeRange(): Promise<{
21
- timeRange: TimeRange | null;
22
- temporalPeriod: TemporalPeriod | null;
23
- }>;
24
- /**
25
- * Gets the data of the widget.
26
- */
27
- getWidgetData(): Promise<Record<string, unknown>>;
28
- /**
29
- * Sets the data of the widget.
30
- * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget.
31
- * Use it to upgrade the widget data to a new version when loading the widget.
32
- *
33
- * @param data the data to set
34
- * @param dataVersion the data version to set
35
- * @param title the title to set
36
- */
37
- setWidgetData(data: Record<string, unknown>, dataVersion: number, title?: string): Promise<void>;
38
- /**
39
- * Gets the data version of the widget.
40
- * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget.
41
- * Use it to upgrade the widget data to a new version when loading the widget.
42
- */
43
- getWidgetDataVersion(): Promise<number>;
44
- /**
45
- * Gets the title of the widget.
46
- */
47
- getWidgetTitle(): Promise<string>;
48
- /**
49
- * Sets the title of the widget.
50
- */
51
- setWidgetTitle(title: string): Promise<void>;
52
- /**
53
- * Opens the edit mode of the widget.
54
- */
55
- openEditMode(): Promise<void>;
56
- /**
57
- * Closes the edit mode of the widget.
58
- */
59
- closeEditMode(): Promise<void>;
60
- /**
61
- * Sets the loading state of the widget.
62
- */
63
- setLoadingState(loadingState: LoadingState): Promise<void>;
64
- /**
65
- * Gets the poll interval of the widget.
66
- */
67
- getWidgetPollInterval(): Promise<number>;
68
- /**
69
- * @deprecated Use { getAssetsFilterBarValues } instead.
70
- * @returns { Promise<FilterBarValues | null> } empty object!
71
- */
72
- getFilterBarValues(): Promise<FilterBarValues | null>;
73
- /**
74
- * Used to get the current filter bar values for assets, only if the host page has a filterbar.
75
- */
76
- getAssetsFilterBarValues(): Promise<FilterBarValues | null>;
77
- /**
78
- * Used to get the current filter bar values for customers, only if the host page has a filterbar.
79
- */
80
- getCustomersFilterBarValues(): Promise<FilterBarValues | null>;
81
- /**
82
- * Used to get the current filter bar values for sites, only if the host page has a filterbar.
83
- */
84
- getSitesFilterBarValues(): Promise<FilterBarValues | null>;
85
- /**
86
- * Adds a toast to the host pages toast stack.
87
- *
88
- * @param toast the toast to add
89
- */
90
- addToast(toast: PublicToast): Promise<void | "primaryAction" | "secondaryAction">;
91
- /**
92
- * Removes a toast from the host pages toast stack.
93
- *
94
- * @param id the id of the toast to remove
95
- */
96
- removeToast(id: string): Promise<void>;
97
- getAppName(): string | undefined;
98
- getOrgName(): string | undefined;
99
- getExtensionName(): string | undefined;
100
- getSiteInfo(): Promise<SiteInfo>;
101
- getAssetInfo(): Promise<AssetInfo>;
102
- getCustomerInfo(): Promise<CustomerInfo>;
103
- getEventInfo(): Promise<EventInfo>;
104
- getThemeCssProperties(): Promise<ThemeCssProperties | null>;
105
- /**
106
- * Requests the rest api.
107
- *
108
- * @deprecated Use the Public Graphql instead.
109
- * @param path the path of the rest api
110
- * @param method the method of the rest api
111
- * @param requestParams the request params of the rest api
112
- * @param body the body of the rest api
113
- * @param bodyType the body type of the rest api
114
- * @param secureByDefault
115
- * @returns { Promise<HttpResponse> } the response from the rest api
116
- */
117
- requestTrackunitRestApi: <TData, TError>(path: string, method: string, requestParams?: RequestParams, body?: unknown, bodyType?: BodyType, secureByDefault?: boolean) => Promise<HttpResponse<TData, TError>>;
11
+ import { FilterBarRuntimeApi } from "./FilterBarRuntime";
12
+ import { ModalDialogRuntimeApi } from "./ModalDialogRuntime";
13
+ import { NavigationRuntimeApi } from "./NavigationRuntime";
14
+ import { OemBrandingRuntimeApi } from "./OemBrandingRuntime";
15
+ import { ParamsRuntimeApi } from "./ParamsRuntime";
16
+ import { RestRuntimeApi } from "./RestRuntime";
17
+ import { SiteRuntimeApi } from "./SiteRuntime";
18
+ import { ThemeCssRuntimeApi } from "./ThemeCssRuntime";
19
+ import { TimeRangeRuntimeApi } from "./TimeRangeRuntime";
20
+ import { ToastRuntimeApi } from "./ToastRuntime";
21
+ import { TokenRuntimeApi } from "./TokenRuntime";
22
+ import { UserSubscriptionRuntimeApi } from "./UserSubscriptionRuntime";
23
+ import { WidgetConfigRuntimeApi } from "./WidgetConfigRuntime";
24
+ export interface HostConnectorApi extends AnalyticsRuntimeApi, AssetRuntimeApi, AssetSortingRuntimeApi, ConfirmationDialogRuntimeApi, CurrentUserPreferenceRuntimeApi, CurrentUserRuntimeApi, CustomerRuntimeApi, EnvironmentRuntimeApi, EventRuntimeApi, ExportDataRuntimeApi, FilterBarRuntimeApi, ModalDialogRuntimeApi, NavigationRuntimeApi, OemBrandingRuntimeApi, RestRuntimeApi, SiteRuntimeApi, ThemeCssRuntimeApi, TimeRangeRuntimeApi, ToastRuntimeApi, TokenRuntimeApi, UserSubscriptionRuntimeApi, ParamsRuntimeApi, WidgetConfigRuntimeApi {
118
25
  }
@@ -0,0 +1,9 @@
1
+ export interface ModalDialogContextValue {
2
+ openModal: ({ scrollX, scrollY }?: {
3
+ scrollX: number;
4
+ scrollY: number;
5
+ }) => Promise<void>;
6
+ closeModal: () => Promise<void>;
7
+ }
8
+ export interface ModalDialogRuntimeApi extends ModalDialogContextValue {
9
+ }
@@ -1,3 +1,77 @@
1
- import { INavigationContext } from "@trackunit/react-core-contexts-api";
2
- export interface INavigationRuntime extends INavigationContext {
1
+ type Page<TPage extends string> = {
2
+ page: TPage;
3
+ } & SubPage & FragmentIdentifier & Search;
4
+ type SubPage = {
5
+ subPage?: string;
6
+ };
7
+ type Search = {
8
+ search?: Record<string, any>;
9
+ };
10
+ type FragmentIdentifier = {
11
+ hash?: string;
12
+ };
13
+ type NeverPage = {
14
+ page?: never;
15
+ };
16
+ type NeverIrisApp = {
17
+ irisAppId?: never;
18
+ extensionId?: never;
19
+ };
20
+ export type IrisAppOptions = {
21
+ irisAppId: string;
22
+ extensionId: string;
23
+ } & SubPage & Search & FragmentIdentifier & NeverPage;
24
+ declare const mainApps: readonly ["reports", "sites", "map", "assets"];
25
+ export type MainFleetApp = (typeof mainApps)[number];
26
+ export type FleetAppStandardOptions = Page<MainFleetApp> & NeverIrisApp;
27
+ export type MapAppStandardOptions = Page<"map"> & NeverIrisApp;
28
+ export type MarketplaceOptions = {
29
+ irisAppId: string;
30
+ };
31
+ export declare const assetHomePageIds: readonly ["status", "movement", "events", "insights", "specification", "telematics", "contracts"];
32
+ export type AssetHomePageId = (typeof assetHomePageIds)[number];
33
+ export type AssetHomeStandardOptions = Page<AssetHomePageId> & NeverIrisApp;
34
+ export declare const siteHomePageIds: readonly ["overview", "assets", "asset-visibility"];
35
+ export type SiteHomePageId = (typeof siteHomePageIds)[number];
36
+ export type SiteHomeStandardOptions = Page<SiteHomePageId> & NeverIrisApp;
37
+ export declare const groupHomePageIds: readonly ["assets", "users", "details"];
38
+ export type GroupHomePageId = (typeof groupHomePageIds)[number];
39
+ export type GroupHomeStandardOptions = Page<GroupHomePageId> & NeverIrisApp;
40
+ export declare const customerHomePageIds: readonly ["info", "assets", "contact-list"];
41
+ export type CustomerHomePageId = (typeof customerHomePageIds)[number];
42
+ export type CustomerHomeStandardOptions = Page<CustomerHomePageId> & NeverIrisApp;
43
+ export type HasAccessToOptions = (IrisAppOptions | AssetHomeStandardOptions | SiteHomeStandardOptions | FleetAppStandardOptions) & {
44
+ assetId?: string;
45
+ siteId?: string;
46
+ };
47
+ /**
48
+ * type guard for IrisAppOptions
49
+ */
50
+ export declare const isIrisOptions: (options: IrisAppOptions | unknown) => options is IrisAppOptions;
51
+ export interface INavigationContext {
52
+ hasAccessTo: (options: HasAccessToOptions) => Promise<boolean>;
53
+ gotoAssetHome: (assetId: string, options?: IrisAppOptions | AssetHomeStandardOptions) => Promise<boolean>;
54
+ gotoSiteHome: (siteId: string, options?: IrisAppOptions | SiteHomeStandardOptions) => Promise<boolean>;
55
+ gotoCustomerHome: (customerId?: string, options?: IrisAppOptions | CustomerHomeStandardOptions) => Promise<boolean>;
56
+ gotoGroupHome: (groupId: string, options?: GroupHomeStandardOptions) => Promise<boolean>;
57
+ gotoAppLibrary: (irisAppId?: string) => Promise<boolean>;
58
+ gotoFleetApp: (options: IrisAppOptions | FleetAppStandardOptions) => Promise<boolean>;
59
+ gotoAdmin: (url?: string) => Promise<boolean>;
60
+ gotoAlerts: (url?: string) => Promise<boolean>;
61
+ gotoMarketplace: (options?: MarketplaceOptions) => Promise<boolean>;
62
+ reloadManager: (options?: {
63
+ renewToken?: boolean;
64
+ }) => Promise<boolean>;
65
+ getAssetHomeUrl: (assetId: string, options?: IrisAppOptions | AssetHomeStandardOptions) => Promise<string | null>;
66
+ getSiteHomeUrl: (siteId: string, options?: IrisAppOptions | SiteHomeStandardOptions) => Promise<string | null>;
67
+ getCustomerHomeUrl: (customerId?: string, options?: IrisAppOptions | CustomerHomeStandardOptions) => Promise<string | null>;
68
+ getGroupHomeUrl: (groupId: string, options?: GroupHomeStandardOptions) => Promise<string | null>;
69
+ getAppLibraryUrl: (irisAppId?: string) => Promise<string | null>;
70
+ getFleetAppUrl: (options: IrisAppOptions | FleetAppStandardOptions) => Promise<string | null>;
71
+ getAdminUrl: (url?: string) => Promise<string>;
72
+ getAlertsUrl: (url?: string) => Promise<string>;
73
+ getMarketplaceUrl: (options?: MarketplaceOptions) => Promise<string>;
3
74
  }
75
+ export interface NavigationRuntimeApi extends INavigationContext {
76
+ }
77
+ export {};
@@ -0,0 +1,17 @@
1
+ export interface OemBranding {
2
+ logo: boolean;
3
+ assetBanner: boolean;
4
+ color?: string;
5
+ platformLogo: boolean;
6
+ conditions?: {
7
+ oemLicensedOnly?: boolean;
8
+ };
9
+ }
10
+ export type OemBrandingImageType = "logo" | "assetBanner" | "platformLogo";
11
+ export interface OemBrandingContext {
12
+ getAllBrandingDetails(): Promise<Record<string, OemBranding>>;
13
+ getOemBranding: (brand: string) => Promise<OemBranding | null>;
14
+ getOemImage: (imageType: OemBrandingImageType, brand: string, model?: string) => Promise<string | null>;
15
+ }
16
+ export interface OemBrandingRuntimeApi extends OemBrandingContext {
17
+ }
@@ -0,0 +1,5 @@
1
+ export interface ParamsRuntimeApi {
2
+ getAppName: () => Promise<string | undefined>;
3
+ getExtensionName: () => Promise<string | undefined>;
4
+ getOrgName: () => Promise<string | undefined>;
5
+ }
@@ -27,4 +27,12 @@ export interface HttpResponse<D, E> {
27
27
  type: ResponseType;
28
28
  url: string;
29
29
  }
30
+ export interface RestRuntimeApi {
31
+ /**
32
+ * Requests the rest api.
33
+ *
34
+ * @deprecated Use the Public Graphql instead.
35
+ */
36
+ requestTrackunitRestApi: <TData, TError>(path: string, method: string, requestParams?: RequestParams, body?: unknown, bodyType?: BodyType, secureByDefault?: boolean) => Promise<HttpResponse<TData, TError>>;
37
+ }
30
38
  export {};
@@ -0,0 +1,3 @@
1
+ export interface RouterRuntimeApi {
2
+ getBasePath: () => string;
3
+ }
@@ -1,3 +1,6 @@
1
1
  export interface SiteInfo {
2
2
  siteId: string;
3
3
  }
4
+ export interface SiteRuntimeApi {
5
+ getSiteInfo: () => Promise<SiteInfo>;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { ThemeCssProperties } from "./ThemeCssProperties";
2
+ export interface ThemeCssRuntimeApi {
3
+ getThemeCssProperties: () => Promise<ThemeCssProperties | null>;
4
+ }
@@ -0,0 +1,43 @@
1
+ export type TimeRange = {
2
+ startMsInEpoch: number;
3
+ endMsInEpoch: number;
4
+ };
5
+ export type TemporalUnit = "day" | "days";
6
+ export type TemporalDirection = "next" | "last";
7
+ export type TemporalPeriod = {
8
+ direction: TemporalDirection;
9
+ count: number;
10
+ unit: TemporalUnit;
11
+ };
12
+ export type SelectedTimeRange = {
13
+ timeRange: TimeRange | null;
14
+ temporalPeriod: TemporalPeriod | null;
15
+ };
16
+ export interface TimeRangeContext {
17
+ /**
18
+ * Gets the current time range.
19
+ * This is the time range that is currently selected.
20
+ * If the user has selected a temporal period, this will be the start and end of the temporal period.
21
+ * If the user has selected a custom time range, this will be the start and end of the custom time range.
22
+ *
23
+ * @returns the current time range
24
+ */
25
+ timeRange: TimeRange | null;
26
+ /**
27
+ * Gets the current temporal period.
28
+ * This is only if the user has selected a temporal period.
29
+ * If the user has selected a custom time range, this will be null.
30
+ *
31
+ * @returns the current temporal period
32
+ */
33
+ temporalPeriod: TemporalPeriod | null;
34
+ }
35
+ export interface TimeRangeRuntimeApi {
36
+ /**
37
+ * Used to get the current time range, only if the host page has a time range.
38
+ */
39
+ getTimeRange: () => Promise<{
40
+ timeRange: TimeRange | null;
41
+ temporalPeriod: TemporalPeriod | null;
42
+ }>;
43
+ }
@@ -1,4 +1,24 @@
1
- import { Toast } from "@trackunit/react-core-contexts-api";
1
+ export type ToastColors = "info" | "warning" | "danger" | "success";
2
+ export type ToastAction = {
3
+ label: string;
4
+ onClick?: () => void;
5
+ loading?: boolean;
6
+ };
7
+ export interface Toast {
8
+ id?: string;
9
+ intent: ToastColors;
10
+ title: string;
11
+ description?: string;
12
+ behavior?: "timed" | "persistent";
13
+ link?: {
14
+ label: string;
15
+ onClick: (event: React.MouseEventHandler<HTMLButtonElement>) => void;
16
+ };
17
+ primaryAction?: ToastAction;
18
+ secondaryAction?: ToastAction;
19
+ duration?: number;
20
+ isLoading?: boolean;
21
+ }
2
22
  /**
3
23
  * Serializable toast which is used for sending through penpal
4
24
  */
@@ -6,3 +26,12 @@ export interface PublicToast extends Omit<Toast, "primaryAction" | "secondaryAct
6
26
  primaryAction?: string;
7
27
  secondaryAction?: string;
8
28
  }
29
+ export interface IToastContext {
30
+ addToast: (toast: Toast) => Promise<void | "primaryAction" | "secondaryAction">;
31
+ removeToast: (id: string) => Promise<void>;
32
+ setIsManifestError?: React.Dispatch<React.SetStateAction<boolean>>;
33
+ }
34
+ export interface ToastRuntimeApi {
35
+ addToast: (toast: PublicToast) => Promise<void | "primaryAction" | "secondaryAction">;
36
+ removeToast: (id: string) => Promise<void>;
37
+ }
@@ -0,0 +1,6 @@
1
+ export interface ITokenContext {
2
+ token?: string;
3
+ }
4
+ export interface TokenRuntimeApi {
5
+ getTokenContext: () => Promise<ITokenContext>;
6
+ }
@@ -0,0 +1,58 @@
1
+ export declare const UserSubscriptionPackage: {
2
+ readonly ENTRY_FLEET_OWNER: "Entry (Fleet Owner)";
3
+ readonly EXPLORE_FLEET_OWNER: "Explore (Fleet Owner)";
4
+ readonly EVOLVE_FLEET_OWNER: "Evolve (Fleet Owner)";
5
+ readonly EXPAND_FLEET_OWNER: "Expand (Fleet Owner)";
6
+ readonly EXPLORE_OEM: "Explore (OEM)";
7
+ readonly EVOLVE_OEM: "Evolve (OEM)";
8
+ readonly EXPAND_OEM: "Expand (OEM)";
9
+ readonly COLLECT: "COLLECT";
10
+ readonly INSIGHT: "INSIGHT";
11
+ readonly VIEW: "VIEW";
12
+ readonly NONE: "NONE";
13
+ readonly EXPLORE: "Explore";
14
+ readonly EVOLVE: "Evolve";
15
+ readonly EXPAND: "Expand";
16
+ readonly LINK: "Link";
17
+ readonly LIFT: "Lift";
18
+ readonly LEAP: "Leap";
19
+ readonly CUSTOMER_PORTAL: "Customer Portal";
20
+ };
21
+ export type UserSubscriptionPackageType = keyof typeof UserSubscriptionPackage;
22
+ export interface IFeature {
23
+ id: string;
24
+ name: string;
25
+ }
26
+ export interface UserSubscription {
27
+ /**
28
+ * The users subscription package
29
+ */
30
+ packageType: UserSubscriptionPackageType;
31
+ /**
32
+ * Extra features enabled for the current user. Will be null if still loading.
33
+ */
34
+ features: Array<IFeature> | null;
35
+ /**
36
+ * Number of days you can see back in time for this subscription.
37
+ *
38
+ * Returns the number of days
39
+ */
40
+ numberOfDaysWithAccessToHistoricalData: number;
41
+ /**
42
+ * Number of days you can see back in time for insights for this subscription.
43
+ *
44
+ * Returns the number of days
45
+ */
46
+ numberOfDaysWithAccessToHistoricalInsights: number;
47
+ /**
48
+ * If the subscription is still loading.
49
+ */
50
+ loading: boolean;
51
+ }
52
+ /**
53
+ * @deprecated Use UserSubscription instead
54
+ */
55
+ export type IUserSubscriptionContext = UserSubscription;
56
+ export interface UserSubscriptionRuntimeApi {
57
+ getUserSubscriptionContext: () => Promise<UserSubscription>;
58
+ }
@@ -1,12 +1,107 @@
1
- import { LoadingState } from "@trackunit/react-core-contexts-api";
2
- export interface WidgetConfigRuntimeApi {
1
+ export type LoadingState = {
2
+ hasData: boolean;
3
+ isLoading: boolean;
4
+ };
5
+ export interface WidgetConfigContext {
6
+ /**
7
+ * Gets the title of the widget.
8
+ *
9
+ * @returns the title of the widget
10
+ */
11
+ getTitle: () => Promise<string>;
12
+ /**
13
+ * Sets the title of the widget.
14
+ *
15
+ * @param title - The title to set.
16
+ */
17
+ setTitle: (title: string) => Promise<void>;
18
+ /**
19
+ * Gets the data of the widget.
20
+ *
21
+ * @returns the data of the widget
22
+ */
3
23
  getData: () => Promise<Record<string, unknown>>;
4
- setData: (data: Record<string, unknown>, dataVersion: number, title?: string) => Promise<void>;
24
+ /**
25
+ * Gets the data version of the widget.
26
+ * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget.
27
+ * Use it to upgrade the widget data to a new version when loading the widget.
28
+ *
29
+ * @returns the data version of the widget
30
+ */
5
31
  getDataVersion: () => Promise<number>;
32
+ /**
33
+ * Sets the data of the widget.
34
+ * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget.
35
+ * Use it to upgrade the widget data to a new version when loading the widget.
36
+ *
37
+ * @param data - The data to set.
38
+ * @param dataVersion - The data version to set.
39
+ */
40
+ setData: (data: Record<string, unknown>, dataVersion: number) => Promise<void>;
41
+ /**
42
+ * Sets the loading state of the widget.
43
+ *
44
+ * @param loadingState - The loading state to set.
45
+ */
46
+ setLoadingState: (loadingState: LoadingState) => Promise<void>;
47
+ /**
48
+ * Opens the edit mode of the widget.
49
+ */
6
50
  openEditMode: () => Promise<void>;
51
+ /**
52
+ * Closes the edit mode of the widget.
53
+ */
7
54
  closeEditMode: () => Promise<void>;
8
- getTitle: () => Promise<string>;
9
- setTitle: (title: string) => Promise<void>;
55
+ /**
56
+ * The poll interval of the widget.
57
+ *
58
+ * @returns the poll interval of the widget
59
+ */
60
+ pollInterval?: number;
61
+ }
62
+ export interface WidgetConfigRuntimeApi {
63
+ /**
64
+ * Gets the data of the widget.
65
+ */
66
+ getWidgetData: () => Promise<Record<string, unknown>>;
67
+ /**
68
+ * Sets the data of the widget.
69
+ * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget.
70
+ * Use it to upgrade the widget data to a new version when loading the widget.
71
+ *
72
+ * @param data the data to set
73
+ * @param dataVersion the data version to set
74
+ * @param title the title to set
75
+ */
76
+ setWidgetData: (data: Record<string, unknown>, dataVersion: number, title?: string) => Promise<void>;
77
+ /**
78
+ * Gets the data version of the widget.
79
+ * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget.
80
+ * Use it to upgrade the widget data to a new version when loading the widget.
81
+ */
82
+ getWidgetDataVersion: () => Promise<number>;
83
+ /**
84
+ * Gets the title of the widget.
85
+ */
86
+ getWidgetTitle: () => Promise<string>;
87
+ /**
88
+ * Sets the title of the widget.
89
+ */
90
+ setWidgetTitle: (title: string) => Promise<void>;
91
+ /**
92
+ * Opens the edit mode of the widget.
93
+ */
94
+ openEditMode: () => Promise<void>;
95
+ /**
96
+ * Closes the edit mode of the widget.
97
+ */
98
+ closeEditMode: () => Promise<void>;
99
+ /**
100
+ * Sets the loading state of the widget.
101
+ */
10
102
  setLoadingState: (loadingState: LoadingState) => Promise<void>;
11
- getPollInterval: () => Promise<number>;
103
+ /**
104
+ * Gets the poll interval of the widget.
105
+ */
106
+ getWidgetPollInterval: () => Promise<number>;
12
107
  }
package/src/index.d.ts CHANGED
@@ -1,14 +1,29 @@
1
+ export * from "./AnalyticsRuntime";
1
2
  export * from "./AssetRuntime";
3
+ export * from "./AssetSortingRuntime";
2
4
  export * from "./ChildConnector";
5
+ export * from "./ConfirmationDialogRuntime";
6
+ export * from "./CurrentUserPreferenceRuntime";
3
7
  export * from "./CurrentUserRuntime";
4
8
  export * from "./CustomerRuntime";
5
9
  export * from "./CustomFieldRuntime";
10
+ export * from "./EnvironmentRuntime";
11
+ export * from "./ErrorHandlingRuntime";
6
12
  export * from "./EventRuntime";
7
13
  export * from "./ExportDataRuntime";
14
+ export * from "./FilterBarRuntime";
8
15
  export * from "./HostConnector";
16
+ export * from "./ModalDialogRuntime";
9
17
  export * from "./NavigationRuntime";
18
+ export * from "./OemBrandingRuntime";
19
+ export * from "./ParamsRuntime";
10
20
  export * from "./RestRuntime";
21
+ export * from "./RouterRuntime";
11
22
  export * from "./SiteRuntime";
12
23
  export * from "./ThemeCssProperties";
24
+ export * from "./ThemeCssRuntime";
25
+ export * from "./TimeRangeRuntime";
13
26
  export * from "./ToastRuntime";
27
+ export * from "./TokenRuntime";
28
+ export * from "./UserSubscriptionRuntime";
14
29
  export * from "./WidgetConfigRuntime";