@ember-data/store 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 (45) hide show
  1. package/addon/-private.js +1 -1
  2. package/addon/{cache-handler-oB00-31L.js → cache-handler-k7I5KvcC.js} +11 -1
  3. package/addon/cache-handler-k7I5KvcC.js.map +1 -0
  4. package/addon/index.js +1 -1
  5. package/package.json +9 -9
  6. package/unstable-preview-types/-private/cache-handler.d.ts +99 -97
  7. package/unstable-preview-types/-private/caches/cache-utils.d.ts +10 -8
  8. package/unstable-preview-types/-private/caches/identifier-cache.d.ts +179 -177
  9. package/unstable-preview-types/-private/caches/instance-cache.d.ts +61 -59
  10. package/unstable-preview-types/-private/caches/resource-utils.d.ts +11 -9
  11. package/unstable-preview-types/-private/document.d.ts +144 -142
  12. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +176 -174
  13. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +17 -15
  14. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +27 -25
  15. package/unstable-preview-types/-private/managers/cache-manager.d.ts +440 -438
  16. package/unstable-preview-types/-private/managers/notification-manager.d.ts +96 -94
  17. package/unstable-preview-types/-private/managers/record-array-manager.d.ts +95 -93
  18. package/unstable-preview-types/-private/network/request-cache.d.ts +107 -105
  19. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +128 -130
  20. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts.map +1 -1
  21. package/unstable-preview-types/-private/record-arrays/native-proxy-type-fix.d.ts +118 -0
  22. package/unstable-preview-types/-private/record-arrays/native-proxy-type-fix.d.ts.map +1 -0
  23. package/unstable-preview-types/-private/store-service.d.ts +1501 -1499
  24. package/unstable-preview-types/-private/utils/coerce-id.d.ts +9 -7
  25. package/unstable-preview-types/-private/utils/construct-resource.d.ts +9 -7
  26. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +6 -4
  27. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +3 -1
  28. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +3 -1
  29. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +3 -1
  30. package/unstable-preview-types/-private.d.ts +18 -1
  31. package/unstable-preview-types/-private.d.ts.map +1 -1
  32. package/unstable-preview-types/-types/overview.d.ts +20 -18
  33. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +105 -103
  34. package/unstable-preview-types/-types/q/cache.d.ts +45 -43
  35. package/unstable-preview-types/-types/q/ds-model.d.ts +13 -11
  36. package/unstable-preview-types/-types/q/identifier.d.ts +167 -165
  37. package/unstable-preview-types/-types/q/promise-proxies.d.ts +3 -1
  38. package/unstable-preview-types/-types/q/record-data-json-api.d.ts +34 -32
  39. package/unstable-preview-types/-types/q/record-instance.d.ts +28 -26
  40. package/unstable-preview-types/-types/q/schema-service.d.ts +212 -210
  41. package/unstable-preview-types/-types/q/store.d.ts +15 -13
  42. package/unstable-preview-types/index.d.ts +219 -184
  43. package/addon/cache-handler-oB00-31L.js.map +0 -1
  44. package/unstable-preview-types/-private/index.d.ts +0 -16
  45. package/unstable-preview-types/-private/index.d.ts.map +0 -1
@@ -1,169 +1,171 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
- import type { ImmutableRequestInfo } from '@ember-data/request';
5
- import type { IdentifierBucket, StableIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
6
- import type { ExistingResourceObject, ResourceIdentifierObject } from '@warp-drive/core-types/spec/raw';
7
- export type ResourceData = ResourceIdentifierObject | ExistingResourceObject;
8
- /**
9
- Configures how unique identifier lid strings are generated by @ember-data/store.
10
-
11
- This configuration MUST occur prior to the store instance being created.
12
-
13
- Takes a method which can expect to receive various data as its first argument
14
- and the name of a bucket as its second argument.
15
-
16
- Currently there are two buckets, 'record' and 'document'.
17
-
18
- ### Resource (`Record`) Identity
19
-
20
- If the bucket is `record` the method must return a unique (to at-least
21
- the given bucket) string identifier for the given data as a string to be
22
- used as the `lid` of an `Identifier` token.
23
-
24
- This method will only be called by either `getOrCreateRecordIdentifier` or
25
- `createIdentifierForNewRecord` when an identifier for the supplied data
26
- is not already known via `lid` or `type + id` combo and one needs to be
27
- generated or retrieved from a proprietary cache.
28
-
29
- `data` will be the same data argument provided to `getOrCreateRecordIdentifier`
30
- and in the `createIdentifierForNewRecord` case will be an object with
31
- only `type` as a key.
32
-
33
- ```ts
34
- import { setIdentifierGenerationMethod } from '@ember-data/store';
35
-
36
- export function initialize(applicationInstance) {
37
- // note how `count` here is now scoped to the application instance
38
- // for our generation method by being inside the closure provided
39
- // by the initialize function
40
- let count = 0;
41
-
42
- setIdentifierGenerationMethod((resource, bucket) => {
43
- return resource.lid || `my-key-${count++}`;
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
- export default {
48
- name: 'configure-ember-data-identifiers',
49
- initialize
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
- ### Document Identity
54
-
55
- If the bucket is `document` the method will receive the associated
56
- immutable `request` passed to `store.request` as its first argument
57
- and should return a unique string for the given request if the document
58
- should be cached, and `null` if it should not be cached.
59
-
60
- Note, the request result will still be passed to the cache via `Cache.put`,
61
- but caches should take this as a signal that the document should not itself
62
- be cached, while its contents may still be used to update other cache state.
63
-
64
- The presence of `cacheOptions.key` on the request will take precedence
65
- for the document cache key, and this method will not be called if it is
66
- present.
67
-
68
- The default method implementation for this bucket is to return `null`
69
- for all requests whose method is not `GET`, and to return the `url` for
70
- those where it is.
71
-
72
- This means that queries via `POST` MUST provide `cacheOptions.key` or
73
- implement this hook.
74
-
75
- ⚠️ Caution: Requests that do not have a `method` assigned are assumed to be `GET`
76
-
77
- @method setIdentifierGenerationMethod
78
- @for @ember-data/store
79
- @param method
80
- @public
81
- @static
82
- */
83
- export interface GenerationMethod {
84
- (data: ImmutableRequestInfo, bucket: 'document'): string | null;
85
- (data: unknown | {
86
- type: string;
87
- }, bucket: 'record'): string;
88
- (data: unknown, bucket: IdentifierBucket): string | null;
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;
89
170
  }
90
- /**
91
- Configure a callback for when the identifier cache encounters new resource
92
- data for an existing resource.
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
171
  //# sourceMappingURL=identifier.d.ts.map
@@ -1,2 +1,4 @@
1
- export type PromiseProxy<T> = Promise<T>;
1
+ declare module '@ember-data/store/-types/q/promise-proxies' {
2
+ export type PromiseProxy<T> = Promise<T>;
3
+ }
2
4
  //# sourceMappingURL=promise-proxies.d.ts.map
@@ -1,34 +1,36 @@
1
- import type { Value } from '@warp-drive/core-types/json/raw';
2
- import type { CollectionResourceRelationship, Link, Links, Meta, SingleResourceRelationship } from '@warp-drive/core-types/spec/raw';
3
- /**
4
- @module @ember-data/store
5
- */
6
- export type AttributesHash = Record<string, Value>;
7
- export interface JsonApiResource {
8
- id?: string | null;
9
- type?: string;
10
- lid?: string;
11
- attributes?: AttributesHash;
12
- relationships?: Record<string, SingleResourceRelationship | CollectionResourceRelationship>;
13
- meta?: Meta;
14
- links?: Links;
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;
15
35
  }
16
- export interface JsonApiError {
17
- id?: string;
18
- title?: string;
19
- detail?: string;
20
- links?: {
21
- about?: Link;
22
- type?: Link;
23
- };
24
- status?: string;
25
- code?: string;
26
- source?: {
27
- pointer: string;
28
- parameter?: string;
29
- header?: string;
30
- };
31
- meta?: Meta;
32
- }
33
- export type JsonApiRelationship = SingleResourceRelationship | CollectionResourceRelationship;
34
36
  //# sourceMappingURL=record-data-json-api.d.ts.map
@@ -1,27 +1,29 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
- /**
5
- In EmberData, a "record instance" is a class instance used to present the data
6
- for a single resource, transforming the resource's cached raw data into a form
7
- that is useful for the application.
8
-
9
- Since every application's needs are different, EmberData does not assume to know
10
- what the shape of the record instance should be. Instead, it provides a way to
11
- define the record instance's via the `instantiateRecord` hook on the store.
12
-
13
- Thus for most purposes the `RecordInstance` type is "opaque" to EmberData, and
14
- should be treated as "unknown" by the library.
15
-
16
- Wherever possible, if typing an API that is consumer facing, instead of using
17
- OpaqueRecordInstance, we should prefer to use a generic and check if the generic
18
- extends `TypedRecordInstance`. This allows consumers to define their own record
19
- instance types and not only have their types flow through EmberData APIs, but
20
- also allows EmberData to provide typechecking and intellisense for the record
21
- based on a special symbol prsent on record instances that implement the
22
- `TypedRecordInstance` interface.
23
-
24
- @typedoc
25
- */
26
- export type OpaqueRecordInstance = unknown;
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
+ }
27
29
  //# sourceMappingURL=record-instance.d.ts.map