@trackunit/react-core-contexts-api 0.0.1-alpha-afcc978985.0

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/README.md ADDED
@@ -0,0 +1,18 @@
1
+ > **⚠️ Beta**
2
+ >
3
+ > This is a beta version and subject to change without notice.
4
+
5
+ # Trackunit React Core Contexts API
6
+ The `@trackunit/react-core-contexts-api` package is a small package containing reusable types for the Trackunit Iris App SDK.
7
+
8
+ Trackunit Iris Apps are used by external developers to integrate custom functionality into [the Trackunit Manager platform](https://www.trackunit.com/services/manager/).
9
+
10
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
11
+ ## Basic Usage
12
+ This package is not meant for isolated usage but is a part of the [`@trackunit/iris-app`](https://www.npmjs.com/package/@trackunit/iris-app) package.
13
+
14
+ ## Trackunit
15
+ This package was developed by Trackunit ApS.
16
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
17
+
18
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
@@ -0,0 +1,34 @@
1
+ export interface ICurrentUserContext {
2
+ tasUserId: string | undefined;
3
+ /**
4
+ * userName used when logging in. Undefined if not authenticated
5
+ */
6
+ userName: string | undefined;
7
+ /**
8
+ * Legacy user id. Undefined if not authenticated
9
+ */
10
+ userId: number | undefined;
11
+ /**
12
+ * Legacy customer id. Undefined if not authenticated
13
+ */
14
+ customerId: number | undefined;
15
+ /**
16
+ * Account ID. undefined if not authenticated
17
+ */
18
+ accountId: string | undefined;
19
+ /**
20
+ * If currently assuming a different user, this contains the information of that user. Null if not assuming
21
+ */
22
+ assumedUser: {
23
+ userId: number;
24
+ customerId: number;
25
+ accountId: string;
26
+ } | null;
27
+ email: string | undefined;
28
+ name: string | undefined;
29
+ jobTitle: string | undefined;
30
+ /**
31
+ * Is there an authenticated user or not
32
+ */
33
+ isAuthenticated: boolean;
34
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export interface IDeveloperSettingsContext {
3
+ localFeatureFlagsEnabled: boolean;
4
+ enableLocalFeatureFlags?: React.Dispatch<React.SetStateAction<boolean>>;
5
+ localFeatureFlags?: FeatureFlags;
6
+ launchdarklyFlags?: FeatureFlags;
7
+ setFlags?: React.Dispatch<React.SetStateAction<FeatureFlags | undefined>>;
8
+ }
9
+ export declare type FeatureFlags = {
10
+ [key: string]: boolean | Json;
11
+ };
12
+ export declare type Json = string;
@@ -0,0 +1,30 @@
1
+ export interface ITracingHeaders {
2
+ "X-TrackunitAppVersion": string;
3
+ "session-id": string;
4
+ }
5
+ export interface IEnvironmentContext {
6
+ auth: {
7
+ url: string;
8
+ clientId: string;
9
+ issuer: string;
10
+ };
11
+ tracingHeaders: ITracingHeaders;
12
+ managerClassicUrl: string;
13
+ googleMapsApiKey: string;
14
+ amplitudeApiKey: string;
15
+ launchDarklyApiKey: string;
16
+ graphqlLegacyUrl: string;
17
+ graphqlManagerUrl: string;
18
+ graphqlManagerImageUploadUrl: string;
19
+ graphqlReportUrl: string;
20
+ graphqlSimulatorUrl: string;
21
+ buildVersion: string;
22
+ commitNumber: number;
23
+ buildDate: string;
24
+ publicUrl: string;
25
+ irisAppSdkServerUrl: string;
26
+ isDev: boolean;
27
+ environment: string;
28
+ sentryDsn: string;
29
+ sessionId: string;
30
+ }
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./currentUserContext";
2
+ export * from "./developerSettingsContext";
3
+ export * from "./environmentContext";
4
+ export * from "./toastContext";
5
+ export * from "./tokenContext";
6
+ export * from "./userSubscriptionContext";
package/index.js ADDED
@@ -0,0 +1,14 @@
1
+ var UserSubscriptionPackageType;
2
+
3
+ (function (UserSubscriptionPackageType) {
4
+ UserSubscriptionPackageType["EXPAND_FLEET_OWNER"] = "Expand (Fleet Owner)";
5
+ UserSubscriptionPackageType["EVOLVE_FLEET_OWNER"] = "Evolve (Fleet Owner)";
6
+ UserSubscriptionPackageType["EXPLORE_FLEET_OWNER"] = "Explore (Fleet Owner)"; // OLD PACKAGES
7
+
8
+ UserSubscriptionPackageType["Collect"] = "COLLECT";
9
+ UserSubscriptionPackageType["Insight"] = "INSIGHT";
10
+ UserSubscriptionPackageType["View"] = "VIEW";
11
+ UserSubscriptionPackageType["None"] = "NONE";
12
+ })(UserSubscriptionPackageType || (UserSubscriptionPackageType = {}));
13
+
14
+ export { UserSubscriptionPackageType };
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@trackunit/react-core-contexts-api",
3
+ "version": "0.0.1-alpha-afcc978985.0",
4
+ "repository": "https://github.com/Trackunit/manager",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "module": "./index.js",
7
+ "main": "./index.js",
8
+ "type": "module",
9
+ "types": "./index.d.ts"
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ export declare type AlertColors = "info" | "warning" | "danger" | "success";
3
+ export declare type AlertAction = {
4
+ label: string;
5
+ onClick: () => void;
6
+ loading?: boolean;
7
+ };
8
+ export interface Toast {
9
+ dedupeKey?: string;
10
+ intent: AlertColors;
11
+ title: string;
12
+ description?: string;
13
+ primaryAction?: AlertAction;
14
+ secondaryAction?: AlertAction;
15
+ duration?: number;
16
+ }
17
+ export declare type AddToast = (toast: Toast) => void;
18
+ export interface IToastContext {
19
+ addToast: AddToast;
20
+ setIsManifestError?: React.Dispatch<React.SetStateAction<boolean>>;
21
+ }
@@ -0,0 +1,6 @@
1
+ export interface ITokenContext {
2
+ /**
3
+ * The current valid token or null if no token is available.
4
+ */
5
+ token?: string;
6
+ }
@@ -0,0 +1,23 @@
1
+ export interface IUserSubscriptionContext {
2
+ /**
3
+ * The users subscription package
4
+ */
5
+ packageType: UserSubscriptionPackageType;
6
+ /**
7
+ * Extra features enabled for the current user. Will be null if still loading
8
+ */
9
+ features: IFeature[] | null;
10
+ }
11
+ export declare enum UserSubscriptionPackageType {
12
+ EXPAND_FLEET_OWNER = "Expand (Fleet Owner)",
13
+ EVOLVE_FLEET_OWNER = "Evolve (Fleet Owner)",
14
+ EXPLORE_FLEET_OWNER = "Explore (Fleet Owner)",
15
+ Collect = "COLLECT",
16
+ Insight = "INSIGHT",
17
+ View = "VIEW",
18
+ None = "NONE"
19
+ }
20
+ export interface IFeature {
21
+ id: string;
22
+ name: string;
23
+ }