@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
|
@@ -109,12 +109,14 @@ var createDataCollector = function createDataCollector(_ref) {
|
|
|
109
109
|
_options$responseBody = options.responseBody,
|
|
110
110
|
responseBody = _options$responseBody === void 0 ? {
|
|
111
111
|
handle: []
|
|
112
|
-
} : _options$responseBody
|
|
112
|
+
} : _options$responseBody,
|
|
113
|
+
personalization = options.personalization;
|
|
113
114
|
var event = eventManager.createEvent();
|
|
114
115
|
return eventManager.applyResponse(event, {
|
|
115
116
|
renderDecisions: renderDecisions,
|
|
116
117
|
responseHeaders: responseHeaders,
|
|
117
|
-
responseBody: responseBody
|
|
118
|
+
responseBody: responseBody,
|
|
119
|
+
personalization: personalization
|
|
118
120
|
});
|
|
119
121
|
}
|
|
120
122
|
}
|
|
@@ -25,7 +25,12 @@ var _default = function _default(_ref) {
|
|
|
25
25
|
type: (0, _validation.string)().required(),
|
|
26
26
|
payload: (0, _validation.anything)().required()
|
|
27
27
|
})).required()
|
|
28
|
-
}).required()
|
|
28
|
+
}).required(),
|
|
29
|
+
personalization: (0, _validation.objectOf)({
|
|
30
|
+
sendDisplayNotifications: (0, _validation.boolean)().default(true)
|
|
31
|
+
}).default({
|
|
32
|
+
sendDisplayNotifications: true
|
|
33
|
+
})
|
|
29
34
|
}).noUnknownFields();
|
|
30
35
|
return validator(options);
|
|
31
36
|
};
|
|
@@ -37,7 +37,11 @@ var _default = function _default(_ref) {
|
|
|
37
37
|
decisionScopes: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems(),
|
|
38
38
|
personalization: (0, _validation.objectOf)({
|
|
39
39
|
decisionScopes: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems(),
|
|
40
|
-
surfaces: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems()
|
|
40
|
+
surfaces: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems(),
|
|
41
|
+
sendDisplayNotifications: (0, _validation.boolean)().default(true),
|
|
42
|
+
includePendingDisplayNotifications: (0, _validation.boolean)().default(false)
|
|
43
|
+
}).default({
|
|
44
|
+
sendDisplayNotifications: true
|
|
41
45
|
}),
|
|
42
46
|
datasetId: (0, _validation.string)(),
|
|
43
47
|
mergeId: (0, _validation.string)(),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports.default =
|
|
4
|
-
|
|
5
|
-
var _composePersonalizationResultingObject = require("./utils/composePersonalizationResultingObject");
|
|
3
|
+
exports.default = void 0;
|
|
6
4
|
|
|
7
5
|
var _utils = require("../../utils");
|
|
8
6
|
|
|
@@ -10,7 +8,17 @@ var _schema = require("./constants/schema");
|
|
|
10
8
|
|
|
11
9
|
var _pageWideScope = require("../../constants/pageWideScope");
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
|
|
13
|
+
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."); }
|
|
14
|
+
|
|
15
|
+
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); }
|
|
16
|
+
|
|
17
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
18
|
+
|
|
19
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
14
22
|
|
|
15
23
|
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; }
|
|
16
24
|
|
|
@@ -19,10 +27,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
19
27
|
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; }
|
|
20
28
|
|
|
21
29
|
var SUPPORTED_SCHEMAS = [_schema.DOM_ACTION, _schema.HTML_CONTENT_ITEM];
|
|
22
|
-
exports.SUPPORTED_SCHEMAS = SUPPORTED_SCHEMAS;
|
|
23
30
|
|
|
24
31
|
var _default = function _default(_ref) {
|
|
25
|
-
var
|
|
32
|
+
var processPropositions = _ref.processPropositions,
|
|
33
|
+
createProposition = _ref.createProposition,
|
|
34
|
+
pendingDisplayNotifications = _ref.pendingDisplayNotifications,
|
|
35
|
+
viewCache = _ref.viewCache;
|
|
26
36
|
|
|
27
37
|
var filterItemsPredicate = function filterItemsPredicate(item) {
|
|
28
38
|
return SUPPORTED_SCHEMAS.indexOf(item.schema) > -1;
|
|
@@ -80,31 +90,34 @@ var _default = function _default(_ref) {
|
|
|
80
90
|
});
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
|
|
84
|
-
var propositions = _ref4.propositions,
|
|
85
|
-
|
|
93
|
+
return function (_ref4) {
|
|
94
|
+
var _ref4$propositions = _ref4.propositions,
|
|
95
|
+
propositions = _ref4$propositions === void 0 ? [] : _ref4$propositions,
|
|
96
|
+
_ref4$metadata = _ref4.metadata,
|
|
97
|
+
metadata = _ref4$metadata === void 0 ? {} : _ref4$metadata,
|
|
98
|
+
viewName = _ref4.viewName;
|
|
86
99
|
var propositionsToExecute = preparePropositions({
|
|
87
100
|
propositions: propositions,
|
|
88
101
|
metadata: metadata
|
|
102
|
+
}).map(function (proposition) {
|
|
103
|
+
return createProposition(proposition);
|
|
89
104
|
});
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return function (_ref5) {
|
|
96
|
-
var propositions = _ref5.propositions,
|
|
97
|
-
_ref5$metadata = _ref5.metadata,
|
|
98
|
-
metadata = _ref5$metadata === void 0 ? {} : _ref5$metadata;
|
|
105
|
+
return Promise.resolve().then(function () {
|
|
106
|
+
if (viewName) {
|
|
107
|
+
return viewCache.getView(viewName);
|
|
108
|
+
}
|
|
99
109
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
110
|
+
return [];
|
|
111
|
+
}).then(function (additionalPropositions) {
|
|
112
|
+
var _processPropositions = processPropositions([].concat(_toConsumableArray(propositionsToExecute), _toConsumableArray(additionalPropositions))),
|
|
113
|
+
render = _processPropositions.render,
|
|
114
|
+
returnedPropositions = _processPropositions.returnedPropositions;
|
|
106
115
|
|
|
107
|
-
|
|
116
|
+
pendingDisplayNotifications.concat(render());
|
|
117
|
+
return {
|
|
118
|
+
propositions: returnedPropositions
|
|
119
|
+
};
|
|
120
|
+
});
|
|
108
121
|
};
|
|
109
122
|
};
|
|
110
123
|
|
|
@@ -32,7 +32,8 @@ var _default = function _default(_ref) {
|
|
|
32
32
|
viewCache = _ref.viewCache,
|
|
33
33
|
showContainers = _ref.showContainers,
|
|
34
34
|
applyPropositions = _ref.applyPropositions,
|
|
35
|
-
setTargetMigration = _ref.setTargetMigration
|
|
35
|
+
setTargetMigration = _ref.setTargetMigration,
|
|
36
|
+
pendingNotificationsHandler = _ref.pendingNotificationsHandler;
|
|
36
37
|
return {
|
|
37
38
|
lifecycle: {
|
|
38
39
|
onBeforeRequest: function onBeforeRequest(_ref2) {
|
|
@@ -67,7 +68,7 @@ var _default = function _default(_ref) {
|
|
|
67
68
|
mergeQuery(event, {
|
|
68
69
|
enabled: false
|
|
69
70
|
});
|
|
70
|
-
return;
|
|
71
|
+
return Promise.resolve();
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
var personalizationDetails = (0, _createPersonalizationDetails.default)({
|
|
@@ -76,34 +77,41 @@ var _default = function _default(_ref) {
|
|
|
76
77
|
decisionScopes: decisionScopes,
|
|
77
78
|
personalization: personalization,
|
|
78
79
|
event: event,
|
|
79
|
-
|
|
80
|
+
isCacheInitialized: viewCache.isInitialized(),
|
|
80
81
|
logger: logger
|
|
81
82
|
});
|
|
83
|
+
var handlerPromises = [];
|
|
84
|
+
|
|
85
|
+
if (personalizationDetails.shouldAddPendingDisplayNotifications()) {
|
|
86
|
+
handlerPromises.push(pendingNotificationsHandler({
|
|
87
|
+
event: event
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
82
90
|
|
|
83
91
|
if (personalizationDetails.shouldFetchData()) {
|
|
84
|
-
var
|
|
85
|
-
viewCache.storeViews(decisionsDeferred.promise);
|
|
92
|
+
var cacheUpdate = viewCache.createCacheUpdate(personalizationDetails.getViewName());
|
|
86
93
|
onRequestFailure(function () {
|
|
87
|
-
return
|
|
94
|
+
return cacheUpdate.cancel();
|
|
88
95
|
});
|
|
89
96
|
fetchDataHandler({
|
|
90
|
-
|
|
97
|
+
cacheUpdate: cacheUpdate,
|
|
91
98
|
personalizationDetails: personalizationDetails,
|
|
92
99
|
event: event,
|
|
93
100
|
onResponse: onResponse
|
|
94
101
|
});
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (personalizationDetails.shouldUseCachedData()) {
|
|
102
|
+
} else if (personalizationDetails.shouldUseCachedData()) {
|
|
99
103
|
// eslint-disable-next-line consistent-return
|
|
100
|
-
|
|
104
|
+
handlerPromises.push(viewChangeHandler({
|
|
101
105
|
personalizationDetails: personalizationDetails,
|
|
102
106
|
event: event,
|
|
103
107
|
onResponse: onResponse,
|
|
104
108
|
onRequestFailure: onRequestFailure
|
|
105
|
-
});
|
|
106
|
-
}
|
|
109
|
+
}));
|
|
110
|
+
} // We can wait for personalization to be applied and for
|
|
111
|
+
// the fetch data request to complete in parallel.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
return Promise.all(handlerPromises);
|
|
107
115
|
},
|
|
108
116
|
onClick: function onClick(_ref4) {
|
|
109
117
|
var event = _ref4.event,
|
|
@@ -2,24 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
var _utils = require("../../utils");
|
|
6
|
+
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
|
|
9
|
+
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."); }
|
|
10
|
+
|
|
11
|
+
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); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
var DECISIONS_HANDLE = "personalization:decisions";
|
|
20
|
+
|
|
16
21
|
var _default = function _default(_ref) {
|
|
17
22
|
var prehidingStyle = _ref.prehidingStyle,
|
|
18
|
-
|
|
23
|
+
showContainers = _ref.showContainers,
|
|
19
24
|
hideContainers = _ref.hideContainers,
|
|
20
|
-
mergeQuery = _ref.mergeQuery
|
|
25
|
+
mergeQuery = _ref.mergeQuery,
|
|
26
|
+
collect = _ref.collect,
|
|
27
|
+
processPropositions = _ref.processPropositions,
|
|
28
|
+
createProposition = _ref.createProposition,
|
|
29
|
+
pendingDisplayNotifications = _ref.pendingDisplayNotifications;
|
|
21
30
|
return function (_ref2) {
|
|
22
|
-
var
|
|
31
|
+
var cacheUpdate = _ref2.cacheUpdate,
|
|
23
32
|
personalizationDetails = _ref2.personalizationDetails,
|
|
24
33
|
event = _ref2.event,
|
|
25
34
|
onResponse = _ref2.onResponse;
|
|
@@ -29,13 +38,69 @@ var _default = function _default(_ref) {
|
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
mergeQuery(event, personalizationDetails.createQueryDetails());
|
|
41
|
+
var handleNotifications;
|
|
42
|
+
|
|
43
|
+
if (personalizationDetails.isSendDisplayNotifications()) {
|
|
44
|
+
handleNotifications = function handleNotifications(decisionsMeta) {
|
|
45
|
+
if (decisionsMeta.length > 0) {
|
|
46
|
+
collect({
|
|
47
|
+
decisionsMeta: decisionsMeta,
|
|
48
|
+
viewName: personalizationDetails.getViewName()
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
var displayNotificationsDeferred = (0, _utils.defer)();
|
|
54
|
+
pendingDisplayNotifications.concat(displayNotificationsDeferred.promise);
|
|
55
|
+
handleNotifications = displayNotificationsDeferred.resolve;
|
|
56
|
+
}
|
|
57
|
+
|
|
32
58
|
onResponse(function (_ref3) {
|
|
33
59
|
var response = _ref3.response;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
response: response
|
|
60
|
+
var handles = response.getPayloadsByType(DECISIONS_HANDLE);
|
|
61
|
+
var propositions = handles.map(function (handle) {
|
|
62
|
+
return createProposition(handle);
|
|
38
63
|
});
|
|
64
|
+
|
|
65
|
+
var _groupBy = (0, _utils.groupBy)(propositions, function (p) {
|
|
66
|
+
return p.getScopeType();
|
|
67
|
+
}),
|
|
68
|
+
_groupBy$page = _groupBy.page,
|
|
69
|
+
pagePropositions = _groupBy$page === void 0 ? [] : _groupBy$page,
|
|
70
|
+
_groupBy$view = _groupBy.view,
|
|
71
|
+
viewPropositions = _groupBy$view === void 0 ? [] : _groupBy$view,
|
|
72
|
+
_groupBy$proposition = _groupBy.proposition,
|
|
73
|
+
nonRenderedPropositions = _groupBy$proposition === void 0 ? [] : _groupBy$proposition;
|
|
74
|
+
|
|
75
|
+
var currentViewPropositions = cacheUpdate.update(viewPropositions);
|
|
76
|
+
var render;
|
|
77
|
+
var returnedPropositions;
|
|
78
|
+
var returnedDecisions;
|
|
79
|
+
|
|
80
|
+
if (personalizationDetails.isRenderDecisions()) {
|
|
81
|
+
var _processPropositions = processPropositions([].concat(_toConsumableArray(pagePropositions), _toConsumableArray(currentViewPropositions)), nonRenderedPropositions);
|
|
82
|
+
|
|
83
|
+
render = _processPropositions.render;
|
|
84
|
+
returnedPropositions = _processPropositions.returnedPropositions;
|
|
85
|
+
returnedDecisions = _processPropositions.returnedDecisions;
|
|
86
|
+
render().then(function (decisionsMeta) {
|
|
87
|
+
showContainers();
|
|
88
|
+
handleNotifications(decisionsMeta);
|
|
89
|
+
}).catch(function (e) {
|
|
90
|
+
showContainers();
|
|
91
|
+
throw e;
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
var _processPropositions2 = processPropositions([], [].concat(_toConsumableArray(pagePropositions), _toConsumableArray(currentViewPropositions), _toConsumableArray(nonRenderedPropositions)));
|
|
95
|
+
|
|
96
|
+
returnedPropositions = _processPropositions2.returnedPropositions;
|
|
97
|
+
returnedDecisions = _processPropositions2.returnedDecisions;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
propositions: returnedPropositions,
|
|
102
|
+
decisions: returnedDecisions
|
|
103
|
+
};
|
|
39
104
|
});
|
|
40
105
|
};
|
|
41
106
|
};
|
|
@@ -43,10 +43,10 @@ var _default = function _default(_ref) {
|
|
|
43
43
|
};
|
|
44
44
|
var scope = decisionsMeta[0].scope;
|
|
45
45
|
|
|
46
|
-
if (scope !== _pageWideScope.default) {
|
|
46
|
+
if ((0, _utils.isNonEmptyString)(scope) && scope !== _pageWideScope.default) {
|
|
47
47
|
xdm.web = {
|
|
48
48
|
webPageDetails: {
|
|
49
|
-
viewName: scope
|
|
49
|
+
viewName: scope.toLowerCase()
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _propositionEventType = require("./constants/propositionEventType");
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2023 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
|
+
var _default = function _default(_ref) {
|
|
19
|
+
var pendingDisplayNotifications = _ref.pendingDisplayNotifications,
|
|
20
|
+
mergeDecisionsMeta = _ref.mergeDecisionsMeta;
|
|
21
|
+
return function (_ref2) {
|
|
22
|
+
var event = _ref2.event;
|
|
23
|
+
return pendingDisplayNotifications.clear().then(function (decisionsMeta) {
|
|
24
|
+
mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.DISPLAY);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.default = _default;
|
|
@@ -48,13 +48,19 @@ var _default = function _default(_ref) {
|
|
|
48
48
|
decisionScopes = _ref.decisionScopes,
|
|
49
49
|
personalization = _ref.personalization,
|
|
50
50
|
event = _ref.event,
|
|
51
|
-
|
|
51
|
+
_isCacheInitialized = _ref.isCacheInitialized,
|
|
52
52
|
logger = _ref.logger;
|
|
53
53
|
var viewName = event.getViewName();
|
|
54
54
|
return {
|
|
55
55
|
isRenderDecisions: function isRenderDecisions() {
|
|
56
56
|
return renderDecisions;
|
|
57
57
|
},
|
|
58
|
+
isSendDisplayNotifications: function isSendDisplayNotifications() {
|
|
59
|
+
return !!personalization.sendDisplayNotifications;
|
|
60
|
+
},
|
|
61
|
+
shouldAddPendingDisplayNotifications: function shouldAddPendingDisplayNotifications() {
|
|
62
|
+
return !!personalization.includePendingDisplayNotifications;
|
|
63
|
+
},
|
|
58
64
|
getViewName: function getViewName() {
|
|
59
65
|
return viewName;
|
|
60
66
|
},
|
|
@@ -94,7 +100,7 @@ var _default = function _default(_ref) {
|
|
|
94
100
|
};
|
|
95
101
|
},
|
|
96
102
|
isCacheInitialized: function isCacheInitialized() {
|
|
97
|
-
return
|
|
103
|
+
return _isCacheInitialized;
|
|
98
104
|
},
|
|
99
105
|
shouldFetchData: function shouldFetchData() {
|
|
100
106
|
return this.hasScopes() || this.hasSurfaces() || !this.isCacheInitialized();
|
|
@@ -6,6 +6,8 @@ var _utils = require("../../utils");
|
|
|
6
6
|
|
|
7
7
|
var _defer = require("../../utils/defer");
|
|
8
8
|
|
|
9
|
+
var _schema = require("./constants/schema");
|
|
10
|
+
|
|
9
11
|
/*
|
|
10
12
|
Copyright 2020 Adobe. All rights reserved.
|
|
11
13
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -17,39 +19,76 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
17
19
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
20
|
governing permissions and limitations under the License.
|
|
19
21
|
*/
|
|
20
|
-
var _default = function _default() {
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
decisionsPromise.then(function (decisions) {
|
|
26
|
-
if (viewStorage === undefined) {
|
|
27
|
-
viewStorage = {};
|
|
28
|
-
}
|
|
22
|
+
var _default = function _default(_ref) {
|
|
23
|
+
var createProposition = _ref.createProposition;
|
|
24
|
+
var viewStorage = {};
|
|
25
|
+
var cacheUpdateCreatedAtLeastOnce = false;
|
|
26
|
+
var previousUpdateCacheComplete = Promise.resolve();
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}).catch(function () {
|
|
33
|
-
if (viewStorage === undefined) {
|
|
34
|
-
viewStorage = {};
|
|
35
|
-
}
|
|
28
|
+
var getViewPropositions = function getViewPropositions(currentViewStorage, viewName) {
|
|
29
|
+
var viewPropositions = currentViewStorage[viewName.toLowerCase()];
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
if (viewPropositions && viewPropositions.length > 0) {
|
|
32
|
+
return viewPropositions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var emptyViewProposition = createProposition({
|
|
36
|
+
scope: viewName,
|
|
37
|
+
scopeDetails: {
|
|
38
|
+
characteristics: {
|
|
39
|
+
scopeType: "view"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
items: [{
|
|
43
|
+
schema: _schema.DEFAULT_CONTENT_ITEM
|
|
44
|
+
}]
|
|
45
|
+
}, false);
|
|
46
|
+
return [emptyViewProposition];
|
|
47
|
+
}; // This should be called before making the request to experience edge.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
var createCacheUpdate = function createCacheUpdate(viewName) {
|
|
51
|
+
var updateCacheDeferred = (0, _defer.default)();
|
|
52
|
+
cacheUpdateCreatedAtLeastOnce = true;
|
|
53
|
+
previousUpdateCacheComplete = previousUpdateCacheComplete.then(function () {
|
|
54
|
+
return updateCacheDeferred.promise;
|
|
55
|
+
}).then(function (newViewStorage) {
|
|
56
|
+
(0, _utils.assign)(viewStorage, newViewStorage);
|
|
57
|
+
}).catch(function () {});
|
|
58
|
+
return {
|
|
59
|
+
update: function update(viewPropositions) {
|
|
60
|
+
var viewPropositionsWithScope = viewPropositions.filter(function (proposition) {
|
|
61
|
+
return proposition.getScope();
|
|
62
|
+
});
|
|
63
|
+
var newViewStorage = (0, _utils.groupBy)(viewPropositionsWithScope, function (proposition) {
|
|
64
|
+
return proposition.getScope().toLowerCase();
|
|
65
|
+
});
|
|
66
|
+
updateCacheDeferred.resolve(newViewStorage);
|
|
67
|
+
|
|
68
|
+
if (viewName) {
|
|
69
|
+
return getViewPropositions(newViewStorage, viewName);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return [];
|
|
73
|
+
},
|
|
74
|
+
cancel: function cancel() {
|
|
75
|
+
updateCacheDeferred.reject();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
39
78
|
};
|
|
40
79
|
|
|
41
80
|
var getView = function getView(viewName) {
|
|
42
|
-
return
|
|
43
|
-
return viewStorage
|
|
81
|
+
return previousUpdateCacheComplete.then(function () {
|
|
82
|
+
return getViewPropositions(viewStorage, viewName);
|
|
44
83
|
});
|
|
45
84
|
};
|
|
46
85
|
|
|
47
86
|
var isInitialized = function isInitialized() {
|
|
48
|
-
return
|
|
87
|
+
return cacheUpdateCreatedAtLeastOnce;
|
|
49
88
|
};
|
|
50
89
|
|
|
51
90
|
return {
|
|
52
|
-
|
|
91
|
+
createCacheUpdate: createCacheUpdate,
|
|
53
92
|
getView: getView,
|
|
54
93
|
isInitialized: isInitialized
|
|
55
94
|
};
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var _composePersonalizationResultingObject = require("./utils/composePersonalizationResultingObject");
|
|
6
|
-
|
|
7
|
-
var _utils = require("../../utils");
|
|
8
|
-
|
|
9
5
|
var _propositionEventType = require("./constants/propositionEventType");
|
|
10
6
|
|
|
11
7
|
/*
|
|
@@ -21,41 +17,40 @@ governing permissions and limitations under the License.
|
|
|
21
17
|
*/
|
|
22
18
|
var _default = function _default(_ref) {
|
|
23
19
|
var mergeDecisionsMeta = _ref.mergeDecisionsMeta,
|
|
24
|
-
|
|
25
|
-
executeDecisions = _ref.executeDecisions,
|
|
20
|
+
processPropositions = _ref.processPropositions,
|
|
26
21
|
viewCache = _ref.viewCache;
|
|
27
22
|
return function (_ref2) {
|
|
28
23
|
var personalizationDetails = _ref2.personalizationDetails,
|
|
29
24
|
event = _ref2.event,
|
|
30
25
|
onResponse = _ref2.onResponse;
|
|
26
|
+
var returnedPropositions;
|
|
27
|
+
var returnedDecisions;
|
|
31
28
|
var viewName = personalizationDetails.getViewName();
|
|
32
|
-
|
|
29
|
+
onResponse(function () {
|
|
30
|
+
return {
|
|
31
|
+
propositions: returnedPropositions,
|
|
32
|
+
decisions: returnedDecisions
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return viewCache.getView(viewName).then(function (propositions) {
|
|
36
|
+
var render;
|
|
37
|
+
|
|
33
38
|
if (personalizationDetails.isRenderDecisions()) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
return;
|
|
42
|
-
} // if there are no decisions in cache for this view, we will send a empty notification
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
onResponse(function () {
|
|
46
|
-
collect({
|
|
47
|
-
decisionsMeta: [],
|
|
48
|
-
viewName: viewName
|
|
49
|
-
});
|
|
50
|
-
return (0, _composePersonalizationResultingObject.default)(viewDecisions, true);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
39
|
+
var _processPropositions = processPropositions(propositions);
|
|
40
|
+
|
|
41
|
+
render = _processPropositions.render;
|
|
42
|
+
returnedPropositions = _processPropositions.returnedPropositions;
|
|
43
|
+
returnedDecisions = _processPropositions.returnedDecisions;
|
|
44
|
+
return render();
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
var _processPropositions2 = processPropositions([], propositions);
|
|
48
|
+
|
|
49
|
+
returnedPropositions = _processPropositions2.returnedPropositions;
|
|
50
|
+
returnedDecisions = _processPropositions2.returnedDecisions;
|
|
51
|
+
return [];
|
|
52
|
+
}).then(function (decisionsMeta) {
|
|
53
|
+
mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.DISPLAY);
|
|
59
54
|
});
|
|
60
55
|
};
|
|
61
56
|
};
|
|
@@ -6,12 +6,6 @@ Object.defineProperty(exports, "appendHtml", {
|
|
|
6
6
|
return _appendHtml.default;
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
|
-
Object.defineProperty(exports, "click", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function get() {
|
|
12
|
-
return _click.default;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
9
|
exports.createAction = void 0;
|
|
16
10
|
Object.defineProperty(exports, "insertHtmlAfter", {
|
|
17
11
|
enumerable: true,
|
|
@@ -102,8 +96,6 @@ var _swapImage = require("./swapImage");
|
|
|
102
96
|
|
|
103
97
|
var _rearrangeChildren = require("./rearrangeChildren");
|
|
104
98
|
|
|
105
|
-
var _click = require("./click");
|
|
106
|
-
|
|
107
99
|
/*
|
|
108
100
|
Copyright 2019 Adobe. All rights reserved.
|
|
109
101
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -123,28 +115,21 @@ var renderContent = function renderContent(elements, content, renderFunc) {
|
|
|
123
115
|
};
|
|
124
116
|
|
|
125
117
|
var createAction = function createAction(renderFunc) {
|
|
126
|
-
return function (
|
|
127
|
-
var selector =
|
|
128
|
-
prehidingSelector =
|
|
129
|
-
content =
|
|
130
|
-
meta = settings.meta;
|
|
118
|
+
return function (itemData) {
|
|
119
|
+
var selector = itemData.selector,
|
|
120
|
+
prehidingSelector = itemData.prehidingSelector,
|
|
121
|
+
content = itemData.content;
|
|
131
122
|
(0, _flicker.hideElements)(prehidingSelector);
|
|
132
123
|
return (0, _dom.awaitSelector)(selector, _dom2.selectNodesWithEq).then(function (elements) {
|
|
133
124
|
return renderContent(elements, content, renderFunc);
|
|
134
125
|
}).then(function () {
|
|
135
126
|
// if everything is OK, show elements
|
|
136
127
|
(0, _flicker.showElements)(prehidingSelector);
|
|
137
|
-
return {
|
|
138
|
-
meta: meta
|
|
139
|
-
};
|
|
140
128
|
}, function (error) {
|
|
141
129
|
// in case of awaiting timing or error, we need to remove the style tag
|
|
142
130
|
// hence showing the pre-hidden elements
|
|
143
131
|
(0, _flicker.showElements)(prehidingSelector);
|
|
144
|
-
|
|
145
|
-
meta: meta,
|
|
146
|
-
error: error
|
|
147
|
-
};
|
|
132
|
+
throw error;
|
|
148
133
|
});
|
|
149
134
|
};
|
|
150
135
|
};
|