@adobe/alloy 2.19.0-beta.9 → 2.19.1-beta.0
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/README.md +4 -1
- package/libEs5/components/DataCollector/index.js +3 -0
- package/libEs5/components/DataCollector/validateApplyResponse.js +2 -1
- package/libEs5/components/DataCollector/validateUserEventOptions.js +2 -1
- package/libEs5/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +32 -0
- package/libEs5/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +25 -0
- package/libEs5/components/DecisioningEngine/constants.js +31 -0
- package/libEs5/components/DecisioningEngine/createApplyResponse.js +36 -0
- package/libEs5/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
- package/libEs5/components/DecisioningEngine/createContextProvider.js +93 -0
- package/libEs5/components/DecisioningEngine/createDecisionHistory.js +28 -0
- package/libEs5/components/DecisioningEngine/createDecisionProvider.js +51 -0
- package/libEs5/components/DecisioningEngine/createEvaluableRulesetPayload.js +80 -0
- package/libEs5/components/DecisioningEngine/createEvaluateRulesetsCommand.js +49 -0
- package/libEs5/components/DecisioningEngine/createEventRegistry.js +130 -0
- package/libEs5/components/DecisioningEngine/createOnResponseHandler.js +46 -0
- package/libEs5/components/DecisioningEngine/createSubscribeRulesetItems.js +87 -0
- package/libEs5/components/DecisioningEngine/index.js +119 -0
- package/libEs5/components/DecisioningEngine/utils.js +90 -0
- package/libEs5/components/Personalization/createActionsProvider.js +72 -0
- package/libEs5/components/Personalization/createApplyPropositions.js +2 -2
- package/libEs5/components/Personalization/createCollect.js +9 -4
- package/libEs5/components/Personalization/createComponent.js +5 -3
- package/libEs5/components/Personalization/createFetchDataHandler.js +2 -17
- package/libEs5/components/Personalization/createNotificationHandler.js +33 -0
- package/libEs5/components/Personalization/createOnClickHandler.js +5 -3
- package/libEs5/components/Personalization/createOnDecisionHandler.js +44 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -5
- package/libEs5/components/Personalization/createPreprocessors.js +21 -0
- package/libEs5/components/Personalization/createViewCacheManager.js +9 -2
- package/libEs5/components/Personalization/dom-actions/createRedirect.js +11 -1
- package/libEs5/components/Personalization/event.js +25 -22
- package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +76 -0
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +5 -2
- package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +288 -0
- package/libEs5/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +23 -0
- package/libEs5/components/Personalization/in-app-message-actions/utils.js +53 -0
- package/libEs5/components/Personalization/index.js +20 -7
- package/libEs5/constants/contentType.js +18 -0
- package/libEs5/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +4 -8
- package/libEs5/constants/eventType.js +25 -0
- package/libEs5/{components/Personalization/constants/eventType.js → constants/handle.js} +4 -7
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/propositionEventType.js +33 -0
- package/libEs5/{components/Personalization/constants → constants}/schema.js +9 -1
- package/libEs5/core/componentCreators.js +2 -1
- package/libEs5/core/createEvent.js +26 -1
- package/libEs5/core/createEventManager.js +3 -0
- package/libEs5/core/createLifecycle.js +4 -1
- package/libEs5/core/edgeNetwork/mergeLifecycleResponses.js +1 -1
- package/libEs5/utils/assignConcatArrayValues.js +49 -0
- package/libEs5/utils/createSubscription.js +91 -0
- package/libEs5/utils/debounce.js +30 -0
- package/libEs5/utils/dom/selectNodesWithShadow.js +10 -3
- package/libEs5/utils/flattenArray.js +37 -0
- package/libEs5/utils/flattenObject.js +43 -0
- package/libEs5/utils/index.js +14 -0
- package/libEs5/utils/parseUrl.js +70 -0
- package/libEs6/components/DataCollector/index.js +2 -0
- package/libEs6/components/DataCollector/validateApplyResponse.js +2 -1
- package/libEs6/components/DataCollector/validateUserEventOptions.js +2 -1
- package/libEs6/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +30 -0
- package/libEs6/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +24 -0
- package/libEs6/components/DecisioningEngine/constants.js +25 -0
- package/libEs6/components/DecisioningEngine/createApplyResponse.js +31 -0
- package/libEs6/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
- package/libEs6/components/DecisioningEngine/createContextProvider.js +95 -0
- package/libEs6/components/DecisioningEngine/createDecisionHistory.js +25 -0
- package/libEs6/components/DecisioningEngine/createDecisionProvider.js +41 -0
- package/libEs6/components/DecisioningEngine/createEvaluableRulesetPayload.js +79 -0
- package/libEs6/components/DecisioningEngine/createEvaluateRulesetsCommand.js +45 -0
- package/libEs6/components/DecisioningEngine/createEventRegistry.js +120 -0
- package/libEs6/components/DecisioningEngine/createOnResponseHandler.js +45 -0
- package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +79 -0
- package/libEs6/components/DecisioningEngine/index.js +124 -0
- package/libEs6/components/DecisioningEngine/utils.js +83 -0
- package/libEs6/components/Personalization/createActionsProvider.js +70 -0
- package/libEs6/components/Personalization/createApplyPropositions.js +2 -2
- package/libEs6/components/Personalization/createCollect.js +7 -4
- package/libEs6/components/Personalization/createComponent.js +5 -3
- package/libEs6/components/Personalization/createFetchDataHandler.js +3 -18
- package/libEs6/components/Personalization/createNotificationHandler.js +29 -0
- package/libEs6/components/Personalization/createOnClickHandler.js +5 -3
- package/libEs6/components/Personalization/createOnDecisionHandler.js +42 -0
- package/libEs6/components/Personalization/createPersonalizationDetails.js +8 -5
- package/libEs6/components/Personalization/createPreprocessors.js +19 -0
- package/libEs6/components/Personalization/createViewCacheManager.js +12 -3
- package/libEs6/components/Personalization/dom-actions/createRedirect.js +10 -1
- package/libEs6/components/Personalization/event.js +14 -9
- package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +77 -0
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +5 -2
- package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +291 -0
- package/libEs6/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +17 -0
- package/libEs6/components/Personalization/in-app-message-actions/utils.js +49 -0
- package/libEs6/components/Personalization/index.js +22 -8
- package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js} +3 -4
- package/libEs6/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +2 -6
- package/libEs6/constants/eventType.js +17 -0
- package/libEs6/constants/handle.js +12 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/propositionEventType.js +33 -0
- package/libEs6/{components/Personalization/constants → constants}/schema.js +4 -0
- package/libEs6/core/componentCreators.js +2 -1
- package/libEs6/core/createEvent.js +26 -1
- package/libEs6/core/createEventManager.js +2 -0
- package/libEs6/core/createLifecycle.js +4 -1
- package/libEs6/core/edgeNetwork/mergeLifecycleResponses.js +3 -2
- package/libEs6/utils/assignConcatArrayValues.js +36 -0
- package/libEs6/utils/createSubscription.js +70 -0
- package/libEs6/utils/debounce.js +22 -0
- package/libEs6/utils/dom/selectNodesWithShadow.js +10 -3
- package/libEs6/utils/flattenArray.js +26 -0
- package/libEs6/utils/flattenObject.js +28 -0
- package/libEs6/utils/index.js +2 -0
- package/libEs6/utils/parseUrl.js +62 -0
- package/package.json +6 -2
|
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { boolean, objectOf, string } from "../../utils/validation";
|
|
14
14
|
import createComponent from "./createComponent";
|
|
15
15
|
import { initDomActionsModules } from "./dom-actions";
|
|
16
16
|
import createCollect from "./createCollect";
|
|
@@ -31,14 +31,18 @@ import remapHeadOffers from "./dom-actions/remapHeadOffers";
|
|
|
31
31
|
import createPreprocess from "./dom-actions/createPreprocess";
|
|
32
32
|
import injectCreateProposition from "./handlers/injectCreateProposition";
|
|
33
33
|
import createAsyncArray from "./utils/createAsyncArray";
|
|
34
|
-
import * as schema from "
|
|
34
|
+
import * as schema from "../../constants/schema";
|
|
35
35
|
import processDefaultContent from "./handlers/processDefaultContent";
|
|
36
36
|
import { isPageWideSurface } from "./utils/surfaceUtils";
|
|
37
37
|
import createProcessDomAction from "./handlers/createProcessDomAction";
|
|
38
38
|
import createProcessHtmlContent from "./handlers/createProcessHtmlContent";
|
|
39
39
|
import createProcessRedirect from "./handlers/createProcessRedirect";
|
|
40
40
|
import createProcessPropositions from "./handlers/createProcessPropositions";
|
|
41
|
+
import createOnDecisionHandler from "./createOnDecisionHandler";
|
|
42
|
+
import createProcessInAppMessage from "./handlers/createProcessInAppMessage";
|
|
43
|
+
import initInAppMessageActionsModules from "./in-app-message-actions/initInAppMessageActionsModules";
|
|
41
44
|
import createRedirect from "./dom-actions/createRedirect";
|
|
45
|
+
import createNotificationHandler from "./createNotificationHandler";
|
|
42
46
|
const createPersonalization = ({
|
|
43
47
|
config,
|
|
44
48
|
logger,
|
|
@@ -60,7 +64,7 @@ const createPersonalization = ({
|
|
|
60
64
|
const getPageLocation = createGetPageLocation({
|
|
61
65
|
window
|
|
62
66
|
});
|
|
63
|
-
const
|
|
67
|
+
const domActionsModules = initDomActionsModules();
|
|
64
68
|
const preprocess = createPreprocess([remapHeadOffers, remapCustomCodeOffers]);
|
|
65
69
|
const createProposition = injectCreateProposition({
|
|
66
70
|
preprocess,
|
|
@@ -73,18 +77,22 @@ const createPersonalization = ({
|
|
|
73
77
|
const schemaProcessors = {
|
|
74
78
|
[schema.DEFAULT_CONTENT_ITEM]: processDefaultContent,
|
|
75
79
|
[schema.DOM_ACTION]: createProcessDomAction({
|
|
76
|
-
modules,
|
|
80
|
+
modules: domActionsModules,
|
|
77
81
|
logger,
|
|
78
82
|
storeClickMetrics
|
|
79
83
|
}),
|
|
80
84
|
[schema.HTML_CONTENT_ITEM]: createProcessHtmlContent({
|
|
81
|
-
modules,
|
|
85
|
+
modules: domActionsModules,
|
|
82
86
|
logger
|
|
83
87
|
}),
|
|
84
88
|
[schema.REDIRECT_ITEM]: createProcessRedirect({
|
|
85
89
|
logger,
|
|
86
90
|
executeRedirect,
|
|
87
91
|
collect
|
|
92
|
+
}),
|
|
93
|
+
[schema.MESSAGE_IN_APP]: createProcessInAppMessage({
|
|
94
|
+
modules: initInAppMessageActionsModules(collect),
|
|
95
|
+
logger
|
|
88
96
|
})
|
|
89
97
|
};
|
|
90
98
|
const processPropositions = createProcessPropositions({
|
|
@@ -92,15 +100,15 @@ const createPersonalization = ({
|
|
|
92
100
|
logger
|
|
93
101
|
});
|
|
94
102
|
const renderedPropositions = createAsyncArray();
|
|
103
|
+
const notificationHandler = createNotificationHandler(collect, renderedPropositions);
|
|
95
104
|
const fetchDataHandler = createFetchDataHandler({
|
|
96
105
|
prehidingStyle,
|
|
97
106
|
showContainers,
|
|
98
107
|
hideContainers,
|
|
99
108
|
mergeQuery,
|
|
100
|
-
collect,
|
|
101
109
|
processPropositions,
|
|
102
110
|
createProposition,
|
|
103
|
-
|
|
111
|
+
notificationHandler
|
|
104
112
|
});
|
|
105
113
|
const onClickHandler = createOnClickHandler({
|
|
106
114
|
mergeDecisionsMeta,
|
|
@@ -121,6 +129,11 @@ const createPersonalization = ({
|
|
|
121
129
|
const setTargetMigration = createSetTargetMigration({
|
|
122
130
|
targetMigrationEnabled
|
|
123
131
|
});
|
|
132
|
+
const onDecisionHandler = createOnDecisionHandler({
|
|
133
|
+
processPropositions,
|
|
134
|
+
createProposition,
|
|
135
|
+
notificationHandler
|
|
136
|
+
});
|
|
124
137
|
return createComponent({
|
|
125
138
|
getPageLocation,
|
|
126
139
|
logger,
|
|
@@ -134,7 +147,8 @@ const createPersonalization = ({
|
|
|
134
147
|
applyPropositions,
|
|
135
148
|
setTargetMigration,
|
|
136
149
|
mergeDecisionsMeta,
|
|
137
|
-
renderedPropositions
|
|
150
|
+
renderedPropositions,
|
|
151
|
+
onDecisionHandler
|
|
138
152
|
});
|
|
139
153
|
};
|
|
140
154
|
createPersonalization.namespace = "Personalization";
|
package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -9,6 +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
|
-
|
|
13
|
-
export const
|
|
14
|
-
export const INTERACT = "decisioning.propositionInteract";
|
|
12
|
+
export const TEXT_HTML = "text/html";
|
|
13
|
+
export const APPLICATION_JSON = "application/json";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -9,8 +9,4 @@ 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
|
-
|
|
13
|
-
export const PropositionEventType = {
|
|
14
|
-
DISPLAY: "display",
|
|
15
|
-
INTERACT: "interact"
|
|
16
|
-
};
|
|
12
|
+
export const ADOBE_JOURNEY_OPTIMIZER = "AJO";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 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
|
+
|
|
13
|
+
export const DISPLAY = "decisioning.propositionDisplay";
|
|
14
|
+
export const INTERACT = "decisioning.propositionInteract";
|
|
15
|
+
export const TRIGGER = "decisioning.propositionTrigger";
|
|
16
|
+
export const DISMISS = "decisioning.propositionDismiss";
|
|
17
|
+
export const EVENT_TYPE_TRUE = 1;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
export const PERSONALIZATION_DECISIONS_HANDLE = "personalization:decisions";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 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
|
+
|
|
13
|
+
import { DISPLAY, INTERACT, TRIGGER, DISMISS } from "./eventType";
|
|
14
|
+
export const PropositionEventType = {
|
|
15
|
+
DISPLAY: "display",
|
|
16
|
+
INTERACT: "interact",
|
|
17
|
+
TRIGGER: "trigger",
|
|
18
|
+
DISMISS: "dismiss"
|
|
19
|
+
};
|
|
20
|
+
const eventTypeToPropositionEventTypeMapping = {
|
|
21
|
+
[DISPLAY]: PropositionEventType.DISPLAY,
|
|
22
|
+
[INTERACT]: PropositionEventType.INTERACT,
|
|
23
|
+
[TRIGGER]: PropositionEventType.TRIGGER,
|
|
24
|
+
[DISMISS]: PropositionEventType.DISMISS
|
|
25
|
+
};
|
|
26
|
+
const propositionEventTypeToEventTypeMapping = {
|
|
27
|
+
[PropositionEventType.DISPLAY]: DISPLAY,
|
|
28
|
+
[PropositionEventType.INTERACT]: INTERACT,
|
|
29
|
+
[PropositionEventType.TRIGGER]: TRIGGER,
|
|
30
|
+
[PropositionEventType.DISMISS]: DISMISS
|
|
31
|
+
};
|
|
32
|
+
export const getPropositionEventType = eventType => eventTypeToPropositionEventTypeMapping[eventType];
|
|
33
|
+
export const getEventType = propositionEventType => propositionEventTypeToEventTypeMapping[propositionEventType];
|
|
@@ -14,5 +14,9 @@ export const DEFAULT_CONTENT_ITEM = "https://ns.adobe.com/personalization/defaul
|
|
|
14
14
|
export const DOM_ACTION = "https://ns.adobe.com/personalization/dom-action";
|
|
15
15
|
export const HTML_CONTENT_ITEM = "https://ns.adobe.com/personalization/html-content-item";
|
|
16
16
|
export const JSON_CONTENT_ITEM = "https://ns.adobe.com/personalization/json-content-item";
|
|
17
|
+
export const RULESET_ITEM = "https://ns.adobe.com/personalization/ruleset-item";
|
|
17
18
|
export const REDIRECT_ITEM = "https://ns.adobe.com/personalization/redirect-item";
|
|
19
|
+
export const MESSAGE_IN_APP = "https://ns.adobe.com/personalization/message/in-app";
|
|
20
|
+
export const MESSAGE_FEED_ITEM = "https://ns.adobe.com/personalization/message/feed-item";
|
|
21
|
+
export const MESSAGE_NATIVE_ALERT = "https://ns.adobe.com/personalization/message/native-alert";
|
|
18
22
|
export const MEASUREMENT_SCHEMA = "https://ns.adobe.com/personalization/measurement";
|
|
@@ -21,8 +21,9 @@ import createContext from "../components/Context";
|
|
|
21
21
|
import createPrivacy from "../components/Privacy";
|
|
22
22
|
import createEventMerge from "../components/EventMerge";
|
|
23
23
|
import createLibraryInfo from "../components/LibraryInfo";
|
|
24
|
+
import createDecisioningEngine from "../components/DecisioningEngine";
|
|
24
25
|
import createMachineLearning from "../components/MachineLearning";
|
|
25
26
|
|
|
26
27
|
// TODO: Register the Components here statically for now. They might be registered differently.
|
|
27
28
|
// TODO: Figure out how sub-components will be made available/registered
|
|
28
|
-
export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning];
|
|
29
|
+
export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning, createDecisioningEngine];
|
|
@@ -35,6 +35,23 @@ export default (() => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const event = {
|
|
38
|
+
hasQuery() {
|
|
39
|
+
return Object.prototype.hasOwnProperty.call(this.getContent(), "query");
|
|
40
|
+
},
|
|
41
|
+
getContent() {
|
|
42
|
+
const currentContent = JSON.parse(JSON.stringify(content));
|
|
43
|
+
if (userXdm) {
|
|
44
|
+
deepAssign(currentContent, {
|
|
45
|
+
xdm: userXdm
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (userData) {
|
|
49
|
+
deepAssign(currentContent, {
|
|
50
|
+
data: userData
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return currentContent;
|
|
54
|
+
},
|
|
38
55
|
setUserXdm(value) {
|
|
39
56
|
throwIfEventFinalized("setUserXdm");
|
|
40
57
|
userXdm = value;
|
|
@@ -51,6 +68,14 @@ export default (() => {
|
|
|
51
68
|
});
|
|
52
69
|
}
|
|
53
70
|
},
|
|
71
|
+
mergeData(data) {
|
|
72
|
+
throwIfEventFinalized("mergeData");
|
|
73
|
+
if (data) {
|
|
74
|
+
deepAssign(content, {
|
|
75
|
+
data
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
},
|
|
54
79
|
mergeMeta(meta) {
|
|
55
80
|
throwIfEventFinalized("mergeMeta");
|
|
56
81
|
if (meta) {
|
|
@@ -83,7 +108,7 @@ export default (() => {
|
|
|
83
108
|
content.xdm._experience.decisioning.propositions = newPropositions;
|
|
84
109
|
}
|
|
85
110
|
if (userData) {
|
|
86
|
-
|
|
111
|
+
event.mergeData(userData);
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
// the event should already be considered finalized in case onBeforeEventSend throws an error
|
|
@@ -101,6 +101,7 @@ export default (({
|
|
|
101
101
|
applyResponse(event, options = {}) {
|
|
102
102
|
const {
|
|
103
103
|
renderDecisions = false,
|
|
104
|
+
decisionContext = {},
|
|
104
105
|
responseHeaders = {},
|
|
105
106
|
responseBody = {
|
|
106
107
|
handle: []
|
|
@@ -115,6 +116,7 @@ export default (({
|
|
|
115
116
|
return lifecycle.onBeforeEvent({
|
|
116
117
|
event,
|
|
117
118
|
renderDecisions,
|
|
119
|
+
decisionContext,
|
|
118
120
|
decisionScopes: [PAGE_WIDE_SCOPE],
|
|
119
121
|
personalization,
|
|
120
122
|
onResponse: onResponseCallbackAggregator.add,
|
|
@@ -29,7 +29,10 @@ const hookNames = [
|
|
|
29
29
|
// { response } is passed as the parameter)
|
|
30
30
|
"onRequestFailure",
|
|
31
31
|
// A user clicked on an element.
|
|
32
|
-
"onClick"
|
|
32
|
+
"onClick",
|
|
33
|
+
// Called by DecisioningEngine when a ruleset is satisfied with a list of
|
|
34
|
+
// propositions
|
|
35
|
+
"onDecision"];
|
|
33
36
|
const createHook = (componentRegistry, hookName) => {
|
|
34
37
|
return (...args) => {
|
|
35
38
|
return Promise.all(componentRegistry.getLifecycleCallbacks(hookName).map(callback => {
|
|
@@ -9,12 +9,13 @@ 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
|
-
|
|
12
|
+
|
|
13
|
+
import { assignConcatArrayValues } from "../../utils";
|
|
13
14
|
export default (returnValues => {
|
|
14
15
|
// Merges all returned objects from all `onResponse` callbacks into
|
|
15
16
|
// a single object that can later be returned to the customer.
|
|
16
17
|
const lifecycleOnResponseReturnValues = returnValues.shift() || [];
|
|
17
18
|
const consumerOnResponseReturnValues = returnValues.shift() || [];
|
|
18
19
|
const lifecycleOnBeforeRequestReturnValues = returnValues;
|
|
19
|
-
return
|
|
20
|
+
return assignConcatArrayValues({}, ...lifecycleOnResponseReturnValues, ...consumerOnResponseReturnValues, ...lifecycleOnBeforeRequestReturnValues);
|
|
20
21
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 assign from "./assign";
|
|
13
|
+
import isObject from "./isObject";
|
|
14
|
+
export default ((...values) => {
|
|
15
|
+
if (values.length < 2) {
|
|
16
|
+
// if the number of args is 0 or 1, just use the default behavior from Object.assign
|
|
17
|
+
return assign(...values);
|
|
18
|
+
}
|
|
19
|
+
return values.reduce((accumulator, currentValue) => {
|
|
20
|
+
if (isObject(currentValue)) {
|
|
21
|
+
Object.keys(currentValue).forEach(key => {
|
|
22
|
+
if (Array.isArray(currentValue[key])) {
|
|
23
|
+
if (Array.isArray(accumulator[key])) {
|
|
24
|
+
accumulator[key].push(...currentValue[key]);
|
|
25
|
+
} else {
|
|
26
|
+
// clone the array so the original isn't modified.
|
|
27
|
+
accumulator[key] = [...currentValue[key]];
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
accumulator[key] = currentValue[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return accumulator;
|
|
35
|
+
}); // no default value to pass into reduce because we want to skip the first value
|
|
36
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 { values } from "./index";
|
|
13
|
+
const defaultPreprocessor = (params, ...args) => {
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
|
18
|
+
const defaultEmissionCondition = (params, ...args) => true;
|
|
19
|
+
const createSubscription = () => {
|
|
20
|
+
let preprocessor = defaultPreprocessor;
|
|
21
|
+
let emissionCondition = defaultEmissionCondition;
|
|
22
|
+
let counter = 0;
|
|
23
|
+
const subscriptions = {};
|
|
24
|
+
const createUnsubscribe = id => {
|
|
25
|
+
return () => {
|
|
26
|
+
delete subscriptions[id];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const add = (callback, params = undefined) => {
|
|
30
|
+
if (typeof callback !== "function") {
|
|
31
|
+
return () => undefined;
|
|
32
|
+
}
|
|
33
|
+
counter += 1;
|
|
34
|
+
subscriptions[counter] = {
|
|
35
|
+
callback,
|
|
36
|
+
params
|
|
37
|
+
};
|
|
38
|
+
return createUnsubscribe(counter);
|
|
39
|
+
};
|
|
40
|
+
const setEmissionPreprocessor = value => {
|
|
41
|
+
if (typeof value === "function") {
|
|
42
|
+
preprocessor = value;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const setEmissionCondition = value => {
|
|
46
|
+
if (typeof value === "function") {
|
|
47
|
+
emissionCondition = value;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const emit = (...args) => {
|
|
51
|
+
values(subscriptions).forEach(({
|
|
52
|
+
callback,
|
|
53
|
+
params
|
|
54
|
+
}) => {
|
|
55
|
+
const result = preprocessor(params, ...args);
|
|
56
|
+
if (emissionCondition(params, ...result)) {
|
|
57
|
+
callback(...result);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const hasSubscriptions = () => Object.keys(subscriptions).length > 0;
|
|
62
|
+
return {
|
|
63
|
+
add,
|
|
64
|
+
emit,
|
|
65
|
+
hasSubscriptions,
|
|
66
|
+
setEmissionPreprocessor,
|
|
67
|
+
setEmissionCondition
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export default createSubscription;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
export default ((fn, delay = 150) => {
|
|
13
|
+
let timer;
|
|
14
|
+
return (...args) => {
|
|
15
|
+
if (timer) {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
timer = setTimeout(() => {
|
|
19
|
+
fn(...args);
|
|
20
|
+
}, delay);
|
|
21
|
+
};
|
|
22
|
+
});
|
|
@@ -17,7 +17,7 @@ const splitWithShadow = selector => {
|
|
|
17
17
|
return selector.split(SHADOW_SEPARATOR);
|
|
18
18
|
};
|
|
19
19
|
const transformPrefix = (parent, selector) => {
|
|
20
|
-
const result = selector
|
|
20
|
+
const result = selector;
|
|
21
21
|
const hasChildCombinatorPrefix = startsWith(result, ">");
|
|
22
22
|
if (!hasChildCombinatorPrefix) {
|
|
23
23
|
return result;
|
|
@@ -45,8 +45,15 @@ export default ((context, selector) => {
|
|
|
45
45
|
// find each subselector element based on the previously selected node's shadowRoot
|
|
46
46
|
let parent = context;
|
|
47
47
|
for (let i = 0; i < parts.length; i += 1) {
|
|
48
|
-
const part =
|
|
49
|
-
|
|
48
|
+
const part = parts[i].trim();
|
|
49
|
+
// if part is empty, it means there's a chained :eq:shadow selector
|
|
50
|
+
if (part === "" && parent.shadowRoot) {
|
|
51
|
+
parent = parent.shadowRoot;
|
|
52
|
+
// eslint-disable-next-line no-continue
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const prefixed = transformPrefix(parent, part);
|
|
56
|
+
const partNode = querySelectorAll(parent, prefixed);
|
|
50
57
|
if (partNode.length === 0 || !partNode[0] || !partNode[0].shadowRoot) {
|
|
51
58
|
return partNode;
|
|
52
59
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
const flattenArray = (items = []) => {
|
|
13
|
+
const flat = [];
|
|
14
|
+
if (!Array.isArray(items)) {
|
|
15
|
+
return items;
|
|
16
|
+
}
|
|
17
|
+
items.forEach(item => {
|
|
18
|
+
if (Array.isArray(item)) {
|
|
19
|
+
flat.push(...flattenArray(item));
|
|
20
|
+
} else {
|
|
21
|
+
flat.push(item);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return flat;
|
|
25
|
+
};
|
|
26
|
+
export default flattenArray;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
const isPlainObject = obj => obj !== null && typeof obj === "object" && Object.getPrototypeOf(obj) === Object.prototype;
|
|
13
|
+
const flattenObject = (obj, result = {}, keys = []) => {
|
|
14
|
+
Object.keys(obj).forEach(key => {
|
|
15
|
+
if (isPlainObject(obj[key]) || Array.isArray(obj[key])) {
|
|
16
|
+
flattenObject(obj[key], result, [...keys, key]);
|
|
17
|
+
} else {
|
|
18
|
+
result[[...keys, key].join(".")] = obj[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
export default (obj => {
|
|
24
|
+
if (!isPlainObject(obj)) {
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
return flattenObject(obj);
|
|
28
|
+
});
|
package/libEs6/utils/index.js
CHANGED
|
@@ -13,6 +13,7 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
// Please keep in alphabetical order.
|
|
14
14
|
export { default as areThirdPartyCookiesSupportedByDefault } from "./areThirdPartyCookiesSupportedByDefault";
|
|
15
15
|
export { default as assign } from "./assign";
|
|
16
|
+
export { default as assignConcatArrayValues } from "./assignConcatArrayValues";
|
|
16
17
|
export { default as assignIf } from "./assignIf";
|
|
17
18
|
export { default as clone } from "./clone";
|
|
18
19
|
export { default as cookieJar } from "./cookieJar";
|
|
@@ -52,6 +53,7 @@ export { default as isString } from "./isString";
|
|
|
52
53
|
export { default as memoize } from "./memoize";
|
|
53
54
|
export { default as noop } from "./noop";
|
|
54
55
|
export { default as padStart } from "./padStart";
|
|
56
|
+
export { default as parseUrl } from "./parseUrl";
|
|
55
57
|
export { default as prepareConfigOverridesForEdge } from "./prepareConfigOverridesForEdge";
|
|
56
58
|
export { default as queryString } from "./querystring";
|
|
57
59
|
export { default as sanitizeOrgIdForCookieName } from "./sanitizeOrgIdForCookieName";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 parseUri from "parse-uri";
|
|
13
|
+
import isString from "./isString";
|
|
14
|
+
const parseDomainBasic = host => {
|
|
15
|
+
const result = {};
|
|
16
|
+
const domainParts = host.split(".");
|
|
17
|
+
switch (domainParts.length) {
|
|
18
|
+
case 1:
|
|
19
|
+
result.subdomain = "";
|
|
20
|
+
result.domain = host;
|
|
21
|
+
result.topLevelDomain = "";
|
|
22
|
+
break;
|
|
23
|
+
case 2:
|
|
24
|
+
result.subdomain = "";
|
|
25
|
+
result.domain = host;
|
|
26
|
+
result.topLevelDomain = domainParts[1];
|
|
27
|
+
break;
|
|
28
|
+
case 3:
|
|
29
|
+
result.subdomain = domainParts[0] === "www" ? "" : domainParts[0];
|
|
30
|
+
result.domain = host;
|
|
31
|
+
result.topLevelDomain = domainParts[2];
|
|
32
|
+
break;
|
|
33
|
+
case 4:
|
|
34
|
+
result.subdomain = domainParts[0] === "www" ? "" : domainParts[0];
|
|
35
|
+
result.domain = host;
|
|
36
|
+
result.topLevelDomain = `${domainParts[2]}.${domainParts[3]}`;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
const parseUrl = (url, parseDomain = parseDomainBasic) => {
|
|
44
|
+
if (!isString(url)) {
|
|
45
|
+
// eslint-disable-next-line no-param-reassign
|
|
46
|
+
url = "";
|
|
47
|
+
}
|
|
48
|
+
const parsed = parseUri(url) || {};
|
|
49
|
+
const {
|
|
50
|
+
host = "",
|
|
51
|
+
path = "",
|
|
52
|
+
query = "",
|
|
53
|
+
anchor = ""
|
|
54
|
+
} = parsed;
|
|
55
|
+
return {
|
|
56
|
+
path,
|
|
57
|
+
query,
|
|
58
|
+
fragment: anchor,
|
|
59
|
+
...parseDomain(host)
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export default parseUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.1-beta.0",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"main": "libEs5/index.js",
|
|
6
6
|
"module": "libEs6/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"format": "prettier --write \"*.{html,js}\" \"{sandbox,src,test,scripts}/**/*.{html,js}\"",
|
|
15
15
|
"test": "npm run test:unit && npm run test:scripts && npm run test:functional",
|
|
16
16
|
"test:unit": "karma start --single-run",
|
|
17
|
+
"test:unit:debug": "karma start --browsers=Chrome --single-run=false --debug",
|
|
17
18
|
"test:unit:watch": "karma start",
|
|
18
19
|
"test:unit:saucelabs:local": "karma start karma.saucelabs.conf.js --single-run",
|
|
19
20
|
"test:unit:coverage": "karma start --single-run --reporters spec,coverage",
|
|
@@ -58,15 +59,18 @@
|
|
|
58
59
|
}
|
|
59
60
|
],
|
|
60
61
|
"dependencies": {
|
|
62
|
+
"@adobe/aep-rules-engine": "^2.0.2",
|
|
63
|
+
"@adobe/reactor-cookie": "^1.0.0",
|
|
61
64
|
"@adobe/reactor-load-script": "^1.1.1",
|
|
62
65
|
"@adobe/reactor-object-assign": "^1.0.0",
|
|
63
66
|
"@adobe/reactor-query-string": "^1.0.0",
|
|
64
67
|
"css.escape": "^1.5.1",
|
|
65
68
|
"js-cookie": "2.2.1",
|
|
69
|
+
"parse-uri": "^1.0.7",
|
|
66
70
|
"uuid": "^3.3.2"
|
|
67
71
|
},
|
|
68
72
|
"devDependencies": {
|
|
69
|
-
"@adobe/alloy": "^2.19.0
|
|
73
|
+
"@adobe/alloy": "^2.19.0",
|
|
70
74
|
"@babel/cli": "^7.12.8",
|
|
71
75
|
"@babel/core": "^7.2.2",
|
|
72
76
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|