@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
@@ -0,0 +1,1929 @@
1
+ import { n as FetchManager, t as upgradeStore } from "./-private-DccRZQsm.js";
2
+ import { n as normalizeModelName } from "./util-Bnx8nm-D.js";
3
+ import { n as LEGACY_SUPPORT, r as lookupLegacySupport, t as Errors } from "./errors-LQhmDVdd.js";
4
+ import { n as decorateMethodV2 } from "./runtime-BPCpkOf1-BgO3Lyjx.js";
5
+ import { recordIdentifierFor, storeFor } from "@warp-drive/core";
6
+ import { getOwner } from "@ember/application";
7
+ import { assertPrivateStore, coerceId, recordIdentifierFor as recordIdentifierFor$1 } from "@warp-drive/core/store/-private";
8
+ import { Context } from "@warp-drive/core/reactive/-private";
9
+ import { deprecate } from "@ember/debug";
10
+ import { defineGate, defineSignal, entangleSignal, gate, memoized, notifyInternalSignal, peekInternalSignal, withSignalStore } from "@warp-drive/core/signals/-leaked";
11
+ import { getGlobalConfig, macroCondition } from "@embroider/macros";
12
+ import EmberObject from "@ember/object";
13
+ import { RecordStore } from "@warp-drive/core/types/symbols";
14
+ import { cacheFor } from "@ember/object/internals";
15
+
16
+ //#region src/model/-private/model-methods.ts
17
+ function rollbackAttributes() {
18
+ const { currentState } = this;
19
+ const { isNew } = currentState;
20
+ const store = this[RecordStore];
21
+ assertPrivateStore(store);
22
+ store._join(() => {
23
+ store.cache.rollbackAttrs(recordIdentifierFor(this));
24
+ this.errors.clear();
25
+ currentState.cleanErrorRequests();
26
+ if (isNew) this.unloadRecord();
27
+ });
28
+ }
29
+ function unloadRecord() {
30
+ if (this.currentState.isNew && (this.isDestroyed || this.isDestroying)) return;
31
+ this[RecordStore].unloadRecord(this);
32
+ }
33
+ function belongsTo(prop) {
34
+ return lookupLegacySupport(this).referenceFor("belongsTo", prop);
35
+ }
36
+ function hasMany(prop) {
37
+ return lookupLegacySupport(this).referenceFor("hasMany", prop);
38
+ }
39
+ function reload(options = {}) {
40
+ if (macroCondition(!getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
41
+ const message = `You cannot use reload() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;
42
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
43
+ if (!test) throw new Error(message);
44
+ })(false);
45
+ return Promise.reject(new Error(message));
46
+ } else {
47
+ deprecate(`record.reload is deprecated, please use store.request to initiate a request instead.`, false, {
48
+ id: "warp-drive:deprecate-legacy-request-methods",
49
+ until: "6.0",
50
+ for: "@warp-drive/core",
51
+ url: "https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS",
52
+ since: {
53
+ enabled: "5.7",
54
+ available: "5.7"
55
+ }
56
+ });
57
+ return _reload.call(this, options);
58
+ }
59
+ }
60
+ function _reload(options = {}) {
61
+ options.isReloading = true;
62
+ options.reload = true;
63
+ const identifier = recordIdentifierFor(this);
64
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
65
+ if (!test) throw new Error(`You cannot reload a record without an ID`);
66
+ })(identifier.id);
67
+ this.isReloading = true;
68
+ return this[RecordStore].request({
69
+ op: "findRecord",
70
+ data: {
71
+ options,
72
+ record: identifier
73
+ },
74
+ cacheOptions: { [Symbol.for("wd:skip-cache")]: true }
75
+ }).then(() => this).finally(() => {
76
+ this.isReloading = false;
77
+ });
78
+ }
79
+ function changedAttributes() {
80
+ return this[RecordStore].cache.changedAttrs(recordIdentifierFor(this));
81
+ }
82
+ function serialize(options) {
83
+ /* @__PURE__ */ upgradeStore(this[RecordStore]);
84
+ return this[RecordStore].serializeRecord(this, options);
85
+ }
86
+ function deleteRecord() {
87
+ if (this.currentState) this[RecordStore].deleteRecord(this);
88
+ }
89
+ function save(options) {
90
+ if (macroCondition(!getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
91
+ const message = `You cannot use save() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;
92
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
93
+ if (!test) throw new Error(message);
94
+ })(false);
95
+ return Promise.reject(new Error(message));
96
+ } else {
97
+ deprecate(`record.save is deprecated, please use store.request to initiate a request instead.`, false, {
98
+ id: "warp-drive:deprecate-legacy-request-methods",
99
+ until: "6.0",
100
+ for: "@warp-drive/core",
101
+ url: "https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS",
102
+ since: {
103
+ enabled: "5.7",
104
+ available: "5.7"
105
+ }
106
+ });
107
+ return _save.call(this, options);
108
+ }
109
+ }
110
+ function _save(options) {
111
+ let promise;
112
+ if (this.currentState.isNew && this.currentState.isDeleted) promise = Promise.resolve(this);
113
+ else {
114
+ this.errors.clear();
115
+ promise = this[RecordStore].saveRecord(this, options);
116
+ }
117
+ return promise;
118
+ }
119
+ function destroyRecord(options) {
120
+ if (macroCondition(!getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
121
+ const message = `You cannot use destroyRecord() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;
122
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
123
+ if (!test) throw new Error(message);
124
+ })(false);
125
+ return Promise.reject(new Error(message));
126
+ } else {
127
+ deprecate(`record.destroyRecord is deprecated, please use store.request to initiate a request instead.`, false, {
128
+ id: "warp-drive:deprecate-legacy-request-methods",
129
+ until: "6.0",
130
+ for: "@warp-drive/core",
131
+ url: "https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS",
132
+ since: {
133
+ enabled: "5.7",
134
+ available: "5.7"
135
+ }
136
+ });
137
+ return _destroyRecord.call(this, options);
138
+ }
139
+ }
140
+ function _destroyRecord(options) {
141
+ const { isNew } = this.currentState;
142
+ this.deleteRecord();
143
+ if (isNew) return Promise.resolve(this);
144
+ return this.save(options).then((_) => {
145
+ this.unloadRecord();
146
+ return this;
147
+ });
148
+ }
149
+ function createSnapshot() {
150
+ const store = this[RecordStore];
151
+ /* @__PURE__ */ upgradeStore(store);
152
+ if (!store._fetchManager) store._fetchManager = new FetchManager(store);
153
+ return store._fetchManager.createSnapshot(recordIdentifierFor(this));
154
+ }
155
+
156
+ //#endregion
157
+ //#region src/model/-private/notify-changes.ts
158
+ function notifyChanges(identifier, value, key, record, store) {
159
+ switch (value) {
160
+ case "added":
161
+ case "attributes":
162
+ if (key) notifyAttribute(store, identifier, key, record);
163
+ else record.eachAttribute((name) => {
164
+ notifyAttribute(store, identifier, name, record);
165
+ });
166
+ break;
167
+ case "relationships":
168
+ if (key) {
169
+ const meta = record.constructor.relationshipsByName.get(key);
170
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
171
+ if (!test) throw new Error(`Expected to find a relationship for ${key} on ${identifier.type}`);
172
+ })(meta);
173
+ notifyRelationship(identifier, key, record, meta);
174
+ } else record.eachRelationship((name, meta) => {
175
+ notifyRelationship(identifier, name, record, meta);
176
+ });
177
+ break;
178
+ case "identity": notifyInternalSignal(peekInternalSignal(withSignalStore(record), "id"));
179
+ }
180
+ }
181
+ function notifyRelationship(identifier, key, record, meta) {
182
+ if (meta.kind === "belongsTo") record.notifyPropertyChange(key);
183
+ else if (meta.kind === "hasMany") {
184
+ const support = LEGACY_SUPPORT.get(identifier);
185
+ const manyArray = support && support._manyArrayCache[key];
186
+ const hasPromise = support && support._relationshipPromisesCache[key];
187
+ if (manyArray && hasPromise) return;
188
+ if (manyArray) {
189
+ notifyInternalSignal(manyArray[Context].signal);
190
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
191
+ if (!test) throw new Error(`Expected options to exist on relationship meta`);
192
+ })(meta.options);
193
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
194
+ if (!test) throw new Error(`Expected async to exist on relationship meta options`);
195
+ })("async" in meta.options);
196
+ if (meta.options.async) record.notifyPropertyChange(key);
197
+ }
198
+ }
199
+ }
200
+ function notifyAttribute(store, identifier, key, record) {
201
+ if (cacheFor(record, key) !== store.cache.getAttr(identifier, key)) record.notifyPropertyChange(key);
202
+ }
203
+
204
+ //#endregion
205
+ //#region src/model/-private/record-state.ts
206
+ const SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
207
+ const SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
208
+ const PRIMARY_ATTRIBUTE_KEY = "base";
209
+ function isInvalidError(error) {
210
+ return !!error && error instanceof Error && "isAdapterError" in error && error.isAdapterError === true && "code" in error && error.code === "InvalidError";
211
+ }
212
+ /**
213
+ Historically WarpDrive managed a state machine
214
+ for each record, the localState for which
215
+ was reflected onto Model.
216
+
217
+ This implements the flags and stateName for backwards compat
218
+ with the state tree that used to be possible (listed below).
219
+
220
+ stateName and dirtyType are candidates for deprecation.
221
+
222
+ root
223
+ empty
224
+ deleted // hidden from stateName
225
+ preloaded // hidden from stateName
226
+
227
+ loading
228
+ empty // hidden from stateName
229
+ preloaded // hidden from stateName
230
+
231
+ loaded
232
+ saved
233
+ updated
234
+ uncommitted
235
+ invalid
236
+ inFlight
237
+ created
238
+ uncommitted
239
+ invalid
240
+ inFlight
241
+
242
+ deleted
243
+ saved
244
+ new // hidden from stateName
245
+ uncommitted
246
+ invalid
247
+ inFlight
248
+
249
+ @hideconstructor
250
+ @private
251
+ */
252
+ var RecordState = class {
253
+ /** @internal */
254
+ /** @internal */
255
+ /** @internal */
256
+ /** @internal */
257
+ /** @internal */
258
+ /** @internal */
259
+ /** @internal */
260
+ /** @internal */
261
+ /** @internal */
262
+ /** @internal */
263
+ /** @internal */
264
+ constructor(record) {
265
+ const store = storeFor(record, false);
266
+ const identity = recordIdentifierFor$1(record);
267
+ this.identifier = identity;
268
+ this.record = record;
269
+ this.cache = store.cache;
270
+ this.pendingCount = 0;
271
+ this.fulfilledCount = 0;
272
+ this.rejectedCount = 0;
273
+ this._errorRequests = [];
274
+ this._lastError = null;
275
+ const requests = store.getRequestStateService();
276
+ const notifications = store.notifications;
277
+ const handleRequest = (req) => {
278
+ if (req.type === "mutation") switch (req.state) {
279
+ case "pending":
280
+ this.isSaving = true;
281
+ break;
282
+ case "rejected":
283
+ this.isSaving = false;
284
+ this._lastError = req;
285
+ if (!(req.response && isInvalidError(req.response.data))) this._errorRequests.push(req);
286
+ notifyErrorsStateChanged(this);
287
+ break;
288
+ case "fulfilled":
289
+ this._errorRequests = [];
290
+ this._lastError = null;
291
+ this.isSaving = false;
292
+ this.notify("isDirty");
293
+ notifyErrorsStateChanged(this);
294
+ }
295
+ else switch (req.state) {
296
+ case "pending":
297
+ this.pendingCount++;
298
+ this.notify("isLoading");
299
+ break;
300
+ case "rejected":
301
+ this.pendingCount--;
302
+ this._lastError = req;
303
+ if (!(req.response && isInvalidError(req.response.data))) this._errorRequests.push(req);
304
+ this.notify("isLoading");
305
+ notifyErrorsStateChanged(this);
306
+ break;
307
+ case "fulfilled":
308
+ this.pendingCount--;
309
+ this.fulfilledCount++;
310
+ this.notify("isLoading");
311
+ this.notify("isDirty");
312
+ notifyErrorsStateChanged(this);
313
+ this._errorRequests = [];
314
+ this._lastError = null;
315
+ }
316
+ };
317
+ requests.subscribeForRecord(identity, handleRequest);
318
+ const lastRequest = requests.getLastRequestForRecord(identity);
319
+ if (lastRequest) handleRequest(lastRequest);
320
+ this.handler = notifications.subscribe(identity, (identifier, type, key) => {
321
+ switch (type) {
322
+ case "state":
323
+ this.notify("isSaved");
324
+ this.notify("isNew");
325
+ this.notify("isDeleted");
326
+ this.notify("isDirty");
327
+ break;
328
+ case "attributes":
329
+ this.notify("isEmpty");
330
+ this.notify("isDirty");
331
+ break;
332
+ case "errors":
333
+ this.updateInvalidErrors(this.record.errors);
334
+ this.notify("isValid");
335
+ }
336
+ });
337
+ }
338
+ /** @internal */
339
+ destroy() {
340
+ storeFor(this.record, false).notifications.unsubscribe(this.handler);
341
+ }
342
+ /** @internal */
343
+ notify(key) {
344
+ const signals = withSignalStore(this);
345
+ const signal = peekInternalSignal(signals, key);
346
+ if (signal) notifyInternalSignal(signal);
347
+ }
348
+ /** @internal */
349
+ updateInvalidErrors(errors) {
350
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
351
+ if (!test) throw new Error(`Expected the Cache instance for ${this.identifier.lid} to implement getErrors(identifier)`);
352
+ })(typeof this.cache.getErrors === "function");
353
+ const jsonApiErrors = this.cache.getErrors(this.identifier);
354
+ errors.clear();
355
+ for (let i = 0; i < jsonApiErrors.length; i++) {
356
+ const error = jsonApiErrors[i];
357
+ if (error.source && error.source.pointer) {
358
+ const keyMatch = error.source.pointer.match(SOURCE_POINTER_REGEXP);
359
+ let key;
360
+ if (keyMatch) key = keyMatch[2];
361
+ else if (error.source.pointer.search(SOURCE_POINTER_PRIMARY_REGEXP) !== -1) key = PRIMARY_ATTRIBUTE_KEY;
362
+ if (key) {
363
+ const errMsg = error.detail || error.title;
364
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
365
+ if (!test) throw new Error(`Expected field error to have a detail or title to use as the message`);
366
+ })(errMsg);
367
+ errors.add(key, errMsg);
368
+ }
369
+ }
370
+ }
371
+ }
372
+ /** @internal */
373
+ cleanErrorRequests() {
374
+ this.notify("isValid");
375
+ this.notify("isError");
376
+ this.notify("adapterError");
377
+ this._errorRequests = [];
378
+ this._lastError = null;
379
+ }
380
+ get isLoading() {
381
+ return !this.isLoaded && this.pendingCount > 0 && this.fulfilledCount === 0;
382
+ }
383
+ static {
384
+ decorateMethodV2(this.prototype, "isLoading", [gate]);
385
+ }
386
+ get isLoaded() {
387
+ if (this.isNew) return true;
388
+ return this.fulfilledCount > 0 || !this.isEmpty;
389
+ }
390
+ static {
391
+ decorateMethodV2(this.prototype, "isLoaded", [gate]);
392
+ }
393
+ get isSaved() {
394
+ const rd = this.cache;
395
+ if (this.isDeleted) {
396
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
397
+ if (!test) throw new Error(`Expected Cache to implement isDeletionCommitted()`);
398
+ })(typeof rd.isDeletionCommitted === "function");
399
+ return rd.isDeletionCommitted(this.identifier);
400
+ }
401
+ if (this.isNew || this.isEmpty || !this.isValid || this.isDirty || this.isLoading) return false;
402
+ return true;
403
+ }
404
+ static {
405
+ decorateMethodV2(this.prototype, "isSaved", [gate]);
406
+ }
407
+ get isEmpty() {
408
+ const rd = this.cache;
409
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
410
+ if (!test) throw new Error(`Expected Cache to implement isEmpty()`);
411
+ })(typeof rd.isEmpty === "function");
412
+ return !this.isNew && rd.isEmpty(this.identifier);
413
+ }
414
+ static {
415
+ decorateMethodV2(this.prototype, "isEmpty", [gate]);
416
+ }
417
+ get isNew() {
418
+ const rd = this.cache;
419
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
420
+ if (!test) throw new Error(`Expected Cache to implement isNew()`);
421
+ })(typeof rd.isNew === "function");
422
+ return rd.isNew(this.identifier);
423
+ }
424
+ static {
425
+ decorateMethodV2(this.prototype, "isNew", [gate]);
426
+ }
427
+ get isDeleted() {
428
+ const rd = this.cache;
429
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
430
+ if (!test) throw new Error(`Expected Cache to implement isDeleted()`);
431
+ })(typeof rd.isDeleted === "function");
432
+ return rd.isDeleted(this.identifier);
433
+ }
434
+ static {
435
+ decorateMethodV2(this.prototype, "isDeleted", [gate]);
436
+ }
437
+ get isValid() {
438
+ return this.record.errors.length === 0;
439
+ }
440
+ static {
441
+ decorateMethodV2(this.prototype, "isValid", [gate]);
442
+ }
443
+ get isDirty() {
444
+ const rd = this.cache;
445
+ if (this.isEmpty || rd.isDeletionCommitted(this.identifier) || this.isDeleted && this.isNew) return false;
446
+ return this.isDeleted || this.isNew || rd.hasChangedAttrs(this.identifier);
447
+ }
448
+ static {
449
+ decorateMethodV2(this.prototype, "isDirty", [gate]);
450
+ }
451
+ get isError() {
452
+ if (!this._errorRequests[this._errorRequests.length - 1]) return false;
453
+ else return true;
454
+ }
455
+ static {
456
+ decorateMethodV2(this.prototype, "isError", [gate]);
457
+ }
458
+ get adapterError() {
459
+ const request = this._lastError;
460
+ if (!request) return null;
461
+ return request.state === "rejected" && request.response.data;
462
+ }
463
+ static {
464
+ decorateMethodV2(this.prototype, "adapterError", [gate]);
465
+ }
466
+ get isPreloaded() {
467
+ return !this.isEmpty && this.isLoading;
468
+ }
469
+ static {
470
+ decorateMethodV2(this.prototype, "isPreloaded", [memoized]);
471
+ }
472
+ get stateName() {
473
+ if (this.isLoading) return "root.loading";
474
+ else if (this.isEmpty) return "root.empty";
475
+ else if (this.isDeleted) {
476
+ if (this.isSaving) return "root.deleted.inFlight";
477
+ else if (this.isSaved) return "root.deleted.saved";
478
+ else if (!this.isValid) return "root.deleted.invalid";
479
+ else return "root.deleted.uncommitted";
480
+ } else if (this.isNew) {
481
+ if (this.isSaving) return "root.loaded.created.inFlight";
482
+ else if (!this.isValid) return "root.loaded.created.invalid";
483
+ return "root.loaded.created.uncommitted";
484
+ } else if (this.isSaving) return "root.loaded.updated.inFlight";
485
+ else if (!this.isValid) return "root.loaded.updated.invalid";
486
+ else if (this.isDirty) return "root.loaded.updated.uncommitted";
487
+ else return "root.loaded.saved";
488
+ }
489
+ static {
490
+ decorateMethodV2(this.prototype, "stateName", [memoized]);
491
+ }
492
+ get dirtyType() {
493
+ if (this.isLoading || this.isEmpty) return "";
494
+ else if (this.isDirty && this.isDeleted) return "deleted";
495
+ else if (this.isNew) return "created";
496
+ else if (this.isSaving || !this.isValid || this.isDirty) return "updated";
497
+ else return "";
498
+ }
499
+ static {
500
+ decorateMethodV2(this.prototype, "dirtyType", [memoized]);
501
+ }
502
+ };
503
+ defineSignal(RecordState.prototype, "isSaving", false);
504
+ function notifyErrorsStateChanged(state) {
505
+ state.notify("isValid");
506
+ state.notify("isError");
507
+ state.notify("adapterError");
508
+ }
509
+
510
+ //#endregion
511
+ //#region src/model/-private/model.ts
512
+ function computeOnce(target, propertyName, desc) {
513
+ const cache = /* @__PURE__ */ new WeakMap();
514
+ const getter = desc.get;
515
+ desc.get = function() {
516
+ let meta = cache.get(this);
517
+ if (!meta) {
518
+ meta = {
519
+ hasComputed: false,
520
+ value: void 0
521
+ };
522
+ cache.set(this, meta);
523
+ }
524
+ if (!meta.hasComputed) {
525
+ meta.value = getter.call(this);
526
+ meta.hasComputed = true;
527
+ }
528
+ return meta.value;
529
+ };
530
+ return desc;
531
+ }
532
+ /**
533
+ * Base class from which Models can be defined.
534
+ *
535
+ * ::: code-group
536
+ *
537
+ * ```js [app/models/user.js]
538
+ * import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model';
539
+ *
540
+ * export default class User extends Model {
541
+ * @attr name;
542
+ * @attr('number') age;
543
+ * @hasMany('post', { async: true, inverse: null }) posts;
544
+ * @belongsTo('group', { async: false, inverse: 'users' }) group;
545
+ * }
546
+ * ```
547
+ *
548
+ * ```ts [app/models/user.ts]
549
+ * import { Model, attr, belongsTo, hasMany, type AsyncHasMany } from '@warp-drive/legacy/model';
550
+ * import type { NumberTransform } from '@ember-data/serializer/transform';
551
+ * import type Group from './group';
552
+ * import type Post from './post';
553
+ *
554
+ * export default class User extends Model {
555
+ * @attr declare name: string;
556
+ *
557
+ * @attr<NumberTransform>('number')
558
+ * declare age: number;
559
+ *
560
+ * @hasMany('post', { async: true, inverse: null })
561
+ * declare posts: AsyncHasMany<Post>;
562
+ *
563
+ * @belongsTo('group', { async: false, inverse: 'users' })
564
+ * declare group: Group | null;
565
+ * }
566
+ * ```
567
+ *
568
+ * :::
569
+ *
570
+ * Models both define the schema for a resource type and provide
571
+ * the class to use as the reactive object for data of resource
572
+ * of that type.
573
+ *
574
+ * @public
575
+ * @noInheritDoc
576
+ * @hideconstructor
577
+ * @legacy
578
+ */
579
+ var Model = class extends EmberObject {
580
+ /** @internal */
581
+ init(options) {
582
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
583
+ if (!options?._secretInit && !options?._createProps) throw new Error("You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.");
584
+ }
585
+ const createProps = options._createProps;
586
+ const _secretInit = options._secretInit;
587
+ options._createProps = null;
588
+ options._secretInit = null;
589
+ const store = this.store = _secretInit.store;
590
+ super.init(options);
591
+ this[RecordStore] = store;
592
+ const identity = _secretInit.identifier;
593
+ _secretInit.cb(this, identity, _secretInit.store);
594
+ this.___recordState = macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? new RecordState(this) : null;
595
+ this.setProperties(createProps);
596
+ const notifications = store.notifications;
597
+ this.___private_notifications = notifications.subscribe(identity, (identifier, type, field) => {
598
+ notifyChanges(identifier, type, field, this, store);
599
+ });
600
+ }
601
+ /** @private */
602
+ destroy() {
603
+ const identifier = recordIdentifierFor(this);
604
+ this.___recordState?.destroy();
605
+ storeFor(this, false).notifications.unsubscribe(this.___private_notifications);
606
+ const support = LEGACY_SUPPORT.get(identifier);
607
+ if (support) {
608
+ support.destroy();
609
+ LEGACY_SUPPORT.delete(identifier);
610
+ }
611
+ super.destroy();
612
+ }
613
+ /**
614
+ If this property is `true` the record is in the `empty`
615
+ state. Empty is the first state all records enter after they have
616
+ been created. Most records created by the store will quickly
617
+ transition to the `loading` state if data needs to be fetched from
618
+ the server or the `created` state if the record is created on the
619
+ client. A record can also enter the empty state if the adapter is
620
+ unable to locate the record.
621
+ @public
622
+ */
623
+ get isEmpty() {
624
+ return this.currentState.isEmpty;
625
+ }
626
+ /**
627
+ If this property is `true` the record is in the `loading` state. A
628
+ record enters this state when the store asks the adapter for its
629
+ data. It remains in this state until the adapter provides the
630
+ requested data.
631
+ @public
632
+ */
633
+ static {
634
+ decorateMethodV2(this.prototype, "isEmpty", [memoized]);
635
+ }
636
+ get isLoading() {
637
+ return this.currentState.isLoading;
638
+ }
639
+ /**
640
+ If this property is `true` the record is in the `loaded` state. A
641
+ record enters this state when its data is populated. Most of a
642
+ record's lifecycle is spent inside substates of the `loaded`
643
+ state.
644
+ Example
645
+ ```javascript
646
+ let record = store.createRecord('model');
647
+ record.isLoaded; // true
648
+ const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));
649
+ model.isLoaded;
650
+ ```
651
+ @public
652
+ */
653
+ static {
654
+ decorateMethodV2(this.prototype, "isLoading", [memoized]);
655
+ }
656
+ get isLoaded() {
657
+ return this.currentState.isLoaded;
658
+ }
659
+ /**
660
+ If this property is `true` the record is in the `dirty` state. The
661
+ record has local changes that have not yet been saved by the
662
+ adapter. This includes records that have been created (but not yet
663
+ saved) or deleted.
664
+ Example
665
+ ```javascript
666
+ let record = store.createRecord('model');
667
+ record.hasDirtyAttributes; // true
668
+ const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));
669
+ model.hasDirtyAttributes; // false
670
+ model.foo = 'some value';
671
+ model.hasDirtyAttributes; // true
672
+ ```
673
+ @since 1.13.0
674
+ @public
675
+ */
676
+ static {
677
+ decorateMethodV2(this.prototype, "isLoaded", [memoized]);
678
+ }
679
+ get hasDirtyAttributes() {
680
+ return this.currentState.isDirty;
681
+ }
682
+ /**
683
+ If this property is `true` the record is in the `saving` state. A
684
+ record enters the saving state when `save` is called, but the
685
+ adapter has not yet acknowledged that the changes have been
686
+ persisted to the backend.
687
+ Example
688
+ ```javascript
689
+ let record = store.createRecord('model');
690
+ record.isSaving; // false
691
+ let promise = record.save();
692
+ record.isSaving; // true
693
+ promise.then(function() {
694
+ record.isSaving; // false
695
+ });
696
+ ```
697
+ @public
698
+ */
699
+ static {
700
+ decorateMethodV2(this.prototype, "hasDirtyAttributes", [memoized]);
701
+ }
702
+ get isSaving() {
703
+ return this.currentState.isSaving;
704
+ }
705
+ /**
706
+ If this property is `true` the record is in the `deleted` state
707
+ and has been marked for deletion. When `isDeleted` is true and
708
+ `hasDirtyAttributes` is true, the record is deleted locally but the deletion
709
+ was not yet persisted. When `isSaving` is true, the change is
710
+ in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the
711
+ change has persisted.
712
+ Example
713
+ ```javascript
714
+ let record = store.createRecord('model');
715
+ record.isDeleted; // false
716
+ record.deleteRecord();
717
+ // Locally deleted
718
+ record.isDeleted; // true
719
+ record.hasDirtyAttributes; // true
720
+ record.isSaving; // false
721
+ // Persisting the deletion
722
+ let promise = record.save();
723
+ record.isDeleted; // true
724
+ record.isSaving; // true
725
+ // Deletion Persisted
726
+ promise.then(function() {
727
+ record.isDeleted; // true
728
+ record.isSaving; // false
729
+ record.hasDirtyAttributes; // false
730
+ });
731
+ ```
732
+ @public
733
+ */
734
+ static {
735
+ decorateMethodV2(this.prototype, "isSaving", [memoized]);
736
+ }
737
+ get isDeleted() {
738
+ return this.currentState.isDeleted;
739
+ }
740
+ /**
741
+ If this property is `true` the record is in the `new` state. A
742
+ record will be in the `new` state when it has been created on the
743
+ client and the adapter has not yet report that it was successfully
744
+ saved.
745
+ Example
746
+ ```javascript
747
+ let record = store.createRecord('model');
748
+ record.isNew; // true
749
+ record.save().then(function(model) {
750
+ model.isNew; // false
751
+ });
752
+ ```
753
+ @public
754
+ */
755
+ static {
756
+ decorateMethodV2(this.prototype, "isDeleted", [memoized]);
757
+ }
758
+ get isNew() {
759
+ return this.currentState.isNew;
760
+ }
761
+ /**
762
+ If this property is `true` the record is in the `valid` state.
763
+ A record will be in the `valid` state when the adapter did not report any
764
+ server-side validation failures.
765
+ @public
766
+ */
767
+ static {
768
+ decorateMethodV2(this.prototype, "isNew", [memoized]);
769
+ }
770
+ get isValid() {
771
+ return this.currentState.isValid;
772
+ }
773
+ /**
774
+ If the record is in the dirty state this property will report what
775
+ kind of change has caused it to move into the dirty
776
+ state. Possible values are:
777
+ - `created` The record has been created by the client and not yet saved to the adapter.
778
+ - `updated` The record has been updated by the client and not yet saved to the adapter.
779
+ - `deleted` The record has been deleted by the client and not yet saved to the adapter.
780
+ Example
781
+ ```javascript
782
+ let record = store.createRecord('model');
783
+ record.dirtyType; // 'created'
784
+ ```
785
+ @public
786
+ */
787
+ static {
788
+ decorateMethodV2(this.prototype, "isValid", [memoized]);
789
+ }
790
+ get dirtyType() {
791
+ return this.currentState.dirtyType;
792
+ }
793
+ /**
794
+ If `true` the adapter reported that it was unable to save local
795
+ changes to the backend for any reason other than a server-side
796
+ validation error.
797
+ Example
798
+ ```javascript
799
+ record.isError; // false
800
+ record.set('foo', 'valid value');
801
+ record.save().then(null, function() {
802
+ record.isError; // true
803
+ });
804
+ ```
805
+ @public
806
+ */
807
+ static {
808
+ decorateMethodV2(this.prototype, "dirtyType", [memoized]);
809
+ }
810
+ get isError() {
811
+ return this.currentState.isError;
812
+ }
813
+ /**
814
+ * `isError` is read-only and cannot be set directly.
815
+ */
816
+ static {
817
+ decorateMethodV2(this.prototype, "isError", [memoized]);
818
+ }
819
+ set isError(v) {
820
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) throw new Error(`isError is not directly settable`);
821
+ }
822
+ /**
823
+ If `true` the store is attempting to reload the record from the adapter.
824
+ Example
825
+ ```javascript
826
+ record.isReloading; // false
827
+ record.reload();
828
+ record.isReloading; // true
829
+ ```
830
+ @public
831
+ */
832
+ /**
833
+ All ember models have an id property. This is an identifier
834
+ managed by an external source. These are always coerced to be
835
+ strings before being used internally. Note when declaring the
836
+ attributes for a model it is an error to declare an id
837
+ attribute.
838
+ ```javascript
839
+ let record = store.createRecord('model');
840
+ record.id; // null
841
+ const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));
842
+ model.id; // '1'
843
+ ```
844
+ @public
845
+ */
846
+ get id() {
847
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) try {
848
+ return recordIdentifierFor(this).id;
849
+ } catch {
850
+ return null;
851
+ }
852
+ return recordIdentifierFor(this).id;
853
+ }
854
+ /**
855
+ * Assigns the resource's primary key. Typically only used internally
856
+ * when a client-created record is assigned an id upon being saved.
857
+ */
858
+ static {
859
+ decorateMethodV2(this.prototype, "id", [gate]);
860
+ }
861
+ set id(id) {
862
+ const normalizedId = coerceId(id);
863
+ const identifier = recordIdentifierFor(this);
864
+ const didChange = normalizedId !== identifier.id;
865
+ assertPrivateStore(this.store);
866
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
867
+ if (!test) throw new Error(`Cannot set ${identifier.type} record's id to ${id}, because id is already ${identifier.id}`);
868
+ })(!didChange || identifier.id === null);
869
+ if (normalizedId !== null && didChange) {
870
+ this.store._instanceCache.setRecordId(identifier, normalizedId);
871
+ this.store.notifications.notify(identifier, "identity", null);
872
+ }
873
+ }
874
+ toString() {
875
+ return `<model::${this.constructor.modelName}:${this.id}>`;
876
+ }
877
+ /**
878
+ @private
879
+ */
880
+ get currentState() {
881
+ if (macroCondition(!getGlobalConfig().WarpDrive.env.DEBUG)) {
882
+ if (!this.___recordState) this.___recordState = new RecordState(this);
883
+ }
884
+ return this.___recordState;
885
+ }
886
+ /**
887
+ * `currentState` is read-only and cannot be set directly.
888
+ */
889
+ static {
890
+ decorateMethodV2(this.prototype, "currentState", [gate]);
891
+ }
892
+ set currentState(_v) {
893
+ throw new Error("cannot set currentState");
894
+ }
895
+ /**
896
+ The store service instance which created this record instance
897
+ @public
898
+ */
899
+ /**
900
+ When the record is in the `invalid` state this object will contain
901
+ any errors returned by the adapter. When present the errors hash
902
+ contains keys corresponding to the invalid property names
903
+ and values which are arrays of Javascript objects with two keys:
904
+ - `message` A string containing the error message from the backend
905
+ - `attribute` The name of the property associated with this error message
906
+ ```javascript
907
+ record.errors.length; // 0
908
+ record.set('foo', 'invalid value');
909
+ record.save().catch(function() {
910
+ record.errors.foo;
911
+ // [{message: 'foo should be a number.', attribute: 'foo'}]
912
+ });
913
+ ```
914
+ The `errors` property is useful for displaying error messages to
915
+ the user.
916
+ ```handlebars
917
+ <label>Username: <Input @value={{@model.username}} /> </label>
918
+ {{#each @model.errors.username as |error|}}
919
+ <div class="error">
920
+ {{error.message}}
921
+ </div>
922
+ {{/each}}
923
+ <label>Email: <Input @value={{@model.email}} /> </label>
924
+ {{#each @model.errors.email as |error|}}
925
+ <div class="error">
926
+ {{error.message}}
927
+ </div>
928
+ {{/each}}
929
+ ```
930
+ You can also access the special `messages` property on the error
931
+ object to get an array of all the error strings.
932
+ ```handlebars
933
+ {{#each @model.errors.messages as |message|}}
934
+ <div class="error">
935
+ {{message}}
936
+ </div>
937
+ {{/each}}
938
+ ```
939
+ @public
940
+ */
941
+ get errors() {
942
+ const errors = Errors.create({ __record: this });
943
+ this.currentState.updateInvalidErrors(errors);
944
+ return errors;
945
+ }
946
+ /**
947
+ This property holds the `AdapterError` object with which
948
+ last adapter operation was rejected.
949
+ @public
950
+ */
951
+ static {
952
+ decorateMethodV2(this.prototype, "errors", [computeOnce]);
953
+ }
954
+ get adapterError() {
955
+ return this.currentState.adapterError;
956
+ }
957
+ /**
958
+ * `adapterError` is read-only and cannot be set directly.
959
+ */
960
+ static {
961
+ decorateMethodV2(this.prototype, "adapterError", [memoized]);
962
+ }
963
+ set adapterError(v) {
964
+ throw new Error(`adapterError is not directly settable`);
965
+ }
966
+ notifyPropertyChange(prop) {
967
+ const signals = withSignalStore(this);
968
+ entangleSignal(signals, this, prop, void 0);
969
+ super.notifyPropertyChange(prop);
970
+ }
971
+ /** @internal */
972
+ attr() {
973
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
974
+ if (!test) throw new Error("The `attr` method is not available on Model, a Snapshot was probably expected. Are you passing a Model instead of a Snapshot to your serializer?");
975
+ })(false);
976
+ }
977
+ /**
978
+ Given a callback, iterates over each of the relationships in the model,
979
+ invoking the callback with the name of each relationship and its relationship
980
+ descriptor.
981
+ The callback method you provide should have the following signature (all
982
+ parameters are optional):
983
+ ```javascript
984
+ function(name, descriptor);
985
+ ```
986
+ - `name` the name of the current property in the iteration
987
+ - `descriptor` the meta object that describes this relationship
988
+ The relationship descriptor argument is an object with the following properties.
989
+ - **name** <span class="type">String</span> the name of this relationship on the Model
990
+ - **kind** <span class="type">String</span> "hasMany" or "belongsTo"
991
+ - **options** <span class="type">Object</span> the original options hash passed when the relationship was declared
992
+ - **parentType** <span class="type">Model</span> the type of the Model that owns this relationship
993
+ - **type** <span class="type">String</span> the type name of the related Model
994
+ Note that in addition to a callback, you can also pass an optional target
995
+ object that will be set as `this` on the context.
996
+ Example
997
+ ```js [app/serializers/application.js]
998
+ import JSONSerializer from '@ember-data/serializer/json';
999
+ export default class ApplicationSerializer extends JSONSerializer {
1000
+ serialize(record, options) {
1001
+ let json = {};
1002
+ record.eachRelationship(function(name, descriptor) {
1003
+ if (descriptor.kind === 'hasMany') {
1004
+ let serializedHasManyName = name.toUpperCase() + '_IDS';
1005
+ json[serializedHasManyName] = record.get(name).map(r => r.id);
1006
+ }
1007
+ });
1008
+ return json;
1009
+ }
1010
+ }
1011
+ ```
1012
+ @public
1013
+ @param callback the callback to invoke
1014
+ @param binding the value to which the callback's `this` should be bound
1015
+ */
1016
+ eachRelationship(callback, binding) {
1017
+ this.constructor.eachRelationship(callback, binding);
1018
+ }
1019
+ /**
1020
+ * Returns the relationship schema for the given relationship name, if any.
1021
+ */
1022
+ relationshipFor(name) {
1023
+ return this.constructor.relationshipsByName.get(name);
1024
+ }
1025
+ /**
1026
+ * Returns the inverse relationship schema for the given relationship
1027
+ * name, if one exists. See {@link Model.inverseFor | the static inverseFor}.
1028
+ */
1029
+ inverseFor(name) {
1030
+ return this.constructor.inverseFor(name, storeFor(this, false));
1031
+ }
1032
+ /**
1033
+ * Iterates over the attributes defined on this record's class, calling
1034
+ * `callback` for each one. See {@link Model.eachAttribute | the static eachAttribute}.
1035
+ *
1036
+ * @param callback the callback to invoke
1037
+ * @param binding the value to which the callback's `this` should be bound
1038
+ */
1039
+ eachAttribute(callback, binding) {
1040
+ this.constructor.eachAttribute(callback, binding);
1041
+ }
1042
+ /**
1043
+ * @internal
1044
+ */
1045
+ static isModel = true;
1046
+ /**
1047
+ Represents the model's class name as a string. This can be used to look up the model's class name through
1048
+ `Store`'s modelFor method.
1049
+ `modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
1050
+ For example:
1051
+ ```javascript
1052
+ store.modelFor('post').modelName; // 'post'
1053
+ store.modelFor('blog-post').modelName; // 'blog-post'
1054
+ ```
1055
+ The most common place you'll want to access `modelName` is in your serializer's `payloadKeyFromModelName` method. For example, to change payload
1056
+ keys to underscore (instead of dasherized), you might use the following code:
1057
+ ```javascript
1058
+ import RESTSerializer from '@ember-data/serializer/rest';
1059
+ import { underscore } from '<app-name>/utils/string-utils';
1060
+ export default const PostSerializer = RESTSerializer.extend({
1061
+ payloadKeyFromModelName(modelName) {
1062
+ return underscore(modelName);
1063
+ }
1064
+ });
1065
+ ```
1066
+ @public
1067
+ */
1068
+ static modelName = null;
1069
+ /**
1070
+ For a given relationship name, returns the model type of the relationship.
1071
+ For example, if you define a model like this:
1072
+ ```js [app/models/post.js]
1073
+ import { Model, hasMany } from '@warp-drive/legacy/model';
1074
+ export default class PostModel extends Model {
1075
+ @hasMany('comment') comments;
1076
+ }
1077
+ ```
1078
+ Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.
1079
+ @public
1080
+ @param name the name of the relationship
1081
+ @param store an instance of Store
1082
+ @return the type of the relationship, or undefined
1083
+ */
1084
+ static typeForRelationship(name, store) {
1085
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1086
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1087
+ })(this.modelName);
1088
+ const relationship = this.relationshipsByName.get(name);
1089
+ return relationship && store.modelFor(relationship.type);
1090
+ }
1091
+ /**
1092
+ * A cache of resolved inverse relationships by name, populated lazily by
1093
+ * {@link Model.inverseFor | inverseFor}.
1094
+ */
1095
+ static get inverseMap() {
1096
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1097
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1098
+ })(this.modelName);
1099
+ return Object.create(null);
1100
+ }
1101
+ /**
1102
+ Find the relationship which is the inverse of the one asked for.
1103
+ For example, if you define models like this:
1104
+ ```js [app/models/post.js]
1105
+ import { Model, hasMany } from '@warp-drive/legacy/model';
1106
+ export default class PostModel extends Model {
1107
+ @hasMany('message') comments;
1108
+ }
1109
+ ```
1110
+ ```js [app/models/message.js]
1111
+ import { Model, belongsTo } from '@warp-drive/legacy/model';
1112
+ export default class MessageModel extends Model {
1113
+ @belongsTo('post') owner;
1114
+ }
1115
+ ```
1116
+ ``` js
1117
+ store.modelFor('post').inverseFor('comments', store) // { type: 'message', name: 'owner', kind: 'belongsTo' }
1118
+ store.modelFor('message').inverseFor('owner', store) // { type: 'post', name: 'comments', kind: 'hasMany' }
1119
+ ```
1120
+ @public
1121
+ @param name the name of the relationship
1122
+ @param store
1123
+ @return the inverse relationship, or null
1124
+ */
1125
+ static {
1126
+ decorateMethodV2(this, "inverseMap", [computeOnce]);
1127
+ }
1128
+ static inverseFor(name, store) {
1129
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1130
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1131
+ })(this.modelName);
1132
+ const inverseMap = this.inverseMap;
1133
+ if (inverseMap[name]) return inverseMap[name];
1134
+ else {
1135
+ const inverse = this._findInverseFor(name, store);
1136
+ inverseMap[name] = inverse;
1137
+ return inverse;
1138
+ }
1139
+ }
1140
+ /**
1141
+ * @private
1142
+ */
1143
+ static _findInverseFor(name, store) {
1144
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1145
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1146
+ })(this.modelName);
1147
+ const relationship = this.relationshipsByName.get(name);
1148
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1149
+ if (!test) throw new Error(`No relationship named '${name}' on '${this.modelName}' exists.`);
1150
+ })(relationship);
1151
+ if (!relationship) return null;
1152
+ const { options } = relationship;
1153
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1154
+ if (!test) throw new Error(`Expected the relationship ${name} on ${this.modelName} to define an inverse.`);
1155
+ })(options.inverse === null || typeof options.inverse === "string" && options.inverse.length > 0);
1156
+ if (options.inverse === null) return null;
1157
+ const schemaExists = store.schema.hasResource(relationship);
1158
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1159
+ if (!test) throw new Error(`No associated schema found for '${relationship.type}' while calculating the inverse of ${name} on ${this.modelName}`);
1160
+ })(schemaExists);
1161
+ if (!schemaExists) return null;
1162
+ const inverseField = store.schema.fields(relationship).get(options.inverse);
1163
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1164
+ if (!test) throw new Error(`No inverse relationship found for '${name}' on '${this.modelName}'`);
1165
+ })(inverseField && (inverseField.kind === "belongsTo" || inverseField.kind === "hasMany"));
1166
+ return inverseField || null;
1167
+ }
1168
+ /**
1169
+ The model's relationships as a map, keyed on the type of the
1170
+ relationship. The value of each entry is an array containing a descriptor
1171
+ for each relationship with that type, describing the name of the relationship
1172
+ as well as the type.
1173
+ For example, given the following model definition:
1174
+ ```js [app/models/blog.js]
1175
+ import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';
1176
+ export default class BlogModel extends Model {
1177
+ @hasMany('user') users;
1178
+ @belongsTo('user') owner;
1179
+ @hasMany('post') posts;
1180
+ }
1181
+ ```
1182
+ This computed property would return a map describing these
1183
+ relationships, like this:
1184
+ ```javascript
1185
+ import Blog from 'app/models/blog';
1186
+ import User from 'app/models/user';
1187
+ import Post from 'app/models/post';
1188
+ let relationships = Blog.relationships;
1189
+ relationships.user;
1190
+ //=> [ { name: 'users', kind: 'hasMany' },
1191
+ // { name: 'owner', kind: 'belongsTo' } ]
1192
+ relationships.post;
1193
+ //=> [ { name: 'posts', kind: 'hasMany' } ]
1194
+ ```
1195
+ @public
1196
+ */
1197
+ static get relationships() {
1198
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1199
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1200
+ })(this.modelName);
1201
+ const map = /* @__PURE__ */ new Map();
1202
+ this.relationshipsByName.forEach((desc) => {
1203
+ const { type } = desc;
1204
+ if (!map.has(type)) map.set(type, []);
1205
+ map.get(type).push(desc);
1206
+ });
1207
+ return map;
1208
+ }
1209
+ /**
1210
+ A hash containing lists of the model's relationships, grouped
1211
+ by the relationship kind. For example, given a model with this
1212
+ definition:
1213
+ ```js [app/models/blog.js]
1214
+ import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';
1215
+ export default class BlogModel extends Model {
1216
+ @hasMany('user') users;
1217
+ @belongsTo('user') owner;
1218
+ @hasMany('post') posts;
1219
+ }
1220
+ ```
1221
+ This property would contain the following:
1222
+ ```javascript
1223
+ import Blog from 'app/models/blog';
1224
+ let relationshipNames = Blog.relationshipNames;
1225
+ relationshipNames.hasMany;
1226
+ //=> ['users', 'posts']
1227
+ relationshipNames.belongsTo;
1228
+ //=> ['owner']
1229
+ ```
1230
+ @public
1231
+ */
1232
+ static {
1233
+ decorateMethodV2(this, "relationships", [computeOnce]);
1234
+ }
1235
+ static get relationshipNames() {
1236
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1237
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1238
+ })(this.modelName);
1239
+ const names = {
1240
+ hasMany: [],
1241
+ belongsTo: []
1242
+ };
1243
+ this.eachComputedProperty((name, meta) => {
1244
+ if (isRelationshipSchema(meta)) names[meta.kind].push(name);
1245
+ });
1246
+ return names;
1247
+ }
1248
+ /**
1249
+ An array of types directly related to a model. Each type will be
1250
+ included once, regardless of the number of relationships it has with
1251
+ the model.
1252
+ For example, given a model with this definition:
1253
+ ```js [app/models/blog.js]
1254
+ import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';
1255
+ export default class BlogModel extends Model {
1256
+ @hasMany('user') users;
1257
+ @belongsTo('user') owner;
1258
+ @hasMany('post') posts;
1259
+ }
1260
+ ```
1261
+ This property would contain the following:
1262
+ ```javascript
1263
+ import Blog from 'app/models/blog';
1264
+ let relatedTypes = Blog.relatedTypes');
1265
+ //=> ['user', 'post']
1266
+ ```
1267
+ @public
1268
+ */
1269
+ static {
1270
+ decorateMethodV2(this, "relationshipNames", [computeOnce]);
1271
+ }
1272
+ static get relatedTypes() {
1273
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1274
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1275
+ })(this.modelName);
1276
+ const types = [];
1277
+ const rels = this.relationshipsObject;
1278
+ const relationships = Object.keys(rels);
1279
+ for (let i = 0; i < relationships.length; i++) {
1280
+ const modelName = rels[relationships[i]].type;
1281
+ if (!types.includes(modelName)) types.push(modelName);
1282
+ }
1283
+ return types;
1284
+ }
1285
+ /**
1286
+ A map whose keys are the relationships of a model and whose values are
1287
+ relationship descriptors.
1288
+ For example, given a model with this
1289
+ definition:
1290
+ ```js [app/models/blog.js]
1291
+ import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model';
1292
+ export default class BlogModel extends Model {
1293
+ @hasMany('user') users;
1294
+ @belongsTo('user') owner;
1295
+ @hasMany('post') posts;
1296
+ }
1297
+ ```
1298
+ This property would contain the following:
1299
+ ```javascript
1300
+ import Blog from 'app/models/blog';
1301
+ let relationshipsByName = Blog.relationshipsByName;
1302
+ relationshipsByName.users;
1303
+ //=> { name: 'users', kind: 'hasMany', type: 'user', options: Object }
1304
+ relationshipsByName.owner;
1305
+ //=> { name: 'owner', kind: 'belongsTo', type: 'user', options: Object }
1306
+ ```
1307
+ @public
1308
+ */
1309
+ static {
1310
+ decorateMethodV2(this, "relatedTypes", [computeOnce]);
1311
+ }
1312
+ static get relationshipsByName() {
1313
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1314
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1315
+ })(this.modelName);
1316
+ const map = /* @__PURE__ */ new Map();
1317
+ const rels = this.relationshipsObject;
1318
+ const relationships = Object.keys(rels);
1319
+ for (let i = 0; i < relationships.length; i++) {
1320
+ const value = rels[relationships[i]];
1321
+ map.set(value.name, value);
1322
+ }
1323
+ return map;
1324
+ }
1325
+ /**
1326
+ * A hash of the model's relationship schemas keyed by relationship name.
1327
+ * See also {@link Model.relationshipsByName | relationshipsByName}, which
1328
+ * provides the same information as a `Map`.
1329
+ */
1330
+ static {
1331
+ decorateMethodV2(this, "relationshipsByName", [computeOnce]);
1332
+ }
1333
+ static get relationshipsObject() {
1334
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1335
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1336
+ })(this.modelName);
1337
+ const relationships = Object.create(null);
1338
+ const modelName = this.modelName;
1339
+ this.eachComputedProperty((name, meta) => {
1340
+ if (!isRelationshipSchema(meta)) return;
1341
+ meta.key = name;
1342
+ meta.name = name;
1343
+ relationships[name] = meta;
1344
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1345
+ if (!test) throw new Error(`Expected options in meta`);
1346
+ })(meta.options && typeof meta.options === "object");
1347
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1348
+ if (!test) throw new Error(`You should not specify both options.as and options.inverse as null on ${modelName}.${meta.name}, as if there is no inverse field there is no abstract type to conform to. You may have intended for this relationship to be polymorphic, or you may have mistakenly set inverse to null.`);
1349
+ })(!(meta.options.inverse === null && meta.options.as?.length));
1350
+ });
1351
+ return relationships;
1352
+ }
1353
+ /**
1354
+ A map whose keys are the fields of the model and whose values are strings
1355
+ describing the kind of the field. A model's fields are the union of all of its
1356
+ attributes and relationships.
1357
+ For example:
1358
+ ```js [app/models/blog.js]
1359
+ import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model';
1360
+ export default class BlogModel extends Model {
1361
+ @hasMany('user') users;
1362
+ @belongsTo('user') owner;
1363
+ @hasMany('post') posts;
1364
+ @attr('string') title;
1365
+ }
1366
+ ```
1367
+ ```js
1368
+ import Blog from 'app/models/blog'
1369
+ let fields = Blog.fields;
1370
+ fields.forEach(function(kind, field) {
1371
+ // do thing
1372
+ });
1373
+ // prints:
1374
+ // users, hasMany
1375
+ // owner, belongsTo
1376
+ // posts, hasMany
1377
+ // title, attribute
1378
+ ```
1379
+ @public
1380
+ */
1381
+ static {
1382
+ decorateMethodV2(this, "relationshipsObject", [computeOnce]);
1383
+ }
1384
+ static get fields() {
1385
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1386
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1387
+ })(this.modelName);
1388
+ const map = /* @__PURE__ */ new Map();
1389
+ this.eachComputedProperty((name, meta) => {
1390
+ if (isRelationshipSchema(meta)) map.set(name, meta.kind);
1391
+ else if (isAttributeSchema(meta)) map.set(name, "attribute");
1392
+ });
1393
+ return map;
1394
+ }
1395
+ /**
1396
+ Given a callback, iterates over each of the relationships in the model,
1397
+ invoking the callback with the name of each relationship and its relationship
1398
+ descriptor.
1399
+ @public
1400
+ @param callback the callback to invoke
1401
+ @param binding the value to which the callback's `this` should be bound
1402
+ */
1403
+ static {
1404
+ decorateMethodV2(this, "fields", [computeOnce]);
1405
+ }
1406
+ static eachRelationship(callback, binding) {
1407
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1408
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1409
+ })(this.modelName);
1410
+ this.relationshipsByName.forEach((relationship, name) => {
1411
+ callback.call(binding, name, relationship);
1412
+ });
1413
+ }
1414
+ /**
1415
+ Given a callback, iterates over each of the types related to a model,
1416
+ invoking the callback with the related type's class. Each type will be
1417
+ returned just once, regardless of how many different relationships it has
1418
+ with a model.
1419
+ @public
1420
+ @param callback the callback to invoke
1421
+ @param binding the value to which the callback's `this` should be bound
1422
+ */
1423
+ static eachRelatedType(callback, binding) {
1424
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1425
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1426
+ })(this.modelName);
1427
+ const relationshipTypes = this.relatedTypes;
1428
+ for (let i = 0; i < relationshipTypes.length; i++) {
1429
+ const type = relationshipTypes[i];
1430
+ callback.call(binding, type);
1431
+ }
1432
+ }
1433
+ /**
1434
+ *
1435
+ * @private
1436
+ * @deprecated
1437
+ */
1438
+ static determineRelationshipType(knownSide, store) {
1439
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1440
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1441
+ })(this.modelName);
1442
+ const knownKey = knownSide.name;
1443
+ const knownKind = knownSide.kind;
1444
+ const inverse = this.inverseFor(knownKey, store);
1445
+ if (!inverse) return knownKind === "belongsTo" ? "oneToNone" : "manyToNone";
1446
+ if (inverse.kind === "belongsTo") return knownKind === "belongsTo" ? "oneToOne" : "manyToOne";
1447
+ else return knownKind === "belongsTo" ? "oneToMany" : "manyToMany";
1448
+ }
1449
+ /**
1450
+ A map whose keys are the attributes of the model (properties
1451
+ described by attr) and whose values are the meta object for the
1452
+ property.
1453
+ Example
1454
+ ```js [app/models/person.js]
1455
+ import { Model, attr } from '@warp-drive/legacy/model';
1456
+ export default class PersonModel extends Model {
1457
+ @attr('string') firstName;
1458
+ @attr('string') lastName;
1459
+ @attr('date') birthday;
1460
+ }
1461
+ ```
1462
+ ```javascript
1463
+ import Person from 'app/models/person'
1464
+ let attributes = Person.attributes
1465
+ attributes.forEach(function(meta, name) {
1466
+ // do thing
1467
+ });
1468
+ // prints:
1469
+ // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"}
1470
+ // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"}
1471
+ // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"}
1472
+ ```
1473
+ @public
1474
+ */
1475
+ static get attributes() {
1476
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1477
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1478
+ })(this.modelName);
1479
+ const map = /* @__PURE__ */ new Map();
1480
+ this.eachComputedProperty((name, meta) => {
1481
+ if (isAttributeSchema(meta)) {
1482
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1483
+ if (!test) throw new Error("You may not set 'id' as an attribute on your model. Please remove any lines that look like: `id: attr('<type>')` from " + this.toString());
1484
+ })(name !== "id");
1485
+ meta.key = name;
1486
+ meta.name = name;
1487
+ map.set(name, meta);
1488
+ }
1489
+ });
1490
+ return map;
1491
+ }
1492
+ /**
1493
+ A map whose keys are the attributes of the model (properties
1494
+ described by attr) and whose values are type of transformation
1495
+ applied to each attribute. This map does not include any
1496
+ attributes that do not have an transformation type.
1497
+ Example
1498
+ ```js [app/models/person.js]
1499
+ import { Model, attr } from '@warp-drive/legacy/model';
1500
+ export default class PersonModel extends Model {
1501
+ @attr firstName;
1502
+ @attr('string') lastName;
1503
+ @attr('date') birthday;
1504
+ }
1505
+ ```
1506
+ ```javascript
1507
+ import Person from 'app/models/person';
1508
+ let transformedAttributes = Person.transformedAttributes
1509
+ transformedAttributes.forEach(function(field, type) {
1510
+ // do thing
1511
+ });
1512
+ // prints:
1513
+ // lastName string
1514
+ // birthday date
1515
+ ```
1516
+ @public
1517
+ */
1518
+ static {
1519
+ decorateMethodV2(this, "attributes", [computeOnce]);
1520
+ }
1521
+ static get transformedAttributes() {
1522
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1523
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1524
+ })(this.modelName);
1525
+ const map = /* @__PURE__ */ new Map();
1526
+ this.eachAttribute((name, meta) => {
1527
+ if (meta.type) map.set(name, meta.type);
1528
+ });
1529
+ return map;
1530
+ }
1531
+ /**
1532
+ Iterates through the attributes of the model, calling the passed function on each
1533
+ attribute.
1534
+ The callback method you provide should have the following signature (all
1535
+ parameters are optional):
1536
+ ```javascript
1537
+ function(name, meta);
1538
+ ```
1539
+ - `name` the name of the current property in the iteration
1540
+ - `meta` the meta object for the attribute property in the iteration
1541
+ Note that in addition to a callback, you can also pass an optional target
1542
+ object that will be set as `this` on the context.
1543
+ Example
1544
+ ```javascript
1545
+ import { Model, attr } from '@warp-drive/legacy/model';
1546
+ class PersonModel extends Model {
1547
+ @attr('string') firstName;
1548
+ @attr('string') lastName;
1549
+ @attr('date') birthday;
1550
+ }
1551
+ PersonModel.eachAttribute(function(name, meta) {
1552
+ // do thing
1553
+ });
1554
+ // prints:
1555
+ // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"}
1556
+ // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"}
1557
+ // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"}
1558
+ ```
1559
+ @public
1560
+ @param callback The callback to execute
1561
+ @param binding [optional] the value to which the callback's `this` should be bound
1562
+ */
1563
+ static {
1564
+ decorateMethodV2(this, "transformedAttributes", [computeOnce]);
1565
+ }
1566
+ static eachAttribute(callback, binding) {
1567
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1568
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1569
+ })(this.modelName);
1570
+ this.attributes.forEach((meta, name) => {
1571
+ callback.call(binding, name, meta);
1572
+ });
1573
+ }
1574
+ /**
1575
+ Iterates through the transformedAttributes of the model, calling
1576
+ the passed function on each attribute. Note the callback will not be
1577
+ called for any attributes that do not have an transformation type.
1578
+ The callback method you provide should have the following signature (all
1579
+ parameters are optional):
1580
+ ```javascript
1581
+ function(name, type);
1582
+ ```
1583
+ - `name` the name of the current property in the iteration
1584
+ - `type` a string containing the name of the type of transformed
1585
+ applied to the attribute
1586
+ Note that in addition to a callback, you can also pass an optional target
1587
+ object that will be set as `this` on the context.
1588
+ Example
1589
+ ```javascript
1590
+ import { Model, attr } from '@warp-drive/legacy/model';
1591
+ let Person = Model.extend({
1592
+ firstName: attr(),
1593
+ lastName: attr('string'),
1594
+ birthday: attr('date')
1595
+ });
1596
+ Person.eachTransformedAttribute(function(name, type) {
1597
+ // do thing
1598
+ });
1599
+ // prints:
1600
+ // lastName string
1601
+ // birthday date
1602
+ ```
1603
+ @public
1604
+ @param callback The callback to execute
1605
+ @param binding [optional] the value to which the callback's `this` should be bound
1606
+ */
1607
+ static eachTransformedAttribute(callback, binding) {
1608
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1609
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1610
+ })(this.modelName);
1611
+ this.transformedAttributes.forEach((type, name) => {
1612
+ callback.call(binding, name, type);
1613
+ });
1614
+ }
1615
+ /**
1616
+ Returns the name of the model class.
1617
+ @public
1618
+ */
1619
+ static toString() {
1620
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1621
+ if (!test) throw new Error(`Accessing schema information on Models without looking up the model via the store is disallowed.`);
1622
+ })(this.modelName);
1623
+ return `model:${this.modelName}`;
1624
+ }
1625
+ };
1626
+ Model.prototype.save = save;
1627
+ Model.prototype.destroyRecord = destroyRecord;
1628
+ Model.prototype.unloadRecord = unloadRecord;
1629
+ Model.prototype.hasMany = hasMany;
1630
+ Model.prototype.belongsTo = belongsTo;
1631
+ Model.prototype.serialize = serialize;
1632
+ Model.prototype._createSnapshot = createSnapshot;
1633
+ Model.prototype.deleteRecord = deleteRecord;
1634
+ Model.prototype.changedAttributes = changedAttributes;
1635
+ Model.prototype.rollbackAttributes = rollbackAttributes;
1636
+ Model.prototype.reload = reload;
1637
+ defineGate(Model.prototype, "isReloading", {
1638
+ get() {
1639
+ deprecate(`record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`, false, {
1640
+ id: "warp-drive:deprecate-legacy-request-methods",
1641
+ until: "6.0",
1642
+ for: "@warp-drive/core",
1643
+ url: "https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS",
1644
+ since: {
1645
+ enabled: "5.7",
1646
+ available: "5.7"
1647
+ }
1648
+ });
1649
+ return this._isReloading ?? false;
1650
+ },
1651
+ set(v) {
1652
+ this._isReloading = v;
1653
+ },
1654
+ configurable: true,
1655
+ isLocal: true
1656
+ });
1657
+ /**
1658
+ * Restores the pre-`RequestManager` implementations of `save`,
1659
+ * `destroyRecord`, and `reload` onto the given `Model` subclass, for
1660
+ * apps that have not yet migrated off of the deprecated
1661
+ * `ENABLE_LEGACY_REQUEST_METHODS` behaviors.
1662
+ */
1663
+ function restoreDeprecatedModelRequestBehaviors(ModelKlass) {
1664
+ ModelKlass.prototype.save = _save;
1665
+ ModelKlass.prototype.destroyRecord = _destroyRecord;
1666
+ ModelKlass.prototype.reload = _reload;
1667
+ defineGate(Model.prototype, "isReloading", {
1668
+ get() {
1669
+ return this._isReloading ?? false;
1670
+ },
1671
+ set(v) {
1672
+ this._isReloading = v;
1673
+ },
1674
+ isLocal: true
1675
+ });
1676
+ }
1677
+ Model.prototype._createProps = null;
1678
+ Model.prototype._secretInit = null;
1679
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
1680
+ const lookupDescriptor = function lookupDescriptor(obj, keyName) {
1681
+ let current = obj;
1682
+ do {
1683
+ const descriptor = Object.getOwnPropertyDescriptor(current, keyName);
1684
+ if (descriptor !== void 0) return descriptor;
1685
+ current = Object.getPrototypeOf(current);
1686
+ } while (current !== null);
1687
+ return null;
1688
+ };
1689
+ const init = Model.prototype.init;
1690
+ Model.prototype.init = function(createArgs) {
1691
+ init.call(this, createArgs);
1692
+ const ourDescriptor = lookupDescriptor(Model.prototype, "currentState");
1693
+ const theirDescriptor = lookupDescriptor(this, "currentState");
1694
+ if (!ourDescriptor || !theirDescriptor) throw new Error(`Unable to determine if 'currentState' is a reserved property name on instances of classes extending Model. Please ensure that 'currentState' is not defined as a property on ${this.constructor.toString()}`);
1695
+ const realState = this.___recordState;
1696
+ if (ourDescriptor.get !== theirDescriptor.get || realState !== this.currentState) throw new Error(`'currentState' is a reserved property name on instances of classes extending Model. Please choose a different property name for ${this.constructor.toString()}`);
1697
+ const ID_DESCRIPTOR = lookupDescriptor(Model.prototype, "id");
1698
+ const idDesc = lookupDescriptor(this, "id");
1699
+ if (!ID_DESCRIPTOR || !idDesc) throw new Error(`Unable to determine if 'id' is a reserved property name on instances of classes extending Model. Please ensure that 'id' is not defined as a property on ${this.constructor.toString()}`);
1700
+ if (idDesc.get !== ID_DESCRIPTOR.get) throw new Error(`You may not set 'id' as an attribute on your model. Please remove any lines that look like: \`id: attr('<type>')\` from ${this.constructor.toString()}`);
1701
+ };
1702
+ delete Model.reopen;
1703
+ delete Model.reopenClass;
1704
+ }
1705
+ function isRelationshipSchema(meta) {
1706
+ return typeof meta === "object" && meta !== null && "kind" in meta && "options" in meta && (meta.kind === "hasMany" || meta.kind === "belongsTo");
1707
+ }
1708
+ function isAttributeSchema(meta) {
1709
+ return typeof meta === "object" && meta !== null && "kind" in meta && meta.kind === "attribute";
1710
+ }
1711
+
1712
+ //#endregion
1713
+ //#region src/model/-private/model-for-mixin.ts
1714
+ function modelForMixin(store, normalizedModelName) {
1715
+ const owner = getOwner(store);
1716
+ const MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);
1717
+ const mixin = MaybeMixin && MaybeMixin.class;
1718
+ if (mixin) {
1719
+ const ModelForMixin = Model.extend(mixin);
1720
+ ModelForMixin.__isMixin = true;
1721
+ ModelForMixin.__mixin = mixin;
1722
+ owner.register(`model:${normalizedModelName}`, ModelForMixin);
1723
+ }
1724
+ return owner.factoryFor(`model:${normalizedModelName}`);
1725
+ }
1726
+
1727
+ //#endregion
1728
+ //#region src/model/-private/schema-provider.ts
1729
+ var ModelSchemaProvider = class {
1730
+ /** @internal */
1731
+ /** @internal */
1732
+ /** @internal */
1733
+ constructor(store) {
1734
+ this.store = store;
1735
+ this._schemas = /* @__PURE__ */ new Map();
1736
+ this._typeMisses = /* @__PURE__ */ new Set();
1737
+ }
1738
+ resourceTypes() {
1739
+ return Array.from(this._schemas.keys());
1740
+ }
1741
+ hasTrait(type) {
1742
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1743
+ if (!test) throw new Error(`hasTrait is not available with @warp-drive/legacy/model's SchemaService`);
1744
+ })(false);
1745
+ return false;
1746
+ }
1747
+ resourceHasTrait(resource, trait) {
1748
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1749
+ if (!test) throw new Error(`resourceHasTrait is not available with @warp-drive/legacy/model's SchemaService`);
1750
+ })(false);
1751
+ return false;
1752
+ }
1753
+ transformation(field) {
1754
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1755
+ if (!test) throw new Error(`transformation is not available with @warp-drive/legacy/model's SchemaService`);
1756
+ })(false);
1757
+ }
1758
+ derivation(field) {
1759
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1760
+ if (!test) throw new Error(`derivation is not available with @warp-drive/legacy/model's SchemaService`);
1761
+ })(false);
1762
+ }
1763
+ hashFn(field) {
1764
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1765
+ if (!test) throw new Error(`hashFn is not available with @warp-drive/legacy/model's SchemaService`);
1766
+ })(false);
1767
+ }
1768
+ resource(resource) {
1769
+ const type = normalizeModelName(resource.type);
1770
+ if (!this._schemas.has(type)) this._loadModelSchema(type);
1771
+ return this._schemas.get(type).schema;
1772
+ }
1773
+ registerResources(schemas) {
1774
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1775
+ if (!test) throw new Error(`registerResources is not available with @warp-drive/legacy/model's SchemaService`);
1776
+ })(false);
1777
+ }
1778
+ registerResource(schema) {
1779
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1780
+ if (!test) throw new Error(`registerResource is not available with @warp-drive/legacy/model's SchemaService`);
1781
+ })(false);
1782
+ }
1783
+ registerTransformation(transform) {
1784
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1785
+ if (!test) throw new Error(`registerTransformation is not available with @warp-drive/legacy/model's SchemaService`);
1786
+ })(false);
1787
+ }
1788
+ registerDerivation(derivation) {
1789
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1790
+ if (!test) throw new Error(`registerDerivation is not available with @warp-drive/legacy/model's SchemaService`);
1791
+ })(false);
1792
+ }
1793
+ registerHashFn(hashFn) {
1794
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1795
+ if (!test) throw new Error(`registerHashFn is not available with @warp-drive/legacy/model's SchemaService`);
1796
+ })(false);
1797
+ }
1798
+ /** @internal */
1799
+ _loadModelSchema(type) {
1800
+ const factory = getModelFactory(this.store, type);
1801
+ if (!factory) throw new Error(`No model was found for '${type}'`);
1802
+ const modelClass = factory.class;
1803
+ const attributeMap = modelClass.attributes;
1804
+ const attributes = Object.create(null);
1805
+ attributeMap.forEach((meta, name) => attributes[name] = meta);
1806
+ const relationships = modelClass.relationshipsObject || null;
1807
+ const fields = /* @__PURE__ */ new Map();
1808
+ for (const attr of Object.values(attributes)) fields.set(attr.name, attr);
1809
+ for (const rel of Object.values(relationships)) fields.set(rel.name, rel);
1810
+ const schema = {
1811
+ legacy: true,
1812
+ identity: {
1813
+ name: "id",
1814
+ kind: "@id"
1815
+ },
1816
+ type,
1817
+ fields: Array.from(fields.values())
1818
+ };
1819
+ const cacheFields = /* @__PURE__ */ new Map();
1820
+ for (const field of fields.values()) {
1821
+ const cacheKey = field.sourceKey ?? field.name;
1822
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
1823
+ if (!test) throw new Error(`The sourceKey '${field.sourceKey}' for the field '${field.name}' on '${type}' is invalid because it matches the name of an existing field`);
1824
+ })(!field.sourceKey || field.sourceKey === field.name || !fields.has(field.sourceKey));
1825
+ cacheFields.set(cacheKey, field);
1826
+ }
1827
+ const internalSchema = {
1828
+ schema,
1829
+ attributes,
1830
+ relationships,
1831
+ fields,
1832
+ cacheFields
1833
+ };
1834
+ this._schemas.set(type, internalSchema);
1835
+ return internalSchema;
1836
+ }
1837
+ fields(resource) {
1838
+ const type = normalizeModelName(resource.type);
1839
+ if (!this._schemas.has(type)) this._loadModelSchema(type);
1840
+ return this._schemas.get(type).fields;
1841
+ }
1842
+ cacheFields(resource) {
1843
+ const type = normalizeModelName(resource.type);
1844
+ if (!this._schemas.has(type)) this._loadModelSchema(type);
1845
+ return this._schemas.get(type).cacheFields;
1846
+ }
1847
+ hasResource(resource) {
1848
+ const type = normalizeModelName(resource.type);
1849
+ if (this._schemas.has(type)) return true;
1850
+ if (this._typeMisses.has(type)) return false;
1851
+ if (!(getModelFactory(this.store, type) !== null)) {
1852
+ this._typeMisses.add(type);
1853
+ return false;
1854
+ }
1855
+ return true;
1856
+ }
1857
+ };
1858
+ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
1859
+ ModelSchemaProvider.prototype.doesTypeExist = function(type) {
1860
+ deprecate(`Use \`schema.hasResource({ type })\` instead of \`schema.doesTypeExist(type)\``, false, {
1861
+ id: "ember-data:schema-service-updates",
1862
+ until: "6.0",
1863
+ for: "ember-data",
1864
+ since: {
1865
+ available: "4.13",
1866
+ enabled: "5.4"
1867
+ }
1868
+ });
1869
+ return this.hasResource({ type });
1870
+ };
1871
+ ModelSchemaProvider.prototype.attributesDefinitionFor = function(resource) {
1872
+ deprecate(`Use \`schema.fields({ type })\` instead of \`schema.attributesDefinitionFor({ type })\``, false, {
1873
+ id: "ember-data:schema-service-updates",
1874
+ until: "6.0",
1875
+ for: "ember-data",
1876
+ since: {
1877
+ available: "4.13",
1878
+ enabled: "5.4"
1879
+ }
1880
+ });
1881
+ const type = normalizeModelName(resource.type);
1882
+ if (!this._schemas.has(type)) this._loadModelSchema(type);
1883
+ return this._schemas.get(type).attributes;
1884
+ };
1885
+ ModelSchemaProvider.prototype.relationshipsDefinitionFor = function(resource) {
1886
+ deprecate(`Use \`schema.fields({ type })\` instead of \`schema.relationshipsDefinitionFor({ type })\``, false, {
1887
+ id: "ember-data:schema-service-updates",
1888
+ until: "6.0",
1889
+ for: "ember-data",
1890
+ since: {
1891
+ available: "4.13",
1892
+ enabled: "5.4"
1893
+ }
1894
+ });
1895
+ const type = normalizeModelName(resource.type);
1896
+ if (!this._schemas.has(type)) this._loadModelSchema(type);
1897
+ return this._schemas.get(type).relationships;
1898
+ };
1899
+ }
1900
+ /**
1901
+ * The `createSchemaService` implementation for use with `Model`. Pass
1902
+ * the result of this to your store's `createSchemaService` method when
1903
+ * configuring the store to use `Model` for schema information.
1904
+ *
1905
+ * @public
1906
+ */
1907
+ function buildSchema(store) {
1908
+ return new ModelSchemaProvider(store);
1909
+ }
1910
+ function getModelFactory(store, type) {
1911
+ if (!store._modelFactoryCache) store._modelFactoryCache = Object.create(null);
1912
+ const cache = store._modelFactoryCache;
1913
+ let factory = cache[type];
1914
+ if (!factory) {
1915
+ factory = getOwner(store).factoryFor(`model:${type}`);
1916
+ if (!factory) factory = modelForMixin(store, type);
1917
+ if (!factory) return null;
1918
+ const klass = factory.class;
1919
+ if (klass.isModel) {
1920
+ if (!(klass.modelName && Object.prototype.hasOwnProperty.call(klass, "modelName"))) Object.defineProperty(klass, "modelName", { value: type });
1921
+ }
1922
+ cache[type] = factory;
1923
+ }
1924
+ return factory;
1925
+ }
1926
+
1927
+ //#endregion
1928
+ export { save as _, RecordState as a, _save as c, createSnapshot as d, deleteRecord as f, rollbackAttributes as g, reload as h, restoreDeprecatedModelRequestBehaviors as i, belongsTo as l, hasMany as m, getModelFactory as n, _destroyRecord as o, destroyRecord as p, Model as r, _reload as s, buildSchema as t, changedAttributes as u, serialize as v, unloadRecord as y };
1929
+ //# sourceMappingURL=schema-provider-DsKuB5Wb.js.map