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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +7 -0
  2. package/dist/-private-BE7RaJCw.js.map +1 -1
  3. package/dist/adapter/-private.d.ts +2 -2
  4. package/dist/adapter/error.d.ts +1 -1
  5. package/dist/adapter/error.js +53 -0
  6. package/dist/adapter/error.js.map +1 -1
  7. package/dist/adapter/json-api.d.ts +4 -2
  8. package/dist/adapter/json-api.d.ts.map +1 -1
  9. package/dist/adapter/json-api.js +7 -0
  10. package/dist/adapter/json-api.js.map +1 -1
  11. package/dist/adapter/rest.d.ts +1 -1
  12. package/dist/adapter/rest.js +20 -1
  13. package/dist/adapter/rest.js.map +1 -1
  14. package/dist/{adapter-eYo2pIuM.js → adapter-BNC6wlWu.js} +42 -1
  15. package/dist/adapter-BNC6wlWu.js.map +1 -0
  16. package/dist/{adapter-CARrK3-8.d.ts → adapter-D3A8ixjz.d.ts} +9 -2
  17. package/dist/adapter-D3A8ixjz.d.ts.map +1 -0
  18. package/dist/adapter.d.ts +1 -1
  19. package/dist/adapter.js +1 -1
  20. package/dist/compat/-private.d.ts +1 -1
  21. package/dist/compat/builders.d.ts +10 -0
  22. package/dist/compat/builders.d.ts.map +1 -1
  23. package/dist/compat/builders.js +10 -0
  24. package/dist/compat/builders.js.map +1 -1
  25. package/dist/compat/extensions.d.ts +1 -1
  26. package/dist/compat/extensions.js +22 -0
  27. package/dist/compat/extensions.js.map +1 -1
  28. package/dist/compat/utils.d.ts +16 -0
  29. package/dist/compat/utils.d.ts.map +1 -1
  30. package/dist/compat/utils.js +18 -0
  31. package/dist/compat/utils.js.map +1 -1
  32. package/dist/{compat-BbNNmTM-.d.ts → compat-BZlQ-5eI.d.ts} +30 -1
  33. package/dist/compat-BZlQ-5eI.d.ts.map +1 -0
  34. package/dist/{compat-DWgmYX8T.js → compat-Da5y9AsM.js} +57 -1
  35. package/dist/compat-Da5y9AsM.js.map +1 -0
  36. package/dist/compat.d.ts +1 -1
  37. package/dist/compat.js +1 -1
  38. package/dist/{error-CzkyXr1Q.d.ts → error-Ba1cMaWG.d.ts} +49 -1
  39. package/dist/error-Ba1cMaWG.d.ts.map +1 -0
  40. package/dist/{errors-BlrR6--x.js → errors-BI0Xugyo.js} +3 -1
  41. package/dist/errors-BI0Xugyo.js.map +1 -0
  42. package/dist/{extensions-DumNm4dA.d.ts → extensions-fwdnX9n4.d.ts} +18 -1
  43. package/dist/extensions-fwdnX9n4.d.ts.map +1 -0
  44. package/dist/index.d.ts +16 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +23 -5
  47. package/dist/index.js.map +1 -1
  48. package/dist/{json-BXNPTlcH.js → json-n2XHdV_P.js} +8 -1
  49. package/dist/json-n2XHdV_P.js.map +1 -0
  50. package/dist/model/-private.d.ts +1 -1
  51. package/dist/model/-private.js +1 -1
  52. package/dist/model/migration-support.d.ts +18 -2
  53. package/dist/model/migration-support.d.ts.map +1 -1
  54. package/dist/model/migration-support.js +21 -3
  55. package/dist/model/migration-support.js.map +1 -1
  56. package/dist/{model-62hn5_PD.d.ts → model-BPVLf-rp.d.ts} +11 -2
  57. package/dist/model-BPVLf-rp.d.ts.map +1 -0
  58. package/dist/{model-C9l1mRs6.js → model-DdlhdL9V.js} +14 -3
  59. package/dist/model-DdlhdL9V.js.map +1 -0
  60. package/dist/{unpkg/dev-deprecated/model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
  61. package/dist/model-fragments-ZM4k_mT3.js.map +1 -0
  62. package/dist/model-fragments.d.ts +31 -1
  63. package/dist/model-fragments.d.ts.map +1 -1
  64. package/dist/model-fragments.js +1 -1
  65. package/dist/model.d.ts +12 -1
  66. package/dist/model.d.ts.map +1 -1
  67. package/dist/model.js +2 -2
  68. package/dist/{rest-0NhtexIq.d.ts → rest-ddU-K5eS.d.ts} +18 -4
  69. package/dist/rest-ddU-K5eS.d.ts.map +1 -0
  70. package/dist/{schema-provider-waPfuoKq.js → schema-provider-Dyjpau2P.js} +13 -6
  71. package/dist/schema-provider-Dyjpau2P.js.map +1 -0
  72. package/dist/serializer/json-api.d.ts +1 -0
  73. package/dist/serializer/json-api.d.ts.map +1 -1
  74. package/dist/serializer/json-api.js +6 -1
  75. package/dist/serializer/json-api.js.map +1 -1
  76. package/dist/serializer/json.d.ts +2 -0
  77. package/dist/serializer/json.d.ts.map +1 -1
  78. package/dist/serializer/json.js +1 -1
  79. package/dist/serializer/rest.d.ts +4 -0
  80. package/dist/serializer/rest.d.ts.map +1 -1
  81. package/dist/serializer/rest.js +10 -1
  82. package/dist/serializer/rest.js.map +1 -1
  83. package/dist/serializer/transform.d.ts +9 -0
  84. package/dist/serializer/transform.d.ts.map +1 -1
  85. package/dist/serializer/transform.js +9 -0
  86. package/dist/serializer/transform.js.map +1 -1
  87. package/dist/serializer.d.ts +2 -0
  88. package/dist/serializer.d.ts.map +1 -1
  89. package/dist/serializer.js +40 -0
  90. package/dist/serializer.js.map +1 -1
  91. package/dist/{store-C4qYzXei.js → store-CMUcaXRp.js} +9 -1
  92. package/dist/store-CMUcaXRp.js.map +1 -0
  93. package/dist/store.d.ts +3 -0
  94. package/dist/store.d.ts.map +1 -1
  95. package/dist/store.js +1 -1
  96. package/dist/unpkg/dev/-private-BWBRzgZO.js.map +1 -1
  97. package/dist/unpkg/dev/adapter/error.js +53 -0
  98. package/dist/unpkg/dev/adapter/error.js.map +1 -1
  99. package/dist/unpkg/dev/adapter/json-api.js +7 -0
  100. package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
  101. package/dist/unpkg/dev/adapter/rest.js +20 -1
  102. package/dist/unpkg/dev/adapter/rest.js.map +1 -1
  103. package/dist/unpkg/{dev-deprecated/adapter-oLwyr47q.js → dev/adapter-CLkSBRpr.js} +42 -1
  104. package/dist/unpkg/dev/adapter-CLkSBRpr.js.map +1 -0
  105. package/dist/unpkg/dev/adapter.js +1 -1
  106. package/dist/unpkg/dev/compat/builders.js +10 -0
  107. package/dist/unpkg/dev/compat/builders.js.map +1 -1
  108. package/dist/unpkg/dev/compat/extensions.js +22 -0
  109. package/dist/unpkg/dev/compat/extensions.js.map +1 -1
  110. package/dist/unpkg/dev/compat/utils.js +18 -0
  111. package/dist/unpkg/dev/compat/utils.js.map +1 -1
  112. package/dist/unpkg/dev/{compat-BIv7BiG_.js → compat-BEO8cSlC.js} +57 -1
  113. package/dist/unpkg/dev/compat-BEO8cSlC.js.map +1 -0
  114. package/dist/unpkg/dev/compat.js +1 -1
  115. package/dist/unpkg/dev/{errors-Dv8RCLdU.js → errors-TUXPdiG8.js} +3 -1
  116. package/dist/unpkg/dev/errors-TUXPdiG8.js.map +1 -0
  117. package/dist/unpkg/dev/index.js +23 -5
  118. package/dist/unpkg/dev/index.js.map +1 -1
  119. package/dist/unpkg/dev/{json-DDJji3V3.js → json-CN-WCWwk.js} +8 -1
  120. package/dist/unpkg/dev/json-CN-WCWwk.js.map +1 -0
  121. package/dist/unpkg/dev/model/-private.js +1 -1
  122. package/dist/unpkg/dev/model/migration-support.js +20 -2
  123. package/dist/unpkg/dev/model/migration-support.js.map +1 -1
  124. package/dist/unpkg/dev/{model-CRYi4C3z.js → model-OQxvzZu6.js} +14 -3
  125. package/dist/unpkg/dev/model-OQxvzZu6.js.map +1 -0
  126. package/dist/unpkg/dev/{model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
  127. package/dist/unpkg/dev/model-fragments-ZM4k_mT3.js.map +1 -0
  128. package/dist/unpkg/dev/model-fragments.js +1 -1
  129. package/dist/unpkg/dev/model.js +2 -2
  130. package/dist/unpkg/dev/{schema-provider-BYjTpV6C.js → schema-provider-Qxo5AVFM.js} +9 -2
  131. package/dist/unpkg/dev/schema-provider-Qxo5AVFM.js.map +1 -0
  132. package/dist/unpkg/dev/serializer/json-api.js +6 -1
  133. package/dist/unpkg/dev/serializer/json-api.js.map +1 -1
  134. package/dist/unpkg/dev/serializer/json.js +1 -1
  135. package/dist/unpkg/dev/serializer/rest.js +10 -1
  136. package/dist/unpkg/dev/serializer/rest.js.map +1 -1
  137. package/dist/unpkg/dev/serializer/transform.js +9 -0
  138. package/dist/unpkg/dev/serializer/transform.js.map +1 -1
  139. package/dist/unpkg/dev/serializer.js +40 -0
  140. package/dist/unpkg/dev/serializer.js.map +1 -1
  141. package/dist/unpkg/dev/{store-D_V8-HQl.js → store-DPzaVp5e.js} +9 -1
  142. package/dist/unpkg/dev/store-DPzaVp5e.js.map +1 -0
  143. package/dist/unpkg/dev/store.js +1 -1
  144. package/dist/unpkg/dev-deprecated/-private-BWBRzgZO.js.map +1 -1
  145. package/dist/unpkg/dev-deprecated/adapter/error.js +53 -0
  146. package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
  147. package/dist/unpkg/dev-deprecated/adapter/json-api.js +7 -0
  148. package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
  149. package/dist/unpkg/dev-deprecated/adapter/rest.js +20 -1
  150. package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
  151. package/dist/unpkg/{dev/adapter-oLwyr47q.js → dev-deprecated/adapter-CLkSBRpr.js} +42 -1
  152. package/dist/unpkg/dev-deprecated/adapter-CLkSBRpr.js.map +1 -0
  153. package/dist/unpkg/dev-deprecated/adapter.js +1 -1
  154. package/dist/unpkg/dev-deprecated/compat/builders.js +10 -0
  155. package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -1
  156. package/dist/unpkg/dev-deprecated/compat/extensions.js +22 -0
  157. package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
  158. package/dist/unpkg/dev-deprecated/compat/utils.js +18 -0
  159. package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -1
  160. package/dist/unpkg/dev-deprecated/{compat-BpJgmr75.js → compat-diBpt972.js} +57 -1
  161. package/dist/unpkg/dev-deprecated/compat-diBpt972.js.map +1 -0
  162. package/dist/unpkg/dev-deprecated/compat.js +1 -1
  163. package/dist/unpkg/dev-deprecated/{errors-__7EyX3m.js → errors-CLRhQKym.js} +3 -1
  164. package/dist/unpkg/dev-deprecated/errors-CLRhQKym.js.map +1 -0
  165. package/dist/unpkg/dev-deprecated/index.js +23 -5
  166. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  167. package/dist/unpkg/dev-deprecated/{json-DDJji3V3.js → json-CN-WCWwk.js} +8 -1
  168. package/dist/unpkg/dev-deprecated/json-CN-WCWwk.js.map +1 -0
  169. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  170. package/dist/unpkg/dev-deprecated/model/migration-support.js +20 -2
  171. package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
  172. package/dist/unpkg/dev-deprecated/{model-BYzXxf9f.js → model-DIvuaUiJ.js} +14 -3
  173. package/dist/unpkg/dev-deprecated/model-DIvuaUiJ.js.map +1 -0
  174. package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev-deprecated/model-fragments-ZM4k_mT3.js} +23 -1
  175. package/dist/unpkg/dev-deprecated/model-fragments-ZM4k_mT3.js.map +1 -0
  176. package/dist/unpkg/dev-deprecated/model-fragments.js +1 -1
  177. package/dist/unpkg/dev-deprecated/model.js +2 -2
  178. package/dist/unpkg/dev-deprecated/{schema-provider-BM9FSxvx.js → schema-provider-DHS8XOdK.js} +9 -2
  179. package/dist/unpkg/dev-deprecated/schema-provider-DHS8XOdK.js.map +1 -0
  180. package/dist/unpkg/dev-deprecated/serializer/json-api.js +6 -1
  181. package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -1
  182. package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
  183. package/dist/unpkg/dev-deprecated/serializer/rest.js +10 -1
  184. package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
  185. package/dist/unpkg/dev-deprecated/serializer/transform.js +9 -0
  186. package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
  187. package/dist/unpkg/dev-deprecated/serializer.js +40 -0
  188. package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
  189. package/dist/unpkg/dev-deprecated/{store-BCOLSC6z.js → store-D4taw4YF.js} +9 -1
  190. package/dist/unpkg/dev-deprecated/store-D4taw4YF.js.map +1 -0
  191. package/dist/unpkg/dev-deprecated/store.js +1 -1
  192. package/dist/unpkg/prod/-private-DG7eJX0Y.js.map +1 -1
  193. package/dist/unpkg/prod/adapter/error.js +53 -0
  194. package/dist/unpkg/prod/adapter/error.js.map +1 -1
  195. package/dist/unpkg/prod/adapter/json-api.js +7 -0
  196. package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
  197. package/dist/unpkg/prod/adapter/rest.js +20 -1
  198. package/dist/unpkg/prod/adapter/rest.js.map +1 -1
  199. package/dist/unpkg/prod/{adapter-DQ9UA7FC.js → adapter-BCGjVOaE.js} +42 -1
  200. package/dist/unpkg/prod/adapter-BCGjVOaE.js.map +1 -0
  201. package/dist/unpkg/prod/adapter.js +1 -1
  202. package/dist/unpkg/prod/compat/builders.js +10 -0
  203. package/dist/unpkg/prod/compat/builders.js.map +1 -1
  204. package/dist/unpkg/prod/compat/extensions.js +22 -0
  205. package/dist/unpkg/prod/compat/extensions.js.map +1 -1
  206. package/dist/unpkg/prod/compat/utils.js +18 -0
  207. package/dist/unpkg/prod/compat/utils.js.map +1 -1
  208. package/dist/unpkg/prod/{compat-BM3u_d5-.js → compat-DFMtpQGs.js} +57 -1
  209. package/dist/unpkg/prod/compat-DFMtpQGs.js.map +1 -0
  210. package/dist/unpkg/prod/compat.js +1 -1
  211. package/dist/unpkg/prod/{errors-BhnSZApj.js → errors-CImmK4OM.js} +3 -1
  212. package/dist/unpkg/prod/errors-CImmK4OM.js.map +1 -0
  213. package/dist/unpkg/prod/index.js +23 -5
  214. package/dist/unpkg/prod/index.js.map +1 -1
  215. package/dist/unpkg/{prod-deprecated/json-BD1kRTfB.js → prod/json-CNq5Z0Xq.js} +8 -1
  216. package/dist/unpkg/prod/json-CNq5Z0Xq.js.map +1 -0
  217. package/dist/unpkg/prod/model/-private.js +1 -1
  218. package/dist/unpkg/prod/model/migration-support.js +20 -2
  219. package/dist/unpkg/prod/model/migration-support.js.map +1 -1
  220. package/dist/unpkg/prod/{model-CDyejvo3.js → model-_HpfLmtZ.js} +14 -3
  221. package/dist/unpkg/prod/model-_HpfLmtZ.js.map +1 -0
  222. package/dist/unpkg/prod/model-fragments-ZM4k_mT3.js +356 -0
  223. package/dist/unpkg/prod/model-fragments-ZM4k_mT3.js.map +1 -0
  224. package/dist/unpkg/prod/model-fragments.js +1 -1
  225. package/dist/unpkg/prod/model.js +2 -2
  226. package/dist/unpkg/prod/{schema-provider-Co3gCBMj.js → schema-provider-DEe5vZ8b.js} +9 -2
  227. package/dist/unpkg/prod/schema-provider-DEe5vZ8b.js.map +1 -0
  228. package/dist/unpkg/prod/serializer/json-api.js +6 -1
  229. package/dist/unpkg/prod/serializer/json-api.js.map +1 -1
  230. package/dist/unpkg/prod/serializer/json.js +1 -1
  231. package/dist/unpkg/prod/serializer/rest.js +10 -1
  232. package/dist/unpkg/prod/serializer/rest.js.map +1 -1
  233. package/dist/unpkg/prod/serializer/transform.js +9 -0
  234. package/dist/unpkg/prod/serializer/transform.js.map +1 -1
  235. package/dist/unpkg/prod/serializer.js +40 -0
  236. package/dist/unpkg/prod/serializer.js.map +1 -1
  237. package/dist/unpkg/prod/{store-RGGc1ilN.js → store-ILh6zPA0.js} +9 -1
  238. package/dist/unpkg/prod/{store-RGGc1ilN.js.map → store-ILh6zPA0.js.map} +1 -1
  239. package/dist/unpkg/prod/store.js +1 -1
  240. package/dist/unpkg/prod-deprecated/-private-DG7eJX0Y.js.map +1 -1
  241. package/dist/unpkg/prod-deprecated/adapter/error.js +53 -0
  242. package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
  243. package/dist/unpkg/prod-deprecated/adapter/json-api.js +7 -0
  244. package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
  245. package/dist/unpkg/prod-deprecated/adapter/rest.js +20 -1
  246. package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
  247. package/dist/unpkg/prod-deprecated/{adapter-DQ9UA7FC.js → adapter-BCGjVOaE.js} +42 -1
  248. package/dist/unpkg/prod-deprecated/adapter-BCGjVOaE.js.map +1 -0
  249. package/dist/unpkg/prod-deprecated/adapter.js +1 -1
  250. package/dist/unpkg/prod-deprecated/compat/builders.js +10 -0
  251. package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -1
  252. package/dist/unpkg/prod-deprecated/compat/extensions.js +22 -0
  253. package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
  254. package/dist/unpkg/prod-deprecated/compat/utils.js +18 -0
  255. package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -1
  256. package/dist/unpkg/prod-deprecated/{compat-BM3u_d5-.js → compat-DFMtpQGs.js} +57 -1
  257. package/dist/unpkg/prod-deprecated/compat-DFMtpQGs.js.map +1 -0
  258. package/dist/unpkg/prod-deprecated/compat.js +1 -1
  259. package/dist/unpkg/prod-deprecated/{errors-BX8zhQS4.js → errors-DIOUcGAT.js} +3 -1
  260. package/dist/unpkg/prod-deprecated/errors-DIOUcGAT.js.map +1 -0
  261. package/dist/unpkg/prod-deprecated/index.js +23 -5
  262. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  263. package/dist/unpkg/{prod/json-BD1kRTfB.js → prod-deprecated/json-CNq5Z0Xq.js} +8 -1
  264. package/dist/unpkg/prod-deprecated/json-CNq5Z0Xq.js.map +1 -0
  265. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  266. package/dist/unpkg/prod-deprecated/model/migration-support.js +20 -2
  267. package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
  268. package/dist/unpkg/prod-deprecated/{model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
  269. package/dist/unpkg/prod-deprecated/model-fragments-ZM4k_mT3.js.map +1 -0
  270. package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
  271. package/dist/unpkg/prod-deprecated/{model-qeqVBN2l.js → model-wzHTp8Up.js} +14 -3
  272. package/dist/unpkg/prod-deprecated/model-wzHTp8Up.js.map +1 -0
  273. package/dist/unpkg/prod-deprecated/model.js +2 -2
  274. package/dist/unpkg/prod-deprecated/{schema-provider-CTLbab33.js → schema-provider-NWVqBEkW.js} +9 -2
  275. package/dist/unpkg/prod-deprecated/schema-provider-NWVqBEkW.js.map +1 -0
  276. package/dist/unpkg/prod-deprecated/serializer/json-api.js +6 -1
  277. package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -1
  278. package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
  279. package/dist/unpkg/prod-deprecated/serializer/rest.js +10 -1
  280. package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
  281. package/dist/unpkg/prod-deprecated/serializer/transform.js +9 -0
  282. package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
  283. package/dist/unpkg/prod-deprecated/serializer.js +40 -0
  284. package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
  285. package/dist/unpkg/prod-deprecated/{store-0L2CkYzh.js → store-CB_rVlXv.js} +9 -1
  286. package/dist/unpkg/prod-deprecated/{store-0L2CkYzh.js.map → store-CB_rVlXv.js.map} +1 -1
  287. package/dist/unpkg/prod-deprecated/store.js +1 -1
  288. package/package.json +9 -9
  289. package/dist/adapter-CARrK3-8.d.ts.map +0 -1
  290. package/dist/adapter-eYo2pIuM.js.map +0 -1
  291. package/dist/compat-BbNNmTM-.d.ts.map +0 -1
  292. package/dist/compat-DWgmYX8T.js.map +0 -1
  293. package/dist/error-CzkyXr1Q.d.ts.map +0 -1
  294. package/dist/errors-BlrR6--x.js.map +0 -1
  295. package/dist/extensions-DumNm4dA.d.ts.map +0 -1
  296. package/dist/json-BXNPTlcH.js.map +0 -1
  297. package/dist/model-62hn5_PD.d.ts.map +0 -1
  298. package/dist/model-C9l1mRs6.js.map +0 -1
  299. package/dist/model-fragments-DSqu0ptR.js.map +0 -1
  300. package/dist/rest-0NhtexIq.d.ts.map +0 -1
  301. package/dist/schema-provider-waPfuoKq.js.map +0 -1
  302. package/dist/store-C4qYzXei.js.map +0 -1
  303. package/dist/unpkg/dev/adapter-oLwyr47q.js.map +0 -1
  304. package/dist/unpkg/dev/compat-BIv7BiG_.js.map +0 -1
  305. package/dist/unpkg/dev/errors-Dv8RCLdU.js.map +0 -1
  306. package/dist/unpkg/dev/json-DDJji3V3.js.map +0 -1
  307. package/dist/unpkg/dev/model-CRYi4C3z.js.map +0 -1
  308. package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +0 -1
  309. package/dist/unpkg/dev/schema-provider-BYjTpV6C.js.map +0 -1
  310. package/dist/unpkg/dev/store-D_V8-HQl.js.map +0 -1
  311. package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +0 -1
  312. package/dist/unpkg/dev-deprecated/compat-BpJgmr75.js.map +0 -1
  313. package/dist/unpkg/dev-deprecated/errors-__7EyX3m.js.map +0 -1
  314. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +0 -1
  315. package/dist/unpkg/dev-deprecated/model-BYzXxf9f.js.map +0 -1
  316. package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  317. package/dist/unpkg/dev-deprecated/schema-provider-BM9FSxvx.js.map +0 -1
  318. package/dist/unpkg/dev-deprecated/store-BCOLSC6z.js.map +0 -1
  319. package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +0 -1
  320. package/dist/unpkg/prod/compat-BM3u_d5-.js.map +0 -1
  321. package/dist/unpkg/prod/errors-BhnSZApj.js.map +0 -1
  322. package/dist/unpkg/prod/json-BD1kRTfB.js.map +0 -1
  323. package/dist/unpkg/prod/model-CDyejvo3.js.map +0 -1
  324. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js +0 -334
  325. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js.map +0 -1
  326. package/dist/unpkg/prod/schema-provider-Co3gCBMj.js.map +0 -1
  327. package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +0 -1
  328. package/dist/unpkg/prod-deprecated/compat-BM3u_d5-.js.map +0 -1
  329. package/dist/unpkg/prod-deprecated/errors-BX8zhQS4.js.map +0 -1
  330. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +0 -1
  331. package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  332. package/dist/unpkg/prod-deprecated/model-qeqVBN2l.js.map +0 -1
  333. package/dist/unpkg/prod-deprecated/schema-provider-CTLbab33.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["CacheHandler","Fetch","recordIdentifierFor","RequestManager","Store","instantiateRecord","registerDerivations","SchemaService","teardownRecord","DefaultCachePolicy","adapterFor","cleanup","LegacyNetworkHandler","normalize","pushPayload","serializeRecord","serializerFor","EmberArrayLikeExtension","EmberObjectArrayExtension","EmberObjectExtension","instantiateModel","modelFor","teardownModel","FragmentArrayExtension","FragmentExtension","fragmentsModelFor","releaseLegacySupport","DelegatingSchemaService","registerLegacyDerivations","restoreDeprecatedStoreBehaviors","useLegacyStore","options","StoreKlass","BaseKlass","LegacyConfiguredStore","constructor","createArgs","requestManager","Object","defineProperty","configurable","enumerable","get","handlersOption","handlers","use","linksMode","filter","Boolean","useCache","set","value","lifetimes","policy","apiCacheHardExpires","apiCacheSoftExpires","constraints","headers","Expires","createSchemaService","schema","schemas","registerResources","traits","trait","registerTrait","derivations","derivation","registerDerivation","transformations","transformation","registerTransformation","hashFns","hashFn","registerHashFn","CAUTION_MEGA_DANGER_ZONE_extensions","extension","CAUTION_MEGA_DANGER_ZONE_registerExtension","modelFragments","createCache","capabilities","cache","key","isDelegated","call","record","type","assertType","klass","modelName","_allowMissing","undefined","args","destroy","legacyRequests"],"sources":["../../../src/index.ts"],"sourcesContent":["/**\n * @module\n * @mergeModuleWith <project>\n */\n\nimport {\n CacheHandler,\n Fetch,\n recordIdentifierFor,\n RequestManager,\n Store,\n type StoreSetupOptions,\n} from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/core/reactive';\nimport type { Handler } from '@warp-drive/core/request';\nimport { DefaultCachePolicy } from '@warp-drive/core/store';\nimport type { CacheCapabilitiesManager, ModelSchema, ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestInfo } from '@warp-drive/core/types/request';\nimport type { ObjectSchema, ResourceSchema } from '@warp-drive/core/types/schema/fields';\n\nimport type { MinimumAdapterInterface } from './compat';\nimport {\n adapterFor,\n cleanup,\n LegacyNetworkHandler,\n normalize,\n pushPayload,\n serializeRecord,\n serializerFor,\n} from './compat';\nimport { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions';\nimport type Model from './model';\nimport { instantiateRecord as instantiateModel, modelFor, teardownRecord as teardownModel } from './model';\nimport { FragmentArrayExtension, FragmentExtension } from './model-fragments';\nimport { fragmentsModelFor } from './model-fragments/hooks/model-for';\nimport { releaseLegacySupport } from './model/-private/legacy-relationships-support';\nimport { DelegatingSchemaService, registerDerivations as registerLegacyDerivations } from './model/migration-support';\nimport { restoreDeprecatedStoreBehaviors } from './store';\n\ninterface _LegacyStoreSetupOptions<T extends Cache> extends Omit<StoreSetupOptions<T>, 'schemas'> {\n /**\n * The {@link ResourceSchema | ResourceSchemas} or {@link ObjectSchema | ObjectSchemas} of entities\n * migrated to no longer use {@link Model}.\n *\n * :::caution\n * {@link Model} is still able to be used directly as a source of schema when using {@link useLegacyStore},\n * however, its reliance on EmberObject, classic computeds and resolver behaviors mean that Model\n * will stop working when these things are deprecated in Ember.\n * :::\n */\n schemas?: Array<ResourceSchema | ObjectSchema>;\n\n /**\n * Whether to include support for ModelFragments migrations.\n *\n * @default false\n */\n modelFragments?: boolean;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` with `linksMode`\n * enabled, meaning no legacy adapter/serializer request infrastructure is required.\n *\n * @public\n */\nexport interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n linksMode: true;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer, but without the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @public\n */\nexport interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer and the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @public\n */\nexport interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests: true;\n}\n\n//export type ConfiguredStore<T = unknown> = typeof Store;\n\n/**\n * The available options when setting up the legacy store,\n * one of:\n *\n * - {@link LegacyModelStoreSetupOptions}\n * - {@link LegacyModelAndNetworkStoreSetupOptions}\n * - {@link LegacyModelAndNetworkAndRequestStoreSetupOptions}\n */\nexport type LegacyStoreSetupOptions<T extends Cache = Cache> =\n | LegacyModelStoreSetupOptions<T>\n | LegacyModelAndNetworkStoreSetupOptions<T>\n | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;\n\nexport declare class ConfiguredStore<\n T extends {\n /**\n * The {@link Cache} implementation this store was configured with.\n */\n cache: Cache;\n },\n> extends Store {\n // get cache(): T extends OptionsWithCache<infer R> ? R : never;\n createCache(capabilities: CacheCapabilitiesManager): T['cache'];\n}\n\n/**\n * Use the legacy store with the given options.\n *\n * See {@link LegacyStoreSetupOptions} for details on the available options.\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * schemas: [],\n * });\n * ```\n *\n * ### Adding Stateful Handlers\n *\n * A request {@link Handler} is sometimes more than a plain object or class\n * with a `request` method — it may need access to a stateful dependency such\n * as an Ember service (an auth token, a feature-flags service, an i18n\n * helper, etc.).\n *\n * A plain class handler that only relies on Ember's `@service` decorator will\n * not work here on its own: the handler is never instantiated *through*\n * Ember's container (it's just `new`'d up), so it has no owner and its\n * `@service` injections would fail to resolve.\n *\n * Instead, give `handlers` a function. It receives the {@link Store} instance\n * being configured, which by the time the function runs already has an owner\n * assigned. Use `getOwner`/`setOwner` from `@ember/owner` to transfer that\n * owner onto your handler instance before returning it, exactly as you would\n * when constructing any other DI-aware object outside of the container:\n *\n * ```ts\n * import { getOwner, setOwner } from '@ember/owner';\n * import { service } from '@ember/service';\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * class AuthHandler {\n * @service session;\n *\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * const headers = new Headers(context.request.headers);\n * headers.append('Authorization', `Bearer ${this.session.accessToken}`);\n * return next(Object.assign({}, context.request, { headers }));\n * }\n * }\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: (store) => {\n * const authHandler = new AuthHandler();\n * setOwner(authHandler, getOwner(store)!);\n * return [authHandler];\n * },\n * });\n * ```\n *\n * The `handlers` function is invoked lazily and only once per store instance,\n * the first time `store.requestManager` is accessed, so it is safe to do\n * owner-dependent setup like this inside of it.\n *\n * ### Accessing the Store from a Handler's Context\n *\n * If a handler only needs to read something *off of the store itself*\n * (its cache, or a property/service you've attached to a custom store\n * subclass) rather than an unrelated Ember service, there is a second,\n * simpler option that requires no DI/`setOwner` wiring at all.\n *\n * Every request issued via {@link Store.request | store.request(...)}\n * automatically carries the originating store along as\n * {@link RequestInfo.store | context.request.store}. Any handler — a plain\n * object, a function-built handler, or a class — can read it directly,\n * without needing the `handlers` callback form shown above:\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * const LoggingHandler = {\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * // only present when the request was made via `store.request(...)`\n * const store = context.request.store;\n * if (store) {\n * console.log(`[${store.constructor.name}] ${context.request.url ?? ''}`);\n * }\n * return next(context.request);\n * },\n * };\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: [LoggingHandler],\n * });\n * ```\n *\n * The trade-off versus the `getOwner`/`setOwner` pattern above is that\n * `context.request.store` is only populated for requests issued via\n * `store.request(...)`; a request made directly against a\n * {@link RequestManager} won't have it set unless the caller supplies it\n * explicitly, so a handler relying on it should treat it as optional (as\n * `LoggingHandler` does above).\n */\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyStoreSetupOptions<T>,\n StoreKlass: typeof Store = Store\n): typeof ConfiguredStore<{ cache: T }> {\n assert(`If legacyRequests is true, linksMode must be false`, !(options.linksMode && options.legacyRequests));\n // we extend the store to ensure we don't leak our prototype overrides to other stores below.\n class BaseKlass extends StoreKlass {}\n class LegacyConfiguredStore extends BaseKlass {\n constructor(createArgs?: unknown) {\n super(createArgs);\n // installed via defineProperty (rather than a class field/accessor) so that\n // this lazy override of the inherited `requestManager` field does not\n // conflict with the documented pattern of assigning it directly on\n // consumer-authored Store subclasses. The setter preserves the ability\n // to replace `requestManager` outright after construction.\n let requestManager: RequestManager | undefined;\n Object.defineProperty(this, 'requestManager', {\n configurable: true,\n enumerable: true,\n get: (): RequestManager => {\n if (!requestManager) {\n const handlersOption = options.handlers;\n const handlers = typeof handlersOption === 'function' ? handlersOption(this) : (handlersOption ?? []);\n requestManager = new RequestManager()\n .use([options.linksMode ? null : LegacyNetworkHandler, ...handlers, Fetch].filter(Boolean) as Handler[])\n .useCache(CacheHandler);\n }\n return requestManager;\n },\n set: (value: RequestManager): void => {\n requestManager = value;\n },\n });\n }\n\n lifetimes =\n options.policy ??\n new DefaultCachePolicy({\n apiCacheHardExpires: 15 * 60 * 1000, // 15 minutes\n apiCacheSoftExpires: 1 * 30 * 1000, // 30 seconds\n constraints: {\n headers: {\n 'X-WarpDrive-Expires': true,\n 'Cache-Control': true,\n Expires: true,\n },\n },\n });\n\n createSchemaService(): DelegatingSchemaService {\n // prepare for PolarisMode\n const schema = new SchemaService();\n registerDerivations(schema);\n if (options.schemas) schema.registerResources(options.schemas);\n\n if (options.traits) {\n for (const trait of options.traits) {\n schema.registerTrait(trait);\n }\n }\n\n if (options.derivations) {\n for (const derivation of options.derivations) {\n schema.registerDerivation(derivation);\n }\n }\n\n if (options.transformations) {\n for (const transformation of options.transformations) {\n schema.registerTransformation(transformation);\n }\n }\n\n if (options.hashFns) {\n for (const hashFn of options.hashFns) {\n schema.registerHashFn(hashFn);\n }\n }\n\n if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);\n }\n }\n\n // Add support for LegacyMode ReactiveResource with Maximal coverage\n // for upgrading from 4.x\n registerLegacyDerivations(schema);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);\n\n // add support for fragments\n if (options.modelFragments) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);\n }\n\n // Add fallback for Models\n return new DelegatingSchemaService(this, schema);\n }\n\n createCache(capabilities: CacheCapabilitiesManager) {\n // oxlint-disable-next-line new-cap\n return new options.cache(capabilities);\n }\n\n instantiateRecord(key: ResourceKey, createArgs?: Record<string, unknown>) {\n if (this.schema.isDelegated(key)) {\n return instantiateModel.call(this, key, createArgs);\n }\n return instantiateRecord(this, key, createArgs);\n }\n\n teardownRecord(record: unknown): void {\n const key = recordIdentifierFor(record);\n if (this.schema.isDelegated(key)) {\n return teardownModel.call(this, record as Model);\n }\n releaseLegacySupport(key);\n return teardownRecord(record);\n }\n\n modelFor<InstanceType>(type: TypeFromInstance<InstanceType>): ModelSchema<InstanceType>;\n modelFor(type: string): ModelSchema;\n modelFor(type: string): ModelSchema {\n assertType(this.schema, type);\n\n const klass =\n // prefer real models if present\n (modelFor.call(this, type) as ModelSchema) ||\n // fallback to ShimModelClass specific to fragments if fragments support in use\n (options.modelFragments ? (fragmentsModelFor.call(this, type) as ModelSchema) : false) ||\n // fallback to ShimModelClass\n super.modelFor(type);\n\n return klass;\n }\n\n adapterFor(this: Store, modelName: string): MinimumAdapterInterface;\n adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;\n adapterFor(this: Store, modelName: string, _allowMissing?: true): MinimumAdapterInterface | undefined {\n // createRecord asks for an adapter with _allowMissing to offer id generation;\n // linksMode has no adapters, so that soft lookup finds none.\n if (options.linksMode && _allowMissing) {\n return undefined;\n }\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n // @ts-expect-error\n return adapterFor.call(this, modelName, _allowMissing);\n }\n\n serializerFor(this: Store, ...args: Parameters<typeof serializerFor>): ReturnType<typeof serializerFor> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializerFor.call(this, ...args);\n }\n\n pushPayload(this: Store, ...args: Parameters<typeof pushPayload>): ReturnType<typeof pushPayload> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return pushPayload.call(this, ...args);\n }\n\n normalize(this: Store, ...args: Parameters<typeof normalize>): ReturnType<typeof normalize> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return normalize.call(this, ...args);\n }\n\n serializeRecord(this: Store, ...args: Parameters<typeof serializeRecord>): ReturnType<typeof serializeRecord> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializeRecord.call(this, ...args);\n }\n\n destroy() {\n if (!options.linksMode) {\n cleanup.call(this);\n }\n super.destroy();\n }\n }\n\n if (options.legacyRequests) {\n restoreDeprecatedStoreBehaviors(BaseKlass);\n }\n\n return LegacyConfiguredStore;\n}\n\nfunction assertType(schema: DelegatingSchemaService, type: string) {\n assert(`Expected type ${type} to be a valid ResourceType`, schema.hasResource({ type }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwSA,SAAgB8B,eACdC,SACAC,aAA2B5B,OACW;CAGtC,MAAM6B,kBAAkBD,WAAW,CAAA;CACnC,MAAME,8BAA8BD,UAAU;EAC5CE,YAAYC,YAAsB;GAChC,MAAMA,UAAU;GAMhB,IAAIC;GACJC,OAAOC,eAAe,MAAM,kBAAkB;IAC5CC,cAAc;IACdC,YAAY;IACZC,WAA2B;KACzB,IAAI,CAACL,gBAAgB;MACnB,MAAMM,iBAAiBZ,QAAQa;MAC/B,MAAMA,WAAW,OAAOD,mBAAmB,aAAaA,eAAe,IAAI,IAAKA,kBAAkB,CAAA;MAClGN,iBAAiB,IAAIlC,eAAe,CAAC,CAClC0C,IAAI;OAACd,QAAQe,YAAY,OAAOlC;OAAsB,GAAGgC;OAAU3C;MAAK,CAAC,CAAC8C,OAAOC,OAAO,CAAc,CAAC,CACvGC,SAASjD,YAAY;KAC1B;KACA,OAAOqC;IACT;IACAa,MAAMC,UAAgC;KACpCd,iBAAiBc;IACnB;GACF,CAAC;EACH;EAEAC,YACErB,QAAQsB,UACR,IAAI5C,mBAAmB;GACrB6C,qBAAqB;GACrBC,qBAAqB;GACrBC,aAAa,EACXC,SAAS;IACP,uBAAuB;IACvB,i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hF,oBAAoBmF,MAAM;GACtC,IAAI,KAAKzB,OAAOuB,YAAYD,GAAG,GAC7B,OAAO5D,iBAAc8D,KAAK,MAAMC,MAAe;GAEjD3D,qBAAqBwD,GAAG;GACxB,OAAO1E,eAAe6E,MAAM;EAC9B;EAIAhE,SAASiE,MAA2B;GAClCC,AAAW,KAAK3B;GAUhB,OANGvC,SAAS+D,KAAK,MAAME,IAAI,MAExBvD,QAAQ+C,iBAAkBrD,kBAAkB2D,KAAK,MAAME,IAAI,IAAoB,UAEhF,MAAMjE,SAASiE,IAAI;EAGvB;EAIA5E,WAAwB+E,WAAmBC,eAA2D;GAGpG,IAAI3D,QAAQe,aAAa4C,eACvB;GAOF,OAAOhF,WAAW0E,KAAK,MAAMK,WAAWC,aAAa;EACvD;EAEA1E,cAA2B,GAAG4E,MAA0E;GAKtG,OAAO5E,cAAcoE,KAAK,MAAM,GAAGQ,IAAI;EACzC;EAEA9E,YAAyB,GAAG8E,MAAsE;GAKhG,OAAO9E,YAAYsE,KAAK,MAAM,GAAGQ,IAAI;EACvC;EAEA/E,UAAuB,GAAG+E,MAAkE;GAK1F,OAAO/E,UAAUuE,KAAK,MAAM,GAAGQ,IAAI;EACrC;EAEA7E,gBAA6B,GAAG6E,MAA8E;GAK5G,OAAO7E,gBAAgBqE,KAAK,MAAM,GAAGQ,IAAI;EAC3C;EAEAC,UAAU;GACR,IAAI,CAAC9D,QAAQe,WACXnC,QAAQyE,KAAK,IAAI;GAEnB,MAAMS,QAAQ;EAChB;CACF;CAEA,IAAI9D,QAAQ+D,gBACVjE,gCAAgCI,SAAS;CAG3C,OAAOC;AACT"}
1
+ {"version":3,"file":"index.js","names":["CacheHandler","Fetch","recordIdentifierFor","RequestManager","Store","instantiateRecord","registerDerivations","SchemaService","teardownRecord","DefaultCachePolicy","adapterFor","cleanup","LegacyNetworkHandler","normalize","pushPayload","serializeRecord","serializerFor","EmberArrayLikeExtension","EmberObjectArrayExtension","EmberObjectExtension","instantiateModel","modelFor","teardownModel","FragmentArrayExtension","FragmentExtension","fragmentsModelFor","releaseLegacySupport","DelegatingSchemaService","registerLegacyDerivations","restoreDeprecatedStoreBehaviors","useLegacyStore","options","StoreKlass","BaseKlass","LegacyConfiguredStore","constructor","createArgs","requestManager","Object","defineProperty","configurable","enumerable","get","handlersOption","handlers","use","linksMode","filter","Boolean","useCache","set","value","lifetimes","policy","apiCacheHardExpires","apiCacheSoftExpires","constraints","headers","Expires","createSchemaService","schema","schemas","registerResources","traits","trait","registerTrait","derivations","derivation","registerDerivation","transformations","transformation","registerTransformation","hashFns","hashFn","registerHashFn","CAUTION_MEGA_DANGER_ZONE_extensions","extension","CAUTION_MEGA_DANGER_ZONE_registerExtension","modelFragments","createCache","capabilities","cache","key","isDelegated","call","record","type","assertType","klass","modelName","_allowMissing","undefined","args","destroy","legacyRequests","instantiateModel","teardownModel"],"sources":["../../../src/index.ts"],"sourcesContent":["/**\n * @summary Legacy `Model`, adapter, and serializer support for WarpDrive, including `useLegacyStore` to configure a\n * store that uses them.\n * @module\n * @mergeModuleWith <project>\n */\n\nimport {\n CacheHandler,\n Fetch,\n recordIdentifierFor,\n RequestManager,\n Store,\n type StoreSetupOptions,\n} from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/core/reactive';\nimport type { Handler } from '@warp-drive/core/request';\nimport { DefaultCachePolicy } from '@warp-drive/core/store';\nimport type { CacheCapabilitiesManager, ModelSchema, ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestInfo } from '@warp-drive/core/types/request';\nimport type { ObjectSchema, ResourceSchema } from '@warp-drive/core/types/schema/fields';\n\nimport type { MinimumAdapterInterface } from './compat';\nimport {\n adapterFor,\n cleanup,\n LegacyNetworkHandler,\n normalize,\n pushPayload,\n serializeRecord,\n serializerFor,\n} from './compat';\nimport { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions';\nimport type Model from './model';\nimport { instantiateRecord as instantiateModel, modelFor, teardownRecord as teardownModel } from './model';\nimport { FragmentArrayExtension, FragmentExtension } from './model-fragments';\nimport { fragmentsModelFor } from './model-fragments/hooks/model-for';\nimport { releaseLegacySupport } from './model/-private/legacy-relationships-support';\nimport { DelegatingSchemaService, registerDerivations as registerLegacyDerivations } from './model/migration-support';\nimport { restoreDeprecatedStoreBehaviors } from './store';\n\ninterface _LegacyStoreSetupOptions<T extends Cache> extends Omit<StoreSetupOptions<T>, 'schemas'> {\n /**\n * The {@link ResourceSchema | ResourceSchemas} or {@link ObjectSchema | ObjectSchemas} of entities\n * migrated to no longer use {@link Model}.\n *\n * :::caution\n * {@link Model} is still able to be used directly as a source of schema when using {@link useLegacyStore},\n * however, its reliance on EmberObject, classic computeds and resolver behaviors mean that Model\n * will stop working when these things are deprecated in Ember.\n * :::\n */\n schemas?: Array<ResourceSchema | ObjectSchema>;\n\n /**\n * Whether to include support for ModelFragments migrations.\n *\n * @default false\n */\n modelFragments?: boolean;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` with `linksMode`\n * enabled, meaning no legacy adapter/serializer request infrastructure is required.\n *\n * @summary `useLegacyStore` options for a store that uses `Model` in `linksMode`, without the legacy adapter and\n * serializer network layer.\n * @public\n */\nexport interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n linksMode: true;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer, but without the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @summary `useLegacyStore` options for a store that uses `Model` and the legacy adapter and serializer network\n * layer, without deprecated request methods like `store.findRecord`.\n * @public\n */\nexport interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer and the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @summary `useLegacyStore` options for a store that uses `Model`, the legacy adapter and serializer network layer,\n * and deprecated request methods like `store.findRecord`.\n * @public\n */\nexport interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests: true;\n}\n\n//export type ConfiguredStore<T = unknown> = typeof Store;\n\n/**\n * The available options when setting up the legacy store,\n * one of:\n *\n * - {@link LegacyModelStoreSetupOptions}\n * - {@link LegacyModelAndNetworkStoreSetupOptions}\n * - {@link LegacyModelAndNetworkAndRequestStoreSetupOptions}\n *\n * @summary Options accepted by `useLegacyStore`, choosing via `linksMode` and `legacyRequests` how much of the\n * legacy `Model`, adapter, and request support to enable.\n */\nexport type LegacyStoreSetupOptions<T extends Cache = Cache> =\n | LegacyModelStoreSetupOptions<T>\n | LegacyModelAndNetworkStoreSetupOptions<T>\n | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;\n\nexport declare class ConfiguredStore<\n T extends {\n /**\n * The {@link Cache} implementation this store was configured with.\n */\n cache: Cache;\n },\n> extends Store {\n // get cache(): T extends OptionsWithCache<infer R> ? R : never;\n createCache(capabilities: CacheCapabilitiesManager): T['cache'];\n}\n\n/**\n * Use the legacy store with the given options.\n *\n * See [Configure The Store](/guides/configuration/#configure-the-store) for where it fits in an\n * app's setup, and [LegacyMode](/guides/the-manual/schemas/resources/legacy-mode) for the schemas\n * it supports.\n *\n * See {@link LegacyStoreSetupOptions} for details on the available options.\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * schemas: [],\n * });\n * ```\n *\n * ### Adding Stateful Handlers\n *\n * A request {@link Handler} is sometimes more than a plain object or class\n * with a `request` method — it may need access to a stateful dependency such\n * as an Ember service (an auth token, a feature-flags service, an i18n\n * helper, etc.).\n *\n * A plain class handler that only relies on Ember's `@service` decorator will\n * not work here on its own: the handler is never instantiated *through*\n * Ember's container (it's just `new`'d up), so it has no owner and its\n * `@service` injections would fail to resolve.\n *\n * Instead, give `handlers` a function. It receives the {@link Store} instance\n * being configured, which by the time the function runs already has an owner\n * assigned. Use `getOwner`/`setOwner` from `@ember/owner` to transfer that\n * owner onto your handler instance before returning it, exactly as you would\n * when constructing any other DI-aware object outside of the container:\n *\n * ```ts\n * import { getOwner, setOwner } from '@ember/owner';\n * import { service } from '@ember/service';\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * class AuthHandler {\n * @service session;\n *\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * const headers = new Headers(context.request.headers);\n * headers.append('Authorization', `Bearer ${this.session.accessToken}`);\n * return next(Object.assign({}, context.request, { headers }));\n * }\n * }\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: (store) => {\n * const authHandler = new AuthHandler();\n * setOwner(authHandler, getOwner(store)!);\n * return [authHandler];\n * },\n * });\n * ```\n *\n * The `handlers` function is invoked lazily and only once per store instance,\n * the first time `store.requestManager` is accessed, so it is safe to do\n * owner-dependent setup like this inside of it.\n *\n * ### Accessing the Store from a Handler's Context\n *\n * If a handler only needs to read something *off of the store itself*\n * (its cache, or a property/service you've attached to a custom store\n * subclass) rather than an unrelated Ember service, there is a second,\n * simpler option that requires no DI/`setOwner` wiring at all.\n *\n * Every request issued via {@link Store.request | store.request(...)}\n * automatically carries the originating store along as\n * {@link RequestInfo.store | context.request.store}. Any handler — a plain\n * object, a function-built handler, or a class — can read it directly,\n * without needing the `handlers` callback form shown above:\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * const LoggingHandler = {\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * // only present when the request was made via `store.request(...)`\n * const store = context.request.store;\n * if (store) {\n * console.log(`[${store.constructor.name}] ${context.request.url ?? ''}`);\n * }\n * return next(context.request);\n * },\n * };\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: [LoggingHandler],\n * });\n * ```\n *\n * The trade-off versus the `getOwner`/`setOwner` pattern above is that\n * `context.request.store` is only populated for requests issued via\n * `store.request(...)`; a request made directly against a\n * {@link RequestManager} won't have it set unless the caller supplies it\n * explicitly, so a handler relying on it should treat it as optional (as\n * `LoggingHandler` does above).\n *\n * @summary Creates a `Store` class preconfigured for legacy apps, with `Model` schema support, request handlers,\n * cache, and optional adapter, serializer, and fragment support.\n */\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyStoreSetupOptions<T>,\n StoreKlass: typeof Store = Store\n): typeof ConfiguredStore<{ cache: T }> {\n assert(`If legacyRequests is true, linksMode must be false`, !(options.linksMode && options.legacyRequests));\n // we extend the store to ensure we don't leak our prototype overrides to other stores below.\n class BaseKlass extends StoreKlass {}\n class LegacyConfiguredStore extends BaseKlass {\n constructor(createArgs?: unknown) {\n super(createArgs);\n // installed via defineProperty (rather than a class field/accessor) so that\n // this lazy override of the inherited `requestManager` field does not\n // conflict with the documented pattern of assigning it directly on\n // consumer-authored Store subclasses. The setter preserves the ability\n // to replace `requestManager` outright after construction.\n let requestManager: RequestManager | undefined;\n Object.defineProperty(this, 'requestManager', {\n configurable: true,\n enumerable: true,\n get: (): RequestManager => {\n if (!requestManager) {\n const handlersOption = options.handlers;\n const handlers = typeof handlersOption === 'function' ? handlersOption(this) : (handlersOption ?? []);\n requestManager = new RequestManager()\n .use([options.linksMode ? null : LegacyNetworkHandler, ...handlers, Fetch].filter(Boolean) as Handler[])\n .useCache(CacheHandler);\n }\n return requestManager;\n },\n set: (value: RequestManager): void => {\n requestManager = value;\n },\n });\n }\n\n lifetimes =\n options.policy ??\n new DefaultCachePolicy({\n apiCacheHardExpires: 15 * 60 * 1000, // 15 minutes\n apiCacheSoftExpires: 1 * 30 * 1000, // 30 seconds\n constraints: {\n headers: {\n 'X-WarpDrive-Expires': true,\n 'Cache-Control': true,\n Expires: true,\n },\n },\n });\n\n createSchemaService(): DelegatingSchemaService {\n // prepare for PolarisMode\n const schema = new SchemaService();\n registerDerivations(schema);\n if (options.schemas) schema.registerResources(options.schemas);\n\n if (options.traits) {\n for (const trait of options.traits) {\n schema.registerTrait(trait);\n }\n }\n\n if (options.derivations) {\n for (const derivation of options.derivations) {\n schema.registerDerivation(derivation);\n }\n }\n\n if (options.transformations) {\n for (const transformation of options.transformations) {\n schema.registerTransformation(transformation);\n }\n }\n\n if (options.hashFns) {\n for (const hashFn of options.hashFns) {\n schema.registerHashFn(hashFn);\n }\n }\n\n if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);\n }\n }\n\n // Add support for LegacyMode ReactiveResource with Maximal coverage\n // for upgrading from 4.x\n registerLegacyDerivations(schema);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);\n\n // add support for fragments\n if (options.modelFragments) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);\n }\n\n // Add fallback for Models\n return new DelegatingSchemaService(this, schema);\n }\n\n createCache(capabilities: CacheCapabilitiesManager) {\n // oxlint-disable-next-line new-cap\n return new options.cache(capabilities);\n }\n\n instantiateRecord(key: ResourceKey, createArgs?: Record<string, unknown>) {\n if (this.schema.isDelegated(key)) {\n return instantiateModel.call(this, key, createArgs);\n }\n return instantiateRecord(this, key, createArgs);\n }\n\n teardownRecord(record: unknown): void {\n const key = recordIdentifierFor(record);\n if (this.schema.isDelegated(key)) {\n return teardownModel.call(this, record as Model);\n }\n releaseLegacySupport(key);\n return teardownRecord(record);\n }\n\n modelFor<InstanceType>(type: TypeFromInstance<InstanceType>): ModelSchema<InstanceType>;\n modelFor(type: string): ModelSchema;\n modelFor(type: string): ModelSchema {\n assertType(this.schema, type);\n\n const klass =\n // prefer real models if present\n (modelFor.call(this, type) as ModelSchema) ||\n // fallback to ShimModelClass specific to fragments if fragments support in use\n (options.modelFragments ? (fragmentsModelFor.call(this, type) as ModelSchema) : false) ||\n // fallback to ShimModelClass\n super.modelFor(type);\n\n return klass;\n }\n\n adapterFor(this: Store, modelName: string): MinimumAdapterInterface;\n adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;\n adapterFor(this: Store, modelName: string, _allowMissing?: true): MinimumAdapterInterface | undefined {\n // createRecord asks for an adapter with _allowMissing to offer id generation;\n // linksMode has no adapters, so that soft lookup finds none.\n if (options.linksMode && _allowMissing) {\n return undefined;\n }\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n // @ts-expect-error\n return adapterFor.call(this, modelName, _allowMissing);\n }\n\n serializerFor(this: Store, ...args: Parameters<typeof serializerFor>): ReturnType<typeof serializerFor> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializerFor.call(this, ...args);\n }\n\n pushPayload(this: Store, ...args: Parameters<typeof pushPayload>): ReturnType<typeof pushPayload> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return pushPayload.call(this, ...args);\n }\n\n normalize(this: Store, ...args: Parameters<typeof normalize>): ReturnType<typeof normalize> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return normalize.call(this, ...args);\n }\n\n serializeRecord(this: Store, ...args: Parameters<typeof serializeRecord>): ReturnType<typeof serializeRecord> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializeRecord.call(this, ...args);\n }\n\n destroy() {\n if (!options.linksMode) {\n cleanup.call(this);\n }\n super.destroy();\n }\n }\n\n if (options.legacyRequests) {\n restoreDeprecatedStoreBehaviors(BaseKlass);\n }\n\n return LegacyConfiguredStore;\n}\n\nfunction assertType(schema: DelegatingSchemaService, type: string) {\n assert(`Expected type ${type} to be a valid ResourceType`, schema.hasResource({ type }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0TA,SAAgB8B,eACdC,SACAC,aAA2B5B,OACW;CAGtC,MAAM6B,kBAAkBD,WAAW,CAAA;CACnC,MAAME,8BAA8BD,UAAU;EAC5CE,YAAYC,YAAsB;GAChC,MAAMA,UAAU;GAMhB,IAAIC;GACJC,OAAOC,eAAe,MAAM,kBAAkB;IAC5CC,cAAc;IACdC,YAAY;IACZC,WAA2B;KACzB,IAAI,CAACL,gBAAgB;MACnB,MAAMM,iBAAiBZ,QAAQa;MAC/B,MAAMA,WAAW,OAAOD,mBAAmB,aAAaA,eAAe,IAAI,IAAKA,kBAAkB,CAAA;MAClGN,iBAAiB,IAAIlC,eAAe,CAAC,CAClC0C,IAAI;OAACd,QAAQe,YAAY,OAAOlC;OAAsB,GAAGgC;OAAU3C;MAAK,CAAC,CAAC8C,OAAOC,OAAO,CAAc,CAAC,CACvGC,SAASjD,YAAY;KAC1B;KACA,OAAOqC;IACT;IACAa,MAAMC,UAAgC;KACpCd,iBAAiBc;IACnB;GACF,CAAC;EACH;EAEAC,YACErB,QAAQsB,UACR,IAAI5C,mBAAmB;GACrB6C,qBAAqB;GACrBC,qBAAqB;GACrBC,aAAa,EACXC,SAAS;IACP,uBAAuB;IACvB,iBAAiB;IACjBC,SAAS;GACX,EACF;EACF,CAAC;EAEHC,sBAA+C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,GAAG,GAC7B,OAAO5D,iBAAc8D,KAAK,MAAMC,MAAe;GAEjD3D,qBAAqBwD,GAAG;GACxB,OAAO1E,eAAe6E,MAAM;EAC9B;EAIAhE,SAASiE,MAA2B;GAClCC,AAAW,KAAK3B;GAUhB,OANGvC,SAAS+D,KAAK,MAAME,IAAI,MAExBvD,QAAQ+C,iBAAkBrD,kBAAkB2D,KAAK,MAAME,IAAI,IAAoB,UAEhF,MAAMjE,SAASiE,IAAI;EAGvB;EAIA5E,WAAwB+E,WAAmBC,eAA2D;GAGpG,IAAI3D,QAAQe,aAAa4C,eACvB;GAOF,OAAOhF,WAAW0E,KAAK,MAAMK,WAAWC,aAAa;EACvD;EAEA1E,cAA2B,GAAG4E,MAA0E;GAKtG,OAAO5E,cAAcoE,KAAK,MAAM,GAAGQ,IAAI;EACzC;EAEA9E,YAAyB,GAAG8E,MAAsE;GAKhG,OAAO9E,YAAYsE,KAAK,MAAM,GAAGQ,IAAI;EACvC;EAEA/E,UAAuB,GAAG+E,MAAkE;GAK1F,OAAO/E,UAAUuE,KAAK,MAAM,GAAGQ,IAAI;EACrC;EAEA7E,gBAA6B,GAAG6E,MAA8E;GAK5G,OAAO7E,gBAAgBqE,KAAK,MAAM,GAAGQ,IAAI;EAC3C;EAEAC,UAAU;GACR,IAAI,CAAC9D,QAAQe,WACXnC,QAAQyE,KAAK,IAAI;GAEnB,MAAMS,QAAQ;EAChB;CACF;CAEA,IAAI9D,QAAQ+D,gBACVjE,gCAAgCI,SAAS;CAG3C,OAAOC;AACT"}
@@ -46,6 +46,11 @@ function determineRelationshipType(store, type, knownSide) {
46
46
 
47
47
  //#endregion
48
48
  //#region src/serializer/json.ts
49
+ /**
50
+ * @module
51
+ * @summary Legacy `JSONSerializer`, which normalizes and serializes plain JSON payloads that don't follow the JSON:API
52
+ * spec.
53
+ */
49
54
  const SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
50
55
  const SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
51
56
  const PRIMARY_ATTRIBUTE_KEY = "base";
@@ -119,6 +124,8 @@ calls it once. This is the method you most likely want to subclass.
119
124
  - `normalize` delegates to these methods to
120
125
  turn the record payload into the JSON API format.
121
126
 
127
+ @summary Legacy serializer for plain JSON payloads that don't follow the JSON:API spec, normalizing them into
128
+ JSON:API documents for the store.
122
129
  @class JSONSerializer
123
130
  @public
124
131
  */
@@ -1077,4 +1084,4 @@ const JSONSerializer = Serializer.extend({
1077
1084
 
1078
1085
  //#endregion
1079
1086
  export { coerceId as n, inverseForRelationship as r, JSONSerializer as t };
1080
- //# sourceMappingURL=json-BD1kRTfB.js.map
1087
+ //# sourceMappingURL=json-CNq5Z0Xq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-CNq5Z0Xq.js","names":["coerceId","id","undefined","toString","String","inverseForRelationship","store","type","name","relationship","schema","fields","get","options","inverse","schemaExists","hasResource","inverseField","determineRelationshipType","knownSide","knownKind","kind","otherKind","getOwner","dasherize","singularize","Serializer","coerceId","determineRelationshipType","SOURCE_POINTER_REGEXP","SOURCE_POINTER_PRIMARY_REGEXP","PRIMARY_ATTRIBUTE_KEY","JSONSerializer","extend","primaryKey","mergedProperties","applyTransforms","typeClass","data","attributes","eachTransformedAttribute","key","type","undefined","transform","transformFor","transformMeta","get","deserialize","options","normalizeResponse","store","primaryModelClass","payload","id","requestType","normalizeFindRecordResponse","arguments","normalizeQueryRecordResponse","normalizeFindAllResponse","normalizeFindBelongsToResponse","normalizeFindHasManyResponse","normalizeFindManyResponse","normalizeQueryResponse","normalizeCreateRecordResponse","normalizeDeleteRecordResponse","normalizeUpdateRecordResponse","normalizeSingleResponse","normalizeArrayResponse","normalizeSaveResponse","_normalizeResponse","isSingle","documentHash","included","meta","extractMeta","normalize","ret","Array","length","i","l","item","concat","modelClass","resourceHash","normalizeUsingDeclaredMapping","links","extractId","modelName","extractAttributes","relationships","extractRelationships","lid","attributeKey","eachAttribute","keyForAttribute","extractRelationship","relationshipModelName","relationshipHash","isArray","modelFor","fields","has","modelNameFromPayloadKey","extractPolymorphicRelationship","relationshipOptions","eachRelationship","relationshipMeta","relationship","relationshipKey","keyForRelationship","kind","polymorphic","linkKey","keyForLink","related","normalizeRelationships","hash","payloadKey","attrs","normalizedKey","_getMappedKey","relationshipsByName","console","warn","mappedKey","_canSerialize","serialize","_mustSerialize","shouldSerializeHasMany","snapshot","relationshipType","json","includeId","attribute","serializeAttribute","serializeBelongsTo","serializeHasMany","serializeIntoHash","Object","assign","value","attr","schema","name","belongsToId","belongsTo","serializePolymorphicType","hasMany","ids","extractErrors","errors","extracted","forEach","error","source","pointer","match","search","push","detail","title","method","attributeType","skipAssertion","lookup"],"sources":["../../../src/serializer/-private/utils.ts","../../../src/serializer/json.ts"],"sourcesContent":["import type { Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type {\n LegacyBelongsToField,\n LegacyHasManyField,\n LegacyRelationshipField,\n} from '@warp-drive/core/types/schema/fields';\n\ntype Coercable = string | number | boolean | null | undefined | symbol;\n\nexport function coerceId(id: Coercable): string | null {\n if (id === null || id === undefined || id === '') {\n return null;\n } else if (typeof id === 'string') {\n return id;\n } else if (typeof id === 'symbol') {\n return id.toString();\n } else {\n return String(id);\n }\n}\n\n/**\n Given the name of a relationship on a resource `type`, determines the\n inverse relationship field (if any) using only the schema service.\n\n Unlike `Model.inverseFor`, this does not require `type` to be backed by\n a `Model` class, so it works for both `Model`-based and schema-only\n (e.g. `withDefaults` migration-support) resources.\n\n @private\n*/\nexport function inverseForRelationship(store: Store, type: string, name: string): LegacyRelationshipField | null {\n const relationship = store.schema.fields({ type }).get(name) as LegacyBelongsToField | LegacyHasManyField | undefined;\n assert(`No relationship named '${name}' on '${type}' exists.`, relationship);\n\n const { options } = relationship;\n assert(\n `Expected the relationship ${name} on ${type} 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 assert(\n `No associated schema found for '${relationship.type}' while calculating the inverse of ${name} on ${type}`,\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 '${type}'`,\n inverseField && (inverseField.kind === 'belongsTo' || inverseField.kind === 'hasMany')\n );\n\n return inverseField ?? null;\n}\n\n/**\n Given a relationship field on a resource `type`, determines the\n cardinality of the relationship using only the schema service.\n\n Unlike `Model.determineRelationshipType`, this does not require `type`\n to be backed by a `Model` class, so it works for both `Model`-based and\n schema-only (e.g. `withDefaults` migration-support) resources.\n\n @private\n*/\nexport function determineRelationshipType(\n store: Store,\n type: string,\n knownSide: LegacyBelongsToField | LegacyHasManyField\n): 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany' | 'oneToNone' | 'manyToNone' {\n const knownKind = knownSide.kind;\n const inverse = inverseForRelationship(store, type, knownSide.name);\n\n if (!inverse) {\n return knownKind === 'belongsTo' ? 'oneToNone' : 'manyToNone';\n }\n\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","/* oxlint-disable typescript/no-unsafe-argument */\n/* oxlint-disable typescript/no-unsafe-call */\n/* oxlint-disable typescript/no-unsafe-return */\n/* oxlint-disable typescript/no-unsafe-member-access */\n/* oxlint-disable typescript/no-unsafe-assignment */\n/**\n * @module\n * @summary Legacy `JSONSerializer`, which normalizes and serializes plain JSON payloads that don't follow the JSON:API\n * spec.\n */\n\nimport { getOwner } from '@ember/application';\nimport { warn } from '@ember/debug';\n\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager, Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// oxlint-disable-next-line no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type {\n LegacyAttributeField,\n LegacyBelongsToField,\n LegacyHasManyField,\n} from '@warp-drive/core/types/schema/fields';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\nimport type { Snapshot } from '../compat/-private.ts';\nimport { Serializer } from '../serializer.ts';\nimport { coerceId, determineRelationshipType } from './-private/utils.ts';\nimport type { Transform } from './transform.ts';\n\nconst SOURCE_POINTER_REGEXP = /^\\/?data\\/(attributes|relationships)\\/(.*)/;\nconst SOURCE_POINTER_PRIMARY_REGEXP = /^\\/?data/;\nconst PRIMARY_ATTRIBUTE_KEY = 'base';\n\n/**\n * :::danger\n ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n {@link Handler} instead to be used with the {@link RequestManager}\n :::\n\n In WarpDrive a Serializer is used to serialize and deserialize\n records when they are transferred in and out of an external source.\n This process involves normalizing property names, transforming\n attribute values and serializing relationships.\n\n By default, WarpDrive uses and recommends the `JSONAPISerializer`.\n\n `JSONSerializer` is useful for simpler or legacy backends that may\n not support the http://jsonapi.org/ spec.\n\n For example, given the following `User` model and JSON payload:\n\n ```js [app/models/user.js]\n import Model, { attr, belongsTo, hasMany } from '@warp-drive/legacy/model';\n\n export default class UserModel extends Model {\n @hasMany('user') friends;\n @belongsTo('location') house;\n\n @attr('string') name;\n }\n ```\n\n ```js\n {\n id: 1,\n name: 'Sebastian',\n friends: [3, 4],\n links: {\n house: '/houses/lefkada'\n }\n }\n ```\n\n `JSONSerializer` will normalize the JSON payload to the {json:api} format that the\n JSONAPICache uses to cache data in the Store.\n\n You can customize how JSONSerializer processes its payload by passing options in\n the `attrs` hash or by subclassing the `JSONSerializer` and overriding hooks:\n\n - To customize how a single record is normalized, use the `normalize` hook.\n - To customize how `JSONSerializer` normalizes the whole server response, use the\n `normalizeResponse` hook.\n - To customize how `JSONSerializer` normalizes a specific response from the server,\n use one of the many specific `normalizeResponse` hooks.\n - To customize how `JSONSerializer` normalizes your id, attributes or relationships,\n use the `extractId`, `extractAttributes` and `extractRelationships` hooks.\n\n The `JSONSerializer` normalization process follows these steps:\n\n 1. `normalizeResponse`\n - entry method to the serializer.\n 2. `normalizeCreateRecordResponse`\n - a `normalizeResponse` for a specific operation is called.\n 3. `normalizeSingleResponse`|`normalizeArrayResponse`\n - for methods like `createRecord` we expect a single record back, while for methods like `findAll` we expect multiple records back.\n 4. `normalize`\n - `normalizeArrayResponse` iterates and calls `normalize` for each of its records while `normalizeSingle`\n calls it once. This is the method you most likely want to subclass.\n 5. `extractId` | `extractAttributes` | `extractRelationships`\n - `normalize` delegates to these methods to\n turn the record payload into the JSON API format.\n\n @summary Legacy serializer for plain JSON payloads that don't follow the JSON:API spec, normalizing them into\n JSON:API documents for the store.\n @class JSONSerializer\n @public\n*/\n// oxlint-disable-next-line typescript/no-explicit-any\nconst JSONSerializer: any = Serializer.extend({\n /**\n The `primaryKey` is used when serializing and deserializing\n data. WarpDrive always uses the `id` property to store the id of\n the record. The external source may not always follow this\n convention. In these cases it is useful to override the\n `primaryKey` property to match the `primaryKey` of your external\n store.\n\n Example\n\n ```js [app/serializers/application.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class ApplicationSerializer extends JSONSerializer {\n primaryKey = '_id'\n }\n ```\n\n @public\n @default 'id'\n */\n primaryKey: 'id',\n\n /**\n The `attrs` object can be used to declare a simple mapping between\n property names on `Model` records and payload keys in the\n serialized JSON object representing the record. An object with the\n property `key` can also be used to designate the attribute's key on\n the response payload.\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('string') occupation;\n @attr('boolean') admin;\n }\n ```\n\n ```js [app/serializers/person.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PersonSerializer extends JSONSerializer {\n attrs = {\n admin: 'is_admin',\n occupation: { key: 'career' }\n }\n }\n ```\n\n You can also remove attributes and relationships by setting the `serialize`\n key to `false` in your mapping object.\n\n Example\n\n ```js [app/serializers/person.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n attrs = {\n admin: { serialize: false },\n occupation: { key: 'career' }\n }\n }\n ```\n\n When serialized:\n\n ```js\n {\n \"firstName\": \"Harry\",\n \"lastName\": \"Houdini\",\n \"career\": \"magician\"\n }\n ```\n\n Note that the `admin` is now not included in the payload.\n\n Setting `serialize` to `true` enforces serialization for hasMany\n relationships even if it's neither a many-to-many nor many-to-none\n relationship.\n\n @public\n */\n mergedProperties: ['attrs'],\n\n /**\n Given a subclass of `Model` and a JSON object this method will\n iterate through each attribute of the `Model` and invoke the\n `Transform#deserialize` method on the matching property of the\n JSON object. This method is typically called after the\n serializer's `normalize` method.\n\n @private\n */\n applyTransforms(typeClass: ModelSchema, data: object): object {\n const attributes = typeClass.attributes;\n\n typeClass.eachTransformedAttribute((key, type) => {\n if (data[key] === undefined) {\n return;\n }\n\n const transform = this.transformFor(type!);\n const transformMeta = attributes.get(key);\n data[key] = transform.deserialize(data[key], transformMeta!.options);\n });\n\n return data;\n },\n\n /**\n The `normalizeResponse` method is used to normalize a payload from the\n server to a JSON-API Document.\n\n http://jsonapi.org/format/#document-structure\n\n This method delegates to a more specific normalize method based on\n the `requestType`.\n\n To override this method with a custom one, make sure to call\n `return super.normalizeResponse(store, primaryModelClass, payload, id, requestType)` with your\n pre-processed data.\n\n Here's an example of using `normalizeResponse` manually:\n\n ```javascript\n socket.on('message', function(message) {\n let data = message.data;\n let modelClass = store.modelFor(data.modelName);\n let serializer = store.serializerFor(data.modelName);\n let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id);\n\n store.push(normalized);\n });\n ```\n\n @since 1.13.0\n @public\n */\n normalizeResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: string | null,\n requestType: string\n // @ts-expect-error\n ): object {\n switch (requestType) {\n case 'findRecord':\n // @ts-expect-error\n return this.normalizeFindRecordResponse(...arguments);\n case 'queryRecord':\n // @ts-expect-error\n return this.normalizeQueryRecordResponse(...arguments);\n case 'findAll':\n // @ts-expect-error\n return this.normalizeFindAllResponse(...arguments);\n case 'findBelongsTo':\n // @ts-expect-error\n return this.normalizeFindBelongsToResponse(...arguments);\n case 'findHasMany':\n // @ts-expect-error\n return this.normalizeFindHasManyResponse(...arguments);\n case 'findMany':\n // @ts-expect-error\n return this.normalizeFindManyResponse(...arguments);\n case 'query':\n // @ts-expect-error\n return this.normalizeQueryResponse(...arguments);\n case 'createRecord':\n // @ts-expect-error\n return this.normalizeCreateRecordResponse(...arguments);\n case 'deleteRecord':\n // @ts-expect-error\n return this.normalizeDeleteRecordResponse(...arguments);\n case 'updateRecord':\n // @ts-expect-error\n return this.normalizeUpdateRecordResponse(...arguments);\n }\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `findRecord`\n\n @since 1.13.0\n @public\n */\n normalizeFindRecordResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: string,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSingleResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `queryRecord`\n\n @since 1.13.0\n @public\n */\n normalizeQueryRecordResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSingleResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `findAll`\n\n @since 1.13.0\n @public\n */\n normalizeFindAllResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeArrayResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `findBelongsTo`\n\n @since 1.13.0\n @public\n */\n normalizeFindBelongsToResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSingleResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `findHasMany`\n\n @since 1.13.0\n @public\n */\n normalizeFindHasManyResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeArrayResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `findMany`\n\n @since 1.13.0\n @public\n */\n normalizeFindManyResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeArrayResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `query`\n\n @since 1.13.0\n @public\n */\n normalizeQueryResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeArrayResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `createRecord`\n\n @since 1.13.0\n @public\n */\n normalizeCreateRecordResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: unknown,\n id: string,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSaveResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `deleteRecord`\n\n @since 1.13.0\n @public\n */\n normalizeDeleteRecordResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: object,\n id: string | null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSaveResponse(...arguments);\n },\n\n /**\n Called by the default normalizeResponse implementation when the\n type of request is `updateRecord`\n\n @since 1.13.0\n @public\n */\n normalizeUpdateRecordResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: object,\n id: string | null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSaveResponse(...arguments);\n },\n\n /**\n normalizeUpdateRecordResponse, normalizeCreateRecordResponse and\n normalizeDeleteRecordResponse delegate to this method by default.\n\n @since 1.13.0\n @public\n */\n normalizeSaveResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: object,\n id: string | null,\n requestType: string\n ): object {\n // @ts-expect-error\n return this.normalizeSingleResponse(...arguments);\n },\n\n /**\n normalizeQueryResponse and normalizeFindRecordResponse delegate to this\n method by default.\n\n @since 1.13.0\n @public\n */\n normalizeSingleResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: object,\n id: string | null,\n requestType: string\n ): object {\n return this._normalizeResponse(store, primaryModelClass, payload, id, requestType, true);\n },\n\n /**\n normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate\n to this method by default.\n\n @since 1.13.0\n @public\n */\n normalizeArrayResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: object,\n id: string | null,\n requestType: string\n ): object {\n return this._normalizeResponse(store, primaryModelClass, payload, id, requestType, false);\n },\n\n /**\n @private\n */\n _normalizeResponse(\n store: Store,\n primaryModelClass: ModelSchema,\n payload: object,\n id: string | null,\n requestType: string,\n isSingle: boolean\n ): object {\n const documentHash = {\n data: null,\n included: [],\n };\n\n const meta = this.extractMeta(store, primaryModelClass, payload);\n if (meta) {\n assert(\n 'The `meta` returned from `extractMeta` has to be an object, not \"' + typeof meta + '\".',\n typeof meta === 'object'\n );\n // @ts-expect-error untyped\n documentHash.meta = meta;\n }\n\n if (isSingle) {\n // @ts-expect-error untyped\n const { data, included } = this.normalize(primaryModelClass, payload);\n documentHash.data = data;\n if (included) {\n documentHash.included = included;\n }\n } else {\n // @ts-expect-error untyped\n const ret = new Array(payload.length);\n // @ts-expect-error untyped\n for (let i = 0, l = payload.length; i < l; i++) {\n const item = payload[i];\n // @ts-expect-error untyped\n const { data, included } = this.normalize(primaryModelClass, item);\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n ret[i] = data;\n }\n\n // @ts-expect-error untyped\n documentHash.data = ret;\n }\n\n return documentHash;\n },\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations.\n\n Example\n\n ```js [app/serializers/application.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n import { underscore } from '<app-name>/utils/string-utils';\n import { get } from '@ember/object';\n\n export default class ApplicationSerializer extends JSONSerializer {\n normalize(typeClass, hash) {\n let fields = typeClass.fields;\n\n fields.forEach(function(type, field) {\n let payloadField = underscore(field);\n if (field === payloadField) { return; }\n\n hash[field] = hash[payloadField];\n delete hash[payloadField];\n });\n\n return super.normalize(...arguments);\n }\n }\n ```\n\n @public\n */\n normalize(modelClass: ModelSchema, resourceHash: object): object {\n let data = null;\n\n if (resourceHash) {\n this.normalizeUsingDeclaredMapping(modelClass, resourceHash);\n // @ts-expect-error untyped\n if (typeof resourceHash.links === 'object') {\n // @ts-expect-error untyped\n this.normalizeUsingDeclaredMapping(modelClass, resourceHash.links);\n }\n\n // @ts-expect-error untyped\n data = {\n id: this.extractId(modelClass, resourceHash),\n type: modelClass.modelName,\n attributes: this.extractAttributes(modelClass, resourceHash),\n relationships: this.extractRelationships(modelClass, resourceHash),\n };\n\n // @ts-expect-error untyped\n if (resourceHash.lid) {\n // @ts-expect-error untyped\n data.lid = resourceHash.lid;\n }\n\n // @ts-expect-error untyped\n this.applyTransforms(modelClass, data.attributes);\n }\n\n return { data };\n },\n\n /**\n Returns the resource's ID.\n\n @public\n */\n extractId(modelClass: ModelSchema, resourceHash: object): string {\n const primaryKey = this.primaryKey;\n const id = resourceHash[primaryKey];\n return coerceId(id) as string;\n },\n\n /**\n Returns the resource's attributes formatted as a JSON-API \"attributes object\".\n\n http://jsonapi.org/format/#document-resource-object-attributes\n\n @public\n */\n extractAttributes(modelClass: ModelSchema, resourceHash: object): object {\n let attributeKey;\n const attributes = {};\n\n modelClass.eachAttribute((key) => {\n attributeKey = this.keyForAttribute(key, 'deserialize');\n if (resourceHash[attributeKey] !== undefined) {\n attributes[key] = resourceHash[attributeKey];\n }\n });\n\n return attributes;\n },\n\n /**\n Returns a relationship formatted as a JSON-API \"relationship object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n @public\n */\n extractRelationship(relationshipModelName: string, relationshipHash: object): object | null {\n if (!relationshipHash) {\n return null;\n }\n /*\n When `relationshipHash` is an object it usually means that the relationship\n is polymorphic. It could however also be embedded resources that the\n EmbeddedRecordsMixin has be able to process.\n */\n if (relationshipHash && typeof relationshipHash === 'object' && !Array.isArray(relationshipHash)) {\n // @ts-expect-error untyped\n if (relationshipHash.id) {\n // @ts-expect-error untyped\n relationshipHash.id = coerceId(relationshipHash.id);\n }\n\n // @ts-expect-error store is dynamically injected\n const modelClass = this.store.modelFor(relationshipModelName);\n // @ts-expect-error untyped\n if (relationshipHash.type && !modelClass.fields.has('type')) {\n // @ts-expect-error untyped\n relationshipHash.type = this.modelNameFromPayloadKey(relationshipHash.type);\n }\n\n return relationshipHash;\n }\n return {\n id: coerceId(relationshipHash as unknown as string | number | null),\n type: dasherize(singularize(relationshipModelName)),\n };\n },\n\n /**\n Returns a polymorphic relationship formatted as a JSON-API \"relationship object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n `relationshipOptions` is a hash which contains more information about the\n polymorphic relationship which should be extracted:\n - `resourceHash` complete hash of the resource the relationship should be\n extracted from\n - `relationshipKey` key under which the value for the relationship is\n extracted from the resourceHash\n - `relationshipMeta` meta information about the relationship\n\n @public\n */\n extractPolymorphicRelationship(\n relationshipModelName: string,\n relationshipHash: object,\n relationshipOptions?: object\n ): object | null {\n return this.extractRelationship(relationshipModelName, relationshipHash);\n },\n\n /**\n Returns the resource's relationships formatted as a JSON-API \"relationships object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n @public\n */\n extractRelationships(modelClass: ModelSchema, resourceHash: object): object {\n const relationships = {};\n\n modelClass.eachRelationship((key, relationshipMeta) => {\n let relationship = null;\n const relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');\n if (resourceHash[relationshipKey] !== undefined) {\n let data = null;\n const relationshipHash = resourceHash[relationshipKey];\n if (relationshipMeta.kind === 'belongsTo') {\n if (relationshipMeta.options.polymorphic) {\n // extracting a polymorphic belongsTo may need more information\n // than the type and the hash (which might only be an id) for the\n // relationship, hence we pass the key, resource and\n // relationshipMeta too\n // @ts-expect-error untyped\n data = this.extractPolymorphicRelationship(relationshipMeta.type, relationshipHash, {\n key,\n resourceHash,\n relationshipMeta,\n });\n } else {\n // @ts-expect-error untyped\n data = this.extractRelationship(relationshipMeta.type, relationshipHash);\n }\n } else if (relationshipMeta.kind === 'hasMany') {\n if (relationshipHash) {\n // @ts-expect-error untyped\n data = new Array(relationshipHash.length);\n if (relationshipMeta.options.polymorphic) {\n for (let i = 0, l = relationshipHash.length; i < l; i++) {\n const item = relationshipHash[i];\n // @ts-expect-error untyped\n data[i] = this.extractPolymorphicRelationship(relationshipMeta.type, item, {\n key,\n resourceHash,\n relationshipMeta,\n });\n }\n } else {\n for (let i = 0, l = relationshipHash.length; i < l; i++) {\n const item = relationshipHash[i];\n // @ts-expect-error untyped\n data[i] = this.extractRelationship(relationshipMeta.type, item);\n }\n }\n }\n }\n // @ts-expect-error untyped\n relationship = { data };\n }\n\n const linkKey = this.keyForLink(key, relationshipMeta.kind);\n // @ts-expect-error untyped\n if (resourceHash.links && resourceHash.links[linkKey] !== undefined) {\n // @ts-expect-error untyped\n const related = resourceHash.links[linkKey];\n // @ts-expect-error untyped\n relationship = relationship || {};\n // @ts-expect-error untyped\n relationship.links = { related };\n }\n\n if (relationship) {\n relationships[key] = relationship;\n }\n });\n\n return relationships;\n },\n\n /**\n Dasherizes the model name in the payload\n\n @public\n @return the model's modelName\n */\n modelNameFromPayloadKey(key: string): string {\n return dasherize(singularize(key));\n },\n\n /**\n @private\n */\n normalizeRelationships(typeClass: ModelSchema, hash: object): void {\n let payloadKey;\n\n if (this.keyForRelationship) {\n typeClass.eachRelationship((key, relationship) => {\n payloadKey = this.keyForRelationship(key, relationship.kind, 'deserialize');\n if (key === payloadKey) {\n return;\n }\n if (hash[payloadKey] === undefined) {\n return;\n }\n\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n });\n }\n },\n\n /**\n @private\n */\n normalizeUsingDeclaredMapping(modelClass: ModelSchema, hash: object): void {\n // @ts-expect-error attrs is dynamically injected\n const attrs = this.attrs;\n let normalizedKey;\n let payloadKey;\n\n if (attrs) {\n for (const key in attrs) {\n normalizedKey = payloadKey = this._getMappedKey(key, modelClass);\n\n if (hash[payloadKey] === undefined) {\n continue;\n }\n\n if (modelClass.attributes.has(key)) {\n normalizedKey = this.keyForAttribute(key, 'deserialize');\n }\n\n if (modelClass.relationshipsByName.has(key)) {\n normalizedKey = this.keyForRelationship(key, modelClass, 'deserialize');\n }\n\n if (payloadKey !== normalizedKey) {\n hash[normalizedKey] = hash[payloadKey];\n delete hash[payloadKey];\n }\n }\n }\n },\n\n /**\n Looks up the property key that was set by the custom `attr` mapping\n passed to the serializer.\n\n @private\n */\n _getMappedKey(key: string, modelClass: ModelSchema): string {\n warn(\n 'There is no attribute or relationship with the name `' +\n key +\n '` on `' +\n modelClass.modelName +\n '`. Check your serializers attrs hash.',\n modelClass.attributes.has(key) || modelClass.relationshipsByName.has(key),\n {\n id: 'ds.serializer.no-mapped-attrs-key',\n }\n );\n // @ts-expect-error attrs is dynamically injected\n const attrs = this.attrs;\n let mappedKey;\n if (attrs && attrs[key]) {\n mappedKey = attrs[key];\n //We need to account for both the { title: 'post_title' } and\n //{ title: { key: 'post_title' }} forms\n if (mappedKey.key) {\n mappedKey = mappedKey.key;\n }\n if (typeof mappedKey === 'string') {\n key = mappedKey;\n }\n }\n\n return key;\n },\n\n /**\n Check attrs.key.serialize property to inform if the `key`\n can be serialized\n\n @private\n @return true if the key can be serialized\n */\n _canSerialize(key: string): boolean {\n // @ts-expect-error no idea what attrs is here\n const attrs = this.attrs;\n\n return !attrs || !attrs[key] || attrs[key].serialize !== false;\n },\n\n /**\n When attrs.key.serialize is set to true then\n it takes priority over the other checks and the related\n attribute/relationship will be serialized\n\n @private\n @return true if the key must be serialized\n */\n _mustSerialize(key: string): boolean {\n // @ts-expect-error no idea what attrs is here\n const attrs = this.attrs;\n\n return attrs && attrs[key] && attrs[key].serialize === true;\n },\n\n /**\n Check if the given hasMany relationship should be serialized\n\n By default only many-to-many and many-to-none relationships are serialized.\n This could be configured per relationship by Serializer's `attrs` object.\n\n @public\n @return true if the hasMany relationship should be serialized\n */\n shouldSerializeHasMany(\n snapshot: Snapshot,\n key: string,\n relationship: LegacyBelongsToField | LegacyHasManyField\n ): boolean {\n // @ts-expect-error store is dynamically injected\n const relationshipType = determineRelationshipType(this.store, snapshot.modelName, relationship);\n if (this._mustSerialize(key)) {\n return true;\n }\n return this._canSerialize(key) && (relationshipType === 'manyToNone' || relationshipType === 'manyToMany');\n },\n\n // SERIALIZE\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```js [app/models/comment.js]\n import Model, { attr, belongsTo } from '@warp-drive/legacy/model';\n\n export default class CommentModel extends Model {\n @attr title;\n @attr body;\n\n @belongsTo('user') author;\n }\n ```\n\n The default serialization would create a JSON object like:\n\n ```javascript\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n Whether `includeId` is `true` or `false` depends on the\n adapter and the operation being performed, since it is the\n adapter that invokes `serialize` and decides which options\n to pass. For instance, `RESTAdapter` passes `includeId: true`\n when serializing a record for `createRecord`, but not for\n `updateRecord`, while `JSONAPIAdapter` passes `includeId: true`\n for both `createRecord` and `updateRecord`. Refer to the\n documentation for the adapter and serializer pairing you are\n using for specifics.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n serialize(snapshot, options) {\n let json = {\n POST_TTL: snapshot.attr('title'),\n POST_BDY: snapshot.attr('body'),\n POST_CMS: snapshot.hasMany('comments', { ids: true })\n };\n\n if (options.includeId) {\n json.POST_ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```js [app/serializers/application.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n import { singularize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONSerializer {\n serialize(snapshot, options) {\n let json = {};\n\n snapshot.eachAttribute((name) => {\n json[serverAttributeName(name)] = snapshot.attr(name);\n });\n\n snapshot.eachRelationship((name, relationship) => {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n }\n });\n\n if (options.includeId) {\n json.ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(singularize(name)) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```javascript\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ \"1\", \"2\", \"3\" ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call `super.serialize` first and make the tweaks on\n the returned JSON.\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n serialize(snapshot, options) {\n let json = super.serialize(...arguments);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n }\n ```\n\n @public\n */\n serialize(snapshot: Snapshot, options: object): object {\n const json = {};\n\n // @ts-expect-error super loose typing here right now\n if (options && options.includeId) {\n const id = snapshot.id;\n if (id) {\n json[this.primaryKey] = id;\n }\n }\n\n snapshot.eachAttribute((key, attribute) => {\n this.serializeAttribute(snapshot, json, key, attribute);\n });\n\n snapshot.eachRelationship((key, relationship) => {\n if (relationship.kind === 'belongsTo') {\n this.serializeBelongsTo(snapshot, json, relationship);\n } else if (relationship.kind === 'hasMany') {\n this.serializeHasMany(snapshot, json, relationship);\n }\n });\n\n return json;\n },\n\n /**\n You can use this method to customize how a serialized record is added to the complete\n JSON hash to be sent to the server. By default the JSON Serializer does not namespace\n the payload and just sends the raw serialized JSON object.\n If your server expects namespaced keys, you should consider using the RESTSerializer.\n Otherwise you can override this method to customize how the record is added to the hash.\n The hash property should be modified by reference.\n\n For example, your server may expect underscored root objects.\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@warp-drive/legacy/serializer/rest';\n import { underscoren} from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serializeIntoHash(data, type, snapshot, options) {\n let root = underscore(type.modelName);\n data[root] = this.serialize(snapshot, options);\n }\n }\n ```\n\n @public\n */\n serializeIntoHash(hash: object, typeClass: ModelSchema, snapshot: Snapshot, options: object): void {\n Object.assign(hash, this.serialize(snapshot, options));\n },\n\n /**\n `serializeAttribute` can be used to customize how `attr`\n properties are serialized\n\n For example if you wanted to ensure all your attributes were always\n serialized as properties on an `attributes` object you could\n write:\n\n ```js [app/serializers/application.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class ApplicationSerializer extends JSONSerializer {\n serializeAttribute(snapshot, json, key, attributes) {\n json.attributes = json.attributes || {};\n super.serializeAttribute(snapshot, json.attributes, key, attributes);\n }\n }\n ```\n\n @public\n */\n serializeAttribute(snapshot: Snapshot, json: object, key: string, attribute: LegacyAttributeField): void {\n if (this._canSerialize(key)) {\n const type = attribute.type;\n // @ts-expect-error we don't know what is on the snapshot\n let value = snapshot.attr(key);\n if (type) {\n const transform = this.transformFor(type);\n value = transform.serialize(value, attribute.options);\n }\n\n // if provided, use the mapping provided by `attrs` in\n // the serializer\n // @ts-expect-error store added dynamically\n const schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(key, schema);\n\n if (payloadKey === key && this.keyForAttribute) {\n payloadKey = this.keyForAttribute(key, 'serialize');\n }\n\n json[payloadKey] = value;\n }\n },\n\n /**\n `serializeBelongsTo` can be used to customize how `belongsTo`\n properties are serialized.\n\n Example\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n serializeBelongsTo(snapshot, json, relationship) {\n let key = relationship.name;\n let belongsTo = snapshot.belongsTo(key);\n\n key = this.keyForRelationship ? this.keyForRelationship(key, \"belongsTo\", \"serialize\") : key;\n\n json[key] = !belongsTo ? null : belongsTo.record.toJSON();\n }\n }\n ```\n\n @public\n */\n serializeBelongsTo(snapshot: Snapshot, json: object, relationship: LegacyHasManyField | LegacyBelongsToField): void {\n const name = relationship.name;\n\n if (this._canSerialize(name)) {\n const belongsToId = snapshot.belongsTo(name, { id: true });\n\n // if provided, use the mapping provided by `attrs` in\n // the serializer\n // @ts-expect-error store added dynamically\n const schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(name, schema);\n if (payloadKey === name && this.keyForRelationship) {\n payloadKey = this.keyForRelationship(name, 'belongsTo', 'serialize');\n }\n\n //Need to check whether the id is there for new&async records\n if (!belongsToId) {\n json[payloadKey] = null;\n } else {\n json[payloadKey] = belongsToId;\n }\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n },\n\n /**\n `serializeHasMany` can be used to customize how `hasMany`\n properties are serialized.\n\n Example\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n serializeHasMany(snapshot, json, relationship) {\n let key = relationship.name;\n if (key === 'comments') {\n return;\n } else {\n super.serializeHasMany(...arguments);\n }\n }\n }\n ```\n\n @public\n */\n serializeHasMany(snapshot: Snapshot, json: object, relationship: LegacyBelongsToField | LegacyHasManyField): void {\n const name = relationship.name;\n\n if (this.shouldSerializeHasMany(snapshot, name, relationship)) {\n const hasMany = snapshot.hasMany(name, { ids: true });\n if (hasMany !== undefined) {\n // if provided, use the mapping provided by `attrs` in\n // the serializer\n // @ts-expect-error store added dynamically\n const schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(name, schema);\n if (payloadKey === name && this.keyForRelationship) {\n payloadKey = this.keyForRelationship(name, 'hasMany', 'serialize');\n }\n\n json[payloadKey] = hasMany;\n // TODO support for polymorphic manyToNone and manyToMany relationships\n }\n }\n },\n\n /**\n You can use this method to customize how polymorphic objects are\n serialized. Objects are considered to be polymorphic if\n `{ polymorphic: true }` is pass as the second argument to the\n `belongsTo` function.\n\n Example\n\n ```js [app/serializers/comment.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class CommentSerializer extends JSONSerializer {\n serializePolymorphicType(snapshot, json, relationship) {\n let key = relationship.name;\n let belongsTo = snapshot.belongsTo(key);\n\n key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key;\n\n if (!belongsTo) {\n json[key + '_type'] = null;\n } else {\n json[key + '_type'] = belongsTo.modelName;\n }\n }\n }\n ```\n\n @public\n */\n serializePolymorphicType(\n snapshot: Snapshot,\n json: object,\n relationship: LegacyBelongsToField | LegacyHasManyField\n ): void {},\n\n /**\n `extractMeta` is used to deserialize any meta information in the\n adapter payload. By default Ember Data expects meta information to\n be located on the `meta` property of the payload object.\n\n Example\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n extractMeta(store, typeClass, payload) {\n if (payload && payload.hasOwnProperty('_pagination')) {\n let meta = payload._pagination;\n delete payload._pagination;\n return meta;\n }\n }\n }\n ```\n\n @public\n */\n extractMeta(store: Store, modelClass: ModelSchema, payload: object): object | undefined {\n if (payload && payload['meta'] !== undefined) {\n // @ts-expect-error\n const meta = payload.meta;\n // @ts-expect-error\n delete payload.meta;\n return meta;\n }\n },\n\n /**\n `extractErrors` is used to extract model errors when a call\n to `Model#save` fails with an `InvalidError`. By default\n Ember Data expects error information to be located on the `errors`\n property of the payload object.\n\n This serializer expects this `errors` object to be an Array similar\n to the following, compliant with the https://jsonapi.org/format/#errors specification:\n\n ```js\n {\n \"errors\": [\n {\n \"detail\": \"This username is already taken!\",\n \"source\": {\n \"pointer\": \"data/attributes/username\"\n }\n }, {\n \"detail\": \"Doesn't look like a valid email.\",\n \"source\": {\n \"pointer\": \"data/attributes/email\"\n }\n }\n ]\n }\n ```\n\n The key `detail` provides a textual description of the problem.\n Alternatively, the key `title` can be used for the same purpose.\n\n The nested keys `source.pointer` detail which specific element\n of the request data was invalid.\n\n Note that JSON-API also allows for object-level errors to be placed\n in an object with pointer `data`, signifying that the problem\n cannot be traced to a specific attribute:\n\n ```javascript\n {\n \"errors\": [\n {\n \"detail\": \"Some generic non property error message\",\n \"source\": {\n \"pointer\": \"data\"\n }\n }\n ]\n }\n ```\n\n When turn into a `Errors` object, you can read these errors\n through the property `base`:\n\n ```handlebars\n {{#each @model.errors.base as |error|}}\n <div class=\"error\">\n {{error.message}}\n </div>\n {{/each}}\n ```\n\n Example of alternative implementation, overriding the default\n behavior to deal with a different format of errors:\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n\n export default class PostSerializer extends JSONSerializer {\n extractErrors(store, typeClass, payload, id) {\n if (payload && typeof payload === 'object' && payload._problems) {\n payload = payload._problems;\n this.normalizeErrors(typeClass, payload);\n }\n return payload;\n }\n }\n ```\n\n @public\n @return json The deserialized errors\n */\n extractErrors(store: Store, typeClass: ModelSchema, payload: object, id: string | null): object {\n // @ts-expect-error\n if (payload && typeof payload === 'object' && payload.errors) {\n // the default assumption is that errors is already in JSON:API format\n const extracted = {};\n\n // @ts-expect-error\n payload.errors.forEach((error) => {\n if (error.source && error.source.pointer) {\n let key = error.source.pointer.match(SOURCE_POINTER_REGEXP);\n\n if (key) {\n key = key[2];\n } else if (error.source.pointer.search(SOURCE_POINTER_PRIMARY_REGEXP) !== -1) {\n key = PRIMARY_ATTRIBUTE_KEY;\n }\n\n if (key) {\n extracted[key] = extracted[key] || [];\n extracted[key].push(error.detail || error.title);\n }\n }\n });\n\n // if the user has an attrs hash, convert keys using it\n this.normalizeUsingDeclaredMapping(typeClass, extracted);\n\n // for each attr and relationship, make sure that we use\n // the normalized key\n typeClass.eachAttribute((name) => {\n const key = this.keyForAttribute(name, 'deserialize');\n if (key !== name && extracted[key] !== undefined) {\n extracted[name] = extracted[key];\n delete extracted[key];\n }\n });\n\n typeClass.eachRelationship((name) => {\n const key = this.keyForRelationship(name, 'deserialize');\n if (key !== name && extracted[key] !== undefined) {\n extracted[name] = extracted[key];\n delete extracted[key];\n }\n });\n\n return extracted;\n }\n\n return payload;\n },\n\n /**\n `keyForAttribute` can be used to define rules for how to convert an\n attribute name in your model to a key in your JSON.\n\n Example\n\n ```js [app/serializers/application.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONSerializer {\n keyForAttribute(attr, method) {\n return underscore(attr).toUpperCase();\n }\n }\n ```\n\n @public\n */\n keyForAttribute(key: string, method: string): string {\n return key;\n },\n\n /**\n `keyForRelationship` can be used to define a custom key when\n serializing and deserializing relationship properties. By default\n `JSONSerializer` does not provide an implementation of this method.\n\n Example\n\n ```js [app/serializers/post.js]\n import { JSONSerializer } from '@warp-drive/legacy/serializer/json';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class PostSerializer extends JSONSerializer {\n keyForRelationship(key, relationship, method) {\n return `rel_${underscore(key)}`;\n }\n }\n ```\n\n @public\n */\n keyForRelationship(key: string, typeClass: ModelSchema | string, method?: string): string {\n return key;\n },\n\n /**\n `keyForLink` can be used to define a custom key when deserializing link\n properties.\n\n @public\n */\n keyForLink(key: string, kind: 'belongsTo' | 'hasMany'): string {\n return key;\n },\n\n // HELPERS\n\n /**\n @private\n */\n transformFor(attributeType: string, skipAssertion?: boolean): Transform {\n const transform = getOwner(this)!.lookup(`transform:${attributeType}`) as Transform | undefined;\n\n assert(`Unable to find the transform for \\`attr('${attributeType}')\\``, skipAssertion || !!transform);\n\n return transform!;\n },\n});\n\nexport { JSONSerializer };\n"],"mappings":";;;;;AAUA,SAAgBA,SAASC,IAA8B;CACrD,IAAIA,OAAO,QAAQA,OAAOC,UAAaD,OAAO,IAC5C,OAAO;MACF,IAAI,OAAOA,OAAO,UACvB,OAAOA;MACF,IAAI,OAAOA,OAAO,UACvB,OAAOA,GAAGE,SAAS;MAEnB,OAAOC,OAAOH,EAAE;AAEpB;;;;;;;;;;;AAYA,SAAgBI,uBAAuBC,OAAcC,MAAcC,MAA8C;CAC/G,MAAMC,eAAeH,MAAMI,OAAOC,OAAO,EAAEJ,KAAK,CAAC,CAAC,CAACK,IAAIJ,IAAI;CAG3D,MAAM,EAAEK,YAAYJ;CAMpB,IAAII,QAAQC,YAAY,MACtB,OAAO;CAST,IAAI,CANiBR,MAAMI,OAAOM,YAAYP,YAMzCM,GACH,OAAO;CAST,OANqBT,MAAMI,OAAOC,OAAOF,YAAY,CAAC,CAACG,IAAIC,QAAQC,OAM5DG,KAAgB;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H;CACT;AACF,CAAC"}
@@ -1,3 +1,3 @@
1
- import { a as PromiseManyArray, n as LEGACY_SUPPORT, o as PromiseBelongsTo, r as lookupLegacySupport, t as Errors } from "../errors-BX8zhQS4.js";
1
+ import { a as PromiseManyArray, n as LEGACY_SUPPORT, o as PromiseBelongsTo, r as lookupLegacySupport, t as Errors } from "../errors-DIOUcGAT.js";
2
2
 
3
3
  export { Errors, LEGACY_SUPPORT, PromiseBelongsTo, PromiseManyArray, lookupLegacySupport };
@@ -1,5 +1,5 @@
1
- import { r as lookupLegacySupport, t as Errors } from "../errors-BX8zhQS4.js";
2
- import { _ as save, a as RecordState, c as _save, d as createSnapshot, f as deleteRecord, g as rollbackAttributes, h as reload, l as belongsTo, m as hasMany, o as _destroyRecord, p as destroyRecord, s as _reload, t as buildSchema, u as changedAttributes, v as serialize, y as unloadRecord } from "../schema-provider-CTLbab33.js";
1
+ import { r as lookupLegacySupport, t as Errors } from "../errors-DIOUcGAT.js";
2
+ import { _ as save, a as RecordState, c as _save, d as createSnapshot, f as deleteRecord, g as rollbackAttributes, h as reload, l as belongsTo, m as hasMany, o as _destroyRecord, p as destroyRecord, s as _reload, t as buildSchema, u as changedAttributes, v as serialize, y as unloadRecord } from "../schema-provider-NWVqBEkW.js";
3
3
  import "./-private.js";
4
4
  import { recordIdentifierFor } from "@warp-drive/core";
5
5
  import { assertPrivateStore } from "@warp-drive/core/store/-private";
@@ -26,12 +26,17 @@ import { notifyInternalSignal } from "@warp-drive/core/signals/-leaked";
26
26
  * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone
27
27
  * to assist in more rapidly adopting modern WarpDrive features.
28
28
  *
29
+ * @summary Legacy helpers for migrating from `Model` to `ReactiveResource`: LegacyMode schema defaults, derivations,
30
+ * types, and a schema service that serves both at once.
29
31
  * @module
30
32
  */
31
33
  /**
32
34
  * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a
33
35
  * {@link TypedRecordInstance}, for use when migrating a resource from
34
36
  * `Model` to a schema-based record while preserving these APIs.
37
+ *
38
+ * @summary Legacy type that adds the `Model`-style `belongsTo` and `hasMany` reference methods to a typed record
39
+ * migrating from `Model` to a schema-based record.
35
40
  */
36
41
  const LegacyFields = [
37
42
  "_createSnapshot",
@@ -100,6 +105,8 @@ const LegacyFields = [
100
105
  * }>
101
106
  * ```
102
107
  *
108
+ * @summary Legacy type that adds the `Model`-style state flags and methods (`save`, `isNew`, `errors`, etc.) that
109
+ * `withDefaults` provides to a LegacyMode record type.
103
110
  */
104
111
  const LegacySupport = getOrSetGlobal("LegacySupport", /* @__PURE__ */ new WeakMap());
105
112
  function legacySupport(record, options, prop) {
@@ -192,6 +199,8 @@ legacySupport[Type] = "@legacy";
192
199
  * registerDerivations(schema);
193
200
  * ```
194
201
  *
202
+ * @summary Legacy helper that marks a resource schema as LegacyMode and adds the fields that give its records
203
+ * `Model`-like state and methods.
195
204
  * @param schema The schema to add legacy support to.
196
205
  * @return The schema with legacy support added.
197
206
  * @public
@@ -249,6 +258,9 @@ function withDefaults(schema) {
249
258
  * ]
250
259
  * });
251
260
  * ```
261
+ *
262
+ * @summary Legacy alternative to `withDefaults` that makes a LegacyMode schema whose `save`, `reload`, and
263
+ * `destroyRecord` run without deprecation warnings.
252
264
  */
253
265
  function withRestoredDeprecatedModelRequestBehaviors(schema) {
254
266
  schema.legacy = true;
@@ -291,6 +303,8 @@ function withRestoredDeprecatedModelRequestBehaviors(schema) {
291
303
  * This must be called in order to use the fields added by {@link withDefaults} or
292
304
  * {@link withRestoredDeprecatedModelRequestBehaviors}.
293
305
  *
306
+ * @summary Legacy setup that registers the derivation, relationship behaviors, and extension a schema service needs to
307
+ * support LegacyMode records.
294
308
  * @param schema The schema service to register the derivations with.
295
309
  * @public
296
310
  */
@@ -373,11 +387,15 @@ function registerDerivations(schema) {
373
387
  * All calls to register resources, derivations, transformations, hash functions
374
388
  * etc. will be delegated to the primary schema service.
375
389
  *
390
+ * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and
391
+ * otherwise from its `Model` class, for incremental migration.
376
392
  * @class DelegatingSchemaService
377
393
  * @public
378
394
  */
379
395
  /**
380
396
  * See the {@link DelegatingSchemaService | class documentation above} for usage.
397
+ * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and
398
+ * otherwise from its `Model` class, for incremental migration.
381
399
  */
382
400
  var DelegatingSchemaService = class {
383
401
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"migration-support.js","names":["recordIdentifierFor","Context","notifyInternalSignal","assertPrivateStore","getOrSetGlobal","Type","Errors","lookupLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","RecordState","buildSchema","LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","suppressDeprecation","Boolean","currentState","adapterError","_constructor","isModel","name","type","modelName","recordState","dirtyType","errors","create","__record","isDirty","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","objectExtensions","withRestoredDeprecatedModelRequestBehaviors","registerDerivations","registerDerivation","_registerMode","store","cacheKey","getBelongsTo","value","_join","setDirtyBelongsTo","getHasMany","support","manyArray","getManyArray","splice","length","notify","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","CAUTION_MEGA_DANGER_ZONE_registerExtension","features","isReloading","console","warn","_isReloading","v","DelegatingSchemaService","_preferred","_secondary","constructor","isDelegated","resource","hasResource","resourceTypes","Array","from","Set","concat","hasTrait","resourceHasTrait","trait","cacheFields","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","CAUTION_MEGA_DANGER_ZONE_hasExtension","ext","extension","CAUTION_MEGA_DANGER_ZONE_resourceExtensions","CAUTION_MEGA_DANGER_ZONE_objectExtensions","resolvedType","CAUTION_MEGA_DANGER_ZONE_arrayExtensions","mode","kinds","_kind","assertPrivate","service","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"sources":["../../../../src/model/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @warp-drive/legacy/model\n * to ReactiveResource from @warp-drive/core/reactive.\n *\n * It includes:\n *\n * - A `withDefaults` function to assist in creating a schema in LegacyMode\n * - A `registerDerivations` function to register the derivations necessary to support LegacyMode\n * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both\n * @warp-drive/legacy/model and @warp-drive/core/reactive simultaneously for migration purposes.\n * - A `WithLegacy` type util that can be used to create a type that includes the legacy\n * properties and methods of a record.\n *\n * Using LegacyMode features on a ReactiveResource *requires* the use of these derivations and schema\n * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone\n * to assist in more rapidly adopting modern WarpDrive features.\n *\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } 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 { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from '@warp-drive/core/reactive';\nimport type { ExtensibleField } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { ObjectValue } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core/types/schema/concepts';\nimport type {\n ArrayField,\n CacheableFieldSchema,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n IdentityField,\n LegacyBelongsToField,\n LegacyHasManyField,\n LegacyResourceSchema,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core/types/schema/fields';\nimport { Type } from '@warp-drive/core/types/symbols';\nimport type { WithPartial } from '@warp-drive/core/types/utils';\n\nimport type { Snapshot } from '../compat/-private.ts';\nimport { Errors, lookupLegacySupport } from './-private.ts';\nimport type { MinimalLegacyRecord } from './-private/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 './-private/model-methods.ts';\nimport RecordState from './-private/record-state.ts';\nimport type BelongsToReference from './-private/references/belongs-to.ts';\nimport type HasManyReference from './-private/references/has-many.ts';\nimport { buildSchema } from './-private/schema-provider.ts';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils.ts';\n\n/**\n * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a\n * {@link TypedRecordInstance}, for use when migrating a resource from\n * `Model` to a schema-based record while preserving these APIs.\n */\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n /**\n * see {@link belongsTo}\n */\n belongsTo: typeof belongsTo;\n /**\n * see {@link hasMany}\n */\n hasMany: typeof hasMany;\n };\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ninterface LegacyModeRecord<T extends TypedRecordInstance> {\n id: string | null;\n\n serialize(options?: Record<string, unknown>): unknown;\n destroyRecord(options?: Record<string, unknown>): Promise<this>;\n unloadRecord(): void;\n changedAttributes(): ChangedAttributesHash;\n rollbackAttributes(): void;\n _createSnapshot(): Snapshot<T>;\n save(options?: Record<string, unknown>): Promise<this>;\n reload(options?: Record<string, unknown>): Promise<T>;\n belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;\n hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;\n deleteRecord(): void;\n\n adapterError: unknown;\n constructor: { modelName: TypeFromInstance<T> };\n currentState: RecordState;\n dirtyType: 'deleted' | 'created' | 'updated' | '';\n errors: unknown;\n hasDirtyAttributes: boolean;\n isDeleted: boolean;\n isEmpty: boolean;\n isError: boolean;\n isLoaded: boolean;\n isLoading: boolean;\n isDestroying: boolean;\n isDestroyed: boolean;\n isNew: boolean;\n isSaving: boolean;\n isValid: boolean;\n}\n\n// 'isDestroying', 'isDestroyed'\nconst LegacyFields = [\n '_createSnapshot',\n 'adapterError',\n 'belongsTo',\n 'changedAttributes',\n 'constructor',\n 'currentState',\n 'deleteRecord',\n 'destroyRecord',\n 'dirtyType',\n 'errors',\n 'hasDirtyAttributes',\n 'hasMany',\n 'isDeleted',\n 'isEmpty',\n 'isError',\n 'isLoaded',\n 'isLoading',\n 'isNew',\n 'isSaving',\n 'isValid',\n 'reload',\n 'rollbackAttributes',\n 'save',\n 'serialize',\n 'unloadRecord',\n] as const;\n\n/**\n * A Type utility that enables quickly adding type information for the fields\n * defined by `import { withDefaults } from '@warp-drive/legacy/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n */\nexport type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;\n\nconst LegacySupport = getOrSetGlobal('LegacySupport', new WeakMap<MinimalLegacyRecord, Record<string, unknown>>());\n\nfunction legacySupport(record: MinimalLegacyRecord, options: ObjectValue | null, prop: string): unknown {\n let state = LegacySupport.get(record);\n if (!state) {\n state = {};\n LegacySupport.set(record, state);\n }\n const suppressDeprecation = Boolean(options && options.suppressDeprecation);\n\n switch (prop) {\n case '_createSnapshot':\n // FIXME should be deprecated too?\n return createSnapshot;\n case 'adapterError':\n // FIXME should be deprecated too?\n return record.currentState.adapterError;\n case 'belongsTo':\n return belongsTo;\n case 'changedAttributes':\n return changedAttributes;\n case 'constructor':\n return (state._constructor = state._constructor || {\n isModel: true,\n name: `Record<${recordIdentifierFor(record).type}>`,\n modelName: recordIdentifierFor(record).type,\n });\n case 'currentState':\n return (state.recordState = state.recordState || new RecordState(record));\n case 'deleteRecord':\n return deleteRecord;\n case 'destroyRecord':\n return suppressDeprecation ? _destroyRecord : destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // FIXME should be deprecated too?\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return (state.errors = state.errors || Errors.create({ __record: record }));\n case 'hasDirtyAttributes':\n return record.currentState.isDirty;\n case 'hasMany':\n return hasMany;\n case 'isDeleted':\n return record.currentState.isDeleted;\n case 'isEmpty':\n return record.currentState.isEmpty;\n case 'isError':\n return record.currentState.isError;\n case 'isLoaded':\n return record.currentState.isLoaded;\n case 'isLoading':\n return record.currentState.isLoading;\n case 'isNew':\n return record.currentState.isNew;\n case 'isSaving':\n return record.currentState.isSaving;\n case 'isValid':\n return record.currentState.isValid;\n case 'reload':\n return suppressDeprecation ? _reload : reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return suppressDeprecation ? _save : save;\n case 'serialize':\n // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)\n return serialize;\n case 'unloadRecord':\n return unloadRecord;\n default:\n assert(`${prop} is not a supported legacy field`, false);\n }\n}\nlegacySupport[Type] = '@legacy';\n\n/**\n * A function which adds the necessary fields to a schema and marks it as\n * being in LegacyMode. This is used to support the legacy features of\n * @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * Using this function require registering the derivations\n * it requires with the schema service.\n *\n * ```ts\n * import { registerDerivations } from '@warp-drive/legacy/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @param schema The schema to add legacy support to.\n * @return The schema with legacy support added.\n * @public\n */\nexport function withDefaults(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n schema.fields.push({\n name: '_isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.objectExtensions = schema.objectExtensions || [];\n schema.objectExtensions.push('deprecated-model-behaviors');\n return schema as LegacyResourceSchema;\n}\n\n/**\n * Adds the necessasary fields to the schema for supporting\n * the deprecated request methods on LegacyMode schemas.\n *\n * Use this instead of `withDefaults` to add the fields\n * and behaviors necessary to support Model-Like capabilities.\n *\n * ```ts\n * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';\n *\n * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * ]\n * });\n * ```\n */\nexport function withRestoredDeprecatedModelRequestBehaviors(\n schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>\n): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n options: { suppressDeprecation: true },\n });\n });\n schema.fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return schema as LegacyResourceSchema;\n}\n\n/**\n * A function which registers the necessary derivations to support\n * the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by {@link withDefaults} or\n * {@link withRestoredDeprecatedModelRequestBehaviors}.\n *\n * @param schema The schema service to register the derivations with.\n * @public\n */\nexport function registerDerivations(schema: SchemaService): void {\n schema.registerDerivation(legacySupport);\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n schema._registerMode('@legacy', {\n belongsTo: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getBelongsTo(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) {\n assertPrivateStore(store);\n store._join(() => {\n // FIXME field.name here should likely be field.sourceKey || field.name\n lookupLegacySupport(record as unknown as MinimalLegacyRecord).setDirtyBelongsTo(field.name, value);\n });\n },\n },\n hasMany: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getHasMany(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown[]) {\n assertPrivateStore(store);\n store._join(() => {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support.getManyArray(field.name);\n\n manyArray.splice(0, manyArray.length, ...value);\n });\n },\n notify(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField): boolean {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support && support._manyArrayCache[field.name];\n const hasPromise = support && (support._relationshipPromisesCache[field.name] as Promise<unknown> | undefined);\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return false;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n return true;\n }\n\n return false;\n },\n },\n });\n\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension!({\n name: 'deprecated-model-behaviors',\n kind: 'object',\n features: {\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n get isReloading() {\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 // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-return\n return this._isReloading;\n },\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n this._isReloading = v;\n },\n },\n });\n}\n\n/**\n * A class which provides a schema service that delegates between\n * a primary schema service and one that supports legacy model\n * classes as its schema source.\n *\n * When the primary schema service has a schema for the given\n * resource, it will be used. Otherwise, the fallback schema\n * service will be used.\n *\n * This can be used when incrementally migrating from Models to\n * ReactiveResources by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';\n * import { SchemaService } from '@warp-drive/core/reactive';\n *\n * class AppStore extends Store {\n * createSchemaService() {\n * const schema = new SchemaService();\n * return new DelegatingSchemaService(this, schema);\n * }\n * }\n * ```\n *\n * All calls to register resources, derivations, transformations, hash functions\n * etc. will be delegated to the primary schema service.\n *\n * @class DelegatingSchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n attributesDefinitionFor?(resource: ResourceKey | { type: string }): AttributesSchema;\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n relationshipsDefinitionFor?(resource: ResourceKey | { type: string }): RelationshipsSchema;\n /**\n * Whether either the primary or fallback schema service has a schema\n * for the given type.\n */\n doesTypeExist?(type: string): boolean;\n}\n/**\n * See the {@link DelegatingSchemaService | class documentation above} for usage.\n */\nexport class DelegatingSchemaService implements SchemaService {\n /** @internal */\n _preferred!: SchemaService;\n /** @internal */\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n /**\n * Whether the given resource's schema is being served by the fallback\n * (legacy Model-derived) schema service rather than the primary one.\n */\n isDelegated(resource: ResourceKey | { type: string }): boolean {\n return !this._preferred.hasResource(resource) && this._secondary.hasResource(resource);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: ResourceKey | { type: string }): boolean {\n return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);\n }\n hasTrait(type: string): boolean {\n if (this._preferred.hasResource({ type })) {\n return this._preferred.hasTrait(type);\n }\n return this._secondary.hasTrait(type);\n }\n resourceHasTrait(resource: ResourceKey | { type: string }, trait: string): boolean {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resourceHasTrait(resource, trait);\n }\n return this._secondary.resourceHasTrait(resource, trait);\n }\n fields(resource: ResourceKey | { type: string }): Map<string, FieldSchema> {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.fields(resource);\n }\n return this._secondary.fields(resource);\n }\n cacheFields?(resource: { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n if (this._preferred.hasResource?.(resource)) {\n // @ts-expect-error\n return this._preferred.cacheFields?.(resource);\n }\n\n // @ts-expect-error\n return this._secondary.cacheFields?.(resource);\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n return this._preferred.transformation(field);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n return this._preferred.hashFn(field);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n return this._preferred.derivation(field);\n }\n resource(resource: ResourceKey | { type: string }): ResourceSchema | ObjectSchema {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resource(resource);\n }\n return this._secondary.resource(resource);\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n this._preferred.registerResources(schemas);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n this._preferred.registerResource(schema);\n }\n registerTransformation(transform: Transformation): void {\n this._preferred.registerTransformation(transform);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n this._preferred.registerDerivation(derivation);\n }\n registerHashFn(hashFn: HashFn): void {\n this._preferred.registerHashFn(hashFn);\n }\n\n CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: { kind: 'object' | 'array'; name: string }): boolean {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension!(ext);\n }\n\n CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void {\n this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension!(extension);\n }\n\n CAUTION_MEGA_DANGER_ZONE_resourceExtensions(\n resource: ResourceKey | { type: string }\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions!(resource);\n }\n\n CAUTION_MEGA_DANGER_ZONE_objectExtensions(\n field: ExtensibleField,\n resolvedType: string | null\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions!(field, resolvedType);\n }\n\n CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions!(field);\n }\n\n /**\n * This is an internal method used to register behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _registerMode(mode: string, kinds: unknown): void {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n this._preferred._registerMode(mode, kinds);\n }\n\n /**\n * This is an internal method used to enable legacy behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _kind(mode: string, kind: 'belongsTo' | 'hasMany'): () => unknown {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return this._preferred._kind(mode, kind) as () => unknown;\n }\n}\n\n/**\n * @internal\n */\nexport interface PrivateDelegatingSchemaService extends DelegatingSchemaService {\n _preferred: SchemaService;\n _secondary: SchemaService;\n}\nfunction assertPrivate(service: DelegatingSchemaService): asserts service is PrivateDelegatingSchemaService {}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.attributesDefinitionFor!(resource);\n }\n\n return this._secondary.attributesDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.relationshipsDefinitionFor!(resource);\n }\n\n return this._secondary.relationshipsDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.doesTypeExist = function (type: string) {\n assertPrivate(this);\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuIA,MAAMwB,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8ChB,MAAMC,gBAAgBrB,eAAe,iCAAiB,IAAIsB,QAAsD,CAAC;AAEj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CkC,WAAqD;EAC9F,KAAK1B,WAAWR,2CAA4CkC,SAAS;CACvE;CAEAC,4CACEvB,UACuC;EACvC,OAAO,KAAKJ,WAAW2B,4CAA6CvB,QAAQ;CAC9E;CAEAwB,0CACE9D,OACA+D,cACuC;EACvC,OAAO,KAAK7B,WAAW4B,0CAA2C9D,OAAO+D,YAAY;CACvF;CAEAC,yCAAyChE,OAA+D;EACtG,OAAO,KAAKkC,WAAW8B,yCAA0ChE,KAAK;CACxE;;;;;;;;;;;;CAaAQ,cAAcyD,MAAcC,OAAsB;EAGhD,KAAKhC,WAAW1B,cAAcyD,MAAMC,KAAK;CAC3C;;;;;;;;;;;;CAaAC,MAAMF,MAAcnE,MAA8C;EAGhE,OAAO,KAAKoC,WAAWiC,MAAMF,MAAMnE,IAAI;CACzC;AACF;AAYEmC,wBAAwBqC,UAAUC,0BAA0B,SAAUjC,UAA0C;CAE9G,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWqC,wBAAyBjC,QAAQ;CAG1D,OAAO,KAAKH,WAAWoC,wBAAyBjC,QAAQ;AAC1D;AACAL,wBAAwBqC,UAAUE,6BAA6B,SAAUlC,UAA0C;CAEjH,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWsC,2BAA4BlC,QAAQ;CAG7D,OAAO,KAAKH,WAAWqC,2BAA4BlC,QAAQ;AAC7D;AACAL,wBAAwBqC,UAAUG,gBAAgB,SAAU/F,MAAc;CAExE,OAAO,KAAKwD,WAAWuC,gBAAgB/F,IAAI,KAAK,KAAKyD,WAAWsC,gBAAgB/F,IAAI,KAAK;AAC3F"}
1
+ {"version":3,"file":"migration-support.js","names":["recordIdentifierFor","Context","notifyInternalSignal","assertPrivateStore","getOrSetGlobal","Type","Errors","lookupLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","RecordState","buildSchema","LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","suppressDeprecation","Boolean","currentState","adapterError","_constructor","isModel","name","type","modelName","recordState","dirtyType","errors","create","__record","isDirty","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","objectExtensions","withRestoredDeprecatedModelRequestBehaviors","registerDerivations","registerDerivation","_registerMode","store","cacheKey","getBelongsTo","value","_join","setDirtyBelongsTo","getHasMany","support","manyArray","getManyArray","splice","length","notify","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","CAUTION_MEGA_DANGER_ZONE_registerExtension","features","isReloading","console","warn","_isReloading","v","DelegatingSchemaService","_preferred","_secondary","constructor","isDelegated","resource","hasResource","resourceTypes","Array","from","Set","concat","hasTrait","resourceHasTrait","trait","cacheFields","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","CAUTION_MEGA_DANGER_ZONE_hasExtension","ext","extension","CAUTION_MEGA_DANGER_ZONE_resourceExtensions","CAUTION_MEGA_DANGER_ZONE_objectExtensions","resolvedType","CAUTION_MEGA_DANGER_ZONE_arrayExtensions","mode","kinds","_kind","assertPrivate","service","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"sources":["../../../../src/model/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @warp-drive/legacy/model\n * to ReactiveResource from @warp-drive/core/reactive.\n *\n * It includes:\n *\n * - A `withDefaults` function to assist in creating a schema in LegacyMode\n * - A `registerDerivations` function to register the derivations necessary to support LegacyMode\n * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both\n * @warp-drive/legacy/model and @warp-drive/core/reactive simultaneously for migration purposes.\n * - A `WithLegacy` type util that can be used to create a type that includes the legacy\n * properties and methods of a record.\n *\n * Using LegacyMode features on a ReactiveResource *requires* the use of these derivations and schema\n * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone\n * to assist in more rapidly adopting modern WarpDrive features.\n *\n * @summary Legacy helpers for migrating from `Model` to `ReactiveResource`: LegacyMode schema defaults, derivations,\n * types, and a schema service that serves both at once.\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } 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 { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from '@warp-drive/core/reactive';\nimport type { ExtensibleField } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { ObjectValue } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core/types/schema/concepts';\nimport type {\n ArrayField,\n CacheableFieldSchema,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n IdentityField,\n LegacyBelongsToField,\n LegacyHasManyField,\n LegacyResourceSchema,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core/types/schema/fields';\nimport { Type } from '@warp-drive/core/types/symbols';\nimport type { WithPartial } from '@warp-drive/core/types/utils';\n\nimport type { Snapshot } from '../compat/-private.ts';\nimport { Errors, lookupLegacySupport } from './-private.ts';\nimport type { MinimalLegacyRecord } from './-private/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 './-private/model-methods.ts';\nimport RecordState from './-private/record-state.ts';\nimport type BelongsToReference from './-private/references/belongs-to.ts';\nimport type HasManyReference from './-private/references/has-many.ts';\nimport { buildSchema } from './-private/schema-provider.ts';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils.ts';\n\n/**\n * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a\n * {@link TypedRecordInstance}, for use when migrating a resource from\n * `Model` to a schema-based record while preserving these APIs.\n *\n * @summary Legacy type that adds the `Model`-style `belongsTo` and `hasMany` reference methods to a typed record\n * migrating from `Model` to a schema-based record.\n */\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n /**\n * see {@link belongsTo}\n */\n belongsTo: typeof belongsTo;\n /**\n * see {@link hasMany}\n */\n hasMany: typeof hasMany;\n };\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ninterface LegacyModeRecord<T extends TypedRecordInstance> {\n id: string | null;\n\n serialize(options?: Record<string, unknown>): unknown;\n destroyRecord(options?: Record<string, unknown>): Promise<this>;\n unloadRecord(): void;\n changedAttributes(): ChangedAttributesHash;\n rollbackAttributes(): void;\n _createSnapshot(): Snapshot<T>;\n save(options?: Record<string, unknown>): Promise<this>;\n reload(options?: Record<string, unknown>): Promise<T>;\n belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;\n hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;\n deleteRecord(): void;\n\n adapterError: unknown;\n constructor: { modelName: TypeFromInstance<T> };\n currentState: RecordState;\n dirtyType: 'deleted' | 'created' | 'updated' | '';\n errors: unknown;\n hasDirtyAttributes: boolean;\n isDeleted: boolean;\n isEmpty: boolean;\n isError: boolean;\n isLoaded: boolean;\n isLoading: boolean;\n isDestroying: boolean;\n isDestroyed: boolean;\n isNew: boolean;\n isSaving: boolean;\n isValid: boolean;\n}\n\n// 'isDestroying', 'isDestroyed'\nconst LegacyFields = [\n '_createSnapshot',\n 'adapterError',\n 'belongsTo',\n 'changedAttributes',\n 'constructor',\n 'currentState',\n 'deleteRecord',\n 'destroyRecord',\n 'dirtyType',\n 'errors',\n 'hasDirtyAttributes',\n 'hasMany',\n 'isDeleted',\n 'isEmpty',\n 'isError',\n 'isLoaded',\n 'isLoading',\n 'isNew',\n 'isSaving',\n 'isValid',\n 'reload',\n 'rollbackAttributes',\n 'save',\n 'serialize',\n 'unloadRecord',\n] as const;\n\n/**\n * A Type utility that enables quickly adding type information for the fields\n * defined by `import { withDefaults } from '@warp-drive/legacy/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * @summary Legacy type that adds the `Model`-style state flags and methods (`save`, `isNew`, `errors`, etc.) that\n * `withDefaults` provides to a LegacyMode record type.\n */\nexport type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;\n\nconst LegacySupport = getOrSetGlobal('LegacySupport', new WeakMap<MinimalLegacyRecord, Record<string, unknown>>());\n\nfunction legacySupport(record: MinimalLegacyRecord, options: ObjectValue | null, prop: string): unknown {\n let state = LegacySupport.get(record);\n if (!state) {\n state = {};\n LegacySupport.set(record, state);\n }\n const suppressDeprecation = Boolean(options && options.suppressDeprecation);\n\n switch (prop) {\n case '_createSnapshot':\n // FIXME should be deprecated too?\n return createSnapshot;\n case 'adapterError':\n // FIXME should be deprecated too?\n return record.currentState.adapterError;\n case 'belongsTo':\n return belongsTo;\n case 'changedAttributes':\n return changedAttributes;\n case 'constructor':\n return (state._constructor = state._constructor || {\n isModel: true,\n name: `Record<${recordIdentifierFor(record).type}>`,\n modelName: recordIdentifierFor(record).type,\n });\n case 'currentState':\n return (state.recordState = state.recordState || new RecordState(record));\n case 'deleteRecord':\n return deleteRecord;\n case 'destroyRecord':\n return suppressDeprecation ? _destroyRecord : destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // FIXME should be deprecated too?\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return (state.errors = state.errors || Errors.create({ __record: record }));\n case 'hasDirtyAttributes':\n return record.currentState.isDirty;\n case 'hasMany':\n return hasMany;\n case 'isDeleted':\n return record.currentState.isDeleted;\n case 'isEmpty':\n return record.currentState.isEmpty;\n case 'isError':\n return record.currentState.isError;\n case 'isLoaded':\n return record.currentState.isLoaded;\n case 'isLoading':\n return record.currentState.isLoading;\n case 'isNew':\n return record.currentState.isNew;\n case 'isSaving':\n return record.currentState.isSaving;\n case 'isValid':\n return record.currentState.isValid;\n case 'reload':\n return suppressDeprecation ? _reload : reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return suppressDeprecation ? _save : save;\n case 'serialize':\n // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)\n return serialize;\n case 'unloadRecord':\n return unloadRecord;\n default:\n assert(`${prop} is not a supported legacy field`, false);\n }\n}\nlegacySupport[Type] = '@legacy';\n\n/**\n * A function which adds the necessary fields to a schema and marks it as\n * being in LegacyMode. This is used to support the legacy features of\n * @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * Using this function require registering the derivations\n * it requires with the schema service.\n *\n * ```ts\n * import { registerDerivations } from '@warp-drive/legacy/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @summary Legacy helper that marks a resource schema as LegacyMode and adds the fields that give its records\n * `Model`-like state and methods.\n * @param schema The schema to add legacy support to.\n * @return The schema with legacy support added.\n * @public\n */\nexport function withDefaults(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n schema.fields.push({\n name: '_isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.objectExtensions = schema.objectExtensions || [];\n schema.objectExtensions.push('deprecated-model-behaviors');\n return schema as LegacyResourceSchema;\n}\n\n/**\n * Adds the necessasary fields to the schema for supporting\n * the deprecated request methods on LegacyMode schemas.\n *\n * Use this instead of `withDefaults` to add the fields\n * and behaviors necessary to support Model-Like capabilities.\n *\n * ```ts\n * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';\n *\n * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * ]\n * });\n * ```\n *\n * @summary Legacy alternative to `withDefaults` that makes a LegacyMode schema whose `save`, `reload`, and\n * `destroyRecord` run without deprecation warnings.\n */\nexport function withRestoredDeprecatedModelRequestBehaviors(\n schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>\n): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n options: { suppressDeprecation: true },\n });\n });\n schema.fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return schema as LegacyResourceSchema;\n}\n\n/**\n * A function which registers the necessary derivations to support\n * the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by {@link withDefaults} or\n * {@link withRestoredDeprecatedModelRequestBehaviors}.\n *\n * @summary Legacy setup that registers the derivation, relationship behaviors, and extension a schema service needs to\n * support LegacyMode records.\n * @param schema The schema service to register the derivations with.\n * @public\n */\nexport function registerDerivations(schema: SchemaService): void {\n schema.registerDerivation(legacySupport);\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n schema._registerMode('@legacy', {\n belongsTo: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getBelongsTo(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) {\n assertPrivateStore(store);\n store._join(() => {\n // FIXME field.name here should likely be field.sourceKey || field.name\n lookupLegacySupport(record as unknown as MinimalLegacyRecord).setDirtyBelongsTo(field.name, value);\n });\n },\n },\n hasMany: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getHasMany(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown[]) {\n assertPrivateStore(store);\n store._join(() => {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support.getManyArray(field.name);\n\n manyArray.splice(0, manyArray.length, ...value);\n });\n },\n notify(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField): boolean {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support && support._manyArrayCache[field.name];\n const hasPromise = support && (support._relationshipPromisesCache[field.name] as Promise<unknown> | undefined);\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return false;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n return true;\n }\n\n return false;\n },\n },\n });\n\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension!({\n name: 'deprecated-model-behaviors',\n kind: 'object',\n features: {\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n get isReloading() {\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://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 // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-return\n return this._isReloading;\n },\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n this._isReloading = v;\n },\n },\n });\n}\n\n/**\n * A class which provides a schema service that delegates between\n * a primary schema service and one that supports legacy model\n * classes as its schema source.\n *\n * When the primary schema service has a schema for the given\n * resource, it will be used. Otherwise, the fallback schema\n * service will be used.\n *\n * This can be used when incrementally migrating from Models to\n * ReactiveResources by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';\n * import { SchemaService } from '@warp-drive/core/reactive';\n *\n * class AppStore extends Store {\n * createSchemaService() {\n * const schema = new SchemaService();\n * return new DelegatingSchemaService(this, schema);\n * }\n * }\n * ```\n *\n * All calls to register resources, derivations, transformations, hash functions\n * etc. will be delegated to the primary schema service.\n *\n * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n * @class DelegatingSchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n attributesDefinitionFor?(resource: ResourceKey | { type: string }): AttributesSchema;\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n relationshipsDefinitionFor?(resource: ResourceKey | { type: string }): RelationshipsSchema;\n /**\n * Whether either the primary or fallback schema service has a schema\n * for the given type.\n */\n doesTypeExist?(type: string): boolean;\n}\n/**\n * See the {@link DelegatingSchemaService | class documentation above} for usage.\n * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n */\nexport class DelegatingSchemaService implements SchemaService {\n /** @internal */\n _preferred!: SchemaService;\n /** @internal */\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n /**\n * Whether the given resource's schema is being served by the fallback\n * (legacy Model-derived) schema service rather than the primary one.\n */\n isDelegated(resource: ResourceKey | { type: string }): boolean {\n return !this._preferred.hasResource(resource) && this._secondary.hasResource(resource);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: ResourceKey | { type: string }): boolean {\n return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);\n }\n hasTrait(type: string): boolean {\n if (this._preferred.hasResource({ type })) {\n return this._preferred.hasTrait(type);\n }\n return this._secondary.hasTrait(type);\n }\n resourceHasTrait(resource: ResourceKey | { type: string }, trait: string): boolean {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resourceHasTrait(resource, trait);\n }\n return this._secondary.resourceHasTrait(resource, trait);\n }\n fields(resource: ResourceKey | { type: string }): Map<string, FieldSchema> {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.fields(resource);\n }\n return this._secondary.fields(resource);\n }\n cacheFields?(resource: { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n if (this._preferred.hasResource?.(resource)) {\n // @ts-expect-error\n return this._preferred.cacheFields?.(resource);\n }\n\n // @ts-expect-error\n return this._secondary.cacheFields?.(resource);\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n return this._preferred.transformation(field);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n return this._preferred.hashFn(field);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n return this._preferred.derivation(field);\n }\n resource(resource: ResourceKey | { type: string }): ResourceSchema | ObjectSchema {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resource(resource);\n }\n return this._secondary.resource(resource);\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n this._preferred.registerResources(schemas);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n this._preferred.registerResource(schema);\n }\n registerTransformation(transform: Transformation): void {\n this._preferred.registerTransformation(transform);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n this._preferred.registerDerivation(derivation);\n }\n registerHashFn(hashFn: HashFn): void {\n this._preferred.registerHashFn(hashFn);\n }\n\n CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: { kind: 'object' | 'array'; name: string }): boolean {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension!(ext);\n }\n\n CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void {\n this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension!(extension);\n }\n\n CAUTION_MEGA_DANGER_ZONE_resourceExtensions(\n resource: ResourceKey | { type: string }\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions!(resource);\n }\n\n CAUTION_MEGA_DANGER_ZONE_objectExtensions(\n field: ExtensibleField,\n resolvedType: string | null\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions!(field, resolvedType);\n }\n\n CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions!(field);\n }\n\n /**\n * This is an internal method used to register behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _registerMode(mode: string, kinds: unknown): void {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n this._preferred._registerMode(mode, kinds);\n }\n\n /**\n * This is an internal method used to enable legacy behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _kind(mode: string, kind: 'belongsTo' | 'hasMany'): () => unknown {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return this._preferred._kind(mode, kind) as () => unknown;\n }\n}\n\n/**\n * @internal\n */\nexport interface PrivateDelegatingSchemaService extends DelegatingSchemaService {\n _preferred: SchemaService;\n _secondary: SchemaService;\n}\nfunction assertPrivate(service: DelegatingSchemaService): asserts service is PrivateDelegatingSchemaService {}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.attributesDefinitionFor!(resource);\n }\n\n return this._secondary.attributesDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.relationshipsDefinitionFor!(resource);\n }\n\n return this._secondary.relationshipsDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.doesTypeExist = function (type: string) {\n assertPrivate(this);\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,MAAMwB,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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