@ember-data/legacy-compat 5.4.0-alpha.30 → 5.4.0-alpha.32

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 (25) hide show
  1. package/package.json +17 -16
  2. package/unstable-preview-types/-private.d.ts +15 -0
  3. package/unstable-preview-types/-private.d.ts.map +1 -0
  4. package/unstable-preview-types/index.d.ts +141 -0
  5. package/unstable-preview-types/index.d.ts.map +1 -0
  6. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts +47 -0
  7. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts.map +1 -0
  8. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts +3 -0
  9. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts.map +1 -0
  10. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts +3 -0
  11. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts.map +1 -0
  12. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts +4 -0
  13. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts.map +1 -0
  14. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts +3 -0
  15. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts.map +1 -0
  16. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts +547 -0
  17. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts.map +1 -0
  18. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts +233 -0
  19. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts.map +1 -0
  20. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts +7 -0
  21. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts.map +1 -0
  22. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts +95 -0
  23. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts.map +1 -0
  24. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts +246 -0
  25. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts.map +1 -0
@@ -0,0 +1,547 @@
1
+ /**
2
+ * @module @ember-data/experimental-preview-types
3
+ */
4
+ import type Store from '@ember-data/store';
5
+ import type { Collection } from '@ember-data/store/-private/record-arrays/identifier-array';
6
+ import type { ModelSchema } from '@ember-data/store/-types/q/ds-model';
7
+ import type { RelationshipSchema } from '@warp-drive/core-types/schema';
8
+ import type Snapshot from './snapshot';
9
+ import type SnapshotRecordArray from './snapshot-record-array';
10
+ type Group = Snapshot[];
11
+ export type AdapterPayload = Record<string, unknown> | unknown[];
12
+ /**
13
+ * <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
14
+ <p>
15
+ ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
16
+ If starting a new app or thinking of implementing a new adapter, consider writing a
17
+ <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
18
+ </p>
19
+ </blockquote>
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 <Interface> Adapter
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
+ * `adapter.findAll` takes a request for resources of a given `type` and should return
61
+ * a `Promise` which fulfills with a collection of resource data matching that `type`.
62
+ *
63
+ * The response will be fed to the associated serializer's `normalizeResponse` method
64
+ * with the `requestType` set to `findAll`, which should return a `JSON:API` document.
65
+ *
66
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
67
+ * it will merge with any existing records for `type`. Existing records for the `type` will not be removed.
68
+ *
69
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
70
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
71
+ * processing within the adapter.
72
+ *
73
+ * `adapter.findAll` is called whenever `store.findAll` is asked to reload or backgroundReload.
74
+ * The records in the response are merged with the contents of the store. Existing records for
75
+ * the `type` will not be removed.
76
+ *
77
+ * See also `shouldReloadAll` and `shouldBackgroundReloadAll`
78
+ *
79
+ * @method findAll
80
+ * @public
81
+ * @param {Store} store The store service that initiated the request being normalized
82
+ * @param {ModelSchema} schema An object with methods for accessing information about
83
+ * the type, attributes and relationships of the primary type associated with the request.
84
+ * @param {null} sinceToken This parameter is no longer used and will always be null.
85
+ * @param {SnapshotRecordArray} snapshotRecordArray an object containing any passed in options,
86
+ * adapterOptions, and the ability to access a snapshot for each existing record of the type.
87
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
88
+ */
89
+ findAll(store: Store, schema: ModelSchema, sinceToken: null, snapshotRecordArray: SnapshotRecordArray): Promise<AdapterPayload>;
90
+ /**
91
+ * `adapter.query` takes a request for resources of a given `type` and should return
92
+ * a `Promise` which fulfills with a collection of resource data matching that `type`.
93
+ *
94
+ * The response will be fed to the associated serializer's `normalizeResponse` method
95
+ * with the `requestType` set to `query`, which should return a `JSON:API` document.
96
+ *
97
+ * As with `findAll`, the final result after normalization to `JSON:API` will be added to
98
+ * store via `store.push` where it will merge with any existing records for `type`.
99
+ *
100
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
101
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
102
+ * processing within the adapter.
103
+ *
104
+ * `adapter.query` is called whenever `store.query` is called or a previous query result is
105
+ * asked to reload.
106
+ *
107
+ * Existing records for the `type` will not be removed. The key difference is in the result
108
+ * returned by the `store`. For `findAll` the result is all known records of the `type`,
109
+ * while for `query` it will only be the records returned from `adapter.query`.
110
+ *
111
+ * @method query
112
+ * @public
113
+ * @param {Store} store The store service that initiated the request being normalized
114
+ * @param {ModelSchema} schema An object with methods for accessing information about
115
+ * the type, attributes and relationships of the primary type associated with the request.
116
+ * @param {object} query
117
+ * @param {Collection} recordArray
118
+ * @param {object} options
119
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
120
+ */
121
+ query(store: Store, schema: ModelSchema, query: Record<string, unknown>, recordArray: Collection, options: {
122
+ adapterOptions?: unknown;
123
+ }): Promise<AdapterPayload>;
124
+ /**
125
+ * `adapter.queryRecord` takes a request for resource of a given `type` and should return
126
+ * a `Promise` which fulfills with data for a single resource matching that `type`.
127
+ *
128
+ * The response will be fed to the associated serializer's `normalizeResponse` method
129
+ * with the `requestType` set to `queryRecord`, which should return a `JSON:API` document.
130
+ *
131
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
132
+ * it will merge with any existing data for the returned record.
133
+ *
134
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
135
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
136
+ * processing within the adapter.
137
+ *
138
+ * @method queryRecord
139
+ * @public
140
+ * @param {Store} store The store service that initiated the request being normalized
141
+ * @param {ModelSchema} schema An object with methods for accessing information about
142
+ * the type, attributes and relationships of the primary type associated with the request.
143
+ * @param query
144
+ * @param options
145
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
146
+ */
147
+ queryRecord(store: Store, schema: ModelSchema, query: Record<string, unknown>, options: {
148
+ adapterOptions?: unknown;
149
+ }): Promise<AdapterPayload>;
150
+ /**
151
+ * `adapter.createRecord` takes a request to create a resource of a given `type` and should
152
+ * return a `Promise` which fulfills with data for the newly created resource.
153
+ *
154
+ * The response will be fed to the associated serializer's `normalizeResponse` method
155
+ * with the `requestType` set to `createRecord`, which should return a `JSON:API` document.
156
+ *
157
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
158
+ * it will merge with any existing data for the record.
159
+ *
160
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
161
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
162
+ * processing within the adapter.
163
+ *
164
+ * If the adapter rejects or throws an error the record will enter an error state and the attributes
165
+ * that had attempted to be saved will still be considered dirty.
166
+ *
167
+ * ### InvalidErrors
168
+ *
169
+ * When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code),
170
+ * you may throw an `InvalidError`.
171
+ *
172
+ * Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed.
173
+ * Records can also use this information to mark themselves as being in an `invalid` state.
174
+ * For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html)
175
+ *
176
+ * ```js
177
+ * let error = new Error(errorMessage);
178
+ *
179
+ * // these two properties combined
180
+ * // alert EmberData to this error being for
181
+ * // invalid properties on the record during
182
+ * // the request
183
+ * error.isAdapterError = true;
184
+ * error.code = 'InvalidError';
185
+ *
186
+ * // A JSON:API formatted array of errors
187
+ * // See https://jsonapi.org/format/#errors
188
+ * error.errors = [];
189
+ *
190
+ * throw error;
191
+ * ```
192
+ *
193
+ * @method createRecord
194
+ * @public
195
+ * @param {Store} store The store service that initiated the request being normalized
196
+ * @param {ModelSchema} schema An object with methods for accessing information about
197
+ * the type, attributes and relationships of the primary type associated with the request.
198
+ * @param {Snapshot} snapshot
199
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
200
+ */
201
+ createRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
202
+ /**
203
+ * `adapter.updateRecord` takes a request to update a resource of a given `type` and should
204
+ * return a `Promise` which fulfills with the updated data for the resource.
205
+ *
206
+ * The response will be fed to the associated serializer's `normalizeResponse` method
207
+ * with the `requestType` set to `updateRecord`, which should return a `JSON:API` document.
208
+ *
209
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
210
+ * it will merge with any existing data for the record.
211
+ *
212
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
213
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
214
+ * processing within the adapter.
215
+ *
216
+ * If the adapter rejects or throws an error the record will enter an error state and the attributes
217
+ * that had attempted to be saved will still be considered dirty.
218
+ *
219
+ * ### InvalidErrors
220
+ *
221
+ * When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code),
222
+ * you may throw an `InvalidError`.
223
+ *
224
+ * Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed.
225
+ * Records can also use this information to mark themselves as being in an `invalid` state.
226
+ * For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html)
227
+ *
228
+ * ```js
229
+ * let error = new Error(errorMessage);
230
+ *
231
+ * // these two properties combined
232
+ * // alert EmberData to this error being for
233
+ * // invalid properties on the record during
234
+ * // the request
235
+ * error.isAdapterError = true;
236
+ * error.code = 'InvalidError';
237
+ *
238
+ * // A JSON:API formatted array of errors
239
+ * // See https://jsonapi.org/format/#errors
240
+ * error.errors = [];
241
+ *
242
+ * throw error;
243
+ * ```
244
+ *
245
+ * @method updateRecord
246
+ * @public
247
+ * @param {Store} store The store service that initiated the request being normalized
248
+ * @param {ModelSchema} schema An object with methods for accessing information about
249
+ * the type, attributes and relationships of the primary type associated with the request.
250
+ * @param {Snapshot} snapshot
251
+ */
252
+ updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
253
+ /**
254
+ * `adapter.deleteRecord` takes a request to delete a resource of a given `type` and
255
+ * should return a `Promise` which resolves when that deletion is complete.
256
+ *
257
+ * Usually the response will be empty, but you may include additional updates in the
258
+ * response. The response will be fed to the associated serializer's `normalizeResponse` method
259
+ * with the `requestType` set to `deleteRecord`, which should return a `JSON:API` document.
260
+ *
261
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
262
+ * it will merge with any existing data.
263
+ *
264
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
265
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
266
+ * processing within the adapter.
267
+ *
268
+ * If the adapter rejects or errors the record will need to be saved again once the reason
269
+ * for the error is addressed in order to persist the deleted state.
270
+ *
271
+ * @method deleteRecord
272
+ * @public
273
+ * @param {Store} store The store service that initiated the request being normalized
274
+ * @param {ModelSchema} schema An object with methods for accessing information about
275
+ * the type, attributes and relationships of the primary type associated with the request.
276
+ * @param {Snapshot} snapshot A Snapshot containing the record's current data
277
+ * @return
278
+ */
279
+ deleteRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
280
+ /**
281
+ * `adapter.findBelongsTo` takes a request to fetch a related resource located at a
282
+ * `relatedLink` and should return a `Promise` which fulfills with data for a single
283
+ * resource.
284
+ *
285
+ * ⚠️ This method is only called if the store previously received relationship information for a resource
286
+ * containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links).
287
+ *
288
+ * If the cache does not have a `link` for the relationship then `findRecord` will be used if a `type` and `id`
289
+ * for the related resource is known.
290
+ *
291
+ * The response will be fed to the associated serializer's `normalizeResponse` method
292
+ * with the `requestType` set to `findBelongsTo`, which should return a `JSON:API` document.
293
+ *
294
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
295
+ * it will merge with any existing data.
296
+ *
297
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
298
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
299
+ * processing within the adapter.
300
+ *
301
+ * @method findBelongsTo [OPTIONAL]
302
+ * @public
303
+ * @optional
304
+ * @param {Store} store The store service that initiated the request being normalized
305
+ * @param {Snapshot} snapshot A Snapshot containing the parent record's current data
306
+ * @param {string} relatedLink The link at which the associated resource might be found
307
+ * @param {RelationshipSchema} relationship
308
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
309
+ */
310
+ findBelongsTo?(store: Store, snapshot: Snapshot, relatedLink: string, relationship: RelationshipSchema): Promise<AdapterPayload>;
311
+ /**
312
+ * `adapter.findHasMany` takes a request to fetch a related resource collection located
313
+ * at a `relatedLink` and should return a `Promise` which fulfills with data for that
314
+ * collection.
315
+ *
316
+ * ⚠️ This method is only called if the store previously received relationship information for a resource
317
+ * containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links).
318
+ *
319
+ * If the cache does not have a `link` for the relationship but the `type` and `id` of
320
+ * related resources are known then `findRecord` will be used for each individual related
321
+ * resource.
322
+ *
323
+ * The response will be fed to the associated serializer's `normalizeResponse` method
324
+ * with the `requestType` set to `findHasMany`, which should return a `JSON:API` document.
325
+ *
326
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
327
+ * it will merge with any existing data.
328
+ *
329
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
330
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
331
+ * processing within the adapter.
332
+ *
333
+ * @method findhasMany [OPTIONAL]
334
+ * @public
335
+ * @optional
336
+ * @param {Store} store The store service that initiated the request being normalized
337
+ * @param {Snapshot} snapshot A Snapshot containing the parent record's current data
338
+ * @param {string} relatedLink The link at which the associated resource collection might be found
339
+ * @param {RelationshipSchema} relationship
340
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
341
+ */
342
+ findHasMany?(store: Store, snapshot: Snapshot, relatedLink: string, relationship: RelationshipSchema): Promise<AdapterPayload>;
343
+ /**
344
+ * ⚠️ This Method is only called if `coalesceFindRequests` is `true`. The array passed to it is determined
345
+ * by the adapter's `groupRecordsForFindMany` method, and will be called once per group returned.
346
+ *
347
+ * `adapter.findMany` takes a request to fetch a collection of resources and should return a
348
+ * `Promise` which fulfills with data for that collection.
349
+ *
350
+ * The response will be fed to the associated serializer's `normalizeResponse` method
351
+ * with the `requestType` set to `findMany`, which should return a `JSON:API` document.
352
+ *
353
+ * The final result after normalization to `JSON:API` will be added to store via `store.push` where
354
+ * it will merge with any existing data.
355
+ *
356
+ * ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
357
+ * call will NOT be made. In this scenario you may need to do at least a minimum amount of response
358
+ * processing within the adapter.
359
+ *
360
+ * See also `groupRecordsForFindMany` and `coalesceFindRequests`
361
+ *
362
+ * @method findMany [OPTIONAL]
363
+ * @public
364
+ * @optional
365
+ * @param {Store} store The store service that initiated the request being normalized
366
+ * @param {ModelSchema} schema An object with methods for accessing information about
367
+ * the type, attributes and relationships of the primary type associated with the request.
368
+ * @param {Array<string>} ids An array of the ids of the resources to fetch
369
+ * @param {Array<Snapshot>} snapshots An array of snapshots of the available data for the resources to fetch
370
+ * @return {Promise} a promise resolving with resource data to feed to the associated serializer
371
+ */
372
+ findMany?(store: Store, schema: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload>;
373
+ /**
374
+ * This method provides the ability to generate an ID to assign to a new record whenever `store.createRecord`
375
+ * is called if no `id` was provided.
376
+ *
377
+ * Alternatively you can pass an id into the call to `store.createRecord` directly.
378
+ *
379
+ * ```js
380
+ * let id = generateNewId(type);
381
+ * let newRecord = store.createRecord(type, { id });
382
+ * ```
383
+ *
384
+ * @method generateIdForRecord [OPTIONAL]
385
+ * @public
386
+ * @optional
387
+ * @param {Store} store The store service that initiated the request being normalized
388
+ * @param {String} type The type (or modelName) of record being created
389
+ * @param properties the properties passed as the second arg to `store.createRecord`
390
+ * @return {String} a string ID that should be unique (no other models of `type` in the cache should have this `id`)
391
+ */
392
+ generateIdForRecord?(store: Store, type: string, properties: unknown): string;
393
+ /**
394
+ * If your adapter implements `findMany`, setting this to `true` will cause `findRecord`
395
+ * requests triggered within the same `runloop` to be coalesced into one or more calls
396
+ * to `adapter.findMany`. The number of calls made and the records contained in each call
397
+ * can be tuned by your adapter's `groupRecordsForHasMany` method.
398
+ *
399
+ * Implementing coalescing using this flag and the associated methods does not always offer
400
+ * the right level of correctness, timing control or granularity. If your application would
401
+ * be better suited coalescing across multiple types, coalescing for longer than a single runloop,
402
+ * or with a more custom request structure, coalescing within your application adapter may prove
403
+ * more effective.
404
+ *
405
+ * @property coalesceFindRequests [OPTIONAL]
406
+ * @public
407
+ * @optional
408
+ * @type {boolean} true if the requests to find individual records should be coalesced, false otherwise
409
+ */
410
+ coalesceFindRequests?: boolean;
411
+ /**
412
+ * ⚠️ This Method is only called if `coalesceFindRequests` is `true`.
413
+ *
414
+ * This method allows for you to split pending requests for records into multiple `findMany`
415
+ * requests. It receives an array of snapshots where each snapshot represents a unique record
416
+ * requested via `store.findRecord` during the most recent `runloop` that was not found in the
417
+ * cache or needs to be reloaded. It should return an array of groups.
418
+ *
419
+ * A group is an array of snapshots meant to be fetched together by a single `findMany` request.
420
+ *
421
+ * By default if this method is not implemented EmberData will call `findMany` once with all
422
+ * requested records as a single group when `coalesceFindRequests` is `true`.
423
+ *
424
+ * See also `findMany` and `coalesceFindRequests`
425
+ *
426
+ * @method groupRecordsForFindMany [OPTIONAL]
427
+ * @public
428
+ * @optional
429
+ * @param {Store} store The store service that initiated the request being normalized
430
+ * @param {Array<Snapshot>} snapshots An array of snapshots
431
+ * @return {Array<Array<Snapshot>>} An array of Snapshot arrays
432
+ */
433
+ groupRecordsForFindMany?(store: Store, snapshots: Snapshot[]): Group[];
434
+ /**
435
+ * When a record is already available in the store and is requested again via `store.findRecord`,
436
+ * and `reload` is not specified as an option in the request, this method is called to determine
437
+ * whether the record should be reloaded prior to returning the result.
438
+ *
439
+ * If `reload` is specified as an option in the request (`true` or `false`) this method will not
440
+ * be called.
441
+ *
442
+ * ```js
443
+ * store.findRecord('user', '1', { reload: false })
444
+ * ```
445
+ *
446
+ * The default behavior if this method is not implemented and the option is not specified is to
447
+ * not reload, the same as a return of `false`.
448
+ *
449
+ * See also the documentation for `shouldBackgroundReloadRecord` which defaults to `true`.
450
+ *
451
+ * @method shouldReloadRecord [OPTIONAL]
452
+ * @public
453
+ * @optional
454
+ * @param {Store} store The store service that initiated the request being normalized
455
+ * @param {Snapshot} snapshot A Snapshot containing the record's current data
456
+ * @return {boolean} true if the record should be reloaded immediately, false otherwise
457
+ */
458
+ shouldReloadRecord?(store: Store, snapshot: Snapshot): boolean;
459
+ /**
460
+ * When `store.findAll(<type>)` is called without a `reload` option, the adapter
461
+ * is presented the opportunity to trigger a new request for records of that type.
462
+ *
463
+ * If `reload` is specified as an option in the request (`true` or `false`) this method will not
464
+ * be called.
465
+ *
466
+ * ```js
467
+ * store.findAll('user', { reload: false })
468
+ * ```
469
+ *
470
+ * The default behavior if this method is not implemented and the option is not specified is to
471
+ * not reload, the same as a return of `false`.
472
+ *
473
+ * Note: the Promise returned by `store.findAll` resolves to the same RecordArray instance
474
+ * returned by `store.peekAll` for that type, and will include all records in the store for
475
+ * the given type, including any previously existing records not returned by the reload request.
476
+ *
477
+ * @method shouldReloadAll [OPTIONAL]
478
+ * @public
479
+ * @optional
480
+ * @param {Store} store The store service that initiated the request being normalized
481
+ * @param {SnapshotRecordArray} snapshotArray
482
+ * @return {boolean} true if the a new request for all records of the type in SnapshotRecordArray should be made immediately, false otherwise
483
+ */
484
+ shouldReloadAll?(store: Store, snapshotArray: SnapshotRecordArray): boolean;
485
+ /**
486
+ * When a record is already available in the store and is requested again via `store.findRecord`,
487
+ * and the record does not need to be reloaded prior to return, this method provides the ability
488
+ * to specify whether a refresh of the data for the reload should be scheduled to occur in the background.
489
+ *
490
+ * Users may explicitly declare a record should/should not be background reloaded by passing
491
+ * `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively.
492
+ *
493
+ * ```js
494
+ * store.findRecord('user', '1', { backgroundReload: false })
495
+ * ```
496
+ *
497
+ * If the `backgroundReload` option is not present, this method will be called to determine whether
498
+ * a backgroundReload should be performed.
499
+ *
500
+ * The default behavior if this method is not implemented and the option was not specified is to
501
+ * background reload, the same as a return of `true`.
502
+ *
503
+ * @method shouldBackgroundReloadRecord [OPTIONAL]
504
+ * @public
505
+ * @optional
506
+ * @param {Store} store The store service that initiated the request being normalized
507
+ * @param {Snapshot} snapshot A Snapshot containing the record's current data
508
+ * @return {boolean} true if the record should be reloaded in the background, false otherwise
509
+ */
510
+ shouldBackgroundReloadRecord?(store: Store, snapshot: Snapshot): boolean;
511
+ /**
512
+ * When `store.findAll(<type>)` is called and a `reload` is not initiated, the adapter
513
+ * is presented the opportunity to trigger a new non-blocking (background) request for
514
+ * records of that type
515
+ *
516
+ * Users may explicitly declare that this background request should/should not occur by passing
517
+ * `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively.
518
+ *
519
+ * ```js
520
+ * store.findAll('user', { backgroundReload: false })
521
+ * ```
522
+ *
523
+ * The default behavior if this method is not implemented and the option is not specified is to
524
+ * perform a reload, the same as a return of `true`.
525
+ *
526
+ * @method shouldBackgroundReloadAll [OPTIONAL]
527
+ * @public
528
+ * @optional
529
+ * @param {Store} store The store service that initiated the request being normalized
530
+ * @param {SnapshotRecordArray} snapshotArray
531
+ * @return {boolean} true if the a new request for all records of the type in SnapshotRecordArray should be made in the background, false otherwise
532
+ */
533
+ shouldBackgroundReloadAll?(store: Store, snapshotArray: SnapshotRecordArray): boolean;
534
+ /**
535
+ * In some situations the adapter may need to perform cleanup when destroyed,
536
+ * that cleanup can be done in `destroy`.
537
+ *
538
+ * If not implemented, the store does not inform the adapter of destruction.
539
+ *
540
+ * @method destroy [OPTIONAL]
541
+ * @public
542
+ * @optional
543
+ */
544
+ destroy?(): void;
545
+ }
546
+ export {};
547
+ //# sourceMappingURL=minimum-adapter-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minimum-adapter-interface.d.ts","sourceRoot":"","sources":["../../src/legacy-network-handler/minimum-adapter-interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,mBAAmB,MAAM,yBAAyB,CAAC;AAE/D,KAAK,KAAK,GAAG,QAAQ,EAAE,CAAC;AAMxB,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;AAEjE;;;;;;;;;;;;;;;;;EAiBE;AACF,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,OAAO,CACL,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,IAAI,EAChB,mBAAmB,EAAE,mBAAmB,GACvC,OAAO,CAAC,cAAc,CAA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