@warp-drive/core 5.8.0-alpha.3 → 5.8.0-alpha.30

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 (65) hide show
  1. package/README.md +22 -38
  2. package/declarations/build-config.d.ts +18 -1
  3. package/declarations/graph/-private/-edge-definition.d.ts +12 -2
  4. package/declarations/index.d.ts +82 -3
  5. package/declarations/reactive/-private/document.d.ts +58 -46
  6. package/declarations/reactive/-private/record.d.ts +10 -1
  7. package/declarations/reactive/-private/schema.d.ts +77 -4
  8. package/declarations/reactive/-private.d.ts +1 -0
  9. package/declarations/reactive.d.ts +13 -7
  10. package/declarations/request/-private/types.d.ts +1 -1
  11. package/declarations/request.d.ts +47 -0
  12. package/declarations/store/-private/caches/instance-cache.d.ts +4 -5
  13. package/declarations/store/-private/default-cache-policy.d.ts +147 -129
  14. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +1 -1
  15. package/declarations/store/-private/managers/cache-key-manager.d.ts +26 -8
  16. package/declarations/store/-private/managers/cache-manager.d.ts +6 -4
  17. package/declarations/store/-private/managers/notification-manager.d.ts +1 -1
  18. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +1 -0
  19. package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
  20. package/declarations/store/-private/store-service.d.ts +43 -64
  21. package/declarations/store/-private.d.ts +0 -1
  22. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +1 -1
  23. package/declarations/store/deprecated/store.d.ts +33 -32
  24. package/declarations/store.d.ts +1 -0
  25. package/declarations/types/cache.d.ts +8 -6
  26. package/declarations/types/record.d.ts +132 -0
  27. package/declarations/types/request.d.ts +26 -14
  28. package/declarations/types/schema/fields.d.ts +30 -6
  29. package/declarations/{store/-types/q → types/schema}/schema-service.d.ts +11 -9
  30. package/declarations/types/spec/document.d.ts +34 -0
  31. package/declarations/types/symbols.d.ts +2 -2
  32. package/declarations/types.d.ts +1 -1
  33. package/dist/build-config.js +1 -1
  34. package/dist/default-cache-policy-D7_u4YRH.js +572 -0
  35. package/dist/graph/-private.js +13 -4
  36. package/dist/{request-state-CUuZzgvE.js → index-CHrZ1B2X.js} +10081 -8924
  37. package/dist/index.js +6 -382
  38. package/dist/reactive.js +4 -778
  39. package/dist/{context-C_7OLieY.js → request-oqoLC9rz.js} +219 -172
  40. package/dist/request.js +1 -1
  41. package/dist/store/-private.js +1 -1
  42. package/dist/store.js +1 -533
  43. package/dist/types/-private.js +1 -1
  44. package/dist/types/record.js +127 -0
  45. package/dist/types/request.js +14 -12
  46. package/dist/types/schema/fields.js +14 -0
  47. package/dist/types/schema/schema-service.js +0 -0
  48. package/dist/types/symbols.js +2 -2
  49. package/logos/README.md +2 -2
  50. package/logos/logo-yellow-slab.svg +1 -0
  51. package/logos/word-mark-black.svg +1 -0
  52. package/logos/word-mark-white.svg +1 -0
  53. package/package.json +3 -3
  54. package/logos/NCC-1701-a-blue.svg +0 -4
  55. package/logos/NCC-1701-a-gold.svg +0 -4
  56. package/logos/NCC-1701-a-gold_100.svg +0 -1
  57. package/logos/NCC-1701-a-gold_base-64.txt +0 -1
  58. package/logos/NCC-1701-a.svg +0 -4
  59. package/logos/docs-badge.svg +0 -2
  60. package/logos/ember-data-logo-dark.svg +0 -12
  61. package/logos/ember-data-logo-light.svg +0 -12
  62. package/logos/social1.png +0 -0
  63. package/logos/social2.png +0 -0
  64. package/logos/warp-drive-logo-dark.svg +0 -4
  65. package/logos/warp-drive-logo-gold.svg +0 -4
@@ -4,18 +4,18 @@ import type { PrivateRequestManager, RequestManager } from "../../request/-priva
4
4
  import type { Cache } from "../../types/cache.js";
5
5
  import type { PersistedResourceKey, ResourceKey } from "../../types/identifier.js";
6
6
  import type { TypedRecordInstance, TypeFromInstance } from "../../types/record.js";
7
+ import type { SchemaService } from "../../types/schema/schema-service.js";
7
8
  import type { CollectionResourceDocument, EmptyResourceDocument, JsonApiDocument, ResourceIdentifierObject, SingleResourceDocument } from "../../types/spec/json-api-raw.js";
8
9
  import type { Type } from "../../types/symbols.js";
9
10
  import type { CacheCapabilitiesManager } from "../-types/q/cache-capabilities-manager.js";
10
11
  import type { OpaqueRecordInstance } from "../-types/q/record-instance.js";
11
- import type { SchemaService } from "../-types/q/schema-service.js";
12
12
  import type { StoreRequestInput } from "./cache-handler/handler.js";
13
13
  import type { CachePolicy } from "./cache-handler/types.js";
14
14
  import { InstanceCache, storeFor } from "./caches/instance-cache.js";
15
15
  import type { PrivateCacheKeyManager } from "./managers/cache-key-manager.js";
16
16
  import { CacheKeyManager } from "./managers/cache-key-manager.js";
17
17
  import type { PrivateNotificationManager } from "./managers/notification-manager.js";
18
- import NotificationManager from "./managers/notification-manager.js";
18
+ import { NotificationManager } from "./managers/notification-manager.js";
19
19
  import type { PrivateRecordArrayManager } from "./managers/record-array-manager.js";
20
20
  import type { PrivateRequestStateService } from "./network/request-cache.js";
21
21
  import { RequestStateService } from "./network/request-cache.js";
@@ -101,7 +101,7 @@ export interface Store {
101
101
  * For Example, to use the default SchemaService for ReactiveResource
102
102
  *
103
103
  * ```ts
104
- * import { SchemaService } from '@warp-drive/schema-record';
104
+ * import { SchemaService } from '@warp-drive/core/reactive';
105
105
  *
106
106
  * class extends Store {
107
107
  * createSchemaService() {
@@ -110,10 +110,10 @@ export interface Store {
110
110
  * }
111
111
  * ```
112
112
  *
113
- * Or to use the SchemaService for @ember-data/model
113
+ * Or to use the SchemaService for @warp-drive/legacy/model
114
114
  *
115
115
  * ```ts
116
- * import { buildSchema } from '@ember-data/model';
116
+ * import { buildSchema } from '@warp-drive/legacy/model';
117
117
  *
118
118
  * class extends Store {
119
119
  * createSchemaService() {
@@ -125,13 +125,13 @@ export interface Store {
125
125
  * If you wish to chain services, you must either
126
126
  * instantiate each schema source directly or super to retrieve
127
127
  * an existing service. For convenience, when migrating from
128
- * `@ember-data/model` to `@warp-drive/schema-record` a
128
+ * `@warp-drive/legacy/model` to {@link ReactiveResource} a
129
129
  * SchemaService is provided that handles this transition
130
130
  * for you:
131
131
  *
132
132
  * ```ts
133
- * import { DelegatingSchemaService } from '@ember-data/model/migration-support';
134
- * import { SchemaService } from '@warp-drive/schema-record';
133
+ * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';
134
+ * import { SchemaService } from '@warp-drive/core/reactive';
135
135
  *
136
136
  * class extends Store {
137
137
  * createSchemaService() {
@@ -176,7 +176,7 @@ export interface Store {
176
176
  * For Example:
177
177
  *
178
178
  * ```ts
179
- * import Store from '@ember-data/store';
179
+ * import { Store } from '@warp-drive/core';
180
180
  *
181
181
  * class SchemaDelegator {
182
182
  * constructor(schema) {
@@ -210,7 +210,6 @@ export interface Store {
210
210
  * }
211
211
  * ```
212
212
  *
213
- * @param {SchemaService} schema
214
213
  * @deprecated
215
214
  * @public
216
215
  */
@@ -230,7 +229,7 @@ export interface Store {
230
229
  * For Example:
231
230
  *
232
231
  * ```ts
233
- * import Store from '@ember-data/store';
232
+ * import { Store } from '@warp-drive/core';
234
233
  *
235
234
  * class SchemaDelegator {
236
235
  * constructor(schema) {
@@ -264,7 +263,6 @@ export interface Store {
264
263
  * }
265
264
  * ```
266
265
  *
267
- * @param {SchemaService} schema
268
266
  * @deprecated
269
267
  * @public
270
268
  */
@@ -290,7 +288,7 @@ export interface Store {
290
288
  */
291
289
  export declare class Store extends BaseClass {
292
290
  /**
293
- * Provides access to the NotificationManager associated
291
+ * Provides access to the {@link NotificationManager} associated
294
292
  * with this Store instance.
295
293
  *
296
294
  * The NotificationManager can be used to subscribe to
@@ -321,20 +319,18 @@ export declare class Store extends BaseClass {
321
319
  */
322
320
  readonly cacheKeyManager: CacheKeyManager;
323
321
  /**
324
- * Provides access to the requestManager instance associated
322
+ * Provides access to the {@link RequestManager} instance associated
325
323
  * with this Store instance.
326
324
  *
327
- * When using `ember-data` this property is automatically
328
- * set to an instance of `RequestManager`. When not using `ember-data`
329
- * you must configure this property yourself, either by declaring
330
- * it as a service or by initializing it.
325
+ * See also:
326
+ * - {@link Fetch}
327
+ * - {@link CacheHandlerInterface | CacheHandler (Interface)}
328
+ * - {@link CacheHandler | CacheHandler (Class)}
331
329
  *
332
330
  * ```ts
333
- * import Store, { CacheHandler } from '@ember-data/store';
334
- * import RequestManager from '@ember-data/request';
335
- * import Fetch from '@ember-data/request/fetch';
331
+ * import { CacheHandler, Fetch, RequestManager, Store } from '@warp-drive/core';
336
332
  *
337
- * class extends Store {
333
+ * class AppStore extends Store {
338
334
  * requestManager = new RequestManager()
339
335
  * .use([Fetch])
340
336
  * .useCache(CacheHandler);
@@ -350,9 +346,9 @@ export declare class Store extends BaseClass {
350
346
  *
351
347
  * Note, when defined, these methods will only be invoked if a
352
348
  * cache key exists for the request, either because the request
353
- * contains `cacheOptions.key` or because the [CacheKeyManager](/ember-data/release/classes/CacheKeyManager)
349
+ * contains `cacheOptions.key` or because the {@link CacheKeyManager}
354
350
  * was able to generate a key for the request using the configured
355
- * [generation method](/ember-data/release/functions/@ember-data%2Fstore/setIdentifierGenerationMethod).
351
+ * {@link setIdentifierGenerationMethod | generation method}.
356
352
  *
357
353
  * `isSoftExpired` will only be invoked if `isHardExpired` returns `false`.
358
354
  *
@@ -557,14 +553,10 @@ export declare class Store extends BaseClass {
557
553
  otherwise it will return `null`. A record is available if it has been fetched earlier, or
558
554
  pushed manually into the store.
559
555
 
560
- See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend.
561
-
562
- _Note: This is a synchronous method and does not return a promise._
563
-
564
556
  **Example 1**
565
557
 
566
- ```js
567
- let post = store.peekRecord('post', '1');
558
+ ```ts
559
+ const post = store.peekRecord('post', '1');
568
560
 
569
561
  post.id; // '1'
570
562
  ```
@@ -575,8 +567,8 @@ export declare class Store extends BaseClass {
575
567
 
576
568
  **Example 2**
577
569
 
578
- ```js
579
- let post = store.peekRecord({ type: 'post', id });
570
+ ```ts
571
+ const post = store.peekRecord({ type: 'post', id: '1' });
580
572
  post.id; // '1'
581
573
  ```
582
574
 
@@ -590,40 +582,34 @@ export declare class Store extends BaseClass {
590
582
  post.id; // '1'
591
583
  ```
592
584
 
593
-
594
585
  @since 1.13.0
595
586
  @public
596
- @param {String|object} modelName - either a string representing the modelName or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
597
- @param {String|Integer} id - optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved.
598
- @return {Model|null} record
587
+ @param type - either a string representing the modelName or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
588
+ @param id - optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved.
599
589
  */
600
590
  peekRecord<T>(type: TypeFromInstance<T>, id: string | number): T | null;
601
591
  peekRecord(type: string, id: string | number): unknown | null;
602
592
  peekRecord<T>(identifier: ResourceIdentifierObject<TypeFromInstance<T>>): T | null;
603
593
  peekRecord(identifier: ResourceIdentifierObject): unknown | null;
604
594
  /**
605
- This method returns a filtered array that contains all of the
606
- known records for a given type in the store.
595
+ This method returns the {@link LegacyLiveArray} that contains all of the
596
+ known records for a given type in the store. Each ResourceType has only
597
+ one LiveArray instance, so multiple calls to `peekAll` with the same type
598
+ will always return the same instance.
607
599
 
608
- Note that because it's just a filter, the result will contain any
600
+ Note that because it's a LiveArray, the result will contain any
609
601
  locally created records of the type, however, it will not make a
610
- request to the backend to retrieve additional records. If you
611
- would like to request all the records from the backend please use
612
- [store.findAll](../methods/findAll?anchor=findAll).
613
-
614
- Also note that multiple calls to `peekAll` for a given type will always
615
- return the same `RecordArray`.
602
+ request to the backend to retrieve additional records.
616
603
 
617
604
  Example
618
605
 
619
- ```javascript
620
- let localPosts = store.peekAll('post');
606
+ ```ts
607
+ const allPosts = store.peekAll('post');
621
608
  ```
622
609
 
623
610
  @since 1.13.0
624
611
  @public
625
- @param {String} type the name of the resource
626
- @return {RecordArray}
612
+ @param type the name of the resource
627
613
  */
628
614
  peekAll<T>(type: TypeFromInstance<T>): LegacyLiveArray<T>;
629
615
  peekAll(type: string): LegacyLiveArray;
@@ -708,7 +694,7 @@ export declare class Store extends BaseClass {
708
694
  For this model:
709
695
 
710
696
  ```js [app/models/person.js]
711
- import Model, { attr, hasMany } from '@ember-data/model';
697
+ import Model, { attr, hasMany } from '@warp-drive/legacy/model';
712
698
 
713
699
  export default class PersonRoute extends Route {
714
700
  @attr('string') firstName;
@@ -775,23 +761,17 @@ export declare class Store extends BaseClass {
775
761
  }
776
762
  ```
777
763
 
778
- If you're streaming data or implementing an adapter, make sure
779
- that you have converted the incoming data into this form. The
780
- store's [normalize](../methods/normalize?anchor=normalize) method is a convenience
781
- helper for converting a json payload into the form Ember Data
782
- expects.
783
-
784
- ```js
785
- store.push(store.normalize('person', data));
786
- ```
764
+ If you're streaming data, or implementing response handling, make sure
765
+ that you have converted the incoming data into this form.
787
766
 
788
767
  This method can be used both to push in brand new
789
768
  records, as well as to update existing records.
790
769
 
770
+ See also {@link Cache.patch}
771
+
791
772
  @public
792
- @param {Object} data
793
- @return the record(s) that was created or
794
- updated.
773
+ @param data
774
+ @return the primary record(s) that created or updated.
795
775
  */
796
776
  push(data: EmptyResourceDocument): null;
797
777
  push<T>(data: SingleResourceDocument<TypeFromInstance<T>>): T;
@@ -803,8 +783,7 @@ export declare class Store extends BaseClass {
803
783
  without creating materialized records.
804
784
 
805
785
  @private
806
- @param {Object} jsonApiDoc
807
- @return {ResourceKey|Array<ResourceKey>|null} identifiers for the primary records that had data loaded
786
+ @return identifiers for the primary records that had data loaded
808
787
  */
809
788
  _push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean): PersistedResourceKey | PersistedResourceKey[] | null;
810
789
  /**
@@ -22,7 +22,6 @@ export { normalizeModelName as _deprecatingNormalize } from "./-private/utils/no
22
22
  export type { StoreRequestInput } from "./-private/cache-handler/handler.js";
23
23
  export { type LegacyManyArray, type LegacyManyArray as RelatedCollection, createLegacyManyArray } from "./-private/record-arrays/legacy-many-array.js";
24
24
  export { log, logGroup } from "./-private/debug/utils.js";
25
- export { getPromiseState, type PromiseState } from "./-private/new-core-tmp/promise-state.js";
26
25
  export { DISPOSE, createRequestSubscription, type RequestArgs, type SubscriptionArgs, type RequestComponentArgs, type RequestSubscription, type ContentFeatures, type RecoveryFeatures, type AutorefreshBehaviorCombos, type AutorefreshBehaviorType } from "./-private/new-core-tmp/request-subscription.js";
27
26
  export { getRequestState, type RequestLoadingState, type RequestCacheRequestState as RequestState } from "./-private/new-core-tmp/request-state.js";
28
27
  export { type SignalHooks, waitFor } from "./-private/new-core-tmp/reactivity/configure.js";
@@ -1,7 +1,7 @@
1
1
  import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
2
+ import type { SchemaService } from "../../../types/schema/schema-service.js";
2
3
  import type { CacheKeyManager } from "../../-private/managers/cache-key-manager.js";
3
4
  import type { NotificationType } from "../../-private/managers/notification-manager.js";
4
- import type { SchemaService } from "./schema-service.js";
5
5
  /**
6
6
  * CacheCapabilitiesManager provides encapsulated API access to the minimal
7
7
  * subset of the Store's functionality that Cache implementations
@@ -248,13 +248,13 @@ declare module "../-private/store-service" {
248
248
  }
249
249
  ```
250
250
 
251
- See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record.
251
+ See {@link Store.peekRecord | peekRecord} to get the cached version of a record.
252
252
 
253
253
  ### Retrieving Related Model Records
254
254
 
255
- If you use an adapter such as Ember's default
256
- [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter)
257
- that supports the [JSON API specification](http://jsonapi.org/) and if your server
255
+ If you use an adapter such as the
256
+ [JSONAPIAdapter](/api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter)
257
+ which supports the [{json:api} specification](http://jsonapi.org/) and if your server
258
258
  endpoint supports the use of an
259
259
  ['include' query parameter](http://jsonapi.org/format/#fetching-includes),
260
260
  you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to
@@ -421,7 +421,7 @@ declare module "../-private/store-service" {
421
421
  records in the store:
422
422
 
423
423
  ```js [app/adapters/application.js]
424
- import Adapter from '@ember-data/adapter';
424
+ import { Adapter } from '@warp-drive/legacy/adapter';
425
425
 
426
426
  export default class ApplicationAdapter extends Adapter {
427
427
  shouldReloadAll(store, snapshotsArray) {
@@ -498,13 +498,13 @@ declare module "../-private/store-service" {
498
498
  }
499
499
  ```
500
500
 
501
- See [peekAll](../methods/peekAll?anchor=peekAll) to get an array of current records in the
501
+ See {@link Store.peekAll | peekAll} to get an array of current records in the
502
502
  store, without waiting until a reload is finished.
503
503
 
504
504
  ### Retrieving Related Model Records
505
505
 
506
- If you use an adapter such as Ember's default
507
- [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter)
506
+ If you use an adapter such as the default
507
+ [JSONAPIAdapter](/api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter)
508
508
  that supports the [JSON API specification](http://jsonapi.org/) and if your server
509
509
  endpoint supports the use of an
510
510
  ['include' query parameter](http://jsonapi.org/format/#fetching-includes),
@@ -535,7 +535,7 @@ declare module "../-private/store-service" {
535
535
  }
536
536
  ```
537
537
 
538
- See [query](../methods/query?anchor=query) to only get a subset of records from the server.
538
+ See {@link Store.query | query} to only get a subset of records from the server.
539
539
 
540
540
  @public
541
541
  @deprecated use {@link Store.request} instead
@@ -575,7 +575,7 @@ declare module "../-private/store-service" {
575
575
 
576
576
  If you do something like this:
577
577
 
578
- ```javascript
578
+ ```js
579
579
  store.query('person', { ids: ['1', '2', '3'] });
580
580
  ```
581
581
 
@@ -602,7 +602,7 @@ declare module "../-private/store-service" {
602
602
  query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray>;
603
603
  /**
604
604
  This method makes a request for one record, where the `id` is not known
605
- beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord)
605
+ beforehand (if the `id` is known, use {@link Store.findRecord | findRecord}
606
606
  instead).
607
607
 
608
608
  This method can be used when it is certain that the server will return a
@@ -611,37 +611,40 @@ declare module "../-private/store-service" {
611
611
  Each time this method is called a new request is made through the adapter.
612
612
 
613
613
  Let's assume our API provides an endpoint for the currently logged in user
614
- via:
615
614
 
616
- ```
617
- // GET /api/current_user
615
+ ```ts
616
+ // GET /api/user/me
618
617
  {
619
- user: {
620
- id: 1234,
618
+ data: {
619
+ type: 'user',
620
+ id: '1234',
621
+ attributes: {
621
622
  username: 'admin'
622
623
  }
623
624
  }
625
+ }
624
626
  ```
625
627
 
626
628
  Since the specific `id` of the `user` is not known beforehand, we can use
627
629
  `queryRecord` to get the user:
628
630
 
629
- ```javascript
630
- store.queryRecord('user', {}).then(function(user) {
631
- let username = user.username;
632
- // do thing
633
- });
631
+ ```ts
632
+ const user = await store.queryRecord('user', { me: true });
633
+ user.username; // admin
634
634
  ```
635
635
 
636
636
  The request is made through the adapters' `queryRecord`:
637
637
 
638
- ```js [app/adapters/user.js]
639
- import Adapter from '@ember-data/adapter';
640
- import $ from 'jquery';
638
+ ```ts [app/adapters/user.ts]
639
+ import Adapter from '@warp-drive/legacy/adapter';
641
640
 
642
641
  export default class UserAdapter extends Adapter {
643
- queryRecord(modelName, query) {
644
- return $.getJSON('/api/current_user');
642
+ async queryRecord(modelName, query) {
643
+ if (query.me) {
644
+ const response = await fetch('/api/me');
645
+ return await response.json();
646
+ }
647
+ throw new Error('Unsupported query');
645
648
  }
646
649
  }
647
650
  ```
@@ -664,7 +667,7 @@ declare module "../-private/store-service" {
664
667
  }
665
668
  ```
666
669
 
667
- ```javascript
670
+ ```js
668
671
  store.query('user', { username: 'unique' }).then(function(users) {
669
672
  return users.firstObject;
670
673
  }).then(function(user) {
@@ -684,7 +687,7 @@ declare module "../-private/store-service" {
684
687
  }
685
688
  ```
686
689
 
687
- ```javascript
690
+ ```js
688
691
  store.queryRecord('user', { username: 'unique' }).then(function(user) {
689
692
  // user is null
690
693
  });
@@ -744,7 +747,7 @@ declare module "../-private/store-service" {
744
747
  /**
745
748
  Returns the schema for a particular resource type (modelName).
746
749
 
747
- When used with Model from @ember-data/model the return is the model class,
750
+ When used with [Model](/api/@warp-drive/legacy/model/classes/Model) the return is the model class,
748
751
  but this is not guaranteed.
749
752
 
750
753
  If looking to query attribute or relationship information it is
@@ -754,9 +757,7 @@ declare module "../-private/store-service" {
754
757
  signatures.
755
758
 
756
759
  The class of a model might be useful if you want to get a list of all the
757
- relationship names of the model, see
758
- [`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames)
759
- for example.
760
+ relationship names of the model.
760
761
 
761
762
  @public
762
763
  @deprecated use {@link Store.schema} instead
@@ -1 +1,2 @@
1
1
  export { DefaultCachePolicy, type PolicyConfig, type CacheControlValue, parseCacheControl } from "./store/-private/default-cache-policy.js";
2
+ export type { NotificationManager } from "./store/-private/managers/notification-manager.js";
@@ -7,7 +7,7 @@ import type { RequestKey, ResourceKey } from "./identifier.js";
7
7
  import type { Value } from "./json/raw.js";
8
8
  import type { TypeFromInstanceOrString } from "./record.js";
9
9
  import type { RequestContext, StructuredDataDocument, StructuredDocument } from "./request.js";
10
- import type { ResourceDocument, SingleResourceDataDocument } from "./spec/document.js";
10
+ import type { CollectionResourceDataDocument, ResourceDocument, SingleResourceDataDocument } from "./spec/document.js";
11
11
  import type { ApiError } from "./spec/error.js";
12
12
  /**
13
13
  * A hash of changed attributes with the key being the attribute name and the value being an
@@ -253,23 +253,25 @@ export interface Cache {
253
253
  *
254
254
  * @public
255
255
  */
256
- willCommit(cacheKey: ResourceKey, context: RequestContext | null): void;
256
+ willCommit(cacheKey: ResourceKey | ResourceKey[], context: RequestContext | null): void;
257
257
  /**
258
258
  * [LIFECYCLE] Signals to the cache that a resource
259
259
  * was successfully updated as part of a save transaction.
260
260
  *
261
261
  * @public
262
- * @param the primary ResourceKey that was operated on
263
- * @param data - a document in the cache format containing any updated data
262
+ * @param cacheKey - the primary ResourceKey that was operated on
263
+ * @param result - a document in the cache format containing any updated data
264
264
  */
265
- didCommit(cacheKey: ResourceKey, result: StructuredDataDocument<unknown> | null): SingleResourceDataDocument;
265
+ didCommit(cacheKey: ResourceKey, result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
266
+ didCommit(cacheKey: ResourceKey[], result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
267
+ didCommit(cacheKey: ResourceKey[], result: StructuredDataDocument<CollectionResourceDataDocument> | null): CollectionResourceDataDocument;
266
268
  /**
267
269
  * [LIFECYCLE] Signals to the cache that a resource
268
270
  * was update via a save transaction failed.
269
271
  *
270
272
  * @public
271
273
  */
272
- commitWasRejected(cacheKey: ResourceKey, errors?: ApiError[]): void;
274
+ commitWasRejected(cacheKey: ResourceKey | ResourceKey[], errors?: ApiError[]): void;
273
275
  /**
274
276
  * [LIFECYCLE] Signals to the cache that all data for a resource
275
277
  * should be cleared.
@@ -134,4 +134,136 @@ export type StringSatisfiesIncludes<
134
134
  SET extends string
135
135
  > = _StringSatisfiesIncludes<T, SET, T>;
136
136
  export declare function createIncludeValidator<T extends TypedRecordInstance>(): <U extends string>(includes: StringSatisfiesIncludes<U, Includes<T>>) => U;
137
+ /**
138
+ * A utility that takes two types, K and T, and produces a new type that is a "mask" of T based on K.
139
+ *
140
+ * That's a mouthful, so let's break it down:
141
+ *
142
+ * Let's say you have a User type and an Address type.
143
+ *
144
+ * ```ts
145
+ * interface Address {
146
+ * street: string;
147
+ * city: string;
148
+ * state: string;
149
+ * zip: string;
150
+ * }
151
+ *
152
+ * interface User {
153
+ * name: string;
154
+ * title: string;
155
+ * address: Address;
156
+ * }
157
+ * ```
158
+ *
159
+ * Now, imagine you want to load a preview of the user with some information about their address,
160
+ * but you don't want to load the entire user or address. You probably want to still ensure
161
+ * the type of the data you do load matches the underlying Address and User types, but doesn't
162
+ * include everything.
163
+ *
164
+ * If you did this manually, you might do something like this:
165
+ *
166
+ * ```ts
167
+ * interface UserPreview {
168
+ * name: string;
169
+ * address: AddressPreview;
170
+ * }
171
+ *
172
+ * interface AddressPreview {
173
+ * city: string;
174
+ * }
175
+ * ```
176
+ *
177
+ * From a TypeScript performance perspective, this is the best way to approach these preview
178
+ * types, but this is also tedious and error-prone, especially if the User or Address types change.
179
+ *
180
+ * For Address, we could create a validated type using `Pick`:
181
+ *
182
+ * ```ts
183
+ * type AddressPreview = Pick<Address, 'city'>;
184
+ * ```
185
+ *
186
+ * This ensures that if the Address type changes, our AddressPreview will still be valid.
187
+ * However, for UserPreview, we can't just use `Pick` because the `address` property is of type `Address`,
188
+ * not `AddressPreview`. This is where the `Mask` type comes in.
189
+ *
190
+ * With `Mask`, we define the `UserPreview` in two parts
191
+ * - first, we define the subset of fields we want to include from `User`, using `Pick` or an interface.
192
+ * - then, we use `Mask` to replace the related types of fields like Address with their more limited subset.
193
+ *
194
+ * Here's how we can do it:
195
+ *
196
+ * ```ts
197
+ * // First, we define the base of UserPreview with Pick
198
+ * type UserPreviewBase = Pick<User, 'name' | 'address'>;
199
+ * // Then, we use Mask to replace Address with AddressPreview
200
+ * type UserPreview = Mask<{ address: AddressPreview }, UserPreviewBase>;
201
+ * ```
202
+ *
203
+ * Now, `UserPreview` will have the `name` field from `User` and the `address` field will be of type `AddressPreview`.
204
+ * This way, if the `User` or `Address` types change, TypeScript will ensure that our `UserPreview` and `AddressPreview`
205
+ * types remain valid and consistent with the underlying types.
206
+ *
207
+ * But what if your app has data with massive interfaces such that the TypeScript performance of this
208
+ * approach becomes a problem? In that case, see {@link Validate}
209
+ */
210
+ export type Mask<
211
+ K extends object,
212
+ T extends K
213
+ > = { [P in keyof T] : P extends keyof K ? (T[P] extends K[P] ? K[P] : never) : T[P] };
214
+ /**
215
+ * A utility that takes two types, K and T, and ensures that K is a valid subset of T.
216
+ *
217
+ * That's a mouthful, so let's break it down:
218
+ *
219
+ * Let's say you have a User type and an Address type.
220
+ *
221
+ * ```ts
222
+ * interface Address {
223
+ * street: string;
224
+ * city: string;
225
+ * state: string;
226
+ * zip: string;
227
+ * }
228
+ *
229
+ * interface User {
230
+ * name: string;
231
+ * title: string;
232
+ * address: Address;
233
+ * }
234
+ * ```
235
+ *
236
+ * Now, imagine you want to load a preview of the user with some information about their address,
237
+ * but you don't want to load the entire user or address. You probably want to still ensure
238
+ * the type of the data you do load matches the underlying Address and User types, but doesn't
239
+ * include everything.
240
+ *
241
+ * You might do something like this:
242
+ *
243
+ * ```ts
244
+ * interface UserPreview {
245
+ * name: string;
246
+ * address: AddressPreview;
247
+ * }
248
+ *
249
+ * interface AddressPreview {
250
+ * city: string;
251
+ * }
252
+ * ```
253
+ *
254
+ * From a TypeScript performance perspective, this is the best way to approach these preview
255
+ * types, but this is also error-prone, especially if the User or Address types change.
256
+ *
257
+ * Validate can help ensure that your preview types remain valid.
258
+ *
259
+ * ```ts
260
+ * type IsValidUserPreview = Validate<UserPreview, User>; // This will be valid
261
+ * ```
262
+ *
263
+ * For help creating subsets of types, see {@link Mask}
264
+ */
265
+ export type Validate<
266
+ K extends object,
267
+ T extends K
268
+ > = T extends K ? K : never;
137
269
  export {};