@ember-data/store 4.5.0-beta.0 → 4.5.0

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 (64) hide show
  1. package/addon/-private/{system/backburner.js → backburner.js} +0 -0
  2. package/addon/-private/{system/coerce-id.ts → coerce-id.ts} +0 -0
  3. package/addon/-private/{system/store/common.js → common.js} +0 -0
  4. package/addon/-private/{system/core-store.ts → core-store.ts} +467 -1253
  5. package/addon/-private/{system/errors-utils.js → errors-utils.js} +7 -6
  6. package/addon/-private/{system/fetch-manager.ts → fetch-manager.ts} +72 -42
  7. package/addon/-private/finders.js +107 -0
  8. package/addon/-private/identifer-debug-consts.ts +3 -0
  9. package/addon/-private/{identifiers/cache.ts → identifier-cache.ts} +26 -14
  10. package/addon/-private/{system/identity-map.ts → identity-map.ts} +2 -1
  11. package/addon/-private/index.ts +17 -17
  12. package/addon/-private/instance-cache.ts +387 -0
  13. package/addon/-private/{system/store/internal-model-factory.ts → internal-model-factory.ts} +25 -19
  14. package/addon/-private/{system/internal-model-map.ts → internal-model-map.ts} +9 -5
  15. package/addon/-private/model/internal-model.ts +602 -0
  16. package/addon/-private/{system/references/record.ts → model/record-reference.ts} +23 -36
  17. package/addon/-private/{system/model → model}/shim-model-class.ts +19 -14
  18. package/addon/-private/{system/normalize-model-name.ts → normalize-model-name.ts} +0 -0
  19. package/addon/-private/{system/promise-proxies.ts → promise-proxies.ts} +12 -5
  20. package/addon/-private/{system/promise-proxy-base.js → promise-proxy-base.js} +0 -0
  21. package/addon/-private/{system/record-array-manager.ts → record-array-manager.ts} +19 -18
  22. package/addon/-private/{system/record-arrays → record-arrays}/adapter-populated-record-array.ts +11 -10
  23. package/addon/-private/{system/record-arrays → record-arrays}/record-array.ts +37 -19
  24. package/addon/-private/record-data-for.ts +39 -0
  25. package/addon/-private/{system/store/record-data-store-wrapper.ts → record-data-store-wrapper.ts} +21 -26
  26. package/addon/-private/{system/record-notification-manager.ts → record-notification-manager.ts} +8 -3
  27. package/addon/-private/{system/request-cache.ts → request-cache.ts} +5 -6
  28. package/addon/-private/{system/schema-definition-service.ts → schema-definition-service.ts} +30 -14
  29. package/addon/-private/{system/store/serializer-response.ts → serializer-response.ts} +7 -6
  30. package/addon/-private/{system/snapshot-record-array.ts → snapshot-record-array.ts} +27 -8
  31. package/addon/-private/{system/snapshot.ts → snapshot.ts} +54 -39
  32. package/addon/-private/utils/construct-resource.ts +7 -3
  33. package/addon/-private/utils/promise-record.ts +9 -18
  34. package/addon/-private/{system/weak-cache.ts → weak-cache.ts} +2 -2
  35. package/addon/index.ts +1 -0
  36. package/package.json +21 -20
  37. package/addon/-private/identifiers/is-stable-identifier.ts +0 -18
  38. package/addon/-private/identifiers/utils/uuid-v4.ts +0 -80
  39. package/addon/-private/system/ds-model-store.ts +0 -136
  40. package/addon/-private/system/model/internal-model.ts +0 -1303
  41. package/addon/-private/system/model/states.js +0 -736
  42. package/addon/-private/system/record-arrays.ts +0 -8
  43. package/addon/-private/system/record-data-for.ts +0 -54
  44. package/addon/-private/system/references/belongs-to.ts +0 -406
  45. package/addon/-private/system/references/has-many.ts +0 -487
  46. package/addon/-private/system/references/reference.ts +0 -205
  47. package/addon/-private/system/references.js +0 -9
  48. package/addon/-private/system/store/finders.js +0 -412
  49. package/addon/-private/ts-interfaces/ds-model.ts +0 -50
  50. package/addon/-private/ts-interfaces/ember-data-json-api.ts +0 -145
  51. package/addon/-private/ts-interfaces/fetch-manager.ts +0 -44
  52. package/addon/-private/ts-interfaces/identifier.ts +0 -246
  53. package/addon/-private/ts-interfaces/minimum-adapter-interface.ts +0 -584
  54. package/addon/-private/ts-interfaces/minimum-serializer-interface.ts +0 -257
  55. package/addon/-private/ts-interfaces/promise-proxies.ts +0 -3
  56. package/addon/-private/ts-interfaces/record-data-json-api.ts +0 -29
  57. package/addon/-private/ts-interfaces/record-data-record-wrapper.ts +0 -46
  58. package/addon/-private/ts-interfaces/record-data-schemas.ts +0 -45
  59. package/addon/-private/ts-interfaces/record-data-store-wrapper.ts +0 -56
  60. package/addon/-private/ts-interfaces/record-data.ts +0 -72
  61. package/addon/-private/ts-interfaces/record-instance.ts +0 -18
  62. package/addon/-private/ts-interfaces/schema-definition-service.ts +0 -12
  63. package/addon/-private/ts-interfaces/store.ts +0 -10
  64. package/addon/-private/ts-interfaces/utils.ts +0 -6
@@ -1,584 +0,0 @@
1
- import type Store from '../system/core-store';
2
- import type AdapterPopulatedRecordArray from '../system/record-arrays/adapter-populated-record-array';
3
- import type Snapshot from '../system/snapshot';
4
- import type SnapshotRecordArray from '../system/snapshot-record-array';
5
- import type { ModelSchema } from '../ts-interfaces/ds-model';
6
- import type { RelationshipSchema } from './record-data-schemas';
7
- import type { Dict } from './utils';
8
-
9
- type Group = Snapshot[];
10
- // TODO this should probably just alias unknown
11
- // since in theory a user could pass a blob or a string
12
- // however those deserialization cases are handled
13
- // far easier in the adapter itself and are unlikely
14
- // to be passed to the serializer today.
15
- export type AdapterPayload = Dict<unknown> | unknown[];
16
- /**
17
- * @module @ember-data/adapter
18
- */
19
-
20
- /**
21
- The following documentation describes the methods an
22
- adapter should implement with descriptions around when an
23
- application might expect these methods to be called.
24
-
25
- Methods that are not required are marked as **optional**.
26
-
27
- @class MinimumAdapterInterface
28
- @public
29
- */
30
- export interface MinimumAdapterInterface {
31
- /**
32
- * `adapter.findRecord` takes a request for a resource of a given `type` and `id` combination
33
- * and should return a `Promise` which fulfills with data for a single resource matching that
34
- * `type` and `id`.
35
- *
36
- * The response will be fed to the associated serializer's `normalizeResponse` method with the
37
- * `requestType` set to `findRecord`, which should return a `JSON:API` document.
38
- *
39
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
40
- * it will merge with any existing data for the record.
41
- *
42
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
43
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
44
- * processing within the adapter.
45
- *
46
- * `adapter.findRecord` is called whenever the `store` needs to load, reload, or backgroundReload
47
- * the resource data for a given `type` and `id`.
48
- *
49
- * @method findRecord
50
- * @public
51
- * @param {Store} store The store service that initiated the request being normalized
52
- * @param {ModelSchema} schema An object with methods for accessing information about
53
- * the type, attributes and relationships of the primary type associated with the request.
54
- * @param {String} id
55
- * @param {Snapshot} snapshot
56
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
57
- */
58
- findRecord(store: Store, schema: ModelSchema, id: string, snapshot: Snapshot): Promise<AdapterPayload>;
59
-
60
- /**
61
- * `adapter.findAll` takes a request for resources of a given `type` and should return
62
- * a `Promise` which fulfills with a collection of resource data matching that `type`.
63
- *
64
- * The response will be fed to the associated serializer's `normalizeResponse` method
65
- * with the `requestType` set to `findAll`, which should return a `JSON:API` document.
66
- *
67
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
68
- * it will merge with any existing records for `type`. Existing records for the `type` will not be removed.
69
- *
70
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
71
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
72
- * processing within the adapter.
73
- *
74
- * `adapter.findAll` is called whenever `store.findAll` is asked to reload or backgroundReload.
75
- * The records in the response are merged with the contents of the store. Existing records for
76
- * the `type` will not be removed.
77
- *
78
- * See also `shouldReloadAll` and `shouldBackgroundReloadAll`
79
- *
80
- * @method findAll
81
- * @public
82
- * @param {Store} store The store service that initiated the request being normalized
83
- * @param {ModelSchema} schema An object with methods for accessing information about
84
- * the type, attributes and relationships of the primary type associated with the request.
85
- * @param {null} sinceToken This parameter is no longer used and will always be null.
86
- * @param {SnapshotRecordArray} snapshotRecordArray an object containing any passed in options,
87
- * adapterOptions, and the ability to access a snapshot for each existing record of the type.
88
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
89
- */
90
- findAll(
91
- store: Store,
92
- schema: ModelSchema,
93
- sinceToken: null,
94
- snapshotRecordArray: SnapshotRecordArray
95
- ): Promise<AdapterPayload>;
96
-
97
- /**
98
- * `adapter.query` takes a request for resources of a given `type` and should return
99
- * a `Promise` which fulfills with a collection of resource data matching that `type`.
100
- *
101
- * The response will be fed to the associated serializer's `normalizeResponse` method
102
- * with the `requestType` set to `query`, which should return a `JSON:API` document.
103
- *
104
- * As with `findAll`, the final result after normalization to `JSON:API` will be added to
105
- * store via `store.push` where it will merge with any existing records for `type`.
106
- *
107
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
108
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
109
- * processing within the adapter.
110
- *
111
- * `adapter.query` is called whenever `store.query` is called or a previous query result is
112
- * asked to reload.
113
- *
114
- * Existing records for the `type` will not be removed. The key difference is in the result
115
- * returned by the `store`. For `findAll` the result is all known records of the `type`,
116
- * while for `query` it will only be the records returned from `adapter.query`.
117
- *
118
- * @method query
119
- * @public
120
- * @param {Store} store The store service that initiated the request being normalized
121
- * @param {ModelSchema} schema An object with methods for accessing information about
122
- * the type, attributes and relationships of the primary type associated with the request.
123
- * @param {object} query
124
- * @param {AdapterPopulatedRecordArray} recordArray
125
- * @param {object} options
126
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
127
- */
128
- query(
129
- store: Store,
130
- schema: ModelSchema,
131
- query: Dict<unknown>,
132
- recordArray: AdapterPopulatedRecordArray,
133
- options: { adapterOptions?: unknown }
134
- ): Promise<AdapterPayload>;
135
-
136
- /**
137
- * `adapter.queryRecord` takes a request for resource of a given `type` and should return
138
- * a `Promise` which fulfills with data for a single resource matching that `type`.
139
- *
140
- * The response will be fed to the associated serializer's `normalizeResponse` method
141
- * with the `requestType` set to `queryRecord`, which should return a `JSON:API` document.
142
- *
143
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
144
- * it will merge with any existing data for the returned record.
145
- *
146
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
147
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
148
- * processing within the adapter.
149
- *
150
- * @method queryRecord
151
- * @public
152
- * @param {Store} store The store service that initiated the request being normalized
153
- * @param {ModelSchema} schema An object with methods for accessing information about
154
- * the type, attributes and relationships of the primary type associated with the request.
155
- * @param query
156
- * @param options
157
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
158
- */
159
- queryRecord(
160
- store: Store,
161
- schema: ModelSchema,
162
- query: Dict<unknown>,
163
- options: { adapterOptions?: unknown }
164
- ): Promise<AdapterPayload>;
165
-
166
- /**
167
- * `adapter.createRecord` takes a request to create a resource of a given `type` and should
168
- * return a `Promise` which fulfills with data for the newly created resource.
169
- *
170
- * The response will be fed to the associated serializer's `normalizeResponse` method
171
- * with the `requestType` set to `createRecord`, which should return a `JSON:API` document.
172
- *
173
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
174
- * it will merge with any existing data for the record.
175
- *
176
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
177
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
178
- * processing within the adapter.
179
- *
180
- * If the adapter rejects or throws an error the record will enter an error state and the attributes
181
- * that had attempted to be saved will still be considered dirty.
182
- *
183
- * ### InvalidErrors
184
- *
185
- * When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code),
186
- * you may throw an `InvalidError`.
187
- *
188
- * Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed.
189
- * Records can also use this information to mark themselves as being in an `invalid` state.
190
- * For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html)
191
- *
192
- * ```js
193
- * let error = new Error(errorMessage);
194
- *
195
- * // these two properties combined
196
- * // alert EmberData to this error being for
197
- * // invalid properties on the record during
198
- * // the request
199
- * error.isAdapterError = true;
200
- * error.code = 'InvalidError';
201
- *
202
- * // A JSON:API formatted array of errors
203
- * // See https://jsonapi.org/format/#errors
204
- * error.errors = [];
205
- *
206
- * throw error;
207
- * ```
208
- *
209
- * @method createRecord
210
- * @public
211
- * @param {Store} store The store service that initiated the request being normalized
212
- * @param {ModelSchema} schema An object with methods for accessing information about
213
- * the type, attributes and relationships of the primary type associated with the request.
214
- * @param {Snapshot} snapshot
215
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
216
- */
217
- createRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
218
-
219
- /**
220
- * `adapter.updateRecord` takes a request to update a resource of a given `type` and should
221
- * return a `Promise` which fulfills with the updated data for the resource.
222
- *
223
- * The response will be fed to the associated serializer's `normalizeResponse` method
224
- * with the `requestType` set to `updateRecord`, which should return a `JSON:API` document.
225
- *
226
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
227
- * it will merge with any existing data for the record.
228
- *
229
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
230
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
231
- * processing within the adapter.
232
- *
233
- * If the adapter rejects or throws an error the record will enter an error state and the attributes
234
- * that had attempted to be saved will still be considered dirty.
235
- *
236
- * ### InvalidErrors
237
- *
238
- * When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code),
239
- * you may throw an `InvalidError`.
240
- *
241
- * Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed.
242
- * Records can also use this information to mark themselves as being in an `invalid` state.
243
- * For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html)
244
- *
245
- * ```js
246
- * let error = new Error(errorMessage);
247
- *
248
- * // these two properties combined
249
- * // alert EmberData to this error being for
250
- * // invalid properties on the record during
251
- * // the request
252
- * error.isAdapterError = true;
253
- * error.code = 'InvalidError';
254
- *
255
- * // A JSON:API formatted array of errors
256
- * // See https://jsonapi.org/format/#errors
257
- * error.errors = [];
258
- *
259
- * throw error;
260
- * ```
261
- *
262
- * @method updateRecord
263
- * @public
264
- * @param {Store} store The store service that initiated the request being normalized
265
- * @param {ModelSchema} schema An object with methods for accessing information about
266
- * the type, attributes and relationships of the primary type associated with the request.
267
- * @param {Snapshot} snapshot
268
- */
269
- updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
270
-
271
- /**
272
- * `adapter.deleteRecord` takes a request to delete a resource of a given `type` and
273
- * should return a `Promise` which resolves when that deletion is complete.
274
- *
275
- * Usually the response will be empty, but you may include additional updates in the
276
- * response. The response will be fed to the associated serializer's `normalizeResponse` method
277
- * with the `requestType` set to `deleteRecord`, which should return a `JSON:API` document.
278
- *
279
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
280
- * it will merge with any existing data.
281
- *
282
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
283
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
284
- * processing within the adapter.
285
- *
286
- * If the adapter rejects or errors the record will need to be saved again once the reason
287
- * for the error is addressed in order to persist the deleted state.
288
- *
289
- * @method deleteRecord
290
- * @public
291
- * @param {Store} store The store service that initiated the request being normalized
292
- * @param {ModelSchema} schema An object with methods for accessing information about
293
- * the type, attributes and relationships of the primary type associated with the request.
294
- * @param {Snapshot} snapshot A Snapshot containing the record's current data
295
- * @return
296
- */
297
- deleteRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
298
-
299
- /**
300
- * `adapter.findBelongsTo` takes a request to fetch a related resource located at a
301
- * `relatedLink` and should return a `Promise` which fulfills with data for a single
302
- * resource.
303
- *
304
- * ⚠️ This method is only called if the store previously received relationship information for a resource
305
- * containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links).
306
- *
307
- * If the cache does not have a `link` for the relationship then `findRecord` will be used if a `type` and `id`
308
- * for the related resource is known.
309
- *
310
- * The response will be fed to the associated serializer's `normalizeResponse` method
311
- * with the `requestType` set to `findBelongsTo`, which should return a `JSON:API` document.
312
- *
313
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
314
- * it will merge with any existing data.
315
- *
316
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
317
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
318
- * processing within the adapter.
319
- *
320
- * @method findBelongsTo [OPTIONAL]
321
- * @public
322
- * @optional
323
- * @param {Store} store The store service that initiated the request being normalized
324
- * @param {Snapshot} snapshot A Snapshot containing the parent record's current data
325
- * @param {string} relatedLink The link at which the associated resource might be found
326
- * @param {RelationshipSchema} relationship
327
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
328
- */
329
- findBelongsTo?(
330
- store: Store,
331
- snapshot: Snapshot,
332
- relatedLink: string,
333
- relationship: RelationshipSchema
334
- ): Promise<AdapterPayload>;
335
-
336
- /**
337
- * `adapter.findHasMany` takes a request to fetch a related resource collection located
338
- * at a `relatedLink` and should return a `Promise` which fulfills with data for that
339
- * collection.
340
- *
341
- * ⚠️ This method is only called if the store previously received relationship information for a resource
342
- * containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links).
343
- *
344
- * If the cache does not have a `link` for the relationship but the `type` and `id` of
345
- * related resources are known then `findRecord` will be used for each individual related
346
- * resource.
347
- *
348
- * The response will be fed to the associated serializer's `normalizeResponse` method
349
- * with the `requestType` set to `findHasMany`, which should return a `JSON:API` document.
350
- *
351
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
352
- * it will merge with any existing data.
353
- *
354
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
355
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
356
- * processing within the adapter.
357
- *
358
- * @method findhasMany [OPTIONAL]
359
- * @public
360
- * @optional
361
- * @param {Store} store The store service that initiated the request being normalized
362
- * @param {Snapshot} snapshot A Snapshot containing the parent record's current data
363
- * @param {string} relatedLink The link at which the associated resource collection might be found
364
- * @param {RelationshipSchema} relationship
365
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
366
- */
367
- findHasMany?(
368
- store: Store,
369
- snapshot: Snapshot,
370
- relatedLink: string,
371
- relationship: RelationshipSchema
372
- ): Promise<AdapterPayload>;
373
-
374
- /**
375
- * ⚠️ This Method is only called if `coalesceFindRequests` is `true`. The array passed to it is determined
376
- * by the adapter's `groupRecordsForFindMany` method, and will be called once per group returned.
377
- *
378
- * `adapter.findMany` takes a request to fetch a collection of resources and should return a
379
- * `Promise` which fulfills with data for that collection.
380
- *
381
- * The response will be fed to the associated serializer's `normalizeResponse` method
382
- * with the `requestType` set to `findMany`, which should return a `JSON:API` document.
383
- *
384
- * The final result after normalization to `JSON:API` will be added to store via `store.push` where
385
- * it will merge with any existing data.
386
- *
387
- * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
388
- * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
389
- * processing within the adapter.
390
- *
391
- * See also `groupRecordsForFindMany` and `coalesceFindRequests`
392
- *
393
- * @method findMany [OPTIONAL]
394
- * @public
395
- * @optional
396
- * @param {Store} store The store service that initiated the request being normalized
397
- * @param {ModelSchema} schema An object with methods for accessing information about
398
- * the type, attributes and relationships of the primary type associated with the request.
399
- * @param {Array<string>} ids An array of the ids of the resources to fetch
400
- * @param {Array<Snapshot>} snapshots An array of snapshots of the available data for the resources to fetch
401
- * @return {Promise} a promise resolving with resource data to feed to the associated serializer
402
- */
403
- findMany?(store: Store, schema: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload>;
404
-
405
- /**
406
- * This method provides the ability to generate an ID to assign to a new record whenever `store.createRecord`
407
- * is called if no `id` was provided.
408
- *
409
- * Alternatively you can pass an id into the call to `store.createRecord` directly.
410
- *
411
- * ```js
412
- * let id = generateNewId(type);
413
- * let newRecord = store.createRecord(type, { id });
414
- * ```
415
- *
416
- * @method generateIdForRecord [OPTIONAL]
417
- * @public
418
- * @optional
419
- * @param {Store} store The store service that initiated the request being normalized
420
- * @param {String} type The type (or modelName) of record being created
421
- * @param properties the properties passed as the second arg to `store.createRecord`
422
- * @return {String} a string ID that should be unique (no other models of `type` in the cache should have this `id`)
423
- */
424
- generateIdForRecord?(store: Store, type: string, properties: unknown): string;
425
-
426
- /**
427
- * If your adapter implements `findMany`, setting this to `true` will cause `findRecord`
428
- * requests triggered within the same `runloop` to be coalesced into one or more calls
429
- * to `adapter.findMany`. The number of calls made and the records contained in each call
430
- * can be tuned by your adapter's `groupRecordsForHasMany` method.
431
- *
432
- * Implementing coalescing using this flag and the associated methods does not always offer
433
- * the right level of correctness, timing control or granularity. If your application would
434
- * be better suited coalescing across multiple types, coalescing for longer than a single runloop,
435
- * or with a more custom request structure, coalescing within your application adapter may prove
436
- * more effective.
437
- *
438
- * @property coalesceFindRequests [OPTIONAL]
439
- * @public
440
- * @optional
441
- * @type {boolean} true if the requests to find individual records should be coalesced, false otherwise
442
- */
443
- coalesceFindRequests?: boolean;
444
-
445
- /**
446
- * ⚠️ This Method is only called if `coalesceFindRequests` is `true`.
447
- *
448
- * This method allows for you to split pending requests for records into multiple `findMany`
449
- * requests. It receives an array of snapshots where each snapshot represents a unique record
450
- * requested via `store.findRecord` during the most recent `runloop` that was not found in the
451
- * cache or needs to be reloaded. It should return an array of groups.
452
- *
453
- * A group is an array of snapshots meant to be fetched together by a single `findMany` request.
454
- *
455
- * By default if this method is not implemented EmberData will call `findMany` once with all
456
- * requested records as a single group when `coalesceFindRequests` is `true`.
457
- *
458
- * See also `findMany` and `coalesceFindRequests`
459
- *
460
- * @method groupRecordsForFindMany [OPTIONAL]
461
- * @public
462
- * @optional
463
- * @param {Store} store The store service that initiated the request being normalized
464
- * @param {Array<Snapshot>} snapshots An array of snapshots
465
- * @return {Array<Array<Snapshot>>} An array of Snapshot arrays
466
- */
467
- groupRecordsForFindMany?(store: Store, snapshots: Snapshot[]): Group[];
468
-
469
- /**
470
- * When a record is already available in the store and is requested again via `store.findRecord`,
471
- * and `reload` is not specified as an option in the request, this method is called to determine
472
- * whether the record should be reloaded prior to returning the result.
473
- *
474
- * If `reload` is specified as an option in the request (`true` or `false`) this method will not
475
- * be called.
476
- *
477
- * ```js
478
- * store.findRecord('user', '1', { reload: false })
479
- * ```
480
- *
481
- * The default behavior if this method is not implemented and the option is not specified is to
482
- * not reload, the same as a return of `false`.
483
- *
484
- * See also the documentation for `shouldBackgroundReloadRecord` which defaults to `true`.
485
- *
486
- * @method shouldReloadRecord [OPTIONAL]
487
- * @public
488
- * @optional
489
- * @param {Store} store The store service that initiated the request being normalized
490
- * @param {Snapshot} snapshot A Snapshot containing the record's current data
491
- * @return {boolean} true if the record should be reloaded immediately, false otherwise
492
- */
493
- shouldReloadRecord?(store: Store, snapshot: Snapshot): boolean;
494
-
495
- /**
496
- * When `store.findAll(<type>)` is called without a `reload` option, the adapter
497
- * is presented the opportunity to trigger a new request for records of that type.
498
- *
499
- * If `reload` is specified as an option in the request (`true` or `false`) this method will not
500
- * be called.
501
- *
502
- * ```js
503
- * store.findAll('user', { reload: false })
504
- * ```
505
- *
506
- * The default behavior if this method is not implemented and the option is not specified is to
507
- * not reload, the same as a return of `false`.
508
- *
509
- * Note: the Promise returned by `store.findAll` resolves to the same RecordArray instance
510
- * returned by `store.peekAll` for that type, and will include all records in the store for
511
- * the given type, including any previously existing records not returned by the reload request.
512
- *
513
- * @method shouldReloadAll [OPTIONAL]
514
- * @public
515
- * @optional
516
- * @param {Store} store The store service that initiated the request being normalized
517
- * @param {SnapshotRecordArray} snapshotArray
518
- * @return {boolean} true if the a new request for all records of the type in SnapshotRecordArray should be made immediately, false otherwise
519
- */
520
- shouldReloadAll?(store: Store, snapshotArray: SnapshotRecordArray): boolean;
521
-
522
- /**
523
- * When a record is already available in the store and is requested again via `store.findRecord`,
524
- * and the record does not need to be reloaded prior to return, this method provides the ability
525
- * to specify whether a refresh of the data for the reload should be scheduled to occur in the background.
526
- *
527
- * Users may explicitly declare a record should/should not be background reloaded by passing
528
- * `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively.
529
- *
530
- * ```js
531
- * store.findRecord('user', '1', { backgroundReload: false })
532
- * ```
533
- *
534
- * If the `backgroundReload` option is not present, this method will be called to determine whether
535
- * a backgroundReload should be performed.
536
- *
537
- * The default behavior if this method is not implemented and the option was not specified is to
538
- * background reload, the same as a return of `true`.
539
- *
540
- * @method shouldBackgroundReloadRecord [OPTIONAL]
541
- * @public
542
- * @optional
543
- * @param {Store} store The store service that initiated the request being normalized
544
- * @param {Snapshot} snapshot A Snapshot containing the record's current data
545
- * @return {boolean} true if the record should be reloaded in the background, false otherwise
546
- */
547
- shouldBackgroundReloadRecord?(store: Store, snapshot: Snapshot): boolean;
548
-
549
- /**
550
- * When `store.findAll(<type>)` is called and a `reload` is not initiated, the adapter
551
- * is presented the opportunity to trigger a new non-blocking (background) request for
552
- * records of that type
553
- *
554
- * Users may explicitly declare that this background request should/should not occur by passing
555
- * `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively.
556
- *
557
- * ```js
558
- * store.findAll('user', { backgroundReload: false })
559
- * ```
560
- *
561
- * The default behavior if this method is not implemented and the option is not specified is to
562
- * perform a reload, the same as a return of `true`.
563
- *
564
- * @method shouldBackgroundReloadAll [OPTIONAL]
565
- * @public
566
- * @optional
567
- * @param {Store} store The store service that initiated the request being normalized
568
- * @param {SnapshotRecordArray} snapshotArray
569
- * @return {boolean} true if the a new request for all records of the type in SnapshotRecordArray should be made in the background, false otherwise
570
- */
571
- shouldBackgroundReloadAll?(store: Store, snapshotArray: SnapshotRecordArray): boolean;
572
-
573
- /**
574
- * In some situations the adapter may need to perform cleanup when destroyed,
575
- * that cleanup can be done in `destroy`.
576
- *
577
- * If not implemented, the store does not inform the adapter of destruction.
578
- *
579
- * @method destroy [OPTIONAL]
580
- * @public
581
- * @optional
582
- */
583
- destroy?(): void;
584
- }