@warp-drive/legacy 5.10.0-alpha.2 → 5.10.0-alpha.21

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 (413) hide show
  1. package/README.md +91 -8
  2. package/blueprints/adapter/files/__root__/__path__/__name__.js +1 -0
  3. package/blueprints/adapter/index.js +27 -0
  4. package/blueprints/adapter-test/index.js +33 -0
  5. package/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js +1 -0
  6. package/blueprints/model/HELP.md +26 -0
  7. package/blueprints/model/files/__root__/__path__/__name__.js +1 -0
  8. package/blueprints/model/index.js +27 -0
  9. package/blueprints/model-test/index.js +33 -0
  10. package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +1 -0
  11. package/blueprints/serializer/files/__root__/__path__/__name__.js +1 -0
  12. package/blueprints/serializer/index.js +27 -0
  13. package/blueprints/serializer-test/index.js +33 -0
  14. package/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +1 -0
  15. package/blueprints/transform/files/__root__/__path__/__name__.js +1 -0
  16. package/blueprints/transform/index.js +17 -0
  17. package/blueprints/transform-test/index.js +33 -0
  18. package/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +1 -0
  19. package/dist/{-private-DccRZQsm.js → -private-0_Oc-M3x.js} +10 -17
  20. package/dist/-private-0_Oc-M3x.js.map +1 -0
  21. package/dist/{-private-DQ6Iap2t.js → -private-L2BtGGYa.js} +8 -14
  22. package/dist/{-private-DQ6Iap2t.js.map → -private-L2BtGGYa.js.map} +1 -1
  23. package/dist/adapter/-private.d.ts +2 -12
  24. package/dist/adapter/-private.d.ts.map +1 -1
  25. package/dist/adapter/-private.js +1 -1
  26. package/dist/adapter/error.d.ts +1 -1
  27. package/dist/adapter/error.js +54 -2
  28. package/dist/adapter/error.js.map +1 -1
  29. package/dist/adapter/json-api.d.ts +5 -5
  30. package/dist/adapter/json-api.d.ts.map +1 -1
  31. package/dist/adapter/json-api.js +10 -4
  32. package/dist/adapter/json-api.js.map +1 -1
  33. package/dist/adapter/rest.d.ts +1 -1
  34. package/dist/adapter/rest.js +23 -5
  35. package/dist/adapter/rest.js.map +1 -1
  36. package/dist/{adapter-eYo2pIuM.js → adapter-AwGvdMSZ.js} +45 -6
  37. package/dist/adapter-AwGvdMSZ.js.map +1 -0
  38. package/dist/{adapter-CARrK3-8.d.ts → adapter-DvDVeaCc.d.ts} +9 -6
  39. package/dist/adapter-DvDVeaCc.d.ts.map +1 -0
  40. package/dist/adapter.d.ts +1 -1
  41. package/dist/adapter.js +1 -1
  42. package/dist/compat/-private.d.ts +1 -1
  43. package/dist/compat/-private.js +1 -1
  44. package/dist/compat/builders.d.ts +10 -8
  45. package/dist/compat/builders.d.ts.map +1 -1
  46. package/dist/compat/builders.js +15 -9
  47. package/dist/compat/builders.js.map +1 -1
  48. package/dist/compat/extensions.d.ts +1 -1
  49. package/dist/compat/extensions.js +23 -2
  50. package/dist/compat/extensions.js.map +1 -1
  51. package/dist/compat/utils.d.ts +17 -2
  52. package/dist/compat/utils.d.ts.map +1 -1
  53. package/dist/compat/utils.js +19 -2
  54. package/dist/compat/utils.js.map +1 -1
  55. package/dist/{compat-DcHVxuuZ.js → compat-C-yQnbkF.js} +61 -8
  56. package/dist/compat-C-yQnbkF.js.map +1 -0
  57. package/dist/{compat-BbNNmTM-.d.ts → compat-DoWEarkU.d.ts} +30 -17
  58. package/dist/compat-DoWEarkU.d.ts.map +1 -0
  59. package/dist/compat.d.ts +1 -1
  60. package/dist/compat.js +1 -1
  61. package/dist/{error-CzkyXr1Q.d.ts → error-798wGD3r.d.ts} +49 -3
  62. package/dist/error-798wGD3r.d.ts.map +1 -0
  63. package/dist/{errors-CS110tMl.js → errors-BEExAZtv.js} +42 -32
  64. package/dist/errors-BEExAZtv.js.map +1 -0
  65. package/dist/{extensions-DumNm4dA.d.ts → extensions-DcEz1lKv.d.ts} +18 -3
  66. package/dist/extensions-DcEz1lKv.d.ts.map +1 -0
  67. package/dist/index.d.ts +17 -2
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +25 -7
  70. package/dist/index.js.map +1 -1
  71. package/dist/{json-BXNPTlcH.js → json-Baaga4BP.js} +10 -5
  72. package/dist/json-Baaga4BP.js.map +1 -0
  73. package/dist/model/-private.d.ts +1 -1
  74. package/dist/model/-private.js +1 -1
  75. package/dist/model/migration-support.d.ts +19 -4
  76. package/dist/model/migration-support.d.ts.map +1 -1
  77. package/dist/model/migration-support.js +25 -7
  78. package/dist/model/migration-support.js.map +1 -1
  79. package/dist/{model-DWH9f__L.js → model-Be-e84FX.js} +19 -12
  80. package/dist/model-Be-e84FX.js.map +1 -0
  81. package/dist/{model-62hn5_PD.d.ts → model-DAdY1ibr.d.ts} +13 -26
  82. package/dist/model-DAdY1ibr.d.ts.map +1 -0
  83. package/dist/{unpkg/dev-deprecated/model-fragments-DSqu0ptR.js → model-fragments-DCHMDr5f.js} +32 -18
  84. package/dist/model-fragments-DCHMDr5f.js.map +1 -0
  85. package/dist/model-fragments.d.ts +31 -19
  86. package/dist/model-fragments.d.ts.map +1 -1
  87. package/dist/model-fragments.js +1 -1
  88. package/dist/model.d.ts +12 -11
  89. package/dist/model.d.ts.map +1 -1
  90. package/dist/model.js +2 -2
  91. package/dist/{rest-0NhtexIq.d.ts → rest-CmFneLJH.d.ts} +18 -8
  92. package/dist/rest-CmFneLJH.d.ts.map +1 -0
  93. package/dist/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  94. package/dist/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  95. package/dist/{schema-provider-DguGmQDS.js → schema-provider-BAB8DyMr.js} +22 -21
  96. package/dist/schema-provider-BAB8DyMr.js.map +1 -0
  97. package/dist/serializer/json-api.d.ts +1 -2
  98. package/dist/serializer/json-api.d.ts.map +1 -1
  99. package/dist/serializer/json-api.js +7 -3
  100. package/dist/serializer/json-api.js.map +1 -1
  101. package/dist/serializer/json.d.ts +2 -2
  102. package/dist/serializer/json.d.ts.map +1 -1
  103. package/dist/serializer/json.js +1 -1
  104. package/dist/serializer/rest.d.ts +4 -4
  105. package/dist/serializer/rest.d.ts.map +1 -1
  106. package/dist/serializer/rest.js +12 -5
  107. package/dist/serializer/rest.js.map +1 -1
  108. package/dist/serializer/transform.d.ts +9 -10
  109. package/dist/serializer/transform.d.ts.map +1 -1
  110. package/dist/serializer/transform.js +14 -10
  111. package/dist/serializer/transform.js.map +1 -1
  112. package/dist/serializer.d.ts +2 -2
  113. package/dist/serializer.d.ts.map +1 -1
  114. package/dist/serializer.js +42 -3
  115. package/dist/serializer.js.map +1 -1
  116. package/dist/{store-C4qYzXei.js → store-BLKEsJyw.js} +13 -7
  117. package/dist/store-BLKEsJyw.js.map +1 -0
  118. package/dist/store.d.ts +3 -2
  119. package/dist/store.d.ts.map +1 -1
  120. package/dist/store.js +1 -1
  121. package/dist/unpkg/dev/{-private-CrEyBE-B.js → -private-BprUAEe_.js} +8 -14
  122. package/dist/unpkg/{dev-deprecated/-private-CrEyBE-B.js.map → dev/-private-BprUAEe_.js.map} +1 -1
  123. package/dist/unpkg/dev/{-private-vOhxVExH.js → -private-Dch4SxkU.js} +10 -17
  124. package/dist/unpkg/dev/-private-Dch4SxkU.js.map +1 -0
  125. package/dist/unpkg/dev/adapter/-private.js +1 -1
  126. package/dist/unpkg/dev/adapter/error.js +54 -2
  127. package/dist/unpkg/dev/adapter/error.js.map +1 -1
  128. package/dist/unpkg/dev/adapter/json-api.js +10 -4
  129. package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
  130. package/dist/unpkg/dev/adapter/rest.js +23 -5
  131. package/dist/unpkg/dev/adapter/rest.js.map +1 -1
  132. package/dist/unpkg/dev/{adapter-oLwyr47q.js → adapter-BAn4SeUA.js} +45 -6
  133. package/dist/unpkg/dev/adapter-BAn4SeUA.js.map +1 -0
  134. package/dist/unpkg/dev/adapter.js +1 -1
  135. package/dist/unpkg/dev/compat/-private.js +1 -1
  136. package/dist/unpkg/dev/compat/builders.js +15 -9
  137. package/dist/unpkg/dev/compat/builders.js.map +1 -1
  138. package/dist/unpkg/dev/compat/extensions.js +23 -2
  139. package/dist/unpkg/dev/compat/extensions.js.map +1 -1
  140. package/dist/unpkg/dev/compat/utils.js +19 -2
  141. package/dist/unpkg/dev/compat/utils.js.map +1 -1
  142. package/dist/unpkg/dev/{compat-DNQT2TQx.js → compat-BdovRRzQ.js} +62 -10
  143. package/dist/unpkg/dev/compat-BdovRRzQ.js.map +1 -0
  144. package/dist/unpkg/dev/compat.js +1 -1
  145. package/dist/unpkg/dev/{errors-DnzvLM2A.js → errors-CGvbM6WH.js} +42 -32
  146. package/dist/unpkg/dev/errors-CGvbM6WH.js.map +1 -0
  147. package/dist/unpkg/dev/index.js +25 -7
  148. package/dist/unpkg/dev/index.js.map +1 -1
  149. package/dist/unpkg/{dev-deprecated/json-DDJji3V3.js → dev/json-BlSBe84o.js} +10 -5
  150. package/dist/unpkg/dev/json-BlSBe84o.js.map +1 -0
  151. package/dist/unpkg/dev/model/-private.js +1 -1
  152. package/dist/unpkg/dev/model/migration-support.js +24 -6
  153. package/dist/unpkg/dev/model/migration-support.js.map +1 -1
  154. package/dist/unpkg/dev/{model-BxPIR7m2.js → model-QCZr8eec.js} +19 -12
  155. package/dist/unpkg/dev/model-QCZr8eec.js.map +1 -0
  156. package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev/model-fragments-DCHMDr5f.js} +32 -18
  157. package/dist/unpkg/dev/model-fragments-DCHMDr5f.js.map +1 -0
  158. package/dist/unpkg/dev/model-fragments.js +1 -1
  159. package/dist/unpkg/dev/model.js +2 -2
  160. package/dist/unpkg/dev/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  161. package/dist/unpkg/dev/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  162. package/dist/unpkg/dev/{schema-provider-CI_a48ja.js → schema-provider-IMFO9Kgw.js} +18 -17
  163. package/dist/unpkg/dev/schema-provider-IMFO9Kgw.js.map +1 -0
  164. package/dist/unpkg/dev/serializer/json-api.js +7 -3
  165. package/dist/unpkg/dev/serializer/json-api.js.map +1 -1
  166. package/dist/unpkg/dev/serializer/json.js +1 -1
  167. package/dist/unpkg/dev/serializer/rest.js +12 -5
  168. package/dist/unpkg/dev/serializer/rest.js.map +1 -1
  169. package/dist/unpkg/dev/serializer/transform.js +14 -10
  170. package/dist/unpkg/dev/serializer/transform.js.map +1 -1
  171. package/dist/unpkg/dev/serializer.js +42 -3
  172. package/dist/unpkg/dev/serializer.js.map +1 -1
  173. package/dist/unpkg/dev/{store-D_V8-HQl.js → store-BiXsLLAu.js} +13 -7
  174. package/dist/unpkg/dev/store-BiXsLLAu.js.map +1 -0
  175. package/dist/unpkg/dev/store.js +1 -1
  176. package/dist/unpkg/dev/{util-dSKEgQDp.js → util-CI7b4vAE.js} +2 -3
  177. package/dist/unpkg/dev/{util-dSKEgQDp.js.map → util-CI7b4vAE.js.map} +1 -1
  178. package/dist/unpkg/{prod/utils-DYC9utVJ.js → dev/utils-_O0MjUTU.js} +2 -3
  179. package/dist/unpkg/dev/{utils-DYC9utVJ.js.map → utils-_O0MjUTU.js.map} +1 -1
  180. package/dist/unpkg/dev-deprecated/{-private-CrEyBE-B.js → -private-BprUAEe_.js} +8 -14
  181. package/dist/unpkg/{dev/-private-CrEyBE-B.js.map → dev-deprecated/-private-BprUAEe_.js.map} +1 -1
  182. package/dist/unpkg/dev-deprecated/{-private-vOhxVExH.js → -private-Dch4SxkU.js} +10 -17
  183. package/dist/unpkg/dev-deprecated/-private-Dch4SxkU.js.map +1 -0
  184. package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -1
  185. package/dist/unpkg/dev-deprecated/adapter/error.js +54 -2
  186. package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
  187. package/dist/unpkg/dev-deprecated/adapter/json-api.js +10 -4
  188. package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
  189. package/dist/unpkg/dev-deprecated/adapter/rest.js +23 -5
  190. package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
  191. package/dist/unpkg/dev-deprecated/{adapter-oLwyr47q.js → adapter-BAn4SeUA.js} +45 -6
  192. package/dist/unpkg/dev-deprecated/adapter-BAn4SeUA.js.map +1 -0
  193. package/dist/unpkg/dev-deprecated/adapter.js +1 -1
  194. package/dist/unpkg/dev-deprecated/compat/-private.js +1 -1
  195. package/dist/unpkg/dev-deprecated/compat/builders.js +15 -9
  196. package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -1
  197. package/dist/unpkg/dev-deprecated/compat/extensions.js +23 -2
  198. package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
  199. package/dist/unpkg/dev-deprecated/compat/utils.js +19 -2
  200. package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -1
  201. package/dist/unpkg/dev-deprecated/{compat-CeT0PnVX.js → compat-CPVriwH0.js} +62 -10
  202. package/dist/unpkg/dev-deprecated/compat-CPVriwH0.js.map +1 -0
  203. package/dist/unpkg/dev-deprecated/compat.js +1 -1
  204. package/dist/unpkg/dev-deprecated/{errors-jHQESeNQ.js → errors-yPc7D7r3.js} +42 -32
  205. package/dist/unpkg/dev-deprecated/errors-yPc7D7r3.js.map +1 -0
  206. package/dist/unpkg/dev-deprecated/index.js +25 -7
  207. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  208. package/dist/unpkg/{dev/json-DDJji3V3.js → dev-deprecated/json-BlSBe84o.js} +10 -5
  209. package/dist/unpkg/dev-deprecated/json-BlSBe84o.js.map +1 -0
  210. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  211. package/dist/unpkg/dev-deprecated/model/migration-support.js +24 -6
  212. package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
  213. package/dist/unpkg/dev-deprecated/{model-BeGORt6h.js → model-B0ZNLaHO.js} +19 -12
  214. package/dist/unpkg/dev-deprecated/model-B0ZNLaHO.js.map +1 -0
  215. package/dist/unpkg/{prod-deprecated/model-fragments-DSqu0ptR.js → dev-deprecated/model-fragments-DCHMDr5f.js} +32 -18
  216. package/dist/unpkg/dev-deprecated/model-fragments-DCHMDr5f.js.map +1 -0
  217. package/dist/unpkg/dev-deprecated/model-fragments.js +1 -1
  218. package/dist/unpkg/dev-deprecated/model.js +2 -2
  219. package/dist/unpkg/dev-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  220. package/dist/unpkg/dev-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  221. package/dist/unpkg/dev-deprecated/{schema-provider-NmtdR4n_.js → schema-provider-DGWYnFno.js} +18 -17
  222. package/dist/unpkg/dev-deprecated/schema-provider-DGWYnFno.js.map +1 -0
  223. package/dist/unpkg/dev-deprecated/serializer/json-api.js +7 -3
  224. package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -1
  225. package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
  226. package/dist/unpkg/dev-deprecated/serializer/rest.js +12 -5
  227. package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
  228. package/dist/unpkg/dev-deprecated/serializer/transform.js +14 -10
  229. package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
  230. package/dist/unpkg/dev-deprecated/serializer.js +42 -3
  231. package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
  232. package/dist/unpkg/dev-deprecated/{store-BCOLSC6z.js → store-Ci8k7Lh6.js} +13 -7
  233. package/dist/unpkg/dev-deprecated/store-Ci8k7Lh6.js.map +1 -0
  234. package/dist/unpkg/dev-deprecated/store.js +1 -1
  235. package/dist/unpkg/dev-deprecated/{util-CXA3RNYH.js → util-DL_8JecH.js} +2 -3
  236. package/dist/unpkg/dev-deprecated/{util-CXA3RNYH.js.map → util-DL_8JecH.js.map} +1 -1
  237. package/dist/unpkg/dev-deprecated/{utils-DQkMqhDv.js → utils-DyGjRZ14.js} +2 -3
  238. package/dist/unpkg/dev-deprecated/{utils-DQkMqhDv.js.map → utils-DyGjRZ14.js.map} +1 -1
  239. package/dist/unpkg/{prod-deprecated/-private-B4bxoTuK.js → prod/-private-Dc9yg98O.js} +8 -14
  240. package/dist/unpkg/{prod-deprecated/-private-B4bxoTuK.js.map → prod/-private-Dc9yg98O.js.map} +1 -1
  241. package/dist/unpkg/prod/{-private-SfXkkHKd.js → -private-DuRzYAyW.js} +9 -15
  242. package/dist/unpkg/prod/-private-DuRzYAyW.js.map +1 -0
  243. package/dist/unpkg/prod/adapter/-private.js +1 -1
  244. package/dist/unpkg/prod/adapter/error.js +54 -2
  245. package/dist/unpkg/prod/adapter/error.js.map +1 -1
  246. package/dist/unpkg/prod/adapter/json-api.js +10 -4
  247. package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
  248. package/dist/unpkg/prod/adapter/rest.js +23 -5
  249. package/dist/unpkg/prod/adapter/rest.js.map +1 -1
  250. package/dist/unpkg/prod/{adapter-DQ9UA7FC.js → adapter-D0HCLrwm.js} +45 -6
  251. package/dist/unpkg/prod/adapter-D0HCLrwm.js.map +1 -0
  252. package/dist/unpkg/prod/adapter.js +1 -1
  253. package/dist/unpkg/prod/compat/-private.js +1 -1
  254. package/dist/unpkg/prod/compat/builders.js +15 -9
  255. package/dist/unpkg/prod/compat/builders.js.map +1 -1
  256. package/dist/unpkg/prod/compat/extensions.js +23 -2
  257. package/dist/unpkg/prod/compat/extensions.js.map +1 -1
  258. package/dist/unpkg/prod/compat/utils.js +19 -2
  259. package/dist/unpkg/prod/compat/utils.js.map +1 -1
  260. package/dist/unpkg/{prod-deprecated/compat-DxiVkCUb.js → prod/compat-PrUuencH.js} +62 -10
  261. package/dist/unpkg/prod/compat-PrUuencH.js.map +1 -0
  262. package/dist/unpkg/prod/compat.js +1 -1
  263. package/dist/unpkg/prod/{errors-DQDfNqVx.js → errors-Bw8niCo8.js} +38 -27
  264. package/dist/unpkg/prod/errors-Bw8niCo8.js.map +1 -0
  265. package/dist/unpkg/prod/index.js +25 -7
  266. package/dist/unpkg/prod/index.js.map +1 -1
  267. package/dist/unpkg/prod/{json-BD1kRTfB.js → json-D1bH8enA.js} +10 -5
  268. package/dist/unpkg/prod/json-D1bH8enA.js.map +1 -0
  269. package/dist/unpkg/prod/model/-private.js +1 -1
  270. package/dist/unpkg/prod/model/migration-support.js +24 -6
  271. package/dist/unpkg/prod/model/migration-support.js.map +1 -1
  272. package/dist/unpkg/prod/{model-CYMA-e_S.js → model-QtC0IWbE.js} +19 -12
  273. package/dist/unpkg/prod/model-QtC0IWbE.js.map +1 -0
  274. package/dist/unpkg/prod/model-fragments-DCHMDr5f.js +348 -0
  275. package/dist/unpkg/prod/model-fragments-DCHMDr5f.js.map +1 -0
  276. package/dist/unpkg/prod/model-fragments.js +1 -1
  277. package/dist/unpkg/prod/model.js +2 -2
  278. package/dist/unpkg/prod/runtime--fcdnjmJ-5yaSpa-d.js +52 -0
  279. package/dist/unpkg/prod/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  280. package/dist/unpkg/prod/{schema-provider-05U1H-Kl.js → schema-provider-DPOzTa8e.js} +18 -17
  281. package/dist/unpkg/prod/schema-provider-DPOzTa8e.js.map +1 -0
  282. package/dist/unpkg/prod/serializer/json-api.js +7 -3
  283. package/dist/unpkg/prod/serializer/json-api.js.map +1 -1
  284. package/dist/unpkg/prod/serializer/json.js +1 -1
  285. package/dist/unpkg/prod/serializer/rest.js +12 -5
  286. package/dist/unpkg/prod/serializer/rest.js.map +1 -1
  287. package/dist/unpkg/prod/serializer/transform.js +14 -10
  288. package/dist/unpkg/prod/serializer/transform.js.map +1 -1
  289. package/dist/unpkg/prod/serializer.js +42 -3
  290. package/dist/unpkg/prod/serializer.js.map +1 -1
  291. package/dist/unpkg/{prod-deprecated/store-0L2CkYzh.js → prod/store-BsSkzWgk.js} +13 -7
  292. package/dist/unpkg/{prod-deprecated/store-0L2CkYzh.js.map → prod/store-BsSkzWgk.js.map} +1 -1
  293. package/dist/unpkg/prod/store.js +1 -1
  294. package/dist/unpkg/prod/{util-dSKEgQDp.js → util-CI7b4vAE.js} +2 -3
  295. package/dist/unpkg/prod/{util-dSKEgQDp.js.map → util-CI7b4vAE.js.map} +1 -1
  296. package/dist/unpkg/{dev/utils-DYC9utVJ.js → prod/utils-_O0MjUTU.js} +2 -3
  297. package/dist/unpkg/prod/{utils-DYC9utVJ.js.map → utils-_O0MjUTU.js.map} +1 -1
  298. package/dist/unpkg/{prod/-private-B4bxoTuK.js → prod-deprecated/-private-Dc9yg98O.js} +8 -14
  299. package/dist/unpkg/{prod/-private-B4bxoTuK.js.map → prod-deprecated/-private-Dc9yg98O.js.map} +1 -1
  300. package/dist/unpkg/prod-deprecated/{-private-SfXkkHKd.js → -private-DuRzYAyW.js} +9 -15
  301. package/dist/unpkg/prod-deprecated/-private-DuRzYAyW.js.map +1 -0
  302. package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -1
  303. package/dist/unpkg/prod-deprecated/adapter/error.js +54 -2
  304. package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
  305. package/dist/unpkg/prod-deprecated/adapter/json-api.js +10 -4
  306. package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
  307. package/dist/unpkg/prod-deprecated/adapter/rest.js +23 -5
  308. package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
  309. package/dist/unpkg/prod-deprecated/{adapter-DQ9UA7FC.js → adapter-D0HCLrwm.js} +45 -6
  310. package/dist/unpkg/prod-deprecated/adapter-D0HCLrwm.js.map +1 -0
  311. package/dist/unpkg/prod-deprecated/adapter.js +1 -1
  312. package/dist/unpkg/prod-deprecated/compat/-private.js +1 -1
  313. package/dist/unpkg/prod-deprecated/compat/builders.js +15 -9
  314. package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -1
  315. package/dist/unpkg/prod-deprecated/compat/extensions.js +23 -2
  316. package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
  317. package/dist/unpkg/prod-deprecated/compat/utils.js +19 -2
  318. package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -1
  319. package/dist/unpkg/{prod/compat-DxiVkCUb.js → prod-deprecated/compat-PrUuencH.js} +62 -10
  320. package/dist/unpkg/prod-deprecated/compat-PrUuencH.js.map +1 -0
  321. package/dist/unpkg/prod-deprecated/compat.js +1 -1
  322. package/dist/unpkg/prod-deprecated/{errors-ii4L43_1.js → errors-D20lKboZ.js} +38 -27
  323. package/dist/unpkg/prod-deprecated/errors-D20lKboZ.js.map +1 -0
  324. package/dist/unpkg/prod-deprecated/index.js +25 -7
  325. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  326. package/dist/unpkg/prod-deprecated/{json-BD1kRTfB.js → json-D1bH8enA.js} +10 -5
  327. package/dist/unpkg/prod-deprecated/json-D1bH8enA.js.map +1 -0
  328. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  329. package/dist/unpkg/prod-deprecated/model/migration-support.js +24 -6
  330. package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
  331. package/dist/unpkg/prod-deprecated/{model-D3oCPHtM.js → model-B946S2pl.js} +19 -12
  332. package/dist/unpkg/prod-deprecated/model-B946S2pl.js.map +1 -0
  333. package/dist/unpkg/{dev/model-fragments-DSqu0ptR.js → prod-deprecated/model-fragments-DCHMDr5f.js} +32 -18
  334. package/dist/unpkg/prod-deprecated/model-fragments-DCHMDr5f.js.map +1 -0
  335. package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
  336. package/dist/unpkg/prod-deprecated/model.js +2 -2
  337. package/dist/unpkg/prod-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  338. package/dist/unpkg/prod-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  339. package/dist/unpkg/prod-deprecated/{schema-provider-CKH_bnnS.js → schema-provider-xcaytn9y.js} +18 -17
  340. package/dist/unpkg/prod-deprecated/schema-provider-xcaytn9y.js.map +1 -0
  341. package/dist/unpkg/prod-deprecated/serializer/json-api.js +7 -3
  342. package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -1
  343. package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
  344. package/dist/unpkg/prod-deprecated/serializer/rest.js +12 -5
  345. package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
  346. package/dist/unpkg/prod-deprecated/serializer/transform.js +14 -10
  347. package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
  348. package/dist/unpkg/prod-deprecated/serializer.js +42 -3
  349. package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
  350. package/dist/unpkg/{prod/store-RGGc1ilN.js → prod-deprecated/store-Dsw2f4s-.js} +13 -7
  351. package/dist/unpkg/{prod/store-RGGc1ilN.js.map → prod-deprecated/store-Dsw2f4s-.js.map} +1 -1
  352. package/dist/unpkg/prod-deprecated/store.js +1 -1
  353. package/dist/unpkg/prod-deprecated/{util-CQQdHX3n.js → util-CVu5_VeN.js} +2 -3
  354. package/dist/unpkg/prod-deprecated/{util-CQQdHX3n.js.map → util-CVu5_VeN.js.map} +1 -1
  355. package/dist/unpkg/prod-deprecated/{utils-BMI_JwFP.js → utils-z1h-zTls.js} +2 -3
  356. package/dist/unpkg/prod-deprecated/{utils-BMI_JwFP.js.map → utils-z1h-zTls.js.map} +1 -1
  357. package/dist/{util-Bnx8nm-D.js → util-fMuLguoj.js} +2 -3
  358. package/dist/{util-Bnx8nm-D.js.map → util-fMuLguoj.js.map} +1 -1
  359. package/dist/{utils-ZAytYep8.js → utils-UqBsN9IU.js} +2 -3
  360. package/dist/{utils-ZAytYep8.js.map → utils-UqBsN9IU.js.map} +1 -1
  361. package/logos/README.md +1 -1
  362. package/package.json +17 -12
  363. package/dist/-private-DccRZQsm.js.map +0 -1
  364. package/dist/adapter-CARrK3-8.d.ts.map +0 -1
  365. package/dist/adapter-eYo2pIuM.js.map +0 -1
  366. package/dist/compat-BbNNmTM-.d.ts.map +0 -1
  367. package/dist/compat-DcHVxuuZ.js.map +0 -1
  368. package/dist/error-CzkyXr1Q.d.ts.map +0 -1
  369. package/dist/errors-CS110tMl.js.map +0 -1
  370. package/dist/extensions-DumNm4dA.d.ts.map +0 -1
  371. package/dist/json-BXNPTlcH.js.map +0 -1
  372. package/dist/model-62hn5_PD.d.ts.map +0 -1
  373. package/dist/model-DWH9f__L.js.map +0 -1
  374. package/dist/model-fragments-DSqu0ptR.js.map +0 -1
  375. package/dist/rest-0NhtexIq.d.ts.map +0 -1
  376. package/dist/schema-provider-DguGmQDS.js.map +0 -1
  377. package/dist/store-C4qYzXei.js.map +0 -1
  378. package/dist/unpkg/dev/-private-vOhxVExH.js.map +0 -1
  379. package/dist/unpkg/dev/adapter-oLwyr47q.js.map +0 -1
  380. package/dist/unpkg/dev/compat-DNQT2TQx.js.map +0 -1
  381. package/dist/unpkg/dev/errors-DnzvLM2A.js.map +0 -1
  382. package/dist/unpkg/dev/json-DDJji3V3.js.map +0 -1
  383. package/dist/unpkg/dev/model-BxPIR7m2.js.map +0 -1
  384. package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +0 -1
  385. package/dist/unpkg/dev/schema-provider-CI_a48ja.js.map +0 -1
  386. package/dist/unpkg/dev/store-D_V8-HQl.js.map +0 -1
  387. package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js.map +0 -1
  388. package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +0 -1
  389. package/dist/unpkg/dev-deprecated/compat-CeT0PnVX.js.map +0 -1
  390. package/dist/unpkg/dev-deprecated/errors-jHQESeNQ.js.map +0 -1
  391. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +0 -1
  392. package/dist/unpkg/dev-deprecated/model-BeGORt6h.js.map +0 -1
  393. package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  394. package/dist/unpkg/dev-deprecated/schema-provider-NmtdR4n_.js.map +0 -1
  395. package/dist/unpkg/dev-deprecated/store-BCOLSC6z.js.map +0 -1
  396. package/dist/unpkg/prod/-private-SfXkkHKd.js.map +0 -1
  397. package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +0 -1
  398. package/dist/unpkg/prod/compat-DxiVkCUb.js.map +0 -1
  399. package/dist/unpkg/prod/errors-DQDfNqVx.js.map +0 -1
  400. package/dist/unpkg/prod/json-BD1kRTfB.js.map +0 -1
  401. package/dist/unpkg/prod/model-CYMA-e_S.js.map +0 -1
  402. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js +0 -334
  403. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js.map +0 -1
  404. package/dist/unpkg/prod/runtime--fcdnjmJ-DMTJ0Kb3.js +0 -53
  405. package/dist/unpkg/prod/schema-provider-05U1H-Kl.js.map +0 -1
  406. package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js.map +0 -1
  407. package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +0 -1
  408. package/dist/unpkg/prod-deprecated/compat-DxiVkCUb.js.map +0 -1
  409. package/dist/unpkg/prod-deprecated/errors-ii4L43_1.js.map +0 -1
  410. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +0 -1
  411. package/dist/unpkg/prod-deprecated/model-D3oCPHtM.js.map +0 -1
  412. package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  413. package/dist/unpkg/prod-deprecated/schema-provider-CKH_bnnS.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-provider-05U1H-Kl.js","names":["recordIdentifierFor","assertPrivateStore","RecordStore","FetchManager","upgradeStore","lookupLegacySupport","rollbackAttributes","currentState","isNew","store","_join","cache","rollbackAttrs","errors","clear","cleanErrorRequests","unloadRecord","isDestroyed","isDestroying","belongsTo","prop","referenceFor","hasMany","reload","options","message","Promise","reject","Error","_reload","isReloading","identifier","promise","request","op","data","record","cacheOptions","Symbol","for","then","finally","changedAttributes","changedAttrs","serialize","serializeRecord","deleteRecord","save","_save","isDeleted","resolve","saveRecord","destroyRecord","_destroyRecord","_","createSnapshot","_fetchManager","cacheFor","Context","notifyInternalSignal","peekInternalSignal","withSignalStore","LEGACY_SUPPORT","notifyChanges","identifier","value","key","record","store","notifyAttribute","eachAttribute","name","meta","constructor","relationshipsByName","get","notifyRelationship","eachRelationship","kind","notifyPropertyChange","support","manyArray","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","options","async","currentValue","cache","getAttr","storeFor","defineSignal","gate","memoized","notifyInternalSignal","peekInternalSignal","withSignalStore","recordIdentifierFor","n","SOURCE_POINTER_REGEXP","SOURCE_POINTER_PRIMARY_REGEXP","PRIMARY_ATTRIBUTE_KEY","isInvalidError","error","Error","isAdapterError","code","RecordState","constructor","record","store","identity","identifier","cache","pendingCount","fulfilledCount","rejectedCount","_errorRequests","_lastError","requests","getRequestStateService","notifications","handleRequest","req","type","state","isSaving","response","data","push","notifyErrorsStateChanged","notify","subscribeForRecord","lastRequest","getLastRequestForRecord","handler","subscribe","key","updateInvalidErrors","errors","destroy","unsubscribe","signals","signal","jsonApiErrors","getErrors","clear","i","length","source","pointer","keyMatch","match","search","errMsg","detail","title","add","cleanErrorRequests","isLoading","isLoaded","prototype","isNew","isEmpty","isSaved","rd","isDeleted","isDeletionCommitted","isValid","isDirty","hasChangedAttrs","isError","errorReq","adapterError","request","isPreloaded","stateName","dirtyType","EmberObject","recordIdentifierFor","storeFor","defineGate","entangleSignal","gate","memoized","withSignalStore","assertPrivateStore","coerceId","RecordStore","Errors","releaseLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","notifyChanges","RecordState","n","computeOnce","target","propertyName","desc","cache","WeakMap","getter","get","meta","hasComputed","value","undefined","set","call","Model","init","options","createProps","_createProps","_secretInit","store","identity","identifier","cb","___recordState","setProperties","notifications","___private_notifications","subscribe","type","field","destroy","unsubscribe","isEmpty","currentState","prototype","isLoading","isLoaded","hasDirtyAttributes","isDirty","isSaving","isDeleted","isNew","isValid","dirtyType","isError","v","id","normalizedId","didChange","_instanceCache","setRecordId","notify","toString","constructor","modelName","_v","Error","errors","create","__record","updateInvalidErrors","adapterError","notifyPropertyChange","prop","signals","attr","eachRelationship","callback","binding","relationshipFor","name","relationshipsByName","inverseFor","eachAttribute","isModel","typeForRelationship","relationship","modelFor","inverseMap","Object","inverse","_findInverseFor","schemaExists","schema","hasResource","inverseField","fields","relationships","map","Map","forEach","has","push","relationshipNames","names","eachComputedProperty","isRelationshipSchema","kind","relatedTypes","types","rels","relationshipsObject","keys","i","length","includes","key","isAttributeSchema","eachRelatedType","relationshipTypes","determineRelationshipType","knownSide","knownKey","knownKind","otherKind","attributes","transformedAttributes","eachTransformedAttribute","_createSnapshot","console","warn","_isReloading","configurable","isLocal","restoreDeprecatedModelRequestBehaviors","ModelKlass","hasKind","getOwner","Model","modelForMixin","store","normalizedModelName","owner","MaybeMixin","factoryFor","mixin","class","ModelForMixin","extend","__isMixin","__mixin","register","getOwner","_modelForMixin","normalizeModelName","ModelSchemaProvider","constructor","store","_schemas","Map","_typeMisses","Set","resourceTypes","Array","from","keys","hasTrait","type","resourceHasTrait","resource","trait","transformation","field","derivation","hashFn","has","_loadModelSchema","get","schema","registerResources","schemas","registerResource","registerTransformation","transform","registerDerivation","registerHashFn","factory","getModelFactory","Error","modelClass","class","attributeMap","attributes","Object","create","forEach","meta","name","relationships","relationshipsObject","fields","attr","values","set","rel","legacy","identity","kind","cacheFields","cacheKey","sourceKey","internalSchema","hasResource","exists","add","buildSchema","_modelFactoryCache","cache","owner","factoryFor","klass","isModel","hasOwnModelNameSet","modelName","prototype","hasOwnProperty","call","defineProperty","value"],"sources":["../../../src/model/-private/model-methods.ts","../../../src/model/-private/notify-changes.ts","../../../src/model/-private/record-state.ts","../../../src/model/-private/model.ts","../../../src/model/-private/model-for-mixin.ts","../../../src/model/-private/schema-provider.ts"],"sourcesContent":["import { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { ENABLE_LEGACY_REQUEST_METHODS } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\n\nimport type { Snapshot } from '../../compat/-private.ts';\nimport { FetchManager, upgradeStore } from '../../compat/-private.ts';\nimport type { Errors } from './errors.ts';\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type RecordState from './record-state.ts';\nimport type BelongsToReference from './references/belongs-to.ts';\nimport type HasManyReference from './references/has-many.ts';\nimport type { MaybeBelongsToFields, MaybeHasManyFields } from './type-utils.ts';\n\nexport interface MinimalLegacyRecord {\n errors: Errors;\n /** @internal */\n ___recordState: RecordState;\n currentState: RecordState;\n isDestroyed: boolean;\n isDestroying: boolean;\n isReloading: boolean;\n isValid: boolean;\n /** @internal */\n [RecordStore]: Store;\n\n deleteRecord(): void;\n unloadRecord(): void;\n save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;\n destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;\n}\n\nexport function rollbackAttributes<T extends MinimalLegacyRecord>(this: T): void {\n const { currentState } = this;\n const { isNew } = currentState;\n const store = this[RecordStore];\n assertPrivateStore(store);\n\n store._join(() => {\n store.cache.rollbackAttrs(recordIdentifierFor(this));\n this.errors.clear();\n currentState.cleanErrorRequests();\n if (isNew) {\n this.unloadRecord();\n }\n });\n}\n\nexport function unloadRecord<T extends MinimalLegacyRecord>(this: T): void {\n if (this.currentState.isNew && (this.isDestroyed || this.isDestroying)) {\n return;\n }\n this[RecordStore].unloadRecord(this);\n}\n\nexport function belongsTo<T extends MinimalLegacyRecord, K extends MaybeBelongsToFields<T>>(\n this: T,\n prop: K\n): BelongsToReference<T, K> {\n return lookupLegacySupport(this).referenceFor('belongsTo', prop) as BelongsToReference<T, K>;\n}\n\nexport function hasMany<T extends MinimalLegacyRecord, K extends MaybeHasManyFields<T>>(\n this: T,\n prop: K\n): HasManyReference<T, K> {\n return lookupLegacySupport(this).referenceFor('hasMany', prop) as HasManyReference<T, K>;\n}\n\nexport function reload<T extends MinimalLegacyRecord>(this: T, options: Record<string, unknown> = {}): Promise<T> {\n if (!ENABLE_LEGACY_REQUEST_METHODS) {\n const message = `You cannot use reload() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;\n assert(message, false);\n return Promise.reject(new Error(message));\n } else {\n deprecate(`record.reload is deprecated, please use store.request to initiate a request instead.`, false, {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n });\n\n return _reload.call(this, options) as Promise<T>;\n }\n}\n\nexport function _reload<T extends MinimalLegacyRecord>(this: T, options: Record<string, unknown> = {}): Promise<T> {\n options.isReloading = true;\n options.reload = true;\n\n const identifier = recordIdentifierFor(this);\n assert(`You cannot reload a record without an ID`, identifier.id);\n\n this.isReloading = true;\n const promise = this[RecordStore]\n .request({\n op: 'findRecord',\n data: {\n options,\n record: identifier,\n },\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n })\n .then(() => this)\n .finally(() => {\n this.isReloading = false;\n });\n\n return promise;\n}\n\nexport function changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash {\n return this[RecordStore].cache.changedAttrs(recordIdentifierFor(this));\n}\n\nexport function serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown {\n upgradeStore(this[RecordStore]);\n return this[RecordStore].serializeRecord(this, options);\n}\n\nexport function deleteRecord<T extends MinimalLegacyRecord>(this: T): void {\n // ensure we've populated currentState prior to deleting a new record\n if (this.currentState) {\n this[RecordStore].deleteRecord(this);\n }\n}\n\nexport function save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T> {\n if (!ENABLE_LEGACY_REQUEST_METHODS) {\n const message = `You cannot use save() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;\n assert(message, false);\n return Promise.reject(new Error(message));\n } else {\n deprecate(`record.save is deprecated, please use store.request to initiate a request instead.`, false, {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n });\n\n return _save.call(this, options) as Promise<T>;\n }\n}\n\nexport function _save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T> {\n let promise: Promise<T>;\n\n if (this.currentState.isNew && this.currentState.isDeleted) {\n promise = Promise.resolve(this);\n } else {\n this.errors.clear();\n promise = this[RecordStore].saveRecord(this, options);\n }\n\n return promise;\n}\n\nexport function destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T> {\n if (!ENABLE_LEGACY_REQUEST_METHODS) {\n const message = `You cannot use destroyRecord() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;\n assert(message, false);\n return Promise.reject(new Error(message));\n } else {\n deprecate(`record.destroyRecord is deprecated, please use store.request to initiate a request instead.`, false, {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n });\n\n return _destroyRecord.call(this, options) as Promise<T>;\n }\n}\n\nexport function _destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T> {\n const { isNew } = this.currentState;\n this.deleteRecord();\n if (isNew) {\n return Promise.resolve(this);\n }\n return this.save(options).then((_) => {\n this.unloadRecord();\n return this;\n });\n}\n\nexport function createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T> {\n const store = this[RecordStore];\n\n upgradeStore(store);\n if (!store._fetchManager) {\n store._fetchManager = new FetchManager(store);\n }\n\n // @ts-expect-error Typescript isn't able to curry narrowed args that are divorced from each other.\n return store._fetchManager.createSnapshot<T>(recordIdentifierFor(this));\n}\n","import { cacheFor } from '@ember/object/internals';\n\nimport type { NotificationType, Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal, peekInternalSignal, withSignalStore } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { LegacyRelationshipField as RelationshipSchema } from '@warp-drive/core/types/schema/fields';\n\nimport { LEGACY_SUPPORT } from './legacy-relationships-support.ts';\nimport type { Model } from './model.ts';\n\nexport default function notifyChanges(\n identifier: ResourceKey,\n value: NotificationType,\n key: string | undefined,\n record: Model,\n store: Store\n): void {\n switch (value) {\n case 'added':\n case 'attributes':\n if (key) {\n notifyAttribute(store, identifier, key, record);\n } else {\n record.eachAttribute((name) => {\n notifyAttribute(store, identifier, name, record);\n });\n }\n break;\n\n case 'relationships':\n if (key) {\n const meta = (record.constructor as typeof Model).relationshipsByName.get(key);\n assert(`Expected to find a relationship for ${key} on ${identifier.type}`, meta);\n notifyRelationship(identifier, key, record, meta);\n } else {\n record.eachRelationship((name, meta) => {\n notifyRelationship(identifier, name, record, meta);\n });\n }\n break;\n\n case 'identity':\n notifyInternalSignal(peekInternalSignal(withSignalStore(record), 'id'));\n break;\n }\n}\n\nfunction notifyRelationship(identifier: ResourceKey, key: string, record: Model, meta: RelationshipSchema) {\n if (meta.kind === 'belongsTo') {\n record.notifyPropertyChange(key);\n } else if (meta.kind === 'hasMany') {\n const support = LEGACY_SUPPORT.get(identifier);\n const manyArray = support && support._manyArrayCache[key];\n const hasPromise = support && support._relationshipPromisesCache[key];\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n //We need to notifyPropertyChange in the adding case because we need to make sure\n //we fetch the newly added record in case it is unloaded\n //TODO(Igor): Consider whether we could do this only if the record state is unloaded\n assert(`Expected options to exist on relationship meta`, meta.options);\n assert(`Expected async to exist on relationship meta options`, 'async' in meta.options);\n if (meta.options.async) {\n record.notifyPropertyChange(key);\n }\n }\n }\n}\n\nfunction notifyAttribute(store: Store, identifier: ResourceKey, key: string, record: Model) {\n const currentValue = cacheFor(record, key);\n const cache = store.cache;\n if (currentValue !== cache.getAttr(identifier, key)) {\n record.notifyPropertyChange(key);\n }\n}\n","import type { NotificationType, Store } from '@warp-drive/core';\nimport { storeFor } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport {\n defineSignal,\n gate,\n memoized,\n notifyInternalSignal,\n peekInternalSignal,\n withSignalStore,\n} from '@warp-drive/core/signals/-leaked';\nimport type { RequestCacheRequestState, RequestStateService } from '@warp-drive/core/store/-private';\nimport { recordIdentifierFor } from '@warp-drive/core/store/-private';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\n\nimport type { Errors } from './errors';\nimport type { MinimalLegacyRecord } from './model-methods';\n\nconst SOURCE_POINTER_REGEXP = /^\\/?data\\/(attributes|relationships)\\/(.*)/;\nconst SOURCE_POINTER_PRIMARY_REGEXP = /^\\/?data/;\nconst PRIMARY_ATTRIBUTE_KEY = 'base';\nfunction isInvalidError(error: unknown): error is Error & { isAdapterError: true; code: 'InvalidError' } {\n return (\n !!error &&\n error instanceof Error &&\n 'isAdapterError' in error &&\n error.isAdapterError === true &&\n 'code' in error &&\n error.code === 'InvalidError'\n );\n}\n\n/**\nHistorically WarpDrive managed a state machine\nfor each record, the localState for which\nwas reflected onto Model.\n\nThis implements the flags and stateName for backwards compat\nwith the state tree that used to be possible (listed below).\n\nstateName and dirtyType are candidates for deprecation.\n\nroot\n empty\n deleted // hidden from stateName\n preloaded // hidden from stateName\n\n loading\n empty // hidden from stateName\n preloaded // hidden from stateName\n\n loaded\n saved\n updated\n uncommitted\n invalid\n inFlight\n created\n uncommitted\n invalid\n inFlight\n\n deleted\n saved\n new // hidden from stateName\n uncommitted\n invalid\n inFlight\n\n @hideconstructor\n @private\n*/\nexport default class RecordState {\n /** @internal */\n declare private store: Store;\n /** @internal */\n declare private identifier: ResourceKey;\n /** @internal */\n declare private record: MinimalLegacyRecord;\n /** @internal */\n declare private rs: RequestStateService;\n\n /** @internal */\n declare private pendingCount: number;\n /** @internal */\n declare private fulfilledCount: number;\n /** @internal */\n declare private rejectedCount: number;\n /** @internal */\n declare private cache: Cache;\n /** @internal */\n declare private _errorRequests: RequestCacheRequestState[];\n /** @internal */\n declare private _lastError: RequestCacheRequestState | null;\n /** @internal */\n declare private handler: object;\n\n constructor(record: MinimalLegacyRecord) {\n const store = storeFor(record, false)!;\n const identity = recordIdentifierFor(record);\n\n this.identifier = identity;\n this.record = record;\n this.cache = store.cache;\n\n this.pendingCount = 0;\n this.fulfilledCount = 0;\n this.rejectedCount = 0;\n this._errorRequests = [];\n this._lastError = null;\n\n const requests = store.getRequestStateService();\n const notifications = store.notifications;\n\n const handleRequest = (req: RequestCacheRequestState) => {\n if (req.type === 'mutation') {\n switch (req.state) {\n case 'pending':\n this.isSaving = true;\n break;\n case 'rejected':\n this.isSaving = false;\n this._lastError = req;\n if (!(req.response && isInvalidError(req.response.data))) {\n this._errorRequests.push(req);\n }\n\n notifyErrorsStateChanged(this);\n break;\n case 'fulfilled':\n this._errorRequests = [];\n this._lastError = null;\n this.isSaving = false;\n this.notify('isDirty');\n notifyErrorsStateChanged(this);\n break;\n }\n } else {\n switch (req.state) {\n case 'pending':\n this.pendingCount++;\n this.notify('isLoading');\n break;\n case 'rejected':\n this.pendingCount--;\n this._lastError = req;\n if (!(req.response && isInvalidError(req.response.data))) {\n this._errorRequests.push(req);\n }\n this.notify('isLoading');\n notifyErrorsStateChanged(this);\n break;\n case 'fulfilled':\n this.pendingCount--;\n this.fulfilledCount++;\n this.notify('isLoading');\n this.notify('isDirty');\n notifyErrorsStateChanged(this);\n this._errorRequests = [];\n this._lastError = null;\n break;\n }\n }\n };\n\n requests.subscribeForRecord(identity, handleRequest);\n\n // we instantiate lazily\n // so we grab anything we don't have yet\n const lastRequest = requests.getLastRequestForRecord(identity);\n if (lastRequest) {\n handleRequest(lastRequest);\n }\n\n this.handler = notifications.subscribe(\n identity,\n (identifier: ResourceKey, type: NotificationType, key?: string) => {\n switch (type) {\n case 'state':\n this.notify('isSaved');\n this.notify('isNew');\n this.notify('isDeleted');\n this.notify('isDirty');\n break;\n case 'attributes':\n this.notify('isEmpty');\n this.notify('isDirty');\n break;\n case 'errors':\n this.updateInvalidErrors(this.record.errors);\n this.notify('isValid');\n break;\n }\n }\n );\n }\n\n /** @internal */\n destroy(): void {\n storeFor(this.record, false)!.notifications.unsubscribe(this.handler);\n }\n\n /** @internal */\n notify(key: keyof this & string): void {\n const signals = withSignalStore(this);\n const signal = peekInternalSignal(signals, key);\n if (signal) {\n notifyInternalSignal(signal);\n }\n }\n\n /** @internal */\n updateInvalidErrors(errors: Errors): void {\n assert(\n `Expected the Cache instance for ${this.identifier.lid} to implement getErrors(identifier)`,\n typeof this.cache.getErrors === 'function'\n );\n const jsonApiErrors = this.cache.getErrors(this.identifier);\n\n errors.clear();\n\n for (let i = 0; i < jsonApiErrors.length; i++) {\n const error = jsonApiErrors[i];\n\n if (error.source && error.source.pointer) {\n const keyMatch = error.source.pointer.match(SOURCE_POINTER_REGEXP);\n let key: string | undefined;\n\n if (keyMatch) {\n key = keyMatch[2];\n } else if (error.source.pointer.search(SOURCE_POINTER_PRIMARY_REGEXP) !== -1) {\n key = PRIMARY_ATTRIBUTE_KEY;\n }\n\n if (key) {\n const errMsg = error.detail || error.title;\n assert(`Expected field error to have a detail or title to use as the message`, errMsg);\n errors.add(key, errMsg);\n }\n }\n }\n }\n\n /** @internal */\n cleanErrorRequests(): void {\n this.notify('isValid');\n this.notify('isError');\n this.notify('adapterError');\n this._errorRequests = [];\n this._lastError = null;\n }\n\n declare isSaving: boolean;\n\n @gate\n get isLoading(): boolean {\n return !this.isLoaded && this.pendingCount > 0 && this.fulfilledCount === 0;\n }\n\n @gate\n get isLoaded(): boolean {\n if (this.isNew) {\n return true;\n }\n return this.fulfilledCount > 0 || !this.isEmpty;\n }\n\n @gate\n get isSaved(): boolean {\n const rd = this.cache;\n if (this.isDeleted) {\n assert(`Expected Cache to implement isDeletionCommitted()`, typeof rd.isDeletionCommitted === 'function');\n return rd.isDeletionCommitted(this.identifier);\n }\n if (this.isNew || this.isEmpty || !this.isValid || this.isDirty || this.isLoading) {\n return false;\n }\n return true;\n }\n\n @gate\n get isEmpty(): boolean {\n const rd = this.cache;\n // TODO this is not actually an RFC'd concept. Determine the\n // correct heuristic to replace this with.\n assert(`Expected Cache to implement isEmpty()`, typeof rd.isEmpty === 'function');\n return !this.isNew && rd.isEmpty(this.identifier);\n }\n\n @gate\n get isNew(): boolean {\n const rd = this.cache;\n assert(`Expected Cache to implement isNew()`, typeof rd.isNew === 'function');\n return rd.isNew(this.identifier);\n }\n\n @gate\n get isDeleted(): boolean {\n const rd = this.cache;\n assert(`Expected Cache to implement isDeleted()`, typeof rd.isDeleted === 'function');\n return rd.isDeleted(this.identifier);\n }\n\n @gate\n get isValid(): boolean {\n return this.record.errors.length === 0;\n }\n\n @gate\n get isDirty(): boolean {\n const rd = this.cache;\n if (this.isEmpty || rd.isDeletionCommitted(this.identifier) || (this.isDeleted && this.isNew)) {\n return false;\n }\n return this.isDeleted || this.isNew || rd.hasChangedAttrs(this.identifier);\n }\n\n @gate\n get isError(): boolean {\n const errorReq = this._errorRequests[this._errorRequests.length - 1];\n if (!errorReq) {\n return false;\n } else {\n return true;\n }\n }\n\n @gate\n get adapterError(): unknown {\n const request = this._lastError;\n if (!request) {\n return null;\n }\n return request.state === 'rejected' && request.response!.data;\n }\n\n @memoized\n get isPreloaded(): boolean {\n return !this.isEmpty && this.isLoading;\n }\n\n @memoized\n get stateName():\n | 'root.loading'\n | 'root.empty'\n | 'root.deleted.inFlight'\n | 'root.deleted.saved'\n | 'root.deleted.invalid'\n | 'root.deleted.uncommitted'\n | 'root.loaded.created.inFlight'\n | 'root.loaded.created.invalid'\n | 'root.loaded.created.uncommitted'\n | 'root.loaded.updated.inFlight'\n | 'root.loaded.updated.invalid'\n | 'root.loaded.updated.uncommitted'\n | 'root.loaded.saved' {\n // we might be empty while loading so check this first\n if (this.isLoading) {\n return 'root.loading';\n\n // got nothing yet or were unloaded\n } else if (this.isEmpty) {\n return 'root.empty';\n\n // deleted substates\n } else if (this.isDeleted) {\n if (this.isSaving) {\n return 'root.deleted.inFlight';\n } else if (this.isSaved) {\n // TODO ensure isSaved isn't true from previous requests\n return 'root.deleted.saved';\n } else if (!this.isValid) {\n return 'root.deleted.invalid';\n } else {\n return 'root.deleted.uncommitted';\n }\n\n // loaded.created substates\n } else if (this.isNew) {\n if (this.isSaving) {\n return 'root.loaded.created.inFlight';\n } else if (!this.isValid) {\n return 'root.loaded.created.invalid';\n }\n return 'root.loaded.created.uncommitted';\n\n // loaded.updated substates\n } else if (this.isSaving) {\n return 'root.loaded.updated.inFlight';\n } else if (!this.isValid) {\n return 'root.loaded.updated.invalid';\n } else if (this.isDirty) {\n return 'root.loaded.updated.uncommitted';\n\n // if nothing remains, we are loaded saved!\n } else {\n return 'root.loaded.saved';\n }\n }\n\n @memoized\n get dirtyType(): '' | 'deleted' | 'created' | 'updated' {\n // we might be empty while loading so check this first\n if (this.isLoading || this.isEmpty) {\n return '';\n\n // deleted substates\n } else if (this.isDirty && this.isDeleted) {\n return 'deleted';\n\n // loaded.created substates\n } else if (this.isNew) {\n return 'created';\n\n // loaded.updated substates\n } else if (this.isSaving || !this.isValid || this.isDirty) {\n return 'updated';\n\n // if nothing remains, we are loaded saved!\n } else {\n return '';\n }\n }\n}\ndefineSignal(RecordState.prototype, 'isSaving', false);\n\nfunction notifyErrorsStateChanged(state: RecordState) {\n state.notify('isValid');\n state.notify('isError');\n state.notify('adapterError');\n}\n","import { deprecate } from '@ember/debug';\nimport EmberObject from '@ember/object';\n\nimport type { NotificationType, Store } from '@warp-drive/core';\nimport { recordIdentifierFor, storeFor } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { defineGate, entangleSignal, gate, memoized, withSignalStore } from '@warp-drive/core/signals/-leaked';\nimport { assertPrivateStore, coerceId } from '@warp-drive/core/store/-private';\nimport type { ModelSchema, ResourceKey } from '@warp-drive/core/types';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core/types/schema/fields';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\n\nimport type { Snapshot } from '../../compat/-private.ts';\nimport { Errors } from './errors.ts';\nimport { releaseLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\nimport {\n _destroyRecord,\n _reload,\n _save,\n belongsTo,\n changedAttributes,\n createSnapshot,\n deleteRecord,\n destroyRecord,\n hasMany,\n reload,\n rollbackAttributes,\n save,\n serialize,\n unloadRecord,\n} from './model-methods.ts';\nimport notifyChanges from './notify-changes.ts';\nimport RecordState from './record-state.ts';\nimport type BelongsToReference from './references/belongs-to.ts';\nimport type HasManyReference from './references/has-many.ts';\nimport type {\n _MaybeBelongsToFields,\n isSubClass,\n MaybeAttrFields,\n MaybeHasManyFields,\n MaybeRelationshipFields,\n} from './type-utils.ts';\n\nexport type ModelCreateArgs = {\n _createProps: Record<string, unknown>;\n // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for\n _secretInit: {\n identifier: ResourceKey;\n store: Store;\n cb: (record: Model, identifier: ResourceKey, store: Store) => void;\n };\n};\n\nexport type StaticModel = typeof Model & { create(options: ModelCreateArgs): Model };\nexport type ModelFactory = { class: StaticModel };\nexport type FactoryCache = Record<string, ModelFactory>;\n// we put this on the store for interop because it's used by modelFor and\n// instantiateRecord as well.\nexport type ModelStore = Store & { _modelFactoryCache: FactoryCache };\n\n/*\n * This decorator allows us to lazily compute\n * an expensive getter on first-access and thereafter\n * never recompute it.\n */\nfunction computeOnce(target: object, propertyName: string, desc: PropertyDescriptor) {\n const cache = new WeakMap<object, { hasComputed: boolean; value: unknown }>();\n // oxlint-disable-next-line typescript/unbound-method\n const getter = desc.get;\n desc.get = function () {\n let meta = cache.get(this);\n\n if (!meta) {\n meta = { hasComputed: false, value: undefined };\n cache.set(this, meta);\n }\n\n if (!meta.hasComputed) {\n meta.value = (getter as () => unknown).call(this);\n meta.hasComputed = true;\n }\n\n return meta.value;\n };\n return desc;\n}\n\ninterface Model {\n // set during create by the store\n /**\n * The store service instance which created this record instance\n */\n store: Store;\n /** @internal */\n ___recordState: RecordState;\n /** @internal */\n ___private_notifications: object;\n /** @internal */\n _isReloading: boolean;\n /** @internal */\n [RecordStore]: Store;\n\n /**\n Create a JSON representation of the record, using the serialization\n strategy of the store's adapter.\n\n `serialize` takes an optional hash as a parameter, currently\n supported options are:\n\n - `includeId`: `true` if the record's ID should be included in the\n JSON representation.\n\n @public\n @param {Object} options\n @return {Object} an object whose values are primitive JSON values only\n */\n serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown;\n\n /**\n Same as `deleteRecord`, but saves the record immediately.\n\n Example\n\n ```js\n import Component from '@glimmer/component';\n\n export default class extends Component {\n delete = () => {\n this.args.model.destroyRecord().then(function() {\n this.transitionToRoute('model.index');\n });\n }\n }\n ```\n\n If you pass an object on the `adapterOptions` property of the options\n argument it will be passed to your adapter via the snapshot\n\n ```js\n record.destroyRecord({ adapterOptions: { subscribe: false } });\n ```\n\n ```js [app/adapters/post.js]\n import MyCustomAdapter from './custom-adapter';\n\n export default class PostAdapter extends MyCustomAdapter {\n deleteRecord(store, type, snapshot) {\n if (snapshot.adapterOptions.subscribe) {\n // ...\n }\n // ...\n }\n }\n ```\n\n @public\n @param options\n @return a promise that will be resolved when the adapter returns\n successfully or rejected if the adapter returns with an error.\n */\n destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;\n\n /**\n Unloads the record from the store. This will not send a delete request\n to your server, it just unloads the record from memory.\n\n @public\n */\n unloadRecord<T extends MinimalLegacyRecord>(this: T): void;\n\n /**\n Returns an object, whose keys are changed properties, and value is\n an [oldProp, newProp] array.\n\n The array represents the diff of the canonical state with the local state\n of the model. Note: if the model is created locally, the canonical state is\n empty since the adapter hasn't acknowledged the attributes yet:\n\n Example\n\n ```js [app/models/mascot.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class MascotModel extends Model {\n @attr('string') name;\n @attr('boolean', {\n defaultValue: false\n })\n isAdmin;\n }\n ```\n\n ```javascript\n let mascot = store.createRecord('mascot');\n\n mascot.changedAttributes(); // {}\n\n mascot.set('name', 'Tomster');\n mascot.changedAttributes(); // { name: [undefined, 'Tomster'] }\n\n mascot.set('isAdmin', true);\n mascot.changedAttributes(); // { isAdmin: [undefined, true], name: [undefined, 'Tomster'] }\n\n mascot.save().then(function() {\n mascot.changedAttributes(); // {}\n\n mascot.set('isAdmin', false);\n mascot.changedAttributes(); // { isAdmin: [true, false] }\n });\n ```\n\n @public\n @return {Object} an object, whose keys are changed properties,\n and value is an [oldProp, newProp] array.\n */\n changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;\n\n /**\n If the model `hasDirtyAttributes` this function will discard any unsaved\n changes. If the model `isNew` it will be removed from the store.\n\n Example\n\n ```javascript\n record.name; // 'Untitled Document'\n record.set('name', 'Doc 1');\n record.name; // 'Doc 1'\n record.rollbackAttributes();\n record.name; // 'Untitled Document'\n ```\n\n @since 1.13.0\n @public\n */\n rollbackAttributes<T extends MinimalLegacyRecord>(this: T): void;\n\n // TODO @deprecate in favor of a public API or examples of how to test successfully\n /**\n @private\n */\n _createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;\n\n /**\n Save the record and persist any changes to the record to an\n external source via the adapter.\n\n Example\n\n ```javascript\n record.set('name', 'Tomster');\n record.save().then(function() {\n // Success callback\n }, function() {\n // Error callback\n });\n ```\n\n If you pass an object using the `adapterOptions` property of the options\n argument it will be passed to your adapter via the snapshot.\n\n ```js\n record.save({ adapterOptions: { subscribe: false } });\n ```\n\n ```js [app/adapters/post.js]\n import MyCustomAdapter from './custom-adapter';\n\n export default class PostAdapter extends MyCustomAdapter {\n updateRecord(store, type, snapshot) {\n if (snapshot.adapterOptions.subscribe) {\n // ...\n }\n // ...\n }\n }\n ```\n\n @deprecated use {@link Store.request} instead\n @public\n @return a promise that will be resolved when the adapter returns\n successfully or rejected if the adapter returns with an error.\n */\n save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;\n\n /**\n Reload the record from the adapter.\n\n This will only work if the record has already finished loading.\n\n Example\n\n ```js\n import Component from '@glimmer/component';\n\n export default class extends Component {\n async reload = () => {\n await this.args.model.reload();\n // do something with the reloaded model\n }\n }\n ```\n\n @public\n @param {Object} options optional, may include `adapterOptions` hash which will be passed to adapter request\n\n @return {Promise} a promise that will be resolved with the record when the\n adapter returns successfully or rejected if the adapter returns\n with an error.\n */\n\n reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;\n\n // belongsTo<T extends MinimalLegacyRecord, K extends MaybeBelongsToFields<T>>(\n // this: T,\n // prop: K\n // ): BelongsToReference<T, K>;\n\n /**\n Get the reference for the specified belongsTo relationship.\n\n For instance, given the following model\n\n ```js [app/models/blog-post.js]\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogPost extends Model {\n @belongsTo('user', { async: true, inverse: null }) author;\n }\n ```\n\n Then the reference for the author relationship would be\n retrieved from a record instance like so:\n\n ```js\n blogPost.belongsTo('author');\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 as it allows synchronous access to the relationship data if loaded, as\n well as APIs for loading, reloading the data or accessing available\n information without triggering a load.\n\n It may also be useful when using `sync` relationships that need to be\n 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 @param prop - the name of the relationship\n @since 2.5.0\n @return reference for this relationship\n */\n belongsTo<T extends Model, K extends keyof T & string>(\n this: T,\n prop: K & (K extends _MaybeBelongsToFields<T> ? K : never)\n ): BelongsToReference<T, K>;\n\n /**\n Get the reference for the specified hasMany relationship.\n\n For instance, given the following model\n\n ```js [app/models/blog-post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class BlogPost extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n Then the reference for the comments relationship would be\n retrieved from a record instance like so:\n\n ```js\n blogPost.hasMany('comments');\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 are dealing with `async` relationships\n as it allows synchronous access to the relationship data if loaded, as\n well as APIs for loading, reloading the data or accessing available\n information without triggering a load.\n\n It may also be useful when using `sync` relationships with `@ember-data/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 @param prop - the name of the relationship\n @since 2.5.0\n @return reference for this relationship\n */\n hasMany<T extends MinimalLegacyRecord, K extends MaybeHasManyFields<T>>(this: T, prop: K): HasManyReference<T, K>;\n\n /**\n Marks the record as deleted but does not save it. You must call\n `save` afterwards if you want to persist it. You might use this\n method if you want to allow the user to still `rollbackAttributes()`\n after a delete was made.\n\n Example\n\n ```js\n import Component from '@glimmer/component';\n\n export default class extends Component {\n softDelete = () => {\n this.args.model.deleteRecord();\n }\n\n confirm = () => {\n this.args.model.save();\n }\n\n undo = () => {\n this.args.model.rollbackAttributes();\n }\n }\n ```\n\n @public\n */\n deleteRecord<T extends MinimalLegacyRecord>(this: T): void;\n}\n\n/**\n * Base class from which Models can be defined.\n *\n * ::: code-group\n *\n * ```js [app/models/user.js]\n * import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model';\n *\n * export default class User extends Model {\n * @attr name;\n * @attr('number') age;\n * @hasMany('post', { async: true, inverse: null }) posts;\n * @belongsTo('group', { async: false, inverse: 'users' }) group;\n * }\n * ```\n *\n * ```ts [app/models/user.ts]\n * import { Model, attr, belongsTo, hasMany, type AsyncHasMany } from '@warp-drive/legacy/model';\n * import type { NumberTransform } from '@ember-data/serializer/transform';\n * import type Group from './group';\n * import type Post from './post';\n *\n * export default class User extends Model {\n * @attr declare name: string;\n *\n * @attr<NumberTransform>('number')\n * declare age: number;\n *\n * @hasMany('post', { async: true, inverse: null })\n * declare posts: AsyncHasMany<Post>;\n *\n * @belongsTo('group', { async: false, inverse: 'users' })\n * declare group: Group | null;\n * }\n * ```\n *\n * :::\n *\n * Models both define the schema for a resource type and provide\n * the class to use as the reactive object for data of resource\n * of that type.\n *\n * @public\n * @noInheritDoc\n * @hideconstructor\n * @legacy\n */\nclass Model extends EmberObject implements MinimalLegacyRecord {\n /** @internal */\n init(options: ModelCreateArgs): void {\n if (DEBUG) {\n if (!options?._secretInit && !options?._createProps) {\n throw new Error(\n 'You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.'\n );\n }\n }\n const createProps = options._createProps;\n const _secretInit = options._secretInit;\n (options as Record<string, unknown>)._createProps = null;\n (options as Record<string, unknown>)._secretInit = null;\n\n const store = (this.store = _secretInit.store);\n super.init(options);\n\n this[RecordStore] = store;\n\n const identity = _secretInit.identifier;\n _secretInit.cb(this, identity, _secretInit.store);\n\n this.___recordState = DEBUG ? new RecordState(this) : (null as unknown as RecordState);\n\n this.setProperties(createProps);\n\n const notifications = store.notifications;\n this.___private_notifications = notifications.subscribe(\n identity,\n (identifier: ResourceKey, type: NotificationType, field?: string): void => {\n notifyChanges(identifier, type, field, this, store);\n }\n );\n }\n\n /** @private */\n // @ts-expect-error destroy should not return a value, but ember's types force it to\n destroy(): this {\n const identifier = recordIdentifierFor(this);\n this.___recordState?.destroy();\n const store = storeFor(this, false)!;\n store.notifications.unsubscribe(this.___private_notifications);\n\n releaseLegacySupport(identifier);\n\n super.destroy();\n }\n\n /**\n If this property is `true` the record is in the `empty`\n state. Empty is the first state all records enter after they have\n been created. Most records created by the store will quickly\n transition to the `loading` state if data needs to be fetched from\n the server or the `created` state if the record is created on the\n client. A record can also enter the empty state if the adapter is\n unable to locate the record.\n\n @public\n */\n @memoized\n get isEmpty(): boolean {\n return this.currentState.isEmpty;\n }\n\n /**\n If this property is `true` the record is in the `loading` state. A\n record enters this state when the store asks the adapter for its\n data. It remains in this state until the adapter provides the\n requested data.\n\n @public\n */\n @memoized\n get isLoading(): boolean {\n return this.currentState.isLoading;\n }\n\n /**\n If this property is `true` the record is in the `loaded` state. A\n record enters this state when its data is populated. Most of a\n record's lifecycle is spent inside substates of the `loaded`\n state.\n\n Example\n\n ```javascript\n let record = store.createRecord('model');\n record.isLoaded; // true\n\n const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));\n model.isLoaded;\n ```\n\n @public\n */\n @memoized\n get isLoaded(): boolean {\n return this.currentState.isLoaded;\n }\n\n /**\n If this property is `true` the record is in the `dirty` state. The\n record has local changes that have not yet been saved by the\n adapter. This includes records that have been created (but not yet\n saved) or deleted.\n\n Example\n\n ```javascript\n let record = store.createRecord('model');\n record.hasDirtyAttributes; // true\n\n const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));\n\n model.hasDirtyAttributes; // false\n model.foo = 'some value';\n model.hasDirtyAttributes; // true\n ```\n\n @since 1.13.0\n @public\n */\n @memoized\n get hasDirtyAttributes(): boolean {\n return this.currentState.isDirty;\n }\n\n /**\n If this property is `true` the record is in the `saving` state. A\n record enters the saving state when `save` is called, but the\n adapter has not yet acknowledged that the changes have been\n persisted to the backend.\n\n Example\n\n ```javascript\n let record = store.createRecord('model');\n record.isSaving; // false\n let promise = record.save();\n record.isSaving; // true\n promise.then(function() {\n record.isSaving; // false\n });\n ```\n\n @public\n */\n @memoized\n get isSaving(): boolean {\n return this.currentState.isSaving;\n }\n\n /**\n If this property is `true` the record is in the `deleted` state\n and has been marked for deletion. When `isDeleted` is true and\n `hasDirtyAttributes` is true, the record is deleted locally but the deletion\n was not yet persisted. When `isSaving` is true, the change is\n in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the\n change has persisted.\n\n Example\n\n ```javascript\n let record = store.createRecord('model');\n record.isDeleted; // false\n record.deleteRecord();\n\n // Locally deleted\n record.isDeleted; // true\n record.hasDirtyAttributes; // true\n record.isSaving; // false\n\n // Persisting the deletion\n let promise = record.save();\n record.isDeleted; // true\n record.isSaving; // true\n\n // Deletion Persisted\n promise.then(function() {\n record.isDeleted; // true\n record.isSaving; // false\n record.hasDirtyAttributes; // false\n });\n ```\n\n @public\n */\n @memoized\n get isDeleted(): boolean {\n return this.currentState.isDeleted;\n }\n\n /**\n If this property is `true` the record is in the `new` state. A\n record will be in the `new` state when it has been created on the\n client and the adapter has not yet report that it was successfully\n saved.\n\n Example\n\n ```javascript\n let record = store.createRecord('model');\n record.isNew; // true\n\n record.save().then(function(model) {\n model.isNew; // false\n });\n ```\n\n @public\n */\n @memoized\n get isNew(): boolean {\n return this.currentState.isNew;\n }\n\n /**\n If this property is `true` the record is in the `valid` state.\n\n A record will be in the `valid` state when the adapter did not report any\n server-side validation failures.\n\n @public\n */\n @memoized\n get isValid(): boolean {\n return this.currentState.isValid;\n }\n\n /**\n If the record is in the dirty state this property will report what\n kind of change has caused it to move into the dirty\n state. Possible values are:\n\n - `created` The record has been created by the client and not yet saved to the adapter.\n - `updated` The record has been updated by the client and not yet saved to the adapter.\n - `deleted` The record has been deleted by the client and not yet saved to the adapter.\n\n Example\n\n ```javascript\n let record = store.createRecord('model');\n record.dirtyType; // 'created'\n ```\n\n @public\n */\n @memoized\n get dirtyType(): 'created' | 'updated' | 'deleted' | '' {\n return this.currentState.dirtyType;\n }\n\n /**\n If `true` the adapter reported that it was unable to save local\n changes to the backend for any reason other than a server-side\n validation error.\n\n Example\n\n ```javascript\n record.isError; // false\n record.set('foo', 'valid value');\n record.save().then(null, function() {\n record.isError; // true\n });\n ```\n\n @public\n */\n @memoized\n get isError(): boolean {\n return this.currentState.isError;\n }\n /**\n * `isError` is read-only and cannot be set directly.\n */\n set isError(v) {\n if (DEBUG) {\n throw new Error(`isError is not directly settable`);\n }\n }\n\n /**\n If `true` the store is attempting to reload the record from the adapter.\n\n Example\n\n ```javascript\n record.isReloading; // false\n record.reload();\n record.isReloading; // true\n ```\n\n @public\n */\n declare isReloading: boolean;\n\n /**\n All ember models have an id property. This is an identifier\n managed by an external source. These are always coerced to be\n strings before being used internally. Note when declaring the\n attributes for a model it is an error to declare an id\n attribute.\n\n ```javascript\n let record = store.createRecord('model');\n record.id; // null\n\n const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));\n model.id; // '1'\n ```\n\n @public\n */\n @gate\n get id(): string | null {\n // this guard exists, because some dev-only deprecation code\n // (addListener via validatePropertyInjections) invokes toString before the\n // object is real.\n if (DEBUG) {\n try {\n return recordIdentifierFor(this).id;\n } catch {\n return null;\n }\n }\n return recordIdentifierFor(this).id;\n }\n /**\n * Assigns the resource's primary key. Typically only used internally\n * when a client-created record is assigned an id upon being saved.\n */\n set id(id) {\n const normalizedId = coerceId(id);\n const identifier = recordIdentifierFor(this);\n const didChange = normalizedId !== identifier.id;\n assertPrivateStore(this.store);\n assert(\n `Cannot set ${identifier.type} record's id to ${id}, because id is already ${identifier.id}`,\n !didChange || identifier.id === null\n );\n\n if (normalizedId !== null && didChange) {\n this.store._instanceCache.setRecordId(identifier, normalizedId);\n this.store.notifications.notify(identifier, 'identity', null);\n }\n }\n\n toString() {\n return `<model::${(this.constructor as unknown as { modelName: string }).modelName}:${this.id}>`;\n }\n\n /**\n @private\n */\n // TODO we can probably make this a computeOnce\n // we likely do not need to notify the currentState root anymore\n @gate\n get currentState(): RecordState {\n // descriptors are called with the wrong `this` context during mergeMixins\n // when using legacy/classic ember classes. Basically: lazy in prod and eager in dev.\n // so we do this to try to steer folks to the nicer \"dont user currentState\"\n // error.\n if (!DEBUG) {\n if (!this.___recordState) {\n this.___recordState = new RecordState(this);\n }\n }\n return this.___recordState;\n }\n /**\n * `currentState` is read-only and cannot be set directly.\n */\n set currentState(_v) {\n throw new Error('cannot set currentState');\n }\n\n /**\n The store service instance which created this record instance\n\n @public\n */\n declare store: Store;\n\n /**\n When the record is in the `invalid` state this object will contain\n any errors returned by the adapter. When present the errors hash\n contains keys corresponding to the invalid property names\n and values which are arrays of Javascript objects 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 ```javascript\n record.errors.length; // 0\n record.set('foo', 'invalid value');\n record.save().catch(function() {\n record.errors.foo;\n // [{message: 'foo should be a number.', attribute: 'foo'}]\n });\n ```\n\n The `errors` property is useful for displaying error messages to\n the user.\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 <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\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 @public\n */\n @computeOnce\n get errors(): Errors {\n const errors = (Errors as unknown as { create(obj: object): Errors }).create({ __record: this });\n this.currentState.updateInvalidErrors(errors);\n return errors;\n }\n\n /**\n This property holds the `AdapterError` object with which\n last adapter operation was rejected.\n\n @public\n */\n @memoized\n get adapterError(): unknown {\n return this.currentState.adapterError;\n }\n /**\n * `adapterError` is read-only and cannot be set directly.\n */\n set adapterError(v) {\n throw new Error(`adapterError is not directly settable`);\n }\n\n /*\n We hook the default implementation to ensure\n our tagged properties are properly notified\n as well. We still super for everything because\n sync observers require a direct call occuring\n to trigger their flush. We wouldn't need to\n super in 4.0+ where sync observers are removed.\n */\n // @ts-expect-error no return is necessary, but Ember's types are forcing it\n notifyPropertyChange(prop: string): this {\n const signals = withSignalStore(this);\n entangleSignal(signals, this, prop, undefined);\n super.notifyPropertyChange(prop);\n }\n\n /** @internal */\n attr(): void {\n assert(\n 'The `attr` method is not available on Model, a Snapshot was probably expected. Are you passing a Model instead of a Snapshot to your serializer?',\n false\n );\n }\n\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, descriptor);\n ```\n\n - `name` the name of the current property in the iteration\n - `descriptor` the meta object that describes this relationship\n\n The relationship descriptor argument is an object with the following properties.\n\n - **name** <span class=\"type\">String</span> the name of this relationship on the Model\n - **kind** <span class=\"type\">String</span> \"hasMany\" or \"belongsTo\"\n - **options** <span class=\"type\">Object</span> the original options hash passed when the relationship was declared\n - **parentType** <span class=\"type\">Model</span> the type of the Model that owns this relationship\n - **type** <span class=\"type\">String</span> the type name of the related Model\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```js [app/serializers/application.js]\n import JSONSerializer from '@ember-data/serializer/json';\n\n export default class ApplicationSerializer extends JSONSerializer {\n serialize(record, options) {\n let json = {};\n\n record.eachRelationship(function(name, descriptor) {\n if (descriptor.kind === 'hasMany') {\n let serializedHasManyName = name.toUpperCase() + '_IDS';\n json[serializedHasManyName] = record.get(name).map(r => r.id);\n }\n });\n\n return json;\n }\n }\n ```\n\n @public\n @param callback the callback to invoke\n @param binding the value to which the callback's `this` should be bound\n */\n eachRelationship<T>(\n callback: (this: NoInfer<T> | undefined, key: MaybeRelationshipFields<this>, meta: LegacyRelationshipField) => void,\n binding?: T\n ): void {\n (this.constructor as typeof Model).eachRelationship<T, this>(callback, binding);\n }\n\n /**\n * Returns the relationship schema for the given relationship name, if any.\n */\n relationshipFor(name: string): LegacyRelationshipField | undefined {\n return (this.constructor as typeof Model).relationshipsByName.get(name);\n }\n\n /**\n * Returns the inverse relationship schema for the given relationship\n * name, if one exists. See {@link Model.inverseFor | the static inverseFor}.\n */\n inverseFor(name: string): LegacyRelationshipField | null {\n return (this.constructor as typeof Model).inverseFor(name, storeFor(this, false)!);\n }\n\n /**\n * Iterates over the attributes defined on this record's class, calling\n * `callback` for each one. See {@link Model.eachAttribute | the static eachAttribute}.\n *\n * @param callback the callback to invoke\n * @param binding the value to which the callback's `this` should be bound\n */\n eachAttribute<T>(\n callback: (\n this: NoInfer<T> | undefined,\n key: isSubClass<this> extends true ? MaybeAttrFields<this> : string,\n meta: LegacyAttributeField\n ) => void,\n binding?: T\n ): void {\n (this.constructor as typeof Model).eachAttribute<T, this>(callback, binding);\n }\n\n /**\n * @internal\n */\n static isModel = true;\n\n /**\n Represents the model's class name as a string. This can be used to look up the model's class name through\n `Store`'s modelFor method.\n\n `modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.\n For example:\n\n ```javascript\n store.modelFor('post').modelName; // 'post'\n store.modelFor('blog-post').modelName; // 'blog-post'\n ```\n\n The most common place you'll want to access `modelName` is in your serializer's `payloadKeyFromModelName` method. For example, to change payload\n keys to underscore (instead of dasherized), you might use the following code:\n\n ```javascript\n import RESTSerializer from '@ember-data/serializer/rest';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default const PostSerializer = RESTSerializer.extend({\n payloadKeyFromModelName(modelName) {\n return underscore(modelName);\n }\n });\n ```\n\n @public\n */\n static modelName: string = null as unknown as string;\n\n /*\n These class methods below provide relationship\n introspection abilities about relationships.\n\n A note about the computed properties contained here:\n\n **These properties are effectively sealed once called for the first time.**\n To avoid repeatedly doing expensive iteration over a model's fields, these\n values are computed once and then cached for the remainder of the runtime of\n your application.\n\n If your application needs to modify a class after its initial definition\n (for example, using `reopen()` to add additional attributes), make sure you\n do it before using your model with the store, which uses these properties\n extensively.\n */\n\n /**\n For a given relationship name, returns the model type of the relationship.\n\n For example, if you define a model like this:\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') comments;\n }\n ```\n\n Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.\n\n @public\n @param name the name of the relationship\n @param store an instance of Store\n @return the type of the relationship, or undefined\n */\n static typeForRelationship(name: string, store: Store): ModelSchema | undefined {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const relationship = this.relationshipsByName.get(name);\n return relationship && store.modelFor(relationship.type);\n }\n\n /**\n * A cache of resolved inverse relationships by name, populated lazily by\n * {@link Model.inverseFor | inverseFor}.\n */\n @computeOnce\n static get inverseMap(): Record<string, LegacyRelationshipField | null> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n return Object.create(null) as Record<string, LegacyRelationshipField | null>;\n }\n\n /**\n Find the relationship which is the inverse of the one asked for.\n\n For example, if you define models like this:\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('message') comments;\n }\n ```\n\n ```js [app/models/message.js]\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class MessageModel extends Model {\n @belongsTo('post') owner;\n }\n ```\n\n ``` js\n store.modelFor('post').inverseFor('comments', store) // { type: 'message', name: 'owner', kind: 'belongsTo' }\n store.modelFor('message').inverseFor('owner', store) // { type: 'post', name: 'comments', kind: 'hasMany' }\n ```\n\n @public\n @param name the name of the relationship\n @param store\n @return the inverse relationship, or null\n */\n static inverseFor(name: string, store: Store): LegacyRelationshipField | null {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n const inverseMap = this.inverseMap;\n if (inverseMap[name]) {\n return inverseMap[name];\n } else {\n const inverse = this._findInverseFor(name, store);\n inverseMap[name] = inverse;\n return inverse;\n }\n }\n\n /**\n * @private\n */\n //Calculate the inverse, ignoring the cache\n static _findInverseFor(name: string, store: Store): LegacyRelationshipField | null {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const relationship = this.relationshipsByName.get(name)!;\n assert(`No relationship named '${name}' on '${this.modelName}' exists.`, relationship);\n\n if (!relationship) {\n return null;\n }\n\n const { options } = relationship;\n assert(\n `Expected the relationship ${name} on ${this.modelName} to define an inverse.`,\n options.inverse === null || (typeof options.inverse === 'string' && options.inverse.length > 0)\n );\n\n if (options.inverse === null) {\n return null;\n }\n\n const schemaExists = store.schema.hasResource(relationship);\n\n assert(\n `No associated schema found for '${relationship.type}' while calculating the inverse of ${name} on ${this.modelName}`,\n schemaExists\n );\n\n if (!schemaExists) {\n return null;\n }\n\n const inverseField = store.schema.fields(relationship).get(options.inverse);\n assert(\n `No inverse relationship found for '${name}' on '${this.modelName}'`,\n inverseField && (inverseField.kind === 'belongsTo' || inverseField.kind === 'hasMany')\n );\n\n return inverseField || null;\n }\n\n /**\n The model's relationships as a map, keyed on the type of the\n relationship. The value of each entry is an array containing a descriptor\n for each relationship with that type, describing the name of the relationship\n as well as the type.\n\n For example, given the following model definition:\n\n ```js [app/models/blog.js]\n import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @hasMany('user') users;\n @belongsTo('user') owner;\n @hasMany('post') posts;\n }\n ```\n\n This computed property would return a map describing these\n relationships, like this:\n\n ```javascript\n import Blog from 'app/models/blog';\n import User from 'app/models/user';\n import Post from 'app/models/post';\n\n let relationships = Blog.relationships;\n relationships.user;\n //=> [ { name: 'users', kind: 'hasMany' },\n // { name: 'owner', kind: 'belongsTo' } ]\n relationships.post;\n //=> [ { name: 'posts', kind: 'hasMany' } ]\n ```\n\n @public\n */\n @computeOnce\n static get relationships(): Map<string, LegacyRelationshipField[]> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const map = new Map<string, LegacyRelationshipField[]>();\n const relationshipsByName = this.relationshipsByName;\n\n // Loop through each computed property on the class\n relationshipsByName.forEach((desc) => {\n const { type } = desc;\n\n if (!map.has(type)) {\n map.set(type, []);\n }\n\n map.get(type)!.push(desc);\n });\n\n return map;\n }\n\n /**\n A hash containing lists of the model's relationships, grouped\n by the relationship kind. For example, given a model with this\n definition:\n\n ```js [app/models/blog.js]\n import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @hasMany('user') users;\n @belongsTo('user') owner;\n\n @hasMany('post') posts;\n }\n ```\n\n This property would contain the following:\n\n ```javascript\n import Blog from 'app/models/blog';\n\n let relationshipNames = Blog.relationshipNames;\n relationshipNames.hasMany;\n //=> ['users', 'posts']\n relationshipNames.belongsTo;\n //=> ['owner']\n ```\n\n @public\n */\n @computeOnce\n static get relationshipNames(): {\n /**\n * the names of the model's `hasMany` relationships\n */\n hasMany: string[];\n /**\n * the names of the model's `belongsTo` relationships\n */\n belongsTo: string[];\n } {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n const names: { hasMany: string[]; belongsTo: string[] } = {\n hasMany: [],\n belongsTo: [],\n };\n\n this.eachComputedProperty((name, meta) => {\n if (isRelationshipSchema(meta)) {\n names[meta.kind].push(name);\n }\n });\n\n return names;\n }\n\n /**\n An array of types directly related to a model. Each type will be\n included once, regardless of the number of relationships it has with\n the model.\n\n For example, given a model with this definition:\n\n ```js [app/models/blog.js]\n import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @hasMany('user') users;\n @belongsTo('user') owner;\n\n @hasMany('post') posts;\n }\n ```\n\n This property would contain the following:\n\n ```javascript\n import Blog from 'app/models/blog';\n\n let relatedTypes = Blog.relatedTypes');\n //=> ['user', 'post']\n ```\n\n @public\n */\n @computeOnce\n static get relatedTypes(): string[] {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const types: string[] = [];\n\n const rels = this.relationshipsObject;\n const relationships = Object.keys(rels);\n\n // create an array of the unique types involved\n // in relationships\n for (let i = 0; i < relationships.length; i++) {\n const name = relationships[i];\n const meta = rels[name];\n const modelName = meta.type;\n\n if (!types.includes(modelName)) {\n types.push(modelName);\n }\n }\n\n return types;\n }\n\n /**\n A map whose keys are the relationships of a model and whose values are\n relationship descriptors.\n\n For example, given a model with this\n definition:\n\n ```js [app/models/blog.js]\n import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @hasMany('user') users;\n @belongsTo('user') owner;\n\n @hasMany('post') posts;\n }\n ```\n\n This property would contain the following:\n\n ```javascript\n import Blog from 'app/models/blog';\n\n let relationshipsByName = Blog.relationshipsByName;\n relationshipsByName.users;\n //=> { name: 'users', kind: 'hasMany', type: 'user', options: Object }\n relationshipsByName.owner;\n //=> { name: 'owner', kind: 'belongsTo', type: 'user', options: Object }\n ```\n\n @public\n */\n @computeOnce\n static get relationshipsByName(): Map<string, LegacyRelationshipField> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n const map = new Map();\n const rels = this.relationshipsObject;\n const relationships = Object.keys(rels);\n\n for (let i = 0; i < relationships.length; i++) {\n const name = relationships[i];\n const value = rels[name];\n\n map.set(value.name, value);\n }\n\n return map;\n }\n\n /**\n * A hash of the model's relationship schemas keyed by relationship name.\n * See also {@link Model.relationshipsByName | relationshipsByName}, which\n * provides the same information as a `Map`.\n */\n @computeOnce\n static get relationshipsObject(): Record<string, LegacyRelationshipField> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const relationships = Object.create(null) as Record<string, LegacyRelationshipField>;\n const modelName = this.modelName;\n this.eachComputedProperty((name: string, meta: unknown) => {\n if (!isRelationshipSchema(meta)) {\n return;\n }\n // TODO deprecate key being here\n (meta as unknown as { key: string }).key = name;\n meta.name = name;\n relationships[name] = meta;\n\n assert(`Expected options in meta`, meta.options && typeof meta.options === 'object');\n assert(\n `You should not specify both options.as and options.inverse as null on ${modelName}.${meta.name}, as if there is no inverse field there is no abstract type to conform to. You may have intended for this relationship to be polymorphic, or you may have mistakenly set inverse to null.`,\n !(meta.options.inverse === null && meta.options.as?.length)\n );\n });\n return relationships;\n }\n\n /**\n A map whose keys are the fields of the model and whose values are strings\n describing the kind of the field. A model's fields are the union of all of its\n attributes and relationships.\n\n For example:\n\n ```js [app/models/blog.js]\n import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @hasMany('user') users;\n @belongsTo('user') owner;\n\n @hasMany('post') posts;\n\n @attr('string') title;\n }\n ```\n\n ```js\n import Blog from 'app/models/blog'\n\n let fields = Blog.fields;\n fields.forEach(function(kind, field) {\n // do thing\n });\n\n // prints:\n // users, hasMany\n // owner, belongsTo\n // posts, hasMany\n // title, attribute\n ```\n\n @public\n */\n @computeOnce\n static get fields(): Map<string, 'attribute' | 'belongsTo' | 'hasMany'> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n const map = new Map();\n\n this.eachComputedProperty((name, meta) => {\n if (isRelationshipSchema(meta)) {\n map.set(name, meta.kind);\n } else if (isAttributeSchema(meta)) {\n map.set(name, 'attribute');\n }\n });\n\n return map;\n }\n\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @public\n @param callback the callback to invoke\n @param binding the value to which the callback's `this` should be bound\n */\n static eachRelationship<T, Schema extends Model>(\n callback: (\n this: T | undefined,\n key: MaybeRelationshipFields<Schema>,\n relationship: LegacyRelationshipField\n ) => void,\n binding?: T\n ): void {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n this.relationshipsByName.forEach((relationship, name) => {\n callback.call(binding, name as MaybeRelationshipFields<Schema>, relationship);\n });\n }\n\n /**\n Given a callback, iterates over each of the types related to a model,\n invoking the callback with the related type's class. Each type will be\n returned just once, regardless of how many different relationships it has\n with a model.\n\n @public\n @param callback the callback to invoke\n @param binding the value to which the callback's `this` should be bound\n */\n static eachRelatedType<T>(callback: (this: T | undefined, type: string) => void, binding?: T): void {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const relationshipTypes = this.relatedTypes;\n\n for (let i = 0; i < relationshipTypes.length; i++) {\n const type = relationshipTypes[i];\n callback.call(binding, type);\n }\n }\n\n /**\n *\n * @private\n * @deprecated\n */\n static determineRelationshipType(\n knownSide: LegacyRelationshipField,\n store: Store\n ): 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany' | 'oneToNone' | 'manyToNone' {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const knownKey = knownSide.name;\n const knownKind = knownSide.kind;\n const inverse = this.inverseFor(knownKey, store);\n // let key;\n\n if (!inverse) {\n return knownKind === 'belongsTo' ? 'oneToNone' : 'manyToNone';\n }\n\n // key = inverse.name;\n const otherKind = inverse.kind;\n\n if (otherKind === 'belongsTo') {\n return knownKind === 'belongsTo' ? 'oneToOne' : 'manyToOne';\n } else {\n return knownKind === 'belongsTo' ? 'oneToMany' : 'manyToMany';\n }\n }\n\n /**\n A map whose keys are the attributes of the model (properties\n described by attr) and whose values are the meta object for the\n property.\n\n Example\n\n ```js [app/models/person.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class PersonModel extends Model {\n @attr('string') firstName;\n @attr('string') lastName;\n @attr('date') birthday;\n }\n ```\n\n ```javascript\n import Person from 'app/models/person'\n\n let attributes = Person.attributes\n\n attributes.forEach(function(meta, name) {\n // do thing\n });\n\n // prints:\n // firstName {type: \"string\", kind: 'attribute', options: Object, parentType: function, name: \"firstName\"}\n // lastName {type: \"string\", kind: 'attribute', options: Object, parentType: function, name: \"lastName\"}\n // birthday {type: \"date\", kind: 'attribute', options: Object, parentType: function, name: \"birthday\"}\n ```\n\n @public\n */\n @computeOnce\n static get attributes(): Map<string, LegacyAttributeField> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const map = new Map<string, LegacyAttributeField>();\n\n this.eachComputedProperty((name, meta) => {\n if (isAttributeSchema(meta)) {\n assert(\n \"You may not set 'id' as an attribute on your model. Please remove any lines that look like: `id: attr('<type>')` from \" +\n this.toString(),\n name !== 'id'\n );\n\n // TODO deprecate key being here\n (meta as unknown as { key: string }).key = name;\n meta.name = name;\n map.set(name, meta);\n }\n });\n\n return map;\n }\n\n /**\n A map whose keys are the attributes of the model (properties\n described by attr) and whose values are type of transformation\n applied to each attribute. This map does not include any\n attributes that do not have an transformation type.\n\n Example\n\n ```js [app/models/person.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class PersonModel extends Model {\n @attr firstName;\n @attr('string') lastName;\n @attr('date') birthday;\n }\n ```\n\n ```javascript\n import Person from 'app/models/person';\n\n let transformedAttributes = Person.transformedAttributes\n\n transformedAttributes.forEach(function(field, type) {\n // do thing\n });\n\n // prints:\n // lastName string\n // birthday date\n ```\n\n @public\n */\n @computeOnce\n static get transformedAttributes(): Map<string, string> {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n const map = new Map<string, string>();\n\n this.eachAttribute((name: string, meta: LegacyAttributeField) => {\n if (meta.type) {\n map.set(name, meta.type);\n }\n });\n\n return map;\n }\n\n /**\n Iterates through the attributes of the model, calling the passed function on each\n attribute.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, meta);\n ```\n\n - `name` the name of the current property in the iteration\n - `meta` the meta object for the attribute property in the iteration\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```javascript\n import { Model, attr } from '@warp-drive/legacy/model';\n\n class PersonModel extends Model {\n @attr('string') firstName;\n @attr('string') lastName;\n @attr('date') birthday;\n }\n\n PersonModel.eachAttribute(function(name, meta) {\n // do thing\n });\n\n // prints:\n // firstName {type: \"string\", kind: 'attribute', options: Object, parentType: function, name: \"firstName\"}\n // lastName {type: \"string\", kind: 'attribute', options: Object, parentType: function, name: \"lastName\"}\n // birthday {type: \"date\", kind: 'attribute', options: Object, parentType: function, name: \"birthday\"}\n ```\n\n @public\n @param callback The callback to execute\n @param binding [optional] the value to which the callback's `this` should be bound\n */\n static eachAttribute<T, Schema extends Model>(\n callback: (this: T | undefined, key: MaybeAttrFields<Schema>, attribute: LegacyAttributeField) => void,\n binding?: T\n ): void {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n this.attributes.forEach((meta, name) => {\n callback.call(binding, name as MaybeAttrFields<Schema>, meta);\n });\n }\n\n /**\n Iterates through the transformedAttributes of the model, calling\n the passed function on each attribute. Note the callback will not be\n called for any attributes that do not have an transformation type.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, type);\n ```\n\n - `name` the name of the current property in the iteration\n - `type` a string containing the name of the type of transformed\n applied to the attribute\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```javascript\n import { Model, attr } from '@warp-drive/legacy/model';\n\n let Person = Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n Person.eachTransformedAttribute(function(name, type) {\n // do thing\n });\n\n // prints:\n // lastName string\n // birthday date\n ```\n\n @public\n @param callback The callback to execute\n @param binding [optional] the value to which the callback's `this` should be bound\n */\n static eachTransformedAttribute<T, Schema extends Model>(\n callback: (this: T | undefined, key: Exclude<keyof Schema & string, keyof Model & string>, type: string) => void,\n binding?: T\n ): void {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n this.transformedAttributes.forEach((type: string, name) => {\n callback.call(binding, name as Exclude<keyof Schema & string, keyof Model & string>, type);\n });\n }\n\n /**\n Returns the name of the model class.\n\n @public\n */\n static toString() {\n assert(\n `Accessing schema information on Models without looking up the model via the store is disallowed.`,\n this.modelName\n );\n\n return `model:${this.modelName}`;\n }\n}\n\n// @ts-expect-error TS doesn't know how to do `this` function overloads\nModel.prototype.save = save;\n// @ts-expect-error TS doesn't know how to do `this` function overloads\nModel.prototype.destroyRecord = destroyRecord;\nModel.prototype.unloadRecord = unloadRecord;\nModel.prototype.hasMany = hasMany;\nModel.prototype.belongsTo = belongsTo;\nModel.prototype.serialize = serialize;\nModel.prototype._createSnapshot = createSnapshot;\nModel.prototype.deleteRecord = deleteRecord;\nModel.prototype.changedAttributes = changedAttributes;\nModel.prototype.rollbackAttributes = rollbackAttributes;\nModel.prototype.reload = reload;\n\ndefineGate(Model.prototype, 'isReloading', {\n get(this: Model): boolean {\n deprecate(\n `record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`,\n false,\n {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n }\n );\n return this._isReloading ?? false;\n },\n set(this: Model, v: boolean) {\n this._isReloading = v;\n },\n configurable: true,\n // @ts-expect-error specially handled prop\n isLocal: true,\n});\n\n/**\n * Restores the pre-`RequestManager` implementations of `save`,\n * `destroyRecord`, and `reload` onto the given `Model` subclass, for\n * apps that have not yet migrated off of the deprecated\n * `ENABLE_LEGACY_REQUEST_METHODS` behaviors.\n */\nexport function restoreDeprecatedModelRequestBehaviors(ModelKlass: typeof Model): void {\n // @ts-expect-error TS doesn't know how to do `this` function overloads\n ModelKlass.prototype.save = _save;\n // @ts-expect-error TS doesn't know how to do `this` function overloads\n ModelKlass.prototype.destroyRecord = _destroyRecord;\n ModelKlass.prototype.reload = _reload;\n\n defineGate(Model.prototype, 'isReloading', {\n get(this: Model): boolean {\n return this._isReloading ?? false;\n },\n set(this: Model, v: boolean) {\n this._isReloading = v;\n },\n // @ts-expect-error specially handled prop\n isLocal: true,\n });\n}\n\n// this is required to prevent `init` from passing\n// the values initialized during create to `setUnknownProperty`\n(Model.prototype as unknown as { _createProps: null })._createProps = null;\n(Model.prototype as unknown as { _secretInit: null })._secretInit = null;\n\nif (DEBUG) {\n const lookupDescriptor = function lookupDescriptor(obj: object, keyName: string) {\n let current: object = obj;\n do {\n const descriptor = Object.getOwnPropertyDescriptor(current, keyName);\n if (descriptor !== undefined) {\n return descriptor;\n }\n current = Object.getPrototypeOf(current) as object;\n } while (current !== null);\n return null;\n };\n\n // oxlint-disable-next-line typescript/unbound-method\n const init = Model.prototype.init;\n Model.prototype.init = function (createArgs: ModelCreateArgs) {\n init.call(this, createArgs);\n\n const ourDescriptor = lookupDescriptor(Model.prototype, 'currentState');\n const theirDescriptor = lookupDescriptor(this, 'currentState');\n\n if (!ourDescriptor || !theirDescriptor) {\n throw new Error(\n `Unable to determine if 'currentState' is a reserved property name on instances of classes extending Model. Please ensure that 'currentState' is not defined as a property on ${this.constructor.toString()}`\n );\n }\n\n const realState = this.___recordState;\n if (ourDescriptor.get !== theirDescriptor.get || realState !== this.currentState) {\n throw new Error(\n `'currentState' is a reserved property name on instances of classes extending Model. Please choose a different property name for ${this.constructor.toString()}`\n );\n }\n\n const ID_DESCRIPTOR = lookupDescriptor(Model.prototype, 'id');\n const idDesc = lookupDescriptor(this, 'id');\n\n if (!ID_DESCRIPTOR || !idDesc) {\n throw new Error(\n `Unable to determine if 'id' is a reserved property name on instances of classes extending Model. Please ensure that 'id' is not defined as a property on ${this.constructor.toString()}`\n );\n }\n\n if (idDesc.get !== ID_DESCRIPTOR.get) {\n throw new Error(\n `You may not set 'id' as an attribute on your model. Please remove any lines that look like: \\`id: attr('<type>')\\` from ${this.constructor.toString()}`\n );\n }\n };\n\n delete (Model as unknown as { reopen: unknown }).reopen;\n delete (Model as unknown as { reopenClass: unknown }).reopenClass;\n}\n\nexport { Model };\n\nfunction isRelationshipSchema(meta: unknown): meta is LegacyRelationshipField {\n const hasKind = typeof meta === 'object' && meta !== null && 'kind' in meta && 'options' in meta;\n return hasKind && (meta.kind === 'hasMany' || meta.kind === 'belongsTo');\n}\n\nfunction isAttributeSchema(meta: unknown): meta is LegacyAttributeField {\n return typeof meta === 'object' && meta !== null && 'kind' in meta && meta.kind === 'attribute';\n}\n","import { getOwner } from '@ember/application';\n\nimport type { Store } from '@warp-drive/core';\n\nimport { Model, type ModelFactory } from './model';\n\n/*\n In case someone defined a relationship to a mixin, for example:\n ```ts\n class CommentModel extends Model {\n @belongsTo('commentable', { polymorphic: true }) owner;\n }\n\n let Commentable = Mixin.create({\n @hasMany('comment') comments;\n });\n ```\n we want to look up a Commentable class which has all the necessary\n relationship meta data. Thus, we look up the mixin and create a mock\n Model, so we can access the relationship CPs of the mixin (`comments`)\n in this case\n */\nexport default function modelForMixin(store: Store, normalizedModelName: string): ModelFactory | undefined {\n const owner = getOwner(store)!;\n const MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);\n const mixin = MaybeMixin && MaybeMixin.class;\n if (mixin) {\n const ModelForMixin = Model.extend(mixin) as unknown as { __isMixin: boolean; __mixin: typeof mixin };\n ModelForMixin.__isMixin = true;\n ModelForMixin.__mixin = mixin;\n //Cache the class as a model\n owner.register(`model:${normalizedModelName}`, ModelForMixin);\n }\n return owner.factoryFor(`model:${normalizedModelName}`) as ModelFactory | undefined;\n}\n","import { getOwner } from '@ember/application';\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { ENABLE_LEGACY_SCHEMA_SERVICE } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { ObjectValue } from '@warp-drive/core/types/json/raw';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core/types/schema/concepts';\nimport type {\n ArrayField,\n CacheableFieldSchema,\n DerivedField,\n GenericField,\n HashField,\n IdentityField,\n LegacyAttributeField,\n LegacyField,\n LegacyRelationshipField,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core/types/schema/fields';\n\nimport _modelForMixin from './model-for-mixin.ts';\nimport type { FactoryCache, ModelFactory, ModelStore } from './model.ts';\nimport { normalizeModelName } from './util.ts';\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ntype InternalSchema = {\n schema: ResourceSchema;\n fields: Map<string, LegacyAttributeField | LegacyRelationshipField>;\n cacheFields: Map<string, Exclude<CacheableFieldSchema, IdentityField>>;\n attributes: Record<string, LegacyAttributeField>;\n relationships: Record<string, LegacyRelationshipField>;\n};\n\nexport interface ModelSchemaProvider {\n attributesDefinitionFor(resource: ResourceKey | { type: string }): AttributesSchema;\n\n relationshipsDefinitionFor(resource: ResourceKey | { type: string }): RelationshipsSchema;\n\n doesTypeExist(type: string): boolean;\n}\nexport class ModelSchemaProvider implements SchemaService {\n /** @internal */\n declare private store: ModelStore;\n /** @internal */\n declare private _schemas: Map<string, InternalSchema>;\n /** @internal */\n declare private _typeMisses: Set<string>;\n\n constructor(store: ModelStore) {\n this.store = store;\n this._schemas = new Map();\n this._typeMisses = new Set();\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(this._schemas.keys());\n }\n\n hasTrait(type: string): boolean {\n assert(`hasTrait is not available with @warp-drive/legacy/model's SchemaService`);\n return false;\n }\n resourceHasTrait(resource: ResourceKey | { type: string }, trait: string): boolean {\n assert(`resourceHasTrait is not available with @warp-drive/legacy/model's SchemaService`);\n return false;\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n assert(`transformation is not available with @warp-drive/legacy/model's SchemaService`);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n assert(`derivation is not available with @warp-drive/legacy/model's SchemaService`);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n assert(`hashFn is not available with @warp-drive/legacy/model's SchemaService`);\n }\n resource(resource: ResourceKey | { type: string }): ResourceSchema | ObjectSchema {\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.schema;\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n assert(`registerResources is not available with @warp-drive/legacy/model's SchemaService`);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n assert(`registerResource is not available with @warp-drive/legacy/model's SchemaService`);\n }\n registerTransformation(transform: Transformation): void {\n assert(`registerTransformation is not available with @warp-drive/legacy/model's SchemaService`);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n assert(`registerDerivation is not available with @warp-drive/legacy/model's SchemaService`);\n }\n registerHashFn(hashFn: HashFn): void {\n assert(`registerHashFn is not available with @warp-drive/legacy/model's SchemaService`);\n }\n /** @internal */\n private _loadModelSchema(type: string): InternalSchema {\n const factory = getModelFactory(this.store, type);\n\n if (!factory) {\n throw new Error(`No model was found for '${type}'`);\n }\n\n const modelClass = factory.class;\n const attributeMap = modelClass.attributes;\n\n const attributes = Object.create(null) as AttributesSchema;\n attributeMap.forEach((meta, name) => (attributes[name] = meta));\n const relationships = modelClass.relationshipsObject || null;\n const fields = new Map<string, LegacyAttributeField | LegacyRelationshipField>();\n\n for (const attr of Object.values(attributes)) {\n fields.set(attr.name, attr);\n }\n\n for (const rel of Object.values(relationships)) {\n fields.set(rel.name, rel);\n }\n\n const schema: ResourceSchema = {\n legacy: true,\n identity: { name: 'id', kind: '@id' },\n type,\n fields: Array.from(fields.values()),\n };\n\n const cacheFields = new Map<string, Exclude<CacheableFieldSchema, IdentityField>>();\n for (const field of fields.values()) {\n const cacheKey = field.sourceKey ?? field.name;\n assert(\n `The sourceKey '${field.sourceKey}' for the field '${field.name}' on '${type}' is invalid because it matches the name of an existing field`,\n !field.sourceKey || field.sourceKey === field.name || !fields.has(field.sourceKey)\n );\n cacheFields.set(cacheKey, field);\n }\n\n const internalSchema: InternalSchema = {\n schema,\n attributes,\n relationships,\n fields,\n cacheFields,\n };\n\n this._schemas.set(type, internalSchema);\n\n return internalSchema;\n }\n\n fields(resource: ResourceKey | { type: string }): Map<string, LegacyField> {\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.fields;\n }\n\n cacheFields(resource: ResourceKey | { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.cacheFields;\n }\n\n hasResource(resource: { type: string }): boolean {\n const type = normalizeModelName(resource.type);\n\n if (this._schemas.has(type)) {\n return true;\n }\n\n if (this._typeMisses.has(type)) {\n return false;\n }\n\n const factory = getModelFactory(this.store, type);\n const exists = factory !== null;\n\n if (!exists) {\n this._typeMisses.add(type);\n return false;\n }\n\n return true;\n }\n}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n ModelSchemaProvider.prototype.doesTypeExist = function (type: string): boolean {\n deprecate(`Use \\`schema.hasResource({ type })\\` instead of \\`schema.doesTypeExist(type)\\``, false, {\n id: 'ember-data:schema-service-updates',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.4',\n },\n });\n return this.hasResource({ type });\n };\n\n ModelSchemaProvider.prototype.attributesDefinitionFor = function (\n resource: ResourceKey | { type: string }\n ): AttributesSchema {\n deprecate(`Use \\`schema.fields({ type })\\` instead of \\`schema.attributesDefinitionFor({ type })\\``, false, {\n id: 'ember-data:schema-service-updates',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.4',\n },\n });\n const type = normalizeModelName(resource.type);\n\n // @ts-expect-error intentional use of internal API\n if (!this._schemas.has(type)) {\n // @ts-expect-error intentional use of internal API\n this._loadModelSchema(type);\n }\n\n // @ts-expect-error intentional use of internal API\n return this._schemas.get(type)!.attributes;\n };\n\n ModelSchemaProvider.prototype.relationshipsDefinitionFor = function (\n resource: ResourceKey | { type: string }\n ): RelationshipsSchema {\n deprecate(`Use \\`schema.fields({ type })\\` instead of \\`schema.relationshipsDefinitionFor({ type })\\``, false, {\n id: 'ember-data:schema-service-updates',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.4',\n },\n });\n const type = normalizeModelName(resource.type);\n\n // @ts-expect-error intentional use of internal API\n if (!this._schemas.has(type)) {\n // @ts-expect-error intentional use of internal API\n this._loadModelSchema(type);\n }\n\n // @ts-expect-error intentional use of internal API\n return this._schemas.get(type)!.relationships;\n };\n}\n\n/**\n * The `createSchemaService` implementation for use with `Model`. Pass\n * the result of this to your store's `createSchemaService` method when\n * configuring the store to use `Model` for schema information.\n *\n * @public\n */\nexport function buildSchema(store: Store): SchemaService {\n return new ModelSchemaProvider(store as ModelStore);\n}\n\nexport function getModelFactory(store: ModelStore, type: string): ModelFactory | null {\n if (!store._modelFactoryCache) {\n store._modelFactoryCache = Object.create(null) as FactoryCache;\n }\n const cache = store._modelFactoryCache;\n let factory: ModelFactory | undefined = cache[type];\n\n if (!factory) {\n const owner = getOwner(store)!;\n factory = owner.factoryFor(`model:${type}`) as ModelFactory | undefined;\n\n if (!factory) {\n //Support looking up mixins as base types for polymorphic relationships\n factory = _modelForMixin(store, type);\n }\n\n if (!factory) {\n // we don't cache misses in case someone wants to register a missing model\n return null;\n }\n\n const klass = factory.class;\n\n if (klass.isModel) {\n const hasOwnModelNameSet = klass.modelName && Object.prototype.hasOwnProperty.call(klass, 'modelName');\n if (!hasOwnModelNameSet) {\n Object.defineProperty(klass, 'modelName', { value: type });\n }\n }\n\n cache[type] = factory;\n }\n\n return factory;\n}\n"],"mappings":";;;;;;;;;;;;;;AAqCA,SAAgBM,qBAAiE;CAC/E,MAAM,EAAEC,iBAAiB;CACzB,MAAM,EAAEC,UAAUD;CAClB,MAAME,QAAQ,KAAKP;CACnBD,mBAAmBQ,KAAK;CAExBA,MAAMC,YAAY;EAChBD,MAAME,MAAMC,cAAcZ,oBAAoB,IAAI,CAAC;EACnD,KAAKa,OAAOC,MAAM;EAClBP,aAAaQ,mBAAmB;EAChC,IAAIP,OACF,KAAKQ,aAAa;CAEtB,CAAC;AACH;AAEA,SAAgBA,eAA2D;CACzE,IAAI,KAAKT,aAAaC,UAAU,KAAKS,eAAe,K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.js","names":["Context","upgradeStore","SnapshotRecordArray","constructor","store","type","options","__store","_snapshots","modelName","adapterOptions","include","_recordArray","peekAll","length","snapshots","_fetchManager","LiveArrayContext","source","map","identifier","createSnapshot","assertIdentifierHasId","identifier","validateDocumentStructure","doc","normalizeResponseHelper","serializer","store","modelClass","payload","id","requestType","normalizedResponse","normalizeResponse","assertPrivateStore","upgradeStore","Snapshot","constructor","options","identifier","store","_store","__attributes","_belongsToRelationships","Object","create","_belongsToIds","_hasManyRelationships","_hasManyIds","hasRecord","_instanceCache","peek","modelName","type","_attributes","id","adapterOptions","include","cache","_changedAttributes","changedAttrs","record","peekRecord","attributes","eachAttribute","key","meta","getAttr","isNew","attr","keyName","changedAttributes","changedAttributeKeys","keys","i","length","slice","belongsTo","returnModeIsId","result","relationshipMeta","schema","fields","get","value","getRelationship","data","inverseIdentifier","cacheKeyManager","getOrCreateRecordIdentifier","undefined","isDeleted","_fetchManager","createSnapshot","hasMany","returnModeIsIds","ids","results","cachedIds","cachedSnapshots","forEach","member","push","callback","binding","modelFor","modelSchema","field","kind","call","eachRelationship","serialize","serializer","serializerFor","createDeferred","waitFor","assertPrivateStore","coerceId","getOrSetGlobal","upgradeStore","assertIdentifierHasId","payloadIsNotBlank","normalizeResponseHelper","Snapshot","SaveOp","Symbol","FetchManager","constructor","store","_store","_pendingFetch","Map","requestCache","getRequestStateService","isDestroyed","createSnapshot","identifier","options","scheduleSave","resolver","query","op","recordIdentifier","queryRequest","data","snapshot","pendingSaveItem","monitored","_enqueue","promise","_flushPendingSave","scheduleFetch","request","pendingFetch","getPendingFetch","modelName","type","pendingFetchItem","resolverPromise","isInitialLoad","_instanceCache","recordIsLoaded","then","payload","Array","isArray","lid","potentiallyNewIm","_push","reload","error","cache","isEmpty","isReleasable","_graph","graph","unload","_enableAsyncFlush","unloadRecord","size","Promise","resolve","setTimeout","flushAllPendingFetches","fetchesByType","fetchesById","get","set","requestsForIdentifier","push","pendingFetches","matchingPendingFetch","find","fetch","isSameRequest","forEach","fetchItem","_flushPendingFetchForType","clear","fetchDataIfNeededForIdentifier","_isEmpty","isLoading","_isLoading","destroy","instanceCache","isNew","isDeleted","req","isLoaded","getPendingRequestsForRecord","some","r","includesSatisfies","current","existing","length","arrCurrent","split","sort","arrExisting","join","i","includes","optionsSatisfies","Object","keys","existingOptions","adapterOptions","include","_findMany","adapter","snapshots","modelClass","modelFor","ids","map","s","id","ret","findMany","adapterPayload","serializer","serializerFor","rejectFetchedItems","fetchMap","l","pair","reject","Error","handleFoundRecords","coalescedPayload","snapshotsById","snapshotGroup","included","resources","resource","delete","rejected","snapshotArray","console","warn","values","_fetchRecord","_fetchManager","klass","findRecord","_processCoalescedGroup","group","payloads","catch","pendingFetchMap","adapterFor","shouldCoalesce","coalesceFindRequests","pendingFetchItems","totalItems","groups","groupRecordsForFindMany","pending","operation"],"sources":["../../../src/compat/legacy-network-handler/snapshot-record-array.ts","../../../src/compat/legacy-network-handler/identifier-has-id.ts","../../../src/compat/legacy-network-handler/serializer-response.ts","../../../src/compat/legacy-network-handler/snapshot.ts","../../../src/compat/legacy-network-handler/fetch-manager.ts","../../../src/compat/-private.ts"],"sourcesContent":["import type { Store } from '@warp-drive/core';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport type { LegacyLiveArray, PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport type { FindAllOptions, ModelSchema } from '@warp-drive/core/types';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\n\nimport { upgradeStore } from '../-private.ts';\nimport type { Snapshot } from './snapshot.ts';\n/**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters for certain `findAll` requests.\n\n @hideconstructor\n @public\n*/\nexport class SnapshotRecordArray {\n /**\n * An array of snapshots\n *\n * @internal\n */\n declare private _snapshots: Snapshot[] | null;\n\n /** @internal */\n declare private _type: ModelSchema | null;\n\n /**\n * The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array\n */\n declare modelName: string;\n\n /** @internal */\n declare private __store: Store;\n\n /**\n * A hash of adapter options passed into the store method for this request.\n\n Example\n\n ```js [app/adapters/post.js]\n import MyCustomAdapter from './custom-adapter';\n\n export default class PostAdapter extends MyCustomAdapter {\n findAll(store, type, sinceToken, snapshotRecordArray) {\n if (snapshotRecordArray.adapterOptions.subscribe) {\n // ...\n }\n // ...\n }\n }\n ```\n */\n declare adapterOptions?: Record<string, unknown>;\n /**\n * The relationships to include for this request.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default class ApplicationAdapter extends Adapter {\n findAll(store, type, snapshotRecordArray) {\n let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;\n\n return fetch(url).then((response) => response.json())\n }\n }\n ```\n */\n declare include?: string | string[];\n\n /**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters and serializers for certain requests.\n\n @private\n @constructor\n @param {Store} store\n @param {String} type\n @param options\n */\n constructor(store: Store, type: string, options: FindAllOptions = {}) {\n this.__store = store;\n this._snapshots = null;\n this.modelName = type;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n }\n\n /**\n An array of records\n\n @internal\n */\n get _recordArray(): LegacyLiveArray {\n return this.__store.peekAll(this.modelName);\n }\n\n /**\n Number of records in the array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotRecordArray) {\n return !snapshotRecordArray.length;\n }\n });\n ```\n */\n get length(): number {\n return this._recordArray.length;\n }\n\n /**\n Get snapshots of the underlying record array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotArray) {\n let snapshots = snapshotArray.snapshots();\n\n return snapshots.any(function(ticketSnapshot) {\n let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');\n if (timeDiff > 20) {\n return true;\n } else {\n return false;\n }\n });\n }\n }\n ```\n\n @public\n @return Array of snapshots\n */\n snapshots(): Snapshot[] {\n if (this._snapshots !== null) {\n return this._snapshots;\n }\n upgradeStore(this.__store);\n\n const { _fetchManager } = this.__store;\n const LiveArrayContext = (this._recordArray as unknown as PrivateReactiveResourceArray)[Context];\n this._snapshots = LiveArrayContext.source.map((identifier: ResourceKey) =>\n _fetchManager.createSnapshot(identifier)\n );\n\n return this._snapshots;\n }\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport type { PersistedResourceKey } from '@warp-drive/core/types/identifier';\n\nexport function assertIdentifierHasId(identifier: unknown): asserts identifier is PersistedResourceKey {\n assert(\n `Attempted to schedule a fetch for a record without an id.`,\n identifier && (identifier as PersistedResourceKey).id !== null\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 { ModelSchema } from '@warp-drive/core/types';\nimport type { JsonApiDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { AdapterPayload } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface, RequestType } from './minimum-serializer-interface.ts';\n\n/**\n This is a helper method that validates a JSON API top-level document\n\n The format of a document is described here:\n http://jsonapi.org/format/#document-top-level\n\n @internal\n*/\nfunction validateDocumentStructure(doc?: AdapterPayload | JsonApiDocument): asserts doc is JsonApiDocument {\n if (DEBUG) {\n const errors: string[] = [];\n if (!doc || typeof doc !== 'object') {\n errors.push('Top level of a JSON API document must be an object');\n } else {\n if (!('data' in doc) && !('errors' in doc) && !('meta' in doc)) {\n errors.push('One or more of the following keys must be present: \"data\", \"errors\", \"meta\".');\n } else {\n if ('data' in doc && 'errors' in doc) {\n errors.push('Top level keys \"errors\" and \"data\" cannot both be present in a JSON API document');\n }\n }\n if ('data' in doc) {\n if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {\n errors.push('data must be null, an object, or an array');\n }\n }\n if ('meta' in doc) {\n if (typeof doc.meta !== 'object') {\n errors.push('meta must be an object');\n }\n }\n if ('errors' in doc) {\n if (!Array.isArray(doc.errors)) {\n errors.push('errors must be an array');\n }\n }\n if ('links' in doc) {\n if (typeof doc.links !== 'object') {\n errors.push('links must be an object');\n }\n }\n if ('jsonapi' in doc) {\n if (typeof doc.jsonapi !== 'object') {\n errors.push('jsonapi must be an object');\n }\n }\n if ('included' in doc) {\n if (typeof doc.included !== 'object') {\n errors.push('included must be an array');\n }\n }\n }\n\n assert(\n `Response must be normalized to a valid JSON API document:\\n\\t* ${errors.join('\\n\\t* ')}`,\n errors.length === 0\n );\n }\n}\n\nexport function normalizeResponseHelper(\n serializer: MinimumSerializerInterface | null,\n store: Store,\n modelClass: ModelSchema,\n payload: AdapterPayload,\n id: string | null,\n requestType: RequestType\n): JsonApiDocument {\n const normalizedResponse = serializer\n ? serializer.normalizeResponse(store, modelClass, payload, id, requestType)\n : payload;\n\n validateDocumentStructure(normalizedResponse);\n\n return normalizedResponse;\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 { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions } from '@warp-drive/core/types';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { Value } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core/types/schema/fields';\n\nimport { upgradeStore } from '../-private';\nimport type { SerializerOptions } from './minimum-serializer-interface';\n\ntype RecordId = string | null;\n\n/**\n Snapshot is not directly instantiable.\n Instances are provided to a consuming application's\n adapters and serializers for certain requests.\n\n Snapshots are only available when using `@ember-data/legacy-compat`\n for legacy compatibility with adapters and serializers.\n\n For serialization of records in modern paradigms, request data from\n the cache or off the record directly.\n\n @hideconstructor\n @public\n*/\nexport class Snapshot<R = unknown> {\n /** @internal */\n declare private __attributes: Record<keyof R & string, unknown> | null;\n /** @internal */\n declare private _belongsToRelationships: Record<string, Snapshot>;\n /** @internal */\n declare private _belongsToIds: Record<string, RecordId>;\n /** @internal */\n declare private _hasManyRelationships: Record<string, Snapshot[]>;\n /** @internal */\n declare private _hasManyIds: Record<string, RecordId[]>;\n /** @internal */\n declare private _changedAttributes: ChangedAttributesHash;\n /** @internal */\n declare private _store: Store;\n\n /**\n The unique ResourceKey associated with this Snapshot.\n\n @public\n */\n declare identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;\n\n /**\n The ResourceType of the underlying record for this Snapshot, as a string.\n\n @public\n */\n declare modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;\n\n /**\n The id of the snapshot's underlying record\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.id; // => '1'\n ```\n\n @public\n */\n declare id: string | null;\n\n /**\n If `include` was passed to the options for the request, the value\n would be available here.\n\n @public\n */\n declare include?: string | string[];\n\n /**\n The adapterOptions passed to the request which generated this Snapshot, if any\n\n @public\n */\n declare adapterOptions?: Record<string, unknown>;\n\n constructor(\n options: FindRecordOptions,\n identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>,\n store: Store\n ) {\n this._store = store;\n\n this.__attributes = null;\n this._belongsToRelationships = Object.create(null) as Record<string, Snapshot>;\n this._belongsToIds = Object.create(null) as Record<string, RecordId>;\n this._hasManyRelationships = Object.create(null) as Record<string, Snapshot[]>;\n this._hasManyIds = Object.create(null) as Record<string, RecordId[]>;\n\n assertPrivateStore(store);\n const hasRecord = !!store._instanceCache.peek(identifier);\n this.modelName = identifier.type;\n this.identifier = identifier;\n\n /*\n If the we do not yet have a record, then we are\n likely a snapshot being provided to a find request, so we\n populate __attributes lazily. Else, to preserve the \"moment\n in time\" in which a snapshot is created, we greedily grab\n the values.\n */\n if (hasRecord) {\n // oxlint-disable-next-line no-unused-expressions\n this._attributes;\n }\n\n this.id = identifier.id;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n this.modelName = identifier.type;\n\n if (hasRecord) {\n const cache = this._store.cache;\n this._changedAttributes = cache.changedAttrs(identifier);\n }\n }\n\n /**\n The underlying record for this snapshot. Can be used to access methods and\n properties defined on the record.\n\n ```js\n const someValue = snapshot.record.someProp;\n ```\n\n @property record\n @public\n */\n get record(): R | null {\n const record = this._store.peekRecord<R>(this.identifier);\n assert(\n `Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`,\n record !== null\n );\n return record;\n }\n\n /** @internal */\n private get _attributes(): Record<keyof R & string, unknown> {\n if (this.__attributes !== null) {\n return this.__attributes;\n }\n const attributes = (this.__attributes = Object.create(null) as Record<string, unknown>);\n const { identifier } = this;\n const cache = this._store.cache;\n\n this.eachAttribute((key: string, meta: LegacyAttributeField) => {\n attributes[key] = cache.getAttr(identifier, key);\n });\n\n return attributes;\n }\n\n get isNew(): boolean {\n const cache = this._store.cache;\n return cache?.isNew(this.identifier) || false;\n }\n\n /**\n Returns the value of an attribute.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attr('author'); // => 'Tomster'\n postSnapshot.attr('title'); // => 'Ember.js rocks'\n ```\n\n Note: Values are loaded eagerly and cached when the snapshot is created.\n\n @return The attribute value or undefined\n @public\n */\n attr(keyName: keyof R & string): unknown {\n if (keyName in this._attributes) {\n return this._attributes[keyName];\n }\n assert(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`, false);\n }\n\n /**\n Returns all attributes and their corresponding values.\n\n ::: warning ⚠️ WARNING\n Attributes are SHALLOW copied from the cache.\n Because they are NOT deep copied from the cache, mutating\n any object or array fields will cause unintended side-effects\n and bugs.\n :::\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }\n ```\n\n @return All attributes of the current snapshot\n @public\n */\n attributes(): Record<keyof R & string, unknown> {\n return { ...this._attributes };\n }\n\n /**\n Returns all changed attributes and their old and new values.\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postModel.set('title', 'Ember.js rocks!');\n postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }\n ```\n\n @return All changed attributes of the current snapshot\n @public\n */\n changedAttributes(): ChangedAttributesHash {\n const changedAttributes = Object.create(null) as ChangedAttributesHash;\n if (!this._changedAttributes) {\n return changedAttributes;\n }\n\n const changedAttributeKeys = Object.keys(this._changedAttributes);\n\n for (let i = 0, length = changedAttributeKeys.length; i < length; i++) {\n const key = changedAttributeKeys[i];\n changedAttributes[key] = this._changedAttributes[key].slice() as [Value | undefined, Value];\n }\n\n return changedAttributes;\n }\n\n /**\n Returns the current value of a belongsTo relationship.\n\n `belongsTo` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `id`: set to `true` if you only want the ID of the related record to be\n returned.\n\n Example\n\n ```js\n // store.push('post', { id: 1, title: 'Hello World' });\n // store.createRecord('comment', { body: 'Lorem ipsum', post: post });\n commentSnapshot.belongsTo('post'); // => Snapshot\n commentSnapshot.belongsTo('post', { id: true }); // => '1'\n\n // store.push('comment', { id: 1, body: 'Lorem ipsum' });\n commentSnapshot.belongsTo('post'); // => undefined\n ```\n\n Calling `belongsTo` will return a new Snapshot as long as there's any known\n data for the relationship available, such as an ID. If the relationship is\n known but unset, `belongsTo` will return `null`. If the contents of the\n relationship is unknown `belongsTo` will return `undefined`.\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return A snapshot or ID of a known relationship or null if the\n relationship is known but unset. undefined will be returned if the\n contents of the relationship are unknown.\n */\n belongsTo(keyName: string, options?: { id?: boolean }): Snapshot | RecordId | undefined {\n const returnModeIsId = !!(options && options.id);\n let result: Snapshot | RecordId | undefined;\n const store = this._store;\n\n if (returnModeIsId === true && keyName in this._belongsToIds) {\n return this._belongsToIds[keyName];\n }\n\n if (returnModeIsId === false && keyName in this._belongsToRelationships) {\n return this._belongsToRelationships[keyName];\n }\n\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'belongsTo'\n );\n\n assert(`snapshot.belongsTo only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a hasMany.`,\n relationship.kind === 'belongsTo'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName);\n const data = value && value.data;\n upgradeStore(store);\n\n const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;\n\n if (value && value.data !== undefined) {\n const cache = store.cache;\n\n if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsId) {\n result = inverseIdentifier.id;\n } else {\n result = store._fetchManager.createSnapshot(inverseIdentifier);\n }\n } else {\n result = null;\n }\n }\n\n if (returnModeIsId) {\n this._belongsToIds[keyName] = result as RecordId;\n } else {\n this._belongsToRelationships[keyName] = result as Snapshot;\n }\n\n return result;\n }\n\n /**\n Returns the current value of a hasMany relationship.\n\n `hasMany` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `ids`: set to `true` if you only want the IDs of the related records to be\n returned.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });\n postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]\n postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']\n\n // store.push('post', { id: 1, title: 'Hello World' });\n postSnapshot.hasMany('comments'); // => undefined\n ```\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return An array of snapshots or IDs of a known\n relationship or an empty array if the relationship is known but unset.\n undefined will be returned if the contents of the relationship is unknown.\n */\n hasMany(keyName: string, options?: { ids?: boolean }): RecordId[] | Snapshot[] | undefined {\n const returnModeIsIds = !!(options && options.ids);\n let results: RecordId[] | Snapshot[] | undefined;\n const cachedIds: RecordId[] | undefined = this._hasManyIds[keyName];\n const cachedSnapshots: Snapshot[] | undefined = this._hasManyRelationships[keyName];\n\n if (returnModeIsIds === true && keyName in this._hasManyIds) {\n return cachedIds;\n }\n\n if (returnModeIsIds === false && keyName in this._hasManyRelationships) {\n return cachedSnapshots;\n }\n\n const store = this._store;\n upgradeStore(store);\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'hasMany'\n );\n\n // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes\n // this check is not a regression in behavior because relationships don't currently\n // function without access to intimate API contracts between RecordData and Model.\n // This is a requirement we should fix as soon as the relationship layer does not require\n // this intimate API usage.\n assert(`snapshot.hasMany only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a belongsTo.`,\n relationship.kind === 'hasMany'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName) as CollectionRelationship;\n\n if (value.data) {\n results = [];\n value.data.forEach((member) => {\n const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);\n const cache = store.cache;\n\n if (!cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsIds) {\n (results as RecordId[]).push(inverseIdentifier.id);\n } else {\n (results as Snapshot[]).push(store._fetchManager.createSnapshot(inverseIdentifier));\n }\n }\n });\n }\n\n // we assign even if `undefined` so that we don't reprocess the relationship\n // on next access. This works with the `keyName in` checks above.\n if (returnModeIsIds) {\n this._hasManyIds[keyName] = results as RecordId[];\n } else {\n this._hasManyRelationships[keyName] = results as Snapshot[];\n }\n\n return results;\n }\n\n /**\n Iterates through all the attributes of the model, calling the passed\n function on each attribute.\n\n Example\n\n ```javascript\n snapshot.eachAttribute(function(name, meta) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate attributes. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachAttribute(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'attribute') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Iterates through all the relationships of the model, calling the passed\n function on each relationship.\n\n Example\n\n ```javascript\n snapshot.eachRelationship(function(name, relationship) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate relationships. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachRelationship(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'belongsTo' || field.kind === 'hasMany') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Serializes the snapshot using the serializer for the model.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default Adapter.extend({\n createRecord(store, type, snapshot) {\n let data = snapshot.serialize({ includeId: true });\n let url = `/${type.modelName}`;\n\n return fetch(url, {\n method: 'POST',\n body: data,\n }).then((response) => response.json())\n }\n });\n ```\n\n @return an object whose values are primitive JSON values only\n @public\n */\n serialize(options?: SerializerOptions): unknown {\n upgradeStore(this._store);\n const serializer = this._store.serializerFor(this.modelName);\n assert(`Cannot serialize record, no serializer found`, serializer);\n return serializer.serialize(this, options);\n }\n}\n","import { warn } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { createDeferred } from '@warp-drive/core/request';\nimport { waitFor } from '@warp-drive/core/signals/-leaked';\nimport type {\n FindRecordQuery,\n InstanceCache,\n PrivateRequestStateService,\n PrivateStore,\n Request,\n SaveRecordMutation,\n} from '@warp-drive/core/store/-private';\nimport { assertPrivateStore, coerceId } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions, ModelSchema } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ImmutableRequestInfo } from '@warp-drive/core/types/request';\nimport type { CollectionResourceDocument, SingleResourceDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../-private.ts';\nimport { assertIdentifierHasId } from './identifier-has-id.ts';\nimport { payloadIsNotBlank } from './legacy-data-utils.ts';\nimport type { AdapterPayload, MinimumAdapterInterface } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface } from './minimum-serializer-interface.ts';\nimport { normalizeResponseHelper } from './serializer-response.ts';\nimport { Snapshot } from './snapshot.ts';\n\ntype Deferred<T> = ReturnType<typeof createDeferred<T>>;\ntype AdapterErrors = Error & { errors?: string[]; isAdapterError?: true };\ntype SerializerWithParseErrors = MinimumSerializerInterface & {\n extractErrors?(store: Store, modelClass: ModelSchema, error: AdapterErrors, recordId: string | null): unknown;\n};\n\nexport const SaveOp: '___(unique) Symbol(SaveOp)' = getOrSetGlobal('SaveOp', Symbol('SaveOp'));\n\nexport type FetchMutationOptions = FindRecordOptions & { [SaveOp]: 'createRecord' | 'deleteRecord' | 'updateRecord' };\n\ninterface PendingFetchItem {\n identifier: PersistedResourceKey;\n queryRequest: Request;\n // oxlint-disable-next-line typescript/no-explicit-any\n resolver: Deferred<any>;\n options: FindRecordOptions;\n trace?: unknown;\n promise: Promise<PersistedResourceKey>;\n}\n\ninterface PendingSaveItem {\n // oxlint-disable-next-line typescript/no-explicit-any\n resolver: Deferred<any>;\n snapshot: Snapshot;\n identifier: ResourceKey;\n options: FetchMutationOptions;\n queryRequest: Request;\n}\n\n/**\n * @private\n */\nexport class FetchManager {\n /**\n * @internal\n */\n declare isDestroyed: boolean;\n /** @internal */\n declare private requestCache: PrivateRequestStateService;\n // fetches pending in the runloop, waiting to be coalesced\n /**\n * @internal\n */\n declare _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n\n /** @internal */\n declare private _store: PrivateStore;\n\n constructor(store: Store) {\n assertPrivateStore(store);\n this._store = store;\n // used to keep track of all the find requests that need to be coalesced\n this._pendingFetch = new Map();\n this.requestCache = store.getRequestStateService();\n this.isDestroyed = false;\n }\n\n createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;\n createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;\n createSnapshot(identifier: ResourceKey, options: FindRecordOptions = {}): Snapshot {\n return new Snapshot(options, identifier, this._store);\n }\n\n /**\n This method is called by `record.save`, and gets passed a\n resolver for the promise that `record.save` returns.\n\n It schedules saving to happen at the end of the run loop.\n\n @private\n */\n scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument> {\n const resolver = createDeferred<SingleResourceDocument | null>();\n const query: SaveRecordMutation = {\n op: 'saveRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const snapshot = this.createSnapshot(identifier, options);\n const pendingSaveItem: PendingSaveItem = {\n snapshot: snapshot,\n resolver: resolver,\n identifier,\n options,\n queryRequest,\n };\n\n const monitored = this.requestCache._enqueue(resolver.promise, pendingSaveItem.queryRequest);\n _flushPendingSave(this._store, pendingSaveItem);\n\n return monitored;\n }\n\n scheduleFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions,\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n const query: FindRecordQuery = {\n op: 'findRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const pendingFetch = this.getPendingFetch(identifier, options);\n if (pendingFetch) {\n return pendingFetch;\n }\n\n const modelName = identifier.type;\n\n const resolver = createDeferred<SingleResourceDocument>();\n const pendingFetchItem: PendingFetchItem = {\n identifier,\n resolver,\n options,\n queryRequest,\n } as PendingFetchItem;\n\n const resolverPromise = resolver.promise;\n const store = this._store;\n const isInitialLoad = !store._instanceCache.recordIsLoaded(identifier); // we don't use isLoading directly because we are the request\n\n const monitored = this.requestCache._enqueue(resolverPromise, pendingFetchItem.queryRequest);\n let promise = monitored.then(\n (payload) => {\n // ensure that regardless of id returned we assign to the correct record\n if (payload.data && !Array.isArray(payload.data)) {\n payload.data.lid = identifier.lid;\n }\n\n // additional data received in the payload\n // may result in the merging of identifiers (and thus records)\n const potentiallyNewIm = store._push(payload, options.reload);\n if (potentiallyNewIm && !Array.isArray(potentiallyNewIm)) {\n return potentiallyNewIm;\n }\n\n return identifier;\n },\n (error) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !store.isDestroyed);\n const cache = store.cache;\n if (!cache || cache.isEmpty(identifier) || isInitialLoad) {\n let isReleasable = true;\n if (store._graph) {\n const graph = store._graph;\n if (!cache) {\n isReleasable = graph.isReleasable(identifier);\n if (!isReleasable) {\n graph.unload(identifier, true);\n }\n }\n }\n if (cache || isReleasable) {\n store._enableAsyncFlush = true;\n store._instanceCache.unloadRecord(identifier);\n store._enableAsyncFlush = null;\n }\n }\n throw error;\n }\n );\n\n if (this._pendingFetch.size === 0) {\n void new Promise((resolve) => setTimeout(resolve, 0)).then(() => {\n this.flushAllPendingFetches();\n });\n }\n\n const fetchesByType = this._pendingFetch;\n let fetchesById = fetchesByType.get(modelName);\n\n if (!fetchesById) {\n fetchesById = new Map();\n fetchesByType.set(modelName, fetchesById);\n }\n\n let requestsForIdentifier = fetchesById.get(identifier);\n if (!requestsForIdentifier) {\n requestsForIdentifier = [];\n fetchesById.set(identifier, requestsForIdentifier);\n }\n\n requestsForIdentifier.push(pendingFetchItem);\n\n if (TESTING) {\n if (!request.disableTestWaiter) {\n promise = waitFor(promise);\n }\n }\n\n pendingFetchItem.promise = promise;\n return promise;\n }\n\n getPendingFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions\n ): Promise<PersistedResourceKey> | undefined {\n const pendingFetches = this._pendingFetch.get(identifier.type)?.get(identifier);\n\n // We already have a pending fetch for this\n if (pendingFetches) {\n const matchingPendingFetch = pendingFetches.find((fetch) => isSameRequest(options, fetch.options));\n if (matchingPendingFetch) {\n return matchingPendingFetch.promise;\n }\n }\n }\n\n flushAllPendingFetches(): void {\n if (this.isDestroyed) {\n return;\n }\n\n const store = this._store;\n this._pendingFetch.forEach((fetchItem, type) => _flushPendingFetchForType(store, fetchItem, type));\n this._pendingFetch.clear();\n }\n\n fetchDataIfNeededForIdentifier(\n identifier: PersistedResourceKey,\n options: FindRecordOptions | undefined = {},\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n // pre-loading will change the isEmpty value\n const isEmpty = _isEmpty(this._store._instanceCache, identifier);\n const isLoading = _isLoading(this._store._instanceCache, identifier);\n\n let promise: Promise<PersistedResourceKey>;\n if (isEmpty) {\n assertIdentifierHasId(identifier);\n\n if (DEBUG) {\n promise = this.scheduleFetch(identifier, Object.assign({}, options, { reload: true }), request);\n } else {\n options.reload = true;\n promise = this.scheduleFetch(identifier, options, request);\n }\n } else if (isLoading) {\n promise = this.getPendingFetch(identifier, options)!;\n assert(`Expected to find a pending request for a record in the loading state, but found none`, promise);\n } else {\n promise = Promise.resolve(identifier);\n }\n\n return promise;\n }\n\n destroy(): void {\n this.isDestroyed = true;\n }\n}\n\n/**\n * This type exists for internal use only for\n * where intimate contracts still exist either for\n * the Test Suite or for Legacy code.\n *\n * @private\n */\nexport interface PrivateFetchManager extends FetchManager {\n _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n}\n\nfunction _isEmpty(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n if (!cache) {\n return true;\n }\n const isNew = cache.isNew(identifier);\n const isDeleted = cache.isDeleted(identifier);\n const isEmpty = cache.isEmpty(identifier);\n\n return (!isNew || isDeleted) && isEmpty;\n}\n\nfunction _isLoading(cache: InstanceCache, identifier: ResourceKey): boolean {\n const req = cache.store.getRequestStateService();\n // const fulfilled = req.getLastRequestForRecord(identifier);\n const isLoaded = cache.recordIsLoaded(identifier);\n\n return (\n !isLoaded &&\n // fulfilled === null &&\n req.getPendingRequestsForRecord(identifier).some((r) => r.type === 'query')\n );\n}\n\nfunction includesSatisfies(current: undefined | string | string[], existing: undefined | string | string[]): boolean {\n // if we have no includes we are good\n if (!current?.length) {\n return true;\n }\n\n // if we are here we have includes,\n // and if existing has no includes then we will need a new request\n if (!existing?.length) {\n return false;\n }\n\n const arrCurrent = (Array.isArray(current) ? current : current.split(',')).sort();\n const arrExisting = (Array.isArray(existing) ? existing : existing.split(',')).sort();\n\n // includes are identical\n if (arrCurrent.join(',') === arrExisting.join(',')) {\n return true;\n }\n\n // if all of current includes are in existing includes then we are good\n // so if we find one that is not in existing then we need a new request\n for (let i = 0; i < arrCurrent.length; i++) {\n if (!arrExisting.includes(arrCurrent[i])) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction optionsSatisfies(current: object | undefined, existing: object | undefined): boolean {\n return !current || current === existing || Object.keys(current).length === 0;\n}\n\n// this function helps resolve whether we have a pending request that we should use instead\nfunction isSameRequest(options: FindRecordOptions = {}, existingOptions: FindRecordOptions = {}) {\n return (\n optionsSatisfies(options.adapterOptions, existingOptions.adapterOptions) &&\n includesSatisfies(options.include, existingOptions.include)\n );\n}\n\nfunction _findMany(\n store: Store,\n adapter: MinimumAdapterInterface,\n modelName: string,\n snapshots: Snapshot[]\n): Promise<CollectionResourceDocument> {\n const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still\n const promise = Promise.resolve().then(() => {\n const ids = snapshots.map((s) => s.id!);\n assert(\n `Cannot fetch a record without an id`,\n ids.every((v) => v !== null)\n );\n // oxlint-disable-next-line typescript/unbound-method\n assert(`Expected this adapter to implement findMany for coalescing`, adapter.findMany);\n const ret = adapter.findMany(store, modelClass, ids, snapshots);\n assert('adapter.findMany returned undefined, this was very likely a mistake', ret !== undefined);\n return ret;\n });\n upgradeStore(store);\n\n return promise.then((adapterPayload) => {\n assert(\n `You made a 'findMany' request for '${modelName}' records with ids '[${snapshots\n .map((s) => s.id!)\n .join(',')}]', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');\n return payload as CollectionResourceDocument;\n });\n}\n\nfunction rejectFetchedItems(fetchMap: Map<Snapshot, PendingFetchItem>, snapshots: Snapshot[], error?: Error) {\n for (let i = 0, l = snapshots.length; i < l; i++) {\n const snapshot = snapshots[i];\n const pair = fetchMap.get(snapshot);\n\n if (pair) {\n pair.resolver.reject(\n error ||\n new Error(\n `Expected: '<${\n snapshot.modelName\n }:${snapshot.id!}>' to be present in the adapter provided payload, but it was not found.`\n )\n );\n }\n }\n}\n\nfunction handleFoundRecords(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n snapshots: Snapshot[],\n coalescedPayload: CollectionResourceDocument\n) {\n /*\n It is possible that the same ID is included multiple times\n via multiple snapshots. This happens when more than one\n options hash was supplied, each of which must be uniquely\n accounted for.\n\n However, since we can't map from response to a specific\n options object, we resolve all snapshots by id with\n the first response we see.\n */\n const snapshotsById = new Map<string, Snapshot[]>();\n for (let i = 0; i < snapshots.length; i++) {\n const id = snapshots[i].id!;\n let snapshotGroup = snapshotsById.get(id);\n if (!snapshotGroup) {\n snapshotGroup = [];\n snapshotsById.set(id, snapshotGroup);\n }\n snapshotGroup.push(snapshots[i]);\n }\n\n const included = Array.isArray(coalescedPayload.included) ? coalescedPayload.included : [];\n\n // resolve found records\n const resources = coalescedPayload.data;\n for (let i = 0, l = resources.length; i < l; i++) {\n const resource = resources[i];\n const snapshotGroup = snapshotsById.get(resource.id);\n snapshotsById.delete(resource.id);\n\n if (!snapshotGroup) {\n // TODO consider whether this should be a deprecation/assertion\n included.push(resource);\n } else {\n snapshotGroup.forEach((snapshot) => {\n const pair = fetchMap.get(snapshot)!;\n const resolver = pair.resolver;\n resolver.resolve({ data: resource });\n });\n }\n }\n\n if (included.length > 0) {\n store._push({ data: null, included }, true);\n }\n\n if (snapshotsById.size === 0) {\n return;\n }\n\n // reject missing records\n const rejected: Snapshot[] = [];\n snapshotsById.forEach((snapshotArray) => {\n rejected.push(...snapshotArray);\n });\n warn(\n 'Ember Data expected to find records with the following ids in the adapter response from findMany but they were missing: [ \"' +\n [...snapshotsById.values()].map((r) => r[0].id).join('\", \"') +\n '\" ]',\n {\n id: 'ds.store.missing-records-from-adapter',\n }\n );\n\n rejectFetchedItems(fetchMap, rejected);\n}\n\nfunction _fetchRecord(store: Store, adapter: MinimumAdapterInterface, fetchItem: PendingFetchItem) {\n upgradeStore(store);\n const identifier = fetchItem.identifier;\n const modelName = identifier.type;\n\n assert(`You tried to find a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`,\n typeof adapter.findRecord === 'function'\n );\n\n const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);\n const klass = store.modelFor(identifier.type);\n const id = identifier.id;\n\n let promise = Promise.resolve().then(() => {\n return adapter.findRecord(store, klass, identifier.id, snapshot);\n });\n\n promise = promise.then((adapterPayload) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !(store.isDestroyed || store.isDestroying));\n assert(\n `You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');\n assert(\n `Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`,\n !Array.isArray(payload.data)\n );\n assert(\n `The 'findRecord' request for ${modelName}:${id} resolved indicating success but contained no primary data. To indicate a 404 not found you should either reject the promise returned by the adapter's findRecord method or throw a NotFoundError.`,\n 'data' in payload && payload.data !== null && typeof payload.data === 'object'\n );\n\n warn(\n `You requested a record of type '${modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead.`,\n coerceId(payload.data.id) === coerceId(id),\n {\n id: 'ds.store.findRecord.id-mismatch',\n }\n );\n\n return payload;\n });\n\n fetchItem.resolver.resolve(promise);\n}\n\nfunction _processCoalescedGroup(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n group: Snapshot[],\n adapter: MinimumAdapterInterface,\n modelName: string\n) {\n if (group.length > 1) {\n _findMany(store, adapter, modelName, group)\n .then((payloads: CollectionResourceDocument) => {\n handleFoundRecords(store, fetchMap, group, payloads);\n })\n .catch((error: Error) => {\n rejectFetchedItems(fetchMap, group, error);\n });\n } else if (group.length === 1) {\n _fetchRecord(store, adapter, fetchMap.get(group[0])!);\n } else {\n assert(\"You cannot return an empty array from adapter's method groupRecordsForFindMany\", false);\n }\n}\n\nfunction _flushPendingFetchForType(\n store: Store,\n pendingFetchMap: Map<PersistedResourceKey, PendingFetchItem[]>,\n modelName: string\n) {\n upgradeStore(store);\n const adapter = store.adapterFor(modelName);\n const shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;\n\n if (shouldCoalesce) {\n const pendingFetchItems: PendingFetchItem[] = [];\n pendingFetchMap.forEach((requestsForIdentifier, identifier) => {\n if (requestsForIdentifier.length > 1) {\n return;\n }\n\n // remove this entry from the map so it's not processed again\n pendingFetchMap.delete(identifier);\n pendingFetchItems.push(requestsForIdentifier[0]);\n });\n\n const totalItems = pendingFetchItems.length;\n\n if (totalItems > 1) {\n const snapshots = new Array<Snapshot>(totalItems);\n const fetchMap = new Map<Snapshot, PendingFetchItem>();\n for (let i = 0; i < totalItems; i++) {\n const fetchItem = pendingFetchItems[i];\n snapshots[i] = store._fetchManager.createSnapshot(fetchItem.identifier, fetchItem.options);\n fetchMap.set(snapshots[i], fetchItem);\n }\n\n let groups: Snapshot[][];\n if (adapter.groupRecordsForFindMany) {\n groups = adapter.groupRecordsForFindMany(store, snapshots);\n } else {\n groups = [snapshots];\n }\n\n for (let i = 0, l = groups.length; i < l; i++) {\n _processCoalescedGroup(store, fetchMap, groups[i], adapter, modelName);\n }\n } else if (totalItems === 1) {\n _fetchRecord(store, adapter, pendingFetchItems[0]);\n }\n }\n\n pendingFetchMap.forEach((pendingFetchItems) => {\n pendingFetchItems.forEach((pendingFetchItem) => {\n _fetchRecord(store, adapter, pendingFetchItem);\n });\n });\n}\n\nfunction _flushPendingSave(store: Store, pending: PendingSaveItem) {\n const { snapshot, resolver, identifier, options } = pending;\n upgradeStore(store);\n const adapter = store.adapterFor(identifier.type);\n const operation = options[SaveOp];\n\n const modelName = snapshot.modelName;\n const modelClass = store.modelFor(modelName);\n\n assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`,\n typeof adapter[operation] === 'function'\n );\n\n let promise: Promise<AdapterPayload> = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));\n const serializer: SerializerWithParseErrors | null = store.serializerFor(modelName);\n\n assert(\n `Your adapter's '${operation}' method must return a value, but it returned 'undefined'`,\n promise !== undefined\n );\n\n promise = promise.then((adapterPayload) => {\n if (adapterPayload) {\n return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);\n }\n }) as Promise<AdapterPayload>;\n\n resolver.resolve(promise);\n}\n","import type { Store } from '@warp-drive/core';\n\nimport type { CompatStore } from '../compat.ts';\n\n/**\n * Utilities - often temporary - for maintaining backwards compatibility with\n * older parts of WarpDrive.\n *\n @module\n*/\nexport { SnapshotRecordArray } from './legacy-network-handler/snapshot-record-array.ts';\nexport { SaveOp } from './legacy-network-handler/fetch-manager.ts';\nexport { FetchManager } from './legacy-network-handler/fetch-manager.ts';\nexport { Snapshot } from './legacy-network-handler/snapshot.ts';\n\nexport function upgradeStore(store: Store): asserts store is CompatStore {}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAaE,sBAAb,MAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE/BC,YAAYC,OAAcC,MAAcC,UAA0B,CAAC,GAAG;EACpE,KAAKC,UAAUH;EACf,KAAKI,aAAa;EAClB,KAAKC,YAAYJ;EACjB,KAAKK,iBAAiBJ,QAAQI;EAC9B,KAAKC,UAA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