@ember-data/model 5.4.0-alpha.3 → 5.4.0-alpha.31
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 +2 -2
- package/addon/has-many-Qm5aUQol.js +645 -0
- package/addon/has-many-Qm5aUQol.js.map +1 -0
- package/addon/{hooks-0482f3cc.js → hooks-YY4O5eQM.js} +34 -15
- package/addon/hooks-YY4O5eQM.js.map +1 -0
- package/addon/hooks.js +1 -1
- package/addon/index.js +3 -3
- package/addon/index.js.map +1 -1
- package/addon/migration-support.js +118 -0
- package/addon/migration-support.js.map +1 -0
- package/addon/{model-48ae96f9.js → model-eXqU5A13.js} +2030 -1876
- package/addon/model-eXqU5A13.js.map +1 -0
- package/addon/util-Km_Z-hz0.js +35 -0
- package/addon/util-Km_Z-hz0.js.map +1 -0
- package/package.json +85 -34
- package/unstable-preview-types/-private/attr.d.ts +172 -0
- package/unstable-preview-types/-private/attr.d.ts.map +1 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts +2 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.d.ts +179 -0
- package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts +2 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +6 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
- package/unstable-preview-types/-private/errors.d.ts +306 -0
- package/unstable-preview-types/-private/errors.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.d.ts +168 -0
- package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts +2 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/hooks.d.ts +11 -0
- package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
- package/unstable-preview-types/-private/many-array.d.ts +195 -0
- package/unstable-preview-types/-private/many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts +4 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-methods.d.ts +32 -0
- package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.d.ts +101 -0
- package/unstable-preview-types/-private/model.type-test.d.ts +2 -0
- package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/notify-changes.d.ts +6 -0
- package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +45 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts +127 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-proxy-base.d.ts +32 -0
- package/unstable-preview-types/-private/record-state.d.ts +89 -0
- package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts +501 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/has-many.d.ts +513 -0
- package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/schema-provider.d.ts +25 -0
- package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
- package/unstable-preview-types/-private/util.d.ts +9 -0
- package/unstable-preview-types/-private/util.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +10 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/hooks.d.ts +3 -0
- package/unstable-preview-types/hooks.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +46 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
- package/unstable-preview-types/migration-support.d.ts +9 -0
- package/unstable-preview-types/migration-support.d.ts.map +1 -0
- package/addon/has-many-0759b264.js +0 -507
- package/addon/has-many-0759b264.js.map +0 -1
- package/addon/hooks-0482f3cc.js.map +0 -1
- package/addon/model-48ae96f9.js.map +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
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;
|
|
48
|
+
}
|
|
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
|
|
78
|
+
*/
|
|
79
|
+
isLoaded: boolean;
|
|
80
|
+
/**
|
|
81
|
+
`true` if the relationship is polymorphic, `false` otherwise.
|
|
82
|
+
|
|
83
|
+
@property {Boolean} isPolymorphic
|
|
84
|
+
@private
|
|
85
|
+
*/
|
|
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
|
|
124
|
+
*/
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC;IASvC,OAAO;CAGjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-for-mixin.d.ts","sourceRoot":"","sources":["../../src/-private/model-for-mixin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAkBnD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAYzG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-methods.d.ts","sourceRoot":"","sources":["../../src/-private/model-methods.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,WAAW,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAA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AG,IAAI,CAKzE;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,mBAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAW1G;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,mBAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAUnH;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,mBAAmB,EAAE,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAalF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type EmberObject from '@ember/object';
|
|
2
|
+
|
|
3
|
+
import type { Errors } from './errors';
|
|
4
|
+
import type Store from '@ember-data/store';
|
|
5
|
+
|
|
6
|
+
import type { AttributeSchema, RelationshipSchema, RelationshipsSchema } from '@warp-drive/core-types/schema';
|
|
7
|
+
import type { JsonApiError } from '@ember-data/store/-types/q/record-data-json-api';
|
|
8
|
+
import type HasManyReference from './references/has-many';
|
|
9
|
+
import type BelongsToReference from './references/belongs-to';
|
|
10
|
+
import type { StableRecordIdentifier } from '@warp-drive/core-types';
|
|
11
|
+
import type { LegacySupport } from './legacy-relationships-support';
|
|
12
|
+
import type { Cache } from '@warp-drive/core-types/cache';
|
|
13
|
+
import type RecordState from './record-state';
|
|
14
|
+
|
|
15
|
+
export type ModelCreateArgs = {
|
|
16
|
+
_createProps: Record<string, unknown>;
|
|
17
|
+
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
18
|
+
_secretInit: {
|
|
19
|
+
identifier: StableRecordIdentifier;
|
|
20
|
+
cache: Cache;
|
|
21
|
+
store: Store;
|
|
22
|
+
cb: (record: Model, cache: Cache, identifier: StableRecordIdentifier, store: Store) => void;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class Model extends EmberObject {
|
|
27
|
+
store: Store;
|
|
28
|
+
errors: Errors;
|
|
29
|
+
currentState: RecordState;
|
|
30
|
+
adapterError?: Error;
|
|
31
|
+
toString(): string;
|
|
32
|
+
save(): Promise<this>;
|
|
33
|
+
hasMany<T extends keyof this & string>(key: T): HasManyReference<this, T>;
|
|
34
|
+
belongsTo<T extends keyof this & string>(key: T): BelongsToReference<this, T>;
|
|
35
|
+
eachRelationship<T extends Model, K extends keyof T & string>(
|
|
36
|
+
callback: (this: T, key: K, meta: RelationshipSchema) => void,
|
|
37
|
+
binding?: T
|
|
38
|
+
): void;
|
|
39
|
+
eachAttribute<T extends Model, K extends keyof T & string>(
|
|
40
|
+
callback: (this: T, key: K, meta: AttributeSchema) => void,
|
|
41
|
+
binding?: T
|
|
42
|
+
): void;
|
|
43
|
+
invalidErrorsChanged(errors: JsonApiError[]): void;
|
|
44
|
+
rollbackAttributes(): void;
|
|
45
|
+
changedAttributes(): Record<string, [unknown, unknown]>;
|
|
46
|
+
id: string;
|
|
47
|
+
isValid: boolean;
|
|
48
|
+
isSaving: boolean;
|
|
49
|
+
isNew: boolean;
|
|
50
|
+
isEmpty: boolean;
|
|
51
|
+
isDeleted: boolean;
|
|
52
|
+
hasDirtyAttributes: boolean;
|
|
53
|
+
isLoaded: boolean;
|
|
54
|
+
isLoading: boolean;
|
|
55
|
+
isReloading: boolean;
|
|
56
|
+
dirtyType: string;
|
|
57
|
+
deleteRecord(): void;
|
|
58
|
+
unloadRecord(): void;
|
|
59
|
+
serialize(): Record<string, unknown>;
|
|
60
|
+
|
|
61
|
+
static modelName: string;
|
|
62
|
+
static fields: Map<keyof this & string, 'attribute' | 'belongsTo' | 'hasMany'>;
|
|
63
|
+
static attributes: Map<keyof this & string, AttributeSchema>;
|
|
64
|
+
static relationshipsByName: Map<keyof this & string, RelationshipSchema>;
|
|
65
|
+
static eachAttribute<K extends keyof this & string>(
|
|
66
|
+
callback: (this: ModelSchema<this>, key: K, attribute: AttributeSchema) => void,
|
|
67
|
+
binding?: T
|
|
68
|
+
): void;
|
|
69
|
+
static eachRelationship<K extends keyof this & string>(
|
|
70
|
+
callback: (this: ModelSchema<this>, key: K, relationship: RelationshipSchema) => void,
|
|
71
|
+
binding?: T
|
|
72
|
+
): void;
|
|
73
|
+
static eachTransformedAttribute<K extends keyof this & string>(
|
|
74
|
+
callback: (this: ModelSchema<this>, key: K, type: string | null) => void,
|
|
75
|
+
binding?: T
|
|
76
|
+
): void;
|
|
77
|
+
|
|
78
|
+
static toString(): string;
|
|
79
|
+
static isModel: true;
|
|
80
|
+
static relationshipsObject: RelationshipsSchema;
|
|
81
|
+
static extend(...mixins: unknown[]): typeof Model;
|
|
82
|
+
static create(createArgs: ModelCreateArgs): Model;
|
|
83
|
+
static __isMixin?: true;
|
|
84
|
+
static __mixin?: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Model {
|
|
88
|
+
constructor: typeof Model;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { Model };
|
|
92
|
+
|
|
93
|
+
export type StaticModel = typeof Model;
|
|
94
|
+
|
|
95
|
+
export const LEGACY_SUPPORT: Map<StableRecordIdentifier | Model, LegacySupport>;
|
|
96
|
+
|
|
97
|
+
export type ModelFactory = { class: StaticModel };
|
|
98
|
+
export type FactoryCache = Record<string, ModelFactory>;
|
|
99
|
+
// we put this on the store for interop because it's used by modelFor and
|
|
100
|
+
// instantiateRecord as well.
|
|
101
|
+
export type ModelStore = Store & { _modelFactoryCache: FactoryCache };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.type-test.d.ts","sourceRoot":"","sources":["../../src/-private/model.type-test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type Store from '@ember-data/store';
|
|
2
|
+
import type { NotificationType } from '@ember-data/store/-private/managers/notification-manager';
|
|
3
|
+
import type { StableRecordIdentifier } from '@warp-drive/core-types';
|
|
4
|
+
import type { Model } from './model';
|
|
5
|
+
export default function notifyChanges(identifier: StableRecordIdentifier, value: NotificationType, key: string | undefined, record: Model, store: Store): void;
|
|
6
|
+
//# sourceMappingURL=notify-changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify-changes.d.ts","sourceRoot":"","sources":["../../src/-private/notify-changes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AACjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,MAAM,EAAE,KAAK,EACb,KAAK,EAAE,KAAK,QAuBb"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="ember-source/types" />
|
|
2
|
+
/// <reference types="ember-source/types" />
|
|
3
|
+
import type PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
4
|
+
import type ObjectProxy from '@ember/object/proxy';
|
|
5
|
+
import type Store from '@ember-data/store';
|
|
6
|
+
import type { OpaqueRecordInstance } from '@ember-data/store/-types/q/record-instance';
|
|
7
|
+
import type { TypeFromInstanceOrString } from '@warp-drive/core-types/record';
|
|
8
|
+
import type { LegacySupport } from './legacy-relationships-support';
|
|
9
|
+
export interface BelongsToProxyMeta<T = unknown> {
|
|
10
|
+
key: string;
|
|
11
|
+
store: Store;
|
|
12
|
+
legacySupport: LegacySupport;
|
|
13
|
+
modelName: TypeFromInstanceOrString<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface BelongsToProxyCreateArgs<T = unknown> {
|
|
16
|
+
promise: Promise<T | null>;
|
|
17
|
+
content?: T | null;
|
|
18
|
+
_belongsToState: BelongsToProxyMeta<T>;
|
|
19
|
+
}
|
|
20
|
+
interface PromiseObjectType<T> extends PromiseProxyMixin<T | null>, ObjectProxy<T> {
|
|
21
|
+
new <PT>(...args: unknown[]): PromiseObjectType<PT>;
|
|
22
|
+
}
|
|
23
|
+
declare class PromiseObjectType<T> {
|
|
24
|
+
}
|
|
25
|
+
declare const Extended: PromiseObjectType<OpaqueRecordInstance>;
|
|
26
|
+
/**
|
|
27
|
+
@module @ember-data/model
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
A PromiseBelongsTo is a PromiseObject that also proxies certain method calls
|
|
31
|
+
to the underlying belongsTo model.
|
|
32
|
+
Right now we proxy:
|
|
33
|
+
* `reload()`
|
|
34
|
+
@class PromiseBelongsTo
|
|
35
|
+
@extends PromiseObject
|
|
36
|
+
@private
|
|
37
|
+
*/
|
|
38
|
+
declare class PromiseBelongsTo<T = unknown> extends Extended<T> {
|
|
39
|
+
_belongsToState: BelongsToProxyMeta<T>;
|
|
40
|
+
get id(): string | null;
|
|
41
|
+
get meta(): void;
|
|
42
|
+
reload(options: Record<string, unknown>): Promise<this>;
|
|
43
|
+
}
|
|
44
|
+
export { PromiseBelongsTo };
|
|
45
|
+
//# sourceMappingURL=promise-belongs-to.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-belongs-to.d.ts","sourceRoot":"","sources":["../../src/-private/promise-belongs-to.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,iBAAiB,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;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|
2
|
+
import type ManyArray from './many-array';
|
|
3
|
+
export interface HasManyProxyCreateArgs<T = unknown> {
|
|
4
|
+
promise: Promise<ManyArray<T>>;
|
|
5
|
+
content?: ManyArray<T>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
@module @ember-data/model
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
This class is returned as the result of accessing an async hasMany relationship
|
|
12
|
+
on an instance of a Model extending from `@ember-data/model`.
|
|
13
|
+
|
|
14
|
+
A PromiseManyArray is an iterable proxy that allows templates to consume related
|
|
15
|
+
ManyArrays and update once their contents are no longer pending.
|
|
16
|
+
|
|
17
|
+
In your JS code you should resolve the promise first.
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
const comments = await post.comments;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
@class PromiseManyArray
|
|
24
|
+
@public
|
|
25
|
+
*/
|
|
26
|
+
export default class PromiseManyArray<T = unknown> {
|
|
27
|
+
promise: Promise<ManyArray<T>> | null;
|
|
28
|
+
isDestroyed: boolean;
|
|
29
|
+
content: ManyArray<T> | null;
|
|
30
|
+
constructor(promise: Promise<ManyArray<T>>, content?: ManyArray<T>);
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve the length of the content
|
|
33
|
+
* @property length
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
get length(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Iterate the proxied content. Called by the glimmer iterator in #each
|
|
39
|
+
* We do not guarantee that forEach will always be available. This
|
|
40
|
+
* may eventually be made to use Symbol.Iterator once glimmer supports it.
|
|
41
|
+
*
|
|
42
|
+
* @method forEach
|
|
43
|
+
* @param cb
|
|
44
|
+
* @return
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
forEach(cb: (item: T, index: number, array: T[]) => void): void;
|
|
48
|
+
/**
|
|
49
|
+
* Reload the relationship
|
|
50
|
+
* @method reload
|
|
51
|
+
* @public
|
|
52
|
+
* @param options
|
|
53
|
+
* @return
|
|
54
|
+
*/
|
|
55
|
+
reload(options: Omit<BaseFinderOptions, ''>): this;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the loading promise is still pending
|
|
58
|
+
*
|
|
59
|
+
* @property {boolean} isPending
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
isPending: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the loading promise rejected
|
|
65
|
+
*
|
|
66
|
+
* @property {boolean} isRejected
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
isRejected: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the loading promise succeeded
|
|
72
|
+
*
|
|
73
|
+
* @property {boolean} isFulfilled
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
isFulfilled: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the loading promise completed (resolved or rejected)
|
|
79
|
+
*
|
|
80
|
+
* @property {boolean} isSettled
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
isSettled: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* chain this promise
|
|
86
|
+
*
|
|
87
|
+
* @method then
|
|
88
|
+
* @public
|
|
89
|
+
* @param success
|
|
90
|
+
* @param fail
|
|
91
|
+
* @return Promise
|
|
92
|
+
*/
|
|
93
|
+
then(s: Parameters<Promise<ManyArray<T>>['then']>[0], f?: Parameters<Promise<ManyArray<T>>['then']>[1]): Promise<unknown>;
|
|
94
|
+
/**
|
|
95
|
+
* catch errors thrown by this promise
|
|
96
|
+
* @method catch
|
|
97
|
+
* @public
|
|
98
|
+
* @param callback
|
|
99
|
+
* @return Promise
|
|
100
|
+
*/
|
|
101
|
+
catch(cb: Parameters<Promise<ManyArray<T>>['catch']>[0]): Promise<unknown>;
|
|
102
|
+
/**
|
|
103
|
+
* run cleanup after this promise completes
|
|
104
|
+
*
|
|
105
|
+
* @method finally
|
|
106
|
+
* @public
|
|
107
|
+
* @param callback
|
|
108
|
+
* @return Promise
|
|
109
|
+
*/
|
|
110
|
+
finally(cb: Parameters<Promise<ManyArray<T>>['finally']>[0]): Promise<ManyArray<T>>;
|
|
111
|
+
destroy(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Retrieve the links for this relationship
|
|
114
|
+
* @property links
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
get links(): import("@warp-drive/core-types/spec/raw").Links | null | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Retrieve the meta for this relationship
|
|
120
|
+
* @property meta
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
get meta(): Record<string, unknown> | null | undefined;
|
|
124
|
+
_update(promise: Promise<ManyArray<T>>, content?: ManyArray<T>): void;
|
|
125
|
+
static create<T>({ promise, content }: HasManyProxyCreateArgs<T>): PromiseManyArray<T>;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=promise-many-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-many-array.d.ts","sourceRoot":"","sources":["../../src/-private/promise-many-array.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAI1E,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,OAAO;IACjD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CACxB;AAED;;GAEG;AACH;;;;;;;;;;;;;;;EAeE;AACF,MAAM,CAAC,OAAO,OAAO,gBAAgB,CAAC,CAAC,GAAG,OAAO;IACvC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAA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P;IAID,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAQ9D,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;CAGvF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ObjectProxy from '@ember/object/proxy';
|
|
2
|
+
|
|
3
|
+
export interface PromiseObject<T> extends Promise<T> {}
|
|
4
|
+
export class PromiseObject<T> extends ObjectProxy<T> {
|
|
5
|
+
declare content?: T | null;
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* If the proxied promise is rejected this will contain the reason
|
|
9
|
+
* provided.
|
|
10
|
+
*/
|
|
11
|
+
reason: string | Error;
|
|
12
|
+
/*
|
|
13
|
+
* Once the proxied promise has settled this will become `false`.
|
|
14
|
+
*/
|
|
15
|
+
isPending: boolean;
|
|
16
|
+
/*
|
|
17
|
+
* Once the proxied promise has settled this will become `true`.
|
|
18
|
+
*/
|
|
19
|
+
isSettled: boolean;
|
|
20
|
+
/*
|
|
21
|
+
* Will become `true` if the proxied promise is rejected.
|
|
22
|
+
*/
|
|
23
|
+
isRejected: boolean;
|
|
24
|
+
/*
|
|
25
|
+
* Will become `true` if the proxied promise is fulfilled.
|
|
26
|
+
*/
|
|
27
|
+
isFulfilled: boolean;
|
|
28
|
+
/*
|
|
29
|
+
* The promise whose fulfillment value is being proxied by this object.
|
|
30
|
+
*/
|
|
31
|
+
promise: Promise<T>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type Store from '@ember-data/store';
|
|
2
|
+
import type RequestStateService from '@ember-data/store/-private/network/request-cache';
|
|
3
|
+
import type { RequestState } from '@ember-data/store/-private/network/request-cache';
|
|
4
|
+
import type { Cache } from '@ember-data/store/-types/q/cache';
|
|
5
|
+
import type { StableRecordIdentifier } from '@warp-drive/core-types';
|
|
6
|
+
import type Errors from './errors';
|
|
7
|
+
import type { MinimalLegacyRecord } from './model-methods';
|
|
8
|
+
/**
|
|
9
|
+
* A decorator that caches a getter while
|
|
10
|
+
* providing the ability to bust that cache
|
|
11
|
+
* when we so choose in a way that notifies
|
|
12
|
+
* tracking systems.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function tagged<T extends object, K extends keyof T & string>(_target: T, key: K, desc: PropertyDescriptor): PropertyDescriptor;
|
|
17
|
+
export declare function notifySignal<T extends object, K extends keyof T & string>(obj: T, key: K): void;
|
|
18
|
+
/**
|
|
19
|
+
Historically EmberData managed a state machine
|
|
20
|
+
for each record, the localState for which
|
|
21
|
+
was reflected onto Model.
|
|
22
|
+
|
|
23
|
+
This implements the flags and stateName for backwards compat
|
|
24
|
+
with the state tree that used to be possible (listed below).
|
|
25
|
+
|
|
26
|
+
stateName and dirtyType are candidates for deprecation.
|
|
27
|
+
|
|
28
|
+
root
|
|
29
|
+
empty
|
|
30
|
+
deleted // hidden from stateName
|
|
31
|
+
preloaded // hidden from stateName
|
|
32
|
+
|
|
33
|
+
loading
|
|
34
|
+
empty // hidden from stateName
|
|
35
|
+
preloaded // hidden from stateName
|
|
36
|
+
|
|
37
|
+
loaded
|
|
38
|
+
saved
|
|
39
|
+
updated
|
|
40
|
+
uncommitted
|
|
41
|
+
invalid
|
|
42
|
+
inFlight
|
|
43
|
+
created
|
|
44
|
+
uncommitted
|
|
45
|
+
invalid
|
|
46
|
+
inFlight
|
|
47
|
+
|
|
48
|
+
deleted
|
|
49
|
+
saved
|
|
50
|
+
new // hidden from stateName
|
|
51
|
+
uncommitted
|
|
52
|
+
invalid
|
|
53
|
+
inFlight
|
|
54
|
+
|
|
55
|
+
@internal
|
|
56
|
+
*/
|
|
57
|
+
export default class RecordState {
|
|
58
|
+
store: Store;
|
|
59
|
+
identifier: StableRecordIdentifier;
|
|
60
|
+
record: MinimalLegacyRecord;
|
|
61
|
+
rs: RequestStateService;
|
|
62
|
+
pendingCount: number;
|
|
63
|
+
fulfilledCount: number;
|
|
64
|
+
rejectedCount: number;
|
|
65
|
+
cache: Cache;
|
|
66
|
+
_errorRequests: RequestState[];
|
|
67
|
+
_lastError: RequestState | null;
|
|
68
|
+
handler: object;
|
|
69
|
+
constructor(record: MinimalLegacyRecord);
|
|
70
|
+
destroy(): void;
|
|
71
|
+
notify(key: keyof this & string): void;
|
|
72
|
+
updateInvalidErrors(errors: Errors): void;
|
|
73
|
+
cleanErrorRequests(): void;
|
|
74
|
+
isSaving: boolean;
|
|
75
|
+
get isLoading(): boolean;
|
|
76
|
+
get isLoaded(): boolean;
|
|
77
|
+
get isSaved(): boolean;
|
|
78
|
+
get isEmpty(): boolean;
|
|
79
|
+
get isNew(): boolean;
|
|
80
|
+
get isDeleted(): boolean;
|
|
81
|
+
get isValid(): boolean;
|
|
82
|
+
get isDirty(): boolean;
|
|
83
|
+
get isError(): boolean;
|
|
84
|
+
get adapterError(): unknown;
|
|
85
|
+
get isPreloaded(): boolean;
|
|
86
|
+
get stateName(): "root.loading" | "root.empty" | "root.deleted.inFlight" | "root.deleted.saved" | "root.deleted.invalid" | "root.deleted.uncommitted" | "root.loaded.created.inFlight" | "root.loaded.created.invalid" | "root.loaded.created.uncommitted" | "root.loaded.updated.inFlight" | "root.loaded.updated.invalid" | "root.loaded.updated.uncommitted" | "root.loaded.saved";
|
|
87
|
+
get dirtyType(): "" | "deleted" | "created" | "updated";
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=record-state.d.ts.map
|