@ember-data/store 4.12.0-alpha.16 → 4.12.0-alpha.17

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/addon/-private.js CHANGED
@@ -1 +1 @@
1
- export { f as AdapterPopulatedRecordArray, C as CacheHandler, j as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, h as SOURCE, S as Store, _ as _clearCaches, e as coerceId, k as fastPush, i as isStableIdentifier, n as normalizeModelName, g as notifyArray, p as peekCache, r as recordIdentifierFor, l as removeRecordDataFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, s as storeFor } from "./index-35424a6b";
1
+ export { f as AdapterPopulatedRecordArray, C as CacheHandler, j as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, h as SOURCE, S as Store, _ as _clearCaches, e as coerceId, k as fastPush, i as isStableIdentifier, n as normalizeModelName, g as notifyArray, p as peekCache, r as recordIdentifierFor, l as removeRecordDataFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, s as storeFor } from "./index-f7d3d5e5";
@@ -727,9 +727,9 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
727
727
  return desc;
728
728
  }
729
729
  let tokenId = 0;
730
- const CacheOperations$1 = new Set(['added', 'removed', 'state', 'updated']);
730
+ const CacheOperations = new Set(['added', 'removed', 'state', 'updated']);
731
731
  function isCacheOperationValue(value) {
732
- return CacheOperations$1.has(value);
732
+ return CacheOperations.has(value);
733
733
  }
734
734
  function runLoopIsFlushing() {
735
735
  //@ts-expect-error
@@ -4888,8 +4888,10 @@ class Store {
4888
4888
  // we lazily set the cache handler when we issue the first request
4889
4889
  // because constructor doesn't allow for this to run after
4890
4890
  // the user has had the chance to set the prop.
4891
+ const storeSymbol = Symbol.for('ember-data:enable-hydration');
4891
4892
  let opts = {
4892
- store: this
4893
+ store: this,
4894
+ [storeSymbol]: true
4893
4895
  };
4894
4896
  if (macroCondition(getOwnConfig().env.TESTING)) {
4895
4897
  if (this.DISABLE_WAITER) {
@@ -6798,11 +6800,7 @@ function secretInit(record, cache, identifier, store) {
6798
6800
  StoreMap.set(record, store);
6799
6801
  setCacheFor(record, cache);
6800
6802
  }
6801
- const CacheOperations = new Set(['findRecord', 'findAll', 'query', 'queryRecord', 'findBelongsTo', 'findHasMany', 'updateRecord', 'createRecord', 'deleteRecord']);
6802
6803
  function getHydratedContent(store, request, document) {
6803
- if (!request.op || !CacheOperations.has(request.op)) {
6804
- return document;
6805
- }
6806
6804
  if (Array.isArray(document.data)) {
6807
6805
  const {
6808
6806
  lid
@@ -6829,14 +6827,9 @@ function getHydratedContent(store, request, document) {
6829
6827
  }
6830
6828
  return managed;
6831
6829
  } else {
6832
- switch (request.op) {
6833
- case 'findBelongsTo':
6834
- case 'queryRecord':
6835
- case 'findRecord':
6836
- return document.data ? store.peekRecord(document.data) : null;
6837
- default:
6838
- return document.data;
6839
- }
6830
+ return Object.assign({}, document, {
6831
+ data: document.data ? store.peekRecord(document.data) : null
6832
+ });
6840
6833
  }
6841
6834
  }
6842
6835
  function calcShouldFetch(store, request, hasCachedValue, lid) {
@@ -6859,12 +6852,13 @@ function fetchContentAndHydrate(next, context, shouldFetch, shouldBackgroundFetc
6859
6852
  const {
6860
6853
  store
6861
6854
  } = context.request;
6855
+ const shouldHydrate = context.request[Symbol.for('ember-data:enable-hydration')] || false;
6862
6856
  return next(context.request).then(document => {
6863
6857
  store._enableAsyncFlush = true;
6864
6858
  let response;
6865
6859
  store._join(() => {
6866
6860
  response = store.cache.put(document);
6867
- if (shouldFetch) {
6861
+ if (shouldFetch && shouldHydrate) {
6868
6862
  response = getHydratedContent(store, context.request, response);
6869
6863
  }
6870
6864
  });
@@ -6887,8 +6881,8 @@ function fetchContentAndHydrate(next, context, shouldFetch, shouldBackgroundFetc
6887
6881
  }
6888
6882
  const CacheHandler = {
6889
6883
  request(context, next) {
6890
- // if we are a legacy request or did not originate from the store, skip cache handling
6891
- if (!context.request.store || context.request.op && CacheOperations.has(context.request.op) && !context.request.url) {
6884
+ // if we have no cache or no cache-key skip cache handling
6885
+ if (!context.request.store || !(context.request.cacheOptions?.key || context.request.url)) {
6892
6886
  return next(context.request);
6893
6887
  }
6894
6888
  const {
@@ -6916,7 +6910,8 @@ const CacheHandler = {
6916
6910
  if ('error' in peeked) {
6917
6911
  throw peeked.error;
6918
6912
  }
6919
- return Promise.resolve(getHydratedContent(store, context.request, peeked.content));
6913
+ const shouldHydrate = context.request[Symbol.for('ember-data:enable-hydration')] || false;
6914
+ return Promise.resolve(shouldHydrate ? getHydratedContent(store, context.request, peeked.content) : peeked.content);
6920
6915
  }
6921
6916
  };
6922
6917
  function normalizeModelName(modelName) {