@copart/ops-tool-kit 1.13.6-alpha.4 → 1.13.6-alpha.5

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/changelog.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### alpha
2
+
3
+ FormData requests work in iframe apps, user status apps come from the user record, and the chat window can talk to the lot agent.
4
+
5
+ - `fetcher.post` / `put` / `patch` with a `FormData` body threw `DataCloneError` in iframe apps, because `postMessage` cannot clone a `FormData`. The bridge now sends the entries with `bodyType: 'formData'` and drops the iframe `Content-Type` header. The shell rebuilds the `FormData` so the browser can set the multipart boundary.
6
+ - A request body that `postMessage` cannot clone now rejects with the real error and is removed from the pending list, instead of staying pending.
7
+ - The signed-in user's status apps are read from `user_availability_checked_apps`. The apps list is the overlap of `user_eligible_apps` and `user_provisioned_apps`, with display names from `endpoints.getAllUserAvailabilityApps`.
8
+ - The status apps dropdown is disabled when `self_managed_flag` is not true.
9
+ - `mihelpAgentProps.version: 'v2'` posts to `endpoints.lotAgentChat` with `messages` and `client_context` from `storage.appContext`. The session id is kept per app, and thumbs are hidden. Apps that do not pass `version: 'v2'` still use `endpoints.mihelpChat`. The window title is G2 Agent, and the clear button is New conversation.
10
+
1
11
  ### 1.13.5
2
12
 
3
13
  Iframe storage now matches the portal store the embedded app used to share.
@@ -49,7 +49,7 @@ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
49
49
  var ReactRouterDOM__namespace = /*#__PURE__*/_interopNamespace(ReactRouterDOM);
50
50
 
51
51
  const name$1 = "@copart/ops-tool-kit";
52
- const version$3 = "1.13.6-alpha.4";
52
+ const version$3 = "1.13.6-alpha.5";
53
53
  const main$1 = "dist/ops-tool-kit.js";
54
54
  const style = "dist/ops-tool-kit.css";
55
55
  const files = [
@@ -2943,7 +2943,7 @@ function isArrayBuffer(val) {
2943
2943
  * @param {Object} val The value to test
2944
2944
  * @returns {boolean} True if value is an FormData, otherwise false
2945
2945
  */
2946
- function isFormData(val) {
2946
+ function isFormData$1(val) {
2947
2947
  return typeof FormData !== 'undefined' && val instanceof FormData;
2948
2948
  }
2949
2949
 
@@ -3186,7 +3186,7 @@ var utils = {
3186
3186
  isArray: isArray$2,
3187
3187
  isArrayBuffer: isArrayBuffer,
3188
3188
  isBuffer: isBuffer_1$1,
3189
- isFormData: isFormData,
3189
+ isFormData: isFormData$1,
3190
3190
  isArrayBufferView: isArrayBufferView,
3191
3191
  isString: isString,
3192
3192
  isNumber: isNumber,
@@ -70064,6 +70064,31 @@ function isAllowedOrigin(origin) {
70064
70064
  }
70065
70065
  }
70066
70066
 
70067
+ // window.parent.postMessage copies its payload with the structured clone algorithm, which
70068
+ // cannot clone a FormData (DataCloneError). Its entries can be cloned: strings, File and
70069
+ // Blob values all survive, so the bridge sends the entries and the shell rebuilds the FormData.
70070
+ var FORM_DATA_BODY_TYPE = 'formData';
70071
+ function isFormData(value) {
70072
+ return typeof FormData !== 'undefined' && value instanceof FormData;
70073
+ }
70074
+
70075
+ // [[name, value], ...] in append order; duplicate names are kept.
70076
+ function serializeFormData(formData) {
70077
+ return Array.from(formData.entries());
70078
+ }
70079
+
70080
+ // The iframe app sets Content-Type: multipart/form-data with no boundary. The browser
70081
+ // adds the boundary only when it sends a FormData itself, so that header must not be
70082
+ // forwarded. Axios 0.18 also drops Content-Type when the body is a FormData.
70083
+ function headersForFormData(headers) {
70084
+ if (!headers || _typeof$1(headers) !== 'object') return headers;
70085
+ var next = _objectSpread2({}, headers);
70086
+ Object.keys(next).forEach(function (key) {
70087
+ if (String(key).toLowerCase() === 'content-type') delete next[key];
70088
+ });
70089
+ return next;
70090
+ }
70091
+
70067
70092
  var _excluded$1 = ["signal"];
70068
70093
  var pending = new Map();
70069
70094
  var STORAGE_REQUEST_TIMEOUT_MS = 5000;
@@ -70517,7 +70542,14 @@ if (typeof window !== 'undefined') {
70517
70542
  }
70518
70543
  function sendFetchRequest(payload) {
70519
70544
  var signal = payload.signal,
70520
- restPayload = _objectWithoutProperties(payload, _excluded$1);
70545
+ rest = _objectWithoutProperties(payload, _excluded$1);
70546
+ // A FormData body cannot be posted to the shell as-is (see ./formData.js). It is sent as
70547
+ // its entries, flagged with bodyType so the shell knows to rebuild it.
70548
+ var restPayload = isFormData(rest.data) ? _objectSpread2(_objectSpread2({}, rest), {}, {
70549
+ data: serializeFormData(rest.data),
70550
+ bodyType: FORM_DATA_BODY_TYPE,
70551
+ headers: headersForFormData(rest.headers)
70552
+ }) : rest;
70521
70553
  return new Promise(function (resolve, reject) {
70522
70554
  if (signal !== null && signal !== void 0 && signal.aborted) {
70523
70555
  reject(new DOMException('Request aborted', 'AbortError'));
@@ -70529,8 +70561,9 @@ function sendFetchRequest(payload) {
70529
70561
  reject: reject,
70530
70562
  responseType: payload.responseType
70531
70563
  });
70564
+ var onAbort;
70532
70565
  if (signal) {
70533
- var onAbort = function onAbort() {
70566
+ onAbort = function onAbort() {
70534
70567
  if (pending.has(id)) {
70535
70568
  pending.delete(id);
70536
70569
  post(IFRAME_EVENTS.CANCEL_REQUEST, {
@@ -70543,11 +70576,24 @@ function sendFetchRequest(payload) {
70543
70576
  once: true
70544
70577
  });
70545
70578
  }
70546
- var sent = post(IFRAME_EVENTS.FETCH_REQUEST, _objectSpread2(_objectSpread2({}, restPayload), {}, {
70547
- requestId: id
70548
- }));
70549
- if (!sent) {
70579
+ var dropPending = function dropPending() {
70550
70580
  pending.delete(id);
70581
+ if (signal && onAbort) signal.removeEventListener('abort', onAbort);
70582
+ };
70583
+ var sent;
70584
+ try {
70585
+ sent = post(IFRAME_EVENTS.FETCH_REQUEST, _objectSpread2(_objectSpread2({}, restPayload), {}, {
70586
+ requestId: id
70587
+ }));
70588
+ } catch (error) {
70589
+ // postMessage throws DataCloneError for any body the structured clone cannot copy.
70590
+ // Without this the request stays in `pending` forever.
70591
+ dropPending();
70592
+ reject(error);
70593
+ return;
70594
+ }
70595
+ if (!sent) {
70596
+ dropPending();
70551
70597
  reject(new Error('iframe-bridge: FETCH_REQUEST blocked — shell origin not pinned'));
70552
70598
  }
70553
70599
  });