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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +6 -6
@@ -0,0 +1,1020 @@
1
+ import { getOwner } from '@ember/application';
2
+ import { recordIdentifierFor } from '@warp-drive/core';
3
+ import { assertPrivateStore, waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
4
+ import '@warp-drive/core/reactive/-private';
5
+ import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-B1pSSN52.js";
6
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
7
+ function _findHasMany(adapter, store, identifier, link, relationship, options) {
8
+ const promise = Promise.resolve().then(() => {
9
+ const snapshot = store._fetchManager.createSnapshot(identifier, options);
10
+ const useLink = !link || typeof link === 'string';
11
+ const relatedLink = useLink ? link : link.href;
12
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
13
+ if (!test) {
14
+ throw new Error(`Attempted to load a hasMany relationship from a specified 'link' in the original payload, but the specified link is empty. You must provide a valid 'link' in the original payload to use 'findHasMany'`);
15
+ }
16
+ })(relatedLink) : {};
17
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
18
+ if (!test) {
19
+ throw new Error(`Expected the adapter to implement 'findHasMany' but it does not`);
20
+ }
21
+ })(typeof adapter.findHasMany === 'function') : {};
22
+ return adapter.findHasMany(store, snapshot, relatedLink, relationship);
23
+ });
24
+ return promise.then(adapterPayload => {
25
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
26
+ if (!test) {
27
+ throw new Error(`You made a 'findHasMany' request for a ${identifier.type}'s '${relationship.name}' relationship, using link '${JSON.stringify(link)}' , but the adapter's response did not have any data`);
28
+ }
29
+ })(payloadIsNotBlank(adapterPayload)) : {};
30
+ const modelClass = store.modelFor(relationship.type);
31
+ const serializer = store.serializerFor(relationship.type);
32
+ let payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findHasMany');
33
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
34
+ if (!test) {
35
+ throw new Error(`fetched the hasMany relationship '${relationship.name}' for ${identifier.type}:${identifier.id} with link '${JSON.stringify(link)}', but no data member is present in the response. If no data exists, the response should set { data: [] }`);
36
+ }
37
+ })('data' in payload && Array.isArray(payload.data)) : {};
38
+ payload = syncRelationshipDataFromLink(store, payload, identifier, relationship);
39
+ return store._push(payload, true);
40
+ }, null);
41
+ }
42
+ function _findBelongsTo(store, identifier, link, relationship, options) {
43
+ const promise = Promise.resolve().then(() => {
44
+ const adapter = store.adapterFor(identifier.type);
45
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
46
+ if (!test) {
47
+ throw new Error(`You tried to load a belongsTo relationship but you have no adapter (for ${identifier.type})`);
48
+ }
49
+ })(adapter) : {};
50
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
51
+ if (!test) {
52
+ throw new Error(`You tried to load a belongsTo relationship from a specified 'link' in the original payload but your adapter does not implement 'findBelongsTo'`);
53
+ }
54
+ })(typeof adapter.findBelongsTo === 'function') : {};
55
+ const snapshot = store._fetchManager.createSnapshot(identifier, options);
56
+ const useLink = !link || typeof link === 'string';
57
+ const relatedLink = useLink ? link : link.href;
58
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
59
+ if (!test) {
60
+ throw new Error(`Attempted to load a belongsTo relationship from a specified 'link' in the original payload, but the specified link is empty. You must provide a valid 'link' in the original payload to use 'findBelongsTo'`);
61
+ }
62
+ })(relatedLink) : {};
63
+ return adapter.findBelongsTo(store, snapshot, relatedLink, relationship);
64
+ });
65
+ return promise.then(adapterPayload => {
66
+ const modelClass = store.modelFor(relationship.type);
67
+ const serializer = store.serializerFor(relationship.type);
68
+ let payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findBelongsTo');
69
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
70
+ if (!test) {
71
+ throw new Error(`fetched the belongsTo relationship '${relationship.name}' for ${identifier.type}:${identifier.id} with link '${JSON.stringify(link)}', but no data member is present in the response. If no data exists, the response should set { data: null }`);
72
+ }
73
+ })('data' in payload && (payload.data === null || typeof payload.data === 'object' && !Array.isArray(payload.data))) : {};
74
+ if (!payload.data && !payload.links && !payload.meta) {
75
+ return null;
76
+ }
77
+ payload = syncRelationshipDataFromLink(store, payload, identifier, relationship);
78
+ return store._push(payload, true);
79
+ }, null);
80
+ }
81
+
82
+ // sync
83
+ // iterate over records in payload.data
84
+ // for each record
85
+ // assert that record.relationships[inverse] is either undefined (so we can fix it)
86
+ // or provide a data: {id, type} that matches the record that requested it
87
+ // return the relationship data for the parent
88
+ function syncRelationshipDataFromLink(store, payload, parentIdentifier, relationship) {
89
+ // ensure the right hand side (incoming payload) points to the parent record that
90
+ // requested this relationship
91
+ const relationshipData = payload.data ? iterateData(payload.data, (data, index) => {
92
+ const {
93
+ id,
94
+ type
95
+ } = data;
96
+ ensureRelationshipIsSetToParent(data, parentIdentifier, store, relationship, index);
97
+ return {
98
+ id,
99
+ type
100
+ };
101
+ }) : null;
102
+ const relatedDataHash = {};
103
+ if ('meta' in payload) {
104
+ relatedDataHash.meta = payload.meta;
105
+ }
106
+ if ('links' in payload) {
107
+ relatedDataHash.links = payload.links;
108
+ }
109
+ if ('data' in payload) {
110
+ relatedDataHash.data = relationshipData;
111
+ }
112
+
113
+ // now, push the left hand side (the parent record) to ensure things are in sync, since
114
+ // the payload will be pushed with store._push
115
+ const parentPayload = {
116
+ id: parentIdentifier.id,
117
+ type: parentIdentifier.type,
118
+ relationships: {
119
+ [relationship.name]: relatedDataHash
120
+ }
121
+ };
122
+ if (!Array.isArray(payload.included)) {
123
+ payload.included = [];
124
+ }
125
+ payload.included.push(parentPayload);
126
+ return payload;
127
+ }
128
+ function ensureRelationshipIsSetToParent(payload, parentIdentifier, store, parentRelationship, index) {
129
+ const {
130
+ id,
131
+ type
132
+ } = payload;
133
+ if (!payload.relationships) {
134
+ payload.relationships = {};
135
+ }
136
+ const {
137
+ relationships
138
+ } = payload;
139
+ const inverse = getInverse(store, parentIdentifier, parentRelationship, type);
140
+ if (inverse) {
141
+ const {
142
+ inverseKey,
143
+ kind
144
+ } = inverse;
145
+ const relationshipData = relationships[inverseKey]?.data;
146
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
147
+ if (typeof relationshipData !== 'undefined' && !relationshipDataPointsToParent(relationshipData, parentIdentifier)) {
148
+ const inspect = function inspect(thing) {
149
+ return `'${JSON.stringify(thing)}'`;
150
+ };
151
+ const quotedType = inspect(type);
152
+ const quotedInverse = inspect(inverseKey);
153
+ const expected = inspect({
154
+ id: parentIdentifier.id,
155
+ type: parentIdentifier.type
156
+ });
157
+ const expectedModel = `${parentIdentifier.type}:${parentIdentifier.id}`;
158
+ const got = inspect(relationshipData);
159
+ const prefix = typeof index === 'number' ? `data[${index}]` : `data`;
160
+ const path = `${prefix}.relationships.${inverseKey}.data`;
161
+ const data = Array.isArray(relationshipData) ? relationshipData[0] : relationshipData;
162
+ const other = data ? `<${data.type}:${data.id}>` : null;
163
+ const relationshipFetched = `${expectedModel}.${parentRelationship.kind}("${parentRelationship.name}")`;
164
+ const includedRecord = `<${type}:${id}>`;
165
+ const message = [`Encountered mismatched relationship: Ember Data expected ${path} in the payload from ${relationshipFetched} to include ${expected} but got ${got} instead.\n`, `The ${includedRecord} record loaded at ${prefix} in the payload specified ${other} as its ${quotedInverse}, but should have specified ${expectedModel} (the record the relationship is being loaded from) as its ${quotedInverse} instead.`, `This could mean that the response for ${relationshipFetched} may have accidentally returned ${quotedType} records that aren't related to ${expectedModel} and could be related to a different ${parentIdentifier.type} record instead.`, `Ember Data has corrected the ${includedRecord} record's ${quotedInverse} relationship to ${expectedModel} so that ${relationshipFetched} will include ${includedRecord}.`, `Please update the response from the server or change your serializer to either ensure that the response for only includes ${quotedType} records that specify ${expectedModel} as their ${quotedInverse}, or omit the ${quotedInverse} relationship from the response.`].join('\n');
166
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
167
+ {
168
+ throw new Error(message);
169
+ }
170
+ })() : {};
171
+ }
172
+ }
173
+ if (kind !== 'hasMany' || typeof relationshipData !== 'undefined') {
174
+ relationships[inverseKey] = relationships[inverseKey] || {};
175
+ relationships[inverseKey].data = fixRelationshipData(relationshipData ?? null, kind, parentIdentifier);
176
+ }
177
+ }
178
+ }
179
+ function inverseForRelationship(store, identifier, key) {
180
+ const definition = store.schema.fields(identifier).get(key);
181
+ if (!definition) {
182
+ return null;
183
+ }
184
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
185
+ if (!test) {
186
+ throw new Error(`Expected the field definition to be a relationship`);
187
+ }
188
+ })(definition.kind === 'hasMany' || definition.kind === 'belongsTo') : {};
189
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
190
+ if (!test) {
191
+ throw new Error(`Expected the relationship defintion to specify the inverse type or null.`);
192
+ }
193
+ })(definition.options?.inverse === null || typeof definition.options?.inverse === 'string' && definition.options.inverse.length > 0) : {};
194
+ return definition.options.inverse;
195
+ }
196
+ function getInverse(store, parentIdentifier, parentRelationship, type) {
197
+ const {
198
+ name: lhs_relationshipName
199
+ } = parentRelationship;
200
+ const {
201
+ type: parentType
202
+ } = parentIdentifier;
203
+ const inverseKey = inverseForRelationship(store, {
204
+ type: parentType
205
+ }, lhs_relationshipName);
206
+ if (inverseKey) {
207
+ const definition = store.schema.fields({
208
+ type
209
+ }).get(inverseKey);
210
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
211
+ if (!test) {
212
+ throw new Error(`Expected the field definition to be a relationship`);
213
+ }
214
+ })(definition && (definition.kind === 'hasMany' || definition.kind === 'belongsTo')) : {};
215
+ return {
216
+ inverseKey,
217
+ kind: definition.kind
218
+ };
219
+ }
220
+ }
221
+ function relationshipDataPointsToParent(relationshipData, identifier) {
222
+ if (relationshipData === null) {
223
+ return false;
224
+ }
225
+ if (Array.isArray(relationshipData)) {
226
+ if (relationshipData.length === 0) {
227
+ return false;
228
+ }
229
+ for (let i = 0; i < relationshipData.length; i++) {
230
+ const entry = relationshipData[i];
231
+ if (validateRelationshipEntry(entry, identifier)) {
232
+ return true;
233
+ }
234
+ }
235
+ } else {
236
+ return validateRelationshipEntry(relationshipData, identifier);
237
+ }
238
+ return false;
239
+ }
240
+ function fixRelationshipData(relationshipData, relationshipKind, {
241
+ id,
242
+ type
243
+ }) {
244
+ const parentRelationshipData = {
245
+ id,
246
+ type
247
+ };
248
+ let payload = null;
249
+ if (relationshipKind === 'hasMany') {
250
+ const relData = relationshipData || [];
251
+ if (relationshipData) {
252
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
253
+ if (!test) {
254
+ throw new Error('expected the relationship data to be an array');
255
+ }
256
+ })(Array.isArray(relationshipData)) : {};
257
+ // these arrays could be massive so this is better than filter
258
+ // Note: this is potentially problematic if type/id are not in the
259
+ // same state of normalization.
260
+ const found = relationshipData.find(v => {
261
+ return v.type === parentRelationshipData.type && v.id === parentRelationshipData.id;
262
+ });
263
+ if (!found) {
264
+ relData.push(parentRelationshipData);
265
+ }
266
+ } else {
267
+ relData.push(parentRelationshipData);
268
+ }
269
+ payload = relData;
270
+ } else {
271
+ const relData = relationshipData || {};
272
+ Object.assign(relData, parentRelationshipData);
273
+ payload = relData;
274
+ }
275
+ return payload;
276
+ }
277
+ function validateRelationshipEntry({
278
+ id
279
+ }, {
280
+ id: parentModelID
281
+ }) {
282
+ return !!id && id.toString() === parentModelID;
283
+ }
284
+ const PotentialLegacyOperations = new Set(['findRecord', 'findAll', 'query', 'queryRecord', 'findBelongsTo', 'findHasMany', 'updateRecord', 'createRecord', 'deleteRecord']);
285
+ const LegacyNetworkHandler = {
286
+ request(context, next) {
287
+ // if we are not a legacy request, move on
288
+ if (context.request.url || !context.request.op || !PotentialLegacyOperations.has(context.request.op)) {
289
+ return next(context.request);
290
+ }
291
+ const {
292
+ store
293
+ } = context.request;
294
+ if (!store._fetchManager) {
295
+ store._fetchManager = new FetchManager(store);
296
+ }
297
+ switch (context.request.op) {
298
+ case 'findRecord':
299
+ return findRecord(context);
300
+ case 'findAll':
301
+ return findAll(context);
302
+ case 'query':
303
+ return query(context);
304
+ case 'queryRecord':
305
+ return queryRecord(context);
306
+ case 'findBelongsTo':
307
+ return findBelongsTo(context);
308
+ case 'findHasMany':
309
+ return findHasMany(context);
310
+ case 'updateRecord':
311
+ return saveRecord(context);
312
+ case 'createRecord':
313
+ return saveRecord(context);
314
+ case 'deleteRecord':
315
+ return saveRecord(context);
316
+ default:
317
+ return next(context.request);
318
+ }
319
+ }
320
+ };
321
+ function findBelongsTo(context) {
322
+ const {
323
+ store,
324
+ data,
325
+ records: identifiers
326
+ } = context.request;
327
+ const {
328
+ options,
329
+ record,
330
+ links,
331
+ useLink,
332
+ field
333
+ } = data;
334
+ const identifier = identifiers?.[0];
335
+
336
+ // short circuit if we are already loading
337
+ const pendingRequest = identifier && store._fetchManager.getPendingFetch(identifier, options);
338
+ if (pendingRequest) {
339
+ return pendingRequest;
340
+ }
341
+ if (useLink) {
342
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
343
+ if (!test) {
344
+ throw new Error(`Expected a related link when calling store.findBelongsTo, found ${String(links)}`);
345
+ }
346
+ })(links && links.related) : {};
347
+ return _findBelongsTo(store, record, links.related, field, options);
348
+ }
349
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
350
+ if (!test) {
351
+ throw new Error(`Expected an identifier`);
352
+ }
353
+ })(Array.isArray(identifiers) && identifiers.length === 1) : {};
354
+ const manager = store._fetchManager;
355
+ assertIdentifierHasId(identifier);
356
+ return options.reload ? manager.scheduleFetch(identifier, options, context.request) : manager.fetchDataIfNeededForIdentifier(identifier, options, context.request);
357
+ }
358
+ function findHasMany(context) {
359
+ const {
360
+ store,
361
+ data,
362
+ records: identifiers
363
+ } = context.request;
364
+ const {
365
+ options,
366
+ record,
367
+ links,
368
+ useLink,
369
+ field
370
+ } = data;
371
+
372
+ // link case
373
+ if (useLink) {
374
+ const adapter = store.adapterFor(record.type);
375
+ /*
376
+ If a relationship was originally populated by the adapter as a link
377
+ (as opposed to a list of IDs), this method is called when the
378
+ relationship is fetched.
379
+ The link (which is usually a URL) is passed through unchanged, so the
380
+ adapter can make whatever request it wants.
381
+ The usual use-case is for the server to register a URL as a link, and
382
+ then use that URL in the future to make a request for the relationship.
383
+ */
384
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
385
+ if (!test) {
386
+ throw new Error(`You tried to load a hasMany relationship but you have no adapter (for ${record.type})`);
387
+ }
388
+ })(adapter) : {};
389
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
390
+ if (!test) {
391
+ throw new Error(`You tried to load a hasMany relationship from a specified 'link' in the original payload but your adapter does not implement 'findHasMany'`);
392
+ }
393
+ })(typeof adapter.findHasMany === 'function') : {};
394
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
395
+ if (!test) {
396
+ throw new Error(`Expected a related link when calling store.findHasMany, found ${String(links)}`);
397
+ }
398
+ })(links && links.related) : {};
399
+ return _findHasMany(adapter, store, record, links.related, field, options);
400
+ }
401
+
402
+ // identifiers case
403
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
404
+ if (!test) {
405
+ throw new Error(`Expected an array of identifiers to fetch`);
406
+ }
407
+ })(Array.isArray(identifiers)) : {};
408
+ const fetches = new Array(identifiers.length);
409
+ const manager = store._fetchManager;
410
+ for (let i = 0; i < identifiers.length; i++) {
411
+ const identifier = identifiers[i];
412
+ // TODO we probably can be lenient here and return from cache for the isNew case
413
+ assertIdentifierHasId(identifier);
414
+ fetches[i] = options.reload ? manager.scheduleFetch(identifier, options, context.request) : manager.fetchDataIfNeededForIdentifier(identifier, options, context.request);
415
+ }
416
+ return Promise.all(fetches);
417
+ }
418
+ function saveRecord(context) {
419
+ const {
420
+ store,
421
+ data,
422
+ op: operation
423
+ } = context.request;
424
+ const {
425
+ options,
426
+ record: identifier
427
+ } = data;
428
+ assertPrivateStore(store);
429
+ store.cache.willCommit(identifier, context);
430
+ const saveOptions = Object.assign({
431
+ [SaveOp]: operation
432
+ }, options);
433
+ const fetchManagerPromise = store._fetchManager.scheduleSave(identifier, saveOptions);
434
+ return fetchManagerPromise.then(payload => {
435
+ let result;
436
+ store._join(() => {
437
+ // @ts-expect-error we don't have access to a response in legacy
438
+ result = store.cache.didCommit(identifier, {
439
+ request: context.request,
440
+ content: payload
441
+ });
442
+ });
443
+
444
+ // blatantly lie if we were a createRecord request
445
+ // to give some semblance of cache-control to the
446
+ // CachePolicy while legacy is still around
447
+ if (store.lifetimes?.didRequest && operation === 'createRecord') {
448
+ store.lifetimes.didRequest(context.request, {
449
+ status: 201
450
+ }, null, store);
451
+ }
452
+ return store.peekRecord(result.data);
453
+ }).catch(e => {
454
+ let err = e;
455
+ if (!e) {
456
+ err = new Error(`Unknown Error Occurred During Request`);
457
+ } else if (typeof e === 'string') {
458
+ err = new Error(e);
459
+ }
460
+ adapterDidInvalidate(store, identifier, err);
461
+ throw err;
462
+ });
463
+ }
464
+ function adapterDidInvalidate(store, identifier, error) {
465
+ if (error && error.isAdapterError === true && error.code === 'InvalidError') {
466
+ const serializer = store.serializerFor(identifier.type);
467
+
468
+ // TODO @deprecate extractErrors being called
469
+ // TODO remove extractErrors from the default serializers.
470
+ if (serializer && typeof serializer.extractErrors === 'function') {
471
+ const errorsHash = serializer.extractErrors(store, store.modelFor(identifier.type), error, identifier.id);
472
+ error.errors = errorsHashToArray(errorsHash);
473
+ }
474
+ }
475
+ const cache = store.cache;
476
+ if (error.errors) {
477
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
478
+ if (!test) {
479
+ throw new Error(`Expected the cache in use by resource ${String(identifier)} to have a getErrors(identifier) method for retrieving errors.`);
480
+ }
481
+ })(typeof cache.getErrors === 'function') : {};
482
+ let jsonApiErrors = error.errors;
483
+ if (jsonApiErrors.length === 0) {
484
+ jsonApiErrors = [{
485
+ title: 'Invalid Error',
486
+ detail: '',
487
+ source: {
488
+ pointer: '/data'
489
+ }
490
+ }];
491
+ }
492
+ cache.commitWasRejected(identifier, jsonApiErrors);
493
+ } else {
494
+ cache.commitWasRejected(identifier);
495
+ }
496
+ }
497
+ function makeArray(value) {
498
+ return Array.isArray(value) ? value : [value];
499
+ }
500
+ const PRIMARY_ATTRIBUTE_KEY = 'base';
501
+ function errorsHashToArray(errors) {
502
+ const out = [];
503
+ if (errors) {
504
+ Object.keys(errors).forEach(key => {
505
+ const messages = makeArray(errors[key]);
506
+ for (let i = 0; i < messages.length; i++) {
507
+ let title = 'Invalid Attribute';
508
+ let pointer = `/data/attributes/${key}`;
509
+ if (key === PRIMARY_ATTRIBUTE_KEY) {
510
+ title = 'Invalid Document';
511
+ pointer = `/data`;
512
+ }
513
+ out.push({
514
+ title: title,
515
+ detail: messages[i],
516
+ source: {
517
+ pointer: pointer
518
+ }
519
+ });
520
+ }
521
+ });
522
+ }
523
+ return out;
524
+ }
525
+ function findRecord(context) {
526
+ const {
527
+ store,
528
+ data
529
+ } = context.request;
530
+ const {
531
+ record: identifier,
532
+ options
533
+ } = data;
534
+ assertPrivateStore(store);
535
+ let promise;
536
+
537
+ // if not loaded start loading
538
+ if (!store._instanceCache.recordIsLoaded(identifier)) {
539
+ promise = store._fetchManager.fetchDataIfNeededForIdentifier(identifier, options, context.request);
540
+
541
+ // Refetch if the reload option is passed
542
+ } else if (options.reload) {
543
+ assertIdentifierHasId(identifier);
544
+ promise = store._fetchManager.scheduleFetch(identifier, options, context.request);
545
+ } else {
546
+ let snapshot = null;
547
+ const adapter = store.adapterFor(identifier.type);
548
+
549
+ // Refetch the record if the adapter thinks the record is stale
550
+ if (typeof options.reload === 'undefined' && adapter.shouldReloadRecord && adapter.shouldReloadRecord(store, snapshot = store._fetchManager.createSnapshot(identifier, options))) {
551
+ assertIdentifierHasId(identifier);
552
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
553
+ promise = store._fetchManager.scheduleFetch(identifier, Object.assign({}, options, {
554
+ reload: true
555
+ }), context.request);
556
+ } else {
557
+ options.reload = true;
558
+ promise = store._fetchManager.scheduleFetch(identifier, options, context.request);
559
+ }
560
+ } else {
561
+ // Trigger the background refetch if backgroundReload option is passed
562
+ if (options.backgroundReload !== false && (options.backgroundReload || !adapter.shouldBackgroundReloadRecord || adapter.shouldBackgroundReloadRecord(store, snapshot = snapshot || store._fetchManager.createSnapshot(identifier, options)))) {
563
+ assertIdentifierHasId(identifier);
564
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
565
+ void store._fetchManager.scheduleFetch(identifier, Object.assign({}, options, {
566
+ backgroundReload: true
567
+ }), context.request);
568
+ } else {
569
+ options.backgroundReload = true;
570
+ void store._fetchManager.scheduleFetch(identifier, options, context.request);
571
+ }
572
+ }
573
+
574
+ // Return the cached record
575
+ promise = Promise.resolve(identifier);
576
+ }
577
+ }
578
+ return promise.then(i => store.peekRecord(i));
579
+ }
580
+ function findAll(context) {
581
+ const {
582
+ store,
583
+ data
584
+ } = context.request;
585
+ const {
586
+ type,
587
+ options
588
+ } = data;
589
+ assertPrivateStore(store);
590
+ const adapter = store.adapterFor(type);
591
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
592
+ if (!test) {
593
+ throw new Error(`You tried to load all records but you have no adapter (for ${type})`);
594
+ }
595
+ })(adapter) : {};
596
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
597
+ if (!test) {
598
+ throw new Error(`You tried to load all records but your adapter does not implement 'findAll'`);
599
+ }
600
+ })(typeof adapter.findAll === 'function') : {};
601
+
602
+ // avoid initializing the liveArray just to set `isUpdating`
603
+ const maybeRecordArray = store.recordArrayManager._live.get(type);
604
+ const snapshotArray = new SnapshotRecordArray(store, type, options);
605
+ const shouldReload = options.reload || options.reload !== false && (adapter.shouldReloadAll && adapter.shouldReloadAll(store, snapshotArray) || !adapter.shouldReloadAll && snapshotArray.length === 0);
606
+ let fetch;
607
+ if (shouldReload) {
608
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
609
+ maybeRecordArray && (maybeRecordArray.isUpdating = true);
610
+ fetch = _findAll(adapter, store, type, snapshotArray, context.request, true);
611
+ } else {
612
+ fetch = Promise.resolve(store.peekAll(type));
613
+ if (options.backgroundReload || options.backgroundReload !== false && (!adapter.shouldBackgroundReloadAll || adapter.shouldBackgroundReloadAll(store, snapshotArray))) {
614
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
615
+ maybeRecordArray && (maybeRecordArray.isUpdating = true);
616
+ void _findAll(adapter, store, type, snapshotArray, context.request, false);
617
+ }
618
+ }
619
+ return fetch;
620
+ }
621
+ function _findAll(adapter, store, type, snapshotArray, request, isAsyncFlush) {
622
+ const schema = store.modelFor(type);
623
+ let promise = Promise.resolve().then(() => adapter.findAll(store, schema, null, snapshotArray));
624
+ promise = promise.then(adapterPayload => {
625
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
626
+ if (!test) {
627
+ throw new Error(`You made a 'findAll' request for '${type}' records, but the adapter's response did not have any data`);
628
+ }
629
+ })(payloadIsNotBlank(adapterPayload)) : {};
630
+ const serializer = store.serializerFor(type);
631
+ const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'findAll');
632
+ store._push(payload, isAsyncFlush);
633
+ snapshotArray._recordArray.isUpdating = false;
634
+ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_REQUESTS)) {
635
+ if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
636
+ // eslint-disable-next-line no-console
637
+ console.log(`request: findAll<${type}> background reload complete`);
638
+ }
639
+ }
640
+ return snapshotArray._recordArray;
641
+ });
642
+ if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
643
+ if (!request.disableTestWaiter) {
644
+ promise = waitFor(promise);
645
+ }
646
+ }
647
+ return promise;
648
+ }
649
+ function query(context) {
650
+ const {
651
+ store,
652
+ data
653
+ } = context.request;
654
+ assertPrivateStore(store);
655
+ let {
656
+ options
657
+ } = data;
658
+ // eslint-disable-next-line @typescript-eslint/no-shadow
659
+ const {
660
+ type,
661
+ query
662
+ } = data;
663
+ const adapter = store.adapterFor(type);
664
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
665
+ if (!test) {
666
+ throw new Error(`You tried to make a query but you have no adapter (for ${type})`);
667
+ }
668
+ })(adapter) : {};
669
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
670
+ if (!test) {
671
+ throw new Error(`You tried to make a query but your adapter does not implement 'query'`);
672
+ }
673
+ })(typeof adapter.query === 'function') : {};
674
+ const recordArray = options._recordArray || store.recordArrayManager.getCollection({
675
+ type,
676
+ query
677
+ });
678
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
679
+ options = Object.assign({}, options);
680
+ delete options._recordArray;
681
+ } else {
682
+ delete options._recordArray;
683
+ }
684
+ const schema = store.modelFor(type);
685
+ const promise = Promise.resolve().then(() => adapter.query(store, schema, query, recordArray, options));
686
+ return promise.then(adapterPayload => {
687
+ const serializer = store.serializerFor(type);
688
+ const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'query');
689
+ const identifiers = store._push(payload, true);
690
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
691
+ if (!test) {
692
+ throw new Error('The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use `store.queryRecord` to query for a single record.');
693
+ }
694
+ })(Array.isArray(identifiers)) : {};
695
+ store.recordArrayManager.populateManagedArray(recordArray, identifiers, payload);
696
+ return recordArray;
697
+ });
698
+ }
699
+ function assertSingleResourceDocument(payload) {
700
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
701
+ if (!test) {
702
+ throw new Error(`Expected the primary data returned by the serializer for a 'queryRecord' response to be a single object or null but instead it was an array.`);
703
+ }
704
+ })(!Array.isArray(payload.data)) : {};
705
+ }
706
+ function queryRecord(context) {
707
+ const {
708
+ store,
709
+ data
710
+ } = context.request;
711
+ // eslint-disable-next-line @typescript-eslint/no-shadow
712
+ const {
713
+ type,
714
+ query,
715
+ options
716
+ } = data;
717
+ const adapter = store.adapterFor(type);
718
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
719
+ if (!test) {
720
+ throw new Error(`You tried to make a query but you have no adapter (for ${type})`);
721
+ }
722
+ })(adapter) : {};
723
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
724
+ if (!test) {
725
+ throw new Error(`You tried to make a query but your adapter does not implement 'queryRecord'`);
726
+ }
727
+ })(typeof adapter.queryRecord === 'function') : {};
728
+ const schema = store.modelFor(type);
729
+ const promise = Promise.resolve().then(() => adapter.queryRecord(store, schema, query, options));
730
+ return promise.then(adapterPayload => {
731
+ const serializer = store.serializerFor(type);
732
+ const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'queryRecord');
733
+ assertSingleResourceDocument(payload);
734
+ const identifier = store._push(payload, true);
735
+ return identifier ? store.peekRecord(identifier) : null;
736
+ });
737
+ }
738
+
739
+ /**
740
+ * Extends the signature of {@link Store} with additional
741
+ * methods available when using the legacy network layer.
742
+ *
743
+ * @public
744
+ * @noInheritDoc
745
+ * @legacy
746
+ */
747
+
748
+ /**
749
+ * @deprecated - use {@link LegacyStoreCompat} instead
750
+ */
751
+
752
+ /**
753
+ Returns an instance of the adapter for a given type. For
754
+ example, `adapterFor('person')` will return an instance of
755
+ the adapter located at `app/adapters/person.js`
756
+
757
+ If no `person` adapter is found, this method will look
758
+ for an `application` adapter (the default adapter for
759
+ your entire application).
760
+
761
+ @public
762
+ @param modelName
763
+ */
764
+
765
+ function adapterFor(modelName, _allowMissing) {
766
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
767
+ if (!test) {
768
+ throw new Error(`Attempted to call store.adapterFor(), but the store instance has already been destroyed.`);
769
+ }
770
+ })(!(this.isDestroying || this.isDestroyed)) : {};
771
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
772
+ if (!test) {
773
+ throw new Error(`You need to pass a model name to the store's adapterFor method`);
774
+ }
775
+ })(modelName) : {};
776
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
777
+ if (!test) {
778
+ throw new Error(`Passing classes to store.adapterFor has been removed. Please pass a dasherized string instead of ${modelName}`);
779
+ }
780
+ })(typeof modelName === 'string') : {};
781
+ this._adapterCache = this._adapterCache || Object.create(null);
782
+ const normalizedModelName = _deprecatingNormalize(modelName);
783
+ const {
784
+ _adapterCache
785
+ } = this;
786
+ let adapter = _adapterCache[normalizedModelName];
787
+ if (adapter) {
788
+ return adapter;
789
+ }
790
+ const owner = getOwner(this);
791
+
792
+ // name specific adapter
793
+ adapter = owner.lookup(`adapter:${normalizedModelName}`);
794
+ if (adapter !== undefined) {
795
+ _adapterCache[normalizedModelName] = adapter;
796
+ return adapter;
797
+ }
798
+
799
+ // no adapter found for the specific name, fallback and check for application adapter
800
+ adapter = _adapterCache.application || owner.lookup('adapter:application');
801
+ if (adapter !== undefined) {
802
+ _adapterCache[normalizedModelName] = adapter;
803
+ _adapterCache.application = adapter;
804
+ return adapter;
805
+ }
806
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
807
+ if (!test) {
808
+ throw new Error(`No adapter was found for '${modelName}' and no 'application' adapter was found as a fallback.`);
809
+ }
810
+ })(_allowMissing) : {};
811
+ }
812
+
813
+ /**
814
+ Returns an instance of the serializer for a given type. For
815
+ example, `serializerFor('person')` will return an instance of
816
+ `App.PersonSerializer`.
817
+
818
+ If no `App.PersonSerializer` is found, this method will look
819
+ for an `App.ApplicationSerializer` (the default serializer for
820
+ your entire application).
821
+
822
+ If a serializer cannot be found on the adapter, it will fall back
823
+ to an instance of `JSONSerializer`.
824
+
825
+ @public
826
+ @param modelName the record to serialize
827
+ */
828
+ function serializerFor(modelName) {
829
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
830
+ if (!test) {
831
+ throw new Error(`Attempted to call store.serializerFor(), but the store instance has already been destroyed.`);
832
+ }
833
+ })(!(this.isDestroying || this.isDestroyed)) : {};
834
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
835
+ if (!test) {
836
+ throw new Error(`You need to pass a model name to the store's serializerFor method`);
837
+ }
838
+ })(modelName) : {};
839
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
840
+ if (!test) {
841
+ throw new Error(`Passing classes to store.serializerFor has been removed. Please pass a dasherized string instead of ${modelName}`);
842
+ }
843
+ })(typeof modelName === 'string') : {};
844
+ this._serializerCache = this._serializerCache || Object.create(null);
845
+ const normalizedModelName = _deprecatingNormalize(modelName);
846
+ const {
847
+ _serializerCache
848
+ } = this;
849
+ let serializer = _serializerCache[normalizedModelName];
850
+ if (serializer) {
851
+ return serializer;
852
+ }
853
+
854
+ // by name
855
+ const owner = getOwner(this);
856
+ serializer = owner.lookup(`serializer:${normalizedModelName}`);
857
+ if (serializer !== undefined) {
858
+ _serializerCache[normalizedModelName] = serializer;
859
+ return serializer;
860
+ }
861
+
862
+ // no serializer found for the specific model, fallback and check for application serializer
863
+ serializer = _serializerCache.application || owner.lookup('serializer:application');
864
+ if (serializer !== undefined) {
865
+ _serializerCache[normalizedModelName] = serializer;
866
+ _serializerCache.application = serializer;
867
+ return serializer;
868
+ }
869
+ return null;
870
+ }
871
+
872
+ /**
873
+ `normalize` converts a json payload into the normalized form expected by
874
+ {@link Store.push | push} using the serializer specified by `modelName`
875
+
876
+ :::warning
877
+ Generally it would be better to invoke the serializer yourself directly,
878
+ or write a more specialized normalization utility.
879
+ :::
880
+
881
+ Example
882
+
883
+ ```js
884
+ socket.on('message', function(message) {
885
+ let modelName = message.model;
886
+ let data = message.data;
887
+ store.push(store.normalize(modelName, data));
888
+ });
889
+ ```
890
+
891
+ @legacy
892
+ @public
893
+ @param modelName The name of the model type for this payload
894
+ @return The normalized payload
895
+ */
896
+ // TODO @runspired @deprecate users should call normalize on the associated serializer directly
897
+ function normalize(modelName, payload) {
898
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
899
+ if (!test) {
900
+ throw new Error(`Attempted to call store.normalize(), but the store instance has already been destroyed.`);
901
+ }
902
+ })(!(this.isDestroying || this.isDestroyed)) : {};
903
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
904
+ if (!test) {
905
+ throw new Error(`You need to pass a model name to the store's normalize method`);
906
+ }
907
+ })(modelName) : {};
908
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
909
+ if (!test) {
910
+ throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${typeof modelName}`);
911
+ }
912
+ })(typeof modelName === 'string') : {};
913
+ const normalizedModelName = _deprecatingNormalize(modelName);
914
+ const serializer = this.serializerFor(normalizedModelName);
915
+ const schema = this.modelFor(normalizedModelName);
916
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
917
+ if (!test) {
918
+ throw new Error(`You must define a normalize method in your serializer in order to call store.normalize`);
919
+ }
920
+ })(typeof serializer?.normalize === 'function') : {};
921
+ return serializer.normalize(schema, payload);
922
+ }
923
+
924
+ /**
925
+ Push some raw data into the store.
926
+
927
+ This method can be used both to push in brand new
928
+ records, as well as to update existing records. You
929
+ can push in more than one type of object at once.
930
+ All objects should be in the format expected by the
931
+ serializer.
932
+
933
+ ```js [app/serializers/application.js]
934
+ import RESTSerializer from '@warp-drive/legacy/serializer/rest';
935
+
936
+ export default class ApplicationSerializer extends RESTSerializer;
937
+ ```
938
+
939
+ ```js
940
+ let pushData = {
941
+ posts: [
942
+ { id: 1, postTitle: "Great post", commentIds: [2] }
943
+ ],
944
+ comments: [
945
+ { id: 2, commentBody: "Insightful comment" }
946
+ ]
947
+ }
948
+
949
+ store.pushPayload(pushData);
950
+ ```
951
+
952
+ By default, the data will be deserialized using a default
953
+ serializer (the application serializer if it exists).
954
+
955
+ Alternatively, `pushPayload` will accept a model type which
956
+ will determine which serializer will process the payload.
957
+
958
+ ```js [app/serializers/application.js]
959
+ import RESTSerializer from '@warp-drive/legacy/serializer/rest';
960
+
961
+ export default class ApplicationSerializer extends RESTSerializer;
962
+ ```
963
+
964
+ ```js [app/serializers/post.js]
965
+ import JSONSerializer from '@warp-drive/legacy/serializer/json';
966
+
967
+ export default JSONSerializer;
968
+ ```
969
+
970
+ ```js
971
+ store.pushPayload(pushData); // Will use the application serializer
972
+ store.pushPayload('post', pushData); // Will use the post serializer
973
+ ```
974
+
975
+ @public
976
+ @param modelName Optionally, a model type used to determine which serializer will be used
977
+ @param inputPayload
978
+ */
979
+ // TODO @runspired @deprecate pushPayload in favor of looking up the serializer
980
+ function pushPayload(modelName, inputPayload) {
981
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
982
+ if (!test) {
983
+ throw new Error(`Attempted to call store.pushPayload(), but the store instance has already been destroyed.`);
984
+ }
985
+ })(!(this.isDestroying || this.isDestroyed)) : {};
986
+ const payload = inputPayload || modelName;
987
+ const normalizedModelName = inputPayload ? _deprecatingNormalize(modelName) : 'application';
988
+ const serializer = this.serializerFor(normalizedModelName);
989
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
990
+ if (!test) {
991
+ throw new Error(`You cannot use 'store.pushPayload(<type>, <payload>)' unless the serializer for '${normalizedModelName}' defines 'pushPayload'`);
992
+ }
993
+ })(serializer && typeof serializer.pushPayload === 'function') : {};
994
+ serializer.pushPayload(this, payload);
995
+ }
996
+
997
+ // TODO @runspired @deprecate records should implement their own serialization if desired
998
+ function serializeRecord(record, options) {
999
+ // TODO we used to check if the record was destroyed here
1000
+ if (!this._fetchManager) {
1001
+ this._fetchManager = new FetchManager(this);
1002
+ }
1003
+ return this._fetchManager.createSnapshot(recordIdentifierFor(record)).serialize(options);
1004
+ }
1005
+ function cleanup() {
1006
+ // enqueue destruction of any adapters/serializers we have created
1007
+ for (const adapterName in this._adapterCache) {
1008
+ const adapter = this._adapterCache[adapterName];
1009
+ if (typeof adapter.destroy === 'function') {
1010
+ adapter.destroy();
1011
+ }
1012
+ }
1013
+ for (const serializerName in this._serializerCache) {
1014
+ const serializer = this._serializerCache[serializerName];
1015
+ if (typeof serializer.destroy === 'function') {
1016
+ serializer.destroy();
1017
+ }
1018
+ }
1019
+ }
1020
+ export { LegacyNetworkHandler, adapterFor, cleanup, normalize, pushPayload, serializeRecord, serializerFor };