@warp-drive/legacy 5.9.0-alpha.23 → 5.9.0-alpha.28

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 (226) hide show
  1. package/dist/-private-DQ6Iap2t.js.map +1 -1
  2. package/dist/-private-DccRZQsm.js.map +1 -1
  3. package/dist/adapter/error.js.map +1 -1
  4. package/dist/adapter/json-api.js.map +1 -1
  5. package/dist/adapter/rest.js +3 -3
  6. package/dist/adapter/rest.js.map +1 -1
  7. package/dist/{adapter-DFVAuivO.js → adapter-eYo2pIuM.js} +2 -2
  8. package/dist/adapter-eYo2pIuM.js.map +1 -0
  9. package/dist/adapter.js +1 -1
  10. package/dist/compat/extensions.js.map +1 -1
  11. package/dist/{compat-g__Pfy2S.js → compat-DcHVxuuZ.js} +3 -3
  12. package/dist/compat-DcHVxuuZ.js.map +1 -0
  13. package/dist/compat.js +1 -1
  14. package/dist/{errors-BbCo7Tut.js → errors-BEEsrHbl.js} +2 -2
  15. package/dist/errors-BEEsrHbl.js.map +1 -0
  16. package/dist/extensions-DumNm4dA.d.ts.map +1 -1
  17. package/dist/index.js +3 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/json-BXNPTlcH.js.map +1 -1
  20. package/dist/model/-private.js +1 -1
  21. package/dist/model/migration-support.js +2 -2
  22. package/dist/model/migration-support.js.map +1 -1
  23. package/dist/model-62hn5_PD.d.ts.map +1 -1
  24. package/dist/{model-C7-ZIbd5.js → model-DcXZdNMu.js} +3 -3
  25. package/dist/model-DcXZdNMu.js.map +1 -0
  26. package/dist/{model-fragments-tlMYPSd_.js → model-fragments-DSqu0ptR.js} +60 -60
  27. package/dist/model-fragments-DSqu0ptR.js.map +1 -0
  28. package/dist/model-fragments.js +1 -1
  29. package/dist/model.js +2 -2
  30. package/dist/rest-0NhtexIq.d.ts.map +1 -1
  31. package/dist/{runtime-BPCpkOf1-CVHWB0MF.js → runtime--fcdnjmJ-DMTJ0Kb3.js} +3 -3
  32. package/dist/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -0
  33. package/dist/{schema-provider-7RHVFTdb.js → schema-provider-H4zNXtry.js} +3 -3
  34. package/dist/schema-provider-H4zNXtry.js.map +1 -0
  35. package/dist/serializer/json-api.js.map +1 -1
  36. package/dist/serializer/rest.js.map +1 -1
  37. package/dist/serializer/transform.js.map +1 -1
  38. package/dist/serializer.js +1 -1
  39. package/dist/serializer.js.map +1 -1
  40. package/dist/store-C4qYzXei.js.map +1 -1
  41. package/dist/unpkg/dev/-private-CrEyBE-B.js.map +1 -1
  42. package/dist/unpkg/dev/-private-vOhxVExH.js.map +1 -1
  43. package/dist/unpkg/dev/adapter/error.js.map +1 -1
  44. package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
  45. package/dist/unpkg/dev/adapter/rest.js +3 -3
  46. package/dist/unpkg/dev/adapter/rest.js.map +1 -1
  47. package/dist/unpkg/{dev-deprecated/adapter-RlAbN461.js → dev/adapter-oLwyr47q.js} +2 -2
  48. package/dist/unpkg/dev/adapter-oLwyr47q.js.map +1 -0
  49. package/dist/unpkg/dev/adapter.js +1 -1
  50. package/dist/unpkg/dev/compat/extensions.js.map +1 -1
  51. package/dist/unpkg/dev/{compat-B2O7jZLN.js → compat-BqmMZNci.js} +4 -4
  52. package/dist/unpkg/dev/compat-BqmMZNci.js.map +1 -0
  53. package/dist/unpkg/dev/compat.js +1 -1
  54. package/dist/unpkg/dev/{errors-DiBJX1gq.js → errors-8GnRWcxo.js} +2 -2
  55. package/dist/unpkg/dev/errors-8GnRWcxo.js.map +1 -0
  56. package/dist/unpkg/dev/index.js +3 -3
  57. package/dist/unpkg/dev/index.js.map +1 -1
  58. package/dist/unpkg/dev/json-DDJji3V3.js.map +1 -1
  59. package/dist/unpkg/dev/model/-private.js +1 -1
  60. package/dist/unpkg/dev/model/migration-support.js +2 -2
  61. package/dist/unpkg/dev/model/migration-support.js.map +1 -1
  62. package/dist/unpkg/dev/{model-BrJ3pFM-.js → model-LK7ethC5.js} +3 -3
  63. package/dist/unpkg/dev/model-LK7ethC5.js.map +1 -0
  64. package/dist/unpkg/dev/{model-fragments-tlMYPSd_.js → model-fragments-DSqu0ptR.js} +60 -60
  65. package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +1 -0
  66. package/dist/unpkg/dev/model-fragments.js +1 -1
  67. package/dist/unpkg/dev/model.js +2 -2
  68. package/dist/unpkg/dev/{runtime-BPCpkOf1-CVHWB0MF.js → runtime--fcdnjmJ-DMTJ0Kb3.js} +3 -3
  69. package/dist/unpkg/dev/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -0
  70. package/dist/unpkg/dev/{schema-provider-Z5GzOhu-.js → schema-provider-CRzoMoTO.js} +3 -3
  71. package/dist/unpkg/dev/schema-provider-CRzoMoTO.js.map +1 -0
  72. package/dist/unpkg/dev/serializer/json-api.js.map +1 -1
  73. package/dist/unpkg/dev/serializer/rest.js.map +1 -1
  74. package/dist/unpkg/dev/serializer/transform.js.map +1 -1
  75. package/dist/unpkg/dev/serializer.js +1 -1
  76. package/dist/unpkg/dev/serializer.js.map +1 -1
  77. package/dist/unpkg/dev/store-D_V8-HQl.js.map +1 -1
  78. package/dist/unpkg/dev-deprecated/-private-CrEyBE-B.js.map +1 -1
  79. package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js.map +1 -1
  80. package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
  81. package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
  82. package/dist/unpkg/dev-deprecated/adapter/rest.js +3 -3
  83. package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
  84. package/dist/unpkg/{dev/adapter-RlAbN461.js → dev-deprecated/adapter-oLwyr47q.js} +2 -2
  85. package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +1 -0
  86. package/dist/unpkg/dev-deprecated/adapter.js +1 -1
  87. package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
  88. package/dist/unpkg/dev-deprecated/{compat-CgUa-VIF.js → compat-D_T7cGfd.js} +4 -4
  89. package/dist/unpkg/dev-deprecated/compat-D_T7cGfd.js.map +1 -0
  90. package/dist/unpkg/dev-deprecated/compat.js +1 -1
  91. package/dist/unpkg/dev-deprecated/{errors-Cba2PDIB.js → errors-0ydn94s0.js} +2 -2
  92. package/dist/unpkg/dev-deprecated/errors-0ydn94s0.js.map +1 -0
  93. package/dist/unpkg/dev-deprecated/index.js +3 -3
  94. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  95. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +1 -1
  96. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  97. package/dist/unpkg/dev-deprecated/model/migration-support.js +2 -2
  98. package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
  99. package/dist/unpkg/dev-deprecated/{model-D-JSD2Bx.js → model-C1ts6Mod.js} +3 -3
  100. package/dist/unpkg/dev-deprecated/model-C1ts6Mod.js.map +1 -0
  101. package/dist/unpkg/dev-deprecated/{model-fragments-tlMYPSd_.js → model-fragments-DSqu0ptR.js} +60 -60
  102. package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +1 -0
  103. package/dist/unpkg/dev-deprecated/model-fragments.js +1 -1
  104. package/dist/unpkg/dev-deprecated/model.js +2 -2
  105. package/dist/unpkg/dev-deprecated/{runtime-BPCpkOf1-CVHWB0MF.js → runtime--fcdnjmJ-DMTJ0Kb3.js} +3 -3
  106. package/dist/unpkg/dev-deprecated/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -0
  107. package/dist/unpkg/dev-deprecated/{schema-provider-n96uVRhl.js → schema-provider-D2ESMsA8.js} +3 -3
  108. package/dist/unpkg/dev-deprecated/schema-provider-D2ESMsA8.js.map +1 -0
  109. package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -1
  110. package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
  111. package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
  112. package/dist/unpkg/dev-deprecated/serializer.js +1 -1
  113. package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
  114. package/dist/unpkg/dev-deprecated/store-BX7GvXC_.js.map +1 -1
  115. package/dist/unpkg/prod/-private-B4bxoTuK.js.map +1 -1
  116. package/dist/unpkg/prod/-private-SfXkkHKd.js.map +1 -1
  117. package/dist/unpkg/prod/adapter/error.js.map +1 -1
  118. package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
  119. package/dist/unpkg/prod/adapter/rest.js +3 -3
  120. package/dist/unpkg/prod/adapter/rest.js.map +1 -1
  121. package/dist/unpkg/{prod-deprecated/adapter-DAx_reer.js → prod/adapter-DQ9UA7FC.js} +2 -2
  122. package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +1 -0
  123. package/dist/unpkg/prod/adapter.js +1 -1
  124. package/dist/unpkg/prod/compat/extensions.js.map +1 -1
  125. package/dist/unpkg/{prod-deprecated/compat-CJ87MzDn.js → prod/compat-DxiVkCUb.js} +3 -3
  126. package/dist/unpkg/prod/compat-DxiVkCUb.js.map +1 -0
  127. package/dist/unpkg/prod/compat.js +1 -1
  128. package/dist/unpkg/prod/{errors-CoKAYQJi.js → errors-CVXWrUjP.js} +2 -2
  129. package/dist/unpkg/prod/errors-CVXWrUjP.js.map +1 -0
  130. package/dist/unpkg/prod/index.js +3 -3
  131. package/dist/unpkg/prod/index.js.map +1 -1
  132. package/dist/unpkg/prod/json-BD1kRTfB.js.map +1 -1
  133. package/dist/unpkg/prod/model/-private.js +1 -1
  134. package/dist/unpkg/prod/model/migration-support.js +2 -2
  135. package/dist/unpkg/prod/model/migration-support.js.map +1 -1
  136. package/dist/unpkg/prod/{model-D2zzdmP8.js → model-D3WMsNNE.js} +3 -3
  137. package/dist/unpkg/prod/model-D3WMsNNE.js.map +1 -0
  138. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js +334 -0
  139. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js.map +1 -0
  140. package/dist/unpkg/prod/model-fragments.js +1 -1
  141. package/dist/unpkg/prod/model.js +2 -2
  142. package/dist/unpkg/prod/runtime--fcdnjmJ-DMTJ0Kb3.js +53 -0
  143. package/dist/unpkg/prod/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -0
  144. package/dist/unpkg/prod/{schema-provider-BUXipKQV.js → schema-provider-_pimTZ3P.js} +3 -3
  145. package/dist/unpkg/prod/schema-provider-_pimTZ3P.js.map +1 -0
  146. package/dist/unpkg/prod/serializer/json-api.js.map +1 -1
  147. package/dist/unpkg/prod/serializer/rest.js.map +1 -1
  148. package/dist/unpkg/prod/serializer/transform.js.map +1 -1
  149. package/dist/unpkg/prod/serializer.js +1 -1
  150. package/dist/unpkg/prod/serializer.js.map +1 -1
  151. package/dist/unpkg/prod/store-RGGc1ilN.js.map +1 -1
  152. package/dist/unpkg/prod-deprecated/-private-B4bxoTuK.js.map +1 -1
  153. package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js.map +1 -1
  154. package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
  155. package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
  156. package/dist/unpkg/prod-deprecated/adapter/rest.js +3 -3
  157. package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
  158. package/dist/unpkg/{prod/adapter-DAx_reer.js → prod-deprecated/adapter-DQ9UA7FC.js} +2 -2
  159. package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +1 -0
  160. package/dist/unpkg/prod-deprecated/adapter.js +1 -1
  161. package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
  162. package/dist/unpkg/{prod/compat-CJ87MzDn.js → prod-deprecated/compat-DxiVkCUb.js} +3 -3
  163. package/dist/unpkg/prod-deprecated/compat-DxiVkCUb.js.map +1 -0
  164. package/dist/unpkg/prod-deprecated/compat.js +1 -1
  165. package/dist/unpkg/prod-deprecated/{errors-BUVJ3jcW.js → errors-9LXqpfRd.js} +2 -2
  166. package/dist/unpkg/prod-deprecated/errors-9LXqpfRd.js.map +1 -0
  167. package/dist/unpkg/prod-deprecated/index.js +3 -3
  168. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  169. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +1 -1
  170. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  171. package/dist/unpkg/prod-deprecated/model/migration-support.js +2 -2
  172. package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
  173. package/dist/unpkg/prod-deprecated/{model-66Pl5niO.js → model-aiVrr1fz.js} +3 -3
  174. package/dist/unpkg/prod-deprecated/model-aiVrr1fz.js.map +1 -0
  175. package/dist/unpkg/prod-deprecated/{model-fragments-tlMYPSd_.js → model-fragments-DSqu0ptR.js} +60 -60
  176. package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +1 -0
  177. package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
  178. package/dist/unpkg/prod-deprecated/model.js +2 -2
  179. package/dist/unpkg/prod-deprecated/{runtime-BPCpkOf1-CVHWB0MF.js → runtime--fcdnjmJ-DMTJ0Kb3.js} +3 -3
  180. package/dist/unpkg/prod-deprecated/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -0
  181. package/dist/unpkg/prod-deprecated/{schema-provider-DtyBaLoG.js → schema-provider-DyfSd9Cv.js} +3 -3
  182. package/dist/unpkg/prod-deprecated/schema-provider-DyfSd9Cv.js.map +1 -0
  183. package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -1
  184. package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
  185. package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
  186. package/dist/unpkg/prod-deprecated/serializer.js +1 -1
  187. package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
  188. package/dist/unpkg/prod-deprecated/store-0L2CkYzh.js.map +1 -1
  189. package/package.json +12 -16
  190. package/dist/adapter-DFVAuivO.js.map +0 -1
  191. package/dist/compat-g__Pfy2S.js.map +0 -1
  192. package/dist/errors-BbCo7Tut.js.map +0 -1
  193. package/dist/model-C7-ZIbd5.js.map +0 -1
  194. package/dist/model-fragments-tlMYPSd_.js.map +0 -1
  195. package/dist/runtime-BPCpkOf1-CVHWB0MF.js.map +0 -1
  196. package/dist/schema-provider-7RHVFTdb.js.map +0 -1
  197. package/dist/unpkg/dev/adapter-RlAbN461.js.map +0 -1
  198. package/dist/unpkg/dev/compat-B2O7jZLN.js.map +0 -1
  199. package/dist/unpkg/dev/errors-DiBJX1gq.js.map +0 -1
  200. package/dist/unpkg/dev/model-BrJ3pFM-.js.map +0 -1
  201. package/dist/unpkg/dev/model-fragments-tlMYPSd_.js.map +0 -1
  202. package/dist/unpkg/dev/runtime-BPCpkOf1-CVHWB0MF.js.map +0 -1
  203. package/dist/unpkg/dev/schema-provider-Z5GzOhu-.js.map +0 -1
  204. package/dist/unpkg/dev-deprecated/adapter-RlAbN461.js.map +0 -1
  205. package/dist/unpkg/dev-deprecated/compat-CgUa-VIF.js.map +0 -1
  206. package/dist/unpkg/dev-deprecated/errors-Cba2PDIB.js.map +0 -1
  207. package/dist/unpkg/dev-deprecated/model-D-JSD2Bx.js.map +0 -1
  208. package/dist/unpkg/dev-deprecated/model-fragments-tlMYPSd_.js.map +0 -1
  209. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-CVHWB0MF.js.map +0 -1
  210. package/dist/unpkg/dev-deprecated/schema-provider-n96uVRhl.js.map +0 -1
  211. package/dist/unpkg/prod/adapter-DAx_reer.js.map +0 -1
  212. package/dist/unpkg/prod/compat-CJ87MzDn.js.map +0 -1
  213. package/dist/unpkg/prod/errors-CoKAYQJi.js.map +0 -1
  214. package/dist/unpkg/prod/model-D2zzdmP8.js.map +0 -1
  215. package/dist/unpkg/prod/model-fragments-tlMYPSd_.js +0 -334
  216. package/dist/unpkg/prod/model-fragments-tlMYPSd_.js.map +0 -1
  217. package/dist/unpkg/prod/runtime-BPCpkOf1-CVHWB0MF.js +0 -53
  218. package/dist/unpkg/prod/runtime-BPCpkOf1-CVHWB0MF.js.map +0 -1
  219. package/dist/unpkg/prod/schema-provider-BUXipKQV.js.map +0 -1
  220. package/dist/unpkg/prod-deprecated/adapter-DAx_reer.js.map +0 -1
  221. package/dist/unpkg/prod-deprecated/compat-CJ87MzDn.js.map +0 -1
  222. package/dist/unpkg/prod-deprecated/errors-BUVJ3jcW.js.map +0 -1
  223. package/dist/unpkg/prod-deprecated/model-66Pl5niO.js.map +0 -1
  224. package/dist/unpkg/prod-deprecated/model-fragments-tlMYPSd_.js.map +0 -1
  225. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-CVHWB0MF.js.map +0 -1
  226. package/dist/unpkg/prod-deprecated/schema-provider-DtyBaLoG.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"-private-DQ6Iap2t.js","names":["warn","continueOnReject","getGlobalConfig","macroCondition","_determineContent","response","requestData","payload","ret","error","ok","status","payloadIsEmpty","statusIndicatesEmptyResponse","method","WarpDrive","env","DEBUG","message","url","id","JSON","parse","e","SyntaxError","console","determineBodyPromise","text","then","RBRACKET","isPlainObject","obj","Object","prototype","toString","call","isPrimitiveArray","Array","isArray","isParamsArray","buildParams","prefix","s","i","len","key","length","test","add","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","Error","name","value","serializeQueryParams","queryParamsObject","join","k","v","undefined","encodeURIComponent","_fetch","REQUEST","getFetchFunction","fetch","FastBoot","nodeFetch","require","httpRegex","protocolRelativeRegex","parseRequest","request","Error","protocol","get","buildAbsoluteUrl","url","test","host","patchedFetch","input","options","href","info","Object","assign","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","setupFastboot","fastBootRequest","upgradeStore","macroCondition","getGlobalConfig","serializeIntoHash","store","modelClass","snapshot","options","includeId","serializer","serializerFor","modelName","WarpDrive","env","DEBUG","test","Error","data","serialize"],"sources":["../src/adapter/-private/utils/parse-response-headers.ts","../src/adapter/-private/utils/continue-on-reject.ts","../src/adapter/-private/utils/determine-body-promise.ts","../src/adapter/-private/utils/serialize-query-params.ts","../src/adapter/-private/utils/fetch.ts","../src/adapter/-private/utils/serialize-into-hash.ts"],"sourcesContent":["const newline = /\\r?\\n/;\n\nexport function parseResponseHeaders(headersString: string): Record<string, string> {\n const headers = Object.create(null) as Record<string, string>;\n\n if (!headersString) {\n return headers;\n }\n\n const headerPairs: string[] = headersString.split(newline);\n\n for (let i = 0; i < headerPairs.length; i++) {\n const header = headerPairs[i];\n let j = 0;\n let foundSep = false;\n\n for (; j < header.length; j++) {\n if (header.charCodeAt(j) === 58 /* ':' */) {\n foundSep = true;\n break;\n }\n }\n\n if (foundSep === false) {\n continue;\n }\n\n const field = header.substring(0, j).trim();\n const value = header.substring(j + 1, header.length).trim();\n\n if (value) {\n const lowerCasedField = field.toLowerCase();\n\n headers[lowerCasedField] = value;\n headers[field] = value;\n }\n }\n\n return headers;\n}\n","/**\n * A utility function that returns a promise that resolves\n * even when the source promise rejects.\n *\n * @internal\n */\nexport function continueOnReject<T>(promise: Promise<T>): Promise<T> {\n return Promise.resolve(promise).catch((e) => e as T);\n}\n","import { warn } from '@ember/debug';\n\nimport { DEBUG } from '@warp-drive/core/build-config/env';\n\nimport type { RequestData } from '../../rest.ts';\nimport { continueOnReject } from './continue-on-reject.ts';\n\ntype Payload = Error | Record<string, unknown> | unknown[] | string | undefined;\n\ninterface CustomSyntaxError extends SyntaxError {\n payload: Payload;\n}\n\n/*\n * Function that always attempts to parse the response as json, and if an error is thrown,\n * returns `undefined` if the response is successful and has a status code of 204 (No Content),\n * or 205 (Reset Content) or if the request method was 'HEAD', and the plain payload otherwise.\n */\nfunction _determineContent(response: Response, requestData: JQueryAjaxSettings, payload: Payload): Payload {\n let ret: Payload = payload;\n let error: Error | null = null;\n\n if (!response.ok) {\n return payload;\n }\n\n const status = response.status;\n const payloadIsEmpty = payload === '' || payload === null;\n const statusIndicatesEmptyResponse = status === 204 || status === 205 || requestData.method === 'HEAD';\n\n if (DEBUG) {\n if (payloadIsEmpty && !statusIndicatesEmptyResponse) {\n const message = `The server returned an empty string for ${requestData.method} ${requestData.url}, which cannot be parsed into a valid JSON. Return either null or {}.`;\n if (payload === '') {\n warn(message, {\n id: 'ds.adapter.returned-empty-string-as-JSON',\n });\n }\n }\n }\n\n if (response.ok && (statusIndicatesEmptyResponse || payloadIsEmpty)) {\n return;\n }\n\n try {\n ret = JSON.parse(payload as string) as Payload;\n } catch (e) {\n if (!(e instanceof SyntaxError)) {\n return e as Error;\n }\n (e as CustomSyntaxError).payload = payload;\n error = e;\n }\n\n if (error) {\n if (DEBUG) {\n // eslint-disable-next-line no-console\n console.warn('This response was unable to be parsed as json.', payload);\n }\n return error;\n }\n\n return ret;\n}\n\nexport function determineBodyPromise(response: Response, requestData: RequestData): Promise<Payload> {\n // response.text() may resolve or reject\n // it is a native promise, may not have finally\n return continueOnReject(response.text()).then((payload) => _determineContent(response, requestData, payload));\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\n\nconst RBRACKET = /\\[\\]$/;\n\ninterface PlainObject {\n [key: string]: string | PlainObject | PlainObject[] | string[];\n}\ntype ParamObject = { name: string; value: string };\n\nfunction isPlainObject<T>(obj: unknown): obj is T {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\nfunction isPrimitiveArray(obj: unknown): obj is Array<PlainObject | string> {\n return Array.isArray(obj);\n}\n\nfunction isParamsArray(obj: unknown): obj is ParamObject[] {\n return Array.isArray(obj);\n}\n\nfunction buildParams<T extends PlainObject>(\n prefix: string,\n obj: ParamObject | ParamObject[] | Array<T | string> | T | string,\n s: string[]\n) {\n let i: number, len: number, key: keyof T & string;\n\n if (prefix) {\n if (isPrimitiveArray(obj)) {\n for (i = 0, len = obj.length; i < len; i++) {\n if (RBRACKET.test(prefix)) {\n add(s, prefix, obj[i] as string);\n } else {\n buildParams(prefix + '[' + (typeof obj[i] === 'object' && obj[i] !== null ? i : '') + ']', obj[i], s);\n }\n }\n } else if (isPlainObject<T>(obj)) {\n for (key in obj) {\n buildParams(prefix + '[' + key + ']', obj[key], s);\n }\n } else {\n assert(\n `query params cannot be a { name, value } pair if prefix is present`,\n obj === null || typeof obj !== 'object'\n );\n add(s, prefix, obj);\n }\n } else if (isParamsArray(obj)) {\n for (i = 0, len = obj.length; i < len; i++) {\n add(s, obj[i].name, obj[i].value);\n }\n } else {\n assert(`query params cannot be a string if no prefix is present`, typeof obj !== 'string');\n assert(`query params should not be an array if no prefix is present`, !Array.isArray(obj));\n assert(`query params should not be a { name, value } pair if no prefix is present`, isPlainObject<T>(obj));\n for (key in obj) {\n buildParams(key, obj[key], s);\n }\n }\n return s;\n}\n\n/*\n * Helper function that turns the data/body of a request into a query param string.\n * This is directly copied from jQuery.param.\n */\nexport function serializeQueryParams(queryParamsObject: PlainObject | string): string {\n return buildParams('', queryParamsObject, []).join('&');\n}\n\n/*\n * Part of the `serializeQueryParams` helper function.\n */\nfunction add(s: string[], k: string, v?: string | (() => string)) {\n // Strip out keys with undefined value and replace null values with\n // empty strings (mimics jQuery.ajax)\n if (v === undefined) {\n return;\n } else if (v === null) {\n v = '';\n }\n\n v = typeof v === 'function' ? v() : v;\n s[s.length] = `${encodeURIComponent(k)}=${encodeURIComponent(v)}`;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\n\ntype FetchFunction = (input: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nlet _fetch: (() => FetchFunction) | null = null;\ntype MockRequest = { protocol?: string; get(key: string): string | undefined };\nlet REQUEST: MockRequest = null as unknown as MockRequest;\n\nexport function getFetchFunction(): FetchFunction {\n // return cached fetch function\n if (_fetch !== null) {\n return _fetch();\n }\n\n // grab browser native fetch if available, or global fetch if otherwise configured\n if (typeof fetch === 'function') {\n // fallback to using global fetch\n _fetch = () => fetch;\n\n /* global FastBoot */\n // grab fetch from node-fetch\n } else if (typeof FastBoot !== 'undefined') {\n try {\n const nodeFetch = FastBoot.require('node-fetch') as typeof fetch;\n\n const httpRegex = /^https?:\\/\\//;\n const protocolRelativeRegex = /^\\/\\//;\n\n function parseRequest(request: MockRequest) {\n if (request === null) {\n throw new Error(\n \"Trying to fetch with relative url but the application hasn't finished loading FastBootInfo, see details at https://github.com/ember-cli/ember-fetch#relative-url\"\n );\n }\n // Old Prember version is not sending protocol\n const protocol = request.protocol === 'undefined:' ? 'http:' : request.protocol;\n return [request.get('host'), protocol];\n }\n\n function buildAbsoluteUrl(url: string) {\n if (protocolRelativeRegex.test(url)) {\n const [host] = parseRequest(REQUEST);\n url = host + url;\n } else if (!httpRegex.test(url)) {\n const [host, protocol] = parseRequest(REQUEST);\n url = protocol + '//' + host + url;\n }\n return url;\n }\n\n function patchedFetch(input: string | { href: string } | RequestInfo, options?: RequestInit) {\n if (input && typeof input === 'object' && 'href' in input) {\n const url = buildAbsoluteUrl(input.href);\n const info = Object.assign({}, input, { url }) as unknown as RequestInfo;\n return nodeFetch(info, options);\n } else if (typeof input === 'string') {\n const url = buildAbsoluteUrl(input);\n return nodeFetch(url, options);\n }\n\n return nodeFetch(input, options);\n }\n\n _fetch = () => patchedFetch;\n } catch {\n throw new Error(`Unable to create a compatible 'fetch' for FastBoot with node-fetch`);\n }\n }\n\n assert(`Cannot find a 'fetch' global and did not detect FastBoot.`, _fetch);\n\n return _fetch();\n}\n\nexport function setupFastboot(fastBootRequest: MockRequest): void {\n REQUEST = fastBootRequest;\n}\n","import type { Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ModelSchema } from '@warp-drive/core/types';\n\nimport type { MinimumSerializerInterface, SerializerOptions } from '../../../compat.ts';\nimport { type Snapshot, upgradeStore } from '../../../compat/-private.ts';\n\ntype SerializerWithSerializeIntoHash = MinimumSerializerInterface & {\n serializeIntoHash?(hash: object, modelClass: ModelSchema, snapshot: Snapshot, options?: SerializerOptions): void;\n};\n\nexport function serializeIntoHash(\n store: Store,\n modelClass: ModelSchema,\n snapshot: Snapshot,\n options: { includeId?: boolean } = { includeId: true }\n): object {\n upgradeStore(store);\n const serializer: SerializerWithSerializeIntoHash | null = store.serializerFor(modelClass.modelName);\n\n assert(`Cannot serialize record, no serializer defined`, serializer);\n\n if (typeof serializer.serializeIntoHash === 'function') {\n const data = {};\n serializer.serializeIntoHash(data, modelClass, snapshot, options);\n return data;\n }\n\n return serializer.serialize(snapshot, options);\n}\n"],"mappings":";;;;;AAAA,MAAM,UAAU;AAEhB,SAAgB,qBAAqB,eAA+C;CAClF,MAAM,UAAU,OAAO,OAAO,IAAI;CAElC,IAAI,CAAC,eACH,OAAO;CAGT,MAAM,cAAwB,cAAc,MAAM,OAAO;CAEzD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,SAAS,YAAY;EAC3B,IAAI,IAAI;EACR,IAAI,WAAW;EAEf,OAAO,IAAI,OAAO,QAAQ,KACxB,IAAI,OAAO,WAAW,CAAC,MAAM,IAAc;GACzC,WAAW;GACX;EACF;EAGF,IAAI,aAAa,OACf;EAGF,MAAM,QAAQ,OAAO,UAAU,GAAG,CAAC,CAAC,CAAC,KAAK;EAC1C,MAAM,QAAQ,OAAO,UAAU,IAAI,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK;EAE1D,IAAI,OAAO;GACT,MAAM,kBAAkB,MAAM,YAAY;GAE1C,QAAQ,mBAAmB;GAC3B,QAAQ,SAAS;EACnB;CACF;CAEA,OAAO;AACT;;;;;;;;;;ACjCA,SAAgB,iBAAoB,SAAiC;CACnE,OAAO,QAAQ,QAAQ,OAAO,CAAC,CAAC,OAAO,MAAM,CAAM;AACrD;;;;ACUA,SAASI,kBAAkBC,UAAoBC,aAAiCC,SAA2B;CACzG,IAAIC,MAAeD;CACnB,IAAIE,QAAsB;CAE1B,IAAI,CAACJ,SAASK,IACZ,OAAOH;CAGT,MAAMI,SAASN,SAASM;CACxB,MAAMC,iBAAiBL,YAAY,MAAMA,YAAY;CACrD,MAAMM,+BAA+BF,WAAW,OAAOA,WAAW,OAAOL,YAA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OAAOC,OAAOC,OAAO,CAAC,GAAGL,OAAO,EAAEJ,IAAI,CAAC;IAC7C,OAAOV,UAAUiB,MAAMF,OAAO;GAChC,OAAO,IAAI,OAAOD,UAAU,UAAU;IACpC,MAAMJ,MAAMD,iBAAiBK,KAAK;IAClC,OAAOd,UAAUU,KAAKK,OAAO;GAC/B;GAEA,OAAOf,UAAUc,OAAOC,OAAO;EACjC;EAEApB,eAAekB;CACjB,QAAQ;EACN,MAAM,IAAIP,MAAM,oEAAoE;CACtF;CAGFc,eAAAC,gBAAA,CAAA,CAAAC,UAAAC,IAAAC,KAAA,OAAAb,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAL,MAAO,2DAA2D;CAAA,EAAA,CAAEX,MAAM;CAE1E,OAAOA,OAAO;AAChB;AAEA,SAAgB8B,cAAcC,iBAAoC;CAChE9B,UAAU8B;AACZ;;;;ACjEA,SAAgBI,kBACdC,OACAC,YACAC,UACAC,UAAmC,EAAEC,WAAW,KAAK,GAC7C;CACRR,6BAAaI,KAAK;CAClB,MAAMK,aAAqDL,MAAMM,cAAcL,WAAWM,SAAS;CAEnGV,eAAAC,gBAAA,CAAA,CAAAU,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,gDAAgD;CAAA,EAAA,CAAEP,UAAU;CAEnE,IAAI,OAAOA,WAAWN,sBAAsB,YAAY;EACtD,MAAMc,OAAO,CAAC;EACdR,WAAWN,kBAAkBc,MAAMZ,YAAYC,UAAUC,OAAO;EAChE,OAAOU;CACT;CAEA,OAAOR,WAAWS,UAAUZ,UAAUC,OAAO;AAC/C"}
1
+ {"version":3,"file":"-private-DQ6Iap2t.js","names":["warn","continueOnReject","getGlobalConfig","macroCondition","_determineContent","response","requestData","payload","ret","error","ok","status","payloadIsEmpty","statusIndicatesEmptyResponse","method","WarpDrive","env","DEBUG","message","url","id","JSON","parse","e","SyntaxError","console","determineBodyPromise","text","then","RBRACKET","isPlainObject","obj","Object","prototype","toString","call","isPrimitiveArray","Array","isArray","isParamsArray","buildParams","prefix","s","i","len","key","length","test","add","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","Error","name","value","serializeQueryParams","queryParamsObject","join","k","v","undefined","encodeURIComponent","_fetch","REQUEST","getFetchFunction","fetch","FastBoot","nodeFetch","require","httpRegex","protocolRelativeRegex","parseRequest","request","Error","protocol","get","buildAbsoluteUrl","url","test","host","patchedFetch","input","options","href","info","Object","assign","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","setupFastboot","fastBootRequest","upgradeStore","macroCondition","getGlobalConfig","serializeIntoHash","store","modelClass","snapshot","options","includeId","serializer","serializerFor","modelName","WarpDrive","env","DEBUG","test","Error","data","serialize"],"sources":["../src/adapter/-private/utils/parse-response-headers.ts","../src/adapter/-private/utils/continue-on-reject.ts","../src/adapter/-private/utils/determine-body-promise.ts","../src/adapter/-private/utils/serialize-query-params.ts","../src/adapter/-private/utils/fetch.ts","../src/adapter/-private/utils/serialize-into-hash.ts"],"sourcesContent":["const newline = /\\r?\\n/;\n\nexport function parseResponseHeaders(headersString: string): Record<string, string> {\n const headers = Object.create(null) as Record<string, string>;\n\n if (!headersString) {\n return headers;\n }\n\n const headerPairs: string[] = headersString.split(newline);\n\n for (let i = 0; i < headerPairs.length; i++) {\n const header = headerPairs[i];\n let j = 0;\n let foundSep = false;\n\n for (; j < header.length; j++) {\n if (header.charCodeAt(j) === 58 /* ':' */) {\n foundSep = true;\n break;\n }\n }\n\n if (foundSep === false) {\n continue;\n }\n\n const field = header.substring(0, j).trim();\n const value = header.substring(j + 1, header.length).trim();\n\n if (value) {\n const lowerCasedField = field.toLowerCase();\n\n headers[lowerCasedField] = value;\n headers[field] = value;\n }\n }\n\n return headers;\n}\n","/**\n * A utility function that returns a promise that resolves\n * even when the source promise rejects.\n *\n * @internal\n */\nexport function continueOnReject<T>(promise: Promise<T>): Promise<T> {\n return Promise.resolve(promise).catch((e) => e as T);\n}\n","import { warn } from '@ember/debug';\n\nimport { DEBUG } from '@warp-drive/core/build-config/env';\n\nimport type { RequestData } from '../../rest.ts';\nimport { continueOnReject } from './continue-on-reject.ts';\n\ntype Payload = Error | Record<string, unknown> | unknown[] | string | undefined;\n\ninterface CustomSyntaxError extends SyntaxError {\n payload: Payload;\n}\n\n/*\n * Function that always attempts to parse the response as json, and if an error is thrown,\n * returns `undefined` if the response is successful and has a status code of 204 (No Content),\n * or 205 (Reset Content) or if the request method was 'HEAD', and the plain payload otherwise.\n */\nfunction _determineContent(response: Response, requestData: JQueryAjaxSettings, payload: Payload): Payload {\n let ret: Payload = payload;\n let error: Error | null = null;\n\n if (!response.ok) {\n return payload;\n }\n\n const status = response.status;\n const payloadIsEmpty = payload === '' || payload === null;\n const statusIndicatesEmptyResponse = status === 204 || status === 205 || requestData.method === 'HEAD';\n\n if (DEBUG) {\n if (payloadIsEmpty && !statusIndicatesEmptyResponse) {\n const message = `The server returned an empty string for ${requestData.method} ${requestData.url}, which cannot be parsed into a valid JSON. Return either null or {}.`;\n if (payload === '') {\n warn(message, {\n id: 'ds.adapter.returned-empty-string-as-JSON',\n });\n }\n }\n }\n\n if (response.ok && (statusIndicatesEmptyResponse || payloadIsEmpty)) {\n return;\n }\n\n try {\n ret = JSON.parse(payload as string) as Payload;\n } catch (e) {\n if (!(e instanceof SyntaxError)) {\n return e as Error;\n }\n (e as CustomSyntaxError).payload = payload;\n error = e;\n }\n\n if (error) {\n if (DEBUG) {\n // oxlint-disable-next-line no-console\n console.warn('This response was unable to be parsed as json.', payload);\n }\n return error;\n }\n\n return ret;\n}\n\nexport function determineBodyPromise(response: Response, requestData: RequestData): Promise<Payload> {\n // response.text() may resolve or reject\n // it is a native promise, may not have finally\n return continueOnReject(response.text()).then((payload) => _determineContent(response, requestData, payload));\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\n\nconst RBRACKET = /\\[\\]$/;\n\ninterface PlainObject {\n [key: string]: string | PlainObject | PlainObject[] | string[];\n}\ntype ParamObject = { name: string; value: string };\n\nfunction isPlainObject<T>(obj: unknown): obj is T {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\nfunction isPrimitiveArray(obj: unknown): obj is Array<PlainObject | string> {\n return Array.isArray(obj);\n}\n\nfunction isParamsArray(obj: unknown): obj is ParamObject[] {\n return Array.isArray(obj);\n}\n\nfunction buildParams<T extends PlainObject>(\n prefix: string,\n obj: ParamObject | ParamObject[] | Array<T | string> | T | string,\n s: string[]\n) {\n let i: number, len: number, key: keyof T & string;\n\n if (prefix) {\n if (isPrimitiveArray(obj)) {\n for (i = 0, len = obj.length; i < len; i++) {\n if (RBRACKET.test(prefix)) {\n add(s, prefix, obj[i] as string);\n } else {\n buildParams(prefix + '[' + (typeof obj[i] === 'object' && obj[i] !== null ? i : '') + ']', obj[i], s);\n }\n }\n } else if (isPlainObject<T>(obj)) {\n for (key in obj) {\n buildParams(prefix + '[' + key + ']', obj[key], s);\n }\n } else {\n assert(\n `query params cannot be a { name, value } pair if prefix is present`,\n obj === null || typeof obj !== 'object'\n );\n add(s, prefix, obj);\n }\n } else if (isParamsArray(obj)) {\n for (i = 0, len = obj.length; i < len; i++) {\n add(s, obj[i].name, obj[i].value);\n }\n } else {\n assert(`query params cannot be a string if no prefix is present`, typeof obj !== 'string');\n assert(`query params should not be an array if no prefix is present`, !Array.isArray(obj));\n assert(`query params should not be a { name, value } pair if no prefix is present`, isPlainObject<T>(obj));\n for (key in obj) {\n buildParams(key, obj[key], s);\n }\n }\n return s;\n}\n\n/*\n * Helper function that turns the data/body of a request into a query param string.\n * This is directly copied from jQuery.param.\n */\nexport function serializeQueryParams(queryParamsObject: PlainObject | string): string {\n return buildParams('', queryParamsObject, []).join('&');\n}\n\n/*\n * Part of the `serializeQueryParams` helper function.\n */\nfunction add(s: string[], k: string, v?: string | (() => string)) {\n // Strip out keys with undefined value and replace null values with\n // empty strings (mimics jQuery.ajax)\n if (v === undefined) {\n return;\n } else if (v === null) {\n v = '';\n }\n\n v = typeof v === 'function' ? v() : v;\n s[s.length] = `${encodeURIComponent(k)}=${encodeURIComponent(v)}`;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\n\ntype FetchFunction = (input: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nlet _fetch: (() => FetchFunction) | null = null;\ntype MockRequest = { protocol?: string; get(key: string): string | undefined };\nlet REQUEST: MockRequest = null as unknown as MockRequest;\n\nexport function getFetchFunction(): FetchFunction {\n // return cached fetch function\n if (_fetch !== null) {\n return _fetch();\n }\n\n // grab browser native fetch if available, or global fetch if otherwise configured\n if (typeof fetch === 'function') {\n // fallback to using global fetch\n _fetch = () => fetch;\n\n /* global FastBoot */\n // grab fetch from node-fetch\n } else if (typeof FastBoot !== 'undefined') {\n try {\n const nodeFetch = FastBoot.require('node-fetch') as typeof fetch;\n\n const httpRegex = /^https?:\\/\\//;\n const protocolRelativeRegex = /^\\/\\//;\n\n function parseRequest(request: MockRequest) {\n if (request === null) {\n throw new Error(\n \"Trying to fetch with relative url but the application hasn't finished loading FastBootInfo, see details at https://github.com/ember-cli/ember-fetch#relative-url\"\n );\n }\n // Old Prember version is not sending protocol\n const protocol = request.protocol === 'undefined:' ? 'http:' : request.protocol;\n return [request.get('host'), protocol];\n }\n\n function buildAbsoluteUrl(url: string) {\n if (protocolRelativeRegex.test(url)) {\n const [host] = parseRequest(REQUEST);\n url = host + url;\n } else if (!httpRegex.test(url)) {\n const [host, protocol] = parseRequest(REQUEST);\n url = protocol + '//' + host + url;\n }\n return url;\n }\n\n function patchedFetch(input: string | { href: string } | RequestInfo, options?: RequestInit) {\n if (input && typeof input === 'object' && 'href' in input) {\n const url = buildAbsoluteUrl(input.href);\n const info = Object.assign({}, input, { url }) as unknown as RequestInfo;\n return nodeFetch(info, options);\n } else if (typeof input === 'string') {\n const url = buildAbsoluteUrl(input);\n return nodeFetch(url, options);\n }\n\n return nodeFetch(input, options);\n }\n\n _fetch = () => patchedFetch;\n } catch {\n throw new Error(`Unable to create a compatible 'fetch' for FastBoot with node-fetch`);\n }\n }\n\n assert(`Cannot find a 'fetch' global and did not detect FastBoot.`, _fetch);\n\n return _fetch();\n}\n\nexport function setupFastboot(fastBootRequest: MockRequest): void {\n REQUEST = fastBootRequest;\n}\n","import type { Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ModelSchema } from '@warp-drive/core/types';\n\nimport type { MinimumSerializerInterface, SerializerOptions } from '../../../compat.ts';\nimport { type Snapshot, upgradeStore } from '../../../compat/-private.ts';\n\ntype SerializerWithSerializeIntoHash = MinimumSerializerInterface & {\n serializeIntoHash?(hash: object, modelClass: ModelSchema, snapshot: Snapshot, options?: SerializerOptions): void;\n};\n\nexport function serializeIntoHash(\n store: Store,\n modelClass: ModelSchema,\n snapshot: Snapshot,\n options: { includeId?: boolean } = { includeId: true }\n): object {\n upgradeStore(store);\n const serializer: SerializerWithSerializeIntoHash | null = store.serializerFor(modelClass.modelName);\n\n assert(`Cannot serialize record, no serializer defined`, serializer);\n\n if (typeof serializer.serializeIntoHash === 'function') {\n const data = {};\n serializer.serializeIntoHash(data, modelClass, snapshot, options);\n return data;\n }\n\n return serializer.serialize(snapshot, options);\n}\n"],"mappings":";;;;;AAAA,MAAM,UAAU;AAEhB,SAAgB,qBAAqB,eAA+C;CAClF,MAAM,UAAU,OAAO,OAAO,IAAI;CAElC,IAAI,CAAC,eACH,OAAO;CAGT,MAAM,cAAwB,cAAc,MAAM,OAAO;CAEzD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,SAAS,YAAY;EAC3B,IAAI,IAAI;EACR,IAAI,WAAW;EAEf,OAAO,IAAI,OAAO,QAAQ,KACxB,IAAI,OAAO,WAAW,CAAC,MAAM,IAAc;GACzC,WAAW;GACX;EACF;EAGF,IAAI,aAAa,OACf;EAGF,MAAM,QAAQ,OAAO,UAAU,GAAG,CAAC,CAAC,CAAC,KAAK;EAC1C,MAAM,QAAQ,OAAO,UAAU,IA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AAA,CAAA,CAAAU,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,gDAAgD;CAAA,EAAA,CAAEP,UAAU;CAEnE,IAAI,OAAOA,WAAWN,sBAAsB,YAAY;EACtD,MAAMc,OAAO,CAAC;EACdR,WAAWN,kBAAkBc,MAAMZ,YAAYC,UAAUC,OAAO;EAChE,OAAOU;CACT;CAEA,OAAOR,WAAWS,UAAUZ,UAAUC,OAAO;AAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"-private-DccRZQsm.js","names":["Context","upgradeStore","SnapshotRecordArray","constructor","store","type","options","__store","_snapshots","modelName","adapterOptions","include","_recordArray","peekAll","length","snapshots","_fetchManager","LiveArrayContext","source","map","identifier","createSnapshot","assertIdentifierHasId","identifier","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","id","validateDocumentStructure","doc","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","errors","push","data","Array","isArray","meta","links","jsonapi","included","test","Error","join","length","normalizeResponseHelper","serializer","store","modelClass","payload","id","requestType","normalizedResponse","normalizeResponse","assertPrivateStore","upgradeStore","getGlobalConfig","macroCondition","Snapshot","constructor","options","identifier","store","_store","__attributes","_belongsToRelationships","Object","create","_belongsToIds","_hasManyRelationships","_hasManyIds","hasRecord","_instanceCache","peek","modelName","type","_attributes","id","adapterOptions","include","cache","_changedAttributes","changedAttrs","record","peekRecord","WarpDrive","env","DEBUG","test","Error","lid","attributes","eachAttribute","key","meta","getAttr","isNew","attr","keyName","changedAttributes","changedAttributeKeys","keys","i","length","slice","belongsTo","returnModeIsId","result","relationshipMeta","schema","fields","get","kind","_graph","relationship","value","getRelationship","data","inverseIdentifier","cacheKeyManager","getOrCreateRecordIdentifier","undefined","isDeleted","_fetchManager","createSnapshot","hasMany","returnModeIsIds","ids","results","cachedIds","cachedSnapshots","forEach","member","push","callback","binding","modelFor","modelSchema","field","call","eachRelationship","serialize","serializer","serializerFor","warn","createDeferred","waitFor","assertPrivateStore","coerceId","getOrSetGlobal","upgradeStore","assertIdentifierHasId","payloadIsNotBlank","normalizeResponseHelper","Snapshot","getGlobalConfig","macroCondition","SaveOp","Symbol","FetchManager","constructor","store","_store","_pendingFetch","Map","requestCache","getRequestStateService","isDestroyed","createSnapshot","identifier","options","scheduleSave","resolver","query","op","recordIdentifier","queryRequest","data","snapshot","pendingSaveItem","monitored","_enqueue","promise","_flushPendingSave","scheduleFetch","request","pendingFetch","getPendingFetch","modelName","type","pendingFetchItem","resolverPromise","isInitialLoad","_instanceCache","recordIsLoaded","then","payload","Array","isArray","lid","potentiallyNewIm","_push","reload","error","WarpDrive","env","DEBUG","test","Error","cache","isEmpty","isReleasable","_graph","graph","unload","_enableAsyncFlush","unloadRecord","size","Promise","resolve","setTimeout","flushAllPendingFetches","fetchesByType","fetchesById","get","set","requestsForIdentifier","push","TESTING","disableTestWaiter","pendingFetches","matchingPendingFetch","find","fetch","isSameRequest","forEach","fetchItem","_flushPendingFetchForType","clear","fetchDataIfNeededForIdentifier","_isEmpty","isLoading","_isLoading","Object","assign","destroy","instanceCache","isNew","isDeleted","req","isLoaded","getPendingRequestsForRecord","some","r","includesSatisfies","current","existing","length","arrCurrent","split","sort","arrExisting","join","i","includes","optionsSatisfies","keys","existingOptions","adapterOptions","include","_findMany","adapter","snapshots","modelClass","modelFor","ids","map","s","id","every","v","findMany","ret","undefined","adapterPayload","serializer","serializerFor","rejectFetchedItems","fetchMap","l","pair","reject","handleFoundRecords","coalescedPayload","snapshotsById","snapshotGroup","included","resources","resource","delete","rejected","snapshotArray","values","_fetchRecord","findRecord","_fetchManager","klass","isDestroying","_processCoalescedGroup","group","payloads","catch","pendingFetchMap","adapterFor","shouldCoalesce","coalesceFindRequests","pendingFetchItems","totalItems","groups","groupRecordsForFindMany","pending","operation"],"sources":["../src/compat/legacy-network-handler/snapshot-record-array.ts","../src/compat/legacy-network-handler/identifier-has-id.ts","../src/compat/legacy-network-handler/legacy-data-utils.ts","../src/compat/legacy-network-handler/serializer-response.ts","../src/compat/legacy-network-handler/snapshot.ts","../src/compat/legacy-network-handler/fetch-manager.ts","../src/compat/-private.ts"],"sourcesContent":["import type { Store } from '@warp-drive/core';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport type { LegacyLiveArray, PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport type { FindAllOptions, ModelSchema } from '@warp-drive/core/types';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\n\nimport { upgradeStore } from '../-private.ts';\nimport type { Snapshot } from './snapshot.ts';\n/**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters for certain `findAll` requests.\n\n @hideconstructor\n @public\n*/\nexport class SnapshotRecordArray {\n /**\n * An array of snapshots\n *\n * @internal\n */\n declare private _snapshots: Snapshot[] | null;\n\n /** @internal */\n declare private _type: ModelSchema | null;\n\n /**\n * The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array\n */\n declare modelName: string;\n\n /** @internal */\n declare private __store: Store;\n\n /**\n * A hash of adapter options passed into the store method for this request.\n\n Example\n\n ```js [app/adapters/post.js]\n import MyCustomAdapter from './custom-adapter';\n\n export default class PostAdapter extends MyCustomAdapter {\n findAll(store, type, sinceToken, snapshotRecordArray) {\n if (snapshotRecordArray.adapterOptions.subscribe) {\n // ...\n }\n // ...\n }\n }\n ```\n */\n declare adapterOptions?: Record<string, unknown>;\n /**\n * The relationships to include for this request.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default class ApplicationAdapter extends Adapter {\n findAll(store, type, snapshotRecordArray) {\n let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;\n\n return fetch(url).then((response) => response.json())\n }\n }\n ```\n */\n declare include?: string | string[];\n\n /**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters and serializers for certain requests.\n\n @private\n @constructor\n @param {Store} store\n @param {String} type\n @param options\n */\n constructor(store: Store, type: string, options: FindAllOptions = {}) {\n this.__store = store;\n this._snapshots = null;\n this.modelName = type;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n }\n\n /**\n An array of records\n\n @internal\n */\n get _recordArray(): LegacyLiveArray {\n return this.__store.peekAll(this.modelName);\n }\n\n /**\n Number of records in the array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotRecordArray) {\n return !snapshotRecordArray.length;\n }\n });\n ```\n */\n get length(): number {\n return this._recordArray.length;\n }\n\n /**\n Get snapshots of the underlying record array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotArray) {\n let snapshots = snapshotArray.snapshots();\n\n return snapshots.any(function(ticketSnapshot) {\n let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');\n if (timeDiff > 20) {\n return true;\n } else {\n return false;\n }\n });\n }\n }\n ```\n\n @public\n @return Array of snapshots\n */\n snapshots(): Snapshot[] {\n if (this._snapshots !== null) {\n return this._snapshots;\n }\n upgradeStore(this.__store);\n\n const { _fetchManager } = this.__store;\n const LiveArrayContext = (this._recordArray as unknown as PrivateReactiveResourceArray)[Context];\n this._snapshots = LiveArrayContext.source.map((identifier: ResourceKey) =>\n _fetchManager.createSnapshot(identifier)\n );\n\n return this._snapshots;\n }\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport type { PersistedResourceKey } from '@warp-drive/core/types/identifier';\n\nexport function assertIdentifierHasId(identifier: unknown): asserts identifier is PersistedResourceKey {\n assert(\n `Attempted to schedule a fetch for a record without an id.`,\n identifier && (identifier as PersistedResourceKey).id !== null\n );\n}\n","import type { AdapterPayload } from './minimum-adapter-interface.ts';\n\ntype IteratorCB<T> = ((o: T, index: number) => T) | ((o: T) => T);\n\nexport function iterateData<T>(data: T[] | T, fn: IteratorCB<T>): T | T[] {\n if (Array.isArray(data)) {\n return data.map(fn);\n } else {\n return fn(data, 0);\n }\n}\n\nexport function payloadIsNotBlank<T>(adapterPayload: T | AdapterPayload): adapterPayload is AdapterPayload {\n if (Array.isArray(adapterPayload)) {\n return true;\n } else {\n return Object.keys(adapterPayload || {}).length !== 0;\n }\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { JsonApiDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { AdapterPayload } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface, RequestType } from './minimum-serializer-interface.ts';\n\n/**\n This is a helper method that validates a JSON API top-level document\n\n The format of a document is described here:\n http://jsonapi.org/format/#document-top-level\n\n @internal\n*/\nfunction validateDocumentStructure(doc?: AdapterPayload | JsonApiDocument): asserts doc is JsonApiDocument {\n if (DEBUG) {\n const errors: string[] = [];\n if (!doc || typeof doc !== 'object') {\n errors.push('Top level of a JSON API document must be an object');\n } else {\n if (!('data' in doc) && !('errors' in doc) && !('meta' in doc)) {\n errors.push('One or more of the following keys must be present: \"data\", \"errors\", \"meta\".');\n } else {\n if ('data' in doc && 'errors' in doc) {\n errors.push('Top level keys \"errors\" and \"data\" cannot both be present in a JSON API document');\n }\n }\n if ('data' in doc) {\n if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {\n errors.push('data must be null, an object, or an array');\n }\n }\n if ('meta' in doc) {\n if (typeof doc.meta !== 'object') {\n errors.push('meta must be an object');\n }\n }\n if ('errors' in doc) {\n if (!Array.isArray(doc.errors)) {\n errors.push('errors must be an array');\n }\n }\n if ('links' in doc) {\n if (typeof doc.links !== 'object') {\n errors.push('links must be an object');\n }\n }\n if ('jsonapi' in doc) {\n if (typeof doc.jsonapi !== 'object') {\n errors.push('jsonapi must be an object');\n }\n }\n if ('included' in doc) {\n if (typeof doc.included !== 'object') {\n errors.push('included must be an array');\n }\n }\n }\n\n assert(\n `Response must be normalized to a valid JSON API document:\\n\\t* ${errors.join('\\n\\t* ')}`,\n errors.length === 0\n );\n }\n}\n\nexport function normalizeResponseHelper(\n serializer: MinimumSerializerInterface | null,\n store: Store,\n modelClass: ModelSchema,\n payload: AdapterPayload,\n id: string | null,\n requestType: RequestType\n): JsonApiDocument {\n const normalizedResponse = serializer\n ? serializer.normalizeResponse(store, modelClass, payload, id, requestType)\n : payload;\n\n validateDocumentStructure(normalizedResponse);\n\n return normalizedResponse;\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions } from '@warp-drive/core/types';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { Value } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core/types/schema/fields';\n\nimport { upgradeStore } from '../-private';\nimport type { SerializerOptions } from './minimum-serializer-interface';\n\ntype RecordId = string | null;\n\n/**\n Snapshot is not directly instantiable.\n Instances are provided to a consuming application's\n adapters and serializers for certain requests.\n\n Snapshots are only available when using `@ember-data/legacy-compat`\n for legacy compatibility with adapters and serializers.\n\n For serialization of records in modern paradigms, request data from\n the cache or off the record directly.\n\n @hideconstructor\n @public\n*/\nexport class Snapshot<R = unknown> {\n /** @internal */\n declare private __attributes: Record<keyof R & string, unknown> | null;\n /** @internal */\n declare private _belongsToRelationships: Record<string, Snapshot>;\n /** @internal */\n declare private _belongsToIds: Record<string, RecordId>;\n /** @internal */\n declare private _hasManyRelationships: Record<string, Snapshot[]>;\n /** @internal */\n declare private _hasManyIds: Record<string, RecordId[]>;\n /** @internal */\n declare private _changedAttributes: ChangedAttributesHash;\n /** @internal */\n declare private _store: Store;\n\n /**\n The unique ResourceKey associated with this Snapshot.\n\n @public\n */\n declare identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;\n\n /**\n The ResourceType of the underlying record for this Snapshot, as a string.\n\n @public\n */\n declare modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;\n\n /**\n The id of the snapshot's underlying record\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.id; // => '1'\n ```\n\n @public\n */\n declare id: string | null;\n\n /**\n If `include` was passed to the options for the request, the value\n would be available here.\n\n @public\n */\n declare include?: string | string[];\n\n /**\n The adapterOptions passed to the request which generated this Snapshot, if any\n\n @public\n */\n declare adapterOptions?: Record<string, unknown>;\n\n constructor(\n options: FindRecordOptions,\n identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>,\n store: Store\n ) {\n this._store = store;\n\n this.__attributes = null;\n this._belongsToRelationships = Object.create(null) as Record<string, Snapshot>;\n this._belongsToIds = Object.create(null) as Record<string, RecordId>;\n this._hasManyRelationships = Object.create(null) as Record<string, Snapshot[]>;\n this._hasManyIds = Object.create(null) as Record<string, RecordId[]>;\n\n assertPrivateStore(store);\n const hasRecord = !!store._instanceCache.peek(identifier);\n this.modelName = identifier.type;\n this.identifier = identifier;\n\n /*\n If the we do not yet have a record, then we are\n likely a snapshot being provided to a find request, so we\n populate __attributes lazily. Else, to preserve the \"moment\n in time\" in which a snapshot is created, we greedily grab\n the values.\n */\n if (hasRecord) {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n this._attributes;\n }\n\n this.id = identifier.id;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n this.modelName = identifier.type;\n\n if (hasRecord) {\n const cache = this._store.cache;\n this._changedAttributes = cache.changedAttrs(identifier);\n }\n }\n\n /**\n The underlying record for this snapshot. Can be used to access methods and\n properties defined on the record.\n\n ```js\n const someValue = snapshot.record.someProp;\n ```\n\n @property record\n @public\n */\n get record(): R | null {\n const record = this._store.peekRecord<R>(this.identifier);\n assert(\n `Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`,\n record !== null\n );\n return record;\n }\n\n /** @internal */\n private get _attributes(): Record<keyof R & string, unknown> {\n if (this.__attributes !== null) {\n return this.__attributes;\n }\n const attributes = (this.__attributes = Object.create(null) as Record<string, unknown>);\n const { identifier } = this;\n const cache = this._store.cache;\n\n this.eachAttribute((key: string, meta: LegacyAttributeField) => {\n attributes[key] = cache.getAttr(identifier, key);\n });\n\n return attributes;\n }\n\n get isNew(): boolean {\n const cache = this._store.cache;\n return cache?.isNew(this.identifier) || false;\n }\n\n /**\n Returns the value of an attribute.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attr('author'); // => 'Tomster'\n postSnapshot.attr('title'); // => 'Ember.js rocks'\n ```\n\n Note: Values are loaded eagerly and cached when the snapshot is created.\n\n @return The attribute value or undefined\n @public\n */\n attr(keyName: keyof R & string): unknown {\n if (keyName in this._attributes) {\n return this._attributes[keyName];\n }\n assert(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`, false);\n }\n\n /**\n Returns all attributes and their corresponding values.\n\n ::: warning ⚠️ WARNING\n Attributes are SHALLOW copied from the cache.\n Because they are NOT deep copied from the cache, mutating\n any object or array fields will cause unintended side-effects\n and bugs.\n :::\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }\n ```\n\n @return All attributes of the current snapshot\n @public\n */\n attributes(): Record<keyof R & string, unknown> {\n return { ...this._attributes };\n }\n\n /**\n Returns all changed attributes and their old and new values.\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postModel.set('title', 'Ember.js rocks!');\n postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }\n ```\n\n @return All changed attributes of the current snapshot\n @public\n */\n changedAttributes(): ChangedAttributesHash {\n const changedAttributes = Object.create(null) as ChangedAttributesHash;\n if (!this._changedAttributes) {\n return changedAttributes;\n }\n\n const changedAttributeKeys = Object.keys(this._changedAttributes);\n\n for (let i = 0, length = changedAttributeKeys.length; i < length; i++) {\n const key = changedAttributeKeys[i];\n changedAttributes[key] = this._changedAttributes[key].slice() as [Value | undefined, Value];\n }\n\n return changedAttributes;\n }\n\n /**\n Returns the current value of a belongsTo relationship.\n\n `belongsTo` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `id`: set to `true` if you only want the ID of the related record to be\n returned.\n\n Example\n\n ```js\n // store.push('post', { id: 1, title: 'Hello World' });\n // store.createRecord('comment', { body: 'Lorem ipsum', post: post });\n commentSnapshot.belongsTo('post'); // => Snapshot\n commentSnapshot.belongsTo('post', { id: true }); // => '1'\n\n // store.push('comment', { id: 1, body: 'Lorem ipsum' });\n commentSnapshot.belongsTo('post'); // => undefined\n ```\n\n Calling `belongsTo` will return a new Snapshot as long as there's any known\n data for the relationship available, such as an ID. If the relationship is\n known but unset, `belongsTo` will return `null`. If the contents of the\n relationship is unknown `belongsTo` will return `undefined`.\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return A snapshot or ID of a known relationship or null if the\n relationship is known but unset. undefined will be returned if the\n contents of the relationship are unknown.\n */\n belongsTo(keyName: string, options?: { id?: boolean }): Snapshot | RecordId | undefined {\n const returnModeIsId = !!(options && options.id);\n let result: Snapshot | RecordId | undefined;\n const store = this._store;\n\n if (returnModeIsId === true && keyName in this._belongsToIds) {\n return this._belongsToIds[keyName];\n }\n\n if (returnModeIsId === false && keyName in this._belongsToRelationships) {\n return this._belongsToRelationships[keyName];\n }\n\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'belongsTo'\n );\n\n assert(`snapshot.belongsTo only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a hasMany.`,\n relationship.kind === 'belongsTo'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName);\n const data = value && value.data;\n upgradeStore(store);\n\n const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;\n\n if (value && value.data !== undefined) {\n const cache = store.cache;\n\n if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsId) {\n result = inverseIdentifier.id;\n } else {\n result = store._fetchManager.createSnapshot(inverseIdentifier);\n }\n } else {\n result = null;\n }\n }\n\n if (returnModeIsId) {\n this._belongsToIds[keyName] = result as RecordId;\n } else {\n this._belongsToRelationships[keyName] = result as Snapshot;\n }\n\n return result;\n }\n\n /**\n Returns the current value of a hasMany relationship.\n\n `hasMany` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `ids`: set to `true` if you only want the IDs of the related records to be\n returned.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });\n postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]\n postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']\n\n // store.push('post', { id: 1, title: 'Hello World' });\n postSnapshot.hasMany('comments'); // => undefined\n ```\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return An array of snapshots or IDs of a known\n relationship or an empty array if the relationship is known but unset.\n undefined will be returned if the contents of the relationship is unknown.\n */\n hasMany(keyName: string, options?: { ids?: boolean }): RecordId[] | Snapshot[] | undefined {\n const returnModeIsIds = !!(options && options.ids);\n let results: RecordId[] | Snapshot[] | undefined;\n const cachedIds: RecordId[] | undefined = this._hasManyIds[keyName];\n const cachedSnapshots: Snapshot[] | undefined = this._hasManyRelationships[keyName];\n\n if (returnModeIsIds === true && keyName in this._hasManyIds) {\n return cachedIds;\n }\n\n if (returnModeIsIds === false && keyName in this._hasManyRelationships) {\n return cachedSnapshots;\n }\n\n const store = this._store;\n upgradeStore(store);\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'hasMany'\n );\n\n // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes\n // this check is not a regression in behavior because relationships don't currently\n // function without access to intimate API contracts between RecordData and Model.\n // This is a requirement we should fix as soon as the relationship layer does not require\n // this intimate API usage.\n assert(`snapshot.hasMany only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a belongsTo.`,\n relationship.kind === 'hasMany'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName) as CollectionRelationship;\n\n if (value.data) {\n results = [];\n value.data.forEach((member) => {\n const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);\n const cache = store.cache;\n\n if (!cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsIds) {\n (results as RecordId[]).push(inverseIdentifier.id);\n } else {\n (results as Snapshot[]).push(store._fetchManager.createSnapshot(inverseIdentifier));\n }\n }\n });\n }\n\n // we assign even if `undefined` so that we don't reprocess the relationship\n // on next access. This works with the `keyName in` checks above.\n if (returnModeIsIds) {\n this._hasManyIds[keyName] = results as RecordId[];\n } else {\n this._hasManyRelationships[keyName] = results as Snapshot[];\n }\n\n return results;\n }\n\n /**\n Iterates through all the attributes of the model, calling the passed\n function on each attribute.\n\n Example\n\n ```javascript\n snapshot.eachAttribute(function(name, meta) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate attributes. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachAttribute(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'attribute') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Iterates through all the relationships of the model, calling the passed\n function on each relationship.\n\n Example\n\n ```javascript\n snapshot.eachRelationship(function(name, relationship) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate relationships. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachRelationship(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'belongsTo' || field.kind === 'hasMany') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Serializes the snapshot using the serializer for the model.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default Adapter.extend({\n createRecord(store, type, snapshot) {\n let data = snapshot.serialize({ includeId: true });\n let url = `/${type.modelName}`;\n\n return fetch(url, {\n method: 'POST',\n body: data,\n }).then((response) => response.json())\n }\n });\n ```\n\n @return an object whose values are primitive JSON values only\n @public\n */\n serialize(options?: SerializerOptions): unknown {\n upgradeStore(this._store);\n const serializer = this._store.serializerFor(this.modelName);\n assert(`Cannot serialize record, no serializer found`, serializer);\n return serializer.serialize(this, options);\n }\n}\n","import { warn } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { createDeferred } from '@warp-drive/core/request';\nimport { waitFor } from '@warp-drive/core/signals/-leaked';\nimport type {\n FindRecordQuery,\n InstanceCache,\n PrivateRequestStateService,\n PrivateStore,\n Request,\n SaveRecordMutation,\n} from '@warp-drive/core/store/-private';\nimport { assertPrivateStore, coerceId } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions, ModelSchema } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ImmutableRequestInfo } from '@warp-drive/core/types/request';\nimport type { CollectionResourceDocument, SingleResourceDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../-private.ts';\nimport { assertIdentifierHasId } from './identifier-has-id.ts';\nimport { payloadIsNotBlank } from './legacy-data-utils.ts';\nimport type { AdapterPayload, MinimumAdapterInterface } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface } from './minimum-serializer-interface.ts';\nimport { normalizeResponseHelper } from './serializer-response.ts';\nimport { Snapshot } from './snapshot.ts';\n\ntype Deferred<T> = ReturnType<typeof createDeferred<T>>;\ntype AdapterErrors = Error & { errors?: string[]; isAdapterError?: true };\ntype SerializerWithParseErrors = MinimumSerializerInterface & {\n extractErrors?(store: Store, modelClass: ModelSchema, error: AdapterErrors, recordId: string | null): unknown;\n};\n\nexport const SaveOp: '___(unique) Symbol(SaveOp)' = getOrSetGlobal('SaveOp', Symbol('SaveOp'));\n\nexport type FetchMutationOptions = FindRecordOptions & { [SaveOp]: 'createRecord' | 'deleteRecord' | 'updateRecord' };\n\ninterface PendingFetchItem {\n identifier: PersistedResourceKey;\n queryRequest: Request;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n resolver: Deferred<any>;\n options: FindRecordOptions;\n trace?: unknown;\n promise: Promise<PersistedResourceKey>;\n}\n\ninterface PendingSaveItem {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n resolver: Deferred<any>;\n snapshot: Snapshot;\n identifier: ResourceKey;\n options: FetchMutationOptions;\n queryRequest: Request;\n}\n\n/**\n * @private\n */\nexport class FetchManager {\n /**\n * @internal\n */\n declare isDestroyed: boolean;\n /** @internal */\n declare private requestCache: PrivateRequestStateService;\n // fetches pending in the runloop, waiting to be coalesced\n /**\n * @internal\n */\n declare _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n\n /** @internal */\n declare private _store: PrivateStore;\n\n constructor(store: Store) {\n assertPrivateStore(store);\n this._store = store;\n // used to keep track of all the find requests that need to be coalesced\n this._pendingFetch = new Map();\n this.requestCache = store.getRequestStateService();\n this.isDestroyed = false;\n }\n\n createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;\n createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;\n createSnapshot(identifier: ResourceKey, options: FindRecordOptions = {}): Snapshot {\n return new Snapshot(options, identifier, this._store);\n }\n\n /**\n This method is called by `record.save`, and gets passed a\n resolver for the promise that `record.save` returns.\n\n It schedules saving to happen at the end of the run loop.\n\n @private\n */\n scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument> {\n const resolver = createDeferred<SingleResourceDocument | null>();\n const query: SaveRecordMutation = {\n op: 'saveRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const snapshot = this.createSnapshot(identifier, options);\n const pendingSaveItem: PendingSaveItem = {\n snapshot: snapshot,\n resolver: resolver,\n identifier,\n options,\n queryRequest,\n };\n\n const monitored = this.requestCache._enqueue(resolver.promise, pendingSaveItem.queryRequest);\n _flushPendingSave(this._store, pendingSaveItem);\n\n return monitored;\n }\n\n scheduleFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions,\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n const query: FindRecordQuery = {\n op: 'findRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const pendingFetch = this.getPendingFetch(identifier, options);\n if (pendingFetch) {\n return pendingFetch;\n }\n\n const modelName = identifier.type;\n\n const resolver = createDeferred<SingleResourceDocument>();\n const pendingFetchItem: PendingFetchItem = {\n identifier,\n resolver,\n options,\n queryRequest,\n } as PendingFetchItem;\n\n const resolverPromise = resolver.promise;\n const store = this._store;\n const isInitialLoad = !store._instanceCache.recordIsLoaded(identifier); // we don't use isLoading directly because we are the request\n\n const monitored = this.requestCache._enqueue(resolverPromise, pendingFetchItem.queryRequest);\n let promise = monitored.then(\n (payload) => {\n // ensure that regardless of id returned we assign to the correct record\n if (payload.data && !Array.isArray(payload.data)) {\n payload.data.lid = identifier.lid;\n }\n\n // additional data received in the payload\n // may result in the merging of identifiers (and thus records)\n const potentiallyNewIm = store._push(payload, options.reload);\n if (potentiallyNewIm && !Array.isArray(potentiallyNewIm)) {\n return potentiallyNewIm;\n }\n\n return identifier;\n },\n (error) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !store.isDestroyed);\n const cache = store.cache;\n if (!cache || cache.isEmpty(identifier) || isInitialLoad) {\n let isReleasable = true;\n if (store._graph) {\n const graph = store._graph;\n if (!cache) {\n isReleasable = graph.isReleasable(identifier);\n if (!isReleasable) {\n graph.unload(identifier, true);\n }\n }\n }\n if (cache || isReleasable) {\n store._enableAsyncFlush = true;\n store._instanceCache.unloadRecord(identifier);\n store._enableAsyncFlush = null;\n }\n }\n throw error;\n }\n );\n\n if (this._pendingFetch.size === 0) {\n void new Promise((resolve) => setTimeout(resolve, 0)).then(() => {\n this.flushAllPendingFetches();\n });\n }\n\n const fetchesByType = this._pendingFetch;\n let fetchesById = fetchesByType.get(modelName);\n\n if (!fetchesById) {\n fetchesById = new Map();\n fetchesByType.set(modelName, fetchesById);\n }\n\n let requestsForIdentifier = fetchesById.get(identifier);\n if (!requestsForIdentifier) {\n requestsForIdentifier = [];\n fetchesById.set(identifier, requestsForIdentifier);\n }\n\n requestsForIdentifier.push(pendingFetchItem);\n\n if (TESTING) {\n if (!request.disableTestWaiter) {\n promise = waitFor(promise);\n }\n }\n\n pendingFetchItem.promise = promise;\n return promise;\n }\n\n getPendingFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions\n ): Promise<PersistedResourceKey> | undefined {\n const pendingFetches = this._pendingFetch.get(identifier.type)?.get(identifier);\n\n // We already have a pending fetch for this\n if (pendingFetches) {\n const matchingPendingFetch = pendingFetches.find((fetch) => isSameRequest(options, fetch.options));\n if (matchingPendingFetch) {\n return matchingPendingFetch.promise;\n }\n }\n }\n\n flushAllPendingFetches(): void {\n if (this.isDestroyed) {\n return;\n }\n\n const store = this._store;\n this._pendingFetch.forEach((fetchItem, type) => _flushPendingFetchForType(store, fetchItem, type));\n this._pendingFetch.clear();\n }\n\n fetchDataIfNeededForIdentifier(\n identifier: PersistedResourceKey,\n options: FindRecordOptions | undefined = {},\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n // pre-loading will change the isEmpty value\n const isEmpty = _isEmpty(this._store._instanceCache, identifier);\n const isLoading = _isLoading(this._store._instanceCache, identifier);\n\n let promise: Promise<PersistedResourceKey>;\n if (isEmpty) {\n assertIdentifierHasId(identifier);\n\n if (DEBUG) {\n promise = this.scheduleFetch(identifier, Object.assign({}, options, { reload: true }), request);\n } else {\n options.reload = true;\n promise = this.scheduleFetch(identifier, options, request);\n }\n } else if (isLoading) {\n promise = this.getPendingFetch(identifier, options)!;\n assert(`Expected to find a pending request for a record in the loading state, but found none`, promise);\n } else {\n promise = Promise.resolve(identifier);\n }\n\n return promise;\n }\n\n destroy(): void {\n this.isDestroyed = true;\n }\n}\n\n/**\n * This type exists for internal use only for\n * where intimate contracts still exist either for\n * the Test Suite or for Legacy code.\n *\n * @private\n */\nexport interface PrivateFetchManager extends FetchManager {\n _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n}\n\nfunction _isEmpty(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n if (!cache) {\n return true;\n }\n const isNew = cache.isNew(identifier);\n const isDeleted = cache.isDeleted(identifier);\n const isEmpty = cache.isEmpty(identifier);\n\n return (!isNew || isDeleted) && isEmpty;\n}\n\nfunction _isLoading(cache: InstanceCache, identifier: ResourceKey): boolean {\n const req = cache.store.getRequestStateService();\n // const fulfilled = req.getLastRequestForRecord(identifier);\n const isLoaded = cache.recordIsLoaded(identifier);\n\n return (\n !isLoaded &&\n // fulfilled === null &&\n req.getPendingRequestsForRecord(identifier).some((r) => r.type === 'query')\n );\n}\n\nfunction includesSatisfies(current: undefined | string | string[], existing: undefined | string | string[]): boolean {\n // if we have no includes we are good\n if (!current?.length) {\n return true;\n }\n\n // if we are here we have includes,\n // and if existing has no includes then we will need a new request\n if (!existing?.length) {\n return false;\n }\n\n const arrCurrent = (Array.isArray(current) ? current : current.split(',')).sort();\n const arrExisting = (Array.isArray(existing) ? existing : existing.split(',')).sort();\n\n // includes are identical\n if (arrCurrent.join(',') === arrExisting.join(',')) {\n return true;\n }\n\n // if all of current includes are in existing includes then we are good\n // so if we find one that is not in existing then we need a new request\n for (let i = 0; i < arrCurrent.length; i++) {\n if (!arrExisting.includes(arrCurrent[i])) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction optionsSatisfies(current: object | undefined, existing: object | undefined): boolean {\n return !current || current === existing || Object.keys(current).length === 0;\n}\n\n// this function helps resolve whether we have a pending request that we should use instead\nfunction isSameRequest(options: FindRecordOptions = {}, existingOptions: FindRecordOptions = {}) {\n return (\n optionsSatisfies(options.adapterOptions, existingOptions.adapterOptions) &&\n includesSatisfies(options.include, existingOptions.include)\n );\n}\n\nfunction _findMany(\n store: Store,\n adapter: MinimumAdapterInterface,\n modelName: string,\n snapshots: Snapshot[]\n): Promise<CollectionResourceDocument> {\n const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still\n const promise = Promise.resolve().then(() => {\n const ids = snapshots.map((s) => s.id!);\n assert(\n `Cannot fetch a record without an id`,\n ids.every((v) => v !== null)\n );\n // eslint-disable-next-line @typescript-eslint/unbound-method\n assert(`Expected this adapter to implement findMany for coalescing`, adapter.findMany);\n const ret = adapter.findMany(store, modelClass, ids, snapshots);\n assert('adapter.findMany returned undefined, this was very likely a mistake', ret !== undefined);\n return ret;\n });\n upgradeStore(store);\n\n return promise.then((adapterPayload) => {\n assert(\n `You made a 'findMany' request for '${modelName}' records with ids '[${snapshots\n .map((s) => s.id!)\n .join(',')}]', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');\n return payload as CollectionResourceDocument;\n });\n}\n\nfunction rejectFetchedItems(fetchMap: Map<Snapshot, PendingFetchItem>, snapshots: Snapshot[], error?: Error) {\n for (let i = 0, l = snapshots.length; i < l; i++) {\n const snapshot = snapshots[i];\n const pair = fetchMap.get(snapshot);\n\n if (pair) {\n pair.resolver.reject(\n error ||\n new Error(\n `Expected: '<${\n snapshot.modelName\n }:${snapshot.id!}>' to be present in the adapter provided payload, but it was not found.`\n )\n );\n }\n }\n}\n\nfunction handleFoundRecords(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n snapshots: Snapshot[],\n coalescedPayload: CollectionResourceDocument\n) {\n /*\n It is possible that the same ID is included multiple times\n via multiple snapshots. This happens when more than one\n options hash was supplied, each of which must be uniquely\n accounted for.\n\n However, since we can't map from response to a specific\n options object, we resolve all snapshots by id with\n the first response we see.\n */\n const snapshotsById = new Map<string, Snapshot[]>();\n for (let i = 0; i < snapshots.length; i++) {\n const id = snapshots[i].id!;\n let snapshotGroup = snapshotsById.get(id);\n if (!snapshotGroup) {\n snapshotGroup = [];\n snapshotsById.set(id, snapshotGroup);\n }\n snapshotGroup.push(snapshots[i]);\n }\n\n const included = Array.isArray(coalescedPayload.included) ? coalescedPayload.included : [];\n\n // resolve found records\n const resources = coalescedPayload.data;\n for (let i = 0, l = resources.length; i < l; i++) {\n const resource = resources[i];\n const snapshotGroup = snapshotsById.get(resource.id);\n snapshotsById.delete(resource.id);\n\n if (!snapshotGroup) {\n // TODO consider whether this should be a deprecation/assertion\n included.push(resource);\n } else {\n snapshotGroup.forEach((snapshot) => {\n const pair = fetchMap.get(snapshot)!;\n const resolver = pair.resolver;\n resolver.resolve({ data: resource });\n });\n }\n }\n\n if (included.length > 0) {\n store._push({ data: null, included }, true);\n }\n\n if (snapshotsById.size === 0) {\n return;\n }\n\n // reject missing records\n const rejected: Snapshot[] = [];\n snapshotsById.forEach((snapshotArray) => {\n rejected.push(...snapshotArray);\n });\n warn(\n 'Ember Data expected to find records with the following ids in the adapter response from findMany but they were missing: [ \"' +\n [...snapshotsById.values()].map((r) => r[0].id).join('\", \"') +\n '\" ]',\n {\n id: 'ds.store.missing-records-from-adapter',\n }\n );\n\n rejectFetchedItems(fetchMap, rejected);\n}\n\nfunction _fetchRecord(store: Store, adapter: MinimumAdapterInterface, fetchItem: PendingFetchItem) {\n upgradeStore(store);\n const identifier = fetchItem.identifier;\n const modelName = identifier.type;\n\n assert(`You tried to find a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`,\n typeof adapter.findRecord === 'function'\n );\n\n const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);\n const klass = store.modelFor(identifier.type);\n const id = identifier.id;\n\n let promise = Promise.resolve().then(() => {\n return adapter.findRecord(store, klass, identifier.id, snapshot);\n });\n\n promise = promise.then((adapterPayload) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !(store.isDestroyed || store.isDestroying));\n assert(\n `You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');\n assert(\n `Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`,\n !Array.isArray(payload.data)\n );\n assert(\n `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.`,\n 'data' in payload && payload.data !== null && typeof payload.data === 'object'\n );\n\n warn(\n `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.`,\n coerceId(payload.data.id) === coerceId(id),\n {\n id: 'ds.store.findRecord.id-mismatch',\n }\n );\n\n return payload;\n }) as Promise<AdapterPayload>;\n\n fetchItem.resolver.resolve(promise);\n}\n\nfunction _processCoalescedGroup(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n group: Snapshot[],\n adapter: MinimumAdapterInterface,\n modelName: string\n) {\n if (group.length > 1) {\n _findMany(store, adapter, modelName, group)\n .then((payloads: CollectionResourceDocument) => {\n handleFoundRecords(store, fetchMap, group, payloads);\n })\n .catch((error: Error) => {\n rejectFetchedItems(fetchMap, group, error);\n });\n } else if (group.length === 1) {\n _fetchRecord(store, adapter, fetchMap.get(group[0])!);\n } else {\n assert(\"You cannot return an empty array from adapter's method groupRecordsForFindMany\", false);\n }\n}\n\nfunction _flushPendingFetchForType(\n store: Store,\n pendingFetchMap: Map<PersistedResourceKey, PendingFetchItem[]>,\n modelName: string\n) {\n upgradeStore(store);\n const adapter = store.adapterFor(modelName);\n const shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;\n\n if (shouldCoalesce) {\n const pendingFetchItems: PendingFetchItem[] = [];\n pendingFetchMap.forEach((requestsForIdentifier, identifier) => {\n if (requestsForIdentifier.length > 1) {\n return;\n }\n\n // remove this entry from the map so it's not processed again\n pendingFetchMap.delete(identifier);\n pendingFetchItems.push(requestsForIdentifier[0]);\n });\n\n const totalItems = pendingFetchItems.length;\n\n if (totalItems > 1) {\n const snapshots = new Array<Snapshot>(totalItems);\n const fetchMap = new Map<Snapshot, PendingFetchItem>();\n for (let i = 0; i < totalItems; i++) {\n const fetchItem = pendingFetchItems[i];\n snapshots[i] = store._fetchManager.createSnapshot(fetchItem.identifier, fetchItem.options);\n fetchMap.set(snapshots[i], fetchItem);\n }\n\n let groups: Snapshot[][];\n if (adapter.groupRecordsForFindMany) {\n groups = adapter.groupRecordsForFindMany(store, snapshots);\n } else {\n groups = [snapshots];\n }\n\n for (let i = 0, l = groups.length; i < l; i++) {\n _processCoalescedGroup(store, fetchMap, groups[i], adapter, modelName);\n }\n } else if (totalItems === 1) {\n _fetchRecord(store, adapter, pendingFetchItems[0]);\n }\n }\n\n pendingFetchMap.forEach((pendingFetchItems) => {\n pendingFetchItems.forEach((pendingFetchItem) => {\n _fetchRecord(store, adapter, pendingFetchItem);\n });\n });\n}\n\nfunction _flushPendingSave(store: Store, pending: PendingSaveItem) {\n const { snapshot, resolver, identifier, options } = pending;\n upgradeStore(store);\n const adapter = store.adapterFor(identifier.type);\n const operation = options[SaveOp];\n\n const modelName = snapshot.modelName;\n const modelClass = store.modelFor(modelName);\n\n assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`,\n typeof adapter[operation] === 'function'\n );\n\n let promise: Promise<AdapterPayload> = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));\n const serializer: SerializerWithParseErrors | null = store.serializerFor(modelName);\n\n assert(\n `Your adapter's '${operation}' method must return a value, but it returned 'undefined'`,\n promise !== undefined\n );\n\n promise = promise.then((adapterPayload) => {\n if (adapterPayload) {\n return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);\n }\n }) as Promise<AdapterPayload>;\n\n resolver.resolve(promise);\n}\n","import type { Store } from '@warp-drive/core';\n\nimport type { CompatStore } from '../compat.ts';\n\n/**\n * Utilities - often temporary - for maintaining backwards compatibility with\n * older parts of WarpDrive.\n *\n @module\n*/\nexport { SnapshotRecordArray } from './legacy-network-handler/snapshot-record-array.ts';\nexport { SaveOp } from './legacy-network-handler/fetch-manager.ts';\nexport { FetchManager } from './legacy-network-handler/fetch-manager.ts';\nexport { Snapshot } from './legacy-network-handler/snapshot.ts';\n\nexport function upgradeStore(store: Store): asserts store is CompatStore {}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAaE,sBAAb,MAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE/BC,YAAYC,OAAcC,MAAcC,UAA0B,CAAC,GAAG;EACpE,KAAKC,UAAUH;EACf,KAAKI,aAAa;EAClB,KAAKC,YAAYJ;EACjB,KAAKK,iBAAiBJ,QAAQI;EAC9B,KAAKC,UAAUL,QAAQK;CACzB;;;;;CAOA,IAAIC,eAAgC;EAClC,OAAO,KAAKL,QAAQM,QAAQ,KAAKJ,SAAS;CAC5C;;;;;;;;;;;;;CAiBA,IAAIK,SAAiB;EACnB,OAAO,KAAKF,aAAaE;CAC3B;;;;;;;;;;;;;;;;;;;;;;;CA6BAC,YAAwB;EACtB,IAAI,KAAKP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AAsDpB,UAAS,wBAAyBqI,UAAS,EAAG;CAAA,EAAA,CACpG,OAAOlD,QAAQkD,eAAe,UAAU;CAG1C,IAAI3I,UAAmCoC,QAAQC,QAAQ,CAAC,CAACxB,WAAW4E,QAAQkD,UAAU,CAAChK,OAAOgH,YAAY/F,QAAQ,CAAC;CACnH,MAAM2G,aAA+C5H,MAAM6H,cAAclG,SAAS;CAElFhC,eAAAD,gBAAA,CAAA,CAAAiD,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mBAAmBiH,UAAS,0DAA2D;CAAA,EAAA,CACvF3I,YAAYqG,MAAS;CAGvBrG,UAAUA,QAAQa,MAAMyF,mBAAmB;EACzC,IAAIA,gBACF,OAAOnI,wBAAwBoI,YAAY5H,OAAOgH,YAAYW,gBAAgB1G,SAASoG,IAAI2C,SAAS;CAExG,CAAC;CAEDrJ,SAAS+C,QAAQrC,OAAO;AAC1B;;;;AC/nBA,SAAgB,aAAa,OAA4C,CAAC"}
1
+ {"version":3,"file":"-private-DccRZQsm.js","names":["Context","upgradeStore","SnapshotRecordArray","constructor","store","type","options","__store","_snapshots","modelName","adapterOptions","include","_recordArray","peekAll","length","snapshots","_fetchManager","LiveArrayContext","source","map","identifier","createSnapshot","assertIdentifierHasId","identifier","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","id","validateDocumentStructure","doc","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","errors","push","data","Array","isArray","meta","links","jsonapi","included","test","Error","join","length","normalizeResponseHelper","serializer","store","modelClass","payload","id","requestType","normalizedResponse","normalizeResponse","assertPrivateStore","upgradeStore","getGlobalConfig","macroCondition","Snapshot","constructor","options","identifier","store","_store","__attributes","_belongsToRelationships","Object","create","_belongsToIds","_hasManyRelationships","_hasManyIds","hasRecord","_instanceCache","peek","modelName","type","_attributes","id","adapterOptions","include","cache","_changedAttributes","changedAttrs","record","peekRecord","WarpDrive","env","DEBUG","test","Error","lid","attributes","eachAttribute","key","meta","getAttr","isNew","attr","keyName","changedAttributes","changedAttributeKeys","keys","i","length","slice","belongsTo","returnModeIsId","result","relationshipMeta","schema","fields","get","kind","_graph","relationship","value","getRelationship","data","inverseIdentifier","cacheKeyManager","getOrCreateRecordIdentifier","undefined","isDeleted","_fetchManager","createSnapshot","hasMany","returnModeIsIds","ids","results","cachedIds","cachedSnapshots","forEach","member","push","callback","binding","modelFor","modelSchema","field","call","eachRelationship","serialize","serializer","serializerFor","warn","createDeferred","waitFor","assertPrivateStore","coerceId","getOrSetGlobal","upgradeStore","assertIdentifierHasId","payloadIsNotBlank","normalizeResponseHelper","Snapshot","getGlobalConfig","macroCondition","SaveOp","Symbol","FetchManager","constructor","store","_store","_pendingFetch","Map","requestCache","getRequestStateService","isDestroyed","createSnapshot","identifier","options","scheduleSave","resolver","query","op","recordIdentifier","queryRequest","data","snapshot","pendingSaveItem","monitored","_enqueue","promise","_flushPendingSave","scheduleFetch","request","pendingFetch","getPendingFetch","modelName","type","pendingFetchItem","resolverPromise","isInitialLoad","_instanceCache","recordIsLoaded","then","payload","Array","isArray","lid","potentiallyNewIm","_push","reload","error","WarpDrive","env","DEBUG","test","Error","cache","isEmpty","isReleasable","_graph","graph","unload","_enableAsyncFlush","unloadRecord","size","Promise","resolve","setTimeout","flushAllPendingFetches","fetchesByType","fetchesById","get","set","requestsForIdentifier","push","TESTING","disableTestWaiter","pendingFetches","matchingPendingFetch","find","fetch","isSameRequest","forEach","fetchItem","_flushPendingFetchForType","clear","fetchDataIfNeededForIdentifier","_isEmpty","isLoading","_isLoading","Object","assign","destroy","instanceCache","isNew","isDeleted","req","isLoaded","getPendingRequestsForRecord","some","r","includesSatisfies","current","existing","length","arrCurrent","split","sort","arrExisting","join","i","includes","optionsSatisfies","keys","existingOptions","adapterOptions","include","_findMany","adapter","snapshots","modelClass","modelFor","ids","map","s","id","every","v","findMany","ret","undefined","adapterPayload","serializer","serializerFor","rejectFetchedItems","fetchMap","l","pair","reject","handleFoundRecords","coalescedPayload","snapshotsById","snapshotGroup","included","resources","resource","delete","rejected","snapshotArray","values","_fetchRecord","findRecord","_fetchManager","klass","isDestroying","_processCoalescedGroup","group","payloads","catch","pendingFetchMap","adapterFor","shouldCoalesce","coalesceFindRequests","pendingFetchItems","totalItems","groups","groupRecordsForFindMany","pending","operation"],"sources":["../src/compat/legacy-network-handler/snapshot-record-array.ts","../src/compat/legacy-network-handler/identifier-has-id.ts","../src/compat/legacy-network-handler/legacy-data-utils.ts","../src/compat/legacy-network-handler/serializer-response.ts","../src/compat/legacy-network-handler/snapshot.ts","../src/compat/legacy-network-handler/fetch-manager.ts","../src/compat/-private.ts"],"sourcesContent":["import type { Store } from '@warp-drive/core';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport type { LegacyLiveArray, PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport type { FindAllOptions, ModelSchema } from '@warp-drive/core/types';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\n\nimport { upgradeStore } from '../-private.ts';\nimport type { Snapshot } from './snapshot.ts';\n/**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters for certain `findAll` requests.\n\n @hideconstructor\n @public\n*/\nexport class SnapshotRecordArray {\n /**\n * An array of snapshots\n *\n * @internal\n */\n declare private _snapshots: Snapshot[] | null;\n\n /** @internal */\n declare private _type: ModelSchema | null;\n\n /**\n * The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array\n */\n declare modelName: string;\n\n /** @internal */\n declare private __store: Store;\n\n /**\n * A hash of adapter options passed into the store method for this request.\n\n Example\n\n ```js [app/adapters/post.js]\n import MyCustomAdapter from './custom-adapter';\n\n export default class PostAdapter extends MyCustomAdapter {\n findAll(store, type, sinceToken, snapshotRecordArray) {\n if (snapshotRecordArray.adapterOptions.subscribe) {\n // ...\n }\n // ...\n }\n }\n ```\n */\n declare adapterOptions?: Record<string, unknown>;\n /**\n * The relationships to include for this request.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default class ApplicationAdapter extends Adapter {\n findAll(store, type, snapshotRecordArray) {\n let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;\n\n return fetch(url).then((response) => response.json())\n }\n }\n ```\n */\n declare include?: string | string[];\n\n /**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters and serializers for certain requests.\n\n @private\n @constructor\n @param {Store} store\n @param {String} type\n @param options\n */\n constructor(store: Store, type: string, options: FindAllOptions = {}) {\n this.__store = store;\n this._snapshots = null;\n this.modelName = type;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n }\n\n /**\n An array of records\n\n @internal\n */\n get _recordArray(): LegacyLiveArray {\n return this.__store.peekAll(this.modelName);\n }\n\n /**\n Number of records in the array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotRecordArray) {\n return !snapshotRecordArray.length;\n }\n });\n ```\n */\n get length(): number {\n return this._recordArray.length;\n }\n\n /**\n Get snapshots of the underlying record array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotArray) {\n let snapshots = snapshotArray.snapshots();\n\n return snapshots.any(function(ticketSnapshot) {\n let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');\n if (timeDiff > 20) {\n return true;\n } else {\n return false;\n }\n });\n }\n }\n ```\n\n @public\n @return Array of snapshots\n */\n snapshots(): Snapshot[] {\n if (this._snapshots !== null) {\n return this._snapshots;\n }\n upgradeStore(this.__store);\n\n const { _fetchManager } = this.__store;\n const LiveArrayContext = (this._recordArray as unknown as PrivateReactiveResourceArray)[Context];\n this._snapshots = LiveArrayContext.source.map((identifier: ResourceKey) =>\n _fetchManager.createSnapshot(identifier)\n );\n\n return this._snapshots;\n }\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport type { PersistedResourceKey } from '@warp-drive/core/types/identifier';\n\nexport function assertIdentifierHasId(identifier: unknown): asserts identifier is PersistedResourceKey {\n assert(\n `Attempted to schedule a fetch for a record without an id.`,\n identifier && (identifier as PersistedResourceKey).id !== null\n );\n}\n","import type { AdapterPayload } from './minimum-adapter-interface.ts';\n\ntype IteratorCB<T> = ((o: T, index: number) => T) | ((o: T) => T);\n\nexport function iterateData<T>(data: T[] | T, fn: IteratorCB<T>): T | T[] {\n if (Array.isArray(data)) {\n return data.map(fn);\n } else {\n return fn(data, 0);\n }\n}\n\nexport function payloadIsNotBlank<T>(adapterPayload: T | AdapterPayload): adapterPayload is AdapterPayload {\n if (Array.isArray(adapterPayload)) {\n return true;\n } else {\n return Object.keys(adapterPayload || {}).length !== 0;\n }\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { JsonApiDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { AdapterPayload } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface, RequestType } from './minimum-serializer-interface.ts';\n\n/**\n This is a helper method that validates a JSON API top-level document\n\n The format of a document is described here:\n http://jsonapi.org/format/#document-top-level\n\n @internal\n*/\nfunction validateDocumentStructure(doc?: AdapterPayload | JsonApiDocument): asserts doc is JsonApiDocument {\n if (DEBUG) {\n const errors: string[] = [];\n if (!doc || typeof doc !== 'object') {\n errors.push('Top level of a JSON API document must be an object');\n } else {\n if (!('data' in doc) && !('errors' in doc) && !('meta' in doc)) {\n errors.push('One or more of the following keys must be present: \"data\", \"errors\", \"meta\".');\n } else {\n if ('data' in doc && 'errors' in doc) {\n errors.push('Top level keys \"errors\" and \"data\" cannot both be present in a JSON API document');\n }\n }\n if ('data' in doc) {\n if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {\n errors.push('data must be null, an object, or an array');\n }\n }\n if ('meta' in doc) {\n if (typeof doc.meta !== 'object') {\n errors.push('meta must be an object');\n }\n }\n if ('errors' in doc) {\n if (!Array.isArray(doc.errors)) {\n errors.push('errors must be an array');\n }\n }\n if ('links' in doc) {\n if (typeof doc.links !== 'object') {\n errors.push('links must be an object');\n }\n }\n if ('jsonapi' in doc) {\n if (typeof doc.jsonapi !== 'object') {\n errors.push('jsonapi must be an object');\n }\n }\n if ('included' in doc) {\n if (typeof doc.included !== 'object') {\n errors.push('included must be an array');\n }\n }\n }\n\n assert(\n `Response must be normalized to a valid JSON API document:\\n\\t* ${errors.join('\\n\\t* ')}`,\n errors.length === 0\n );\n }\n}\n\nexport function normalizeResponseHelper(\n serializer: MinimumSerializerInterface | null,\n store: Store,\n modelClass: ModelSchema,\n payload: AdapterPayload,\n id: string | null,\n requestType: RequestType\n): JsonApiDocument {\n const normalizedResponse = serializer\n ? serializer.normalizeResponse(store, modelClass, payload, id, requestType)\n : payload;\n\n validateDocumentStructure(normalizedResponse);\n\n return normalizedResponse;\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions } from '@warp-drive/core/types';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { Value } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core/types/schema/fields';\n\nimport { upgradeStore } from '../-private';\nimport type { SerializerOptions } from './minimum-serializer-interface';\n\ntype RecordId = string | null;\n\n/**\n Snapshot is not directly instantiable.\n Instances are provided to a consuming application's\n adapters and serializers for certain requests.\n\n Snapshots are only available when using `@ember-data/legacy-compat`\n for legacy compatibility with adapters and serializers.\n\n For serialization of records in modern paradigms, request data from\n the cache or off the record directly.\n\n @hideconstructor\n @public\n*/\nexport class Snapshot<R = unknown> {\n /** @internal */\n declare private __attributes: Record<keyof R & string, unknown> | null;\n /** @internal */\n declare private _belongsToRelationships: Record<string, Snapshot>;\n /** @internal */\n declare private _belongsToIds: Record<string, RecordId>;\n /** @internal */\n declare private _hasManyRelationships: Record<string, Snapshot[]>;\n /** @internal */\n declare private _hasManyIds: Record<string, RecordId[]>;\n /** @internal */\n declare private _changedAttributes: ChangedAttributesHash;\n /** @internal */\n declare private _store: Store;\n\n /**\n The unique ResourceKey associated with this Snapshot.\n\n @public\n */\n declare identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;\n\n /**\n The ResourceType of the underlying record for this Snapshot, as a string.\n\n @public\n */\n declare modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;\n\n /**\n The id of the snapshot's underlying record\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.id; // => '1'\n ```\n\n @public\n */\n declare id: string | null;\n\n /**\n If `include` was passed to the options for the request, the value\n would be available here.\n\n @public\n */\n declare include?: string | string[];\n\n /**\n The adapterOptions passed to the request which generated this Snapshot, if any\n\n @public\n */\n declare adapterOptions?: Record<string, unknown>;\n\n constructor(\n options: FindRecordOptions,\n identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>,\n store: Store\n ) {\n this._store = store;\n\n this.__attributes = null;\n this._belongsToRelationships = Object.create(null) as Record<string, Snapshot>;\n this._belongsToIds = Object.create(null) as Record<string, RecordId>;\n this._hasManyRelationships = Object.create(null) as Record<string, Snapshot[]>;\n this._hasManyIds = Object.create(null) as Record<string, RecordId[]>;\n\n assertPrivateStore(store);\n const hasRecord = !!store._instanceCache.peek(identifier);\n this.modelName = identifier.type;\n this.identifier = identifier;\n\n /*\n If the we do not yet have a record, then we are\n likely a snapshot being provided to a find request, so we\n populate __attributes lazily. Else, to preserve the \"moment\n in time\" in which a snapshot is created, we greedily grab\n the values.\n */\n if (hasRecord) {\n // oxlint-disable-next-line no-unused-expressions\n this._attributes;\n }\n\n this.id = identifier.id;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n this.modelName = identifier.type;\n\n if (hasRecord) {\n const cache = this._store.cache;\n this._changedAttributes = cache.changedAttrs(identifier);\n }\n }\n\n /**\n The underlying record for this snapshot. Can be used to access methods and\n properties defined on the record.\n\n ```js\n const someValue = snapshot.record.someProp;\n ```\n\n @property record\n @public\n */\n get record(): R | null {\n const record = this._store.peekRecord<R>(this.identifier);\n assert(\n `Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`,\n record !== null\n );\n return record;\n }\n\n /** @internal */\n private get _attributes(): Record<keyof R & string, unknown> {\n if (this.__attributes !== null) {\n return this.__attributes;\n }\n const attributes = (this.__attributes = Object.create(null) as Record<string, unknown>);\n const { identifier } = this;\n const cache = this._store.cache;\n\n this.eachAttribute((key: string, meta: LegacyAttributeField) => {\n attributes[key] = cache.getAttr(identifier, key);\n });\n\n return attributes;\n }\n\n get isNew(): boolean {\n const cache = this._store.cache;\n return cache?.isNew(this.identifier) || false;\n }\n\n /**\n Returns the value of an attribute.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attr('author'); // => 'Tomster'\n postSnapshot.attr('title'); // => 'Ember.js rocks'\n ```\n\n Note: Values are loaded eagerly and cached when the snapshot is created.\n\n @return The attribute value or undefined\n @public\n */\n attr(keyName: keyof R & string): unknown {\n if (keyName in this._attributes) {\n return this._attributes[keyName];\n }\n assert(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`, false);\n }\n\n /**\n Returns all attributes and their corresponding values.\n\n ::: warning ⚠️ WARNING\n Attributes are SHALLOW copied from the cache.\n Because they are NOT deep copied from the cache, mutating\n any object or array fields will cause unintended side-effects\n and bugs.\n :::\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }\n ```\n\n @return All attributes of the current snapshot\n @public\n */\n attributes(): Record<keyof R & string, unknown> {\n return { ...this._attributes };\n }\n\n /**\n Returns all changed attributes and their old and new values.\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postModel.set('title', 'Ember.js rocks!');\n postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }\n ```\n\n @return All changed attributes of the current snapshot\n @public\n */\n changedAttributes(): ChangedAttributesHash {\n const changedAttributes = Object.create(null) as ChangedAttributesHash;\n if (!this._changedAttributes) {\n return changedAttributes;\n }\n\n const changedAttributeKeys = Object.keys(this._changedAttributes);\n\n for (let i = 0, length = changedAttributeKeys.length; i < length; i++) {\n const key = changedAttributeKeys[i];\n changedAttributes[key] = this._changedAttributes[key].slice() as [Value | undefined, Value];\n }\n\n return changedAttributes;\n }\n\n /**\n Returns the current value of a belongsTo relationship.\n\n `belongsTo` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `id`: set to `true` if you only want the ID of the related record to be\n returned.\n\n Example\n\n ```js\n // store.push('post', { id: 1, title: 'Hello World' });\n // store.createRecord('comment', { body: 'Lorem ipsum', post: post });\n commentSnapshot.belongsTo('post'); // => Snapshot\n commentSnapshot.belongsTo('post', { id: true }); // => '1'\n\n // store.push('comment', { id: 1, body: 'Lorem ipsum' });\n commentSnapshot.belongsTo('post'); // => undefined\n ```\n\n Calling `belongsTo` will return a new Snapshot as long as there's any known\n data for the relationship available, such as an ID. If the relationship is\n known but unset, `belongsTo` will return `null`. If the contents of the\n relationship is unknown `belongsTo` will return `undefined`.\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return A snapshot or ID of a known relationship or null if the\n relationship is known but unset. undefined will be returned if the\n contents of the relationship are unknown.\n */\n belongsTo(keyName: string, options?: { id?: boolean }): Snapshot | RecordId | undefined {\n const returnModeIsId = !!(options && options.id);\n let result: Snapshot | RecordId | undefined;\n const store = this._store;\n\n if (returnModeIsId === true && keyName in this._belongsToIds) {\n return this._belongsToIds[keyName];\n }\n\n if (returnModeIsId === false && keyName in this._belongsToRelationships) {\n return this._belongsToRelationships[keyName];\n }\n\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'belongsTo'\n );\n\n assert(`snapshot.belongsTo only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a hasMany.`,\n relationship.kind === 'belongsTo'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName);\n const data = value && value.data;\n upgradeStore(store);\n\n const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;\n\n if (value && value.data !== undefined) {\n const cache = store.cache;\n\n if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsId) {\n result = inverseIdentifier.id;\n } else {\n result = store._fetchManager.createSnapshot(inverseIdentifier);\n }\n } else {\n result = null;\n }\n }\n\n if (returnModeIsId) {\n this._belongsToIds[keyName] = result as RecordId;\n } else {\n this._belongsToRelationships[keyName] = result as Snapshot;\n }\n\n return result;\n }\n\n /**\n Returns the current value of a hasMany relationship.\n\n `hasMany` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `ids`: set to `true` if you only want the IDs of the related records to be\n returned.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });\n postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]\n postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']\n\n // store.push('post', { id: 1, title: 'Hello World' });\n postSnapshot.hasMany('comments'); // => undefined\n ```\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return An array of snapshots or IDs of a known\n relationship or an empty array if the relationship is known but unset.\n undefined will be returned if the contents of the relationship is unknown.\n */\n hasMany(keyName: string, options?: { ids?: boolean }): RecordId[] | Snapshot[] | undefined {\n const returnModeIsIds = !!(options && options.ids);\n let results: RecordId[] | Snapshot[] | undefined;\n const cachedIds: RecordId[] | undefined = this._hasManyIds[keyName];\n const cachedSnapshots: Snapshot[] | undefined = this._hasManyRelationships[keyName];\n\n if (returnModeIsIds === true && keyName in this._hasManyIds) {\n return cachedIds;\n }\n\n if (returnModeIsIds === false && keyName in this._hasManyRelationships) {\n return cachedSnapshots;\n }\n\n const store = this._store;\n upgradeStore(store);\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'hasMany'\n );\n\n // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes\n // this check is not a regression in behavior because relationships don't currently\n // function without access to intimate API contracts between RecordData and Model.\n // This is a requirement we should fix as soon as the relationship layer does not require\n // this intimate API usage.\n assert(`snapshot.hasMany only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a belongsTo.`,\n relationship.kind === 'hasMany'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName) as CollectionRelationship;\n\n if (value.data) {\n results = [];\n value.data.forEach((member) => {\n const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);\n const cache = store.cache;\n\n if (!cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsIds) {\n (results as RecordId[]).push(inverseIdentifier.id);\n } else {\n (results as Snapshot[]).push(store._fetchManager.createSnapshot(inverseIdentifier));\n }\n }\n });\n }\n\n // we assign even if `undefined` so that we don't reprocess the relationship\n // on next access. This works with the `keyName in` checks above.\n if (returnModeIsIds) {\n this._hasManyIds[keyName] = results as RecordId[];\n } else {\n this._hasManyRelationships[keyName] = results as Snapshot[];\n }\n\n return results;\n }\n\n /**\n Iterates through all the attributes of the model, calling the passed\n function on each attribute.\n\n Example\n\n ```javascript\n snapshot.eachAttribute(function(name, meta) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate attributes. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachAttribute(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'attribute') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Iterates through all the relationships of the model, calling the passed\n function on each relationship.\n\n Example\n\n ```javascript\n snapshot.eachRelationship(function(name, relationship) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate relationships. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachRelationship(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'belongsTo' || field.kind === 'hasMany') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Serializes the snapshot using the serializer for the model.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default Adapter.extend({\n createRecord(store, type, snapshot) {\n let data = snapshot.serialize({ includeId: true });\n let url = `/${type.modelName}`;\n\n return fetch(url, {\n method: 'POST',\n body: data,\n }).then((response) => response.json())\n }\n });\n ```\n\n @return an object whose values are primitive JSON values only\n @public\n */\n serialize(options?: SerializerOptions): unknown {\n upgradeStore(this._store);\n const serializer = this._store.serializerFor(this.modelName);\n assert(`Cannot serialize record, no serializer found`, serializer);\n return serializer.serialize(this, options);\n }\n}\n","import { warn } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { createDeferred } from '@warp-drive/core/request';\nimport { waitFor } from '@warp-drive/core/signals/-leaked';\nimport type {\n FindRecordQuery,\n InstanceCache,\n PrivateRequestStateService,\n PrivateStore,\n Request,\n SaveRecordMutation,\n} from '@warp-drive/core/store/-private';\nimport { assertPrivateStore, coerceId } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions, ModelSchema } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ImmutableRequestInfo } from '@warp-drive/core/types/request';\nimport type { CollectionResourceDocument, SingleResourceDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../-private.ts';\nimport { assertIdentifierHasId } from './identifier-has-id.ts';\nimport { payloadIsNotBlank } from './legacy-data-utils.ts';\nimport type { AdapterPayload, MinimumAdapterInterface } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface } from './minimum-serializer-interface.ts';\nimport { normalizeResponseHelper } from './serializer-response.ts';\nimport { Snapshot } from './snapshot.ts';\n\ntype Deferred<T> = ReturnType<typeof createDeferred<T>>;\ntype AdapterErrors = Error & { errors?: string[]; isAdapterError?: true };\ntype SerializerWithParseErrors = MinimumSerializerInterface & {\n extractErrors?(store: Store, modelClass: ModelSchema, error: AdapterErrors, recordId: string | null): unknown;\n};\n\nexport const SaveOp: '___(unique) Symbol(SaveOp)' = getOrSetGlobal('SaveOp', Symbol('SaveOp'));\n\nexport type FetchMutationOptions = FindRecordOptions & { [SaveOp]: 'createRecord' | 'deleteRecord' | 'updateRecord' };\n\ninterface PendingFetchItem {\n identifier: PersistedResourceKey;\n queryRequest: Request;\n // oxlint-disable-next-line typescript/no-explicit-any\n resolver: Deferred<any>;\n options: FindRecordOptions;\n trace?: unknown;\n promise: Promise<PersistedResourceKey>;\n}\n\ninterface PendingSaveItem {\n // oxlint-disable-next-line typescript/no-explicit-any\n resolver: Deferred<any>;\n snapshot: Snapshot;\n identifier: ResourceKey;\n options: FetchMutationOptions;\n queryRequest: Request;\n}\n\n/**\n * @private\n */\nexport class FetchManager {\n /**\n * @internal\n */\n declare isDestroyed: boolean;\n /** @internal */\n declare private requestCache: PrivateRequestStateService;\n // fetches pending in the runloop, waiting to be coalesced\n /**\n * @internal\n */\n declare _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n\n /** @internal */\n declare private _store: PrivateStore;\n\n constructor(store: Store) {\n assertPrivateStore(store);\n this._store = store;\n // used to keep track of all the find requests that need to be coalesced\n this._pendingFetch = new Map();\n this.requestCache = store.getRequestStateService();\n this.isDestroyed = false;\n }\n\n createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;\n createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;\n createSnapshot(identifier: ResourceKey, options: FindRecordOptions = {}): Snapshot {\n return new Snapshot(options, identifier, this._store);\n }\n\n /**\n This method is called by `record.save`, and gets passed a\n resolver for the promise that `record.save` returns.\n\n It schedules saving to happen at the end of the run loop.\n\n @private\n */\n scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument> {\n const resolver = createDeferred<SingleResourceDocument | null>();\n const query: SaveRecordMutation = {\n op: 'saveRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const snapshot = this.createSnapshot(identifier, options);\n const pendingSaveItem: PendingSaveItem = {\n snapshot: snapshot,\n resolver: resolver,\n identifier,\n options,\n queryRequest,\n };\n\n const monitored = this.requestCache._enqueue(resolver.promise, pendingSaveItem.queryRequest);\n _flushPendingSave(this._store, pendingSaveItem);\n\n return monitored;\n }\n\n scheduleFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions,\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n const query: FindRecordQuery = {\n op: 'findRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const pendingFetch = this.getPendingFetch(identifier, options);\n if (pendingFetch) {\n return pendingFetch;\n }\n\n const modelName = identifier.type;\n\n const resolver = createDeferred<SingleResourceDocument>();\n const pendingFetchItem: PendingFetchItem = {\n identifier,\n resolver,\n options,\n queryRequest,\n } as PendingFetchItem;\n\n const resolverPromise = resolver.promise;\n const store = this._store;\n const isInitialLoad = !store._instanceCache.recordIsLoaded(identifier); // we don't use isLoading directly because we are the request\n\n const monitored = this.requestCache._enqueue(resolverPromise, pendingFetchItem.queryRequest);\n let promise = monitored.then(\n (payload) => {\n // ensure that regardless of id returned we assign to the correct record\n if (payload.data && !Array.isArray(payload.data)) {\n payload.data.lid = identifier.lid;\n }\n\n // additional data received in the payload\n // may result in the merging of identifiers (and thus records)\n const potentiallyNewIm = store._push(payload, options.reload);\n if (potentiallyNewIm && !Array.isArray(potentiallyNewIm)) {\n return potentiallyNewIm;\n }\n\n return identifier;\n },\n (error) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !store.isDestroyed);\n const cache = store.cache;\n if (!cache || cache.isEmpty(identifier) || isInitialLoad) {\n let isReleasable = true;\n if (store._graph) {\n const graph = store._graph;\n if (!cache) {\n isReleasable = graph.isReleasable(identifier);\n if (!isReleasable) {\n graph.unload(identifier, true);\n }\n }\n }\n if (cache || isReleasable) {\n store._enableAsyncFlush = true;\n store._instanceCache.unloadRecord(identifier);\n store._enableAsyncFlush = null;\n }\n }\n throw error;\n }\n );\n\n if (this._pendingFetch.size === 0) {\n void new Promise((resolve) => setTimeout(resolve, 0)).then(() => {\n this.flushAllPendingFetches();\n });\n }\n\n const fetchesByType = this._pendingFetch;\n let fetchesById = fetchesByType.get(modelName);\n\n if (!fetchesById) {\n fetchesById = new Map();\n fetchesByType.set(modelName, fetchesById);\n }\n\n let requestsForIdentifier = fetchesById.get(identifier);\n if (!requestsForIdentifier) {\n requestsForIdentifier = [];\n fetchesById.set(identifier, requestsForIdentifier);\n }\n\n requestsForIdentifier.push(pendingFetchItem);\n\n if (TESTING) {\n if (!request.disableTestWaiter) {\n promise = waitFor(promise);\n }\n }\n\n pendingFetchItem.promise = promise;\n return promise;\n }\n\n getPendingFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions\n ): Promise<PersistedResourceKey> | undefined {\n const pendingFetches = this._pendingFetch.get(identifier.type)?.get(identifier);\n\n // We already have a pending fetch for this\n if (pendingFetches) {\n const matchingPendingFetch = pendingFetches.find((fetch) => isSameRequest(options, fetch.options));\n if (matchingPendingFetch) {\n return matchingPendingFetch.promise;\n }\n }\n }\n\n flushAllPendingFetches(): void {\n if (this.isDestroyed) {\n return;\n }\n\n const store = this._store;\n this._pendingFetch.forEach((fetchItem, type) => _flushPendingFetchForType(store, fetchItem, type));\n this._pendingFetch.clear();\n }\n\n fetchDataIfNeededForIdentifier(\n identifier: PersistedResourceKey,\n options: FindRecordOptions | undefined = {},\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n // pre-loading will change the isEmpty value\n const isEmpty = _isEmpty(this._store._instanceCache, identifier);\n const isLoading = _isLoading(this._store._instanceCache, identifier);\n\n let promise: Promise<PersistedResourceKey>;\n if (isEmpty) {\n assertIdentifierHasId(identifier);\n\n if (DEBUG) {\n promise = this.scheduleFetch(identifier, Object.assign({}, options, { reload: true }), request);\n } else {\n options.reload = true;\n promise = this.scheduleFetch(identifier, options, request);\n }\n } else if (isLoading) {\n promise = this.getPendingFetch(identifier, options)!;\n assert(`Expected to find a pending request for a record in the loading state, but found none`, promise);\n } else {\n promise = Promise.resolve(identifier);\n }\n\n return promise;\n }\n\n destroy(): void {\n this.isDestroyed = true;\n }\n}\n\n/**\n * This type exists for internal use only for\n * where intimate contracts still exist either for\n * the Test Suite or for Legacy code.\n *\n * @private\n */\nexport interface PrivateFetchManager extends FetchManager {\n _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n}\n\nfunction _isEmpty(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n if (!cache) {\n return true;\n }\n const isNew = cache.isNew(identifier);\n const isDeleted = cache.isDeleted(identifier);\n const isEmpty = cache.isEmpty(identifier);\n\n return (!isNew || isDeleted) && isEmpty;\n}\n\nfunction _isLoading(cache: InstanceCache, identifier: ResourceKey): boolean {\n const req = cache.store.getRequestStateService();\n // const fulfilled = req.getLastRequestForRecord(identifier);\n const isLoaded = cache.recordIsLoaded(identifier);\n\n return (\n !isLoaded &&\n // fulfilled === null &&\n req.getPendingRequestsForRecord(identifier).some((r) => r.type === 'query')\n );\n}\n\nfunction includesSatisfies(current: undefined | string | string[], existing: undefined | string | string[]): boolean {\n // if we have no includes we are good\n if (!current?.length) {\n return true;\n }\n\n // if we are here we have includes,\n // and if existing has no includes then we will need a new request\n if (!existing?.length) {\n return false;\n }\n\n const arrCurrent = (Array.isArray(current) ? current : current.split(',')).sort();\n const arrExisting = (Array.isArray(existing) ? existing : existing.split(',')).sort();\n\n // includes are identical\n if (arrCurrent.join(',') === arrExisting.join(',')) {\n return true;\n }\n\n // if all of current includes are in existing includes then we are good\n // so if we find one that is not in existing then we need a new request\n for (let i = 0; i < arrCurrent.length; i++) {\n if (!arrExisting.includes(arrCurrent[i])) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction optionsSatisfies(current: object | undefined, existing: object | undefined): boolean {\n return !current || current === existing || Object.keys(current).length === 0;\n}\n\n// this function helps resolve whether we have a pending request that we should use instead\nfunction isSameRequest(options: FindRecordOptions = {}, existingOptions: FindRecordOptions = {}) {\n return (\n optionsSatisfies(options.adapterOptions, existingOptions.adapterOptions) &&\n includesSatisfies(options.include, existingOptions.include)\n );\n}\n\nfunction _findMany(\n store: Store,\n adapter: MinimumAdapterInterface,\n modelName: string,\n snapshots: Snapshot[]\n): Promise<CollectionResourceDocument> {\n const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still\n const promise = Promise.resolve().then(() => {\n const ids = snapshots.map((s) => s.id!);\n assert(\n `Cannot fetch a record without an id`,\n ids.every((v) => v !== null)\n );\n // oxlint-disable-next-line typescript/unbound-method\n assert(`Expected this adapter to implement findMany for coalescing`, adapter.findMany);\n const ret = adapter.findMany(store, modelClass, ids, snapshots);\n assert('adapter.findMany returned undefined, this was very likely a mistake', ret !== undefined);\n return ret;\n });\n upgradeStore(store);\n\n return promise.then((adapterPayload) => {\n assert(\n `You made a 'findMany' request for '${modelName}' records with ids '[${snapshots\n .map((s) => s.id!)\n .join(',')}]', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');\n return payload as CollectionResourceDocument;\n });\n}\n\nfunction rejectFetchedItems(fetchMap: Map<Snapshot, PendingFetchItem>, snapshots: Snapshot[], error?: Error) {\n for (let i = 0, l = snapshots.length; i < l; i++) {\n const snapshot = snapshots[i];\n const pair = fetchMap.get(snapshot);\n\n if (pair) {\n pair.resolver.reject(\n error ||\n new Error(\n `Expected: '<${\n snapshot.modelName\n }:${snapshot.id!}>' to be present in the adapter provided payload, but it was not found.`\n )\n );\n }\n }\n}\n\nfunction handleFoundRecords(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n snapshots: Snapshot[],\n coalescedPayload: CollectionResourceDocument\n) {\n /*\n It is possible that the same ID is included multiple times\n via multiple snapshots. This happens when more than one\n options hash was supplied, each of which must be uniquely\n accounted for.\n\n However, since we can't map from response to a specific\n options object, we resolve all snapshots by id with\n the first response we see.\n */\n const snapshotsById = new Map<string, Snapshot[]>();\n for (let i = 0; i < snapshots.length; i++) {\n const id = snapshots[i].id!;\n let snapshotGroup = snapshotsById.get(id);\n if (!snapshotGroup) {\n snapshotGroup = [];\n snapshotsById.set(id, snapshotGroup);\n }\n snapshotGroup.push(snapshots[i]);\n }\n\n const included = Array.isArray(coalescedPayload.included) ? coalescedPayload.included : [];\n\n // resolve found records\n const resources = coalescedPayload.data;\n for (let i = 0, l = resources.length; i < l; i++) {\n const resource = resources[i];\n const snapshotGroup = snapshotsById.get(resource.id);\n snapshotsById.delete(resource.id);\n\n if (!snapshotGroup) {\n // TODO consider whether this should be a deprecation/assertion\n included.push(resource);\n } else {\n snapshotGroup.forEach((snapshot) => {\n const pair = fetchMap.get(snapshot)!;\n const resolver = pair.resolver;\n resolver.resolve({ data: resource });\n });\n }\n }\n\n if (included.length > 0) {\n store._push({ data: null, included }, true);\n }\n\n if (snapshotsById.size === 0) {\n return;\n }\n\n // reject missing records\n const rejected: Snapshot[] = [];\n snapshotsById.forEach((snapshotArray) => {\n rejected.push(...snapshotArray);\n });\n warn(\n 'Ember Data expected to find records with the following ids in the adapter response from findMany but they were missing: [ \"' +\n [...snapshotsById.values()].map((r) => r[0].id).join('\", \"') +\n '\" ]',\n {\n id: 'ds.store.missing-records-from-adapter',\n }\n );\n\n rejectFetchedItems(fetchMap, rejected);\n}\n\nfunction _fetchRecord(store: Store, adapter: MinimumAdapterInterface, fetchItem: PendingFetchItem) {\n upgradeStore(store);\n const identifier = fetchItem.identifier;\n const modelName = identifier.type;\n\n assert(`You tried to find a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`,\n typeof adapter.findRecord === 'function'\n );\n\n const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);\n const klass = store.modelFor(identifier.type);\n const id = identifier.id;\n\n let promise = Promise.resolve().then(() => {\n return adapter.findRecord(store, klass, identifier.id, snapshot);\n });\n\n promise = promise.then((adapterPayload) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !(store.isDestroyed || store.isDestroying));\n assert(\n `You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');\n assert(\n `Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`,\n !Array.isArray(payload.data)\n );\n assert(\n `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.`,\n 'data' in payload && payload.data !== null && typeof payload.data === 'object'\n );\n\n warn(\n `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.`,\n coerceId(payload.data.id) === coerceId(id),\n {\n id: 'ds.store.findRecord.id-mismatch',\n }\n );\n\n return payload;\n });\n\n fetchItem.resolver.resolve(promise);\n}\n\nfunction _processCoalescedGroup(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n group: Snapshot[],\n adapter: MinimumAdapterInterface,\n modelName: string\n) {\n if (group.length > 1) {\n _findMany(store, adapter, modelName, group)\n .then((payloads: CollectionResourceDocument) => {\n handleFoundRecords(store, fetchMap, group, payloads);\n })\n .catch((error: Error) => {\n rejectFetchedItems(fetchMap, group, error);\n });\n } else if (group.length === 1) {\n _fetchRecord(store, adapter, fetchMap.get(group[0])!);\n } else {\n assert(\"You cannot return an empty array from adapter's method groupRecordsForFindMany\", false);\n }\n}\n\nfunction _flushPendingFetchForType(\n store: Store,\n pendingFetchMap: Map<PersistedResourceKey, PendingFetchItem[]>,\n modelName: string\n) {\n upgradeStore(store);\n const adapter = store.adapterFor(modelName);\n const shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;\n\n if (shouldCoalesce) {\n const pendingFetchItems: PendingFetchItem[] = [];\n pendingFetchMap.forEach((requestsForIdentifier, identifier) => {\n if (requestsForIdentifier.length > 1) {\n return;\n }\n\n // remove this entry from the map so it's not processed again\n pendingFetchMap.delete(identifier);\n pendingFetchItems.push(requestsForIdentifier[0]);\n });\n\n const totalItems = pendingFetchItems.length;\n\n if (totalItems > 1) {\n const snapshots = new Array<Snapshot>(totalItems);\n const fetchMap = new Map<Snapshot, PendingFetchItem>();\n for (let i = 0; i < totalItems; i++) {\n const fetchItem = pendingFetchItems[i];\n snapshots[i] = store._fetchManager.createSnapshot(fetchItem.identifier, fetchItem.options);\n fetchMap.set(snapshots[i], fetchItem);\n }\n\n let groups: Snapshot[][];\n if (adapter.groupRecordsForFindMany) {\n groups = adapter.groupRecordsForFindMany(store, snapshots);\n } else {\n groups = [snapshots];\n }\n\n for (let i = 0, l = groups.length; i < l; i++) {\n _processCoalescedGroup(store, fetchMap, groups[i], adapter, modelName);\n }\n } else if (totalItems === 1) {\n _fetchRecord(store, adapter, pendingFetchItems[0]);\n }\n }\n\n pendingFetchMap.forEach((pendingFetchItems) => {\n pendingFetchItems.forEach((pendingFetchItem) => {\n _fetchRecord(store, adapter, pendingFetchItem);\n });\n });\n}\n\nfunction _flushPendingSave(store: Store, pending: PendingSaveItem) {\n const { snapshot, resolver, identifier, options } = pending;\n upgradeStore(store);\n const adapter = store.adapterFor(identifier.type);\n const operation = options[SaveOp];\n\n const modelName = snapshot.modelName;\n const modelClass = store.modelFor(modelName);\n\n assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`,\n typeof adapter[operation] === 'function'\n );\n\n let promise: Promise<AdapterPayload> = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));\n const serializer: SerializerWithParseErrors | null = store.serializerFor(modelName);\n\n assert(\n `Your adapter's '${operation}' method must return a value, but it returned 'undefined'`,\n promise !== undefined\n );\n\n promise = promise.then((adapterPayload) => {\n if (adapterPayload) {\n return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);\n }\n }) as Promise<AdapterPayload>;\n\n resolver.resolve(promise);\n}\n","import type { Store } from '@warp-drive/core';\n\nimport type { CompatStore } from '../compat.ts';\n\n/**\n * Utilities - often temporary - for maintaining backwards compatibility with\n * older parts of WarpDrive.\n *\n @module\n*/\nexport { SnapshotRecordArray } from './legacy-network-handler/snapshot-record-array.ts';\nexport { SaveOp } from './legacy-network-handler/fetch-manager.ts';\nexport { FetchManager } from './legacy-network-handler/fetch-manager.ts';\nexport { Snapshot } from './legacy-network-handler/snapshot.ts';\n\nexport function upgradeStore(store: Store): asserts store is CompatStore {}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAaE,sBAAb,MAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE/BC,YAAYC,OAAcC,MAAcC,UAA0B,CAAC,GAAG;EACpE,KAAKC,UAAUH;EACf,KAAKI,aAAa;EAClB,KAAKC,YAAYJ;EACjB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AAAD,gBAAA,CAAA,CAAAiD,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,6DAA6DpB,UAAS,EAAG;CAAA,EAAA,CAAEmF,OAAO;CACzFnH,eAAAD,gBAAA,CAAA,CAAAiD,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,sDAAsDpB,UAAS,wBAAyBqI,UAAS,EAAG;CAAA,EAAA,CACpG,OAAOlD,QAAQkD,eAAe,UAAU;CAG1C,IAAI3I,UAAmCoC,QAAQC,QAAQ,CAAC,CAACxB,WAAW4E,QAAQkD,UAAU,CAAChK,OAAOgH,YAAY/F,QAAQ,CAAC;CACnH,MAAM2G,aAA+C5H,MAAM6H,cAAclG,SAAS;CAElFhC,eAAAD,gBAAA,CAAA,CAAAiD,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mBAAmBiH,UAAS,0DAA2D;CAAA,EAAA,CACvF3I,YAAYqG,MAAS;CAGvBrG,UAAUA,QAAQa,MAAMyF,mBAAmB;EACzC,IAAIA,gBACF,OAAOnI,wBAAwBoI,YAAY5H,OAAOgH,YAAYW,gBAAgB1G,SAASoG,IAAI2C,SAAS;CAExG,CAAC;CAEDrJ,SAAS+C,QAAQrC,OAAO;AAC1B;;;;AC/nBA,SAAgB,aAAa,OAA4C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":["getOrSetGlobal","macroCondition","getGlobalConfig","_AdapterError","errors","message","isAdapterError","error","Error","call","stack","description","fileName","lineNumber","name","number","title","detail","prototype","Object","create","code","extend","extendFn","AdapterError","ErrorClass","defaultMessage","ParentErrorClass","WarpDrive","env","DEBUG","test","Array","isArray","InvalidError","TimeoutError","AbortError","UnauthorizedError","ForbiddenError","NotFoundError","ConflictError","ServerError"],"sources":["../../src/adapter/error.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { RequestManager } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ApiError } from '@warp-drive/core/types/spec/error';\n\nfunction _AdapterError(this: AdapterRequestError, errors: ApiError[], message = 'Adapter operation failed') {\n this.isAdapterError = true;\n const error = Error.call(this, message);\n\n if (error) {\n this.stack = error.stack;\n // @ts-expect-error untyped\n this.description = error.description;\n // @ts-expect-error untyped\n this.fileName = error.fileName;\n // @ts-expect-error untyped\n this.lineNumber = error.lineNumber;\n this.message = error.message;\n this.name = error.name;\n // @ts-expect-error untyped\n this.number = error.number;\n }\n\n this.errors = errors || [\n {\n title: 'Adapter Error',\n detail: message,\n },\n ];\n}\n\n/**\n * The shape of the errors thrown/returned by {@link AdapterError} and its subclasses.\n */\nexport interface AdapterRequestError<T extends string = string> extends Error {\n /**\n * A property signifying that an Error uses the {@link AdapterRequestError} interface.\n */\n isAdapterError: true;\n /**\n * A short code identifying the kind of error, e.g. `'NotFoundError'`.\n */\n code: T;\n /**\n * The {json:api} formatted errors associated with the request.\n */\n errors: ApiError[];\n}\n/**\n * The static interface shared by {@link AdapterError} and its subclasses,\n * allowing further subclassing via {@link AdapterRequestErrorConstructor.extend | extend}.\n */\nexport interface AdapterRequestErrorConstructor<Instance extends AdapterRequestError = AdapterRequestError> {\n new (errors?: unknown[], message?: string): Instance;\n /**\n * Creates a new {@link AdapterRequestErrorConstructor} that inherits from this one.\n */\n extend(options: { message: string }): AdapterRequestErrorConstructor;\n}\n\n_AdapterError.prototype = Object.create(Error.prototype);\n\n_AdapterError.prototype.code = 'AdapterError';\n_AdapterError.extend = extendFn(_AdapterError as unknown as AdapterRequestErrorConstructor);\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AdapterError} constructor.\n */\nexport type AdapterError = AdapterRequestError<'AdapterError'>;\n/**\n * :::danger\n * ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n * If starting a new app or thinking of implementing a new adapter, consider writing a\n * {@link Handler} instead to be used with the {@link RequestManager}\n * :::\n *\n * An `AdapterError` is used by an adapter to signal that an error occurred\n * during a request to an external API. It indicates a generic error, and\n * subclasses are used to indicate specific error states.\n *\n * To create a custom error to signal a specific error state in communicating\n * with an external API, extend the `AdapterError`. For example, if the\n * external API exclusively used HTTP `503 Service Unavailable` to indicate\n * it was closed for maintenance:\n *\n * ```js [app/adapters/maintenance-error.js]\n * import AdapterError from '@warp-drive/legacy/adapter/error';\n *\n * export default AdapterError.extend({ message: \"Down for maintenance.\" });\n * ```\n *\n * This error would then be returned by an adapter's `handleResponse` method:\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n * import MaintenanceError from './maintenance-error';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status) {\n * if (503 === status) {\n * return new MaintenanceError();\n * }\n *\n * return super.handleResponse(...arguments);\n * }\n * }\n * ```\n *\n * And can then be detected in an application and used to send the user to an\n * `under-maintenance` route:\n *\n * ```js [app/routes/application.js]\n * import MaintenanceError from '../adapters/maintenance-error';\n *\n * export default class ApplicationRoute extends Route {\n * actions: {\n * error(error, transition) {\n * if (error instanceof MaintenanceError) {\n * this.transitionTo('under-maintenance');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * }\n * ```\n *\n * ### Signaling an Error Without Extending `AdapterError`\n *\n * Extending `AdapterError` (or one of its subclasses) is a convenience, not\n * a requirement. WarpDrive only inspects an error for the {@link AdapterRequestError}\n * shape: an `isAdapterError` flag, a `code`, and an {json:api}-formatted\n * `errors` array. Any object satisfying that shape — including a plain\n * `Error` with those properties attached — will be handled identically to\n * an instance created via `new AdapterError()` or one of its subclasses.\n *\n * This is useful when you'd rather not introduce a class hierarchy, or\n * when the error needs to be constructed from data you don't control\n * (for example, re-throwing an error surfaced by a third-party library):\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status, headers, payload) {\n * if (status === 503) {\n * const error = new Error('Down for maintenance.');\n * error.isAdapterError = true;\n * error.code = 'MaintenanceError';\n * error.errors = [{ title: 'Service Unavailable', detail: 'Down for maintenance.' }];\n * return error;\n * }\n *\n * return super.handleResponse(status, headers, payload);\n * }\n * }\n * ```\n *\n * Because `code` is just a string you control, `error instanceof AdapterError`\n * checks won't match a plain object built this way — consumers should\n * instead branch on `error.isAdapterError && error.code === 'MaintenanceError'`,\n * or on whichever of the {@link AdapterError} subclasses' `code` values\n * (e.g. `'InvalidError'`, `'NotFoundError'`) the error's `code` matches.\n *\n * @public\n */\nexport const AdapterError: AdapterRequestErrorConstructor<AdapterError> = getOrSetGlobal(\n 'AdapterError',\n _AdapterError as unknown as AdapterRequestErrorConstructor<AdapterError>\n);\ntype ErrorExtender = (opts: { message?: string }) => AdapterRequestErrorConstructor;\nfunction extendFn(ErrorClass: AdapterRequestErrorConstructor): ErrorExtender {\n return function ({ message: defaultMessage }: { message?: string } = {}) {\n return extend(ErrorClass, defaultMessage);\n };\n}\n\nfunction extend<Final extends AdapterRequestError>(\n ParentErrorClass: AdapterRequestErrorConstructor,\n defaultMessage?: string\n): AdapterRequestErrorConstructor<Final> {\n const ErrorClass = function (this: AdapterRequestError, errors: ApiError[], message?: string) {\n assert('`AdapterError` expects json-api formatted errors array.', Array.isArray(errors || []));\n ParentErrorClass.call(this, errors, message || defaultMessage);\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n ErrorClass.prototype = Object.create(ParentErrorClass.prototype);\n ErrorClass.extend = extendFn(ErrorClass as unknown as AdapterRequestErrorConstructor);\n\n return ErrorClass as unknown as AdapterRequestErrorConstructor<Final>;\n}\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link InvalidError} constructor.\n */\n// TODO @deprecate extractError documentation\nexport type InvalidError = AdapterRequestError<'InvalidError'>;\n/**\n * An `InvalidError` is used by an adapter to signal that the external API\n * was unable to process a request because the content was not semantically\n * correct or meaningful per the API. Usually, this means a record failed\n * some form of server-side validation. When a promise from an adapter is\n * rejected with an `InvalidError` the record will transition to the\n * `invalid` state and the errors will be set to the `errors` property on\n * the record.\n *\n * For WarpDrive to correctly map errors to their corresponding properties\n * on the model, WarpDrive expects each error to be a valid {json:api} error\n * object with a `source.pointer` that matches the property name. For\n * example, if you had a `Post` model that looked like this:\n *\n * ```js [app/models/post.js]\n * import { Model, attr } from '@warp-drive/legacy/model';\n *\n * export default class PostModel extends Model {\n * @attr('string') title;\n * @attr('string') content;\n * }\n * ```\n *\n * To show an error from the server related to the `title` and `content`\n * properties your adapter could return a promise that rejects with an\n * `InvalidError` that looks like this:\n *\n * ```js [app/adapters/post.js]\n * import RSVP from 'RSVP';\n * import RESTAdapter from '@warp-drive/legacy/adapter/rest';\n * import { InvalidError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationAdapter extends RESTAdapter {\n * updateRecord() {\n * // Fictional adapter that always rejects\n * return RSVP.reject(new InvalidError([\n * {\n * detail: 'Must be unique',\n * source: { pointer: '/data/attributes/title' }\n * },\n * {\n * detail: 'Must not be blank',\n * source: { pointer: '/data/attributes/content' }\n * }\n * ]));\n * }\n * }\n * ```\n *\n * Your backend may use different property names for your records; the\n * store will attempt to extract and normalize the errors using the\n * serializer's `extractErrors` method before the errors get added to the\n * model. As a result, it is safe for the `InvalidError` to wrap the error\n * payload unaltered.\n *\n * @public\n */\nexport const InvalidError: AdapterRequestErrorConstructor<InvalidError> = getOrSetGlobal(\n 'InvalidError',\n extend<InvalidError>(AdapterError, 'The adapter rejected the commit because it was invalid')\n);\nInvalidError.prototype.code = 'InvalidError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link TimeoutError} constructor.\n */\nexport type TimeoutError = AdapterRequestError<'TimeoutError'>;\n/**\n * A `TimeoutError` is used by an adapter to signal that a request to the\n * external API has timed out, i.e. no response was received from the\n * external API within an allowed time period.\n *\n * An example use case would be to warn the user to check their internet\n * connection if an adapter operation has timed out:\n *\n * ```js [app/routes/application.js]\n * import { TimeoutError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof TimeoutError) {\n * // alert the user\n * alert('Are you still connected to the Internet?');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const TimeoutError: AdapterRequestErrorConstructor<TimeoutError> = getOrSetGlobal(\n 'TimeoutError',\n extend(AdapterError, 'The adapter operation timed out')\n);\nTimeoutError.prototype.code = 'TimeoutError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AbortError} constructor.\n */\nexport type AbortError = AdapterRequestError<'AbortError'>;\n/**\n * An `AbortError` is used by an adapter to signal that a request to the\n * external API was aborted. For example, this can occur if the user\n * navigates away from the current page after a request to the external API\n * has been initiated but before a response has been received.\n *\n * Because an aborted request is typically expected (the user chose to\n * navigate away, or a newer request superseded this one) rather than\n * exceptional, an example use case would be to silently ignore it instead\n * of surfacing an error to the user:\n *\n * ```js [app/routes/application.js]\n * import { AbortError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof AbortError) {\n * // the request was aborted, nothing to report\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const AbortError: AdapterRequestErrorConstructor<AbortError> = getOrSetGlobal(\n 'AbortError',\n extend(AdapterError, 'The adapter operation was aborted')\n);\nAbortError.prototype.code = 'AbortError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link UnauthorizedError} constructor.\n */\nexport type UnauthorizedError = AdapterRequestError<'UnauthorizedError'>;\n/**\n * A `UnauthorizedError` equates to an HTTP `401 Unauthorized` response\n * status. It is used by an adapter to signal that a request to the external\n * API was rejected because authorization is required and has failed or has\n * not yet been provided.\n *\n * An example use case would be to redirect the user to a login route if a\n * request is unauthorized:\n *\n * ```js [app/routes/application.js]\n * import { UnauthorizedError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof UnauthorizedError) {\n * // go to the login route\n * this.transitionTo('login');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const UnauthorizedError: AdapterRequestErrorConstructor<UnauthorizedError> = getOrSetGlobal(\n 'UnauthorizedError',\n extend(AdapterError, 'The adapter operation is unauthorized')\n);\nUnauthorizedError.prototype.code = 'UnauthorizedError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ForbiddenError} constructor.\n */\nexport type ForbiddenError = AdapterRequestError<'ForbiddenError'>;\n/**\n * A `ForbiddenError` equates to an HTTP `403 Forbidden` response status.\n * It is used by an adapter to signal that a request to the external API was\n * valid but the server is refusing to respond to it. If authorization was\n * provided and is valid, then the authenticated user does not have the\n * necessary permissions for the request.\n *\n * Unlike an {@link UnauthorizedError}, retrying the request with different\n * credentials will not help; the currently authenticated user simply lacks\n * permission. An example use case would be to show the user a \"you don't\n * have access to this\" message rather than redirecting them to log in:\n *\n * ```js [app/routes/application.js]\n * import { ForbiddenError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ForbiddenError) {\n * this.transitionTo('forbidden');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ForbiddenError: AdapterRequestErrorConstructor<ForbiddenError> = getOrSetGlobal(\n 'ForbiddenError',\n extend(AdapterError, 'The adapter operation is forbidden')\n);\nForbiddenError.prototype.code = 'ForbiddenError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link NotFoundError} constructor.\n */\nexport type NotFoundError = AdapterRequestError<'NotFoundError'>;\n/**\n * A `NotFoundError` equates to an HTTP `404 Not Found` response status.\n * It is used by an adapter to signal that a request to the external API\n * was rejected because the resource could not be found on the API.\n *\n * An example use case would be to detect if the user has entered a route\n * for a specific model that does not exist. For example:\n *\n * ```js [app/routes/post.js]\n * import { NotFoundError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class PostRoute extends Route {\n * @service store;\n * model(params) {\n * return this.store.findRecord('post', params.post_id);\n * }\n * @action\n * error(error, transition) {\n * if (error instanceof NotFoundError) {\n * // redirect to a list of all posts instead\n * this.transitionTo('posts');\n * } else {\n * // otherwise let the error bubble\n * return true;\n * }\n * }\n * }\n * ```\n *\n * @public\n */\nexport const NotFoundError: AdapterRequestErrorConstructor<NotFoundError> = getOrSetGlobal(\n 'NotFoundError',\n extend(AdapterError, 'The adapter could not find the resource')\n);\nNotFoundError.prototype.code = 'NotFoundError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ConflictError} constructor.\n */\nexport type ConflictError = AdapterRequestError<'ConflictError'>;\n/**\n * A `ConflictError` equates to an HTTP `409 Conflict` response status.\n * It is used by an adapter to indicate that the request could not be\n * processed because of a conflict in the request. An example scenario\n * would be when creating a record with a client-generated ID but that ID\n * is already known to the external API.\n *\n * An example use case would be to surface a conflict-specific message so\n * the user can retry with different input:\n *\n * ```js [app/routes/application.js]\n * import { ConflictError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ConflictError) {\n * alert('That identifier is already in use, please choose another.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ConflictError: AdapterRequestErrorConstructor<ConflictError> = getOrSetGlobal(\n 'ConflictError',\n extend(AdapterError, 'The adapter operation failed due to a conflict')\n);\nConflictError.prototype.code = 'ConflictError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ServerError} constructor.\n */\nexport type ServerError = AdapterRequestError<'ServerError'>;\n/**\n * A `ServerError` equates to an HTTP `500 Internal Server Error` response\n * status. It is used by the adapter to indicate that a request has failed\n * because of an error in the external API, and is unlikely to succeed if\n * retried immediately.\n *\n * An example use case would be to show a generic \"something went wrong on\n * our end\" message rather than one implying the user made a mistake:\n *\n * ```js [app/routes/application.js]\n * import { ServerError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ServerError) {\n * alert('Something went wrong on our end. Please try again later.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ServerError: AdapterRequestErrorConstructor<ServerError> = getOrSetGlobal(\n 'ServerError',\n extend(AdapterError, 'The adapter operation failed due to a server error')\n);\nServerError.prototype.code = 'ServerError';\n"],"mappings":";;;;AAUA,SAASG,cAAyCC,QAAoBC,UAAU,4BAA4B;CAC1G,KAAKC,iBAAiB;CACtB,MAAMC,QAAQC,MAAMC,KAAK,MAAMJ,OAAO;CAEtC,IAAIE,OAAO;EACT,KAAKG,QAAQH,MAAMG;EAEnB,KAAKC,cAAcJ,MAAMI;EAEzB,KAAKC,WAAWL,MAAMK;EAEtB,KAAKC,aAAaN,MAAMM;EACxB,KAAKR,UAAUE,MAAMF;EACrB,KAAKS,OAAOP,MAAMO;EAElB,KAAKC,SAASR,MAAMQ;CACtB;CAEA,KAAKX,SAASA,UAAU,CACtB;EACEY,OAAO;EACPC,QAAQZ;CACV,CAAC;AAEL;;;;;;;;AA+BAF,cAAce,YAAYC,OAAOC,OAAOZ,MAAMU,SAAS;AAEvDf,cAAce,UAAUG,OAAO;AAC/BlB,cAAcmB,SAASC,SAASpB,aAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AaiB,iBAAiEtC,eAC5E,kBACAsB,OAAOE,cAAc,oCAAoC,CAC3D;AACAc,eAAepB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqChC,MAAakB,gBAA+DvC,eAC1E,iBACAsB,OAAOE,cAAc,yCAAyC,CAChE;AACAe,cAAcrB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC/B,MAAamB,gBAA+DxC,eAC1E,iBACAsB,OAAOE,cAAc,gDAAgD,CACvE;AACAgB,cAActB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC/B,MAAaoB,cAA2DzC,eACtE,eACAsB,OAAOE,cAAc,oDAAoD,CAC3E;AACAiB,YAAYvB,UAAUG,OAAO"}
1
+ {"version":3,"file":"error.js","names":["getOrSetGlobal","macroCondition","getGlobalConfig","_AdapterError","errors","message","isAdapterError","error","Error","call","stack","description","fileName","lineNumber","name","number","title","detail","prototype","Object","create","code","extend","extendFn","AdapterError","ErrorClass","defaultMessage","ParentErrorClass","WarpDrive","env","DEBUG","test","Array","isArray","InvalidError","TimeoutError","AbortError","UnauthorizedError","ForbiddenError","NotFoundError","ConflictError","ServerError"],"sources":["../../src/adapter/error.ts"],"sourcesContent":["/* oxlint-disable typescript/no-unsafe-assignment */\n/* oxlint-disable typescript/no-unsafe-member-access */\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// oxlint-disable-next-line no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ApiError } from '@warp-drive/core/types/spec/error';\n\nfunction _AdapterError(this: AdapterRequestError, errors: ApiError[], message = 'Adapter operation failed') {\n this.isAdapterError = true;\n const error = Error.call(this, message);\n\n if (error) {\n this.stack = error.stack;\n // @ts-expect-error untyped\n this.description = error.description;\n // @ts-expect-error untyped\n this.fileName = error.fileName;\n // @ts-expect-error untyped\n this.lineNumber = error.lineNumber;\n this.message = error.message;\n this.name = error.name;\n // @ts-expect-error untyped\n this.number = error.number;\n }\n\n this.errors = errors || [\n {\n title: 'Adapter Error',\n detail: message,\n },\n ];\n}\n\n/**\n * The shape of the errors thrown/returned by {@link AdapterError} and its subclasses.\n */\nexport interface AdapterRequestError<T extends string = string> extends Error {\n /**\n * A property signifying that an Error uses the {@link AdapterRequestError} interface.\n */\n isAdapterError: true;\n /**\n * A short code identifying the kind of error, e.g. `'NotFoundError'`.\n */\n code: T;\n /**\n * The {json:api} formatted errors associated with the request.\n */\n errors: ApiError[];\n}\n/**\n * The static interface shared by {@link AdapterError} and its subclasses,\n * allowing further subclassing via {@link AdapterRequestErrorConstructor.extend | extend}.\n */\nexport interface AdapterRequestErrorConstructor<Instance extends AdapterRequestError = AdapterRequestError> {\n new (errors?: unknown[], message?: string): Instance;\n /**\n * Creates a new {@link AdapterRequestErrorConstructor} that inherits from this one.\n */\n extend(options: { message: string }): AdapterRequestErrorConstructor;\n}\n\n_AdapterError.prototype = Object.create(Error.prototype);\n\n_AdapterError.prototype.code = 'AdapterError';\n_AdapterError.extend = extendFn(_AdapterError as unknown as AdapterRequestErrorConstructor);\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AdapterError} constructor.\n */\nexport type AdapterError = AdapterRequestError<'AdapterError'>;\n/**\n * :::danger\n * ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n * If starting a new app or thinking of implementing a new adapter, consider writing a\n * {@link Handler} instead to be used with the {@link RequestManager}\n * :::\n *\n * An `AdapterError` is used by an adapter to signal that an error occurred\n * during a request to an external API. It indicates a generic error, and\n * subclasses are used to indicate specific error states.\n *\n * To create a custom error to signal a specific error state in communicating\n * with an external API, extend the `AdapterError`. For example, if the\n * external API exclusively used HTTP `503 Service Unavailable` to indicate\n * it was closed for maintenance:\n *\n * ```js [app/adapters/maintenance-error.js]\n * import AdapterError from '@warp-drive/legacy/adapter/error';\n *\n * export default AdapterError.extend({ message: \"Down for maintenance.\" });\n * ```\n *\n * This error would then be returned by an adapter's `handleResponse` method:\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n * import MaintenanceError from './maintenance-error';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status) {\n * if (503 === status) {\n * return new MaintenanceError();\n * }\n *\n * return super.handleResponse(...arguments);\n * }\n * }\n * ```\n *\n * And can then be detected in an application and used to send the user to an\n * `under-maintenance` route:\n *\n * ```js [app/routes/application.js]\n * import MaintenanceError from '../adapters/maintenance-error';\n *\n * export default class ApplicationRoute extends Route {\n * actions: {\n * error(error, transition) {\n * if (error instanceof MaintenanceError) {\n * this.transitionTo('under-maintenance');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * }\n * ```\n *\n * ### Signaling an Error Without Extending `AdapterError`\n *\n * Extending `AdapterError` (or one of its subclasses) is a convenience, not\n * a requirement. WarpDrive only inspects an error for the {@link AdapterRequestError}\n * shape: an `isAdapterError` flag, a `code`, and an {json:api}-formatted\n * `errors` array. Any object satisfying that shape — including a plain\n * `Error` with those properties attached — will be handled identically to\n * an instance created via `new AdapterError()` or one of its subclasses.\n *\n * This is useful when you'd rather not introduce a class hierarchy, or\n * when the error needs to be constructed from data you don't control\n * (for example, re-throwing an error surfaced by a third-party library):\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status, headers, payload) {\n * if (status === 503) {\n * const error = new Error('Down for maintenance.');\n * error.isAdapterError = true;\n * error.code = 'MaintenanceError';\n * error.errors = [{ title: 'Service Unavailable', detail: 'Down for maintenance.' }];\n * return error;\n * }\n *\n * return super.handleResponse(status, headers, payload);\n * }\n * }\n * ```\n *\n * Because `code` is just a string you control, `error instanceof AdapterError`\n * checks won't match a plain object built this way — consumers should\n * instead branch on `error.isAdapterError && error.code === 'MaintenanceError'`,\n * or on whichever of the {@link AdapterError} subclasses' `code` values\n * (e.g. `'InvalidError'`, `'NotFoundError'`) the error's `code` matches.\n *\n * @public\n */\nexport const AdapterError: AdapterRequestErrorConstructor<AdapterError> = getOrSetGlobal(\n 'AdapterError',\n _AdapterError as unknown as AdapterRequestErrorConstructor<AdapterError>\n);\ntype ErrorExtender = (opts: { message?: string }) => AdapterRequestErrorConstructor;\nfunction extendFn(ErrorClass: AdapterRequestErrorConstructor): ErrorExtender {\n return function ({ message: defaultMessage }: { message?: string } = {}) {\n return extend(ErrorClass, defaultMessage);\n };\n}\n\nfunction extend<Final extends AdapterRequestError>(\n ParentErrorClass: AdapterRequestErrorConstructor,\n defaultMessage?: string\n): AdapterRequestErrorConstructor<Final> {\n const ErrorClass = function (this: AdapterRequestError, errors: ApiError[], message?: string) {\n assert('`AdapterError` expects json-api formatted errors array.', Array.isArray(errors || []));\n ParentErrorClass.call(this, errors, message || defaultMessage);\n };\n // oxlint-disable-next-line typescript/no-unsafe-argument\n ErrorClass.prototype = Object.create(ParentErrorClass.prototype);\n ErrorClass.extend = extendFn(ErrorClass as unknown as AdapterRequestErrorConstructor);\n\n return ErrorClass as unknown as AdapterRequestErrorConstructor<Final>;\n}\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link InvalidError} constructor.\n */\n// TODO @deprecate extractError documentation\nexport type InvalidError = AdapterRequestError<'InvalidError'>;\n/**\n * An `InvalidError` is used by an adapter to signal that the external API\n * was unable to process a request because the content was not semantically\n * correct or meaningful per the API. Usually, this means a record failed\n * some form of server-side validation. When a promise from an adapter is\n * rejected with an `InvalidError` the record will transition to the\n * `invalid` state and the errors will be set to the `errors` property on\n * the record.\n *\n * For WarpDrive to correctly map errors to their corresponding properties\n * on the model, WarpDrive expects each error to be a valid {json:api} error\n * object with a `source.pointer` that matches the property name. For\n * example, if you had a `Post` model that looked like this:\n *\n * ```js [app/models/post.js]\n * import { Model, attr } from '@warp-drive/legacy/model';\n *\n * export default class PostModel extends Model {\n * @attr('string') title;\n * @attr('string') content;\n * }\n * ```\n *\n * To show an error from the server related to the `title` and `content`\n * properties your adapter could return a promise that rejects with an\n * `InvalidError` that looks like this:\n *\n * ```js [app/adapters/post.js]\n * import RSVP from 'RSVP';\n * import RESTAdapter from '@warp-drive/legacy/adapter/rest';\n * import { InvalidError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationAdapter extends RESTAdapter {\n * updateRecord() {\n * // Fictional adapter that always rejects\n * return RSVP.reject(new InvalidError([\n * {\n * detail: 'Must be unique',\n * source: { pointer: '/data/attributes/title' }\n * },\n * {\n * detail: 'Must not be blank',\n * source: { pointer: '/data/attributes/content' }\n * }\n * ]));\n * }\n * }\n * ```\n *\n * Your backend may use different property names for your records; the\n * store will attempt to extract and normalize the errors using the\n * serializer's `extractErrors` method before the errors get added to the\n * model. As a result, it is safe for the `InvalidError` to wrap the error\n * payload unaltered.\n *\n * @public\n */\nexport const InvalidError: AdapterRequestErrorConstructor<InvalidError> = getOrSetGlobal(\n 'InvalidError',\n extend<InvalidError>(AdapterError, 'The adapter rejected the commit because it was invalid')\n);\nInvalidError.prototype.code = 'InvalidError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link TimeoutError} constructor.\n */\nexport type TimeoutError = AdapterRequestError<'TimeoutError'>;\n/**\n * A `TimeoutError` is used by an adapter to signal that a request to the\n * external API has timed out, i.e. no response was received from the\n * external API within an allowed time period.\n *\n * An example use case would be to warn the user to check their internet\n * connection if an adapter operation has timed out:\n *\n * ```js [app/routes/application.js]\n * import { TimeoutError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof TimeoutError) {\n * // alert the user\n * alert('Are you still connected to the Internet?');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const TimeoutError: AdapterRequestErrorConstructor<TimeoutError> = getOrSetGlobal(\n 'TimeoutError',\n extend(AdapterError, 'The adapter operation timed out')\n);\nTimeoutError.prototype.code = 'TimeoutError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AbortError} constructor.\n */\nexport type AbortError = AdapterRequestError<'AbortError'>;\n/**\n * An `AbortError` is used by an adapter to signal that a request to the\n * external API was aborted. For example, this can occur if the user\n * navigates away from the current page after a request to the external API\n * has been initiated but before a response has been received.\n *\n * Because an aborted request is typically expected (the user chose to\n * navigate away, or a newer request superseded this one) rather than\n * exceptional, an example use case would be to silently ignore it instead\n * of surfacing an error to the user:\n *\n * ```js [app/routes/application.js]\n * import { AbortError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof AbortError) {\n * // the request was aborted, nothing to report\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const AbortError: AdapterRequestErrorConstructor<AbortError> = getOrSetGlobal(\n 'AbortError',\n extend(AdapterError, 'The adapter operation was aborted')\n);\nAbortError.prototype.code = 'AbortError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link UnauthorizedError} constructor.\n */\nexport type UnauthorizedError = AdapterRequestError<'UnauthorizedError'>;\n/**\n * A `UnauthorizedError` equates to an HTTP `401 Unauthorized` response\n * status. It is used by an adapter to signal that a request to the external\n * API was rejected because authorization is required and has failed or has\n * not yet been provided.\n *\n * An example use case would be to redirect the user to a login route if a\n * request is unauthorized:\n *\n * ```js [app/routes/application.js]\n * import { UnauthorizedError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof UnauthorizedError) {\n * // go to the login route\n * this.transitionTo('login');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const UnauthorizedError: AdapterRequestErrorConstructor<UnauthorizedError> = getOrSetGlobal(\n 'UnauthorizedError',\n extend(AdapterError, 'The adapter operation is unauthorized')\n);\nUnauthorizedError.prototype.code = 'UnauthorizedError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ForbiddenError} constructor.\n */\nexport type ForbiddenError = AdapterRequestError<'ForbiddenError'>;\n/**\n * A `ForbiddenError` equates to an HTTP `403 Forbidden` response status.\n * It is used by an adapter to signal that a request to the external API was\n * valid but the server is refusing to respond to it. If authorization was\n * provided and is valid, then the authenticated user does not have the\n * necessary permissions for the request.\n *\n * Unlike an {@link UnauthorizedError}, retrying the request with different\n * credentials will not help; the currently authenticated user simply lacks\n * permission. An example use case would be to show the user a \"you don't\n * have access to this\" message rather than redirecting them to log in:\n *\n * ```js [app/routes/application.js]\n * import { ForbiddenError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ForbiddenError) {\n * this.transitionTo('forbidden');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ForbiddenError: AdapterRequestErrorConstructor<ForbiddenError> = getOrSetGlobal(\n 'ForbiddenError',\n extend(AdapterError, 'The adapter operation is forbidden')\n);\nForbiddenError.prototype.code = 'ForbiddenError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link NotFoundError} constructor.\n */\nexport type NotFoundError = AdapterRequestError<'NotFoundError'>;\n/**\n * A `NotFoundError` equates to an HTTP `404 Not Found` response status.\n * It is used by an adapter to signal that a request to the external API\n * was rejected because the resource could not be found on the API.\n *\n * An example use case would be to detect if the user has entered a route\n * for a specific model that does not exist. For example:\n *\n * ```js [app/routes/post.js]\n * import { NotFoundError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class PostRoute extends Route {\n * @service store;\n * model(params) {\n * return this.store.findRecord('post', params.post_id);\n * }\n * @action\n * error(error, transition) {\n * if (error instanceof NotFoundError) {\n * // redirect to a list of all posts instead\n * this.transitionTo('posts');\n * } else {\n * // otherwise let the error bubble\n * return true;\n * }\n * }\n * }\n * ```\n *\n * @public\n */\nexport const NotFoundError: AdapterRequestErrorConstructor<NotFoundError> = getOrSetGlobal(\n 'NotFoundError',\n extend(AdapterError, 'The adapter could not find the resource')\n);\nNotFoundError.prototype.code = 'NotFoundError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ConflictError} constructor.\n */\nexport type ConflictError = AdapterRequestError<'ConflictError'>;\n/**\n * A `ConflictError` equates to an HTTP `409 Conflict` response status.\n * It is used by an adapter to indicate that the request could not be\n * processed because of a conflict in the request. An example scenario\n * would be when creating a record with a client-generated ID but that ID\n * is already known to the external API.\n *\n * An example use case would be to surface a conflict-specific message so\n * the user can retry with different input:\n *\n * ```js [app/routes/application.js]\n * import { ConflictError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ConflictError) {\n * alert('That identifier is already in use, please choose another.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ConflictError: AdapterRequestErrorConstructor<ConflictError> = getOrSetGlobal(\n 'ConflictError',\n extend(AdapterError, 'The adapter operation failed due to a conflict')\n);\nConflictError.prototype.code = 'ConflictError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ServerError} constructor.\n */\nexport type ServerError = AdapterRequestError<'ServerError'>;\n/**\n * A `ServerError` equates to an HTTP `500 Internal Server Error` response\n * status. It is used by the adapter to indicate that a request has failed\n * because of an error in the external API, and is unlikely to succeed if\n * retried immediately.\n *\n * An example use case would be to show a generic \"something went wrong on\n * our end\" message rather than one implying the user made a mistake:\n *\n * ```js [app/routes/application.js]\n * import { ServerError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ServerError) {\n * alert('Something went wrong on our end. Please try again later.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ServerError: AdapterRequestErrorConstructor<ServerError> = getOrSetGlobal(\n 'ServerError',\n extend(AdapterError, 'The adapter operation failed due to a server error')\n);\nServerError.prototype.code = 'ServerError';\n"],"mappings":";;;;AAUA,SAASG,cAAyCC,QAAoBC,UAAU,4BAA4B;CAC1G,KAAKC,iBAAiB;CACtB,MAAMC,QAAQC,MAAMC,KAAK,MAAMJ,OAAO;CAEtC,IAAIE,OAAO;EACT,KAAKG,QAAQH,MAAMG;EAEnB,KAAKC,cAAcJ,MAAMI;EAEzB,KAAKC,WAAWL,MAAMK;EAEtB,KAAKC,aAAaN,MAAMM;EACxB,KAAKR,UAAUE,MAAMF;EACrB,KAAKS,OAAOP,MAAMO;EAElB,KAAKC,SAASR,MAAMQ;CACtB;CAEA,KAAKX,SAASA,UAAU,CACtB;EACEY,OAAO;EACPC,QAAQZ;CACV,CAAC;AAEL;;;;;;;;AA+BAF,cAAce,YAAYC,OAAOC,OAAOZ,MAAMU,SAAS;AAEvDf,cAAce,UAAUG,OAAO;AAC/BlB,cAAcmB,SAASC,SAASpB,aAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwG1F,MAAaqB,eAA6DxB,eACxE,gBACAG,aACF;AAEA,SAASoB,SAASE,YAA2D;CAC3E,OAAO,SAAU,EAAEpB,SAASqB,mBAAyC,CAAC,GAAG;EACvE,OAAOJ,OAAOG,YAAYC,cAAc;CAC1C;AACF;AAEA,SAASJ,OACPK,kBACAD,gBACuC;CACvC,MAAMD,aAAa,SAAqCrB,QAAoBC,SAAkB;EAC5FJ,eAAAC,gBAAA,CAAA,CAAA0B,UAAAC,IAAAC,KAAA,OAAAC,SAAA;GAAA,IAAA,CAAAA,MAAA,MAAA,IAAAvB,MAAO,yDAAyD;EAAA,EAAA,CAAEwB,MAAMC,QAAQ7B,UAAU,CAAA,CAAE,CAAC;EAC7FuB,iBAAiBlB,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