@adobe/alloy 2.30.1-beta.13 → 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.
- package/libEs5/components/BrandConcierge/constants.js +3 -2
- package/libEs5/components/BrandConcierge/createSendConversationEvent.js +16 -2
- package/libEs5/components/BrandConcierge/createTimeoutWrapper.js +52 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs6/components/BrandConcierge/constants.js +2 -1
- package/libEs6/components/BrandConcierge/createSendConversationEvent.js +16 -2
- package/libEs6/components/BrandConcierge/createTimeoutWrapper.js +49 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/package.json +1 -1
- package/types/components/BrandConcierge/constants.d.ts +1 -0
- package/types/components/BrandConcierge/constants.d.ts.map +1 -1
- package/types/components/BrandConcierge/createSendConversationEvent.d.ts +2 -1
- package/types/components/BrandConcierge/createSendConversationEvent.d.ts.map +1 -1
- package/types/components/BrandConcierge/createTimeoutWrapper.d.ts +3 -0
- package/types/components/BrandConcierge/createTimeoutWrapper.d.ts.map +1 -0
|
@@ -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");
|
|
@@ -27,7 +28,8 @@ var _default = ({
|
|
|
27
28
|
cookieTransfer,
|
|
28
29
|
createResponse,
|
|
29
30
|
decodeKndctrCookie,
|
|
30
|
-
lifecycle
|
|
31
|
+
lifecycle,
|
|
32
|
+
consent
|
|
31
33
|
}) => {
|
|
32
34
|
const {
|
|
33
35
|
edgeDomain,
|
|
@@ -63,6 +65,14 @@ var _default = ({
|
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
}
|
|
68
|
+
const {
|
|
69
|
+
state
|
|
70
|
+
} = consent.current();
|
|
71
|
+
event.mergeMeta({
|
|
72
|
+
consent: {
|
|
73
|
+
state: state
|
|
74
|
+
}
|
|
75
|
+
});
|
|
66
76
|
const ecid = decodeKndctrCookie();
|
|
67
77
|
event.mergeXdm({
|
|
68
78
|
identityMap: {
|
|
@@ -109,6 +119,7 @@ var _default = ({
|
|
|
109
119
|
}
|
|
110
120
|
const onStreamResponseCallback = event => {
|
|
111
121
|
if (event.error) {
|
|
122
|
+
logger.error("Stream error occurred", event.error);
|
|
112
123
|
onStreamResponse({
|
|
113
124
|
error: event.error
|
|
114
125
|
});
|
|
@@ -123,8 +134,11 @@ var _default = ({
|
|
|
123
134
|
logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
|
|
124
135
|
onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
|
|
125
136
|
};
|
|
137
|
+
const wrappedCallback = (0, _createTimeoutWrapper.default)({
|
|
138
|
+
onStreamResponseCallback
|
|
139
|
+
});
|
|
126
140
|
const streamParser = (0, _createStreamParser.default)();
|
|
127
|
-
streamParser(response.body,
|
|
141
|
+
streamParser(response.body, wrappedCallback);
|
|
128
142
|
});
|
|
129
143
|
});
|
|
130
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.
|
|
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,
|
|
@@ -24,7 +25,8 @@ export default ({
|
|
|
24
25
|
cookieTransfer,
|
|
25
26
|
createResponse,
|
|
26
27
|
decodeKndctrCookie,
|
|
27
|
-
lifecycle
|
|
28
|
+
lifecycle,
|
|
29
|
+
consent
|
|
28
30
|
}) => {
|
|
29
31
|
const {
|
|
30
32
|
edgeDomain,
|
|
@@ -60,6 +62,14 @@ export default ({
|
|
|
60
62
|
}
|
|
61
63
|
});
|
|
62
64
|
}
|
|
65
|
+
const {
|
|
66
|
+
state
|
|
67
|
+
} = consent.current();
|
|
68
|
+
event.mergeMeta({
|
|
69
|
+
consent: {
|
|
70
|
+
state: state
|
|
71
|
+
}
|
|
72
|
+
});
|
|
63
73
|
const ecid = decodeKndctrCookie();
|
|
64
74
|
event.mergeXdm({
|
|
65
75
|
identityMap: {
|
|
@@ -106,6 +116,7 @@ export default ({
|
|
|
106
116
|
}
|
|
107
117
|
const onStreamResponseCallback = event => {
|
|
108
118
|
if (event.error) {
|
|
119
|
+
logger.error("Stream error occurred", event.error);
|
|
109
120
|
onStreamResponse({
|
|
110
121
|
error: event.error
|
|
111
122
|
});
|
|
@@ -120,8 +131,11 @@ export default ({
|
|
|
120
131
|
logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
|
|
121
132
|
onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
|
|
122
133
|
};
|
|
134
|
+
const wrappedCallback = createTimeoutWrapper({
|
|
135
|
+
onStreamResponseCallback
|
|
136
|
+
});
|
|
123
137
|
const streamParser = createStreamParser();
|
|
124
|
-
streamParser(response.body,
|
|
138
|
+
streamParser(response.body, wrappedCallback);
|
|
125
139
|
});
|
|
126
140
|
});
|
|
127
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
|
+
};
|
package/package.json
CHANGED
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
declare function _default({ eventManager, loggingCookieJar, config, logger, sendConversationServiceRequest, buildEndpointUrl, cookieTransfer, createResponse, decodeKndctrCookie, lifecycle, }: {
|
|
1
|
+
declare function _default({ eventManager, loggingCookieJar, config, logger, sendConversationServiceRequest, buildEndpointUrl, cookieTransfer, createResponse, decodeKndctrCookie, lifecycle, consent, }: {
|
|
2
2
|
eventManager: any;
|
|
3
3
|
loggingCookieJar: any;
|
|
4
4
|
config: any;
|
|
@@ -9,6 +9,7 @@ declare function _default({ eventManager, loggingCookieJar, config, logger, send
|
|
|
9
9
|
createResponse: any;
|
|
10
10
|
decodeKndctrCookie: any;
|
|
11
11
|
lifecycle: any;
|
|
12
|
+
consent: any;
|
|
12
13
|
}): (options: any) => any;
|
|
13
14
|
export default _default;
|
|
14
15
|
//# sourceMappingURL=createSendConversationEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSendConversationEvent.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createSendConversationEvent.js"],"names":[],"mappings":"
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"createTimeoutWrapper.d.ts","sourceRoot":"","sources":["../../../packages/core/src/components/BrandConcierge/createTimeoutWrapper.js"],"names":[],"mappings":"AAqBe,4EA2Bd"}
|