@adobe/alloy 2.19.0-beta.12 → 2.19.0-beta.14

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.
@@ -36,7 +36,7 @@ var _default = function _default(_ref) {
36
36
  surfaces: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems(),
37
37
  sendDisplayEvent: (0, _validation.boolean)().default(true),
38
38
  includeRenderedPropositions: (0, _validation.boolean)().default(false),
39
- requestPersonalization: (0, _validation.boolean)(),
39
+ defaultPersonalizationEnabled: (0, _validation.boolean)(),
40
40
  decisionContext: (0, _validation.objectOf)({})
41
41
  }).default({
42
42
  sendDisplayEvent: true
@@ -74,7 +74,7 @@ var _default = function _default(_ref) {
74
74
  scopes.push.apply(scopes, _toConsumableArray(personalization.decisionScopes));
75
75
  }
76
76
  var eventSurfaces = (0, _surfaceUtils.normalizeSurfaces)(personalization.surfaces, getPageLocation, logger);
77
- if (!this.isCacheInitialized() || personalization.requestPersonalization) {
77
+ if (this.shouldRequestDefaultPersonalization()) {
78
78
  addPageWideScope(scopes);
79
79
  addPageSurface(eventSurfaces, getPageLocation);
80
80
  }
@@ -92,10 +92,13 @@ var _default = function _default(_ref) {
92
92
  return _isCacheInitialized;
93
93
  },
94
94
  shouldFetchData: function shouldFetchData() {
95
- return this.hasScopes() || this.hasSurfaces() || personalization.requestPersonalization || !this.isCacheInitialized() && personalization.requestPersonalization !== false;
95
+ return this.hasScopes() || this.hasSurfaces() || this.shouldRequestDefaultPersonalization();
96
96
  },
97
97
  shouldUseCachedData: function shouldUseCachedData() {
98
- return this.hasViewName() && this.isCacheInitialized();
98
+ return this.hasViewName() && !this.shouldFetchData();
99
+ },
100
+ shouldRequestDefaultPersonalization: function shouldRequestDefaultPersonalization() {
101
+ return personalization.defaultPersonalizationEnabled || !this.isCacheInitialized() && personalization.defaultPersonalizationEnabled !== false;
99
102
  }
100
103
  };
101
104
  };
@@ -43,8 +43,15 @@ var _default = function _default(_ref) {
43
43
  var createCacheUpdate = function createCacheUpdate(viewName) {
44
44
  var updateCacheDeferred = (0, _defer.default)();
45
45
  cacheUpdateCreatedAtLeastOnce = true;
46
+
47
+ // Additional updates will merge the new view propositions with the old.
48
+ // i.e. if there are new "cart" view propositions they will overwrite the
49
+ // old "cart" view propositions, but if there are no new "cart" view
50
+ // propositions the old "cart" view propositions will remain.
46
51
  viewStoragePromise = viewStoragePromise.then(function (oldViewStorage) {
47
- return updateCacheDeferred.promise.catch(function () {
52
+ return updateCacheDeferred.promise.then(function (newViewStorage) {
53
+ return (0, _utils.assign)({}, oldViewStorage, newViewStorage);
54
+ }).catch(function () {
48
55
  return oldViewStorage;
49
56
  });
50
57
  });
@@ -14,5 +14,5 @@ governing permissions and limitations under the License.
14
14
  */
15
15
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
16
16
  // see babel-plugin-version
17
- var _default = "2.19.0-beta.12";
17
+ var _default = "2.19.0-beta.14";
18
18
  exports.default = _default;
@@ -35,7 +35,7 @@ export default (({
35
35
  surfaces: arrayOf(string()).uniqueItems(),
36
36
  sendDisplayEvent: boolean().default(true),
37
37
  includeRenderedPropositions: boolean().default(false),
38
- requestPersonalization: boolean(),
38
+ defaultPersonalizationEnabled: boolean(),
39
39
  decisionContext: objectOf({})
40
40
  }).default({
41
41
  sendDisplayEvent: true
@@ -64,7 +64,7 @@ export default (({
64
64
  scopes.push(...personalization.decisionScopes);
65
65
  }
66
66
  const eventSurfaces = normalizeSurfaces(personalization.surfaces, getPageLocation, logger);
67
- if (!this.isCacheInitialized() || personalization.requestPersonalization) {
67
+ if (this.shouldRequestDefaultPersonalization()) {
68
68
  addPageWideScope(scopes);
69
69
  addPageSurface(eventSurfaces, getPageLocation);
70
70
  }
@@ -82,10 +82,13 @@ export default (({
82
82
  return isCacheInitialized;
83
83
  },
84
84
  shouldFetchData() {
85
- return this.hasScopes() || this.hasSurfaces() || personalization.requestPersonalization || !this.isCacheInitialized() && personalization.requestPersonalization !== false;
85
+ return this.hasScopes() || this.hasSurfaces() || this.shouldRequestDefaultPersonalization();
86
86
  },
87
87
  shouldUseCachedData() {
88
- return this.hasViewName() && this.isCacheInitialized();
88
+ return this.hasViewName() && !this.shouldFetchData();
89
+ },
90
+ shouldRequestDefaultPersonalization() {
91
+ return personalization.defaultPersonalizationEnabled || !this.isCacheInitialized() && personalization.defaultPersonalizationEnabled !== false;
89
92
  }
90
93
  };
91
94
  });
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { groupBy } from "../../utils";
13
+ import { assign, groupBy } from "../../utils";
14
14
  import defer from "../../utils/defer";
15
15
  import { DEFAULT_CONTENT_ITEM } from "../../constants/schema";
16
16
  import { VIEW_SCOPE_TYPE } from "./constants/scopeType";
@@ -42,7 +42,16 @@ export default (({
42
42
  const createCacheUpdate = viewName => {
43
43
  const updateCacheDeferred = defer();
44
44
  cacheUpdateCreatedAtLeastOnce = true;
45
- viewStoragePromise = viewStoragePromise.then(oldViewStorage => updateCacheDeferred.promise.catch(() => oldViewStorage));
45
+
46
+ // Additional updates will merge the new view propositions with the old.
47
+ // i.e. if there are new "cart" view propositions they will overwrite the
48
+ // old "cart" view propositions, but if there are no new "cart" view
49
+ // propositions the old "cart" view propositions will remain.
50
+ viewStoragePromise = viewStoragePromise.then(oldViewStorage => {
51
+ return updateCacheDeferred.promise.then(newViewStorage => {
52
+ return assign({}, oldViewStorage, newViewStorage);
53
+ }).catch(() => oldViewStorage);
54
+ });
46
55
  return {
47
56
  update(viewPropositions) {
48
57
  const viewPropositionsWithScope = viewPropositions.filter(proposition => proposition.getScope());
@@ -13,4 +13,4 @@ governing permissions and limitations under the License.
13
13
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
14
14
  // see babel-plugin-version
15
15
 
16
- export default "2.19.0-beta.12";
16
+ export default "2.19.0-beta.14";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.19.0-beta.12",
3
+ "version": "2.19.0-beta.14",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",