@warp-drive/legacy 5.6.0-alpha.11

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 (211) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE.md +23 -0
  3. package/README.md +54 -0
  4. package/addon-main.cjs +5 -0
  5. package/declarations/adapter/-private/build-url-mixin.d.ts +34 -0
  6. package/declarations/adapter/-private/build-url-mixin.d.ts.map +1 -0
  7. package/declarations/adapter/-private/fastboot-interface.d.ts +9 -0
  8. package/declarations/adapter/-private/fastboot-interface.d.ts.map +1 -0
  9. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +8 -0
  10. package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +1 -0
  11. package/declarations/adapter/-private/utils/determine-body-promise.d.ts +5 -0
  12. package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +1 -0
  13. package/declarations/adapter/-private/utils/fetch.d.ts +9 -0
  14. package/declarations/adapter/-private/utils/fetch.d.ts.map +1 -0
  15. package/declarations/adapter/-private/utils/parse-response-headers.d.ts +2 -0
  16. package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +1 -0
  17. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +7 -0
  18. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +1 -0
  19. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +6 -0
  20. package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +1 -0
  21. package/declarations/adapter/-private.d.ts +6 -0
  22. package/declarations/adapter/-private.d.ts.map +1 -0
  23. package/declarations/adapter/error.d.ts +188 -0
  24. package/declarations/adapter/error.d.ts.map +1 -0
  25. package/declarations/adapter/json-api.d.ts +234 -0
  26. package/declarations/adapter/json-api.d.ts.map +1 -0
  27. package/declarations/adapter/rest.d.ts +823 -0
  28. package/declarations/adapter/rest.d.ts.map +1 -0
  29. package/declarations/adapter.d.ts +801 -0
  30. package/declarations/adapter.d.ts.map +1 -0
  31. package/declarations/compat/-private.d.ts +14 -0
  32. package/declarations/compat/-private.d.ts.map +1 -0
  33. package/declarations/compat/builders/find-all.d.ts +33 -0
  34. package/declarations/compat/builders/find-all.d.ts.map +1 -0
  35. package/declarations/compat/builders/find-record.d.ts +54 -0
  36. package/declarations/compat/builders/find-record.d.ts.map +1 -0
  37. package/declarations/compat/builders/query.d.ts +61 -0
  38. package/declarations/compat/builders/query.d.ts.map +1 -0
  39. package/declarations/compat/builders/save-record.d.ts +32 -0
  40. package/declarations/compat/builders/save-record.d.ts.map +1 -0
  41. package/declarations/compat/builders/utils.d.ts +4 -0
  42. package/declarations/compat/builders/utils.d.ts.map +1 -0
  43. package/declarations/compat/builders.d.ts +15 -0
  44. package/declarations/compat/builders.d.ts.map +1 -0
  45. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +47 -0
  46. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +1 -0
  47. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +3 -0
  48. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +1 -0
  49. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +12 -0
  50. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +1 -0
  51. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +6 -0
  52. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +1 -0
  53. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +3 -0
  54. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +1 -0
  55. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +527 -0
  56. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +1 -0
  57. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +224 -0
  58. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +1 -0
  59. package/declarations/compat/legacy-network-handler/serializer-response.d.ts +7 -0
  60. package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +1 -0
  61. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +89 -0
  62. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +1 -0
  63. package/declarations/compat/legacy-network-handler/snapshot.d.ts +237 -0
  64. package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +1 -0
  65. package/declarations/compat/utils.d.ts +138 -0
  66. package/declarations/compat/utils.d.ts.map +1 -0
  67. package/declarations/compat.d.ts +134 -0
  68. package/declarations/compat.d.ts.map +1 -0
  69. package/declarations/model/-private/attr.d.ts +165 -0
  70. package/declarations/model/-private/attr.d.ts.map +1 -0
  71. package/declarations/model/-private/attr.type-test.d.ts +2 -0
  72. package/declarations/model/-private/attr.type-test.d.ts.map +1 -0
  73. package/declarations/model/-private/belongs-to.d.ts +173 -0
  74. package/declarations/model/-private/belongs-to.d.ts.map +1 -0
  75. package/declarations/model/-private/belongs-to.type-test.d.ts +2 -0
  76. package/declarations/model/-private/belongs-to.type-test.d.ts.map +1 -0
  77. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +6 -0
  78. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  79. package/declarations/model/-private/errors.d.ts +290 -0
  80. package/declarations/model/-private/errors.d.ts.map +1 -0
  81. package/declarations/model/-private/has-many.d.ts +164 -0
  82. package/declarations/model/-private/has-many.d.ts.map +1 -0
  83. package/declarations/model/-private/has-many.type-test.d.ts +2 -0
  84. package/declarations/model/-private/has-many.type-test.d.ts.map +1 -0
  85. package/declarations/model/-private/hooks.d.ts +11 -0
  86. package/declarations/model/-private/hooks.d.ts.map +1 -0
  87. package/declarations/model/-private/legacy-relationships-support.d.ts +57 -0
  88. package/declarations/model/-private/legacy-relationships-support.d.ts.map +1 -0
  89. package/declarations/model/-private/model-for-mixin.d.ts +4 -0
  90. package/declarations/model/-private/model-for-mixin.d.ts.map +1 -0
  91. package/declarations/model/-private/model-methods.d.ts +35 -0
  92. package/declarations/model/-private/model-methods.d.ts.map +1 -0
  93. package/declarations/model/-private/model.d.ts +1270 -0
  94. package/declarations/model/-private/model.d.ts.map +1 -0
  95. package/declarations/model/-private/model.type-test.d.ts +2 -0
  96. package/declarations/model/-private/model.type-test.d.ts.map +1 -0
  97. package/declarations/model/-private/notify-changes.d.ts +5 -0
  98. package/declarations/model/-private/notify-changes.d.ts.map +1 -0
  99. package/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  100. package/declarations/model/-private/promise-belongs-to.d.ts.map +1 -0
  101. package/declarations/model/-private/promise-many-array.d.ts +126 -0
  102. package/declarations/model/-private/promise-many-array.d.ts.map +1 -0
  103. package/declarations/model/-private/promise-proxy-base.d.ts +3 -0
  104. package/declarations/model/-private/promise-proxy-base.d.ts.map +1 -0
  105. package/declarations/model/-private/record-state.d.ts +78 -0
  106. package/declarations/model/-private/record-state.d.ts.map +1 -0
  107. package/declarations/model/-private/references/belongs-to.d.ts +495 -0
  108. package/declarations/model/-private/references/belongs-to.d.ts.map +1 -0
  109. package/declarations/model/-private/references/has-many.d.ts +504 -0
  110. package/declarations/model/-private/references/has-many.d.ts.map +1 -0
  111. package/declarations/model/-private/schema-provider.d.ts +63 -0
  112. package/declarations/model/-private/schema-provider.d.ts.map +1 -0
  113. package/declarations/model/-private/type-utils.d.ts +57 -0
  114. package/declarations/model/-private/type-utils.d.ts.map +1 -0
  115. package/declarations/model/-private/util.d.ts +6 -0
  116. package/declarations/model/-private/util.d.ts.map +1 -0
  117. package/declarations/model/-private.d.ts +8 -0
  118. package/declarations/model/-private.d.ts.map +1 -0
  119. package/declarations/model/migration-support.d.ts +287 -0
  120. package/declarations/model/migration-support.d.ts.map +1 -0
  121. package/declarations/model/migration-support.type-test.d.ts +2 -0
  122. package/declarations/model/migration-support.type-test.d.ts.map +1 -0
  123. package/declarations/model.d.ts +50 -0
  124. package/declarations/model.d.ts.map +1 -0
  125. package/declarations/serializer/-private/embedded-records-mixin.d.ts +97 -0
  126. package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +1 -0
  127. package/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  128. package/declarations/serializer/-private/transforms/boolean.d.ts.map +1 -0
  129. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +2 -0
  130. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +1 -0
  131. package/declarations/serializer/-private/transforms/date.d.ts +28 -0
  132. package/declarations/serializer/-private/transforms/date.d.ts.map +1 -0
  133. package/declarations/serializer/-private/transforms/number.d.ts +29 -0
  134. package/declarations/serializer/-private/transforms/number.d.ts.map +1 -0
  135. package/declarations/serializer/-private/transforms/string.d.ts +29 -0
  136. package/declarations/serializer/-private/transforms/string.d.ts.map +1 -0
  137. package/declarations/serializer/-private/transforms/transform.d.ts +119 -0
  138. package/declarations/serializer/-private/transforms/transform.d.ts.map +1 -0
  139. package/declarations/serializer/-private/utils.d.ts +4 -0
  140. package/declarations/serializer/-private/utils.d.ts.map +1 -0
  141. package/declarations/serializer/json-api.d.ts +496 -0
  142. package/declarations/serializer/json-api.d.ts.map +1 -0
  143. package/declarations/serializer/json.d.ts +1047 -0
  144. package/declarations/serializer/json.d.ts.map +1 -0
  145. package/declarations/serializer/rest.d.ts +554 -0
  146. package/declarations/serializer/rest.d.ts.map +1 -0
  147. package/declarations/serializer/transform.d.ts +6 -0
  148. package/declarations/serializer/transform.d.ts.map +1 -0
  149. package/declarations/serializer.d.ts +258 -0
  150. package/declarations/serializer.d.ts.map +1 -0
  151. package/dist/-private-DFfBszo5.js +1182 -0
  152. package/dist/-private-DFfBszo5.js.map +1 -0
  153. package/dist/adapter/-private.js +1 -0
  154. package/dist/adapter/-private.js.map +1 -0
  155. package/dist/adapter/error.js +254 -0
  156. package/dist/adapter/error.js.map +1 -0
  157. package/dist/adapter/json-api.js +129 -0
  158. package/dist/adapter/json-api.js.map +1 -0
  159. package/dist/adapter/rest.js +1262 -0
  160. package/dist/adapter/rest.js.map +1 -0
  161. package/dist/adapter.js +1284 -0
  162. package/dist/adapter.js.map +1 -0
  163. package/dist/compat/-private.js +1 -0
  164. package/dist/compat/-private.js.map +1 -0
  165. package/dist/compat/builders.js +292 -0
  166. package/dist/compat/builders.js.map +1 -0
  167. package/dist/compat/utils.js +225 -0
  168. package/dist/compat/utils.js.map +1 -0
  169. package/dist/compat.js +999 -0
  170. package/dist/compat.js.map +1 -0
  171. package/dist/errors-D74uk36r.js +2541 -0
  172. package/dist/errors-D74uk36r.js.map +1 -0
  173. package/dist/json-BCH3fil7.js +1349 -0
  174. package/dist/json-BCH3fil7.js.map +1 -0
  175. package/dist/model/-private.js +2 -0
  176. package/dist/model/-private.js.map +1 -0
  177. package/dist/model/migration-support.js +453 -0
  178. package/dist/model/migration-support.js.map +1 -0
  179. package/dist/model.js +736 -0
  180. package/dist/model.js.map +1 -0
  181. package/dist/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  182. package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +1 -0
  183. package/dist/schema-provider-CXFLTMjg.js +2228 -0
  184. package/dist/schema-provider-CXFLTMjg.js.map +1 -0
  185. package/dist/serialize-into-hash-BxfqWC8u.js +260 -0
  186. package/dist/serialize-into-hash-BxfqWC8u.js.map +1 -0
  187. package/dist/serializer/json-api.js +514 -0
  188. package/dist/serializer/json-api.js.map +1 -0
  189. package/dist/serializer/json.js +6 -0
  190. package/dist/serializer/json.js.map +1 -0
  191. package/dist/serializer/rest.js +1245 -0
  192. package/dist/serializer/rest.js.map +1 -0
  193. package/dist/serializer/transform.js +313 -0
  194. package/dist/serializer/transform.js.map +1 -0
  195. package/dist/serializer.js +252 -0
  196. package/dist/serializer.js.map +1 -0
  197. package/logos/NCC-1701-a-blue.svg +4 -0
  198. package/logos/NCC-1701-a-gold.svg +4 -0
  199. package/logos/NCC-1701-a-gold_100.svg +1 -0
  200. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  201. package/logos/NCC-1701-a.svg +4 -0
  202. package/logos/README.md +4 -0
  203. package/logos/docs-badge.svg +2 -0
  204. package/logos/ember-data-logo-dark.svg +12 -0
  205. package/logos/ember-data-logo-light.svg +12 -0
  206. package/logos/github-header.svg +444 -0
  207. package/logos/social1.png +0 -0
  208. package/logos/social2.png +0 -0
  209. package/logos/warp-drive-logo-dark.svg +4 -0
  210. package/logos/warp-drive-logo-gold.svg +4 -0
  211. package/package.json +72 -0
@@ -0,0 +1,527 @@
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';
7
+ type Group = Snapshot[];
8
+ export type AdapterPayload = Record<string, unknown> | unknown[];
9
+ /**
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>
17
+
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.
21
+
22
+ Methods that are not required are marked as **optional**.
23
+
24
+ @class (Interface) Adapter
25
+ @public
26
+ */
27
+ 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;
525
+ }
526
+ export {};
527
+ //# sourceMappingURL=minimum-adapter-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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