@ember-data/legacy-compat 5.3.3 → 5.3.4

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