@adobe/alloy 2.30.1-beta.14 → 2.30.1-beta.15

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,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- exports.BC_SESSION_COOKIE_NAME = void 0;
3
+ exports.STREAM_START_TIMEOUT_MS = exports.BC_SESSION_COOKIE_NAME = void 0;
4
4
  /*
5
5
  Copyright 2025 Adobe. All rights reserved.
6
6
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -12,4 +12,5 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
12
12
  OF ANY KIND, either express or implied. See the License for the specific language
13
13
  governing permissions and limitations under the License.
14
14
  */
15
- const BC_SESSION_COOKIE_NAME = exports.BC_SESSION_COOKIE_NAME = "bc_session_id";
15
+ const BC_SESSION_COOKIE_NAME = exports.BC_SESSION_COOKIE_NAME = "bc_session_id";
16
+ const STREAM_START_TIMEOUT_MS = exports.STREAM_START_TIMEOUT_MS = 10000;
@@ -6,6 +6,7 @@ var _createConversationServiceRequest = require("./createConversationServiceRequ
6
6
  var _utils = require("./utils.js");
7
7
  var _uuid = require("../../utils/uuid.js");
8
8
  var _createStreamParser = require("./createStreamParser.js");
9
+ var _createTimeoutWrapper = require("./createTimeoutWrapper.js");
9
10
  /*
10
11
  Copyright 2025 Adobe. All rights reserved.
11
12
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -118,6 +119,7 @@ var _default = ({
118
119
  }
119
120
  const onStreamResponseCallback = event => {
120
121
  if (event.error) {
122
+ logger.error("Stream error occurred", event.error);
121
123
  onStreamResponse({
122
124
  error: event.error
123
125
  });
@@ -132,8 +134,11 @@ var _default = ({
132
134
  logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
133
135
  onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
134
136
  };
137
+ const wrappedCallback = (0, _createTimeoutWrapper.default)({
138
+ onStreamResponseCallback
139
+ });
135
140
  const streamParser = (0, _createStreamParser.default)();
136
- streamParser(response.body, onStreamResponseCallback);
141
+ streamParser(response.body, wrappedCallback);
137
142
  });
138
143
  });
139
144
  };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _constants = require("./constants.js");
5
+ /*
6
+ Copyright 2025 Adobe. All rights reserved.
7
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License. You may obtain a copy
9
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software distributed under
12
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ OF ANY KIND, either express or implied. See the License for the specific language
14
+ governing permissions and limitations under the License.
15
+ */
16
+ /**
17
+ * Creates a wrapper around a callback that implements a timeout for the first call.
18
+ * If the callback is not invoked within the specified timeout, an error is passed to it.
19
+ * After timeout fires, all subsequent calls are ignored.
20
+ *
21
+ * @param {Function} callback - The callback function to wrap
22
+ * @returns {Function} Wrapped callback function
23
+ */
24
+ var _default = ({
25
+ onStreamResponseCallback
26
+ }) => {
27
+ const timeoutMs = _constants.STREAM_START_TIMEOUT_MS;
28
+ let firstCallMade = false;
29
+ let timedOut = false;
30
+ const timeoutId = setTimeout(() => {
31
+ // Double-check firstCallMade right before firing
32
+ if (!firstCallMade) {
33
+ timedOut = true;
34
+ onStreamResponseCallback({
35
+ error: {
36
+ message: "Stream timeout: No data received within 10 seconds"
37
+ }
38
+ });
39
+ }
40
+ }, timeoutMs);
41
+ return event => {
42
+ if (timedOut) {
43
+ return;
44
+ }
45
+ if (!firstCallMade) {
46
+ firstCallMade = true;
47
+ clearTimeout(timeoutId);
48
+ }
49
+ onStreamResponseCallback(event);
50
+ };
51
+ };
52
+ exports.default = _default;
@@ -14,4 +14,4 @@ governing permissions and limitations under the License.
14
14
  */
15
15
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
16
16
  // see babel-plugin-version
17
- var _default = exports.default = "2.30.1-beta.14";
17
+ var _default = exports.default = "2.30.1-beta.15";
@@ -9,4 +9,5 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- export const BC_SESSION_COOKIE_NAME = "bc_session_id";
12
+ export const BC_SESSION_COOKIE_NAME = "bc_session_id";
13
+ export const STREAM_START_TIMEOUT_MS = 10000;
@@ -14,6 +14,7 @@ import createConversationServiceRequest from "./createConversationServiceRequest
14
14
  import { getConciergeSessionCookie, getPageSurface } from "./utils.js";
15
15
  import uuid from "../../utils/uuid.js";
16
16
  import createStreamParser from "./createStreamParser.js";
17
+ import createTimeoutWrapper from "./createTimeoutWrapper.js";
17
18
  export default ({
18
19
  eventManager,
19
20
  loggingCookieJar,
@@ -115,6 +116,7 @@ export default ({
115
116
  }
116
117
  const onStreamResponseCallback = event => {
117
118
  if (event.error) {
119
+ logger.error("Stream error occurred", event.error);
118
120
  onStreamResponse({
119
121
  error: event.error
120
122
  });
@@ -129,8 +131,11 @@ export default ({
129
131
  logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
130
132
  onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
131
133
  };
134
+ const wrappedCallback = createTimeoutWrapper({
135
+ onStreamResponseCallback
136
+ });
132
137
  const streamParser = createStreamParser();
133
- streamParser(response.body, onStreamResponseCallback);
138
+ streamParser(response.body, wrappedCallback);
134
139
  });
135
140
  });
136
141
  };
@@ -0,0 +1,49 @@
1
+ /*
2
+ Copyright 2025 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { STREAM_START_TIMEOUT_MS } from "./constants.js";
13
+
14
+ /**
15
+ * Creates a wrapper around a callback that implements a timeout for the first call.
16
+ * If the callback is not invoked within the specified timeout, an error is passed to it.
17
+ * After timeout fires, all subsequent calls are ignored.
18
+ *
19
+ * @param {Function} callback - The callback function to wrap
20
+ * @returns {Function} Wrapped callback function
21
+ */
22
+ export default ({
23
+ onStreamResponseCallback
24
+ }) => {
25
+ const timeoutMs = STREAM_START_TIMEOUT_MS;
26
+ let firstCallMade = false;
27
+ let timedOut = false;
28
+ const timeoutId = setTimeout(() => {
29
+ // Double-check firstCallMade right before firing
30
+ if (!firstCallMade) {
31
+ timedOut = true;
32
+ onStreamResponseCallback({
33
+ error: {
34
+ message: "Stream timeout: No data received within 10 seconds"
35
+ }
36
+ });
37
+ }
38
+ }, timeoutMs);
39
+ return event => {
40
+ if (timedOut) {
41
+ return;
42
+ }
43
+ if (!firstCallMade) {
44
+ firstCallMade = true;
45
+ clearTimeout(timeoutId);
46
+ }
47
+ onStreamResponseCallback(event);
48
+ };
49
+ };
@@ -13,4 +13,4 @@ governing permissions and limitations under the License.
13
13
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
14
14
  // see babel-plugin-version
15
15
 
16
- export default "2.30.1-beta.14";
16
+ export default "2.30.1-beta.15";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.30.1-beta.14",
3
+ "version": "2.30.1-beta.15",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "type": "module",
6
6
  "main": "libEs5/index.js",
@@ -1,2 +1,3 @@
1
1
  export const BC_SESSION_COOKIE_NAME: "bc_session_id";
2
+ export const STREAM_START_TIMEOUT_MS: 10000;
2
3
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/constants.js"],"names":[],"mappings":"AAWA,qCAAsC,eAAe,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/constants.js"],"names":[],"mappings":"AAWA,qCAAsC,eAAe,CAAC;AACtD,sCAAuC,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createSendConversationEvent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createSendConversationEvent.js"],"names":[],"mappings":"AAiBe;;;;;;;;;;;;KAeL,YAAO,SAuGhB"}
1
+ {"version":3,"file":"createSendConversationEvent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createSendConversationEvent.js"],"names":[],"mappings":"AAkBe;;;;;;;;;;;;KAeL,YAAO,SA4GhB"}
@@ -0,0 +1,3 @@
1
+ declare function _default({ onStreamResponseCallback }: Function): Function;
2
+ export default _default;
3
+ //# sourceMappingURL=createTimeoutWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTimeoutWrapper.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createTimeoutWrapper.js"],"names":[],"mappings":"AAqBe,4EA2Bd"}