@trackunit/iris-app-runtime-core-api 0.0.34
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 +149 -0
- package/HostConnector.d.ts +20 -0
- package/README.md +5 -0
- package/RestRuntime.d.ts +30 -0
- package/index.d.ts +4 -0
- package/index.js +69 -0
- package/package.json +14 -0
@@ -0,0 +1,149 @@
|
|
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
|
+
defaultStringValue?: string | null;
|
35
|
+
type: CustomFieldType.DATE;
|
36
|
+
};
|
37
|
+
export declare type PhoneNumberFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
38
|
+
defaultStringValue?: string | null;
|
39
|
+
type: CustomFieldType.PHONE_NUMBER;
|
40
|
+
};
|
41
|
+
export declare type EmailFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
42
|
+
defaultStringValue?: string | null;
|
43
|
+
type: CustomFieldType.EMAIL;
|
44
|
+
};
|
45
|
+
export declare type WebAddressFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
46
|
+
defaultStringValue?: string | null;
|
47
|
+
type: CustomFieldType.WEB_ADDRESS;
|
48
|
+
};
|
49
|
+
export declare type DropDownFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
50
|
+
defaultStringArrayValue?: string[] | null;
|
51
|
+
multiSelect?: boolean | null;
|
52
|
+
allValues?: string[] | null;
|
53
|
+
type: CustomFieldType.DROPDOWN;
|
54
|
+
};
|
55
|
+
export declare enum UnitUs {
|
56
|
+
"mi" = "mi",
|
57
|
+
"yd" = "yd",
|
58
|
+
"ft" = "ft",
|
59
|
+
"in" = "in",
|
60
|
+
"ac" = "ac",
|
61
|
+
"ha" = "ha",
|
62
|
+
"ft_2" = "ft\u00B2",
|
63
|
+
"gal" = "gal",
|
64
|
+
"ft_3" = "ft\u00B3",
|
65
|
+
"ton_us" = "ton_us",
|
66
|
+
"lb" = "lb",
|
67
|
+
"oz" = "oz",
|
68
|
+
"mph" = "mph",
|
69
|
+
"lb_h" = "lb/h",
|
70
|
+
"lb_s" = "lb/s"
|
71
|
+
}
|
72
|
+
export declare enum UnitSi {
|
73
|
+
"km" = "km",
|
74
|
+
"m" = "m",
|
75
|
+
"cm" = "cm",
|
76
|
+
"mm" = "mm",
|
77
|
+
"l" = "l",
|
78
|
+
"kg" = "kg",
|
79
|
+
"g" = "g",
|
80
|
+
"ton" = "ton",
|
81
|
+
"N" = "N",
|
82
|
+
"kW" = "kW",
|
83
|
+
"W" = "W",
|
84
|
+
"kWh" = "kWh",
|
85
|
+
"kPa" = "kPa",
|
86
|
+
"Pa" = "Pa",
|
87
|
+
"bar" = "bar",
|
88
|
+
"m_s" = "m/s",
|
89
|
+
"kg_h" = "kg/h",
|
90
|
+
"kg_s" = "kg/s",
|
91
|
+
"km_h" = "km/h",
|
92
|
+
"km_2" = "km\u00B2",
|
93
|
+
"m_2" = "m\u00B2",
|
94
|
+
"m_3" = "m\u00B3",
|
95
|
+
"m_s_2" = "m/s\u00B2"
|
96
|
+
}
|
97
|
+
export declare type NumberFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
98
|
+
defaultNumberValue?: number | null;
|
99
|
+
minimumNumber?: number | null;
|
100
|
+
maximumNumber?: number | null;
|
101
|
+
unitSi?: UnitSi | null;
|
102
|
+
unitUs?: UnitUs | null;
|
103
|
+
isInteger?: boolean | null;
|
104
|
+
type: CustomFieldType.NUMBER;
|
105
|
+
};
|
106
|
+
export declare type StringFieldDefinition = AbstractCustomFieldDefinitionObject & {
|
107
|
+
defaultStringValue?: string | null;
|
108
|
+
minimumLength?: number | null;
|
109
|
+
maximumLength?: number | null;
|
110
|
+
pattern?: string | null;
|
111
|
+
type: CustomFieldType.STRING;
|
112
|
+
};
|
113
|
+
export interface AbstractCustomFieldValue {
|
114
|
+
type: CustomFieldType;
|
115
|
+
}
|
116
|
+
export declare type BooleanFieldValue = AbstractCustomFieldValue & {
|
117
|
+
booleanValue?: boolean | null;
|
118
|
+
};
|
119
|
+
export declare type DateFieldValue = AbstractCustomFieldValue & {
|
120
|
+
stringValue?: string | null;
|
121
|
+
};
|
122
|
+
export declare type DropDownFieldValue = AbstractCustomFieldValue & {
|
123
|
+
stringArrayValue?: string[];
|
124
|
+
};
|
125
|
+
export declare type EmailFieldValue = AbstractCustomFieldValue & {
|
126
|
+
stringValue?: string | null;
|
127
|
+
};
|
128
|
+
export declare type NumberFieldValue = AbstractCustomFieldValue & {
|
129
|
+
numberValue?: number | null;
|
130
|
+
};
|
131
|
+
export declare type PhoneNumberFieldValue = AbstractCustomFieldValue & {
|
132
|
+
stringValue?: string | null;
|
133
|
+
};
|
134
|
+
export declare type StringFieldValue = AbstractCustomFieldValue & {
|
135
|
+
stringValue?: string | null;
|
136
|
+
};
|
137
|
+
export declare type WebAddressFieldValue = AbstractCustomFieldValue & {
|
138
|
+
stringValue?: string | null;
|
139
|
+
};
|
140
|
+
export declare type CustomFieldDefinition = BooleanFieldDefinition | DateFieldDefinition | DropDownFieldDefinition | EmailFieldDefinition | NumberFieldDefinition | PhoneNumberFieldDefinition | StringFieldDefinition | WebAddressFieldDefinition;
|
141
|
+
export declare type CustomFieldValue = BooleanFieldValue | DateFieldValue | DropDownFieldValue | EmailFieldValue | NumberFieldValue | PhoneNumberFieldValue | StringFieldValue | WebAddressFieldValue;
|
142
|
+
export interface ValueAndDefinition {
|
143
|
+
definition: CustomFieldDefinition;
|
144
|
+
value: CustomFieldValue;
|
145
|
+
}
|
146
|
+
export interface ValueAndDefinitionKey {
|
147
|
+
definitionKey: string;
|
148
|
+
value: CustomFieldValue;
|
149
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { ICurrentUserContext, 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
|
+
export interface CustomFieldError {
|
6
|
+
/**
|
7
|
+
* The custom fields that does not obey the rules of the definition, read the definition to figure out what is wrong.
|
8
|
+
*/
|
9
|
+
customFieldKeys: string[];
|
10
|
+
}
|
11
|
+
export interface HostConnectorApi {
|
12
|
+
getAssetInfo(): Promise<AssetInfo>;
|
13
|
+
requestTrackunitRestApi: <T, E>(path: string, method: string, requestParams?: RequestParams, body?: unknown, bodyType?: BodyType, secureByDefault?: boolean) => Promise<HttpResponse<T, E>>;
|
14
|
+
getCustomFieldsFor(entity: EntityIdentity): Promise<ValueAndDefinition[]>;
|
15
|
+
setCustomFieldsFor(entity: EntityIdentity, values: ValueAndDefinitionKey[]): Promise<void | CustomFieldError>;
|
16
|
+
getEnvironmentContext(): Promise<IEnvironmentContext>;
|
17
|
+
getUserSubscriptionContext(): Promise<IUserSubscriptionContext>;
|
18
|
+
getTokenContext(): Promise<ITokenContext>;
|
19
|
+
getCurrentUserContext(): Promise<ICurrentUserContext>;
|
20
|
+
}
|
package/README.md
ADDED
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 {};
|
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.34",
|
4
|
+
"repository": "https://github.com/Trackunit/manager",
|
5
|
+
"license": "MIT",
|
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.34"
|
12
|
+
},
|
13
|
+
"peerDependencies": {}
|
14
|
+
}
|