@trackunit/iris-app-runtime-core 0.0.42 → 0.0.46
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 +2 -1
- package/CurrentUserRuntime.d.ts +3 -2
- package/CustomFieldRuntime.d.ts +5 -3
- package/DeveloperSettingsRuntime.d.ts +4 -0
- package/EnvironmentRuntime.d.ts +3 -2
- package/RestRuntime.d.ts +5 -3
- package/TokenRuntime.d.ts +3 -2
- package/UserSubscriptionRuntime.d.ts +3 -2
- package/index.d.ts +1 -0
- package/index.js +113 -117
- package/package.json +3 -3
package/AssetRuntime.d.ts
CHANGED
package/CurrentUserRuntime.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ICurrentUserContext } from "@trackunit/react-core-contexts-api";
|
|
2
|
-
export
|
|
2
|
+
export interface ICurrentUserRuntime {
|
|
3
3
|
getCurrentUserContext: () => Promise<ICurrentUserContext>;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export declare const CurrentUserRuntime: ICurrentUserRuntime;
|
package/CustomFieldRuntime.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { CustomFieldError, EntityIdentity, ValueAndDefinition, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
|
|
2
|
-
export
|
|
2
|
+
export interface DropdownSelection {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ICustomFieldRuntime {
|
|
3
6
|
getCustomFieldsFor: (entity: EntityIdentity) => Promise<ValueAndDefinition[]>;
|
|
4
7
|
setCustomFieldsFor: (entity: EntityIdentity, values: ValueAndDefinitionKey[]) => Promise<void | CustomFieldError>;
|
|
5
8
|
setCustomFieldsFromFormData: (entity: EntityIdentity, formData: Record<string, boolean | string | string[] | number>, originalDefinitions: ValueAndDefinition[]) => Promise<void | CustomFieldError>;
|
|
6
|
-
private getValue;
|
|
7
|
-
private getStringValue;
|
|
8
9
|
}
|
|
10
|
+
export declare const CustomFieldRuntime: ICustomFieldRuntime;
|
package/EnvironmentRuntime.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IEnvironmentContext } from "@trackunit/react-core-contexts-api";
|
|
2
|
-
export
|
|
2
|
+
export interface IEnvironmentRuntime {
|
|
3
3
|
getEnvironmentContext: () => Promise<IEnvironmentContext>;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export declare const EnvironmentRuntime: IEnvironmentRuntime;
|
package/RestRuntime.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { BodyType, HttpResponse,
|
|
2
|
-
export declare
|
|
1
|
+
import { BodyType, HttpResponse, RequestParams } from "@trackunit/iris-app-runtime-core-api";
|
|
2
|
+
export declare type RestRunTimeResponse = HttpResponse<any, any>;
|
|
3
|
+
export interface IRestRuntime {
|
|
3
4
|
apiHost: string;
|
|
4
|
-
request(path: string, method: string, requestParams?: RequestParams | undefined, body?: unknown, bodyType?: BodyType | undefined, secureByDefault?: boolean | undefined)
|
|
5
|
+
request: (path: string, method: string, requestParams?: RequestParams | undefined, body?: unknown, bodyType?: BodyType | undefined, secureByDefault?: boolean | undefined) => Promise<RestRunTimeResponse>;
|
|
5
6
|
}
|
|
7
|
+
export declare const RestRuntime: IRestRuntime;
|
package/TokenRuntime.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IUserSubscriptionContext } from "@trackunit/react-core-contexts-api";
|
|
2
|
-
export
|
|
2
|
+
export interface IUserSubscriptionRuntime {
|
|
3
3
|
getUserSubscriptionContext: () => Promise<IUserSubscriptionContext>;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export declare const UserSubscriptionRuntime: IUserSubscriptionRuntime;
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "@trackunit/iris-app-runtime-core-api";
|
|
|
2
2
|
export * from "./AssetRuntime";
|
|
3
3
|
export * from "./CurrentUserRuntime";
|
|
4
4
|
export * from "./CustomFieldRuntime";
|
|
5
|
+
export * from "./DeveloperSettingsRuntime";
|
|
5
6
|
export * from "./EnvironmentRuntime";
|
|
6
7
|
export * from "./RestRuntime";
|
|
7
8
|
export * from "./TokenRuntime";
|
package/index.js
CHANGED
|
@@ -35,15 +35,12 @@ const getHostConnector = () => {
|
|
|
35
35
|
return hostConnector.promise;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}
|
|
38
|
+
const AssetRuntime = {
|
|
39
|
+
getAssetInfo: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const api = yield getHostConnector();
|
|
41
|
+
return api.getAssetInfo();
|
|
42
|
+
})
|
|
43
|
+
};
|
|
47
44
|
|
|
48
45
|
const CurrentUserRuntime = {
|
|
49
46
|
getCurrentUserContext: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1181,116 +1178,118 @@ $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
|
|
|
1181
1178
|
}
|
|
1182
1179
|
});
|
|
1183
1180
|
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
if (found) {
|
|
1205
|
-
values.push({
|
|
1206
|
-
definitionKey: key,
|
|
1207
|
-
value: this.getValue(found, formData[key])
|
|
1208
|
-
});
|
|
1181
|
+
const getValue = (customFieldDefinition, newValue) => {
|
|
1182
|
+
if (customFieldDefinition.type === CustomFieldType.BOOLEAN) {
|
|
1183
|
+
const value = newValue === "true";
|
|
1184
|
+
return {
|
|
1185
|
+
booleanValue: value,
|
|
1186
|
+
type: CustomFieldType.BOOLEAN
|
|
1187
|
+
};
|
|
1188
|
+
} else if (customFieldDefinition.type === CustomFieldType.DATE) {
|
|
1189
|
+
return {
|
|
1190
|
+
stringValue: getStringValue(newValue),
|
|
1191
|
+
type: CustomFieldType.DATE
|
|
1192
|
+
};
|
|
1193
|
+
} else if (customFieldDefinition.type === CustomFieldType.DROPDOWN) {
|
|
1194
|
+
const stringArrayValue = [];
|
|
1195
|
+
|
|
1196
|
+
if (Array.isArray(newValue)) {
|
|
1197
|
+
newValue.forEach(item => {
|
|
1198
|
+
if (typeof item === "string") {
|
|
1199
|
+
stringArrayValue.push(item);
|
|
1209
1200
|
} else {
|
|
1210
|
-
|
|
1201
|
+
stringArrayValue.push(item === null || item === void 0 ? void 0 : item.value);
|
|
1211
1202
|
}
|
|
1212
1203
|
});
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
if (customFieldDefinition.type === CustomFieldType.BOOLEAN) {
|
|
1219
|
-
const value = newValue === "true";
|
|
1220
|
-
return {
|
|
1221
|
-
booleanValue: value,
|
|
1222
|
-
type: CustomFieldType.BOOLEAN
|
|
1223
|
-
};
|
|
1224
|
-
} else if (customFieldDefinition.type === CustomFieldType.DATE) {
|
|
1225
|
-
return {
|
|
1226
|
-
stringValue: this.getStringValue(newValue),
|
|
1227
|
-
type: CustomFieldType.DATE
|
|
1228
|
-
};
|
|
1229
|
-
} else if (customFieldDefinition.type === CustomFieldType.DROPDOWN) {
|
|
1230
|
-
const stringArrayValue = [];
|
|
1231
|
-
|
|
1232
|
-
if (Array.isArray(newValue)) {
|
|
1233
|
-
newValue.forEach(item => {
|
|
1234
|
-
if (typeof item === "string") {
|
|
1235
|
-
stringArrayValue.push(item);
|
|
1236
|
-
} else {
|
|
1237
|
-
stringArrayValue.push(item === null || item === void 0 ? void 0 : item.value);
|
|
1238
|
-
}
|
|
1239
|
-
});
|
|
1240
|
-
} else {
|
|
1241
|
-
if (typeof newValue === "string") {
|
|
1242
|
-
stringArrayValue.push(newValue);
|
|
1243
|
-
} else if (typeof newValue === "object") {
|
|
1244
|
-
stringArrayValue.push(newValue === null || newValue === void 0 ? void 0 : newValue.value);
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
return {
|
|
1249
|
-
stringArrayValue: stringArrayValue,
|
|
1250
|
-
type: CustomFieldType.DROPDOWN
|
|
1251
|
-
};
|
|
1252
|
-
} else if (customFieldDefinition.type === CustomFieldType.EMAIL) {
|
|
1253
|
-
return {
|
|
1254
|
-
stringValue: this.getStringValue(newValue),
|
|
1255
|
-
type: CustomFieldType.EMAIL
|
|
1256
|
-
};
|
|
1257
|
-
} else if (customFieldDefinition.type === CustomFieldType.NUMBER) {
|
|
1258
|
-
let value = customFieldDefinition.isInteger ? parseInt(newValue) : parseFloat(newValue);
|
|
1259
|
-
|
|
1260
|
-
if (isNaN(value)) {
|
|
1261
|
-
value = null;
|
|
1204
|
+
} else {
|
|
1205
|
+
if (typeof newValue === "string") {
|
|
1206
|
+
stringArrayValue.push(newValue);
|
|
1207
|
+
} else if (typeof newValue === "object") {
|
|
1208
|
+
stringArrayValue.push(newValue === null || newValue === void 0 ? void 0 : newValue.value);
|
|
1262
1209
|
}
|
|
1210
|
+
}
|
|
1263
1211
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
} else if (customFieldDefinition.type === CustomFieldType.WEB_ADDRESS) {
|
|
1279
|
-
return {
|
|
1280
|
-
stringValue: this.getStringValue(newValue),
|
|
1281
|
-
type: CustomFieldType.WEB_ADDRESS
|
|
1282
|
-
};
|
|
1212
|
+
return {
|
|
1213
|
+
stringArrayValue: stringArrayValue,
|
|
1214
|
+
type: CustomFieldType.DROPDOWN
|
|
1215
|
+
};
|
|
1216
|
+
} else if (customFieldDefinition.type === CustomFieldType.EMAIL) {
|
|
1217
|
+
return {
|
|
1218
|
+
stringValue: getStringValue(newValue),
|
|
1219
|
+
type: CustomFieldType.EMAIL
|
|
1220
|
+
};
|
|
1221
|
+
} else if (customFieldDefinition.type === CustomFieldType.NUMBER) {
|
|
1222
|
+
let value = customFieldDefinition.isInteger ? parseInt(newValue) : parseFloat(newValue);
|
|
1223
|
+
|
|
1224
|
+
if (isNaN(value)) {
|
|
1225
|
+
value = null;
|
|
1283
1226
|
}
|
|
1284
1227
|
|
|
1285
|
-
|
|
1228
|
+
return {
|
|
1229
|
+
numberValue: value,
|
|
1230
|
+
type: CustomFieldType.NUMBER
|
|
1231
|
+
};
|
|
1232
|
+
} else if (customFieldDefinition.type === CustomFieldType.PHONE_NUMBER) {
|
|
1233
|
+
return {
|
|
1234
|
+
stringValue: getStringValue(newValue),
|
|
1235
|
+
type: CustomFieldType.PHONE_NUMBER
|
|
1236
|
+
};
|
|
1237
|
+
} else if (customFieldDefinition.type === CustomFieldType.STRING) {
|
|
1238
|
+
return {
|
|
1239
|
+
stringValue: getStringValue(newValue),
|
|
1240
|
+
type: CustomFieldType.STRING
|
|
1241
|
+
};
|
|
1242
|
+
} else if (customFieldDefinition.type === CustomFieldType.WEB_ADDRESS) {
|
|
1243
|
+
return {
|
|
1244
|
+
stringValue: getStringValue(newValue),
|
|
1245
|
+
type: CustomFieldType.WEB_ADDRESS
|
|
1246
|
+
};
|
|
1286
1247
|
}
|
|
1287
1248
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
return stringValue === null ? null : stringValue.trim().length === 0 ? null : stringValue.trim();
|
|
1291
|
-
}
|
|
1249
|
+
throw new Error("Unsupported custom field type");
|
|
1250
|
+
};
|
|
1292
1251
|
|
|
1293
|
-
|
|
1252
|
+
const getStringValue = value => {
|
|
1253
|
+
const stringValue = value;
|
|
1254
|
+
return stringValue === null ? null : stringValue.trim().length === 0 ? null : stringValue.trim();
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
const CustomFieldRuntime = {
|
|
1258
|
+
getCustomFieldsFor: entity => __awaiter(void 0, void 0, void 0, function* () {
|
|
1259
|
+
const api = yield getHostConnector();
|
|
1260
|
+
return api.getCustomFieldsFor(entity);
|
|
1261
|
+
}),
|
|
1262
|
+
setCustomFieldsFor: (entity, values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1263
|
+
const api = yield getHostConnector();
|
|
1264
|
+
return api.setCustomFieldsFor(entity, values);
|
|
1265
|
+
}),
|
|
1266
|
+
setCustomFieldsFromFormData: (entity, formData, originalDefinitions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1267
|
+
const api = yield getHostConnector();
|
|
1268
|
+
const values = [];
|
|
1269
|
+
Object.keys(formData).forEach(key => {
|
|
1270
|
+
var _a;
|
|
1271
|
+
|
|
1272
|
+
const found = (_a = originalDefinitions.find(originalDefinition => originalDefinition.definition.key === key)) === null || _a === void 0 ? void 0 : _a.definition;
|
|
1273
|
+
|
|
1274
|
+
if (found) {
|
|
1275
|
+
values.push({
|
|
1276
|
+
definitionKey: key,
|
|
1277
|
+
value: getValue(found, formData[key])
|
|
1278
|
+
});
|
|
1279
|
+
} else {
|
|
1280
|
+
throw new Error("Unsupported custom field type: " + key);
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
return api.setCustomFieldsFor(entity, values);
|
|
1284
|
+
})
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
const DeveloperSettingsRuntime = {
|
|
1288
|
+
getDeveloperSettingsContext: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1289
|
+
const api = yield getHostConnector();
|
|
1290
|
+
return api.getDeveloperSettingsContext();
|
|
1291
|
+
})
|
|
1292
|
+
};
|
|
1294
1293
|
|
|
1295
1294
|
const EnvironmentRuntime = {
|
|
1296
1295
|
getEnvironmentContext: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1299,20 +1298,17 @@ const EnvironmentRuntime = {
|
|
|
1299
1298
|
})
|
|
1300
1299
|
};
|
|
1301
1300
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
this.apiHost = "https://API_HOST";
|
|
1305
|
-
}
|
|
1301
|
+
const RestRuntime = {
|
|
1302
|
+
apiHost: "https://API_HOST",
|
|
1306
1303
|
|
|
1307
|
-
request(path, method, requestParams, body, bodyType, secureByDefault
|
|
1308
|
-
) {
|
|
1304
|
+
request(path, method, requestParams, body, bodyType, secureByDefault) {
|
|
1309
1305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1310
1306
|
const api = yield getHostConnector();
|
|
1311
1307
|
return api.requestTrackunitRestApi(path, method, requestParams, body, bodyType, secureByDefault);
|
|
1312
1308
|
});
|
|
1313
1309
|
}
|
|
1314
1310
|
|
|
1315
|
-
}
|
|
1311
|
+
};
|
|
1316
1312
|
|
|
1317
1313
|
const TokenRuntime = {
|
|
1318
1314
|
getTokenContext: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1328,4 +1324,4 @@ const UserSubscriptionRuntime = {
|
|
|
1328
1324
|
})
|
|
1329
1325
|
};
|
|
1330
1326
|
|
|
1331
|
-
export { AssetRuntime, CurrentUserRuntime, CustomFieldRuntime, EnvironmentRuntime, RestRuntime, TokenRuntime, UserSubscriptionRuntime };
|
|
1327
|
+
export { AssetRuntime, CurrentUserRuntime, CustomFieldRuntime, DeveloperSettingsRuntime, EnvironmentRuntime, RestRuntime, TokenRuntime, UserSubscriptionRuntime };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-runtime-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@trackunit/iris-app-runtime-core-api": "0.0.
|
|
12
|
-
"@trackunit/react-core-contexts-api": "0.0.
|
|
11
|
+
"@trackunit/iris-app-runtime-core-api": "0.0.44",
|
|
12
|
+
"@trackunit/react-core-contexts-api": "0.0.43"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {}
|
|
15
15
|
}
|