@warp-drive-mirror/core 5.10.0-alpha.10 → 5.10.0-alpha.13

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 (278) hide show
  1. package/README.md +116 -6
  2. package/dist/{-private-CjK1Dmuh.js → -private-BpyvBYFj.js} +508 -144
  3. package/dist/-private-BpyvBYFj.js.map +1 -0
  4. package/dist/{unpkg/dev/-private-Dtj8O5W7.js → -private-CmNOwhK0.js} +3 -1
  5. package/dist/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
  6. package/dist/{aliases-BWYW5EhX.d.ts → aliases-BQmAxXmb.d.ts} +4 -1
  7. package/dist/aliases-BQmAxXmb.d.ts.map +1 -0
  8. package/dist/{change-C7kqv2kW.d.ts → change-DClXcHvr.d.ts} +4 -2
  9. package/dist/change-DClXcHvr.d.ts.map +1 -0
  10. package/dist/{concepts-DFldVwEM.d.ts → concepts-DzuY5M1K.d.ts} +14 -5
  11. package/dist/concepts-DzuY5M1K.d.ts.map +1 -0
  12. package/dist/{configure-B_F639tN.d.ts → configure-CjsojjiI.d.ts} +7 -1
  13. package/dist/configure-CjsojjiI.d.ts.map +1 -0
  14. package/dist/configure.d.ts +1 -1
  15. package/dist/configure.js +1 -1
  16. package/dist/{document-Ca4ZZBd9.d.ts → document-Ni8Ns26t.d.ts} +22 -4
  17. package/dist/document-Ni8Ns26t.d.ts.map +1 -0
  18. package/dist/{error-0uD6GkNX.d.ts → error-APuUdUGk.d.ts} +4 -2
  19. package/dist/error-APuUdUGk.d.ts.map +1 -0
  20. package/dist/{fields-FM7peCiM.d.ts → fields-D6173Q_a.d.ts} +134 -7
  21. package/dist/fields-D6173Q_a.d.ts.map +1 -0
  22. package/dist/graph/-private.d.ts +1 -1
  23. package/dist/graph/-private.js +2 -0
  24. package/dist/graph/-private.js.map +1 -1
  25. package/dist/{graph-DLqYXP2z.d.ts → graph-rjTyJ-gd.d.ts} +25 -5
  26. package/dist/graph-rjTyJ-gd.d.ts.map +1 -0
  27. package/dist/{identifier-DQnqOSJK.d.ts → identifier-B_tK3FUw.d.ts} +29 -4
  28. package/dist/identifier-B_tK3FUw.d.ts.map +1 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/{internal-9XuWZdDv.d.ts → internal-CgOlgOt3.d.ts} +497 -31
  32. package/dist/internal-CgOlgOt3.d.ts.map +1 -0
  33. package/dist/{json-api-raw-C5APJHHB.d.ts → json-api-raw-BxzNsCg0.d.ts} +44 -2
  34. package/dist/json-api-raw-BxzNsCg0.d.ts.map +1 -0
  35. package/dist/{mutations-CqtoGB4t.d.ts → mutations-C81gbYjB.d.ts} +18 -2
  36. package/dist/mutations-C81gbYjB.d.ts.map +1 -0
  37. package/dist/{operations-D1qA6r0_.d.ts → operations-B4pQM7D6.d.ts} +39 -5
  38. package/dist/operations-B4pQM7D6.d.ts.map +1 -0
  39. package/dist/{params-DrEx3bf8.d.ts → params-dbHiSOMF.d.ts} +11 -1
  40. package/dist/params-dbHiSOMF.d.ts.map +1 -0
  41. package/dist/{raw-D5hnjiq7.d.ts → raw-CiC64nCY.d.ts} +10 -1
  42. package/dist/raw-CiC64nCY.d.ts.map +1 -0
  43. package/dist/reactive/-private.d.ts +1 -1
  44. package/dist/reactive/-private.js +1 -1
  45. package/dist/reactive.d.ts +2 -2
  46. package/dist/reactive.js +3 -3
  47. package/dist/{record-D3QQcaIR.d.ts → record-DDxPtzcY.d.ts} +22 -2
  48. package/dist/record-DDxPtzcY.d.ts.map +1 -0
  49. package/dist/{relationship-CmHzMPKf.d.ts → relationship-BlGIXgj4.d.ts} +10 -3
  50. package/dist/relationship-BlGIXgj4.d.ts.map +1 -0
  51. package/dist/{request-Di274pQz.js → request-MiwUbGdT.js} +26 -1
  52. package/dist/request-MiwUbGdT.js.map +1 -0
  53. package/dist/request.d.ts +1 -1
  54. package/dist/request.js +1 -1
  55. package/dist/signals/-leaked.d.ts +86 -4
  56. package/dist/signals/-leaked.d.ts.map +1 -1
  57. package/dist/signals/-leaked.js +1 -1
  58. package/dist/{src-TlQlgL5V.js → src-DlNeupkA.js} +222 -20
  59. package/dist/src-DlNeupkA.js.map +1 -0
  60. package/dist/store/-private.d.ts +1 -1
  61. package/dist/store/-private.js +1 -1
  62. package/dist/{store-DNF9Rgoh.js → store-lcyaxrpj.js} +16 -1
  63. package/dist/store-lcyaxrpj.js.map +1 -0
  64. package/dist/store.d.ts +1 -1
  65. package/dist/store.js +1 -1
  66. package/dist/{symbols-DjRDCeX0.d.ts → symbols-Cu9un1NR.d.ts} +10 -1
  67. package/dist/symbols-Cu9un1NR.d.ts.map +1 -0
  68. package/dist/types/-private.js +1 -1
  69. package/dist/types/cache/aliases.d.ts +1 -1
  70. package/dist/types/cache/change.d.ts +1 -1
  71. package/dist/types/cache/mutations.d.ts +1 -1
  72. package/dist/types/cache/operations.d.ts +1 -1
  73. package/dist/types/cache/relationship.d.ts +1 -1
  74. package/dist/types/cache.d.ts +1 -1
  75. package/dist/types/graph.d.ts +1 -1
  76. package/dist/types/identifier.d.ts +1 -1
  77. package/dist/types/identifier.js +33 -3
  78. package/dist/types/identifier.js.map +1 -1
  79. package/dist/types/json/raw.d.ts +1 -1
  80. package/dist/types/params.d.ts +1 -1
  81. package/dist/types/record.d.ts +1 -1
  82. package/dist/types/record.js +25 -0
  83. package/dist/types/record.js.map +1 -1
  84. package/dist/types/request.d.ts +1 -1
  85. package/dist/types/request.js +80 -0
  86. package/dist/types/request.js.map +1 -1
  87. package/dist/types/runtime.d.ts.map +1 -1
  88. package/dist/types/schema/concepts.d.ts +1 -1
  89. package/dist/types/schema/fields.d.ts +1 -1
  90. package/dist/types/schema/fields.js +132 -3
  91. package/dist/types/schema/fields.js.map +1 -1
  92. package/dist/types/schema/schema-service.d.ts +1 -1
  93. package/dist/types/spec/document.d.ts +1 -1
  94. package/dist/types/spec/error.d.ts +1 -1
  95. package/dist/types/spec/json-api-raw.d.ts +1 -1
  96. package/dist/types/symbols.d.ts +1 -1
  97. package/dist/types/symbols.js +14 -0
  98. package/dist/types/symbols.js.map +1 -1
  99. package/dist/types/utils.d.ts +1 -1
  100. package/dist/types.d.ts +2 -2
  101. package/dist/unpkg/{dev-deprecated/-private-DrQgwtNS.js → dev/-private-BH4O810v.js} +508 -144
  102. package/dist/unpkg/dev/-private-BH4O810v.js.map +1 -0
  103. package/dist/{-private-Dtj8O5W7.js → unpkg/dev/-private-CmNOwhK0.js} +3 -1
  104. package/dist/unpkg/dev/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
  105. package/dist/unpkg/dev/configure.js +1 -1
  106. package/dist/unpkg/dev/graph/-private.js +2 -0
  107. package/dist/unpkg/dev/graph/-private.js.map +1 -1
  108. package/dist/unpkg/dev/index.js +1 -1
  109. package/dist/unpkg/dev/reactive/-private.js +1 -1
  110. package/dist/unpkg/dev/reactive.js +3 -3
  111. package/dist/unpkg/{dev-deprecated/request-nAaeDlS9.js → dev/request-Fe-vpe-u.js} +26 -1
  112. package/dist/unpkg/dev/request-Fe-vpe-u.js.map +1 -0
  113. package/dist/unpkg/dev/request.js +1 -1
  114. package/dist/unpkg/dev/signals/-leaked.js +1 -1
  115. package/dist/unpkg/dev/{src-D8uKAIUN.js → src-FSk0Z_Lp.js} +213 -13
  116. package/dist/unpkg/dev/src-FSk0Z_Lp.js.map +1 -0
  117. package/dist/unpkg/dev/store/-private.js +1 -1
  118. package/dist/unpkg/dev/{store-BIFNM_fB.js → store-BUV8Pfi7.js} +16 -1
  119. package/dist/unpkg/dev/store-BUV8Pfi7.js.map +1 -0
  120. package/dist/unpkg/dev/store.js +1 -1
  121. package/dist/unpkg/dev/types/-private.js +1 -1
  122. package/dist/unpkg/dev/types/identifier.js +33 -3
  123. package/dist/unpkg/dev/types/identifier.js.map +1 -1
  124. package/dist/unpkg/dev/types/record.js +25 -0
  125. package/dist/unpkg/dev/types/record.js.map +1 -1
  126. package/dist/unpkg/dev/types/request.js +80 -0
  127. package/dist/unpkg/dev/types/request.js.map +1 -1
  128. package/dist/unpkg/dev/types/schema/fields.js +132 -3
  129. package/dist/unpkg/dev/types/schema/fields.js.map +1 -1
  130. package/dist/unpkg/dev/types/symbols.js +14 -0
  131. package/dist/unpkg/dev/types/symbols.js.map +1 -1
  132. package/dist/unpkg/{dev/-private-DrQgwtNS.js → dev-deprecated/-private-BH4O810v.js} +508 -144
  133. package/dist/unpkg/dev-deprecated/-private-BH4O810v.js.map +1 -0
  134. package/dist/unpkg/{prod-deprecated/-private-Dtj8O5W7.js → dev-deprecated/-private-CmNOwhK0.js} +3 -1
  135. package/dist/unpkg/dev-deprecated/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
  136. package/dist/unpkg/dev-deprecated/configure.js +1 -1
  137. package/dist/unpkg/dev-deprecated/graph/-private.js +2 -0
  138. package/dist/unpkg/dev-deprecated/graph/-private.js.map +1 -1
  139. package/dist/unpkg/dev-deprecated/index.js +1 -1
  140. package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -1
  141. package/dist/unpkg/dev-deprecated/reactive.js +3 -3
  142. package/dist/unpkg/{dev/request-nAaeDlS9.js → dev-deprecated/request-Fe-vpe-u.js} +26 -1
  143. package/dist/unpkg/dev-deprecated/request-Fe-vpe-u.js.map +1 -0
  144. package/dist/unpkg/dev-deprecated/request.js +1 -1
  145. package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -1
  146. package/dist/unpkg/dev-deprecated/{src-BlewXGbB.js → src-Isk_Je7q.js} +215 -13
  147. package/dist/unpkg/dev-deprecated/src-Isk_Je7q.js.map +1 -0
  148. package/dist/unpkg/dev-deprecated/store/-private.js +1 -1
  149. package/dist/unpkg/dev-deprecated/{store-X1WN7P_O.js → store-CCZBSe0p.js} +16 -1
  150. package/dist/unpkg/dev-deprecated/store-CCZBSe0p.js.map +1 -0
  151. package/dist/unpkg/dev-deprecated/store.js +1 -1
  152. package/dist/unpkg/dev-deprecated/types/-private.js +1 -1
  153. package/dist/unpkg/dev-deprecated/types/identifier.js +33 -3
  154. package/dist/unpkg/dev-deprecated/types/identifier.js.map +1 -1
  155. package/dist/unpkg/dev-deprecated/types/record.js +25 -0
  156. package/dist/unpkg/dev-deprecated/types/record.js.map +1 -1
  157. package/dist/unpkg/dev-deprecated/types/request.js +80 -0
  158. package/dist/unpkg/dev-deprecated/types/request.js.map +1 -1
  159. package/dist/unpkg/dev-deprecated/types/schema/fields.js +132 -3
  160. package/dist/unpkg/dev-deprecated/types/schema/fields.js.map +1 -1
  161. package/dist/unpkg/dev-deprecated/types/symbols.js +14 -0
  162. package/dist/unpkg/dev-deprecated/types/symbols.js.map +1 -1
  163. package/dist/unpkg/prod/-private-CmNOwhK0.js +24 -0
  164. package/dist/unpkg/prod/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
  165. package/dist/unpkg/prod/{-private-Dg1vsF-H.js → -private-DKVDMUfT.js} +481 -138
  166. package/dist/unpkg/prod/-private-DKVDMUfT.js.map +1 -0
  167. package/dist/unpkg/prod/configure.js +1 -1
  168. package/dist/unpkg/prod/graph/-private.js +2 -0
  169. package/dist/unpkg/prod/graph/-private.js.map +1 -1
  170. package/dist/unpkg/prod/index.js +1 -1
  171. package/dist/unpkg/prod/reactive/-private.js +1 -1
  172. package/dist/unpkg/prod/reactive.js +3 -3
  173. package/dist/unpkg/prod/{request-DK7nNaAf.js → request-ndw2Fy91.js} +26 -1
  174. package/dist/unpkg/prod/request-ndw2Fy91.js.map +1 -0
  175. package/dist/unpkg/prod/request.js +1 -1
  176. package/dist/unpkg/prod/signals/-leaked.js +1 -1
  177. package/dist/unpkg/prod/{src-DGB6WvXW.js → src-CoSpuocQ.js} +213 -13
  178. package/dist/unpkg/prod/src-CoSpuocQ.js.map +1 -0
  179. package/dist/unpkg/prod/store/-private.js +1 -1
  180. package/dist/unpkg/{prod-deprecated/store-BWhmb7Ob.js → prod/store-CQOsqdST.js} +16 -1
  181. package/dist/unpkg/prod/store-CQOsqdST.js.map +1 -0
  182. package/dist/unpkg/prod/store.js +1 -1
  183. package/dist/unpkg/prod/types/-private.js +1 -1
  184. package/dist/unpkg/prod/types/identifier.js +33 -3
  185. package/dist/unpkg/prod/types/identifier.js.map +1 -1
  186. package/dist/unpkg/prod/types/record.js +25 -0
  187. package/dist/unpkg/prod/types/record.js.map +1 -1
  188. package/dist/unpkg/prod/types/request.js +80 -0
  189. package/dist/unpkg/prod/types/request.js.map +1 -1
  190. package/dist/unpkg/prod/types/schema/fields.js +132 -3
  191. package/dist/unpkg/prod/types/schema/fields.js.map +1 -1
  192. package/dist/unpkg/prod/types/symbols.js +14 -0
  193. package/dist/unpkg/prod/types/symbols.js.map +1 -1
  194. package/dist/unpkg/{dev-deprecated/-private-Dtj8O5W7.js → prod-deprecated/-private-CmNOwhK0.js} +3 -1
  195. package/dist/unpkg/prod-deprecated/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
  196. package/dist/unpkg/prod-deprecated/{-private-Dg1vsF-H.js → -private-DKVDMUfT.js} +481 -138
  197. package/dist/unpkg/prod-deprecated/-private-DKVDMUfT.js.map +1 -0
  198. package/dist/unpkg/prod-deprecated/configure.js +1 -1
  199. package/dist/unpkg/prod-deprecated/graph/-private.js +2 -0
  200. package/dist/unpkg/prod-deprecated/graph/-private.js.map +1 -1
  201. package/dist/unpkg/prod-deprecated/index.js +1 -1
  202. package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -1
  203. package/dist/unpkg/prod-deprecated/reactive.js +3 -3
  204. package/dist/unpkg/prod-deprecated/{request-DK7nNaAf.js → request-ndw2Fy91.js} +26 -1
  205. package/dist/unpkg/prod-deprecated/request-ndw2Fy91.js.map +1 -0
  206. package/dist/unpkg/prod-deprecated/request.js +1 -1
  207. package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -1
  208. package/dist/unpkg/prod-deprecated/{src-B9AnmJPz.js → src-FK_rMde5.js} +215 -13
  209. package/dist/unpkg/prod-deprecated/src-FK_rMde5.js.map +1 -0
  210. package/dist/unpkg/prod-deprecated/store/-private.js +1 -1
  211. package/dist/unpkg/{prod/store-BWhmb7Ob.js → prod-deprecated/store-CQOsqdST.js} +16 -1
  212. package/dist/unpkg/prod-deprecated/store-CQOsqdST.js.map +1 -0
  213. package/dist/unpkg/prod-deprecated/store.js +1 -1
  214. package/dist/unpkg/prod-deprecated/types/-private.js +1 -1
  215. package/dist/unpkg/prod-deprecated/types/identifier.js +33 -3
  216. package/dist/unpkg/prod-deprecated/types/identifier.js.map +1 -1
  217. package/dist/unpkg/prod-deprecated/types/record.js +25 -0
  218. package/dist/unpkg/prod-deprecated/types/record.js.map +1 -1
  219. package/dist/unpkg/prod-deprecated/types/request.js +80 -0
  220. package/dist/unpkg/prod-deprecated/types/request.js.map +1 -1
  221. package/dist/unpkg/prod-deprecated/types/schema/fields.js +132 -3
  222. package/dist/unpkg/prod-deprecated/types/schema/fields.js.map +1 -1
  223. package/dist/unpkg/prod-deprecated/types/symbols.js +14 -0
  224. package/dist/unpkg/prod-deprecated/types/symbols.js.map +1 -1
  225. package/dist/{utils-BtURiy8l.d.ts → utils-CNmQoKm8.d.ts} +8 -1
  226. package/dist/utils-CNmQoKm8.d.ts.map +1 -0
  227. package/package.json +5 -5
  228. package/dist/-private-CjK1Dmuh.js.map +0 -1
  229. package/dist/aliases-BWYW5EhX.d.ts.map +0 -1
  230. package/dist/change-C7kqv2kW.d.ts.map +0 -1
  231. package/dist/concepts-DFldVwEM.d.ts.map +0 -1
  232. package/dist/configure-B_F639tN.d.ts.map +0 -1
  233. package/dist/document-Ca4ZZBd9.d.ts.map +0 -1
  234. package/dist/error-0uD6GkNX.d.ts.map +0 -1
  235. package/dist/fields-FM7peCiM.d.ts.map +0 -1
  236. package/dist/graph-DLqYXP2z.d.ts.map +0 -1
  237. package/dist/identifier-DQnqOSJK.d.ts.map +0 -1
  238. package/dist/internal-9XuWZdDv.d.ts.map +0 -1
  239. package/dist/json-api-raw-C5APJHHB.d.ts.map +0 -1
  240. package/dist/mutations-CqtoGB4t.d.ts.map +0 -1
  241. package/dist/operations-D1qA6r0_.d.ts.map +0 -1
  242. package/dist/params-DrEx3bf8.d.ts.map +0 -1
  243. package/dist/raw-D5hnjiq7.d.ts.map +0 -1
  244. package/dist/record-D3QQcaIR.d.ts.map +0 -1
  245. package/dist/relationship-CmHzMPKf.d.ts.map +0 -1
  246. package/dist/request-Di274pQz.js.map +0 -1
  247. package/dist/src-TlQlgL5V.js.map +0 -1
  248. package/dist/store-DNF9Rgoh.js.map +0 -1
  249. package/dist/symbols-DjRDCeX0.d.ts.map +0 -1
  250. package/dist/types/schema/fields.type-test.d.ts +0 -1
  251. package/dist/types/schema/fields.type-test.js +0 -79
  252. package/dist/types/schema/fields.type-test.js.map +0 -1
  253. package/dist/unpkg/dev/-private-DrQgwtNS.js.map +0 -1
  254. package/dist/unpkg/dev/request-nAaeDlS9.js.map +0 -1
  255. package/dist/unpkg/dev/src-D8uKAIUN.js.map +0 -1
  256. package/dist/unpkg/dev/store-BIFNM_fB.js.map +0 -1
  257. package/dist/unpkg/dev/types/schema/fields.type-test.js +0 -79
  258. package/dist/unpkg/dev/types/schema/fields.type-test.js.map +0 -1
  259. package/dist/unpkg/dev-deprecated/-private-DrQgwtNS.js.map +0 -1
  260. package/dist/unpkg/dev-deprecated/request-nAaeDlS9.js.map +0 -1
  261. package/dist/unpkg/dev-deprecated/src-BlewXGbB.js.map +0 -1
  262. package/dist/unpkg/dev-deprecated/store-X1WN7P_O.js.map +0 -1
  263. package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js +0 -79
  264. package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js.map +0 -1
  265. package/dist/unpkg/prod/-private-Dg1vsF-H.js.map +0 -1
  266. package/dist/unpkg/prod/-private-Dtj8O5W7.js +0 -22
  267. package/dist/unpkg/prod/request-DK7nNaAf.js.map +0 -1
  268. package/dist/unpkg/prod/src-DGB6WvXW.js.map +0 -1
  269. package/dist/unpkg/prod/store-BWhmb7Ob.js.map +0 -1
  270. package/dist/unpkg/prod/types/schema/fields.type-test.js +0 -79
  271. package/dist/unpkg/prod/types/schema/fields.type-test.js.map +0 -1
  272. package/dist/unpkg/prod-deprecated/-private-Dg1vsF-H.js.map +0 -1
  273. package/dist/unpkg/prod-deprecated/request-DK7nNaAf.js.map +0 -1
  274. package/dist/unpkg/prod-deprecated/src-B9AnmJPz.js.map +0 -1
  275. package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js.map +0 -1
  276. package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js +0 -79
  277. package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js.map +0 -1
  278. package/dist/utils-BtURiy8l.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { $ as PrivateRequestStateService, B as logGroup, Dt as StoreRequestContext, Et as CacheHandler, G as ensureStringId, H as createLegacyManyArray, J as PrivateStore, K as constructResource, Ot as StoreRequestInput, Q as FindRecordQuery, Tt as CachePolicy, U as normalizeModelName, V as LegacyManyArray, W as coerceId, X as assertPrivateStore, Y as Store, Z as isPrivateStore, _t as recordIdentifierFor, at as fastPush, bt as PrivateCacheCapabilitiesManager, ct as PrivateReactiveResourceArray, et as Request, gt as _clearCaches, ht as StoreMap, in as isResourceKey, it as RecordArrayManager, lt as ReactiveResourceArray, mt as InstanceCache, nn as fieldValueIdentity, nt as RequestStateService, ot as LegacyQueryArray, pt as NativeProxy, q as CreateRecordProperties, rn as isRequestKey, rt as SaveRecordMutation, st as LegacyLiveArray, tn as FieldValueIdentity, tt as RequestCacheRequestState, vt as setRecordIdentifier, xt as assertPrivateCapabilities, yt as storeFor, z as log } from "../internal-9XuWZdDv.js";
1
+ import { $ as PrivateStore, At as CachePolicy, Ct as setRecordIdentifier, Et as assertPrivateCapabilities, G as logGroup, J as normalizeModelName, K as LegacyManyArray, Mt as StoreRequestContext, Nt as StoreRequestInput, Q as CreateRecordProperties, St as recordIdentifierFor, Tt as PrivateCacheCapabilitiesManager, W as log, X as ensureStringId, Y as coerceId, Z as constructResource, at as Request, bt as StoreMap, cn as isRequestKey, ct as SaveRecordMutation, dt as LegacyQueryArray, et as Store, ft as LegacyLiveArray, it as PrivateRequestStateService, jt as CacheHandler, ln as isResourceKey, lt as RecordArrayManager, mt as ReactiveResourceArray, nt as isPrivateStore, on as FieldValueIdentity, ot as RequestCacheRequestState, pt as PrivateReactiveResourceArray, q as createLegacyManyArray, rt as FindRecordQuery, sn as fieldValueIdentity, st as RequestStateService, tt as assertPrivateStore, ut as fastPush, vt as NativeProxy, wt as storeFor, xt as _clearCaches, yt as InstanceCache } from "../internal-CgOlgOt3.js";
2
2
  export { CacheHandler, type CachePolicy, type LegacyQueryArray as CollectionRecordArray, type LegacyQueryArray, type CreateRecordProperties, type FieldValueIdentity, type FindRecordQuery, type InstanceCache, type LegacyLiveArray, type LegacyLiveArray as LiveArray, type LegacyManyArray, type LegacyManyArray as RelatedCollection, type NativeProxy, type PrivateCacheCapabilitiesManager, type PrivateReactiveResourceArray, type PrivateRequestStateService, type PrivateStore, type ReactiveResourceArray, RecordArrayManager, type Request, type RequestCacheRequestState, type RequestStateService, type SaveRecordMutation, Store, StoreMap, type StoreRequestContext, type StoreRequestInput, _clearCaches, normalizeModelName as _deprecatingNormalize, assertPrivateCapabilities, assertPrivateStore, coerceId, constructResource, createLegacyManyArray, ensureStringId, fastPush, fieldValueIdentity, isPrivateStore, isRequestKey, isResourceKey, log, logGroup, recordIdentifierFor, setRecordIdentifier, storeFor };
@@ -1,3 +1,3 @@
1
- import { C as setRecordIdentifier, D as isRequestKey, E as fieldValueIdentity, F as coerceId, I as ensureStringId, L as log, O as isResourceKey, P as normalizeModelName, R as logGroup, S as recordIdentifierFor, T as assertPrivateCapabilities, _ as isPrivateStore, b as StoreMap, f as createLegacyManyArray, g as assertPrivateStore, h as Store, m as CacheHandler, p as constructResource, v as RecordArrayManager, w as storeFor, x as _clearCaches, y as fastPush } from "../src-TlQlgL5V.js";
1
+ import { C as setRecordIdentifier, D as isRequestKey, E as fieldValueIdentity, F as coerceId, I as ensureStringId, L as log, O as isResourceKey, P as normalizeModelName, R as logGroup, S as recordIdentifierFor, T as assertPrivateCapabilities, _ as isPrivateStore, b as StoreMap, f as createLegacyManyArray, g as assertPrivateStore, h as Store, m as CacheHandler, p as constructResource, v as RecordArrayManager, w as storeFor, x as _clearCaches, y as fastPush } from "../src-DlNeupkA.js";
2
2
 
3
3
  export { CacheHandler, RecordArrayManager, Store, StoreMap, _clearCaches, normalizeModelName as _deprecatingNormalize, assertPrivateCapabilities, assertPrivateStore, coerceId, constructResource, createLegacyManyArray, ensureStringId, fastPush, fieldValueIdentity, isPrivateStore, isRequestKey, isResourceKey, log, logGroup, recordIdentifierFor, setRecordIdentifier, storeFor };
@@ -7,6 +7,9 @@ import { deprecate } from "@ember/debug";
7
7
  * Interface of a parsed Cache-Control header value.
8
8
  *
9
9
  * - [MDN Cache-Control Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)
10
+ *
11
+ * @summary The directives of a `Cache-Control` header as an object of flags and second counts, as
12
+ * returned by `parseCacheControl`.
10
13
  */
11
14
  const NUMERIC_KEYS = /* @__PURE__ */ new Set([
12
15
  "max-age",
@@ -38,6 +41,8 @@ const NUMERIC_KEYS = /* @__PURE__ */ new Set([
38
41
  *
39
42
  * See also {@link CacheControlValue} and [Response Directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control#response_directives)
40
43
  *
44
+ * @summary Parses a `Cache-Control` header string into a `CacheControlValue` object, caching results
45
+ * per header string.
41
46
  * @public
42
47
  */
43
48
  function parseCacheControl(header) {
@@ -173,6 +178,9 @@ function isExpired(cacheKey, request, config) {
173
178
  /**
174
179
  * The configuration options for the {@link DefaultCachePolicy}
175
180
  *
181
+ * The [Advanced Store Configuration](/guides/configuration/advanced#decide-how-long-requests-are-valid-for-with-a-cachepolicy)
182
+ * guide shows a policy configured with them.
183
+ *
176
184
  * ```ts [app/services/store.ts]
177
185
  * import { Store } from '@warp-drive-mirror/core';
178
186
  * import { DefaultCachePolicy } from '@warp-drive-mirror/core/store'; // [!code focus]
@@ -184,10 +192,15 @@ function isExpired(cacheKey, request, config) {
184
192
  * }
185
193
  * ```
186
194
  *
195
+ * @summary Options for `DefaultCachePolicy`: soft and hard expiration times, header-based expiration
196
+ * constraints, and test-mode behavior.
187
197
  */
188
198
  /**
189
199
  * A basic {@link CachePolicy} that can be added to the Store service.
190
200
  *
201
+ * The [Advanced Store Configuration](/guides/configuration/advanced#decide-how-long-requests-are-valid-for-with-a-cachepolicy)
202
+ * guide shows how to configure it.
203
+ *
191
204
  * ```ts [app/services/store.ts]
192
205
  * import { Store } from '@warp-drive-mirror/core';
193
206
  * import { DefaultCachePolicy } from '@warp-drive-mirror/core/store'; // [!code focus]
@@ -266,6 +279,8 @@ function isExpired(cacheKey, request, config) {
266
279
  * This behavior can be opted out of by setting `disableTestOptimization = true`
267
280
  * in the policy config.
268
281
  *
282
+ * @summary The built-in cache policy, which expires cached requests using expiration headers or time
283
+ * since the response `date`, and invalidates queries after matching creates.
269
284
  * @public
270
285
  */
271
286
  var DefaultCachePolicy = class {
@@ -459,4 +474,4 @@ var DefaultCachePolicy = class {
459
474
 
460
475
  //#endregion
461
476
  export { parseCacheControl as n, DefaultCachePolicy as t };
462
- //# sourceMappingURL=store-DNF9Rgoh.js.map
477
+ //# sourceMappingURL=store-lcyaxrpj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-lcyaxrpj.js","names":["deprecate","LRUCache","getGlobalConfig","macroCondition","NUMERIC_KEYS","Set","parseCacheControl","header","CACHE_CONTROL_CACHE","get","key","value","isParsingKey","cacheControlValue","i","length","char","charAt","WarpDrive","env","DEBUG","test","Error","has","parseCacheControlValue","stringToParse","parsedValue","Number","parseInt","isNaN","isExpired","cacheKey","request","config","constraints","result","activeLogging","LOG_CACHE_POLICY","debug","globalThis","getWarpDriveRuntimeConfig","console","log","lid","headers","response","now","Date","date","xWarpDriveExpires","expirationTime","getTime","cacheControl","age","maxAge","ageValue","dateValue","Expires","expires","apiCacheHardExpires","TESTING","disableTestOptimization","apiCacheSoftExpires","time","deadline","DefaultCachePolicy","_getStore","store","set","_stores","invalidated","types","Map","constructor","WeakMap","_config","arguments","id","since","enabled","available","for","until","invalidateRequest","add","invalidateRequestsForType","type","storeCache","notifications","forEach","notify","didRequest","op","statusNumber","status","records","map","r","additionalTypes","cacheOptions","delete","isHardExpired","cache","cached","peekRequest","isSoftExpired"],"sources":["../src/store/-private/default-cache-policy.ts"],"sourcesContent":["import { deprecate } from '@ember/debug';\n\nimport { LOG_CACHE_POLICY } from '@warp-drive-mirror/core/build-config/debugging';\nimport { TESTING } from '@warp-drive-mirror/core/build-config/env';\nimport { assert } from '@warp-drive-mirror/core/build-config/macros';\n\n// oxlint-disable-next-line no-unused-vars\nimport type { CacheHandler, CachePolicy } from '../-private';\n// oxlint-disable-next-line no-unused-vars\nimport type { Fetch } from '../../request/-private/fetch';\nimport type { Cache } from '../../types/cache';\nimport type { RequestKey, ResourceKey } from '../../types/identifier';\nimport type {\n // oxlint-disable-next-line no-unused-vars\n CacheOptions,\n ImmutableRequestInfo,\n // oxlint-disable-next-line no-unused-vars\n RequestInfo,\n ResponseInfo,\n StructuredDocument,\n} from '../../types/request';\nimport type { ResourceDocument } from '../../types/spec/document';\nimport { LRUCache } from '../../utils/string';\n\ntype UnsubscribeToken = object;\ntype CacheOperation = 'added' | 'removed' | 'updated' | 'state';\ntype DocumentCacheOperation = 'invalidated' | 'added' | 'removed' | 'updated' | 'state';\n\nexport interface NotificationCallback {\n (resourceKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;\n (resourceKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;\n // (resourceKey: ResourceKey, notificationType: NotificationType, key?: string): void;\n}\n\ninterface ResourceOperationCallback {\n // resource updates\n (resourceKey: ResourceKey, notificationType: CacheOperation): void;\n}\n\ninterface DocumentOperationCallback {\n // document updates\n (cacheKey: RequestKey, notificationType: DocumentCacheOperation): void;\n}\n\ntype NotificationManager = {\n subscribe(resourceKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;\n subscribe(cacheKey: 'resource', callback: ResourceOperationCallback): UnsubscribeToken;\n subscribe(cacheKey: 'document' | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;\n\n notify(cacheKey: ResourceKey, value: 'attributes' | 'relationships', key?: string): boolean;\n notify(cacheKey: ResourceKey, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;\n notify(cacheKey: ResourceKey, value: CacheOperation): boolean;\n notify(cacheKey: RequestKey, value: DocumentCacheOperation): boolean;\n};\n\ntype Store = {\n cache: Cache;\n notifications: NotificationManager;\n};\n\n/**\n * Interface of a parsed Cache-Control header value.\n *\n * - [MDN Cache-Control Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)\n *\n * @summary The directives of a `Cache-Control` header as an object of flags and second counts, as\n * returned by `parseCacheControl`.\n */\nexport interface CacheControlValue {\n /** Indicates the response will never change; parsed but not currently used by this cache policy's expiration logic. */\n immutable?: boolean;\n /** Seconds since the response's `Date` that it is considered fresh; combined with the `Age` header to determine expiration. */\n 'max-age'?: number;\n /** Indicates a stale response must be revalidated before use; parsed but not currently used by this cache policy's expiration logic. */\n 'must-revalidate'?: boolean;\n /** Indicates the client must understand the response's status code semantics before caching; parsed but not currently used by this cache policy's expiration logic. */\n 'must-understand'?: boolean;\n /** Indicates the response must be revalidated before being reused from cache; parsed but not currently used by this cache policy's expiration logic. */\n 'no-cache'?: boolean;\n /** Indicates the response must not be stored in any cache; parsed but not currently used by this cache policy's expiration logic. */\n 'no-store'?: boolean;\n /** Indicates the response must not be transformed by intermediaries; parsed but not currently used by this cache policy's expiration logic. */\n 'no-transform'?: boolean;\n /** Indicates only an already-cached response should be used; parsed but not currently used by this cache policy's expiration logic. */\n 'only-if-cached'?: boolean;\n /** Indicates the response is intended for a single user and should not be stored by shared caches; parsed but not currently used by this cache policy's expiration logic. */\n private?: boolean;\n /** Like `must-revalidate` but only for shared caches; parsed but not currently used by this cache policy's expiration logic. */\n 'proxy-revalidate'?: boolean;\n /** Indicates the response may be stored by any cache; parsed but not currently used by this cache policy's expiration logic. */\n public?: boolean;\n /** Seconds since the response's `Date` that it is considered fresh for shared caches; used as a fallback for `max-age` when determining expiration. */\n 's-maxage'?: number;\n /** Seconds a stale response may be reused if an error occurs while revalidating; parsed but not currently used by this cache policy's expiration logic. */\n 'stale-if-error'?: number;\n /** Seconds a stale response may be reused while a revalidation happens in the background; parsed but not currently used by this cache policy's expiration logic. */\n 'stale-while-revalidate'?: number;\n}\n\ntype CacheControlKey = keyof CacheControlValue;\n\nconst NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);\n\n/**\n * Parses a string Cache-Control header value into an object with the following structure:\n *\n * ```ts\n * interface CacheControlValue {\n * immutable?: boolean;\n * 'max-age'?: number;\n * 'must-revalidate'?: boolean;\n * 'must-understand'?: boolean;\n * 'no-cache'?: boolean;\n * 'no-store'?: boolean;\n * 'no-transform'?: boolean;\n * 'only-if-cached'?: boolean;\n * private?: boolean;\n * 'proxy-revalidate'?: boolean;\n * public?: boolean;\n * 's-maxage'?: number;\n * 'stale-if-error'?: number;\n * 'stale-while-revalidate'?: number;\n * }\n * ```\n *\n * See also {@link CacheControlValue} and [Response Directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control#response_directives)\n *\n * @summary Parses a `Cache-Control` header string into a `CacheControlValue` object, caching results\n * per header string.\n * @public\n */\nexport function parseCacheControl(header: string): CacheControlValue {\n return CACHE_CONTROL_CACHE.get(header);\n}\n\nconst CACHE_CONTROL_CACHE = new LRUCache((header: string) => {\n let key: CacheControlKey = '' as CacheControlKey;\n let value = '';\n let isParsingKey = true;\n const cacheControlValue: CacheControlValue = {};\n\n for (let i = 0; i < header.length; i++) {\n const char = header.charAt(i);\n if (char === ',') {\n assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));\n assert(\n `Invalid Cache-Control value, expected a value after \"=\" but got \",\"`,\n i === 0 || header.charAt(i - 1) !== '='\n );\n isParsingKey = true;\n // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;\n key = '' as CacheControlKey;\n value = '';\n continue;\n } else if (char === '=') {\n assert(`Invalid Cache-Control value, expected a value after \"=\"`, i + 1 !== header.length);\n isParsingKey = false;\n } else if (char === ' ' || char === `\\t` || char === `\\n`) {\n continue;\n } else if (isParsingKey) {\n key += char;\n } else {\n value += char;\n }\n\n if (i === header.length - 1) {\n // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;\n }\n }\n\n return cacheControlValue;\n}, 200);\n\nfunction parseCacheControlValue(stringToParse: string): number {\n const parsedValue = Number.parseInt(stringToParse);\n assert(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`, !Number.isNaN(parsedValue));\n assert(`Invalid Cache-Control value, expected a number greater than 0 but got - ${stringToParse}`, parsedValue >= 0);\n if (Number.isNaN(parsedValue) || parsedValue < 0) {\n return 0;\n }\n\n return parsedValue;\n}\n\nfunction isExpired(cacheKey: RequestKey, request: StructuredDocument<ResourceDocument>, config: PolicyConfig): boolean {\n const { constraints } = config;\n\n if (constraints?.isExpired) {\n const result = constraints.isExpired(request);\n if (result !== null) {\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(\n `CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because constraints.isExpired returned ${result}`\n );\n }\n return result;\n }\n }\n\n const { headers } = request.response!;\n\n if (!headers) {\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(`CachePolicy: ${cacheKey.lid} is EXPIRED because no headers were provided`);\n }\n\n // if we have no headers then both the headers based expiration\n // and the time based expiration will be considered expired\n return true;\n }\n\n // check for X-WarpDrive-Expires\n const now = Date.now();\n const date = headers.get('Date');\n\n if (constraints?.headers) {\n if (constraints.headers['X-WarpDrive-Expires']) {\n const xWarpDriveExpires = headers.get('X-WarpDrive-Expires');\n if (xWarpDriveExpires) {\n const expirationTime = new Date(xWarpDriveExpires).getTime();\n const result = now >= expirationTime;\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(\n `CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by X-WarpDrive-Expires header is ${result ? 'in the past' : 'in the future'}`\n );\n }\n return result;\n }\n }\n\n // check for Cache-Control\n if (constraints.headers['Cache-Control']) {\n const cacheControl = headers.get('Cache-Control');\n const age = headers.get('Age');\n\n if (cacheControl && age && date) {\n const cacheControlValue = parseCacheControl(cacheControl);\n\n // max-age and s-maxage are stored in\n const maxAge = cacheControlValue['max-age'] || cacheControlValue['s-maxage'];\n\n if (maxAge) {\n // age is stored in seconds\n const ageValue = parseInt(age, 10);\n assert(`Invalid Cache-Control value, expected a number but got - ${age}`, !Number.isNaN(ageValue));\n assert(`Invalid Cache-Control value, expected a number greater than 0 but got - ${age}`, ageValue >= 0);\n\n if (!Number.isNaN(ageValue) && ageValue >= 0) {\n const dateValue = new Date(date).getTime();\n const expirationTime = dateValue + (maxAge - ageValue) * 1000;\n const result = now >= expirationTime;\n\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(\n `CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by Cache-Control header is ${result ? 'in the past' : 'in the future'}`\n );\n }\n\n return result;\n }\n }\n }\n }\n\n // check for Expires\n if (constraints.headers.Expires) {\n const expires = headers.get('Expires');\n if (expires) {\n const expirationTime = new Date(expires).getTime();\n const result = now >= expirationTime;\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(\n `CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by Expires header is ${result ? 'in the past' : 'in the future'}`\n );\n }\n return result;\n }\n }\n }\n\n // check for Date\n if (!date) {\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(`CachePolicy: ${cacheKey.lid} is EXPIRED because no Date header was provided`);\n }\n return true;\n }\n\n let expirationTime = config.apiCacheHardExpires;\n if (TESTING) {\n if (!config.disableTestOptimization) {\n expirationTime = config.apiCacheSoftExpires;\n }\n }\n\n const time = new Date(date).getTime();\n const deadline = time + expirationTime;\n const result = now >= deadline;\n\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(\n `CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the apiCacheHardExpires time since the response's Date header is ${result ? 'in the past' : 'in the future'}`\n );\n }\n\n return result;\n}\n\n/**\n * The constraint options for {@link PolicyConfig.constraints}\n */\nexport interface PolicyConfigConstraints {\n /**\n * Headers that should be checked for expiration.\n *\n */\n headers?: {\n /**\n * Whether the `Cache-Control` header should be checked for expiration.\n * If `true`, then the `max-age` and `s-maxage` directives are used alongside\n * the `Age` and `Date` headers to determine if the expiration time has passed.\n *\n * Other directives are ignored.\n *\n * 'Cache-Control' will take precedence over 'Expires' if both are present\n * and both configured to be checked.\n *\n */\n 'Cache-Control'?: boolean;\n\n /**\n * Whether the `Expires` header should be checked for expiration.\n *\n * If `true`, then the `Expires` header is used to caclulate the expiration time\n * and determine if the expiration time has passed.\n *\n * 'Cache-Control' will take precedence over 'Expires' if both are present.\n *\n */\n Expires?: boolean;\n\n /**\n * Whether the `X-WarpDrive-Expires` header should be checked for expiration.\n *\n * If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time\n * and determine if the expiration time has passed.\n *\n * This header will take precedence over 'Cache-Control' and 'Expires' if all three are present.\n *\n * The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).\n *\n */\n 'X-WarpDrive-Expires'?: boolean;\n };\n\n /**\n * A function that should be called to determine if the request is expired.\n *\n * If present, this function will be called with the request and should return\n * `true` if the request is expired, `false` if it is not expired, and\n * `null` if the expiration status is unknown.\n *\n * If the function does not return `null`,\n *\n */\n isExpired?: (request: StructuredDocument<ResourceDocument>) => boolean | null;\n}\n\n/**\n * The configuration options for the {@link DefaultCachePolicy}\n *\n * The [Advanced Store Configuration](/guides/configuration/advanced#decide-how-long-requests-are-valid-for-with-a-cachepolicy)\n * guide shows a policy configured with them.\n *\n * ```ts [app/services/store.ts]\n * import { Store } from '@warp-drive-mirror/core';\n * import { DefaultCachePolicy } from '@warp-drive-mirror/core/store'; // [!code focus]\n *\n * export default class AppStore extends Store {\n * lifetimes = new DefaultCachePolicy({ // [!code focus:3]\n * // ... PolicyConfig Settings ... //\n * });\n * }\n * ```\n *\n * @summary Options for `DefaultCachePolicy`: soft and hard expiration times, header-based expiration\n * constraints, and test-mode behavior.\n */\nexport interface PolicyConfig {\n /**\n * the number of milliseconds after which a request is considered\n * stale. If a request is issued again after this time, the request\n * will respond from cache immediately while a background request\n * is made to update the cache.\n *\n * This is calculated against the `date` header of the response.\n *\n * If your API does not provide a `date` header, the {@link Fetch} handler\n * will automatically add it to responses if it is not present. Responses\n * without a `date` header will be considered stale immediately.\n *\n */\n apiCacheSoftExpires: number;\n /**\n * the number of milliseconds after which a request is considered\n * expired and should be re-fetched. If a request is issued again\n * after this time, the request will disregard the cache and\n * wait for a fresh response from the API.\n *\n * This is calculated against the `date` header of the response.\n *\n * If your API does not provide a `date` header, the {@link Fetch} handler\n * will automatically add it to responses if it is not present. Responses\n * without a `date` header will be considered hard expired immediately.\n *\n */\n apiCacheHardExpires: number;\n /**\n * In Testing environments, the `apiCacheSoftExpires` will always be `false`\n * and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.\n *\n * This helps reduce flakiness and produce predictably rendered results in test suites.\n *\n * Requests that specifically set {@link RequestInfo.cacheOptions.backgroundReload | cacheOptions.backgroundReload }\n * will still be background reloaded in tests.\n *\n * This behavior can be opted out of by setting this value to `true`.\n *\n */\n disableTestOptimization?: boolean;\n\n /**\n * In addition to the simple time-based expiration strategy, CachePolicy\n * supports various common server-supplied expiration strategies via\n * headers, as well as custom expiration strategies via the {@link PolicyConfigConstraints.isExpired | isExpired}\n * function.\n *\n * Requests will be validated for expiration against these constraints.\n * If any of these constraints are not met, the request will be considered\n * expired. If all constraints are met, the request will be considered\n * valid and the time based expiration strategy will NOT be used.\n *\n * Meeting a constraint means BOTH that the properties the constraint\n * requires are present AND that the expiration time indicated by those\n * properties has not been exceeded.\n *\n * In other words, if the properties for a constraint are not present,\n * this does not count either as meeting or as not meeting the constraint,\n * the constraint simply does not apply.\n *\n * The `isExpired` function is called with the request and should return\n * `true` if the request is expired, `false` if it is not expired, and\n * `null` if the expiration status is unknown.\n *\n * In order constraints are checked:\n *\n * - isExpired function\n * - ↳ (if null) X-WarpDrive-Expires header\n * - ↳ (if null) Cache-Control header\n * - ↳ (if null) Expires header\n *\n * See {@link PolicyConfigConstraints} for configuration options.\n */\n constraints?: PolicyConfigConstraints;\n}\n\n/**\n * A basic {@link CachePolicy} that can be added to the Store service.\n *\n * The [Advanced Store Configuration](/guides/configuration/advanced#decide-how-long-requests-are-valid-for-with-a-cachepolicy)\n * guide shows how to configure it.\n *\n * ```ts [app/services/store.ts]\n * import { Store } from '@warp-drive-mirror/core';\n * import { DefaultCachePolicy } from '@warp-drive-mirror/core/store'; // [!code focus]\n *\n * export default class AppStore extends Store {\n * lifetimes = new DefaultCachePolicy({ // [!code focus:5]\n * apiCacheSoftExpires: 30_000,\n * apiCacheHardExpires: 60_000,\n * // ... Other PolicyConfig Settings ... //\n * });\n * }\n * ```\n *\n * :::tip 💡 TIP\n * Date headers do not have millisecond precision, so expiration times should\n * generally be larger than 1000ms.\n * :::\n *\n * See also {@link PolicyConfig} for configuration options.\n *\n * ### The Mechanics\n *\n * This policy determines staleness based on various configurable constraints falling back to a simple\n * check of the time elapsed since the request was last received from the API using the `date` header\n * from the last response.\n *\n * :::tip 💡 TIP\n * The {@link Fetch} handler provided by `@warp-drive-mirror/core` will automatically\n * add the `date` header to responses if it is not present.\n * :::\n *\n * - For manual override of reload see {@link CacheOptions.reload | cacheOptions.reload}\n * - For manual override of background reload see {@link CacheOptions.backgroundReload | cacheOptions.backgroundReload}\n *\n * In order expiration is determined by:\n *\n * ```md\n * Is explicitly invalidated by `cacheOptions.reload`\n * ↳ (if falsey) if the request has been explicitly invalidated\n * since the last request (see Automatic Invalidation below)\n * ↳ (if false) (If Active) isExpired function\n * ↳ (if null) (If Active) X-WarpDrive-Expires header\n * ↳ (if null) (If Active) Cache-Control header\n * ↳ (if null) (If Active) Expires header\n * ↳ (if null) Date header + apiCacheHardExpires < current time\n *\n * -- <if above is false, a background request is issued if> --\n *\n * ↳ is invalidated by `cacheOptions.backgroundReload`\n * ↳ (if falsey) Date header + apiCacheSoftExpires < current time\n * ```\n *\n * ### Automatic Invalidation / Entanglement\n *\n * It also invalidates any request with an {@link RequestInfo.op | OpCode} of `\"query\"`\n * for which {@link CacheOptions.types | cacheOptions.types} was provided\n * when a request with an `OpCode` of `\"createRecord\"` is successful and also includes\n * a matching type in its own `cacheOptions.types` array.\n\n * :::tip 💡 TIP\n * Abstracting this behavior via builders is recommended to ensure consistency.\n * :::\n *\n * ### Testing\n *\n * In Testing environments:\n *\n * - `apiCacheSoftExpires` will always be `false`\n * - `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.\n *\n * This helps reduce flakiness and produce predictably rendered results in test suites.\n *\n * Requests that specifically set `cacheOptions.backgroundReload = true` will\n * still be background reloaded in tests.\n *\n * This behavior can be opted out of by setting `disableTestOptimization = true`\n * in the policy config.\n *\n * @summary The built-in cache policy, which expires cached requests using expiration headers or time\n * since the response `date`, and invalidates queries after matching creates.\n * @public\n */\nexport class DefaultCachePolicy implements CachePolicy {\n /**\n * @internal\n */\n declare private config: PolicyConfig;\n /**\n * @internal\n */\n declare private _stores: WeakMap<Store, { invalidated: Set<RequestKey>; types: Map<string, Set<RequestKey>> }>;\n\n /**\n * @internal\n */\n private _getStore(store: Store): {\n invalidated: Set<RequestKey>;\n types: Map<string, Set<RequestKey>>;\n } {\n let set = this._stores.get(store);\n if (!set) {\n set = { invalidated: new Set(), types: new Map() };\n this._stores.set(store, set);\n }\n return set;\n }\n\n constructor(config: PolicyConfig) {\n this._stores = new WeakMap();\n\n const _config = arguments.length === 1 ? config : (arguments[1] as unknown as PolicyConfig);\n deprecate(\n `Passing a Store to the CachePolicy is deprecated, please pass only a config instead.`,\n arguments.length === 1,\n {\n id: 'ember-data-mirror:request-utils:lifetimes-service-store-arg',\n since: {\n enabled: '5.4',\n available: '4.13',\n },\n for: '@ember-data-mirror/request-utils',\n until: '6.0',\n }\n );\n assert(`You must pass a config to the CachePolicy`, _config);\n assert(`You must pass a apiCacheSoftExpires to the CachePolicy`, typeof _config.apiCacheSoftExpires === 'number');\n assert(`You must pass a apiCacheHardExpires to the CachePolicy`, typeof _config.apiCacheHardExpires === 'number');\n this.config = _config;\n }\n\n /**\n * Invalidate a request by its CacheKey for the given store instance.\n *\n * While the store argument may seem redundant, the CachePolicy\n * is designed to be shared across multiple stores / forks\n * of the store.\n *\n * ```ts\n * store.lifetimes.invalidateRequest(store, cacheKey);\n * ```\n *\n * @public\n */\n invalidateRequest(cacheKey: RequestKey, store: Store): void {\n this._getStore(store).invalidated.add(cacheKey);\n }\n\n /**\n * Invalidate all requests associated to a specific type\n * for a given store instance.\n *\n * While the store argument may seem redundant, the CachePolicy\n * is designed to be shared across multiple stores / forks\n * of the store.\n *\n * This invalidation is done automatically when using this service\n * for both the {@link CacheHandler} and the [NetworkHandler](/api/@warp-drive-mirror/legacy/compat/variables/LegacyNetworkHandler).\n *\n * ```ts\n * store.lifetimes.invalidateRequestsForType(store, 'person');\n * ```\n *\n * @public\n */\n invalidateRequestsForType(type: string, store: Store): void {\n const storeCache = this._getStore(store);\n const set = storeCache.types.get(type);\n const notifications = store.notifications;\n\n if (set) {\n // TODO batch notifications\n set.forEach((id) => {\n storeCache.invalidated.add(id);\n // @ts-expect-error\n notifications.notify(id, 'invalidated', null);\n });\n }\n }\n\n /**\n * Invoked when a request has been fulfilled from the configured request handlers.\n * This is invoked by the CacheHandler for both foreground and background requests\n * once the cache has been updated.\n *\n * Note, this is invoked by the {@link CacheHandler} regardless of whether\n * the request has a cache-key.\n *\n * This method should not be invoked directly by consumers.\n *\n * @public\n */\n didRequest(\n request: ImmutableRequestInfo,\n response: Response | ResponseInfo | null,\n cacheKey: RequestKey | null,\n store: Store\n ): void {\n // if this is a successful createRecord request, invalidate the cacheKey for the type\n if (request.op === 'createRecord') {\n const statusNumber = response?.status ?? 0;\n if (statusNumber >= 200 && statusNumber < 400) {\n const types = new Set(request.records?.map((r) => r.type));\n const additionalTypes = request.cacheOptions?.types;\n additionalTypes?.forEach((type) => {\n types.add(type);\n });\n\n types.forEach((type) => {\n this.invalidateRequestsForType(type, store);\n });\n }\n\n // add this document's cacheKey to a map for all associated types\n // it is recommended to only use this for queries\n } else if (cacheKey && request.cacheOptions?.types?.length) {\n const storeCache = this._getStore(store);\n request.cacheOptions?.types.forEach((type) => {\n const set = storeCache.types.get(type);\n if (set) {\n set.add(cacheKey);\n storeCache.invalidated.delete(cacheKey);\n } else {\n storeCache.types.set(type, new Set([cacheKey]));\n }\n });\n }\n }\n\n /**\n * Invoked to determine if the request may be fulfilled from cache\n * if possible.\n *\n * Note, this is only invoked by the {@link CacheHandler} if the request has\n * a cache-key.\n *\n * If no cache entry is found or the entry is hard expired,\n * the request will be fulfilled from the configured request handlers\n * and the cache will be updated before returning the response.\n *\n * @public\n * @return true if the request is considered hard expired\n */\n isHardExpired(cacheKey: RequestKey, store: Store): boolean {\n // if we are explicitly invalidated, we are hard expired\n const storeCache = this._getStore(store);\n if (storeCache.invalidated.has(cacheKey)) {\n return true;\n }\n const cache = store.cache;\n const cached = cache.peekRequest(cacheKey);\n\n if (!cached?.response) {\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(`CachePolicy: ${cacheKey.lid} is EXPIRED because no cache entry was found`);\n }\n return true;\n }\n\n return isExpired(cacheKey, cached, this.config);\n }\n\n /**\n * Invoked if `isHardExpired` is false to determine if the request\n * should be update behind the scenes if cache data is already available.\n *\n * Note, this is only invoked by the {@link CacheHandler} if the request has\n * a cache-key.\n *\n * If true, the request will be fulfilled from cache while a backgrounded\n * request is made to update the cache via the configured request handlers.\n *\n * @public\n * @return true if the request is considered soft expired\n */\n isSoftExpired(cacheKey: RequestKey, store: Store): boolean {\n if (TESTING) {\n if (!this.config.disableTestOptimization) {\n return false;\n }\n }\n const cache = store.cache;\n const cached = cache.peekRequest(cacheKey);\n\n if (cached?.response) {\n const date = cached.response.headers.get('date');\n\n if (!date) {\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(`CachePolicy: ${cacheKey.lid} is STALE because no date header was found`);\n }\n return true;\n } else {\n const time = new Date(date).getTime();\n const now = Date.now();\n const deadline = time + this.config.apiCacheSoftExpires;\n const result = now >= deadline;\n\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(\n `CachePolicy: ${cacheKey.lid} is ${result ? 'STALE' : 'NOT stale'}. Expiration time: ${deadline}, now: ${now}`\n );\n }\n\n return result;\n }\n }\n\n if (LOG_CACHE_POLICY) {\n // oxlint-disable-next-line no-console\n console.log(`CachePolicy: ${cacheKey.lid} is STALE because no cache entry was found`);\n }\n\n return true;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqGA,MAAMI,+BAAe,IAAIC,IAAI;CAAC;CAAW;CAAY;CAAkB;AAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BhG,SAAgBC,kBAAkBC,QAAmC;CACnE,OAAOC,oBAAoBC,IAAIF,MAAM;AACvC;AAEA,MAAMC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/C,IAAI,CAACuC,MAAM;IACT,IAAA7C,eAAAD,gBAAA,CAAA,CAAAgB,UAAAkB,cAAAC,gBAAA,GAAA;SAAAnC,gBAAA,CAAA,CAAAgB,UAAAoB,MAAAD,oBAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,kBAEEI,QAAQC,IAAI,gBAAgBX,SAASY,IAAG,2CAA4C;IACtF;IACA,OAAO;GACT,OAAO;IACL,MAAMoB,OAAO,IAAIhB,KAAKC,IAAI,CAAC,CAACG,QAAQ;IACpC,MAAML,MAAMC,KAAKD,IAAI;IACrB,MAAMkB,WAAWD,OAAO,KAAK9B,OAAO6B;IACpC,MAAM3B,SAASW,OAAOkB;IAEtB,IAAA7D,eAAAD,gBAAA,CAAA,CAAAgB,UAAAkB,cAAAC,gBAAA,GAAA;SAAAnC,gBAAA,CAAA,CAAAgB,UAAAoB,MAAAD,oBAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,kBAEEI,QAAQC,IACN,gBAAgBX,SAASY,IAAG,MAAOR,SAAS,UAAU,YAAW,qBAAsB6B,SAAQ,SAAUlB,KAC3G;IACF;IAEA,OAAOX;GACT;EACF;EAEA,IAAAhC,eAAAD,gBAAA,CAAA,CAAAgB,UAAAkB,cAAAC,gBAAA,GAAA;OAAAnC,gBAAA,CAAA,CAAAgB,UAAAoB,MAAAD,oBAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,kBAEEI,QAAQC,IAAI,gBAAgBX,SAASY,IAAG,2CAA4C;EACtF;EAEA,OAAO;CACT;AACF"}
package/dist/store.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as PolicyConfig, O as CacheControlValue, Qt as NotificationManager, j as parseCacheControl, k as DefaultCachePolicy } from "./internal-9XuWZdDv.js";
1
+ import { F as PolicyConfig, I as parseCacheControl, N as CacheControlValue, P as DefaultCachePolicy, rn as NotificationManager } from "./internal-CgOlgOt3.js";
2
2
  export { type CacheControlValue, DefaultCachePolicy, type NotificationManager, type PolicyConfig, parseCacheControl };
package/dist/store.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as parseCacheControl, t as DefaultCachePolicy } from "./store-DNF9Rgoh.js";
1
+ import { n as parseCacheControl, t as DefaultCachePolicy } from "./store-lcyaxrpj.js";
2
2
 
3
3
  export { DefaultCachePolicy, parseCacheControl };
@@ -3,6 +3,7 @@
3
3
  * Symbol used internally to stash a reference to the owning
4
4
  * {@link Store} on a record instance.
5
5
  *
6
+ * @summary Internal symbol key under which a record instance keeps a reference to the store that owns it.
6
7
  * @type {Symbol}
7
8
  */
8
9
  declare const RecordStore: "___(unique) Symbol(Store)";
@@ -42,6 +43,8 @@ declare const RecordStore: "___(unique) Symbol(Store)";
42
43
  * If used, `attr<Transform>('name')` will enforce
43
44
  * that the name is the same as the transform name.
44
45
  *
46
+ * @summary Symbol key that brands a record with its resource type for TypeScript, and names a derivation or
47
+ * transformation when it is registered.
45
48
  * @type {Symbol}
46
49
  */
47
50
  declare const Type: "___(unique) Symbol($type)";
@@ -56,6 +59,8 @@ declare const Type: "___(unique) Symbol($type)";
56
59
  * take advantage of this to provide better type
57
60
  * safety and intellisense.
58
61
  *
62
+ * @summary Alias of the `Type` symbol that a record type can declare to tell WarpDrive APIs its resource type for
63
+ * better type inference.
59
64
  * @type {Symbol}
60
65
  */
61
66
  declare const ResourceType: "___(unique) Symbol($type)";
@@ -73,6 +78,8 @@ declare const ResourceType: "___(unique) Symbol($type)";
73
78
  * If used, `attr<Transform>('name')` will enforce
74
79
  * that the name is the same as the transform name.
75
80
  *
81
+ * @summary Alias of the `Type` symbol that a legacy transform can declare so `attr<Transform>('name')` checks the
82
+ * transform name at the type level.
76
83
  * @type {Symbol}
77
84
  */
78
85
  declare const TransformName: "___(unique) Symbol($type)";
@@ -80,9 +87,11 @@ declare const TransformName: "___(unique) Symbol($type)";
80
87
  * Symbol for use by builders to indicate the return type
81
88
  * generic to use for store.request()
82
89
  *
90
+ * @summary Type-only symbol key that request builders set on the request they return so `store.request()` can
91
+ * infer the response type.
83
92
  * @type {Symbol}
84
93
  */
85
94
  declare const RequestSignature: "___(unique) Symbol(RequestSignature)";
86
95
  //#endregion
87
96
  export { Type as a, TransformName as i, RequestSignature as n, ResourceType as r, RecordStore as t };
88
- //# sourceMappingURL=symbols-DjRDCeX0.d.ts.map
97
+ //# sourceMappingURL=symbols-Cu9un1NR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbols-Cu9un1NR.d.ts","names":[],"sources":["../src/types/symbols.ts"],"mappings":";;;;;;;;cAiBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0CA;;;;;;;;;;;;;;;;cAiBA;;;;;;;;;;;;;;;;;;;cAoBA;;;;;;;;;cAUA"}
@@ -2,7 +2,7 @@ import { getGlobalConfig, macroCondition } from "@embroider/macros";
2
2
 
3
3
  //#region src/types/-private.ts
4
4
  const name = "@warp-drive-mirror/core";
5
- const version = "5.10.0-alpha.10";
5
+ const version = "5.10.0-alpha.13";
6
6
  const GlobalRef = globalThis;
7
7
  const UniversalCache = GlobalRef.__warpDrive_universalCache = GlobalRef.__warpDrive_universalCache ?? {};
8
8
  GlobalRef[name] = GlobalRef[name] ?? { __version: version };
@@ -1,2 +1,2 @@
1
- import { t as ResourceBlob } from "../../aliases-BWYW5EhX.js";
1
+ import { t as ResourceBlob } from "../../aliases-BQmAxXmb.js";
2
2
  export { ResourceBlob };
@@ -1,2 +1,2 @@
1
- import { t as Change } from "../../change-C7kqv2kW.js";
1
+ import { t as Change } from "../../change-DClXcHvr.js";
2
2
  export { Change };
@@ -1,2 +1,2 @@
1
- import { a as ReplaceRelatedRecordsMutation, i as ReplaceRelatedRecordMutation, n as Mutation, o as SortRelatedRecordsMutation, r as RemoveFromResourceRelationshipMutation, t as AddToResourceRelationshipMutation } from "../../mutations-CqtoGB4t.js";
1
+ import { a as ReplaceRelatedRecordsMutation, i as ReplaceRelatedRecordMutation, n as Mutation, o as SortRelatedRecordsMutation, r as RemoveFromResourceRelationshipMutation, t as AddToResourceRelationshipMutation } from "../../mutations-C81gbYjB.js";
2
2
  export { AddToResourceRelationshipMutation, Mutation, RemoveFromResourceRelationshipMutation, ReplaceRelatedRecordMutation, ReplaceRelatedRecordsMutation, SortRelatedRecordsMutation };
@@ -1,2 +1,2 @@
1
- import { a as Op, c as RemoveFromDocumentOperation, d as UpdateResourceFieldOperation, f as UpdateResourceOperation, i as MergeOperation, l as RemoveFromResourceRelationshipOperation, n as AddToDocumentOperation, o as Operation, p as UpdateResourceRelationshipOperation, r as AddToResourceRelationshipOperation, s as RemoveDocumentOperation, t as AddResourceOperation, u as RemoveResourceOperation } from "../../operations-D1qA6r0_.js";
1
+ import { a as Op, c as RemoveFromDocumentOperation, d as UpdateResourceFieldOperation, f as UpdateResourceOperation, i as MergeOperation, l as RemoveFromResourceRelationshipOperation, n as AddToDocumentOperation, o as Operation, p as UpdateResourceRelationshipOperation, r as AddToResourceRelationshipOperation, s as RemoveDocumentOperation, t as AddResourceOperation, u as RemoveResourceOperation } from "../../operations-B4pQM7D6.js";
2
2
  export { AddResourceOperation, AddToDocumentOperation, AddToResourceRelationshipOperation, MergeOperation, Op, Operation, RemoveDocumentOperation, RemoveFromDocumentOperation, RemoveFromResourceRelationshipOperation, RemoveResourceOperation, UpdateResourceFieldOperation, UpdateResourceOperation, UpdateResourceRelationshipOperation };
@@ -1,2 +1,2 @@
1
- import { n as Relationship, r as ResourceRelationship, t as CollectionRelationship } from "../../relationship-CmHzMPKf.js";
1
+ import { n as Relationship, r as ResourceRelationship, t as CollectionRelationship } from "../../relationship-BlGIXgj4.js";
2
2
  export { CollectionRelationship, Relationship, ResourceRelationship };
@@ -1,2 +1,2 @@
1
- import { Gt as Cache, Kt as ChangedAttributesHash, qt as RelationshipDiff } from "../internal-9XuWZdDv.js";
1
+ import { Qt as RelationshipDiff, Xt as Cache, Zt as ChangedAttributesHash } from "../internal-CgOlgOt3.js";
2
2
  export { Cache, ChangedAttributesHash, RelationshipDiff };
@@ -1,2 +1,2 @@
1
- import { a as ReplaceRelatedRecordOperation, c as UnknownOperation, i as RemoteRelationshipOperation, l as UpdateRelationshipOperation, n as LocalRelationshipOperation, o as ReplaceRelatedRecordsOperation, r as Operation, s as SortRelatedRecords, t as DeleteRecordOperation } from "../graph-DLqYXP2z.js";
1
+ import { a as ReplaceRelatedRecordOperation, c as UnknownOperation, i as RemoteRelationshipOperation, l as UpdateRelationshipOperation, n as LocalRelationshipOperation, o as ReplaceRelatedRecordsOperation, r as Operation, s as SortRelatedRecords, t as DeleteRecordOperation } from "../graph-rjTyJ-gd.js";
2
2
  export { DeleteRecordOperation, LocalRelationshipOperation, Operation, RemoteRelationshipOperation, ReplaceRelatedRecordOperation, ReplaceRelatedRecordsOperation, SortRelatedRecords, UnknownOperation, UpdateRelationshipOperation };
@@ -1,2 +1,2 @@
1
- import { a as DEBUG_STALE_CACHE_OWNER, c as RequestKey, d as StableExistingRecordIdentifier, f as StableRecordIdentifier, i as DEBUG_KEY_TYPE, l as ResourceKey, n as CacheKeyType, o as NewResourceKey, r as DEBUG_CLIENT_ORIGINATED, s as PersistedResourceKey, t as CACHE_OWNER, u as StableDocumentIdentifier } from "../identifier-DQnqOSJK.js";
1
+ import { a as DEBUG_STALE_CACHE_OWNER, c as RequestKey, d as StableExistingRecordIdentifier, f as StableRecordIdentifier, i as DEBUG_KEY_TYPE, l as ResourceKey, n as CacheKeyType, o as NewResourceKey, r as DEBUG_CLIENT_ORIGINATED, s as PersistedResourceKey, t as CACHE_OWNER, u as StableDocumentIdentifier } from "../identifier-B_tK3FUw.js";
2
2
  export { CACHE_OWNER, CacheKeyType, DEBUG_CLIENT_ORIGINATED, DEBUG_KEY_TYPE, DEBUG_STALE_CACHE_OWNER, NewResourceKey, PersistedResourceKey, RequestKey, ResourceKey, StableDocumentIdentifier, StableExistingRecordIdentifier, StableRecordIdentifier };
@@ -2,6 +2,11 @@ import { getGlobalConfig, macroCondition } from "@embroider/macros";
2
2
 
3
3
  //#region src/types/identifier.ts
4
4
  /**
5
+ * @module
6
+ * @summary Types for the stable keys that reference cached data, `ResourceKey` for resources and `RequestKey` for
7
+ * request documents, plus their deprecated identifier aliases.
8
+ */
9
+ /**
5
10
  * @private
6
11
  */
7
12
  const DEBUG_CLIENT_ORIGINATED = Symbol("record-originated-on-client");
@@ -24,6 +29,8 @@ const CACHE_OWNER = ProdSymbol("__$co", "CACHE_OWNER");
24
29
  * Identifies which "bucket" of the cache a key belongs to: resources
25
30
  * (`'record'`, see {@link ResourceKey}) or request documents
26
31
  * (`'document'`, see {@link RequestKey}).
32
+ *
33
+ * @summary Which cache bucket a key belongs to: `'record'` for resource keys or `'document'` for request keys.
27
34
  */
28
35
  /**
29
36
  * A referentially stable object with a unique string (lid) that can be used
@@ -32,9 +39,17 @@ const CACHE_OWNER = ProdSymbol("__$co", "CACHE_OWNER");
32
39
  * Only requests that are assigned a RequestKey are retrievable/replayable from
33
40
  * the cache, though requests without RequestKeys may still update cache state.
34
41
  *
42
+ * The [Key Terminology](/guides/the-manual/caching/key-terms#documents) guide explains
43
+ * the documents it identifies.
44
+ *
45
+ * @summary Stable object with a unique `lid` that references a cached request document, letting that request's
46
+ * result be retrieved or replayed.
35
47
  * @public
36
48
  */
37
- /** @deprecated use {@link RequestKey} */
49
+ /**
50
+ * @summary Deprecated alias for `RequestKey`, the stable cache reference to a request document.
51
+ * @deprecated use {@link RequestKey}
52
+ */
38
53
  /**
39
54
  * Used when an ResourceKey is known to be the stable version
40
55
  */
@@ -45,8 +60,13 @@ const CACHE_OWNER = ProdSymbol("__$co", "CACHE_OWNER");
45
60
  * Distinguishing between this ResourceKey and one for a client created
46
61
  * resource that was created with an ID is generally speaking not possible
47
62
  * at runtime, so anything with an ID typically narrows to this.
63
+ *
64
+ * @summary Resource key whose `id` is a known string, the form keys for server-loaded resources take.
65
+ */
66
+ /**
67
+ * @summary Deprecated alias for `PersistedResourceKey`, a resource key whose `id` is known.
68
+ * @deprecated use {@link PersistedResourceKey}
48
69
  */
49
- /** @deprecated use {@link PersistedResourceKey} */
50
70
  /**
51
71
  * Used when a ResourceKey was created locally
52
72
  * (by a call to store.createRecord).
@@ -55,6 +75,8 @@ const CACHE_OWNER = ProdSymbol("__$co", "CACHE_OWNER");
55
75
  * that is not for a new record but does not have an ID. This would
56
76
  * happen if a user intentionally created one for use with a secondary-index
57
77
  * prior to the record having been fully loaded.
78
+ *
79
+ * @summary Resource key for a record created locally with `store.createRecord`, whose `id` may still be `null`.
58
80
  */
59
81
  /**
60
82
  * A referentially stable object with a unique string (lid) that can be used
@@ -63,9 +85,17 @@ const CACHE_OWNER = ProdSymbol("__$co", "CACHE_OWNER");
63
85
  * Every resource has a unique ResourceKey, and ResourceKeys may refer
64
86
  * to data that has never been loaded (for instance, in an async relationship).
65
87
  *
88
+ * The [Key Terminology](/guides/the-manual/caching/key-terms#resources) guide explains
89
+ * the resources it identifies.
90
+ *
91
+ * @summary Stable object with a unique `lid` plus `type` and `id` that uniquely references one resource's data in
92
+ * the cache, loaded or not.
66
93
  * @public
67
94
  */
68
- /** @deprecated use {@link ResourceKey} */
95
+ /**
96
+ * @summary Deprecated alias for `ResourceKey`, the stable cache reference to a single resource.
97
+ * @deprecated use {@link ResourceKey}
98
+ */
69
99
  //#endregion
70
100
  export { CACHE_OWNER, DEBUG_CLIENT_ORIGINATED, DEBUG_KEY_TYPE, DEBUG_STALE_CACHE_OWNER };
71
101
  //# sourceMappingURL=identifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","names":["getGlobalConfig","macroCondition","DEBUG_CLIENT_ORIGINATED","Symbol","DEBUG_KEY_TYPE","DEBUG_STALE_CACHE_OWNER","ProdSymbol","str","debugStr","WarpDrive","env","DEBUG","CACHE_OWNER"],"sources":["../../src/types/identifier.ts"],"sourcesContent":["import { DEBUG } from '@warp-drive-mirror/core/build-config/env';\n\n// provided for additional debuggability\n/**\n * @private\n */\nexport const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');\n/**\n * @private\n */\nexport const DEBUG_KEY_TYPE: unique symbol = Symbol('key-type');\n/**\n * @private\n */\nexport const DEBUG_STALE_CACHE_OWNER: unique symbol = Symbol('warpDriveStaleCache');\n\nfunction ProdSymbol<T extends string>(str: T, debugStr: string): T {\n return DEBUG ? (Symbol(debugStr) as unknown as T) : str;\n}\n\n// also present in production\n/**\n * @private\n */\nexport const CACHE_OWNER: '__$co' = ProdSymbol('__$co', 'CACHE_OWNER');\n\n/**\n * Identifies which \"bucket\" of the cache a key belongs to: resources\n * (`'record'`, see {@link ResourceKey}) or request documents\n * (`'document'`, see {@link RequestKey}).\n */\nexport type CacheKeyType = 'record' | 'document';\n\n/**\n * A referentially stable object with a unique string (lid) that can be used\n * as a reference to request data in the cache.\n *\n * Only requests that are assigned a RequestKey are retrievable/replayable from\n * the cache, though requests without RequestKeys may still update cache state.\n *\n * @public\n */\nexport interface RequestKey {\n /**\n * A string representing a unique identity.\n */\n lid: string;\n /**\n * Discriminates a {@link RequestKey} from a {@link ResourceKey}.\n */\n type: '@document';\n /** @internal */\n [CACHE_OWNER]: number | undefined;\n}\n\n/** @deprecated use {@link RequestKey} */\nexport type StableDocumentIdentifier = RequestKey;\n\n/**\n * Used when an ResourceKey is known to be the stable version\n */\ninterface ResourceKeyBase<T extends string = string> {\n /**\n * A string representing a unique identity.\n *\n * @public\n */\n lid: string;\n\n /**\n * the primary `ResourceType` or \"model name\" this ResourceKey belongs to.\n *\n * @public\n */\n type: T;\n\n /** @internal */\n [CACHE_OWNER]: number | undefined;\n\n /** @internal */\n [DEBUG_CLIENT_ORIGINATED]?: boolean;\n /** @internal */\n [DEBUG_STALE_CACHE_OWNER]?: number | undefined;\n}\n\n/**\n * Used when a ResourceKey was not created locally as part\n * of a call to store.createRecord\n *\n * Distinguishing between this ResourceKey and one for a client created\n * resource that was created with an ID is generally speaking not possible\n * at runtime, so anything with an ID typically narrows to this.\n */\nexport interface PersistedResourceKey<T extends string = string> extends ResourceKeyBase<T> {\n /**\n * the PrimaryKey for the resource this ResourceKey represents.\n *\n * @public\n */\n id: string;\n}\n\n/** @deprecated use {@link PersistedResourceKey} */\nexport type StableExistingRecordIdentifier<T extends string = string> = PersistedResourceKey<T>;\n\n/**\n * Used when a ResourceKey was created locally\n * (by a call to store.createRecord).\n *\n * It is possible in rare circumstances to have a ResourceKey\n * that is not for a new record but does not have an ID. This would\n * happen if a user intentionally created one for use with a secondary-index\n * prior to the record having been fully loaded.\n */\nexport interface NewResourceKey<T extends string = string> extends ResourceKeyBase<T> {\n /**\n * the PrimaryKey for the resource this ResourceKey represents. `null`\n * if not yet assigned a PrimaryKey value.\n *\n * @public\n */\n id: string | null;\n}\n\n/**\n * A referentially stable object with a unique string (lid) that can be used\n * as a reference to data in the cache.\n *\n * Every resource has a unique ResourceKey, and ResourceKeys may refer\n * to data that has never been loaded (for instance, in an async relationship).\n *\n * @public\n */\nexport type ResourceKey<T extends string = string> = PersistedResourceKey<T> | NewResourceKey<T>;\n\n/** @deprecated use {@link ResourceKey} */\nexport type StableRecordIdentifier<T extends string = string> = ResourceKey<T>;\n"],"mappings":";;;;;;AAMA,MAAaE,0BAAyCC,OAAO,6BAA6B;;;;AAI1F,MAAaC,iBAAgCD,OAAO,UAAU;;;;AAI9D,MAAaE,0BAAyCF,OAAO,qBAAqB;AAElF,SAASG,WAA6BC,KAAQC,UAAqB;CACjE,OAAOP,eAAAD,gBAAA,CAAA,CAAAS,UAAAC,IAAAC,KAAA,IAASR,OAAOK,QAAQ,IAAqBD;AACtD;;;;AAMA,MAAaK,cAAuBN,WAAW,SAAS,aAAa"}
1
+ {"version":3,"file":"identifier.js","names":["getGlobalConfig","macroCondition","DEBUG_CLIENT_ORIGINATED","Symbol","DEBUG_KEY_TYPE","DEBUG_STALE_CACHE_OWNER","ProdSymbol","str","debugStr","WarpDrive","env","DEBUG","CACHE_OWNER"],"sources":["../../src/types/identifier.ts"],"sourcesContent":["/**\n * @module\n * @summary Types for the stable keys that reference cached data, `ResourceKey` for resources and `RequestKey` for\n * request documents, plus their deprecated identifier aliases.\n */\n\nimport { DEBUG } from '@warp-drive-mirror/core/build-config/env';\n\n// provided for additional debuggability\n/**\n * @private\n */\nexport const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');\n/**\n * @private\n */\nexport const DEBUG_KEY_TYPE: unique symbol = Symbol('key-type');\n/**\n * @private\n */\nexport const DEBUG_STALE_CACHE_OWNER: unique symbol = Symbol('warpDriveStaleCache');\n\nfunction ProdSymbol<T extends string>(str: T, debugStr: string): T {\n return DEBUG ? (Symbol(debugStr) as unknown as T) : str;\n}\n\n// also present in production\n/**\n * @private\n */\nexport const CACHE_OWNER: '__$co' = ProdSymbol('__$co', 'CACHE_OWNER');\n\n/**\n * Identifies which \"bucket\" of the cache a key belongs to: resources\n * (`'record'`, see {@link ResourceKey}) or request documents\n * (`'document'`, see {@link RequestKey}).\n *\n * @summary Which cache bucket a key belongs to: `'record'` for resource keys or `'document'` for request keys.\n */\nexport type CacheKeyType = 'record' | 'document';\n\n/**\n * A referentially stable object with a unique string (lid) that can be used\n * as a reference to request data in the cache.\n *\n * Only requests that are assigned a RequestKey are retrievable/replayable from\n * the cache, though requests without RequestKeys may still update cache state.\n *\n * The [Key Terminology](/guides/the-manual/caching/key-terms#documents) guide explains\n * the documents it identifies.\n *\n * @summary Stable object with a unique `lid` that references a cached request document, letting that request's\n * result be retrieved or replayed.\n * @public\n */\nexport interface RequestKey {\n /**\n * A string representing a unique identity.\n */\n lid: string;\n /**\n * Discriminates a {@link RequestKey} from a {@link ResourceKey}.\n */\n type: '@document';\n /** @internal */\n [CACHE_OWNER]: number | undefined;\n}\n\n/**\n * @summary Deprecated alias for `RequestKey`, the stable cache reference to a request document.\n * @deprecated use {@link RequestKey}\n */\nexport type StableDocumentIdentifier = RequestKey;\n\n/**\n * Used when an ResourceKey is known to be the stable version\n */\ninterface ResourceKeyBase<T extends string = string> {\n /**\n * A string representing a unique identity.\n *\n * @public\n */\n lid: string;\n\n /**\n * the primary `ResourceType` or \"model name\" this ResourceKey belongs to.\n *\n * @public\n */\n type: T;\n\n /** @internal */\n [CACHE_OWNER]: number | undefined;\n\n /** @internal */\n [DEBUG_CLIENT_ORIGINATED]?: boolean;\n /** @internal */\n [DEBUG_STALE_CACHE_OWNER]?: number | undefined;\n}\n\n/**\n * Used when a ResourceKey was not created locally as part\n * of a call to store.createRecord\n *\n * Distinguishing between this ResourceKey and one for a client created\n * resource that was created with an ID is generally speaking not possible\n * at runtime, so anything with an ID typically narrows to this.\n *\n * @summary Resource key whose `id` is a known string, the form keys for server-loaded resources take.\n */\nexport interface PersistedResourceKey<T extends string = string> extends ResourceKeyBase<T> {\n /**\n * the PrimaryKey for the resource this ResourceKey represents.\n *\n * @public\n */\n id: string;\n}\n\n/**\n * @summary Deprecated alias for `PersistedResourceKey`, a resource key whose `id` is known.\n * @deprecated use {@link PersistedResourceKey}\n */\nexport type StableExistingRecordIdentifier<T extends string = string> = PersistedResourceKey<T>;\n\n/**\n * Used when a ResourceKey was created locally\n * (by a call to store.createRecord).\n *\n * It is possible in rare circumstances to have a ResourceKey\n * that is not for a new record but does not have an ID. This would\n * happen if a user intentionally created one for use with a secondary-index\n * prior to the record having been fully loaded.\n *\n * @summary Resource key for a record created locally with `store.createRecord`, whose `id` may still be `null`.\n */\nexport interface NewResourceKey<T extends string = string> extends ResourceKeyBase<T> {\n /**\n * the PrimaryKey for the resource this ResourceKey represents. `null`\n * if not yet assigned a PrimaryKey value.\n *\n * @public\n */\n id: string | null;\n}\n\n/**\n * A referentially stable object with a unique string (lid) that can be used\n * as a reference to data in the cache.\n *\n * Every resource has a unique ResourceKey, and ResourceKeys may refer\n * to data that has never been loaded (for instance, in an async relationship).\n *\n * The [Key Terminology](/guides/the-manual/caching/key-terms#resources) guide explains\n * the resources it identifies.\n *\n * @summary Stable object with a unique `lid` plus `type` and `id` that uniquely references one resource's data in\n * the cache, loaded or not.\n * @public\n */\nexport type ResourceKey<T extends string = string> = PersistedResourceKey<T> | NewResourceKey<T>;\n\n/**\n * @summary Deprecated alias for `ResourceKey`, the stable cache reference to a single resource.\n * @deprecated use {@link ResourceKey}\n */\nexport type StableRecordIdentifier<T extends string = string> = ResourceKey<T>;\n"],"mappings":";;;;;;;;;;;AAYA,MAAaE,0BAAyCC,OAAO,6BAA6B;;;;AAI1F,MAAaC,iBAAgCD,OAAO,UAAU;;;;AAI9D,MAAaE,0BAAyCF,OAAO,qBAAqB;AAElF,SAASG,WAA6BC,KAAQC,UAAqB;CACjE,OAAOP,eAAAD,gBAAA,CAAA,CAAAS,UAAAC,IAAAC,KAAA,IAASR,OAAOK,QAAQ,IAAqBD;AACtD;;;;AAMA,MAAaK,cAAuBN,WAAW,SAAS,aAAa"}
@@ -1,2 +1,2 @@
1
- import { i as Value, n as ObjectValue, r as PrimitiveValue, t as ArrayValue } from "../../raw-D5hnjiq7.js";
1
+ import { i as Value, n as ObjectValue, r as PrimitiveValue, t as ArrayValue } from "../../raw-CiC64nCY.js";
2
2
  export { ArrayValue, ObjectValue, PrimitiveValue, Value };
@@ -1,2 +1,2 @@
1
- import { i as SerializablePrimitive, n as QueryParamsSource, r as Serializable, t as QueryParamsSerializationOptions } from "../params-DrEx3bf8.js";
1
+ import { i as SerializablePrimitive, n as QueryParamsSource, r as Serializable, t as QueryParamsSerializationOptions } from "../params-dbHiSOMF.js";
2
2
  export { QueryParamsSerializationOptions, QueryParamsSource, Serializable, SerializablePrimitive };
@@ -1,2 +1,2 @@
1
- import { a as StringSatisfiesIncludes, c as TypedRecordInstance, i as OpaqueRecordInstance, l as Validate, n as Includes, o as TypeFromInstance, r as Mask, s as TypeFromInstanceOrString, t as ExtractSuggestedCacheTypes, u as createIncludeValidator } from "../record-D3QQcaIR.js";
1
+ import { a as StringSatisfiesIncludes, c as TypedRecordInstance, i as OpaqueRecordInstance, l as Validate, n as Includes, o as TypeFromInstance, r as Mask, s as TypeFromInstanceOrString, t as ExtractSuggestedCacheTypes, u as createIncludeValidator } from "../record-DDxPtzcY.js";
2
2
  export { ExtractSuggestedCacheTypes, Includes, Mask, OpaqueRecordInstance, StringSatisfiesIncludes, TypeFromInstance, TypeFromInstanceOrString, TypedRecordInstance, Validate, createIncludeValidator };
@@ -1,5 +1,10 @@
1
1
  //#region src/types/record.ts
2
2
  /**
3
+ * @module
4
+ * @summary Types for records that declare their resource type via the `[Type]` symbol, including `TypedRecordInstance`,
5
+ * `Includes`, `Mask` and the `createIncludeValidator` helper.
6
+ */
7
+ /**
3
8
  * Records may be anything, They don't even
4
9
  * have to be objects.
5
10
  *
@@ -8,17 +13,21 @@
8
13
  * and WarpDrive to provide better type safety and
9
14
  * intellisense.
10
15
  *
16
+ * @summary Shape of a record type that declares its resource type via the `[Type]` symbol, letting WarpDrive APIs
17
+ * infer types for better type safety.
11
18
  * @class TypedRecordInstance
12
19
  */
13
20
  /**
14
21
  * A type utility that extracts the Type if available,
15
22
  * otherwise it returns never.
16
23
  *
24
+ * @summary Type utility giving a record type's `[Type]` resource type string, or `never` if it declares none.
17
25
  */
18
26
  /**
19
27
  * A type utility that extracts the Type if available,
20
28
  * otherwise it returns string
21
29
  *
30
+ * @summary Type utility giving a record type's `[Type]` resource type string, or `string` if it declares none.
22
31
  */
23
32
  /**
24
33
  * A Utility that extracts either resource types or resource paths from a TypedRecordInstance.
@@ -41,6 +50,8 @@
41
50
  * A utility that provides the union of all ResourceName for all potential
42
51
  * includes for the given TypedRecordInstance.
43
52
  *
53
+ * @summary Type utility giving the union of resource types reachable from a typed record through its
54
+ * relationships, up to a max depth.
44
55
  */
45
56
  /**
46
57
  * A utility that provides the union type of all valid include paths for the given
@@ -48,10 +59,14 @@
48
59
  *
49
60
  * Cyclical paths are filtered out.
50
61
  *
62
+ * @summary Type utility giving the union of valid dot-separated `include` relationship paths for a typed record,
63
+ * excluding cycles.
51
64
  */
52
65
  /**
53
66
  * A type-erased placeholder for a record instance, used where the
54
67
  * specific record type is not known or not relevant.
68
+ *
69
+ * @summary Type-erased (`unknown`) stand-in for a record instance where its specific type is unknown or irrelevant.
55
70
  */
56
71
  /**
57
72
  * @internal
@@ -63,6 +78,8 @@
63
78
  * TypeScript cannot autocomplete against this type; prefer {@link createIncludeValidator}
64
79
  * for a better development experience unless you are writing a similar wrapper utility.
65
80
  *
81
+ * @summary Type utility that checks a comma-separated `include` string contains only paths from an allowed union,
82
+ * resolving to `never` otherwise.
66
83
  * @example
67
84
  * ```ts
68
85
  * import type { StringSatisfiesIncludes, Includes } from '@warp-drive-mirror/core/types/record';
@@ -78,6 +95,8 @@
78
95
  * ensuring at compile time that only valid paths for `T` (per {@link Includes})
79
96
  * are supplied.
80
97
  *
98
+ * @summary Returns a function that type-checks a comma-separated `include` string against the valid relationship paths
99
+ * of a record type and returns it unchanged.
81
100
  * @example
82
101
  * ```ts
83
102
  * import { createIncludeValidator } from '@warp-drive-mirror/core/types/record';
@@ -164,6 +183,9 @@ function createIncludeValidator() {
164
183
  *
165
184
  * But what if your app has data with massive interfaces such that the TypeScript performance of this
166
185
  * approach becomes a problem? In that case, see {@link Validate}
186
+ *
187
+ * @summary Type utility that builds a preview type from `T` by replacing selected fields with narrower subset types
188
+ * from `K`, resolving to `never` where a field is not compatible.
167
189
  */
168
190
  /**
169
191
  * A utility that takes two types, K and T, and ensures that K is a valid subset of T.
@@ -215,6 +237,9 @@ function createIncludeValidator() {
215
237
  * ```
216
238
  *
217
239
  * For help creating subsets of types, see {@link Mask}
240
+ *
241
+ * @summary Type utility that checks a hand-written preview type `K` is a valid subset of the full type `T`, resolving
242
+ * to `K` if so and `never` otherwise.
218
243
  */
219
244
  //#endregion
220
245
  export { createIncludeValidator };
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","names":["createIncludeValidator","validateIncludes","includes"],"sources":["../../src/types/record.ts"],"sourcesContent":["import type { Type } from './symbols.ts';\n\n/**\n * Records may be anything, They don't even\n * have to be objects.\n *\n * Whatever they are, if they have a Type\n * property, that property will be used by WarpDrive\n * and WarpDrive to provide better type safety and\n * intellisense.\n *\n * @class TypedRecordInstance\n */\nexport interface TypedRecordInstance {\n /**\n * The type of the resource.\n *\n * This is an optional feature that can be used by\n * record implementations to provide a typescript\n * hint for the type of the resource.\n *\n * When used, WarpDrive APIs can\n * take advantage of this to provide better type\n * safety and intellisense.\n *\n * @property [Type]\n * @type {Type}\n * @type {String}\n */\n [Type]: string;\n}\n\n/**\n * A type utility that extracts the Type if available,\n * otherwise it returns never.\n *\n */\nexport type TypeFromInstance<T> = T extends TypedRecordInstance ? T[typeof Type] : never;\n\n/**\n * A type utility that extracts the Type if available,\n * otherwise it returns string\n *\n */\nexport type TypeFromInstanceOrString<T> = T extends TypedRecordInstance ? T[typeof Type] : string;\n\ntype IsUniqueSymbol<T> = T extends `___(unique) Symbol(${string})` ? true : false;\ntype Unpacked<T> = T extends (infer U)[] ? U : T;\ntype NONE = { __NONE: never };\n\ntype __InternalExtract<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n V extends TypedRecordInstance,\n IncludePrefix extends boolean,\n Ignore,\n Pre extends string,\n DEPTH extends _DEPTHCOUNT,\n> =\n // if we extend T, we return the leaf value\n V extends T\n ? IncludePrefix extends false\n ? V[typeof Type]\n : Pre\n : // else if we are in Ignore we add the lead and exit\n V extends Ignore\n ? IncludePrefix extends false\n ? V[typeof Type]\n : Pre\n : // else if we are at max depth, we return never\n IS_MAX_DEPTH<DEPTH, MAX_DEPTH> extends true\n ? Pre\n : // else add T to Ignore and recurse\n ExtractUnion<MAX_DEPTH, V, IncludePrefix, Ignore | T, Pre, INC_DEPTH<DEPTH>>;\n\ntype __ExtractIfRecord<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n V,\n IncludePrefix extends boolean,\n Ignore,\n Pre extends string,\n DEPTH extends _DEPTHCOUNT,\n> = V extends TypedRecordInstance ? __InternalExtract<MAX_DEPTH, T, V, IncludePrefix, Ignore, Pre, DEPTH> : never;\n\ntype _ExtractUnion<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n IncludePrefix extends boolean,\n Ignore,\n Pre,\n DEPTH extends _DEPTHCOUNT,\n> = {\n // for each string key in the record,\n [K in keyof T]: IsUniqueSymbol<K> extends true\n ? never\n : K extends string\n ? // we recursively extract any values that resolve to a TypedRecordInstance\n __ExtractIfRecord<\n MAX_DEPTH,\n T,\n Unpacked<Awaited<T[K]>>,\n IncludePrefix,\n Ignore,\n Pre extends string ? `${Pre}.${K}` : K,\n DEPTH\n >\n : never;\n // then we return any value that is not 'never'\n}[keyof T];\n\n/**\n * A Utility that extracts either resource types or resource paths from a TypedRecordInstance.\n *\n * Its limitations are mostly around its intentional non-recursiveness. It presumes that APIs which\n * implement includes will not allow cyclical include paths, and will collapse includes by type.\n *\n * This follows closer to the JSON:API fields spec than to the includes spec in nature, but in\n * practice it is so impracticle for an API to allow z-algo include paths that this is probably\n * reasonable.\n *\n * We may need to revisit this in the future, opting to either make this restriction optional or\n * to allow for other strategies.\n *\n * There's a 90% chance this particular implementation belongs being in the JSON:API package instead\n * of core-types, but it's here for now.\n *\n */\ntype ExtractUnion<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n IncludePrefix extends boolean = false,\n Ignore = NONE,\n Pre = NONE,\n DEPTH extends _DEPTHCOUNT = 1,\n> = Exclude<\n IncludePrefix extends true\n ? // if we want to include prefix, we union with the prefix. Outer Exclude will filter any \"NONE\" types\n _ExtractUnion<MAX_DEPTH, T, IncludePrefix, Ignore, Pre, DEPTH> | Pre\n : // Else we just union the types.\n _ExtractUnion<MAX_DEPTH, T, IncludePrefix, Ignore, Pre, DEPTH> | T[typeof Type],\n NONE\n>;\n\ntype _DEPTHCOUNT = 1 | 2 | 3 | 4 | 5;\ntype INC_DEPTH<START extends _DEPTHCOUNT> = START extends 1 ? 2 : START extends 2 ? 3 : START extends 3 ? 4 : 5;\ntype IS_MAX_DEPTH<\n DEPTH extends _DEPTHCOUNT,\n MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH,\n> = DEPTH extends MAX_DEPTH ? true : false;\ntype DEFAULT_MAX_DEPTH = 3;\n/**\n * A utility that provides the union of all ResourceName for all potential\n * includes for the given TypedRecordInstance.\n *\n */\nexport type ExtractSuggestedCacheTypes<\n T extends TypedRecordInstance,\n MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH,\n> = ExtractUnion<MAX_DEPTH, T>; // ToPaths<ExpandIgnore<T, true>, false>;\n\n/**\n * A utility that provides the union type of all valid include paths for the given\n * TypedRecordInstance.\n *\n * Cyclical paths are filtered out.\n *\n */\nexport type Includes<T extends TypedRecordInstance, MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH> = ExtractUnion<\n MAX_DEPTH,\n T,\n true\n>;\n\n/**\n * A type-erased placeholder for a record instance, used where the\n * specific record type is not known or not relevant.\n */\nexport type OpaqueRecordInstance = unknown;\n\n/**\n * @internal\n */\nexport type _StringSatisfiesIncludes<T extends string, SET extends string, FT extends string> = T extends SET\n ? FT\n : T extends `${infer U},${infer V}`\n ? U extends SET\n ? _StringSatisfiesIncludes<V, Exclude<SET, U>, FT>\n : never\n : never;\n\n/**\n * Validates that the comma-separated-string `T` (e.g. `'company,company.ceo,friends'`)\n * only contains paths present in the union `SET` (typically {@link Includes}).\n *\n * TypeScript cannot autocomplete against this type; prefer {@link createIncludeValidator}\n * for a better development experience unless you are writing a similar wrapper utility.\n *\n * @example\n * ```ts\n * import type { StringSatisfiesIncludes, Includes } from '@warp-drive-mirror/core/types/record';\n *\n * const includes: StringSatisfiesIncludes<\n * 'company,company.ceo,friends',\n * Includes<User>\n * > = 'company,company.ceo,friends';\n * ```\n */\nexport type StringSatisfiesIncludes<T extends string, SET extends string> = _StringSatisfiesIncludes<T, SET, T>;\n\n/**\n * Creates a runtime validator function for comma-separated `include` strings,\n * ensuring at compile time that only valid paths for `T` (per {@link Includes})\n * are supplied.\n *\n * @example\n * ```ts\n * import { createIncludeValidator } from '@warp-drive-mirror/core/types/record';\n *\n * const userIncludesValidator = createIncludeValidator<User>;\n *\n * userIncludesValidator('company,company.ceo,friends');\n * ```\n */\nexport function createIncludeValidator<T extends TypedRecordInstance>() {\n return function validateIncludes<U extends string>(includes: StringSatisfiesIncludes<U, Includes<T>>): U {\n return includes;\n };\n}\n\n/**\n * A utility that takes two types, K and T, and produces a new type that is a \"mask\" of T based on K.\n *\n * That's a mouthful, so let's break it down:\n *\n * Let's say you have a User type and an Address type.\n *\n * ```ts\n * interface Address {\n * street: string;\n * city: string;\n * state: string;\n * zip: string;\n * }\n *\n * interface User {\n * name: string;\n * title: string;\n * address: Address;\n * }\n * ```\n *\n * Now, imagine you want to load a preview of the user with some information about their address,\n * but you don't want to load the entire user or address. You probably want to still ensure\n * the type of the data you do load matches the underlying Address and User types, but doesn't\n * include everything.\n *\n * If you did this manually, you might do something like this:\n *\n * ```ts\n * interface UserPreview {\n * name: string;\n * address: AddressPreview;\n * }\n *\n * interface AddressPreview {\n * city: string;\n * }\n * ```\n *\n * From a TypeScript performance perspective, this is the best way to approach these preview\n * types, but this is also tedious and error-prone, especially if the User or Address types change.\n *\n * For Address, we could create a validated type using `Pick`:\n *\n * ```ts\n * type AddressPreview = Pick<Address, 'city'>;\n * ```\n *\n * This ensures that if the Address type changes, our AddressPreview will still be valid.\n * However, for UserPreview, we can't just use `Pick` because the `address` property is of type `Address`,\n * not `AddressPreview`. This is where the `Mask` type comes in.\n *\n * With `Mask`, we define the `UserPreview` in two parts\n * - first, we define the subset of fields we want to include from `User`, using `Pick` or an interface.\n * - then, we use `Mask` to replace the related types of fields like Address with their more limited subset.\n *\n * Here's how we can do it:\n *\n * ```ts\n * // First, we define the base of UserPreview with Pick\n * type UserPreviewBase = Pick<User, 'name' | 'address'>;\n * // Then, we use Mask to replace Address with AddressPreview\n * type UserPreview = Mask<{ address: AddressPreview }, UserPreviewBase>;\n * ```\n *\n * Now, `UserPreview` will have the `name` field from `User` and the `address` field will be of type `AddressPreview`.\n * This way, if the `User` or `Address` types change, TypeScript will ensure that our `UserPreview` and `AddressPreview`\n * types remain valid and consistent with the underlying types.\n *\n * But what if your app has data with massive interfaces such that the TypeScript performance of this\n * approach becomes a problem? In that case, see {@link Validate}\n */\nexport type Mask<K extends object, T extends K> = {\n [P in keyof T]: P extends keyof K ? (T[P] extends K[P] ? K[P] : never) : T[P];\n};\n\n/**\n * A utility that takes two types, K and T, and ensures that K is a valid subset of T.\n *\n * That's a mouthful, so let's break it down:\n *\n * Let's say you have a User type and an Address type.\n *\n * ```ts\n * interface Address {\n * street: string;\n * city: string;\n * state: string;\n * zip: string;\n * }\n *\n * interface User {\n * name: string;\n * title: string;\n * address: Address;\n * }\n * ```\n *\n * Now, imagine you want to load a preview of the user with some information about their address,\n * but you don't want to load the entire user or address. You probably want to still ensure\n * the type of the data you do load matches the underlying Address and User types, but doesn't\n * include everything.\n *\n * You might do something like this:\n *\n * ```ts\n * interface UserPreview {\n * name: string;\n * address: AddressPreview;\n * }\n *\n * interface AddressPreview {\n * city: string;\n * }\n * ```\n *\n * From a TypeScript performance perspective, this is the best way to approach these preview\n * types, but this is also error-prone, especially if the User or Address types change.\n *\n * Validate can help ensure that your preview types remain valid.\n *\n * ```ts\n * type IsValidUserPreview = Validate<UserPreview, User>; // This will be valid\n * ```\n *\n * For help creating subsets of types, see {@link Mask}\n */\nexport type Validate<K extends object, T extends K> = T extends K ? K : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgOA,SAAgBA,yBAAwD;CACtE,OAAO,SAASC,iBAAmCC,UAAsD;EACvG,OAAOA;CACT;AACF"}
1
+ {"version":3,"file":"record.js","names":["createIncludeValidator","validateIncludes","includes"],"sources":["../../src/types/record.ts"],"sourcesContent":["/**\n * @module\n * @summary Types for records that declare their resource type via the `[Type]` symbol, including `TypedRecordInstance`,\n * `Includes`, `Mask` and the `createIncludeValidator` helper.\n */\n\nimport type { Type } from './symbols.ts';\n\n/**\n * Records may be anything, They don't even\n * have to be objects.\n *\n * Whatever they are, if they have a Type\n * property, that property will be used by WarpDrive\n * and WarpDrive to provide better type safety and\n * intellisense.\n *\n * @summary Shape of a record type that declares its resource type via the `[Type]` symbol, letting WarpDrive APIs\n * infer types for better type safety.\n * @class TypedRecordInstance\n */\nexport interface TypedRecordInstance {\n /**\n * The type of the resource.\n *\n * This is an optional feature that can be used by\n * record implementations to provide a typescript\n * hint for the type of the resource.\n *\n * When used, WarpDrive APIs can\n * take advantage of this to provide better type\n * safety and intellisense.\n *\n * @property [Type]\n * @type {Type}\n * @type {String}\n */\n [Type]: string;\n}\n\n/**\n * A type utility that extracts the Type if available,\n * otherwise it returns never.\n *\n * @summary Type utility giving a record type's `[Type]` resource type string, or `never` if it declares none.\n */\nexport type TypeFromInstance<T> = T extends TypedRecordInstance ? T[typeof Type] : never;\n\n/**\n * A type utility that extracts the Type if available,\n * otherwise it returns string\n *\n * @summary Type utility giving a record type's `[Type]` resource type string, or `string` if it declares none.\n */\nexport type TypeFromInstanceOrString<T> = T extends TypedRecordInstance ? T[typeof Type] : string;\n\ntype IsUniqueSymbol<T> = T extends `___(unique) Symbol(${string})` ? true : false;\ntype Unpacked<T> = T extends (infer U)[] ? U : T;\ntype NONE = { __NONE: never };\n\ntype __InternalExtract<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n V extends TypedRecordInstance,\n IncludePrefix extends boolean,\n Ignore,\n Pre extends string,\n DEPTH extends _DEPTHCOUNT,\n> =\n // if we extend T, we return the leaf value\n V extends T\n ? IncludePrefix extends false\n ? V[typeof Type]\n : Pre\n : // else if we are in Ignore we add the lead and exit\n V extends Ignore\n ? IncludePrefix extends false\n ? V[typeof Type]\n : Pre\n : // else if we are at max depth, we return never\n IS_MAX_DEPTH<DEPTH, MAX_DEPTH> extends true\n ? Pre\n : // else add T to Ignore and recurse\n ExtractUnion<MAX_DEPTH, V, IncludePrefix, Ignore | T, Pre, INC_DEPTH<DEPTH>>;\n\ntype __ExtractIfRecord<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n V,\n IncludePrefix extends boolean,\n Ignore,\n Pre extends string,\n DEPTH extends _DEPTHCOUNT,\n> = V extends TypedRecordInstance ? __InternalExtract<MAX_DEPTH, T, V, IncludePrefix, Ignore, Pre, DEPTH> : never;\n\ntype _ExtractUnion<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n IncludePrefix extends boolean,\n Ignore,\n Pre,\n DEPTH extends _DEPTHCOUNT,\n> = {\n // for each string key in the record,\n [K in keyof T]: IsUniqueSymbol<K> extends true\n ? never\n : K extends string\n ? // we recursively extract any values that resolve to a TypedRecordInstance\n __ExtractIfRecord<\n MAX_DEPTH,\n T,\n Unpacked<Awaited<T[K]>>,\n IncludePrefix,\n Ignore,\n Pre extends string ? `${Pre}.${K}` : K,\n DEPTH\n >\n : never;\n // then we return any value that is not 'never'\n}[keyof T];\n\n/**\n * A Utility that extracts either resource types or resource paths from a TypedRecordInstance.\n *\n * Its limitations are mostly around its intentional non-recursiveness. It presumes that APIs which\n * implement includes will not allow cyclical include paths, and will collapse includes by type.\n *\n * This follows closer to the JSON:API fields spec than to the includes spec in nature, but in\n * practice it is so impracticle for an API to allow z-algo include paths that this is probably\n * reasonable.\n *\n * We may need to revisit this in the future, opting to either make this restriction optional or\n * to allow for other strategies.\n *\n * There's a 90% chance this particular implementation belongs being in the JSON:API package instead\n * of core-types, but it's here for now.\n *\n */\ntype ExtractUnion<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n IncludePrefix extends boolean = false,\n Ignore = NONE,\n Pre = NONE,\n DEPTH extends _DEPTHCOUNT = 1,\n> = Exclude<\n IncludePrefix extends true\n ? // if we want to include prefix, we union with the prefix. Outer Exclude will filter any \"NONE\" types\n _ExtractUnion<MAX_DEPTH, T, IncludePrefix, Ignore, Pre, DEPTH> | Pre\n : // Else we just union the types.\n _ExtractUnion<MAX_DEPTH, T, IncludePrefix, Ignore, Pre, DEPTH> | T[typeof Type],\n NONE\n>;\n\ntype _DEPTHCOUNT = 1 | 2 | 3 | 4 | 5;\ntype INC_DEPTH<START extends _DEPTHCOUNT> = START extends 1 ? 2 : START extends 2 ? 3 : START extends 3 ? 4 : 5;\ntype IS_MAX_DEPTH<\n DEPTH extends _DEPTHCOUNT,\n MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH,\n> = DEPTH extends MAX_DEPTH ? true : false;\ntype DEFAULT_MAX_DEPTH = 3;\n/**\n * A utility that provides the union of all ResourceName for all potential\n * includes for the given TypedRecordInstance.\n *\n * @summary Type utility giving the union of resource types reachable from a typed record through its\n * relationships, up to a max depth.\n */\nexport type ExtractSuggestedCacheTypes<\n T extends TypedRecordInstance,\n MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH,\n> = ExtractUnion<MAX_DEPTH, T>; // ToPaths<ExpandIgnore<T, true>, false>;\n\n/**\n * A utility that provides the union type of all valid include paths for the given\n * TypedRecordInstance.\n *\n * Cyclical paths are filtered out.\n *\n * @summary Type utility giving the union of valid dot-separated `include` relationship paths for a typed record,\n * excluding cycles.\n */\nexport type Includes<T extends TypedRecordInstance, MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH> = ExtractUnion<\n MAX_DEPTH,\n T,\n true\n>;\n\n/**\n * A type-erased placeholder for a record instance, used where the\n * specific record type is not known or not relevant.\n *\n * @summary Type-erased (`unknown`) stand-in for a record instance where its specific type is unknown or irrelevant.\n */\nexport type OpaqueRecordInstance = unknown;\n\n/**\n * @internal\n */\nexport type _StringSatisfiesIncludes<T extends string, SET extends string, FT extends string> = T extends SET\n ? FT\n : T extends `${infer U},${infer V}`\n ? U extends SET\n ? _StringSatisfiesIncludes<V, Exclude<SET, U>, FT>\n : never\n : never;\n\n/**\n * Validates that the comma-separated-string `T` (e.g. `'company,company.ceo,friends'`)\n * only contains paths present in the union `SET` (typically {@link Includes}).\n *\n * TypeScript cannot autocomplete against this type; prefer {@link createIncludeValidator}\n * for a better development experience unless you are writing a similar wrapper utility.\n *\n * @summary Type utility that checks a comma-separated `include` string contains only paths from an allowed union,\n * resolving to `never` otherwise.\n * @example\n * ```ts\n * import type { StringSatisfiesIncludes, Includes } from '@warp-drive-mirror/core/types/record';\n *\n * const includes: StringSatisfiesIncludes<\n * 'company,company.ceo,friends',\n * Includes<User>\n * > = 'company,company.ceo,friends';\n * ```\n */\nexport type StringSatisfiesIncludes<T extends string, SET extends string> = _StringSatisfiesIncludes<T, SET, T>;\n\n/**\n * Creates a runtime validator function for comma-separated `include` strings,\n * ensuring at compile time that only valid paths for `T` (per {@link Includes})\n * are supplied.\n *\n * @summary Returns a function that type-checks a comma-separated `include` string against the valid relationship paths\n * of a record type and returns it unchanged.\n * @example\n * ```ts\n * import { createIncludeValidator } from '@warp-drive-mirror/core/types/record';\n *\n * const userIncludesValidator = createIncludeValidator<User>;\n *\n * userIncludesValidator('company,company.ceo,friends');\n * ```\n */\nexport function createIncludeValidator<T extends TypedRecordInstance>() {\n return function validateIncludes<U extends string>(includes: StringSatisfiesIncludes<U, Includes<T>>): U {\n return includes;\n };\n}\n\n/**\n * A utility that takes two types, K and T, and produces a new type that is a \"mask\" of T based on K.\n *\n * That's a mouthful, so let's break it down:\n *\n * Let's say you have a User type and an Address type.\n *\n * ```ts\n * interface Address {\n * street: string;\n * city: string;\n * state: string;\n * zip: string;\n * }\n *\n * interface User {\n * name: string;\n * title: string;\n * address: Address;\n * }\n * ```\n *\n * Now, imagine you want to load a preview of the user with some information about their address,\n * but you don't want to load the entire user or address. You probably want to still ensure\n * the type of the data you do load matches the underlying Address and User types, but doesn't\n * include everything.\n *\n * If you did this manually, you might do something like this:\n *\n * ```ts\n * interface UserPreview {\n * name: string;\n * address: AddressPreview;\n * }\n *\n * interface AddressPreview {\n * city: string;\n * }\n * ```\n *\n * From a TypeScript performance perspective, this is the best way to approach these preview\n * types, but this is also tedious and error-prone, especially if the User or Address types change.\n *\n * For Address, we could create a validated type using `Pick`:\n *\n * ```ts\n * type AddressPreview = Pick<Address, 'city'>;\n * ```\n *\n * This ensures that if the Address type changes, our AddressPreview will still be valid.\n * However, for UserPreview, we can't just use `Pick` because the `address` property is of type `Address`,\n * not `AddressPreview`. This is where the `Mask` type comes in.\n *\n * With `Mask`, we define the `UserPreview` in two parts\n * - first, we define the subset of fields we want to include from `User`, using `Pick` or an interface.\n * - then, we use `Mask` to replace the related types of fields like Address with their more limited subset.\n *\n * Here's how we can do it:\n *\n * ```ts\n * // First, we define the base of UserPreview with Pick\n * type UserPreviewBase = Pick<User, 'name' | 'address'>;\n * // Then, we use Mask to replace Address with AddressPreview\n * type UserPreview = Mask<{ address: AddressPreview }, UserPreviewBase>;\n * ```\n *\n * Now, `UserPreview` will have the `name` field from `User` and the `address` field will be of type `AddressPreview`.\n * This way, if the `User` or `Address` types change, TypeScript will ensure that our `UserPreview` and `AddressPreview`\n * types remain valid and consistent with the underlying types.\n *\n * But what if your app has data with massive interfaces such that the TypeScript performance of this\n * approach becomes a problem? In that case, see {@link Validate}\n *\n * @summary Type utility that builds a preview type from `T` by replacing selected fields with narrower subset types\n * from `K`, resolving to `never` where a field is not compatible.\n */\nexport type Mask<K extends object, T extends K> = {\n [P in keyof T]: P extends keyof K ? (T[P] extends K[P] ? K[P] : never) : T[P];\n};\n\n/**\n * A utility that takes two types, K and T, and ensures that K is a valid subset of T.\n *\n * That's a mouthful, so let's break it down:\n *\n * Let's say you have a User type and an Address type.\n *\n * ```ts\n * interface Address {\n * street: string;\n * city: string;\n * state: string;\n * zip: string;\n * }\n *\n * interface User {\n * name: string;\n * title: string;\n * address: Address;\n * }\n * ```\n *\n * Now, imagine you want to load a preview of the user with some information about their address,\n * but you don't want to load the entire user or address. You probably want to still ensure\n * the type of the data you do load matches the underlying Address and User types, but doesn't\n * include everything.\n *\n * You might do something like this:\n *\n * ```ts\n * interface UserPreview {\n * name: string;\n * address: AddressPreview;\n * }\n *\n * interface AddressPreview {\n * city: string;\n * }\n * ```\n *\n * From a TypeScript performance perspective, this is the best way to approach these preview\n * types, but this is also error-prone, especially if the User or Address types change.\n *\n * Validate can help ensure that your preview types remain valid.\n *\n * ```ts\n * type IsValidUserPreview = Validate<UserPreview, User>; // This will be valid\n * ```\n *\n * For help creating subsets of types, see {@link Mask}\n *\n * @summary Type utility that checks a hand-written preview type `K` is a valid subset of the full type `T`, resolving\n * to `K` if so and `never` otherwise.\n */\nexport type Validate<K extends object, T extends K> = T extends K ? K : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoPA,SAAgBA,yBAAwD;CACtE,OAAO,SAASC,iBAAmCC,UAAsD;EACvG,OAAOA;CACT;AACF"}
@@ -1,2 +1,2 @@
1
- import { $n as UpdateRequestOptions, An as CreateRequestOptions, Bn as ImmutableRequestInfo, Fn as HTTPMethod, Gn as RequestContext, Hn as PostQueryRequestOptions, In as IS_FUTURE, Jn as STRUCTURED, Kn as RequestInfo, Ln as ImmutableCreateRequestOptions, Mn as EnableHydration, Nn as FindRecordOptions, On as CacheOptions, Pn as FindRecordRequestOptions, Qn as StructuredErrorDocument, Rn as ImmutableDeleteRequestOptions, Un as QueryRequestOptions, Vn as ImmutableUpdateRequestOptions, Wn as RemotelyAccessibleIdentifier, Xn as StructuredDataDocument, Yn as SkipCache, Zn as StructuredDocument, er as FetchError, jn as DeleteRequestOptions, kn as ConstrainedRequestOptions, qn as ResponseInfo, zn as ImmutableHeaders } from "../internal-9XuWZdDv.js";
1
+ import { $n as STRUCTURED, Bn as HTTPMethod, Fn as CreateRequestOptions, Gn as ImmutableRequestInfo, Hn as ImmutableCreateRequestOptions, In as DeleteRequestOptions, Jn as QueryRequestOptions, Kn as ImmutableUpdateRequestOptions, Ln as EnableHydration, Nn as CacheOptions, Pn as ConstrainedRequestOptions, Qn as ResponseInfo, Rn as FindRecordOptions, Un as ImmutableDeleteRequestOptions, Vn as IS_FUTURE, Wn as ImmutableHeaders, Xn as RequestContext, Yn as RemotelyAccessibleIdentifier, Zn as RequestInfo, ar as FetchError, er as SkipCache, ir as UpdateRequestOptions, nr as StructuredDocument, qn as PostQueryRequestOptions, rr as StructuredErrorDocument, tr as StructuredDataDocument, zn as FindRecordRequestOptions } from "../internal-CgOlgOt3.js";
2
2
  export { CacheOptions, ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, EnableHydration, type FetchError, FindRecordOptions, FindRecordRequestOptions, HTTPMethod, IS_FUTURE, ImmutableCreateRequestOptions, ImmutableDeleteRequestOptions, ImmutableHeaders, ImmutableRequestInfo, ImmutableUpdateRequestOptions, PostQueryRequestOptions, QueryRequestOptions, RemotelyAccessibleIdentifier, RequestContext, RequestInfo, ResponseInfo, STRUCTURED, SkipCache, StructuredDataDocument, StructuredDocument, StructuredErrorDocument, UpdateRequestOptions };