@trackunit/iris-app-runtime-core-api 1.7.79 → 1.7.81

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
@@ -13,6 +13,7 @@ var sharedUtils = require('@trackunit/shared-utils');
13
13
  */
14
14
  const createEvent = (event) => ({
15
15
  description: event?.description,
16
+ // eslint-disable-next-line local-rules/no-typescript-assertion
16
17
  properties: {},
17
18
  });
18
19
 
@@ -42,6 +43,13 @@ exports.AssetSortByProperty = void 0;
42
43
  AssetSortByProperty["PlannedServiceBookingDate"] = "PLANNED_SERVICE_BOOKING_DATE";
43
44
  AssetSortByProperty["ServicePlanPrediction"] = "SERVICE_PLAN_PREDICTION";
44
45
  AssetSortByProperty["IssueCreatedAt"] = "ISSUE_CREATED_AT";
46
+ AssetSortByProperty["BatteryChargerState"] = "BATTERY_CHARGER_STATE";
47
+ AssetSortByProperty["BatteryPotential"] = "BATTERY_POTENTIAL";
48
+ AssetSortByProperty["BatteryStateOfChargePercent"] = "BATTERY_STATE_OF_CHARGE_PERCENT";
49
+ AssetSortByProperty["CumulativeOperatingHours"] = "CUMULATIVE_OPERATING_HOURS";
50
+ AssetSortByProperty["FuelLevel"] = "FUEL_LEVEL";
51
+ AssetSortByProperty["AfterTreatmentDieselExhaustFluidTankLevel"] = "AFTER_TREATMENT_DIESEL_EXHAUST_FLUID_TANK_LEVEL";
52
+ AssetSortByProperty["EngineTotalIdleHours"] = "ENGINE_TOTAL_IDLE_HOURS";
45
53
  })(exports.AssetSortByProperty || (exports.AssetSortByProperty = {}));
46
54
  // The type [key in AssetSortByProperty] will ensure that ALL keys are present
47
55
  const stringToEnum = {
@@ -69,6 +77,13 @@ const stringToEnum = {
69
77
  PLANNED_SERVICE_BOOKING_DATE: exports.AssetSortByProperty.PlannedServiceBookingDate,
70
78
  SERVICE_PLAN_PREDICTION: exports.AssetSortByProperty.ServicePlanPrediction,
71
79
  ISSUE_CREATED_AT: exports.AssetSortByProperty.IssueCreatedAt,
80
+ BATTERY_CHARGER_STATE: exports.AssetSortByProperty.BatteryChargerState,
81
+ BATTERY_POTENTIAL: exports.AssetSortByProperty.BatteryPotential,
82
+ BATTERY_STATE_OF_CHARGE_PERCENT: exports.AssetSortByProperty.BatteryStateOfChargePercent,
83
+ CUMULATIVE_OPERATING_HOURS: exports.AssetSortByProperty.CumulativeOperatingHours,
84
+ FUEL_LEVEL: exports.AssetSortByProperty.FuelLevel,
85
+ AFTER_TREATMENT_DIESEL_EXHAUST_FLUID_TANK_LEVEL: exports.AssetSortByProperty.AfterTreatmentDieselExhaustFluidTankLevel,
86
+ ENGINE_TOTAL_IDLE_HOURS: exports.AssetSortByProperty.EngineTotalIdleHours,
72
87
  };
73
88
  /**
74
89
  * Ensures that a string is a valid AssetSortByProperty enum value
@@ -223,6 +238,7 @@ const UnitSi = {
223
238
  hour: "HOUR",
224
239
  };
225
240
 
241
+ const mainApps = ["reports", "sites", "map", "assets"];
226
242
  const assetHomePageIds = [
227
243
  "status",
228
244
  "movement",
@@ -286,5 +302,6 @@ exports.createEvent = createEvent;
286
302
  exports.customerHomePageIds = customerHomePageIds;
287
303
  exports.groupHomePageIds = groupHomePageIds;
288
304
  exports.isIrisOptions = isIrisOptions;
305
+ exports.mainApps = mainApps;
289
306
  exports.siteHomePageIds = siteHomePageIds;
290
307
  exports.validateStringAsAssetSortByProperty = validateStringAsAssetSortByProperty;
package/index.esm.js CHANGED
@@ -11,6 +11,7 @@ import { isUUID } from '@trackunit/shared-utils';
11
11
  */
12
12
  const createEvent = (event) => ({
13
13
  description: event?.description,
14
+ // eslint-disable-next-line local-rules/no-typescript-assertion
14
15
  properties: {},
15
16
  });
16
17
 
@@ -40,6 +41,13 @@ var AssetSortByProperty;
40
41
  AssetSortByProperty["PlannedServiceBookingDate"] = "PLANNED_SERVICE_BOOKING_DATE";
41
42
  AssetSortByProperty["ServicePlanPrediction"] = "SERVICE_PLAN_PREDICTION";
42
43
  AssetSortByProperty["IssueCreatedAt"] = "ISSUE_CREATED_AT";
44
+ AssetSortByProperty["BatteryChargerState"] = "BATTERY_CHARGER_STATE";
45
+ AssetSortByProperty["BatteryPotential"] = "BATTERY_POTENTIAL";
46
+ AssetSortByProperty["BatteryStateOfChargePercent"] = "BATTERY_STATE_OF_CHARGE_PERCENT";
47
+ AssetSortByProperty["CumulativeOperatingHours"] = "CUMULATIVE_OPERATING_HOURS";
48
+ AssetSortByProperty["FuelLevel"] = "FUEL_LEVEL";
49
+ AssetSortByProperty["AfterTreatmentDieselExhaustFluidTankLevel"] = "AFTER_TREATMENT_DIESEL_EXHAUST_FLUID_TANK_LEVEL";
50
+ AssetSortByProperty["EngineTotalIdleHours"] = "ENGINE_TOTAL_IDLE_HOURS";
43
51
  })(AssetSortByProperty || (AssetSortByProperty = {}));
44
52
  // The type [key in AssetSortByProperty] will ensure that ALL keys are present
45
53
  const stringToEnum = {
@@ -67,6 +75,13 @@ const stringToEnum = {
67
75
  PLANNED_SERVICE_BOOKING_DATE: AssetSortByProperty.PlannedServiceBookingDate,
68
76
  SERVICE_PLAN_PREDICTION: AssetSortByProperty.ServicePlanPrediction,
69
77
  ISSUE_CREATED_AT: AssetSortByProperty.IssueCreatedAt,
78
+ BATTERY_CHARGER_STATE: AssetSortByProperty.BatteryChargerState,
79
+ BATTERY_POTENTIAL: AssetSortByProperty.BatteryPotential,
80
+ BATTERY_STATE_OF_CHARGE_PERCENT: AssetSortByProperty.BatteryStateOfChargePercent,
81
+ CUMULATIVE_OPERATING_HOURS: AssetSortByProperty.CumulativeOperatingHours,
82
+ FUEL_LEVEL: AssetSortByProperty.FuelLevel,
83
+ AFTER_TREATMENT_DIESEL_EXHAUST_FLUID_TANK_LEVEL: AssetSortByProperty.AfterTreatmentDieselExhaustFluidTankLevel,
84
+ ENGINE_TOTAL_IDLE_HOURS: AssetSortByProperty.EngineTotalIdleHours,
70
85
  };
71
86
  /**
72
87
  * Ensures that a string is a valid AssetSortByProperty enum value
@@ -221,6 +236,7 @@ const UnitSi = {
221
236
  hour: "HOUR",
222
237
  };
223
238
 
239
+ const mainApps = ["reports", "sites", "map", "assets"];
224
240
  const assetHomePageIds = [
225
241
  "status",
226
242
  "movement",
@@ -273,4 +289,4 @@ const UserSubscriptionPackage = {
273
289
  CUSTOMER_PORTAL: "Customer Portal",
274
290
  };
275
291
 
276
- export { AssetSortByProperty, BodyType, SortOrder, SystemOfMeasurement, TimeZonePreference, UnitOfMeasurement, UnitSi, UnitUs, UserSubscriptionPackage, assetHomePageIds, createEvent, customerHomePageIds, groupHomePageIds, isIrisOptions, siteHomePageIds, validateStringAsAssetSortByProperty };
292
+ export { AssetSortByProperty, BodyType, SortOrder, SystemOfMeasurement, TimeZonePreference, UnitOfMeasurement, UnitSi, UnitUs, UserSubscriptionPackage, assetHomePageIds, createEvent, customerHomePageIds, groupHomePageIds, isIrisOptions, mainApps, siteHomePageIds, validateStringAsAssetSortByProperty };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-runtime-core-api",
3
- "version": "1.7.79",
3
+ "version": "1.7.81",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -1,3 +1,4 @@
1
+ import { PromisifyObject } from "./types";
1
2
  export type AdditionalProperties = Record<string, string | number | boolean | null | undefined | Array<string | number>>;
2
3
  export interface BaseEvent {
3
4
  additionalProperties?: AdditionalProperties;
@@ -15,13 +16,13 @@ export declare const createEvent: <TEventType extends object = BaseEvent>(event?
15
16
  description?: string;
16
17
  }) => Event<TEventType>;
17
18
  export type UnspecifiedEvent = AdditionalProperties;
18
- export type Event<T> = {
19
+ export type Event<TProperties> = {
19
20
  description?: string;
20
- properties: T;
21
+ properties: TProperties;
21
22
  };
22
23
  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?: {
24
+ export interface AnalyticsRuntimeApiSync<TEvents extends EventDictionary> {
25
+ logEvent<TEventName extends keyof TEvents & string>(eventName: TEventName, details: TEvents[TEventName]["properties"], nameSupplement?: {
25
26
  prefix?: string;
26
27
  postfix?: string;
27
28
  }): void;
@@ -31,12 +32,5 @@ export interface IAnalyticsContext<Events extends EventDictionary> {
31
32
  logError(details: UnspecifiedEvent): void;
32
33
  setUserProperty(name: string, data: string | number): void;
33
34
  }
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>> {
35
+ export interface AnalyticsRuntimeApi<TEventDictionary extends EventDictionary> extends PromisifyObject<AnalyticsRuntimeApiSync<TEventDictionary>> {
41
36
  }
42
- export {};
@@ -22,7 +22,14 @@ export declare enum AssetSortByProperty {
22
22
  PlannedServiceBooked = "PLANNED_SERVICE_BOOKED",
23
23
  PlannedServiceBookingDate = "PLANNED_SERVICE_BOOKING_DATE",
24
24
  ServicePlanPrediction = "SERVICE_PLAN_PREDICTION",
25
- IssueCreatedAt = "ISSUE_CREATED_AT"
25
+ IssueCreatedAt = "ISSUE_CREATED_AT",
26
+ BatteryChargerState = "BATTERY_CHARGER_STATE",
27
+ BatteryPotential = "BATTERY_POTENTIAL",
28
+ BatteryStateOfChargePercent = "BATTERY_STATE_OF_CHARGE_PERCENT",
29
+ CumulativeOperatingHours = "CUMULATIVE_OPERATING_HOURS",
30
+ FuelLevel = "FUEL_LEVEL",
31
+ AfterTreatmentDieselExhaustFluidTankLevel = "AFTER_TREATMENT_DIESEL_EXHAUST_FLUID_TANK_LEVEL",
32
+ EngineTotalIdleHours = "ENGINE_TOTAL_IDLE_HOURS"
26
33
  }
27
34
  /**
28
35
  * Ensures that a string is a valid AssetSortByProperty enum value
@@ -43,11 +50,11 @@ export interface SortingState {
43
50
  sortBy: AssetSortByProperty;
44
51
  order: SortOrder;
45
52
  }
46
- export interface AssetSortingContextValue {
53
+ export interface AssetSortingState {
47
54
  sortingState: SortingState;
48
55
  setSortBy: (sortBy: AssetSortByProperty, order?: SortOrder, customFieldDefinitionId?: string) => void;
49
56
  }
50
57
  export interface AssetSortingRuntimeApi {
51
- getAssetSortingState: () => Promise<AssetSortingContextValue["sortingState"]>;
52
- setAssetSortingState: (...args: Parameters<AssetSortingContextValue["setSortBy"]>) => Promise<void>;
58
+ getAssetSortingState: () => Promise<AssetSortingState["sortingState"]>;
59
+ setAssetSortingState: (...args: Parameters<AssetSortingState["setSortBy"]>) => Promise<void>;
53
60
  }
@@ -1,4 +1,4 @@
1
- import { AssetSortingContextValue } from "./AssetSortingRuntime";
1
+ import { AssetSortingState } from "./AssetSortingRuntime";
2
2
  import { FilterBarValues } from "./FilterBarRuntime";
3
3
  import { TemporalPeriod, TimeRange } from "./TimeRangeRuntime";
4
4
  import { ITokenContext } from "./TokenRuntime";
@@ -39,7 +39,7 @@ export interface ChildConnectorApi {
39
39
  *
40
40
  * @param sorting new sorting state
41
41
  */
42
- onAssetSortingStateChanged: (sorting: AssetSortingContextValue["sortingState"]) => void;
42
+ onAssetSortingStateChanged: (sorting: AssetSortingState["sortingState"]) => void;
43
43
  /**
44
44
  * Gets called when the filter bar values change.
45
45
  *
@@ -6,8 +6,6 @@ export interface ConfirmationDialogProps {
6
6
  primaryActionLabel: string;
7
7
  secondaryActionLabel?: string;
8
8
  }
9
- export interface ConfirmationDialogContextValue {
9
+ export interface ConfirmationDialogRuntimeApi {
10
10
  confirm: (props: ConfirmationDialogProps) => Promise<UserInteractionType>;
11
11
  }
12
- export interface ConfirmationDialogRuntimeApi extends ConfirmationDialogContextValue {
13
- }
@@ -9,7 +9,7 @@ export declare const TimeZonePreference: {
9
9
  };
10
10
  export type SystemOfMeasurementType = (typeof SystemOfMeasurement)[keyof typeof SystemOfMeasurement];
11
11
  export type TimeZonePreferenceType = (typeof TimeZonePreference)[keyof typeof TimeZonePreference];
12
- export interface IUserPreferencesContext {
12
+ export interface CurrentUserPreferenceState {
13
13
  language?: string;
14
14
  setLanguage?: (language: string) => void;
15
15
  timeZonePreference?: TimeZonePreferenceType;
@@ -17,10 +17,8 @@ export interface IUserPreferencesContext {
17
17
  systemOfMeasurement?: SystemOfMeasurementType;
18
18
  setSystemOfMeasurement?: (systemOfMeasurement: SystemOfMeasurementType) => void;
19
19
  }
20
- export interface ICurrentUserPreferenceContext {
20
+ export interface CurrentUserPreferenceRuntimeApi {
21
21
  getCurrentUserLanguage: () => Promise<string>;
22
22
  getCurrentUserTimeZonePreference: () => Promise<TimeZonePreferenceType>;
23
23
  getCurrentUserSystemOfMeasurement: () => Promise<SystemOfMeasurementType>;
24
24
  }
25
- export interface CurrentUserPreferenceRuntimeApi extends ICurrentUserPreferenceContext {
26
- }
@@ -1,15 +1,15 @@
1
- export interface ITracingHeaders {
1
+ export interface TracingHeaders {
2
2
  "X-TrackunitAppVersion": string;
3
3
  "session-id": string;
4
4
  "commit-number": number;
5
5
  }
6
- export interface IEnvironmentContext {
6
+ export interface EnvironmentState {
7
7
  auth: {
8
8
  url: string;
9
9
  clientId: string;
10
10
  issuer: string;
11
11
  };
12
- tracingHeaders: ITracingHeaders;
12
+ tracingHeaders: TracingHeaders;
13
13
  managerClassicUrl: string;
14
14
  googleMapsApiKey: string;
15
15
  amplitudeApiKey: string;
@@ -32,5 +32,5 @@ export interface IEnvironmentContext {
32
32
  reportAccessClientId: string;
33
33
  }
34
34
  export interface EnvironmentRuntimeApi {
35
- getEnvironmentContext: () => Promise<IEnvironmentContext>;
35
+ getEnvironmentContext: () => Promise<EnvironmentState>;
36
36
  }
@@ -1,4 +1,4 @@
1
- import { AnalyticsRuntimeApi } from "./AnalyticsRuntime";
1
+ import { AnalyticsRuntimeApi, EventDictionary } from "./AnalyticsRuntime";
2
2
  import { AssetRuntimeApi } from "./AssetRuntime";
3
3
  import { AssetSortingRuntimeApi } from "./AssetSortingRuntime";
4
4
  import { ConfirmationDialogRuntimeApi } from "./ConfirmationDialogRuntime";
@@ -21,5 +21,5 @@ import { ToastRuntimeApi } from "./ToastRuntime";
21
21
  import { TokenRuntimeApi } from "./TokenRuntime";
22
22
  import { UserSubscriptionRuntimeApi } from "./UserSubscriptionRuntime";
23
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 {
24
+ export interface HostConnectorApi extends AnalyticsRuntimeApi<EventDictionary>, AssetRuntimeApi, AssetSortingRuntimeApi, ConfirmationDialogRuntimeApi, CurrentUserPreferenceRuntimeApi, CurrentUserRuntimeApi, CustomerRuntimeApi, EnvironmentRuntimeApi, EventRuntimeApi, ExportDataRuntimeApi, FilterBarRuntimeApi, ModalDialogRuntimeApi, NavigationRuntimeApi, OemBrandingRuntimeApi, RestRuntimeApi, SiteRuntimeApi, ThemeCssRuntimeApi, TimeRangeRuntimeApi, ToastRuntimeApi, TokenRuntimeApi, UserSubscriptionRuntimeApi, ParamsRuntimeApi, WidgetConfigRuntimeApi {
25
25
  }
@@ -1,9 +1,7 @@
1
- export interface ModalDialogContextValue {
1
+ export interface ModalDialogRuntimeApi {
2
2
  openModal: ({ scrollX, scrollY }?: {
3
3
  scrollX: number;
4
4
  scrollY: number;
5
5
  }) => Promise<void>;
6
6
  closeModal: () => Promise<void>;
7
7
  }
8
- export interface ModalDialogRuntimeApi extends ModalDialogContextValue {
9
- }
@@ -21,7 +21,7 @@ export type IrisAppOptions = {
21
21
  irisAppId: string;
22
22
  extensionId: string;
23
23
  } & SubPage & Search & FragmentIdentifier & NeverPage;
24
- declare const mainApps: readonly ["reports", "sites", "map", "assets"];
24
+ export declare const mainApps: readonly ["reports", "sites", "map", "assets"];
25
25
  export type MainFleetApp = (typeof mainApps)[number];
26
26
  export type FleetAppStandardOptions = Page<MainFleetApp> & NeverIrisApp;
27
27
  export type MapAppStandardOptions = Page<"map"> & NeverIrisApp;
@@ -48,7 +48,7 @@ export type HasAccessToOptions = (IrisAppOptions | AssetHomeStandardOptions | Si
48
48
  * type guard for IrisAppOptions
49
49
  */
50
50
  export declare const isIrisOptions: (options: IrisAppOptions | unknown) => options is IrisAppOptions;
51
- export interface INavigationContext {
51
+ export interface NavigationRuntimeApi {
52
52
  hasAccessTo: (options: HasAccessToOptions) => Promise<boolean>;
53
53
  gotoAssetHome: (assetId: string, options?: IrisAppOptions | AssetHomeStandardOptions) => Promise<boolean>;
54
54
  gotoSiteHome: (siteId: string, options?: IrisAppOptions | SiteHomeStandardOptions) => Promise<boolean>;
@@ -72,6 +72,4 @@ export interface INavigationContext {
72
72
  getAlertsUrl: (url?: string) => Promise<string>;
73
73
  getMarketplaceUrl: (options?: MarketplaceOptions) => Promise<string>;
74
74
  }
75
- export interface NavigationRuntimeApi extends INavigationContext {
76
- }
77
75
  export {};
@@ -8,10 +8,8 @@ export interface OemBranding {
8
8
  };
9
9
  }
10
10
  export type OemBrandingImageType = "logo" | "assetBanner" | "platformLogo";
11
- export interface OemBrandingContext {
12
- getAllBrandingDetails(): Promise<Record<string, OemBranding>>;
11
+ export interface OemBrandingRuntimeApi {
12
+ getAllBrandingDetails: () => Promise<Record<string, OemBranding>>;
13
13
  getOemBranding: (brand: string) => Promise<OemBranding | null>;
14
14
  getOemImage: (imageType: OemBrandingImageType, brand: string, model?: string) => Promise<string | null>;
15
15
  }
16
- export interface OemBrandingRuntimeApi extends OemBrandingContext {
17
- }
package/src/types.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export type PromisifyMethod<TNonPromise> = TNonPromise extends (...args: infer U) => infer V ? (...args: U) => Promise<V> : TNonPromise;
2
+ export type PromisifyObject<TNonPromiseObject> = {
3
+ [K in keyof TNonPromiseObject]: PromisifyMethod<TNonPromiseObject[K]>;
4
+ };