@warp-drive/legacy 5.6.0-alpha.15 → 5.6.0-alpha.17

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