@adobe/alloy 2.30.1-beta.22 → 2.30.1-beta.23

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.
Files changed (40) hide show
  1. package/libEs5/components/Advertising/createComponent.js +7 -3
  2. package/libEs5/components/Advertising/handlers/sendAdConversion.js +11 -6
  3. package/libEs5/components/Advertising/index.js +2 -1
  4. package/libEs5/components/BrandConcierge/configValidators.js +25 -0
  5. package/libEs5/components/BrandConcierge/createSendConversationEvent.js +6 -4
  6. package/libEs5/components/BrandConcierge/createStreamParser.js +49 -14
  7. package/libEs5/components/BrandConcierge/createTimeoutWrapper.js +47 -20
  8. package/libEs5/components/BrandConcierge/index.js +3 -5
  9. package/libEs5/components/BrandConcierge/validateMessage.js +5 -2
  10. package/libEs5/constants/libraryVersion.js +1 -1
  11. package/libEs5/utils/request/createRequestPayload.js +6 -1
  12. package/libEs6/components/Advertising/createComponent.js +7 -3
  13. package/libEs6/components/Advertising/handlers/sendAdConversion.js +11 -6
  14. package/libEs6/components/Advertising/index.js +2 -1
  15. package/libEs6/components/BrandConcierge/configValidators.js +22 -0
  16. package/libEs6/components/BrandConcierge/createSendConversationEvent.js +6 -4
  17. package/libEs6/components/BrandConcierge/createStreamParser.js +49 -14
  18. package/libEs6/components/BrandConcierge/createTimeoutWrapper.js +47 -20
  19. package/libEs6/components/BrandConcierge/index.js +3 -5
  20. package/libEs6/components/BrandConcierge/validateMessage.js +6 -3
  21. package/libEs6/constants/libraryVersion.js +1 -1
  22. package/libEs6/utils/request/createRequestPayload.js +6 -1
  23. package/package.json +1 -1
  24. package/types/components/Advertising/createComponent.d.ts +3 -2
  25. package/types/components/Advertising/createComponent.d.ts.map +1 -1
  26. package/types/components/Advertising/handlers/sendAdConversion.d.ts +2 -1
  27. package/types/components/Advertising/handlers/sendAdConversion.d.ts.map +1 -1
  28. package/types/components/Advertising/index.d.ts +1 -1
  29. package/types/components/Advertising/index.d.ts.map +1 -1
  30. package/types/components/BrandConcierge/configValidators.d.ts +3 -0
  31. package/types/components/BrandConcierge/configValidators.d.ts.map +1 -0
  32. package/types/components/BrandConcierge/createSendConversationEvent.d.ts.map +1 -1
  33. package/types/components/BrandConcierge/createStreamParser.d.ts +5 -1
  34. package/types/components/BrandConcierge/createStreamParser.d.ts.map +1 -1
  35. package/types/components/BrandConcierge/createTimeoutWrapper.d.ts +4 -1
  36. package/types/components/BrandConcierge/createTimeoutWrapper.d.ts.map +1 -1
  37. package/types/components/BrandConcierge/index.d.ts +3 -2
  38. package/types/components/BrandConcierge/index.d.ts.map +1 -1
  39. package/types/components/BrandConcierge/validateMessage.d.ts.map +1 -1
  40. package/types/utils/request/createRequestPayload.d.ts.map +1 -1
@@ -20,7 +20,8 @@ var _default = ({
20
20
  eventManager,
21
21
  cookieManager,
22
22
  adConversionHandler,
23
- getBrowser
23
+ getBrowser,
24
+ consent
24
25
  }) => {
25
26
  const componentConfig = config.advertising;
26
27
  const sendAdConversionHandler = (0, _sendAdConversion.default)({
@@ -29,12 +30,15 @@ var _default = ({
29
30
  adConversionHandler,
30
31
  logger,
31
32
  componentConfig,
32
- getBrowser
33
+ getBrowser,
34
+ consent
33
35
  });
34
36
  return {
35
37
  lifecycle: {
36
38
  onComponentsRegistered() {
37
- return sendAdConversionHandler();
39
+ // Fire-and-forget: don't return the promise so we don't block
40
+ // the configure command from resolving while waiting for consent.
41
+ sendAdConversionHandler();
38
42
  },
39
43
  onBeforeEvent: ({
40
44
  event,
@@ -26,16 +26,21 @@ var _default = ({
26
26
  adConversionHandler,
27
27
  logger,
28
28
  componentConfig,
29
- getBrowser
29
+ getBrowser,
30
+ consent
30
31
  }) => {
31
32
  const activeAdvertiserIds = componentConfig?.advertiserSettings ? (0, _helpers.normalizeAdvertiser)(componentConfig.advertiserSettings) : "";
32
33
  return async () => {
33
- const {
34
- skwcid,
35
- efid
36
- } = (0, _helpers.getUrlParams)();
37
- const isClickThru = !!(skwcid || efid);
38
34
  try {
35
+ // Wait for consent before any ad conversion processing.
36
+ // This ensures no advertising cookies are set without user consent.
37
+ // If consent is declined, awaitConsent() rejects and we exit gracefully.
38
+ await consent.awaitConsent();
39
+ const {
40
+ skwcid,
41
+ efid
42
+ } = (0, _helpers.getUrlParams)();
43
+ const isClickThru = !!(skwcid || efid);
39
44
  if (isClickThru) {
40
45
  // wait for click through to complete
41
46
  return (0, _clickThroughHandler.default)({
@@ -44,7 +44,8 @@ const createAdvertising = ({
44
44
  eventManager,
45
45
  cookieManager,
46
46
  adConversionHandler,
47
- getBrowser
47
+ getBrowser,
48
+ consent
48
49
  });
49
50
  };
50
51
  createAdvertising.namespace = "Advertising";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _constants = require("./constants.js");
5
+ var _index = require("../../utils/validation/index.js");
6
+ /*
7
+ Copyright 2026 Adobe. All rights reserved.
8
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License. You may obtain a copy
10
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software distributed under
13
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ OF ANY KIND, either express or implied. See the License for the specific language
15
+ governing permissions and limitations under the License.
16
+ */
17
+ var _default = exports.default = (0, _index.objectOf)({
18
+ conversation: (0, _index.objectOf)({
19
+ stickyConversationSession: (0, _index.boolean)().default(false),
20
+ streamTimeout: (0, _index.number)().integer().minimum(_constants.STREAM_START_TIMEOUT_MS).default(_constants.STREAM_START_TIMEOUT_MS)
21
+ }).default({
22
+ stickyConversationSession: false,
23
+ streamTimeout: _constants.STREAM_START_TIMEOUT_MS
24
+ })
25
+ });
@@ -35,7 +35,8 @@ var _default = ({
35
35
  edgeDomain,
36
36
  edgeBasePath,
37
37
  datastreamId,
38
- onBeforeEventSend
38
+ onBeforeEventSend,
39
+ conversation
39
40
  } = config;
40
41
  return options => {
41
42
  let streamingEnabled = false;
@@ -134,11 +135,12 @@ var _default = ({
134
135
  logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
135
136
  onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
136
137
  };
137
- const wrappedCallback = (0, _createTimeoutWrapper.default)({
138
- onStreamResponseCallback
138
+ const timeoutWrapper = (0, _createTimeoutWrapper.default)({
139
+ onStreamResponseCallback,
140
+ streamTimeout: conversation.streamTimeout
139
141
  });
140
142
  const streamParser = (0, _createStreamParser.default)();
141
- streamParser(response.body, wrappedCallback);
143
+ streamParser(response.body, timeoutWrapper);
142
144
  });
143
145
  });
144
146
  };
@@ -19,6 +19,20 @@ var _default = () => {
19
19
  const LINE_ENDING_REGEX = /\r\n|\r|\n/;
20
20
  // Events are separated by blank lines (double line endings)
21
21
  const EVENT_SEPARATOR_REGEX = /\r\n\r\n|\n\n|\r\r/;
22
+ // Ping comment format: `: ping` (colon followed immediately by "ping")
23
+ const PING_COMMENT = ": ping";
24
+
25
+ /**
26
+ * Check if an event block is a ping comment.
27
+ * Ping comments are SSE comments in the format `:ping`
28
+ *
29
+ * @param {string} eventData - Raw event data
30
+ * @returns {boolean} - True if this is a ping comment
31
+ */
32
+ const isPingComment = eventData => {
33
+ const trimmed = eventData.trim();
34
+ return trimmed.startsWith(PING_COMMENT);
35
+ };
22
36
 
23
37
  /**
24
38
  * Parse a single SSE event from raw event data.
@@ -57,9 +71,16 @@ var _default = () => {
57
71
  * Uses modern async iteration (for await...of) for clean, performant stream processing.
58
72
  *
59
73
  * @param {ReadableStream} stream - The readable stream from fetch response
60
- * @param {Function} onEvent - Callback function called for each parsed event
74
+ * @param {Object} callbacks - Callback functions for stream events
75
+ * @param {Function} callbacks.onEvent - Callback function called for each parsed event
76
+ * @param {Function} callbacks.onPing - Callback function called for ping comments
77
+ * @param {Function} callbacks.onComplete - Callback function called when stream ends
61
78
  */
62
- return async (stream, onEvent) => {
79
+ return async (stream, {
80
+ onEvent,
81
+ onPing,
82
+ onComplete
83
+ }) => {
63
84
  const decoder = new TextDecoder(ENCODING);
64
85
  let buffer = "";
65
86
  try {
@@ -69,27 +90,41 @@ var _default = () => {
69
90
  });
70
91
  const events = buffer.split(EVENT_SEPARATOR_REGEX);
71
92
  buffer = events.pop() || "";
72
- for (const eventData of events) {
73
- const trimmedEvent = eventData.trim();
74
- if (trimmedEvent) {
75
- const event = parseEventFromBuffer(trimmedEvent);
76
- if (event !== null) {
77
- onEvent(event);
78
- }
93
+ for (const event of events) {
94
+ const trimmedEvent = event.trim();
95
+ if (!trimmedEvent) {
96
+ continue;
97
+ }
98
+ if (isPingComment(trimmedEvent)) {
99
+ onPing();
100
+ continue;
101
+ }
102
+ const parsedEvent = parseEventFromBuffer(trimmedEvent);
103
+ if (parsedEvent !== null) {
104
+ onEvent(parsedEvent);
79
105
  }
80
106
  }
81
107
  }
82
108
  const trimmedBuffer = buffer.trim();
83
- if (trimmedBuffer) {
84
- const event = parseEventFromBuffer(trimmedBuffer);
85
- if (event !== null) {
86
- onEvent(event);
87
- }
109
+ if (!trimmedBuffer) {
110
+ onComplete();
111
+ return;
112
+ }
113
+ if (isPingComment(trimmedBuffer)) {
114
+ onPing();
115
+ onComplete();
116
+ return;
117
+ }
118
+ const event = parseEventFromBuffer(trimmedBuffer);
119
+ if (event !== null) {
120
+ onEvent(event);
88
121
  }
122
+ onComplete();
89
123
  } catch (error) {
90
124
  onEvent({
91
125
  error
92
126
  });
127
+ onComplete();
93
128
  }
94
129
  };
95
130
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  exports.default = void 0;
4
- var _constants = require("./constants.js");
5
4
  /*
6
5
  Copyright 2025 Adobe. All rights reserved.
7
6
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -14,39 +13,67 @@ OF ANY KIND, either express or implied. See the License for the specific languag
14
13
  governing permissions and limitations under the License.
15
14
  */
16
15
  /**
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.
16
+ * Creates a wrapper around a callback that implements a rolling timeout.
17
+ * The timeout resets on every data event or ping. If no activity occurs
18
+ * within the timeout period, an error is passed to the callback.
19
19
  * After timeout fires, all subsequent calls are ignored.
20
20
  *
21
- * @param {Function} callback - The callback function to wrap
22
- * @returns {Function} Wrapped callback function
21
+ * @param {Object} options - Configuration options
22
+ * @param {Function} options.onStreamResponseCallback - The callback function to wrap
23
+ * @param {number} options.streamTimeout - Timeout duration in milliseconds
24
+ * @returns {Object} Object with onEvent, onPing, and onComplete handler functions
23
25
  */
24
26
  var _default = ({
25
- onStreamResponseCallback
27
+ onStreamResponseCallback,
28
+ streamTimeout
26
29
  }) => {
27
- const timeoutMs = _constants.STREAM_START_TIMEOUT_MS;
28
- let firstCallMade = false;
29
30
  let timedOut = false;
30
- const timeoutId = setTimeout(() => {
31
- // Double-check firstCallMade right before firing
32
- if (!firstCallMade) {
31
+ let timeoutId;
32
+ const resetTimeout = () => {
33
+ clearTimeout(timeoutId);
34
+ timeoutId = setTimeout(() => {
33
35
  timedOut = true;
34
36
  onStreamResponseCallback({
35
37
  error: {
36
38
  message: "Stream timeout: No data received within 10 seconds"
37
39
  }
38
40
  });
39
- }
40
- }, timeoutMs);
41
- return event => {
42
- if (timedOut) {
43
- return;
44
- }
45
- if (!firstCallMade) {
46
- firstCallMade = true;
41
+ }, streamTimeout);
42
+ };
43
+
44
+ // Start initial timeout
45
+ resetTimeout();
46
+ return {
47
+ /**
48
+ * Handle data events from the stream parser.
49
+ * Resets the timeout and forwards the event to the callback.
50
+ *
51
+ * @param {Object} event - The parsed SSE event
52
+ */
53
+ onEvent: event => {
54
+ if (timedOut) {
55
+ return;
56
+ }
57
+ resetTimeout();
58
+ onStreamResponseCallback(event);
59
+ },
60
+ /**
61
+ * Handle ping events from the stream parser.
62
+ * Resets the timeout but does not forward anything to the callback.
63
+ */
64
+ onPing: () => {
65
+ if (timedOut) {
66
+ return;
67
+ }
68
+ resetTimeout();
69
+ },
70
+ /**
71
+ * Handle stream completion.
72
+ * Clears the timeout since the stream has ended successfully.
73
+ */
74
+ onComplete: () => {
47
75
  clearTimeout(timeoutId);
48
76
  }
49
- onStreamResponseCallback(event);
50
77
  };
51
78
  };
52
79
  exports.default = _default;
@@ -7,9 +7,9 @@ var _createBuildEndpointUrl = require("./createBuildEndpointUrl.js");
7
7
  var _reactorQueryString = require("@adobe/reactor-query-string");
8
8
  var _index = require("../../utils/index.js");
9
9
  var _constants = require("./constants.js");
10
- var _index2 = require("../../utils/validation/index.js");
11
10
  var _createDecodeKndctrCookie = require("../../utils/createDecodeKndctrCookie.js");
12
11
  var _createSendConversationServiceRequest = require("./createSendConversationServiceRequest.js");
12
+ var _configValidators = require("./configValidators.js");
13
13
  /*
14
14
  Copyright 2024 Adobe. All rights reserved.
15
15
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -38,7 +38,7 @@ const createConciergeComponent = ({
38
38
  const {
39
39
  fetch
40
40
  } = window;
41
- if (!config.stickyConversationSession) {
41
+ if (!config.conversation.stickyConversationSession) {
42
42
  loggingCookieJar.remove((0, _index.getNamespacedCookieName)(config.orgId, _constants.BC_SESSION_COOKIE_NAME), {
43
43
  domain: apexDomain
44
44
  });
@@ -98,7 +98,5 @@ const createConciergeComponent = ({
98
98
  };
99
99
  };
100
100
  createConciergeComponent.namespace = "BrandConcierge";
101
- createConciergeComponent.configValidators = (0, _index2.objectOf)({
102
- stickyConversationSession: (0, _index2.boolean)().default(false)
103
- });
101
+ createConciergeComponent.configValidators = _configValidators.default;
104
102
  var _default = exports.default = createConciergeComponent;
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports.default = void 0;
4
4
  var _index = require("../../utils/validation/index.js");
5
+ var _index2 = require("../../utils/index.js");
5
6
  /*
6
7
  Copyright 2025 Adobe. All rights reserved.
7
8
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -17,7 +18,8 @@ var _default = ({
17
18
  options
18
19
  }) => {
19
20
  const brandConciergeEventValidator = (0, _index.anyOf)([(0, _index.objectOf)({
20
- message: (0, _index.string)().required()
21
+ message: (0, _index.string)().required(),
22
+ onStreamResponse: (0, _index.callback)().default(_index2.noop)
21
23
  }), (0, _index.objectOf)({
22
24
  xdm: (0, _index.objectOf)({
23
25
  interactionId: (0, _index.string)(),
@@ -34,7 +36,8 @@ var _default = ({
34
36
  data: (0, _index.objectOf)({
35
37
  type: (0, _index.string)().required(),
36
38
  payload: (0, _index.objectOf)({})
37
- }).required()
39
+ }).required(),
40
+ onStreamResponse: (0, _index.callback)().default(_index2.noop)
38
41
  })]);
39
42
  return brandConciergeEventValidator(options);
40
43
  };
@@ -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.22";
17
+ var _default = exports.default = "2.30.1-beta.23";
@@ -93,7 +93,12 @@ var _default = options => {
93
93
  mergeConfigOverride: updates => mergeConfigOverrides(updates),
94
94
  finalizeConfigOverrides: () => {
95
95
  if (content.meta?.configOverrides) {
96
- content.meta.configOverrides = (0, _index.prepareConfigOverridesForEdge)(content.meta.configOverrides);
96
+ const prepared = (0, _index.prepareConfigOverridesForEdge)(content.meta.configOverrides);
97
+ if (prepared === null) {
98
+ delete content.meta.configOverrides;
99
+ } else {
100
+ content.meta.configOverrides = prepared;
101
+ }
97
102
  }
98
103
  },
99
104
  addIdentity,
@@ -18,7 +18,8 @@ export default ({
18
18
  eventManager,
19
19
  cookieManager,
20
20
  adConversionHandler,
21
- getBrowser
21
+ getBrowser,
22
+ consent
22
23
  }) => {
23
24
  const componentConfig = config.advertising;
24
25
  const sendAdConversionHandler = createSendAdConversion({
@@ -27,12 +28,15 @@ export default ({
27
28
  adConversionHandler,
28
29
  logger,
29
30
  componentConfig,
30
- getBrowser
31
+ getBrowser,
32
+ consent
31
33
  });
32
34
  return {
33
35
  lifecycle: {
34
36
  onComponentsRegistered() {
35
- return sendAdConversionHandler();
37
+ // Fire-and-forget: don't return the promise so we don't block
38
+ // the configure command from resolving while waiting for consent.
39
+ sendAdConversionHandler();
36
40
  },
37
41
  onBeforeEvent: ({
38
42
  event,
@@ -25,16 +25,21 @@ export default ({
25
25
  adConversionHandler,
26
26
  logger,
27
27
  componentConfig,
28
- getBrowser
28
+ getBrowser,
29
+ consent
29
30
  }) => {
30
31
  const activeAdvertiserIds = componentConfig?.advertiserSettings ? normalizeAdvertiser(componentConfig.advertiserSettings) : "";
31
32
  return async () => {
32
- const {
33
- skwcid,
34
- efid
35
- } = getUrlParams();
36
- const isClickThru = !!(skwcid || efid);
37
33
  try {
34
+ // Wait for consent before any ad conversion processing.
35
+ // This ensures no advertising cookies are set without user consent.
36
+ // If consent is declined, awaitConsent() rejects and we exit gracefully.
37
+ await consent.awaitConsent();
38
+ const {
39
+ skwcid,
40
+ efid
41
+ } = getUrlParams();
42
+ const isClickThru = !!(skwcid || efid);
38
43
  if (isClickThru) {
39
44
  // wait for click through to complete
40
45
  return handleClickThrough({
@@ -41,7 +41,8 @@ const createAdvertising = ({
41
41
  eventManager,
42
42
  cookieManager,
43
43
  adConversionHandler,
44
- getBrowser
44
+ getBrowser,
45
+ consent
45
46
  });
46
47
  };
47
48
  createAdvertising.namespace = "Advertising";
@@ -0,0 +1,22 @@
1
+ /*
2
+ Copyright 2026 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
+ import { number, objectOf, boolean } from "../../utils/validation/index.js";
14
+ export default objectOf({
15
+ conversation: objectOf({
16
+ stickyConversationSession: boolean().default(false),
17
+ streamTimeout: number().integer().minimum(STREAM_START_TIMEOUT_MS).default(STREAM_START_TIMEOUT_MS)
18
+ }).default({
19
+ stickyConversationSession: false,
20
+ streamTimeout: STREAM_START_TIMEOUT_MS
21
+ })
22
+ });
@@ -32,7 +32,8 @@ export default ({
32
32
  edgeDomain,
33
33
  edgeBasePath,
34
34
  datastreamId,
35
- onBeforeEventSend
35
+ onBeforeEventSend,
36
+ conversation
36
37
  } = config;
37
38
  return options => {
38
39
  let streamingEnabled = false;
@@ -131,11 +132,12 @@ export default ({
131
132
  logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
132
133
  onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
133
134
  };
134
- const wrappedCallback = createTimeoutWrapper({
135
- onStreamResponseCallback
135
+ const timeoutWrapper = createTimeoutWrapper({
136
+ onStreamResponseCallback,
137
+ streamTimeout: conversation.streamTimeout
136
138
  });
137
139
  const streamParser = createStreamParser();
138
- streamParser(response.body, wrappedCallback);
140
+ streamParser(response.body, timeoutWrapper);
139
141
  });
140
142
  });
141
143
  };
@@ -16,6 +16,20 @@ export default () => {
16
16
  const LINE_ENDING_REGEX = /\r\n|\r|\n/;
17
17
  // Events are separated by blank lines (double line endings)
18
18
  const EVENT_SEPARATOR_REGEX = /\r\n\r\n|\n\n|\r\r/;
19
+ // Ping comment format: `: ping` (colon followed immediately by "ping")
20
+ const PING_COMMENT = ": ping";
21
+
22
+ /**
23
+ * Check if an event block is a ping comment.
24
+ * Ping comments are SSE comments in the format `:ping`
25
+ *
26
+ * @param {string} eventData - Raw event data
27
+ * @returns {boolean} - True if this is a ping comment
28
+ */
29
+ const isPingComment = eventData => {
30
+ const trimmed = eventData.trim();
31
+ return trimmed.startsWith(PING_COMMENT);
32
+ };
19
33
 
20
34
  /**
21
35
  * Parse a single SSE event from raw event data.
@@ -54,9 +68,16 @@ export default () => {
54
68
  * Uses modern async iteration (for await...of) for clean, performant stream processing.
55
69
  *
56
70
  * @param {ReadableStream} stream - The readable stream from fetch response
57
- * @param {Function} onEvent - Callback function called for each parsed event
71
+ * @param {Object} callbacks - Callback functions for stream events
72
+ * @param {Function} callbacks.onEvent - Callback function called for each parsed event
73
+ * @param {Function} callbacks.onPing - Callback function called for ping comments
74
+ * @param {Function} callbacks.onComplete - Callback function called when stream ends
58
75
  */
59
- return async (stream, onEvent) => {
76
+ return async (stream, {
77
+ onEvent,
78
+ onPing,
79
+ onComplete
80
+ }) => {
60
81
  const decoder = new TextDecoder(ENCODING);
61
82
  let buffer = "";
62
83
  try {
@@ -66,27 +87,41 @@ export default () => {
66
87
  });
67
88
  const events = buffer.split(EVENT_SEPARATOR_REGEX);
68
89
  buffer = events.pop() || "";
69
- for (const eventData of events) {
70
- const trimmedEvent = eventData.trim();
71
- if (trimmedEvent) {
72
- const event = parseEventFromBuffer(trimmedEvent);
73
- if (event !== null) {
74
- onEvent(event);
75
- }
90
+ for (const event of events) {
91
+ const trimmedEvent = event.trim();
92
+ if (!trimmedEvent) {
93
+ continue;
94
+ }
95
+ if (isPingComment(trimmedEvent)) {
96
+ onPing();
97
+ continue;
98
+ }
99
+ const parsedEvent = parseEventFromBuffer(trimmedEvent);
100
+ if (parsedEvent !== null) {
101
+ onEvent(parsedEvent);
76
102
  }
77
103
  }
78
104
  }
79
105
  const trimmedBuffer = buffer.trim();
80
- if (trimmedBuffer) {
81
- const event = parseEventFromBuffer(trimmedBuffer);
82
- if (event !== null) {
83
- onEvent(event);
84
- }
106
+ if (!trimmedBuffer) {
107
+ onComplete();
108
+ return;
109
+ }
110
+ if (isPingComment(trimmedBuffer)) {
111
+ onPing();
112
+ onComplete();
113
+ return;
114
+ }
115
+ const event = parseEventFromBuffer(trimmedBuffer);
116
+ if (event !== null) {
117
+ onEvent(event);
85
118
  }
119
+ onComplete();
86
120
  } catch (error) {
87
121
  onEvent({
88
122
  error
89
123
  });
124
+ onComplete();
90
125
  }
91
126
  };
92
127
  };
@@ -9,41 +9,68 @@ 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
- import { STREAM_START_TIMEOUT_MS } from "./constants.js";
13
12
 
14
13
  /**
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.
14
+ * Creates a wrapper around a callback that implements a rolling timeout.
15
+ * The timeout resets on every data event or ping. If no activity occurs
16
+ * within the timeout period, an error is passed to the callback.
17
17
  * After timeout fires, all subsequent calls are ignored.
18
18
  *
19
- * @param {Function} callback - The callback function to wrap
20
- * @returns {Function} Wrapped callback function
19
+ * @param {Object} options - Configuration options
20
+ * @param {Function} options.onStreamResponseCallback - The callback function to wrap
21
+ * @param {number} options.streamTimeout - Timeout duration in milliseconds
22
+ * @returns {Object} Object with onEvent, onPing, and onComplete handler functions
21
23
  */
22
24
  export default ({
23
- onStreamResponseCallback
25
+ onStreamResponseCallback,
26
+ streamTimeout
24
27
  }) => {
25
- const timeoutMs = STREAM_START_TIMEOUT_MS;
26
- let firstCallMade = false;
27
28
  let timedOut = false;
28
- const timeoutId = setTimeout(() => {
29
- // Double-check firstCallMade right before firing
30
- if (!firstCallMade) {
29
+ let timeoutId;
30
+ const resetTimeout = () => {
31
+ clearTimeout(timeoutId);
32
+ timeoutId = setTimeout(() => {
31
33
  timedOut = true;
32
34
  onStreamResponseCallback({
33
35
  error: {
34
36
  message: "Stream timeout: No data received within 10 seconds"
35
37
  }
36
38
  });
37
- }
38
- }, timeoutMs);
39
- return event => {
40
- if (timedOut) {
41
- return;
42
- }
43
- if (!firstCallMade) {
44
- firstCallMade = true;
39
+ }, streamTimeout);
40
+ };
41
+
42
+ // Start initial timeout
43
+ resetTimeout();
44
+ return {
45
+ /**
46
+ * Handle data events from the stream parser.
47
+ * Resets the timeout and forwards the event to the callback.
48
+ *
49
+ * @param {Object} event - The parsed SSE event
50
+ */
51
+ onEvent: event => {
52
+ if (timedOut) {
53
+ return;
54
+ }
55
+ resetTimeout();
56
+ onStreamResponseCallback(event);
57
+ },
58
+ /**
59
+ * Handle ping events from the stream parser.
60
+ * Resets the timeout but does not forward anything to the callback.
61
+ */
62
+ onPing: () => {
63
+ if (timedOut) {
64
+ return;
65
+ }
66
+ resetTimeout();
67
+ },
68
+ /**
69
+ * Handle stream completion.
70
+ * Clears the timeout since the stream has ended successfully.
71
+ */
72
+ onComplete: () => {
45
73
  clearTimeout(timeoutId);
46
74
  }
47
- onStreamResponseCallback(event);
48
75
  };
49
76
  };
@@ -15,9 +15,9 @@ import createBuildEndpointUrl from "./createBuildEndpointUrl.js";
15
15
  import queryString from "@adobe/reactor-query-string";
16
16
  import { getNamespacedCookieName } from "../../utils/index.js";
17
17
  import { BC_SESSION_COOKIE_NAME } from "./constants.js";
18
- import { boolean, objectOf } from "../../utils/validation/index.js";
19
18
  import createGetEcidFromCookie from "../../utils/createDecodeKndctrCookie.js";
20
19
  import createSendConversationServiceRequest from "./createSendConversationServiceRequest.js";
20
+ import configValidators from "./configValidators.js";
21
21
  const createConciergeComponent = ({
22
22
  loggingCookieJar,
23
23
  logger,
@@ -34,7 +34,7 @@ const createConciergeComponent = ({
34
34
  const {
35
35
  fetch
36
36
  } = window;
37
- if (!config.stickyConversationSession) {
37
+ if (!config.conversation.stickyConversationSession) {
38
38
  loggingCookieJar.remove(getNamespacedCookieName(config.orgId, BC_SESSION_COOKIE_NAME), {
39
39
  domain: apexDomain
40
40
  });
@@ -94,7 +94,5 @@ const createConciergeComponent = ({
94
94
  };
95
95
  };
96
96
  createConciergeComponent.namespace = "BrandConcierge";
97
- createConciergeComponent.configValidators = objectOf({
98
- stickyConversationSession: boolean().default(false)
99
- });
97
+ createConciergeComponent.configValidators = configValidators;
100
98
  export default createConciergeComponent;
@@ -9,12 +9,14 @@ 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
- import { anyOf, arrayOf, objectOf, string } from "../../utils/validation/index.js";
12
+ import { anyOf, arrayOf, objectOf, string, callback } from "../../utils/validation/index.js";
13
+ import { noop } from "../../utils/index.js";
13
14
  export default ({
14
15
  options
15
16
  }) => {
16
17
  const brandConciergeEventValidator = anyOf([objectOf({
17
- message: string().required()
18
+ message: string().required(),
19
+ onStreamResponse: callback().default(noop)
18
20
  }), objectOf({
19
21
  xdm: objectOf({
20
22
  interactionId: string(),
@@ -31,7 +33,8 @@ export default ({
31
33
  data: objectOf({
32
34
  type: string().required(),
33
35
  payload: objectOf({})
34
- }).required()
36
+ }).required(),
37
+ onStreamResponse: callback().default(noop)
35
38
  })]);
36
39
  return brandConciergeEventValidator(options);
37
40
  };
@@ -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.22";
16
+ export default "2.30.1-beta.23";
@@ -91,7 +91,12 @@ export default options => {
91
91
  mergeConfigOverride: updates => mergeConfigOverrides(updates),
92
92
  finalizeConfigOverrides: () => {
93
93
  if (content.meta?.configOverrides) {
94
- content.meta.configOverrides = prepareConfigOverridesForEdge(content.meta.configOverrides);
94
+ const prepared = prepareConfigOverridesForEdge(content.meta.configOverrides);
95
+ if (prepared === null) {
96
+ delete content.meta.configOverrides;
97
+ } else {
98
+ content.meta.configOverrides = prepared;
99
+ }
95
100
  }
96
101
  },
97
102
  addIdentity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.30.1-beta.22",
3
+ "version": "2.30.1-beta.23",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "type": "module",
6
6
  "main": "libEs5/index.js",
@@ -1,13 +1,14 @@
1
- declare function _default({ logger, config, eventManager, cookieManager, adConversionHandler, getBrowser, }: {
1
+ declare function _default({ logger, config, eventManager, cookieManager, adConversionHandler, getBrowser, consent, }: {
2
2
  logger: any;
3
3
  config: any;
4
4
  eventManager: any;
5
5
  cookieManager: any;
6
6
  adConversionHandler: any;
7
7
  getBrowser: any;
8
+ consent: any;
8
9
  }): {
9
10
  lifecycle: {
10
- onComponentsRegistered(): Promise<any>;
11
+ onComponentsRegistered(): void;
11
12
  onBeforeEvent: ({ event, advertising }: {
12
13
  event: any;
13
14
  advertising?: {};
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/Advertising/createComponent.js"],"names":[],"mappings":"AAee;;;;;;;;;;;;;;;EAoCd"}
1
+ {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/Advertising/createComponent.js"],"names":[],"mappings":"AAee;;;;;;;;;;;;;;;;EAwCd"}
@@ -1,10 +1,11 @@
1
- declare function _default({ eventManager, cookieManager, adConversionHandler, logger, componentConfig, getBrowser, }: {
1
+ declare function _default({ eventManager, cookieManager, adConversionHandler, logger, componentConfig, getBrowser, consent, }: {
2
2
  eventManager: any;
3
3
  cookieManager: any;
4
4
  adConversionHandler: any;
5
5
  logger: any;
6
6
  componentConfig: any;
7
7
  getBrowser: any;
8
+ consent: any;
8
9
  }): () => Promise<any>;
9
10
  export default _default;
10
11
  //# sourceMappingURL=sendAdConversion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendAdConversion.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/components/Advertising/handlers/sendAdConversion.js"],"names":[],"mappings":"AAqBe;;;;;;;uBA0Cd"}
1
+ {"version":3,"file":"sendAdConversion.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/components/Advertising/handlers/sendAdConversion.js"],"names":[],"mappings":"AAqBe;;;;;;;;uBAgDd"}
@@ -8,7 +8,7 @@ declare function createAdvertising({ logger, config, eventManager, sendEdgeNetwo
8
8
  getBrowser: any;
9
9
  }): {
10
10
  lifecycle: {
11
- onComponentsRegistered(): Promise<any>;
11
+ onComponentsRegistered(): void;
12
12
  onBeforeEvent: ({ event, advertising }: {
13
13
  event: any;
14
14
  advertising?: {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/Advertising/index.js"],"names":[],"mappings":";AAqBA;;;;;;;;;;;;;;;EA6BC;;;;;6BArC4B,uBAAuB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/Advertising/index.js"],"names":[],"mappings":";AAqBA;;;;;;;;;;;;;;;EA8BC;;;;;6BAtC4B,uBAAuB"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=configValidators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configValidators.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/configValidators.js"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"createSendConversationEvent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createSendConversationEvent.js"],"names":[],"mappings":"AAkBe;;;;;;;;;;;;KAeL,YAAO,SA4GhB"}
1
+ {"version":3,"file":"createSendConversationEvent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createSendConversationEvent.js"],"names":[],"mappings":"AAkBe;;;;;;;;;;;;KAqBL,YAAO,SAgHhB"}
@@ -1,3 +1,7 @@
1
- declare function _default(): (stream: ReadableStream, onEvent: Function) => Promise<void>;
1
+ declare function _default(): (stream: ReadableStream, { onEvent, onPing, onComplete }: {
2
+ onEvent: Function;
3
+ onPing: Function;
4
+ onComplete: Function;
5
+ }) => Promise<void>;
2
6
  export default _default;
3
7
  //# sourceMappingURL=createStreamParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createStreamParser.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createStreamParser.js"],"names":[],"mappings":"AAWe,8BAsDC,QAHH,cAGS,EAAE,iBAAO,mBAoC9B"}
1
+ {"version":3,"file":"createStreamParser.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createStreamParser.js"],"names":[],"mappings":"AAWe,8BAwEC,QANH,cAMS,EAAE,iCAJnB;IAA4B,OAAO;IACP,MAAM;IACN,UAAU;CAEY,mBAuDtD"}
@@ -1,3 +1,6 @@
1
- declare function _default({ onStreamResponseCallback }: Function): Function;
1
+ declare function _default({ onStreamResponseCallback, streamTimeout }: {
2
+ onStreamResponseCallback: Function;
3
+ streamTimeout: number;
4
+ }): any;
2
5
  export default _default;
3
6
  //# sourceMappingURL=createTimeoutWrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTimeoutWrapper.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createTimeoutWrapper.js"],"names":[],"mappings":"AAqBe,4EA2Bd"}
1
+ {"version":3,"file":"createTimeoutWrapper.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createTimeoutWrapper.js"],"names":[],"mappings":"AAuBe,uEAJZ;IAA0B,wBAAwB;IAC1B,aAAa,EAA7B,MAAM;CACd,OAuDF"}
@@ -25,7 +25,8 @@ declare function createConciergeComponent({ loggingCookieJar, logger, eventManag
25
25
  };
26
26
  };
27
27
  declare namespace createConciergeComponent {
28
- let namespace: string;
29
- let configValidators: any;
28
+ export let namespace: string;
29
+ export { configValidators };
30
30
  }
31
+ import configValidators from "./configValidators.js";
31
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/index.js"],"names":[],"mappings":";AAqBA;;;;;;;;;;;;;;;;;;;;;;;;EAkEC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/index.js"],"names":[],"mappings":";AAqBA;;;;;;;;;;;;;;;;;;;;;;;;EAkEC;;;;;6BApE4B,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateMessage.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/validateMessage.js"],"names":[],"mappings":"AAkBe;;QA2Bd"}
1
+ {"version":3,"file":"validateMessage.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/validateMessage.js"],"names":[],"mappings":"AAoBe;;QA6Bd"}
@@ -1 +1 @@
1
- {"version":3,"file":"createRequestPayload.d.ts","sourceRoot":"","sources":["../../../packages/core/src/utils/request/createRequestPayload.js"],"names":[],"mappings":"AAgFe,mCANZ;IAAwB,OAAO;IACmB,WAAW,EAArD,CAAS,IAAM,EAAN,MAAM,EAAE,IAAQ,EAAR,QAAQ,KAAG,IAAI;IACI,WAAW,EAA/C,CAAS,IAAM,EAAN,MAAM,KAAI,OAAO;CAElC,GAAU,cAAc,CA0B1B;;8BA5F6C,YAAY;oCAAZ,YAAY"}
1
+ {"version":3,"file":"createRequestPayload.d.ts","sourceRoot":"","sources":["../../../packages/core/src/utils/request/createRequestPayload.js"],"names":[],"mappings":"AAgFe,mCANZ;IAAwB,OAAO;IACmB,WAAW,EAArD,CAAS,IAAM,EAAN,MAAM,EAAE,IAAQ,EAAR,QAAQ,KAAG,IAAI;IACI,WAAW,EAA/C,CAAS,IAAM,EAAN,MAAM,KAAI,OAAO;CAElC,GAAU,cAAc,CA+B1B;;8BAjG6C,YAAY;oCAAZ,YAAY"}