@trackunit/iris-app-runtime-core 0.0.62-alpha-01a8ce128.0 → 0.0.63

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.
@@ -1,7 +1,8 @@
1
- import { CustomFieldError, EntityIdentity, ValueAndDefinition, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
1
+ import { CustomFieldDefinition, CustomFieldError, CustomFieldValue, EntityIdentity, ValueAndDefinition, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
2
2
  export interface DropdownSelection {
3
3
  value: string;
4
4
  }
5
+ export declare const getCustomFieldValueFromRawValue: (customFieldDefinition: CustomFieldDefinition, newValue: boolean | string | string[] | DropdownSelection[] | DropdownSelection | number) => CustomFieldValue;
5
6
  export interface ICustomFieldRuntime {
6
7
  getCustomFieldsFor: (entity: EntityIdentity) => Promise<ValueAndDefinition[]>;
7
8
  setCustomFieldsFor: (entity: EntityIdentity, values: ValueAndDefinitionKey[]) => Promise<void | CustomFieldError>;
package/index.js CHANGED
@@ -1204,16 +1204,15 @@ $$1({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
1204
1204
  }
1205
1205
  });
1206
1206
 
1207
- const getValue = (customFieldDefinition, newValue) => {
1207
+ const getCustomFieldValueFromRawValue = (customFieldDefinition, newValue) => {
1208
1208
  if (customFieldDefinition.type === CustomFieldType.BOOLEAN) {
1209
- const value = newValue === "true";
1210
1209
  return {
1211
- booleanValue: value,
1210
+ booleanValue: newValue === "true",
1212
1211
  type: CustomFieldType.BOOLEAN
1213
1212
  };
1214
1213
  } else if (customFieldDefinition.type === CustomFieldType.DATE) {
1215
1214
  return {
1216
- stringValue: getStringValue(newValue),
1215
+ dateValue: getStringValue(newValue),
1217
1216
  type: CustomFieldType.DATE
1218
1217
  };
1219
1218
  } else if (customFieldDefinition.type === CustomFieldType.DROPDOWN) {
@@ -1277,7 +1276,7 @@ const getValue = (customFieldDefinition, newValue) => {
1277
1276
 
1278
1277
  const getStringValue = value => {
1279
1278
  const stringValue = value;
1280
- return stringValue === null ? null : stringValue.trim().length === 0 ? null : stringValue.trim();
1279
+ return stringValue === null || stringValue === undefined ? null : stringValue.trim().length === 0 ? null : stringValue.trim();
1281
1280
  };
1282
1281
 
1283
1282
  const CustomFieldRuntime = {
@@ -1300,7 +1299,7 @@ const CustomFieldRuntime = {
1300
1299
  if (found) {
1301
1300
  values.push({
1302
1301
  definitionKey: key,
1303
- value: getValue(found, formData[key])
1302
+ value: getCustomFieldValueFromRawValue(found, formData[key])
1304
1303
  });
1305
1304
  } else {
1306
1305
  throw new Error("Unsupported custom field type: " + key);
@@ -1461,4 +1460,4 @@ const UserSubscriptionRuntime = {
1461
1460
  })
1462
1461
  };
1463
1462
 
1464
- export { AssetRuntime, CurrentUserRuntime, CustomFieldRuntime, DeveloperSettingsRuntime, EnvironmentRuntime, NavigationRuntime, RestRuntime, ToastRuntime, TokenRuntime, UserSubscriptionRuntime };
1463
+ export { AssetRuntime, CurrentUserRuntime, CustomFieldRuntime, DeveloperSettingsRuntime, EnvironmentRuntime, NavigationRuntime, RestRuntime, ToastRuntime, TokenRuntime, UserSubscriptionRuntime, getCustomFieldValueFromRawValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-runtime-core",
3
- "version": "0.0.62-alpha-01a8ce128.0",
3
+ "version": "0.0.63",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
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.60-alpha-01a8ce128.0",
12
- "@trackunit/react-core-contexts-api": "0.0.55-alpha-01a8ce128.0"
11
+ "@trackunit/iris-app-runtime-core-api": "0.0.61",
12
+ "@trackunit/react-core-contexts-api": "0.0.55"
13
13
  },
14
14
  "peerDependencies": {}
15
15
  }