@adobe/alloy 2.18.0 → 2.19.0-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/libEs5/components/DataCollector/index.js +4 -2
- package/libEs5/components/DataCollector/validateApplyResponse.js +6 -1
- package/libEs5/components/DataCollector/validateUserEventOptions.js +5 -1
- package/libEs5/components/Personalization/createApplyPropositions.js +38 -25
- package/libEs5/components/Personalization/createComponent.js +22 -14
- package/libEs5/components/Personalization/createFetchDataHandler.js +83 -18
- package/libEs5/components/Personalization/createOnClickHandler.js +2 -2
- package/libEs5/components/Personalization/createPendingNotificationsHandler.js +29 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -2
- package/libEs5/components/Personalization/createViewCacheManager.js +60 -21
- package/libEs5/components/Personalization/createViewChangeHandler.js +25 -30
- package/libEs5/components/Personalization/dom-actions/action.js +5 -20
- package/{libEs6/components/Personalization/utils/composePersonalizationResultingObject.js → libEs5/components/Personalization/dom-actions/createPreprocess.js} +17 -13
- package/libEs5/components/Personalization/dom-actions/index.js +1 -9
- package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +2 -10
- package/libEs5/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
- package/libEs5/components/Personalization/handlers/createProcessDomAction.js +61 -0
- package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +43 -0
- package/libEs5/components/Personalization/handlers/createProcessPropositions.js +240 -0
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +45 -0
- package/libEs5/components/Personalization/handlers/injectCreateProposition.js +124 -0
- package/libEs5/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +8 -4
- package/libEs5/components/Personalization/index.js +70 -53
- package/libEs5/components/Personalization/utils/createAsyncArray.js +42 -0
- package/libEs5/components/Personalization/validateApplyPropositionsOptions.js +3 -2
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/createEvent.js +31 -13
- package/libEs5/core/createEventManager.js +3 -2
- package/libEs5/{components/Personalization/utils/composePersonalizationResultingObject.js → utils/deduplicateArray.js} +16 -14
- package/libEs5/utils/index.js +8 -0
- package/libEs6/components/DataCollector/index.js +4 -2
- package/libEs6/components/DataCollector/validateApplyResponse.js +6 -1
- package/libEs6/components/DataCollector/validateUserEventOptions.js +5 -1
- package/libEs6/components/Personalization/createApplyPropositions.js +25 -24
- package/libEs6/components/Personalization/createComponent.js +23 -15
- package/libEs6/components/Personalization/createFetchDataHandler.js +65 -9
- package/libEs6/components/Personalization/createOnClickHandler.js +3 -3
- package/{libEs5/components/Personalization/dom-actions/click.js → libEs6/components/Personalization/createPendingNotificationsHandler.js} +11 -15
- package/libEs6/components/Personalization/createPersonalizationDetails.js +10 -2
- package/libEs6/components/Personalization/createViewCacheManager.js +55 -20
- package/libEs6/components/Personalization/createViewChangeHandler.js +25 -28
- package/libEs6/components/Personalization/dom-actions/action.js +4 -12
- package/libEs6/components/Personalization/dom-actions/{click.js → createPreprocess.js} +8 -11
- package/libEs6/components/Personalization/dom-actions/index.js +1 -2
- package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +3 -7
- package/libEs6/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
- package/libEs6/components/Personalization/handlers/createProcessDomAction.js +53 -0
- package/libEs6/components/Personalization/handlers/createProcessHtmlContent.js +37 -0
- package/libEs6/components/Personalization/handlers/createProcessPropositions.js +202 -0
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +39 -0
- package/libEs6/components/Personalization/handlers/injectCreateProposition.js +129 -0
- package/libEs6/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +7 -3
- package/libEs6/components/Personalization/index.js +60 -40
- package/libEs6/components/Personalization/utils/createAsyncArray.js +37 -0
- package/libEs6/components/Personalization/validateApplyPropositionsOptions.js +4 -3
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/createEvent.js +19 -3
- package/libEs6/core/createEventManager.js +3 -2
- package/libEs6/utils/deduplicateArray.js +26 -0
- package/libEs6/utils/index.js +1 -0
- package/package.json +2 -2
- package/libEs5/components/Personalization/createAutoRenderingHandler.js +0 -92
- package/libEs5/components/Personalization/createExecuteDecisions.js +0 -89
- package/libEs5/components/Personalization/createNonRenderingHandler.js +0 -66
- package/libEs5/components/Personalization/createOnResponseHandler.js +0 -73
- package/libEs5/components/Personalization/createRedirectHandler.js +0 -58
- package/libEs5/components/Personalization/dom-actions/executeActions.js +0 -75
- package/libEs5/components/Personalization/groupDecisions.js +0 -160
- package/libEs6/components/Personalization/createAutoRenderingHandler.js +0 -84
- package/libEs6/components/Personalization/createExecuteDecisions.js +0 -77
- package/libEs6/components/Personalization/createNonRenderingHandler.js +0 -56
- package/libEs6/components/Personalization/createOnResponseHandler.js +0 -68
- package/libEs6/components/Personalization/createRedirectHandler.js +0 -57
- package/libEs6/components/Personalization/dom-actions/executeActions.js +0 -66
- package/libEs6/components/Personalization/groupDecisions.js +0 -131
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _utils = require("../../../utils");
|
|
6
|
+
|
|
1
7
|
/*
|
|
2
8
|
Copyright 2023 Adobe. All rights reserved.
|
|
3
9
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -9,18 +15,16 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
15
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
16
|
governing permissions and limitations under the License.
|
|
11
17
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
renderAttempted: renderDecisions
|
|
18
|
-
})
|
|
19
|
-
};
|
|
18
|
+
var _default = function _default(preprocessors) {
|
|
19
|
+
return function (action) {
|
|
20
|
+
if (!action) {
|
|
21
|
+
return action;
|
|
22
|
+
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
return preprocessors.reduce(function (processed, fn) {
|
|
25
|
+
return (0, _utils.assign)(processed, fn(processed));
|
|
26
|
+
}, action);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
});
|
|
30
|
+
exports.default = _default;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "executeActions", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
get: function get() {
|
|
6
|
-
return _executeActions.default;
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
3
|
Object.defineProperty(exports, "initDomActionsModules", {
|
|
10
4
|
enumerable: true,
|
|
11
5
|
get: function get() {
|
|
@@ -13,6 +7,4 @@ Object.defineProperty(exports, "initDomActionsModules", {
|
|
|
13
7
|
}
|
|
14
8
|
});
|
|
15
9
|
|
|
16
|
-
var _initDomActionsModules = require("./initDomActionsModules");
|
|
17
|
-
|
|
18
|
-
var _executeActions = require("./executeActions");
|
|
10
|
+
var _initDomActionsModules = require("./initDomActionsModules");
|
|
@@ -17,7 +17,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
17
17
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
|
-
var _default = function _default(
|
|
20
|
+
var _default = function _default() {
|
|
21
21
|
return {
|
|
22
22
|
setHtml: (0, _action.createAction)(_action.setHtml),
|
|
23
23
|
customCode: (0, _action.createAction)(_action.prependHtml),
|
|
@@ -33,15 +33,7 @@ var _default = function _default(store) {
|
|
|
33
33
|
insertBefore: (0, _action.createAction)(_action.insertHtmlBefore),
|
|
34
34
|
replaceHtml: (0, _action.createAction)(_action.replaceHtml),
|
|
35
35
|
prependHtml: (0, _action.createAction)(_action.prependHtml),
|
|
36
|
-
appendHtml: (0, _action.createAction)(_action.appendHtml)
|
|
37
|
-
click: function click(settings) {
|
|
38
|
-
return (0, _action.click)(settings, store);
|
|
39
|
-
},
|
|
40
|
-
defaultContent: function defaultContent(settings) {
|
|
41
|
-
return Promise.resolve({
|
|
42
|
-
meta: settings.meta
|
|
43
|
-
});
|
|
44
|
-
}
|
|
36
|
+
appendHtml: (0, _action.createAction)(_action.appendHtml)
|
|
45
37
|
};
|
|
46
38
|
};
|
|
47
39
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
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 = function _default(_ref) {
|
|
17
|
+
var modules = _ref.modules,
|
|
18
|
+
logger = _ref.logger,
|
|
19
|
+
storeClickMetrics = _ref.storeClickMetrics;
|
|
20
|
+
return function (item) {
|
|
21
|
+
var _ref2 = item.getData() || {},
|
|
22
|
+
type = _ref2.type,
|
|
23
|
+
selector = _ref2.selector;
|
|
24
|
+
|
|
25
|
+
if (!type) {
|
|
26
|
+
logger.warn("Invalid DOM action data: missing type.", item.getData());
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (type === "click") {
|
|
31
|
+
if (!selector) {
|
|
32
|
+
logger.warn("Invalid DOM action data: missing selector.", item.getData());
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
storeClickMetrics({
|
|
37
|
+
selector: selector,
|
|
38
|
+
meta: item.getMeta()
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
setRenderAttempted: true,
|
|
42
|
+
includeInNotification: false
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!modules[type]) {
|
|
47
|
+
logger.warn("Invalid DOM action data: unknown type.", item.getData());
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
render: function render() {
|
|
53
|
+
return modules[type](item.getData());
|
|
54
|
+
},
|
|
55
|
+
setRenderAttempted: true,
|
|
56
|
+
includeInNotification: true
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.default = _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
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 = function _default(_ref) {
|
|
17
|
+
var modules = _ref.modules,
|
|
18
|
+
logger = _ref.logger;
|
|
19
|
+
return function (item) {
|
|
20
|
+
var _ref2 = item.getData() || {},
|
|
21
|
+
type = _ref2.type,
|
|
22
|
+
selector = _ref2.selector;
|
|
23
|
+
|
|
24
|
+
if (!selector || !type) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!modules[type]) {
|
|
29
|
+
logger.warn("Invalid HTML content data", item.getData());
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
render: function render() {
|
|
35
|
+
modules[type](item.getData());
|
|
36
|
+
},
|
|
37
|
+
setRenderAttempted: true,
|
|
38
|
+
includeInNotification: true
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.default = _default;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
|
|
7
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
|
|
13
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
+
|
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
19
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
|
|
23
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
var _default = function _default(_ref) {
|
|
29
|
+
var schemaProcessors = _ref.schemaProcessors,
|
|
30
|
+
logger = _ref.logger;
|
|
31
|
+
|
|
32
|
+
var wrapRenderWithLogging = function wrapRenderWithLogging(render, item) {
|
|
33
|
+
return function () {
|
|
34
|
+
return Promise.resolve().then(render).then(function () {
|
|
35
|
+
if (logger.enabled) {
|
|
36
|
+
logger.info("Action " + item.toString() + " executed.");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
}).catch(function (error) {
|
|
41
|
+
if (logger.enabled) {
|
|
42
|
+
var message = error.message,
|
|
43
|
+
stack = error.stack;
|
|
44
|
+
var errorMessage = "Failed to execute action " + item.toString() + ". " + message + " " + stack;
|
|
45
|
+
logger.error(errorMessage);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var renderItems = function renderItems(renderers, meta) {
|
|
54
|
+
return Promise.all(renderers.map(function (renderer) {
|
|
55
|
+
return renderer();
|
|
56
|
+
})).then(function (successes) {
|
|
57
|
+
// as long as at least one renderer succeeds, we want to add the notification
|
|
58
|
+
// to the display notifications
|
|
59
|
+
if (!successes.includes(true)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return meta;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var processItem = function processItem(item) {
|
|
68
|
+
var processor = schemaProcessors[item.getSchema()];
|
|
69
|
+
|
|
70
|
+
if (!processor) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return processor(item);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var processItems = function processItems(_ref2) {
|
|
78
|
+
var existingRenderers = _ref2.renderers,
|
|
79
|
+
existingReturnedPropositions = _ref2.returnedPropositions,
|
|
80
|
+
existingReturnedDecisions = _ref2.returnedDecisions,
|
|
81
|
+
items = _ref2.items,
|
|
82
|
+
proposition = _ref2.proposition;
|
|
83
|
+
|
|
84
|
+
var renderers = _toConsumableArray(existingRenderers);
|
|
85
|
+
|
|
86
|
+
var returnedPropositions = _toConsumableArray(existingReturnedPropositions);
|
|
87
|
+
|
|
88
|
+
var returnedDecisions = _toConsumableArray(existingReturnedDecisions);
|
|
89
|
+
|
|
90
|
+
var renderedItems = [];
|
|
91
|
+
var nonRenderedItems = [];
|
|
92
|
+
var itemRenderers = [];
|
|
93
|
+
var atLeastOneWithNotification = false;
|
|
94
|
+
var render;
|
|
95
|
+
var setRenderAttempted;
|
|
96
|
+
var includeInNotification;
|
|
97
|
+
var onlyRenderThis = false;
|
|
98
|
+
var i = 0;
|
|
99
|
+
var item;
|
|
100
|
+
|
|
101
|
+
while (items.length > i) {
|
|
102
|
+
item = items[i];
|
|
103
|
+
|
|
104
|
+
var _processItem = processItem(item);
|
|
105
|
+
|
|
106
|
+
render = _processItem.render;
|
|
107
|
+
setRenderAttempted = _processItem.setRenderAttempted;
|
|
108
|
+
includeInNotification = _processItem.includeInNotification;
|
|
109
|
+
onlyRenderThis = _processItem.onlyRenderThis;
|
|
110
|
+
|
|
111
|
+
if (onlyRenderThis) {
|
|
112
|
+
returnedPropositions = [];
|
|
113
|
+
returnedDecisions = [];
|
|
114
|
+
|
|
115
|
+
if (setRenderAttempted) {
|
|
116
|
+
renderedItems = [item];
|
|
117
|
+
nonRenderedItems = [];
|
|
118
|
+
} else {
|
|
119
|
+
renderedItems = [];
|
|
120
|
+
nonRenderedItems = [item];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
renderers = [];
|
|
124
|
+
itemRenderers = [render];
|
|
125
|
+
atLeastOneWithNotification = includeInNotification;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (render) {
|
|
130
|
+
itemRenderers.push(wrapRenderWithLogging(render, item));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (includeInNotification) {
|
|
134
|
+
atLeastOneWithNotification = true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (setRenderAttempted) {
|
|
138
|
+
renderedItems.push(item);
|
|
139
|
+
} else {
|
|
140
|
+
nonRenderedItems.push(item);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
i += 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (itemRenderers.length > 0) {
|
|
147
|
+
var meta = atLeastOneWithNotification ? proposition.getNotification() : undefined;
|
|
148
|
+
renderers.push(function () {
|
|
149
|
+
return renderItems(itemRenderers, meta);
|
|
150
|
+
});
|
|
151
|
+
} else if (atLeastOneWithNotification) {
|
|
152
|
+
renderers.push(function () {
|
|
153
|
+
return proposition.getNotification();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (renderedItems.length > 0) {
|
|
158
|
+
proposition.addToReturnValues(returnedPropositions, returnedDecisions, renderedItems, true);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (nonRenderedItems.length > 0) {
|
|
162
|
+
proposition.addToReturnValues(returnedPropositions, returnedDecisions, nonRenderedItems, false);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
renderers: renderers,
|
|
167
|
+
returnedPropositions: returnedPropositions,
|
|
168
|
+
returnedDecisions: returnedDecisions,
|
|
169
|
+
onlyRenderThis: onlyRenderThis
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return function (renderPropositions) {
|
|
174
|
+
var nonRenderPropositions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
175
|
+
var renderers = [];
|
|
176
|
+
var returnedPropositions = [];
|
|
177
|
+
var returnedDecisions = [];
|
|
178
|
+
var onlyRenderThis;
|
|
179
|
+
var i = 0;
|
|
180
|
+
var proposition;
|
|
181
|
+
var items;
|
|
182
|
+
|
|
183
|
+
while (renderPropositions.length > i) {
|
|
184
|
+
proposition = renderPropositions[i];
|
|
185
|
+
items = proposition.getItems();
|
|
186
|
+
|
|
187
|
+
var _processItems = processItems({
|
|
188
|
+
renderers: renderers,
|
|
189
|
+
returnedPropositions: returnedPropositions,
|
|
190
|
+
returnedDecisions: returnedDecisions,
|
|
191
|
+
items: items,
|
|
192
|
+
proposition: proposition
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
renderers = _processItems.renderers;
|
|
196
|
+
returnedPropositions = _processItems.returnedPropositions;
|
|
197
|
+
returnedDecisions = _processItems.returnedDecisions;
|
|
198
|
+
onlyRenderThis = _processItems.onlyRenderThis;
|
|
199
|
+
|
|
200
|
+
if (onlyRenderThis) {
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
i += 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (onlyRenderThis) {
|
|
208
|
+
// if onlyRenderThis is true, that means returnedPropositions and returnedDecisions
|
|
209
|
+
// only contains the proposition that triggered only rendering this. We need to
|
|
210
|
+
// add the other propositions to the returnedPropositions and returnedDecisions.
|
|
211
|
+
renderPropositions.forEach(function (p, index) {
|
|
212
|
+
if (index !== i) {
|
|
213
|
+
p.addToReturnValues(returnedPropositions, returnedDecisions, p.getItems(), false);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
nonRenderPropositions.forEach(function (p) {
|
|
219
|
+
p.addToReturnValues(returnedPropositions, returnedDecisions, p.getItems(), false);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
var render = function render() {
|
|
223
|
+
return Promise.all(renderers.map(function (renderer) {
|
|
224
|
+
return renderer();
|
|
225
|
+
})).then(function (metas) {
|
|
226
|
+
return metas.filter(function (meta) {
|
|
227
|
+
return meta;
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
returnedPropositions: returnedPropositions,
|
|
234
|
+
returnedDecisions: returnedDecisions,
|
|
235
|
+
render: render
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
exports.default = _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
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 = function _default(_ref) {
|
|
17
|
+
var logger = _ref.logger,
|
|
18
|
+
executeRedirect = _ref.executeRedirect,
|
|
19
|
+
collect = _ref.collect;
|
|
20
|
+
return function (item) {
|
|
21
|
+
var _ref2 = item.getData() || {},
|
|
22
|
+
content = _ref2.content;
|
|
23
|
+
|
|
24
|
+
if (!content) {
|
|
25
|
+
logger.warn("Invalid Redirect data", item.getData());
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var render = function render() {
|
|
30
|
+
return collect({
|
|
31
|
+
decisionsMeta: [item.getMeta()]
|
|
32
|
+
}).then(function () {
|
|
33
|
+
executeRedirect(content); // We've already sent the display notification, so don't return anything
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
render: render,
|
|
39
|
+
setRenderAttempted: true,
|
|
40
|
+
onlyRenderThis: true
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.default = _default;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _pageWideScope = require("../../../constants/pageWideScope");
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
|
|
11
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
|
|
13
|
+
var _default = function _default(_ref) {
|
|
14
|
+
var preprocess = _ref.preprocess,
|
|
15
|
+
isPageWideSurface = _ref.isPageWideSurface;
|
|
16
|
+
|
|
17
|
+
var createItem = function createItem(item, meta) {
|
|
18
|
+
var schema = item.schema,
|
|
19
|
+
data = item.data,
|
|
20
|
+
_item$characteristics = item.characteristics;
|
|
21
|
+
_item$characteristics = _item$characteristics === void 0 ? {} : _item$characteristics;
|
|
22
|
+
var trackingLabel = _item$characteristics.trackingLabel;
|
|
23
|
+
var processedData = preprocess(data);
|
|
24
|
+
|
|
25
|
+
if (trackingLabel) {
|
|
26
|
+
meta.trackingLabel = trackingLabel;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
getSchema: function getSchema() {
|
|
31
|
+
return schema;
|
|
32
|
+
},
|
|
33
|
+
getData: function getData() {
|
|
34
|
+
return processedData;
|
|
35
|
+
},
|
|
36
|
+
getMeta: function getMeta() {
|
|
37
|
+
return meta;
|
|
38
|
+
},
|
|
39
|
+
getOriginalItem: function getOriginalItem() {
|
|
40
|
+
return item;
|
|
41
|
+
},
|
|
42
|
+
toString: function toString() {
|
|
43
|
+
return JSON.stringify(item);
|
|
44
|
+
},
|
|
45
|
+
toJSON: function toJSON() {
|
|
46
|
+
return item;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return function (payload) {
|
|
52
|
+
var visibleInReturnedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
53
|
+
var id = payload.id,
|
|
54
|
+
scope = payload.scope,
|
|
55
|
+
scopeDetails = payload.scopeDetails,
|
|
56
|
+
_payload$items = payload.items,
|
|
57
|
+
items = _payload$items === void 0 ? [] : _payload$items;
|
|
58
|
+
|
|
59
|
+
var _ref2 = scopeDetails || {},
|
|
60
|
+
_ref2$characteristics = _ref2.characteristics;
|
|
61
|
+
|
|
62
|
+
_ref2$characteristics = _ref2$characteristics === void 0 ? {} : _ref2$characteristics;
|
|
63
|
+
var scopeType = _ref2$characteristics.scopeType;
|
|
64
|
+
return {
|
|
65
|
+
getScope: function getScope() {
|
|
66
|
+
if (!scope) {
|
|
67
|
+
return scope;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return scope;
|
|
71
|
+
},
|
|
72
|
+
getScopeType: function getScopeType() {
|
|
73
|
+
if (scope === _pageWideScope.default || isPageWideSurface(scope)) {
|
|
74
|
+
return "page";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (scopeType === "view") {
|
|
78
|
+
return "view";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return "proposition";
|
|
82
|
+
},
|
|
83
|
+
getItems: function getItems() {
|
|
84
|
+
return items.map(function (item) {
|
|
85
|
+
return createItem(item, {
|
|
86
|
+
id: id,
|
|
87
|
+
scope: scope,
|
|
88
|
+
scopeDetails: scopeDetails
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
getNotification: function getNotification() {
|
|
93
|
+
return {
|
|
94
|
+
id: id,
|
|
95
|
+
scope: scope,
|
|
96
|
+
scopeDetails: scopeDetails
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
toJSON: function toJSON() {
|
|
100
|
+
return payload;
|
|
101
|
+
},
|
|
102
|
+
addToReturnValues: function addToReturnValues(propositions, decisions, includedItems, renderAttempted) {
|
|
103
|
+
if (visibleInReturnedItems) {
|
|
104
|
+
propositions.push(_objectSpread(_objectSpread({}, payload), {}, {
|
|
105
|
+
items: includedItems.map(function (i) {
|
|
106
|
+
return i.getOriginalItem();
|
|
107
|
+
}),
|
|
108
|
+
renderAttempted: renderAttempted
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
if (!renderAttempted) {
|
|
112
|
+
decisions.push(_objectSpread(_objectSpread({}, payload), {}, {
|
|
113
|
+
items: includedItems.map(function (i) {
|
|
114
|
+
return i.getOriginalItem();
|
|
115
|
+
})
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
exports.default = _default;
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var _collectClicks = require("./collectClicks");
|
|
6
|
-
|
|
7
5
|
/*
|
|
8
|
-
Copyright
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
9
7
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
8
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
9
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -15,5 +13,11 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
14
|
governing permissions and limitations under the License.
|
|
17
15
|
*/
|
|
18
|
-
var _default =
|
|
16
|
+
var _default = function _default() {
|
|
17
|
+
return {
|
|
18
|
+
setRenderAttempted: true,
|
|
19
|
+
includeInNotification: true
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
exports.default = _default;
|