@ember-data/model 4.10.0-beta.2 → 4.10.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.
@@ -749,7 +749,7 @@ function anyUnloaded(store: Store, relationship: ManyRelationship) {
749
749
  return unloaded || false;
750
750
  }
751
751
 
752
- export function areAllInverseRecordsLoaded(store: Store, resource: JsonApiRelationship): boolean {
752
+ function areAllInverseRecordsLoaded(store: Store, resource: JsonApiRelationship): boolean {
753
753
  const instanceCache = store._instanceCache;
754
754
  const identifiers = resource.data;
755
755
 
@@ -2,7 +2,6 @@ import { assert } from '@ember/debug';
2
2
  import { computed } from '@ember/object';
3
3
  import type PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
4
4
  import type ObjectProxy from '@ember/object/proxy';
5
- import { cached } from '@glimmer/tracking';
6
5
 
7
6
  import type Store from '@ember-data/store';
8
7
  import type { RecordInstance } from '@ember-data/types/q/record-instance';
@@ -10,7 +9,6 @@ import type { Dict } from '@ember-data/types/q/utils';
10
9
 
11
10
  import { LegacySupport } from './legacy-relationships-support';
12
11
  import { PromiseObject } from './promise-proxy-base';
13
- import type BelongsToReference from './references/belongs-to';
14
12
 
15
13
  export interface BelongsToProxyMeta {
16
14
  key: string;
@@ -47,15 +45,6 @@ const Extended: PromiseObjectType<RecordInstance> = PromiseObject as unknown as
47
45
  */
48
46
  class PromiseBelongsTo extends Extended<RecordInstance> {
49
47
  declare _belongsToState: BelongsToProxyMeta;
50
-
51
- @cached
52
- get id() {
53
- const { key, legacySupport } = this._belongsToState;
54
- const ref = legacySupport.referenceFor('belongsTo', key) as BelongsToReference;
55
-
56
- return ref.id();
57
- }
58
-
59
48
  // we don't proxy meta because we would need to proxy it to the relationship state container
60
49
  // however, meta on relationships does not trigger change notifications.
61
50
  // if you need relationship meta, you should do `record.belongsTo(relationshipName).meta()`
@@ -23,7 +23,7 @@ import type { RecordInstance } from '@ember-data/types/q/record-instance';
23
23
  import type { Dict } from '@ember-data/types/q/utils';
24
24
 
25
25
  import { assertPolymorphicType } from '../debug/assert-polymorphic-type';
26
- import { areAllInverseRecordsLoaded, LegacySupport } from '../legacy-relationships-support';
26
+ import type { LegacySupport } from '../legacy-relationships-support';
27
27
  import { LEGACY_SUPPORT } from '../model';
28
28
 
29
29
  /**
@@ -112,6 +112,7 @@ export default class BelongsToReference {
112
112
  @cached
113
113
  @dependentKeyCompat
114
114
  get identifier(): StableRecordIdentifier | null {
115
+ this._ref; // consume the tracked prop
115
116
  if (this.___relatedToken) {
116
117
  this.store._notificationManager.unsubscribe(this.___relatedToken);
117
118
  this.___relatedToken = null;
@@ -292,7 +293,6 @@ export default class BelongsToReference {
292
293
  }
293
294
 
294
295
  _resource() {
295
- this._ref; // subscribe
296
296
  return this.store._instanceCache
297
297
  .getRecordData(this.___identifier)
298
298
  .getRelationship(this.___identifier, this.key) as SingleResourceRelationship;
@@ -562,11 +562,7 @@ export default class BelongsToReference {
562
562
  const support: LegacySupport = (LEGACY_SUPPORT as Map<StableRecordIdentifier, LegacySupport>).get(
563
563
  this.___identifier
564
564
  )!;
565
- const fetchSyncRel =
566
- !this.belongsToRelationship.definition.isAsync && !areAllInverseRecordsLoaded(this.store, this._resource());
567
- return fetchSyncRel
568
- ? support.reloadBelongsTo(this.key, options).then(() => this.value())
569
- : support.getBelongsTo(this.key, options);
565
+ return support.getBelongsTo(this.key, options);
570
566
  }
571
567
 
572
568
  /**
@@ -28,7 +28,7 @@ import type { FindOptions } from '@ember-data/types/q/store';
28
28
  import type { Dict } from '@ember-data/types/q/utils';
29
29
 
30
30
  import { assertPolymorphicType } from '../debug/assert-polymorphic-type';
31
- import { areAllInverseRecordsLoaded, LegacySupport } from '../legacy-relationships-support';
31
+ import type { LegacySupport } from '../legacy-relationships-support';
32
32
  import { LEGACY_SUPPORT } from '../model';
33
33
 
34
34
  /**
@@ -607,11 +607,7 @@ export default class HasManyReference {
607
607
  const support: LegacySupport = (LEGACY_SUPPORT as Map<StableRecordIdentifier, LegacySupport>).get(
608
608
  this.___identifier
609
609
  )!;
610
- const fetchSyncRel =
611
- !this.hasManyRelationship.definition.isAsync && !areAllInverseRecordsLoaded(this.store, this._resource());
612
- return fetchSyncRel
613
- ? (support.reloadHasMany(this.key, options) as Promise<ManyArray>)
614
- : (support.getHasMany(this.key, options) as Promise<ManyArray> | ManyArray); // this cast is necessary because typescript does not work properly with custom thenables;
610
+ return support.getHasMany(this.key, options) as Promise<ManyArray> | ManyArray; // this cast is necessary because typescript does not work properly with custom thenables;
615
611
  }
616
612
 
617
613
  /**
package/index.js CHANGED
@@ -27,7 +27,6 @@ module.exports = Object.assign({}, addonBaseConfig, {
27
27
  '@ember/array/mutable',
28
28
  '@ember/array/proxy',
29
29
  '@ember/debug',
30
- '@ember/error',
31
30
  '@ember/object',
32
31
  '@ember/object/compat',
33
32
  '@ember/object/computed',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-data/model",
3
- "version": "4.10.0-beta.2",
3
+ "version": "4.10.0",
4
4
  "description": "A presentation layer for apps built with @ember-data/store",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -14,10 +14,10 @@
14
14
  "author": "",
15
15
  "directories": {},
16
16
  "peerDependencies": {
17
- "@ember-data/record-data": "4.10.0-beta.2",
18
- "@ember-data/store": "4.10.0-beta.2",
19
- "@ember-data/tracking": "4.10.0-beta.2",
20
- "@ember/string": "^3.0.0",
17
+ "@ember-data/record-data": "4.10.0",
18
+ "@ember-data/store": "4.10.0",
19
+ "@ember-data/tracking": "4.10.0",
20
+ "@ember/string": "^3.0.1",
21
21
  "ember-inflector": "^4.0.2"
22
22
  },
23
23
  "peerDependenciesMeta": {
@@ -34,11 +34,11 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@ember-data/canary-features": "4.10.0-beta.2",
38
- "@ember-data/private-build-infra": "4.10.0-beta.2",
37
+ "@ember-data/canary-features": "4.10.0",
38
+ "@ember-data/private-build-infra": "4.10.0",
39
39
  "@ember/edition-utils": "^1.2.0",
40
40
  "@embroider/macros": "^1.10.0",
41
- "ember-auto-import": "^2.5.0",
41
+ "ember-auto-import": "^2.4.3",
42
42
  "ember-cached-decorator-polyfill": "^1.0.1",
43
43
  "ember-cli-babel": "^7.26.11",
44
44
  "ember-cli-string-utils": "^1.1.0",
@@ -59,6 +59,6 @@
59
59
  "volta": {
60
60
  "extends": "../../package.json"
61
61
  },
62
- "packageManager": "pnpm@7.18.0",
62
+ "packageManager": "pnpm@7.15.0",
63
63
  "scripts": {}
64
64
  }