@warp-drive/legacy 5.7.0-alpha.9 → 5.7.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.
Files changed (54) hide show
  1. package/declarations/adapter/-private/build-url-mixin.d.ts +0 -13
  2. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -7
  3. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -4
  4. package/declarations/adapter/error.d.ts +0 -1
  5. package/declarations/adapter/rest.d.ts +0 -2
  6. package/declarations/adapter.d.ts +0 -5
  7. package/declarations/compat/builders/find-all.d.ts +2 -2
  8. package/declarations/compat/builders/query.d.ts +2 -2
  9. package/declarations/compat/builders/save-record.d.ts +3 -3
  10. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +24 -17
  11. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
  12. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
  13. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -8
  14. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +40 -18
  15. package/declarations/compat/legacy-network-handler/snapshot.d.ts +63 -44
  16. package/declarations/compat.d.ts +3 -6
  17. package/declarations/model/-private/attr.d.ts +1 -14
  18. package/declarations/model/-private/belongs-to.d.ts +0 -11
  19. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -14
  20. package/declarations/model/-private/errors.d.ts +0 -6
  21. package/declarations/model/-private/has-many.d.ts +0 -4
  22. package/declarations/model/-private/hooks.d.ts +2 -2
  23. package/declarations/model/-private/legacy-relationships-support.d.ts +18 -27
  24. package/declarations/model/-private/model-for-mixin.d.ts +0 -16
  25. package/declarations/model/-private/model-methods.d.ts +0 -4
  26. package/declarations/model/-private/model.d.ts +13 -69
  27. package/declarations/model/-private/notify-changes.d.ts +2 -2
  28. package/declarations/model/-private/promise-belongs-to.d.ts +0 -6
  29. package/declarations/model/-private/promise-many-array.d.ts +0 -11
  30. package/declarations/model/-private/record-state.d.ts +2 -25
  31. package/declarations/model/-private/references/belongs-to.d.ts +6 -7
  32. package/declarations/model/-private/references/has-many.d.ts +6 -13
  33. package/declarations/model/-private/schema-provider.d.ts +6 -10
  34. package/declarations/model/-private.d.ts +1 -2
  35. package/declarations/model/migration-support.d.ts +9 -33
  36. package/declarations/serializer/json-api.d.ts +0 -1
  37. package/declarations/serializer/json.d.ts +0 -1
  38. package/declarations/serializer/rest.d.ts +0 -1
  39. package/declarations/store/-private.d.ts +12 -24
  40. package/dist/{-private-CKrP0ogQ.js → -private-8UmnAf9J.js} +169 -141
  41. package/dist/adapter/-private.js +1 -1
  42. package/dist/adapter/json-api.js +1 -1
  43. package/dist/adapter/rest.js +1 -1
  44. package/dist/compat/-private.js +1 -1
  45. package/dist/compat/builders.js +3 -2
  46. package/dist/compat.js +7 -2
  47. package/dist/{errors-BX5wowuz.js → errors-8kD2mSe_.js} +66 -36
  48. package/dist/model/-private.js +1 -2
  49. package/dist/model/migration-support.js +7 -4
  50. package/dist/model.js +13 -11
  51. package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-DQu4Rjco.js} +62 -26
  52. package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-CS0MIv4F.js} +2 -1
  53. package/dist/store.js +8 -6
  54. package/package.json +15 -15
@@ -1,7 +1,8 @@
1
- import { memoized, defineSignal, defineNonEnumerableSignal, isStableIdentifier, recordIdentifierFor, storeFor, peekCache, SOURCE, fastPush, RelatedCollection, notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
1
+ import { Context } from '@warp-drive/core/reactive/-private';
2
+ import { memoized, defineSignal, assertPrivateStore, defineNonEnumerableSignal, isResourceKey, recordIdentifierFor, isPrivateStore, storeFor, fastPush, createLegacyManyArray, notifyInternalSignal } from '@warp-drive/core/store/-private';
2
3
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
3
4
  import { EnableHydration } from '@warp-drive/core/types/request';
4
- import { u as upgradeStore } from "./-private-CKrP0ogQ.js";
5
+ import { u as upgradeStore } from "./-private-8UmnAf9J.js";
5
6
  import { computed, get } from '@ember/object';
6
7
  import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
7
8
  import ObjectProxy from '@ember/object/proxy';
@@ -420,7 +421,7 @@ class HasManyReference {
420
421
  * An array of identifiers for the records that this reference refers to.
421
422
  *
422
423
  * @property identifiers
423
- * @type {StableRecordIdentifier[]}
424
+ * @type {ResourceKey[]}
424
425
  * @public
425
426
  */
426
427
  get identifiers() {
@@ -432,7 +433,7 @@ class HasManyReference {
432
433
  this.___relatedTokenMap = new Map();
433
434
  if (resource && resource.data) {
434
435
  return resource.data.map(resourceIdentifier => {
435
- const identifier = this.store.identifierCache.getOrCreateRecordIdentifier(resourceIdentifier);
436
+ const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
436
437
  let token = map.get(identifier);
437
438
  if (token) {
438
439
  map.delete(identifier);
@@ -724,7 +725,7 @@ class HasManyReference {
724
725
  throw new Error(`You must provide at least one of 'links', 'meta' or 'data' when calling hasManyReference.push`);
725
726
  }
726
727
  })('links' in dataDoc || 'meta' in dataDoc || 'data' in dataDoc) : {};
727
- const identifiers = !Array.isArray(dataDoc.data) ? [] : isResourceData ? store._push(dataDoc, true) : dataDoc.data.map(i => store.identifierCache.getOrCreateRecordIdentifier(i));
728
+ const identifiers = !Array.isArray(dataDoc.data) ? [] : isResourceData ? store._push(dataDoc, true) : dataDoc.data.map(i => store.cacheKeyManager.getOrCreateRecordIdentifier(i));
728
729
  const {
729
730
  identifier
730
731
  } = this.hasManyRelationship;
@@ -745,6 +746,7 @@ class HasManyReference {
745
746
  if ('meta' in dataDoc) {
746
747
  newData.meta = dataDoc.meta;
747
748
  }
749
+ assertPrivateStore(store);
748
750
  store._join(() => {
749
751
  this.graph.push({
750
752
  op: 'updateRelationship',
@@ -762,6 +764,7 @@ class HasManyReference {
762
764
  }
763
765
  const relationship = this.graph.getData(this.hasManyRelationship.identifier, this.key);
764
766
  return relationship.data ? relationship.data.every(identifier => {
767
+ assertPrivateStore(this.store);
765
768
  return this.store._instanceCache.recordIsLoaded(identifier, true) === true;
766
769
  }) : false;
767
770
  }
@@ -1022,7 +1025,7 @@ class BelongsToReference {
1022
1025
  * `null` if no related record is known.
1023
1026
  *
1024
1027
  * @property identifier
1025
- * @type {StableRecordIdentifier | null}
1028
+ * @type {ResourceKey | null}
1026
1029
  * @public
1027
1030
  */
1028
1031
  get identifier() {
@@ -1032,7 +1035,7 @@ class BelongsToReference {
1032
1035
  }
1033
1036
  const resource = this._resource();
1034
1037
  if (resource && resource.data) {
1035
- const identifier = this.store.identifierCache.getOrCreateRecordIdentifier(resource.data);
1038
+ const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resource.data);
1036
1039
  this.___relatedToken = this.store.notifications.subscribe(identifier, (_, bucket, notifiedKey) => {
1037
1040
  if (bucket === 'identity' || bucket === 'attributes' && notifiedKey === 'id') {
1038
1041
  this._ref++;
@@ -1309,7 +1312,7 @@ class BelongsToReference {
1309
1312
  store
1310
1313
  } = this;
1311
1314
  const isResourceData = doc.data && isMaybeResource(doc.data);
1312
- const added = isResourceData ? store._push(doc, true) : doc.data ? store.identifierCache.getOrCreateRecordIdentifier(doc.data) : null;
1315
+ const added = isResourceData ? store._push(doc, true) : doc.data ? store.cacheKeyManager.getOrCreateRecordIdentifier(doc.data) : null;
1313
1316
  const {
1314
1317
  identifier
1315
1318
  } = this.belongsToRelationship;
@@ -1330,6 +1333,7 @@ class BelongsToReference {
1330
1333
  if ('meta' in doc) {
1331
1334
  newData.meta = doc.meta;
1332
1335
  }
1336
+ assertPrivateStore(store);
1333
1337
  store._join(() => {
1334
1338
  this.graph.push({
1335
1339
  op: 'updateRelationship',
@@ -1508,18 +1512,43 @@ function lookupLegacySupport(record) {
1508
1512
  throw new Error(`Memory Leak Detected`);
1509
1513
  }
1510
1514
  })(!record.isDestroyed && !record.isDestroying) : {};
1511
- support = new LegacySupport(record);
1515
+ support = new LegacySupport(record, identifier);
1512
1516
  LEGACY_SUPPORT.set(identifier, support);
1513
- LEGACY_SUPPORT.set(record, support);
1514
1517
  }
1515
1518
  return support;
1516
1519
  }
1520
+
1521
+ /**
1522
+ * @hideconstructor
1523
+ */
1517
1524
  class LegacySupport {
1518
- constructor(record) {
1525
+ /** @internal */
1526
+
1527
+ /** @internal */
1528
+
1529
+ /** @internal */
1530
+
1531
+ /** @internal */
1532
+
1533
+ /** @internal */
1534
+
1535
+ /** @internal */
1536
+
1537
+ /** @internal */
1538
+
1539
+ /** @internal */
1540
+
1541
+ /** @internal */
1542
+
1543
+ /** @internal */
1544
+
1545
+ /** @internal */
1546
+
1547
+ constructor(record, identifier) {
1519
1548
  this.record = record;
1520
- this.store = storeFor(record);
1521
- this.identifier = recordIdentifierFor(record);
1522
- this.cache = peekCache(record);
1549
+ this.store = isPrivateStore(storeFor(record, false));
1550
+ this.identifier = identifier;
1551
+ this.cache = this.store.cache;
1523
1552
  if (this.store._graph) {
1524
1553
  this.graph = this.store._graph;
1525
1554
  }
@@ -1529,12 +1558,14 @@ class LegacySupport {
1529
1558
  this._pending = Object.create(null);
1530
1559
  this.references = Object.create(null);
1531
1560
  }
1561
+
1562
+ /** @private */
1532
1563
  _syncArray(array) {
1533
1564
  // It’s possible the parent side of the relationship may have been destroyed by this point
1534
1565
  if (this.isDestroyed || this.isDestroying) {
1535
1566
  return;
1536
1567
  }
1537
- const currentState = array[SOURCE];
1568
+ const currentState = array[Context].source;
1538
1569
  const identifier = this.identifier;
1539
1570
  const [identifiers, jsonApi] = this._getCurrentState(identifier, array.key);
1540
1571
  if (jsonApi.meta) {
@@ -1588,7 +1619,7 @@ class LegacySupport {
1588
1619
  if (!test) {
1589
1620
  throw new Error(`Expected a stable identifier`);
1590
1621
  }
1591
- })(!relatedIdentifier || isStableIdentifier(relatedIdentifier)) : {};
1622
+ })(!relatedIdentifier || isResourceKey(relatedIdentifier)) : {};
1592
1623
  const store = this.store;
1593
1624
  const relationship = this.graph.get(this.identifier, key);
1594
1625
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
@@ -1648,7 +1679,7 @@ class LegacySupport {
1648
1679
  if (!test) {
1649
1680
  throw new Error(`Expected a stable identifier`);
1650
1681
  }
1651
- })(isStableIdentifier(relatedIdentifier)) : {};
1682
+ })(isResourceKey(relatedIdentifier)) : {};
1652
1683
  if (cache.recordIsLoaded(relatedIdentifier, true)) {
1653
1684
  identifiers.push(relatedIdentifier);
1654
1685
  }
@@ -1664,23 +1695,20 @@ class LegacySupport {
1664
1695
  }
1665
1696
  if (!manyArray) {
1666
1697
  const [identifiers, doc] = this._getCurrentState(this.identifier, key);
1667
- manyArray = new RelatedCollection({
1698
+ manyArray = createLegacyManyArray({
1668
1699
  store: this.store,
1669
- type: definition.type,
1670
- identifier: this.identifier,
1671
- cache: this.cache,
1672
- field: this.store.schema.fields(this.identifier).get(key),
1673
- identifiers,
1674
- key,
1675
- meta: doc.meta || null,
1676
- links: doc.links || null,
1677
- isPolymorphic: definition.isPolymorphic,
1678
- isAsync: definition.isAsync,
1679
- _inverseIsAsync: definition.inverseIsAsync,
1680
1700
  // @ts-expect-error Typescript doesn't have a way for us to thread the generic backwards so it infers unknown instead of T
1681
1701
  manager: this,
1702
+ source: identifiers,
1703
+ type: definition.type,
1682
1704
  isLoaded: !definition.isAsync,
1683
- allowMutation: true
1705
+ editable: true,
1706
+ isAsync: definition.isAsync,
1707
+ isPolymorphic: definition.isPolymorphic,
1708
+ field: this.store.schema.fields(this.identifier).get(key),
1709
+ identifier: this.identifier,
1710
+ links: doc.links || null,
1711
+ meta: doc.meta || null
1684
1712
  });
1685
1713
  this._manyArrayCache[key] = manyArray;
1686
1714
  }
@@ -1901,7 +1929,7 @@ class LegacySupport {
1901
1929
  if (!test) {
1902
1930
  throw new Error(`Expected stable identifiers`);
1903
1931
  }
1904
- })(!identifiers || identifiers.every(isStableIdentifier)) : {};
1932
+ })(!identifiers || identifiers.every(isResourceKey)) : {};
1905
1933
  const req = field.options.linksMode ? {
1906
1934
  url: getRelatedLink(resource),
1907
1935
  op: 'findHasMany',
@@ -1936,7 +1964,7 @@ class LegacySupport {
1936
1964
  if (!test) {
1937
1965
  throw new Error(`Expected stable identifiers`);
1938
1966
  }
1939
- })(identifiers.every(isStableIdentifier)) : {};
1967
+ })(identifiers.every(isResourceKey)) : {};
1940
1968
  options.reload = options.reload || !attemptLocalCache || undefined;
1941
1969
  return this.store.request({
1942
1970
  op: 'findHasMany',
@@ -1975,7 +2003,7 @@ class LegacySupport {
1975
2003
  if (!test) {
1976
2004
  throw new Error(`Expected a stable identifier`);
1977
2005
  }
1978
- })(!identifier || isStableIdentifier(identifier)) : {};
2006
+ })(!identifier || isResourceKey(identifier)) : {};
1979
2007
  const {
1980
2008
  isStale,
1981
2009
  hasDematerializedInverse,
@@ -2104,7 +2132,7 @@ function handleCompletedRelationshipRequest(recordExt, key, relationship, value,
2104
2132
  if (isHasMany) {
2105
2133
  // we don't notify the record property here to avoid refetch
2106
2134
  // only the many array
2107
- notifyInternalSignal(value[ARRAY_SIGNAL]);
2135
+ notifyInternalSignal(value[Context].signal);
2108
2136
  }
2109
2137
  if (error) {
2110
2138
  relationship.state.hasFailedLoadAttempt = true;
@@ -2142,6 +2170,7 @@ function extractIdentifierFromRecord(record) {
2142
2170
  return recordIdentifierFor(record);
2143
2171
  }
2144
2172
  function anyUnloaded(store, relationship) {
2173
+ assertPrivateStore(store);
2145
2174
  const graph = store._graph;
2146
2175
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
2147
2176
  if (!test) {
@@ -2158,6 +2187,7 @@ function anyUnloaded(store, relationship) {
2158
2187
  return unloaded || false;
2159
2188
  }
2160
2189
  function areAllInverseRecordsLoaded(store, resource) {
2190
+ assertPrivateStore(store);
2161
2191
  const instanceCache = store._instanceCache;
2162
2192
  const identifiers = resource.data;
2163
2193
  if (Array.isArray(identifiers)) {
@@ -2165,7 +2195,7 @@ function areAllInverseRecordsLoaded(store, resource) {
2165
2195
  if (!test) {
2166
2196
  throw new Error(`Expected stable identifiers`);
2167
2197
  }
2168
- })(identifiers.every(isStableIdentifier)) : {};
2198
+ })(identifiers.every(isResourceKey)) : {};
2169
2199
  // treat as collection
2170
2200
  // check for unloaded records
2171
2201
  return identifiers.every(identifier => instanceCache.recordIsLoaded(identifier));
@@ -2177,7 +2207,7 @@ function areAllInverseRecordsLoaded(store, resource) {
2177
2207
  if (!test) {
2178
2208
  throw new Error(`Expected stable identifiers`);
2179
2209
  }
2180
- })(isStableIdentifier(identifiers)) : {};
2210
+ })(isResourceKey(identifiers)) : {};
2181
2211
  return instanceCache.recordIsLoaded(identifiers);
2182
2212
  }
2183
2213
  function isBelongsTo(relationship) {
@@ -1,2 +1 @@
1
- export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-BX5wowuz.js";
2
- export { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
1
+ export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-8kD2mSe_.js";
@@ -1,10 +1,11 @@
1
1
  import { deprecate } from '@ember/debug';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
- import { notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
3
+ import { Context } from '@warp-drive/core/reactive/-private';
4
+ import { notifyInternalSignal, assertPrivateStore } from '@warp-drive/core/store/-private';
4
5
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
5
6
  import { Type } from '@warp-drive/core/types/symbols';
6
- import { l as lookupLegacySupport, E as Errors } from "../errors-BX5wowuz.js";
7
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-Cbnf6sKm.js";
7
+ import { l as lookupLegacySupport, E as Errors } from "../errors-8kD2mSe_.js";
8
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-DQu4Rjco.js";
8
9
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
9
10
 
10
11
  /**
@@ -314,6 +315,7 @@ function registerDerivations(schema) {
314
315
  return lookupLegacySupport(record).getBelongsTo(field.name);
315
316
  },
316
317
  set(store, record, cacheKey, field, value) {
318
+ assertPrivateStore(store);
317
319
  store._join(() => {
318
320
  // FIXME field.name here should likely be field.sourceKey || field.name
319
321
  lookupLegacySupport(record).setDirtyBelongsTo(field.name, value);
@@ -326,6 +328,7 @@ function registerDerivations(schema) {
326
328
  return lookupLegacySupport(record).getHasMany(field.name);
327
329
  },
328
330
  set(store, record, cacheKey, field, value) {
331
+ assertPrivateStore(store);
329
332
  store._join(() => {
330
333
  const support = lookupLegacySupport(record);
331
334
  // FIXME field.name here should likely be field.sourceKey || field.name
@@ -344,7 +347,7 @@ function registerDerivations(schema) {
344
347
  return false;
345
348
  }
346
349
  if (manyArray) {
347
- notifyInternalSignal(manyArray[ARRAY_SIGNAL]);
350
+ notifyInternalSignal(manyArray[Context].signal);
348
351
  return true;
349
352
  }
350
353
  return false;
package/dist/model.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { computed } from '@ember/object';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
- import { peekCache, setRecordIdentifier, StoreMap, setCacheFor } from '@warp-drive/core/store/-private';
3
+ import { RecordStore } from '@warp-drive/core/types/symbols';
4
4
  import { i as isElementDescriptor, n as normalizeModelName } from "./util-Dul6TZts.js";
5
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
6
  import { warn, deprecate } from '@ember/debug';
7
- import { RecordStore } from '@warp-drive/core/types/symbols';
8
- import { l as lookupLegacySupport } from "./errors-BX5wowuz.js";
7
+ import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
8
+ import { l as lookupLegacySupport } from "./errors-8kD2mSe_.js";
9
9
  import { singularize, dasherize } from '@warp-drive/utilities/string';
10
- import { l as getModelFactory } from "./schema-provider-Cbnf6sKm.js";
11
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-Cbnf6sKm.js";
10
+ import { l as getModelFactory } from "./schema-provider-DQu4Rjco.js";
11
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-DQu4Rjco.js";
12
12
  import { setOwner, getOwner } from '@ember/application';
13
13
  function _attr(type, options) {
14
14
  if (typeof type === 'object') {
@@ -34,7 +34,8 @@ function _attr(type, options) {
34
34
  if (this.isDestroyed || this.isDestroying) {
35
35
  return;
36
36
  }
37
- return peekCache(this).getAttr(recordIdentifierFor(this), key);
37
+ const cache = this[RecordStore].cache;
38
+ return cache.getAttr(recordIdentifierFor(this), key);
38
39
  },
39
40
  set(key, value) {
40
41
  if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
@@ -48,7 +49,7 @@ function _attr(type, options) {
48
49
  throw new Error(`Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`);
49
50
  }
50
51
  })(!this.currentState.isDeleted) : {};
51
- const cache = peekCache(this);
52
+ const cache = this[RecordStore].cache;
52
53
  const currentValue = cache.getAttr(identifier, key);
53
54
  if (currentValue !== value) {
54
55
  cache.setAttr(identifier, key, value);
@@ -246,6 +247,7 @@ function _belongsTo(type, options) {
246
247
  throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`);
247
248
  }
248
249
  }
250
+ assertPrivateStore(this[RecordStore]);
249
251
  this[RecordStore]._join(() => {
250
252
  support.setDirtyBelongsTo(key, value);
251
253
  });
@@ -484,6 +486,7 @@ function _hasMany(type, options) {
484
486
  throw new Error(`You must pass an array of records to set a hasMany relationship`);
485
487
  }
486
488
  })(Array.isArray(records)) : {};
489
+ assertPrivateStore(this[RecordStore]);
487
490
  this[RecordStore]._join(() => {
488
491
  manyArray.splice(0, manyArray.length, ...records);
489
492
  });
@@ -667,14 +670,13 @@ function hasMany(type, options) {
667
670
  }
668
671
  function instantiateRecord(identifier, createRecordArgs) {
669
672
  const type = identifier.type;
670
- const cache = this.cache;
673
+
671
674
  // TODO deprecate allowing unknown args setting
672
675
  const createOptions = {
673
676
  _createProps: createRecordArgs,
674
677
  // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
675
678
  _secretInit: {
676
679
  identifier,
677
- cache,
678
680
  store: this,
679
681
  cb: secretInit
680
682
  }
@@ -699,6 +701,7 @@ function teardownRecord(record) {
699
701
  record.destroy();
700
702
  }
701
703
  function modelFor(modelName) {
704
+ assertPrivateStore(this);
702
705
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
703
706
  if (!test) {
704
707
  throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
@@ -729,9 +732,8 @@ function modelFor(modelName) {
729
732
  type
730
733
  })) : {};
731
734
  }
732
- function secretInit(record, cache, identifier, store) {
735
+ function secretInit(record, identifier, store) {
733
736
  setRecordIdentifier(record, identifier);
734
737
  StoreMap.set(record, store);
735
- setCacheFor(record, cache);
736
738
  }
737
739
  export { attr, belongsTo, hasMany, instantiateRecord, modelFor, teardownRecord };
@@ -2,12 +2,13 @@ import { getOwner } from '@ember/application';
2
2
  import { deprecate } from '@ember/debug';
3
3
  import EmberObject from '@ember/object';
4
4
  import { recordIdentifierFor, storeFor } from '@warp-drive/core';
5
- import { peekCache, notifyInternalSignal, peekInternalSignal, withSignalStore, ARRAY_SIGNAL, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
5
+ import { assertPrivateStore, notifyInternalSignal, peekInternalSignal, withSignalStore, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
6
6
  import { RecordStore } from '@warp-drive/core/types/symbols';
7
- import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-BX5wowuz.js";
8
- import { u as upgradeStore, F as FetchManager } from "./-private-CKrP0ogQ.js";
7
+ import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-8kD2mSe_.js";
8
+ import { u as upgradeStore, F as FetchManager } from "./-private-8UmnAf9J.js";
9
9
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
10
  import { cacheFor } from '@ember/object/internals';
11
+ import { Context } from '@warp-drive/core/reactive/-private';
11
12
  import { d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
12
13
  import { n as normalizeModelName } from "./util-Dul6TZts.js";
13
14
  function rollbackAttributes() {
@@ -17,8 +18,10 @@ function rollbackAttributes() {
17
18
  const {
18
19
  isNew
19
20
  } = currentState;
20
- this[RecordStore]._join(() => {
21
- peekCache(this).rollbackAttrs(recordIdentifierFor(this));
21
+ const store = this[RecordStore];
22
+ assertPrivateStore(store);
23
+ store._join(() => {
24
+ store.cache.rollbackAttrs(recordIdentifierFor(this));
22
25
  this.errors.clear();
23
26
  currentState.cleanErrorRequests();
24
27
  if (isNew) {
@@ -84,7 +87,7 @@ function _reload(options = {}) {
84
87
  return promise;
85
88
  }
86
89
  function changedAttributes() {
87
- return peekCache(this).changedAttrs(recordIdentifierFor(this));
90
+ return this[RecordStore].cache.changedAttrs(recordIdentifierFor(this));
88
91
  }
89
92
  function serialize(options) {
90
93
  upgradeStore(this[RecordStore]);
@@ -215,7 +218,7 @@ function notifyRelationship(identifier, key, record, meta) {
215
218
  return;
216
219
  }
217
220
  if (manyArray) {
218
- notifyInternalSignal(manyArray[ARRAY_SIGNAL]);
221
+ notifyInternalSignal(manyArray[Context].signal);
219
222
 
220
223
  //We need to notifyPropertyChange in the adding case because we need to make sure
221
224
  //we fetch the newly added record in case it is unloaded
@@ -287,11 +290,34 @@ root
287
290
  invalid
288
291
  inFlight
289
292
 
290
- @internal
293
+ @hideconstructor
294
+ @private
291
295
  */
292
296
  class RecordState {
297
+ /** @internal */
298
+
299
+ /** @internal */
300
+
301
+ /** @internal */
302
+
303
+ /** @internal */
304
+
305
+ /** @internal */
306
+
307
+ /** @internal */
308
+
309
+ /** @internal */
310
+
311
+ /** @internal */
312
+
313
+ /** @internal */
314
+
315
+ /** @internal */
316
+
317
+ /** @internal */
318
+
293
319
  constructor(record) {
294
- const store = storeFor(record);
320
+ const store = storeFor(record, false);
295
321
  const identity = recordIdentifierFor$1(record);
296
322
  this.identifier = identity;
297
323
  this.record = record;
@@ -382,7 +408,7 @@ class RecordState {
382
408
 
383
409
  /** @internal */
384
410
  destroy() {
385
- storeFor(this.record).notifications.unsubscribe(this.handler);
411
+ storeFor(this.record, false).notifications.unsubscribe(this.handler);
386
412
  }
387
413
 
388
414
  /** @internal */
@@ -719,7 +745,7 @@ class Model extends EmberObject {
719
745
  super.init(options);
720
746
  this[RecordStore] = store;
721
747
  const identity = _secretInit.identifier;
722
- _secretInit.cb(this, _secretInit.cache, identity, _secretInit.store);
748
+ _secretInit.cb(this, identity, _secretInit.store);
723
749
  this.___recordState = macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? new RecordState(this) : null;
724
750
  this.setProperties(createProps);
725
751
  const notifications = store.notifications;
@@ -728,16 +754,18 @@ class Model extends EmberObject {
728
754
  });
729
755
  }
730
756
 
731
- /** @internal */
757
+ /** @private */
732
758
  // @ts-expect-error destroy should not return a value, but ember's types force it to
733
759
  destroy() {
734
760
  const identifier = recordIdentifierFor(this);
735
761
  this.___recordState?.destroy();
736
- const store = storeFor(this);
762
+ const store = storeFor(this, false);
737
763
  store.notifications.unsubscribe(this.___private_notifications);
738
- LEGACY_SUPPORT.get(this)?.destroy();
739
- LEGACY_SUPPORT.delete(this);
740
- LEGACY_SUPPORT.delete(identifier);
764
+ const support = LEGACY_SUPPORT.get(identifier);
765
+ if (support) {
766
+ support.destroy();
767
+ LEGACY_SUPPORT.delete(identifier);
768
+ }
741
769
  super.destroy();
742
770
  }
743
771
 
@@ -1027,6 +1055,7 @@ class Model extends EmberObject {
1027
1055
  const normalizedId = coerceId(id);
1028
1056
  const identifier = recordIdentifierFor(this);
1029
1057
  const didChange = normalizedId !== identifier.id;
1058
+ assertPrivateStore(this.store);
1030
1059
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1031
1060
  if (!test) {
1032
1061
  throw new Error(`Cannot set ${identifier.type} record's id to ${id}, because id is already ${identifier.id}`);
@@ -1034,7 +1063,7 @@ class Model extends EmberObject {
1034
1063
  })(!didChange || identifier.id === null) : {};
1035
1064
  if (normalizedId !== null && didChange) {
1036
1065
  this.store._instanceCache.setRecordId(identifier, normalizedId);
1037
- this.store.notifications.notify(identifier, 'identity');
1066
+ this.store.notifications.notify(identifier, 'identity', null);
1038
1067
  }
1039
1068
  }
1040
1069
  toString() {
@@ -1202,8 +1231,8 @@ class Model extends EmberObject {
1202
1231
  }
1203
1232
  ```
1204
1233
  @public
1205
- @param {Function} callback the callback to invoke
1206
- @param {any} binding the value to which the callback's `this` should be bound
1234
+ @param callback the callback to invoke
1235
+ @param binding the value to which the callback's `this` should be bound
1207
1236
  */
1208
1237
  eachRelationship(callback, binding) {
1209
1238
  this.constructor.eachRelationship(callback, binding);
@@ -1212,7 +1241,7 @@ class Model extends EmberObject {
1212
1241
  return this.constructor.relationshipsByName.get(name);
1213
1242
  }
1214
1243
  inverseFor(name) {
1215
- return this.constructor.inverseFor(name, storeFor(this));
1244
+ return this.constructor.inverseFor(name, storeFor(this, false));
1216
1245
  }
1217
1246
  eachAttribute(callback, binding) {
1218
1247
  this.constructor.eachAttribute(callback, binding);
@@ -1274,9 +1303,9 @@ class Model extends EmberObject {
1274
1303
  ```
1275
1304
  Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.
1276
1305
  @public
1277
- @param {String} name the name of the relationship
1278
- @param {store} store an instance of Store
1279
- @return {Model} the type of the relationship, or undefined
1306
+ @param name the name of the relationship
1307
+ @param store an instance of Store
1308
+ @return the type of the relationship, or undefined
1280
1309
  */
1281
1310
  static typeForRelationship(name, store) {
1282
1311
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
@@ -1316,9 +1345,9 @@ class Model extends EmberObject {
1316
1345
  store.modelFor('message').inverseFor('owner', store) // { type: 'post', name: 'comments', kind: 'hasMany' }
1317
1346
  ```
1318
1347
  @public
1319
- @param {String} name the name of the relationship
1320
- @param {Store} store
1321
- @return {Object} the inverse relationship, or null
1348
+ @param name the name of the relationship
1349
+ @param store
1350
+ @return the inverse relationship, or null
1322
1351
  */
1323
1352
  static {
1324
1353
  decorateMethodV2(this, "inverseMap", [computeOnce]);
@@ -2068,6 +2097,12 @@ function modelForMixin(store, normalizedModelName) {
2068
2097
  return owner.factoryFor(`model:${normalizedModelName}`);
2069
2098
  }
2070
2099
  class ModelSchemaProvider {
2100
+ /** @internal */
2101
+
2102
+ /** @internal */
2103
+
2104
+ /** @internal */
2105
+
2071
2106
  constructor(store) {
2072
2107
  this.store = store;
2073
2108
  this._schemas = new Map();
@@ -2155,6 +2190,7 @@ class ModelSchemaProvider {
2155
2190
  }
2156
2191
  })() : {};
2157
2192
  }
2193
+ /** @internal */
2158
2194
  _loadModelSchema(type) {
2159
2195
  const modelClass = this.store.modelFor(type);
2160
2196
  const attributeMap = modelClass.attributes;
@@ -1,7 +1,8 @@
1
1
  import { warn } from '@ember/debug';
2
2
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
3
+ import '@warp-drive/core/reactive/-private';
4
+ import "./-private-8UmnAf9J.js";
3
5
  import '@warp-drive/core/store/-private';
4
- import "./-private-CKrP0ogQ.js";
5
6
  const newline = /\r?\n/;
6
7
  function parseResponseHeaders(headersString) {
7
8
  const headers = Object.create(null);