@ember-data/model 5.4.0-alpha.32 → 5.4.0-alpha.34

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 (37) hide show
  1. package/addon/-private.js +1 -1
  2. package/addon/{has-many-Qm5aUQol.js → has-many-Mz5PIxmL.js} +10 -0
  3. package/addon/{has-many-Qm5aUQol.js.map → has-many-Mz5PIxmL.js.map} +1 -1
  4. package/addon/index.js +1 -1
  5. package/addon/model-eXqU5A13.js.map +1 -1
  6. package/package.json +19 -19
  7. package/unstable-preview-types/-private/attr.d.ts +170 -168
  8. package/unstable-preview-types/-private/attr.type-test.d.ts +3 -1
  9. package/unstable-preview-types/-private/belongs-to.d.ts +179 -178
  10. package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -1
  11. package/unstable-preview-types/-private/belongs-to.type-test.d.ts +3 -1
  12. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +7 -5
  13. package/unstable-preview-types/-private/errors.d.ts +288 -286
  14. package/unstable-preview-types/-private/has-many.d.ts +168 -167
  15. package/unstable-preview-types/-private/has-many.d.ts.map +1 -1
  16. package/unstable-preview-types/-private/has-many.type-test.d.ts +3 -1
  17. package/unstable-preview-types/-private/hooks.d.ts +12 -10
  18. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -58
  19. package/unstable-preview-types/-private/many-array.d.ts +192 -189
  20. package/unstable-preview-types/-private/many-array.d.ts.map +1 -1
  21. package/unstable-preview-types/-private/model-for-mixin.d.ts +5 -3
  22. package/unstable-preview-types/-private/model-methods.d.ts +32 -30
  23. package/unstable-preview-types/-private/model.d.ts +103 -100
  24. package/unstable-preview-types/-private/model.type-test.d.ts +3 -1
  25. package/unstable-preview-types/-private/notify-changes.d.ts +7 -5
  26. package/unstable-preview-types/-private/promise-belongs-to.d.ts +45 -43
  27. package/unstable-preview-types/-private/promise-many-array.d.ts +127 -125
  28. package/unstable-preview-types/-private/promise-proxy-base.d.ts +35 -32
  29. package/unstable-preview-types/-private/record-state.d.ts +86 -84
  30. package/unstable-preview-types/-private/references/belongs-to.d.ts +471 -469
  31. package/unstable-preview-types/-private/references/has-many.d.ts +486 -484
  32. package/unstable-preview-types/-private/schema-provider.d.ts +25 -23
  33. package/unstable-preview-types/-private/util.d.ts +10 -8
  34. package/unstable-preview-types/-private.d.ts +11 -9
  35. package/unstable-preview-types/hooks.d.ts +4 -2
  36. package/unstable-preview-types/index.d.ts +74 -45
  37. package/unstable-preview-types/migration-support.d.ts +10 -8
@@ -1,168 +1,169 @@
1
- import type { TypeFromInstance } from '@warp-drive/core-types/record';
2
- import type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to';
3
- /**
4
- `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
5
- relationships on a [Model](/ember-data/release/classes/Model).
6
-
7
- `hasMany` takes a configuration hash as a second parameter, currently
8
- supported options are:
9
-
10
- - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.
11
- - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
12
- - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
13
- - `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism.
14
-
15
- ### Examples
16
-
17
- To declare a **many-to-one** (or one-to-many) relationship, use
18
- `belongsTo` in combination with `hasMany`:
19
-
20
- ```js
21
- // app/models/post.js
22
- import Model, { hasMany } from '@ember-data/model';
23
-
24
- export default class Post extends Model {
25
- @hasMany('comment', { async: false, inverse: 'post' }) comments;
26
- }
27
-
28
-
29
- // app/models/comment.js
30
- import Model, { belongsTo } from '@ember-data/model';
31
-
32
- export default class Comment extends Model {
33
- @belongsTo('post', { async: false, inverse: 'comments' }) post;
34
- }
35
- ```
36
-
37
- To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:
38
-
39
- ```js
40
- // app/models/post.js
41
- import Model, { hasMany } from '@ember-data/model';
42
-
43
- export default class Post extends Model {
44
- @hasMany('tag', { async: true, inverse: 'posts' }) tags;
45
- }
46
-
47
- // app/models/tag.js
48
- import Model, { hasMany } from '@ember-data/model';
49
-
50
- export default class Tag extends Model {
51
- @hasMany('post', { async: true, inverse: 'tags' }) posts;
52
- }
53
- ```
54
-
55
- To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides
56
- with `null` as the inverse:
57
-
58
- ```js
59
- // app/models/post.js
60
- import Model, { hasMany } from '@ember-data/model';
61
-
62
- export default class Post extends Model {
63
- @hasMany('tag', { async: true, inverse: null }) tags;
64
- }
65
-
66
- // app/models/tag.js
67
- import Model, { hasMany } from '@ember-data/model';
68
-
69
- export default class Tag extends Model {
70
- @hasMany('post', { async: true, inverse: null }) posts;
71
- }
72
- ```
73
-
74
- To declare a many-to-none relationship between two models, use
75
- `hasMany` with inverse set to `null` on just one side::
76
-
77
- ```js
78
- // app/models/post.js
79
- import Model, { hasMany } from '@ember-data/model';
80
-
81
- export default class Post extends Model {
82
- @hasMany('category', { async: true, inverse: null }) categories;
83
- }
84
- ```
85
-
86
- #### Sync vs Async Relationships
87
-
88
- EmberData fulfills relationships using resource data available in
89
- the cache.
90
-
91
- Sync relationships point directly to the known related resources.
92
-
93
- When a relationship is declared as async, if any of the known related
94
- resources have not been loaded, they will be fetched. The property
95
- on the record when accessed provides a promise that resolves once
96
- all resources are loaded.
97
-
98
- Async relationships may take advantage of links. On access, if the related
99
- link has not been loaded, or if any known resources are not available in
100
- the cache, the fresh state will be fetched using the link.
101
-
102
- In contrast to async relationship, accessing a sync relationship
103
- will error on access when any of the known related resources have
104
- not been loaded.
105
-
106
- If you are using `links` with sync relationships, you have to use
107
- the HasMany reference API to fetch or refresh related resources
108
- that aren't loaded. For instance, for a `comments` relationship:
109
-
110
- ```js
111
- post.hasMany('comments').reload();
112
- ```
113
-
114
- #### Polymorphic Relationships
115
-
116
- To declare a polymorphic relationship, use `hasMany` with the `polymorphic`
117
- option set to `true`:
118
-
119
- ```js
120
- // app/models/comment.js
121
- import Model, { belongsTo } from '@ember-data/model';
122
-
123
- export default class Comment extends Model {
124
- @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
125
- }
126
- ```
127
-
128
- `'commentable'` here is referred to as the "abstract type" for the polymorphic
129
- relationship.
130
-
131
- Polymorphic relationships with `inverse: null` will accept any type of record as their content.
132
- Polymorphic relationships with `inverse` set to a string will only accept records with a matching
133
- inverse relationships declaring itself as satisfying the abstract type.
134
-
135
- Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'
136
- for this relationship.
137
-
138
- ```js
139
- // app/models/post.js
140
- import Model, { hasMany } from '@ember-data/model';
141
-
142
- export default class Post extends Model {
143
- @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
144
- }
145
- ```
146
-
147
- Note: every Model that declares an inverse to a polymorphic relationship must
148
- declare itself exactly the same. This is because polymorphism is based on structural
149
- traits.
150
-
151
- Polymorphic to polymorphic relationships are supported. Both sides of the relationship
152
- must be declared as polymorphic, and the `as` option must be used to declare the abstract
153
- type each record satisfies on both sides.
154
-
155
- @method hasMany
156
- @public
157
- @static
158
- @for @ember-data/model
159
- @param {string} type (optional) the name of the related resource
160
- @param {object} options (optional) a hash of options
161
- @return {PropertyDescriptor} relationship
162
- */
163
- export declare function hasMany(): never;
164
- export declare function hasMany(type: string): never;
165
- export declare function hasMany<T>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, false>): RelationshipDecorator<T>;
166
- export declare function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, true>): RelationshipDecorator<K>;
167
- export declare function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;
1
+ declare module '@ember-data/model/-private/has-many' {
2
+ import type { TypeFromInstance } from '@warp-drive/core-types/record';
3
+ import type { NoNull, RelationshipDecorator, RelationshipOptions } from '@ember-data/model/-private/belongs-to';
4
+ /**
5
+ `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
6
+ relationships on a [Model](/ember-data/release/classes/Model).
7
+
8
+ `hasMany` takes a configuration hash as a second parameter, currently
9
+ supported options are:
10
+
11
+ - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.
12
+ - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
13
+ - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
14
+ - `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism.
15
+
16
+ ### Examples
17
+
18
+ To declare a **many-to-one** (or one-to-many) relationship, use
19
+ `belongsTo` in combination with `hasMany`:
20
+
21
+ ```js
22
+ // app/models/post.js
23
+ import Model, { hasMany } from '@ember-data/model';
24
+
25
+ export default class Post extends Model {
26
+ @hasMany('comment', { async: false, inverse: 'post' }) comments;
27
+ }
28
+
29
+
30
+ // app/models/comment.js
31
+ import Model, { belongsTo } from '@ember-data/model';
32
+
33
+ export default class Comment extends Model {
34
+ @belongsTo('post', { async: false, inverse: 'comments' }) post;
35
+ }
36
+ ```
37
+
38
+ To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:
39
+
40
+ ```js
41
+ // app/models/post.js
42
+ import Model, { hasMany } from '@ember-data/model';
43
+
44
+ export default class Post extends Model {
45
+ @hasMany('tag', { async: true, inverse: 'posts' }) tags;
46
+ }
47
+
48
+ // app/models/tag.js
49
+ import Model, { hasMany } from '@ember-data/model';
50
+
51
+ export default class Tag extends Model {
52
+ @hasMany('post', { async: true, inverse: 'tags' }) posts;
53
+ }
54
+ ```
55
+
56
+ To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides
57
+ with `null` as the inverse:
58
+
59
+ ```js
60
+ // app/models/post.js
61
+ import Model, { hasMany } from '@ember-data/model';
62
+
63
+ export default class Post extends Model {
64
+ @hasMany('tag', { async: true, inverse: null }) tags;
65
+ }
66
+
67
+ // app/models/tag.js
68
+ import Model, { hasMany } from '@ember-data/model';
69
+
70
+ export default class Tag extends Model {
71
+ @hasMany('post', { async: true, inverse: null }) posts;
72
+ }
73
+ ```
74
+
75
+ To declare a many-to-none relationship between two models, use
76
+ `hasMany` with inverse set to `null` on just one side::
77
+
78
+ ```js
79
+ // app/models/post.js
80
+ import Model, { hasMany } from '@ember-data/model';
81
+
82
+ export default class Post extends Model {
83
+ @hasMany('category', { async: true, inverse: null }) categories;
84
+ }
85
+ ```
86
+
87
+ #### Sync vs Async Relationships
88
+
89
+ EmberData fulfills relationships using resource data available in
90
+ the cache.
91
+
92
+ Sync relationships point directly to the known related resources.
93
+
94
+ When a relationship is declared as async, if any of the known related
95
+ resources have not been loaded, they will be fetched. The property
96
+ on the record when accessed provides a promise that resolves once
97
+ all resources are loaded.
98
+
99
+ Async relationships may take advantage of links. On access, if the related
100
+ link has not been loaded, or if any known resources are not available in
101
+ the cache, the fresh state will be fetched using the link.
102
+
103
+ In contrast to async relationship, accessing a sync relationship
104
+ will error on access when any of the known related resources have
105
+ not been loaded.
106
+
107
+ If you are using `links` with sync relationships, you have to use
108
+ the HasMany reference API to fetch or refresh related resources
109
+ that aren't loaded. For instance, for a `comments` relationship:
110
+
111
+ ```js
112
+ post.hasMany('comments').reload();
113
+ ```
114
+
115
+ #### Polymorphic Relationships
116
+
117
+ To declare a polymorphic relationship, use `hasMany` with the `polymorphic`
118
+ option set to `true`:
119
+
120
+ ```js
121
+ // app/models/comment.js
122
+ import Model, { belongsTo } from '@ember-data/model';
123
+
124
+ export default class Comment extends Model {
125
+ @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
126
+ }
127
+ ```
128
+
129
+ `'commentable'` here is referred to as the "abstract type" for the polymorphic
130
+ relationship.
131
+
132
+ Polymorphic relationships with `inverse: null` will accept any type of record as their content.
133
+ Polymorphic relationships with `inverse` set to a string will only accept records with a matching
134
+ inverse relationships declaring itself as satisfying the abstract type.
135
+
136
+ Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'
137
+ for this relationship.
138
+
139
+ ```js
140
+ // app/models/post.js
141
+ import Model, { hasMany } from '@ember-data/model';
142
+
143
+ export default class Post extends Model {
144
+ @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
145
+ }
146
+ ```
147
+
148
+ Note: every Model that declares an inverse to a polymorphic relationship must
149
+ declare itself exactly the same. This is because polymorphism is based on structural
150
+ traits.
151
+
152
+ Polymorphic to polymorphic relationships are supported. Both sides of the relationship
153
+ must be declared as polymorphic, and the `as` option must be used to declare the abstract
154
+ type each record satisfies on both sides.
155
+
156
+ @method hasMany
157
+ @public
158
+ @static
159
+ @for @ember-data/model
160
+ @param {string} type (optional) the name of the related resource
161
+ @param {object} options (optional) a hash of options
162
+ @return {PropertyDescriptor} relationship
163
+ */
164
+ export declare function hasMany(): never;
165
+ export declare function hasMany(type: string): never;
166
+ export declare function hasMany<T>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, boolean>): RelationshipDecorator<T>;
167
+ export declare function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;
168
+ }
168
169
  //# sourceMappingURL=has-many.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"has-many.d.ts","sourceRoot":"","sources":["../../src/-private/has-many.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAkFvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JE;AACF,wBAAgB,OAAO,IAAI,KAAK,CAAC;AACjC,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,GACrC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAC5B,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACnF,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,GACpC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAC5B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"has-many.d.ts","sourceRoot":"","sources":["../../src/-private/has-many.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAkFvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JE;AACF,wBAAgB,OAAO,IAAI,KAAK,CAAC;AACjC,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,OAAO,CAAC,GACvC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAK5B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC"}
@@ -1,2 +1,4 @@
1
- export {};
1
+ declare module '@ember-data/model/-private/has-many.type-test' {
2
+ export {};
3
+ }
2
4
  //# sourceMappingURL=has-many.type-test.d.ts.map
@@ -1,11 +1,13 @@
1
- import { type Store } from '@ember-data/store/-private';
2
- import type { StableRecordIdentifier } from '@warp-drive/core-types';
3
- import type { TypeFromInstance } from '@warp-drive/core-types/record';
4
- import type { Model } from './model';
5
- export declare function instantiateRecord(this: Store, identifier: StableRecordIdentifier, createRecordArgs: {
6
- [key: string]: unknown;
7
- }): Model;
8
- export declare function teardownRecord(record: Model): void;
9
- export declare function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;
10
- export declare function modelFor(type: string): typeof Model | void;
1
+ declare module '@ember-data/model/-private/hooks' {
2
+ import { type Store } from '@ember-data/store/-private';
3
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
4
+ import type { TypeFromInstance } from '@warp-drive/core-types/record';
5
+ import type { Model } from '@ember-data/model/-private/model';
6
+ export declare function instantiateRecord(this: Store, identifier: StableRecordIdentifier, createRecordArgs: {
7
+ [key: string]: unknown;
8
+ }): Model;
9
+ export declare function teardownRecord(record: Model): void;
10
+ export declare function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;
11
+ export declare function modelFor(type: string): typeof Model | void;
12
+ }
11
13
  //# sourceMappingURL=hooks.d.ts.map
@@ -1,60 +1,62 @@
1
- import type { UpgradedMeta } from '@ember-data/graph/-private/-edge-definition';
2
- import type { CollectionEdge } from '@ember-data/graph/-private/edges/collection';
3
- import type { ResourceEdge } from '@ember-data/graph/-private/edges/resource';
4
- import type { Graph } from '@ember-data/graph/-private/graph';
5
- import type Store from '@ember-data/store';
6
- import type { Cache } from '@ember-data/store/-types/q/cache';
7
- import type { JsonApiRelationship } from '@ember-data/store/-types/q/record-data-json-api';
8
- import type { OpaqueRecordInstance } from '@ember-data/store/-types/q/record-instance';
9
- import type { BaseFinderOptions } from '@ember-data/store/-types/q/store';
10
- import type { StableRecordIdentifier } from '@warp-drive/core-types';
11
- import type { CollectionRelationship } from '@warp-drive/core-types/cache/relationship';
12
- import type { LocalRelationshipOperation } from '@warp-drive/core-types/graph';
13
- import type { CollectionResourceRelationship, SingleResourceRelationship } from '@warp-drive/core-types/spec/raw';
14
- import RelatedCollection from './many-array';
15
- import type { MinimalLegacyRecord } from './model-methods';
16
- import type { BelongsToProxyCreateArgs } from './promise-belongs-to';
17
- import { PromiseBelongsTo } from './promise-belongs-to';
18
- import type { HasManyProxyCreateArgs } from './promise-many-array';
19
- import PromiseManyArray from './promise-many-array';
20
- import BelongsToReference from './references/belongs-to';
21
- import HasManyReference from './references/has-many';
22
- export declare const LEGACY_SUPPORT: Map<StableRecordIdentifier | MinimalLegacyRecord, LegacySupport>;
23
- export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
24
- export declare class LegacySupport {
25
- record: MinimalLegacyRecord;
26
- store: Store;
27
- graph: Graph;
28
- cache: Cache;
29
- references: Record<string, BelongsToReference | HasManyReference>;
30
- identifier: StableRecordIdentifier;
31
- _manyArrayCache: Record<string, RelatedCollection>;
32
- _relationshipPromisesCache: Record<string, Promise<RelatedCollection | OpaqueRecordInstance>>;
33
- _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
34
- _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
35
- isDestroying: boolean;
36
- isDestroyed: boolean;
37
- constructor(record: MinimalLegacyRecord);
38
- _syncArray(array: RelatedCollection): void;
39
- mutate(mutation: LocalRelationshipOperation): void;
40
- _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
41
- reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
42
- getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
43
- setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
44
- _getCurrentState(identifier: StableRecordIdentifier, field: string): [StableRecordIdentifier[], CollectionRelationship];
45
- getManyArray<T>(key: string, definition?: UpgradedMeta): RelatedCollection<T>;
46
- fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: RelatedCollection, options?: BaseFinderOptions): Promise<RelatedCollection>;
47
- reloadHasMany(key: string, options?: BaseFinderOptions): Promise<unknown> | PromiseManyArray<unknown>;
48
- getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | RelatedCollection;
49
- _updatePromiseProxyFor(kind: 'hasMany', key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
50
- _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
51
- _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: {
52
- promise: Promise<OpaqueRecordInstance | null>;
53
- }): PromiseBelongsTo;
54
- referenceFor(kind: string | null, name: string): BelongsToReference<unknown, string, unknown> | HasManyReference<unknown, string, unknown>;
55
- _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
56
- _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<StableRecordIdentifier | null>;
57
- destroy(): void;
1
+ declare module '@ember-data/model/-private/legacy-relationships-support' {
2
+ import type { UpgradedMeta } from '@ember-data/graph/-private/-edge-definition';
3
+ import type { CollectionEdge } from '@ember-data/graph/-private/edges/collection';
4
+ import type { ResourceEdge } from '@ember-data/graph/-private/edges/resource';
5
+ import type { Graph } from '@ember-data/graph/-private/graph';
6
+ import type Store from '@ember-data/store';
7
+ import type { Cache } from '@ember-data/store/-types/q/cache';
8
+ import type { JsonApiRelationship } from '@ember-data/store/-types/q/record-data-json-api';
9
+ import type { OpaqueRecordInstance } from '@ember-data/store/-types/q/record-instance';
10
+ import type { BaseFinderOptions } from '@ember-data/store/-types/q/store';
11
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
12
+ import type { CollectionRelationship } from '@warp-drive/core-types/cache/relationship';
13
+ import type { LocalRelationshipOperation } from '@warp-drive/core-types/graph';
14
+ import type { CollectionResourceRelationship, SingleResourceRelationship } from '@warp-drive/core-types/spec/raw';
15
+ import RelatedCollection from '@ember-data/model/-private/many-array';
16
+ import type { MinimalLegacyRecord } from '@ember-data/model/-private/model-methods';
17
+ import type { BelongsToProxyCreateArgs } from '@ember-data/model/-private/promise-belongs-to';
18
+ import { PromiseBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
19
+ import type { HasManyProxyCreateArgs } from '@ember-data/model/-private/promise-many-array';
20
+ import PromiseManyArray from '@ember-data/model/-private/promise-many-array';
21
+ import BelongsToReference from '@ember-data/model/-private/references/belongs-to';
22
+ import HasManyReference from '@ember-data/model/-private/references/has-many';
23
+ export declare const LEGACY_SUPPORT: Map<StableRecordIdentifier | MinimalLegacyRecord, LegacySupport>;
24
+ export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
25
+ export declare class LegacySupport {
26
+ record: MinimalLegacyRecord;
27
+ store: Store;
28
+ graph: Graph;
29
+ cache: Cache;
30
+ references: Record<string, BelongsToReference | HasManyReference>;
31
+ identifier: StableRecordIdentifier;
32
+ _manyArrayCache: Record<string, RelatedCollection>;
33
+ _relationshipPromisesCache: Record<string, Promise<RelatedCollection | OpaqueRecordInstance>>;
34
+ _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
35
+ _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
36
+ isDestroying: boolean;
37
+ isDestroyed: boolean;
38
+ constructor(record: MinimalLegacyRecord);
39
+ _syncArray(array: RelatedCollection): void;
40
+ mutate(mutation: LocalRelationshipOperation): void;
41
+ _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
42
+ reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
43
+ getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
44
+ setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
45
+ _getCurrentState(identifier: StableRecordIdentifier, field: string): [StableRecordIdentifier[], CollectionRelationship];
46
+ getManyArray<T>(key: string, definition?: UpgradedMeta): RelatedCollection<T>;
47
+ fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: RelatedCollection, options?: BaseFinderOptions): Promise<RelatedCollection>;
48
+ reloadHasMany(key: string, options?: BaseFinderOptions): Promise<unknown> | PromiseManyArray<unknown>;
49
+ getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | RelatedCollection;
50
+ _updatePromiseProxyFor(kind: 'hasMany', key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
51
+ _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
52
+ _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: {
53
+ promise: Promise<OpaqueRecordInstance | null>;
54
+ }): PromiseBelongsTo;
55
+ referenceFor(kind: string | null, name: string): BelongsToReference<unknown, string, unknown> | HasManyReference<unknown, string, unknown>;
56
+ _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
57
+ _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<StableRecordIdentifier | null>;
58
+ destroy(): void;
59
+ }
60
+ export declare function areAllInverseRecordsLoaded(store: Store, resource: JsonApiRelationship): boolean;
58
61
  }
59
- export declare function areAllInverseRecordsLoaded(store: Store, resource: JsonApiRelationship): boolean;
60
62
  //# sourceMappingURL=legacy-relationships-support.d.ts.map