@warp-drive/legacy 5.8.0-alpha.30 → 5.8.0-alpha.34

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 (477) hide show
  1. package/declarations/adapter/error.d.ts +5 -5
  2. package/declarations/adapter/json-api.d.ts +2 -2
  3. package/declarations/compat/builders/find-all.d.ts +6 -6
  4. package/declarations/compat/builders/find-record.d.ts +8 -8
  5. package/declarations/compat/builders/query.d.ts +12 -12
  6. package/declarations/compat.d.ts +3 -3
  7. package/declarations/model/-private/references/belongs-to.d.ts +4 -4
  8. package/declarations/model/-private/references/has-many.d.ts +2 -2
  9. package/declarations/model/migration-support.d.ts +34 -18
  10. package/declarations/model.d.ts +2 -2
  11. package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -1
  12. package/declarations/serializer/json-api.d.ts +3 -3
  13. package/declarations/serializer/json.d.ts +1 -1
  14. package/declarations/serializer.d.ts +1 -1
  15. package/dist/adapter/error.js +7 -7
  16. package/dist/compat/builders.js +26 -26
  17. package/dist/compat/utils.js +0 -1
  18. package/dist/compat.js +3 -3
  19. package/dist/{errors-B9CDPh3R.js → errors-CIGPcDvd.js} +12 -12
  20. package/dist/{hooks-CQXyievu.js → hooks-QqRnX108.js} +1 -1
  21. package/dist/index.js +4 -4
  22. package/dist/{json-BHxlccxF.js → json-BNrV8EYG.js} +4 -4
  23. package/dist/model/-private.js +1 -1
  24. package/dist/model/migration-support.js +41 -24
  25. package/dist/{model-for-B0TSd9HU.js → model-for-CqXsIKws.js} +1 -1
  26. package/dist/model-fragments.js +2 -2
  27. package/dist/model.js +3 -3
  28. package/dist/{schema-provider-BnVr_CnJ.js → schema-provider-g5MfTj8n.js} +11 -11
  29. package/dist/serializer/json-api.js +7 -7
  30. package/dist/serializer/json.js +1 -1
  31. package/dist/serializer/rest.js +10 -10
  32. package/dist/serializer.js +1 -1
  33. package/dist/unpkg/dev/-private-B1pSSN52.js +1210 -0
  34. package/dist/unpkg/dev/adapter/-private.js +1 -0
  35. package/dist/unpkg/dev/adapter/error.js +336 -0
  36. package/dist/unpkg/dev/adapter/json-api.js +132 -0
  37. package/dist/unpkg/dev/adapter/rest.js +1257 -0
  38. package/dist/unpkg/dev/adapter.js +1253 -0
  39. package/dist/unpkg/dev/compat/-private.js +1 -0
  40. package/dist/unpkg/dev/compat/builders.js +273 -0
  41. package/dist/unpkg/dev/compat/extensions.js +243 -0
  42. package/dist/unpkg/dev/compat/utils.js +224 -0
  43. package/dist/unpkg/dev/compat.js +1020 -0
  44. package/dist/unpkg/dev/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  45. package/dist/unpkg/dev/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  46. package/dist/unpkg/dev/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  47. package/dist/unpkg/dev/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  48. package/dist/unpkg/dev/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  49. package/dist/unpkg/dev/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  50. package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  51. package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  52. package/dist/unpkg/dev/declarations/adapter/-private.d.ts +5 -0
  53. package/dist/unpkg/dev/declarations/adapter/error.d.ts +215 -0
  54. package/dist/unpkg/dev/declarations/adapter/json-api.d.ts +231 -0
  55. package/dist/unpkg/dev/declarations/adapter/rest.d.ts +815 -0
  56. package/dist/unpkg/dev/declarations/adapter.d.ts +770 -0
  57. package/dist/unpkg/dev/declarations/compat/-private.d.ts +13 -0
  58. package/dist/unpkg/dev/declarations/compat/builders/find-all.d.ts +35 -0
  59. package/dist/unpkg/dev/declarations/compat/builders/find-record.d.ts +56 -0
  60. package/dist/unpkg/dev/declarations/compat/builders/query.d.ts +66 -0
  61. package/dist/unpkg/dev/declarations/compat/builders/save-record.d.ts +34 -0
  62. package/dist/unpkg/dev/declarations/compat/builders/utils.d.ts +3 -0
  63. package/dist/unpkg/dev/declarations/compat/builders.d.ts +14 -0
  64. package/dist/unpkg/dev/declarations/compat/extensions.d.ts +59 -0
  65. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  66. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  67. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  68. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  69. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  70. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  71. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  72. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  73. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  74. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  75. package/dist/unpkg/dev/declarations/compat/utils.d.ts +137 -0
  76. package/dist/unpkg/dev/declarations/compat.d.ts +157 -0
  77. package/dist/unpkg/dev/declarations/index.d.ts +70 -0
  78. package/dist/unpkg/dev/declarations/model/-private/attr.d.ts +170 -0
  79. package/dist/unpkg/dev/declarations/model/-private/belongs-to.d.ts +174 -0
  80. package/dist/unpkg/dev/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  81. package/dist/unpkg/dev/declarations/model/-private/errors.d.ts +289 -0
  82. package/dist/unpkg/dev/declarations/model/-private/has-many.d.ts +162 -0
  83. package/dist/unpkg/dev/declarations/model/-private/hooks.d.ts +10 -0
  84. package/dist/unpkg/dev/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  85. package/dist/unpkg/dev/declarations/model/-private/model-for-mixin.d.ts +3 -0
  86. package/dist/unpkg/dev/declarations/model/-private/model-methods.d.ts +39 -0
  87. package/dist/unpkg/dev/declarations/model/-private/model.d.ts +1269 -0
  88. package/dist/unpkg/dev/declarations/model/-private/notify-changes.d.ts +4 -0
  89. package/dist/unpkg/dev/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  90. package/dist/unpkg/dev/declarations/model/-private/promise-many-array.d.ts +124 -0
  91. package/dist/unpkg/dev/declarations/model/-private/record-state.d.ts +58 -0
  92. package/dist/unpkg/dev/declarations/model/-private/references/belongs-to.d.ts +498 -0
  93. package/dist/unpkg/dev/declarations/model/-private/references/has-many.d.ts +500 -0
  94. package/dist/unpkg/dev/declarations/model/-private/schema-provider.d.ts +56 -0
  95. package/dist/unpkg/dev/declarations/model/-private/type-utils.d.ts +57 -0
  96. package/dist/unpkg/dev/declarations/model/-private/util.d.ts +5 -0
  97. package/dist/unpkg/dev/declarations/model/-private.d.ts +8 -0
  98. package/dist/unpkg/dev/declarations/model/migration-support.d.ts +280 -0
  99. package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  100. package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  101. package/dist/unpkg/dev/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  102. package/dist/unpkg/dev/declarations/model-fragments/index.d.ts +5 -0
  103. package/dist/unpkg/dev/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  104. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  105. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  106. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  107. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  108. package/dist/unpkg/dev/declarations/model-fragments.d.ts +9 -0
  109. package/dist/unpkg/dev/declarations/model.d.ts +49 -0
  110. package/dist/unpkg/dev/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  111. package/dist/unpkg/dev/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  112. package/dist/unpkg/dev/declarations/serializer/-private/transforms/date.d.ts +28 -0
  113. package/dist/unpkg/dev/declarations/serializer/-private/transforms/number.d.ts +29 -0
  114. package/dist/unpkg/dev/declarations/serializer/-private/transforms/string.d.ts +29 -0
  115. package/dist/unpkg/dev/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  116. package/dist/unpkg/dev/declarations/serializer/-private/utils.d.ts +3 -0
  117. package/dist/unpkg/dev/declarations/serializer/json-api.d.ts +123 -0
  118. package/dist/unpkg/dev/declarations/serializer/json.d.ts +75 -0
  119. package/dist/unpkg/dev/declarations/serializer/rest.d.ts +51 -0
  120. package/dist/unpkg/dev/declarations/serializer/transform.d.ts +5 -0
  121. package/dist/unpkg/dev/declarations/serializer.d.ts +254 -0
  122. package/dist/unpkg/dev/declarations/store/-private.d.ts +223 -0
  123. package/dist/unpkg/dev/declarations/store.d.ts +3 -0
  124. package/dist/unpkg/dev/errors-CIGPcDvd.js +2595 -0
  125. package/dist/unpkg/dev/hooks-QqRnX108.js +74 -0
  126. package/dist/unpkg/dev/index.js +195 -0
  127. package/dist/unpkg/dev/json-BNrV8EYG.js +1272 -0
  128. package/dist/unpkg/dev/model/-private.js +1 -0
  129. package/dist/unpkg/dev/model/migration-support.js +579 -0
  130. package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
  131. package/dist/unpkg/dev/model-fragments.js +76 -0
  132. package/dist/unpkg/dev/model.js +667 -0
  133. package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  134. package/dist/unpkg/dev/schema-provider-g5MfTj8n.js +2338 -0
  135. package/dist/unpkg/dev/serialize-into-hash-BnYvPex3.js +261 -0
  136. package/dist/unpkg/dev/serializer/json-api.js +527 -0
  137. package/dist/unpkg/dev/serializer/json.js +6 -0
  138. package/dist/unpkg/dev/serializer/rest.js +1243 -0
  139. package/dist/unpkg/dev/serializer/transform.js +278 -0
  140. package/dist/unpkg/dev/serializer.js +248 -0
  141. package/dist/unpkg/dev/store.js +636 -0
  142. package/dist/unpkg/dev/util-Dul6TZts.js +35 -0
  143. package/dist/unpkg/dev/utils-Cqw9eRj5.js +23 -0
  144. package/dist/unpkg/dev-deprecated/-private-B1pSSN52.js +1210 -0
  145. package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
  146. package/dist/unpkg/dev-deprecated/adapter/error.js +336 -0
  147. package/dist/unpkg/dev-deprecated/adapter/json-api.js +132 -0
  148. package/dist/unpkg/dev-deprecated/adapter/rest.js +1257 -0
  149. package/dist/unpkg/dev-deprecated/adapter.js +1253 -0
  150. package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
  151. package/dist/unpkg/dev-deprecated/compat/builders.js +273 -0
  152. package/dist/unpkg/dev-deprecated/compat/extensions.js +243 -0
  153. package/dist/unpkg/dev-deprecated/compat/utils.js +224 -0
  154. package/dist/unpkg/dev-deprecated/compat.js +1020 -0
  155. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  156. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  157. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  158. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  159. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  160. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  161. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  162. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  163. package/dist/unpkg/dev-deprecated/declarations/adapter/-private.d.ts +5 -0
  164. package/dist/unpkg/dev-deprecated/declarations/adapter/error.d.ts +215 -0
  165. package/dist/unpkg/dev-deprecated/declarations/adapter/json-api.d.ts +231 -0
  166. package/dist/unpkg/dev-deprecated/declarations/adapter/rest.d.ts +815 -0
  167. package/dist/unpkg/dev-deprecated/declarations/adapter.d.ts +770 -0
  168. package/dist/unpkg/dev-deprecated/declarations/compat/-private.d.ts +13 -0
  169. package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-all.d.ts +35 -0
  170. package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-record.d.ts +56 -0
  171. package/dist/unpkg/dev-deprecated/declarations/compat/builders/query.d.ts +66 -0
  172. package/dist/unpkg/dev-deprecated/declarations/compat/builders/save-record.d.ts +34 -0
  173. package/dist/unpkg/dev-deprecated/declarations/compat/builders/utils.d.ts +3 -0
  174. package/dist/unpkg/dev-deprecated/declarations/compat/builders.d.ts +14 -0
  175. package/dist/unpkg/dev-deprecated/declarations/compat/extensions.d.ts +59 -0
  176. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  177. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  178. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  179. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  180. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  181. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  182. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  183. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  184. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  185. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  186. package/dist/unpkg/dev-deprecated/declarations/compat/utils.d.ts +137 -0
  187. package/dist/unpkg/dev-deprecated/declarations/compat.d.ts +157 -0
  188. package/dist/unpkg/dev-deprecated/declarations/index.d.ts +70 -0
  189. package/dist/unpkg/dev-deprecated/declarations/model/-private/attr.d.ts +170 -0
  190. package/dist/unpkg/dev-deprecated/declarations/model/-private/belongs-to.d.ts +174 -0
  191. package/dist/unpkg/dev-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  192. package/dist/unpkg/dev-deprecated/declarations/model/-private/errors.d.ts +289 -0
  193. package/dist/unpkg/dev-deprecated/declarations/model/-private/has-many.d.ts +162 -0
  194. package/dist/unpkg/dev-deprecated/declarations/model/-private/hooks.d.ts +10 -0
  195. package/dist/unpkg/dev-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  196. package/dist/unpkg/dev-deprecated/declarations/model/-private/model-for-mixin.d.ts +3 -0
  197. package/dist/unpkg/dev-deprecated/declarations/model/-private/model-methods.d.ts +39 -0
  198. package/dist/unpkg/dev-deprecated/declarations/model/-private/model.d.ts +1269 -0
  199. package/dist/unpkg/dev-deprecated/declarations/model/-private/notify-changes.d.ts +4 -0
  200. package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  201. package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-many-array.d.ts +124 -0
  202. package/dist/unpkg/dev-deprecated/declarations/model/-private/record-state.d.ts +58 -0
  203. package/dist/unpkg/dev-deprecated/declarations/model/-private/references/belongs-to.d.ts +498 -0
  204. package/dist/unpkg/dev-deprecated/declarations/model/-private/references/has-many.d.ts +500 -0
  205. package/dist/unpkg/dev-deprecated/declarations/model/-private/schema-provider.d.ts +56 -0
  206. package/dist/unpkg/dev-deprecated/declarations/model/-private/type-utils.d.ts +57 -0
  207. package/dist/unpkg/dev-deprecated/declarations/model/-private/util.d.ts +5 -0
  208. package/dist/unpkg/dev-deprecated/declarations/model/-private.d.ts +8 -0
  209. package/dist/unpkg/dev-deprecated/declarations/model/migration-support.d.ts +280 -0
  210. package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  211. package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  212. package/dist/unpkg/dev-deprecated/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  213. package/dist/unpkg/dev-deprecated/declarations/model-fragments/index.d.ts +5 -0
  214. package/dist/unpkg/dev-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  215. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  216. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  217. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  218. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  219. package/dist/unpkg/dev-deprecated/declarations/model-fragments.d.ts +9 -0
  220. package/dist/unpkg/dev-deprecated/declarations/model.d.ts +49 -0
  221. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  222. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  223. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/date.d.ts +28 -0
  224. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/number.d.ts +29 -0
  225. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/string.d.ts +29 -0
  226. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  227. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/utils.d.ts +3 -0
  228. package/dist/unpkg/dev-deprecated/declarations/serializer/json-api.d.ts +123 -0
  229. package/dist/unpkg/dev-deprecated/declarations/serializer/json.d.ts +75 -0
  230. package/dist/unpkg/dev-deprecated/declarations/serializer/rest.d.ts +51 -0
  231. package/dist/unpkg/dev-deprecated/declarations/serializer/transform.d.ts +5 -0
  232. package/dist/unpkg/dev-deprecated/declarations/serializer.d.ts +254 -0
  233. package/dist/unpkg/dev-deprecated/declarations/store/-private.d.ts +223 -0
  234. package/dist/unpkg/dev-deprecated/declarations/store.d.ts +3 -0
  235. package/dist/unpkg/dev-deprecated/errors-CIGPcDvd.js +2595 -0
  236. package/dist/unpkg/dev-deprecated/hooks-QqRnX108.js +74 -0
  237. package/dist/unpkg/dev-deprecated/index.js +195 -0
  238. package/dist/unpkg/dev-deprecated/json-BNrV8EYG.js +1272 -0
  239. package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
  240. package/dist/unpkg/dev-deprecated/model/migration-support.js +579 -0
  241. package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
  242. package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
  243. package/dist/unpkg/dev-deprecated/model.js +667 -0
  244. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  245. package/dist/unpkg/dev-deprecated/schema-provider-g5MfTj8n.js +2338 -0
  246. package/dist/unpkg/dev-deprecated/serialize-into-hash-BnYvPex3.js +261 -0
  247. package/dist/unpkg/dev-deprecated/serializer/json-api.js +527 -0
  248. package/dist/unpkg/dev-deprecated/serializer/json.js +6 -0
  249. package/dist/unpkg/dev-deprecated/serializer/rest.js +1243 -0
  250. package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
  251. package/dist/unpkg/dev-deprecated/serializer.js +248 -0
  252. package/dist/unpkg/dev-deprecated/store.js +636 -0
  253. package/dist/unpkg/dev-deprecated/util-Dul6TZts.js +35 -0
  254. package/dist/unpkg/dev-deprecated/utils-Cqw9eRj5.js +23 -0
  255. package/dist/unpkg/prod/-private-B1pSSN52.js +1210 -0
  256. package/dist/unpkg/prod/adapter/-private.js +1 -0
  257. package/dist/unpkg/prod/adapter/error.js +336 -0
  258. package/dist/unpkg/prod/adapter/json-api.js +132 -0
  259. package/dist/unpkg/prod/adapter/rest.js +1257 -0
  260. package/dist/unpkg/prod/adapter.js +1253 -0
  261. package/dist/unpkg/prod/compat/-private.js +1 -0
  262. package/dist/unpkg/prod/compat/builders.js +273 -0
  263. package/dist/unpkg/prod/compat/extensions.js +243 -0
  264. package/dist/unpkg/prod/compat/utils.js +224 -0
  265. package/dist/unpkg/prod/compat.js +1020 -0
  266. package/dist/unpkg/prod/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  267. package/dist/unpkg/prod/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  268. package/dist/unpkg/prod/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  269. package/dist/unpkg/prod/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  270. package/dist/unpkg/prod/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  271. package/dist/unpkg/prod/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  272. package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  273. package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  274. package/dist/unpkg/prod/declarations/adapter/-private.d.ts +5 -0
  275. package/dist/unpkg/prod/declarations/adapter/error.d.ts +215 -0
  276. package/dist/unpkg/prod/declarations/adapter/json-api.d.ts +231 -0
  277. package/dist/unpkg/prod/declarations/adapter/rest.d.ts +815 -0
  278. package/dist/unpkg/prod/declarations/adapter.d.ts +770 -0
  279. package/dist/unpkg/prod/declarations/compat/-private.d.ts +13 -0
  280. package/dist/unpkg/prod/declarations/compat/builders/find-all.d.ts +35 -0
  281. package/dist/unpkg/prod/declarations/compat/builders/find-record.d.ts +56 -0
  282. package/dist/unpkg/prod/declarations/compat/builders/query.d.ts +66 -0
  283. package/dist/unpkg/prod/declarations/compat/builders/save-record.d.ts +34 -0
  284. package/dist/unpkg/prod/declarations/compat/builders/utils.d.ts +3 -0
  285. package/dist/unpkg/prod/declarations/compat/builders.d.ts +14 -0
  286. package/dist/unpkg/prod/declarations/compat/extensions.d.ts +59 -0
  287. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  288. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  289. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  290. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  291. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  292. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  293. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  294. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  295. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  296. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  297. package/dist/unpkg/prod/declarations/compat/utils.d.ts +137 -0
  298. package/dist/unpkg/prod/declarations/compat.d.ts +157 -0
  299. package/dist/unpkg/prod/declarations/index.d.ts +70 -0
  300. package/dist/unpkg/prod/declarations/model/-private/attr.d.ts +170 -0
  301. package/dist/unpkg/prod/declarations/model/-private/belongs-to.d.ts +174 -0
  302. package/dist/unpkg/prod/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  303. package/dist/unpkg/prod/declarations/model/-private/errors.d.ts +289 -0
  304. package/dist/unpkg/prod/declarations/model/-private/has-many.d.ts +162 -0
  305. package/dist/unpkg/prod/declarations/model/-private/hooks.d.ts +10 -0
  306. package/dist/unpkg/prod/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  307. package/dist/unpkg/prod/declarations/model/-private/model-for-mixin.d.ts +3 -0
  308. package/dist/unpkg/prod/declarations/model/-private/model-methods.d.ts +39 -0
  309. package/dist/unpkg/prod/declarations/model/-private/model.d.ts +1269 -0
  310. package/dist/unpkg/prod/declarations/model/-private/notify-changes.d.ts +4 -0
  311. package/dist/unpkg/prod/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  312. package/dist/unpkg/prod/declarations/model/-private/promise-many-array.d.ts +124 -0
  313. package/dist/unpkg/prod/declarations/model/-private/record-state.d.ts +58 -0
  314. package/dist/unpkg/prod/declarations/model/-private/references/belongs-to.d.ts +498 -0
  315. package/dist/unpkg/prod/declarations/model/-private/references/has-many.d.ts +500 -0
  316. package/dist/unpkg/prod/declarations/model/-private/schema-provider.d.ts +56 -0
  317. package/dist/unpkg/prod/declarations/model/-private/type-utils.d.ts +57 -0
  318. package/dist/unpkg/prod/declarations/model/-private/util.d.ts +5 -0
  319. package/dist/unpkg/prod/declarations/model/-private.d.ts +8 -0
  320. package/dist/unpkg/prod/declarations/model/migration-support.d.ts +280 -0
  321. package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  322. package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  323. package/dist/unpkg/prod/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  324. package/dist/unpkg/prod/declarations/model-fragments/index.d.ts +5 -0
  325. package/dist/unpkg/prod/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  326. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  327. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  328. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  329. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  330. package/dist/unpkg/prod/declarations/model-fragments.d.ts +9 -0
  331. package/dist/unpkg/prod/declarations/model.d.ts +49 -0
  332. package/dist/unpkg/prod/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  333. package/dist/unpkg/prod/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  334. package/dist/unpkg/prod/declarations/serializer/-private/transforms/date.d.ts +28 -0
  335. package/dist/unpkg/prod/declarations/serializer/-private/transforms/number.d.ts +29 -0
  336. package/dist/unpkg/prod/declarations/serializer/-private/transforms/string.d.ts +29 -0
  337. package/dist/unpkg/prod/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  338. package/dist/unpkg/prod/declarations/serializer/-private/utils.d.ts +3 -0
  339. package/dist/unpkg/prod/declarations/serializer/json-api.d.ts +123 -0
  340. package/dist/unpkg/prod/declarations/serializer/json.d.ts +75 -0
  341. package/dist/unpkg/prod/declarations/serializer/rest.d.ts +51 -0
  342. package/dist/unpkg/prod/declarations/serializer/transform.d.ts +5 -0
  343. package/dist/unpkg/prod/declarations/serializer.d.ts +254 -0
  344. package/dist/unpkg/prod/declarations/store/-private.d.ts +223 -0
  345. package/dist/unpkg/prod/declarations/store.d.ts +3 -0
  346. package/dist/unpkg/prod/errors-CIGPcDvd.js +2595 -0
  347. package/dist/unpkg/prod/hooks-QqRnX108.js +74 -0
  348. package/dist/unpkg/prod/index.js +195 -0
  349. package/dist/unpkg/prod/json-BNrV8EYG.js +1272 -0
  350. package/dist/unpkg/prod/model/-private.js +1 -0
  351. package/dist/unpkg/prod/model/migration-support.js +579 -0
  352. package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
  353. package/dist/unpkg/prod/model-fragments.js +76 -0
  354. package/dist/unpkg/prod/model.js +667 -0
  355. package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  356. package/dist/unpkg/prod/schema-provider-g5MfTj8n.js +2338 -0
  357. package/dist/unpkg/prod/serialize-into-hash-BnYvPex3.js +261 -0
  358. package/dist/unpkg/prod/serializer/json-api.js +527 -0
  359. package/dist/unpkg/prod/serializer/json.js +6 -0
  360. package/dist/unpkg/prod/serializer/rest.js +1243 -0
  361. package/dist/unpkg/prod/serializer/transform.js +278 -0
  362. package/dist/unpkg/prod/serializer.js +248 -0
  363. package/dist/unpkg/prod/store.js +636 -0
  364. package/dist/unpkg/prod/util-Dul6TZts.js +35 -0
  365. package/dist/unpkg/prod/utils-Cqw9eRj5.js +23 -0
  366. package/dist/unpkg/prod-deprecated/-private-B1pSSN52.js +1210 -0
  367. package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
  368. package/dist/unpkg/prod-deprecated/adapter/error.js +336 -0
  369. package/dist/unpkg/prod-deprecated/adapter/json-api.js +132 -0
  370. package/dist/unpkg/prod-deprecated/adapter/rest.js +1257 -0
  371. package/dist/unpkg/prod-deprecated/adapter.js +1253 -0
  372. package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
  373. package/dist/unpkg/prod-deprecated/compat/builders.js +273 -0
  374. package/dist/unpkg/prod-deprecated/compat/extensions.js +243 -0
  375. package/dist/unpkg/prod-deprecated/compat/utils.js +224 -0
  376. package/dist/unpkg/prod-deprecated/compat.js +1020 -0
  377. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  378. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  379. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  380. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  381. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  382. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  383. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  384. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  385. package/dist/unpkg/prod-deprecated/declarations/adapter/-private.d.ts +5 -0
  386. package/dist/unpkg/prod-deprecated/declarations/adapter/error.d.ts +215 -0
  387. package/dist/unpkg/prod-deprecated/declarations/adapter/json-api.d.ts +231 -0
  388. package/dist/unpkg/prod-deprecated/declarations/adapter/rest.d.ts +815 -0
  389. package/dist/unpkg/prod-deprecated/declarations/adapter.d.ts +770 -0
  390. package/dist/unpkg/prod-deprecated/declarations/compat/-private.d.ts +13 -0
  391. package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-all.d.ts +35 -0
  392. package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-record.d.ts +56 -0
  393. package/dist/unpkg/prod-deprecated/declarations/compat/builders/query.d.ts +66 -0
  394. package/dist/unpkg/prod-deprecated/declarations/compat/builders/save-record.d.ts +34 -0
  395. package/dist/unpkg/prod-deprecated/declarations/compat/builders/utils.d.ts +3 -0
  396. package/dist/unpkg/prod-deprecated/declarations/compat/builders.d.ts +14 -0
  397. package/dist/unpkg/prod-deprecated/declarations/compat/extensions.d.ts +59 -0
  398. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  399. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  400. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  401. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  402. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  403. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  404. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  405. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  406. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  407. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  408. package/dist/unpkg/prod-deprecated/declarations/compat/utils.d.ts +137 -0
  409. package/dist/unpkg/prod-deprecated/declarations/compat.d.ts +157 -0
  410. package/dist/unpkg/prod-deprecated/declarations/index.d.ts +70 -0
  411. package/dist/unpkg/prod-deprecated/declarations/model/-private/attr.d.ts +170 -0
  412. package/dist/unpkg/prod-deprecated/declarations/model/-private/belongs-to.d.ts +174 -0
  413. package/dist/unpkg/prod-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  414. package/dist/unpkg/prod-deprecated/declarations/model/-private/errors.d.ts +289 -0
  415. package/dist/unpkg/prod-deprecated/declarations/model/-private/has-many.d.ts +162 -0
  416. package/dist/unpkg/prod-deprecated/declarations/model/-private/hooks.d.ts +10 -0
  417. package/dist/unpkg/prod-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  418. package/dist/unpkg/prod-deprecated/declarations/model/-private/model-for-mixin.d.ts +3 -0
  419. package/dist/unpkg/prod-deprecated/declarations/model/-private/model-methods.d.ts +39 -0
  420. package/dist/unpkg/prod-deprecated/declarations/model/-private/model.d.ts +1269 -0
  421. package/dist/unpkg/prod-deprecated/declarations/model/-private/notify-changes.d.ts +4 -0
  422. package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  423. package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-many-array.d.ts +124 -0
  424. package/dist/unpkg/prod-deprecated/declarations/model/-private/record-state.d.ts +58 -0
  425. package/dist/unpkg/prod-deprecated/declarations/model/-private/references/belongs-to.d.ts +498 -0
  426. package/dist/unpkg/prod-deprecated/declarations/model/-private/references/has-many.d.ts +500 -0
  427. package/dist/unpkg/prod-deprecated/declarations/model/-private/schema-provider.d.ts +56 -0
  428. package/dist/unpkg/prod-deprecated/declarations/model/-private/type-utils.d.ts +57 -0
  429. package/dist/unpkg/prod-deprecated/declarations/model/-private/util.d.ts +5 -0
  430. package/dist/unpkg/prod-deprecated/declarations/model/-private.d.ts +8 -0
  431. package/dist/unpkg/prod-deprecated/declarations/model/migration-support.d.ts +280 -0
  432. package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  433. package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  434. package/dist/unpkg/prod-deprecated/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  435. package/dist/unpkg/prod-deprecated/declarations/model-fragments/index.d.ts +5 -0
  436. package/dist/unpkg/prod-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  437. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  438. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  439. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  440. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  441. package/dist/unpkg/prod-deprecated/declarations/model-fragments.d.ts +9 -0
  442. package/dist/unpkg/prod-deprecated/declarations/model.d.ts +49 -0
  443. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  444. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  445. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/date.d.ts +28 -0
  446. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/number.d.ts +29 -0
  447. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/string.d.ts +29 -0
  448. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  449. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/utils.d.ts +3 -0
  450. package/dist/unpkg/prod-deprecated/declarations/serializer/json-api.d.ts +123 -0
  451. package/dist/unpkg/prod-deprecated/declarations/serializer/json.d.ts +75 -0
  452. package/dist/unpkg/prod-deprecated/declarations/serializer/rest.d.ts +51 -0
  453. package/dist/unpkg/prod-deprecated/declarations/serializer/transform.d.ts +5 -0
  454. package/dist/unpkg/prod-deprecated/declarations/serializer.d.ts +254 -0
  455. package/dist/unpkg/prod-deprecated/declarations/store/-private.d.ts +223 -0
  456. package/dist/unpkg/prod-deprecated/declarations/store.d.ts +3 -0
  457. package/dist/unpkg/prod-deprecated/errors-CIGPcDvd.js +2595 -0
  458. package/dist/unpkg/prod-deprecated/hooks-QqRnX108.js +74 -0
  459. package/dist/unpkg/prod-deprecated/index.js +195 -0
  460. package/dist/unpkg/prod-deprecated/json-BNrV8EYG.js +1272 -0
  461. package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
  462. package/dist/unpkg/prod-deprecated/model/migration-support.js +579 -0
  463. package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
  464. package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
  465. package/dist/unpkg/prod-deprecated/model.js +667 -0
  466. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  467. package/dist/unpkg/prod-deprecated/schema-provider-g5MfTj8n.js +2338 -0
  468. package/dist/unpkg/prod-deprecated/serialize-into-hash-BnYvPex3.js +261 -0
  469. package/dist/unpkg/prod-deprecated/serializer/json-api.js +527 -0
  470. package/dist/unpkg/prod-deprecated/serializer/json.js +6 -0
  471. package/dist/unpkg/prod-deprecated/serializer/rest.js +1243 -0
  472. package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
  473. package/dist/unpkg/prod-deprecated/serializer.js +248 -0
  474. package/dist/unpkg/prod-deprecated/store.js +636 -0
  475. package/dist/unpkg/prod-deprecated/util-Dul6TZts.js +35 -0
  476. package/dist/unpkg/prod-deprecated/utils-Cqw9eRj5.js +23 -0
  477. package/package.json +30 -6
@@ -0,0 +1,1253 @@
1
+ import EmberObject from '@ember/object';
2
+ import * as s from '@ember/service';
3
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
+ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtime-BPCpkOf1-BKOwiRJp.js";
5
+ import Mixin from '@ember/object/mixin';
6
+ import { camelize, pluralize } from '@warp-drive/utilities/string';
7
+
8
+ /*
9
+ The structure of this file is such because typing Mixins is hard. Here we've structured it in
10
+ such a way as to maximize the type information that a consumer can utilize. There are simpler
11
+ ways to type a mixin but we would not be able to provide the nice overload signature for buildURL
12
+ */
13
+ // the interface must fully declare the function signatures that the individual functions
14
+ // will also declare. If instead we try to keep them in sync by doing something like
15
+ // `interface BuildURLMixin { buildURL: typeof buildURL }`
16
+ // then an extending class overwriting one of the methods will break because typescript
17
+ // thinks it is a switch from an instance prop (that is a method) to an instance method.
18
+
19
+ // prevents the final constructed object from needing to add
20
+ // host and namespace which are provided by the final consuming
21
+ // class to the prototype which can result in overwrite errors
22
+
23
+ /**
24
+ ## Using BuildURLMixin
25
+
26
+ To use URL building, include the mixin when extending an adapter, and call `buildURL` where needed.
27
+ The default behaviour is designed for RESTAdapter.
28
+
29
+ ### Example
30
+
31
+ ```javascript
32
+ import Adapter, { BuildURLMixin } from '@ember-data/adapter';
33
+
34
+ export default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {
35
+ findRecord(store, type, id, snapshot) {
36
+ var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
37
+ return this.ajax(url, 'GET');
38
+ }
39
+ }
40
+ ```
41
+
42
+ ### Attributes
43
+
44
+ The `host` and `namespace` attributes will be used if defined, and are optional.
45
+
46
+ @class BuildURLMixin
47
+ @public
48
+ */
49
+ /**
50
+ Builds a URL for a given type and optional ID.
51
+
52
+ By default, it pluralizes the type's name (for example, 'post'
53
+ becomes 'posts' and 'person' becomes 'people'). To override the
54
+ pluralization see [pathForType](./pathForType?anchor=pathForType).
55
+
56
+ If an ID is specified, it adds the ID to the path generated
57
+ for the type, separated by a `/`.
58
+
59
+ When called by `RESTAdapter.findMany()` the `id` and `snapshot` parameters
60
+ will be arrays of ids and snapshots.
61
+
62
+ @public
63
+ @param {String} modelName
64
+ @param {(String|Array|Object)} id single id or array of ids or query
65
+ @param {(Snapshot|SnapshotRecordArray)} snapshot single snapshot or array of snapshots
66
+ @param {String} requestType
67
+ @param {Object} query object of query parameters to send for query requests.
68
+ @return {String} url
69
+ */
70
+
71
+ function buildURL(modelName, id, snapshot, requestType, query) {
72
+ /*
73
+ Switch statements in typescript don't currently narrow even when the function is implemented
74
+ with overloads.
75
+ We still extract this to stand alone so that we can provide nice overloads for calling signatures,
76
+ but we will still require all of this casting (or a ridiculous number of assertsthat narrow it down
77
+ for us).
78
+ */
79
+ switch (requestType) {
80
+ case 'findRecord':
81
+ return this.urlForFindRecord(id, modelName, snapshot);
82
+ case 'findAll':
83
+ return this.urlForFindAll(modelName, snapshot);
84
+ case 'query':
85
+ return this.urlForQuery(query || {}, modelName);
86
+ case 'queryRecord':
87
+ return this.urlForQueryRecord(query || {}, modelName);
88
+ case 'findMany':
89
+ return this.urlForFindMany(id, modelName, snapshot);
90
+ case 'findHasMany':
91
+ return this.urlForFindHasMany(id, modelName, snapshot);
92
+ case 'findBelongsTo':
93
+ return this.urlForFindBelongsTo(id, modelName, snapshot);
94
+ case 'createRecord':
95
+ return this.urlForCreateRecord(modelName, snapshot);
96
+ case 'updateRecord':
97
+ return this.urlForUpdateRecord(id, modelName, snapshot);
98
+ case 'deleteRecord':
99
+ return this.urlForDeleteRecord(id, modelName, snapshot);
100
+ default:
101
+ // this is the 'never' case but someone may call `buildURL` manually so
102
+ // we try to do something for them.
103
+ return this._buildURL(modelName, id);
104
+ }
105
+ }
106
+
107
+ /**
108
+ @private
109
+ @param {String} modelName
110
+ @param {String} id
111
+ @return {String} url
112
+ */
113
+ function _buildURL(modelName, id) {
114
+ let path;
115
+ const url = [];
116
+ const {
117
+ host
118
+ } = this;
119
+ const prefix = this.urlPrefix();
120
+ if (modelName) {
121
+ path = this.pathForType(modelName);
122
+ if (path) {
123
+ url.push(path);
124
+ }
125
+ }
126
+ if (id) {
127
+ url.push(encodeURIComponent(id));
128
+ }
129
+ if (prefix) {
130
+ url.unshift(prefix);
131
+ }
132
+ let urlString = url.join('/');
133
+ if (!host && urlString && urlString.charAt(0) !== '/') {
134
+ urlString = '/' + urlString;
135
+ }
136
+ return urlString;
137
+ }
138
+
139
+ /**
140
+ Builds a URL for a `store.findRecord(type, id)` call.
141
+
142
+ Example:
143
+
144
+ ```js [app/adapters/user.js]
145
+ import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';
146
+
147
+ export default class ApplicationAdapter extends JSONAPIAdapter {
148
+ urlForFindRecord(id, modelName, snapshot) {
149
+ let baseUrl = this.buildURL(modelName, id, snapshot);
150
+ return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;
151
+ }
152
+ }
153
+ ```
154
+
155
+ @public
156
+ @param {String} id
157
+ @param {String} modelName
158
+ @param {Snapshot} snapshot
159
+ @return {String} url
160
+
161
+ */
162
+ function urlForFindRecord(id, modelName, snapshot) {
163
+ return this._buildURL(modelName, id);
164
+ }
165
+
166
+ /**
167
+ Builds a URL for a `store.findAll(type)` call.
168
+
169
+ Example:
170
+
171
+ ```js [app/adapters/comment.js]
172
+ import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';
173
+
174
+ export default class ApplicationAdapter extends JSONAPIAdapter {
175
+ urlForFindAll(modelName, snapshot) {
176
+ let baseUrl = this.buildURL(modelName);
177
+ return `${baseUrl}/data/comments.json`;
178
+ }
179
+ }
180
+ ```
181
+
182
+ @public
183
+ @param {String} modelName
184
+ @param {SnapshotRecordArray} snapshot
185
+ @return {String} url
186
+ */
187
+ function urlForFindAll(modelName, snapshots) {
188
+ return this._buildURL(modelName);
189
+ }
190
+
191
+ /**
192
+ Builds a URL for a `store.query(type, query)` call.
193
+
194
+ Example:
195
+
196
+ ```js [app/adapters/application.js]
197
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
198
+
199
+ export default class ApplicationAdapter extends RESTAdapter {
200
+ host = 'https://api.github.com';
201
+ urlForQuery (query, modelName) {
202
+ switch(modelName) {
203
+ case 'repo':
204
+ return `https://api.github.com/orgs/${query.orgId}/repos`;
205
+ default:
206
+ return super.urlForQuery(...arguments);
207
+ }
208
+ }
209
+ }
210
+ ```
211
+
212
+ @public
213
+ @param {Object} query
214
+ @param {String} modelName
215
+ @return {String} url
216
+ */
217
+ function urlForQuery(query, modelName) {
218
+ return this._buildURL(modelName);
219
+ }
220
+
221
+ /**
222
+ Builds a URL for a `store.queryRecord(type, query)` call.
223
+
224
+ Example:
225
+
226
+ ```js [app/adapters/application.js]
227
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
228
+
229
+ export default class ApplicationAdapter extends RESTAdapter {
230
+ urlForQueryRecord({ slug }, modelName) {
231
+ let baseUrl = this.buildURL();
232
+ return `${baseUrl}/${encodeURIComponent(slug)}`;
233
+ }
234
+ }
235
+ ```
236
+
237
+ @public
238
+ @param {Object} query
239
+ @param {String} modelName
240
+ @return {String} url
241
+ */
242
+ function urlForQueryRecord(query, modelName) {
243
+ return this._buildURL(modelName);
244
+ }
245
+
246
+ /**
247
+ Builds a URL for coalescing multiple `store.findRecord(type, id)`
248
+ records into 1 request when the adapter's `coalesceFindRequests`
249
+ property is `true`.
250
+
251
+ Example:
252
+
253
+ ```js [app/adapters/application.js]
254
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
255
+
256
+ export default class ApplicationAdapter extends RESTAdapter {
257
+ urlForFindMany(ids, modelName) {
258
+ let baseUrl = this.buildURL();
259
+ return `${baseUrl}/coalesce`;
260
+ }
261
+ }
262
+ ```
263
+
264
+ @public
265
+ @param {Array} ids
266
+ @param {String} modelName
267
+ @param {Array} snapshots
268
+ @return {String} url
269
+ */
270
+ function urlForFindMany(ids, modelName, snapshots) {
271
+ return this._buildURL(modelName);
272
+ }
273
+
274
+ /**
275
+ Builds a URL for fetching an async `hasMany` relationship when a URL
276
+ is not provided by the server.
277
+
278
+ Example:
279
+
280
+ ```js [app/adapters/application.js]
281
+ import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';
282
+
283
+ export default class ApplicationAdapter extends JSONAPIAdapter {
284
+ urlForFindHasMany(id, modelName, snapshot) {
285
+ let baseUrl = this.buildURL(modelName, id);
286
+ return `${baseUrl}/relationships`;
287
+ }
288
+ }
289
+ ```
290
+
291
+ @public
292
+ @param {String} id
293
+ @param {String} modelName
294
+ @param {Snapshot} snapshot
295
+ @return {String} url
296
+ */
297
+ function urlForFindHasMany(id, modelName, snapshot) {
298
+ return this._buildURL(modelName, id);
299
+ }
300
+
301
+ /**
302
+ Builds a URL for fetching an async `belongsTo` relationship when a url
303
+ is not provided by the server.
304
+
305
+ Example:
306
+
307
+ ```js [app/adapters/application.js]
308
+ import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';
309
+
310
+ export default class ApplicationAdapter extends JSONAPIAdapter {
311
+ urlForFindBelongsTo(id, modelName, snapshot) {
312
+ let baseUrl = this.buildURL(modelName, id);
313
+ return `${baseUrl}/relationships`;
314
+ }
315
+ }
316
+ ```
317
+
318
+ @public
319
+ @param {String} id
320
+ @param {String} modelName
321
+ @param {Snapshot} snapshot
322
+ @return {String} url
323
+ */
324
+ function urlForFindBelongsTo(id, modelName, snapshot) {
325
+ return this._buildURL(modelName, id);
326
+ }
327
+
328
+ /**
329
+ Builds a URL for a `record.save()` call when the record was created
330
+ locally using `store.createRecord()`.
331
+
332
+ Example:
333
+
334
+ ```js [app/adapters/application.js]
335
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
336
+
337
+ export default class ApplicationAdapter extends RESTAdapter {
338
+ urlForCreateRecord(modelName, snapshot) {
339
+ return super.urlForCreateRecord(...arguments) + '/new';
340
+ }
341
+ }
342
+ ```
343
+
344
+ @public
345
+ @param {String} modelName
346
+ @param {Snapshot} snapshot
347
+ @return {String} url
348
+ */
349
+ function urlForCreateRecord(modelName, snapshot) {
350
+ return this._buildURL(modelName);
351
+ }
352
+
353
+ /**
354
+ Builds a URL for a `record.save()` call when the record has been updated locally.
355
+
356
+ Example:
357
+
358
+ ```js [app/adapters/application.js]
359
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
360
+
361
+ export default class ApplicationAdapter extends RESTAdapter {
362
+ urlForUpdateRecord(id, modelName, snapshot) {
363
+ return `/${id}/feed?access_token=${snapshot.adapterOptions.token}`;
364
+ }
365
+ }
366
+ ```
367
+
368
+ @public
369
+ @param {String} id
370
+ @param {String} modelName
371
+ @param {Snapshot} snapshot
372
+ @return {String} url
373
+ */
374
+ function urlForUpdateRecord(id, modelName, snapshot) {
375
+ return this._buildURL(modelName, id);
376
+ }
377
+
378
+ /**
379
+ Builds a URL for a `record.save()` call when the record has been deleted locally.
380
+
381
+ Example:
382
+
383
+ ```js [app/adapters/application.js]
384
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
385
+
386
+ export default class ApplicationAdapter extends RESTAdapter {
387
+ urlForDeleteRecord(id, modelName, snapshot) {
388
+ return super.urlForDeleteRecord(...arguments) + '/destroy';
389
+ }
390
+ }
391
+ ```
392
+
393
+ @public
394
+ @param {String} id
395
+ @param {String} modelName
396
+ @param {Snapshot} snapshot
397
+ @return {String} url
398
+ */
399
+ function urlForDeleteRecord(id, modelName, snapshot) {
400
+ return this._buildURL(modelName, id);
401
+ }
402
+
403
+ /**
404
+ @private
405
+ @param {String} path
406
+ @param {String} parentURL
407
+ @return {String} urlPrefix
408
+ */
409
+ function urlPrefix(path, parentURL) {
410
+ const {
411
+ namespace
412
+ } = this;
413
+ let {
414
+ host
415
+ } = this;
416
+ if (!host || host === '/') {
417
+ host = '';
418
+ }
419
+ if (path) {
420
+ // Protocol relative url
421
+ if (/^\/\//.test(path) || /http(s)?:\/\//.test(path)) {
422
+ // Do nothing, the full host is already included.
423
+ return path;
424
+
425
+ // Absolute path
426
+ } else if (path.charAt(0) === '/') {
427
+ return `${host}${path}`;
428
+ // Relative path
429
+ } else {
430
+ return `${parentURL}/${path}`;
431
+ }
432
+ }
433
+
434
+ // No path provided
435
+ const url = [];
436
+ if (host) {
437
+ url.push(host);
438
+ }
439
+ if (namespace) {
440
+ url.push(namespace);
441
+ }
442
+ return url.join('/');
443
+ }
444
+
445
+ /**
446
+ Determines the pathname for a given type.
447
+
448
+ By default, it pluralizes the type's name (for example,
449
+ 'post' becomes 'posts' and 'person' becomes 'people').
450
+
451
+ ### Pathname customization
452
+
453
+ For example, if you have an object `LineItem` with an
454
+ endpoint of `/line_items/`.
455
+
456
+ ```js [app/adapters/application.js]
457
+ import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
458
+ import { undesrcore, pluralize } from '<app-name>/utils/string-utils';
459
+
460
+ export default class ApplicationAdapter extends RESTAdapter {
461
+ pathForType(modelName) {
462
+ return pluralize(underscore(modelName));
463
+ }
464
+ }
465
+ ```
466
+
467
+ @public
468
+ @param {String} modelName
469
+ @return {String} path
470
+ **/
471
+ function pathForType(modelName) {
472
+ const camelized = camelize(modelName);
473
+ return pluralize(camelized);
474
+ }
475
+
476
+ // we build it this way vs casting to BuildURLMixin so that any
477
+ // changes to the interface surface as errors here.
478
+ const mixinProps = {
479
+ buildURL,
480
+ _buildURL,
481
+ urlForFindRecord,
482
+ urlForFindAll,
483
+ urlForQueryRecord,
484
+ urlForQuery,
485
+ urlForFindMany,
486
+ urlForFindHasMany,
487
+ urlForFindBelongsTo,
488
+ urlForCreateRecord,
489
+ urlForDeleteRecord,
490
+ urlForUpdateRecord,
491
+ urlPrefix,
492
+ pathForType
493
+ };
494
+ const BuildURLMixin = Mixin.create(mixinProps);
495
+
496
+ /**
497
+ * ## Overview
498
+ *
499
+ * :::danger
500
+ * ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
501
+ * If starting a new app or thinking of implementing a new adapter, consider writing a
502
+ * {@link Handler} instead to be used with the {@link RequestManager}
503
+ * ::::
504
+ *
505
+ * In order to properly fetch and update data, @warp-drive/legacy
506
+ * needs to understand how to connect to your API.
507
+ *
508
+ * `Adapters` accept various kinds of requests from the store
509
+ * and manage fulfillment of the request from your API.
510
+ *
511
+ * ### Request Flow
512
+ *
513
+ * When the store decides it needs to issue a request it uses the following flow to manage the request and process the data.
514
+ *
515
+ * - find the appropriate adapter
516
+ * - issue the request to the adapter
517
+ * - await the adapter's response
518
+ * - if an error occurs reject with the error
519
+ * - if no error
520
+ * - if there is response data
521
+ * - pass the response data to the appropriate serializer
522
+ * - update the cache using the JSON:API formatted data from the serializer's response
523
+ * - return the primary record(s) associated with the request
524
+ *
525
+ * ### Request Errors
526
+ *
527
+ * When a request errors and your adapter does not have the ability to recover from the error,
528
+ * you may either reject the promise returned by your adapter method with the error or simply
529
+ * throw the error.
530
+ *
531
+ * If the request was for a `createRecord` `updateRecord` or `deleteRecord` special rules
532
+ * apply to how this error will affect the state of the store and additional properties on
533
+ * the `Error` class may be used. See the documentation for these methods in
534
+ * {@link MinimumAdapterInterface} for more information.
535
+ *
536
+ * ### Implementing an Adapter
537
+ *
538
+ * There are seven required adapter methods, one for each of
539
+ * the primary request types that @warp-drive/legacy issues.
540
+ *
541
+ * They are:
542
+ *
543
+ * - findRecord
544
+ * - findAll
545
+ * - queryRecord
546
+ * - query
547
+ * - createRecord
548
+ * - updateRecord
549
+ * - deleteRecord
550
+ *
551
+ * Each of these request types has a matching store method that triggers it
552
+ * and matching `requestType` that is passed to the serializer's
553
+ * `normalizeResponse` method.
554
+ *
555
+ * If your app only reads data but never writes data, it is not necessary
556
+ * to implement the methods for create, update, and delete. This extends to
557
+ * all of the store's find methods with the exception of `findRecord` (`findAll`,
558
+ * `query`, `queryRecord`): if you do not use the store method in your app then
559
+ * your Adapter does not need the method.
560
+ *
561
+ * ```ts
562
+ * async function fetchData(url, options = {}) {
563
+ * let response = await fetch(url, options);
564
+ * return response.toJSON();
565
+ * }
566
+ *
567
+ * export default class ApplicationAdapter {
568
+ * findRecord(_, { modelName }, id) {
569
+ * return fetchData(`./${modelName}s/${id}`);
570
+ * }
571
+ *
572
+ * static create() {
573
+ * return new this();
574
+ * }
575
+ * }
576
+ * ```
577
+ *
578
+ * ### Adapter Resolution
579
+ *
580
+ * `store.adapterFor(name)` will lookup adapters defined in `app/adapters/` and
581
+ * return an instance.
582
+ *
583
+ * `adapterFor` first attempts to find an adapter with an exact match on `name`,
584
+ then falls back to checking for the presence of an adapter named `application`.
585
+
586
+ If no adapter is found, an error will be thrown.
587
+
588
+ ```ts
589
+ store.adapterFor('author');
590
+
591
+ // lookup paths (in order) =>
592
+ // app/adapters/author.js
593
+ // app/adapters/application.js
594
+ ```
595
+
596
+ Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`)
597
+ (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
598
+ refer to this as the **primary** resource `type`.
599
+
600
+ `adapterFor` is used by the store to find an adapter with a name matching that of the primary
601
+ resource `type` for the request, which then falls back to the `application` adapter.
602
+
603
+ It is recommended that applications define only a single `application` adapter and serializer
604
+ where possible, only implementing an adapter specific to the `type` when absolutely necessary.
605
+
606
+ If you need to support multiple API versions for the same type, the per-type strategy for
607
+ defining adapters might not be adequate.
608
+
609
+ If you have multiple APIs or multiple API versions and the single application adapter and per-type
610
+ strategy does not suite your needs, one strategy is to write an `application` adapter and serializer
611
+ that make use of `options` to specify the desired format when making a request, then forwards to the
612
+ request to the desired adapter or serializer as needed.
613
+
614
+ ```js [app/adapters/application.js]
615
+ export default class Adapter extends EmberObject {
616
+ findRecord(store, schema, id, snapshot) {
617
+ let { apiVersion } = snapshot.adapterOptions;
618
+ return this.adapterFor(`-api-${apiVersion}`).findRecord(store, schema, id, snapshot);
619
+ }
620
+ }
621
+ ```
622
+
623
+ ### Overriding `Store.adapterFor`
624
+
625
+ ```js
626
+ import Store from '@ember-data/store';
627
+ import Adapter from '@ember-data/adapter/json-api';
628
+
629
+ class extends Store {
630
+ #adapter = new Adapter();
631
+
632
+ adapterFor() {
633
+ return this.#adapter;
634
+ }
635
+ }
636
+ ```
637
+
638
+
639
+ Note: If you are using Ember and would like to make use of `service` injections in your adapter, you will want to additionally `setOwner` for the Adapter.
640
+
641
+ ```js
642
+ import Store from '@ember-data/store';
643
+ import Adapter from '@ember-data/adapter/json-api';
644
+ import { getOwner, setOwner } from '@ember/owner';
645
+
646
+ class extends Store {
647
+ #adapter = null;
648
+
649
+ adapterFor() {
650
+ let adapter = this.#adapter;
651
+ if (!adapter) {
652
+ const owner = getOwner(this);
653
+ adapter = new Adapter();
654
+ setOwner(adapter, owner);
655
+ this.#adapter = adapter;
656
+ }
657
+
658
+ return adapter;
659
+ }
660
+ }
661
+ ```
662
+
663
+ By default when using with Ember you only need to implement this hook if you want your adapter usage to be statically analyzeable. *Ember***Data** will attempt to resolve adapters using Ember's resolver. To provide a single Adapter for your application like the above you would provide it as the default export of the file `app/adapters/application.{js/ts}`
664
+
665
+ ### Using an Adapter
666
+
667
+ Any adapter in `app/adapters/` can be looked up by `name` using `store.adapterFor(name)`.
668
+
669
+ ### Default Adapters
670
+
671
+ Applications whose API's structure endpoint URLs *very close to* or *exactly* the **REST**
672
+ or **JSON:API** convention, the `@ember-data/adapter` package contains implementations
673
+ these applications can extend.
674
+
675
+ Many applications will find writing their own adapter to be allow greater flexibility,
676
+ customization, and maintenance than attempting to override methods in these adapters.
677
+
678
+ @module
679
+ */
680
+
681
+ const service = s.service ?? s.inject;
682
+ /**
683
+ An adapter is an object that receives requests from a store and
684
+ translates them into the appropriate action to take against your
685
+ persistence layer. The persistence layer is usually an HTTP API but
686
+ may be anything, such as the browser's local storage. Typically the
687
+ adapter is not invoked directly instead its functionality is accessed
688
+ through the `store`.
689
+
690
+ > ⚠️ CAUTION you likely want the docs for {@link MinimumAdapterInterface}
691
+ > as extending this abstract class is unnecessary.
692
+
693
+ ### Creating an Adapter
694
+
695
+ Create a new subclass of `Adapter` in the `app/adapters` folder:
696
+
697
+ ```js [app/adapters/application.js]
698
+ import { Adapter } from '@warp-drive/legacy/adapter';
699
+
700
+ export default class extends Adapter {
701
+ // ...your code here
702
+ }
703
+ ```
704
+
705
+ Model-specific adapters can be created by putting your adapter
706
+ class in an `app/adapters/` + `model-name` + `.js` file of the application.
707
+
708
+ ```js [app/adapters/post.js]
709
+ import { Adapter } from '@warp-drive/legacy/adapter';
710
+
711
+ export default class extends Adapter {
712
+ // ...Post-specific adapter code goes here
713
+ }
714
+ ```
715
+
716
+ `Adapter` is an abstract base class that you should override in your
717
+ application to customize it for your backend. The minimum set of methods
718
+ that you should implement is:
719
+
720
+ * `findRecord()`
721
+ * `createRecord()`
722
+ * `updateRecord()`
723
+ * `deleteRecord()`
724
+ * `findAll()`
725
+ * `query()`
726
+
727
+ To improve the network performance of your application, you can optimize
728
+ your adapter by overriding these lower-level methods:
729
+
730
+ * `findMany()`
731
+
732
+
733
+ For an example of the implementation, see `RESTAdapter`, the
734
+ included REST adapter.
735
+
736
+ @public
737
+ */
738
+ class Adapter extends EmberObject {
739
+ static {
740
+ decorateFieldV2(this.prototype, "store", [service]);
741
+ }
742
+ #store = (initializeDeferredDecorator(this, "store"), void 0);
743
+ /**
744
+ The `findRecord()` method is invoked when the store is asked for a record that
745
+ has not previously been loaded. In response to `findRecord()` being called, you
746
+ should query your persistence layer for a record with the given ID. The `findRecord`
747
+ method should return a promise that will resolve to a JavaScript object that will be
748
+ normalized by the serializer.
749
+ Here is an example of the `findRecord` implementation:
750
+ ```js [app/adapters/application.js]
751
+ import { Adapter } from '@warp-drive/legacy/adapter';
752
+ import RSVP from 'RSVP';
753
+ import $ from 'jquery';
754
+ export default class ApplicationAdapter extends Adapter {
755
+ findRecord(store, type, id, snapshot) {
756
+ return new RSVP.Promise(function(resolve, reject) {
757
+ $.getJSON(`/${type.modelName}/${id}`).then(function(data) {
758
+ resolve(data);
759
+ }, function(jqXHR) {
760
+ reject(jqXHR);
761
+ });
762
+ });
763
+ }
764
+ }
765
+ ```
766
+ @public
767
+ */
768
+ // @ts-expect-error
769
+ findRecord(store, type, id, snapshot) {
770
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
771
+ throw new Error('You subclassed the Adapter class but missing a findRecord override');
772
+ }
773
+ }
774
+
775
+ /**
776
+ The `findAll()` method is used to retrieve all records for a given type.
777
+ Example
778
+ ```js [app/adapters/application.js]
779
+ import { Adapter } from '@warp-drive/legacy/adapter';
780
+ import RSVP from 'RSVP';
781
+ import $ from 'jquery';
782
+ export default class ApplicationAdapter extends Adapter {
783
+ findAll(store, type) {
784
+ return new RSVP.Promise(function(resolve, reject) {
785
+ $.getJSON(`/${type.modelName}`).then(function(data) {
786
+ resolve(data);
787
+ }, function(jqXHR) {
788
+ reject(jqXHR);
789
+ });
790
+ });
791
+ }
792
+ }
793
+ ```
794
+ @param neverSet a value is never provided to this argument
795
+ @public
796
+ */
797
+ findAll(store, type, neverSet, snapshotRecordArray) {
798
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
799
+ throw new Error('You subclassed the Adapter class but missing a findAll override');
800
+ }
801
+ }
802
+
803
+ /**
804
+ This method is called when you call `query` on the store.
805
+ Example
806
+ ```js [app/adapters/application.js]
807
+ import { Adapter } from '@warp-drive/legacy/adapter';
808
+ import RSVP from 'RSVP';
809
+ import $ from 'jquery';
810
+ export default class ApplicationAdapter extends Adapter {
811
+ query(store, type, query) {
812
+ return new RSVP.Promise(function(resolve, reject) {
813
+ $.getJSON(`/${type.modelName}`, query).then(function(data) {
814
+ resolve(data);
815
+ }, function(jqXHR) {
816
+ reject(jqXHR);
817
+ });
818
+ });
819
+ }
820
+ }
821
+ ```
822
+ @public
823
+ */
824
+ // @ts-expect-error
825
+ query(store, type, query) {
826
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
827
+ throw new Error('You subclassed the Adapter class but missing a query override');
828
+ }
829
+ }
830
+
831
+ /**
832
+ The `queryRecord()` method is invoked when the store is asked for a single
833
+ record through a query object.
834
+ In response to `queryRecord()` being called, you should always fetch fresh
835
+ data. Once found, you can asynchronously call the store's `push()` method
836
+ to push the record into the store.
837
+ Here is an example `queryRecord` implementation:
838
+ Example
839
+ ```js [app/adapters/application.js]
840
+ import { Adapter, BuildURLMixin } from '@warp-drive/legacy/adapter';
841
+ export default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {
842
+ queryRecord(store, type, query) {
843
+ return fetch(`/${type.modelName}`, { body: JSON.stringify(query) })
844
+ .then((response) => response.json());
845
+ }
846
+ }
847
+ ```
848
+ @public
849
+ */
850
+ queryRecord(store, type, query, adapterOptions) {
851
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
852
+ throw new Error('You subclassed the Adapter class but missing a queryRecord override');
853
+ }
854
+ }
855
+
856
+ /**
857
+ If the globally unique IDs for your records should be generated on the client,
858
+ implement the `generateIdForRecord()` method. This method will be invoked
859
+ each time you create a new record, and the value returned from it will be
860
+ assigned to the record's `primaryKey`.
861
+ Most traditional REST-like HTTP APIs will not use this method. Instead, the ID
862
+ of the record will be set by the server, and your adapter will update the store
863
+ with the new ID when it calls `didCreateRecord()`. Only implement this method if
864
+ you intend to generate record IDs on the client-side.
865
+ The `generateIdForRecord()` method will be invoked with the requesting store as
866
+ the first parameter and the newly created record as the second parameter:
867
+ ```javascript
868
+ import { Adapter } from '@warp-drive/legacy/adapter';
869
+ import { v4 } from 'uuid';
870
+ export default class ApplicationAdapter extends Adapter {
871
+ generateIdForRecord(store, type, inputProperties) {
872
+ return v4();
873
+ }
874
+ }
875
+ ```
876
+ @param {Store} store
877
+ @param {Model} type the Model class of the record
878
+ @param {Object} inputProperties a hash of properties to set on the
879
+ newly created record.
880
+ @return {(String|Number)} id
881
+ @public
882
+ */
883
+
884
+ /**
885
+ Proxies to the serializer's `serialize` method.
886
+ Example
887
+ ```js [app/adapters/application.js]
888
+ import { Adapter } from '@warp-drive/legacy/adapter';
889
+ export default class ApplicationAdapter extends Adapter {
890
+ createRecord(store, type, snapshot) {
891
+ let data = this.serialize(snapshot, { includeId: true });
892
+ let url = `/${type.modelName}`;
893
+ // ...
894
+ }
895
+ }
896
+ ```
897
+ @public
898
+ */
899
+ serialize(snapshot, options) {
900
+ const serialized = snapshot.serialize(options);
901
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
902
+ if (!test) {
903
+ throw new Error(`Your adapter's serialize method must return an object, but it returned ${typeof serialized}`);
904
+ }
905
+ })(serialized && typeof serialized === 'object') : {};
906
+ return serialized;
907
+ }
908
+
909
+ /**
910
+ Implement this method in a subclass to handle the creation of
911
+ new records.
912
+ Serializes the record and sends it to the server.
913
+ Example
914
+ ```js [app/adapters/application.js]
915
+ import { Adapter } from '@warp-drive/legacy/adapter';
916
+ import RSVP from 'RSVP';
917
+ import $ from 'jquery';
918
+ export default class ApplicationAdapter extends Adapter {
919
+ createRecord(store, type, snapshot) {
920
+ let data = this.serialize(snapshot, { includeId: true });
921
+ return new RSVP.Promise(function (resolve, reject) {
922
+ $.ajax({
923
+ type: 'POST',
924
+ url: `/${type.modelName}`,
925
+ dataType: 'json',
926
+ data: data
927
+ }).then(function (data) {
928
+ resolve(data);
929
+ }, function (jqXHR) {
930
+ jqXHR.then = null; // tame jQuery's ill mannered promises
931
+ reject(jqXHR);
932
+ });
933
+ });
934
+ }
935
+ }
936
+ ```
937
+ @public
938
+ */
939
+ // @ts-expect-error
940
+ createRecord(store, type, snapshot) {
941
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
942
+ throw new Error('You subclassed the Adapter class but missing a createRecord override');
943
+ }
944
+ }
945
+
946
+ /**
947
+ Implement this method in a subclass to handle the updating of
948
+ a record.
949
+ Serializes the record update and sends it to the server.
950
+ The updateRecord method is expected to return a promise that will
951
+ resolve with the serialized record. This allows the backend to
952
+ inform the Ember Data store the current state of this record after
953
+ the update. If it is not possible to return a serialized record
954
+ the updateRecord promise can also resolve with `undefined` and the
955
+ Ember Data store will assume all of the updates were successfully
956
+ applied on the backend.
957
+ Example
958
+ ```js [app/adapters/application.js]
959
+ import { Adapter } from '@warp-drive/legacy/adapter';
960
+ import RSVP from 'RSVP';
961
+ import $ from 'jquery';
962
+ export default class ApplicationAdapter extends Adapter {
963
+ updateRecord(store, type, snapshot) {
964
+ let data = this.serialize(snapshot, { includeId: true });
965
+ let id = snapshot.id;
966
+ return new RSVP.Promise(function(resolve, reject) {
967
+ $.ajax({
968
+ type: 'PUT',
969
+ url: `/${type.modelName}/${id}`,
970
+ dataType: 'json',
971
+ data: data
972
+ }).then(function(data) {
973
+ resolve(data);
974
+ }, function(jqXHR) {
975
+ jqXHR.then = null; // tame jQuery's ill mannered promises
976
+ reject(jqXHR);
977
+ });
978
+ });
979
+ }
980
+ }
981
+ ```
982
+ @param {Store} store
983
+ @param {Model} type the Model class of the record
984
+ @param {Snapshot} snapshot
985
+ @return {Promise} promise
986
+ @public
987
+ */
988
+ // @ts-expect-error
989
+ updateRecord(store, type, snapshot) {
990
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
991
+ throw new Error('You subclassed the Adapter class but missing a updateRecord override');
992
+ }
993
+ }
994
+
995
+ /**
996
+ Implement this method in a subclass to handle the deletion of
997
+ a record.
998
+ Sends a delete request for the record to the server.
999
+ Example
1000
+ ```js [app/adapters/application.js]
1001
+ import { Adapter } from '@warp-drive/legacy/adapter';
1002
+ import RSVP from 'RSVP';
1003
+ import $ from 'jquery';
1004
+ export default class ApplicationAdapter extends Adapter {
1005
+ deleteRecord(store, type, snapshot) {
1006
+ let data = this.serialize(snapshot, { includeId: true });
1007
+ let id = snapshot.id;
1008
+ return new RSVP.Promise(function(resolve, reject) {
1009
+ $.ajax({
1010
+ type: 'DELETE',
1011
+ url: `/${type.modelName}/${id}`,
1012
+ dataType: 'json',
1013
+ data: data
1014
+ }).then(function(data) {
1015
+ resolve(data)
1016
+ }, function(jqXHR) {
1017
+ jqXHR.then = null; // tame jQuery's ill mannered promises
1018
+ reject(jqXHR);
1019
+ });
1020
+ });
1021
+ }
1022
+ }
1023
+ ```
1024
+ @param {Store} store
1025
+ @param {Model} type the Model class of the record
1026
+ @param {Snapshot} snapshot
1027
+ @return {Promise} promise
1028
+ @public
1029
+ */
1030
+ // @ts-expect-error
1031
+ deleteRecord(store, type, snapshot) {
1032
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
1033
+ throw new Error('You subclassed the Adapter class but missing a deleteRecord override');
1034
+ }
1035
+ }
1036
+
1037
+ /**
1038
+ By default the store will try to coalesce all `findRecord` calls within the same runloop
1039
+ into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call.
1040
+ You can opt out of this behaviour by either not implementing the findMany hook or by setting
1041
+ coalesceFindRequests to false.
1042
+ @property coalesceFindRequests
1043
+ @public
1044
+ @type {Boolean}
1045
+ */
1046
+ get coalesceFindRequests() {
1047
+ const coalesceFindRequests = this._coalesceFindRequests;
1048
+ if (typeof coalesceFindRequests === 'boolean') {
1049
+ return coalesceFindRequests;
1050
+ }
1051
+ return this._coalesceFindRequests = true;
1052
+ }
1053
+ set coalesceFindRequests(value) {
1054
+ this._coalesceFindRequests = value;
1055
+ }
1056
+
1057
+ /**
1058
+ The store will call `findMany` instead of multiple `findRecord`
1059
+ requests to find multiple records at once if coalesceFindRequests
1060
+ is true.
1061
+ ```js [app/adapters/application.js]
1062
+ import { Adapter } from '@warp-drive/legacy/adapter';
1063
+ import RSVP from 'RSVP';
1064
+ import $ from 'jquery';
1065
+ export default class ApplicationAdapter extends Adapter {
1066
+ findMany(store, type, ids, snapshots) {
1067
+ return new RSVP.Promise(function(resolve, reject) {
1068
+ $.ajax({
1069
+ type: 'GET',
1070
+ url: `/${type.modelName}/`,
1071
+ dataType: 'json',
1072
+ data: { filter: { id: ids.join(',') } }
1073
+ }).then(function(data) {
1074
+ resolve(data);
1075
+ }, function(jqXHR) {
1076
+ jqXHR.then = null; // tame jQuery's ill mannered promises
1077
+ reject(jqXHR);
1078
+ });
1079
+ });
1080
+ }
1081
+ }
1082
+ ```
1083
+ @param {Store} store
1084
+ @param {Model} type the Model class of the records
1085
+ @param {Array} ids
1086
+ @param {Array} snapshots
1087
+ @return {Promise} promise
1088
+ @public
1089
+ */
1090
+
1091
+ /**
1092
+ Organize records into groups, each of which is to be passed to separate
1093
+ calls to `findMany`.
1094
+ For example, if your API has nested URLs that depend on the parent, you will
1095
+ want to group records by their parent.
1096
+ The default implementation returns the records as a single group.
1097
+ @public
1098
+ @param {Store} store
1099
+ @param {Array} snapshots
1100
+ @return {Array} an array of arrays of records, each of which is to be
1101
+ loaded separately by `findMany`.
1102
+ */
1103
+ groupRecordsForFindMany(store, snapshots) {
1104
+ return [snapshots];
1105
+ }
1106
+
1107
+ /**
1108
+ This method is used by the store to determine if the store should
1109
+ reload a record from the adapter when a record is requested by
1110
+ `store.findRecord`.
1111
+ If this method returns `true`, the store will re-fetch a record from
1112
+ the adapter. If this method returns `false`, the store will resolve
1113
+ immediately using the cached record.
1114
+ For example, if you are building an events ticketing system, in which users
1115
+ can only reserve tickets for 20 minutes at a time, and want to ensure that
1116
+ in each route you have data that is no more than 20 minutes old you could
1117
+ write:
1118
+ ```javascript
1119
+ shouldReloadRecord(store, ticketSnapshot) {
1120
+ let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');
1121
+ let timeDiff = moment().diff(lastAccessedAt, 'minutes');
1122
+ if (timeDiff > 20) {
1123
+ return true;
1124
+ } else {
1125
+ return false;
1126
+ }
1127
+ }
1128
+ ```
1129
+ This method would ensure that whenever you do `store.findRecord('ticket',
1130
+ id)` you will always get a ticket that is no more than 20 minutes old. In
1131
+ case the cached version is more than 20 minutes old, `findRecord` will not
1132
+ resolve until you fetched the latest version.
1133
+ By default this hook returns `false`, as most UIs should not block user
1134
+ interactions while waiting on data update.
1135
+ Note that, with default settings, `shouldBackgroundReloadRecord` will always
1136
+ re-fetch the records in the background even if `shouldReloadRecord` returns
1137
+ `false`. You can override `shouldBackgroundReloadRecord` if this does not
1138
+ suit your use case.
1139
+ @since 1.13.0
1140
+ @param {Store} store
1141
+ @param {Snapshot} snapshot
1142
+ @return {Boolean}
1143
+ @public
1144
+ */
1145
+ shouldReloadRecord(store, snapshot) {
1146
+ return false;
1147
+ }
1148
+
1149
+ /**
1150
+ This method is used by the store to determine if the store should
1151
+ reload all records from the adapter when records are requested by
1152
+ `store.findAll`.
1153
+ If this method returns `true`, the store will re-fetch all records from
1154
+ the adapter. If this method returns `false`, the store will resolve
1155
+ immediately using the cached records.
1156
+ For example, if you are building an events ticketing system, in which users
1157
+ can only reserve tickets for 20 minutes at a time, and want to ensure that
1158
+ in each route you have data that is no more than 20 minutes old you could
1159
+ write:
1160
+ ```javascript
1161
+ shouldReloadAll(store, snapshotArray) {
1162
+ let snapshots = snapshotArray.snapshots();
1163
+ return snapshots.any((ticketSnapshot) => {
1164
+ let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');
1165
+ let timeDiff = moment().diff(lastAccessedAt, 'minutes');
1166
+ if (timeDiff > 20) {
1167
+ return true;
1168
+ } else {
1169
+ return false;
1170
+ }
1171
+ });
1172
+ }
1173
+ ```
1174
+ This method would ensure that whenever you do `store.findAll('ticket')` you
1175
+ will always get a list of tickets that are no more than 20 minutes old. In
1176
+ case a cached version is more than 20 minutes old, `findAll` will not
1177
+ resolve until you fetched the latest versions.
1178
+ By default, this method returns `true` if the passed `snapshotRecordArray`
1179
+ is empty (meaning that there are no records locally available yet),
1180
+ otherwise, it returns `false`.
1181
+ Note that, with default settings, `shouldBackgroundReloadAll` will always
1182
+ re-fetch all the records in the background even if `shouldReloadAll` returns
1183
+ `false`. You can override `shouldBackgroundReloadAll` if this does not suit
1184
+ your use case.
1185
+ @since 1.13.0
1186
+ @param {Store} store
1187
+ @param {SnapshotRecordArray} snapshotRecordArray
1188
+ @return {Boolean}
1189
+ @public
1190
+ */
1191
+ shouldReloadAll(store, snapshotRecordArray) {
1192
+ return !snapshotRecordArray.length;
1193
+ }
1194
+
1195
+ /**
1196
+ This method is used by the store to determine if the store should
1197
+ reload a record after the `store.findRecord` method resolves a
1198
+ cached record.
1199
+ This method is *only* checked by the store when the store is
1200
+ returning a cached record.
1201
+ If this method returns `true` the store will re-fetch a record from
1202
+ the adapter.
1203
+ For example, if you do not want to fetch complex data over a mobile
1204
+ connection, or if the network is down, you can implement
1205
+ `shouldBackgroundReloadRecord` as follows:
1206
+ ```javascript
1207
+ shouldBackgroundReloadRecord(store, snapshot) {
1208
+ let { downlink, effectiveType } = navigator.connection;
1209
+ return downlink > 0 && effectiveType === '4g';
1210
+ }
1211
+ ```
1212
+ By default, this hook returns `true` so the data for the record is updated
1213
+ in the background.
1214
+ @since 1.13.0
1215
+ @param {Store} store
1216
+ @param {Snapshot} snapshot
1217
+ @return {Boolean}
1218
+ @public
1219
+ */
1220
+ shouldBackgroundReloadRecord(store, snapshot) {
1221
+ return true;
1222
+ }
1223
+
1224
+ /**
1225
+ This method is used by the store to determine if the store should
1226
+ reload a record array after the `store.findAll` method resolves
1227
+ with a cached record array.
1228
+ This method is *only* checked by the store when the store is
1229
+ returning a cached record array.
1230
+ If this method returns `true` the store will re-fetch all records
1231
+ from the adapter.
1232
+ For example, if you do not want to fetch complex data over a mobile
1233
+ connection, or if the network is down, you can implement
1234
+ `shouldBackgroundReloadAll` as follows:
1235
+ ```javascript
1236
+ shouldBackgroundReloadAll(store, snapshotArray) {
1237
+ let { downlink, effectiveType } = navigator.connection;
1238
+ return downlink > 0 && effectiveType === '4g';
1239
+ }
1240
+ ```
1241
+ By default this method returns `true`, indicating that a background reload
1242
+ should always be triggered.
1243
+ @since 1.13.0
1244
+ @param {Store} store
1245
+ @param {SnapshotRecordArray} snapshotRecordArray
1246
+ @return {Boolean}
1247
+ @public
1248
+ */
1249
+ shouldBackgroundReloadAll(store, snapshotRecordArray) {
1250
+ return true;
1251
+ }
1252
+ }
1253
+ export { Adapter, BuildURLMixin };