@@ -13,8 +13,9 @@ import type { InstanceCache } from '@ember-data/store/-private/caches/instance-c
13
13
import type RequestStateService from '@ember-data/store/-private/network/request-cache' ;
14
14
import type { FindRecordQuery , Request , SaveRecordMutation } from '@ember-data/store/-private/network/request-cache' ;
15
15
import type { ModelSchema } from '@ember-data/store/-types/q/ds-model' ;
16
- import type { FindOptions } from '@ember-data/store/-types/q/store' ;
16
+ import type { FindRecordOptions } from '@ember-data/store/-types/q/store' ;
17
17
import type { StableExistingRecordIdentifier , StableRecordIdentifier } from '@warp-drive/core-types/identifier' ;
18
+ import type { TypeFromInstance } from '@warp-drive/core-types/record' ;
18
19
import type { CollectionResourceDocument , SingleResourceDocument } from '@warp-drive/core-types/spec/raw' ;
19
20
20
21
import { upgradeStore } from '../-private' ;
@@ -32,14 +33,14 @@ type SerializerWithParseErrors = MinimumSerializerInterface & {
32
33
33
34
export const SaveOp : unique symbol = Symbol ( 'SaveOp' ) ;
34
35
35
- export type FetchMutationOptions = FindOptions & { [ SaveOp ] : 'createRecord' | 'deleteRecord' | 'updateRecord' } ;
36
+ export type FetchMutationOptions = FindRecordOptions & { [ SaveOp ] : 'createRecord' | 'deleteRecord' | 'updateRecord' } ;
36
37
37
38
interface PendingFetchItem {
38
39
identifier : StableExistingRecordIdentifier ;
39
40
queryRequest : Request ;
40
41
// eslint-disable-next-line @typescript-eslint/no-explicit-any
41
42
resolver : Deferred < any > ;
42
- options : FindOptions ;
43
+ options : FindRecordOptions ;
43
44
trace ?: unknown ;
44
45
promise : Promise < StableExistingRecordIdentifier > ;
45
46
}
@@ -68,7 +69,9 @@ export default class FetchManager {
68
69
this . isDestroyed = false ;
69
70
}
70
71
71
- createSnapshot ( identifier : StableRecordIdentifier , options : FindOptions = { } ) : Snapshot {
72
+ createSnapshot < T > ( identifier : StableRecordIdentifier < TypeFromInstance < T > > , options ?: FindRecordOptions ) : Snapshot < T > ;
73
+ createSnapshot ( identifier : StableRecordIdentifier , options ?: FindRecordOptions ) : Snapshot ;
74
+ createSnapshot ( identifier : StableRecordIdentifier , options : FindRecordOptions = { } ) : Snapshot {
72
75
return new Snapshot ( options , identifier , this . _store ) ;
73
76
}
74
77
@@ -112,7 +115,7 @@ export default class FetchManager {
112
115
113
116
scheduleFetch (
114
117
identifier : StableExistingRecordIdentifier ,
115
- options : FindOptions ,
118
+ options : FindRecordOptions ,
116
119
request : StoreRequestInfo
117
120
) : Promise < StableExistingRecordIdentifier > {
118
121
const query : FindRecordQuery = {
@@ -222,7 +225,7 @@ export default class FetchManager {
222
225
return promise ;
223
226
}
224
227
225
- getPendingFetch ( identifier : StableExistingRecordIdentifier , options : FindOptions ) {
228
+ getPendingFetch ( identifier : StableExistingRecordIdentifier , options : FindRecordOptions ) {
226
229
const pendingFetches = this . _pendingFetch . get ( identifier . type ) ?. get ( identifier ) ;
227
230
228
231
// We already have a pending fetch for this
@@ -246,7 +249,7 @@ export default class FetchManager {
246
249
247
250
fetchDataIfNeededForIdentifier (
248
251
identifier : StableExistingRecordIdentifier ,
249
- options : FindOptions = { } ,
252
+ options : FindRecordOptions = { } ,
250
253
request : StoreRequestInfo
251
254
) : Promise < StableExistingRecordIdentifier > {
252
255
// pre-loading will change the isEmpty value
@@ -338,7 +341,7 @@ function optionsSatisfies(current: object | undefined, existing: object | undefi
338
341
}
339
342
340
343
// this function helps resolve whether we have a pending request that we should use instead
341
- function isSameRequest ( options : FindOptions = { } , existingOptions : FindOptions = { } ) {
344
+ function isSameRequest ( options : FindRecordOptions = { } , existingOptions : FindRecordOptions = { } ) {
342
345
return (
343
346
optionsSatisfies ( options . adapterOptions , existingOptions . adapterOptions ) &&
344
347
includesSatisfies ( options . include , existingOptions . include )
0 commit comments