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

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 (29) hide show
  1. package/package.json +19 -19
  2. package/unstable-preview-types/-private/attr.d.ts +171 -169
  3. package/unstable-preview-types/-private/attr.type-test.d.ts +4 -2
  4. package/unstable-preview-types/-private/belongs-to.d.ts +181 -179
  5. package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -2
  6. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -6
  7. package/unstable-preview-types/-private/errors.d.ts +290 -288
  8. package/unstable-preview-types/-private/has-many.d.ts +170 -168
  9. package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -2
  10. package/unstable-preview-types/-private/hooks.d.ts +13 -11
  11. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +62 -60
  12. package/unstable-preview-types/-private/many-array.d.ts +193 -191
  13. package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -4
  14. package/unstable-preview-types/-private/model-methods.d.ts +34 -32
  15. package/unstable-preview-types/-private/model.d.ts +103 -100
  16. package/unstable-preview-types/-private/model.type-test.d.ts +4 -2
  17. package/unstable-preview-types/-private/notify-changes.d.ts +8 -6
  18. package/unstable-preview-types/-private/promise-belongs-to.d.ts +47 -45
  19. package/unstable-preview-types/-private/promise-many-array.d.ts +129 -127
  20. package/unstable-preview-types/-private/promise-proxy-base.d.ts +35 -32
  21. package/unstable-preview-types/-private/record-state.d.ts +88 -86
  22. package/unstable-preview-types/-private/references/belongs-to.d.ts +473 -471
  23. package/unstable-preview-types/-private/references/has-many.d.ts +488 -486
  24. package/unstable-preview-types/-private/schema-provider.d.ts +27 -25
  25. package/unstable-preview-types/-private/util.d.ts +11 -9
  26. package/unstable-preview-types/-private.d.ts +12 -10
  27. package/unstable-preview-types/hooks.d.ts +5 -3
  28. package/unstable-preview-types/index.d.ts +75 -46
  29. package/unstable-preview-types/migration-support.d.ts +11 -9
@@ -1,195 +1,197 @@
1
- import type Store from '@ember-data/store';
2
- import { MUTATE, RecordArray } from '@ember-data/store/-private';
3
- import type { CreateRecordProperties } from '@ember-data/store/-private/store-service';
4
- import type { Cache } from '@ember-data/store/-types/q/cache';
5
- import type { ModelSchema } from '@ember-data/store/-types/q/ds-model';
6
- import type { BaseFinderOptions } from '@ember-data/store/-types/q/store';
7
- import type { Signal } from '@ember-data/tracking/-private';
8
- import type { StableRecordIdentifier } from '@warp-drive/core-types';
9
- import type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';
10
- import type { Links, PaginationLinks } from '@warp-drive/core-types/spec/raw';
11
- import type { LegacySupport } from './legacy-relationships-support';
12
- export interface ManyArrayCreateArgs {
13
- identifiers: StableRecordIdentifier[];
14
- type: string;
15
- store: Store;
16
- allowMutation: boolean;
17
- manager: LegacySupport;
18
- identifier: StableRecordIdentifier;
19
- cache: Cache;
20
- meta: Record<string, unknown> | null;
21
- links: Links | PaginationLinks | null;
22
- key: string;
23
- isPolymorphic: boolean;
24
- isAsync: boolean;
25
- _inverseIsAsync: boolean;
26
- isLoaded: boolean;
27
- }
28
- /**
29
- A `ManyArray` is a `MutableArray` that represents the contents of a has-many
30
- relationship.
31
-
32
- The `ManyArray` is instantiated lazily the first time the relationship is
33
- requested.
34
-
35
- This class is not intended to be directly instantiated by consuming applications.
36
-
37
- ### Inverses
38
-
39
- Often, the relationships in Ember Data applications will have
40
- an inverse. For example, imagine the following models are
41
- defined:
42
-
43
- ```app/models/post.js
44
- import Model, { hasMany } from '@ember-data/model';
45
-
46
- export default class PostModel extends Model {
47
- @hasMany('comment') comments;
1
+ declare module '@ember-data/model/-private/many-array' {
2
+ import type Store from '@ember-data/store';
3
+ import { MUTATE, RecordArray } from '@ember-data/store/-private';
4
+ import type { CreateRecordProperties } from '@ember-data/store/-private/store-service';
5
+ import type { Cache } from '@ember-data/store/-types/q/cache';
6
+ import type { ModelSchema } from '@ember-data/store/-types/q/ds-model';
7
+ import type { BaseFinderOptions } from '@ember-data/store/-types/q/store';
8
+ import type { Signal } from '@ember-data/tracking/-private';
9
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
10
+ import type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';
11
+ import type { Links, PaginationLinks } from '@warp-drive/core-types/spec/raw';
12
+ import type { LegacySupport } from '@ember-data/model/-private/legacy-relationships-support';
13
+ export interface ManyArrayCreateArgs {
14
+ identifiers: StableRecordIdentifier[];
15
+ type: string;
16
+ store: Store;
17
+ allowMutation: boolean;
18
+ manager: LegacySupport;
19
+ identifier: StableRecordIdentifier;
20
+ cache: Cache;
21
+ meta: Record<string, unknown> | null;
22
+ links: Links | PaginationLinks | null;
23
+ key: string;
24
+ isPolymorphic: boolean;
25
+ isAsync: boolean;
26
+ _inverseIsAsync: boolean;
27
+ isLoaded: boolean;
48
28
  }
49
- ```
50
-
51
- ```app/models/comment.js
52
- import Model, { belongsTo } from '@ember-data/model';
53
-
54
- export default class CommentModel extends Model {
55
- @belongsTo('post') post;
56
- }
57
- ```
58
-
59
- If you created a new instance of `Post` and added
60
- a `Comment` record to its `comments` has-many
61
- relationship, you would expect the comment's `post`
62
- property to be set to the post that contained
63
- the has-many.
64
-
65
- We call the record to which a relationship belongs-to the
66
- relationship's _owner_.
67
-
68
- @class ManyArray
69
- @public
70
- */
71
- export default class RelatedCollection<T = unknown> extends RecordArray<T> {
72
- isAsync: boolean;
73
- /**
74
- The loading state of this array
75
-
76
- @property {Boolean} isLoaded
77
- @public
29
+ /**
30
+ A `ManyArray` is a `MutableArray` that represents the contents of a has-many
31
+ relationship.
32
+
33
+ The `ManyArray` is instantiated lazily the first time the relationship is
34
+ requested.
35
+
36
+ This class is not intended to be directly instantiated by consuming applications.
37
+
38
+ ### Inverses
39
+
40
+ Often, the relationships in Ember Data applications will have
41
+ an inverse. For example, imagine the following models are
42
+ defined:
43
+
44
+ ```app/models/post.js
45
+ import Model, { hasMany } from '@ember-data/model';
46
+
47
+ export default class PostModel extends Model {
48
+ @hasMany('comment') comments;
49
+ }
50
+ ```
51
+
52
+ ```app/models/comment.js
53
+ import Model, { belongsTo } from '@ember-data/model';
54
+
55
+ export default class CommentModel extends Model {
56
+ @belongsTo('post') post;
57
+ }
58
+ ```
59
+
60
+ If you created a new instance of `Post` and added
61
+ a `Comment` record to its `comments` has-many
62
+ relationship, you would expect the comment's `post`
63
+ property to be set to the post that contained
64
+ the has-many.
65
+
66
+ We call the record to which a relationship belongs-to the
67
+ relationship's _owner_.
68
+
69
+ @class ManyArray
70
+ @public
71
+ */
72
+ export default class RelatedCollection<T = unknown> extends RecordArray<T> {
73
+ isAsync: boolean;
74
+ /**
75
+ The loading state of this array
76
+
77
+ @property {Boolean} isLoaded
78
+ @public
79
+ */
80
+ isLoaded: boolean;
81
+ /**
82
+ `true` if the relationship is polymorphic, `false` otherwise.
83
+
84
+ @property {Boolean} isPolymorphic
85
+ @private
86
+ */
87
+ isPolymorphic: boolean;
88
+ _inverseIsAsync: boolean;
89
+ /**
90
+ Metadata associated with the request for async hasMany relationships.
91
+
92
+ Example
93
+
94
+ Given that the server returns the following JSON payload when fetching a
95
+ hasMany relationship:
96
+
97
+ ```js
98
+ {
99
+ "comments": [{
100
+ "id": 1,
101
+ "comment": "This is the first comment",
102
+ }, {
103
+ // ...
104
+ }],
105
+
106
+ "meta": {
107
+ "page": 1,
108
+ "total": 5
109
+ }
110
+ }
111
+ ```
112
+
113
+ You can then access the meta data via the `meta` property:
114
+
115
+ ```js
116
+ let comments = await post.comments;
117
+ let meta = comments.meta;
118
+
119
+ // meta.page => 1
120
+ // meta.total => 5
121
+ ```
122
+
123
+ @property {Object | null} meta
124
+ @public
125
+ */
126
+ meta: Record<string, unknown> | null;
127
+ /**
128
+ * Retrieve the links for this relationship
129
+ *
130
+ @property {Object | null} links
131
+ @public
132
+ */
133
+ links: Links | PaginationLinks | null;
134
+ identifier: StableRecordIdentifier;
135
+ cache: Cache;
136
+ _manager: LegacySupport;
137
+ store: Store;
138
+ key: string;
139
+ type: ModelSchema;
140
+ modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
141
+ constructor(options: ManyArrayCreateArgs);
142
+ [MUTATE](target: StableRecordIdentifier[], receiver: typeof Proxy<StableRecordIdentifier[], T[]>, prop: string, args: unknown[], _SIGNAL: Signal): unknown;
143
+ notify(): void;
144
+ /**
145
+ Reloads all of the records in the manyArray. If the manyArray
146
+ holds a relationship that was originally fetched using a links url
147
+ Ember Data will revisit the original links url to repopulate the
148
+ relationship.
149
+
150
+ If the manyArray holds the result of a `store.query()` reload will
151
+ re-run the original query.
152
+
153
+ Example
154
+
155
+ ```javascript
156
+ let user = store.peekRecord('user', '1')
157
+ await login(user);
158
+
159
+ let permissions = await user.permissions;
160
+ await permissions.reload();
161
+ ```
162
+
163
+ @method reload
164
+ @public
78
165
  */
79
- isLoaded: boolean;
80
- /**
81
- `true` if the relationship is polymorphic, `false` otherwise.
82
-
83
- @property {Boolean} isPolymorphic
84
- @private
166
+ reload(options?: BaseFinderOptions): Promise<unknown> | import("./promise-many-array").default<unknown>;
167
+ /**
168
+ Saves all of the records in the `ManyArray`.
169
+
170
+ Example
171
+
172
+ ```javascript
173
+ let inbox = await store.findRecord('inbox', '1');
174
+ let messages = await inbox.messages;
175
+ messages.forEach((message) => {
176
+ message.isRead = true;
177
+ });
178
+ messages.save();
179
+ ```
180
+
181
+ @method save
182
+ @public
183
+ @return {PromiseArray} promise
85
184
  */
86
- isPolymorphic: boolean;
87
- _inverseIsAsync: boolean;
88
- /**
89
- Metadata associated with the request for async hasMany relationships.
90
-
91
- Example
92
-
93
- Given that the server returns the following JSON payload when fetching a
94
- hasMany relationship:
95
-
96
- ```js
97
- {
98
- "comments": [{
99
- "id": 1,
100
- "comment": "This is the first comment",
101
- }, {
102
- // ...
103
- }],
104
-
105
- "meta": {
106
- "page": 1,
107
- "total": 5
108
- }
109
- }
110
- ```
111
-
112
- You can then access the meta data via the `meta` property:
113
-
114
- ```js
115
- let comments = await post.comments;
116
- let meta = comments.meta;
117
-
118
- // meta.page => 1
119
- // meta.total => 5
120
- ```
121
-
122
- @property {Object | null} meta
123
- @public
185
+ /**
186
+ Create a child record within the owner
187
+
188
+ @method createRecord
189
+ @public
190
+ @param {Object} hash
191
+ @return {Model} record
124
192
  */
125
- meta: Record<string, unknown> | null;
126
- /**
127
- * Retrieve the links for this relationship
128
- *
129
- @property {Object | null} links
130
- @public
131
- */
132
- links: Links | PaginationLinks | null;
133
- identifier: StableRecordIdentifier;
134
- cache: Cache;
135
- _manager: LegacySupport;
136
- store: Store;
137
- key: string;
138
- type: ModelSchema;
139
- modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
140
- constructor(options: ManyArrayCreateArgs);
141
- [MUTATE](target: StableRecordIdentifier[], receiver: typeof Proxy<StableRecordIdentifier[], T[]>, prop: string, args: unknown[], _SIGNAL: Signal): unknown;
142
- notify(): void;
143
- /**
144
- Reloads all of the records in the manyArray. If the manyArray
145
- holds a relationship that was originally fetched using a links url
146
- Ember Data will revisit the original links url to repopulate the
147
- relationship.
148
-
149
- If the manyArray holds the result of a `store.query()` reload will
150
- re-run the original query.
151
-
152
- Example
153
-
154
- ```javascript
155
- let user = store.peekRecord('user', '1')
156
- await login(user);
157
-
158
- let permissions = await user.permissions;
159
- await permissions.reload();
160
- ```
161
-
162
- @method reload
163
- @public
164
- */
165
- reload(options?: BaseFinderOptions): Promise<unknown> | import("./promise-many-array").default<unknown>;
166
- /**
167
- Saves all of the records in the `ManyArray`.
168
-
169
- Example
170
-
171
- ```javascript
172
- let inbox = await store.findRecord('inbox', '1');
173
- let messages = await inbox.messages;
174
- messages.forEach((message) => {
175
- message.isRead = true;
176
- });
177
- messages.save();
178
- ```
179
-
180
- @method save
181
- @public
182
- @return {PromiseArray} promise
183
- */
184
- /**
185
- Create a child record within the owner
186
-
187
- @method createRecord
188
- @public
189
- @param {Object} hash
190
- @return {Model} record
191
- */
192
- createRecord(hash: CreateRecordProperties<T>): T;
193
- destroy(): void;
194
- }
195
- //# sourceMappingURL=many-array.d.ts.map
193
+ createRecord(hash: CreateRecordProperties<T>): T;
194
+ destroy(): void;
195
+ }
196
+ //# sourceMappingURL=many-array.d.ts.map
197
+ }
@@ -1,4 +1,6 @@
1
- import type Store from '@ember-data/store';
2
- import { type ModelFactory } from './model';
3
- export default function modelForMixin(store: Store, normalizedModelName: string): ModelFactory | undefined;
4
- //# sourceMappingURL=model-for-mixin.d.ts.map
1
+ declare module '@ember-data/model/-private/model-for-mixin' {
2
+ import type Store from '@ember-data/store';
3
+ import { type ModelFactory } from '@ember-data/model/-private/model';
4
+ export default function modelForMixin(store: Store, normalizedModelName: string): ModelFactory | undefined;
5
+ //# sourceMappingURL=model-for-mixin.d.ts.map
6
+ }
@@ -1,32 +1,34 @@
1
- import type { Snapshot } from '@ember-data/legacy-compat/-private';
2
- import type Store from '@ember-data/store';
3
- import type { ChangedAttributesHash } from '@warp-drive/core-types/cache';
4
- import { RecordStore } from '@warp-drive/core-types/symbols';
5
- import type Errors from './errors';
6
- import type RecordState from './record-state';
7
- export interface MinimalLegacyRecord {
8
- errors: Errors;
9
- ___recordState: RecordState;
10
- currentState: RecordState;
11
- isDestroyed: boolean;
12
- isDestroying: boolean;
13
- isReloading: boolean;
14
- isValid: boolean;
15
- [RecordStore]: Store;
16
- deleteRecord(): void;
17
- unloadRecord(): void;
18
- save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
19
- destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
20
- }
21
- export declare function rollbackAttributes(this: MinimalLegacyRecord): void;
22
- export declare function unloadRecord(this: MinimalLegacyRecord): void;
23
- export declare function belongsTo(this: MinimalLegacyRecord, prop: string): import("./references/belongs-to").default<unknown, string, unknown> | import("./references/has-many").default<unknown, string, unknown>;
24
- export declare function hasMany(this: MinimalLegacyRecord, prop: string): import("./references/belongs-to").default<unknown, string, unknown> | import("./references/has-many").default<unknown, string, unknown>;
25
- export declare function reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
26
- export declare function changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;
27
- export declare function serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown;
28
- export declare function deleteRecord<T extends MinimalLegacyRecord>(this: T): void;
29
- export declare function save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
30
- export declare function destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
31
- export declare function createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;
32
- //# sourceMappingURL=model-methods.d.ts.map
1
+ declare module '@ember-data/model/-private/model-methods' {
2
+ import type { Snapshot } from '@ember-data/legacy-compat/-private';
3
+ import type Store from '@ember-data/store';
4
+ import type { ChangedAttributesHash } from '@warp-drive/core-types/cache';
5
+ import { RecordStore } from '@warp-drive/core-types/symbols';
6
+ import type Errors from '@ember-data/model/-private/errors';
7
+ import type RecordState from '@ember-data/model/-private/record-state';
8
+ export interface MinimalLegacyRecord {
9
+ errors: Errors;
10
+ ___recordState: RecordState;
11
+ currentState: RecordState;
12
+ isDestroyed: boolean;
13
+ isDestroying: boolean;
14
+ isReloading: boolean;
15
+ isValid: boolean;
16
+ [RecordStore]: Store;
17
+ deleteRecord(): void;
18
+ unloadRecord(): void;
19
+ save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
20
+ destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
21
+ }
22
+ export declare function rollbackAttributes(this: MinimalLegacyRecord): void;
23
+ export declare function unloadRecord(this: MinimalLegacyRecord): void;
24
+ export declare function belongsTo(this: MinimalLegacyRecord, prop: string): import("./references/belongs-to").default<unknown, string, unknown> | import("./references/has-many").default<unknown, string, unknown>;
25
+ export declare function hasMany(this: MinimalLegacyRecord, prop: string): import("./references/belongs-to").default<unknown, string, unknown> | import("./references/has-many").default<unknown, string, unknown>;
26
+ export declare function reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
27
+ export declare function changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;
28
+ export declare function serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown;
29
+ export declare function deleteRecord<T extends MinimalLegacyRecord>(this: T): void;
30
+ export declare function save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
31
+ export declare function destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
32
+ export declare function createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;
33
+ //# sourceMappingURL=model-methods.d.ts.map
34
+ }