@warp-drive/legacy 5.9.0-alpha.21 → 5.9.0-alpha.22

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 (467) hide show
  1. package/dist/-private-DQ6Iap2t.js +193 -0
  2. package/dist/-private-DQ6Iap2t.js.map +1 -0
  3. package/dist/-private-DccRZQsm.js +904 -0
  4. package/dist/-private-DccRZQsm.js.map +1 -0
  5. package/dist/adapter/-private.d.ts +33 -0
  6. package/dist/adapter/-private.d.ts.map +1 -0
  7. package/dist/adapter/-private.js +3 -1
  8. package/dist/adapter/error.d.ts +2 -0
  9. package/dist/adapter/error.js +422 -453
  10. package/dist/adapter/error.js.map +1 -0
  11. package/{declarations → dist}/adapter/json-api.d.ts +30 -29
  12. package/dist/adapter/json-api.d.ts.map +1 -0
  13. package/dist/adapter/json-api.js +265 -143
  14. package/dist/adapter/json-api.js.map +1 -0
  15. package/dist/adapter/rest.d.ts +2 -0
  16. package/dist/adapter/rest.js +937 -1136
  17. package/dist/adapter/rest.js.map +1 -0
  18. package/dist/adapter-CARrK3-8.d.ts +784 -0
  19. package/dist/adapter-CARrK3-8.d.ts.map +1 -0
  20. package/dist/adapter-XgLAkYVs.js +1130 -0
  21. package/dist/adapter-XgLAkYVs.js.map +1 -0
  22. package/dist/adapter.d.ts +2 -0
  23. package/dist/adapter.js +1 -1248
  24. package/dist/compat/-private.d.ts +2 -0
  25. package/dist/compat/-private.js +3 -1
  26. package/dist/compat/builders.d.ts +169 -0
  27. package/dist/compat/builders.d.ts.map +1 -0
  28. package/dist/compat/builders.js +205 -245
  29. package/dist/compat/builders.js.map +1 -0
  30. package/dist/compat/extensions.d.ts +2 -0
  31. package/dist/compat/extensions.js +265 -304
  32. package/dist/compat/extensions.js.map +1 -0
  33. package/dist/compat/utils.d.ts +151 -0
  34. package/dist/compat/utils.d.ts.map +1 -0
  35. package/dist/compat/utils.js +187 -206
  36. package/dist/compat/utils.js.map +1 -0
  37. package/dist/compat-BbNNmTM-.d.ts +1386 -0
  38. package/dist/compat-BbNNmTM-.d.ts.map +1 -0
  39. package/dist/compat-g__Pfy2S.js +734 -0
  40. package/dist/compat-g__Pfy2S.js.map +1 -0
  41. package/dist/compat.d.ts +2 -0
  42. package/dist/compat.js +1 -1036
  43. package/dist/error-CzkyXr1Q.d.ts +435 -0
  44. package/dist/error-CzkyXr1Q.d.ts.map +1 -0
  45. package/dist/errors-LQhmDVdd.js +2134 -0
  46. package/dist/errors-LQhmDVdd.js.map +1 -0
  47. package/dist/extensions-DumNm4dA.d.ts +102 -0
  48. package/dist/extensions-DumNm4dA.d.ts.map +1 -0
  49. package/dist/index.d.ts +243 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +267 -339
  52. package/dist/index.js.map +1 -0
  53. package/dist/json-BXNPTlcH.js +1106 -0
  54. package/dist/json-BXNPTlcH.js.map +1 -0
  55. package/dist/model/-private.d.ts +3 -0
  56. package/dist/model/-private.js +3 -1
  57. package/dist/model/migration-support.d.ts +335 -0
  58. package/dist/model/migration-support.d.ts.map +1 -0
  59. package/dist/model/migration-support.js +504 -575
  60. package/dist/model/migration-support.js.map +1 -0
  61. package/dist/model-62hn5_PD.d.ts +3107 -0
  62. package/dist/model-62hn5_PD.d.ts.map +1 -0
  63. package/dist/model-BtIEHqYZ.js +683 -0
  64. package/dist/model-BtIEHqYZ.js.map +1 -0
  65. package/dist/model-fragments-Dpn9285r.js +334 -0
  66. package/dist/model-fragments-Dpn9285r.js.map +1 -0
  67. package/dist/model-fragments.d.ts +294 -0
  68. package/dist/model-fragments.d.ts.map +1 -0
  69. package/dist/model-fragments.js +2 -94
  70. package/dist/model.d.ts +404 -0
  71. package/dist/model.d.ts.map +1 -0
  72. package/dist/model.js +3 -670
  73. package/{declarations/adapter/rest.d.ts → dist/rest-0NhtexIq.d.ts} +183 -173
  74. package/dist/rest-0NhtexIq.d.ts.map +1 -0
  75. package/dist/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
  76. package/dist/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
  77. package/dist/schema-provider-DsKuB5Wb.js +1929 -0
  78. package/dist/schema-provider-DsKuB5Wb.js.map +1 -0
  79. package/{declarations → dist}/serializer/json-api.d.ts +3 -0
  80. package/dist/serializer/json-api.d.ts.map +1 -0
  81. package/dist/serializer/json-api.js +527 -519
  82. package/dist/serializer/json-api.js.map +1 -0
  83. package/{declarations → dist}/serializer/json.d.ts +3 -0
  84. package/dist/serializer/json.d.ts.map +1 -0
  85. package/dist/serializer/json.js +3 -6
  86. package/{declarations/serializer/-private/embedded-records-mixin.d.ts → dist/serializer/rest.d.ts} +56 -1
  87. package/dist/serializer/rest.d.ts.map +1 -0
  88. package/dist/serializer/rest.js +958 -1199
  89. package/dist/serializer/rest.js.map +1 -0
  90. package/dist/serializer/transform.d.ts +313 -0
  91. package/dist/serializer/transform.d.ts.map +1 -0
  92. package/dist/serializer/transform.js +283 -308
  93. package/dist/serializer/transform.js.map +1 -0
  94. package/dist/serializer.d.ts +151 -0
  95. package/dist/serializer.d.ts.map +1 -0
  96. package/dist/serializer.js +205 -205
  97. package/dist/serializer.js.map +1 -0
  98. package/dist/store-C4qYzXei.js +473 -0
  99. package/dist/store-C4qYzXei.js.map +1 -0
  100. package/dist/store.d.ts +13 -0
  101. package/dist/store.d.ts.map +1 -0
  102. package/dist/store.js +1 -641
  103. package/dist/unpkg/dev/-private-CrEyBE-B.js +189 -0
  104. package/dist/unpkg/dev/-private-CrEyBE-B.js.map +1 -0
  105. package/dist/unpkg/dev/-private-vOhxVExH.js +896 -0
  106. package/dist/unpkg/dev/-private-vOhxVExH.js.map +1 -0
  107. package/dist/unpkg/dev/adapter/-private.js +3 -1
  108. package/dist/unpkg/dev/adapter/error.js +421 -452
  109. package/dist/unpkg/dev/adapter/error.js.map +1 -0
  110. package/dist/unpkg/dev/adapter/json-api.js +239 -257
  111. package/dist/unpkg/dev/adapter/json-api.js.map +1 -0
  112. package/dist/unpkg/dev/adapter/rest.js +935 -1134
  113. package/dist/unpkg/dev/adapter/rest.js.map +1 -0
  114. package/dist/unpkg/dev/adapter-Cw0uSl8d.js +1129 -0
  115. package/dist/unpkg/dev/adapter-Cw0uSl8d.js.map +1 -0
  116. package/dist/unpkg/dev/adapter.js +1 -1247
  117. package/dist/unpkg/dev/compat/-private.js +3 -1
  118. package/dist/unpkg/dev/compat/builders.js +204 -247
  119. package/dist/unpkg/dev/compat/builders.js.map +1 -0
  120. package/dist/unpkg/dev/compat/extensions.js +264 -303
  121. package/dist/unpkg/dev/compat/extensions.js.map +1 -0
  122. package/dist/unpkg/dev/compat/utils.js +186 -205
  123. package/dist/unpkg/dev/compat/utils.js.map +1 -0
  124. package/dist/unpkg/dev/compat-CeyxXB7K.js +825 -0
  125. package/dist/unpkg/dev/compat-CeyxXB7K.js.map +1 -0
  126. package/dist/unpkg/dev/compat.js +1 -1178
  127. package/dist/unpkg/dev/errors-1javxsPo.js +2127 -0
  128. package/dist/unpkg/dev/errors-1javxsPo.js.map +1 -0
  129. package/dist/unpkg/dev/index.js +266 -344
  130. package/dist/unpkg/dev/index.js.map +1 -0
  131. package/dist/unpkg/dev/json-DDJji3V3.js +1104 -0
  132. package/dist/unpkg/dev/json-DDJji3V3.js.map +1 -0
  133. package/dist/unpkg/dev/model/-private.js +3 -1
  134. package/dist/unpkg/dev/model/migration-support.js +481 -549
  135. package/dist/unpkg/dev/model/migration-support.js.map +1 -0
  136. package/dist/unpkg/dev/model-C9Xb1R1x.js +655 -0
  137. package/dist/unpkg/dev/model-C9Xb1R1x.js.map +1 -0
  138. package/dist/unpkg/dev/model-fragments-Dpn9285r.js +334 -0
  139. package/dist/unpkg/dev/model-fragments-Dpn9285r.js.map +1 -0
  140. package/dist/unpkg/dev/model-fragments.js +2 -94
  141. package/dist/unpkg/dev/model.js +3 -681
  142. package/dist/unpkg/dev/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
  143. package/dist/unpkg/dev/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
  144. package/dist/unpkg/dev/schema-provider-Dy6c1J5f.js +1834 -0
  145. package/dist/unpkg/dev/schema-provider-Dy6c1J5f.js.map +1 -0
  146. package/dist/unpkg/dev/serializer/json-api.js +514 -634
  147. package/dist/unpkg/dev/serializer/json-api.js.map +1 -0
  148. package/dist/unpkg/dev/serializer/json.js +3 -4
  149. package/dist/unpkg/dev/serializer/rest.js +954 -1196
  150. package/dist/unpkg/dev/serializer/rest.js.map +1 -0
  151. package/dist/unpkg/dev/serializer/transform.js +283 -308
  152. package/dist/unpkg/dev/serializer/transform.js.map +1 -0
  153. package/dist/unpkg/dev/serializer.js +205 -205
  154. package/dist/unpkg/dev/serializer.js.map +1 -0
  155. package/dist/unpkg/dev/store-D_V8-HQl.js +472 -0
  156. package/dist/unpkg/dev/store-D_V8-HQl.js.map +1 -0
  157. package/dist/unpkg/dev/store.js +1 -649
  158. package/dist/unpkg/dev/util-dSKEgQDp.js +12 -0
  159. package/dist/unpkg/dev/util-dSKEgQDp.js.map +1 -0
  160. package/dist/unpkg/dev/utils-DYC9utVJ.js +11 -0
  161. package/dist/unpkg/dev/utils-DYC9utVJ.js.map +1 -0
  162. package/dist/unpkg/dev-deprecated/-private-CrEyBE-B.js +189 -0
  163. package/dist/unpkg/dev-deprecated/-private-CrEyBE-B.js.map +1 -0
  164. package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js +896 -0
  165. package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js.map +1 -0
  166. package/dist/unpkg/dev-deprecated/adapter/-private.js +3 -1
  167. package/dist/unpkg/dev-deprecated/adapter/error.js +421 -452
  168. package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -0
  169. package/dist/unpkg/dev-deprecated/adapter/json-api.js +239 -257
  170. package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -0
  171. package/dist/unpkg/dev-deprecated/adapter/rest.js +935 -1134
  172. package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -0
  173. package/dist/unpkg/dev-deprecated/adapter-Cw0uSl8d.js +1129 -0
  174. package/dist/unpkg/dev-deprecated/adapter-Cw0uSl8d.js.map +1 -0
  175. package/dist/unpkg/dev-deprecated/adapter.js +1 -1247
  176. package/dist/unpkg/dev-deprecated/compat/-private.js +3 -1
  177. package/dist/unpkg/dev-deprecated/compat/builders.js +204 -247
  178. package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -0
  179. package/dist/unpkg/dev-deprecated/compat/extensions.js +264 -303
  180. package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -0
  181. package/dist/unpkg/dev-deprecated/compat/utils.js +186 -205
  182. package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -0
  183. package/dist/unpkg/dev-deprecated/compat-DmAgB2NS.js +825 -0
  184. package/dist/unpkg/dev-deprecated/compat-DmAgB2NS.js.map +1 -0
  185. package/dist/unpkg/dev-deprecated/compat.js +1 -1178
  186. package/dist/unpkg/dev-deprecated/errors-C4_aOhY5.js +2128 -0
  187. package/dist/unpkg/dev-deprecated/errors-C4_aOhY5.js.map +1 -0
  188. package/dist/unpkg/dev-deprecated/index.js +266 -343
  189. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  190. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js +1104 -0
  191. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +1 -0
  192. package/dist/unpkg/dev-deprecated/model/-private.js +3 -1
  193. package/dist/unpkg/dev-deprecated/model/migration-support.js +492 -566
  194. package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -0
  195. package/dist/unpkg/dev-deprecated/model-CvSMYkgs.js +660 -0
  196. package/dist/unpkg/dev-deprecated/model-CvSMYkgs.js.map +1 -0
  197. package/dist/unpkg/dev-deprecated/model-fragments-Dpn9285r.js +334 -0
  198. package/dist/unpkg/dev-deprecated/model-fragments-Dpn9285r.js.map +1 -0
  199. package/dist/unpkg/dev-deprecated/model-fragments.js +2 -94
  200. package/dist/unpkg/dev-deprecated/model.js +3 -685
  201. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
  202. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
  203. package/dist/unpkg/dev-deprecated/schema-provider-Cqttza94.js +1835 -0
  204. package/dist/unpkg/dev-deprecated/schema-provider-Cqttza94.js.map +1 -0
  205. package/dist/unpkg/dev-deprecated/serializer/json-api.js +514 -634
  206. package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -0
  207. package/dist/unpkg/dev-deprecated/serializer/json.js +3 -4
  208. package/dist/unpkg/dev-deprecated/serializer/rest.js +954 -1196
  209. package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -0
  210. package/dist/unpkg/dev-deprecated/serializer/transform.js +283 -308
  211. package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -0
  212. package/dist/unpkg/dev-deprecated/serializer.js +205 -205
  213. package/dist/unpkg/dev-deprecated/serializer.js.map +1 -0
  214. package/dist/unpkg/dev-deprecated/store-BX7GvXC_.js +472 -0
  215. package/dist/unpkg/dev-deprecated/store-BX7GvXC_.js.map +1 -0
  216. package/dist/unpkg/dev-deprecated/store.js +1 -649
  217. package/dist/unpkg/dev-deprecated/util-9mgEBJ3W.js +18 -0
  218. package/dist/unpkg/dev-deprecated/util-9mgEBJ3W.js.map +1 -0
  219. package/dist/unpkg/dev-deprecated/utils-Cl86-e7F.js +17 -0
  220. package/dist/unpkg/dev-deprecated/utils-Cl86-e7F.js.map +1 -0
  221. package/dist/unpkg/prod/-private-B4bxoTuK.js +160 -0
  222. package/dist/unpkg/prod/-private-B4bxoTuK.js.map +1 -0
  223. package/dist/unpkg/prod/-private-SfXkkHKd.js +745 -0
  224. package/dist/unpkg/prod/-private-SfXkkHKd.js.map +1 -0
  225. package/dist/unpkg/prod/adapter/-private.js +3 -1
  226. package/dist/unpkg/prod/adapter/error.js +418 -447
  227. package/dist/unpkg/prod/adapter/error.js.map +1 -0
  228. package/dist/unpkg/prod/adapter/json-api.js +236 -252
  229. package/dist/unpkg/prod/adapter/json-api.js.map +1 -0
  230. package/dist/unpkg/prod/adapter/rest.js +911 -1097
  231. package/dist/unpkg/prod/adapter/rest.js.map +1 -0
  232. package/dist/unpkg/prod/adapter-Wnk7jizX.js +1111 -0
  233. package/dist/unpkg/prod/adapter-Wnk7jizX.js.map +1 -0
  234. package/dist/unpkg/prod/adapter.js +1 -1214
  235. package/dist/unpkg/prod/compat/-private.js +3 -1
  236. package/dist/unpkg/prod/compat/builders.js +165 -182
  237. package/dist/unpkg/prod/compat/builders.js.map +1 -0
  238. package/dist/unpkg/prod/compat/extensions.js +252 -283
  239. package/dist/unpkg/prod/compat/extensions.js.map +1 -0
  240. package/dist/unpkg/prod/compat/utils.js +183 -200
  241. package/dist/unpkg/prod/compat/utils.js.map +1 -0
  242. package/dist/unpkg/prod/compat-CJ87MzDn.js +547 -0
  243. package/dist/unpkg/prod/compat-CJ87MzDn.js.map +1 -0
  244. package/dist/unpkg/prod/compat.js +1 -742
  245. package/dist/unpkg/prod/errors-Co7YWHoA.js +1977 -0
  246. package/dist/unpkg/prod/errors-Co7YWHoA.js.map +1 -0
  247. package/dist/unpkg/prod/index.js +245 -308
  248. package/dist/unpkg/prod/index.js.map +1 -0
  249. package/dist/unpkg/prod/json-BD1kRTfB.js +1080 -0
  250. package/dist/unpkg/prod/json-BD1kRTfB.js.map +1 -0
  251. package/dist/unpkg/prod/model/-private.js +3 -1
  252. package/dist/unpkg/prod/model/migration-support.js +477 -542
  253. package/dist/unpkg/prod/model/migration-support.js.map +1 -0
  254. package/dist/unpkg/prod/model-BzoOmtka.js +603 -0
  255. package/dist/unpkg/prod/model-BzoOmtka.js.map +1 -0
  256. package/dist/unpkg/prod/model-fragments-Dpn9285r.js +334 -0
  257. package/dist/unpkg/prod/model-fragments-Dpn9285r.js.map +1 -0
  258. package/dist/unpkg/prod/model-fragments.js +2 -94
  259. package/dist/unpkg/prod/model.js +3 -596
  260. package/dist/unpkg/prod/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
  261. package/dist/unpkg/prod/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
  262. package/dist/unpkg/prod/schema-provider-CKZcqWyP.js +1622 -0
  263. package/dist/unpkg/prod/schema-provider-CKZcqWyP.js.map +1 -0
  264. package/dist/unpkg/prod/serializer/json-api.js +497 -592
  265. package/dist/unpkg/prod/serializer/json-api.js.map +1 -0
  266. package/dist/unpkg/prod/serializer/json.js +3 -4
  267. package/dist/unpkg/prod/serializer/rest.js +938 -1166
  268. package/dist/unpkg/prod/serializer/rest.js.map +1 -0
  269. package/dist/unpkg/prod/serializer/transform.js +283 -308
  270. package/dist/unpkg/prod/serializer/transform.js.map +1 -0
  271. package/dist/unpkg/prod/serializer.js +205 -205
  272. package/dist/unpkg/prod/serializer.js.map +1 -0
  273. package/dist/unpkg/prod/store-RGGc1ilN.js +392 -0
  274. package/dist/unpkg/prod/store-RGGc1ilN.js.map +1 -0
  275. package/dist/unpkg/prod/store.js +1 -517
  276. package/dist/unpkg/prod/util-dSKEgQDp.js +12 -0
  277. package/dist/unpkg/prod/util-dSKEgQDp.js.map +1 -0
  278. package/dist/unpkg/prod/utils-DYC9utVJ.js +11 -0
  279. package/dist/unpkg/prod/utils-DYC9utVJ.js.map +1 -0
  280. package/dist/unpkg/prod-deprecated/-private-B4bxoTuK.js +160 -0
  281. package/dist/unpkg/prod-deprecated/-private-B4bxoTuK.js.map +1 -0
  282. package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js +745 -0
  283. package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js.map +1 -0
  284. package/dist/unpkg/prod-deprecated/adapter/-private.js +3 -1
  285. package/dist/unpkg/prod-deprecated/adapter/error.js +418 -447
  286. package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -0
  287. package/dist/unpkg/prod-deprecated/adapter/json-api.js +236 -252
  288. package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -0
  289. package/dist/unpkg/prod-deprecated/adapter/rest.js +911 -1097
  290. package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -0
  291. package/{declarations/adapter.d.ts → dist/unpkg/prod-deprecated/adapter-Wnk7jizX.js} +445 -110
  292. package/dist/unpkg/prod-deprecated/adapter-Wnk7jizX.js.map +1 -0
  293. package/dist/unpkg/prod-deprecated/adapter.js +1 -1214
  294. package/dist/unpkg/prod-deprecated/compat/-private.js +3 -1
  295. package/dist/unpkg/prod-deprecated/compat/builders.js +165 -182
  296. package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -0
  297. package/dist/unpkg/prod-deprecated/compat/extensions.js +252 -283
  298. package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -0
  299. package/dist/unpkg/prod-deprecated/compat/utils.js +183 -200
  300. package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -0
  301. package/dist/unpkg/prod-deprecated/compat-CJ87MzDn.js +547 -0
  302. package/dist/unpkg/prod-deprecated/compat-CJ87MzDn.js.map +1 -0
  303. package/dist/unpkg/prod-deprecated/compat.js +1 -742
  304. package/dist/unpkg/prod-deprecated/errors-C-opde61.js +1978 -0
  305. package/dist/unpkg/prod-deprecated/errors-C-opde61.js.map +1 -0
  306. package/dist/unpkg/prod-deprecated/index.js +245 -307
  307. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  308. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js +1080 -0
  309. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +1 -0
  310. package/dist/unpkg/prod-deprecated/model/-private.js +3 -1
  311. package/dist/unpkg/prod-deprecated/model/migration-support.js +488 -559
  312. package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -0
  313. package/dist/unpkg/prod-deprecated/model-C0bTXzGn.js +604 -0
  314. package/dist/unpkg/prod-deprecated/model-C0bTXzGn.js.map +1 -0
  315. package/dist/unpkg/prod-deprecated/model-fragments-Dpn9285r.js +334 -0
  316. package/dist/unpkg/prod-deprecated/model-fragments-Dpn9285r.js.map +1 -0
  317. package/dist/unpkg/prod-deprecated/model-fragments.js +2 -94
  318. package/dist/unpkg/prod-deprecated/model.js +3 -599
  319. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
  320. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
  321. package/dist/unpkg/prod-deprecated/schema-provider-lH3qP5tw.js +1635 -0
  322. package/dist/unpkg/prod-deprecated/schema-provider-lH3qP5tw.js.map +1 -0
  323. package/dist/unpkg/prod-deprecated/serializer/json-api.js +497 -592
  324. package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -0
  325. package/dist/unpkg/prod-deprecated/serializer/json.js +3 -4
  326. package/dist/unpkg/prod-deprecated/serializer/rest.js +938 -1166
  327. package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -0
  328. package/dist/unpkg/prod-deprecated/serializer/transform.js +283 -308
  329. package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -0
  330. package/dist/unpkg/prod-deprecated/serializer.js +205 -205
  331. package/dist/unpkg/prod-deprecated/serializer.js.map +1 -0
  332. package/dist/unpkg/prod-deprecated/store-0L2CkYzh.js +392 -0
  333. package/dist/unpkg/prod-deprecated/store-0L2CkYzh.js.map +1 -0
  334. package/dist/unpkg/prod-deprecated/store.js +1 -517
  335. package/dist/unpkg/prod-deprecated/util-CQQdHX3n.js +14 -0
  336. package/dist/unpkg/prod-deprecated/util-CQQdHX3n.js.map +1 -0
  337. package/dist/unpkg/prod-deprecated/utils-BMI_JwFP.js +13 -0
  338. package/dist/unpkg/prod-deprecated/utils-BMI_JwFP.js.map +1 -0
  339. package/dist/util-Bnx8nm-D.js +29 -0
  340. package/dist/util-Bnx8nm-D.js.map +1 -0
  341. package/dist/utils-ZAytYep8.js +28 -0
  342. package/dist/utils-ZAytYep8.js.map +1 -0
  343. package/package.json +13 -13
  344. package/declarations/adapter/-private/build-url-mixin.d.ts +0 -189
  345. package/declarations/adapter/-private/fastboot-interface.d.ts +0 -8
  346. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +0 -1
  347. package/declarations/adapter/-private/utils/determine-body-promise.d.ts +0 -4
  348. package/declarations/adapter/-private/utils/fetch.d.ts +0 -8
  349. package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
  350. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +0 -6
  351. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -5
  352. package/declarations/adapter/-private.d.ts +0 -5
  353. package/declarations/adapter/error.d.ts +0 -431
  354. package/declarations/compat/-private.d.ts +0 -13
  355. package/declarations/compat/builders/find-all.d.ts +0 -34
  356. package/declarations/compat/builders/find-record.d.ts +0 -56
  357. package/declarations/compat/builders/query.d.ts +0 -66
  358. package/declarations/compat/builders/save-record.d.ts +0 -34
  359. package/declarations/compat/builders/utils.d.ts +0 -3
  360. package/declarations/compat/builders.d.ts +0 -14
  361. package/declarations/compat/extensions.d.ts +0 -99
  362. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +0 -55
  363. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +0 -2
  364. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +0 -11
  365. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +0 -5
  366. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +0 -9
  367. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +0 -528
  368. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +0 -220
  369. package/declarations/compat/legacy-network-handler/serializer-response.d.ts +0 -6
  370. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +0 -110
  371. package/declarations/compat/legacy-network-handler/snapshot.d.ts +0 -255
  372. package/declarations/compat/utils.d.ts +0 -148
  373. package/declarations/compat.d.ts +0 -189
  374. package/declarations/index.d.ts +0 -244
  375. package/declarations/model/-private/attr.d.ts +0 -191
  376. package/declarations/model/-private/belongs-to.d.ts +0 -195
  377. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +0 -5
  378. package/declarations/model/-private/errors.d.ts +0 -289
  379. package/declarations/model/-private/has-many.d.ts +0 -162
  380. package/declarations/model/-private/hooks.d.ts +0 -36
  381. package/declarations/model/-private/legacy-relationships-support.d.ts +0 -47
  382. package/declarations/model/-private/model-for-mixin.d.ts +0 -3
  383. package/declarations/model/-private/model-methods.d.ts +0 -39
  384. package/declarations/model/-private/model.d.ts +0 -1279
  385. package/declarations/model/-private/notify-changes.d.ts +0 -4
  386. package/declarations/model/-private/promise-belongs-to.d.ts +0 -40
  387. package/declarations/model/-private/promise-many-array.d.ts +0 -130
  388. package/declarations/model/-private/record-state.d.ts +0 -58
  389. package/declarations/model/-private/references/belongs-to.d.ts +0 -488
  390. package/declarations/model/-private/references/has-many.d.ts +0 -498
  391. package/declarations/model/-private/schema-provider.d.ts +0 -66
  392. package/declarations/model/-private/type-utils.d.ts +0 -57
  393. package/declarations/model/-private/util.d.ts +0 -5
  394. package/declarations/model/-private.d.ts +0 -8
  395. package/declarations/model/migration-support.d.ts +0 -306
  396. package/declarations/model-fragments/extensions/fragment-array.d.ts +0 -54
  397. package/declarations/model-fragments/extensions/fragment.d.ts +0 -50
  398. package/declarations/model-fragments/hooks/model-for.d.ts +0 -27
  399. package/declarations/model-fragments/index.d.ts +0 -13
  400. package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +0 -15
  401. package/declarations/model-fragments/utilities/with-array-defaults.d.ts +0 -56
  402. package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +0 -38
  403. package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +0 -34
  404. package/declarations/model-fragments/utilities/with-legacy.d.ts +0 -11
  405. package/declarations/model-fragments.d.ts +0 -9
  406. package/declarations/model.d.ts +0 -49
  407. package/declarations/serializer/-private/transforms/boolean.d.ts +0 -60
  408. package/declarations/serializer/-private/transforms/date.d.ts +0 -42
  409. package/declarations/serializer/-private/transforms/number.d.ts +0 -42
  410. package/declarations/serializer/-private/transforms/string.d.ts +0 -42
  411. package/declarations/serializer/-private/transforms/transform.d.ts +0 -118
  412. package/declarations/serializer/-private/utils.d.ts +0 -27
  413. package/declarations/serializer/rest.d.ts +0 -51
  414. package/declarations/serializer/transform.d.ts +0 -5
  415. package/declarations/serializer.d.ts +0 -252
  416. package/declarations/store/-private.d.ts +0 -223
  417. package/declarations/store.d.ts +0 -10
  418. package/dist/-private-BG3bMiKp.js +0 -1211
  419. package/dist/errors-DZKA206g.js +0 -2589
  420. package/dist/hooks-BvOqJBei.js +0 -105
  421. package/dist/json-DU8m1pGf.js +0 -1336
  422. package/dist/model-for-CXkJw59V.js +0 -297
  423. package/dist/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
  424. package/dist/schema-provider-DtPOp0d7.js +0 -2382
  425. package/dist/serialize-into-hash-DPZYoF-i.js +0 -261
  426. package/dist/unpkg/dev/-private-DtjBbEgy.js +0 -1206
  427. package/dist/unpkg/dev/errors-DngRU-If.js +0 -2585
  428. package/dist/unpkg/dev/hooks-UuiLxWxS.js +0 -104
  429. package/dist/unpkg/dev/json-K2Y9z6MN.js +0 -1333
  430. package/dist/unpkg/dev/model-for-CXkJw59V.js +0 -297
  431. package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
  432. package/dist/unpkg/dev/schema-provider-0D7f-QOn.js +0 -2272
  433. package/dist/unpkg/dev/serialize-into-hash-B2xDbuo5.js +0 -259
  434. package/dist/unpkg/dev/util-DvanW33H.js +0 -20
  435. package/dist/unpkg/dev/utils-BhvS1iTS.js +0 -8
  436. package/dist/unpkg/dev-deprecated/-private-DtjBbEgy.js +0 -1206
  437. package/dist/unpkg/dev-deprecated/errors-Bzidntpi.js +0 -2588
  438. package/dist/unpkg/dev-deprecated/hooks-DVXhMW14.js +0 -104
  439. package/dist/unpkg/dev-deprecated/json-K2Y9z6MN.js +0 -1333
  440. package/dist/unpkg/dev-deprecated/model-for-CXkJw59V.js +0 -297
  441. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
  442. package/dist/unpkg/dev-deprecated/schema-provider-ZwO5_fZw.js +0 -2292
  443. package/dist/unpkg/dev-deprecated/serialize-into-hash-B2xDbuo5.js +0 -259
  444. package/dist/unpkg/dev-deprecated/util-CWr5WQOT.js +0 -24
  445. package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +0 -12
  446. package/dist/unpkg/prod/-private-BdyZaGEh.js +0 -971
  447. package/dist/unpkg/prod/errors-B-PWeYlW.js +0 -2337
  448. package/dist/unpkg/prod/hooks-Bx-zBziU.js +0 -72
  449. package/dist/unpkg/prod/json-Qewu-UN9.js +0 -1300
  450. package/dist/unpkg/prod/model-for-CXkJw59V.js +0 -297
  451. package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
  452. package/dist/unpkg/prod/schema-provider-BgRqk8i9.js +0 -1951
  453. package/dist/unpkg/prod/serialize-into-hash-DGlzQteF.js +0 -215
  454. package/dist/unpkg/prod/util-DvanW33H.js +0 -20
  455. package/dist/unpkg/prod/utils-BhvS1iTS.js +0 -8
  456. package/dist/unpkg/prod-deprecated/-private-BdyZaGEh.js +0 -971
  457. package/dist/unpkg/prod-deprecated/errors-Dl2J9d1D.js +0 -2340
  458. package/dist/unpkg/prod-deprecated/hooks-Cm60wWTf.js +0 -72
  459. package/dist/unpkg/prod-deprecated/json-Qewu-UN9.js +0 -1300
  460. package/dist/unpkg/prod-deprecated/model-for-CXkJw59V.js +0 -297
  461. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
  462. package/dist/unpkg/prod-deprecated/schema-provider-Dh6tRqVI.js +0 -1980
  463. package/dist/unpkg/prod-deprecated/serialize-into-hash-DGlzQteF.js +0 -215
  464. package/dist/unpkg/prod-deprecated/util-B6cn-i93.js +0 -23
  465. package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +0 -11
  466. package/dist/util-Dul6TZts.js +0 -35
  467. package/dist/utils-Cqw9eRj5.js +0 -23
@@ -1,1180 +1,3 @@
1
- import { getOwner } from '@ember/application';
2
- import { recordIdentifierFor } from '@warp-drive/core';
3
- import { assertPrivateStore, _deprecatingNormalize } from '@warp-drive/core/store/-private';
4
- import '@warp-drive/core/reactive/-private';
5
- import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-DtjBbEgy.js";
6
- import { waitFor } from '@warp-drive/core/signals/-leaked';
7
- function _findHasMany(adapter, store, identifier, link, relationship, options) {
8
- const promise = Promise.resolve().then(() => {
9
- const snapshot = store._fetchManager.createSnapshot(identifier, options);
10
- const useLink = !link || typeof link === 'string';
11
- const relatedLink = useLink ? link : link.href;
12
- (test => {
13
- if (!test) {
14
- throw new Error(`Attempted to load a hasMany relationship from a specified 'link' in the original payload, but the specified link is empty. You must provide a valid 'link' in the original payload to use 'findHasMany'`);
15
- }
16
- })(relatedLink);
17
- (test => {
18
- if (!test) {
19
- throw new Error(`Expected the adapter to implement 'findHasMany' but it does not`);
20
- }
21
- })(typeof adapter.findHasMany === 'function');
22
- return adapter.findHasMany(store, snapshot, relatedLink, relationship);
23
- });
24
- return promise.then(adapterPayload => {
25
- (test => {
26
- if (!test) {
27
- throw new Error(`You made a 'findHasMany' request for a ${identifier.type}'s '${relationship.name}' relationship, using link '${JSON.stringify(link)}' , but the adapter's response did not have any data`);
28
- }
29
- })(payloadIsNotBlank(adapterPayload));
30
- const modelClass = store.modelFor(relationship.type);
31
- const serializer = store.serializerFor(relationship.type);
32
- let payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findHasMany');
33
- (test => {
34
- if (!test) {
35
- throw new Error(`fetched the hasMany relationship '${relationship.name}' for ${identifier.type}:${identifier.id} with link '${JSON.stringify(link)}', but no data member is present in the response. If no data exists, the response should set { data: [] }`);
36
- }
37
- })('data' in payload && Array.isArray(payload.data));
38
- payload = syncRelationshipDataFromLink(store, payload, identifier, relationship);
39
- return store._push(payload, true);
40
- }, null);
41
- }
42
- function _findBelongsTo(store, identifier, link, relationship, options) {
43
- const promise = Promise.resolve().then(() => {
44
- const adapter = store.adapterFor(identifier.type);
45
- (test => {
46
- if (!test) {
47
- throw new Error(`You tried to load a belongsTo relationship but you have no adapter (for ${identifier.type})`);
48
- }
49
- })(adapter);
50
- (test => {
51
- if (!test) {
52
- throw new Error(`You tried to load a belongsTo relationship from a specified 'link' in the original payload but your adapter does not implement 'findBelongsTo'`);
53
- }
54
- })(typeof adapter.findBelongsTo === 'function');
55
- const snapshot = store._fetchManager.createSnapshot(identifier, options);
56
- const useLink = !link || typeof link === 'string';
57
- const relatedLink = useLink ? link : link.href;
58
- (test => {
59
- if (!test) {
60
- throw new Error(`Attempted to load a belongsTo relationship from a specified 'link' in the original payload, but the specified link is empty. You must provide a valid 'link' in the original payload to use 'findBelongsTo'`);
61
- }
62
- })(relatedLink);
63
- return adapter.findBelongsTo(store, snapshot, relatedLink, relationship);
64
- });
65
- return promise.then(adapterPayload => {
66
- const modelClass = store.modelFor(relationship.type);
67
- const serializer = store.serializerFor(relationship.type);
68
- let payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findBelongsTo');
69
- (test => {
70
- if (!test) {
71
- throw new Error(`fetched the belongsTo relationship '${relationship.name}' for ${identifier.type}:${identifier.id} with link '${JSON.stringify(link)}', but no data member is present in the response. If no data exists, the response should set { data: null }`);
72
- }
73
- })('data' in payload && (payload.data === null || typeof payload.data === 'object' && !Array.isArray(payload.data)));
74
- if (!payload.data && !payload.links && !payload.meta) {
75
- return null;
76
- }
77
- payload = syncRelationshipDataFromLink(store, payload, identifier, relationship);
78
- return store._push(payload, true);
79
- }, null);
80
- }
1
+ import { a as serializeRecord, i as pushPayload, n as cleanup, o as serializerFor, r as normalize, s as LegacyNetworkHandler, t as adapterFor } from "./compat-CeyxXB7K.js";
81
2
 
82
- // sync
83
- // iterate over records in payload.data
84
- // for each record
85
- // assert that record.relationships[inverse] is either undefined (so we can fix it)
86
- // or provide a data: {id, type} that matches the record that requested it
87
- // return the relationship data for the parent
88
- function syncRelationshipDataFromLink(store, payload, parentIdentifier, relationship) {
89
- // ensure the right hand side (incoming payload) points to the parent record that
90
- // requested this relationship
91
- const relationshipData = payload.data ? iterateData(payload.data, (data, index) => {
92
- const {
93
- id,
94
- type
95
- } = data;
96
- ensureRelationshipIsSetToParent(data, parentIdentifier, store, relationship, index);
97
- return {
98
- id,
99
- type
100
- };
101
- }) : null;
102
- const relatedDataHash = {};
103
- if ('meta' in payload) {
104
- relatedDataHash.meta = payload.meta;
105
- }
106
- if ('links' in payload) {
107
- relatedDataHash.links = payload.links;
108
- }
109
- if ('data' in payload) {
110
- relatedDataHash.data = relationshipData;
111
- }
112
-
113
- // now, push the left hand side (the parent record) to ensure things are in sync, since
114
- // the payload will be pushed with store._push
115
- const parentPayload = {
116
- id: parentIdentifier.id,
117
- type: parentIdentifier.type,
118
- relationships: {
119
- [relationship.name]: relatedDataHash
120
- }
121
- };
122
- if (!Array.isArray(payload.included)) {
123
- payload.included = [];
124
- }
125
- payload.included.push(parentPayload);
126
- return payload;
127
- }
128
- function ensureRelationshipIsSetToParent(payload, parentIdentifier, store, parentRelationship, index) {
129
- const {
130
- id,
131
- type
132
- } = payload;
133
- if (!payload.relationships) {
134
- payload.relationships = {};
135
- }
136
- const {
137
- relationships
138
- } = payload;
139
- const inverse = getInverse(store, parentIdentifier, parentRelationship, type);
140
- if (inverse) {
141
- const {
142
- inverseKey,
143
- kind
144
- } = inverse;
145
- const relationshipData = relationships[inverseKey]?.data;
146
- {
147
- if (typeof relationshipData !== 'undefined' && !relationshipDataPointsToParent(relationshipData, parentIdentifier)) {
148
- const inspect = function inspect(thing) {
149
- return `'${JSON.stringify(thing)}'`;
150
- };
151
- const quotedType = inspect(type);
152
- const quotedInverse = inspect(inverseKey);
153
- const expected = inspect({
154
- id: parentIdentifier.id,
155
- type: parentIdentifier.type
156
- });
157
- const expectedModel = `${parentIdentifier.type}:${parentIdentifier.id}`;
158
- const got = inspect(relationshipData);
159
- const prefix = typeof index === 'number' ? `data[${index}]` : `data`;
160
- const path = `${prefix}.relationships.${inverseKey}.data`;
161
- const data = Array.isArray(relationshipData) ? relationshipData[0] : relationshipData;
162
- const other = data ? `<${data.type}:${data.id}>` : null;
163
- const relationshipFetched = `${expectedModel}.${parentRelationship.kind}("${parentRelationship.name}")`;
164
- const includedRecord = `<${type}:${id}>`;
165
- const message = [`Encountered mismatched relationship: WarpDrive expected ${path} in the payload from ${relationshipFetched} to include ${expected} but got ${got} instead.\n`, `The ${includedRecord} record loaded at ${prefix} in the payload specified ${other} as its ${quotedInverse}, but should have specified ${expectedModel} (the record the relationship is being loaded from) as its ${quotedInverse} instead.`, `This could mean that the response for ${relationshipFetched} may have accidentally returned ${quotedType} records that aren't related to ${expectedModel} and could be related to a different ${parentIdentifier.type} record instead.`, `WarpDrive has corrected the ${includedRecord} record's ${quotedInverse} relationship to ${expectedModel} so that ${relationshipFetched} will include ${includedRecord}.`, `Please update the response from the server or change your serializer to either ensure that the response for only includes ${quotedType} records that specify ${expectedModel} as their ${quotedInverse}, or omit the ${quotedInverse} relationship from the response.`].join('\n');
166
- (test => {
167
- {
168
- throw new Error(message);
169
- }
170
- })();
171
- }
172
- }
173
- if (kind !== 'hasMany' || typeof relationshipData !== 'undefined') {
174
- relationships[inverseKey] = relationships[inverseKey] || {};
175
- relationships[inverseKey].data = fixRelationshipData(relationshipData ?? null, kind, parentIdentifier);
176
- }
177
- }
178
- }
179
- function inverseForRelationship(store, identifier, key) {
180
- const definition = store.schema.fields(identifier).get(key);
181
- if (!definition) {
182
- return null;
183
- }
184
- (test => {
185
- if (!test) {
186
- throw new Error(`Expected the field definition to be a relationship`);
187
- }
188
- })(definition.kind === 'hasMany' || definition.kind === 'belongsTo');
189
- (test => {
190
- if (!test) {
191
- throw new Error(`Expected the relationship defintion to specify the inverse type or null.`);
192
- }
193
- })(definition.options?.inverse === null || typeof definition.options?.inverse === 'string' && definition.options.inverse.length > 0);
194
- return definition.options.inverse;
195
- }
196
- function getInverse(store, parentIdentifier, parentRelationship, type) {
197
- const {
198
- name: lhs_relationshipName
199
- } = parentRelationship;
200
- const {
201
- type: parentType
202
- } = parentIdentifier;
203
- const inverseKey = inverseForRelationship(store, {
204
- type: parentType
205
- }, lhs_relationshipName);
206
- if (inverseKey) {
207
- const definition = store.schema.fields({
208
- type
209
- }).get(inverseKey);
210
- (test => {
211
- if (!test) {
212
- throw new Error(`Expected the field definition to be a relationship`);
213
- }
214
- })(definition && (definition.kind === 'hasMany' || definition.kind === 'belongsTo'));
215
- return {
216
- inverseKey,
217
- kind: definition.kind
218
- };
219
- }
220
- }
221
- function relationshipDataPointsToParent(relationshipData, identifier) {
222
- if (relationshipData === null) {
223
- return false;
224
- }
225
- if (Array.isArray(relationshipData)) {
226
- if (relationshipData.length === 0) {
227
- return false;
228
- }
229
- for (let i = 0; i < relationshipData.length; i++) {
230
- const entry = relationshipData[i];
231
- if (validateRelationshipEntry(entry, identifier)) {
232
- return true;
233
- }
234
- }
235
- } else {
236
- return validateRelationshipEntry(relationshipData, identifier);
237
- }
238
- return false;
239
- }
240
- function fixRelationshipData(relationshipData, relationshipKind, {
241
- id,
242
- type
243
- }) {
244
- const parentRelationshipData = {
245
- id,
246
- type
247
- };
248
- let payload = null;
249
- if (relationshipKind === 'hasMany') {
250
- const relData = relationshipData || [];
251
- if (relationshipData) {
252
- (test => {
253
- if (!test) {
254
- throw new Error('expected the relationship data to be an array');
255
- }
256
- })(Array.isArray(relationshipData));
257
- // these arrays could be massive so this is better than filter
258
- // Note: this is potentially problematic if type/id are not in the
259
- // same state of normalization.
260
- const found = relationshipData.find(v => {
261
- return v.type === parentRelationshipData.type && v.id === parentRelationshipData.id;
262
- });
263
- if (!found) {
264
- relData.push(parentRelationshipData);
265
- }
266
- } else {
267
- relData.push(parentRelationshipData);
268
- }
269
- payload = relData;
270
- } else {
271
- const relData = relationshipData || {};
272
- Object.assign(relData, parentRelationshipData);
273
- payload = relData;
274
- }
275
- return payload;
276
- }
277
- function validateRelationshipEntry({
278
- id
279
- }, {
280
- id: parentModelID
281
- }) {
282
- return !!id && id.toString() === parentModelID;
283
- }
284
-
285
- /*
286
- These are the runtime implementations for the javascript macros that have
287
- runtime implementations.
288
-
289
- Not every macro has a runtime implementation, some only make sense in the
290
- build and always run there.
291
-
292
- Even when we have runtime implementations, we are still careful to emit static
293
- errors during the build wherever possible, and runtime errors when necessary,
294
- so that you're not surprised when you switch from runtime-mode to compile-time
295
- mode.
296
- */
297
-
298
- // This is here as a compile target for `getConfig` and `getOwnConfig` when
299
- // we're in runtime mode. This is not public API to call from your own code.
300
- function config(packageRoot) {
301
- return runtimeConfig.packages[packageRoot];
302
- }
303
- function getGlobalConfig() {
304
- return runtimeConfig.global;
305
- }
306
-
307
- // Welcome intrepid developer!
308
- //
309
- // While this data is "global", this is a private variable.
310
- //
311
- // do not build features based off of its contents,
312
- // or assume it will have the same name in future releases.
313
- const runtimeConfig = globalThis.__embroider_macros__runtime_config__ ||= {};
314
- runtimeConfig.packages ||= {};
315
- runtimeConfig.global ||= {};
316
-
317
- // In the off chance there are duplicate copies of @embroider/macros in the dep graph
318
- // (due to the package manager messing up)
319
- // Let's try to merge them together via the above global well known variable
320
- const localConfig = initializeRuntimeMacrosConfig();
321
- Object.assign(runtimeConfig.packages, localConfig.packages);
322
- Object.assign(runtimeConfig.global, localConfig.global);
323
-
324
- // this exists to be targeted by our babel plugin
325
- function initializeRuntimeMacrosConfig() {
326
- return {
327
- "packages": {},
328
- "global": {
329
- "@embroider/macros": {
330
- "isTesting": false
331
- },
332
- "WarpDrive": {
333
- "debug": {
334
- "DEBUG_RELATIONSHIP_NOTIFICATIONS": false,
335
- "LOG_CACHE": false,
336
- "LOG_CACHE_POLICY": false,
337
- "LOG_GRAPH": false,
338
- "LOG_IDENTIFIERS": false,
339
- "LOG_INSTANCE_CACHE": false,
340
- "LOG_METRIC_COUNTS": false,
341
- "LOG_MUTATIONS": false,
342
- "LOG_NOTIFICATIONS": false,
343
- "LOG_OPERATIONS": false,
344
- "LOG_PAYLOADS": false,
345
- "LOG_REACT_SIGNAL_INTEGRATION": false,
346
- "LOG_REQUESTS": false,
347
- "LOG_REQUEST_STATUS": false,
348
- "__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS": false
349
- },
350
- "polyfillUUID": false,
351
- "includeDataAdapter": true,
352
- "compatWith": "99.0",
353
- "deprecations": {
354
- "DEPRECATE_CATCH_ALL": false,
355
- "DEPRECATE_COMPUTED_CHAINS": false,
356
- "DEPRECATE_EMBER_INFLECTOR": false,
357
- "DEPRECATE_LEGACY_IMPORTS": false,
358
- "DEPRECATE_MANY_ARRAY_DUPLICATES": false,
359
- "DEPRECATE_NON_STRICT_ID": false,
360
- "DEPRECATE_NON_STRICT_TYPES": false,
361
- "DEPRECATE_NON_UNIQUE_PAYLOADS": false,
362
- "DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE": false,
363
- "DEPRECATE_STORE_EXTENDS_EMBER_OBJECT": false,
364
- "DEPRECATE_TRACKING_PACKAGE": false,
365
- "DISABLE_7X_DEPRECATIONS": false,
366
- "ENABLE_LEGACY_REQUEST_METHODS": false,
367
- "ENABLE_LEGACY_SCHEMA_SERVICE": false
368
- },
369
- "features": {
370
- "ENFORCE_STRICT_RESOURCE_FINALIZATION": false,
371
- "JSON_API_CACHE_VALIDATION_ERRORS": false,
372
- "SAMPLE_FEATURE_FLAG": null
373
- },
374
- "activeLogging": {
375
- "DEBUG_RELATIONSHIP_NOTIFICATIONS": true,
376
- "LOG_CACHE": true,
377
- "LOG_CACHE_POLICY": true,
378
- "LOG_GRAPH": true,
379
- "LOG_IDENTIFIERS": true,
380
- "LOG_INSTANCE_CACHE": true,
381
- "LOG_METRIC_COUNTS": true,
382
- "LOG_MUTATIONS": true,
383
- "LOG_NOTIFICATIONS": true,
384
- "LOG_OPERATIONS": true,
385
- "LOG_PAYLOADS": true,
386
- "LOG_REACT_SIGNAL_INTEGRATION": true,
387
- "LOG_REQUESTS": true,
388
- "LOG_REQUEST_STATUS": true,
389
- "__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS": true
390
- },
391
- "env": {
392
- "TESTING": true,
393
- "PRODUCTION": false,
394
- "DEBUG": true,
395
- "IS_RECORDING": false,
396
- "IS_CI": true,
397
- "SHOULD_RECORD": false
398
- }
399
- }
400
- }
401
- };
402
- }
403
- function updaterMethods() {
404
- return {
405
- config,
406
- getGlobalConfig,
407
- setConfig(packageRoot, value) {
408
- runtimeConfig.packages[packageRoot] = value;
409
- },
410
- setGlobalConfig(key, value) {
411
- runtimeConfig.global[key] = value;
412
- }
413
- };
414
- }
415
-
416
- // this is how runtime config can get injected at boot. I'm not sure yet if this
417
- // should be public API, but we certainly need it internally to set things like
418
- // the global fastboot.isRunning.
419
- //
420
- // consumers of this API push a function onto
421
- // window._embroider_macros_runtime_config. The function is given four methods
422
- // which allow it to read and write the per-package and global configs. The
423
- // reason for allowing both read & write is that merging strategies are up to
424
- // each consumers -- read first, then merge, then write.
425
- //
426
- // For an example user of this API, see where we generate
427
- // embroider_macros_fastboot_init.js' in @embroider/core.
428
- let updaters = typeof window !== 'undefined' ? window._embroider_macros_runtime_config : undefined;
429
- if (updaters) {
430
- let methods = updaterMethods();
431
- for (let updater of updaters) {
432
- updater(methods);
433
- }
434
- }
435
- const PotentialLegacyOperations = new Set(['findRecord', 'findAll', 'query', 'queryRecord', 'findBelongsTo', 'findHasMany', 'updateRecord', 'createRecord', 'deleteRecord']);
436
-
437
- /**
438
- * A {@link Handler} that fulfills legacy `findRecord`/`findAll`/`query`/
439
- * `queryRecord`/`findBelongsTo`/`findHasMany`/`createRecord`/`updateRecord`/
440
- * `deleteRecord` requests using the store's configured {@link MinimumAdapterInterface | adapter}
441
- * and {@link MinimumSerializerInterface | serializer}, passing any other
442
- * request through to the next handler unchanged.
443
- */
444
- const LegacyNetworkHandler = {
445
- request(context, next) {
446
- // if we are not a legacy request, move on
447
- if (context.request.url || !context.request.op || !PotentialLegacyOperations.has(context.request.op)) {
448
- return next(context.request);
449
- }
450
- const {
451
- store
452
- } = context.request;
453
- if (!store._fetchManager) {
454
- store._fetchManager = new FetchManager(store);
455
- }
456
- switch (context.request.op) {
457
- case 'findRecord':
458
- return findRecord(context);
459
- case 'findAll':
460
- return findAll(context);
461
- case 'query':
462
- return query(context);
463
- case 'queryRecord':
464
- return queryRecord(context);
465
- case 'findBelongsTo':
466
- return findBelongsTo(context);
467
- case 'findHasMany':
468
- return findHasMany(context);
469
- case 'updateRecord':
470
- return saveRecord(context);
471
- case 'createRecord':
472
- return saveRecord(context);
473
- case 'deleteRecord':
474
- return saveRecord(context);
475
- default:
476
- return next(context.request);
477
- }
478
- }
479
- };
480
- function findBelongsTo(context) {
481
- const {
482
- store,
483
- data,
484
- records: identifiers
485
- } = context.request;
486
- const {
487
- options,
488
- record,
489
- links,
490
- useLink,
491
- field
492
- } = data;
493
- const identifier = identifiers?.[0];
494
-
495
- // short circuit if we are already loading
496
- const pendingRequest = identifier && store._fetchManager.getPendingFetch(identifier, options);
497
- if (pendingRequest) {
498
- return pendingRequest;
499
- }
500
- if (useLink) {
501
- (test => {
502
- if (!test) {
503
- throw new Error(`Expected a related link when calling store.findBelongsTo, found ${String(links)}`);
504
- }
505
- })(links && links.related);
506
- return _findBelongsTo(store, record, links.related, field, options);
507
- }
508
- (test => {
509
- if (!test) {
510
- throw new Error(`Expected an identifier`);
511
- }
512
- })(Array.isArray(identifiers) && identifiers.length === 1);
513
- const manager = store._fetchManager;
514
- assertIdentifierHasId(identifier);
515
- return options.reload ? manager.scheduleFetch(identifier, options, context.request) : manager.fetchDataIfNeededForIdentifier(identifier, options, context.request);
516
- }
517
- function findHasMany(context) {
518
- const {
519
- store,
520
- data,
521
- records: identifiers
522
- } = context.request;
523
- const {
524
- options,
525
- record,
526
- links,
527
- useLink,
528
- field
529
- } = data;
530
-
531
- // link case
532
- if (useLink) {
533
- const adapter = store.adapterFor(record.type);
534
- /*
535
- If a relationship was originally populated by the adapter as a link
536
- (as opposed to a list of IDs), this method is called when the
537
- relationship is fetched.
538
- The link (which is usually a URL) is passed through unchanged, so the
539
- adapter can make whatever request it wants.
540
- The usual use-case is for the server to register a URL as a link, and
541
- then use that URL in the future to make a request for the relationship.
542
- */
543
- (test => {
544
- if (!test) {
545
- throw new Error(`You tried to load a hasMany relationship but you have no adapter (for ${record.type})`);
546
- }
547
- })(adapter);
548
- (test => {
549
- if (!test) {
550
- throw new Error(`You tried to load a hasMany relationship from a specified 'link' in the original payload but your adapter does not implement 'findHasMany'`);
551
- }
552
- })(typeof adapter.findHasMany === 'function');
553
- (test => {
554
- if (!test) {
555
- throw new Error(`Expected a related link when calling store.findHasMany, found ${String(links)}`);
556
- }
557
- })(links && links.related);
558
- return _findHasMany(adapter, store, record, links.related, field, options);
559
- }
560
-
561
- // identifiers case
562
- (test => {
563
- if (!test) {
564
- throw new Error(`Expected an array of identifiers to fetch`);
565
- }
566
- })(Array.isArray(identifiers));
567
- const fetches = new Array(identifiers.length);
568
- const manager = store._fetchManager;
569
- for (let i = 0; i < identifiers.length; i++) {
570
- const identifier = identifiers[i];
571
- // TODO we probably can be lenient here and return from cache for the isNew case
572
- assertIdentifierHasId(identifier);
573
- fetches[i] = options.reload ? manager.scheduleFetch(identifier, options, context.request) : manager.fetchDataIfNeededForIdentifier(identifier, options, context.request);
574
- }
575
- return Promise.all(fetches);
576
- }
577
- function saveRecord(context) {
578
- const {
579
- store,
580
- data,
581
- op: operation
582
- } = context.request;
583
- const {
584
- options,
585
- record: identifier
586
- } = data;
587
- assertPrivateStore(store);
588
- store.cache.willCommit(identifier, context);
589
- const saveOptions = Object.assign({
590
- [SaveOp]: operation
591
- }, options);
592
- const fetchManagerPromise = store._fetchManager.scheduleSave(identifier, saveOptions);
593
- return fetchManagerPromise.then(payload => {
594
- let result;
595
- store._join(() => {
596
- // @ts-expect-error we don't have access to a response in legacy
597
- result = store.cache.didCommit(identifier, {
598
- request: context.request,
599
- content: payload
600
- });
601
- });
602
-
603
- // blatantly lie if we were a createRecord request
604
- // to give some semblance of cache-control to the
605
- // CachePolicy while legacy is still around
606
- if (store.lifetimes?.didRequest && operation === 'createRecord') {
607
- store.lifetimes.didRequest(context.request, {
608
- status: 201
609
- }, null, store);
610
- }
611
- return store.peekRecord(result.data);
612
- }).catch(e => {
613
- let err = e;
614
- if (!e) {
615
- err = new Error(`Unknown Error Occurred During Request`);
616
- } else if (typeof e === 'string') {
617
- err = new Error(e);
618
- }
619
- adapterDidInvalidate(store, identifier, err);
620
- throw err;
621
- });
622
- }
623
- function adapterDidInvalidate(store, identifier, error) {
624
- if (error && error.isAdapterError === true && error.code === 'InvalidError') {
625
- const serializer = store.serializerFor(identifier.type);
626
-
627
- // TODO @deprecate extractErrors being called
628
- // TODO remove extractErrors from the default serializers.
629
- if (serializer && typeof serializer.extractErrors === 'function') {
630
- const errorsHash = serializer.extractErrors(store, store.modelFor(identifier.type), error, identifier.id);
631
- error.errors = errorsHashToArray(errorsHash);
632
- }
633
- }
634
- const cache = store.cache;
635
- if (error.errors) {
636
- (test => {
637
- if (!test) {
638
- throw new Error(`Expected the cache in use by resource ${String(identifier)} to have a getErrors(identifier) method for retrieving errors.`);
639
- }
640
- })(typeof cache.getErrors === 'function');
641
- let jsonApiErrors = error.errors;
642
- if (jsonApiErrors.length === 0) {
643
- jsonApiErrors = [{
644
- title: 'Invalid Error',
645
- detail: '',
646
- source: {
647
- pointer: '/data'
648
- }
649
- }];
650
- }
651
- cache.commitWasRejected(identifier, jsonApiErrors);
652
- } else {
653
- cache.commitWasRejected(identifier);
654
- }
655
- }
656
- function makeArray(value) {
657
- return Array.isArray(value) ? value : [value];
658
- }
659
- const PRIMARY_ATTRIBUTE_KEY = 'base';
660
- function errorsHashToArray(errors) {
661
- const out = [];
662
- if (errors) {
663
- Object.keys(errors).forEach(key => {
664
- const messages = makeArray(errors[key]);
665
- for (let i = 0; i < messages.length; i++) {
666
- let title = 'Invalid Attribute';
667
- let pointer = `/data/attributes/${key}`;
668
- if (key === PRIMARY_ATTRIBUTE_KEY) {
669
- title = 'Invalid Document';
670
- pointer = `/data`;
671
- }
672
- out.push({
673
- title: title,
674
- detail: messages[i],
675
- source: {
676
- pointer: pointer
677
- }
678
- });
679
- }
680
- });
681
- }
682
- return out;
683
- }
684
- function findRecord(context) {
685
- const {
686
- store,
687
- data
688
- } = context.request;
689
- const {
690
- record: identifier,
691
- options
692
- } = data;
693
- assertPrivateStore(store);
694
- let promise;
695
-
696
- // if not loaded start loading
697
- if (!store._instanceCache.recordIsLoaded(identifier)) {
698
- promise = store._fetchManager.fetchDataIfNeededForIdentifier(identifier, options, context.request);
699
-
700
- // Refetch if the reload option is passed
701
- } else if (options.reload) {
702
- assertIdentifierHasId(identifier);
703
- promise = store._fetchManager.scheduleFetch(identifier, options, context.request);
704
- } else {
705
- let snapshot = null;
706
- const adapter = store.adapterFor(identifier.type);
707
-
708
- // Refetch the record if the adapter thinks the record is stale
709
- if (typeof options.reload === 'undefined' && adapter.shouldReloadRecord && adapter.shouldReloadRecord(store, snapshot = store._fetchManager.createSnapshot(identifier, options))) {
710
- assertIdentifierHasId(identifier);
711
- {
712
- promise = store._fetchManager.scheduleFetch(identifier, Object.assign({}, options, {
713
- reload: true
714
- }), context.request);
715
- }
716
- } else {
717
- // Trigger the background refetch if backgroundReload option is passed
718
- if (options.backgroundReload !== false && (options.backgroundReload || !adapter.shouldBackgroundReloadRecord || adapter.shouldBackgroundReloadRecord(store, snapshot = snapshot || store._fetchManager.createSnapshot(identifier, options)))) {
719
- assertIdentifierHasId(identifier);
720
- {
721
- void store._fetchManager.scheduleFetch(identifier, Object.assign({}, options, {
722
- backgroundReload: true
723
- }), context.request);
724
- }
725
- }
726
-
727
- // Return the cached record
728
- promise = Promise.resolve(identifier);
729
- }
730
- }
731
- return promise.then(i => store.peekRecord(i));
732
- }
733
- function findAll(context) {
734
- const {
735
- store,
736
- data
737
- } = context.request;
738
- const {
739
- type,
740
- options
741
- } = data;
742
- assertPrivateStore(store);
743
- const adapter = store.adapterFor(type);
744
- (test => {
745
- if (!test) {
746
- throw new Error(`You tried to load all records but you have no adapter (for ${type})`);
747
- }
748
- })(adapter);
749
- (test => {
750
- if (!test) {
751
- throw new Error(`You tried to load all records but your adapter does not implement 'findAll'`);
752
- }
753
- })(typeof adapter.findAll === 'function');
754
-
755
- // avoid initializing the liveArray just to set `isUpdating`
756
- const maybeRecordArray = store.recordArrayManager._live.get(type);
757
- const snapshotArray = new SnapshotRecordArray(store, type, options);
758
- const shouldReload = options.reload || options.reload !== false && (adapter.shouldReloadAll && adapter.shouldReloadAll(store, snapshotArray) || !adapter.shouldReloadAll && snapshotArray.length === 0);
759
- let fetch;
760
- if (shouldReload) {
761
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
762
- maybeRecordArray && (maybeRecordArray.isUpdating = true);
763
- fetch = _findAll(adapter, store, type, snapshotArray, context.request, true);
764
- } else {
765
- fetch = Promise.resolve(store.peekAll(type));
766
- if (options.backgroundReload || options.backgroundReload !== false && (!adapter.shouldBackgroundReloadAll || adapter.shouldBackgroundReloadAll(store, snapshotArray))) {
767
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
768
- maybeRecordArray && (maybeRecordArray.isUpdating = true);
769
- void _findAll(adapter, store, type, snapshotArray, context.request, false);
770
- }
771
- }
772
- return fetch;
773
- }
774
- function _findAll(adapter, store, type, snapshotArray, request, isAsyncFlush) {
775
- const schema = store.modelFor(type);
776
- let promise = Promise.resolve().then(() => adapter.findAll(store, schema, null, snapshotArray));
777
- promise = promise.then(adapterPayload => {
778
- (test => {
779
- if (!test) {
780
- throw new Error(`You made a 'findAll' request for '${type}' records, but the adapter's response did not have any data`);
781
- }
782
- })(payloadIsNotBlank(adapterPayload));
783
- const serializer = store.serializerFor(type);
784
- const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'findAll');
785
- store._push(payload, isAsyncFlush);
786
- snapshotArray._recordArray.isUpdating = false;
787
- {
788
- if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
789
- // eslint-disable-next-line no-console
790
- console.log(`request: findAll<${type}> background reload complete`);
791
- }
792
- }
793
- return snapshotArray._recordArray;
794
- });
795
- {
796
- if (!request.disableTestWaiter) {
797
- promise = waitFor(promise);
798
- }
799
- }
800
- return promise;
801
- }
802
- function query(context) {
803
- const {
804
- store,
805
- data
806
- } = context.request;
807
- assertPrivateStore(store);
808
- let {
809
- options
810
- } = data;
811
- // eslint-disable-next-line @typescript-eslint/no-shadow
812
- const {
813
- type,
814
- query
815
- } = data;
816
- const adapter = store.adapterFor(type);
817
- (test => {
818
- if (!test) {
819
- throw new Error(`You tried to make a query but you have no adapter (for ${type})`);
820
- }
821
- })(adapter);
822
- (test => {
823
- if (!test) {
824
- throw new Error(`You tried to make a query but your adapter does not implement 'query'`);
825
- }
826
- })(typeof adapter.query === 'function');
827
- const recordArray = options._recordArray || store.recordArrayManager.getCollection({
828
- type,
829
- query
830
- });
831
- {
832
- options = Object.assign({}, options);
833
- delete options._recordArray;
834
- }
835
- const schema = store.modelFor(type);
836
- const promise = Promise.resolve().then(() => adapter.query(store, schema, query, recordArray, options));
837
- return promise.then(adapterPayload => {
838
- const serializer = store.serializerFor(type);
839
- const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'query');
840
- const identifiers = store._push(payload, true);
841
- (test => {
842
- if (!test) {
843
- throw new Error('The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use `store.queryRecord` to query for a single record.');
844
- }
845
- })(Array.isArray(identifiers));
846
- store.recordArrayManager.populateManagedArray(recordArray, identifiers, payload);
847
- return recordArray;
848
- });
849
- }
850
- function assertSingleResourceDocument(payload) {
851
- (test => {
852
- if (!test) {
853
- throw new Error(`Expected the primary data returned by the serializer for a 'queryRecord' response to be a single object or null but instead it was an array.`);
854
- }
855
- })(!Array.isArray(payload.data));
856
- }
857
- function queryRecord(context) {
858
- const {
859
- store,
860
- data
861
- } = context.request;
862
- // eslint-disable-next-line @typescript-eslint/no-shadow
863
- const {
864
- type,
865
- query,
866
- options
867
- } = data;
868
- const adapter = store.adapterFor(type);
869
- (test => {
870
- if (!test) {
871
- throw new Error(`You tried to make a query but you have no adapter (for ${type})`);
872
- }
873
- })(adapter);
874
- (test => {
875
- if (!test) {
876
- throw new Error(`You tried to make a query but your adapter does not implement 'queryRecord'`);
877
- }
878
- })(typeof adapter.queryRecord === 'function');
879
- const schema = store.modelFor(type);
880
- const promise = Promise.resolve().then(() => adapter.queryRecord(store, schema, query, options));
881
- return promise.then(adapterPayload => {
882
- const serializer = store.serializerFor(type);
883
- const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'queryRecord');
884
- assertSingleResourceDocument(payload);
885
- const identifier = store._push(payload, true);
886
- return identifier ? store.peekRecord(identifier) : null;
887
- });
888
- }
889
-
890
- /**
891
- * Extends the signature of {@link Store} with additional
892
- * methods available when using the legacy network layer.
893
- *
894
- * @public
895
- * @noInheritDoc
896
- * @legacy
897
- */
898
-
899
- /**
900
- * @deprecated - use {@link LegacyStoreCompat} instead
901
- */
902
-
903
- /**
904
- Returns an instance of the adapter for a given type. For
905
- example, `adapterFor('person')` will return an instance of
906
- the adapter located at `app/adapters/person.js`
907
-
908
- If no `person` adapter is found, this method will look
909
- for an `application` adapter (the default adapter for
910
- your entire application).
911
-
912
- @public
913
- @param modelName
914
- */
915
-
916
- function adapterFor(modelName, _allowMissing) {
917
- (test => {
918
- if (!test) {
919
- throw new Error(`Attempted to call store.adapterFor(), but the store instance has already been destroyed.`);
920
- }
921
- })(!(this.isDestroying || this.isDestroyed));
922
- (test => {
923
- if (!test) {
924
- throw new Error(`You need to pass a model name to the store's adapterFor method`);
925
- }
926
- })(modelName);
927
- (test => {
928
- if (!test) {
929
- throw new Error(`Passing classes to store.adapterFor has been removed. Please pass a dasherized string instead of ${modelName}`);
930
- }
931
- })(typeof modelName === 'string');
932
- this._adapterCache = this._adapterCache || Object.create(null);
933
- const normalizedModelName = _deprecatingNormalize(modelName);
934
- const {
935
- _adapterCache
936
- } = this;
937
- let adapter = _adapterCache[normalizedModelName];
938
- if (adapter) {
939
- return adapter;
940
- }
941
- const owner = getOwner(this);
942
-
943
- // name specific adapter
944
- adapter = owner.lookup(`adapter:${normalizedModelName}`);
945
- if (adapter !== undefined) {
946
- _adapterCache[normalizedModelName] = adapter;
947
- return adapter;
948
- }
949
-
950
- // no adapter found for the specific name, fallback and check for application adapter
951
- adapter = _adapterCache.application || owner.lookup('adapter:application');
952
- if (adapter !== undefined) {
953
- _adapterCache[normalizedModelName] = adapter;
954
- _adapterCache.application = adapter;
955
- return adapter;
956
- }
957
- (test => {
958
- if (!test) {
959
- throw new Error(`No adapter was found for '${modelName}' and no 'application' adapter was found as a fallback.`);
960
- }
961
- })(_allowMissing);
962
- }
963
-
964
- /**
965
- Returns an instance of the serializer for a given type. For
966
- example, `serializerFor('person')` will return an instance of
967
- `App.PersonSerializer`.
968
-
969
- If no `App.PersonSerializer` is found, this method will look
970
- for an `App.ApplicationSerializer` (the default serializer for
971
- your entire application).
972
-
973
- If a serializer cannot be found on the adapter, it will fall back
974
- to an instance of `JSONSerializer`.
975
-
976
- @public
977
- @param modelName the record to serialize
978
- */
979
- function serializerFor(modelName) {
980
- (test => {
981
- if (!test) {
982
- throw new Error(`Attempted to call store.serializerFor(), but the store instance has already been destroyed.`);
983
- }
984
- })(!(this.isDestroying || this.isDestroyed));
985
- (test => {
986
- if (!test) {
987
- throw new Error(`You need to pass a model name to the store's serializerFor method`);
988
- }
989
- })(modelName);
990
- (test => {
991
- if (!test) {
992
- throw new Error(`Passing classes to store.serializerFor has been removed. Please pass a dasherized string instead of ${modelName}`);
993
- }
994
- })(typeof modelName === 'string');
995
- this._serializerCache = this._serializerCache || Object.create(null);
996
- const normalizedModelName = _deprecatingNormalize(modelName);
997
- const {
998
- _serializerCache
999
- } = this;
1000
- let serializer = _serializerCache[normalizedModelName];
1001
- if (serializer) {
1002
- return serializer;
1003
- }
1004
-
1005
- // by name
1006
- const owner = getOwner(this);
1007
- serializer = owner.lookup(`serializer:${normalizedModelName}`);
1008
- if (serializer !== undefined) {
1009
- _serializerCache[normalizedModelName] = serializer;
1010
- return serializer;
1011
- }
1012
-
1013
- // no serializer found for the specific model, fallback and check for application serializer
1014
- serializer = _serializerCache.application || owner.lookup('serializer:application');
1015
- if (serializer !== undefined) {
1016
- _serializerCache[normalizedModelName] = serializer;
1017
- _serializerCache.application = serializer;
1018
- return serializer;
1019
- }
1020
- return null;
1021
- }
1022
-
1023
- /**
1024
- `normalize` converts a json payload into the normalized form expected by
1025
- {@link Store.push | push} using the serializer specified by `modelName`
1026
-
1027
- :::warning
1028
- Generally it would be better to invoke the serializer yourself directly,
1029
- or write a more specialized normalization utility.
1030
- :::
1031
-
1032
- Example
1033
-
1034
- ```js
1035
- socket.on('message', function(message) {
1036
- let modelName = message.model;
1037
- let data = message.data;
1038
- store.push(store.normalize(modelName, data));
1039
- });
1040
- ```
1041
-
1042
- @legacy
1043
- @public
1044
- @param modelName The name of the model type for this payload
1045
- @return The normalized payload
1046
- */
1047
- // TODO @runspired @deprecate users should call normalize on the associated serializer directly
1048
- function normalize(modelName, payload) {
1049
- (test => {
1050
- if (!test) {
1051
- throw new Error(`Attempted to call store.normalize(), but the store instance has already been destroyed.`);
1052
- }
1053
- })(!(this.isDestroying || this.isDestroyed));
1054
- (test => {
1055
- if (!test) {
1056
- throw new Error(`You need to pass a model name to the store's normalize method`);
1057
- }
1058
- })(modelName);
1059
- (test => {
1060
- if (!test) {
1061
- throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${typeof modelName}`);
1062
- }
1063
- })(typeof modelName === 'string');
1064
- const normalizedModelName = _deprecatingNormalize(modelName);
1065
- const serializer = this.serializerFor(normalizedModelName);
1066
- const schema = this.modelFor(normalizedModelName);
1067
- (test => {
1068
- if (!test) {
1069
- throw new Error(`You must define a normalize method in your serializer in order to call store.normalize`);
1070
- }
1071
- })(typeof serializer?.normalize === 'function');
1072
- return serializer.normalize(schema, payload);
1073
- }
1074
-
1075
- /**
1076
- Push some raw data into the store.
1077
-
1078
- This method can be used both to push in brand new
1079
- records, as well as to update existing records. You
1080
- can push in more than one type of object at once.
1081
- All objects should be in the format expected by the
1082
- serializer.
1083
-
1084
- ```js [app/serializers/application.js]
1085
- import RESTSerializer from '@warp-drive/legacy/serializer/rest';
1086
-
1087
- export default class ApplicationSerializer extends RESTSerializer;
1088
- ```
1089
-
1090
- ```js
1091
- let pushData = {
1092
- posts: [
1093
- { id: 1, postTitle: "Great post", commentIds: [2] }
1094
- ],
1095
- comments: [
1096
- { id: 2, commentBody: "Insightful comment" }
1097
- ]
1098
- }
1099
-
1100
- store.pushPayload(pushData);
1101
- ```
1102
-
1103
- By default, the data will be deserialized using a default
1104
- serializer (the application serializer if it exists).
1105
-
1106
- Alternatively, `pushPayload` will accept a model type which
1107
- will determine which serializer will process the payload.
1108
-
1109
- ```js [app/serializers/application.js]
1110
- import RESTSerializer from '@warp-drive/legacy/serializer/rest';
1111
-
1112
- export default class ApplicationSerializer extends RESTSerializer;
1113
- ```
1114
-
1115
- ```js [app/serializers/post.js]
1116
- import JSONSerializer from '@warp-drive/legacy/serializer/json';
1117
-
1118
- export default JSONSerializer;
1119
- ```
1120
-
1121
- ```js
1122
- store.pushPayload(pushData); // Will use the application serializer
1123
- store.pushPayload('post', pushData); // Will use the post serializer
1124
- ```
1125
-
1126
- @public
1127
- @param modelName Optionally, a model type used to determine which serializer will be used
1128
- @param inputPayload
1129
- */
1130
- // TODO @runspired @deprecate pushPayload in favor of looking up the serializer
1131
- function pushPayload(modelName, inputPayload) {
1132
- (test => {
1133
- if (!test) {
1134
- throw new Error(`Attempted to call store.pushPayload(), but the store instance has already been destroyed.`);
1135
- }
1136
- })(!(this.isDestroying || this.isDestroyed));
1137
- const payload = inputPayload || modelName;
1138
- const normalizedModelName = inputPayload ? _deprecatingNormalize(modelName) : 'application';
1139
- const serializer = this.serializerFor(normalizedModelName);
1140
- (test => {
1141
- if (!test) {
1142
- throw new Error(`You cannot use 'store.pushPayload(<type>, <payload>)' unless the serializer for '${normalizedModelName}' defines 'pushPayload'`);
1143
- }
1144
- })(serializer && typeof serializer.pushPayload === 'function');
1145
- serializer.pushPayload(this, payload);
1146
- }
1147
-
1148
- /**
1149
- * Serializes a record using the store's legacy network layer, as with
1150
- * {@link LegacyStoreCompat.serializeRecord | store.serializeRecord}.
1151
- */
1152
- // TODO @runspired @deprecate records should implement their own serialization if desired
1153
- function serializeRecord(record, options) {
1154
- // TODO we used to check if the record was destroyed here
1155
- if (!this._fetchManager) {
1156
- this._fetchManager = new FetchManager(this);
1157
- }
1158
- return this._fetchManager.createSnapshot(recordIdentifierFor(record)).serialize(options);
1159
- }
1160
-
1161
- /**
1162
- * Destroys any adapters/serializers the legacy network layer has created
1163
- * for this store, invoked when the store itself is destroyed.
1164
- */
1165
- function cleanup() {
1166
- // enqueue destruction of any adapters/serializers we have created
1167
- for (const adapterName in this._adapterCache) {
1168
- const adapter = this._adapterCache[adapterName];
1169
- if (typeof adapter.destroy === 'function') {
1170
- adapter.destroy();
1171
- }
1172
- }
1173
- for (const serializerName in this._serializerCache) {
1174
- const serializer = this._serializerCache[serializerName];
1175
- if (typeof serializer.destroy === 'function') {
1176
- serializer.destroy();
1177
- }
1178
- }
1179
- }
1180
3
  export { LegacyNetworkHandler, adapterFor, cleanup, normalize, pushPayload, serializeRecord, serializerFor };