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

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
 
@@ -223,6 +224,7 @@ const UnitSi = {
223
224
  hour: "HOUR",
224
225
  };
225
226
 
227
+ const mainApps = ["reports", "sites", "map", "assets"];
226
228
  const assetHomePageIds = [
227
229
  "status",
228
230
  "movement",
@@ -286,5 +288,6 @@ exports.createEvent = createEvent;
286
288
  exports.customerHomePageIds = customerHomePageIds;
287
289
  exports.groupHomePageIds = groupHomePageIds;
288
290
  exports.isIrisOptions = isIrisOptions;
291
+ exports.mainApps = mainApps;
289
292
  exports.siteHomePageIds = siteHomePageIds;
290
293
  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
 
@@ -221,6 +222,7 @@ const UnitSi = {
221
222
  hour: "HOUR",
222
223
  };
223
224
 
225
+ const mainApps = ["reports", "sites", "map", "assets"];
224
226
  const assetHomePageIds = [
225
227
  "status",
226
228
  "movement",
@@ -273,4 +275,4 @@ const UserSubscriptionPackage = {
273
275
  CUSTOMER_PORTAL: "Customer Portal",
274
276
  };
275
277
 
276
- export { AssetSortByProperty, BodyType, SortOrder, SystemOfMeasurement, TimeZonePreference, UnitOfMeasurement, UnitSi, UnitUs, UserSubscriptionPackage, assetHomePageIds, createEvent, customerHomePageIds, groupHomePageIds, isIrisOptions, siteHomePageIds, validateStringAsAssetSortByProperty };
278
+ 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.78",
3
+ "version": "1.7.80",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@graphql-typed-document-node/core": "^3.2.0",
11
- "@trackunit/shared-utils": "1.9.72",
12
- "@trackunit/geo-json-utils": "1.7.72"
11
+ "@trackunit/shared-utils": "1.9.73",
12
+ "@trackunit/geo-json-utils": "1.7.73"
13
13
  },
14
14
  "module": "./index.esm.js",
15
15
  "main": "./index.cjs.js",
@@ -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 {};
@@ -43,11 +43,11 @@ export interface SortingState {
43
43
  sortBy: AssetSortByProperty;
44
44
  order: SortOrder;
45
45
  }
46
- export interface AssetSortingContextValue {
46
+ export interface AssetSortingState {
47
47
  sortingState: SortingState;
48
48
  setSortBy: (sortBy: AssetSortByProperty, order?: SortOrder, customFieldDefinitionId?: string) => void;
49
49
  }
50
50
  export interface AssetSortingRuntimeApi {
51
- getAssetSortingState: () => Promise<AssetSortingContextValue["sortingState"]>;
52
- setAssetSortingState: (...args: Parameters<AssetSortingContextValue["setSortBy"]>) => Promise<void>;
51
+ getAssetSortingState: () => Promise<AssetSortingState["sortingState"]>;
52
+ setAssetSortingState: (...args: Parameters<AssetSortingState["setSortBy"]>) => Promise<void>;
53
53
  }
@@ -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
+ };