@adobe/alloy 2.30.1-beta.2 → 2.30.1-beta.21

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 (203) hide show
  1. package/libEs5/components/Advertising/handlers/onBeforeSendEventHandler.js +8 -2
  2. package/libEs5/components/Advertising/handlers/viewThroughHandler.js +8 -2
  3. package/libEs5/components/Advertising/identities/collectSurferId.js +8 -1
  4. package/libEs5/components/BrandConcierge/constants.js +16 -0
  5. package/libEs5/components/BrandConcierge/createBuildEndpointUrl.js +33 -0
  6. package/libEs5/components/BrandConcierge/createConversationServiceRequest.js +35 -0
  7. package/libEs5/components/BrandConcierge/createSendConversationEvent.js +146 -0
  8. package/libEs5/components/BrandConcierge/createSendConversationServiceRequest.js +85 -0
  9. package/libEs5/components/BrandConcierge/createStreamParser.js +96 -0
  10. package/libEs5/components/BrandConcierge/createTimeoutWrapper.js +52 -0
  11. package/libEs5/components/BrandConcierge/index.js +104 -0
  12. package/libEs5/components/BrandConcierge/utils.js +33 -0
  13. package/libEs5/components/BrandConcierge/validateMessage.js +41 -0
  14. package/libEs5/components/Consent/types.js +12 -0
  15. package/libEs5/components/Context/createComponent.js +1 -2
  16. package/libEs5/components/Context/implementationDetails.js +7 -9
  17. package/libEs5/components/Context/index.js +4 -1
  18. package/libEs5/components/Context/injectDevice.js +2 -2
  19. package/libEs5/components/Context/injectEnvironment.js +2 -2
  20. package/libEs5/components/Context/injectHighEntropyUserAgentHints.js +2 -2
  21. package/libEs5/components/Context/injectOneTimeAnalyticsReferrer.js +49 -0
  22. package/libEs5/components/Context/injectPlaceContext.js +2 -2
  23. package/libEs5/components/Context/injectTimestamp.js +2 -3
  24. package/libEs5/components/Context/injectWeb.js +9 -11
  25. package/libEs5/components/EventMerge/createEventMergeId.js +1 -1
  26. package/libEs5/components/Personalization/createComponent.js +3 -1
  27. package/libEs5/components/Personalization/createFetchDataHandler.js +4 -3
  28. package/libEs5/components/Personalization/createNotificationHandler.js +5 -3
  29. package/libEs5/components/Personalization/createOnDecisionHandler.js +4 -3
  30. package/libEs5/components/Personalization/createPersonalizationDetails.js +1 -1
  31. package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +1 -1
  32. package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +2 -1
  33. package/libEs5/components/Personalization/handlers/createProcessRedirect.js +2 -1
  34. package/libEs5/components/Personalization/handlers/injectCreateProposition.js +4 -1
  35. package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +4 -2
  36. package/libEs5/components/Personalization/index.js +2 -2
  37. package/libEs5/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +1 -1
  38. package/libEs5/components/PushNotifications/types.js +12 -0
  39. package/libEs5/components/RulesEngine/createApplyResponse.js +3 -1
  40. package/libEs5/components/RulesEngine/types.js +12 -0
  41. package/libEs5/constants/libraryVersion.js +1 -1
  42. package/libEs5/constants/surface.js +19 -0
  43. package/libEs5/core/componentCreators.js +8 -1
  44. package/libEs5/core/consent/types.js +12 -0
  45. package/libEs5/core/createEvent.js +3 -0
  46. package/libEs5/core/edgeNetwork/types.js +12 -0
  47. package/libEs5/core/identity/types.js +12 -0
  48. package/libEs5/core/index.js +5 -1
  49. package/libEs5/core/types.js +12 -0
  50. package/libEs5/utils/createCollect.js +4 -2
  51. package/libEs5/utils/deepAssign.js +5 -0
  52. package/libEs5/utils/dom/createGetPageLocation.js +20 -0
  53. package/libEs5/utils/index.js +8 -1
  54. package/libEs5/utils/request/createRequest.js +5 -1
  55. package/libEs5/utils/request/types.js +12 -0
  56. package/libEs5/utils/surfaceUtils.js +82 -0
  57. package/libEs5/utils/types.js +12 -0
  58. package/libEs5/utils/uuid.js +1 -0
  59. package/libEs6/components/Advertising/handlers/onBeforeSendEventHandler.js +8 -2
  60. package/libEs6/components/Advertising/handlers/viewThroughHandler.js +8 -2
  61. package/libEs6/components/Advertising/identities/collectSurferId.js +8 -1
  62. package/libEs6/components/BrandConcierge/constants.js +13 -0
  63. package/libEs6/components/BrandConcierge/createBuildEndpointUrl.js +30 -0
  64. package/libEs6/components/BrandConcierge/createConversationServiceRequest.js +31 -0
  65. package/libEs6/components/BrandConcierge/createSendConversationEvent.js +142 -0
  66. package/libEs6/components/BrandConcierge/createSendConversationServiceRequest.js +81 -0
  67. package/libEs6/components/BrandConcierge/createStreamParser.js +92 -0
  68. package/libEs6/components/BrandConcierge/createTimeoutWrapper.js +49 -0
  69. package/libEs6/components/BrandConcierge/index.js +100 -0
  70. package/libEs6/components/BrandConcierge/utils.js +27 -0
  71. package/libEs6/components/BrandConcierge/validateMessage.js +37 -0
  72. package/libEs6/components/Consent/types.js +12 -0
  73. package/libEs6/components/Context/createComponent.js +1 -2
  74. package/libEs6/components/Context/implementationDetails.js +7 -9
  75. package/libEs6/components/Context/index.js +4 -1
  76. package/libEs6/components/Context/injectDevice.js +3 -3
  77. package/libEs6/components/Context/injectEnvironment.js +3 -3
  78. package/libEs6/components/Context/injectHighEntropyUserAgentHints.js +3 -3
  79. package/libEs6/components/Context/injectOneTimeAnalyticsReferrer.js +46 -0
  80. package/libEs6/components/Context/injectPlaceContext.js +3 -3
  81. package/libEs6/components/Context/injectTimestamp.js +2 -3
  82. package/libEs6/components/Context/injectWeb.js +9 -11
  83. package/libEs6/components/EventMerge/createEventMergeId.js +1 -1
  84. package/libEs6/components/Personalization/createComponent.js +3 -1
  85. package/libEs6/components/Personalization/createFetchDataHandler.js +4 -3
  86. package/libEs6/components/Personalization/createNotificationHandler.js +5 -3
  87. package/libEs6/components/Personalization/createOnDecisionHandler.js +4 -3
  88. package/libEs6/components/Personalization/createPersonalizationDetails.js +1 -1
  89. package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +1 -1
  90. package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +2 -1
  91. package/libEs6/components/Personalization/handlers/createProcessRedirect.js +2 -1
  92. package/libEs6/components/Personalization/handlers/injectCreateProposition.js +4 -1
  93. package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +4 -2
  94. package/libEs6/components/Personalization/index.js +2 -2
  95. package/libEs6/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +1 -1
  96. package/libEs6/components/PushNotifications/types.js +12 -0
  97. package/libEs6/components/RulesEngine/createApplyResponse.js +3 -1
  98. package/libEs6/components/RulesEngine/types.js +12 -0
  99. package/libEs6/constants/libraryVersion.js +1 -1
  100. package/libEs6/constants/surface.js +16 -0
  101. package/libEs6/core/componentCreators.js +2 -1
  102. package/libEs6/core/consent/types.js +12 -0
  103. package/libEs6/core/createEvent.js +3 -0
  104. package/libEs6/core/edgeNetwork/types.js +12 -0
  105. package/libEs6/core/identity/types.js +12 -0
  106. package/libEs6/core/index.js +5 -1
  107. package/libEs6/core/types.js +12 -0
  108. package/libEs6/utils/createCollect.js +4 -2
  109. package/libEs6/utils/deepAssign.js +6 -0
  110. package/libEs6/utils/dom/createGetPageLocation.js +17 -0
  111. package/libEs6/utils/index.js +2 -1
  112. package/libEs6/utils/request/createRequest.js +5 -1
  113. package/libEs6/utils/request/types.js +12 -0
  114. package/libEs6/utils/surfaceUtils.js +76 -0
  115. package/libEs6/utils/types.js +12 -0
  116. package/libEs6/utils/uuid.js +1 -0
  117. package/package.json +44 -48
  118. package/scripts/helpers/path.js +12 -0
  119. package/scripts/helpers/versionBabelPlugin.js +12 -0
  120. package/types/components/Advertising/handlers/onBeforeSendEventHandler.d.ts.map +1 -1
  121. package/types/components/Advertising/handlers/viewThroughHandler.d.ts.map +1 -1
  122. package/types/components/Advertising/identities/collectSurferId.d.ts.map +1 -1
  123. package/types/components/BrandConcierge/constants.d.ts +3 -0
  124. package/types/components/BrandConcierge/constants.d.ts.map +1 -0
  125. package/types/components/BrandConcierge/createBuildEndpointUrl.d.ts +9 -0
  126. package/types/components/BrandConcierge/createBuildEndpointUrl.d.ts.map +1 -0
  127. package/types/components/BrandConcierge/createConversationServiceRequest.d.ts +7 -0
  128. package/types/components/BrandConcierge/createConversationServiceRequest.d.ts.map +1 -0
  129. package/types/components/BrandConcierge/createSendConversationEvent.d.ts +15 -0
  130. package/types/components/BrandConcierge/createSendConversationEvent.d.ts.map +1 -0
  131. package/types/components/BrandConcierge/createSendConversationServiceRequest.d.ts +11 -0
  132. package/types/components/BrandConcierge/createSendConversationServiceRequest.d.ts.map +1 -0
  133. package/types/components/BrandConcierge/createStreamParser.d.ts +3 -0
  134. package/types/components/BrandConcierge/createStreamParser.d.ts.map +1 -0
  135. package/types/components/BrandConcierge/createTimeoutWrapper.d.ts +3 -0
  136. package/types/components/BrandConcierge/createTimeoutWrapper.d.ts.map +1 -0
  137. package/types/components/BrandConcierge/index.d.ts +31 -0
  138. package/types/components/BrandConcierge/index.d.ts.map +1 -0
  139. package/types/components/BrandConcierge/utils.d.ts +6 -0
  140. package/types/components/BrandConcierge/utils.d.ts.map +1 -0
  141. package/types/components/BrandConcierge/validateMessage.d.ts +5 -0
  142. package/types/components/BrandConcierge/validateMessage.d.ts.map +1 -0
  143. package/types/components/Consent/types.d.ts.map +1 -1
  144. package/types/components/Context/createComponent.d.ts +1 -1
  145. package/types/components/Context/createComponent.d.ts.map +1 -1
  146. package/types/components/Context/implementationDetails.d.ts +1 -1
  147. package/types/components/Context/implementationDetails.d.ts.map +1 -1
  148. package/types/components/Context/index.d.ts +1 -1
  149. package/types/components/Context/index.d.ts.map +1 -1
  150. package/types/components/Context/injectDevice.d.ts +1 -1
  151. package/types/components/Context/injectDevice.d.ts.map +1 -1
  152. package/types/components/Context/injectEnvironment.d.ts +1 -1
  153. package/types/components/Context/injectEnvironment.d.ts.map +1 -1
  154. package/types/components/Context/injectHighEntropyUserAgentHints.d.ts +1 -1
  155. package/types/components/Context/injectHighEntropyUserAgentHints.d.ts.map +1 -1
  156. package/types/components/Context/injectOneTimeAnalyticsReferrer.d.ts +3 -0
  157. package/types/components/Context/injectOneTimeAnalyticsReferrer.d.ts.map +1 -0
  158. package/types/components/Context/injectPlaceContext.d.ts +1 -1
  159. package/types/components/Context/injectPlaceContext.d.ts.map +1 -1
  160. package/types/components/Context/injectTimestamp.d.ts +1 -1
  161. package/types/components/Context/injectTimestamp.d.ts.map +1 -1
  162. package/types/components/Context/injectWeb.d.ts +1 -1
  163. package/types/components/Context/injectWeb.d.ts.map +1 -1
  164. package/types/components/Personalization/createComponent.d.ts.map +1 -1
  165. package/types/components/Personalization/createFetchDataHandler.d.ts +2 -1
  166. package/types/components/Personalization/createFetchDataHandler.d.ts.map +1 -1
  167. package/types/components/Personalization/createNotificationHandler.d.ts +1 -1
  168. package/types/components/Personalization/createNotificationHandler.d.ts.map +1 -1
  169. package/types/components/Personalization/createOnDecisionHandler.d.ts +2 -1
  170. package/types/components/Personalization/createOnDecisionHandler.d.ts.map +1 -1
  171. package/types/components/Personalization/createPersonalizationDetails.d.ts.map +1 -1
  172. package/types/components/Personalization/handlers/createProcessInAppMessage.d.ts.map +1 -1
  173. package/types/components/Personalization/handlers/createProcessRedirect.d.ts.map +1 -1
  174. package/types/components/Personalization/handlers/injectCreateProposition.d.ts +2 -1
  175. package/types/components/Personalization/handlers/injectCreateProposition.d.ts.map +1 -1
  176. package/types/components/Personalization/in-app-message-actions/actions/displayIframeContent.d.ts.map +1 -1
  177. package/types/components/Personalization/index.d.ts.map +1 -1
  178. package/types/components/PushNotifications/types.d.ts.map +1 -1
  179. package/types/components/RulesEngine/createApplyResponse.d.ts.map +1 -1
  180. package/types/components/RulesEngine/index.d.ts.map +1 -1
  181. package/types/components/RulesEngine/types.d.ts.map +1 -1
  182. package/types/constants/surface.d.ts +5 -0
  183. package/types/constants/surface.d.ts.map +1 -0
  184. package/types/core/componentCreators.d.ts +1 -0
  185. package/types/core/consent/types.d.ts.map +1 -1
  186. package/types/core/createEvent.d.ts +1 -0
  187. package/types/core/createEvent.d.ts.map +1 -1
  188. package/types/core/edgeNetwork/types.d.ts.map +1 -1
  189. package/types/core/identity/types.d.ts.map +1 -1
  190. package/types/core/index.d.ts.map +1 -1
  191. package/types/core/types.d.ts.map +1 -1
  192. package/types/utils/createCollect.d.ts +2 -1
  193. package/types/utils/createCollect.d.ts.map +1 -1
  194. package/types/utils/deepAssign.d.ts.map +1 -1
  195. package/types/utils/dom/createGetPageLocation.d.ts +5 -0
  196. package/types/utils/dom/createGetPageLocation.d.ts.map +1 -0
  197. package/types/utils/index.d.ts +1 -0
  198. package/types/utils/request/createRequest.d.ts.map +1 -1
  199. package/types/utils/request/types.d.ts.map +1 -1
  200. package/types/utils/surfaceUtils.d.ts +4 -0
  201. package/types/utils/surfaceUtils.d.ts.map +1 -0
  202. package/types/utils/types.d.ts.map +1 -1
  203. package/types/utils/uuid.d.ts.map +1 -1
@@ -10,8 +10,14 @@ var _consentStatus = require("../../../constants/consentStatus.js");
10
10
  var _browser = require("../../../constants/browser.js");
11
11
  /*
12
12
  Copyright 2023 Adobe. All rights reserved.
13
- Licensed under the Apache License, Version 2.0.
14
- http://www.apache.org/licenses/LICENSE-2.0
13
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ you may not use this file except in compliance with the License. You may obtain a copy
15
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+
17
+ Unless required by applicable law or agreed to in writing, software distributed under
18
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ OF ANY KIND, either express or implied. See the License for the specific language
20
+ governing permissions and limitations under the License.
15
21
  */
16
22
 
17
23
  const isAdvertisingDisabled = advertising => {
@@ -6,8 +6,14 @@ var _index = require("../constants/index.js");
6
6
  var _helpers = require("../utils/helpers.js");
7
7
  /*
8
8
  Copyright 2025 Adobe. All rights reserved.
9
- Licensed under the Apache License, Version 2.0.
10
- http://www.apache.org/licenses/LICENSE-2.0
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
11
17
  */
12
18
 
13
19
  async function handleViewThrough({
@@ -6,7 +6,14 @@ var _createNode = require("../../../utils/dom/createNode.js");
6
6
  var _index2 = require("../../../utils/index.js");
7
7
  /*
8
8
  Copyright 2025 Adobe. All rights reserved.
9
- This file is licensed under the Apache License, Version 2.0.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
10
17
  */
11
18
 
12
19
  let surferId = "";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ exports.STREAM_START_TIMEOUT_MS = exports.BC_SESSION_COOKIE_NAME = void 0;
4
+ /*
5
+ Copyright 2025 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
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;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ /*
5
+ Copyright 2025 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+ var _default = ({
16
+ queryString
17
+ }) => {
18
+ return ({
19
+ edgeDomain,
20
+ request,
21
+ datastreamId
22
+ }) => {
23
+ const params = request.getRequestParams();
24
+ const configId = request.getDatastreamIdOverride() || datastreamId;
25
+ params.requestId = request.getId();
26
+ params.configId = configId;
27
+ const stringifiedRequestParams = queryString.stringify({
28
+ ...params
29
+ });
30
+ return "https://" + edgeDomain + request.getEdgeSubPath() + "/" + request.getAction() + "?" + stringifiedRequestParams;
31
+ };
32
+ };
33
+ exports.default = _default;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _index = require("../../utils/request/index.js");
5
+ /*
6
+ Copyright 2023 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
+ var _default = ({
17
+ payload,
18
+ action = "conversations",
19
+ sessionId
20
+ }) => {
21
+ return (0, _index.createRequest)({
22
+ payload: payload,
23
+ edgeSubPath: "/brand-concierge",
24
+ requestParams: {
25
+ sessionId
26
+ },
27
+ getAction() {
28
+ return action;
29
+ },
30
+ getUseSendBeacon() {
31
+ return false;
32
+ }
33
+ });
34
+ };
35
+ exports.default = _default;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _index = require("../../utils/request/index.js");
5
+ var _createConversationServiceRequest = require("./createConversationServiceRequest.js");
6
+ var _utils = require("./utils.js");
7
+ var _uuid = require("../../utils/uuid.js");
8
+ var _createStreamParser = require("./createStreamParser.js");
9
+ var _createTimeoutWrapper = require("./createTimeoutWrapper.js");
10
+ /*
11
+ Copyright 2025 Adobe. All rights reserved.
12
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ you may not use this file except in compliance with the License. You may obtain a copy
14
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software distributed under
17
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ OF ANY KIND, either express or implied. See the License for the specific language
19
+ governing permissions and limitations under the License.
20
+ */
21
+ var _default = ({
22
+ eventManager,
23
+ loggingCookieJar,
24
+ config,
25
+ logger,
26
+ sendConversationServiceRequest,
27
+ buildEndpointUrl,
28
+ cookieTransfer,
29
+ createResponse,
30
+ decodeKndctrCookie,
31
+ lifecycle,
32
+ consent
33
+ }) => {
34
+ const {
35
+ edgeDomain,
36
+ edgeBasePath,
37
+ datastreamId,
38
+ onBeforeEventSend
39
+ } = config;
40
+ return options => {
41
+ let streamingEnabled = false;
42
+ const {
43
+ message,
44
+ onStreamResponse,
45
+ xdm,
46
+ data
47
+ } = options;
48
+ const sessionId = (0, _utils.getConciergeSessionCookie)({
49
+ loggingCookieJar,
50
+ config
51
+ }) || (0, _uuid.default)();
52
+ const payload = (0, _index.createDataCollectionRequestPayload)();
53
+ const request = (0, _createConversationServiceRequest.default)({
54
+ payload,
55
+ sessionId: sessionId
56
+ });
57
+ const event = eventManager.createEvent();
58
+ if (message || data) {
59
+ const pageSurface = (0, _utils.getPageSurface)();
60
+ event.mergeQuery({
61
+ conversation: {
62
+ surfaces: [pageSurface],
63
+ message,
64
+ data
65
+ }
66
+ });
67
+ }
68
+ const {
69
+ state
70
+ } = consent.current();
71
+ event.mergeMeta({
72
+ consent: {
73
+ state: state
74
+ }
75
+ });
76
+ const ecid = decodeKndctrCookie();
77
+ event.mergeXdm({
78
+ identityMap: {
79
+ ECID: [{
80
+ id: ecid
81
+ }]
82
+ }
83
+ });
84
+ event.mergeXdm({
85
+ ...xdm
86
+ });
87
+ if (message || data) {
88
+ streamingEnabled = true;
89
+ }
90
+ const url = buildEndpointUrl({
91
+ edgeDomain,
92
+ edgeBasePath,
93
+ datastreamId,
94
+ request
95
+ });
96
+ return lifecycle.onBeforeEvent({
97
+ event
98
+ }).then(() => {
99
+ try {
100
+ // NOTE: this calls onBeforeEventSend callback (if configured)
101
+ event.finalize(onBeforeEventSend);
102
+ } catch (error) {
103
+ onStreamResponse({
104
+ error
105
+ });
106
+ throw error;
107
+ }
108
+ payload.addEvent(event);
109
+ cookieTransfer.cookiesToPayload(payload, edgeDomain);
110
+ return sendConversationServiceRequest({
111
+ requestId: (0, _uuid.default)(),
112
+ url,
113
+ request,
114
+ onStreamResponse,
115
+ streamingEnabled
116
+ }).then(response => {
117
+ if (response.status === 204) {
118
+ return;
119
+ }
120
+ const onStreamResponseCallback = event => {
121
+ if (event.error) {
122
+ logger.error("Stream error occurred", event.error);
123
+ onStreamResponse({
124
+ error: event.error
125
+ });
126
+ return;
127
+ }
128
+ const substr = event.data.replace("data: ", "");
129
+ const responseJson = JSON.parse(substr);
130
+ const response = createResponse({
131
+ content: responseJson
132
+ });
133
+ cookieTransfer.responseToCookies(response);
134
+ logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
135
+ onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
136
+ };
137
+ const wrappedCallback = (0, _createTimeoutWrapper.default)({
138
+ onStreamResponseCallback
139
+ });
140
+ const streamParser = (0, _createStreamParser.default)();
141
+ streamParser(response.body, wrappedCallback);
142
+ });
143
+ });
144
+ };
145
+ };
146
+ exports.default = _default;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _index = require("../../utils/index.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
+ var _default = ({
17
+ logger,
18
+ fetch
19
+ }) => {
20
+ return async ({
21
+ requestId,
22
+ url,
23
+ request,
24
+ streamingEnabled = true
25
+ }) => {
26
+ const payload = request.getPayload();
27
+ const stringifiedPayload = JSON.stringify(payload);
28
+ const parsedPayload = JSON.parse(stringifiedPayload);
29
+ const headers = {
30
+ "Content-Type": "text/plain"
31
+ };
32
+ if (streamingEnabled) {
33
+ headers.Accept = "text/event-stream";
34
+ } else {
35
+ headers.Accept = "text/plain";
36
+ }
37
+ logger.logOnBeforeNetworkRequest({
38
+ url,
39
+ requestId,
40
+ payload: parsedPayload
41
+ });
42
+ const fetchWithRetries = async (attemptNumber = 1) => {
43
+ const maxAttempts = 4;
44
+ const retryDelays = [2000, 3000, 5000];
45
+ try {
46
+ const response = await fetch(url, {
47
+ method: "POST",
48
+ headers: headers,
49
+ body: stringifiedPayload
50
+ });
51
+ if (!response.ok) {
52
+ throw new Error("Request failed with status " + response.status);
53
+ }
54
+ return response;
55
+ } catch (error) {
56
+ if (attemptNumber < maxAttempts) {
57
+ const delay = retryDelays[attemptNumber - 1];
58
+ logger.logOnNetworkError({
59
+ requestId,
60
+ url,
61
+ payload: parsedPayload,
62
+ error: new Error("Attempt " + attemptNumber + " failed, retrying in " + delay + "ms: " + error.message)
63
+ });
64
+ await new Promise(resolve => setTimeout(resolve, delay));
65
+ return fetchWithRetries(attemptNumber + 1);
66
+ }
67
+ logger.logOnNetworkError({
68
+ requestId,
69
+ url,
70
+ payload: parsedPayload,
71
+ error
72
+ });
73
+ throw (0, _index.stackError)({
74
+ error,
75
+ message: "Network request failed after all retries."
76
+ });
77
+ }
78
+ };
79
+ const executeRequest = async () => {
80
+ return fetchWithRetries();
81
+ };
82
+ return executeRequest();
83
+ };
84
+ };
85
+ exports.default = _default;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ /*
5
+ Copyright 2024 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+ var _default = () => {
16
+ // SSE streams are always UTF-8 encoded per specification
17
+ const ENCODING = "utf-8";
18
+ // SSE spec allows three line ending styles: CRLF (\r\n), LF (\n), or CR (\r)
19
+ const LINE_ENDING_REGEX = /\r\n|\r|\n/;
20
+ // Events are separated by blank lines (double line endings)
21
+ const EVENT_SEPARATOR_REGEX = /\r\n\r\n|\n\n|\r\r/;
22
+
23
+ /**
24
+ * Parse a single SSE event from raw event data.
25
+ * Follows the Server-Sent Events specification (https://html.spec.whatwg.org/multipage/server-sent-events.html)
26
+ *
27
+ * @param {string} eventData - Raw event data (multi-line string containing SSE fields)
28
+ * @returns {Object|null} - Parsed SSE event with structure { type, data, id } or null if invalid
29
+ */
30
+ const parseEventFromBuffer = eventData => {
31
+ const lines = eventData.split(LINE_ENDING_REGEX);
32
+ const parsedEvent = {};
33
+ for (const line of lines) {
34
+ const trimmedLine = line.trim();
35
+ if (!trimmedLine) {
36
+ continue;
37
+ }
38
+ const colonIndex = trimmedLine.indexOf(":");
39
+ if (colonIndex === -1) {
40
+ continue;
41
+ }
42
+ const field = trimmedLine.substring(0, colonIndex).trim();
43
+ const value = trimmedLine.substring(colonIndex + 1).trim();
44
+ if (field === "data") {
45
+ parsedEvent.data = (parsedEvent.data || "") + value;
46
+ } else if (field === "event") {
47
+ parsedEvent.type = value;
48
+ } else if (field === "id") {
49
+ parsedEvent.id = value;
50
+ }
51
+ }
52
+ return parsedEvent.data ? parsedEvent : null;
53
+ };
54
+
55
+ /**
56
+ * Parse SSE stream using callbacks.
57
+ * Uses modern async iteration (for await...of) for clean, performant stream processing.
58
+ *
59
+ * @param {ReadableStream} stream - The readable stream from fetch response
60
+ * @param {Function} onEvent - Callback function called for each parsed event
61
+ */
62
+ return async (stream, onEvent) => {
63
+ const decoder = new TextDecoder(ENCODING);
64
+ let buffer = "";
65
+ try {
66
+ for await (const chunk of stream) {
67
+ buffer += decoder.decode(chunk, {
68
+ stream: true
69
+ });
70
+ const events = buffer.split(EVENT_SEPARATOR_REGEX);
71
+ 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
+ }
79
+ }
80
+ }
81
+ }
82
+ const trimmedBuffer = buffer.trim();
83
+ if (trimmedBuffer) {
84
+ const event = parseEventFromBuffer(trimmedBuffer);
85
+ if (event !== null) {
86
+ onEvent(event);
87
+ }
88
+ }
89
+ } catch (error) {
90
+ onEvent({
91
+ error
92
+ });
93
+ }
94
+ };
95
+ };
96
+ exports.default = _default;
@@ -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;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _validateMessage = require("./validateMessage.js");
5
+ var _createSendConversationEvent = require("./createSendConversationEvent.js");
6
+ var _createBuildEndpointUrl = require("./createBuildEndpointUrl.js");
7
+ var _reactorQueryString = require("@adobe/reactor-query-string");
8
+ var _index = require("../../utils/index.js");
9
+ var _constants = require("./constants.js");
10
+ var _index2 = require("../../utils/validation/index.js");
11
+ var _createDecodeKndctrCookie = require("../../utils/createDecodeKndctrCookie.js");
12
+ var _createSendConversationServiceRequest = require("./createSendConversationServiceRequest.js");
13
+ /*
14
+ Copyright 2024 Adobe. All rights reserved.
15
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ you may not use this file except in compliance with the License. You may obtain a copy
17
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+
19
+ Unless required by applicable law or agreed to in writing, software distributed under
20
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ OF ANY KIND, either express or implied. See the License for the specific language
22
+ governing permissions and limitations under the License.
23
+ */
24
+
25
+ const createConciergeComponent = ({
26
+ loggingCookieJar,
27
+ logger,
28
+ eventManager,
29
+ consent,
30
+ instanceName,
31
+ sendEdgeNetworkRequest,
32
+ config,
33
+ lifecycle,
34
+ cookieTransfer,
35
+ createResponse,
36
+ apexDomain
37
+ }) => {
38
+ const {
39
+ fetch
40
+ } = window;
41
+ if (!config.stickyConversationSession) {
42
+ loggingCookieJar.remove((0, _index.getNamespacedCookieName)(config.orgId, _constants.BC_SESSION_COOKIE_NAME), {
43
+ domain: apexDomain
44
+ });
45
+ }
46
+ const buildEndpointUrl = (0, _createBuildEndpointUrl.default)({
47
+ queryString: _reactorQueryString.default
48
+ });
49
+ const sendConversationServiceRequest = (0, _createSendConversationServiceRequest.default)({
50
+ logger,
51
+ fetch,
52
+ config
53
+ });
54
+ const decodeKndctrCookie = (0, _createDecodeKndctrCookie.default)({
55
+ orgId: config.orgId,
56
+ cookieJar: loggingCookieJar,
57
+ logger
58
+ });
59
+ const sendConversationEvent = (0, _createSendConversationEvent.default)({
60
+ loggingCookieJar,
61
+ logger,
62
+ eventManager,
63
+ consent,
64
+ instanceName,
65
+ sendEdgeNetworkRequest,
66
+ config,
67
+ buildEndpointUrl,
68
+ lifecycle,
69
+ cookieTransfer,
70
+ createResponse,
71
+ sendConversationServiceRequest,
72
+ decodeKndctrCookie
73
+ });
74
+ return {
75
+ lifecycle: {
76
+ onBeforeEvent({
77
+ event
78
+ }) {
79
+ const parsedParams = _reactorQueryString.default.parse(window.location.search);
80
+ if (parsedParams.source) {
81
+ const source = parsedParams.source;
82
+ event.mergeXdm({
83
+ channel: {
84
+ referringSource: source
85
+ }
86
+ });
87
+ }
88
+ }
89
+ },
90
+ commands: {
91
+ sendConversationEvent: {
92
+ optionsValidator: options => (0, _validateMessage.default)({
93
+ options
94
+ }),
95
+ run: sendConversationEvent
96
+ }
97
+ }
98
+ };
99
+ };
100
+ createConciergeComponent.namespace = "BrandConcierge";
101
+ createConciergeComponent.configValidators = (0, _index2.objectOf)({
102
+ stickyConversationSession: (0, _index2.boolean)().default(false)
103
+ });
104
+ var _default = exports.default = createConciergeComponent;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.getPageSurface = exports.getConciergeSessionCookie = void 0;
4
+ var _index = require("../../utils/index.js");
5
+ var _surfaceUtils = require("../../utils/surfaceUtils.js");
6
+ var _constants = require("./constants.js");
7
+ /*
8
+ Copyright 2025 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
18
+
19
+ const getPageSurface = () => {
20
+ const pageLocation = (0, _index.createGetPageLocation)({
21
+ window: window
22
+ });
23
+ return (0, _surfaceUtils.buildPageSurface)(pageLocation);
24
+ };
25
+ exports.getPageSurface = getPageSurface;
26
+ const getConciergeSessionCookie = ({
27
+ loggingCookieJar,
28
+ config
29
+ }) => {
30
+ const cookieName = (0, _index.getNamespacedCookieName)(config.orgId, _constants.BC_SESSION_COOKIE_NAME);
31
+ return loggingCookieJar.get(cookieName);
32
+ };
33
+ exports.getConciergeSessionCookie = getConciergeSessionCookie;