@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
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."); }
|
|
6
|
+
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); }
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
+
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; }
|
|
10
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
11
|
+
/*
|
|
12
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
13
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
|
|
17
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var isPlainObject = function isPlainObject(obj) {
|
|
23
|
+
return obj !== null && _typeof(obj) === "object" && Object.getPrototypeOf(obj) === Object.prototype;
|
|
24
|
+
};
|
|
25
|
+
var flattenObject = function flattenObject(obj) {
|
|
26
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
27
|
+
var keys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
28
|
+
Object.keys(obj).forEach(function (key) {
|
|
29
|
+
if (isPlainObject(obj[key]) || Array.isArray(obj[key])) {
|
|
30
|
+
flattenObject(obj[key], result, [].concat(_toConsumableArray(keys), [key]));
|
|
31
|
+
} else {
|
|
32
|
+
result[[].concat(_toConsumableArray(keys), [key]).join(".")] = obj[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
var _default = function _default(obj) {
|
|
38
|
+
if (!isPlainObject(obj)) {
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
return flattenObject(obj);
|
|
42
|
+
};
|
|
43
|
+
exports.default = _default;
|
package/libEs5/utils/index.js
CHANGED
|
@@ -12,6 +12,12 @@ Object.defineProperty(exports, "assign", {
|
|
|
12
12
|
return _assign.default;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
Object.defineProperty(exports, "assignConcatArrayValues", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return _assignConcatArrayValues.default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
15
21
|
Object.defineProperty(exports, "assignIf", {
|
|
16
22
|
enumerable: true,
|
|
17
23
|
get: function get() {
|
|
@@ -246,6 +252,12 @@ Object.defineProperty(exports, "padStart", {
|
|
|
246
252
|
return _padStart.default;
|
|
247
253
|
}
|
|
248
254
|
});
|
|
255
|
+
Object.defineProperty(exports, "parseUrl", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
get: function get() {
|
|
258
|
+
return _parseUrl.default;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
249
261
|
Object.defineProperty(exports, "prepareConfigOverridesForEdge", {
|
|
250
262
|
enumerable: true,
|
|
251
263
|
get: function get() {
|
|
@@ -338,6 +350,7 @@ Object.defineProperty(exports, "values", {
|
|
|
338
350
|
});
|
|
339
351
|
var _areThirdPartyCookiesSupportedByDefault = require("./areThirdPartyCookiesSupportedByDefault");
|
|
340
352
|
var _assign = require("./assign");
|
|
353
|
+
var _assignConcatArrayValues = require("./assignConcatArrayValues");
|
|
341
354
|
var _assignIf = require("./assignIf");
|
|
342
355
|
var _clone = require("./clone");
|
|
343
356
|
var _cookieJar = require("./cookieJar");
|
|
@@ -377,6 +390,7 @@ var _isString = require("./isString");
|
|
|
377
390
|
var _memoize = require("./memoize");
|
|
378
391
|
var _noop = require("./noop");
|
|
379
392
|
var _padStart = require("./padStart");
|
|
393
|
+
var _parseUrl = require("./parseUrl");
|
|
380
394
|
var _prepareConfigOverridesForEdge = require("./prepareConfigOverridesForEdge");
|
|
381
395
|
var _querystring = require("./querystring");
|
|
382
396
|
var _sanitizeOrgIdForCookieName = require("./sanitizeOrgIdForCookieName");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _parseUri = require("parse-uri");
|
|
5
|
+
var _isString = require("./isString");
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
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; } /*
|
|
9
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
10
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
+
governing permissions and limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
var parseDomainBasic = function parseDomainBasic(host) {
|
|
20
|
+
var result = {};
|
|
21
|
+
var domainParts = host.split(".");
|
|
22
|
+
switch (domainParts.length) {
|
|
23
|
+
case 1:
|
|
24
|
+
result.subdomain = "";
|
|
25
|
+
result.domain = host;
|
|
26
|
+
result.topLevelDomain = "";
|
|
27
|
+
break;
|
|
28
|
+
case 2:
|
|
29
|
+
result.subdomain = "";
|
|
30
|
+
result.domain = host;
|
|
31
|
+
result.topLevelDomain = domainParts[1];
|
|
32
|
+
break;
|
|
33
|
+
case 3:
|
|
34
|
+
result.subdomain = domainParts[0] === "www" ? "" : domainParts[0];
|
|
35
|
+
result.domain = host;
|
|
36
|
+
result.topLevelDomain = domainParts[2];
|
|
37
|
+
break;
|
|
38
|
+
case 4:
|
|
39
|
+
result.subdomain = domainParts[0] === "www" ? "" : domainParts[0];
|
|
40
|
+
result.domain = host;
|
|
41
|
+
result.topLevelDomain = domainParts[2] + "." + domainParts[3];
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
var parseUrl = function parseUrl(url) {
|
|
49
|
+
var parseDomain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : parseDomainBasic;
|
|
50
|
+
if (!(0, _isString.default)(url)) {
|
|
51
|
+
// eslint-disable-next-line no-param-reassign
|
|
52
|
+
url = "";
|
|
53
|
+
}
|
|
54
|
+
var parsed = (0, _parseUri.default)(url) || {};
|
|
55
|
+
var _parsed$host = parsed.host,
|
|
56
|
+
host = _parsed$host === void 0 ? "" : _parsed$host,
|
|
57
|
+
_parsed$path = parsed.path,
|
|
58
|
+
path = _parsed$path === void 0 ? "" : _parsed$path,
|
|
59
|
+
_parsed$query = parsed.query,
|
|
60
|
+
query = _parsed$query === void 0 ? "" : _parsed$query,
|
|
61
|
+
_parsed$anchor = parsed.anchor,
|
|
62
|
+
anchor = _parsed$anchor === void 0 ? "" : _parsed$anchor;
|
|
63
|
+
return _objectSpread({
|
|
64
|
+
path: path,
|
|
65
|
+
query: query,
|
|
66
|
+
fragment: anchor
|
|
67
|
+
}, parseDomain(host));
|
|
68
|
+
};
|
|
69
|
+
var _default = parseUrl;
|
|
70
|
+
exports.default = _default;
|
|
@@ -82,6 +82,7 @@ const createDataCollector = ({
|
|
|
82
82
|
run: options => {
|
|
83
83
|
const {
|
|
84
84
|
renderDecisions = false,
|
|
85
|
+
decisionContext = {},
|
|
85
86
|
responseHeaders = {},
|
|
86
87
|
responseBody = {
|
|
87
88
|
handle: []
|
|
@@ -91,6 +92,7 @@ const createDataCollector = ({
|
|
|
91
92
|
const event = eventManager.createEvent();
|
|
92
93
|
return eventManager.applyResponse(event, {
|
|
93
94
|
renderDecisions,
|
|
95
|
+
decisionContext,
|
|
94
96
|
responseHeaders,
|
|
95
97
|
responseBody,
|
|
96
98
|
personalization
|
|
@@ -35,7 +35,8 @@ export default (({
|
|
|
35
35
|
surfaces: arrayOf(string()).uniqueItems(),
|
|
36
36
|
sendDisplayEvent: boolean().default(true),
|
|
37
37
|
includeRenderedPropositions: boolean().default(false),
|
|
38
|
-
|
|
38
|
+
defaultPersonalizationEnabled: boolean(),
|
|
39
|
+
decisionContext: objectOf({})
|
|
39
40
|
}).default({
|
|
40
41
|
sendDisplayEvent: true
|
|
41
42
|
}),
|
package/libEs6/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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 { MESSAGE_IN_APP } from "../../../constants/schema";
|
|
13
|
+
import { TEXT_HTML } from "../../../constants/contentType";
|
|
14
|
+
export default ((id, type, detail) => {
|
|
15
|
+
const {
|
|
16
|
+
html,
|
|
17
|
+
mobileParameters
|
|
18
|
+
} = detail;
|
|
19
|
+
const webParameters = {};
|
|
20
|
+
return {
|
|
21
|
+
schema: MESSAGE_IN_APP,
|
|
22
|
+
data: {
|
|
23
|
+
mobileParameters,
|
|
24
|
+
webParameters,
|
|
25
|
+
content: html,
|
|
26
|
+
contentType: TEXT_HTML
|
|
27
|
+
},
|
|
28
|
+
id
|
|
29
|
+
};
|
|
30
|
+
});
|
package/libEs6/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
13
|
+
export default ((id, type, detail) => {
|
|
14
|
+
const {
|
|
15
|
+
schema,
|
|
16
|
+
data,
|
|
17
|
+
id: detailId
|
|
18
|
+
} = detail;
|
|
19
|
+
return {
|
|
20
|
+
schema,
|
|
21
|
+
data,
|
|
22
|
+
id: detailId || id
|
|
23
|
+
};
|
|
24
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
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 CONTEXT_KEY = {
|
|
13
|
+
TYPE: "~type",
|
|
14
|
+
SOURCE: "~source"
|
|
15
|
+
};
|
|
16
|
+
export const CONTEXT_EVENT_TYPE = {
|
|
17
|
+
LIFECYCLE: "com.adobe.eventType.lifecycle",
|
|
18
|
+
TRACK: "com.adobe.eventType.generic.track",
|
|
19
|
+
EDGE: "com.adobe.eventType.edge",
|
|
20
|
+
RULES_ENGINE: "com.adobe.eventType.rulesEngine"
|
|
21
|
+
};
|
|
22
|
+
export const CONTEXT_EVENT_SOURCE = {
|
|
23
|
+
LAUNCH: "com.adobe.eventSource.applicationLaunch",
|
|
24
|
+
REQUEST: "com.adobe.eventSource.requestContent"
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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 (lifecycle => {
|
|
13
|
+
return ({
|
|
14
|
+
renderDecisions = false,
|
|
15
|
+
propositions = [],
|
|
16
|
+
event,
|
|
17
|
+
personalization
|
|
18
|
+
}) => {
|
|
19
|
+
if (propositions.length > 0 && lifecycle) {
|
|
20
|
+
lifecycle.onDecision({
|
|
21
|
+
renderDecisions,
|
|
22
|
+
propositions,
|
|
23
|
+
event,
|
|
24
|
+
personalization
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
propositions
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 inAppMessageConsequenceAdapter from "./consequenceAdapters/inAppMessageConsequenceAdapter";
|
|
13
|
+
import schemaTypeConsequenceAdapter from "./consequenceAdapters/schemaTypeConsequenceAdapter";
|
|
14
|
+
const CJM_IN_APP_MESSAGE_TYPE = "cjmiam";
|
|
15
|
+
const SCHEMA = "schema";
|
|
16
|
+
const adapters = {
|
|
17
|
+
[CJM_IN_APP_MESSAGE_TYPE]: inAppMessageConsequenceAdapter,
|
|
18
|
+
[SCHEMA]: schemaTypeConsequenceAdapter
|
|
19
|
+
};
|
|
20
|
+
export default (() => {
|
|
21
|
+
return consequence => {
|
|
22
|
+
const {
|
|
23
|
+
id,
|
|
24
|
+
type,
|
|
25
|
+
detail
|
|
26
|
+
} = consequence;
|
|
27
|
+
return typeof adapters[type] === "function" ? adapters[type](id, type, detail) : detail;
|
|
28
|
+
};
|
|
29
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
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 getBrowser from "../../utils/getBrowser";
|
|
13
|
+
import parseUrl from "../../utils/parseUrl";
|
|
14
|
+
import flattenObject from "../../utils/flattenObject";
|
|
15
|
+
import libraryVersion from "../../constants/libraryVersion";
|
|
16
|
+
export default (({
|
|
17
|
+
eventRegistry,
|
|
18
|
+
window
|
|
19
|
+
}) => {
|
|
20
|
+
const pageLoadTimestamp = new Date().getTime();
|
|
21
|
+
const getBrowserContext = () => {
|
|
22
|
+
return {
|
|
23
|
+
name: getBrowser(window)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const getPageContext = () => {
|
|
27
|
+
return {
|
|
28
|
+
title: window.title,
|
|
29
|
+
url: window.url,
|
|
30
|
+
...parseUrl(window.url)
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getReferrerContext = () => {
|
|
34
|
+
return {
|
|
35
|
+
url: window.referrer,
|
|
36
|
+
...parseUrl(window.referrer)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const getTimeContext = () => {
|
|
40
|
+
const now = new Date();
|
|
41
|
+
const currentTimestamp = now.getTime();
|
|
42
|
+
return {
|
|
43
|
+
pageLoadTimestamp,
|
|
44
|
+
currentTimestamp,
|
|
45
|
+
currentDate: now.getDate(),
|
|
46
|
+
// Day of the week starts on Monday as is practiced in ISO 8601, but we want it to start on Sunday to match the authoring UI rule
|
|
47
|
+
"~state.com.adobe.module.lifecycle/lifecyclecontextdata.dayofweek": now.getDay() + 1,
|
|
48
|
+
"~state.com.adobe.module.lifecycle/lifecyclecontextdata.hourofday": now.getHours(),
|
|
49
|
+
currentMinute: now.getMinutes(),
|
|
50
|
+
currentMonth: now.getMonth(),
|
|
51
|
+
currentYear: now.getFullYear(),
|
|
52
|
+
pageVisitDuration: currentTimestamp - pageLoadTimestamp,
|
|
53
|
+
"~timestampu": currentTimestamp / 1000,
|
|
54
|
+
"~timestampz": now.toISOString()
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const getWindowContext = () => {
|
|
58
|
+
const height = window.height;
|
|
59
|
+
const width = window.width;
|
|
60
|
+
const scrollY = window.scrollY;
|
|
61
|
+
const scrollX = window.scrollX;
|
|
62
|
+
return {
|
|
63
|
+
height,
|
|
64
|
+
width,
|
|
65
|
+
scrollY,
|
|
66
|
+
scrollX
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const coreGlobalContext = {
|
|
70
|
+
browser: getBrowserContext(),
|
|
71
|
+
page: getPageContext(),
|
|
72
|
+
referringPage: getReferrerContext()
|
|
73
|
+
};
|
|
74
|
+
const getGlobalContext = () => {
|
|
75
|
+
return {
|
|
76
|
+
...coreGlobalContext,
|
|
77
|
+
...getTimeContext(),
|
|
78
|
+
window: getWindowContext(),
|
|
79
|
+
"~sdkver": libraryVersion
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const getContext = (addedContext = {}) => {
|
|
83
|
+
const context = {
|
|
84
|
+
...getGlobalContext(),
|
|
85
|
+
...addedContext
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
...flattenObject(context),
|
|
89
|
+
events: eventRegistry.toJSON()
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
getContext
|
|
94
|
+
};
|
|
95
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { PropositionEventType } from "../../constants/propositionEventType";
|
|
13
|
+
export default (({
|
|
14
|
+
eventRegistry
|
|
15
|
+
}) => {
|
|
16
|
+
const recordQualified = id => {
|
|
17
|
+
if (!id) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return eventRegistry.addEvent({}, PropositionEventType.TRIGGER, id);
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
recordQualified
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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 createEvaluableRulesetPayload from "./createEvaluableRulesetPayload";
|
|
13
|
+
import createDecisionHistory from "./createDecisionHistory";
|
|
14
|
+
import { getActivityId } from "./utils";
|
|
15
|
+
export default (({
|
|
16
|
+
eventRegistry
|
|
17
|
+
}) => {
|
|
18
|
+
const payloadsBasedOnActivityId = {};
|
|
19
|
+
const decisionHistory = createDecisionHistory({
|
|
20
|
+
eventRegistry
|
|
21
|
+
});
|
|
22
|
+
const addPayload = payload => {
|
|
23
|
+
const activityId = getActivityId(payload);
|
|
24
|
+
if (!activityId) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const evaluableRulesetPayload = createEvaluableRulesetPayload(payload, eventRegistry, decisionHistory);
|
|
28
|
+
if (evaluableRulesetPayload.isEvaluable) {
|
|
29
|
+
payloadsBasedOnActivityId[activityId] = evaluableRulesetPayload;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const evaluate = (context = {}) => Object.values(payloadsBasedOnActivityId).map(payload => payload.evaluate(context)).filter(payload => payload.items.length > 0);
|
|
33
|
+
const addPayloads = personalizationPayloads => {
|
|
34
|
+
personalizationPayloads.forEach(addPayload);
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
addPayload,
|
|
38
|
+
addPayloads,
|
|
39
|
+
evaluate
|
|
40
|
+
};
|
|
41
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
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 RulesEngine from "@adobe/aep-rules-engine";
|
|
13
|
+
import { JSON_CONTENT_ITEM, RULESET_ITEM } from "../../constants/schema";
|
|
14
|
+
import { DISPLAY } from "../../constants/eventType";
|
|
15
|
+
import { getActivityId } from "./utils";
|
|
16
|
+
import flattenArray from "../../utils/flattenArray";
|
|
17
|
+
import createConsequenceAdapter from "./createConsequenceAdapter";
|
|
18
|
+
const isRulesetItem = item => {
|
|
19
|
+
const {
|
|
20
|
+
schema,
|
|
21
|
+
data
|
|
22
|
+
} = item;
|
|
23
|
+
if (schema === RULESET_ITEM) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (schema !== JSON_CONTENT_ITEM) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const content = typeof data.content === "string" ? JSON.parse(data.content) : data.content;
|
|
31
|
+
return content && Object.prototype.hasOwnProperty.call(content, "version") && Object.prototype.hasOwnProperty.call(content, "rules");
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export default ((payload, eventRegistry, decisionHistory) => {
|
|
37
|
+
const consequenceAdapter = createConsequenceAdapter();
|
|
38
|
+
const activityId = getActivityId(payload);
|
|
39
|
+
const items = [];
|
|
40
|
+
const addItem = item => {
|
|
41
|
+
const {
|
|
42
|
+
data = {},
|
|
43
|
+
schema
|
|
44
|
+
} = item;
|
|
45
|
+
const content = schema === RULESET_ITEM ? data : data.content;
|
|
46
|
+
if (!content) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
items.push(RulesEngine(typeof content === "string" ? JSON.parse(content) : content));
|
|
50
|
+
};
|
|
51
|
+
const evaluate = context => {
|
|
52
|
+
const displayEvent = eventRegistry.getEvent(DISPLAY, activityId);
|
|
53
|
+
const displayedDate = displayEvent ? displayEvent.firstTimestamp : undefined;
|
|
54
|
+
const qualifyingItems = flattenArray(items.map(item => item.execute(context))).map(consequenceAdapter).map(item => {
|
|
55
|
+
const {
|
|
56
|
+
firstTimestamp: qualifiedDate
|
|
57
|
+
} = decisionHistory.recordQualified(activityId) || {};
|
|
58
|
+
return {
|
|
59
|
+
...item,
|
|
60
|
+
data: {
|
|
61
|
+
...item.data,
|
|
62
|
+
qualifiedDate,
|
|
63
|
+
displayedDate
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
...payload,
|
|
69
|
+
items: qualifyingItems
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
if (Array.isArray(payload.items)) {
|
|
73
|
+
payload.items.filter(isRulesetItem).forEach(addItem);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
evaluate,
|
|
77
|
+
isEvaluable: items.length > 0
|
|
78
|
+
};
|
|
79
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { boolean, objectOf } from "../../utils/validation";
|
|
13
|
+
const validateOptions = ({
|
|
14
|
+
options
|
|
15
|
+
}) => {
|
|
16
|
+
const validator = objectOf({
|
|
17
|
+
renderDecisions: boolean(),
|
|
18
|
+
personalization: objectOf({
|
|
19
|
+
decisionContext: objectOf({})
|
|
20
|
+
})
|
|
21
|
+
}).noUnknownFields();
|
|
22
|
+
return validator(options);
|
|
23
|
+
};
|
|
24
|
+
export default (({
|
|
25
|
+
contextProvider,
|
|
26
|
+
decisionProvider
|
|
27
|
+
}) => {
|
|
28
|
+
const run = ({
|
|
29
|
+
renderDecisions,
|
|
30
|
+
decisionContext,
|
|
31
|
+
applyResponse
|
|
32
|
+
}) => {
|
|
33
|
+
return applyResponse({
|
|
34
|
+
renderDecisions,
|
|
35
|
+
propositions: decisionProvider.evaluate(contextProvider.getContext(decisionContext))
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const optionsValidator = options => validateOptions({
|
|
39
|
+
options
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
optionsValidator,
|
|
43
|
+
run
|
|
44
|
+
};
|
|
45
|
+
});
|