@warp-drive/legacy 5.8.0-alpha.30 → 5.8.0-alpha.32

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 (477) hide show
  1. package/declarations/adapter/error.d.ts +5 -5
  2. package/declarations/adapter/json-api.d.ts +2 -2
  3. package/declarations/compat/builders/find-all.d.ts +6 -6
  4. package/declarations/compat/builders/find-record.d.ts +8 -8
  5. package/declarations/compat/builders/query.d.ts +12 -12
  6. package/declarations/compat.d.ts +3 -3
  7. package/declarations/model/-private/references/belongs-to.d.ts +4 -4
  8. package/declarations/model/-private/references/has-many.d.ts +2 -2
  9. package/declarations/model/migration-support.d.ts +34 -18
  10. package/declarations/model.d.ts +2 -2
  11. package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -1
  12. package/declarations/serializer/json-api.d.ts +3 -3
  13. package/declarations/serializer/json.d.ts +1 -1
  14. package/declarations/serializer.d.ts +1 -1
  15. package/dist/adapter/error.js +7 -7
  16. package/dist/compat/builders.js +26 -26
  17. package/dist/compat/utils.js +0 -1
  18. package/dist/compat.js +3 -3
  19. package/dist/{errors-B9CDPh3R.js → errors-CIGPcDvd.js} +12 -12
  20. package/dist/{hooks-CQXyievu.js → hooks-QqRnX108.js} +1 -1
  21. package/dist/index.js +4 -4
  22. package/dist/{json-BHxlccxF.js → json-BNrV8EYG.js} +4 -4
  23. package/dist/model/-private.js +1 -1
  24. package/dist/model/migration-support.js +41 -24
  25. package/dist/{model-for-B0TSd9HU.js → model-for-CqXsIKws.js} +1 -1
  26. package/dist/model-fragments.js +2 -2
  27. package/dist/model.js +3 -3
  28. package/dist/{schema-provider-BnVr_CnJ.js → schema-provider-g5MfTj8n.js} +11 -11
  29. package/dist/serializer/json-api.js +7 -7
  30. package/dist/serializer/json.js +1 -1
  31. package/dist/serializer/rest.js +10 -10
  32. package/dist/serializer.js +1 -1
  33. package/dist/unpkg/dev/-private-B1pSSN52.js +1210 -0
  34. package/dist/unpkg/dev/adapter/-private.js +1 -0
  35. package/dist/unpkg/dev/adapter/error.js +336 -0
  36. package/dist/unpkg/dev/adapter/json-api.js +132 -0
  37. package/dist/unpkg/dev/adapter/rest.js +1257 -0
  38. package/dist/unpkg/dev/adapter.js +1253 -0
  39. package/dist/unpkg/dev/compat/-private.js +1 -0
  40. package/dist/unpkg/dev/compat/builders.js +273 -0
  41. package/dist/unpkg/dev/compat/extensions.js +243 -0
  42. package/dist/unpkg/dev/compat/utils.js +224 -0
  43. package/dist/unpkg/dev/compat.js +1020 -0
  44. package/dist/unpkg/dev/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  45. package/dist/unpkg/dev/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  46. package/dist/unpkg/dev/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  47. package/dist/unpkg/dev/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  48. package/dist/unpkg/dev/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  49. package/dist/unpkg/dev/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  50. package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  51. package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  52. package/dist/unpkg/dev/declarations/adapter/-private.d.ts +5 -0
  53. package/dist/unpkg/dev/declarations/adapter/error.d.ts +215 -0
  54. package/dist/unpkg/dev/declarations/adapter/json-api.d.ts +231 -0
  55. package/dist/unpkg/dev/declarations/adapter/rest.d.ts +815 -0
  56. package/dist/unpkg/dev/declarations/adapter.d.ts +770 -0
  57. package/dist/unpkg/dev/declarations/compat/-private.d.ts +13 -0
  58. package/dist/unpkg/dev/declarations/compat/builders/find-all.d.ts +35 -0
  59. package/dist/unpkg/dev/declarations/compat/builders/find-record.d.ts +56 -0
  60. package/dist/unpkg/dev/declarations/compat/builders/query.d.ts +66 -0
  61. package/dist/unpkg/dev/declarations/compat/builders/save-record.d.ts +34 -0
  62. package/dist/unpkg/dev/declarations/compat/builders/utils.d.ts +3 -0
  63. package/dist/unpkg/dev/declarations/compat/builders.d.ts +14 -0
  64. package/dist/unpkg/dev/declarations/compat/extensions.d.ts +59 -0
  65. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  66. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  67. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  68. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  69. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  70. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  71. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  72. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  73. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  74. package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  75. package/dist/unpkg/dev/declarations/compat/utils.d.ts +137 -0
  76. package/dist/unpkg/dev/declarations/compat.d.ts +157 -0
  77. package/dist/unpkg/dev/declarations/index.d.ts +70 -0
  78. package/dist/unpkg/dev/declarations/model/-private/attr.d.ts +170 -0
  79. package/dist/unpkg/dev/declarations/model/-private/belongs-to.d.ts +174 -0
  80. package/dist/unpkg/dev/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  81. package/dist/unpkg/dev/declarations/model/-private/errors.d.ts +289 -0
  82. package/dist/unpkg/dev/declarations/model/-private/has-many.d.ts +162 -0
  83. package/dist/unpkg/dev/declarations/model/-private/hooks.d.ts +10 -0
  84. package/dist/unpkg/dev/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  85. package/dist/unpkg/dev/declarations/model/-private/model-for-mixin.d.ts +3 -0
  86. package/dist/unpkg/dev/declarations/model/-private/model-methods.d.ts +39 -0
  87. package/dist/unpkg/dev/declarations/model/-private/model.d.ts +1269 -0
  88. package/dist/unpkg/dev/declarations/model/-private/notify-changes.d.ts +4 -0
  89. package/dist/unpkg/dev/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  90. package/dist/unpkg/dev/declarations/model/-private/promise-many-array.d.ts +124 -0
  91. package/dist/unpkg/dev/declarations/model/-private/record-state.d.ts +58 -0
  92. package/dist/unpkg/dev/declarations/model/-private/references/belongs-to.d.ts +498 -0
  93. package/dist/unpkg/dev/declarations/model/-private/references/has-many.d.ts +500 -0
  94. package/dist/unpkg/dev/declarations/model/-private/schema-provider.d.ts +56 -0
  95. package/dist/unpkg/dev/declarations/model/-private/type-utils.d.ts +57 -0
  96. package/dist/unpkg/dev/declarations/model/-private/util.d.ts +5 -0
  97. package/dist/unpkg/dev/declarations/model/-private.d.ts +8 -0
  98. package/dist/unpkg/dev/declarations/model/migration-support.d.ts +280 -0
  99. package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  100. package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  101. package/dist/unpkg/dev/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  102. package/dist/unpkg/dev/declarations/model-fragments/index.d.ts +5 -0
  103. package/dist/unpkg/dev/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  104. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  105. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  106. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  107. package/dist/unpkg/dev/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  108. package/dist/unpkg/dev/declarations/model-fragments.d.ts +9 -0
  109. package/dist/unpkg/dev/declarations/model.d.ts +49 -0
  110. package/dist/unpkg/dev/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  111. package/dist/unpkg/dev/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  112. package/dist/unpkg/dev/declarations/serializer/-private/transforms/date.d.ts +28 -0
  113. package/dist/unpkg/dev/declarations/serializer/-private/transforms/number.d.ts +29 -0
  114. package/dist/unpkg/dev/declarations/serializer/-private/transforms/string.d.ts +29 -0
  115. package/dist/unpkg/dev/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  116. package/dist/unpkg/dev/declarations/serializer/-private/utils.d.ts +3 -0
  117. package/dist/unpkg/dev/declarations/serializer/json-api.d.ts +123 -0
  118. package/dist/unpkg/dev/declarations/serializer/json.d.ts +75 -0
  119. package/dist/unpkg/dev/declarations/serializer/rest.d.ts +51 -0
  120. package/dist/unpkg/dev/declarations/serializer/transform.d.ts +5 -0
  121. package/dist/unpkg/dev/declarations/serializer.d.ts +254 -0
  122. package/dist/unpkg/dev/declarations/store/-private.d.ts +223 -0
  123. package/dist/unpkg/dev/declarations/store.d.ts +3 -0
  124. package/dist/unpkg/dev/errors-CIGPcDvd.js +2595 -0
  125. package/dist/unpkg/dev/hooks-QqRnX108.js +74 -0
  126. package/dist/unpkg/dev/index.js +195 -0
  127. package/dist/unpkg/dev/json-BNrV8EYG.js +1272 -0
  128. package/dist/unpkg/dev/model/-private.js +1 -0
  129. package/dist/unpkg/dev/model/migration-support.js +579 -0
  130. package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
  131. package/dist/unpkg/dev/model-fragments.js +76 -0
  132. package/dist/unpkg/dev/model.js +667 -0
  133. package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  134. package/dist/unpkg/dev/schema-provider-g5MfTj8n.js +2338 -0
  135. package/dist/unpkg/dev/serialize-into-hash-BnYvPex3.js +261 -0
  136. package/dist/unpkg/dev/serializer/json-api.js +527 -0
  137. package/dist/unpkg/dev/serializer/json.js +6 -0
  138. package/dist/unpkg/dev/serializer/rest.js +1243 -0
  139. package/dist/unpkg/dev/serializer/transform.js +278 -0
  140. package/dist/unpkg/dev/serializer.js +248 -0
  141. package/dist/unpkg/dev/store.js +636 -0
  142. package/dist/unpkg/dev/util-Dul6TZts.js +35 -0
  143. package/dist/unpkg/dev/utils-Cqw9eRj5.js +23 -0
  144. package/dist/unpkg/dev-deprecated/-private-B1pSSN52.js +1210 -0
  145. package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
  146. package/dist/unpkg/dev-deprecated/adapter/error.js +336 -0
  147. package/dist/unpkg/dev-deprecated/adapter/json-api.js +132 -0
  148. package/dist/unpkg/dev-deprecated/adapter/rest.js +1257 -0
  149. package/dist/unpkg/dev-deprecated/adapter.js +1253 -0
  150. package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
  151. package/dist/unpkg/dev-deprecated/compat/builders.js +273 -0
  152. package/dist/unpkg/dev-deprecated/compat/extensions.js +243 -0
  153. package/dist/unpkg/dev-deprecated/compat/utils.js +224 -0
  154. package/dist/unpkg/dev-deprecated/compat.js +1020 -0
  155. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  156. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  157. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  158. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  159. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  160. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  161. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  162. package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  163. package/dist/unpkg/dev-deprecated/declarations/adapter/-private.d.ts +5 -0
  164. package/dist/unpkg/dev-deprecated/declarations/adapter/error.d.ts +215 -0
  165. package/dist/unpkg/dev-deprecated/declarations/adapter/json-api.d.ts +231 -0
  166. package/dist/unpkg/dev-deprecated/declarations/adapter/rest.d.ts +815 -0
  167. package/dist/unpkg/dev-deprecated/declarations/adapter.d.ts +770 -0
  168. package/dist/unpkg/dev-deprecated/declarations/compat/-private.d.ts +13 -0
  169. package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-all.d.ts +35 -0
  170. package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-record.d.ts +56 -0
  171. package/dist/unpkg/dev-deprecated/declarations/compat/builders/query.d.ts +66 -0
  172. package/dist/unpkg/dev-deprecated/declarations/compat/builders/save-record.d.ts +34 -0
  173. package/dist/unpkg/dev-deprecated/declarations/compat/builders/utils.d.ts +3 -0
  174. package/dist/unpkg/dev-deprecated/declarations/compat/builders.d.ts +14 -0
  175. package/dist/unpkg/dev-deprecated/declarations/compat/extensions.d.ts +59 -0
  176. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  177. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  178. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  179. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  180. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  181. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  182. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  183. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  184. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  185. package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  186. package/dist/unpkg/dev-deprecated/declarations/compat/utils.d.ts +137 -0
  187. package/dist/unpkg/dev-deprecated/declarations/compat.d.ts +157 -0
  188. package/dist/unpkg/dev-deprecated/declarations/index.d.ts +70 -0
  189. package/dist/unpkg/dev-deprecated/declarations/model/-private/attr.d.ts +170 -0
  190. package/dist/unpkg/dev-deprecated/declarations/model/-private/belongs-to.d.ts +174 -0
  191. package/dist/unpkg/dev-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  192. package/dist/unpkg/dev-deprecated/declarations/model/-private/errors.d.ts +289 -0
  193. package/dist/unpkg/dev-deprecated/declarations/model/-private/has-many.d.ts +162 -0
  194. package/dist/unpkg/dev-deprecated/declarations/model/-private/hooks.d.ts +10 -0
  195. package/dist/unpkg/dev-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  196. package/dist/unpkg/dev-deprecated/declarations/model/-private/model-for-mixin.d.ts +3 -0
  197. package/dist/unpkg/dev-deprecated/declarations/model/-private/model-methods.d.ts +39 -0
  198. package/dist/unpkg/dev-deprecated/declarations/model/-private/model.d.ts +1269 -0
  199. package/dist/unpkg/dev-deprecated/declarations/model/-private/notify-changes.d.ts +4 -0
  200. package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  201. package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-many-array.d.ts +124 -0
  202. package/dist/unpkg/dev-deprecated/declarations/model/-private/record-state.d.ts +58 -0
  203. package/dist/unpkg/dev-deprecated/declarations/model/-private/references/belongs-to.d.ts +498 -0
  204. package/dist/unpkg/dev-deprecated/declarations/model/-private/references/has-many.d.ts +500 -0
  205. package/dist/unpkg/dev-deprecated/declarations/model/-private/schema-provider.d.ts +56 -0
  206. package/dist/unpkg/dev-deprecated/declarations/model/-private/type-utils.d.ts +57 -0
  207. package/dist/unpkg/dev-deprecated/declarations/model/-private/util.d.ts +5 -0
  208. package/dist/unpkg/dev-deprecated/declarations/model/-private.d.ts +8 -0
  209. package/dist/unpkg/dev-deprecated/declarations/model/migration-support.d.ts +280 -0
  210. package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  211. package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  212. package/dist/unpkg/dev-deprecated/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  213. package/dist/unpkg/dev-deprecated/declarations/model-fragments/index.d.ts +5 -0
  214. package/dist/unpkg/dev-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  215. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  216. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  217. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  218. package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  219. package/dist/unpkg/dev-deprecated/declarations/model-fragments.d.ts +9 -0
  220. package/dist/unpkg/dev-deprecated/declarations/model.d.ts +49 -0
  221. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  222. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  223. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/date.d.ts +28 -0
  224. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/number.d.ts +29 -0
  225. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/string.d.ts +29 -0
  226. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  227. package/dist/unpkg/dev-deprecated/declarations/serializer/-private/utils.d.ts +3 -0
  228. package/dist/unpkg/dev-deprecated/declarations/serializer/json-api.d.ts +123 -0
  229. package/dist/unpkg/dev-deprecated/declarations/serializer/json.d.ts +75 -0
  230. package/dist/unpkg/dev-deprecated/declarations/serializer/rest.d.ts +51 -0
  231. package/dist/unpkg/dev-deprecated/declarations/serializer/transform.d.ts +5 -0
  232. package/dist/unpkg/dev-deprecated/declarations/serializer.d.ts +254 -0
  233. package/dist/unpkg/dev-deprecated/declarations/store/-private.d.ts +223 -0
  234. package/dist/unpkg/dev-deprecated/declarations/store.d.ts +3 -0
  235. package/dist/unpkg/dev-deprecated/errors-CIGPcDvd.js +2595 -0
  236. package/dist/unpkg/dev-deprecated/hooks-QqRnX108.js +74 -0
  237. package/dist/unpkg/dev-deprecated/index.js +195 -0
  238. package/dist/unpkg/dev-deprecated/json-BNrV8EYG.js +1272 -0
  239. package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
  240. package/dist/unpkg/dev-deprecated/model/migration-support.js +579 -0
  241. package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
  242. package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
  243. package/dist/unpkg/dev-deprecated/model.js +667 -0
  244. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  245. package/dist/unpkg/dev-deprecated/schema-provider-g5MfTj8n.js +2338 -0
  246. package/dist/unpkg/dev-deprecated/serialize-into-hash-BnYvPex3.js +261 -0
  247. package/dist/unpkg/dev-deprecated/serializer/json-api.js +527 -0
  248. package/dist/unpkg/dev-deprecated/serializer/json.js +6 -0
  249. package/dist/unpkg/dev-deprecated/serializer/rest.js +1243 -0
  250. package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
  251. package/dist/unpkg/dev-deprecated/serializer.js +248 -0
  252. package/dist/unpkg/dev-deprecated/store.js +636 -0
  253. package/dist/unpkg/dev-deprecated/util-Dul6TZts.js +35 -0
  254. package/dist/unpkg/dev-deprecated/utils-Cqw9eRj5.js +23 -0
  255. package/dist/unpkg/prod/-private-B1pSSN52.js +1210 -0
  256. package/dist/unpkg/prod/adapter/-private.js +1 -0
  257. package/dist/unpkg/prod/adapter/error.js +336 -0
  258. package/dist/unpkg/prod/adapter/json-api.js +132 -0
  259. package/dist/unpkg/prod/adapter/rest.js +1257 -0
  260. package/dist/unpkg/prod/adapter.js +1253 -0
  261. package/dist/unpkg/prod/compat/-private.js +1 -0
  262. package/dist/unpkg/prod/compat/builders.js +273 -0
  263. package/dist/unpkg/prod/compat/extensions.js +243 -0
  264. package/dist/unpkg/prod/compat/utils.js +224 -0
  265. package/dist/unpkg/prod/compat.js +1020 -0
  266. package/dist/unpkg/prod/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  267. package/dist/unpkg/prod/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  268. package/dist/unpkg/prod/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  269. package/dist/unpkg/prod/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  270. package/dist/unpkg/prod/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  271. package/dist/unpkg/prod/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  272. package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  273. package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  274. package/dist/unpkg/prod/declarations/adapter/-private.d.ts +5 -0
  275. package/dist/unpkg/prod/declarations/adapter/error.d.ts +215 -0
  276. package/dist/unpkg/prod/declarations/adapter/json-api.d.ts +231 -0
  277. package/dist/unpkg/prod/declarations/adapter/rest.d.ts +815 -0
  278. package/dist/unpkg/prod/declarations/adapter.d.ts +770 -0
  279. package/dist/unpkg/prod/declarations/compat/-private.d.ts +13 -0
  280. package/dist/unpkg/prod/declarations/compat/builders/find-all.d.ts +35 -0
  281. package/dist/unpkg/prod/declarations/compat/builders/find-record.d.ts +56 -0
  282. package/dist/unpkg/prod/declarations/compat/builders/query.d.ts +66 -0
  283. package/dist/unpkg/prod/declarations/compat/builders/save-record.d.ts +34 -0
  284. package/dist/unpkg/prod/declarations/compat/builders/utils.d.ts +3 -0
  285. package/dist/unpkg/prod/declarations/compat/builders.d.ts +14 -0
  286. package/dist/unpkg/prod/declarations/compat/extensions.d.ts +59 -0
  287. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  288. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  289. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  290. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  291. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  292. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  293. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  294. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  295. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  296. package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  297. package/dist/unpkg/prod/declarations/compat/utils.d.ts +137 -0
  298. package/dist/unpkg/prod/declarations/compat.d.ts +157 -0
  299. package/dist/unpkg/prod/declarations/index.d.ts +70 -0
  300. package/dist/unpkg/prod/declarations/model/-private/attr.d.ts +170 -0
  301. package/dist/unpkg/prod/declarations/model/-private/belongs-to.d.ts +174 -0
  302. package/dist/unpkg/prod/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  303. package/dist/unpkg/prod/declarations/model/-private/errors.d.ts +289 -0
  304. package/dist/unpkg/prod/declarations/model/-private/has-many.d.ts +162 -0
  305. package/dist/unpkg/prod/declarations/model/-private/hooks.d.ts +10 -0
  306. package/dist/unpkg/prod/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  307. package/dist/unpkg/prod/declarations/model/-private/model-for-mixin.d.ts +3 -0
  308. package/dist/unpkg/prod/declarations/model/-private/model-methods.d.ts +39 -0
  309. package/dist/unpkg/prod/declarations/model/-private/model.d.ts +1269 -0
  310. package/dist/unpkg/prod/declarations/model/-private/notify-changes.d.ts +4 -0
  311. package/dist/unpkg/prod/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  312. package/dist/unpkg/prod/declarations/model/-private/promise-many-array.d.ts +124 -0
  313. package/dist/unpkg/prod/declarations/model/-private/record-state.d.ts +58 -0
  314. package/dist/unpkg/prod/declarations/model/-private/references/belongs-to.d.ts +498 -0
  315. package/dist/unpkg/prod/declarations/model/-private/references/has-many.d.ts +500 -0
  316. package/dist/unpkg/prod/declarations/model/-private/schema-provider.d.ts +56 -0
  317. package/dist/unpkg/prod/declarations/model/-private/type-utils.d.ts +57 -0
  318. package/dist/unpkg/prod/declarations/model/-private/util.d.ts +5 -0
  319. package/dist/unpkg/prod/declarations/model/-private.d.ts +8 -0
  320. package/dist/unpkg/prod/declarations/model/migration-support.d.ts +280 -0
  321. package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  322. package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  323. package/dist/unpkg/prod/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  324. package/dist/unpkg/prod/declarations/model-fragments/index.d.ts +5 -0
  325. package/dist/unpkg/prod/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  326. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  327. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  328. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  329. package/dist/unpkg/prod/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  330. package/dist/unpkg/prod/declarations/model-fragments.d.ts +9 -0
  331. package/dist/unpkg/prod/declarations/model.d.ts +49 -0
  332. package/dist/unpkg/prod/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  333. package/dist/unpkg/prod/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  334. package/dist/unpkg/prod/declarations/serializer/-private/transforms/date.d.ts +28 -0
  335. package/dist/unpkg/prod/declarations/serializer/-private/transforms/number.d.ts +29 -0
  336. package/dist/unpkg/prod/declarations/serializer/-private/transforms/string.d.ts +29 -0
  337. package/dist/unpkg/prod/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  338. package/dist/unpkg/prod/declarations/serializer/-private/utils.d.ts +3 -0
  339. package/dist/unpkg/prod/declarations/serializer/json-api.d.ts +123 -0
  340. package/dist/unpkg/prod/declarations/serializer/json.d.ts +75 -0
  341. package/dist/unpkg/prod/declarations/serializer/rest.d.ts +51 -0
  342. package/dist/unpkg/prod/declarations/serializer/transform.d.ts +5 -0
  343. package/dist/unpkg/prod/declarations/serializer.d.ts +254 -0
  344. package/dist/unpkg/prod/declarations/store/-private.d.ts +223 -0
  345. package/dist/unpkg/prod/declarations/store.d.ts +3 -0
  346. package/dist/unpkg/prod/errors-CIGPcDvd.js +2595 -0
  347. package/dist/unpkg/prod/hooks-QqRnX108.js +74 -0
  348. package/dist/unpkg/prod/index.js +195 -0
  349. package/dist/unpkg/prod/json-BNrV8EYG.js +1272 -0
  350. package/dist/unpkg/prod/model/-private.js +1 -0
  351. package/dist/unpkg/prod/model/migration-support.js +579 -0
  352. package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
  353. package/dist/unpkg/prod/model-fragments.js +76 -0
  354. package/dist/unpkg/prod/model.js +667 -0
  355. package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  356. package/dist/unpkg/prod/schema-provider-g5MfTj8n.js +2338 -0
  357. package/dist/unpkg/prod/serialize-into-hash-BnYvPex3.js +261 -0
  358. package/dist/unpkg/prod/serializer/json-api.js +527 -0
  359. package/dist/unpkg/prod/serializer/json.js +6 -0
  360. package/dist/unpkg/prod/serializer/rest.js +1243 -0
  361. package/dist/unpkg/prod/serializer/transform.js +278 -0
  362. package/dist/unpkg/prod/serializer.js +248 -0
  363. package/dist/unpkg/prod/store.js +636 -0
  364. package/dist/unpkg/prod/util-Dul6TZts.js +35 -0
  365. package/dist/unpkg/prod/utils-Cqw9eRj5.js +23 -0
  366. package/dist/unpkg/prod-deprecated/-private-B1pSSN52.js +1210 -0
  367. package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
  368. package/dist/unpkg/prod-deprecated/adapter/error.js +336 -0
  369. package/dist/unpkg/prod-deprecated/adapter/json-api.js +132 -0
  370. package/dist/unpkg/prod-deprecated/adapter/rest.js +1257 -0
  371. package/dist/unpkg/prod-deprecated/adapter.js +1253 -0
  372. package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
  373. package/dist/unpkg/prod-deprecated/compat/builders.js +273 -0
  374. package/dist/unpkg/prod-deprecated/compat/extensions.js +243 -0
  375. package/dist/unpkg/prod-deprecated/compat/utils.js +224 -0
  376. package/dist/unpkg/prod-deprecated/compat.js +1020 -0
  377. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
  378. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
  379. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
  380. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
  381. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/fetch.d.ts +8 -0
  382. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
  383. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
  384. package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
  385. package/dist/unpkg/prod-deprecated/declarations/adapter/-private.d.ts +5 -0
  386. package/dist/unpkg/prod-deprecated/declarations/adapter/error.d.ts +215 -0
  387. package/dist/unpkg/prod-deprecated/declarations/adapter/json-api.d.ts +231 -0
  388. package/dist/unpkg/prod-deprecated/declarations/adapter/rest.d.ts +815 -0
  389. package/dist/unpkg/prod-deprecated/declarations/adapter.d.ts +770 -0
  390. package/dist/unpkg/prod-deprecated/declarations/compat/-private.d.ts +13 -0
  391. package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-all.d.ts +35 -0
  392. package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-record.d.ts +56 -0
  393. package/dist/unpkg/prod-deprecated/declarations/compat/builders/query.d.ts +66 -0
  394. package/dist/unpkg/prod-deprecated/declarations/compat/builders/save-record.d.ts +34 -0
  395. package/dist/unpkg/prod-deprecated/declarations/compat/builders/utils.d.ts +3 -0
  396. package/dist/unpkg/prod-deprecated/declarations/compat/builders.d.ts +14 -0
  397. package/dist/unpkg/prod-deprecated/declarations/compat/extensions.d.ts +59 -0
  398. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
  399. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
  400. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
  401. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
  402. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
  403. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
  404. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
  405. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
  406. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
  407. package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
  408. package/dist/unpkg/prod-deprecated/declarations/compat/utils.d.ts +137 -0
  409. package/dist/unpkg/prod-deprecated/declarations/compat.d.ts +157 -0
  410. package/dist/unpkg/prod-deprecated/declarations/index.d.ts +70 -0
  411. package/dist/unpkg/prod-deprecated/declarations/model/-private/attr.d.ts +170 -0
  412. package/dist/unpkg/prod-deprecated/declarations/model/-private/belongs-to.d.ts +174 -0
  413. package/dist/unpkg/prod-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
  414. package/dist/unpkg/prod-deprecated/declarations/model/-private/errors.d.ts +289 -0
  415. package/dist/unpkg/prod-deprecated/declarations/model/-private/has-many.d.ts +162 -0
  416. package/dist/unpkg/prod-deprecated/declarations/model/-private/hooks.d.ts +10 -0
  417. package/dist/unpkg/prod-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
  418. package/dist/unpkg/prod-deprecated/declarations/model/-private/model-for-mixin.d.ts +3 -0
  419. package/dist/unpkg/prod-deprecated/declarations/model/-private/model-methods.d.ts +39 -0
  420. package/dist/unpkg/prod-deprecated/declarations/model/-private/model.d.ts +1269 -0
  421. package/dist/unpkg/prod-deprecated/declarations/model/-private/notify-changes.d.ts +4 -0
  422. package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  423. package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-many-array.d.ts +124 -0
  424. package/dist/unpkg/prod-deprecated/declarations/model/-private/record-state.d.ts +58 -0
  425. package/dist/unpkg/prod-deprecated/declarations/model/-private/references/belongs-to.d.ts +498 -0
  426. package/dist/unpkg/prod-deprecated/declarations/model/-private/references/has-many.d.ts +500 -0
  427. package/dist/unpkg/prod-deprecated/declarations/model/-private/schema-provider.d.ts +56 -0
  428. package/dist/unpkg/prod-deprecated/declarations/model/-private/type-utils.d.ts +57 -0
  429. package/dist/unpkg/prod-deprecated/declarations/model/-private/util.d.ts +5 -0
  430. package/dist/unpkg/prod-deprecated/declarations/model/-private.d.ts +8 -0
  431. package/dist/unpkg/prod-deprecated/declarations/model/migration-support.d.ts +280 -0
  432. package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  433. package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  434. package/dist/unpkg/prod-deprecated/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  435. package/dist/unpkg/prod-deprecated/declarations/model-fragments/index.d.ts +5 -0
  436. package/dist/unpkg/prod-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  437. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  438. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  439. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  440. package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  441. package/dist/unpkg/prod-deprecated/declarations/model-fragments.d.ts +9 -0
  442. package/dist/unpkg/prod-deprecated/declarations/model.d.ts +49 -0
  443. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
  444. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  445. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/date.d.ts +28 -0
  446. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/number.d.ts +29 -0
  447. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/string.d.ts +29 -0
  448. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/transform.d.ts +118 -0
  449. package/dist/unpkg/prod-deprecated/declarations/serializer/-private/utils.d.ts +3 -0
  450. package/dist/unpkg/prod-deprecated/declarations/serializer/json-api.d.ts +123 -0
  451. package/dist/unpkg/prod-deprecated/declarations/serializer/json.d.ts +75 -0
  452. package/dist/unpkg/prod-deprecated/declarations/serializer/rest.d.ts +51 -0
  453. package/dist/unpkg/prod-deprecated/declarations/serializer/transform.d.ts +5 -0
  454. package/dist/unpkg/prod-deprecated/declarations/serializer.d.ts +254 -0
  455. package/dist/unpkg/prod-deprecated/declarations/store/-private.d.ts +223 -0
  456. package/dist/unpkg/prod-deprecated/declarations/store.d.ts +3 -0
  457. package/dist/unpkg/prod-deprecated/errors-CIGPcDvd.js +2595 -0
  458. package/dist/unpkg/prod-deprecated/hooks-QqRnX108.js +74 -0
  459. package/dist/unpkg/prod-deprecated/index.js +195 -0
  460. package/dist/unpkg/prod-deprecated/json-BNrV8EYG.js +1272 -0
  461. package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
  462. package/dist/unpkg/prod-deprecated/model/migration-support.js +579 -0
  463. package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
  464. package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
  465. package/dist/unpkg/prod-deprecated/model.js +667 -0
  466. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  467. package/dist/unpkg/prod-deprecated/schema-provider-g5MfTj8n.js +2338 -0
  468. package/dist/unpkg/prod-deprecated/serialize-into-hash-BnYvPex3.js +261 -0
  469. package/dist/unpkg/prod-deprecated/serializer/json-api.js +527 -0
  470. package/dist/unpkg/prod-deprecated/serializer/json.js +6 -0
  471. package/dist/unpkg/prod-deprecated/serializer/rest.js +1243 -0
  472. package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
  473. package/dist/unpkg/prod-deprecated/serializer.js +248 -0
  474. package/dist/unpkg/prod-deprecated/store.js +636 -0
  475. package/dist/unpkg/prod-deprecated/util-Dul6TZts.js +35 -0
  476. package/dist/unpkg/prod-deprecated/utils-Cqw9eRj5.js +23 -0
  477. package/package.json +6 -6
@@ -0,0 +1,1210 @@
1
+ import { Context } from '@warp-drive/core/reactive/-private';
2
+ import { warn } from '@ember/debug';
3
+ import { createDeferred } from '@warp-drive/core/request';
4
+ import { assertPrivateStore, waitFor, coerceId } from '@warp-drive/core/store/-private';
5
+ import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
7
+
8
+ /**
9
+ SnapshotRecordArray is not directly instantiable.
10
+ Instances are provided to consuming application's
11
+ adapters for certain `findAll` requests.
12
+
13
+ @hideconstructor
14
+ @public
15
+ */
16
+ class SnapshotRecordArray {
17
+ /**
18
+ * An array of snapshots
19
+ *
20
+ * @internal
21
+ */
22
+
23
+ /** @internal */
24
+
25
+ /**
26
+ * The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array
27
+ */
28
+
29
+ /** @internal */
30
+
31
+ /**
32
+ * A hash of adapter options passed into the store method for this request.
33
+ Example
34
+ ```js [app/adapters/post.js]
35
+ import MyCustomAdapter from './custom-adapter';
36
+ export default class PostAdapter extends MyCustomAdapter {
37
+ findAll(store, type, sinceToken, snapshotRecordArray) {
38
+ if (snapshotRecordArray.adapterOptions.subscribe) {
39
+ // ...
40
+ }
41
+ // ...
42
+ }
43
+ }
44
+ ```
45
+ */
46
+
47
+ /**
48
+ * The relationships to include for this request.
49
+ Example
50
+ ```js [app/adapters/application.js]
51
+ import Adapter from '@ember-data/adapter';
52
+ export default class ApplicationAdapter extends Adapter {
53
+ findAll(store, type, snapshotRecordArray) {
54
+ let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;
55
+ return fetch(url).then((response) => response.json())
56
+ }
57
+ }
58
+ ```
59
+ */
60
+
61
+ /**
62
+ SnapshotRecordArray is not directly instantiable.
63
+ Instances are provided to consuming application's
64
+ adapters and serializers for certain requests.
65
+ @private
66
+ @constructor
67
+ @param {Store} store
68
+ @param {String} type
69
+ @param options
70
+ */
71
+ constructor(store, type, options = {}) {
72
+ this.__store = store;
73
+ this._snapshots = null;
74
+ this.modelName = type;
75
+ this.adapterOptions = options.adapterOptions;
76
+ this.include = options.include;
77
+ }
78
+
79
+ /**
80
+ An array of records
81
+ @internal
82
+ */
83
+ get _recordArray() {
84
+ return this.__store.peekAll(this.modelName);
85
+ }
86
+
87
+ /**
88
+ Number of records in the array
89
+ Example
90
+ ```js [app/adapters/post.js]
91
+ import JSONAPIAdapter from '@ember-data/adapter/json-api';
92
+ export default class PostAdapter extends JSONAPIAdapter {
93
+ shouldReloadAll(store, snapshotRecordArray) {
94
+ return !snapshotRecordArray.length;
95
+ }
96
+ });
97
+ ```
98
+ */
99
+ get length() {
100
+ return this._recordArray.length;
101
+ }
102
+
103
+ /**
104
+ Get snapshots of the underlying record array
105
+ Example
106
+ ```js [app/adapters/post.js]
107
+ import JSONAPIAdapter from '@ember-data/adapter/json-api';
108
+ export default class PostAdapter extends JSONAPIAdapter {
109
+ shouldReloadAll(store, snapshotArray) {
110
+ let snapshots = snapshotArray.snapshots();
111
+ return snapshots.any(function(ticketSnapshot) {
112
+ let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');
113
+ if (timeDiff > 20) {
114
+ return true;
115
+ } else {
116
+ return false;
117
+ }
118
+ });
119
+ }
120
+ }
121
+ ```
122
+ @public
123
+ @return Array of snapshots
124
+ */
125
+ snapshots() {
126
+ if (this._snapshots !== null) {
127
+ return this._snapshots;
128
+ }
129
+ upgradeStore(this.__store);
130
+ const {
131
+ _fetchManager
132
+ } = this.__store;
133
+ const LiveArrayContext = this._recordArray[Context];
134
+ this._snapshots = LiveArrayContext.source.map(identifier => _fetchManager.createSnapshot(identifier));
135
+ return this._snapshots;
136
+ }
137
+ }
138
+ function assertIdentifierHasId(identifier) {
139
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
140
+ if (!test) {
141
+ throw new Error(`Attempted to schedule a fetch for a record without an id.`);
142
+ }
143
+ })(identifier && identifier.id !== null) : {};
144
+ }
145
+ function iterateData(data, fn) {
146
+ if (Array.isArray(data)) {
147
+ return data.map(fn);
148
+ } else {
149
+ return fn(data, 0);
150
+ }
151
+ }
152
+ function payloadIsNotBlank(adapterPayload) {
153
+ if (Array.isArray(adapterPayload)) {
154
+ return true;
155
+ } else {
156
+ return Object.keys(adapterPayload || {}).length !== 0;
157
+ }
158
+ }
159
+
160
+ /**
161
+ This is a helper method that validates a JSON API top-level document
162
+
163
+ The format of a document is described here:
164
+ http://jsonapi.org/format/#document-top-level
165
+
166
+ @internal
167
+ */
168
+ function validateDocumentStructure(doc) {
169
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
170
+ const errors = [];
171
+ if (!doc || typeof doc !== 'object') {
172
+ errors.push('Top level of a JSON API document must be an object');
173
+ } else {
174
+ if (!('data' in doc) && !('errors' in doc) && !('meta' in doc)) {
175
+ errors.push('One or more of the following keys must be present: "data", "errors", "meta".');
176
+ } else {
177
+ if ('data' in doc && 'errors' in doc) {
178
+ errors.push('Top level keys "errors" and "data" cannot both be present in a JSON API document');
179
+ }
180
+ }
181
+ if ('data' in doc) {
182
+ if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {
183
+ errors.push('data must be null, an object, or an array');
184
+ }
185
+ }
186
+ if ('meta' in doc) {
187
+ if (typeof doc.meta !== 'object') {
188
+ errors.push('meta must be an object');
189
+ }
190
+ }
191
+ if ('errors' in doc) {
192
+ if (!Array.isArray(doc.errors)) {
193
+ errors.push('errors must be an array');
194
+ }
195
+ }
196
+ if ('links' in doc) {
197
+ if (typeof doc.links !== 'object') {
198
+ errors.push('links must be an object');
199
+ }
200
+ }
201
+ if ('jsonapi' in doc) {
202
+ if (typeof doc.jsonapi !== 'object') {
203
+ errors.push('jsonapi must be an object');
204
+ }
205
+ }
206
+ if ('included' in doc) {
207
+ if (typeof doc.included !== 'object') {
208
+ errors.push('included must be an array');
209
+ }
210
+ }
211
+ }
212
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
213
+ if (!test) {
214
+ throw new Error(`Response must be normalized to a valid JSON API document:\n\t* ${errors.join('\n\t* ')}`);
215
+ }
216
+ })(errors.length === 0) : {};
217
+ }
218
+ }
219
+ function normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
220
+ const normalizedResponse = serializer ? serializer.normalizeResponse(store, modelClass, payload, id, requestType) : payload;
221
+ validateDocumentStructure(normalizedResponse);
222
+ return normalizedResponse;
223
+ }
224
+
225
+ /**
226
+ Snapshot is not directly instantiable.
227
+ Instances are provided to a consuming application's
228
+ adapters and serializers for certain requests.
229
+
230
+ Snapshots are only available when using `@ember-data/legacy-compat`
231
+ for legacy compatibility with adapters and serializers.
232
+
233
+ For serialization of records in modern paradigms, request data from
234
+ the cache or off the record directly.
235
+
236
+ @hideconstructor
237
+ @public
238
+ */
239
+ class Snapshot {
240
+ /** @internal */
241
+
242
+ /** @internal */
243
+
244
+ /** @internal */
245
+
246
+ /** @internal */
247
+
248
+ /** @internal */
249
+
250
+ /** @internal */
251
+
252
+ /** @internal */
253
+
254
+ /**
255
+ The unique ResourceKey associated with this Snapshot.
256
+ @public
257
+ */
258
+
259
+ /**
260
+ The ResourceType of the underlying record for this Snapshot, as a string.
261
+ @public
262
+ */
263
+
264
+ /**
265
+ The id of the snapshot's underlying record
266
+ Example
267
+ ```js
268
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
269
+ postSnapshot.id; // => '1'
270
+ ```
271
+ @public
272
+ */
273
+
274
+ /**
275
+ If `include` was passed to the options for the request, the value
276
+ would be available here.
277
+ @public
278
+ */
279
+
280
+ /**
281
+ The adapterOptions passed to the request which generated this Snapshot, if any
282
+ @public
283
+ */
284
+
285
+ constructor(options, identifier, store) {
286
+ this._store = store;
287
+ this.__attributes = null;
288
+ this._belongsToRelationships = Object.create(null);
289
+ this._belongsToIds = Object.create(null);
290
+ this._hasManyRelationships = Object.create(null);
291
+ this._hasManyIds = Object.create(null);
292
+ assertPrivateStore(store);
293
+ const hasRecord = !!store._instanceCache.peek(identifier);
294
+ this.modelName = identifier.type;
295
+ this.identifier = identifier;
296
+
297
+ /*
298
+ If the we do not yet have a record, then we are
299
+ likely a snapshot being provided to a find request, so we
300
+ populate __attributes lazily. Else, to preserve the "moment
301
+ in time" in which a snapshot is created, we greedily grab
302
+ the values.
303
+ */
304
+ if (hasRecord) {
305
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
306
+ this._attributes;
307
+ }
308
+ this.id = identifier.id;
309
+ this.adapterOptions = options.adapterOptions;
310
+ this.include = options.include;
311
+ this.modelName = identifier.type;
312
+ if (hasRecord) {
313
+ const cache = this._store.cache;
314
+ this._changedAttributes = cache.changedAttrs(identifier);
315
+ }
316
+ }
317
+
318
+ /**
319
+ The underlying record for this snapshot. Can be used to access methods and
320
+ properties defined on the record.
321
+ ```js
322
+ const someValue = snapshot.record.someProp;
323
+ ```
324
+ @property record
325
+ @public
326
+ */
327
+ get record() {
328
+ const record = this._store.peekRecord(this.identifier);
329
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
330
+ if (!test) {
331
+ throw new Error(`Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`);
332
+ }
333
+ })(record !== null) : {};
334
+ return record;
335
+ }
336
+
337
+ /** @internal */
338
+ get _attributes() {
339
+ if (this.__attributes !== null) {
340
+ return this.__attributes;
341
+ }
342
+ const attributes = this.__attributes = Object.create(null);
343
+ const {
344
+ identifier
345
+ } = this;
346
+ const cache = this._store.cache;
347
+ this.eachAttribute((key, meta) => {
348
+ attributes[key] = cache.getAttr(identifier, key);
349
+ });
350
+ return attributes;
351
+ }
352
+ get isNew() {
353
+ const cache = this._store.cache;
354
+ return cache?.isNew(this.identifier) || false;
355
+ }
356
+
357
+ /**
358
+ Returns the value of an attribute.
359
+ Example
360
+ ```javascript
361
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
362
+ postSnapshot.attr('author'); // => 'Tomster'
363
+ postSnapshot.attr('title'); // => 'Ember.js rocks'
364
+ ```
365
+ Note: Values are loaded eagerly and cached when the snapshot is created.
366
+ @return The attribute value or undefined
367
+ @public
368
+ */
369
+ attr(keyName) {
370
+ if (keyName in this._attributes) {
371
+ return this._attributes[keyName];
372
+ }
373
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
374
+ {
375
+ throw new Error(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`);
376
+ }
377
+ })() : {};
378
+ }
379
+
380
+ /**
381
+ Returns all attributes and their corresponding values.
382
+ ::: warning ⚠️ WARNING
383
+ Attributes are SHALLOW copied from the cache.
384
+ Because they are NOT deep copied from the cache, mutating
385
+ any object or array fields will cause unintended side-effects
386
+ and bugs.
387
+ :::
388
+ Example
389
+ ```js
390
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
391
+ postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
392
+ ```
393
+ @return All attributes of the current snapshot
394
+ @public
395
+ */
396
+ attributes() {
397
+ return {
398
+ ...this._attributes
399
+ };
400
+ }
401
+
402
+ /**
403
+ Returns all changed attributes and their old and new values.
404
+ Example
405
+ ```js
406
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
407
+ postModel.set('title', 'Ember.js rocks!');
408
+ postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
409
+ ```
410
+ @return All changed attributes of the current snapshot
411
+ @public
412
+ */
413
+ changedAttributes() {
414
+ const changedAttributes = Object.create(null);
415
+ if (!this._changedAttributes) {
416
+ return changedAttributes;
417
+ }
418
+ const changedAttributeKeys = Object.keys(this._changedAttributes);
419
+ for (let i = 0, length = changedAttributeKeys.length; i < length; i++) {
420
+ const key = changedAttributeKeys[i];
421
+ changedAttributes[key] = this._changedAttributes[key].slice();
422
+ }
423
+ return changedAttributes;
424
+ }
425
+
426
+ /**
427
+ Returns the current value of a belongsTo relationship.
428
+ `belongsTo` takes an optional hash of options as a second parameter,
429
+ currently supported options are:
430
+ - `id`: set to `true` if you only want the ID of the related record to be
431
+ returned.
432
+ Example
433
+ ```js
434
+ // store.push('post', { id: 1, title: 'Hello World' });
435
+ // store.createRecord('comment', { body: 'Lorem ipsum', post: post });
436
+ commentSnapshot.belongsTo('post'); // => Snapshot
437
+ commentSnapshot.belongsTo('post', { id: true }); // => '1'
438
+ // store.push('comment', { id: 1, body: 'Lorem ipsum' });
439
+ commentSnapshot.belongsTo('post'); // => undefined
440
+ ```
441
+ Calling `belongsTo` will return a new Snapshot as long as there's any known
442
+ data for the relationship available, such as an ID. If the relationship is
443
+ known but unset, `belongsTo` will return `null`. If the contents of the
444
+ relationship is unknown `belongsTo` will return `undefined`.
445
+ Note: Relationships are loaded lazily and cached upon first access.
446
+ @public
447
+ @return A snapshot or ID of a known relationship or null if the
448
+ relationship is known but unset. undefined will be returned if the
449
+ contents of the relationship are unknown.
450
+ */
451
+ belongsTo(keyName, options) {
452
+ const returnModeIsId = !!(options && options.id);
453
+ let result;
454
+ const store = this._store;
455
+ if (returnModeIsId === true && keyName in this._belongsToIds) {
456
+ return this._belongsToIds[keyName];
457
+ }
458
+ if (returnModeIsId === false && keyName in this._belongsToRelationships) {
459
+ return this._belongsToRelationships[keyName];
460
+ }
461
+ const relationshipMeta = store.schema.fields({
462
+ type: this.modelName
463
+ }).get(keyName);
464
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
465
+ if (!test) {
466
+ throw new Error(`Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`);
467
+ }
468
+ })(relationshipMeta && relationshipMeta.kind === 'belongsTo') : {};
469
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
470
+ if (!test) {
471
+ throw new Error(`snapshot.belongsTo only supported when using a cache that supports the graph`);
472
+ }
473
+ })(this._store._graph) : {};
474
+ const {
475
+ identifier
476
+ } = this;
477
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
478
+ const relationship = this._store.schema.fields(identifier)?.get(keyName);
479
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
480
+ if (!test) {
481
+ throw new Error(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`);
482
+ }
483
+ })(relationship) : {};
484
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
485
+ if (!test) {
486
+ throw new Error(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a hasMany.`);
487
+ }
488
+ })(relationship.kind === 'belongsTo') : {};
489
+ }
490
+ const value = this._store.cache.getRelationship(identifier, keyName);
491
+ const data = value && value.data;
492
+ const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;
493
+ if (value && value.data !== undefined) {
494
+ const cache = store.cache;
495
+ if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {
496
+ if (returnModeIsId) {
497
+ result = inverseIdentifier.id;
498
+ } else {
499
+ result = store._fetchManager.createSnapshot(inverseIdentifier);
500
+ }
501
+ } else {
502
+ result = null;
503
+ }
504
+ }
505
+ if (returnModeIsId) {
506
+ this._belongsToIds[keyName] = result;
507
+ } else {
508
+ this._belongsToRelationships[keyName] = result;
509
+ }
510
+ return result;
511
+ }
512
+
513
+ /**
514
+ Returns the current value of a hasMany relationship.
515
+ `hasMany` takes an optional hash of options as a second parameter,
516
+ currently supported options are:
517
+ - `ids`: set to `true` if you only want the IDs of the related records to be
518
+ returned.
519
+ Example
520
+ ```javascript
521
+ // store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });
522
+ postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]
523
+ postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']
524
+ // store.push('post', { id: 1, title: 'Hello World' });
525
+ postSnapshot.hasMany('comments'); // => undefined
526
+ ```
527
+ Note: Relationships are loaded lazily and cached upon first access.
528
+ @public
529
+ @return An array of snapshots or IDs of a known
530
+ relationship or an empty array if the relationship is known but unset.
531
+ undefined will be returned if the contents of the relationship is unknown.
532
+ */
533
+ hasMany(keyName, options) {
534
+ const returnModeIsIds = !!(options && options.ids);
535
+ let results;
536
+ const cachedIds = this._hasManyIds[keyName];
537
+ const cachedSnapshots = this._hasManyRelationships[keyName];
538
+ if (returnModeIsIds === true && keyName in this._hasManyIds) {
539
+ return cachedIds;
540
+ }
541
+ if (returnModeIsIds === false && keyName in this._hasManyRelationships) {
542
+ return cachedSnapshots;
543
+ }
544
+ const store = this._store;
545
+ const relationshipMeta = store.schema.fields({
546
+ type: this.modelName
547
+ }).get(keyName);
548
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
549
+ if (!test) {
550
+ throw new Error(`Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`);
551
+ }
552
+ })(relationshipMeta && relationshipMeta.kind === 'hasMany') : {};
553
+
554
+ // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes
555
+ // this check is not a regression in behavior because relationships don't currently
556
+ // function without access to intimate API contracts between RecordData and Model.
557
+ // This is a requirement we should fix as soon as the relationship layer does not require
558
+ // this intimate API usage.
559
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
560
+ if (!test) {
561
+ throw new Error(`snapshot.hasMany only supported when using a cache that supports the graph`);
562
+ }
563
+ })(this._store._graph) : {};
564
+ const {
565
+ identifier
566
+ } = this;
567
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
568
+ const relationship = this._store.schema.fields(identifier)?.get(keyName);
569
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
570
+ if (!test) {
571
+ throw new Error(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`);
572
+ }
573
+ })(relationship) : {};
574
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
575
+ if (!test) {
576
+ throw new Error(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a belongsTo.`);
577
+ }
578
+ })(relationship.kind === 'hasMany') : {};
579
+ }
580
+ const value = this._store.cache.getRelationship(identifier, keyName);
581
+ if (value.data) {
582
+ results = [];
583
+ value.data.forEach(member => {
584
+ const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);
585
+ const cache = store.cache;
586
+ if (!cache.isDeleted(inverseIdentifier)) {
587
+ if (returnModeIsIds) {
588
+ results.push(inverseIdentifier.id);
589
+ } else {
590
+ results.push(store._fetchManager.createSnapshot(inverseIdentifier));
591
+ }
592
+ }
593
+ });
594
+ }
595
+
596
+ // we assign even if `undefined` so that we don't reprocess the relationship
597
+ // on next access. This works with the `keyName in` checks above.
598
+ if (returnModeIsIds) {
599
+ this._hasManyIds[keyName] = results;
600
+ } else {
601
+ this._hasManyRelationships[keyName] = results;
602
+ }
603
+ return results;
604
+ }
605
+
606
+ /**
607
+ Iterates through all the attributes of the model, calling the passed
608
+ function on each attribute.
609
+ Example
610
+ ```javascript
611
+ snapshot.eachAttribute(function(name, meta) {
612
+ // ...
613
+ });
614
+ ```
615
+ @param callback the callback to execute
616
+ @param binding the optional value to which the callback's `this` should be bound
617
+ @public
618
+ */
619
+ eachAttribute(callback, binding) {
620
+ // if the store has a modelFor implementation, we use it to iterate attributes. This allows
621
+ // a custom "ModelSchema" class for legacy serializers to adapt to new fields if desired.
622
+ if (typeof this._store.modelFor === 'function') {
623
+ const modelSchema = this._store.modelFor(this.identifier.type);
624
+ modelSchema.eachAttribute(callback, binding);
625
+ } else {
626
+ const fields = this._store.schema.fields(this.identifier);
627
+ fields.forEach((field, key) => {
628
+ if (field.kind === 'attribute') {
629
+ callback.call(binding, key, field);
630
+ }
631
+ });
632
+ }
633
+ }
634
+
635
+ /**
636
+ Iterates through all the relationships of the model, calling the passed
637
+ function on each relationship.
638
+ Example
639
+ ```javascript
640
+ snapshot.eachRelationship(function(name, relationship) {
641
+ // ...
642
+ });
643
+ ```
644
+ @param callback the callback to execute
645
+ @param binding the optional value to which the callback's `this` should be bound
646
+ @public
647
+ */
648
+ eachRelationship(callback, binding) {
649
+ // if the store has a modelFor implementation, we use it to iterate relationships. This allows
650
+ // a custom "ModelSchema" class for legacy serializers to adapt to new fields if desired.
651
+ if (typeof this._store.modelFor === 'function') {
652
+ const modelSchema = this._store.modelFor(this.identifier.type);
653
+ modelSchema.eachRelationship(callback, binding);
654
+ } else {
655
+ const fields = this._store.schema.fields(this.identifier);
656
+ fields.forEach((field, key) => {
657
+ if (field.kind === 'belongsTo' || field.kind === 'hasMany') {
658
+ callback.call(binding, key, field);
659
+ }
660
+ });
661
+ }
662
+ }
663
+
664
+ /**
665
+ Serializes the snapshot using the serializer for the model.
666
+ Example
667
+ ```js [app/adapters/application.js]
668
+ import Adapter from '@ember-data/adapter';
669
+ export default Adapter.extend({
670
+ createRecord(store, type, snapshot) {
671
+ let data = snapshot.serialize({ includeId: true });
672
+ let url = `/${type.modelName}`;
673
+ return fetch(url, {
674
+ method: 'POST',
675
+ body: data,
676
+ }).then((response) => response.json())
677
+ }
678
+ });
679
+ ```
680
+ @return an object whose values are primitive JSON values only
681
+ @public
682
+ */
683
+ serialize(options) {
684
+ upgradeStore(this._store);
685
+ const serializer = this._store.serializerFor(this.modelName);
686
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
687
+ if (!test) {
688
+ throw new Error(`Cannot serialize record, no serializer found`);
689
+ }
690
+ })(serializer) : {};
691
+ return serializer.serialize(this, options);
692
+ }
693
+ }
694
+ const SaveOp = getOrSetGlobal('SaveOp', Symbol('SaveOp'));
695
+ /**
696
+ * @private
697
+ */
698
+ class FetchManager {
699
+ /**
700
+ * @internal
701
+ */
702
+
703
+ /** @internal */
704
+
705
+ // fetches pending in the runloop, waiting to be coalesced
706
+ /**
707
+ * @internal
708
+ */
709
+
710
+ /** @internal */
711
+
712
+ constructor(store) {
713
+ assertPrivateStore(store);
714
+ this._store = store;
715
+ // used to keep track of all the find requests that need to be coalesced
716
+ this._pendingFetch = new Map();
717
+ this.requestCache = store.getRequestStateService();
718
+ this.isDestroyed = false;
719
+ }
720
+ createSnapshot(identifier, options = {}) {
721
+ return new Snapshot(options, identifier, this._store);
722
+ }
723
+
724
+ /**
725
+ This method is called by `record.save`, and gets passed a
726
+ resolver for the promise that `record.save` returns.
727
+ It schedules saving to happen at the end of the run loop.
728
+ @private
729
+ */
730
+ scheduleSave(identifier, options) {
731
+ const resolver = createDeferred();
732
+ const query = {
733
+ op: 'saveRecord',
734
+ recordIdentifier: identifier,
735
+ options
736
+ };
737
+ const queryRequest = {
738
+ data: [query]
739
+ };
740
+ const snapshot = this.createSnapshot(identifier, options);
741
+ const pendingSaveItem = {
742
+ snapshot: snapshot,
743
+ resolver: resolver,
744
+ identifier,
745
+ options,
746
+ queryRequest
747
+ };
748
+ const monitored = this.requestCache._enqueue(resolver.promise, pendingSaveItem.queryRequest);
749
+ _flushPendingSave(this._store, pendingSaveItem);
750
+ return monitored;
751
+ }
752
+ scheduleFetch(identifier, options, request) {
753
+ const query = {
754
+ op: 'findRecord',
755
+ recordIdentifier: identifier,
756
+ options
757
+ };
758
+ const queryRequest = {
759
+ data: [query]
760
+ };
761
+ const pendingFetch = this.getPendingFetch(identifier, options);
762
+ if (pendingFetch) {
763
+ return pendingFetch;
764
+ }
765
+ const modelName = identifier.type;
766
+ const resolver = createDeferred();
767
+ const pendingFetchItem = {
768
+ identifier,
769
+ resolver,
770
+ options,
771
+ queryRequest
772
+ };
773
+ const resolverPromise = resolver.promise;
774
+ const store = this._store;
775
+ const isInitialLoad = !store._instanceCache.recordIsLoaded(identifier); // we don't use isLoading directly because we are the request
776
+
777
+ const monitored = this.requestCache._enqueue(resolverPromise, pendingFetchItem.queryRequest);
778
+ let promise = monitored.then(payload => {
779
+ // ensure that regardless of id returned we assign to the correct record
780
+ if (payload.data && !Array.isArray(payload.data)) {
781
+ payload.data.lid = identifier.lid;
782
+ }
783
+
784
+ // additional data received in the payload
785
+ // may result in the merging of identifiers (and thus records)
786
+ const potentiallyNewIm = store._push(payload, options.reload);
787
+ if (potentiallyNewIm && !Array.isArray(potentiallyNewIm)) {
788
+ return potentiallyNewIm;
789
+ }
790
+ return identifier;
791
+ }, error => {
792
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
793
+ if (!test) {
794
+ throw new Error(`Async Leak Detected: Expected the store to not be destroyed`);
795
+ }
796
+ })(!store.isDestroyed) : {};
797
+ const cache = store.cache;
798
+ if (!cache || cache.isEmpty(identifier) || isInitialLoad) {
799
+ let isReleasable = true;
800
+ if (store._graph) {
801
+ const graph = store._graph;
802
+ if (!cache) {
803
+ isReleasable = graph.isReleasable(identifier);
804
+ if (!isReleasable) {
805
+ graph.unload(identifier, true);
806
+ }
807
+ }
808
+ }
809
+ if (cache || isReleasable) {
810
+ store._enableAsyncFlush = true;
811
+ store._instanceCache.unloadRecord(identifier);
812
+ store._enableAsyncFlush = null;
813
+ }
814
+ }
815
+ throw error;
816
+ });
817
+ if (this._pendingFetch.size === 0) {
818
+ void new Promise(resolve => setTimeout(resolve, 0)).then(() => {
819
+ this.flushAllPendingFetches();
820
+ });
821
+ }
822
+ const fetchesByType = this._pendingFetch;
823
+ let fetchesById = fetchesByType.get(modelName);
824
+ if (!fetchesById) {
825
+ fetchesById = new Map();
826
+ fetchesByType.set(modelName, fetchesById);
827
+ }
828
+ let requestsForIdentifier = fetchesById.get(identifier);
829
+ if (!requestsForIdentifier) {
830
+ requestsForIdentifier = [];
831
+ fetchesById.set(identifier, requestsForIdentifier);
832
+ }
833
+ requestsForIdentifier.push(pendingFetchItem);
834
+ if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
835
+ if (!request.disableTestWaiter) {
836
+ promise = waitFor(promise);
837
+ }
838
+ }
839
+ pendingFetchItem.promise = promise;
840
+ return promise;
841
+ }
842
+ getPendingFetch(identifier, options) {
843
+ const pendingFetches = this._pendingFetch.get(identifier.type)?.get(identifier);
844
+
845
+ // We already have a pending fetch for this
846
+ if (pendingFetches) {
847
+ const matchingPendingFetch = pendingFetches.find(fetch => isSameRequest(options, fetch.options));
848
+ if (matchingPendingFetch) {
849
+ return matchingPendingFetch.promise;
850
+ }
851
+ }
852
+ }
853
+ flushAllPendingFetches() {
854
+ if (this.isDestroyed) {
855
+ return;
856
+ }
857
+ const store = this._store;
858
+ this._pendingFetch.forEach((fetchItem, type) => _flushPendingFetchForType(store, fetchItem, type));
859
+ this._pendingFetch.clear();
860
+ }
861
+ fetchDataIfNeededForIdentifier(identifier, options = {}, request) {
862
+ // pre-loading will change the isEmpty value
863
+ const isEmpty = _isEmpty(this._store._instanceCache, identifier);
864
+ const isLoading = _isLoading(this._store._instanceCache, identifier);
865
+ let promise;
866
+ if (isEmpty) {
867
+ assertIdentifierHasId(identifier);
868
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
869
+ promise = this.scheduleFetch(identifier, Object.assign({}, options, {
870
+ reload: true
871
+ }), request);
872
+ } else {
873
+ options.reload = true;
874
+ promise = this.scheduleFetch(identifier, options, request);
875
+ }
876
+ } else if (isLoading) {
877
+ promise = this.getPendingFetch(identifier, options);
878
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
879
+ if (!test) {
880
+ throw new Error(`Expected to find a pending request for a record in the loading state, but found none`);
881
+ }
882
+ })(promise) : {};
883
+ } else {
884
+ promise = Promise.resolve(identifier);
885
+ }
886
+ return promise;
887
+ }
888
+ destroy() {
889
+ this.isDestroyed = true;
890
+ }
891
+ }
892
+
893
+ /**
894
+ * This type exists for internal use only for
895
+ * where intimate contracts still exist either for
896
+ * the Test Suite or for Legacy code.
897
+ *
898
+ * @private
899
+ */
900
+
901
+ function _isEmpty(instanceCache, identifier) {
902
+ const cache = instanceCache.cache;
903
+ if (!cache) {
904
+ return true;
905
+ }
906
+ const isNew = cache.isNew(identifier);
907
+ const isDeleted = cache.isDeleted(identifier);
908
+ const isEmpty = cache.isEmpty(identifier);
909
+ return (!isNew || isDeleted) && isEmpty;
910
+ }
911
+ function _isLoading(cache, identifier) {
912
+ const req = cache.store.getRequestStateService();
913
+ // const fulfilled = req.getLastRequestForRecord(identifier);
914
+ const isLoaded = cache.recordIsLoaded(identifier);
915
+ return !isLoaded &&
916
+ // fulfilled === null &&
917
+ req.getPendingRequestsForRecord(identifier).some(r => r.type === 'query');
918
+ }
919
+ function includesSatisfies(current, existing) {
920
+ // if we have no includes we are good
921
+ if (!current?.length) {
922
+ return true;
923
+ }
924
+
925
+ // if we are here we have includes,
926
+ // and if existing has no includes then we will need a new request
927
+ if (!existing?.length) {
928
+ return false;
929
+ }
930
+ const arrCurrent = (Array.isArray(current) ? current : current.split(',')).sort();
931
+ const arrExisting = (Array.isArray(existing) ? existing : existing.split(',')).sort();
932
+
933
+ // includes are identical
934
+ if (arrCurrent.join(',') === arrExisting.join(',')) {
935
+ return true;
936
+ }
937
+
938
+ // if all of current includes are in existing includes then we are good
939
+ // so if we find one that is not in existing then we need a new request
940
+ for (let i = 0; i < arrCurrent.length; i++) {
941
+ if (!arrExisting.includes(arrCurrent[i])) {
942
+ return false;
943
+ }
944
+ }
945
+ return true;
946
+ }
947
+ function optionsSatisfies(current, existing) {
948
+ return !current || current === existing || Object.keys(current).length === 0;
949
+ }
950
+
951
+ // this function helps resolve whether we have a pending request that we should use instead
952
+ function isSameRequest(options = {}, existingOptions = {}) {
953
+ return optionsSatisfies(options.adapterOptions, existingOptions.adapterOptions) && includesSatisfies(options.include, existingOptions.include);
954
+ }
955
+ function _findMany(store, adapter, modelName, snapshots) {
956
+ const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still
957
+ const promise = Promise.resolve().then(() => {
958
+ const ids = snapshots.map(s => s.id);
959
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
960
+ if (!test) {
961
+ throw new Error(`Cannot fetch a record without an id`);
962
+ }
963
+ })(ids.every(v => v !== null)) : {};
964
+ // eslint-disable-next-line @typescript-eslint/unbound-method
965
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
966
+ if (!test) {
967
+ throw new Error(`Expected this adapter to implement findMany for coalescing`);
968
+ }
969
+ })(adapter.findMany) : {};
970
+ const ret = adapter.findMany(store, modelClass, ids, snapshots);
971
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
972
+ if (!test) {
973
+ throw new Error('adapter.findMany returned undefined, this was very likely a mistake');
974
+ }
975
+ })(ret !== undefined) : {};
976
+ return ret;
977
+ });
978
+ return promise.then(adapterPayload => {
979
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
980
+ if (!test) {
981
+ throw new Error(`You made a 'findMany' request for '${modelName}' records with ids '[${snapshots.map(s => s.id).join(',')}]', but the adapter's response did not have any data`);
982
+ }
983
+ })(!!payloadIsNotBlank(adapterPayload)) : {};
984
+ const serializer = store.serializerFor(modelName);
985
+ const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');
986
+ return payload;
987
+ });
988
+ }
989
+ function rejectFetchedItems(fetchMap, snapshots, error) {
990
+ for (let i = 0, l = snapshots.length; i < l; i++) {
991
+ const snapshot = snapshots[i];
992
+ const pair = fetchMap.get(snapshot);
993
+ if (pair) {
994
+ pair.resolver.reject(error || new Error(`Expected: '<${snapshot.modelName}:${snapshot.id}>' to be present in the adapter provided payload, but it was not found.`));
995
+ }
996
+ }
997
+ }
998
+ function handleFoundRecords(store, fetchMap, snapshots, coalescedPayload) {
999
+ /*
1000
+ It is possible that the same ID is included multiple times
1001
+ via multiple snapshots. This happens when more than one
1002
+ options hash was supplied, each of which must be uniquely
1003
+ accounted for.
1004
+ However, since we can't map from response to a specific
1005
+ options object, we resolve all snapshots by id with
1006
+ the first response we see.
1007
+ */
1008
+ const snapshotsById = new Map();
1009
+ for (let i = 0; i < snapshots.length; i++) {
1010
+ const id = snapshots[i].id;
1011
+ let snapshotGroup = snapshotsById.get(id);
1012
+ if (!snapshotGroup) {
1013
+ snapshotGroup = [];
1014
+ snapshotsById.set(id, snapshotGroup);
1015
+ }
1016
+ snapshotGroup.push(snapshots[i]);
1017
+ }
1018
+ const included = Array.isArray(coalescedPayload.included) ? coalescedPayload.included : [];
1019
+
1020
+ // resolve found records
1021
+ const resources = coalescedPayload.data;
1022
+ for (let i = 0, l = resources.length; i < l; i++) {
1023
+ const resource = resources[i];
1024
+ const snapshotGroup = snapshotsById.get(resource.id);
1025
+ snapshotsById.delete(resource.id);
1026
+ if (!snapshotGroup) {
1027
+ // TODO consider whether this should be a deprecation/assertion
1028
+ included.push(resource);
1029
+ } else {
1030
+ snapshotGroup.forEach(snapshot => {
1031
+ const pair = fetchMap.get(snapshot);
1032
+ const resolver = pair.resolver;
1033
+ resolver.resolve({
1034
+ data: resource
1035
+ });
1036
+ });
1037
+ }
1038
+ }
1039
+ if (included.length > 0) {
1040
+ store._push({
1041
+ data: null,
1042
+ included
1043
+ }, true);
1044
+ }
1045
+ if (snapshotsById.size === 0) {
1046
+ return;
1047
+ }
1048
+
1049
+ // reject missing records
1050
+ const rejected = [];
1051
+ snapshotsById.forEach(snapshotArray => {
1052
+ rejected.push(...snapshotArray);
1053
+ });
1054
+ warn('Ember Data expected to find records with the following ids in the adapter response from findMany but they were missing: [ "' + [...snapshotsById.values()].map(r => r[0].id).join('", "') + '" ]', {
1055
+ id: 'ds.store.missing-records-from-adapter'
1056
+ });
1057
+ rejectFetchedItems(fetchMap, rejected);
1058
+ }
1059
+ function _fetchRecord(store, adapter, fetchItem) {
1060
+ const identifier = fetchItem.identifier;
1061
+ const modelName = identifier.type;
1062
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1063
+ if (!test) {
1064
+ throw new Error(`You tried to find a record but you have no adapter (for ${modelName})`);
1065
+ }
1066
+ })(adapter) : {};
1067
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1068
+ if (!test) {
1069
+ throw new Error(`You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`);
1070
+ }
1071
+ })(typeof adapter.findRecord === 'function') : {};
1072
+ const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);
1073
+ const klass = store.modelFor(identifier.type);
1074
+ const id = identifier.id;
1075
+ let promise = Promise.resolve().then(() => {
1076
+ return adapter.findRecord(store, klass, identifier.id, snapshot);
1077
+ });
1078
+ promise = promise.then(adapterPayload => {
1079
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1080
+ if (!test) {
1081
+ throw new Error(`Async Leak Detected: Expected the store to not be destroyed`);
1082
+ }
1083
+ })(!(store.isDestroyed || store.isDestroying)) : {};
1084
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1085
+ if (!test) {
1086
+ throw new Error(`You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`);
1087
+ }
1088
+ })(!!payloadIsNotBlank(adapterPayload)) : {};
1089
+ const serializer = store.serializerFor(modelName);
1090
+ const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');
1091
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1092
+ if (!test) {
1093
+ throw new Error(`Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`);
1094
+ }
1095
+ })(!Array.isArray(payload.data)) : {};
1096
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1097
+ if (!test) {
1098
+ throw new Error(`The 'findRecord' request for ${modelName}:${id} resolved indicating success but contained no primary data. To indicate a 404 not found you should either reject the promise returned by the adapter's findRecord method or throw a NotFoundError.`);
1099
+ }
1100
+ })('data' in payload && payload.data !== null && typeof payload.data === 'object') : {};
1101
+ warn(`You requested a record of type '${modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead.`, coerceId(payload.data.id) === coerceId(id), {
1102
+ id: 'ds.store.findRecord.id-mismatch'
1103
+ });
1104
+ return payload;
1105
+ });
1106
+ fetchItem.resolver.resolve(promise);
1107
+ }
1108
+ function _processCoalescedGroup(store, fetchMap, group, adapter, modelName) {
1109
+ if (group.length > 1) {
1110
+ _findMany(store, adapter, modelName, group).then(payloads => {
1111
+ handleFoundRecords(store, fetchMap, group, payloads);
1112
+ }).catch(error => {
1113
+ rejectFetchedItems(fetchMap, group, error);
1114
+ });
1115
+ } else if (group.length === 1) {
1116
+ _fetchRecord(store, adapter, fetchMap.get(group[0]));
1117
+ } else {
1118
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1119
+ {
1120
+ throw new Error("You cannot return an empty array from adapter's method groupRecordsForFindMany");
1121
+ }
1122
+ })() : {};
1123
+ }
1124
+ }
1125
+ function _flushPendingFetchForType(store, pendingFetchMap, modelName) {
1126
+ const adapter = store.adapterFor(modelName);
1127
+ const shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;
1128
+ if (shouldCoalesce) {
1129
+ const pendingFetchItems = [];
1130
+ pendingFetchMap.forEach((requestsForIdentifier, identifier) => {
1131
+ if (requestsForIdentifier.length > 1) {
1132
+ return;
1133
+ }
1134
+
1135
+ // remove this entry from the map so it's not processed again
1136
+ pendingFetchMap.delete(identifier);
1137
+ pendingFetchItems.push(requestsForIdentifier[0]);
1138
+ });
1139
+ const totalItems = pendingFetchItems.length;
1140
+ if (totalItems > 1) {
1141
+ const snapshots = new Array(totalItems);
1142
+ const fetchMap = new Map();
1143
+ for (let i = 0; i < totalItems; i++) {
1144
+ const fetchItem = pendingFetchItems[i];
1145
+ snapshots[i] = store._fetchManager.createSnapshot(fetchItem.identifier, fetchItem.options);
1146
+ fetchMap.set(snapshots[i], fetchItem);
1147
+ }
1148
+ let groups;
1149
+ if (adapter.groupRecordsForFindMany) {
1150
+ groups = adapter.groupRecordsForFindMany(store, snapshots);
1151
+ } else {
1152
+ groups = [snapshots];
1153
+ }
1154
+ for (let i = 0, l = groups.length; i < l; i++) {
1155
+ _processCoalescedGroup(store, fetchMap, groups[i], adapter, modelName);
1156
+ }
1157
+ } else if (totalItems === 1) {
1158
+ _fetchRecord(store, adapter, pendingFetchItems[0]);
1159
+ }
1160
+ }
1161
+ pendingFetchMap.forEach(pendingFetchItems => {
1162
+ pendingFetchItems.forEach(pendingFetchItem => {
1163
+ _fetchRecord(store, adapter, pendingFetchItem);
1164
+ });
1165
+ });
1166
+ }
1167
+ function _flushPendingSave(store, pending) {
1168
+ const {
1169
+ snapshot,
1170
+ resolver,
1171
+ identifier,
1172
+ options
1173
+ } = pending;
1174
+ const adapter = store.adapterFor(identifier.type);
1175
+ const operation = options[SaveOp];
1176
+ const modelName = snapshot.modelName;
1177
+ const modelClass = store.modelFor(modelName);
1178
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1179
+ if (!test) {
1180
+ throw new Error(`You tried to update a record but you have no adapter (for ${modelName})`);
1181
+ }
1182
+ })(adapter) : {};
1183
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1184
+ if (!test) {
1185
+ throw new Error(`You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`);
1186
+ }
1187
+ })(typeof adapter[operation] === 'function') : {};
1188
+ let promise = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));
1189
+ const serializer = store.serializerFor(modelName);
1190
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1191
+ if (!test) {
1192
+ throw new Error(`Your adapter's '${operation}' method must return a value, but it returned 'undefined'`);
1193
+ }
1194
+ })(promise !== undefined) : {};
1195
+ promise = promise.then(adapterPayload => {
1196
+ if (adapterPayload) {
1197
+ return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);
1198
+ }
1199
+ });
1200
+ resolver.resolve(promise);
1201
+ }
1202
+
1203
+ /**
1204
+ * Utilities - often temporary - for maintaining backwards compatibility with
1205
+ * older parts of WarpDrive.
1206
+ *
1207
+ @module
1208
+ */
1209
+ function upgradeStore(store) {}
1210
+ export { FetchManager as F, SaveOp as S, assertIdentifierHasId as a, SnapshotRecordArray as b, Snapshot as c, iterateData as i, normalizeResponseHelper as n, payloadIsNotBlank as p, upgradeStore as u };