@warp-drive/legacy 5.10.0-alpha.2 → 5.10.0-alpha.21

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 (413) hide show
  1. package/README.md +91 -8
  2. package/blueprints/adapter/files/__root__/__path__/__name__.js +1 -0
  3. package/blueprints/adapter/index.js +27 -0
  4. package/blueprints/adapter-test/index.js +33 -0
  5. package/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js +1 -0
  6. package/blueprints/model/HELP.md +26 -0
  7. package/blueprints/model/files/__root__/__path__/__name__.js +1 -0
  8. package/blueprints/model/index.js +27 -0
  9. package/blueprints/model-test/index.js +33 -0
  10. package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +1 -0
  11. package/blueprints/serializer/files/__root__/__path__/__name__.js +1 -0
  12. package/blueprints/serializer/index.js +27 -0
  13. package/blueprints/serializer-test/index.js +33 -0
  14. package/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +1 -0
  15. package/blueprints/transform/files/__root__/__path__/__name__.js +1 -0
  16. package/blueprints/transform/index.js +17 -0
  17. package/blueprints/transform-test/index.js +33 -0
  18. package/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +1 -0
  19. package/dist/{-private-DccRZQsm.js → -private-0_Oc-M3x.js} +10 -17
  20. package/dist/-private-0_Oc-M3x.js.map +1 -0
  21. package/dist/{-private-DQ6Iap2t.js → -private-L2BtGGYa.js} +8 -14
  22. package/dist/{-private-DQ6Iap2t.js.map → -private-L2BtGGYa.js.map} +1 -1
  23. package/dist/adapter/-private.d.ts +2 -12
  24. package/dist/adapter/-private.d.ts.map +1 -1
  25. package/dist/adapter/-private.js +1 -1
  26. package/dist/adapter/error.d.ts +1 -1
  27. package/dist/adapter/error.js +54 -2
  28. package/dist/adapter/error.js.map +1 -1
  29. package/dist/adapter/json-api.d.ts +5 -5
  30. package/dist/adapter/json-api.d.ts.map +1 -1
  31. package/dist/adapter/json-api.js +10 -4
  32. package/dist/adapter/json-api.js.map +1 -1
  33. package/dist/adapter/rest.d.ts +1 -1
  34. package/dist/adapter/rest.js +23 -5
  35. package/dist/adapter/rest.js.map +1 -1
  36. package/dist/{adapter-eYo2pIuM.js → adapter-AwGvdMSZ.js} +45 -6
  37. package/dist/adapter-AwGvdMSZ.js.map +1 -0
  38. package/dist/{adapter-CARrK3-8.d.ts → adapter-DvDVeaCc.d.ts} +9 -6
  39. package/dist/adapter-DvDVeaCc.d.ts.map +1 -0
  40. package/dist/adapter.d.ts +1 -1
  41. package/dist/adapter.js +1 -1
  42. package/dist/compat/-private.d.ts +1 -1
  43. package/dist/compat/-private.js +1 -1
  44. package/dist/compat/builders.d.ts +10 -8
  45. package/dist/compat/builders.d.ts.map +1 -1
  46. package/dist/compat/builders.js +15 -9
  47. package/dist/compat/builders.js.map +1 -1
  48. package/dist/compat/extensions.d.ts +1 -1
  49. package/dist/compat/extensions.js +23 -2
  50. package/dist/compat/extensions.js.map +1 -1
  51. package/dist/compat/utils.d.ts +17 -2
  52. package/dist/compat/utils.d.ts.map +1 -1
  53. package/dist/compat/utils.js +19 -2
  54. package/dist/compat/utils.js.map +1 -1
  55. package/dist/{compat-DcHVxuuZ.js → compat-C-yQnbkF.js} +61 -8
  56. package/dist/compat-C-yQnbkF.js.map +1 -0
  57. package/dist/{compat-BbNNmTM-.d.ts → compat-DoWEarkU.d.ts} +30 -17
  58. package/dist/compat-DoWEarkU.d.ts.map +1 -0
  59. package/dist/compat.d.ts +1 -1
  60. package/dist/compat.js +1 -1
  61. package/dist/{error-CzkyXr1Q.d.ts → error-798wGD3r.d.ts} +49 -3
  62. package/dist/error-798wGD3r.d.ts.map +1 -0
  63. package/dist/{errors-CS110tMl.js → errors-BEExAZtv.js} +42 -32
  64. package/dist/errors-BEExAZtv.js.map +1 -0
  65. package/dist/{extensions-DumNm4dA.d.ts → extensions-DcEz1lKv.d.ts} +18 -3
  66. package/dist/extensions-DcEz1lKv.d.ts.map +1 -0
  67. package/dist/index.d.ts +17 -2
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +25 -7
  70. package/dist/index.js.map +1 -1
  71. package/dist/{json-BXNPTlcH.js → json-Baaga4BP.js} +10 -5
  72. package/dist/json-Baaga4BP.js.map +1 -0
  73. package/dist/model/-private.d.ts +1 -1
  74. package/dist/model/-private.js +1 -1
  75. package/dist/model/migration-support.d.ts +19 -4
  76. package/dist/model/migration-support.d.ts.map +1 -1
  77. package/dist/model/migration-support.js +25 -7
  78. package/dist/model/migration-support.js.map +1 -1
  79. package/dist/{model-DWH9f__L.js → model-Be-e84FX.js} +19 -12
  80. package/dist/model-Be-e84FX.js.map +1 -0
  81. package/dist/{model-62hn5_PD.d.ts → model-DAdY1ibr.d.ts} +13 -26
  82. package/dist/model-DAdY1ibr.d.ts.map +1 -0
  83. package/dist/{unpkg/dev-deprecated/model-fragments-DSqu0ptR.js → model-fragments-DCHMDr5f.js} +32 -18
  84. package/dist/model-fragments-DCHMDr5f.js.map +1 -0
  85. package/dist/model-fragments.d.ts +31 -19
  86. package/dist/model-fragments.d.ts.map +1 -1
  87. package/dist/model-fragments.js +1 -1
  88. package/dist/model.d.ts +12 -11
  89. package/dist/model.d.ts.map +1 -1
  90. package/dist/model.js +2 -2
  91. package/dist/{rest-0NhtexIq.d.ts → rest-CmFneLJH.d.ts} +18 -8
  92. package/dist/rest-CmFneLJH.d.ts.map +1 -0
  93. package/dist/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  94. package/dist/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  95. package/dist/{schema-provider-DguGmQDS.js → schema-provider-BAB8DyMr.js} +22 -21
  96. package/dist/schema-provider-BAB8DyMr.js.map +1 -0
  97. package/dist/serializer/json-api.d.ts +1 -2
  98. package/dist/serializer/json-api.d.ts.map +1 -1
  99. package/dist/serializer/json-api.js +7 -3
  100. package/dist/serializer/json-api.js.map +1 -1
  101. package/dist/serializer/json.d.ts +2 -2
  102. package/dist/serializer/json.d.ts.map +1 -1
  103. package/dist/serializer/json.js +1 -1
  104. package/dist/serializer/rest.d.ts +4 -4
  105. package/dist/serializer/rest.d.ts.map +1 -1
  106. package/dist/serializer/rest.js +12 -5
  107. package/dist/serializer/rest.js.map +1 -1
  108. package/dist/serializer/transform.d.ts +9 -10
  109. package/dist/serializer/transform.d.ts.map +1 -1
  110. package/dist/serializer/transform.js +14 -10
  111. package/dist/serializer/transform.js.map +1 -1
  112. package/dist/serializer.d.ts +2 -2
  113. package/dist/serializer.d.ts.map +1 -1
  114. package/dist/serializer.js +42 -3
  115. package/dist/serializer.js.map +1 -1
  116. package/dist/{store-C4qYzXei.js → store-BLKEsJyw.js} +13 -7
  117. package/dist/store-BLKEsJyw.js.map +1 -0
  118. package/dist/store.d.ts +3 -2
  119. package/dist/store.d.ts.map +1 -1
  120. package/dist/store.js +1 -1
  121. package/dist/unpkg/dev/{-private-CrEyBE-B.js → -private-BprUAEe_.js} +8 -14
  122. package/dist/unpkg/{dev-deprecated/-private-CrEyBE-B.js.map → dev/-private-BprUAEe_.js.map} +1 -1
  123. package/dist/unpkg/dev/{-private-vOhxVExH.js → -private-Dch4SxkU.js} +10 -17
  124. package/dist/unpkg/dev/-private-Dch4SxkU.js.map +1 -0
  125. package/dist/unpkg/dev/adapter/-private.js +1 -1
  126. package/dist/unpkg/dev/adapter/error.js +54 -2
  127. package/dist/unpkg/dev/adapter/error.js.map +1 -1
  128. package/dist/unpkg/dev/adapter/json-api.js +10 -4
  129. package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
  130. package/dist/unpkg/dev/adapter/rest.js +23 -5
  131. package/dist/unpkg/dev/adapter/rest.js.map +1 -1
  132. package/dist/unpkg/dev/{adapter-oLwyr47q.js → adapter-BAn4SeUA.js} +45 -6
  133. package/dist/unpkg/dev/adapter-BAn4SeUA.js.map +1 -0
  134. package/dist/unpkg/dev/adapter.js +1 -1
  135. package/dist/unpkg/dev/compat/-private.js +1 -1
  136. package/dist/unpkg/dev/compat/builders.js +15 -9
  137. package/dist/unpkg/dev/compat/builders.js.map +1 -1
  138. package/dist/unpkg/dev/compat/extensions.js +23 -2
  139. package/dist/unpkg/dev/compat/extensions.js.map +1 -1
  140. package/dist/unpkg/dev/compat/utils.js +19 -2
  141. package/dist/unpkg/dev/compat/utils.js.map +1 -1
  142. package/dist/unpkg/dev/{compat-DNQT2TQx.js → compat-BdovRRzQ.js} +62 -10
  143. package/dist/unpkg/dev/compat-BdovRRzQ.js.map +1 -0
  144. package/dist/unpkg/dev/compat.js +1 -1
  145. package/dist/unpkg/dev/{errors-DnzvLM2A.js → errors-CGvbM6WH.js} +42 -32
  146. package/dist/unpkg/dev/errors-CGvbM6WH.js.map +1 -0
  147. package/dist/unpkg/dev/index.js +25 -7
  148. package/dist/unpkg/dev/index.js.map +1 -1
  149. package/dist/unpkg/{dev-deprecated/json-DDJji3V3.js → dev/json-BlSBe84o.js} +10 -5
  150. package/dist/unpkg/dev/json-BlSBe84o.js.map +1 -0
  151. package/dist/unpkg/dev/model/-private.js +1 -1
  152. package/dist/unpkg/dev/model/migration-support.js +24 -6
  153. package/dist/unpkg/dev/model/migration-support.js.map +1 -1
  154. package/dist/unpkg/dev/{model-BxPIR7m2.js → model-QCZr8eec.js} +19 -12
  155. package/dist/unpkg/dev/model-QCZr8eec.js.map +1 -0
  156. package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev/model-fragments-DCHMDr5f.js} +32 -18
  157. package/dist/unpkg/dev/model-fragments-DCHMDr5f.js.map +1 -0
  158. package/dist/unpkg/dev/model-fragments.js +1 -1
  159. package/dist/unpkg/dev/model.js +2 -2
  160. package/dist/unpkg/dev/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  161. package/dist/unpkg/dev/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  162. package/dist/unpkg/dev/{schema-provider-CI_a48ja.js → schema-provider-IMFO9Kgw.js} +18 -17
  163. package/dist/unpkg/dev/schema-provider-IMFO9Kgw.js.map +1 -0
  164. package/dist/unpkg/dev/serializer/json-api.js +7 -3
  165. package/dist/unpkg/dev/serializer/json-api.js.map +1 -1
  166. package/dist/unpkg/dev/serializer/json.js +1 -1
  167. package/dist/unpkg/dev/serializer/rest.js +12 -5
  168. package/dist/unpkg/dev/serializer/rest.js.map +1 -1
  169. package/dist/unpkg/dev/serializer/transform.js +14 -10
  170. package/dist/unpkg/dev/serializer/transform.js.map +1 -1
  171. package/dist/unpkg/dev/serializer.js +42 -3
  172. package/dist/unpkg/dev/serializer.js.map +1 -1
  173. package/dist/unpkg/dev/{store-D_V8-HQl.js → store-BiXsLLAu.js} +13 -7
  174. package/dist/unpkg/dev/store-BiXsLLAu.js.map +1 -0
  175. package/dist/unpkg/dev/store.js +1 -1
  176. package/dist/unpkg/dev/{util-dSKEgQDp.js → util-CI7b4vAE.js} +2 -3
  177. package/dist/unpkg/dev/{util-dSKEgQDp.js.map → util-CI7b4vAE.js.map} +1 -1
  178. package/dist/unpkg/{prod/utils-DYC9utVJ.js → dev/utils-_O0MjUTU.js} +2 -3
  179. package/dist/unpkg/dev/{utils-DYC9utVJ.js.map → utils-_O0MjUTU.js.map} +1 -1
  180. package/dist/unpkg/dev-deprecated/{-private-CrEyBE-B.js → -private-BprUAEe_.js} +8 -14
  181. package/dist/unpkg/{dev/-private-CrEyBE-B.js.map → dev-deprecated/-private-BprUAEe_.js.map} +1 -1
  182. package/dist/unpkg/dev-deprecated/{-private-vOhxVExH.js → -private-Dch4SxkU.js} +10 -17
  183. package/dist/unpkg/dev-deprecated/-private-Dch4SxkU.js.map +1 -0
  184. package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -1
  185. package/dist/unpkg/dev-deprecated/adapter/error.js +54 -2
  186. package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
  187. package/dist/unpkg/dev-deprecated/adapter/json-api.js +10 -4
  188. package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
  189. package/dist/unpkg/dev-deprecated/adapter/rest.js +23 -5
  190. package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
  191. package/dist/unpkg/dev-deprecated/{adapter-oLwyr47q.js → adapter-BAn4SeUA.js} +45 -6
  192. package/dist/unpkg/dev-deprecated/adapter-BAn4SeUA.js.map +1 -0
  193. package/dist/unpkg/dev-deprecated/adapter.js +1 -1
  194. package/dist/unpkg/dev-deprecated/compat/-private.js +1 -1
  195. package/dist/unpkg/dev-deprecated/compat/builders.js +15 -9
  196. package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -1
  197. package/dist/unpkg/dev-deprecated/compat/extensions.js +23 -2
  198. package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
  199. package/dist/unpkg/dev-deprecated/compat/utils.js +19 -2
  200. package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -1
  201. package/dist/unpkg/dev-deprecated/{compat-CeT0PnVX.js → compat-CPVriwH0.js} +62 -10
  202. package/dist/unpkg/dev-deprecated/compat-CPVriwH0.js.map +1 -0
  203. package/dist/unpkg/dev-deprecated/compat.js +1 -1
  204. package/dist/unpkg/dev-deprecated/{errors-jHQESeNQ.js → errors-yPc7D7r3.js} +42 -32
  205. package/dist/unpkg/dev-deprecated/errors-yPc7D7r3.js.map +1 -0
  206. package/dist/unpkg/dev-deprecated/index.js +25 -7
  207. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  208. package/dist/unpkg/{dev/json-DDJji3V3.js → dev-deprecated/json-BlSBe84o.js} +10 -5
  209. package/dist/unpkg/dev-deprecated/json-BlSBe84o.js.map +1 -0
  210. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  211. package/dist/unpkg/dev-deprecated/model/migration-support.js +24 -6
  212. package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
  213. package/dist/unpkg/dev-deprecated/{model-BeGORt6h.js → model-B0ZNLaHO.js} +19 -12
  214. package/dist/unpkg/dev-deprecated/model-B0ZNLaHO.js.map +1 -0
  215. package/dist/unpkg/{prod-deprecated/model-fragments-DSqu0ptR.js → dev-deprecated/model-fragments-DCHMDr5f.js} +32 -18
  216. package/dist/unpkg/dev-deprecated/model-fragments-DCHMDr5f.js.map +1 -0
  217. package/dist/unpkg/dev-deprecated/model-fragments.js +1 -1
  218. package/dist/unpkg/dev-deprecated/model.js +2 -2
  219. package/dist/unpkg/dev-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  220. package/dist/unpkg/dev-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  221. package/dist/unpkg/dev-deprecated/{schema-provider-NmtdR4n_.js → schema-provider-DGWYnFno.js} +18 -17
  222. package/dist/unpkg/dev-deprecated/schema-provider-DGWYnFno.js.map +1 -0
  223. package/dist/unpkg/dev-deprecated/serializer/json-api.js +7 -3
  224. package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -1
  225. package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
  226. package/dist/unpkg/dev-deprecated/serializer/rest.js +12 -5
  227. package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
  228. package/dist/unpkg/dev-deprecated/serializer/transform.js +14 -10
  229. package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
  230. package/dist/unpkg/dev-deprecated/serializer.js +42 -3
  231. package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
  232. package/dist/unpkg/dev-deprecated/{store-BCOLSC6z.js → store-Ci8k7Lh6.js} +13 -7
  233. package/dist/unpkg/dev-deprecated/store-Ci8k7Lh6.js.map +1 -0
  234. package/dist/unpkg/dev-deprecated/store.js +1 -1
  235. package/dist/unpkg/dev-deprecated/{util-CXA3RNYH.js → util-DL_8JecH.js} +2 -3
  236. package/dist/unpkg/dev-deprecated/{util-CXA3RNYH.js.map → util-DL_8JecH.js.map} +1 -1
  237. package/dist/unpkg/dev-deprecated/{utils-DQkMqhDv.js → utils-DyGjRZ14.js} +2 -3
  238. package/dist/unpkg/dev-deprecated/{utils-DQkMqhDv.js.map → utils-DyGjRZ14.js.map} +1 -1
  239. package/dist/unpkg/{prod-deprecated/-private-B4bxoTuK.js → prod/-private-Dc9yg98O.js} +8 -14
  240. package/dist/unpkg/{prod-deprecated/-private-B4bxoTuK.js.map → prod/-private-Dc9yg98O.js.map} +1 -1
  241. package/dist/unpkg/prod/{-private-SfXkkHKd.js → -private-DuRzYAyW.js} +9 -15
  242. package/dist/unpkg/prod/-private-DuRzYAyW.js.map +1 -0
  243. package/dist/unpkg/prod/adapter/-private.js +1 -1
  244. package/dist/unpkg/prod/adapter/error.js +54 -2
  245. package/dist/unpkg/prod/adapter/error.js.map +1 -1
  246. package/dist/unpkg/prod/adapter/json-api.js +10 -4
  247. package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
  248. package/dist/unpkg/prod/adapter/rest.js +23 -5
  249. package/dist/unpkg/prod/adapter/rest.js.map +1 -1
  250. package/dist/unpkg/prod/{adapter-DQ9UA7FC.js → adapter-D0HCLrwm.js} +45 -6
  251. package/dist/unpkg/prod/adapter-D0HCLrwm.js.map +1 -0
  252. package/dist/unpkg/prod/adapter.js +1 -1
  253. package/dist/unpkg/prod/compat/-private.js +1 -1
  254. package/dist/unpkg/prod/compat/builders.js +15 -9
  255. package/dist/unpkg/prod/compat/builders.js.map +1 -1
  256. package/dist/unpkg/prod/compat/extensions.js +23 -2
  257. package/dist/unpkg/prod/compat/extensions.js.map +1 -1
  258. package/dist/unpkg/prod/compat/utils.js +19 -2
  259. package/dist/unpkg/prod/compat/utils.js.map +1 -1
  260. package/dist/unpkg/{prod-deprecated/compat-DxiVkCUb.js → prod/compat-PrUuencH.js} +62 -10
  261. package/dist/unpkg/prod/compat-PrUuencH.js.map +1 -0
  262. package/dist/unpkg/prod/compat.js +1 -1
  263. package/dist/unpkg/prod/{errors-DQDfNqVx.js → errors-Bw8niCo8.js} +38 -27
  264. package/dist/unpkg/prod/errors-Bw8niCo8.js.map +1 -0
  265. package/dist/unpkg/prod/index.js +25 -7
  266. package/dist/unpkg/prod/index.js.map +1 -1
  267. package/dist/unpkg/prod/{json-BD1kRTfB.js → json-D1bH8enA.js} +10 -5
  268. package/dist/unpkg/prod/json-D1bH8enA.js.map +1 -0
  269. package/dist/unpkg/prod/model/-private.js +1 -1
  270. package/dist/unpkg/prod/model/migration-support.js +24 -6
  271. package/dist/unpkg/prod/model/migration-support.js.map +1 -1
  272. package/dist/unpkg/prod/{model-CYMA-e_S.js → model-QtC0IWbE.js} +19 -12
  273. package/dist/unpkg/prod/model-QtC0IWbE.js.map +1 -0
  274. package/dist/unpkg/prod/model-fragments-DCHMDr5f.js +348 -0
  275. package/dist/unpkg/prod/model-fragments-DCHMDr5f.js.map +1 -0
  276. package/dist/unpkg/prod/model-fragments.js +1 -1
  277. package/dist/unpkg/prod/model.js +2 -2
  278. package/dist/unpkg/prod/runtime--fcdnjmJ-5yaSpa-d.js +52 -0
  279. package/dist/unpkg/prod/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  280. package/dist/unpkg/prod/{schema-provider-05U1H-Kl.js → schema-provider-DPOzTa8e.js} +18 -17
  281. package/dist/unpkg/prod/schema-provider-DPOzTa8e.js.map +1 -0
  282. package/dist/unpkg/prod/serializer/json-api.js +7 -3
  283. package/dist/unpkg/prod/serializer/json-api.js.map +1 -1
  284. package/dist/unpkg/prod/serializer/json.js +1 -1
  285. package/dist/unpkg/prod/serializer/rest.js +12 -5
  286. package/dist/unpkg/prod/serializer/rest.js.map +1 -1
  287. package/dist/unpkg/prod/serializer/transform.js +14 -10
  288. package/dist/unpkg/prod/serializer/transform.js.map +1 -1
  289. package/dist/unpkg/prod/serializer.js +42 -3
  290. package/dist/unpkg/prod/serializer.js.map +1 -1
  291. package/dist/unpkg/{prod-deprecated/store-0L2CkYzh.js → prod/store-BsSkzWgk.js} +13 -7
  292. package/dist/unpkg/{prod-deprecated/store-0L2CkYzh.js.map → prod/store-BsSkzWgk.js.map} +1 -1
  293. package/dist/unpkg/prod/store.js +1 -1
  294. package/dist/unpkg/prod/{util-dSKEgQDp.js → util-CI7b4vAE.js} +2 -3
  295. package/dist/unpkg/prod/{util-dSKEgQDp.js.map → util-CI7b4vAE.js.map} +1 -1
  296. package/dist/unpkg/{dev/utils-DYC9utVJ.js → prod/utils-_O0MjUTU.js} +2 -3
  297. package/dist/unpkg/prod/{utils-DYC9utVJ.js.map → utils-_O0MjUTU.js.map} +1 -1
  298. package/dist/unpkg/{prod/-private-B4bxoTuK.js → prod-deprecated/-private-Dc9yg98O.js} +8 -14
  299. package/dist/unpkg/{prod/-private-B4bxoTuK.js.map → prod-deprecated/-private-Dc9yg98O.js.map} +1 -1
  300. package/dist/unpkg/prod-deprecated/{-private-SfXkkHKd.js → -private-DuRzYAyW.js} +9 -15
  301. package/dist/unpkg/prod-deprecated/-private-DuRzYAyW.js.map +1 -0
  302. package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -1
  303. package/dist/unpkg/prod-deprecated/adapter/error.js +54 -2
  304. package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
  305. package/dist/unpkg/prod-deprecated/adapter/json-api.js +10 -4
  306. package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
  307. package/dist/unpkg/prod-deprecated/adapter/rest.js +23 -5
  308. package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
  309. package/dist/unpkg/prod-deprecated/{adapter-DQ9UA7FC.js → adapter-D0HCLrwm.js} +45 -6
  310. package/dist/unpkg/prod-deprecated/adapter-D0HCLrwm.js.map +1 -0
  311. package/dist/unpkg/prod-deprecated/adapter.js +1 -1
  312. package/dist/unpkg/prod-deprecated/compat/-private.js +1 -1
  313. package/dist/unpkg/prod-deprecated/compat/builders.js +15 -9
  314. package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -1
  315. package/dist/unpkg/prod-deprecated/compat/extensions.js +23 -2
  316. package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
  317. package/dist/unpkg/prod-deprecated/compat/utils.js +19 -2
  318. package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -1
  319. package/dist/unpkg/{prod/compat-DxiVkCUb.js → prod-deprecated/compat-PrUuencH.js} +62 -10
  320. package/dist/unpkg/prod-deprecated/compat-PrUuencH.js.map +1 -0
  321. package/dist/unpkg/prod-deprecated/compat.js +1 -1
  322. package/dist/unpkg/prod-deprecated/{errors-ii4L43_1.js → errors-D20lKboZ.js} +38 -27
  323. package/dist/unpkg/prod-deprecated/errors-D20lKboZ.js.map +1 -0
  324. package/dist/unpkg/prod-deprecated/index.js +25 -7
  325. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  326. package/dist/unpkg/prod-deprecated/{json-BD1kRTfB.js → json-D1bH8enA.js} +10 -5
  327. package/dist/unpkg/prod-deprecated/json-D1bH8enA.js.map +1 -0
  328. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  329. package/dist/unpkg/prod-deprecated/model/migration-support.js +24 -6
  330. package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
  331. package/dist/unpkg/prod-deprecated/{model-D3oCPHtM.js → model-B946S2pl.js} +19 -12
  332. package/dist/unpkg/prod-deprecated/model-B946S2pl.js.map +1 -0
  333. package/dist/unpkg/{dev/model-fragments-DSqu0ptR.js → prod-deprecated/model-fragments-DCHMDr5f.js} +32 -18
  334. package/dist/unpkg/prod-deprecated/model-fragments-DCHMDr5f.js.map +1 -0
  335. package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
  336. package/dist/unpkg/prod-deprecated/model.js +2 -2
  337. package/dist/unpkg/prod-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
  338. package/dist/unpkg/prod-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
  339. package/dist/unpkg/prod-deprecated/{schema-provider-CKH_bnnS.js → schema-provider-xcaytn9y.js} +18 -17
  340. package/dist/unpkg/prod-deprecated/schema-provider-xcaytn9y.js.map +1 -0
  341. package/dist/unpkg/prod-deprecated/serializer/json-api.js +7 -3
  342. package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -1
  343. package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
  344. package/dist/unpkg/prod-deprecated/serializer/rest.js +12 -5
  345. package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
  346. package/dist/unpkg/prod-deprecated/serializer/transform.js +14 -10
  347. package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
  348. package/dist/unpkg/prod-deprecated/serializer.js +42 -3
  349. package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
  350. package/dist/unpkg/{prod/store-RGGc1ilN.js → prod-deprecated/store-Dsw2f4s-.js} +13 -7
  351. package/dist/unpkg/{prod/store-RGGc1ilN.js.map → prod-deprecated/store-Dsw2f4s-.js.map} +1 -1
  352. package/dist/unpkg/prod-deprecated/store.js +1 -1
  353. package/dist/unpkg/prod-deprecated/{util-CQQdHX3n.js → util-CVu5_VeN.js} +2 -3
  354. package/dist/unpkg/prod-deprecated/{util-CQQdHX3n.js.map → util-CVu5_VeN.js.map} +1 -1
  355. package/dist/unpkg/prod-deprecated/{utils-BMI_JwFP.js → utils-z1h-zTls.js} +2 -3
  356. package/dist/unpkg/prod-deprecated/{utils-BMI_JwFP.js.map → utils-z1h-zTls.js.map} +1 -1
  357. package/dist/{util-Bnx8nm-D.js → util-fMuLguoj.js} +2 -3
  358. package/dist/{util-Bnx8nm-D.js.map → util-fMuLguoj.js.map} +1 -1
  359. package/dist/{utils-ZAytYep8.js → utils-UqBsN9IU.js} +2 -3
  360. package/dist/{utils-ZAytYep8.js.map → utils-UqBsN9IU.js.map} +1 -1
  361. package/logos/README.md +1 -1
  362. package/package.json +17 -12
  363. package/dist/-private-DccRZQsm.js.map +0 -1
  364. package/dist/adapter-CARrK3-8.d.ts.map +0 -1
  365. package/dist/adapter-eYo2pIuM.js.map +0 -1
  366. package/dist/compat-BbNNmTM-.d.ts.map +0 -1
  367. package/dist/compat-DcHVxuuZ.js.map +0 -1
  368. package/dist/error-CzkyXr1Q.d.ts.map +0 -1
  369. package/dist/errors-CS110tMl.js.map +0 -1
  370. package/dist/extensions-DumNm4dA.d.ts.map +0 -1
  371. package/dist/json-BXNPTlcH.js.map +0 -1
  372. package/dist/model-62hn5_PD.d.ts.map +0 -1
  373. package/dist/model-DWH9f__L.js.map +0 -1
  374. package/dist/model-fragments-DSqu0ptR.js.map +0 -1
  375. package/dist/rest-0NhtexIq.d.ts.map +0 -1
  376. package/dist/schema-provider-DguGmQDS.js.map +0 -1
  377. package/dist/store-C4qYzXei.js.map +0 -1
  378. package/dist/unpkg/dev/-private-vOhxVExH.js.map +0 -1
  379. package/dist/unpkg/dev/adapter-oLwyr47q.js.map +0 -1
  380. package/dist/unpkg/dev/compat-DNQT2TQx.js.map +0 -1
  381. package/dist/unpkg/dev/errors-DnzvLM2A.js.map +0 -1
  382. package/dist/unpkg/dev/json-DDJji3V3.js.map +0 -1
  383. package/dist/unpkg/dev/model-BxPIR7m2.js.map +0 -1
  384. package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +0 -1
  385. package/dist/unpkg/dev/schema-provider-CI_a48ja.js.map +0 -1
  386. package/dist/unpkg/dev/store-D_V8-HQl.js.map +0 -1
  387. package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js.map +0 -1
  388. package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +0 -1
  389. package/dist/unpkg/dev-deprecated/compat-CeT0PnVX.js.map +0 -1
  390. package/dist/unpkg/dev-deprecated/errors-jHQESeNQ.js.map +0 -1
  391. package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +0 -1
  392. package/dist/unpkg/dev-deprecated/model-BeGORt6h.js.map +0 -1
  393. package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  394. package/dist/unpkg/dev-deprecated/schema-provider-NmtdR4n_.js.map +0 -1
  395. package/dist/unpkg/dev-deprecated/store-BCOLSC6z.js.map +0 -1
  396. package/dist/unpkg/prod/-private-SfXkkHKd.js.map +0 -1
  397. package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +0 -1
  398. package/dist/unpkg/prod/compat-DxiVkCUb.js.map +0 -1
  399. package/dist/unpkg/prod/errors-DQDfNqVx.js.map +0 -1
  400. package/dist/unpkg/prod/json-BD1kRTfB.js.map +0 -1
  401. package/dist/unpkg/prod/model-CYMA-e_S.js.map +0 -1
  402. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js +0 -334
  403. package/dist/unpkg/prod/model-fragments-DSqu0ptR.js.map +0 -1
  404. package/dist/unpkg/prod/runtime--fcdnjmJ-DMTJ0Kb3.js +0 -53
  405. package/dist/unpkg/prod/schema-provider-05U1H-Kl.js.map +0 -1
  406. package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js.map +0 -1
  407. package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +0 -1
  408. package/dist/unpkg/prod-deprecated/compat-DxiVkCUb.js.map +0 -1
  409. package/dist/unpkg/prod-deprecated/errors-ii4L43_1.js.map +0 -1
  410. package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +0 -1
  411. package/dist/unpkg/prod-deprecated/model-D3oCPHtM.js.map +0 -1
  412. package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
  413. package/dist/unpkg/prod-deprecated/schema-provider-CKH_bnnS.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { n as normalizeModelName, t as isMaybeIdentifier } from "../utils-DQkMqhDv.js";
1
+ import { n as normalizeModelName, t as isMaybeIdentifier } from "../utils-DyGjRZ14.js";
2
2
  import { recordIdentifierFor, storeFor } from "@warp-drive/core";
3
3
  import { assertPrivateStore, constructResource, ensureStringId } from "@warp-drive/core/store/-private";
4
4
  import { SkipCache } from "@warp-drive/core/types/request";
5
5
 
6
- //#region src/compat/builders/find-all.ts
6
+ // src/compat/builders/find-all.ts
7
7
  /**
8
8
  This function builds a request config to perform a `findAll` request for the given type.
9
9
  When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.
@@ -13,6 +13,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
13
13
  This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
14
14
  To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
15
15
 
16
+ @summary Deprecated legacy builder for a `store.request` config that behaves like `store.findAll`, easing
17
+ migration off adapters and serializers.
16
18
  @deprecated
17
19
  @public
18
20
  @param type the name of the resource
@@ -36,8 +38,7 @@ function findAllBuilder(type, options = {}) {
36
38
  };
37
39
  }
38
40
 
39
- //#endregion
40
- //#region src/compat/builders/find-record.ts
41
+ // src/compat/builders/find-record.ts
41
42
  /**
42
43
  This function builds a request config to find the record for a given identifier or type and id combination.
43
44
  When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.
@@ -65,6 +66,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
65
66
  This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
66
67
  To that end, these builders are deprecated and will be removed in a future version of Warp Drive.
67
68
 
69
+ @summary Deprecated legacy builder for a `store.request` config that behaves like `store.findRecord`, taking a
70
+ type and id or a resource identifier.
68
71
  @deprecated
69
72
  @public
70
73
  @param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
@@ -99,8 +102,7 @@ function findRecordBuilder(resource, idOrOptions, options) {
99
102
  };
100
103
  }
101
104
 
102
- //#endregion
103
- //#region src/compat/builders/query.ts
105
+ // src/compat/builders/query.ts
104
106
  /**
105
107
  This function builds a request config for a given type and query object.
106
108
  When passed to `store.request`, this config will result in the same behavior as a `store.query` request.
@@ -110,6 +112,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
110
112
  This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
111
113
  To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
112
114
 
115
+ @summary Deprecated legacy builder for a `store.request` config that behaves like `store.query`, returning the
116
+ records matching a query object.
113
117
  @deprecated
114
118
  @public
115
119
  @param type the name of the resource
@@ -146,6 +150,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
146
150
  This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
147
151
  To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
148
152
 
153
+ @summary Deprecated legacy builder for a `store.request` config that behaves like `store.queryRecord`, returning
154
+ a single record or `null` for a query object.
149
155
  @deprecated
150
156
  @public
151
157
  @param type the name of the resource
@@ -174,8 +180,7 @@ function queryRecordBuilder(type, query, options) {
174
180
  };
175
181
  }
176
182
 
177
- //#endregion
178
- //#region src/compat/builders/save-record.ts
183
+ // src/compat/builders/save-record.ts
179
184
  function _resourceIsFullDeleted(identifier, cache) {
180
185
  return cache.isDeletionCommitted(identifier) || cache.isNew(identifier) && cache.isDeleted(identifier);
181
186
  }
@@ -192,6 +197,8 @@ All `@ember-data/legacy-compat` builders exist to enable you to migrate your cod
192
197
  This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
193
198
  To that end, these builders are deprecated and will be removed in a future version of Ember Data.
194
199
 
200
+ @summary Deprecated legacy builder for a `store.request` config that creates, updates, or deletes a record
201
+ through adapters, like the legacy `store.saveRecord`.
195
202
  @deprecated
196
203
  @public
197
204
  @param {Object} record a record to save
@@ -226,6 +233,5 @@ function saveRecordBuilder(record, options = {}) {
226
233
  };
227
234
  }
228
235
 
229
- //#endregion
230
236
  export { findAllBuilder as findAll, findRecordBuilder as findRecord, queryBuilder as query, queryRecordBuilder as queryRecord, saveRecordBuilder as saveRecord };
231
237
  //# sourceMappingURL=builders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","names":["SkipCache","normalizeModelName","findAllBuilder","type","options","test","Error","op","data","cacheOptions","constructResource","ensureStringId","SkipCache","isMaybeIdentifier","normalizeModelName","findRecordBuilder","resource","idOrOptions","options","test","Error","type","normalizedId","preload","op","data","record","cacheOptions","SkipCache","normalizeModelName","queryBuilder","type","query","options","test","Error","op","data","cacheOptions","queryRecordBuilder","recordIdentifierFor","storeFor","assertPrivateStore","SkipCache","_resourceIsFullDeleted","identifier","cache","isDeletionCommitted","isNew","isDeleted","resourceIsFullyDeleted","instanceCache","saveRecordBuilder","record","options","store","test","Error","lid","_instanceCache","recordIsLoaded","operation","op","data","records","cacheOptions"],"sources":["../../../../src/compat/builders/find-all.ts","../../../../src/compat/builders/find-record.ts","../../../../src/compat/builders/query.ts","../../../../src/compat/builders/save-record.ts"],"sourcesContent":["import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { FindAllOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype FindAllRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'findAll';\n data: {\n type: T;\n options: FindAllBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindAllBuilderOptions = FindAllOptions;\n\n/**\n This function builds a request config to perform a `findAll` request for the given type.\n When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.\n Additionally, it takes the same options as `store.findAll`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @deprecated\n @public\n @param type the name of the resource\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.findAll\n @return request config\n*/\nexport function findAllBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n options?: FindAllBuilderOptions\n): FindAllRequestInput<TypeFromInstance<T>, T[]>;\nexport function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;\nexport function findAllBuilder(type: string, options: FindAllBuilderOptions = {}): FindAllRequestInput {\n assert(`You need to pass a model name to the findAll builder`, type);\n assert(\n `Model name passed to the findAll builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'findAll',\n data: {\n type: normalizeModelName(type),\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { constructResource, ensureStringId } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions, FindRecordOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { ResourceIdentifierObject } from '@warp-drive/core/types/spec/json-api-raw';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { isMaybeIdentifier, normalizeModelName } from './utils.ts';\n\ntype FindRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'findRecord';\n data: {\n record: ResourceIdentifierObject<T>;\n options: FindRecordBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindRecordBuilderOptions = Omit<FindRecordOptions, 'preload'>;\n\n/**\n This function builds a request config to find the record for a given identifier or type and id combination.\n When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.\n Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).\n\n **Example 1**\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));\n ```\n\n **Example 2**\n\n `findRecord` can be called with a single identifier argument instead of the combination\n of `type` (modelName) and `id` as separate arguments. You may recognize this combo as\n the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));\n ```\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Warp Drive.\n\n @deprecated\n @public\n @param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record\n @param id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved\n @param options - if the first param is a string this will be the optional options for the request. See examples for available options.\n @return request config\n*/\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(type: string, id: string, options?: FindRecordBuilderOptions): FindRecordRequestInput;\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n resource: ResourceIdentifierObject<TypeFromInstance<T>>,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(\n resource: ResourceIdentifierObject,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput;\nexport function findRecordBuilder(\n resource: string | ResourceIdentifierObject,\n idOrOptions?: string | FindRecordBuilderOptions,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder`,\n resource\n );\n if (isMaybeIdentifier(resource)) {\n options = idOrOptions as BaseFinderOptions | undefined;\n } else {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`,\n typeof resource === 'string'\n );\n const type = normalizeModelName(resource);\n const normalizedId = ensureStringId(idOrOptions as string | number);\n resource = constructResource(type, normalizedId);\n }\n\n options = options || {};\n\n assert('findRecord builder does not support options.preload', !(options as FindRecordOptions).preload);\n\n return {\n op: 'findRecord' as const,\n data: {\n record: resource,\n options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { LegacyResourceQuery, QueryOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype QueryRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'query';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype QueryBuilderOptions = QueryOptions;\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.query` request.\n Additionally, it takes the same options as `store.query`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput<TypeFromInstance<T>, T[]>;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options: QueryBuilderOptions = {}\n): QueryRequestInput {\n assert(`You need to pass a model name to the query builder`, type);\n assert(`You need to pass a query hash to the query builder`, query);\n assert(\n `Model name passed to the query builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'query' as const,\n data: {\n type: normalizeModelName(type),\n query,\n options: options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n\ntype QueryRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'queryRecord';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.\n Additionally, it takes the same options as `store.queryRecord`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput {\n assert(`You need to pass a model name to the queryRecord builder`, type);\n assert(`You need to pass a query hash to the queryRecord builder`, query);\n assert(\n `Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'queryRecord',\n data: {\n type: normalizeModelName(type),\n query,\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import { recordIdentifierFor, storeFor, type StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, type InstanceCache } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\ntype SaveRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'createRecord' | 'deleteRecord' | 'updateRecord';\n data: {\n record: ResourceKey<T>;\n options: SaveRecordBuilderOptions;\n };\n records: [ResourceKey<T>];\n [RequestSignature]?: RT;\n};\n\ntype SaveRecordBuilderOptions = Record<string, unknown>;\n\nfunction _resourceIsFullDeleted(identifier: ResourceKey, cache: Cache): boolean {\n return cache.isDeletionCommitted(identifier) || (cache.isNew(identifier) && cache.isDeleted(identifier));\n}\n\nfunction resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n return !cache || _resourceIsFullDeleted(identifier, cache);\n}\n\n/**\n This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).\n When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.\n Additionally, it takes the same options as `store.saveRecord`.\n\n All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @deprecated\n @public\n @param {Object} record a record to save\n @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord\n @return {SaveRecordRequestInput} request config\n*/\nexport function saveRecordBuilder<T extends TypedRecordInstance>(\n record: T,\n options: Record<string, unknown> = {}\n): SaveRecordRequestInput<TypeFromInstance<T>, T> {\n const store = storeFor(record, true);\n assertPrivateStore(store);\n assert(`Unable to initiate save for a record in a disconnected state`, store);\n const identifier = recordIdentifierFor<T>(record);\n\n if (!identifier) {\n // this commonly means we're disconnected\n // but just in case we throw here to prevent bad things.\n throw new Error(`Record Is Disconnected`);\n }\n assert(\n `Cannot initiate a save request for an unloaded record: ${identifier.lid}`,\n store._instanceCache.recordIsLoaded(identifier)\n );\n\n if (resourceIsFullyDeleted(store._instanceCache, identifier)) {\n throw new Error('cannot build saveRecord request for deleted record');\n }\n\n if (!options) {\n options = {};\n }\n let operation: 'createRecord' | 'deleteRecord' | 'updateRecord' = 'updateRecord';\n\n const cache = store.cache;\n if (cache.isNew(identifier)) {\n operation = 'createRecord';\n } else if (cache.isDeleted(identifier)) {\n operation = 'deleteRecord';\n }\n\n return {\n op: operation,\n data: {\n options,\n record: identifier,\n },\n records: [identifier],\n cacheOptions: { [SkipCache]: true },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgBE,eAAeC,MAAcC,UAAiC,CAAC,GAAwB;CACrG,EAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,sDAAsD;CAAA,EAAA,CAAEH,IAAI;CACnE,EAAAE,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mFAAmFH,MAAM;CAAA,EAAA,CACzF,OAAOA,SAAS,QAAQ;CAG1B,OAAO;EACLI,IAAI;EACJC,MAAM;GACJL,MAAMF,mBAAmBE,IAAI;GAC7BC,SAASA,WAAW,CAAC;EACvB;EACAK,cAAc,GAAGT,YAAY,KAAK;CACpC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;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BK,MAAMI,gBAAgBd,UAAU,GACzD,MAAM,IAAIY,MAAM,oDAAoD;CAGtE,IAAI,CAACH,SACHA,UAAU,CAAC;CAEb,IAAIO,YAA8D;CAElE,MAAMf,QAAQS,MAAMT;CACpB,IAAIA,MAAME,MAAMH,UAAU,GACxBgB,YAAY;MACP,IAAIf,MAAMG,UAAUJ,UAAU,GACnCgB,YAAY;CAGd,OAAO;EACLC,IAAID;EACJE,MAAM;GACJT;GACAD,QAAQR;EACV;EACAmB,SAAS,CAACnB,UAAU;EACpBoB,cAAc,GAAGtB,YAAY,KAAK;CACpC;AACF"}
1
+ {"version":3,"file":"builders.js","names":["SkipCache","normalizeModelName","findAllBuilder","type","options","test","Error","op","data","cacheOptions","constructResource","ensureStringId","SkipCache","isMaybeIdentifier","normalizeModelName","findRecordBuilder","resource","idOrOptions","options","test","Error","type","normalizedId","preload","op","data","record","cacheOptions","SkipCache","normalizeModelName","queryBuilder","type","query","options","test","Error","op","data","cacheOptions","queryRecordBuilder","recordIdentifierFor","storeFor","assertPrivateStore","SkipCache","_resourceIsFullDeleted","identifier","cache","isDeletionCommitted","isNew","isDeleted","resourceIsFullyDeleted","instanceCache","saveRecordBuilder","record","options","store","test","Error","lid","_instanceCache","recordIsLoaded","operation","op","data","records","cacheOptions"],"sources":["../../../../src/compat/builders/find-all.ts","../../../../src/compat/builders/find-record.ts","../../../../src/compat/builders/query.ts","../../../../src/compat/builders/save-record.ts"],"sourcesContent":["import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { FindAllOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype FindAllRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'findAll';\n data: {\n type: T;\n options: FindAllBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindAllBuilderOptions = FindAllOptions;\n\n/**\n This function builds a request config to perform a `findAll` request for the given type.\n When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.\n Additionally, it takes the same options as `store.findAll`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.findAll`, easing\n migration off adapters and serializers.\n @deprecated\n @public\n @param type the name of the resource\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.findAll\n @return request config\n*/\nexport function findAllBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n options?: FindAllBuilderOptions\n): FindAllRequestInput<TypeFromInstance<T>, T[]>;\nexport function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;\nexport function findAllBuilder(type: string, options: FindAllBuilderOptions = {}): FindAllRequestInput {\n assert(`You need to pass a model name to the findAll builder`, type);\n assert(\n `Model name passed to the findAll builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'findAll',\n data: {\n type: normalizeModelName(type),\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { constructResource, ensureStringId } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions, FindRecordOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { ResourceIdentifierObject } from '@warp-drive/core/types/spec/json-api-raw';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { isMaybeIdentifier, normalizeModelName } from './utils.ts';\n\ntype FindRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'findRecord';\n data: {\n record: ResourceIdentifierObject<T>;\n options: FindRecordBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindRecordBuilderOptions = Omit<FindRecordOptions, 'preload'>;\n\n/**\n This function builds a request config to find the record for a given identifier or type and id combination.\n When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.\n Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).\n\n **Example 1**\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));\n ```\n\n **Example 2**\n\n `findRecord` can be called with a single identifier argument instead of the combination\n of `type` (modelName) and `id` as separate arguments. You may recognize this combo as\n the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));\n ```\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Warp Drive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.findRecord`, taking a\n type and id or a resource identifier.\n @deprecated\n @public\n @param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record\n @param id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved\n @param options - if the first param is a string this will be the optional options for the request. See examples for available options.\n @return request config\n*/\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(type: string, id: string, options?: FindRecordBuilderOptions): FindRecordRequestInput;\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n resource: ResourceIdentifierObject<TypeFromInstance<T>>,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(\n resource: ResourceIdentifierObject,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput;\nexport function findRecordBuilder(\n resource: string | ResourceIdentifierObject,\n idOrOptions?: string | FindRecordBuilderOptions,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder`,\n resource\n );\n if (isMaybeIdentifier(resource)) {\n options = idOrOptions as BaseFinderOptions | undefined;\n } else {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`,\n typeof resource === 'string'\n );\n const type = normalizeModelName(resource);\n const normalizedId = ensureStringId(idOrOptions as string | number);\n resource = constructResource(type, normalizedId);\n }\n\n options = options || {};\n\n assert('findRecord builder does not support options.preload', !(options as FindRecordOptions).preload);\n\n return {\n op: 'findRecord' as const,\n data: {\n record: resource,\n options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { LegacyResourceQuery, QueryOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype QueryRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'query';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype QueryBuilderOptions = QueryOptions;\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.query` request.\n Additionally, it takes the same options as `store.query`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.query`, returning the\n records matching a query object.\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput<TypeFromInstance<T>, T[]>;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options: QueryBuilderOptions = {}\n): QueryRequestInput {\n assert(`You need to pass a model name to the query builder`, type);\n assert(`You need to pass a query hash to the query builder`, query);\n assert(\n `Model name passed to the query builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'query' as const,\n data: {\n type: normalizeModelName(type),\n query,\n options: options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n\ntype QueryRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'queryRecord';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.\n Additionally, it takes the same options as `store.queryRecord`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.queryRecord`, returning\n a single record or `null` for a query object.\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput {\n assert(`You need to pass a model name to the queryRecord builder`, type);\n assert(`You need to pass a query hash to the queryRecord builder`, query);\n assert(\n `Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'queryRecord',\n data: {\n type: normalizeModelName(type),\n query,\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import { recordIdentifierFor, storeFor, type StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, type InstanceCache } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\ntype SaveRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'createRecord' | 'deleteRecord' | 'updateRecord';\n data: {\n record: ResourceKey<T>;\n options: SaveRecordBuilderOptions;\n };\n records: [ResourceKey<T>];\n [RequestSignature]?: RT;\n};\n\ntype SaveRecordBuilderOptions = Record<string, unknown>;\n\nfunction _resourceIsFullDeleted(identifier: ResourceKey, cache: Cache): boolean {\n return cache.isDeletionCommitted(identifier) || (cache.isNew(identifier) && cache.isDeleted(identifier));\n}\n\nfunction resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n return !cache || _resourceIsFullDeleted(identifier, cache);\n}\n\n/**\n This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).\n When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.\n Additionally, it takes the same options as `store.saveRecord`.\n\n All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @summary Deprecated legacy builder for a `store.request` config that creates, updates, or deletes a record\n through adapters, like the legacy `store.saveRecord`.\n @deprecated\n @public\n @param {Object} record a record to save\n @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord\n @return {SaveRecordRequestInput} request config\n*/\nexport function saveRecordBuilder<T extends TypedRecordInstance>(\n record: T,\n options: Record<string, unknown> = {}\n): SaveRecordRequestInput<TypeFromInstance<T>, T> {\n const store = storeFor(record, true);\n assertPrivateStore(store);\n assert(`Unable to initiate save for a record in a disconnected state`, store);\n const identifier = recordIdentifierFor<T>(record);\n\n if (!identifier) {\n // this commonly means we're disconnected\n // but just in case we throw here to prevent bad things.\n throw new Error(`Record Is Disconnected`);\n }\n assert(\n `Cannot initiate a save request for an unloaded record: ${identifier.lid}`,\n store._instanceCache.recordIsLoaded(identifier)\n );\n\n if (resourceIsFullyDeleted(store._instanceCache, identifier)) {\n throw new Error('cannot build saveRecord request for deleted record');\n }\n\n if (!options) {\n options = {};\n }\n let operation: 'createRecord' | 'deleteRecord' | 'updateRecord' = 'updateRecord';\n\n const cache = store.cache;\n if (cache.isNew(identifier)) {\n operation = 'createRecord';\n } else if (cache.isDeleted(identifier)) {\n operation = 'deleteRecord';\n }\n\n return {\n op: operation,\n data: {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,cAAcL;CAC5B,OAAO,CAACA,SAASF,uBAAuBC,YAAYC,KAAK;AAC3D;;;;;;;;;;;;;;;;;;AAmBA,SAAgBM,kBACdC,QACAC,UAAmC,CAAC,GACY;CAChD,MAAMC,QAAQd,SAASY,QAAQ,IAAI;CACnCX,mBAAmBa,KAAK;CACxB,EAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,8DAA8D;CAAA,EAAA,CAAEF,KAAK;CAC5E,MAAMV,aAAaL,oBAAuBa,MAAM;CAEhD,IAAI,CAACR,YAGH,MAAM,IAAIY,MAAM,wBAAwB;CAE1C,EAAAD,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,0DAA0DZ,WAAWa,KAAK;CAAA,EAAA,CAC1EH,MAAMI,eAAeC,eAAef,UAAU,CAAC;CAGjD,IAAIK,uBAAuBK,MAAMI,gBAAgBd,UAAU,GACzD,MAAM,IAAIY,MAAM,oDAAoD;CAGtE,IAAI,CAACH,SACHA,UAAU,CAAC;CAEb,IAAIO,YAA8D;CAElE,MAAMf,QAAQS,MAAMT;CACpB,IAAIA,MAAME,MAAMH,UAAU,GACxBgB,YAAY;MACP,IAAIf,MAAMG,UAAUJ,UAAU,GACnCgB,YAAY;CAGd,OAAO;EACLC,IAAID;EACJE,MAAM;GACJT;GACAD,QAAQR;EACV;EACAmB,SAAS,CAACnB,UAAU;EACpBoB,cAAc,GAAGtB,YAAY,KAAK;CACpC;AACF"}
@@ -2,7 +2,12 @@ import { get, getProperties, notifyPropertyChange, set, setProperties } from "@e
2
2
  import { addObserver, removeObserver } from "@ember/object/observers";
3
3
  import { compare } from "@ember/utils";
4
4
 
5
- //#region src/compat/extensions.ts
5
+ // src/compat/extensions.ts
6
+ /**
7
+ * @module
8
+ * @summary Legacy schema extensions that give reactive objects and arrays the classic `EmberObject` and Ember array
9
+ * APIs, such as `get`, `set` and `mapBy`, plus matching types.
10
+ */
6
11
  const EmberObjectFeatures = {};
7
12
  [
8
13
  "addObserver",
@@ -55,6 +60,9 @@ const EmberObjectFeatures = {};
55
60
  * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,
56
61
  * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)
57
62
  * to reactive array resources.
63
+ *
64
+ * @summary Legacy schema extension that gives reactive arrays the classic `EmberObject` API such as `get`, `set`,
65
+ * and observers, to ease migration from Ember objects.
58
66
  */
59
67
  const EmberObjectArrayExtension = {
60
68
  kind: "array",
@@ -66,6 +74,9 @@ const EmberObjectArrayExtension = {
66
74
  * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,
67
75
  * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)
68
76
  * to reactive object resources.
77
+ *
78
+ * @summary Legacy schema extension that gives reactive objects the classic `EmberObject` API such as `get`, `set`,
79
+ * and observers, to ease migration from Ember objects.
69
80
  */
70
81
  const EmberObjectExtension = {
71
82
  kind: "object",
@@ -258,6 +269,9 @@ const EmberArrayLikeFeatures = {
258
269
  * A schema extension that adds Ember's classic `MutableArray`/`Enumerable`
259
270
  * style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,
260
271
  * `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.
272
+ *
273
+ * @summary Legacy schema extension that gives reactive arrays Ember array methods such as `pushObject`, `mapBy`,
274
+ * `filterBy`, and `firstObject`.
261
275
  */
262
276
  const EmberArrayLikeExtension = {
263
277
  kind: "array",
@@ -266,15 +280,22 @@ const EmberArrayLikeExtension = {
266
280
  };
267
281
  /**
268
282
  * Extracts the element type of an array type, or `never` if `T` is not an array.
283
+ *
284
+ * @summary Type utility resolving to the element type of an array type, or `never` for non-arrays.
269
285
  */
270
286
  /**
271
287
  * Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/
272
288
  * {@link EmberObjectArrayExtension}) to the type of a reactive resource.
289
+ *
290
+ * @summary Legacy type that adds the classic `EmberObject` methods to a reactive resource type using
291
+ * `EmberObjectExtension` or `EmberObjectArrayExtension`.
273
292
  */
274
293
  /**
275
294
  * Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})
276
295
  * to the type of a reactive array resource.
296
+ *
297
+ * @summary Legacy type that adds Ember array methods such as `mapBy` and `firstObject` to a reactive array type
298
+ * using `EmberArrayLikeExtension`.
277
299
  */
278
- //#endregion
279
300
  export { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension };
280
301
  //# sourceMappingURL=extensions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.js","names":["get","getProperties","notifyPropertyChange","set","setProperties","addObserver","removeObserver","compare","EmberObjectFeatures","EmberObjectMethods","forEach","method","delegatedMethod","args","Error","keyName","decrement","test","isNaN","parseFloat","isFinite","increment","String","key","EmberObjectArrayExtension","kind","name","features","EmberObjectExtension","EmberArrayLikeFeatures","addObject","obj","index","indexOf","push","addObjects","objs","popObject","pop","pushObject","pushObjects","shiftObject","shift","unshiftObject","unshift","unshiftObjects","objectAt","arrIndex","Math","sign","length","objectsAt","indices","map","removeAt","splice","insertAt","removeObject","removeObjects","toArray","slice","replace","idx","amt","objects","clear","setObjects","Array","isArray","reverseObjects","reverse","compact","filter","v","undefined","any","callback","target","some","isAny","prop","value","hasValue","arguments","isEvery","every","getEach","mapBy","findBy","find","val","Boolean","filterBy","record","sortBy","sortKeys","sort","a","b","i","propA","propB","compareValue","invoke","addArrayObserver","removeArrayObserver","arrayContentWillChange","arrayContentDidChange","reject","apply","rejectBy","setEach","item","uniq","from","Set","uniqBy","seen","result","has","add","without","newArr","firstObject","at","lastObject","EmberArrayLikeExtension"],"sources":["../../../../src/compat/extensions.ts"],"sourcesContent":["import {\n type default as EmberObject,\n get,\n getProperties,\n notifyPropertyChange,\n set,\n setProperties,\n} from '@ember/object';\nimport { addObserver, removeObserver } from '@ember/object/observers';\nimport { compare } from '@ember/utils';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension } from '@warp-drive/core/reactive';\n\nconst EmberObjectFeatures = {};\nconst EmberObjectMethods = [\n 'addObserver',\n 'cacheFor',\n 'decrementProperty',\n 'get',\n 'getProperties',\n 'incrementProperty',\n 'notifyPropertyChange',\n 'removeObserver',\n 'set',\n 'setProperties',\n 'toggleProperty',\n] as const;\nEmberObjectMethods.forEach((method) => {\n EmberObjectFeatures[method] = function delegatedMethod(...args: unknown[]): unknown {\n switch (method) {\n case 'addObserver':\n return (addObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'cacheFor':\n throw new Error('cacheFor has been removed and will not be replaced');\n case 'decrementProperty': {\n const keyName = args[0] as string;\n const decrement = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to decrementProperty',\n (typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement)\n );\n return set(this, keyName, ((get(this, keyName) as number) || 0) - decrement);\n }\n case 'get':\n // the cast is required: without it, TS resolves `get` to an overload whose\n // parameter list isn't a rest/tuple, and the spread below fails to typecheck\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion\n return (get as (...args: unknown[]) => unknown)(this, ...args);\n case 'getProperties':\n return (getProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'incrementProperty': {\n const keyName = args[0] as string;\n const increment = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to incrementProperty',\n !isNaN(parseFloat(String(increment))) && isFinite(increment)\n );\n return set(this, keyName, (parseFloat(get(this, keyName) as string) || 0) + increment);\n }\n case 'notifyPropertyChange':\n return (notifyPropertyChange as (...args: unknown[]) => unknown)(this, ...args);\n case 'removeObserver':\n return (removeObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'set':\n return (set as (...args: unknown[]) => unknown)(this, ...args);\n case 'setProperties':\n return (setProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'toggleProperty': {\n const key = args[0] as string;\n return set(this, key, !get(this, key));\n }\n }\n };\n});\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive array resources.\n */\nexport const EmberObjectArrayExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive object resources.\n */\nexport const EmberObjectExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'object',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n\nconst EmberArrayLikeFeatures = {\n addObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n return this;\n },\n\n addObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj: T) => {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n });\n return this;\n },\n\n popObject<T>(this: T[]): T | undefined {\n return this.pop();\n },\n\n pushObject<T>(this: T[], obj: T): T {\n this.push(obj);\n return obj;\n },\n\n pushObjects<T>(this: T[], objs: T[]): T[] {\n this.push(...objs);\n return this;\n },\n\n shiftObject<T>(this: T[]): NonNullable<T> {\n return this.shift()!;\n },\n\n unshiftObject<T>(this: T[], obj: T): T {\n this.unshift(obj);\n return obj;\n },\n\n unshiftObjects<T>(this: T[], objs: T[]): T[] {\n this.unshift(...objs);\n return this;\n },\n\n objectAt<T>(this: T[], index: number): T {\n //For negative index values go back from the end of the array\n const arrIndex = Math.sign(index) === -1 ? this.length + index : index;\n\n return this[arrIndex];\n },\n\n objectsAt<T>(this: T[], indices: number[]): T[] {\n // @ts-expect-error adding MutableArray method\n // oxlint-disable-next-line typescript/no-unsafe-return, typescript/no-unsafe-call\n return indices.map((index) => this.objectAt(index)!);\n },\n\n removeAt<T>(this: T[], index: number): T[] {\n this.splice(index, 1);\n return this;\n },\n\n insertAt<T>(this: T[], index: number, obj: T): T[] {\n this.splice(index, 0, obj);\n return this;\n },\n\n removeObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n return this;\n },\n\n removeObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj) => {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n });\n return this;\n },\n\n toArray<T>(this: T[]): T[] {\n return this.slice();\n },\n\n replace<T>(this: T[], idx: number, amt: number, objects?: T[]): void {\n if (objects) {\n this.splice(idx, amt, ...objects);\n } else {\n this.splice(idx, amt);\n }\n },\n\n clear<T>(this: T[]): T[] {\n this.splice(0, this.length);\n return this;\n },\n\n setObjects<T>(this: T[], objects: T[]): T[] {\n assert(`setObjects expects to receive an array as its argument`, Array.isArray(objects));\n this.splice(0, this.length);\n this.push(...objects);\n return this;\n },\n\n reverseObjects<T>(this: T[]): T[] {\n this.reverse();\n return this;\n },\n\n compact<T>(this: T[]): (T & {})[] {\n return this.filter((v) => v !== null && v !== undefined);\n },\n\n any<T>(this: T[], callback: Parameters<Array<T>['some']>[0], target?: unknown): boolean {\n return this.some(callback, target);\n },\n\n isAny<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).some((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n isEvery<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).every((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n getEach<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n mapBy<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n findBy<T>(this: T[], key: string, value?: unknown): T | undefined {\n if (arguments.length === 2) {\n return this.find((val) => {\n return get(val, key) === value;\n });\n } else {\n return this.find((val) => Boolean(get(val, key)));\n }\n },\n\n filterBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) === value;\n });\n }\n\n return this.filter((record) => {\n return Boolean(get(record, key));\n });\n },\n\n sortBy<T>(this: T[], ...sortKeys: string[]): T[] {\n return this.slice().sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n const key = sortKeys[i];\n\n const propA = get(a, key);\n\n const propB = get(b, key);\n // return 1 or -1 else continue to the next sortKey\n const compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n },\n\n invoke<T>(this: T[], key: string, ...args: unknown[]): unknown[] {\n return (this as unknown as Array<Record<string, unknown>>).map((value) =>\n (value[key] as (...args: unknown[]) => unknown)(...args)\n );\n },\n\n addArrayObserver<T>(this: T[]): void {},\n\n removeArrayObserver<T>(this: T[]): void {},\n\n arrayContentWillChange<T>(this: T[]): void {},\n\n arrayContentDidChange<T>(this: T[]): void {},\n\n reject<T>(this: T[], callback: Parameters<Array<T>['filter']>[0], target?: unknown): T[] {\n assert('`reject` expects a function as first argument.', typeof callback === 'function');\n\n return this.filter((...args) => {\n return !callback.apply(target, args);\n });\n },\n\n rejectBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) !== value;\n });\n }\n\n return this.filter((record) => {\n return !get(record, key);\n });\n },\n\n setEach<T>(this: T[], key: string, value: unknown): void {\n (this as unknown as Array<Record<string, unknown>>).forEach((item) => set(item, key, value));\n },\n\n uniq<T>(this: T[]): T[] {\n return Array.from(new Set(this));\n },\n\n uniqBy<T>(this: T[], key: string): T[] {\n const seen = new Set();\n const result: T[] = [];\n this.forEach((item) => {\n const value = get(item, key);\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n result.push(item);\n });\n return result;\n },\n\n without<T>(this: T[], value: T): T[] {\n const newArr = this.slice();\n const index = this.indexOf(value);\n if (index !== -1) {\n newArr.splice(index, 1);\n }\n\n return newArr;\n },\n\n get firstObject(): unknown {\n return (this as unknown as unknown[]).at(0);\n },\n\n get lastObject(): unknown {\n return (this as unknown as unknown[]).at(-1);\n },\n};\n\n/**\n * A schema extension that adds Ember's classic `MutableArray`/`Enumerable`\n * style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,\n * `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.\n */\nexport const EmberArrayLikeExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-array-like' as const,\n features: EmberArrayLikeFeatures,\n};\n\n/**\n * Extracts the element type of an array type, or `never` if `T` is not an array.\n */\nexport type ArrayType<T> = T extends ReadonlyArray<infer U> ? U : never;\n/**\n * Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/\n * {@link EmberObjectArrayExtension}) to the type of a reactive resource.\n */\nexport type WithEmberObject<T> = T & Pick<T & EmberObject, ArrayType<typeof EmberObjectMethods>>;\n\n/**\n * Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})\n * to the type of a reactive array resource.\n */\nexport type WithArrayLike<T> =\n T extends Array<infer U>\n ? U &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n }\n : T[] &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n };\n"],"mappings":";;;;;AAcA,MAAMQ,sBAAsB,CAAC;AAc7BC;CAZE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEFA,CAAkB,CAACC,SAASC,WAAW;CACrCH,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AAKC,QAAQgD,KAAK;EAChC,IAAIjD,UAAU,IACZ0F,OAAOnE,OAAOvB,OAAO,CAAC;EAGxB,OAAO0F;CACT;CAEA,IAAIC,cAAuB;EACzB,OAAQ,KAA8BC,GAAG,CAAC;CAC5C;CAEA,IAAIC,aAAsB;EACxB,OAAQ,KAA8BD,GAAG,EAAE;CAC7C;AACF;;;;;;AAOA,MAAaE,0BAA8D;CACzErG,MAAM;CACNC,MAAM;CACNC,UAAUE;AACZ"}
1
+ {"version":3,"file":"extensions.js","names":["get","getProperties","notifyPropertyChange","set","setProperties","addObserver","removeObserver","compare","EmberObjectFeatures","EmberObjectMethods","forEach","method","delegatedMethod","args","Error","keyName","decrement","test","isNaN","parseFloat","isFinite","increment","String","key","EmberObjectArrayExtension","kind","name","features","EmberObjectExtension","EmberArrayLikeFeatures","addObject","obj","index","indexOf","push","addObjects","objs","popObject","pop","pushObject","pushObjects","shiftObject","shift","unshiftObject","unshift","unshiftObjects","objectAt","arrIndex","Math","sign","length","objectsAt","indices","map","removeAt","splice","insertAt","removeObject","removeObjects","toArray","slice","replace","idx","amt","objects","clear","setObjects","Array","isArray","reverseObjects","reverse","compact","filter","v","undefined","any","callback","target","some","isAny","prop","value","hasValue","arguments","isEvery","every","getEach","mapBy","findBy","find","val","Boolean","filterBy","record","sortBy","sortKeys","sort","a","b","i","propA","propB","compareValue","invoke","addArrayObserver","removeArrayObserver","arrayContentWillChange","arrayContentDidChange","reject","apply","rejectBy","setEach","item","uniq","from","Set","uniqBy","seen","result","has","add","without","newArr","firstObject","at","lastObject","EmberArrayLikeExtension"],"sources":["../../../../src/compat/extensions.ts"],"sourcesContent":["/**\n * @module\n * @summary Legacy schema extensions that give reactive objects and arrays the classic `EmberObject` and Ember array\n * APIs, such as `get`, `set` and `mapBy`, plus matching types.\n */\n\nimport {\n type default as EmberObject,\n get,\n getProperties,\n notifyPropertyChange,\n set,\n setProperties,\n} from '@ember/object';\nimport { addObserver, removeObserver } from '@ember/object/observers';\nimport { compare } from '@ember/utils';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension } from '@warp-drive/core/reactive';\n\nconst EmberObjectFeatures = {};\nconst EmberObjectMethods = [\n 'addObserver',\n 'cacheFor',\n 'decrementProperty',\n 'get',\n 'getProperties',\n 'incrementProperty',\n 'notifyPropertyChange',\n 'removeObserver',\n 'set',\n 'setProperties',\n 'toggleProperty',\n] as const;\nEmberObjectMethods.forEach((method) => {\n EmberObjectFeatures[method] = function delegatedMethod(...args: unknown[]): unknown {\n switch (method) {\n case 'addObserver':\n return (addObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'cacheFor':\n throw new Error('cacheFor has been removed and will not be replaced');\n case 'decrementProperty': {\n const keyName = args[0] as string;\n const decrement = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to decrementProperty',\n (typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement)\n );\n return set(this, keyName, ((get(this, keyName) as number) || 0) - decrement);\n }\n case 'get':\n // the cast is required: without it, TS resolves `get` to an overload whose\n // parameter list isn't a rest/tuple, and the spread below fails to typecheck\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion\n return (get as (...args: unknown[]) => unknown)(this, ...args);\n case 'getProperties':\n return (getProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'incrementProperty': {\n const keyName = args[0] as string;\n const increment = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to incrementProperty',\n !isNaN(parseFloat(String(increment))) && isFinite(increment)\n );\n return set(this, keyName, (parseFloat(get(this, keyName) as string) || 0) + increment);\n }\n case 'notifyPropertyChange':\n return (notifyPropertyChange as (...args: unknown[]) => unknown)(this, ...args);\n case 'removeObserver':\n return (removeObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'set':\n return (set as (...args: unknown[]) => unknown)(this, ...args);\n case 'setProperties':\n return (setProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'toggleProperty': {\n const key = args[0] as string;\n return set(this, key, !get(this, key));\n }\n }\n };\n});\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive array resources.\n *\n * @summary Legacy schema extension that gives reactive arrays the classic `EmberObject` API such as `get`, `set`,\n * and observers, to ease migration from Ember objects.\n */\nexport const EmberObjectArrayExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive object resources.\n *\n * @summary Legacy schema extension that gives reactive objects the classic `EmberObject` API such as `get`, `set`,\n * and observers, to ease migration from Ember objects.\n */\nexport const EmberObjectExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'object',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n\nconst EmberArrayLikeFeatures = {\n addObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n return this;\n },\n\n addObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj: T) => {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n });\n return this;\n },\n\n popObject<T>(this: T[]): T | undefined {\n return this.pop();\n },\n\n pushObject<T>(this: T[], obj: T): T {\n this.push(obj);\n return obj;\n },\n\n pushObjects<T>(this: T[], objs: T[]): T[] {\n this.push(...objs);\n return this;\n },\n\n shiftObject<T>(this: T[]): NonNullable<T> {\n return this.shift()!;\n },\n\n unshiftObject<T>(this: T[], obj: T): T {\n this.unshift(obj);\n return obj;\n },\n\n unshiftObjects<T>(this: T[], objs: T[]): T[] {\n this.unshift(...objs);\n return this;\n },\n\n objectAt<T>(this: T[], index: number): T {\n //For negative index values go back from the end of the array\n const arrIndex = Math.sign(index) === -1 ? this.length + index : index;\n\n return this[arrIndex];\n },\n\n objectsAt<T>(this: T[], indices: number[]): T[] {\n // @ts-expect-error adding MutableArray method\n // oxlint-disable-next-line typescript/no-unsafe-return, typescript/no-unsafe-call\n return indices.map((index) => this.objectAt(index)!);\n },\n\n removeAt<T>(this: T[], index: number): T[] {\n this.splice(index, 1);\n return this;\n },\n\n insertAt<T>(this: T[], index: number, obj: T): T[] {\n this.splice(index, 0, obj);\n return this;\n },\n\n removeObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n return this;\n },\n\n removeObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj) => {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n });\n return this;\n },\n\n toArray<T>(this: T[]): T[] {\n return this.slice();\n },\n\n replace<T>(this: T[], idx: number, amt: number, objects?: T[]): void {\n if (objects) {\n this.splice(idx, amt, ...objects);\n } else {\n this.splice(idx, amt);\n }\n },\n\n clear<T>(this: T[]): T[] {\n this.splice(0, this.length);\n return this;\n },\n\n setObjects<T>(this: T[], objects: T[]): T[] {\n assert(`setObjects expects to receive an array as its argument`, Array.isArray(objects));\n this.splice(0, this.length);\n this.push(...objects);\n return this;\n },\n\n reverseObjects<T>(this: T[]): T[] {\n this.reverse();\n return this;\n },\n\n compact<T>(this: T[]): (T & {})[] {\n return this.filter((v) => v !== null && v !== undefined);\n },\n\n any<T>(this: T[], callback: Parameters<Array<T>['some']>[0], target?: unknown): boolean {\n return this.some(callback, target);\n },\n\n isAny<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).some((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n isEvery<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).every((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n getEach<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n mapBy<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n findBy<T>(this: T[], key: string, value?: unknown): T | undefined {\n if (arguments.length === 2) {\n return this.find((val) => {\n return get(val, key) === value;\n });\n } else {\n return this.find((val) => Boolean(get(val, key)));\n }\n },\n\n filterBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) === value;\n });\n }\n\n return this.filter((record) => {\n return Boolean(get(record, key));\n });\n },\n\n sortBy<T>(this: T[], ...sortKeys: string[]): T[] {\n return this.slice().sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n const key = sortKeys[i];\n\n const propA = get(a, key);\n\n const propB = get(b, key);\n // return 1 or -1 else continue to the next sortKey\n const compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n },\n\n invoke<T>(this: T[], key: string, ...args: unknown[]): unknown[] {\n return (this as unknown as Array<Record<string, unknown>>).map((value) =>\n (value[key] as (...args: unknown[]) => unknown)(...args)\n );\n },\n\n addArrayObserver<T>(this: T[]): void {},\n\n removeArrayObserver<T>(this: T[]): void {},\n\n arrayContentWillChange<T>(this: T[]): void {},\n\n arrayContentDidChange<T>(this: T[]): void {},\n\n reject<T>(this: T[], callback: Parameters<Array<T>['filter']>[0], target?: unknown): T[] {\n assert('`reject` expects a function as first argument.', typeof callback === 'function');\n\n return this.filter((...args) => {\n return !callback.apply(target, args);\n });\n },\n\n rejectBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) !== value;\n });\n }\n\n return this.filter((record) => {\n return !get(record, key);\n });\n },\n\n setEach<T>(this: T[], key: string, value: unknown): void {\n (this as unknown as Array<Record<string, unknown>>).forEach((item) => set(item, key, value));\n },\n\n uniq<T>(this: T[]): T[] {\n return Array.from(new Set(this));\n },\n\n uniqBy<T>(this: T[], key: string): T[] {\n const seen = new Set();\n const result: T[] = [];\n this.forEach((item) => {\n const value = get(item, key);\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n result.push(item);\n });\n return result;\n },\n\n without<T>(this: T[], value: T): T[] {\n const newArr = this.slice();\n const index = this.indexOf(value);\n if (index !== -1) {\n newArr.splice(index, 1);\n }\n\n return newArr;\n },\n\n get firstObject(): unknown {\n return (this as unknown as unknown[]).at(0);\n },\n\n get lastObject(): unknown {\n return (this as unknown as unknown[]).at(-1);\n },\n};\n\n/**\n * A schema extension that adds Ember's classic `MutableArray`/`Enumerable`\n * style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,\n * `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.\n *\n * @summary Legacy schema extension that gives reactive arrays Ember array methods such as `pushObject`, `mapBy`,\n * `filterBy`, and `firstObject`.\n */\nexport const EmberArrayLikeExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-array-like' as const,\n features: EmberArrayLikeFeatures,\n};\n\n/**\n * Extracts the element type of an array type, or `never` if `T` is not an array.\n *\n * @summary Type utility resolving to the element type of an array type, or `never` for non-arrays.\n */\nexport type ArrayType<T> = T extends ReadonlyArray<infer U> ? U : never;\n/**\n * Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/\n * {@link EmberObjectArrayExtension}) to the type of a reactive resource.\n *\n * @summary Legacy type that adds the classic `EmberObject` methods to a reactive resource type using\n * `EmberObjectExtension` or `EmberObjectArrayExtension`.\n */\nexport type WithEmberObject<T> = T & Pick<T & EmberObject, ArrayType<typeof EmberObjectMethods>>;\n\n/**\n * Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})\n * to the type of a reactive array resource.\n *\n * @summary Legacy type that adds Ember array methods such as `mapBy` and `firstObject` to a reactive array type\n * using `EmberArrayLikeExtension`.\n */\nexport type WithArrayLike<T> =\n T extends Array<infer U>\n ? U &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n }\n : T[] &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n };\n"],"mappings":";;;;;;;;;;AAoBA,MAAMQ,sBAAsB,CAAC;AAc7BC;CAZE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEFA,CAAkB,CAACC,SAASC,WAAW;CACrCH,oBAAoBG,UAAU,SAASC,gBAAgB,GAAGC,MAA0B;EAClF,QAAQF,QAAR;GACE,KAAK,eACH,OAAQN,YAAgD,MAAM,GAAGQ,IAAI;GACvE,KAAK,YACH,MAAM,IAAIC,MAAM,oDAAoD;GACtE,KAAK,qBAAqB;IACxB,MAAMC,UAAUF,KAAK;IACrB,MAAMG,YAAaH,KAAK,MAAiB;IACzC,EAAAI,SAAA;KAAA,IAAA,CAAAA,MAAA,MAAA,IAAAH,MACE,gDAAgD;IAAA,EAAA,EAC/C,OAAOE,cAAc,YAAY,CAACE,MAAMC,WAAWH,SAAS,CAAC,MAAMI,SAASJ,SAAS,CAAC;IAEzF,OAAOb,IAAI,MAAMY,UAAWf,IAAI,MAAMe,OAAO,KAAgB,KAAKC,SAAS;GAC7E;GACA,KAAK,OAIH,OAAQhB,IAAwC,MAAM,GAAGa,IAAI;GAC/D,KAAK,iBACH,OAAQZ,cAAkD,MAAM,GAAGY,IAAI;GACzE,KAAK,qBAAqB;IACxB,MAAME,UAAUF,KAAK;IACrB,MAAMQ,YAAaR,KAAK,MAAiB;IACzC,EAAAI,SAAA;KAAA,I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AAa0D,OAAsB;EACtD,KAAmDvE,SAASsG,SAAS7G,IAAI6G,MAAMzF,KAAK0D,KAAK,CAAC;CAC7F;CAEAgC,OAAwB;EACtB,OAAO9C,MAAM+C,KAAK,IAAIC,IAAI,IAAI,CAAC;CACjC;CAEAC,OAAqB7F,KAAkB;EACrC,MAAM8F,uBAAO,IAAIF,IAAI;EACrB,MAAMG,SAAc,CAAA;EACpB,KAAK5G,SAASsG,SAAS;GACrB,MAAM/B,QAAQjF,IAAIgH,MAAMzF,GAAG;GAC3B,IAAI8F,KAAKE,IAAItC,KAAK,GAChB;GAEFoC,KAAKG,IAAIvC,KAAK;GACdqC,OAAOpF,KAAK8E,IAAI;EAClB,CAAC;EACD,OAAOM;CACT;CAEAG,QAAsBxC,OAAe;EACnC,MAAMyC,SAAS,KAAK9D,MAAM;EAC1B,MAAM5B,QAAQ,KAAKC,QAAQgD,KAAK;EAChC,IAAIjD,UAAU,IACZ0F,OAAOnE,OAAOvB,OAAO,CAAC;EAGxB,OAAO0F;CACT;CAEA,IAAIC,cAAuB;EACzB,OAAQ,KAA8BC,GAAG,CAAC;CAC5C;CAEA,IAAIC,aAAsB;EACxB,OAAQ,KAA8BD,GAAG,EAAE;CAC7C;AACF;;;;;;;;;AAUA,MAAaE,0BAA8D;CACzErG,MAAM;CACNC,MAAM;CACNC,UAAUE;AACZ"}
@@ -1,10 +1,12 @@
1
1
  import { dasherize, singularize } from "@warp-drive/utilities/string";
2
2
 
3
- //#region src/compat/utils.ts
3
+ // src/compat/utils.ts
4
4
  /**
5
5
  Utilities for helping to migrate to stricter
6
6
  and more consistent use of IDs and types.
7
7
 
8
+ @summary Legacy helpers that normalize, compare, and report mismatched resource ids and types while migrating to
9
+ stricter formats.
8
10
  @module
9
11
  */
10
12
  let MismatchReporter = function() {};
@@ -23,6 +25,8 @@ let NormalizedType = (str) => {
23
25
  * changes during normalization. This is useful for instrumenting
24
26
  * to discover places where usage in the app is not consistent.
25
27
  *
28
+ * @summary Legacy migration helper that registers a callback invoked whenever `formattedId` or `formattedType`
29
+ * has to change the id or type it was given.
26
30
  * @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
27
31
  * @public
28
32
  */
@@ -34,6 +38,8 @@ function configureMismatchReporter(fn) {
34
38
  * fails validation. This is useful for instrumenting
35
39
  * to discover places where usage in the app is not consistent.
36
40
  *
41
+ * @summary Legacy migration helper that registers a callback invoked when an id or type passed to these utilities
42
+ * fails validation.
37
43
  * @param fn - a function which takes a message and a condition
38
44
  * @public
39
45
  */
@@ -50,6 +56,8 @@ function configureAssertFn(fn) {
50
56
  * the configured mismatch reporter and assert functions will
51
57
  * be called.
52
58
  *
59
+ * @summary Legacy migration helper that replaces the singularize-and-dasherize function `formattedType` and
60
+ * `isEquivType` use to normalize resource types.
53
61
  * @param fn - a function which takes a string and returns a string
54
62
  * @public
55
63
  */
@@ -82,6 +90,8 @@ const NORMALIZED_TYPES = /* @__PURE__ */ new Map();
82
90
  * formattedType('PostComment'); // => 'post-comment'
83
91
  * ```
84
92
  *
93
+ * @summary Legacy migration helper that normalizes a resource type to the singular dasherized form the cache
94
+ * expects, such as `'PostComments'` to `'post-comment'`.
85
95
  * @param type the potentially un-normalized type
86
96
  * @return the normalized type
87
97
  * @public
@@ -115,6 +125,8 @@ function formattedType(type) {
115
125
  * formattedId(null); // => null
116
126
  * ```
117
127
  *
128
+ * @summary Legacy migration helper that normalizes a resource id to the `string` or `null` the cache expects,
129
+ * asserting on invalid ids such as `''` or `0`.
118
130
  * @param id the potentially un-normalized id
119
131
  * @return the normalized id
120
132
  * @public
@@ -132,6 +144,8 @@ function formattedId(id) {
132
144
  * Like {@link formattedId}, but asserts that `id` is not `null` rather
133
145
  * than allowing and passing through `null`.
134
146
  *
147
+ * @summary Legacy migration helper that normalizes a resource id to a string like `formattedId`, but asserts that
148
+ * it is not `null`.
135
149
  * @public
136
150
  */
137
151
  /**
@@ -163,6 +177,8 @@ function expectId(id) {
163
177
  * isEquivType('posts', null); // false
164
178
  * ```
165
179
  *
180
+ * @summary Legacy migration helper that reports whether two resource types match after normalization, so
181
+ * `'posts'` and `'post'` are equivalent.
166
182
  * @param expected a potentially unnormalized type to match against
167
183
  * @param actual a potentially unnormalized type to match against
168
184
  * @return true if the types are equivalent
@@ -195,6 +211,8 @@ function isEquivType(expected, actual) {
195
211
  * isEquivId(1, null); // false
196
212
  * ```
197
213
  *
214
+ * @summary Legacy migration helper that reports whether two resource ids match after normalization, so `1` and
215
+ * `'1'` are equivalent.
198
216
  * @param expected a potentially un-normalized id to match against
199
217
  * @param actual a potentially un-normalized id to match against
200
218
  * @return true if the ids are equivalent
@@ -213,6 +231,5 @@ function isEquivId(expected, actual) {
213
231
  return expected === actual || formattedId(expected) === formattedId(actual);
214
232
  }
215
233
 
216
- //#endregion
217
234
  export { configureAssertFn, configureMismatchReporter, configureTypeNormalization, expectId, formattedId, formattedType, isEquivId, isEquivType };
218
235
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["dasherize","singularize","MismatchReporter","_AssertFn","AssertFn","message","condition","test","Error","NormalizedType","str","configureMismatchReporter","fn","configureAssertFn","configureTypeNormalization","NORMALIZED_TYPES","Map","formattedType","type","undefined","length","normalized","get","set","formattedId","id","formatted","String","expectId","isEquivType","expected","actual","isEquivId"],"sources":["../../../../src/compat/utils.ts"],"sourcesContent":["/**\n Utilities for helping to migrate to stricter\n and more consistent use of IDs and types.\n\n @module\n*/\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\ninterface AssertFunc {\n (desc: string, condition: unknown): asserts condition;\n (desc: string): never;\n}\n\ntype Reporter = (type: 'formatted-id' | 'formatted-type', actual: unknown, expected: unknown) => void;\ntype Normalizer = (type: string) => string;\n\nlet MismatchReporter: Reporter = function () {};\n\n// TODO: @runspired This pattern prevents AssertFn from being removed in production builds\n// but we should enable that if we can.\nlet _AssertFn: (message: string, condition: unknown) => void = function () {};\nconst AssertFn: AssertFunc = ((message: string, condition: unknown) => {\n if (!condition) {\n _AssertFn(message, condition);\n }\n assert(message, condition);\n}) as unknown as AssertFunc;\nlet NormalizedType: Normalizer = (str: string) => {\n return singularize(dasherize(str));\n};\n\n/**\n * Configure a function to be called when an id or type\n * changes during normalization. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value\n * @public\n */\nexport function configureMismatchReporter(fn: Reporter): void {\n MismatchReporter = fn;\n}\n\n/**\n * Configure a function to be called when an id or type\n * fails validation. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @param fn - a function which takes a message and a condition\n * @public\n */\nexport function configureAssertFn(fn: (message: string, condition: unknown) => void): void {\n _AssertFn = fn;\n}\n\n/**\n * Configure a function to be called to normalize\n * a resource type string. Used by both formattedType\n * and isEquivType to ensure consistent normalization\n * during comparison.\n *\n * If validation fails or the type turns out be unnormalized\n * the configured mismatch reporter and assert functions will\n * be called.\n *\n * @param fn - a function which takes a string and returns a string\n * @public\n */\nexport function configureTypeNormalization(fn: (type: string) => string): void {\n NormalizedType = fn;\n}\n\nconst NORMALIZED_TYPES = new Map<string, string>();\n\n/**\n * Converts a potentially unnormalized type into the format expected\n * by our WarpDrive Cache. Currently this is singular-dasherized.\n *\n * you should not rely on this function to give you an exact format\n * for display purposes. Formatting for display should be handled\n * differently if the exact format matters.\n *\n * Asserts invalid types (undefined, null, '') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedType from 'soxhub-client/helpers/formatted-type';\n *\n * formattedType('post'); // => 'post'\n * formattedType('posts'); // => 'post'\n * formattedType('Posts'); // => 'post'\n * formattedType('post-comment'); // => 'post-comment'\n * formattedType('post-comments'); // => 'post-comment'\n * formattedType('post_comment'); // => 'post-comment'\n * formattedType('postComment'); // => 'post-comment'\n * formattedType('PostComment'); // => 'post-comment'\n * ```\n *\n * @param type the potentially un-normalized type\n * @return the normalized type\n * @public\n */\nexport function formattedType<T extends string>(type: T | string): T {\n AssertFn('formattedType: type must not be null', type !== null);\n AssertFn('formattedType: type must not be undefined', type !== undefined);\n AssertFn('formattedType: type must be a string', typeof type === 'string');\n AssertFn('formattedType: type must not be empty', type.length > 0);\n let normalized = NORMALIZED_TYPES.get(type);\n\n if (normalized === undefined) {\n normalized = NormalizedType(type);\n NORMALIZED_TYPES.set(type, normalized);\n }\n\n if (normalized !== type) {\n MismatchReporter('formatted-type', type, normalized);\n }\n\n return normalized as T;\n}\n\n/**\n * Format an id to the format expected by the WarpDrive Cache.\n * Currently this means that id should be `string | null`.\n *\n * Asserts invalid IDs (undefined, '', 0, '0') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedId from 'client/utils/formatted-id';\n *\n * formattedId('1'); // => '1'\n * formattedId(1); // => '1'\n * formattedId(null); // => null\n *\t```\n *\n * @param id the potentially un-normalized id\n * @return the normalized id\n * @public\n */\nexport function formattedId(id: string | number): string;\nexport function formattedId(id: null): null;\nexport function formattedId(id: string | number | null): string | null;\nexport function formattedId(id: string | number | null): string | null {\n AssertFn('formattedId: id must not be undefined', id !== undefined);\n AssertFn(\n 'formattedId: id must be a number, string or null',\n typeof id === 'number' || typeof id === 'string' || id === null\n );\n AssertFn(\n 'formattedId: id must not be empty',\n typeof id === 'number' || id === null || (typeof id === 'string' && id.length > 0)\n );\n AssertFn('formattedId: id must not be 0', id !== '0' && id !== 0);\n\n const formatted = id === null ? null : String(id);\n if (formatted !== id) {\n MismatchReporter('formatted-id', id, formatted);\n }\n return id === null ? null : String(id);\n}\n\n/**\n * Like {@link formattedId}, but asserts that `id` is not `null` rather\n * than allowing and passing through `null`.\n *\n * @public\n */\nexport function expectId(id: string | number): string;\n/**\n * Throws, since `id` is `null`.\n *\n * @public\n */\nexport function expectId(id: null): never;\nexport function expectId(id: string | number | null): string {\n AssertFn('expectId: id must not be null', id !== null);\n\n return formattedId(id);\n}\n\n/**\n * Compares two types for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid types in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivType('posts', 'post'); // true\n * isEquivType('post', 'post'); // true\n * isEquivType('posts', 'posts'); // true\n * isEquivType('post-comment', 'postComment'); // true\n * isEquivType('post-comment', 'PostComment'); // true\n * isEquivType('post-comment', 'post_comment'); // true\n * isEquivType('post-comment', 'post-comment'); // true\n * isEquivType('post-comment', 'post'); // false\n * isEquivType('posts', null); // false\n * ```\n *\n * @param expected a potentially unnormalized type to match against\n * @param actual a potentially unnormalized type to match against\n * @return true if the types are equivalent\n * @public\n */\nexport function isEquivType(expected: string, actual: string): boolean {\n AssertFn('isEquivType: Expected type must not be null', expected !== null);\n AssertFn('isEquivType: Expected type must not be undefined', expected !== undefined);\n AssertFn('isEquivType: Expected type must be a string', typeof expected === 'string');\n AssertFn('isEquivType: Expected type must not be empty', expected.length > 0);\n\n AssertFn('isEquivType: Actual type must not be null', actual !== null);\n AssertFn('isEquivType: Actual type must not be undefined', actual !== undefined);\n AssertFn('isEquivType: Actual type must be a string', typeof actual === 'string');\n AssertFn('isEquivType: Actual type must not be empty', actual.length > 0);\n\n return expected === actual || formattedType(expected) === formattedType(actual);\n}\n\n/**\n * Compares two IDs for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid IDs in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivId('1', 1); // true\n * isEquivId('2', '2'); // true\n * isEquivId(3, '3'); // true\n * isEquivId(4, '3'); // false\n * isEquivId(1, null); // false\n * ```\n *\n * @param expected a potentially un-normalized id to match against\n * @param actual a potentially un-normalized id to match against\n * @return true if the ids are equivalent\n * @public\n */\nexport function isEquivId(expected: string | number, actual: string | number | null): boolean {\n AssertFn('isEquivId: Expected id must not be null', expected !== null);\n AssertFn('isEquivId: Expected id must not be undefined', expected !== undefined);\n AssertFn(\n 'isEquivId: Expected id must be a number or string',\n typeof expected === 'number' || typeof expected === 'string'\n );\n AssertFn(\n 'isEquivId: Expected id must not be empty',\n typeof expected === 'number' || (typeof expected === 'string' && expected.length > 0)\n );\n AssertFn('isEquivId: Expected id must not be 0', expected !== '0' && expected !== 0);\n\n AssertFn('isEquivId: Actual id must not be undefined', actual !== undefined);\n AssertFn(\n 'isEquivId: Actual id must be a number, string or null',\n typeof actual === 'number' || typeof actual === 'string' || actual === null\n );\n AssertFn(\n 'isEquivId: Actual id must not be empty',\n actual === null || typeof actual === 'number' || (typeof actual === 'string' && actual.length > 0)\n );\n AssertFn('isEquivId: Actual id must not be 0', actual !== '0' && actual !== 0);\n\n return expected === actual || formattedId(expected) === formattedId(actual);\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAIE,mBAA6B,WAAY,CAAC;AAI9C,IAAIC,YAA2D,WAAY,CAAC;AAC5E,MAAMC,YAAyBC,SAAiBC,cAAuB;CACrE,IAAI,CAACA,WACHH,UAAUE,SAASC,SAAS;CAE9B,EAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAOH,OAAO;CAAA,EAAA,CAAEC,SAAS;AAC3B;AACA,IAAIG,kBAA8BC,QAAgB;CAChD,OAAOT,YAAYD,UAAUU,GAAG,CAAC;AACnC;;;;;;;;;AAUA,SAAgBC,0BAA0BC,IAAoB;CAC5DV,mBAAmBU;AACrB;;;;;;;;;AAUA,SAAgBC,kBAAkBD,IAAyD;CACzFT,YAAYS;AACd;;;;;;;;;;;;;;AAeA,SAAgBE,2BAA2BF,IAAoC;CAC7EH,iBAAiBG;AACnB;AAEA,MAAMG,mCAAmB,IAAIC,IAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BjD,SAAgBC,cAAgCC,MAAqB;CACnEd,SAAS,wCAAwCc,SAAS,IAAI;CAC9Dd,SAAS,6CAA6Cc,SAASC,MAAS;CACxEf,SAAS,wCAAwC,OAAOc,SAAS,QAAQ;CACzE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X,SAAS,CAAC;CAExE,OAAOU,aAAaC,UAAUd,cAAca,QAAQ,MAAMb,cAAcc,MAAM;AAChF;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgBC,UAAUF,UAA2BC,QAAyC;CAC5F3B,SAAS,2CAA2C0B,aAAa,IAAI;CACrE1B,SAAS,gDAAgD0B,aAAaX,MAAS;CAC/Ef,SACE,qDACA,OAAO0B,aAAa,YAAY,OAAOA,aAAa,QACtD;CACA1B,SACE,4CACA,OAAO0B,aAAa,YAAa,OAAOA,aAAa,YAAYA,SAASV,SAAS,CACrF;CACAhB,SAAS,wCAAwC0B,aAAa,OAAOA,aAAa,CAAC;CAEnF1B,SAAS,8CAA8C2B,WAAWZ,MAAS;CAC3Ef,SACE,yDACA,OAAO2B,WAAW,YAAY,OAAOA,WAAW,YAAYA,WAAW,IACzE;CACA3B,SACE,0CACA2B,WAAW,QAAQ,OAAOA,WAAW,YAAa,OAAOA,WAAW,YAAYA,OAAOX,SAAS,CAClG;CACAhB,SAAS,sCAAsC2B,WAAW,OAAOA,WAAW,CAAC;CAE7E,OAAOD,aAAaC,UAAUP,YAAYM,QAAQ,MAAMN,YAAYO,MAAM;AAC5E"}
1
+ {"version":3,"file":"utils.js","names":["dasherize","singularize","MismatchReporter","_AssertFn","AssertFn","message","condition","test","Error","NormalizedType","str","configureMismatchReporter","fn","configureAssertFn","configureTypeNormalization","NORMALIZED_TYPES","Map","formattedType","type","undefined","length","normalized","get","set","formattedId","id","formatted","String","expectId","isEquivType","expected","actual","isEquivId"],"sources":["../../../../src/compat/utils.ts"],"sourcesContent":["/**\n Utilities for helping to migrate to stricter\n and more consistent use of IDs and types.\n\n @summary Legacy helpers that normalize, compare, and report mismatched resource ids and types while migrating to\n stricter formats.\n @module\n*/\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\ninterface AssertFunc {\n (desc: string, condition: unknown): asserts condition;\n (desc: string): never;\n}\n\ntype Reporter = (type: 'formatted-id' | 'formatted-type', actual: unknown, expected: unknown) => void;\ntype Normalizer = (type: string) => string;\n\nlet MismatchReporter: Reporter = function () {};\n\n// TODO: @runspired This pattern prevents AssertFn from being removed in production builds\n// but we should enable that if we can.\nlet _AssertFn: (message: string, condition: unknown) => void = function () {};\nconst AssertFn: AssertFunc = ((message: string, condition: unknown) => {\n if (!condition) {\n _AssertFn(message, condition);\n }\n assert(message, condition);\n}) as unknown as AssertFunc;\nlet NormalizedType: Normalizer = (str: string) => {\n return singularize(dasherize(str));\n};\n\n/**\n * Configure a function to be called when an id or type\n * changes during normalization. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @summary Legacy migration helper that registers a callback invoked whenever `formattedId` or `formattedType`\n * has to change the id or type it was given.\n * @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value\n * @public\n */\nexport function configureMismatchReporter(fn: Reporter): void {\n MismatchReporter = fn;\n}\n\n/**\n * Configure a function to be called when an id or type\n * fails validation. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @summary Legacy migration helper that registers a callback invoked when an id or type passed to these utilities\n * fails validation.\n * @param fn - a function which takes a message and a condition\n * @public\n */\nexport function configureAssertFn(fn: (message: string, condition: unknown) => void): void {\n _AssertFn = fn;\n}\n\n/**\n * Configure a function to be called to normalize\n * a resource type string. Used by both formattedType\n * and isEquivType to ensure consistent normalization\n * during comparison.\n *\n * If validation fails or the type turns out be unnormalized\n * the configured mismatch reporter and assert functions will\n * be called.\n *\n * @summary Legacy migration helper that replaces the singularize-and-dasherize function `formattedType` and\n * `isEquivType` use to normalize resource types.\n * @param fn - a function which takes a string and returns a string\n * @public\n */\nexport function configureTypeNormalization(fn: (type: string) => string): void {\n NormalizedType = fn;\n}\n\nconst NORMALIZED_TYPES = new Map<string, string>();\n\n/**\n * Converts a potentially unnormalized type into the format expected\n * by our WarpDrive Cache. Currently this is singular-dasherized.\n *\n * you should not rely on this function to give you an exact format\n * for display purposes. Formatting for display should be handled\n * differently if the exact format matters.\n *\n * Asserts invalid types (undefined, null, '') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedType from 'soxhub-client/helpers/formatted-type';\n *\n * formattedType('post'); // => 'post'\n * formattedType('posts'); // => 'post'\n * formattedType('Posts'); // => 'post'\n * formattedType('post-comment'); // => 'post-comment'\n * formattedType('post-comments'); // => 'post-comment'\n * formattedType('post_comment'); // => 'post-comment'\n * formattedType('postComment'); // => 'post-comment'\n * formattedType('PostComment'); // => 'post-comment'\n * ```\n *\n * @summary Legacy migration helper that normalizes a resource type to the singular dasherized form the cache\n * expects, such as `'PostComments'` to `'post-comment'`.\n * @param type the potentially un-normalized type\n * @return the normalized type\n * @public\n */\nexport function formattedType<T extends string>(type: T | string): T {\n AssertFn('formattedType: type must not be null', type !== null);\n AssertFn('formattedType: type must not be undefined', type !== undefined);\n AssertFn('formattedType: type must be a string', typeof type === 'string');\n AssertFn('formattedType: type must not be empty', type.length > 0);\n let normalized = NORMALIZED_TYPES.get(type);\n\n if (normalized === undefined) {\n normalized = NormalizedType(type);\n NORMALIZED_TYPES.set(type, normalized);\n }\n\n if (normalized !== type) {\n MismatchReporter('formatted-type', type, normalized);\n }\n\n return normalized as T;\n}\n\n/**\n * Format an id to the format expected by the WarpDrive Cache.\n * Currently this means that id should be `string | null`.\n *\n * Asserts invalid IDs (undefined, '', 0, '0') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedId from 'client/utils/formatted-id';\n *\n * formattedId('1'); // => '1'\n * formattedId(1); // => '1'\n * formattedId(null); // => null\n *\t```\n *\n * @summary Legacy migration helper that normalizes a resource id to the `string` or `null` the cache expects,\n * asserting on invalid ids such as `''` or `0`.\n * @param id the potentially un-normalized id\n * @return the normalized id\n * @public\n */\nexport function formattedId(id: string | number): string;\nexport function formattedId(id: null): null;\nexport function formattedId(id: string | number | null): string | null;\nexport function formattedId(id: string | number | null): string | null {\n AssertFn('formattedId: id must not be undefined', id !== undefined);\n AssertFn(\n 'formattedId: id must be a number, string or null',\n typeof id === 'number' || typeof id === 'string' || id === null\n );\n AssertFn(\n 'formattedId: id must not be empty',\n typeof id === 'number' || id === null || (typeof id === 'string' && id.length > 0)\n );\n AssertFn('formattedId: id must not be 0', id !== '0' && id !== 0);\n\n const formatted = id === null ? null : String(id);\n if (formatted !== id) {\n MismatchReporter('formatted-id', id, formatted);\n }\n return id === null ? null : String(id);\n}\n\n/**\n * Like {@link formattedId}, but asserts that `id` is not `null` rather\n * than allowing and passing through `null`.\n *\n * @summary Legacy migration helper that normalizes a resource id to a string like `formattedId`, but asserts that\n * it is not `null`.\n * @public\n */\nexport function expectId(id: string | number): string;\n/**\n * Throws, since `id` is `null`.\n *\n * @public\n */\nexport function expectId(id: null): never;\nexport function expectId(id: string | number | null): string {\n AssertFn('expectId: id must not be null', id !== null);\n\n return formattedId(id);\n}\n\n/**\n * Compares two types for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid types in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivType('posts', 'post'); // true\n * isEquivType('post', 'post'); // true\n * isEquivType('posts', 'posts'); // true\n * isEquivType('post-comment', 'postComment'); // true\n * isEquivType('post-comment', 'PostComment'); // true\n * isEquivType('post-comment', 'post_comment'); // true\n * isEquivType('post-comment', 'post-comment'); // true\n * isEquivType('post-comment', 'post'); // false\n * isEquivType('posts', null); // false\n * ```\n *\n * @summary Legacy migration helper that reports whether two resource types match after normalization, so\n * `'posts'` and `'post'` are equivalent.\n * @param expected a potentially unnormalized type to match against\n * @param actual a potentially unnormalized type to match against\n * @return true if the types are equivalent\n * @public\n */\nexport function isEquivType(expected: string, actual: string): boolean {\n AssertFn('isEquivType: Expected type must not be null', expected !== null);\n AssertFn('isEquivType: Expected type must not be undefined', expected !== undefined);\n AssertFn('isEquivType: Expected type must be a string', typeof expected === 'string');\n AssertFn('isEquivType: Expected type must not be empty', expected.length > 0);\n\n AssertFn('isEquivType: Actual type must not be null', actual !== null);\n AssertFn('isEquivType: Actual type must not be undefined', actual !== undefined);\n AssertFn('isEquivType: Actual type must be a string', typeof actual === 'string');\n AssertFn('isEquivType: Actual type must not be empty', actual.length > 0);\n\n return expected === actual || formattedType(expected) === formattedType(actual);\n}\n\n/**\n * Compares two IDs for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid IDs in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivId('1', 1); // true\n * isEquivId('2', '2'); // true\n * isEquivId(3, '3'); // true\n * isEquivId(4, '3'); // false\n * isEquivId(1, null); // false\n * ```\n *\n * @summary Legacy migration helper that reports whether two resource ids match after normalization, so `1` and\n * `'1'` are equivalent.\n * @param expected a potentially un-normalized id to match against\n * @param actual a potentially un-normalized id to match against\n * @return true if the ids are equivalent\n * @public\n */\nexport function isEquivId(expected: string | number, actual: string | number | null): boolean {\n AssertFn('isEquivId: Expected id must not be null', expected !== null);\n AssertFn('isEquivId: Expected id must not be undefined', expected !== undefined);\n AssertFn(\n 'isEquivId: Expected id must be a number or string',\n typeof expected === 'number' || typeof expected === 'string'\n );\n AssertFn(\n 'isEquivId: Expected id must not be empty',\n typeof expected === 'number' || (typeof expected === 'string' && expected.length > 0)\n );\n AssertFn('isEquivId: Expected id must not be 0', expected !== '0' && expected !== 0);\n\n AssertFn('isEquivId: Actual id must not be undefined', actual !== undefined);\n AssertFn(\n 'isEquivId: Actual id must be a number, string or null',\n typeof actual === 'number' || typeof actual === 'string' || actual === null\n );\n AssertFn(\n 'isEquivId: Actual id must not be empty',\n actual === null || typeof actual === 'number' || (typeof actual === 'string' && actual.length > 0)\n );\n AssertFn('isEquivId: Actual id must not be 0', actual !== '0' && actual !== 0);\n\n return expected === actual || formattedId(expected) === formattedId(actual);\n}\n"],"mappings":";;;;;;;;;;;AAmBA,IAAIE,mBAA6B,WAAY,CAAC;AAI9C,IAAIC,YAA2D,WAAY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