@trackunit/iris-app-runtime-core-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/AssetRuntime.d.ts +3 -0
- package/CustomFieldRuntime.d.ts +167 -0
- package/HostConnector.d.ts +31 -0
- package/README.md +19 -0
- package/RestRuntime.d.ts +30 -0
- package/ToastRuntime.d.ts +8 -0
- package/index.d.ts +5 -0
- package/index.js +69 -0
- package/package.json +14 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
export declare type EntityType = "ASSET";
|
2
|
+
export interface EntityIdentity {
|
3
|
+
type: EntityType;
|
4
|
+
id: string;
|
5
|
+
}
|
6
|
+
export declare enum CustomFieldType {
|
7
|
+
BOOLEAN = "BOOLEAN",
|
8
|
+
DATE = "DATE",
|
9
|
+
DROPDOWN = "DROPDOWN",
|
10
|
+
EMAIL = "EMAIL",
|
11
|
+
NUMBER = "NUMBER",
|
12
|
+
PHONE_NUMBER = "PHONE_NUMBER",
|
13
|
+
STRING = "STRING",
|
14
|
+
WEB_ADDRESS = "WEB_ADDRESS"
|
15
|
+
}
|
16
|
+
/**
|
17
|
+
* The new field definition
|
18
|
+
*/
|
19
|
+
export interface AbstractCustomFieldDefinitionObject {
|
20
|
+
key?: string | null;
|
21
|
+
/** The title */
|
22
|
+
title: string | null;
|
23
|
+
entityType: string;
|
24
|
+
description?: string | null;
|
25
|
+
uiVisible?: boolean | null;
|
26
|
+
uiEditable?: boolean | null;
|
27
|
+
type: CustomFieldType;
|
28
|
+
}
|
29
|
+
export declare type BooleanFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
30
|
+
defaultBooleanValue?: boolean | null;
|
31
|
+
type: CustomFieldType.BOOLEAN;
|
32
|
+
};
|
33
|
+
export declare type DateFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
34
|
+
/**
|
35
|
+
* ISO8601 formatted date
|
36
|
+
*/
|
37
|
+
defaultDateValue?: string | null;
|
38
|
+
type: CustomFieldType.DATE;
|
39
|
+
};
|
40
|
+
export declare type PhoneNumberFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
41
|
+
defaultStringValue?: string | null;
|
42
|
+
type: CustomFieldType.PHONE_NUMBER;
|
43
|
+
};
|
44
|
+
export declare type EmailFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
45
|
+
defaultStringValue?: string | null;
|
46
|
+
type: CustomFieldType.EMAIL;
|
47
|
+
};
|
48
|
+
export declare type WebAddressFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
49
|
+
defaultStringValue?: string | null;
|
50
|
+
type: CustomFieldType.WEB_ADDRESS;
|
51
|
+
};
|
52
|
+
export declare type DropDownFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
53
|
+
defaultStringArrayValue?: string[] | null;
|
54
|
+
multiSelect?: boolean | null;
|
55
|
+
allValues?: string[] | null;
|
56
|
+
type: CustomFieldType.DROPDOWN;
|
57
|
+
};
|
58
|
+
export declare enum UnitUs {
|
59
|
+
"mi" = "mi",
|
60
|
+
"yd" = "yd",
|
61
|
+
"ft" = "ft",
|
62
|
+
"in" = "in",
|
63
|
+
"ac" = "ac",
|
64
|
+
"ha" = "ha",
|
65
|
+
"ft_2" = "ft\u00B2",
|
66
|
+
"gal" = "gal",
|
67
|
+
"ft_3" = "ft\u00B3",
|
68
|
+
"ton_us" = "ton_us",
|
69
|
+
"lb" = "lb",
|
70
|
+
"oz" = "oz",
|
71
|
+
"mph" = "mph",
|
72
|
+
"lb_h" = "lb/h",
|
73
|
+
"lb_s" = "lb/s"
|
74
|
+
}
|
75
|
+
export declare enum UnitSi {
|
76
|
+
"km" = "km",
|
77
|
+
"m" = "m",
|
78
|
+
"cm" = "cm",
|
79
|
+
"mm" = "mm",
|
80
|
+
"l" = "l",
|
81
|
+
"kg" = "kg",
|
82
|
+
"g" = "g",
|
83
|
+
"ton" = "ton",
|
84
|
+
"N" = "N",
|
85
|
+
"kW" = "kW",
|
86
|
+
"W" = "W",
|
87
|
+
"kWh" = "kWh",
|
88
|
+
"kPa" = "kPa",
|
89
|
+
"Pa" = "Pa",
|
90
|
+
"bar" = "bar",
|
91
|
+
"m_s" = "m/s",
|
92
|
+
"kg_h" = "kg/h",
|
93
|
+
"kg_s" = "kg/s",
|
94
|
+
"km_h" = "km/h",
|
95
|
+
"km_2" = "km\u00B2",
|
96
|
+
"m_2" = "m\u00B2",
|
97
|
+
"m_3" = "m\u00B3",
|
98
|
+
"m_s_2" = "m/s\u00B2"
|
99
|
+
}
|
100
|
+
export declare type NumberFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
101
|
+
defaultNumberValue?: number | null;
|
102
|
+
minimumNumber?: number | null;
|
103
|
+
maximumNumber?: number | null;
|
104
|
+
unitSi?: UnitSi | null;
|
105
|
+
unitUs?: UnitUs | null;
|
106
|
+
isInteger?: boolean | null;
|
107
|
+
type: CustomFieldType.NUMBER;
|
108
|
+
};
|
109
|
+
export declare type StringFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
110
|
+
defaultStringValue?: string | null;
|
111
|
+
minimumLength?: number | null;
|
112
|
+
maximumLength?: number | null;
|
113
|
+
pattern?: string | null;
|
114
|
+
type: CustomFieldType.STRING;
|
115
|
+
};
|
116
|
+
export interface AbstractCustomFieldValue {
|
117
|
+
type: CustomFieldType;
|
118
|
+
}
|
119
|
+
export declare type BooleanFieldValue = {
|
120
|
+
type: CustomFieldType.BOOLEAN;
|
121
|
+
booleanValue?: boolean | null;
|
122
|
+
};
|
123
|
+
export declare type DateFieldValue = {
|
124
|
+
type: CustomFieldType.DATE;
|
125
|
+
/**
|
126
|
+
* ISO8601 formatted date
|
127
|
+
*/
|
128
|
+
dateValue?: string | null;
|
129
|
+
};
|
130
|
+
export declare type DropDownFieldValue = {
|
131
|
+
type: CustomFieldType.DROPDOWN;
|
132
|
+
stringArrayValue?: string[];
|
133
|
+
};
|
134
|
+
export declare type EmailFieldValue = {
|
135
|
+
type: CustomFieldType.EMAIL;
|
136
|
+
stringValue?: string | null;
|
137
|
+
};
|
138
|
+
export declare type NumberFieldValue = {
|
139
|
+
type: CustomFieldType.NUMBER;
|
140
|
+
numberValue?: number | null;
|
141
|
+
};
|
142
|
+
export declare type PhoneNumberFieldValue = {
|
143
|
+
type: CustomFieldType.PHONE_NUMBER;
|
144
|
+
stringValue?: string | null;
|
145
|
+
};
|
146
|
+
export declare type StringFieldValue = {
|
147
|
+
type: CustomFieldType.STRING;
|
148
|
+
stringValue?: string | null;
|
149
|
+
};
|
150
|
+
export declare type WebAddressFieldValue = {
|
151
|
+
type: CustomFieldType.WEB_ADDRESS;
|
152
|
+
stringValue?: string | null;
|
153
|
+
};
|
154
|
+
export declare type CustomFieldDefinition = BooleanFieldDefinition | DateFieldDefinition | DropDownFieldDefinition | EmailFieldDefinition | NumberFieldDefinition | PhoneNumberFieldDefinition | StringFieldDefinition | WebAddressFieldDefinition;
|
155
|
+
export declare type CustomFieldValue = BooleanFieldValue | DateFieldValue | DropDownFieldValue | EmailFieldValue | NumberFieldValue | PhoneNumberFieldValue | StringFieldValue | WebAddressFieldValue;
|
156
|
+
export interface ValueAndDefinition {
|
157
|
+
definition: CustomFieldDefinition;
|
158
|
+
value: CustomFieldValue;
|
159
|
+
}
|
160
|
+
export interface AbstractValueAndDefinition {
|
161
|
+
definition: AbstractCustomFieldDefinitionObject;
|
162
|
+
value: AbstractCustomFieldValue;
|
163
|
+
}
|
164
|
+
export interface ValueAndDefinitionKey {
|
165
|
+
definitionKey: string;
|
166
|
+
value: CustomFieldValue;
|
167
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { ICurrentUserContext, IDeveloperSettingsContext, IEnvironmentContext, ITokenContext, IUserSubscriptionContext } from "@trackunit/react-core-contexts-api";
|
2
|
+
import { AssetInfo } from "./AssetRuntime";
|
3
|
+
import { EntityIdentity, ValueAndDefinition, ValueAndDefinitionKey } from "./CustomFieldRuntime";
|
4
|
+
import { BodyType, HttpResponse, RequestParams } from "./RestRuntime";
|
5
|
+
import { PublicToast } from "./ToastRuntime";
|
6
|
+
export interface CustomFieldError {
|
7
|
+
/**
|
8
|
+
* The custom fields that does not obey the rules of the definition, read the definition to figure out what is wrong.
|
9
|
+
*/
|
10
|
+
customFieldKeys: string[];
|
11
|
+
}
|
12
|
+
export interface HostConnectorApi {
|
13
|
+
getAssetInfo(): Promise<AssetInfo>;
|
14
|
+
requestTrackunitRestApi: <T, E>(path: string, method: string, requestParams?: RequestParams, body?: unknown, bodyType?: BodyType, secureByDefault?: boolean) => Promise<HttpResponse<T, E>>;
|
15
|
+
getCustomFieldsFor(entity: EntityIdentity): Promise<ValueAndDefinition[]>;
|
16
|
+
setCustomFieldsFor(entity: EntityIdentity, values: ValueAndDefinitionKey[]): Promise<void | CustomFieldError>;
|
17
|
+
getEnvironmentContext(): Promise<IEnvironmentContext>;
|
18
|
+
getUserSubscriptionContext(): Promise<IUserSubscriptionContext>;
|
19
|
+
getTokenContext(): Promise<ITokenContext>;
|
20
|
+
getCurrentUserContext(): Promise<ICurrentUserContext>;
|
21
|
+
setDeepLink: SetDeepLink;
|
22
|
+
addToast(toast: PublicToast): Promise<void | "primaryAction" | "secondaryAction">;
|
23
|
+
getDeveloperSettingsContext(): Promise<IDeveloperSettingsContext>;
|
24
|
+
}
|
25
|
+
export declare type SetDeepLink = (deepLink: DeepLink) => void;
|
26
|
+
export declare type DeepLink = {
|
27
|
+
path: string;
|
28
|
+
pathname: string;
|
29
|
+
search: Location["search"];
|
30
|
+
hash: Location["hash"];
|
31
|
+
};
|
package/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
> **⚠️ Beta**
|
2
|
+
>
|
3
|
+
> This is a beta version and subject to change without notice.
|
4
|
+
|
5
|
+
# Trackunit Iris App Runtime Core API
|
6
|
+
The `@trackunit/iris-app-runtime-core-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
|
+
|
12
|
+
## Basic Usage
|
13
|
+
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.
|
14
|
+
|
15
|
+
## Trackunit
|
16
|
+
This package was developed by Trackunit ApS.
|
17
|
+
Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
|
18
|
+
|
19
|
+

|
package/RestRuntime.d.ts
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
export declare type RequestParams = {
|
2
|
+
headers?: {
|
3
|
+
[key: string]: string;
|
4
|
+
};
|
5
|
+
secure?: boolean;
|
6
|
+
};
|
7
|
+
export declare enum BodyType {
|
8
|
+
Json = 0,
|
9
|
+
FormData = 1
|
10
|
+
}
|
11
|
+
export interface IRestApiClient {
|
12
|
+
request: <T, E>(path: string, method: string, requestParams?: RequestParams, body?: unknown, bodyType?: BodyType, secureByDefault?: boolean) => Promise<HttpResponse<T, E>>;
|
13
|
+
apiHost: string;
|
14
|
+
}
|
15
|
+
export declare type RequestQueryParamsType = Record<string | number, any>;
|
16
|
+
declare type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
|
17
|
+
export interface HttpResponse<D, E> {
|
18
|
+
data?: D;
|
19
|
+
error?: E;
|
20
|
+
headers: {
|
21
|
+
[key: string]: string;
|
22
|
+
};
|
23
|
+
ok: boolean;
|
24
|
+
redirected: boolean;
|
25
|
+
status: number;
|
26
|
+
statusText: string;
|
27
|
+
type: ResponseType;
|
28
|
+
url: string;
|
29
|
+
}
|
30
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Toast } from "@trackunit/react-core-contexts-api";
|
2
|
+
/**
|
3
|
+
* Serializable toast which is used for sending through penpal
|
4
|
+
*/
|
5
|
+
export interface PublicToast extends Omit<Toast, "primaryAction" | "secondaryAction"> {
|
6
|
+
primaryAction?: string;
|
7
|
+
secondaryAction?: string;
|
8
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
var CustomFieldType;
|
2
|
+
|
3
|
+
(function (CustomFieldType) {
|
4
|
+
CustomFieldType["BOOLEAN"] = "BOOLEAN";
|
5
|
+
CustomFieldType["DATE"] = "DATE";
|
6
|
+
CustomFieldType["DROPDOWN"] = "DROPDOWN";
|
7
|
+
CustomFieldType["EMAIL"] = "EMAIL";
|
8
|
+
CustomFieldType["NUMBER"] = "NUMBER";
|
9
|
+
CustomFieldType["PHONE_NUMBER"] = "PHONE_NUMBER";
|
10
|
+
CustomFieldType["STRING"] = "STRING";
|
11
|
+
CustomFieldType["WEB_ADDRESS"] = "WEB_ADDRESS";
|
12
|
+
})(CustomFieldType || (CustomFieldType = {}));
|
13
|
+
|
14
|
+
var UnitUs;
|
15
|
+
|
16
|
+
(function (UnitUs) {
|
17
|
+
UnitUs["mi"] = "mi";
|
18
|
+
UnitUs["yd"] = "yd";
|
19
|
+
UnitUs["ft"] = "ft";
|
20
|
+
UnitUs["in"] = "in";
|
21
|
+
UnitUs["ac"] = "ac";
|
22
|
+
UnitUs["ha"] = "ha";
|
23
|
+
UnitUs["ft_2"] = "ft\u00B2";
|
24
|
+
UnitUs["gal"] = "gal";
|
25
|
+
UnitUs["ft_3"] = "ft\u00B3";
|
26
|
+
UnitUs["ton_us"] = "ton_us";
|
27
|
+
UnitUs["lb"] = "lb";
|
28
|
+
UnitUs["oz"] = "oz";
|
29
|
+
UnitUs["mph"] = "mph";
|
30
|
+
UnitUs["lb_h"] = "lb/h";
|
31
|
+
UnitUs["lb_s"] = "lb/s";
|
32
|
+
})(UnitUs || (UnitUs = {}));
|
33
|
+
|
34
|
+
var UnitSi;
|
35
|
+
|
36
|
+
(function (UnitSi) {
|
37
|
+
UnitSi["km"] = "km";
|
38
|
+
UnitSi["m"] = "m";
|
39
|
+
UnitSi["cm"] = "cm";
|
40
|
+
UnitSi["mm"] = "mm";
|
41
|
+
UnitSi["l"] = "l";
|
42
|
+
UnitSi["kg"] = "kg";
|
43
|
+
UnitSi["g"] = "g";
|
44
|
+
UnitSi["ton"] = "ton";
|
45
|
+
UnitSi["N"] = "N";
|
46
|
+
UnitSi["kW"] = "kW";
|
47
|
+
UnitSi["W"] = "W";
|
48
|
+
UnitSi["kWh"] = "kWh";
|
49
|
+
UnitSi["kPa"] = "kPa";
|
50
|
+
UnitSi["Pa"] = "Pa";
|
51
|
+
UnitSi["bar"] = "bar";
|
52
|
+
UnitSi["m_s"] = "m/s";
|
53
|
+
UnitSi["kg_h"] = "kg/h";
|
54
|
+
UnitSi["kg_s"] = "kg/s";
|
55
|
+
UnitSi["km_h"] = "km/h";
|
56
|
+
UnitSi["km_2"] = "km\u00B2";
|
57
|
+
UnitSi["m_2"] = "m\u00B2";
|
58
|
+
UnitSi["m_3"] = "m\u00B3";
|
59
|
+
UnitSi["m_s_2"] = "m/s\u00B2";
|
60
|
+
})(UnitSi || (UnitSi = {}));
|
61
|
+
|
62
|
+
var BodyType;
|
63
|
+
|
64
|
+
(function (BodyType) {
|
65
|
+
BodyType[BodyType["Json"] = 0] = "Json";
|
66
|
+
BodyType[BodyType["FormData"] = 1] = "FormData";
|
67
|
+
})(BodyType || (BodyType = {}));
|
68
|
+
|
69
|
+
export { BodyType, CustomFieldType, UnitSi, UnitUs };
|
package/package.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "@trackunit/iris-app-runtime-core-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
|
+
"dependencies": {
|
11
|
+
"@trackunit/react-core-contexts-api": "0.0.1-alpha-afcc978985.0"
|
12
|
+
},
|
13
|
+
"peerDependencies": {}
|
14
|
+
}
|