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