@warp-drive/legacy 5.10.0-alpha.12 → 5.10.0-alpha.13

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 (333) hide show
  1. package/README.md +7 -0
  2. package/dist/-private-BE7RaJCw.js.map +1 -1
  3. package/dist/adapter/-private.d.ts +2 -2
  4. package/dist/adapter/error.d.ts +1 -1
  5. package/dist/adapter/error.js +53 -0
  6. package/dist/adapter/error.js.map +1 -1
  7. package/dist/adapter/json-api.d.ts +4 -2
  8. package/dist/adapter/json-api.d.ts.map +1 -1
  9. package/dist/adapter/json-api.js +7 -0
  10. package/dist/adapter/json-api.js.map +1 -1
  11. package/dist/adapter/rest.d.ts +1 -1
  12. package/dist/adapter/rest.js +20 -1
  13. package/dist/adapter/rest.js.map +1 -1
  14. package/dist/{adapter-eYo2pIuM.js → adapter-BNC6wlWu.js} +42 -1
  15. package/dist/adapter-BNC6wlWu.js.map +1 -0
  16. package/dist/{adapter-CARrK3-8.d.ts → adapter-D3A8ixjz.d.ts} +9 -2
  17. package/dist/adapter-D3A8ixjz.d.ts.map +1 -0
  18. package/dist/adapter.d.ts +1 -1
  19. package/dist/adapter.js +1 -1
  20. package/dist/compat/-private.d.ts +1 -1
  21. package/dist/compat/builders.d.ts +10 -0
  22. package/dist/compat/builders.d.ts.map +1 -1
  23. package/dist/compat/builders.js +10 -0
  24. package/dist/compat/builders.js.map +1 -1
  25. package/dist/compat/extensions.d.ts +1 -1
  26. package/dist/compat/extensions.js +22 -0
  27. package/dist/compat/extensions.js.map +1 -1
  28. package/dist/compat/utils.d.ts +16 -0
  29. package/dist/compat/utils.d.ts.map +1 -1
  30. package/dist/compat/utils.js +18 -0
  31. package/dist/compat/utils.js.map +1 -1
  32. package/dist/{compat-BbNNmTM-.d.ts → compat-BZlQ-5eI.d.ts} +30 -1
  33. package/dist/compat-BZlQ-5eI.d.ts.map +1 -0
  34. package/dist/{compat-DWgmYX8T.js → compat-Da5y9AsM.js} +57 -1
  35. package/dist/compat-Da5y9AsM.js.map +1 -0
  36. package/dist/compat.d.ts +1 -1
  37. package/dist/compat.js +1 -1
  38. package/dist/{error-CzkyXr1Q.d.ts → error-Ba1cMaWG.d.ts} +49 -1
  39. package/dist/error-Ba1cMaWG.d.ts.map +1 -0
  40. package/dist/{errors-BlrR6--x.js → errors-BI0Xugyo.js} +3 -1
  41. package/dist/errors-BI0Xugyo.js.map +1 -0
  42. package/dist/{extensions-DumNm4dA.d.ts → extensions-fwdnX9n4.d.ts} +18 -1
  43. package/dist/extensions-fwdnX9n4.d.ts.map +1 -0
  44. package/dist/index.d.ts +16 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +23 -5
  47. package/dist/index.js.map +1 -1
  48. package/dist/{json-BXNPTlcH.js → json-n2XHdV_P.js} +8 -1
  49. package/dist/json-n2XHdV_P.js.map +1 -0
  50. package/dist/model/-private.d.ts +1 -1
  51. package/dist/model/-private.js +1 -1
  52. package/dist/model/migration-support.d.ts +18 -2
  53. package/dist/model/migration-support.d.ts.map +1 -1
  54. package/dist/model/migration-support.js +21 -3
  55. package/dist/model/migration-support.js.map +1 -1
  56. package/dist/{model-62hn5_PD.d.ts → model-BPVLf-rp.d.ts} +11 -2
  57. package/dist/model-BPVLf-rp.d.ts.map +1 -0
  58. package/dist/{model-C9l1mRs6.js → model-DdlhdL9V.js} +14 -3
  59. package/dist/model-DdlhdL9V.js.map +1 -0
  60. package/dist/{unpkg/dev-deprecated/model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
  61. package/dist/model-fragments-ZM4k_mT3.js.map +1 -0
  62. package/dist/model-fragments.d.ts +31 -1
  63. package/dist/model-fragments.d.ts.map +1 -1
  64. package/dist/model-fragments.js +1 -1
  65. package/dist/model.d.ts +12 -1
  66. package/dist/model.d.ts.map +1 -1
  67. package/dist/model.js +2 -2
  68. package/dist/{rest-0NhtexIq.d.ts → rest-ddU-K5eS.d.ts} +18 -4
  69. package/dist/rest-ddU-K5eS.d.ts.map +1 -0
  70. package/dist/{schema-provider-waPfuoKq.js → schema-provider-Dyjpau2P.js} +13 -6
  71. package/dist/schema-provider-Dyjpau2P.js.map +1 -0
  72. package/dist/serializer/json-api.d.ts +1 -0
  73. package/dist/serializer/json-api.d.ts.map +1 -1
  74. package/dist/serializer/json-api.js +6 -1
  75. package/dist/serializer/json-api.js.map +1 -1
  76. package/dist/serializer/json.d.ts +2 -0
  77. package/dist/serializer/json.d.ts.map +1 -1
  78. package/dist/serializer/json.js +1 -1
  79. package/dist/serializer/rest.d.ts +4 -0
  80. package/dist/serializer/rest.d.ts.map +1 -1
  81. package/dist/serializer/rest.js +10 -1
  82. package/dist/serializer/rest.js.map +1 -1
  83. package/dist/serializer/transform.d.ts +9 -0
  84. package/dist/serializer/transform.d.ts.map +1 -1
  85. package/dist/serializer/transform.js +9 -0
  86. package/dist/serializer/transform.js.map +1 -1
  87. package/dist/serializer.d.ts +2 -0
  88. package/dist/serializer.d.ts.map +1 -1
  89. package/dist/serializer.js +40 -0
  90. package/dist/serializer.js.map +1 -1
  91. package/dist/{store-C4qYzXei.js → store-CMUcaXRp.js} +9 -1
  92. package/dist/store-CMUcaXRp.js.map +1 -0
  93. package/dist/store.d.ts +3 -0
  94. package/dist/store.d.ts.map +1 -1
  95. package/dist/store.js +1 -1
  96. package/dist/unpkg/dev/-private-BWBRzgZO.js.map +1 -1
  97. package/dist/unpkg/dev/adapter/error.js +53 -0
  98. package/dist/unpkg/dev/adapter/error.js.map +1 -1
  99. package/dist/unpkg/dev/adapter/json-api.js +7 -0
  100. package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
  101. package/dist/unpkg/dev/adapter/rest.js +20 -1
  102. package/dist/unpkg/dev/adapter/rest.js.map +1 -1
  103. package/dist/unpkg/{dev-deprecated/adapter-oLwyr47q.js → dev/adapter-CLkSBRpr.js} +42 -1
  104. package/dist/unpkg/dev/adapter-CLkSBRpr.js.map +1 -0
  105. package/dist/unpkg/dev/adapter.js +1 -1
  106. package/dist/unpkg/dev/compat/builders.js +10 -0
  107. package/dist/unpkg/dev/compat/builders.js.map +1 -1
  108. package/dist/unpkg/dev/compat/extensions.js +22 -0
  109. package/dist/unpkg/dev/compat/extensions.js.map +1 -1
  110. package/dist/unpkg/dev/compat/utils.js +18 -0
  111. package/dist/unpkg/dev/compat/utils.js.map +1 -1
  112. package/dist/unpkg/dev/{compat-BIv7BiG_.js → compat-BEO8cSlC.js} +57 -1
  113. package/dist/unpkg/dev/compat-BEO8cSlC.js.map +1 -0
  114. package/dist/unpkg/dev/compat.js +1 -1
  115. package/dist/unpkg/dev/{errors-Dv8RCLdU.js → errors-TUXPdiG8.js} +3 -1
  116. package/dist/unpkg/dev/errors-TUXPdiG8.js.map +1 -0
  117. package/dist/unpkg/dev/index.js +23 -5
  118. package/dist/unpkg/dev/index.js.map +1 -1
  119. package/dist/unpkg/dev/{json-DDJji3V3.js → json-CN-WCWwk.js} +8 -1
  120. package/dist/unpkg/dev/json-CN-WCWwk.js.map +1 -0
  121. package/dist/unpkg/dev/model/-private.js +1 -1
  122. package/dist/unpkg/dev/model/migration-support.js +20 -2
  123. package/dist/unpkg/dev/model/migration-support.js.map +1 -1
  124. package/dist/unpkg/dev/{model-CRYi4C3z.js → model-OQxvzZu6.js} +14 -3
  125. package/dist/unpkg/dev/model-OQxvzZu6.js.map +1 -0
  126. package/dist/unpkg/dev/{model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
  127. package/dist/unpkg/dev/model-fragments-ZM4k_mT3.js.map +1 -0
  128. package/dist/unpkg/dev/model-fragments.js +1 -1
  129. package/dist/unpkg/dev/model.js +2 -2
  130. package/dist/unpkg/dev/{schema-provider-BYjTpV6C.js → schema-provider-Qxo5AVFM.js} +9 -2
  131. package/dist/unpkg/dev/schema-provider-Qxo5AVFM.js.map +1 -0
  132. package/dist/unpkg/dev/serializer/json-api.js +6 -1
  133. package/dist/unpkg/dev/serializer/json-api.js.map +1 -1
  134. package/dist/unpkg/dev/serializer/json.js +1 -1
  135. package/dist/unpkg/dev/serializer/rest.js +10 -1
  136. package/dist/unpkg/dev/serializer/rest.js.map +1 -1
  137. package/dist/unpkg/dev/serializer/transform.js +9 -0
  138. package/dist/unpkg/dev/serializer/transform.js.map +1 -1
  139. package/dist/unpkg/dev/serializer.js +40 -0
  140. package/dist/unpkg/dev/serializer.js.map +1 -1
  141. package/dist/unpkg/dev/{store-D_V8-HQl.js → store-DPzaVp5e.js} +9 -1
  142. package/dist/unpkg/dev/store-DPzaVp5e.js.map +1 -0
  143. package/dist/unpkg/dev/store.js +1 -1
  144. package/dist/unpkg/dev-deprecated/-private-BWBRzgZO.js.map +1 -1
  145. package/dist/unpkg/dev-deprecated/adapter/error.js +53 -0
  146. package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
  147. package/dist/unpkg/dev-deprecated/adapter/json-api.js +7 -0
  148. package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
  149. package/dist/unpkg/dev-deprecated/adapter/rest.js +20 -1
  150. package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
  151. package/dist/unpkg/{dev/adapter-oLwyr47q.js → dev-deprecated/adapter-CLkSBRpr.js} +42 -1
  152. package/dist/unpkg/dev-deprecated/adapter-CLkSBRpr.js.map +1 -0
  153. package/dist/unpkg/dev-deprecated/adapter.js +1 -1
  154. package/dist/unpkg/dev-deprecated/compat/builders.js +10 -0
  155. package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -1
  156. package/dist/unpkg/dev-deprecated/compat/extensions.js +22 -0
  157. package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
  158. package/dist/unpkg/dev-deprecated/compat/utils.js +18 -0
  159. package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -1
  160. package/dist/unpkg/dev-deprecated/{compat-BpJgmr75.js → compat-diBpt972.js} +57 -1
  161. package/dist/unpkg/dev-deprecated/compat-diBpt972.js.map +1 -0
  162. package/dist/unpkg/dev-deprecated/compat.js +1 -1
  163. package/dist/unpkg/dev-deprecated/{errors-__7EyX3m.js → errors-CLRhQKym.js} +3 -1
  164. package/dist/unpkg/dev-deprecated/errors-CLRhQKym.js.map +1 -0
  165. package/dist/unpkg/dev-deprecated/index.js +23 -5
  166. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  167. package/dist/unpkg/dev-deprecated/{json-DDJji3V3.js → json-CN-WCWwk.js} +8 -1
  168. package/dist/unpkg/dev-deprecated/json-CN-WCWwk.js.map +1 -0
  169. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  170. package/dist/unpkg/dev-deprecated/model/migration-support.js +20 -2
  171. package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
  172. package/dist/unpkg/dev-deprecated/{model-BYzXxf9f.js → model-DIvuaUiJ.js} +14 -3
  173. package/dist/unpkg/dev-deprecated/model-DIvuaUiJ.js.map +1 -0
  174. package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev-deprecated/model-fragments-ZM4k_mT3.js} +23 -1
  175. package/dist/unpkg/dev-deprecated/model-fragments-ZM4k_mT3.js.map +1 -0
  176. package/dist/unpkg/dev-deprecated/model-fragments.js +1 -1
  177. package/dist/unpkg/dev-deprecated/model.js +2 -2
  178. package/dist/unpkg/dev-deprecated/{schema-provider-BM9FSxvx.js → schema-provider-DHS8XOdK.js} +9 -2
  179. package/dist/unpkg/dev-deprecated/schema-provider-DHS8XOdK.js.map +1 -0
  180. package/dist/unpkg/dev-deprecated/serializer/json-api.js +6 -1
  181. package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -1
  182. package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
  183. package/dist/unpkg/dev-deprecated/serializer/rest.js +10 -1
  184. package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
  185. package/dist/unpkg/dev-deprecated/serializer/transform.js +9 -0
  186. package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
  187. package/dist/unpkg/dev-deprecated/serializer.js +40 -0
  188. package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
  189. package/dist/unpkg/dev-deprecated/{store-BCOLSC6z.js → store-D4taw4YF.js} +9 -1
  190. package/dist/unpkg/dev-deprecated/store-D4taw4YF.js.map +1 -0
  191. package/dist/unpkg/dev-deprecated/store.js +1 -1
  192. package/dist/unpkg/prod/-private-DG7eJX0Y.js.map +1 -1
  193. package/dist/unpkg/prod/adapter/error.js +53 -0
  194. package/dist/unpkg/prod/adapter/error.js.map +1 -1
  195. package/dist/unpkg/prod/adapter/json-api.js +7 -0
  196. package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
  197. package/dist/unpkg/prod/adapter/rest.js +20 -1
  198. package/dist/unpkg/prod/adapter/rest.js.map +1 -1
  199. package/dist/unpkg/prod/{adapter-DQ9UA7FC.js → adapter-BCGjVOaE.js} +42 -1
  200. package/dist/unpkg/prod/adapter-BCGjVOaE.js.map +1 -0
  201. package/dist/unpkg/prod/adapter.js +1 -1
  202. package/dist/unpkg/prod/compat/builders.js +10 -0
  203. package/dist/unpkg/prod/compat/builders.js.map +1 -1
  204. package/dist/unpkg/prod/compat/extensions.js +22 -0
  205. package/dist/unpkg/prod/compat/extensions.js.map +1 -1
  206. package/dist/unpkg/prod/compat/utils.js +18 -0
  207. package/dist/unpkg/prod/compat/utils.js.map +1 -1
  208. package/dist/unpkg/prod/{compat-BM3u_d5-.js → compat-DFMtpQGs.js} +57 -1
  209. package/dist/unpkg/prod/compat-DFMtpQGs.js.map +1 -0
  210. package/dist/unpkg/prod/compat.js +1 -1
  211. package/dist/unpkg/prod/{errors-BhnSZApj.js → errors-CImmK4OM.js} +3 -1
  212. package/dist/unpkg/prod/errors-CImmK4OM.js.map +1 -0
  213. package/dist/unpkg/prod/index.js +23 -5
  214. package/dist/unpkg/prod/index.js.map +1 -1
  215. package/dist/unpkg/{prod-deprecated/json-BD1kRTfB.js → prod/json-CNq5Z0Xq.js} +8 -1
  216. package/dist/unpkg/prod/json-CNq5Z0Xq.js.map +1 -0
  217. package/dist/unpkg/prod/model/-private.js +1 -1
  218. package/dist/unpkg/prod/model/migration-support.js +20 -2
  219. package/dist/unpkg/prod/model/migration-support.js.map +1 -1
  220. package/dist/unpkg/prod/{model-CDyejvo3.js → model-_HpfLmtZ.js} +14 -3
  221. package/dist/unpkg/prod/model-_HpfLmtZ.js.map +1 -0
  222. package/dist/unpkg/prod/model-fragments-ZM4k_mT3.js +356 -0
  223. package/dist/unpkg/prod/model-fragments-ZM4k_mT3.js.map +1 -0
  224. package/dist/unpkg/prod/model-fragments.js +1 -1
  225. package/dist/unpkg/prod/model.js +2 -2
  226. package/dist/unpkg/prod/{schema-provider-Co3gCBMj.js → schema-provider-DEe5vZ8b.js} +9 -2
  227. package/dist/unpkg/prod/schema-provider-DEe5vZ8b.js.map +1 -0
  228. package/dist/unpkg/prod/serializer/json-api.js +6 -1
  229. package/dist/unpkg/prod/serializer/json-api.js.map +1 -1
  230. package/dist/unpkg/prod/serializer/json.js +1 -1
  231. package/dist/unpkg/prod/serializer/rest.js +10 -1
  232. package/dist/unpkg/prod/serializer/rest.js.map +1 -1
  233. package/dist/unpkg/prod/serializer/transform.js +9 -0
  234. package/dist/unpkg/prod/serializer/transform.js.map +1 -1
  235. package/dist/unpkg/prod/serializer.js +40 -0
  236. package/dist/unpkg/prod/serializer.js.map +1 -1
  237. package/dist/unpkg/prod/{store-RGGc1ilN.js → store-ILh6zPA0.js} +9 -1
  238. package/dist/unpkg/prod/{store-RGGc1ilN.js.map → store-ILh6zPA0.js.map} +1 -1
  239. package/dist/unpkg/prod/store.js +1 -1
  240. package/dist/unpkg/prod-deprecated/-private-DG7eJX0Y.js.map +1 -1
  241. package/dist/unpkg/prod-deprecated/adapter/error.js +53 -0
  242. package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
  243. package/dist/unpkg/prod-deprecated/adapter/json-api.js +7 -0
  244. package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
  245. package/dist/unpkg/prod-deprecated/adapter/rest.js +20 -1
  246. package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
  247. package/dist/unpkg/prod-deprecated/{adapter-DQ9UA7FC.js → adapter-BCGjVOaE.js} +42 -1
  248. package/dist/unpkg/prod-deprecated/adapter-BCGjVOaE.js.map +1 -0
  249. package/dist/unpkg/prod-deprecated/adapter.js +1 -1
  250. package/dist/unpkg/prod-deprecated/compat/builders.js +10 -0
  251. package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -1
  252. package/dist/unpkg/prod-deprecated/compat/extensions.js +22 -0
  253. package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
  254. package/dist/unpkg/prod-deprecated/compat/utils.js +18 -0
  255. package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -1
  256. package/dist/unpkg/prod-deprecated/{compat-BM3u_d5-.js → compat-DFMtpQGs.js} +57 -1
  257. package/dist/unpkg/prod-deprecated/compat-DFMtpQGs.js.map +1 -0
  258. package/dist/unpkg/prod-deprecated/compat.js +1 -1
  259. package/dist/unpkg/prod-deprecated/{errors-BX8zhQS4.js → errors-DIOUcGAT.js} +3 -1
  260. package/dist/unpkg/prod-deprecated/errors-DIOUcGAT.js.map +1 -0
  261. package/dist/unpkg/prod-deprecated/index.js +23 -5
  262. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  263. package/dist/unpkg/{prod/json-BD1kRTfB.js → prod-deprecated/json-CNq5Z0Xq.js} +8 -1
  264. package/dist/unpkg/prod-deprecated/json-CNq5Z0Xq.js.map +1 -0
  265. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  266. package/dist/unpkg/prod-deprecated/model/migration-support.js +20 -2
  267. package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
  268. package/dist/unpkg/prod-deprecated/{model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
  269. package/dist/unpkg/prod-deprecated/model-fragments-ZM4k_mT3.js.map +1 -0
  270. package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
  271. package/dist/unpkg/prod-deprecated/{model-qeqVBN2l.js → model-wzHTp8Up.js} +14 -3
  272. package/dist/unpkg/prod-deprecated/model-wzHTp8Up.js.map +1 -0
  273. package/dist/unpkg/prod-deprecated/model.js +2 -2
  274. package/dist/unpkg/prod-deprecated/{schema-provider-CTLbab33.js → schema-provider-NWVqBEkW.js} +9 -2
  275. package/dist/unpkg/prod-deprecated/schema-provider-NWVqBEkW.js.map +1 -0
  276. package/dist/unpkg/prod-deprecated/serializer/json-api.js +6 -1
  277. package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -1
  278. package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
  279. package/dist/unpkg/prod-deprecated/serializer/rest.js +10 -1
  280. package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
  281. package/dist/unpkg/prod-deprecated/serializer/transform.js +9 -0
  282. package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
  283. package/dist/unpkg/prod-deprecated/serializer.js +40 -0
  284. package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
  285. package/dist/unpkg/prod-deprecated/{store-0L2CkYzh.js → store-CB_rVlXv.js} +9 -1
  286. package/dist/unpkg/prod-deprecated/{store-0L2CkYzh.js.map → store-CB_rVlXv.js.map} +1 -1
  287. package/dist/unpkg/prod-deprecated/store.js +1 -1
  288. package/package.json +9 -9
  289. package/dist/adapter-CARrK3-8.d.ts.map +0 -1
  290. package/dist/adapter-eYo2pIuM.js.map +0 -1
  291. package/dist/compat-BbNNmTM-.d.ts.map +0 -1
  292. package/dist/compat-DWgmYX8T.js.map +0 -1
  293. package/dist/error-CzkyXr1Q.d.ts.map +0 -1
  294. package/dist/errors-BlrR6--x.js.map +0 -1
  295. package/dist/extensions-DumNm4dA.d.ts.map +0 -1
  296. package/dist/json-BXNPTlcH.js.map +0 -1
  297. package/dist/model-62hn5_PD.d.ts.map +0 -1
  298. package/dist/model-C9l1mRs6.js.map +0 -1
  299. package/dist/model-fragments-DSqu0ptR.js.map +0 -1
  300. package/dist/rest-0NhtexIq.d.ts.map +0 -1
  301. package/dist/schema-provider-waPfuoKq.js.map +0 -1
  302. package/dist/store-C4qYzXei.js.map +0 -1
  303. package/dist/unpkg/dev/adapter-oLwyr47q.js.map +0 -1
  304. package/dist/unpkg/dev/compat-BIv7BiG_.js.map +0 -1
  305. package/dist/unpkg/dev/errors-Dv8RCLdU.js.map +0 -1
  306. package/dist/unpkg/dev/json-DDJji3V3.js.map +0 -1
  307. package/dist/unpkg/dev/model-CRYi4C3z.js.map +0 -1
  308. package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +0 -1
  309. package/dist/unpkg/dev/schema-provider-BYjTpV6C.js.map +0 -1
  310. package/dist/unpkg/dev/store-D_V8-HQl.js.map +0 -1
  311. package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +0 -1
  312. package/dist/unpkg/dev-deprecated/compat-BpJgmr75.js.map +0 -1
  313. package/dist/unpkg/dev-deprecated/errors-__7EyX3m.js.map +0 -1
  314. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +0 -1
  315. package/dist/unpkg/dev-deprecated/model-BYzXxf9f.js.map +0 -1
  316. package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  317. package/dist/unpkg/dev-deprecated/schema-provider-BM9FSxvx.js.map +0 -1
  318. package/dist/unpkg/dev-deprecated/store-BCOLSC6z.js.map +0 -1
  319. package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +0 -1
  320. package/dist/unpkg/prod/compat-BM3u_d5-.js.map +0 -1
  321. package/dist/unpkg/prod/errors-BhnSZApj.js.map +0 -1
  322. package/dist/unpkg/prod/json-BD1kRTfB.js.map +0 -1
  323. package/dist/unpkg/prod/model-CDyejvo3.js.map +0 -1
  324. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js +0 -334
  325. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js.map +0 -1
  326. package/dist/unpkg/prod/schema-provider-Co3gCBMj.js.map +0 -1
  327. package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +0 -1
  328. package/dist/unpkg/prod-deprecated/compat-BM3u_d5-.js.map +0 -1
  329. package/dist/unpkg/prod-deprecated/errors-BX8zhQS4.js.map +0 -1
  330. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +0 -1
  331. package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  332. package/dist/unpkg/prod-deprecated/model-qeqVBN2l.js.map +0 -1
  333. package/dist/unpkg/prod-deprecated/schema-provider-CTLbab33.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat-DFMtpQGs.js","names":["upgradeStore","iterateData","payloadIsNotBlank","normalizeResponseHelper","_findHasMany","adapter","store","identifier","link","relationship","options","promise","Promise","resolve","then","snapshot","_fetchManager","createSnapshot","useLink","relatedLink","href","findHasMany","adapterPayload","modelClass","modelFor","type","serializer","serializerFor","payload","syncRelationshipDataFromLink","_push","_findBelongsTo","adapterFor","findBelongsTo","data","links","meta","parentIdentifier","relationshipData","index","id","ensureRelationshipIsSetToParent","relatedDataHash","parentPayload","relationships","name","Array","isArray","included","push","parentRelationship","inverse","getInverse","inverseKey","kind","fixRelationshipData","inverseForRelationship","key","definition","schema","fields","get","lhs_relationshipName","parentType","relationshipDataPointsToParent","length","i","entry","validateRelationshipEntry","relationshipKind","parentRelationshipData","relData","found","find","v","Object","assign","parentModelID","toString","waitFor","assertPrivateStore","upgradeStore","FetchManager","SaveOp","assertIdentifierHasId","_findBelongsTo","_findHasMany","payloadIsNotBlank","normalizeResponseHelper","SnapshotRecordArray","PotentialLegacyOperations","Set","LegacyNetworkHandler","request","context","next","url","op","has","store","_fetchManager","findRecord","findAll","query","queryRecord","findBelongsTo","findHasMany","saveRecord","data","records","identifiers","options","record","links","useLink","field","identifier","pendingRequest","getPendingFetch","related","manager","reload","scheduleFetch","fetchDataIfNeededForIdentifier","adapter","adapterFor","type","fetches","Array","length","i","Promise","all","operation","cache","willCommit","saveOptions","Object","assign","fetchManagerPromise","scheduleSave","then","payload","result","_join","didCommit","content","lifetimes","didRequest","status","peekRecord","catch","e","err","Error","adapterDidInvalidate","error","isAdapterError","code","serializer","serializerFor","extractErrors","errorsHash","modelFor","id","errors","errorsHashToArray","jsonApiErrors","title","detail","source","pointer","commitWasRejected","makeArray","value","isArray","PRIMARY_ATTRIBUTE_KEY","out","keys","forEach","key","messages","push","promise","_instanceCache","recordIsLoaded","snapshot","shouldReloadRecord","createSnapshot","backgroundReload","shouldBackgroundReloadRecord","resolve","maybeRecordArray","recordArrayManager","_live","get","snapshotArray","shouldReload","shouldReloadAll","fetch","isUpdating","_findAll","peekAll","shouldBackgroundReloadAll","isAsyncFlush","schema","adapterPayload","_push","_recordArray","recordArray","getCollection","populateManagedArray","assertSingleResourceDocument","getOwner","recordIdentifierFor","_deprecatingNormalize","FetchManager","upgradeStore","LegacyNetworkHandler","adapterFor","modelName","_allowMissing","_adapterCache","Object","create","normalizedModelName","adapter","owner","lookup","undefined","application","serializerFor","_serializerCache","serializer","normalize","payload","schema","modelFor","pushPayload","inputPayload","serializeRecord","record","options","_fetchManager","createSnapshot","serialize","cleanup","adapterName","destroy","serializerName"],"sources":["../../../src/compat/legacy-network-handler/legacy-data-utils.ts","../../../src/compat/legacy-network-handler/legacy-data-fetch.ts","../../../src/compat/legacy-network-handler/legacy-network-handler.ts","../../../src/compat.ts"],"sourcesContent":["import type { AdapterPayload } from './minimum-adapter-interface.ts';\n\ntype IteratorCB<T> = ((o: T, index: number) => T) | ((o: T) => T);\n\nexport function iterateData<T>(data: T[] | T, fn: IteratorCB<T>): T | T[] {\n if (Array.isArray(data)) {\n return data.map(fn);\n } else {\n return fn(data, 0);\n }\n}\n\nexport function payloadIsNotBlank<T>(adapterPayload: T | AdapterPayload): adapterPayload is AdapterPayload {\n if (Array.isArray(adapterPayload)) {\n return true;\n } else {\n return Object.keys(adapterPayload || {}).length !== 0;\n }\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { BaseFinderOptions } from '@warp-drive/core/types';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { LegacyRelationshipField as RelationshipSchema } from '@warp-drive/core/types/schema/fields';\nimport type { ExistingResourceObject, JsonApiDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../-private.ts';\nimport { iterateData, payloadIsNotBlank } from './legacy-data-utils.ts';\nimport type { MinimumAdapterInterface } from './minimum-adapter-interface.ts';\nimport { normalizeResponseHelper } from './serializer-response.ts';\n\nexport function _findHasMany(\n adapter: MinimumAdapterInterface,\n store: Store,\n identifier: ResourceKey,\n link: string | null | { href: string },\n relationship: RelationshipSchema,\n options: BaseFinderOptions\n): Promise<PersistedResourceKey[]> {\n upgradeStore(store);\n const promise = Promise.resolve().then(() => {\n const snapshot = store._fetchManager.createSnapshot(identifier, options);\n const useLink = !link || typeof link === 'string';\n const relatedLink = useLink ? link : link.href;\n assert(\n `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'`,\n relatedLink\n );\n assert(\n `Expected the adapter to implement 'findHasMany' but it does not`,\n typeof adapter.findHasMany === 'function'\n );\n return adapter.findHasMany(store, snapshot, relatedLink, relationship);\n });\n\n return promise.then((adapterPayload) => {\n assert(\n `You made a 'findHasMany' request for a ${identifier.type}'s '${\n relationship.name\n }' relationship, using link '${JSON.stringify(link)}' , but the adapter's response did not have any data`,\n payloadIsNotBlank(adapterPayload)\n );\n const modelClass = store.modelFor(relationship.type);\n\n const serializer = store.serializerFor(relationship.type);\n let payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findHasMany');\n\n assert(\n `fetched the hasMany relationship '${relationship.name}' for ${identifier.type}:${\n identifier.id\n } with link '${JSON.stringify(\n link\n )}', but no data member is present in the response. If no data exists, the response should set { data: [] }`,\n 'data' in payload && Array.isArray(payload.data)\n );\n\n payload = syncRelationshipDataFromLink(store, payload, identifier as ResourceIdentity, relationship);\n return store._push(payload, true) as PersistedResourceKey[];\n }, null);\n}\n\nexport function _findBelongsTo(\n store: Store,\n identifier: ResourceKey,\n link: string | null | { href: string },\n relationship: RelationshipSchema,\n options: BaseFinderOptions\n): Promise<PersistedResourceKey | null> {\n upgradeStore(store);\n const promise = Promise.resolve().then(() => {\n const adapter = store.adapterFor(identifier.type);\n assert(`You tried to load a belongsTo relationship but you have no adapter (for ${identifier.type})`, adapter);\n assert(\n `You tried to load a belongsTo relationship from a specified 'link' in the original payload but your adapter does not implement 'findBelongsTo'`,\n typeof adapter.findBelongsTo === 'function'\n );\n const snapshot = store._fetchManager.createSnapshot(identifier, options);\n const useLink = !link || typeof link === 'string';\n const relatedLink = useLink ? link : link.href;\n assert(\n `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'`,\n relatedLink\n );\n return adapter.findBelongsTo(store, snapshot, relatedLink, relationship);\n });\n\n return promise.then((adapterPayload) => {\n const modelClass = store.modelFor(relationship.type);\n const serializer = store.serializerFor(relationship.type);\n let payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findBelongsTo');\n\n assert(\n `fetched the belongsTo relationship '${relationship.name}' for ${identifier.type}:${\n identifier.id\n } with link '${JSON.stringify(\n link\n )}', but no data member is present in the response. If no data exists, the response should set { data: null }`,\n 'data' in payload && (payload.data === null || (typeof payload.data === 'object' && !Array.isArray(payload.data)))\n );\n\n if (!payload.data && !payload.links && !payload.meta) {\n return null;\n }\n\n payload = syncRelationshipDataFromLink(store, payload, identifier as ResourceIdentity, relationship);\n\n return store._push(payload, true) as PersistedResourceKey | null;\n }, null);\n}\n\n// sync\n// iterate over records in payload.data\n// for each record\n// assert that record.relationships[inverse] is either undefined (so we can fix it)\n// or provide a data: {id, type} that matches the record that requested it\n// return the relationship data for the parent\nfunction syncRelationshipDataFromLink(\n store: Store,\n payload: JsonApiDocument,\n parentIdentifier: ResourceIdentity,\n relationship: RelationshipSchema\n) {\n // ensure the right hand side (incoming payload) points to the parent record that\n // requested this relationship\n const relationshipData = payload.data\n ? iterateData(payload.data, (data, index) => {\n const { id, type } = data;\n ensureRelationshipIsSetToParent(data, parentIdentifier, store, relationship, index);\n return { id, type };\n })\n : null;\n\n const relatedDataHash = {} as JsonApiDocument;\n\n if ('meta' in payload) {\n relatedDataHash.meta = payload.meta;\n }\n if ('links' in payload) {\n relatedDataHash.links = payload.links;\n }\n if ('data' in payload) {\n relatedDataHash.data = relationshipData;\n }\n\n // now, push the left hand side (the parent record) to ensure things are in sync, since\n // the payload will be pushed with store._push\n const parentPayload = {\n id: parentIdentifier.id,\n type: parentIdentifier.type,\n relationships: {\n [relationship.name]: relatedDataHash,\n },\n };\n\n if (!Array.isArray(payload.included)) {\n payload.included = [];\n }\n payload.included.push(parentPayload);\n\n return payload;\n}\n\ntype ResourceIdentity = { id: string; type: string };\ntype RelationshipData = ResourceIdentity | ResourceIdentity[] | null;\n\nfunction ensureRelationshipIsSetToParent(\n payload: ExistingResourceObject,\n parentIdentifier: ResourceIdentity,\n store: Store,\n parentRelationship: RelationshipSchema,\n index: number\n) {\n const { id, type } = payload;\n\n if (!payload.relationships) {\n payload.relationships = {};\n }\n const { relationships } = payload;\n\n const inverse = getInverse(store, parentIdentifier, parentRelationship, type);\n if (inverse) {\n const { inverseKey, kind } = inverse;\n\n const relationshipData = relationships[inverseKey]?.data;\n\n if (DEBUG) {\n if (\n typeof relationshipData !== 'undefined' &&\n !relationshipDataPointsToParent(relationshipData, parentIdentifier)\n ) {\n const inspect = function inspect(thing: unknown) {\n return `'${JSON.stringify(thing)}'`;\n };\n const quotedType = inspect(type);\n const quotedInverse = inspect(inverseKey);\n const expected = inspect({\n id: parentIdentifier.id,\n type: parentIdentifier.type,\n });\n const expectedModel = `${parentIdentifier.type}:${parentIdentifier.id}`;\n const got = inspect(relationshipData);\n const prefix = typeof index === 'number' ? `data[${index}]` : `data`;\n const path = `${prefix}.relationships.${inverseKey}.data`;\n const data = Array.isArray(relationshipData) ? relationshipData[0] : relationshipData;\n const other = data ? `<${data.type}:${data.id}>` : null;\n const relationshipFetched = `${expectedModel}.${parentRelationship.kind}(\"${parentRelationship.name}\")`;\n const includedRecord = `<${type}:${id}>`;\n const message = [\n `Encountered mismatched relationship: WarpDrive expected ${path} in the payload from ${relationshipFetched} to include ${expected} but got ${got} instead.\\n`,\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.`,\n `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.`,\n `WarpDrive has corrected the ${includedRecord} record's ${quotedInverse} relationship to ${expectedModel} so that ${relationshipFetched} will include ${includedRecord}.`,\n `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.`,\n ].join('\\n');\n\n assert(message);\n }\n }\n\n if (kind !== 'hasMany' || typeof relationshipData !== 'undefined') {\n relationships[inverseKey] = relationships[inverseKey] || {};\n relationships[inverseKey].data = fixRelationshipData(relationshipData ?? null, kind, parentIdentifier);\n }\n }\n}\n\nfunction inverseForRelationship(store: Store, identifier: { type: string; id?: string }, key: string) {\n const definition = store.schema.fields(identifier).get(key);\n if (!definition) {\n return null;\n }\n assert(\n `Expected the field definition to be a relationship`,\n definition.kind === 'hasMany' || definition.kind === 'belongsTo'\n );\n assert(\n `Expected the relationship defintion to specify the inverse type or null.`,\n definition.options?.inverse === null ||\n (typeof definition.options?.inverse === 'string' && definition.options.inverse.length > 0)\n );\n return definition.options.inverse;\n}\n\nfunction getInverse(\n store: Store,\n parentIdentifier: ResourceIdentity,\n parentRelationship: RelationshipSchema,\n type: string\n) {\n const { name: lhs_relationshipName } = parentRelationship;\n const { type: parentType } = parentIdentifier;\n const inverseKey = inverseForRelationship(store, { type: parentType }, lhs_relationshipName);\n\n if (inverseKey) {\n const definition = store.schema.fields({ type }).get(inverseKey);\n assert(\n `Expected the field definition to be a relationship`,\n definition && (definition.kind === 'hasMany' || definition.kind === 'belongsTo')\n );\n return {\n inverseKey,\n kind: definition.kind,\n };\n }\n}\n\nfunction relationshipDataPointsToParent(relationshipData: RelationshipData, identifier: ResourceIdentity): boolean {\n if (relationshipData === null) {\n return false;\n }\n\n if (Array.isArray(relationshipData)) {\n if (relationshipData.length === 0) {\n return false;\n }\n for (let i = 0; i < relationshipData.length; i++) {\n const entry = relationshipData[i];\n if (validateRelationshipEntry(entry, identifier)) {\n return true;\n }\n }\n } else {\n return validateRelationshipEntry(relationshipData, identifier);\n }\n\n return false;\n}\n\nfunction fixRelationshipData(\n relationshipData: RelationshipData,\n relationshipKind: 'hasMany' | 'belongsTo',\n { id, type }: ResourceIdentity\n) {\n const parentRelationshipData = {\n id,\n type,\n };\n\n let payload: { type: string; id: string } | { type: string; id: string }[];\n\n if (relationshipKind === 'hasMany') {\n const relData = (relationshipData as { type: string; id: string }[]) || [];\n if (relationshipData) {\n assert('expected the relationship data to be an array', Array.isArray(relationshipData));\n // these arrays could be massive so this is better than filter\n // Note: this is potentially problematic if type/id are not in the\n // same state of normalization.\n const found = relationshipData.find((v) => {\n return v.type === parentRelationshipData.type && v.id === parentRelationshipData.id;\n });\n if (!found) {\n relData.push(parentRelationshipData);\n }\n } else {\n relData.push(parentRelationshipData);\n }\n payload = relData;\n } else {\n const relData = (relationshipData as { type: string; id: string }) || {};\n Object.assign(relData, parentRelationshipData);\n payload = relData;\n }\n\n return payload;\n}\n\nfunction validateRelationshipEntry({ id }: ResourceIdentity, { id: parentModelID }: ResourceIdentity): boolean {\n return !!id && id.toString() === parentModelID;\n}\n","import type { Store, StoreRequestContext } from '@warp-drive/core';\nimport { LOG_REQUESTS } from '@warp-drive/core/build-config/debugging';\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { Future, Handler, NextFn } from '@warp-drive/core/request';\nimport { waitFor } from '@warp-drive/core/signals/-leaked';\nimport { assertPrivateStore, type LegacyQueryArray } from '@warp-drive/core/store/-private';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { ImmutableRequestInfo, StructuredDataDocument } from '@warp-drive/core/types/request';\nimport type { LegacyRelationshipField as RelationshipSchema } from '@warp-drive/core/types/schema/fields';\nimport type { SingleResourceDataDocument } from '@warp-drive/core/types/spec/document';\nimport type { ApiError } from '@warp-drive/core/types/spec/error';\nimport type {\n CollectionResourceDocument,\n JsonApiDocument,\n Links,\n PaginationLinks,\n SingleResourceDocument,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../-private.ts';\nimport { FetchManager, SaveOp } from './fetch-manager.ts';\nimport { assertIdentifierHasId } from './identifier-has-id.ts';\nimport { _findBelongsTo, _findHasMany } from './legacy-data-fetch.ts';\nimport { payloadIsNotBlank } from './legacy-data-utils.ts';\nimport type { MinimumAdapterInterface } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface } from './minimum-serializer-interface.ts';\nimport { normalizeResponseHelper } from './serializer-response.ts';\nimport { SnapshotRecordArray } from './snapshot-record-array.ts';\nimport type { Snapshot } from './snapshot.ts';\n\ntype AdapterErrors = Error & { errors?: unknown[]; isAdapterError?: true; code?: string };\ntype SerializerWithParseErrors = MinimumSerializerInterface & {\n extractErrors?(store: Store, modelClass: ModelSchema, error: AdapterErrors, recordId: string | null): unknown;\n};\n\nconst PotentialLegacyOperations = new Set([\n 'findRecord',\n 'findAll',\n 'query',\n 'queryRecord',\n 'findBelongsTo',\n 'findHasMany',\n 'updateRecord',\n 'createRecord',\n 'deleteRecord',\n]);\n\n/**\n * A {@link Handler} that fulfills legacy `findRecord`/`findAll`/`query`/\n * `queryRecord`/`findBelongsTo`/`findHasMany`/`createRecord`/`updateRecord`/\n * `deleteRecord` requests using the store's configured {@link MinimumAdapterInterface | adapter}\n * and {@link MinimumSerializerInterface | serializer}, passing any other\n * request through to the next handler unchanged.\n *\n * @summary Legacy `RequestManager` handler that fulfills find, query, create, update, and delete operations through\n * the store's adapters and serializers, passing other requests along.\n */\nexport const LegacyNetworkHandler: Handler = {\n request<T>(context: StoreRequestContext, next: NextFn<T>): Future<T> | Promise<StructuredDataDocument<T>> {\n // if we are not a legacy request, move on\n if (context.request.url || !context.request.op || !PotentialLegacyOperations.has(context.request.op)) {\n return next(context.request);\n }\n\n const { store } = context.request;\n upgradeStore(store);\n if (!store._fetchManager) {\n store._fetchManager = new FetchManager(store);\n }\n\n switch (context.request.op) {\n case 'findRecord':\n return findRecord(context);\n case 'findAll':\n return findAll(context);\n case 'query':\n return query(context);\n case 'queryRecord':\n return queryRecord(context);\n case 'findBelongsTo':\n return findBelongsTo(context);\n case 'findHasMany':\n return findHasMany(context);\n case 'updateRecord':\n return saveRecord(context);\n case 'createRecord':\n return saveRecord(context);\n case 'deleteRecord':\n return saveRecord(context);\n default:\n return next(context.request);\n }\n },\n};\n\nfunction findBelongsTo<T>(context: StoreRequestContext): Promise<T> {\n const { store, data, records: identifiers } = context.request;\n const { options, record, links, useLink, field } = data as {\n record: ResourceKey;\n options: Record<string, unknown>;\n links?: Links;\n useLink: boolean;\n field: RelationshipSchema;\n };\n const identifier = identifiers?.[0];\n upgradeStore(store);\n\n // short circuit if we are already loading\n const pendingRequest = identifier && store._fetchManager.getPendingFetch(identifier as PersistedResourceKey, options);\n if (pendingRequest) {\n return pendingRequest as Promise<T>;\n }\n\n if (useLink) {\n assert(`Expected a related link when calling store.findBelongsTo, found ${String(links)}`, links && links.related);\n return _findBelongsTo(store, record, links.related, field, options) as Promise<T>;\n }\n\n assert(`Expected an identifier`, Array.isArray(identifiers) && identifiers.length === 1);\n\n const manager = store._fetchManager;\n assertIdentifierHasId(identifier);\n\n return options.reload\n ? (manager.scheduleFetch(identifier, options, context.request) as Promise<T>)\n : (manager.fetchDataIfNeededForIdentifier(identifier, options, context.request) as Promise<T>);\n}\n\nfunction findHasMany<T>(context: StoreRequestContext): Promise<T> {\n const { store, data, records: identifiers } = context.request;\n const { options, record, links, useLink, field } = data as {\n record: ResourceKey;\n options: Record<string, unknown>;\n links?: PaginationLinks | Links;\n useLink: boolean;\n field: RelationshipSchema;\n };\n upgradeStore(store);\n\n // link case\n if (useLink) {\n const adapter = store.adapterFor(record.type);\n /*\n If a relationship was originally populated by the adapter as a link\n (as opposed to a list of IDs), this method is called when the\n relationship is fetched.\n\n The link (which is usually a URL) is passed through unchanged, so the\n adapter can make whatever request it wants.\n\n The usual use-case is for the server to register a URL as a link, and\n then use that URL in the future to make a request for the relationship.\n */\n assert(`You tried to load a hasMany relationship but you have no adapter (for ${record.type})`, adapter);\n assert(\n `You tried to load a hasMany relationship from a specified 'link' in the original payload but your adapter does not implement 'findHasMany'`,\n typeof adapter.findHasMany === 'function'\n );\n assert(`Expected a related link when calling store.findHasMany, found ${String(links)}`, links && links.related);\n\n return _findHasMany(adapter, store, record, links.related, field, options) as Promise<T>;\n }\n\n // identifiers case\n assert(`Expected an array of identifiers to fetch`, Array.isArray(identifiers));\n const fetches = new Array<globalThis.Promise<ResourceKey>>(identifiers.length);\n const manager = store._fetchManager;\n\n for (let i = 0; i < identifiers.length; i++) {\n const identifier = identifiers[i];\n // TODO we probably can be lenient here and return from cache for the isNew case\n assertIdentifierHasId(identifier);\n fetches[i] = options.reload\n ? manager.scheduleFetch(identifier, options, context.request)\n : manager.fetchDataIfNeededForIdentifier(identifier, options, context.request);\n }\n\n return Promise.all(fetches) as Promise<T>;\n}\n\nfunction saveRecord<T>(context: StoreRequestContext): Promise<T> {\n const { store, data, op: operation } = context.request;\n const { options, record: identifier } = data as { record: ResourceKey; options: Record<string, unknown> };\n\n upgradeStore(store);\n assertPrivateStore(store);\n\n store.cache.willCommit(identifier, context);\n\n const saveOptions = Object.assign(\n { [SaveOp]: operation as 'updateRecord' | 'deleteRecord' | 'createRecord' },\n options\n );\n const fetchManagerPromise = store._fetchManager.scheduleSave(identifier, saveOptions);\n\n return fetchManagerPromise\n .then((payload) => {\n let result: SingleResourceDataDocument;\n store._join(() => {\n // @ts-expect-error we don't have access to a response in legacy\n result = store.cache.didCommit(identifier, { request: context.request, content: payload });\n });\n\n // blatantly lie if we were a createRecord request\n // to give some semblance of cache-control to the\n // CachePolicy while legacy is still around\n if (store.lifetimes?.didRequest && operation === 'createRecord') {\n store.lifetimes.didRequest(context.request, { status: 201 } as Response, null, store);\n }\n return store.peekRecord(result!.data!);\n })\n .catch((e: unknown) => {\n let err = e;\n if (!e) {\n err = new Error(`Unknown Error Occurred During Request`);\n } else if (typeof e === 'string') {\n err = new Error(e);\n }\n adapterDidInvalidate(store, identifier, err as Error);\n throw err;\n }) as Promise<T>;\n}\n\nfunction adapterDidInvalidate(\n store: Store,\n identifier: ResourceKey,\n error: Error & { errors?: ApiError[]; isAdapterError?: true; code?: string }\n) {\n upgradeStore(store);\n if (error && error.isAdapterError === true && error.code === 'InvalidError') {\n const serializer = store.serializerFor(identifier.type) as SerializerWithParseErrors;\n\n // TODO @deprecate extractErrors being called\n // TODO remove extractErrors from the default serializers.\n if (serializer && typeof serializer.extractErrors === 'function') {\n const errorsHash = serializer.extractErrors(\n store,\n store.modelFor(identifier.type),\n error,\n identifier.id\n ) as Record<string, string | string[]>;\n error.errors = errorsHashToArray(errorsHash);\n }\n }\n const cache = store.cache;\n\n if (error.errors) {\n assert(\n `Expected the cache in use by resource ${String(\n identifier\n )} to have a getErrors(identifier) method for retrieving errors.`,\n typeof cache.getErrors === 'function'\n );\n\n let jsonApiErrors: ApiError[] = error.errors;\n if (jsonApiErrors.length === 0) {\n jsonApiErrors = [{ title: 'Invalid Error', detail: '', source: { pointer: '/data' } }];\n }\n cache.commitWasRejected(identifier, jsonApiErrors);\n } else {\n cache.commitWasRejected(identifier);\n }\n}\n\nfunction makeArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\nconst PRIMARY_ATTRIBUTE_KEY = 'base';\nfunction errorsHashToArray(errors: Record<string, string | string[]>): ApiError[] {\n const out: ApiError[] = [];\n\n if (errors) {\n Object.keys(errors).forEach((key) => {\n const messages = makeArray(errors[key]);\n for (let i = 0; i < messages.length; i++) {\n let title = 'Invalid Attribute';\n let pointer = `/data/attributes/${key}`;\n if (key === PRIMARY_ATTRIBUTE_KEY) {\n title = 'Invalid Document';\n pointer = `/data`;\n }\n out.push({\n title: title,\n detail: messages[i],\n source: {\n pointer: pointer,\n },\n });\n }\n });\n }\n\n return out;\n}\n\nfunction findRecord<T>(context: StoreRequestContext): Promise<T> {\n const { store, data } = context.request;\n const { record: identifier, options } = data as {\n record: PersistedResourceKey;\n options: { reload?: boolean; backgroundReload?: boolean };\n };\n upgradeStore(store);\n assertPrivateStore(store);\n let promise: Promise<ResourceKey>;\n\n // if not loaded start loading\n if (!store._instanceCache.recordIsLoaded(identifier)) {\n promise = store._fetchManager.fetchDataIfNeededForIdentifier(identifier, options, context.request);\n\n // Refetch if the reload option is passed\n } else if (options.reload) {\n assertIdentifierHasId(identifier);\n\n promise = store._fetchManager.scheduleFetch(identifier, options, context.request);\n } else {\n let snapshot: Snapshot | null = null;\n const adapter = store.adapterFor(identifier.type);\n\n // Refetch the record if the adapter thinks the record is stale\n if (\n typeof options.reload === 'undefined' &&\n adapter.shouldReloadRecord &&\n adapter.shouldReloadRecord(store, (snapshot = store._fetchManager.createSnapshot(identifier, options)))\n ) {\n assertIdentifierHasId(identifier);\n if (DEBUG) {\n promise = store._fetchManager.scheduleFetch(\n identifier,\n Object.assign({}, options, { reload: true }),\n context.request\n );\n } else {\n options.reload = true;\n promise = store._fetchManager.scheduleFetch(identifier, options, context.request);\n }\n } else {\n // Trigger the background refetch if backgroundReload option is passed\n if (\n options.backgroundReload !== false &&\n (options.backgroundReload ||\n !adapter.shouldBackgroundReloadRecord ||\n adapter.shouldBackgroundReloadRecord(\n store,\n snapshot || store._fetchManager.createSnapshot(identifier, options)\n ))\n ) {\n assertIdentifierHasId(identifier);\n\n if (DEBUG) {\n void store._fetchManager.scheduleFetch(\n identifier,\n Object.assign({}, options, { backgroundReload: true }),\n context.request\n );\n } else {\n options.backgroundReload = true;\n void store._fetchManager.scheduleFetch(identifier, options, context.request);\n }\n }\n\n // Return the cached record\n promise = Promise.resolve(identifier);\n }\n }\n\n return promise.then((i: ResourceKey) => store.peekRecord(i)) as Promise<T>;\n}\n\nfunction findAll<T>(context: StoreRequestContext): Promise<T> {\n const { store, data } = context.request;\n const { type, options } = data as {\n type: string;\n options: { reload?: boolean; backgroundReload?: boolean };\n };\n upgradeStore(store);\n assertPrivateStore(store);\n const adapter = store.adapterFor(type);\n\n assert(`You tried to load all records but you have no adapter (for ${type})`, adapter);\n assert(\n `You tried to load all records but your adapter does not implement 'findAll'`,\n typeof adapter.findAll === 'function'\n );\n\n // avoid initializing the liveArray just to set `isUpdating`\n const maybeRecordArray = store.recordArrayManager._live.get(type);\n const snapshotArray = new SnapshotRecordArray(store, type, options);\n\n const shouldReload =\n options.reload ||\n (options.reload !== false &&\n ((adapter.shouldReloadAll && adapter.shouldReloadAll(store, snapshotArray)) ||\n (!adapter.shouldReloadAll && snapshotArray.length === 0)));\n\n let fetch: Promise<T> | undefined;\n if (shouldReload) {\n // oxlint-disable-next-line no-unused-expressions\n maybeRecordArray && (maybeRecordArray.isUpdating = true);\n fetch = _findAll(adapter, store, type, snapshotArray, context.request, true);\n } else {\n fetch = Promise.resolve(store.peekAll(type)) as Promise<T>;\n\n if (\n options.backgroundReload ||\n (options.backgroundReload !== false &&\n (!adapter.shouldBackgroundReloadAll || adapter.shouldBackgroundReloadAll(store, snapshotArray)))\n ) {\n // oxlint-disable-next-line no-unused-expressions\n maybeRecordArray && (maybeRecordArray.isUpdating = true);\n void _findAll(adapter, store, type, snapshotArray, context.request, false);\n }\n }\n\n return fetch;\n}\n\nfunction _findAll<T>(\n adapter: MinimumAdapterInterface,\n store: Store,\n type: string,\n snapshotArray: SnapshotRecordArray,\n request: ImmutableRequestInfo,\n isAsyncFlush: boolean\n): Promise<T> {\n const schema = store.modelFor(type);\n let promise: Promise<T> = Promise.resolve().then(() =>\n adapter.findAll(store, schema, null, snapshotArray)\n ) as Promise<T>;\n\n promise = promise.then((adapterPayload: T) => {\n assert(\n `You made a 'findAll' request for '${type}' records, but the adapter's response did not have any data`,\n payloadIsNotBlank(adapterPayload)\n );\n upgradeStore(store);\n const serializer = store.serializerFor(type);\n const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'findAll');\n\n store._push(payload, isAsyncFlush);\n snapshotArray._recordArray.isUpdating = false;\n\n if (LOG_REQUESTS) {\n // oxlint-disable-next-line no-console\n console.log(`request: findAll<${type}> background reload complete`);\n }\n return snapshotArray._recordArray;\n }) as Promise<T>;\n\n if (TESTING) {\n if (!request.disableTestWaiter) {\n promise = waitFor(promise);\n }\n }\n\n return promise;\n}\n\nfunction query<T>(context: StoreRequestContext): Promise<T> {\n const { store, data } = context.request;\n upgradeStore(store);\n assertPrivateStore(store);\n let { options } = data as {\n options: { _recordArray?: LegacyQueryArray; adapterOptions?: Record<string, unknown> };\n };\n // oxlint-disable-next-line no-shadow\n const { type, query } = data as {\n type: string;\n query: Record<string, unknown>;\n options: { _recordArray?: LegacyQueryArray; adapterOptions?: Record<string, unknown> };\n };\n const adapter = store.adapterFor(type);\n\n assert(`You tried to make a query but you have no adapter (for ${type})`, adapter);\n assert(`You tried to make a query but your adapter does not implement 'query'`, typeof adapter.query === 'function');\n\n const recordArray =\n options._recordArray ||\n store.recordArrayManager.getCollection({\n type,\n query,\n });\n\n if (DEBUG) {\n options = Object.assign({}, options);\n delete options._recordArray;\n } else {\n delete options._recordArray;\n }\n const schema = store.modelFor(type);\n const promise = Promise.resolve().then(() => adapter.query(store, schema, query, recordArray, options));\n\n return promise.then((adapterPayload) => {\n const serializer = store.serializerFor(type);\n const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'query');\n const identifiers = store._push(payload, true);\n\n assert(\n '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.',\n Array.isArray(identifiers)\n );\n\n store.recordArrayManager.populateManagedArray(recordArray, identifiers, payload as CollectionResourceDocument);\n\n return recordArray;\n }) as Promise<T>;\n}\n\nfunction assertSingleResourceDocument(payload: JsonApiDocument): asserts payload is SingleResourceDocument {\n assert(\n `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.`,\n !Array.isArray(payload.data)\n );\n}\n\nfunction queryRecord<T>(context: StoreRequestContext): Promise<T> {\n const { store, data } = context.request;\n // oxlint-disable-next-line no-shadow\n const { type, query, options } = data as { type: string; query: Record<string, unknown>; options: object };\n upgradeStore(store);\n const adapter = store.adapterFor(type);\n\n assert(`You tried to make a query but you have no adapter (for ${type})`, adapter);\n assert(\n `You tried to make a query but your adapter does not implement 'queryRecord'`,\n typeof adapter.queryRecord === 'function'\n );\n\n const schema = store.modelFor(type);\n const promise = Promise.resolve().then(() => adapter.queryRecord(store, schema, query, options)) as Promise<T>;\n\n return promise.then((adapterPayload: T) => {\n const serializer = store.serializerFor(type);\n const payload = normalizeResponseHelper(\n serializer,\n store,\n schema,\n adapterPayload as Record<string, unknown>,\n null,\n 'queryRecord'\n );\n\n assertSingleResourceDocument(payload);\n\n const identifier = store._push(payload, true) as ResourceKey;\n return identifier ? store.peekRecord(identifier) : null;\n }) as Promise<T>;\n}\n","/**\n * Helps an app migrate incrementally from legacy EmberData patterns to modern ***Warp*Drive**.\n *\n * ## Why it exists\n *\n * While migrating, you may need to:\n *\n * - keep Adapters and Serializers working on a Store whose requests go through the\n * {@link RequestManager}\n * - keep the deprecated request methods such as `store.findRecord` and `store.query`, which\n * Adapters fulfill, working while you move calls to `store.request`\n * - adopt modern patterns one piece at a time rather than all at once\n *\n * ## What it provides\n *\n * - {@link LegacyNetworkHandler}, a request handler that fulfills those legacy requests through\n * the store's Adapters and Serializers and passes every other request along\n * - {@link adapterFor}, {@link serializerFor}, {@link normalize}, {@link pushPayload} and\n * {@link serializeRecord}, the store methods for working with Adapters and Serializers, and\n * {@link LegacyStoreCompat}, the Store type that includes them\n *\n * The Store that [useLegacyStore](/api/@warp-drive/legacy/functions/useLegacyStore) produces\n * adds `LegacyNetworkHandler` to its RequestManager unless `linksMode` is `true`. The hooks\n * that present `Model` instances live in [@warp-drive/legacy/model](/api/@warp-drive/legacy/model/),\n * not here.\n *\n * ## When to use it\n *\n * Only during a migration from legacy EmberData to modern ***Warp*Drive**. It lets you adopt\n * modern patterns incrementally while your existing Adapters and Serializers keep working. For\n * incremental migration strategies, see the [Migration Guide](/upgrading/v5/) and the\n * [Two Store Migration Strategy](/upgrading/v5/two-store-migration).\n *\n * @module\n * @summary Legacy store support for adapters and serializers: the `LegacyNetworkHandler` plus store methods such as\n * `adapterFor`, `serializerFor`, `normalize` and `pushPayload`.\n */\n\nimport { getOwner } from '@ember/application';\n\n// RequestManager is imported only so the @module comment can {@link} it.\n// oxlint-disable-next-line no-unused-vars\nimport { recordIdentifierFor, type RequestManager, type Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { _deprecatingNormalize } from '@warp-drive/core/store/-private';\nimport type { ObjectValue } from '@warp-drive/core/types/json/raw';\nimport type { SingleResourceDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { FetchManager, upgradeStore } from './compat/-private.ts';\nimport type {\n AdapterPayload,\n MinimumAdapterInterface,\n} from './compat/legacy-network-handler/minimum-adapter-interface.ts';\nimport type {\n MinimumSerializerInterface,\n SerializerOptions,\n} from './compat/legacy-network-handler/minimum-serializer-interface.ts';\n\nexport { LegacyNetworkHandler } from './compat/legacy-network-handler/legacy-network-handler.ts';\n\nexport type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };\n\n/**\n * Extends the signature of {@link Store} with additional\n * methods available when using the legacy network layer.\n *\n * @summary Legacy `Store` type extended with `adapterFor`, `serializerFor`, `normalize`, `pushPayload`, and\n * `serializeRecord` from the adapter and serializer network layer.\n * @public\n * @noInheritDoc\n * @legacy\n */\nexport interface LegacyStoreCompat extends Store {\n /**\n * @private\n */\n _fetchManager: FetchManager;\n\n /**\n * Returns the adapter instance for the given model type, instantiating\n * it (and caching the instance) if necessary. See {@link adapterFor}.\n */\n adapterFor(this: Store, modelName: string): MinimumAdapterInterface;\n /**\n * Same as the single-argument overload, but returns `undefined` instead\n * of throwing/asserting when `_allowMissing` is `true` and no adapter\n * is found.\n */\n adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;\n\n /**\n * Returns the serializer instance for the given model type, instantiating\n * it (and caching the instance) if necessary. See {@link serializerFor}.\n */\n serializerFor<K extends string>(modelName: K, _allowMissing?: boolean): MinimumSerializerInterface | null;\n\n /**\n * Normalizes a payload for the given model type using its serializer.\n * See {@link normalize}.\n */\n normalize(modelName: string, payload: ObjectValue): ObjectValue;\n\n /**\n * Pushes a payload into the store using the appropriate serializer to\n * normalize it first. See {@link pushPayload}.\n */\n pushPayload(modelName: string, payload: ObjectValue): void;\n\n /**\n * Serializes a record using its serializer. See {@link serializeRecord}.\n */\n serializeRecord(record: unknown, options?: SerializerOptions): unknown;\n\n /**\n * @private\n */\n _adapterCache: Record<string, MinimumAdapterInterface & { store: Store }>;\n /**\n * @private\n */\n _serializerCache: Record<string, MinimumSerializerInterface & { store: Store }>;\n}\n\n/**\n * @summary Deprecated alias of `LegacyStoreCompat`, the `Store` type extended with legacy adapter and serializer\n * methods.\n * @deprecated - use {@link LegacyStoreCompat} instead\n */\nexport type CompatStore = LegacyStoreCompat;\n\n/**\n Returns an instance of the adapter for a given type. For\n example, `adapterFor('person')` will return an instance of\n the adapter located at `app/adapters/person.js`\n\n If no `person` adapter is found, this method will look\n for an `application` adapter (the default adapter for\n your entire application).\n\n @summary Legacy store method that returns the cached adapter for a model type, falling back to the `application`\n adapter.\n @public\n @param modelName\n*/\nexport function adapterFor(this: Store, modelName: string): MinimumAdapterInterface;\nexport function adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;\nexport function adapterFor(this: Store, modelName: string, _allowMissing?: true): MinimumAdapterInterface | undefined {\n assert(\n `Attempted to call store.adapterFor(), but the store instance has already been destroyed.`,\n !(this.isDestroying || this.isDestroyed)\n );\n assert(`You need to pass a model name to the store's adapterFor method`, modelName);\n assert(\n `Passing classes to store.adapterFor has been removed. Please pass a dasherized string instead of ${modelName}`,\n typeof modelName === 'string'\n );\n upgradeStore(this);\n this._adapterCache =\n this._adapterCache || (Object.create(null) as Record<string, MinimumAdapterInterface & { store: Store }>);\n\n const normalizedModelName = _deprecatingNormalize(modelName);\n\n const { _adapterCache } = this;\n let adapter: (MinimumAdapterInterface & { store: Store }) | undefined = _adapterCache[normalizedModelName];\n if (adapter) {\n return adapter;\n }\n\n const owner = getOwner(this)!;\n\n // name specific adapter\n adapter = owner.lookup(`adapter:${normalizedModelName}`) as (MinimumAdapterInterface & { store: Store }) | undefined;\n if (adapter !== undefined) {\n _adapterCache[normalizedModelName] = adapter;\n return adapter;\n }\n\n // no adapter found for the specific name, fallback and check for application adapter\n adapter = _adapterCache.application || owner.lookup('adapter:application');\n if (adapter !== undefined) {\n _adapterCache[normalizedModelName] = adapter;\n _adapterCache.application = adapter;\n return adapter;\n }\n\n assert(\n `No adapter was found for '${modelName}' and no 'application' adapter was found as a fallback.`,\n _allowMissing\n );\n}\n\n/**\n Returns an instance of the serializer for a given type. For\n example, `serializerFor('person')` will return an instance of\n `App.PersonSerializer`.\n\n If no `App.PersonSerializer` is found, this method will look\n for an `App.ApplicationSerializer` (the default serializer for\n your entire application).\n\n If a serializer cannot be found on the adapter, it will fall back\n to an instance of `JSONSerializer`.\n\n @summary Legacy store method that returns the cached serializer for a model type, falling back to the\n `application` serializer, or `null` if neither exists.\n @public\n @param modelName the record to serialize\n */\nexport function serializerFor(this: Store, modelName: string): MinimumSerializerInterface | null {\n assert(\n `Attempted to call store.serializerFor(), but the store instance has already been destroyed.`,\n !(this.isDestroying || this.isDestroyed)\n );\n assert(`You need to pass a model name to the store's serializerFor method`, modelName);\n assert(\n `Passing classes to store.serializerFor has been removed. Please pass a dasherized string instead of ${modelName}`,\n typeof modelName === 'string'\n );\n upgradeStore(this);\n this._serializerCache =\n this._serializerCache || (Object.create(null) as Record<string, MinimumSerializerInterface & { store: Store }>);\n const normalizedModelName = _deprecatingNormalize(modelName);\n\n const { _serializerCache } = this;\n let serializer: (MinimumSerializerInterface & { store: Store }) | undefined = _serializerCache[normalizedModelName];\n if (serializer) {\n return serializer;\n }\n\n // by name\n const owner = getOwner(this)!;\n serializer = owner.lookup(`serializer:${normalizedModelName}`) as\n | (MinimumSerializerInterface & { store: Store })\n | undefined;\n if (serializer !== undefined) {\n _serializerCache[normalizedModelName] = serializer;\n return serializer;\n }\n\n // no serializer found for the specific model, fallback and check for application serializer\n serializer = _serializerCache.application || owner.lookup('serializer:application');\n if (serializer !== undefined) {\n _serializerCache[normalizedModelName] = serializer;\n _serializerCache.application = serializer;\n return serializer;\n }\n\n return null;\n}\n\n/**\n `normalize` converts a json payload into the normalized form expected by\n {@link Store.push | push} using the serializer specified by `modelName`\n\n :::warning\n Generally it would be better to invoke the serializer yourself directly,\n or write a more specialized normalization utility.\n :::\n\n Example\n\n ```js\n socket.on('message', function(message) {\n let modelName = message.model;\n let data = message.data;\n store.push(store.normalize(modelName, data));\n });\n ```\n\n @summary Legacy store method that converts a raw payload into the normalized document `store.push` expects, using\n the serializer for the given model type.\n @legacy\n @public\n @param modelName The name of the model type for this payload\n @return The normalized payload\n*/\n// TODO @runspired @deprecate users should call normalize on the associated serializer directly\nexport function normalize(this: Store, modelName: string, payload: ObjectValue): SingleResourceDocument {\n upgradeStore(this);\n assert(\n `Attempted to call store.normalize(), but the store instance has already been destroyed.`,\n !(this.isDestroying || this.isDestroyed)\n );\n assert(`You need to pass a model name to the store's normalize method`, modelName);\n assert(\n `Passing classes to store methods has been removed. Please pass a dasherized string instead of ${typeof modelName}`,\n typeof modelName === 'string'\n );\n const normalizedModelName = _deprecatingNormalize(modelName);\n const serializer = this.serializerFor(normalizedModelName);\n const schema = this.modelFor(normalizedModelName);\n assert(\n `You must define a normalize method in your serializer in order to call store.normalize`,\n typeof serializer?.normalize === 'function'\n );\n return serializer.normalize(schema, payload);\n}\n\n/**\n Push some raw data into the store.\n\n This method can be used both to push in brand new\n records, as well as to update existing records. You\n can push in more than one type of object at once.\n All objects should be in the format expected by the\n serializer.\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@warp-drive/legacy/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer;\n ```\n\n ```js\n let pushData = {\n posts: [\n { id: 1, postTitle: \"Great post\", commentIds: [2] }\n ],\n comments: [\n { id: 2, commentBody: \"Insightful comment\" }\n ]\n }\n\n store.pushPayload(pushData);\n ```\n\n By default, the data will be deserialized using a default\n serializer (the application serializer if it exists).\n\n Alternatively, `pushPayload` will accept a model type which\n will determine which serializer will process the payload.\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@warp-drive/legacy/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer;\n ```\n\n ```js [app/serializers/post.js]\n import JSONSerializer from '@warp-drive/legacy/serializer/json';\n\n export default JSONSerializer;\n ```\n\n ```js\n store.pushPayload(pushData); // Will use the application serializer\n store.pushPayload('post', pushData); // Will use the post serializer\n ```\n\n @summary Legacy store method that pushes a raw payload into the store after the application serializer, or the\n given model type's serializer, normalizes it.\n @public\n @param modelName Optionally, a model type used to determine which serializer will be used\n @param inputPayload\n */\n// TODO @runspired @deprecate pushPayload in favor of looking up the serializer\nexport function pushPayload(this: Store, modelName: string, inputPayload: ObjectValue): void {\n upgradeStore(this);\n assert(\n `Attempted to call store.pushPayload(), but the store instance has already been destroyed.`,\n !(this.isDestroying || this.isDestroyed)\n );\n\n const payload: ObjectValue = inputPayload || (modelName as unknown as ObjectValue);\n const normalizedModelName = inputPayload ? _deprecatingNormalize(modelName) : 'application';\n const serializer = this.serializerFor(normalizedModelName);\n\n assert(\n `You cannot use 'store.pushPayload(<type>, <payload>)' unless the serializer for '${normalizedModelName}' defines 'pushPayload'`,\n serializer && typeof serializer.pushPayload === 'function'\n );\n serializer.pushPayload(this, payload);\n}\n\n/**\n * Serializes a record using the store's legacy network layer, as with\n * {@link LegacyStoreCompat.serializeRecord | store.serializeRecord}.\n *\n * @summary Legacy store method that serializes a record into a payload using its model type's serializer.\n */\n// TODO @runspired @deprecate records should implement their own serialization if desired\nexport function serializeRecord(this: Store, record: unknown, options?: SerializerOptions): unknown {\n upgradeStore(this);\n // TODO we used to check if the record was destroyed here\n if (!this._fetchManager) {\n this._fetchManager = new FetchManager(this);\n }\n\n return this._fetchManager.createSnapshot(recordIdentifierFor(record)).serialize(options);\n}\n\n/**\n * Destroys any adapters/serializers the legacy network layer has created\n * for this store, invoked when the store itself is destroyed.\n *\n * @summary Legacy store teardown hook that destroys every adapter and serializer instance the store has cached.\n */\nexport function cleanup(this: Store): void {\n upgradeStore(this);\n // enqueue destruction of any adapters/serializers we have created\n for (const adapterName in this._adapterCache) {\n const adapter = this._adapterCache[adapterName];\n if (typeof adapter.destroy === 'function') {\n adapter.destroy();\n }\n }\n\n for (const serializerName in this._serializerCache) {\n const serializer = this._serializerCache[serializerName];\n if (typeof serializer.destroy === 'function') {\n serializer.destroy();\n }\n }\n}\n"],"mappings":";;;;;;AAIA,SAAgB,YAAe,MAAe,IAA4B;CACxE,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,KAAK,IAAI,EAAE;MAElB,OAAO,GAAG,MAAM,CAAC;AAErB;;;;ACGA,SAAgBI,aACdC,SACAC,OACAC,YACAC,MACAC,cACAC,SACiC;CACjCV,6BAAaM,KAAK;CAgBlB,OAfgBM,Q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A4DA,SAAgBG,YAAyBlB,WAAmBmB,cAAiC;CAC3FtB,6BAAa,IAAI;CAMjB,MAAMkB,UAAuBI,gBAAiBnB;CAC9C,MAAMK,sBAAsBc,eAAexB,sBAAsBK,SAAS,IAAI;CAO9Ea,AANmB,KAAKF,cAAcN,mBAMtCQ,CAAU,CAACK,YAAY,MAAMH,OAAO;AACtC;;;;;;;AASA,SAAgBK,gBAA6BC,QAAiBC,SAAsC;CAClGzB,6BAAa,IAAI;CAEjB,IAAI,CAAC,KAAK0B,eACR,KAAKA,gBAAgB,IAAI3B,aAAa,IAAI;CAG5C,OAAO,KAAK2B,cAAcC,eAAe9B,oBAAoB2B,MAAM,CAAC,CAAC,CAACI,UAAUH,OAAO;AACzF;;;;;;;AAQA,SAAgBI,UAA2B;CACzC7B,6BAAa,IAAI;CAEjB,KAAK,MAAM8B,eAAe,KAAKzB,eAAe;EAC5C,MAAMI,UAAU,KAAKJ,cAAcyB;EACnC,IAAI,OAAOrB,QAAQsB,YAAY,YAC7BtB,QAAQsB,QAAQ;CAEpB;CAEA,KAAK,MAAMC,kBAAkB,KAAKjB,kBAAkB;EAClD,MAAMC,aAAa,KAAKD,iBAAiBiB;EACzC,IAAI,OAAOhB,WAAWe,YAAY,YAChCf,WAAWe,QAAQ;CAEvB;AACF"}
@@ -1,3 +1,3 @@
1
- import { a as serializeRecord, i as pushPayload, n as cleanup, o as serializerFor, r as normalize, s as LegacyNetworkHandler, t as adapterFor } from "./compat-BM3u_d5-.js";
1
+ import { a as serializeRecord, i as pushPayload, n as cleanup, o as serializerFor, r as normalize, s as LegacyNetworkHandler, t as adapterFor } from "./compat-DFMtpQGs.js";
2
2
 
3
3
  export { LegacyNetworkHandler, adapterFor, cleanup, normalize, pushPayload, serializeRecord, serializerFor };
@@ -62,6 +62,8 @@ In your JS code you should resolve the promise first.
62
62
  const comments = await post.comments;
63
63
  ```
64
64
 
65
+ @summary Legacy promise-like, iterable proxy returned by an async `hasMany` on a `Model`, which templates can
66
+ consume while the related records load.
65
67
  @public
66
68
  */
67
69
  var PromiseManyArray = class {
@@ -1982,4 +1984,4 @@ var Errors = class extends ArrayProxyWithCustomOverrides {
1982
1984
 
1983
1985
  //#endregion
1984
1986
  export { PromiseManyArray as a, releaseLegacySupport as i, LEGACY_SUPPORT as n, PromiseBelongsTo as o, lookupLegacySupport as r, Errors as t };
1985
- //# sourceMappingURL=errors-BX8zhQS4.js.map
1987
+ //# sourceMappingURL=errors-DIOUcGAT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-DIOUcGAT.js","names":["computed","memoized","PromiseObject","n","LegacyPromiseProxy","Symbol","for","Extended","PromiseBelongsTo","id","key","legacySupport","_belongsToState","ref","referenceFor","prototype","meta","reload","options","reloadBelongsTo","defineSignal","memoized","LegacyPromiseProxy","n","PromiseManyArray","constructor","promise","content","_update","isDestroyed","length","prototype","[]","forEach","cb","reload","options","then","success","rejected","catch","finally","destroy","links","undefined","meta","tapPromise","create","proxy","isPending","isSettled","isFulfilled","isRejected","Promise","resolve","error","defineNonEnumerableSignal","memoized","assertPrivateStore","assertPolymorphicType","areAllInverseRecordsLoaded","LEGACY_SUPPORT","n","isResourceIdentiferWithRelatedLinks","value","Boolean","links","related","HasManyReference","___token","___identifier","___relatedTokenMap","constructor","store","graph","parentIdentifier","hasManyRelationship","key","type","definition","notifications","subscribe","_","bucket","notifiedKey","_ref","Map","destroy","unsubscribe","forEach","token","clear","identifiers","ensureRefCanSubscribe","resource","_resource","map","data","resourceIdentifier","identifier","cacheKeyManager","getOrCreateRecordIdentifier","get","delete","set","prototype","cache","getRelationship","remoteType","ids","id","link","href","meta","push","doc","skipFetch","dataDoc","Array","isArray","isResourceData","length","isMaybeResource","_push","i","newData","_join","op","record","field","load","_isLoaded","hasRelationshipDataProperty","state","hasReceivedData","relationship","getData","every","_instanceCache","recordIsLoaded","support","getManyArray","options","fetchSyncRel","isAsync","reloadHasMany","getHasMany","reload","object","keys","Object","filter","k","rel","loaded","edge","accessed","isResourceIdentiferWithRelatedLinks","defineNonEnumerableSignal","memoized","assertPrivateStore","assertPolymorphicType","areAllInverseRecordsLoaded","LEGACY_SUPPORT","isMaybeResource","n","isResourceIdentiferWithRelatedLinks","value","Boolean","links","related","BelongsToReference","constructor","store","graph","parentIdentifier","belongsToRelationship","key","type","definition","___identifier","___relatedToken","___token","notifications","subscribe","_","bucket","notifiedKey","_ref","destroy","unsubscribe","identifier","resource","_resource","data","cacheKeyManager","getOrCreateRecordIdentifier","prototype","id","link","href","meta","cache","getRelationship","remoteType","push","doc","skipFetch","isResourceData","added","_push","newData","_join","op","record","field","load","peekRecord","options","support","get","fetchSyncRel","isAsync","reloadBelongsTo","then","getBelongsTo","reload","Context","notifyInternalSignal","assertPrivateStore","createLegacyManyArray","fastPush","isPrivateStore","isResourceKey","recordIdentifierFor","storeFor","getOrSetGlobal","EnableHydration","upgradeStore","PromiseBelongsTo","PromiseManyArray","BelongsToReference","HasManyReference","LEGACY_SUPPORT","Map","releaseLegacySupport","identifier","support","get","destroy","delete","lookupLegacySupport","record","LegacySupport","set","constructor","store","cache","_graph","graph","_manyArrayCache","Object","create","_relationshipPromisesCache","_relationshipProxyCache","_pending","references","_syncArray","array","isDestroyed","isDestroying","currentState","source","identifiers","jsonApi","_getCurrentState","key","meta","links","length","mutate","mutation","_findBelongsTo","resource","relationship","options","name","getRealFieldName","_findBelongsToByJsonApiResource","then","handleCompletedRelationshipRequest","e","reloadBelongsTo","loadingPromise","getRelationship","state","hasFailedLoadAttempt","shouldForceReload","promise","_updatePromiseProxyFor","getBelongsTo","relatedIdentifier","data","isAsync","definition","_belongsToState","legacySupport","modelName","type","isLoaded","_instanceCache","recordIsLoaded","content","getRecord","setDirtyBelongsTo","value","op","field","extractIdentifierFromRecord","i","push","getManyArray","manyArray","doc","getField","manager","editable","isPolymorphic","fetchAsyncHasMany","_findHasManyByJsonApiResource","Promise","resolve","reloadHasMany","getHasMany","kind","args","promiseProxy","_update","undefined","referenceFor","reference","relationshipKind","parentIdentifier","adapter","adapterFor","isStale","hasDematerializedInverse","hasReceivedData","isEmpty","allInverseRecordsAreLoaded","areAllInverseRecordsLoaded","shouldFindViaLink","related","findHasMany","schema","fields","inverseType","request","useLink","req","linksMode","url","getRelatedLink","method","records","cacheOptions","Symbol","for","preferLocalCache","hasLocalPartialData","Array","isArray","attemptLocalCache","hasData","reload","future","finally","localDataIsEmpty","resourceIsLocal","id","keys","forEach","proxy","href","recordExt","error","isHasMany","signal","notifications","_flush","peekRecord","anyUnloaded","relationshipData","getData","unloaded","find","s","instanceCache","every","isBelongsTo","context","cacheFields","sourceKey","A","ArrayProxy","computed","get","mapBy","not","n","g","i","ArrayProxyWithCustomOverrides","Errors","errorsByAttributeName","Map","prototype","errorsFor","attribute","map","errors","undefined","set","messages","content","unknownProperty","length","isEmpty","add","_findOrCreateMessages","addObjects","__record","currentState","notify","notifyPropertyChange","messagesArray","Array","isArray","_messages","message","err","findBy","remove","rejectBy","setObjects","replace","delete","clear","attributes","forEach","_","push","has","i"],"sources":["../../../src/model/-private/promise-proxy-base.js","../../../src/model/-private/promise-belongs-to.ts","../../../src/model/-private/promise-many-array.ts","../../../src/model/-private/references/has-many.ts","../../../src/model/-private/references/belongs-to.ts","../../../src/model/-private/legacy-relationships-support.ts","../../../src/model/-private/errors.ts"],"sourcesContent":["import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';\nimport ObjectProxy from '@ember/object/proxy';\n\nexport const PromiseObject = ObjectProxy.extend(PromiseProxyMixin);\n","import { computed } from '@ember/object';\nimport type PromiseProxyMixin from '@ember/object/promise-proxy-mixin';\nimport type ObjectProxy from '@ember/object/proxy';\n\nimport type { Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { memoized } from '@warp-drive/core/signals/-leaked';\nimport type { OpaqueRecordInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\n\nimport type { LegacySupport } from './legacy-relationships-support.ts';\nimport { PromiseObject } from './promise-proxy-base';\n\nexport interface BelongsToProxyMeta<T = unknown> {\n key: string;\n store: Store;\n legacySupport: LegacySupport;\n modelName: TypeFromInstanceOrString<T>;\n}\nexport interface BelongsToProxyCreateArgs<T = unknown> {\n promise: Promise<T | null>;\n content?: T | null;\n _belongsToState: BelongsToProxyMeta<T>;\n}\n\nexport const LegacyPromiseProxy: unique symbol = Symbol.for('LegacyPromiseProxy');\n\ninterface PromiseObjectType<T> extends PromiseProxyMixin<T | null>, ObjectProxy<T> {\n // oxlint-disable-next-line typescript/no-misused-new\n new <PT>(...args: unknown[]): PromiseObjectType<PT>;\n}\n// oxlint-disable-next-line no-unused-vars, typescript/no-extraneous-class\ndeclare class PromiseObjectType<T> {}\n\nconst Extended: PromiseObjectType<OpaqueRecordInstance> =\n PromiseObject as unknown as PromiseObjectType<OpaqueRecordInstance>;\n\n// oxlint-disable-next-line no-unused-vars\ninterface PromiseBelongsTo<T> {\n [LegacyPromiseProxy]: true;\n}\n\n/**\n A PromiseBelongsTo is a PromiseObject that also proxies certain method calls\n to the underlying belongsTo model.\n Right now we proxy:\n * `reload()`\n @class PromiseBelongsTo\n @private\n*/\nclass PromiseBelongsTo<T = unknown> extends Extended<T> {\n declare _belongsToState: BelongsToProxyMeta<T>;\n\n @memoized\n get id(): string | null {\n const { key, legacySupport } = this._belongsToState;\n const ref = legacySupport.referenceFor('belongsTo', key);\n\n return ref.id();\n }\n\n // we don't proxy meta because we would need to proxy it to the relationship state container\n // however, meta on relationships does not trigger change notifications.\n // if you need relationship meta, you should do `record.belongsTo(relationshipName).meta()`\n @computed()\n get meta(): void {\n // oxlint-disable-next-line no-constant-condition\n if (1) {\n assert(\n 'You attempted to access meta on the promise for the async belongsTo relationship ' +\n `${this._belongsToState.modelName}:${this._belongsToState.key}'.` +\n '\\nUse `record.belongsTo(relationshipName).meta()` instead.',\n false\n );\n }\n return;\n }\n\n async reload(options: Record<string, unknown>): Promise<this> {\n assert('You are trying to reload an async belongsTo before it has been created', this.content !== undefined);\n const { key, legacySupport } = this._belongsToState;\n await legacySupport.reloadBelongsTo(key, options);\n return this;\n }\n}\nPromiseBelongsTo.prototype[LegacyPromiseProxy] = true as const;\n\nexport { PromiseBelongsTo };\n","import { DEPRECATE_COMPUTED_CHAINS } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { defineSignal, memoized } from '@warp-drive/core/signals/-leaked';\nimport type { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions } from '@warp-drive/core/types';\nimport type { Links } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { LegacyPromiseProxy } from './promise-belongs-to.ts';\n\nexport interface HasManyProxyCreateArgs<T = unknown> {\n promise: Promise<ManyArray<T>>;\n content?: ManyArray<T>;\n}\n\n// oxlint-disable-next-line no-unused-vars\nexport interface PromiseManyArray<T> {\n /**\n * A property signifying that this object implements the classic Ember\n * `PromiseProxyMixin`-like API. See {@link LegacyPromiseProxy}.\n */\n [LegacyPromiseProxy]: true;\n}\n\n/**\n This class is returned as the result of accessing an async hasMany relationship\n on an instance of a Model extending from `@warp-drive/legacy/model`.\n\n A PromiseManyArray is an iterable proxy that allows templates to consume related\n ManyArrays and update once their contents are no longer pending.\n\n In your JS code you should resolve the promise first.\n\n ```js\n const comments = await post.comments;\n ```\n\n @summary Legacy promise-like, iterable proxy returned by an async `hasMany` on a `Model`, which templates can\n consume while the related records load.\n @public\n*/\nexport class PromiseManyArray<T = unknown> {\n /**\n * The promise for the relationship's content, or `null` once\n * {@link PromiseManyArray.destroy | destroy} has been called.\n */\n declare promise: Promise<ManyArray<T>> | null;\n /**\n * Whether {@link PromiseManyArray.destroy | destroy} has been called.\n */\n declare isDestroyed: boolean;\n /**\n * The resolved `ManyArray` for the relationship, if the promise has\n * resolved, else `null`.\n */\n declare content: ManyArray<T> | null;\n\n constructor(promise: Promise<ManyArray<T>>, content?: ManyArray<T>) {\n this._update(promise, content);\n this.isDestroyed = false;\n this[LegacyPromiseProxy] = true;\n }\n\n /**\n * Retrieve the length of the content\n * @public\n */\n @memoized\n get length(): number {\n // shouldn't be needed, but ends up being needed\n // for computed chains even in 4.x\n if (DEPRECATE_COMPUTED_CHAINS) {\n // oxlint-disable-next-line no-unused-expressions\n this['[]'];\n }\n return this.content ? this.content.length : 0;\n }\n\n /**\n * @private\n */\n // this will error if someone tries to call\n // A(identifierArray) since it is not configurable\n // which is preferrable to the `meta` override we used\n // before which required importing all of Ember\n @memoized\n get '[]'(): 0 | ManyArray<T> | undefined {\n // ember-source < 3.23 (e.g. 3.20 lts)\n // requires that the tag `'[]'` be notified\n // on the ArrayProxy in order for `{{#each}}`\n // to recompute. We entangle content.\n return this.content?.length && this.content;\n }\n\n /**\n * Iterate the proxied content. Called by the glimmer iterator in #each\n * We do not guarantee that forEach will always be available. This\n * may eventually be made to use Symbol.Iterator once glimmer supports it.\n *\n * @param cb\n * @return\n * @private\n */\n forEach(cb: (item: T, index: number, array: T[]) => void): void {\n if (this.content && this.length) {\n this.content.forEach(cb);\n }\n }\n\n /**\n * Reload the relationship\n * @public\n */\n reload(options: Omit<BaseFinderOptions, ''>): this {\n assert('You are trying to reload an async manyArray before it has been created', this.content);\n void this.content.reload(options);\n return this;\n }\n\n //---- Properties/Methods from the PromiseProxyMixin that we will keep as our API\n\n /**\n * Whether the loading promise is still pending\n *\n * @public\n */\n declare isPending: boolean;\n /**\n * Whether the loading promise rejected\n *\n * @public\n */\n declare isRejected: boolean;\n /**\n * Whether the loading promise succeeded\n *\n * @public\n */\n declare isFulfilled: boolean;\n /**\n * Whether the loading promise completed (resolved or rejected)\n *\n * @public\n */\n declare isSettled: boolean;\n\n /**\n * chain this promise\n *\n * @public\n */\n then(\n success: Parameters<Promise<ManyArray<T>>['then']>[0],\n rejected?: Parameters<Promise<ManyArray<T>>['then']>[1]\n ): Promise<unknown> {\n return this.promise!.then(success, rejected);\n }\n\n /**\n * catch errors thrown by this promise\n * @public\n */\n catch(cb: Parameters<Promise<ManyArray<T>>['catch']>[0]): Promise<unknown> {\n return this.promise!.catch(cb);\n }\n\n /**\n * run cleanup after this promise completes\n *\n * @public\n */\n finally(cb: Parameters<Promise<ManyArray<T>>['finally']>[0]): Promise<unknown> {\n return this.promise!.finally(cb);\n }\n\n //---- Methods on EmberObject that we should keep\n\n /**\n * Tears down this proxy, releasing its {@link PromiseManyArray.content | content} and\n * {@link PromiseManyArray.promise | promise} and marking it as {@link PromiseManyArray.isDestroyed | destroyed}.\n *\n * @public\n */\n destroy(): void {\n this.isDestroyed = true;\n this.content = null;\n this.promise = null;\n }\n\n //---- Methods/Properties on ManyArray that we own and proxy to\n\n /**\n * Retrieve the links for this relationship\n * @public\n */\n @memoized\n get links(): Links | null | undefined {\n return this.content ? this.content.links : undefined;\n }\n\n /**\n * Retrieve the meta for this relationship\n * @public\n */\n @memoized\n get meta(): Record<string, unknown> | null | undefined {\n return this.content ? this.content.meta : undefined;\n }\n\n //---- Our own stuff\n\n /** @internal */\n _update(promise: Promise<ManyArray<T>>, content?: ManyArray<T>): void {\n if (content !== undefined) {\n this.content = content;\n }\n\n this.promise = tapPromise(this, promise);\n }\n\n static create<T>({ promise, content }: HasManyProxyCreateArgs<T>): PromiseManyArray<T> {\n return new this(promise, content);\n }\n}\ndefineSignal(PromiseManyArray.prototype, 'content', null);\ndefineSignal(PromiseManyArray.prototype, 'isPending', false);\ndefineSignal(PromiseManyArray.prototype, 'isRejected', false);\ndefineSignal(PromiseManyArray.prototype, 'isFulfilled', false);\ndefineSignal(PromiseManyArray.prototype, 'isSettled', false);\n\nfunction tapPromise<T>(proxy: PromiseManyArray<T>, promise: Promise<ManyArray<T>>) {\n proxy.isPending = true;\n proxy.isSettled = false;\n proxy.isFulfilled = false;\n proxy.isRejected = false;\n return Promise.resolve(promise).then(\n (content) => {\n proxy.isPending = false;\n proxy.isFulfilled = true;\n proxy.isSettled = true;\n proxy.content = content;\n return content;\n },\n (error) => {\n proxy.isPending = false;\n proxy.isFulfilled = false;\n proxy.isRejected = true;\n proxy.isSettled = true;\n throw error;\n }\n );\n}\n","import type { NotificationType, Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CollectionEdge, Graph } from '@warp-drive/core/graph/-private';\nimport { defineNonEnumerableSignal, memoized } from '@warp-drive/core/signals/-leaked';\nimport type { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions } from '@warp-drive/core/types';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstanceOrString } from '@warp-drive/core/types/record';\nimport type {\n CollectionResourceDocument,\n CollectionResourceRelationship,\n ExistingResourceObject,\n LinkObject,\n Meta,\n PaginationLinks,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { IsUnknown } from '../belongs-to.ts';\nimport { assertPolymorphicType } from '../debug/assert-polymorphic-type.ts';\nimport type { LegacySupport } from '../legacy-relationships-support.ts';\nimport { areAllInverseRecordsLoaded, LEGACY_SUPPORT } from '../legacy-relationships-support.ts';\nimport type { MaybeHasManyFields } from '../type-utils.ts';\n\ninterface ResourceIdentifier {\n links?: {\n related?: string | LinkObject;\n };\n meta?: Meta;\n}\n\ntype ArrayItemType<T> = T extends (infer U)[] ? U : never;\n\nfunction isResourceIdentiferWithRelatedLinks(\n value: CollectionResourceRelationship | ResourceIdentifier | null\n): value is ResourceIdentifier & { links: { related: string | LinkObject | null } } {\n return Boolean(value && value.links && value.links.related);\n}\n/**\n A `HasManyReference` is a low-level API that allows access\n and manipulation of a hasMany relationship.\n\n It is especially useful when you're dealing with `async` relationships\n from `@warp-drive/legacy/model` as it allows synchronous access to\n the relationship data if loaded, as well as APIs for loading, reloading\n the data or accessing available information without triggering a load.\n\n It may also be useful when using `sync` relationships with `@warp-drive/legacy/model`\n that need to be loaded/reloaded with more precise timing than marking the\n relationship as `async` and relying on autofetch would have allowed.\n\n However,keep in mind that marking a relationship as `async: false` will introduce\n bugs into your application if the data is not always guaranteed to be available\n by the time the relationship is accessed. Ergo, it is recommended when using this\n approach to utilize `links` for unloaded relationship state instead of identifiers.\n\n Reference APIs are entangled with the relationship's underlying state,\n thus any getters or cached properties that utilize these will properly\n invalidate if the relationship state changes.\n\n References are \"stable\", meaning that multiple calls to retrieve the reference\n for a given relationship will always return the same HasManyReference.\n\n @class HasManyReference\n @public\n */\nexport default class HasManyReference<\n T = unknown,\n K extends string = IsUnknown<T> extends true ? string : MaybeHasManyFields<T>,\n Related = K extends keyof T ? ArrayItemType<Awaited<T[K]>> : unknown,\n> {\n declare graph: Graph;\n declare store: Store;\n declare hasManyRelationship: CollectionEdge;\n /**\n * The field name on the parent record for this has-many relationship.\n *\n * @property key\n * @type {String}\n * @public\n */\n declare key: K;\n\n /**\n * The type of resource this relationship will contain.\n *\n * @property type\n * @type {String}\n * @public\n */\n declare type: TypeFromInstanceOrString<Related>;\n\n // unsubscribe tokens given to us by the notification manager\n ___token!: object;\n ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;\n ___relatedTokenMap!: Map<ResourceKey, object>;\n\n declare _ref: number;\n\n constructor(\n store: Store,\n graph: Graph,\n parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>,\n hasManyRelationship: CollectionEdge,\n key: K\n ) {\n this.graph = graph;\n this.key = key;\n this.hasManyRelationship = hasManyRelationship;\n this.type = hasManyRelationship.definition.type as TypeFromInstanceOrString<Related>;\n\n this.store = store;\n this.___identifier = parentIdentifier;\n this.___token = store.notifications.subscribe(\n parentIdentifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'relationships' && notifiedKey === key) {\n this._ref++;\n }\n }\n );\n this.___relatedTokenMap = new Map();\n // TODO inverse\n }\n\n /**\n * This method should never be called by user code.\n *\n * @internal\n */\n destroy(): void {\n this.store.notifications.unsubscribe(this.___token);\n this.___relatedTokenMap.forEach((token) => {\n this.store.notifications.unsubscribe(token);\n });\n this.___relatedTokenMap.clear();\n }\n\n /**\n * An array of identifiers for the records that this reference refers to.\n *\n * @property identifiers\n * @type {ResourceKey[]}\n * @public\n */\n @memoized\n get identifiers(): ResourceKey<TypeFromInstanceOrString<Related>>[] {\n ensureRefCanSubscribe(this);\n // oxlint-disable-next-line no-unused-expressions\n this._ref;\n\n const resource = this._resource();\n\n const map = this.___relatedTokenMap;\n this.___relatedTokenMap = new Map();\n\n if (resource && resource.data) {\n return resource.data.map((resourceIdentifier) => {\n const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);\n let token = map.get(identifier);\n\n if (token) {\n map.delete(identifier);\n } else {\n token = this.store.notifications.subscribe(\n identifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'identity' || (bucket === 'attributes' && notifiedKey === 'id')) {\n this._ref++;\n }\n }\n );\n }\n this.___relatedTokenMap.set(identifier, token);\n\n return identifier as ResourceKey<TypeFromInstanceOrString<Related>>;\n });\n }\n\n map.forEach((token) => {\n this.store.notifications.unsubscribe(token);\n });\n map.clear();\n\n return [];\n }\n\n _resource() {\n const cache = this.store.cache;\n return cache.getRelationship(this.___identifier, this.key) as CollectionResourceRelationship;\n }\n\n /**\n This returns a string that represents how the reference will be\n looked up when it is loaded. If the relationship has a link it will\n use the \"link\" otherwise it defaults to \"id\".\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n // get the identifier of the reference\n if (commentsRef.remoteType() === \"ids\") {\n let ids = commentsRef.ids();\n } else if (commentsRef.remoteType() === \"link\") {\n let link = commentsRef.link();\n }\n ```\n\n @public\n @return The name of the remote type. This should either be `link` or `ids`\n */\n remoteType(): 'link' | 'ids' {\n const value = this._resource();\n if (value && value.links && value.links.related) {\n return 'link';\n }\n\n return 'ids';\n }\n\n /**\n `ids()` returns an array of the record IDs in this relationship.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n commentsRef.ids(); // ['1']\n ```\n\n @public\n @return The ids in this has-many relationship\n */\n ids(): Array<string | null> {\n return this.identifiers.map((identifier) => identifier.id);\n }\n\n /**\n The link WarpDrive will use to fetch or reload this belongs-to\n relationship. By default it uses only the \"related\" resource linkage.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n export default Model.extend({\n user: belongsTo('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n links: {\n related: '/articles/1/author'\n }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n // get the identifier of the reference\n if (userRef.remoteType() === \"link\") {\n let link = userRef.link();\n }\n ```\n\n @public\n @return The link WarpDrive will use to fetch or reload this belongs-to relationship.\n */\n link(): string | null {\n const resource = this._resource();\n\n if (isResourceIdentiferWithRelatedLinks(resource)) {\n if (resource.links) {\n const related = resource.links.related;\n return !related || typeof related === 'string' ? related : related.href;\n }\n }\n return null;\n }\n\n /**\n * any links that have been received for this relationship\n *\n * @public\n * @return\n */\n links(): PaginationLinks | null {\n const resource = this._resource();\n\n return resource && resource.links ? resource.links : null;\n }\n\n /**\n The meta data for the has-many relationship.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n export default Model.extend({\n users: hasMany('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n users: {\n links: {\n related: {\n href: '/articles/1/authors'\n },\n },\n meta: {\n lastUpdated: 1458014400000\n }\n }\n }\n }\n });\n\n let usersRef = blog.hasMany('user');\n\n usersRef.meta() // { lastUpdated: 1458014400000 }\n ```\n\n @public\n @return The meta information for the belongs-to relationship.\n */\n meta(): Meta | null {\n let meta: Meta | null = null;\n const resource = this._resource();\n if (resource && resource.meta && typeof resource.meta === 'object') {\n meta = resource.meta;\n }\n return meta;\n }\n\n /**\n `push` can be used to update the data in the relationship and WarpDrive\n will treat the new data as the canonical value of this relationship on\n the backend. An empty array will signify the canonical value should be\n empty.\n\n Example model\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n Setup some initial state, note we haven't loaded the comments yet:\n\n ```js\n const post = store.push({\n data: {\n type: 'post',\n id: '1',\n relationships: {\n comments: {\n data: [{ type: 'comment', id: '1' }]\n }\n }\n }\n });\n\n const commentsRef = post.hasMany('comments');\n commentsRef.ids(); // ['1']\n ```\n\n Update the state using `push`, note we can do this even without\n having loaded these comments yet by providing resource identifiers.\n\n Both full resources and resource identifiers are supported.\n\n ```js\n await commentsRef.push({\n data: [\n { type: 'comment', id: '2' },\n { type: 'comment', id: '3' },\n ]\n });\n\n commentsRef.ids(); // ['2', '3']\n ```\n\n For convenience, you can also pass in an array of resources or resource identifiers\n without wrapping them in the `data` property:\n\n ```js\n await commentsRef.push([\n { type: 'comment', id: '4' },\n { type: 'comment', id: '5' },\n ]);\n\n commentsRef.ids(); // ['4', '5']\n ```\n\n When using the `data` property, you may also include other resource data via included,\n as well as provide new links and meta to the relationship.\n\n ```js\n await commentsRef.push({\n links: {\n related: '/posts/1/comments'\n },\n meta: {\n total: 2\n },\n data: [\n { type: 'comment', id: '4' },\n { type: 'comment', id: '5' },\n ],\n included: [\n { type: 'other-thing', id: '1', attributes: { foo: 'bar' },\n ]\n });\n ```\n\n By default, the store will attempt to fetch any unloaded records before resolving\n the returned promise with the ManyArray.\n\n Alternatively, pass `true` as the second argument to avoid fetching unloaded records\n and instead the promise will resolve with void without attempting to fetch. This is\n particularly useful if you want to update the state of the relationship without\n forcing the load of all of the associated records.\n\n @public\n @param doc a JSONAPI document object describing the new value of this relationship.\n @param skipFetch [optional] if `true`, do not attempt to fetch unloaded records\n */\n async push(\n doc: ExistingResourceObject[] | CollectionResourceDocument,\n skipFetch?: boolean\n ): Promise<ManyArray<Related> | void> {\n const { store } = this;\n const dataDoc = Array.isArray(doc) ? { data: doc } : doc;\n const isResourceData = Array.isArray(dataDoc.data) && dataDoc.data.length > 0 && isMaybeResource(dataDoc.data[0]);\n\n // enforce that one of links, meta or data is present\n assert(\n `You must provide at least one of 'links', 'meta' or 'data' when calling hasManyReference.push`,\n 'links' in dataDoc || 'meta' in dataDoc || 'data' in dataDoc\n );\n\n const identifiers = !Array.isArray(dataDoc.data)\n ? []\n : isResourceData\n ? (store._push(dataDoc, true) as ResourceKey[])\n : dataDoc.data.map((i) => store.cacheKeyManager.getOrCreateRecordIdentifier(i));\n const { identifier } = this.hasManyRelationship;\n\n if (DEBUG) {\n const relationshipMeta = this.hasManyRelationship.definition;\n\n identifiers.forEach((added) => {\n assertPolymorphicType(identifier, relationshipMeta, added, store);\n });\n }\n\n const newData: CollectionResourceRelationship = {};\n // only set data if it was passed in\n if (Array.isArray(dataDoc.data)) {\n newData.data = identifiers;\n }\n if ('links' in dataDoc) {\n newData.links = dataDoc.links;\n }\n if ('meta' in dataDoc) {\n newData.meta = dataDoc.meta;\n }\n assertPrivateStore(store);\n store._join(() => {\n this.graph.push({\n op: 'updateRelationship',\n record: identifier,\n field: this.key,\n value: newData,\n });\n });\n\n if (!skipFetch) return this.load();\n }\n\n _isLoaded(): boolean {\n const hasRelationshipDataProperty = this.hasManyRelationship.state.hasReceivedData;\n if (!hasRelationshipDataProperty) {\n return false;\n }\n\n const relationship = this.graph.getData(this.hasManyRelationship.identifier, this.key) as CollectionRelationship;\n\n return relationship.data\n ? relationship.data.every((identifier) => {\n assertPrivateStore(this.store);\n return this.store._instanceCache.recordIsLoaded(identifier, true) === true;\n })\n : false;\n }\n\n /**\n `value()` synchronously returns the current value of the has-many\n relationship. Unlike `record.relationshipName`, calling\n `value()` on a reference does not trigger a fetch if the async\n relationship is not yet loaded. If the relationship is not loaded\n it will always return `null`.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n post.comments.then(function(comments) {\n commentsRef.value() === comments\n })\n ```\n\n @public\n */\n value(): ManyArray<Related> | null {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n\n if (!ensureRefCanSubscribe(this)) {\n // oxlint-disable-next-line no-unused-expressions\n this._ref;\n return null;\n }\n\n return support.getManyArray<Related>(this.key);\n }\n\n /**\n Loads the relationship if it is not already loaded. If the\n relationship is already loaded this method does not trigger a new\n load. This causes a request to the specified\n relationship link or reloads all items currently in the relationship.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n commentsRef.load().then(function(comments) {\n //...\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference.\n\n Example\n\n ```javascript\n commentsRef.load({ adapterOptions: { isPrivate: true } })\n .then(function(comments) {\n //...\n });\n ```\n\n ```js [app/adapters/comment.js]\n export default ApplicationAdapter.extend({\n findMany(store, type, id, snapshots) {\n // In the adapter you will have access to adapterOptions.\n let adapterOptions = snapshots[0].adapterOptions;\n }\n });\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the ManyArray in\n this has-many relationship.\n */\n async load(options?: BaseFinderOptions): Promise<ManyArray<Related>> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n const fetchSyncRel =\n !this.hasManyRelationship.definition.isAsync && !areAllInverseRecordsLoaded(this.store, this._resource());\n return fetchSyncRel\n ? (support.reloadHasMany(this.key, options) as Promise<ManyArray<Related>>)\n : // we cast to fix the return type since typescript and eslint don't understand async functions\n // properly\n (support.getHasMany(this.key, options) as Promise<ManyArray<Related>> | ManyArray<Related>);\n }\n\n /**\n Reloads this has-many relationship. This causes a request to the specified\n relationship link or reloads all items currently in the relationship.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n commentsRef.reload().then(function(comments) {\n //...\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference. A full example\n can be found in the `load` method.\n\n Example\n\n ```javascript\n commentsRef.reload({ adapterOptions: { isPrivate: true } })\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the ManyArray in this has-many relationship.\n */\n reload(options?: BaseFinderOptions): Promise<ManyArray<Related>> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n return support.reloadHasMany(this.key, options) as Promise<ManyArray<Related>>;\n }\n}\ndefineNonEnumerableSignal(HasManyReference.prototype, '_ref', 0);\n\nexport function isMaybeResource(object: ExistingResourceObject | ResourceIdentifier): object is ExistingResourceObject {\n const keys = Object.keys(object).filter((k) => k !== 'id' && k !== 'type' && k !== 'lid');\n return keys.length > 0;\n}\n\nfunction ensureRefCanSubscribe(rel: HasManyReference) {\n const loaded = rel._isLoaded();\n\n if (!loaded) {\n // subscribe to changes\n // for when we are not loaded yet\n //\n // because the graph optimizes the case where a relationship has never been subscribed,\n // we force accessed to be true here. When we make the graph public we should create a\n // subscribe/unsubscribe API\n const edge = rel.graph.get(rel.___identifier, rel.key);\n assert(`Expected a hasMany relationship for ${rel.___identifier.type}:${rel.key}`, 'accessed' in edge);\n edge.accessed = true;\n\n return false;\n }\n return true;\n}\n","import type { NotificationType, Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport type { Graph, ResourceEdge } from '@warp-drive/core/graph/-private';\nimport { defineNonEnumerableSignal, memoized } from '@warp-drive/core/signals/-leaked';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\nimport type {\n LinkObject,\n Links,\n Meta,\n SingleResourceDocument,\n SingleResourceRelationship,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { IsUnknown } from '../belongs-to.ts';\nimport { assertPolymorphicType } from '../debug/assert-polymorphic-type.ts';\nimport type { LegacySupport } from '../legacy-relationships-support.ts';\nimport { areAllInverseRecordsLoaded, LEGACY_SUPPORT } from '../legacy-relationships-support.ts';\nimport type { MaybeBelongsToFields } from '../type-utils.ts';\nimport { isMaybeResource } from './has-many.ts';\n\ninterface ResourceIdentifier {\n links?: {\n related?: string | LinkObject;\n };\n meta?: Meta;\n}\n\nfunction isResourceIdentiferWithRelatedLinks(\n value: SingleResourceRelationship | ResourceIdentifier | null\n): value is ResourceIdentifier & { links: { related: string | LinkObject | null } } {\n return Boolean(value && value.links && value.links.related);\n}\n\n/**\n A `BelongsToReference` is a low-level API that allows access\n and manipulation of a belongsTo relationship.\n\n It is especially useful when you're dealing with `async` relationships\n from `@warp-drive/legacy/model` as it allows synchronous access to\n the relationship data if loaded, as well as APIs for loading, reloading\n the data or accessing available information without triggering a load.\n\n It may also be useful when using `sync` relationships with `@warp-drive/legacy/model`\n that need to be loaded/reloaded with more precise timing than marking the\n relationship as `async` and relying on autofetch would have allowed.\n\n However,keep in mind that marking a relationship as `async: false` will introduce\n bugs into your application if the data is not always guaranteed to be available\n by the time the relationship is accessed. Ergo, it is recommended when using this\n approach to utilize `links` for unloaded relationship state instead of identifiers.\n\n Reference APIs are entangled with the relationship's underlying state,\n thus any getters or cached properties that utilize these will properly\n invalidate if the relationship state changes.\n\n References are \"stable\", meaning that multiple calls to retrieve the reference\n for a given relationship will always return the same HasManyReference.\n\n @public\n */\nexport default class BelongsToReference<\n T = unknown,\n K extends string = IsUnknown<T> extends true ? string : MaybeBelongsToFields<T>,\n Related = K extends keyof T ? Exclude<Awaited<T[K]>, null> : unknown,\n> {\n declare graph: Graph;\n declare store: Store;\n declare belongsToRelationship: ResourceEdge;\n /**\n * The field name on the parent record for this has-many relationship.\n *\n */\n declare key: K;\n\n /**\n * The type of resource this relationship will contain.\n *\n */\n declare type: TypeFromInstanceOrString<Related>;\n\n // unsubscribe tokens given to us by the notification manager\n declare ___token: object;\n declare ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;\n declare ___relatedToken: object | null;\n\n declare _ref: number;\n\n constructor(\n store: Store,\n graph: Graph,\n parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>,\n belongsToRelationship: ResourceEdge,\n key: K\n ) {\n this.graph = graph;\n this.key = key;\n this.belongsToRelationship = belongsToRelationship;\n this.type = belongsToRelationship.definition.type as TypeFromInstanceOrString<Related>;\n this.store = store;\n this.___identifier = parentIdentifier;\n this.___relatedToken = null;\n\n this.___token = store.notifications.subscribe(\n parentIdentifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'relationships' && notifiedKey === key) {\n this._ref++;\n }\n }\n );\n\n // TODO inverse\n }\n\n destroy(): void {\n // TODO @feature we need the notification manager often enough\n // we should potentially just expose it fully public\n this.store.notifications.unsubscribe(this.___token);\n this.___token = null as unknown as object;\n if (this.___relatedToken) {\n this.store.notifications.unsubscribe(this.___relatedToken);\n this.___relatedToken = null;\n }\n }\n\n /**\n * The identifier of the record that this reference refers to.\n * `null` if no related record is known.\n *\n */\n @memoized\n get identifier(): ResourceKey<TypeFromInstanceOrString<Related>> | null {\n if (this.___relatedToken) {\n this.store.notifications.unsubscribe(this.___relatedToken);\n this.___relatedToken = null;\n }\n\n const resource = this._resource();\n if (resource && resource.data) {\n const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resource.data);\n this.___relatedToken = this.store.notifications.subscribe(\n identifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'identity' || (bucket === 'attributes' && notifiedKey === 'id')) {\n this._ref++;\n }\n }\n );\n\n return identifier as ResourceKey<TypeFromInstanceOrString<Related>>;\n }\n\n return null;\n }\n\n /**\n The `id` of the record that this reference refers to. Together, the\n `type()` and `id()` methods form a composite key for the identity\n map. This can be used to access the id of an async relationship\n without triggering a fetch that would normally happen if you\n attempted to use `record.relationship.id`.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n // get the identifier of the reference\n if (userRef.remoteType() === \"id\") {\n let id = userRef.id();\n }\n ```\n\n @public\n @return The id of the record in this belongsTo relationship.\n */\n id(): string | null {\n return this.identifier?.id || null;\n }\n\n /**\n The link WarpDrive will use to fetch or reload this belongs-to\n relationship. By default it uses only the \"related\" resource linkage.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n export default Model.extend({\n user: belongsTo('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n links: {\n related: '/articles/1/author'\n }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n // get the identifier of the reference\n if (userRef.remoteType() === \"link\") {\n let link = userRef.link();\n }\n ```\n\n @public\n @return The link WarpDrive will use to fetch or reload this belongs-to relationship.\n */\n link(): string | null {\n const resource = this._resource();\n\n if (isResourceIdentiferWithRelatedLinks(resource)) {\n if (resource.links) {\n const related = resource.links.related;\n return !related || typeof related === 'string' ? related : related.href;\n }\n }\n return null;\n }\n\n /**\n * any links that have been received for this relationship\n *\n * @public\n * @return\n */\n links(): Links | null {\n const resource = this._resource();\n\n return resource && resource.links ? resource.links : null;\n }\n\n /**\n The meta data for the belongs-to relationship.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n export default Model.extend({\n user: belongsTo('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n links: {\n related: {\n href: '/articles/1/author'\n },\n },\n meta: {\n lastUpdated: 1458014400000\n }\n }\n }\n }\n });\n\n let userRef = blog.belongsTo('user');\n\n userRef.meta() // { lastUpdated: 1458014400000 }\n ```\n\n @public\n @return The meta information for the belongs-to relationship.\n */\n meta(): Meta | null {\n let meta: Meta | null = null;\n const resource = this._resource();\n if (resource && resource.meta && typeof resource.meta === 'object') {\n meta = resource.meta;\n }\n return meta;\n }\n\n _resource() {\n // oxlint-disable-next-line no-unused-expressions\n this._ref; // subscribe\n const cache = this.store.cache;\n return cache.getRelationship(this.___identifier, this.key) as SingleResourceRelationship<\n ResourceKey<TypeFromInstance<Related>>\n >;\n }\n\n /**\n This returns a string that represents how the reference will be\n looked up when it is loaded. If the relationship has a link it will\n use the \"link\" otherwise it defaults to \"id\".\n\n Example\n\n ```js [app/models/post.js]\n import Model, { hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n // get the identifier of the reference\n if (commentsRef.remoteType() === \"ids\") {\n let ids = commentsRef.ids();\n } else if (commentsRef.remoteType() === \"link\") {\n let link = commentsRef.link();\n }\n ```\n\n @public\n @return The name of the remote type. This should either be `link` or `id`\n */\n remoteType(): 'link' | 'id' {\n const value = this._resource();\n if (isResourceIdentiferWithRelatedLinks(value)) {\n return 'link';\n }\n return 'id';\n }\n\n /**\n `push` can be used to update the data in the relationship and WarpDrive\n will treat the new data as the canonical value of this relationship on\n the backend. A value of `null` (e.g. `{ data: null }`) can be passed to\n clear the relationship.\n\n Example model\n\n ```js [app/models/blog.js]\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n ```\n\n Setup some initial state, note we haven't loaded the user yet:\n\n ```js\n const blog = store.push({\n data: {\n type: 'blog',\n id: '1',\n relationships: {\n user: {\n data: { type: 'user', id: '1' }\n }\n }\n }\n });\n\n const userRef = blog.belongsTo('user');\n userRef.id(); // '1'\n ```\n\n Update the state using `push`, note we can do this even without\n having loaded the user yet by providing a resource-identifier.\n\n Both full a resource and a resource-identifier are supported.\n\n ```js\n await userRef.push({\n data: {\n type: 'user',\n id: '2',\n }\n });\n\n userRef.id(); // '2'\n ```\n\n You may also pass in links and meta fore the relationship, and sideload\n additional resources that might be required.\n\n ```js\n await userRef.push({\n data: {\n type: 'user',\n id: '2',\n },\n links: {\n related: '/articles/1/author'\n },\n meta: {\n lastUpdated: Date.now()\n },\n included: [\n {\n type: 'user-preview',\n id: '2',\n attributes: {\n username: '@runspired'\n }\n }\n ]\n });\n ```\n\n By default, the store will attempt to fetch the record if it is not loaded or its\n resource data is not included in the call to `push` before resolving the returned\n promise with the new state..\n\n Alternatively, pass `true` as the second argument to avoid fetching unloaded records\n and instead the promise will resolve with void without attempting to fetch. This is\n particularly useful if you want to update the state of the relationship without\n forcing the load of all of the associated record.\n\n @public\n @param doc a JSONAPI document object describing the new value of this relationship.\n @param skipFetch [optional] if `true`, do not attempt to fetch unloaded records\n @return a promise that resolves with the record in this belongs-to relationship after the push has completed.\n */\n async push(doc: SingleResourceDocument, skipFetch?: boolean): Promise<Related | null | void> {\n const { store } = this;\n const isResourceData = doc.data && isMaybeResource(doc.data);\n const added = isResourceData\n ? (store._push(doc, true) as PersistedResourceKey)\n : doc.data\n ? store.cacheKeyManager.getOrCreateRecordIdentifier(doc.data)\n : null;\n const { identifier } = this.belongsToRelationship;\n\n if (DEBUG) {\n if (added) {\n assertPolymorphicType(identifier, this.belongsToRelationship.definition, added, store);\n }\n }\n\n const newData: SingleResourceRelationship = {};\n\n // only set data if it was passed in\n if (doc.data || doc.data === null) {\n newData.data = added;\n }\n if ('links' in doc) {\n newData.links = doc.links;\n }\n if ('meta' in doc) {\n newData.meta = doc.meta;\n }\n assertPrivateStore(store);\n store._join(() => {\n this.graph.push({\n op: 'updateRelationship',\n record: identifier,\n field: this.key,\n value: newData,\n });\n });\n\n if (!skipFetch) return this.load();\n }\n\n /**\n `value()` synchronously returns the current value of the belongs-to\n relationship. Unlike `record.relationshipName`, calling\n `value()` on a reference does not trigger a fetch if the async\n relationship is not yet loaded. If the relationship is not loaded\n it will always return `null`.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n userRef.value(); // null\n\n // provide data for reference\n userRef.push({\n data: {\n type: 'user',\n id: 1,\n attributes: {\n username: \"@user\"\n }\n }\n }).then(function(user) {\n userRef.value(); // user\n });\n ```\n\n @public\n @return the record in this relationship\n */\n value(): Related | null {\n const resource = this._resource();\n return resource && resource.data ? this.store.peekRecord(resource.data) : null;\n }\n\n /**\n Loads a record in a belongs-to relationship if it is not already\n loaded. If the relationship is already loaded this method does not\n trigger a new load.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n userRef.value(); // null\n\n userRef.load().then(function(user) {\n userRef.value() === user\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference.\n\n Example\n\n ```javascript\n userRef.load({ adapterOptions: { isPrivate: true } }).then(function(user) {\n userRef.value() === user;\n });\n ```\n ```js [app/adapters/user.js]\n import Adapter from '@warp-drive/legacy/adapter';\n\n export default class UserAdapter extends Adapter {\n findRecord(store, type, id, snapshot) {\n // In the adapter you will have access to adapterOptions.\n let adapterOptions = snapshot.adapterOptions;\n }\n });\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the record in this belongs-to relationship.\n */\n async load(options?: Record<string, unknown>): Promise<Related | null> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n const fetchSyncRel =\n !this.belongsToRelationship.definition.isAsync && !areAllInverseRecordsLoaded(this.store, this._resource());\n return fetchSyncRel\n ? support.reloadBelongsTo(this.key, options).then(() => this.value())\n : // we cast to fix the return type since typescript and eslint don't understand async functions\n // properly\n (support.getBelongsTo(this.key, options) as Promise<Related | null>);\n }\n\n /**\n Triggers a reload of the value in this relationship. If the\n remoteType is `\"link\"` WarpDrive will use the relationship link to\n reload the relationship. Otherwise it will reload the record by its\n id.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n userRef.reload().then(function(user) {\n userRef.value() === user\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference. A full example\n can be found in the `load` method.\n\n Example\n\n ```javascript\n userRef.reload({ adapterOptions: { isPrivate: true } })\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the record in this belongs-to relationship after the reload has completed.\n */\n reload(options?: Record<string, unknown>): Promise<Related | null> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n return support.reloadBelongsTo(this.key, options).then(() => this.value());\n }\n}\ndefineNonEnumerableSignal(BelongsToReference.prototype, '_ref', 0);\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CollectionEdge, Graph, GraphEdge, ResourceEdge, UpgradedMeta } from '@warp-drive/core/graph/-private';\nimport type { ReactiveDocument } from '@warp-drive/core/reactive';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { LegacyManyArray, PrivateReactiveResourceArray, PrivateStore } from '@warp-drive/core/store/-private';\nimport {\n assertPrivateStore,\n createLegacyManyArray,\n fastPush,\n isPrivateStore,\n isResourceKey,\n recordIdentifierFor,\n storeFor,\n} from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions, ResourceKey } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { LocalRelationshipOperation } from '@warp-drive/core/types/graph';\nimport type { OpaqueRecordInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\nimport { EnableHydration } from '@warp-drive/core/types/request';\nimport type { LegacyBelongsToField, LegacyHasManyField } from '@warp-drive/core/types/schema/fields';\nimport type {\n CollectionResourceRelationship,\n InnerRelationshipDocument,\n SingleResourceRelationship,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../../compat/-private.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\nimport type { BelongsToProxyCreateArgs, BelongsToProxyMeta } from './promise-belongs-to.ts';\nimport { PromiseBelongsTo } from './promise-belongs-to.ts';\nimport type { HasManyProxyCreateArgs } from './promise-many-array.ts';\nimport { PromiseManyArray } from './promise-many-array.ts';\nimport BelongsToReference from './references/belongs-to.ts';\nimport HasManyReference from './references/has-many.ts';\n\ntype PromiseBelongsToFactory<T = unknown> = { create(args: BelongsToProxyCreateArgs<T>): PromiseBelongsTo<T> };\n\nexport const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport> = getOrSetGlobal(\n 'LEGACY_SUPPORT',\n new Map<ResourceKey | MinimalLegacyRecord, LegacySupport>()\n);\n\nexport function releaseLegacySupport(identifier: ResourceKey): void {\n const support = LEGACY_SUPPORT.get(identifier);\n if (support) {\n support.destroy();\n LEGACY_SUPPORT.delete(identifier);\n }\n}\n\nexport function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport {\n const identifier = recordIdentifierFor(record);\n assert(`Expected a record`, identifier);\n let support = LEGACY_SUPPORT.get(identifier);\n\n if (!support) {\n assert(`Memory Leak Detected`, !record.isDestroyed && !record.isDestroying);\n support = new LegacySupport(record, identifier);\n LEGACY_SUPPORT.set(identifier, support);\n }\n\n return support;\n}\n\n/**\n * @hideconstructor\n */\nexport class LegacySupport {\n /** @internal */\n declare private record: MinimalLegacyRecord;\n /** @internal */\n declare store: PrivateStore;\n /** @internal */\n declare private graph: Graph;\n /** @internal */\n declare private cache: Cache;\n /** @internal */\n declare private references: Record<string, BelongsToReference | HasManyReference>;\n declare identifier: ResourceKey;\n /** @internal */\n declare _manyArrayCache: Record<string, LegacyManyArray>;\n /** @internal */\n declare _relationshipPromisesCache: Record<string, Promise<LegacyManyArray | OpaqueRecordInstance>>;\n /** @internal */\n declare _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;\n /** @internal */\n declare private _pending: Record<string, Promise<ResourceKey | null> | undefined>;\n\n /** @internal */\n declare private isDestroying: boolean;\n /** @internal */\n declare private isDestroyed: boolean;\n\n constructor(record: MinimalLegacyRecord, identifier: ResourceKey) {\n this.record = record;\n this.store = isPrivateStore(storeFor(record, false)!);\n this.identifier = identifier;\n this.cache = this.store.cache;\n\n if (this.store._graph) {\n this.graph = this.store._graph;\n }\n\n this._manyArrayCache = Object.create(null) as Record<string, LegacyManyArray>;\n this._relationshipPromisesCache = Object.create(null) as Record<\n string,\n Promise<LegacyManyArray | OpaqueRecordInstance>\n >;\n this._relationshipProxyCache = Object.create(null) as Record<string, PromiseManyArray | PromiseBelongsTo>;\n this._pending = Object.create(null) as Record<string, Promise<ResourceKey | null>>;\n this.references = Object.create(null) as Record<string, BelongsToReference>;\n }\n\n /** @private */\n _syncArray(array: LegacyManyArray): void {\n // It’s possible the parent side of the relationship may have been destroyed by this point\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n const currentState = (array as unknown as PrivateReactiveResourceArray)[Context].source;\n const identifier = this.identifier;\n\n const [identifiers, jsonApi] = this._getCurrentState(identifier, array.key);\n\n if (jsonApi.meta) {\n array.meta = jsonApi.meta;\n }\n\n if (jsonApi.links) {\n array.links = jsonApi.links;\n }\n\n currentState.length = 0;\n fastPush(currentState, identifiers);\n }\n\n mutate(mutation: LocalRelationshipOperation): void {\n this.cache.mutate(mutation);\n }\n\n _findBelongsTo(\n key: string,\n resource: SingleResourceRelationship,\n relationship: ResourceEdge,\n options?: BaseFinderOptions\n ): Promise<OpaqueRecordInstance | null> {\n const name = getRealFieldName(this, key);\n\n // TODO @runspired follow up if parent isNew then we should not be attempting load here\n // TODO @runspired follow up on whether this should be in the relationship requests cache\n return this._findBelongsToByJsonApiResource(resource, this.identifier, relationship, options).then(\n (identifier: ResourceKey | null) => handleCompletedRelationshipRequest(this, name, relationship, identifier),\n (e: Error) => handleCompletedRelationshipRequest(this, name, relationship, null, e)\n );\n }\n\n reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null> {\n const loadingPromise = this._relationshipPromisesCache[key] as Promise<OpaqueRecordInstance | null> | undefined;\n if (loadingPromise) {\n return loadingPromise;\n }\n\n const name = getRealFieldName(this, key);\n const resource = this.store.cache.getRelationship(this.identifier, name);\n\n const relationship = this.graph.get(this.identifier, name);\n assert(\n `Expected ${key === name ? name : `${key} (source: ${name})`} to be a belongs-to relationship`,\n isBelongsTo(relationship)\n );\n\n relationship.state.hasFailedLoadAttempt = false;\n relationship.state.shouldForceReload = true;\n const promise = this._findBelongsTo(name, resource as SingleResourceRelationship, relationship, options);\n if (this._relationshipProxyCache[name]) {\n // @ts-expect-error\n return this._updatePromiseProxyFor('belongsTo', name, { promise });\n }\n return promise;\n }\n\n getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null {\n const { identifier } = this;\n const name = getRealFieldName(this, key);\n const resource = this.store.cache.getRelationship(this.identifier, name);\n const relatedIdentifier = resource && resource.data ? resource.data : null;\n assert(`Expected a stable identifier`, !relatedIdentifier || isResourceKey(relatedIdentifier));\n\n const store = this.store;\n const relationship = this.graph.get(this.identifier, name);\n assert(\n `Expected ${key === name ? name : `${key} (source: ${name})`} to be a belongs-to relationship`,\n isBelongsTo(relationship)\n );\n\n const isAsync = relationship.definition.isAsync;\n const _belongsToState: BelongsToProxyMeta = {\n key,\n store,\n legacySupport: this,\n modelName: relationship.definition.type,\n };\n\n if (isAsync) {\n if (relationship.state.hasFailedLoadAttempt) {\n return this._relationshipProxyCache[name];\n }\n\n const promise = this._findBelongsTo(name, resource as SingleResourceRelationship, relationship, options);\n const isLoaded = relatedIdentifier && store._instanceCache.recordIsLoaded(relatedIdentifier);\n\n return this._updatePromiseProxyFor('belongsTo', name, {\n promise,\n content: isLoaded ? store._instanceCache.getRecord(relatedIdentifier) : null,\n _belongsToState,\n });\n } else {\n if (relatedIdentifier === null) {\n return null;\n } else {\n assert(\n `You looked up the '${key === name ? name : `${key} (source: ${name})`}' relationship on a '${identifier.type}' with id ${\n identifier.id || 'null'\n } but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (\\`belongsTo(<type>, { async: true, inverse: <inverse> })\\`)`,\n store._instanceCache.recordIsLoaded(relatedIdentifier, true)\n );\n return store._instanceCache.getRecord(relatedIdentifier);\n }\n }\n }\n\n setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void {\n const name = getRealFieldName(this, key);\n return this.cache.mutate(\n {\n op: 'replaceRelatedRecord',\n record: this.identifier,\n field: name,\n value: extractIdentifierFromRecord(value),\n },\n // @ts-expect-error\n true\n );\n }\n\n _getCurrentState<T>(\n identifier: ResourceKey,\n field: string\n ): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship] {\n const jsonApi = this.cache.getRelationship(identifier, field) as CollectionRelationship;\n const cache = this.store._instanceCache;\n const identifiers: ResourceKey<TypeFromInstanceOrString<T>>[] = [];\n if (jsonApi.data) {\n for (let i = 0; i < jsonApi.data.length; i++) {\n const relatedIdentifier = jsonApi.data[i] as ResourceKey<TypeFromInstanceOrString<T>>;\n assert(`Expected a stable identifier`, isResourceKey(relatedIdentifier));\n if (cache.recordIsLoaded(relatedIdentifier, true)) {\n identifiers.push(relatedIdentifier);\n }\n }\n }\n\n return [identifiers, jsonApi];\n }\n\n getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T> {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n let manyArray: LegacyManyArray<T> | undefined = this._manyArrayCache[name] as LegacyManyArray<T> | undefined;\n if (!definition) {\n definition = this.graph.get(this.identifier, name).definition;\n }\n\n if (!manyArray) {\n const [identifiers, doc] = this._getCurrentState<T>(this.identifier, name);\n const field = getField(this, name);\n\n manyArray = createLegacyManyArray({\n store: this.store,\n // @ts-expect-error Typescript doesn't have a way for us to thread the generic backwards so it infers unknown instead of T\n manager: this,\n source: identifiers,\n type: definition.type,\n isLoaded: !definition.isAsync,\n editable: true,\n isAsync: definition.isAsync,\n isPolymorphic: definition.isPolymorphic,\n field: field as LegacyHasManyField,\n identifier: this.identifier,\n links: doc.links || null,\n meta: doc.meta || null,\n });\n\n this._manyArrayCache[name] = manyArray;\n }\n\n return manyArray;\n }\n assert('hasMany only works with the JSONAPICache');\n }\n\n fetchAsyncHasMany(\n key: string,\n relationship: CollectionEdge,\n manyArray: LegacyManyArray,\n options?: BaseFinderOptions\n ): Promise<LegacyManyArray> {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n let loadingPromise = this._relationshipPromisesCache[name] as Promise<LegacyManyArray> | undefined;\n if (loadingPromise) {\n return loadingPromise;\n }\n\n const jsonApi = this.cache.getRelationship(this.identifier, name) as CollectionRelationship;\n const promise = this._findHasManyByJsonApiResource(jsonApi, this.identifier, relationship, options);\n\n if (!promise) {\n manyArray.isLoaded = true;\n return Promise.resolve(manyArray);\n }\n\n loadingPromise = promise.then(\n () => handleCompletedRelationshipRequest(this, name, relationship, manyArray),\n (e: Error) => handleCompletedRelationshipRequest(this, name, relationship, manyArray, e)\n );\n this._relationshipPromisesCache[name] = loadingPromise;\n return loadingPromise;\n }\n assert('hasMany only works with the JSONAPICache');\n }\n\n reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T> {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n const loadingPromise = this._relationshipPromisesCache[name];\n if (loadingPromise) {\n return loadingPromise as Promise<LegacyManyArray<T>>;\n }\n const relationship = this.graph.get(this.identifier, name) as CollectionEdge;\n const { definition, state } = relationship;\n\n state.hasFailedLoadAttempt = false;\n state.shouldForceReload = true;\n const manyArray = this.getManyArray(name, definition);\n const promise = this.fetchAsyncHasMany(name, relationship, manyArray, options);\n\n if (this._relationshipProxyCache[name]) {\n return this._updatePromiseProxyFor('hasMany', name, { promise }) as PromiseManyArray<T>;\n }\n\n return promise as Promise<LegacyManyArray<T>>;\n }\n assert(`hasMany only works with the JSONAPICache`);\n }\n\n getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n const relationship = this.graph.get(this.identifier, name) as CollectionEdge;\n const { definition, state } = relationship;\n const manyArray = this.getManyArray(name, definition);\n\n if (definition.isAsync) {\n if (state.hasFailedLoadAttempt) {\n return this._relationshipProxyCache[name] as PromiseManyArray;\n }\n\n const promise = this.fetchAsyncHasMany(name, relationship, manyArray, options);\n\n return this._updatePromiseProxyFor('hasMany', name, { promise, content: manyArray });\n } else {\n assert(\n `You looked up the '${key === name ? name : `${key} (source: ${name})`}' relationship on a '${this.identifier.type}' with id ${\n this.identifier.id || 'null'\n } but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async ('hasMany(<type>, { async: true, inverse: <inverse> })')`,\n !anyUnloaded(this.store, relationship)\n );\n\n return manyArray;\n }\n }\n assert(`hasMany only works with the JSONAPICache`);\n }\n\n _updatePromiseProxyFor(kind: 'hasMany', key: string, args: HasManyProxyCreateArgs): PromiseManyArray;\n _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;\n _updatePromiseProxyFor(\n kind: 'belongsTo',\n key: string,\n args: { promise: Promise<OpaqueRecordInstance | null> }\n ): PromiseBelongsTo;\n _updatePromiseProxyFor(\n kind: 'hasMany' | 'belongsTo',\n key: string,\n args: BelongsToProxyCreateArgs | HasManyProxyCreateArgs | { promise: Promise<OpaqueRecordInstance | null> }\n ): PromiseBelongsTo | PromiseManyArray {\n let promiseProxy = this._relationshipProxyCache[key];\n if (kind === 'hasMany') {\n const { promise, content } = args as HasManyProxyCreateArgs;\n if (promiseProxy) {\n assert(`Expected a PromiseManyArray`, '_update' in promiseProxy);\n promiseProxy._update(promise, content);\n } else {\n promiseProxy = this._relationshipProxyCache[key] = new PromiseManyArray(promise, content);\n }\n return promiseProxy;\n }\n if (promiseProxy) {\n const { promise, content } = args as BelongsToProxyCreateArgs;\n assert(`Expected a PromiseBelongsTo`, '_belongsToState' in promiseProxy);\n\n if (content !== undefined) {\n promiseProxy.set('content', content);\n }\n void promiseProxy.set('promise', promise);\n } else {\n promiseProxy = (PromiseBelongsTo as unknown as PromiseBelongsToFactory).create(args as BelongsToProxyCreateArgs);\n this._relationshipProxyCache[key] = promiseProxy;\n }\n\n return promiseProxy;\n }\n\n referenceFor(kind: 'belongsTo', key: string): BelongsToReference;\n referenceFor(kind: 'hasMany', key: string): HasManyReference;\n referenceFor(kind: 'belongsTo' | 'hasMany', key: string) {\n const name = getRealFieldName(this, key);\n\n let reference = this.references[name];\n\n if (!reference) {\n if (!this.graph) {\n // TODO @runspired while this feels odd, it is not a regression in capability because we do\n // not today support references pulling from RecordDatas other than our own\n // because of the intimate API access involved. This is something we will need to redesign.\n assert(`snapshot.belongsTo only supported when using the JSONAPICache`);\n }\n const { graph, identifier } = this;\n const relationship = graph.get(identifier, name);\n\n if (DEBUG) {\n if (kind) {\n const modelName = identifier.type;\n const actualRelationshipKind = relationship.definition.kind;\n assert(\n `You tried to get the '${key === name ? name : `${key} (source: ${name})`}' relationship on a '${modelName}' via record.${kind}('${key}'), but the relationship is of kind '${actualRelationshipKind}'. Use record.${actualRelationshipKind}('${key}') instead.`,\n actualRelationshipKind === kind\n );\n }\n }\n\n const relationshipKind = relationship.definition.kind;\n\n if (relationshipKind === 'belongsTo') {\n reference = new BelongsToReference(this.store, graph, identifier, relationship as ResourceEdge, key);\n } else if (relationshipKind === 'hasMany') {\n reference = new HasManyReference(this.store, graph, identifier, relationship as CollectionEdge, key);\n }\n\n this.references[name] = reference;\n }\n\n return reference;\n }\n\n _findHasManyByJsonApiResource(\n resource: CollectionResourceRelationship,\n parentIdentifier: ResourceKey,\n relationship: CollectionEdge,\n options: BaseFinderOptions = {}\n ): Promise<void | unknown[]> | void {\n if (this.graph) {\n if (!resource) {\n return;\n }\n const { definition, state } = relationship;\n upgradeStore(this.store);\n const adapter = this.store.adapterFor?.(definition.type);\n const { isStale, hasDematerializedInverse, hasReceivedData, isEmpty, shouldForceReload } = state;\n const allInverseRecordsAreLoaded = areAllInverseRecordsLoaded(this.store, resource);\n const identifiers = resource.data;\n const shouldFindViaLink =\n resource.links &&\n resource.links.related &&\n (typeof adapter?.findHasMany === 'function' || typeof identifiers === 'undefined') &&\n (shouldForceReload || hasDematerializedInverse || isStale || (!allInverseRecordsAreLoaded && !isEmpty));\n\n const field = this.store.schema.fields({ type: definition.inverseType }).get(definition.key);\n assert(\n `Expected a hasMany field definition for ${definition.inverseType}.${definition.key}`,\n field && field.kind === 'hasMany'\n );\n\n const request = {\n useLink: shouldFindViaLink,\n field,\n links: resource.links,\n meta: resource.meta,\n options,\n record: parentIdentifier,\n };\n\n // fetch via link\n if (shouldFindViaLink) {\n assert(`Expected collection to be an array`, !identifiers || Array.isArray(identifiers));\n assert(`Expected stable identifiers`, !identifiers || identifiers.every(isResourceKey));\n\n const req = field.options.linksMode\n ? {\n url: getRelatedLink(resource),\n op: 'findHasMany',\n method: 'GET' as const,\n records: identifiers || [],\n data: request,\n [EnableHydration]: false,\n }\n : {\n op: 'findHasMany',\n records: identifiers || [],\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n };\n return this.store.request(req) as unknown as Promise<void>;\n }\n\n const preferLocalCache = hasReceivedData && !isEmpty;\n const hasLocalPartialData =\n hasDematerializedInverse || (isEmpty && Array.isArray(identifiers) && identifiers.length > 0);\n const attemptLocalCache = !shouldForceReload && !isStale && (preferLocalCache || hasLocalPartialData);\n\n if (attemptLocalCache && allInverseRecordsAreLoaded) {\n return;\n }\n\n const hasData = hasReceivedData && !isEmpty;\n if (attemptLocalCache || hasData || hasLocalPartialData) {\n assert(`Expected collection to be an array`, Array.isArray(identifiers));\n assert(`Expected stable identifiers`, identifiers.every(isResourceKey));\n\n options.reload = options.reload || !attemptLocalCache || undefined;\n return this.store.request({\n op: 'findHasMany',\n records: identifiers,\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n }) as unknown as Promise<void>;\n }\n\n // we were explicitly told we have no data and no links.\n // TODO if the relationshipIsStale, should we hit the adapter anyway?\n return;\n }\n assert(`hasMany only works with the JSONAPICache`);\n }\n\n _findBelongsToByJsonApiResource(\n resource: SingleResourceRelationship,\n parentIdentifier: ResourceKey,\n relationship: ResourceEdge,\n options: BaseFinderOptions = {}\n ): Promise<ResourceKey | null> {\n if (!resource) {\n return Promise.resolve(null);\n }\n const key = relationship.definition.key;\n const name = getRealFieldName(this, key);\n\n // interleaved promises mean that we MUST cache this here\n // in order to prevent infinite re-render if the request\n // fails.\n if (this._pending[name]) {\n return this._pending[name];\n }\n\n const identifier = resource.data ? resource.data : null;\n assert(`Expected a stable identifier`, !identifier || isResourceKey(identifier));\n\n const { isStale, hasDematerializedInverse, hasReceivedData, isEmpty, shouldForceReload } = relationship.state;\n\n const allInverseRecordsAreLoaded = areAllInverseRecordsLoaded(this.store, resource);\n const shouldFindViaLink =\n resource.links?.related &&\n (shouldForceReload || hasDematerializedInverse || isStale || (!allInverseRecordsAreLoaded && !isEmpty));\n\n const field = this.store.schema.fields(this.identifier).get(relationship.definition.key);\n assert(\n `Attempted to access a belongsTo relationship but no definition exists for it`,\n field && field.kind === 'belongsTo'\n );\n const request = {\n useLink: shouldFindViaLink,\n field,\n links: resource.links,\n meta: resource.meta,\n options,\n record: parentIdentifier,\n };\n\n // fetch via link\n if (shouldFindViaLink) {\n const req = field.options.linksMode\n ? {\n url: getRelatedLink(resource),\n op: 'findBelongsTo',\n method: 'GET' as const,\n records: identifier ? [identifier] : [],\n data: request,\n [EnableHydration]: false,\n }\n : {\n op: 'findBelongsTo',\n records: identifier ? [identifier] : [],\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n };\n const future = this.store.request<ResourceKey | null>(req);\n this._pending[name] = future\n .then((doc) =>\n field.options.linksMode ? (doc.content as unknown as ReactiveDocument<ResourceKey | null>).data! : doc.content\n )\n .finally(() => {\n this._pending[name] = undefined;\n });\n return this._pending[name];\n }\n\n const preferLocalCache = hasReceivedData && allInverseRecordsAreLoaded && !isEmpty;\n const hasLocalPartialData = hasDematerializedInverse || (isEmpty && resource.data);\n // null is explicit empty, undefined is \"we don't know anything\"\n const localDataIsEmpty = !identifier;\n const attemptLocalCache = !shouldForceReload && !isStale && (preferLocalCache || hasLocalPartialData);\n\n // we dont need to fetch and are empty\n if (attemptLocalCache && localDataIsEmpty) {\n return Promise.resolve(null);\n }\n\n // we dont need to fetch because we are local state\n const resourceIsLocal = identifier?.id === null;\n if ((attemptLocalCache && allInverseRecordsAreLoaded) || resourceIsLocal) {\n return Promise.resolve(identifier);\n }\n\n // we may need to fetch\n if (identifier) {\n assert(`Cannot fetch belongs-to relationship with no information`, identifier);\n options.reload = options.reload || !attemptLocalCache || undefined;\n\n this._pending[name] = this.store\n .request<ResourceKey | null>({\n op: 'findBelongsTo',\n records: [identifier],\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n })\n .then((doc) => doc.content)\n .finally(() => {\n this._pending[name] = undefined;\n });\n return this._pending[name];\n }\n\n // we were explicitly told we have no data and no links.\n // TODO if the relationshipIsStale, should we hit the adapter anyway?\n return Promise.resolve(null);\n }\n\n destroy(): void {\n this.isDestroying = true;\n\n let cache: Record<string, { destroy(): void } | undefined> = this._manyArrayCache;\n this._manyArrayCache = Object.create(null) as Record<string, LegacyManyArray>;\n Object.keys(cache).forEach((key) => {\n cache[key]!.destroy();\n });\n\n cache = this._relationshipProxyCache;\n this._relationshipProxyCache = Object.create(null) as Record<string, PromiseManyArray | PromiseBelongsTo>;\n Object.keys(cache).forEach((key) => {\n const proxy = cache[key]!;\n if (proxy.destroy) {\n proxy.destroy();\n }\n });\n\n cache = this.references;\n this.references = Object.create(null) as Record<string, BelongsToReference | HasManyReference>;\n Object.keys(cache).forEach((key) => {\n cache[key]!.destroy();\n });\n this.isDestroyed = true;\n }\n}\n\nfunction getRelatedLink(resource: SingleResourceRelationship | CollectionResourceRelationship): string {\n const related = resource.links?.related;\n assert(`Expected a related link`, related);\n\n return typeof related === 'object' ? related.href : related;\n}\n\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: ResourceEdge,\n value: ResourceKey | null\n): OpaqueRecordInstance | null;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: CollectionEdge,\n value: LegacyManyArray\n): LegacyManyArray;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: ResourceEdge,\n value: null,\n error: Error\n): never;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: CollectionEdge,\n value: LegacyManyArray,\n error: Error\n): never;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: ResourceEdge | CollectionEdge,\n value: LegacyManyArray | ResourceKey | null,\n error?: Error\n): LegacyManyArray | OpaqueRecordInstance | null {\n delete recordExt._relationshipPromisesCache[key];\n relationship.state.shouldForceReload = false;\n const isHasMany = relationship.definition.kind === 'hasMany';\n\n if (isHasMany) {\n // we don't notify the record property here to avoid refetch\n // only the many array\n notifyInternalSignal((value as unknown as PrivateReactiveResourceArray)[Context].signal);\n }\n\n if (error) {\n relationship.state.hasFailedLoadAttempt = true;\n const proxy = recordExt._relationshipProxyCache[key];\n // belongsTo relationships are sometimes unloaded\n // when a load fails, in this case we need\n // to make sure that we aren't proxying\n // to destroyed content\n // for the sync belongsTo reload case there will be no proxy\n // for the async reload case there will be no proxy if the ui\n // has never been accessed\n if (proxy && !isHasMany) {\n // @ts-expect-error unsure why this is not resolving the boolean but async belongsTo is weird\n if (proxy.content && proxy.content.isDestroying) {\n (proxy as PromiseBelongsTo).set('content', null);\n }\n recordExt.store.notifications._flush();\n }\n\n throw error;\n }\n\n if (isHasMany) {\n (value as LegacyManyArray).isLoaded = true;\n } else {\n recordExt.store.notifications._flush();\n }\n\n relationship.state.hasFailedLoadAttempt = false;\n // only set to not stale if no error is thrown\n relationship.state.isStale = false;\n\n return isHasMany || !value ? value : recordExt.store.peekRecord(value as ResourceKey);\n}\n\ntype PromiseProxyRecord = { then(): void; content: OpaqueRecordInstance | null | undefined };\n\nfunction extractIdentifierFromRecord(record: PromiseProxyRecord | OpaqueRecordInstance | null) {\n if (!record) {\n return null;\n }\n\n return recordIdentifierFor(record);\n}\n\nfunction anyUnloaded(store: Store, relationship: CollectionEdge) {\n assertPrivateStore(store);\n const graph = store._graph;\n assert(`Expected a Graph instance to be available`, graph);\n const relationshipData = graph.getData(\n relationship.identifier,\n relationship.definition.key\n ) as CollectionRelationship;\n const state = relationshipData.data;\n const cache = store._instanceCache;\n const unloaded = state?.find((s) => {\n const isLoaded = cache.recordIsLoaded(s, true);\n return !isLoaded;\n });\n\n return unloaded || false;\n}\n\nexport function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean {\n assertPrivateStore(store);\n const instanceCache = store._instanceCache;\n const identifiers = resource.data;\n\n if (Array.isArray(identifiers)) {\n assert(`Expected stable identifiers`, identifiers.every(isResourceKey));\n // treat as collection\n // check for unloaded records\n return identifiers.every((identifier: ResourceKey) => instanceCache.recordIsLoaded(identifier));\n }\n\n // treat as single resource\n if (!identifiers) return true;\n\n assert(`Expected stable identifiers`, isResourceKey(identifiers));\n return instanceCache.recordIsLoaded(identifiers);\n}\n\nfunction isBelongsTo(relationship: GraphEdge): relationship is ResourceEdge {\n return relationship.definition.kind === 'belongsTo';\n}\n\nfunction getField(context: LegacySupport, key: string): LegacyHasManyField | LegacyBelongsToField {\n const { identifier, store } = context;\n return (store.schema.fields(identifier).get(key) ??\n store.schema.cacheFields?.(identifier).get(key)) as LegacyBelongsToField;\n}\n\nfunction getRealFieldName(context: LegacySupport, key: string): string {\n const field = getField(context, key);\n return field ? (field.sourceKey ?? field.name) : key;\n}\n","import { A, type NativeArray } from '@ember/array';\nimport ArrayProxy from '@ember/array/proxy';\nimport { computed, get } from '@ember/object';\nimport { mapBy, not } from '@ember/object/computed';\n\nimport type RecordState from './record-state.ts';\n\ntype ValidationError = {\n attribute: string;\n message: string;\n};\n\ninterface ArrayProxyWithCustomOverrides<T> extends Omit<ArrayProxy<T>, 'clear' | 'content'> {\n // Omit causes `content` to be merged with the class def for ArrayProxy\n // which then causes it to be seen as a property, disallowing defining it\n // as an accessor. This restores our ability to define it as an accessor.\n content: NativeArray<T>;\n clear(): void;\n _has(name: string): boolean;\n}\n\n// we force the type here to our own construct because mixin and extend patterns\n// lose generic signatures. We also do this because we need to Omit `clear` from\n// the type of ArrayProxy as we override it's signature.\nconst ArrayProxyWithCustomOverrides = ArrayProxy as unknown as new <T>() => ArrayProxyWithCustomOverrides<T>;\n\n/**\n Holds validation errors for a given record, organized by attribute names.\n\n This class is not directly instantiable.\n\n Every `Model` has an `errors` property that is an instance of\n `Errors`. This can be used to display validation error\n messages returned from the server when a `record.save()` rejects.\n\n For Example, if you had a `User` model that looked like this:\n\n ```js [app/models/user.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n }\n ```\n And you attempted to save a record that did not validate on the backend:\n\n ```javascript\n let user = store.createRecord('user', {\n username: 'tomster',\n email: 'invalidEmail'\n });\n user.save();\n ```\n\n Your backend would be expected to return an error response that described\n the problem, so that error messages can be generated on the app.\n\n API responses will be translated into instances of `Errors` differently,\n depending on the specific combination of adapter and serializer used. You\n may want to check the documentation or the source code of the libraries\n that you are using, to know how they expect errors to be communicated.\n\n Errors can be displayed to the user by accessing their property name\n to get an array of all the error objects for that property. Each\n error object is a JavaScript object with two keys:\n\n - `message` A string containing the error message from the backend\n - `attribute` The name of the property associated with this error message\n\n ```handlebars\n <label>Username: <Input @value={{@model.username}} /> </label>\n {{#each @model.errors.username as |error|}}\n <div class=\"error\">\n {{error.message}}\n </div>\n {{/each}}\n\n <label>Email: <Input @value={{@model.email}} /> </label>\n {{#each @model.errors.email as |error|}}\n <div class=\"error\">\n {{error.message}}\n </div>\n {{/each}}\n ```\n\n You can also access the special `messages` property on the error\n object to get an array of all the error strings.\n\n ```handlebars\n {{#each @model.errors.messages as |message|}}\n <div class=\"error\">\n {{message}}\n </div>\n {{/each}}\n ```\n\n @class Errors\n @public\n */\nexport class Errors extends ArrayProxyWithCustomOverrides<ValidationError> {\n declare __record: { currentState: RecordState };\n /**\n @property errorsByAttributeName\n @type {MapWithDefault}\n @private\n */\n @computed()\n get errorsByAttributeName(): Map<string, NativeArray<ValidationError>> {\n return new Map();\n }\n\n /**\n Returns errors for a given attribute\n\n ```javascript\n let user = store.createRecord('user', {\n username: 'tomster',\n email: 'invalidEmail'\n });\n user.save().catch(function(){\n user.errors.errorsFor('email'); // returns:\n // [{attribute: \"email\", message: \"Doesn't look like a valid email.\"}]\n });\n ```\n\n @public\n @param {String} attribute\n @return {Array}\n */\n errorsFor(attribute: string): NativeArray<ValidationError> {\n const map = this.errorsByAttributeName;\n\n let errors = map.get(attribute);\n\n if (errors === undefined) {\n errors = A<ValidationError>();\n map.set(attribute, errors);\n }\n\n // Errors may be a native array with extensions turned on. Since we access\n // the array via a method, and not a computed or using `Ember.get`, it does\n // not entangle properly with autotracking, so we entangle manually by\n // getting the `[]` property.\n get(errors, '[]');\n\n return errors;\n }\n\n /**\n An array containing all of the error messages for this\n record. This is useful for displaying all errors to the user.\n\n ```handlebars\n {{#each @model.errors.messages as |message|}}\n <div class=\"error\">\n {{message}}\n </div>\n {{/each}}\n ```\n\n @property messages\n @public\n @type {Array}\n */\n @mapBy('content', 'message')\n declare messages: string[];\n\n /**\n @property content\n @type {Array}\n @private\n */\n @computed()\n get content(): NativeArray<ValidationError> {\n return A();\n }\n\n /**\n @private\n */\n unknownProperty(attribute: string): NativeArray<ValidationError> | undefined {\n const errors = this.errorsFor(attribute);\n if (errors.length === 0) {\n return undefined;\n }\n return errors;\n }\n\n /**\n Total number of errors.\n\n @property length\n @type {Number}\n @public\n @readonly\n */\n\n /**\n `true` if we have no errors.\n\n @property isEmpty\n @type {Boolean}\n @public\n @readonly\n */\n @not('length')\n declare isEmpty: boolean;\n\n /**\n Manually adds errors to the record. This will trigger the `becameInvalid` event/ lifecycle method on\n the record and transition the record into an `invalid` state.\n\n Example\n ```javascript\n let errors = user.errors;\n\n // add multiple errors\n errors.add('password', [\n 'Must be at least 12 characters',\n 'Must contain at least one symbol',\n 'Cannot contain your name'\n ]);\n\n errors.errorsFor('password');\n // =>\n // [\n // { attribute: 'password', message: 'Must be at least 12 characters' },\n // { attribute: 'password', message: 'Must contain at least one symbol' },\n // { attribute: 'password', message: 'Cannot contain your name' },\n // ]\n\n // add a single error\n errors.add('username', 'This field is required');\n\n errors.errorsFor('username');\n // =>\n // [\n // { attribute: 'username', message: 'This field is required' },\n // ]\n ```\n @public\n @param {String} attribute - the property name of an attribute or relationship\n @param {string[]|string} messages - an error message or array of error messages for the attribute\n */\n add(attribute: string, messages: string[] | string): void {\n const errors = this._findOrCreateMessages(attribute, messages);\n this.addObjects(errors);\n\n this.errorsFor(attribute).addObjects(errors);\n this.__record.currentState.notify('isValid');\n\n this.notifyPropertyChange(attribute);\n }\n\n /**\n @private\n */\n _findOrCreateMessages(attribute: string, messages: string | string[]): ValidationError[] {\n const errors = this.errorsFor(attribute);\n const messagesArray = Array.isArray(messages) ? messages : [messages];\n const _messages: ValidationError[] = new Array(messagesArray.length) as ValidationError[];\n\n for (let i = 0; i < messagesArray.length; i++) {\n const message = messagesArray[i];\n const err = errors.findBy('message', message);\n if (err) {\n _messages[i] = err;\n } else {\n _messages[i] = {\n attribute: attribute,\n message,\n };\n }\n }\n\n return _messages;\n }\n\n /**\n Manually removes all errors for a given member from the record.\n This will transition the record into a `valid` state, and\n triggers the `becameValid` event and lifecycle method.\n\n Example:\n\n ```javascript\n let errors = user.errors;\n errors.add('phone', ['error-1', 'error-2']);\n\n errors.errorsFor('phone');\n // =>\n // [\n // { attribute: 'phone', message: 'error-1' },\n // { attribute: 'phone', message: 'error-2' },\n // ]\n\n errors.remove('phone');\n\n errors.errorsFor('phone');\n // => undefined\n ```\n @public\n @param {String} member - the property name of an attribute or relationship\n */\n remove(attribute: string): void {\n if (this.isEmpty) {\n return;\n }\n\n const content = this.rejectBy('attribute', attribute);\n this.content.setObjects(content);\n\n // Although errorsByAttributeName.delete is technically enough to sync errors state, we also\n // must mutate the array as well for autotracking\n const errors = this.errorsFor(attribute);\n for (let i = 0; i < errors.length; i++) {\n if (errors[i].attribute === attribute) {\n // .replace from Ember.NativeArray is necessary. JS splice will not work.\n errors.replace(i, 1);\n }\n }\n this.errorsByAttributeName.delete(attribute);\n\n this.__record.currentState.notify('isValid');\n this.notifyPropertyChange(attribute);\n this.notifyPropertyChange('length');\n }\n\n /**\n Manually clears all errors for the record.\n This will transition the record into a `valid` state, and\n will trigger the `becameValid` event and lifecycle method.\n\n Example:\n\n ```javascript\n let errors = user.errors;\n errors.add('username', ['error-a']);\n errors.add('phone', ['error-1', 'error-2']);\n\n errors.errorsFor('username');\n // =>\n // [\n // { attribute: 'username', message: 'error-a' },\n // ]\n\n errors.errorsFor('phone');\n // =>\n // [\n // { attribute: 'phone', message: 'error-1' },\n // { attribute: 'phone', message: 'error-2' },\n // ]\n\n errors.clear();\n\n errors.errorsFor('username');\n // => undefined\n\n errors.errorsFor('phone');\n // => undefined\n\n errors.messages\n // => []\n ```\n @public\n */\n clear(): void {\n if (this.isEmpty) {\n return;\n }\n\n const errorsByAttributeName = this.errorsByAttributeName;\n const attributes: string[] = [];\n\n errorsByAttributeName.forEach(function (_, attribute) {\n attributes.push(attribute);\n });\n\n errorsByAttributeName.clear();\n attributes.forEach((attribute) => {\n this.notifyPropertyChange(attribute);\n });\n\n this.__record.currentState.notify('isValid');\n super.clear();\n }\n\n /**\n Checks if there are error messages for the given attribute.\n\n ```js [app/controllers/user/edit.js]\n export default class UserEditController extends Controller {\n @action\n save(user) {\n if (user.errors.has('email')) {\n return alert('Please update your email before attempting to save.');\n }\n user.save();\n }\n }\n ```\n\n @public\n @param {String} attribute\n @return {Boolean} true if there some errors on given attribute\n */\n has(attribute: string): boolean {\n return this.errorsFor(attribute).length > 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,MAAa,gBAAgB,YAAY,OAAO,iBAAiB;;;;ACqBjE,MAAaI,qBAAoCC,OAAOC,IAAI,oBAAoB;AAShF,MAAMC,WACJL;;;;;;;;;AAeF,IAAMM,mBAAN,cAA4CD,SAAY;CAGtD,IACIE,KAAoB;EACtB,MAAM,EAAEC,KAAKC,kBAAkB,KAAKC;EAGpC,OAFYD,cAAcG,aAAa,aAAaJ,GAE7CG,CAAG,CAACJ,GAAG;CAChB;CAIA;EAAAN,iBAAA,KAAAY,WAAA,MAAA,CAVCd,QAAQ,CAAA;CAAA;CAWT,IACIe,OAAa,CAWjB;CAAC;EAAAb,iBAAA,KAAAY,WAAA,QAAA,CAZAf,SAAS,CAAC,CAAA;CAAA;CAcX,MAAMiB,OAAOC,SAAiD;EAE5D,MAAM,EAAER,KAAKC,kBAAkB,KAAKC;EACpC,MAAMD,cAAcQ,gBAAgBT,KAAKQ,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AC5C,IAAIC,KACFF,UAAU3B,KAAK6B;QAEfF,UAAU3B,KAAK;IACFO;IACXqB;GACF;EAEJ;EAEA,OAAOD;CACT;;;;;;;;;;;;;;;;;;;;;;CA4BAI,OAAOxB,WAAyB;EAC9B,IAAI,KAAKS,SACP;EAGF,MAAMH,UAAU,KAAKmB,SAAS,aAAazB,SAAS;EACpD,KAAKM,QAAQoB,WAAWpB,OAAO;EAI/B,MAAMJ,SAAS,KAAKH,UAAUC,SAAS;EACvC,KAAK,IAAIP,IAAI,GAAGA,IAAIS,OAAOM,QAAQf,KACjC,IAAIS,OAAOT,EAAE,CAACO,cAAcA,WAE1BE,OAAOyB,QAAQlC,GAAG,CAAC;EAGvB,KAAKG,sBAAsBgC,OAAO5B,SAAS;EAE3C,KAAKa,SAASC,aAAaC,OAAO,SAAS;EAC3C,KAAKC,qBAAqBhB,SAAS;EACnC,KAAKgB,qBAAqB,QAAQ;CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCAa,QAAc;EACZ,IAAI,KAAKpB,SACP;EAGF,MAAMb,wBAAwB,KAAKA;EACnC,MAAMkC,aAAuB,CAAA;EAE7BlC,sBAAsBmC,QAAQ,SAAUC,GAAGhC,WAAW;GACpD8B,WAAWG,KAAKjC,SAAS;EAC3B,CAAC;EAEDJ,sBAAsBiC,MAAM;EAC5BC,WAAWC,SAAS/B,cAAc;GAChC,KAAKgB,qBAAqBhB,SAAS;EACrC,CAAC;EAED,KAAKa,SAASC,aAAaC,OAAO,SAAS;EAC3C,MAAMc,MAAM;CACd;;;;;;;;;;;;;;;;;;CAqBAK,IAAIlC,WAA4B;EAC9B,OAAO,KAAKD,UAAUC,SAAS,CAAC,CAACQ,SAAS;CAC5C;AACF"}
@@ -1,16 +1,18 @@
1
- import { a as serializeRecord, i as pushPayload, n as cleanup, o as serializerFor, r as normalize, s as LegacyNetworkHandler, t as adapterFor } from "./compat-BM3u_d5-.js";
1
+ import { a as serializeRecord, i as pushPayload, n as cleanup, o as serializerFor, r as normalize, s as LegacyNetworkHandler, t as adapterFor } from "./compat-DFMtpQGs.js";
2
2
  import { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from "./compat/extensions.js";
3
- import { n as modelFor, r as teardownRecord$1, t as instantiateRecord$1 } from "./model-qeqVBN2l.js";
4
- import { i as releaseLegacySupport } from "./errors-BX8zhQS4.js";
5
- import { a as FragmentExtension, s as FragmentArrayExtension, t as fragmentsModelFor } from "./model-fragments-DSqu0ptR.js";
3
+ import { n as modelFor, r as teardownRecord$1, t as instantiateRecord$1 } from "./model-wzHTp8Up.js";
4
+ import { i as releaseLegacySupport } from "./errors-DIOUcGAT.js";
5
+ import { a as FragmentExtension, s as FragmentArrayExtension, t as fragmentsModelFor } from "./model-fragments-ZM4k_mT3.js";
6
6
  import { DelegatingSchemaService, registerDerivations as registerDerivations$1 } from "./model/migration-support.js";
7
- import { t as restoreDeprecatedStoreBehaviors } from "./store-0L2CkYzh.js";
7
+ import { t as restoreDeprecatedStoreBehaviors } from "./store-CB_rVlXv.js";
8
8
  import { CacheHandler, Fetch, RequestManager, Store, recordIdentifierFor } from "@warp-drive/core";
9
9
  import { SchemaService, instantiateRecord, registerDerivations, teardownRecord } from "@warp-drive/core/reactive";
10
10
  import { DefaultCachePolicy } from "@warp-drive/core/store";
11
11
 
12
12
  //#region src/index.ts
13
13
  /**
14
+ * @summary Legacy `Model`, adapter, and serializer support for WarpDrive, including `useLegacyStore` to configure a
15
+ * store that uses them.
14
16
  * @module
15
17
  * @mergeModuleWith <project>
16
18
  */
@@ -18,6 +20,8 @@ import { DefaultCachePolicy } from "@warp-drive/core/store";
18
20
  * Setup options for a legacy store configured to use `Model` with `linksMode`
19
21
  * enabled, meaning no legacy adapter/serializer request infrastructure is required.
20
22
  *
23
+ * @summary `useLegacyStore` options for a store that uses `Model` in `linksMode`, without the legacy adapter and
24
+ * serializer network layer.
21
25
  * @public
22
26
  */
23
27
  /**
@@ -25,6 +29,8 @@ import { DefaultCachePolicy } from "@warp-drive/core/store";
25
29
  * legacy adapter/serializer network layer, but without the deprecated
26
30
  * `store.findRecord`/`findAll`/`query`/etc. request methods.
27
31
  *
32
+ * @summary `useLegacyStore` options for a store that uses `Model` and the legacy adapter and serializer network
33
+ * layer, without deprecated request methods like `store.findRecord`.
28
34
  * @public
29
35
  */
30
36
  /**
@@ -32,6 +38,8 @@ import { DefaultCachePolicy } from "@warp-drive/core/store";
32
38
  * legacy adapter/serializer network layer and the deprecated
33
39
  * `store.findRecord`/`findAll`/`query`/etc. request methods.
34
40
  *
41
+ * @summary `useLegacyStore` options for a store that uses `Model`, the legacy adapter and serializer network layer,
42
+ * and deprecated request methods like `store.findRecord`.
35
43
  * @public
36
44
  */
37
45
  /**
@@ -41,10 +49,17 @@ import { DefaultCachePolicy } from "@warp-drive/core/store";
41
49
  * - {@link LegacyModelStoreSetupOptions}
42
50
  * - {@link LegacyModelAndNetworkStoreSetupOptions}
43
51
  * - {@link LegacyModelAndNetworkAndRequestStoreSetupOptions}
52
+ *
53
+ * @summary Options accepted by `useLegacyStore`, choosing via `linksMode` and `legacyRequests` how much of the
54
+ * legacy `Model`, adapter, and request support to enable.
44
55
  */
45
56
  /**
46
57
  * Use the legacy store with the given options.
47
58
  *
59
+ * See [Configure The Store](/guides/configuration/#configure-the-store) for where it fits in an
60
+ * app's setup, and [LegacyMode](/guides/the-manual/schemas/resources/legacy-mode) for the schemas
61
+ * it supports.
62
+ *
48
63
  * See {@link LegacyStoreSetupOptions} for details on the available options.
49
64
  *
50
65
  * ```ts
@@ -155,6 +170,9 @@ import { DefaultCachePolicy } from "@warp-drive/core/store";
155
170
  * {@link RequestManager} won't have it set unless the caller supplies it
156
171
  * explicitly, so a handler relying on it should treat it as optional (as
157
172
  * `LoggingHandler` does above).
173
+ *
174
+ * @summary Creates a `Store` class preconfigured for legacy apps, with `Model` schema support, request handlers,
175
+ * cache, and optional adapter, serializer, and fragment support.
158
176
  */
159
177
  function useLegacyStore(options, StoreKlass = Store) {
160
178
  class BaseKlass extends StoreKlass {}