@ember-data/store 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.
- package/package.json +9 -9
- package/unstable-preview-types/-private/cache-handler.d.ts +101 -99
- package/unstable-preview-types/-private/caches/cache-utils.d.ts +11 -9
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts +181 -179
- package/unstable-preview-types/-private/caches/instance-cache.d.ts +63 -61
- package/unstable-preview-types/-private/caches/resource-utils.d.ts +12 -10
- package/unstable-preview-types/-private/document.d.ts +146 -144
- package/unstable-preview-types/-private/index.d.ts +18 -16
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +178 -176
- package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +19 -17
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +29 -27
- package/unstable-preview-types/-private/managers/cache-manager.d.ts +442 -440
- package/unstable-preview-types/-private/managers/notification-manager.d.ts +98 -96
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts +97 -95
- package/unstable-preview-types/-private/network/request-cache.d.ts +109 -107
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +134 -132
- package/unstable-preview-types/-private/store-service.d.ts +1503 -1501
- package/unstable-preview-types/-private/utils/coerce-id.d.ts +10 -8
- package/unstable-preview-types/-private/utils/construct-resource.d.ts +10 -8
- package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +7 -5
- package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +4 -2
- package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +4 -2
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +4 -2
- package/unstable-preview-types/-private.d.ts +4 -2
- package/unstable-preview-types/-types/overview.d.ts +21 -19
- package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +107 -105
- package/unstable-preview-types/-types/q/cache.d.ts +47 -45
- package/unstable-preview-types/-types/q/ds-model.d.ts +15 -13
- package/unstable-preview-types/-types/q/identifier.d.ts +169 -167
- package/unstable-preview-types/-types/q/promise-proxies.d.ts +4 -2
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts +36 -34
- package/unstable-preview-types/-types/q/record-instance.d.ts +29 -27
- package/unstable-preview-types/-types/q/schema-service.d.ts +214 -212
- package/unstable-preview-types/-types/q/store.d.ts +17 -15
- package/unstable-preview-types/index.d.ts +220 -185
|
@@ -1,169 +1,171 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
declare module '@ember-data/store/-types/q/identifier' {
|
|
2
|
+
/**
|
|
3
|
+
@module @ember-data/store
|
|
4
|
+
*/
|
|
5
|
+
import type { ImmutableRequestInfo } from '@ember-data/request';
|
|
6
|
+
import type { IdentifierBucket, StableIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
|
|
7
|
+
import type { ExistingResourceObject, ResourceIdentifierObject } from '@warp-drive/core-types/spec/raw';
|
|
8
|
+
export type ResourceData = ResourceIdentifierObject | ExistingResourceObject;
|
|
9
|
+
/**
|
|
10
|
+
Configures how unique identifier lid strings are generated by @ember-data/store.
|
|
11
|
+
|
|
12
|
+
This configuration MUST occur prior to the store instance being created.
|
|
13
|
+
|
|
14
|
+
Takes a method which can expect to receive various data as its first argument
|
|
15
|
+
and the name of a bucket as its second argument.
|
|
16
|
+
|
|
17
|
+
Currently there are two buckets, 'record' and 'document'.
|
|
18
|
+
|
|
19
|
+
### Resource (`Record`) Identity
|
|
20
|
+
|
|
21
|
+
If the bucket is `record` the method must return a unique (to at-least
|
|
22
|
+
the given bucket) string identifier for the given data as a string to be
|
|
23
|
+
used as the `lid` of an `Identifier` token.
|
|
24
|
+
|
|
25
|
+
This method will only be called by either `getOrCreateRecordIdentifier` or
|
|
26
|
+
`createIdentifierForNewRecord` when an identifier for the supplied data
|
|
27
|
+
is not already known via `lid` or `type + id` combo and one needs to be
|
|
28
|
+
generated or retrieved from a proprietary cache.
|
|
29
|
+
|
|
30
|
+
`data` will be the same data argument provided to `getOrCreateRecordIdentifier`
|
|
31
|
+
and in the `createIdentifierForNewRecord` case will be an object with
|
|
32
|
+
only `type` as a key.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { setIdentifierGenerationMethod } from '@ember-data/store';
|
|
36
|
+
|
|
37
|
+
export function initialize(applicationInstance) {
|
|
38
|
+
// note how `count` here is now scoped to the application instance
|
|
39
|
+
// for our generation method by being inside the closure provided
|
|
40
|
+
// by the initialize function
|
|
41
|
+
let count = 0;
|
|
42
|
+
|
|
43
|
+
setIdentifierGenerationMethod((resource, bucket) => {
|
|
44
|
+
return resource.lid || `my-key-${count++}`;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
name: 'configure-ember-data-identifiers',
|
|
50
|
+
initialize
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Document Identity
|
|
55
|
+
|
|
56
|
+
If the bucket is `document` the method will receive the associated
|
|
57
|
+
immutable `request` passed to `store.request` as its first argument
|
|
58
|
+
and should return a unique string for the given request if the document
|
|
59
|
+
should be cached, and `null` if it should not be cached.
|
|
60
|
+
|
|
61
|
+
Note, the request result will still be passed to the cache via `Cache.put`,
|
|
62
|
+
but caches should take this as a signal that the document should not itself
|
|
63
|
+
be cached, while its contents may still be used to update other cache state.
|
|
64
|
+
|
|
65
|
+
The presence of `cacheOptions.key` on the request will take precedence
|
|
66
|
+
for the document cache key, and this method will not be called if it is
|
|
67
|
+
present.
|
|
68
|
+
|
|
69
|
+
The default method implementation for this bucket is to return `null`
|
|
70
|
+
for all requests whose method is not `GET`, and to return the `url` for
|
|
71
|
+
those where it is.
|
|
72
|
+
|
|
73
|
+
This means that queries via `POST` MUST provide `cacheOptions.key` or
|
|
74
|
+
implement this hook.
|
|
75
|
+
|
|
76
|
+
⚠️ Caution: Requests that do not have a `method` assigned are assumed to be `GET`
|
|
77
|
+
|
|
78
|
+
@method setIdentifierGenerationMethod
|
|
79
|
+
@for @ember-data/store
|
|
80
|
+
@param method
|
|
81
|
+
@public
|
|
82
|
+
@static
|
|
83
|
+
*/
|
|
84
|
+
export interface GenerationMethod {
|
|
85
|
+
(data: ImmutableRequestInfo, bucket: 'document'): string | null;
|
|
86
|
+
(data: unknown | {
|
|
87
|
+
type: string;
|
|
88
|
+
}, bucket: 'record'): string;
|
|
89
|
+
(data: unknown, bucket: IdentifierBucket): string | null;
|
|
45
90
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
91
|
+
/**
|
|
92
|
+
Configure a callback for when the identifier cache encounters new resource
|
|
93
|
+
data for an existing resource.
|
|
94
|
+
|
|
95
|
+
This configuration MUST occur prior to the store instance being created.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import { setIdentifierUpdateMethod } from '@ember-data/store';
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Takes a method which can expect to receive an existing `Identifier` alongside
|
|
102
|
+
some new data to consider as a second argument. This is an opportunity
|
|
103
|
+
for secondary lookup tables and caches associated with the identifier
|
|
104
|
+
to be amended.
|
|
105
|
+
|
|
106
|
+
This method is called everytime `updateRecordIdentifier` is called and
|
|
107
|
+
with the same arguments. It provides the opportunity to update secondary
|
|
108
|
+
lookup tables for existing identifiers.
|
|
109
|
+
|
|
110
|
+
It will always be called after an identifier created with `createIdentifierForNewRecord`
|
|
111
|
+
has been committed, or after an update to the `record` a `RecordIdentifier`
|
|
112
|
+
is assigned to has been committed. Committed here meaning that the server
|
|
113
|
+
has acknowledged the update (for instance after a call to `.save()`)
|
|
114
|
+
|
|
115
|
+
If `id` has not previously existed, it will be assigned to the `Identifier`
|
|
116
|
+
prior to this `UpdateMethod` being called; however, calls to the parent method
|
|
117
|
+
`updateRecordIdentifier` that attempt to change the `id` or calling update
|
|
118
|
+
without providing an `id` when one is missing will throw an error.
|
|
119
|
+
|
|
120
|
+
@method setIdentifierUpdateMethod
|
|
121
|
+
@for @ember-data/store
|
|
122
|
+
@param method
|
|
123
|
+
@public
|
|
124
|
+
@static
|
|
125
|
+
*/
|
|
126
|
+
export type UpdateMethod = {
|
|
127
|
+
(identifier: StableRecordIdentifier, newData: unknown, bucket: 'record'): void;
|
|
128
|
+
(identifier: StableIdentifier, newData: unknown, bucket: never): void;
|
|
50
129
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
This configuration MUST occur prior to the store instance being created.
|
|
95
|
-
|
|
96
|
-
```js
|
|
97
|
-
import { setIdentifierUpdateMethod } from '@ember-data/store';
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Takes a method which can expect to receive an existing `Identifier` alongside
|
|
101
|
-
some new data to consider as a second argument. This is an opportunity
|
|
102
|
-
for secondary lookup tables and caches associated with the identifier
|
|
103
|
-
to be amended.
|
|
104
|
-
|
|
105
|
-
This method is called everytime `updateRecordIdentifier` is called and
|
|
106
|
-
with the same arguments. It provides the opportunity to update secondary
|
|
107
|
-
lookup tables for existing identifiers.
|
|
108
|
-
|
|
109
|
-
It will always be called after an identifier created with `createIdentifierForNewRecord`
|
|
110
|
-
has been committed, or after an update to the `record` a `RecordIdentifier`
|
|
111
|
-
is assigned to has been committed. Committed here meaning that the server
|
|
112
|
-
has acknowledged the update (for instance after a call to `.save()`)
|
|
113
|
-
|
|
114
|
-
If `id` has not previously existed, it will be assigned to the `Identifier`
|
|
115
|
-
prior to this `UpdateMethod` being called; however, calls to the parent method
|
|
116
|
-
`updateRecordIdentifier` that attempt to change the `id` or calling update
|
|
117
|
-
without providing an `id` when one is missing will throw an error.
|
|
118
|
-
|
|
119
|
-
@method setIdentifierUpdateMethod
|
|
120
|
-
@for @ember-data/store
|
|
121
|
-
@param method
|
|
122
|
-
@public
|
|
123
|
-
@static
|
|
124
|
-
*/
|
|
125
|
-
export type UpdateMethod = {
|
|
126
|
-
(identifier: StableRecordIdentifier, newData: unknown, bucket: 'record'): void;
|
|
127
|
-
(identifier: StableIdentifier, newData: unknown, bucket: never): void;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
Configure a callback for when the identifier cache is going to release an identifier.
|
|
131
|
-
|
|
132
|
-
This configuration MUST occur prior to the store instance being created.
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
import { setIdentifierForgetMethod } from '@ember-data/store';
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Takes method which can expect to receive an existing `Identifier` that should be eliminated
|
|
139
|
-
from any secondary lookup tables or caches that the user has populated for it.
|
|
140
|
-
|
|
141
|
-
@method setIdentifierForgetMethod
|
|
142
|
-
@for @ember-data/store
|
|
143
|
-
@param method
|
|
144
|
-
@public
|
|
145
|
-
@static
|
|
146
|
-
*/
|
|
147
|
-
export type ForgetMethod = (identifier: StableIdentifier | StableRecordIdentifier, bucket: IdentifierBucket) => void;
|
|
148
|
-
/**
|
|
149
|
-
Configure a callback for when the identifier cache is being torn down.
|
|
150
|
-
|
|
151
|
-
This configuration MUST occur prior to the store instance being created.
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
import { setIdentifierResetMethod } from '@ember-data/store';
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Takes a method which can expect to be called when the parent application is destroyed.
|
|
158
|
-
|
|
159
|
-
If you have properly used a WeakMap to encapsulate the state of your customization
|
|
160
|
-
to the application instance, you may not need to implement the `resetMethod`.
|
|
161
|
-
|
|
162
|
-
@method setIdentifierResetMethod
|
|
163
|
-
@for @ember-data/store
|
|
164
|
-
@param method
|
|
165
|
-
@public
|
|
166
|
-
@static
|
|
167
|
-
*/
|
|
168
|
-
export type ResetMethod = () => void;
|
|
169
|
-
//# sourceMappingURL=identifier.d.ts.map
|
|
130
|
+
/**
|
|
131
|
+
Configure a callback for when the identifier cache is going to release an identifier.
|
|
132
|
+
|
|
133
|
+
This configuration MUST occur prior to the store instance being created.
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import { setIdentifierForgetMethod } from '@ember-data/store';
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Takes method which can expect to receive an existing `Identifier` that should be eliminated
|
|
140
|
+
from any secondary lookup tables or caches that the user has populated for it.
|
|
141
|
+
|
|
142
|
+
@method setIdentifierForgetMethod
|
|
143
|
+
@for @ember-data/store
|
|
144
|
+
@param method
|
|
145
|
+
@public
|
|
146
|
+
@static
|
|
147
|
+
*/
|
|
148
|
+
export type ForgetMethod = (identifier: StableIdentifier | StableRecordIdentifier, bucket: IdentifierBucket) => void;
|
|
149
|
+
/**
|
|
150
|
+
Configure a callback for when the identifier cache is being torn down.
|
|
151
|
+
|
|
152
|
+
This configuration MUST occur prior to the store instance being created.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
import { setIdentifierResetMethod } from '@ember-data/store';
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Takes a method which can expect to be called when the parent application is destroyed.
|
|
159
|
+
|
|
160
|
+
If you have properly used a WeakMap to encapsulate the state of your customization
|
|
161
|
+
to the application instance, you may not need to implement the `resetMethod`.
|
|
162
|
+
|
|
163
|
+
@method setIdentifierResetMethod
|
|
164
|
+
@for @ember-data/store
|
|
165
|
+
@param method
|
|
166
|
+
@public
|
|
167
|
+
@static
|
|
168
|
+
*/
|
|
169
|
+
export type ResetMethod = () => void;
|
|
170
|
+
//# sourceMappingURL=identifier.d.ts.map
|
|
171
|
+
}
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
declare module '@ember-data/store/-types/q/record-data-json-api' {
|
|
2
|
+
import type { Value } from '@warp-drive/core-types/json/raw';
|
|
3
|
+
import type { CollectionResourceRelationship, Link, Links, Meta, SingleResourceRelationship } from '@warp-drive/core-types/spec/raw';
|
|
4
|
+
/**
|
|
5
|
+
@module @ember-data/store
|
|
6
|
+
*/
|
|
7
|
+
export type AttributesHash = Record<string, Value>;
|
|
8
|
+
export interface JsonApiResource {
|
|
9
|
+
id?: string | null;
|
|
10
|
+
type?: string;
|
|
11
|
+
lid?: string;
|
|
12
|
+
attributes?: AttributesHash;
|
|
13
|
+
relationships?: Record<string, SingleResourceRelationship | CollectionResourceRelationship>;
|
|
14
|
+
meta?: Meta;
|
|
15
|
+
links?: Links;
|
|
16
|
+
}
|
|
17
|
+
export interface JsonApiError {
|
|
18
|
+
id?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
detail?: string;
|
|
21
|
+
links?: {
|
|
22
|
+
about?: Link;
|
|
23
|
+
type?: Link;
|
|
24
|
+
};
|
|
25
|
+
status?: string;
|
|
26
|
+
code?: string;
|
|
27
|
+
source?: {
|
|
28
|
+
pointer: string;
|
|
29
|
+
parameter?: string;
|
|
30
|
+
header?: string;
|
|
31
|
+
};
|
|
32
|
+
meta?: Meta;
|
|
33
|
+
}
|
|
34
|
+
export type JsonApiRelationship = SingleResourceRelationship | CollectionResourceRelationship;
|
|
35
|
+
//# sourceMappingURL=record-data-json-api.d.ts.map
|
|
36
|
+
}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
declare module '@ember-data/store/-types/q/record-instance' {
|
|
2
|
+
/**
|
|
3
|
+
@module @ember-data/store
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
In EmberData, a "record instance" is a class instance used to present the data
|
|
7
|
+
for a single resource, transforming the resource's cached raw data into a form
|
|
8
|
+
that is useful for the application.
|
|
9
|
+
|
|
10
|
+
Since every application's needs are different, EmberData does not assume to know
|
|
11
|
+
what the shape of the record instance should be. Instead, it provides a way to
|
|
12
|
+
define the record instance's via the `instantiateRecord` hook on the store.
|
|
13
|
+
|
|
14
|
+
Thus for most purposes the `RecordInstance` type is "opaque" to EmberData, and
|
|
15
|
+
should be treated as "unknown" by the library.
|
|
16
|
+
|
|
17
|
+
Wherever possible, if typing an API that is consumer facing, instead of using
|
|
18
|
+
OpaqueRecordInstance, we should prefer to use a generic and check if the generic
|
|
19
|
+
extends `TypedRecordInstance`. This allows consumers to define their own record
|
|
20
|
+
instance types and not only have their types flow through EmberData APIs, but
|
|
21
|
+
also allows EmberData to provide typechecking and intellisense for the record
|
|
22
|
+
based on a special symbol prsent on record instances that implement the
|
|
23
|
+
`TypedRecordInstance` interface.
|
|
24
|
+
|
|
25
|
+
@typedoc
|
|
26
|
+
*/
|
|
27
|
+
export type OpaqueRecordInstance = unknown;
|
|
28
|
+
//# sourceMappingURL=record-instance.d.ts.map
|
|
29
|
+
}
|