@peektravel/app-utilities 0.9.3 → 0.9.4

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/dist/index.cjs CHANGED
@@ -961,6 +961,7 @@ function fromBookingMetaDataNode(node) {
961
961
  function fromFieldResponseNode(response) {
962
962
  const field = response.fieldLocation?.field;
963
963
  const prompt = response.fieldLocation?.prompt;
964
+ const { value, displayValue } = fromValueNode(response.value);
964
965
  return {
965
966
  id: field?.id || "",
966
967
  name: field?.name || "",
@@ -970,89 +971,96 @@ function fromFieldResponseNode(response) {
970
971
  promptHint: prompt?.hint ?? null,
971
972
  isRequired: Boolean(prompt?.isRequired),
972
973
  refid: response.refid || "",
973
- value: fromValueNode(response.value)
974
+ displayValue,
975
+ value
974
976
  };
975
977
  }
976
978
  function fromValueNode(value) {
977
- if (!value || !value.__typename) return null;
979
+ if (!value || !value.__typename) return { value: null, displayValue: "" };
978
980
  switch (value.__typename) {
979
981
  case "AgeFieldResponseValue": {
980
982
  const age = value.age ?? 0;
981
- return { kind: "age", age, displayValue: String(age) };
983
+ return { value: { kind: "age", age }, displayValue: String(age) };
982
984
  }
983
985
  case "AttachmentFieldResponseValue": {
984
986
  const attachmentUrl = value.attachmentUrl ?? "";
985
987
  const name = value.name ?? null;
986
988
  return {
987
- kind: "attachment",
988
- attachmentUrl,
989
- mime: value.mime ?? null,
990
- name,
991
- size: value.size ?? null,
989
+ value: {
990
+ kind: "attachment",
991
+ attachmentUrl,
992
+ mime: value.mime ?? null,
993
+ name,
994
+ size: value.size ?? null
995
+ },
992
996
  displayValue: name || attachmentUrl
993
997
  };
994
998
  }
995
999
  case "BarcodeFieldResponseValue": {
996
1000
  const barcodeValue = value.barcodeValue ?? "";
997
1001
  return {
998
- kind: "barcode",
999
- barcodeType: value.barcodeType ?? null,
1000
- barcodeValue,
1002
+ value: {
1003
+ kind: "barcode",
1004
+ barcodeType: value.barcodeType ?? null,
1005
+ barcodeValue
1006
+ },
1001
1007
  displayValue: barcodeValue
1002
1008
  };
1003
1009
  }
1004
1010
  case "BooleanFieldResponseValue": {
1005
1011
  const bool = Boolean(value.boolean);
1006
- return { kind: "boolean", boolean: bool, displayValue: yesNo(bool) };
1012
+ return { value: { kind: "boolean", boolean: bool }, displayValue: yesNo(bool) };
1007
1013
  }
1008
1014
  case "CheckboxFieldResponseValue": {
1009
1015
  const isChecked = Boolean(value.isChecked);
1010
- return { kind: "checkbox", isChecked, displayValue: yesNo(isChecked) };
1016
+ return { value: { kind: "checkbox", isChecked }, displayValue: yesNo(isChecked) };
1011
1017
  }
1012
1018
  case "CurrencyFieldResponseValue": {
1013
1019
  const currency = value.currency ?? "";
1014
- return { kind: "currency", currency, displayValue: currency };
1020
+ return { value: { kind: "currency", currency }, displayValue: currency };
1015
1021
  }
1016
1022
  case "DateFieldResponseValue": {
1017
1023
  const date = value.date ?? "";
1018
- return { kind: "date", date, displayValue: date };
1024
+ return { value: { kind: "date", date }, displayValue: date };
1019
1025
  }
1020
1026
  case "DecimalFieldResponseValue": {
1021
1027
  const decimal = value.decimal ?? null;
1022
- return { kind: "decimal", decimal, displayValue: decimal ?? "" };
1028
+ return { value: { kind: "decimal", decimal }, displayValue: decimal ?? "" };
1023
1029
  }
1024
1030
  case "DurationFieldResponseValue": {
1025
1031
  const amount = value.duration?.amount ?? 0;
1026
1032
  const unit = value.duration?.unit ?? null;
1027
- return { kind: "duration", amount, unit, displayValue: amountUnit(amount, unit) };
1033
+ return { value: { kind: "duration", amount, unit }, displayValue: amountUnit(amount, unit) };
1028
1034
  }
1029
1035
  case "EmailFieldResponseValue": {
1030
1036
  const email = value.email ?? null;
1031
- return { kind: "email", email, displayValue: email ?? "" };
1037
+ return { value: { kind: "email", email }, displayValue: email ?? "" };
1032
1038
  }
1033
1039
  case "GuestFieldResponseValue": {
1034
1040
  const name = value.name ?? null;
1035
1041
  return {
1036
- kind: "guest",
1037
- name,
1038
- email: value.email ?? null,
1039
- dateOfBirth: value.dateOfBirth ?? null,
1040
- notes: value.notes ?? null,
1041
- waiverSigned: value.waiverSigned ?? null,
1042
+ value: {
1043
+ kind: "guest",
1044
+ name,
1045
+ email: value.email ?? null,
1046
+ dateOfBirth: value.dateOfBirth ?? null,
1047
+ notes: value.notes ?? null,
1048
+ waiverSigned: value.waiverSigned ?? null
1049
+ },
1042
1050
  displayValue: name ?? ""
1043
1051
  };
1044
1052
  }
1045
1053
  case "HtmlFieldResponseValue": {
1046
1054
  const html = value.html ?? "";
1047
- return { kind: "html", html, displayValue: escapeHtml(html) };
1055
+ return { value: { kind: "html", html }, displayValue: escapeHtml(html) };
1048
1056
  }
1049
1057
  case "ImageUrlFieldResponseValue": {
1050
1058
  const imageUrl = value.imageUrl ?? "";
1051
- return { kind: "imageUrl", imageUrl, displayValue: imageUrl };
1059
+ return { value: { kind: "imageUrl", imageUrl }, displayValue: imageUrl };
1052
1060
  }
1053
1061
  case "IntegerFieldResponseValue": {
1054
1062
  const integer = value.integer ?? 0;
1055
- return { kind: "integer", integer, displayValue: String(integer) };
1063
+ return { value: { kind: "integer", integer }, displayValue: String(integer) };
1056
1064
  }
1057
1065
  case "LocationFieldResponseValue": {
1058
1066
  const streetAddress = value.streetAddress ?? null;
@@ -1061,56 +1069,58 @@ function fromValueNode(value) {
1061
1069
  const postalCode = value.postalCode ?? null;
1062
1070
  const country = value.country ?? null;
1063
1071
  return {
1064
- kind: "location",
1065
- country,
1066
- county: value.county ?? null,
1067
- locality,
1068
- postalCode,
1069
- region,
1070
- streetAddress,
1072
+ value: {
1073
+ kind: "location",
1074
+ country,
1075
+ county: value.county ?? null,
1076
+ locality,
1077
+ postalCode,
1078
+ region,
1079
+ streetAddress
1080
+ },
1071
1081
  displayValue: [streetAddress, locality, region, postalCode, country].filter((part) => part).join(", ")
1072
1082
  };
1073
1083
  }
1074
1084
  case "LongTextFieldResponseValue": {
1075
1085
  const longText = value.longText ?? "";
1076
- return { kind: "longText", longText, displayValue: longText };
1086
+ return { value: { kind: "longText", longText }, displayValue: longText };
1077
1087
  }
1078
1088
  case "MetaFieldResponseValue": {
1079
1089
  const meta = value.meta ?? null;
1080
- return { kind: "meta", meta, displayValue: meta == null ? "" : JSON.stringify(meta) };
1090
+ return { value: { kind: "meta", meta }, displayValue: meta == null ? "" : JSON.stringify(meta) };
1081
1091
  }
1082
1092
  case "PercentFieldResponseValue": {
1083
1093
  const percent = value.percent ?? null;
1084
- return { kind: "percent", percent, displayValue: percent == null ? "" : `${percent}%` };
1094
+ return { value: { kind: "percent", percent }, displayValue: percent == null ? "" : `${percent}%` };
1085
1095
  }
1086
1096
  case "PhoneFieldResponseValue": {
1087
1097
  const phone = value.phone ?? "";
1088
- return { kind: "phone", phone, displayValue: phone };
1098
+ return { value: { kind: "phone", phone }, displayValue: phone };
1089
1099
  }
1090
1100
  case "ShortTextFieldResponseValue": {
1091
1101
  const shortText = value.shortText ?? "";
1092
- return { kind: "shortText", shortText, displayValue: shortText };
1102
+ return { value: { kind: "shortText", shortText }, displayValue: shortText };
1093
1103
  }
1094
1104
  case "TimeFieldResponseValue": {
1095
1105
  const time = value.time ?? "";
1096
- return { kind: "time", time, displayValue: time };
1106
+ return { value: { kind: "time", time }, displayValue: time };
1097
1107
  }
1098
1108
  case "UrlFieldResponseValue": {
1099
1109
  const url = value.url ?? null;
1100
- return { kind: "url", url, displayValue: url ?? "" };
1110
+ return { value: { kind: "url", url }, displayValue: url ?? "" };
1101
1111
  }
1102
1112
  case "VolumeFieldResponseValue": {
1103
1113
  const amount = value.volume?.amount ?? "0";
1104
1114
  const unit = value.volume?.unit ?? null;
1105
- return { kind: "volume", amount, unit, displayValue: amountUnit(amount, unit) };
1115
+ return { value: { kind: "volume", amount, unit }, displayValue: amountUnit(amount, unit) };
1106
1116
  }
1107
1117
  case "WeightFieldResponseValue": {
1108
1118
  const amount = value.weight?.amount ?? "0";
1109
1119
  const unit = value.weight?.unit ?? null;
1110
- return { kind: "weight", amount, unit, displayValue: amountUnit(amount, unit) };
1120
+ return { value: { kind: "weight", amount, unit }, displayValue: amountUnit(amount, unit) };
1111
1121
  }
1112
1122
  default:
1113
- return null;
1123
+ return { value: null, displayValue: "" };
1114
1124
  }
1115
1125
  }
1116
1126
  function yesNo(value) {
@@ -1130,7 +1140,7 @@ function toSetMetaDataResult(node, bookingId) {
1130
1140
  };
1131
1141
  }
1132
1142
  function filterMetaDataByIntegrator(metaData, integrator) {
1133
- const prefix = `integrator:${integrator}:`;
1143
+ const prefix = `integrators:${integrator}:`;
1134
1144
  return metaData.filter((entry) => entry.slug.startsWith(prefix)).map((entry) => ({ ...entry, slug: entry.slug.slice(prefix.length) }));
1135
1145
  }
1136
1146
 
@@ -1626,7 +1636,7 @@ var BookingService = class {
1626
1636
  /**
1627
1637
  * Returns a booking's custom-field metadata (its `fieldResponses`), scoped to
1628
1638
  * this service's integrator. Only fields whose slug starts with
1629
- * `integrator:<integrator>:` are returned, and that prefix is stripped from
1639
+ * `integrators:<integrator>:` are returned, and that prefix is stripped from
1630
1640
  * each returned `slug`. Returns `[]` when the booking is not found or has no
1631
1641
  * matching fields.
1632
1642
  *
@@ -2664,7 +2674,7 @@ async function requestWithRetry(http, url, init, label, onResponse) {
2664
2674
  // src/internal/sdk-headers.ts
2665
2675
  var SDK_HEADER_NAME = "x-peek-sdk";
2666
2676
  var SDK_PLATFORM = "js";
2667
- var SDK_VERSION = "0.9.3";
2677
+ var SDK_VERSION = "0.9.4";
2668
2678
  var SDK_HEADER_VALUE = `${SDK_PLATFORM}-${SDK_VERSION}`;
2669
2679
 
2670
2680
  // src/internal/peek/graphql-client.ts