@backendrelay/core 1.1.0 → 2.0.0

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 (598) hide show
  1. package/dist/standalone/index.js +1 -1
  2. package/dist/standalone/index.umd.cjs +1 -1
  3. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.d.ts +20 -0
  4. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
  5. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.js +5 -0
  6. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.js.map +1 -0
  7. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.d.ts +2 -0
  8. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
  9. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.js +88 -0
  10. package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.js.map +1 -0
  11. package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.d.ts +2 -0
  12. package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.d.ts.map +1 -0
  13. package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.js +131 -0
  14. package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.js.map +1 -0
  15. package/node_modules/@backendrelay/admin/dist/commonjs/config.test.d.ts +2 -0
  16. package/node_modules/@backendrelay/admin/dist/commonjs/config.test.d.ts.map +1 -0
  17. package/node_modules/@backendrelay/admin/dist/commonjs/config.test.js +65 -0
  18. package/node_modules/@backendrelay/admin/dist/commonjs/config.test.js.map +1 -0
  19. package/node_modules/@backendrelay/admin/dist/commonjs/index.d.ts +725 -0
  20. package/node_modules/@backendrelay/admin/dist/commonjs/index.d.ts.map +1 -0
  21. package/node_modules/@backendrelay/admin/dist/commonjs/index.js +1159 -0
  22. package/node_modules/@backendrelay/admin/dist/commonjs/index.js.map +1 -0
  23. package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.d.ts +2 -0
  24. package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.d.ts.map +1 -0
  25. package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.js +91 -0
  26. package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.js.map +1 -0
  27. package/node_modules/@backendrelay/admin/dist/commonjs/package.json +3 -0
  28. package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.d.ts +17 -0
  29. package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.d.ts.map +1 -0
  30. package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.js +26 -0
  31. package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.js.map +1 -0
  32. package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.d.ts +2 -0
  33. package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.d.ts.map +1 -0
  34. package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.js +50 -0
  35. package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.js.map +1 -0
  36. package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.d.ts +2 -0
  37. package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.d.ts.map +1 -0
  38. package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.js +33 -0
  39. package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.js.map +1 -0
  40. package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.d.ts +39 -0
  41. package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.d.ts.map +1 -0
  42. package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.js +306 -0
  43. package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.js.map +1 -0
  44. package/node_modules/@backendrelay/admin/dist/commonjs/version.d.ts +3 -0
  45. package/node_modules/@backendrelay/admin/dist/commonjs/version.d.ts.map +1 -0
  46. package/node_modules/@backendrelay/admin/dist/commonjs/version.js +5 -0
  47. package/node_modules/@backendrelay/admin/dist/commonjs/version.js.map +1 -0
  48. package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.d.ts +20 -0
  49. package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.d.ts.map +1 -0
  50. package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.js +4 -0
  51. package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.js.map +1 -0
  52. package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.d.ts +2 -0
  53. package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.d.ts.map +1 -0
  54. package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.js +86 -0
  55. package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.js.map +1 -0
  56. package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.d.ts +2 -0
  57. package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.d.ts.map +1 -0
  58. package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.js +129 -0
  59. package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.js.map +1 -0
  60. package/node_modules/@backendrelay/admin/dist/esm/config.test.d.ts +2 -0
  61. package/node_modules/@backendrelay/admin/dist/esm/config.test.d.ts.map +1 -0
  62. package/node_modules/@backendrelay/admin/dist/esm/config.test.js +63 -0
  63. package/node_modules/@backendrelay/admin/dist/esm/config.test.js.map +1 -0
  64. package/node_modules/@backendrelay/admin/dist/esm/index.d.ts +725 -0
  65. package/node_modules/@backendrelay/admin/dist/esm/index.d.ts.map +1 -0
  66. package/node_modules/@backendrelay/admin/dist/esm/index.js +1146 -0
  67. package/node_modules/@backendrelay/admin/dist/esm/index.js.map +1 -0
  68. package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.d.ts +2 -0
  69. package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.d.ts.map +1 -0
  70. package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.js +89 -0
  71. package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.js.map +1 -0
  72. package/node_modules/@backendrelay/admin/dist/esm/package.json +3 -0
  73. package/node_modules/@backendrelay/admin/dist/esm/polyfill.d.ts +17 -0
  74. package/node_modules/@backendrelay/admin/dist/esm/polyfill.d.ts.map +1 -0
  75. package/node_modules/@backendrelay/admin/dist/esm/polyfill.js +22 -0
  76. package/node_modules/@backendrelay/admin/dist/esm/polyfill.js.map +1 -0
  77. package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.d.ts +2 -0
  78. package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.d.ts.map +1 -0
  79. package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.js +48 -0
  80. package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.js.map +1 -0
  81. package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.d.ts +2 -0
  82. package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.d.ts.map +1 -0
  83. package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.js +31 -0
  84. package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.js.map +1 -0
  85. package/node_modules/@backendrelay/admin/dist/esm/subscribe.d.ts +39 -0
  86. package/node_modules/@backendrelay/admin/dist/esm/subscribe.d.ts.map +1 -0
  87. package/node_modules/@backendrelay/admin/dist/esm/subscribe.js +300 -0
  88. package/node_modules/@backendrelay/admin/dist/esm/subscribe.js.map +1 -0
  89. package/node_modules/@backendrelay/admin/dist/esm/version.d.ts +3 -0
  90. package/node_modules/@backendrelay/admin/dist/esm/version.d.ts.map +1 -0
  91. package/{src/version.ts → node_modules/@backendrelay/admin/dist/esm/version.js} +1 -1
  92. package/node_modules/@backendrelay/admin/dist/esm/version.js.map +1 -0
  93. package/node_modules/@backendrelay/admin/package.json +52 -0
  94. package/node_modules/@backendrelay/functions/README.md +131 -0
  95. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.d.ts +3 -0
  96. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
  97. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.js +3 -0
  98. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.js.map +1 -0
  99. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.d.ts +2 -0
  100. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
  101. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.js +51 -0
  102. package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.js.map +1 -0
  103. package/node_modules/@backendrelay/functions/dist/commonjs/index.d.ts +230 -0
  104. package/node_modules/@backendrelay/functions/dist/commonjs/index.d.ts.map +1 -0
  105. package/node_modules/@backendrelay/functions/dist/commonjs/index.js +415 -0
  106. package/node_modules/@backendrelay/functions/dist/commonjs/index.js.map +1 -0
  107. package/node_modules/@backendrelay/functions/dist/commonjs/package.json +3 -0
  108. package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.d.ts +3 -0
  109. package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.d.ts.map +1 -0
  110. package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.js +2 -0
  111. package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.js.map +1 -0
  112. package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.d.ts +2 -0
  113. package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.d.ts.map +1 -0
  114. package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.js +49 -0
  115. package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.js.map +1 -0
  116. package/node_modules/@backendrelay/functions/dist/esm/index.d.ts +230 -0
  117. package/node_modules/@backendrelay/functions/dist/esm/index.d.ts.map +1 -0
  118. package/node_modules/@backendrelay/functions/dist/esm/index.js +403 -0
  119. package/node_modules/@backendrelay/functions/dist/esm/index.js.map +1 -0
  120. package/node_modules/@backendrelay/functions/dist/esm/package.json +3 -0
  121. package/node_modules/@backendrelay/functions/package.json +49 -0
  122. package/node_modules/@backendrelay/hatchet/dist/commonjs/index.d.ts +43 -0
  123. package/node_modules/@backendrelay/hatchet/dist/commonjs/index.d.ts.map +1 -0
  124. package/node_modules/@backendrelay/hatchet/dist/commonjs/index.js +63 -0
  125. package/node_modules/@backendrelay/hatchet/dist/commonjs/index.js.map +1 -0
  126. package/node_modules/@backendrelay/hatchet/dist/commonjs/package.json +3 -0
  127. package/node_modules/@backendrelay/hatchet/dist/esm/index.d.ts +43 -0
  128. package/node_modules/@backendrelay/hatchet/dist/esm/index.d.ts.map +1 -0
  129. package/node_modules/@backendrelay/hatchet/dist/esm/index.js +59 -0
  130. package/node_modules/@backendrelay/hatchet/dist/esm/index.js.map +1 -0
  131. package/node_modules/@backendrelay/hatchet/dist/esm/package.json +3 -0
  132. package/node_modules/@backendrelay/hatchet/package.json +46 -0
  133. package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.d.ts +18 -0
  134. package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.d.ts.map +1 -0
  135. package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.js +77 -0
  136. package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.js.map +1 -0
  137. package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.d.ts +99 -0
  138. package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.d.ts.map +1 -0
  139. package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.js +177 -0
  140. package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.js.map +1 -0
  141. package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.d.ts +7 -0
  142. package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.d.ts.map +1 -0
  143. package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.js +15 -0
  144. package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.js.map +1 -0
  145. package/node_modules/@backendrelay/platform/dist/commonjs/api/http.d.ts +3 -0
  146. package/node_modules/@backendrelay/platform/dist/commonjs/api/http.d.ts.map +1 -0
  147. package/node_modules/@backendrelay/platform/dist/commonjs/api/http.js +46 -0
  148. package/node_modules/@backendrelay/platform/dist/commonjs/api/http.js.map +1 -0
  149. package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.d.ts +13 -0
  150. package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.d.ts.map +1 -0
  151. package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.js +25 -0
  152. package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.js.map +1 -0
  153. package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.d.ts +285 -0
  154. package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.d.ts.map +1 -0
  155. package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.js +426 -0
  156. package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.js.map +1 -0
  157. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.d.ts +24 -0
  158. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.d.ts.map +1 -0
  159. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.js +108 -0
  160. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.js.map +1 -0
  161. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.d.ts +188 -0
  162. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.d.ts.map +1 -0
  163. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.js +412 -0
  164. package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.js.map +1 -0
  165. package/node_modules/@backendrelay/platform/dist/commonjs/api.d.ts +9 -0
  166. package/node_modules/@backendrelay/platform/dist/commonjs/api.d.ts.map +1 -0
  167. package/node_modules/@backendrelay/platform/dist/commonjs/api.js +12 -0
  168. package/node_modules/@backendrelay/platform/dist/commonjs/api.js.map +1 -0
  169. package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.d.ts +89 -0
  170. package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.d.ts.map +1 -0
  171. package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.js +357 -0
  172. package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.js.map +1 -0
  173. package/node_modules/@backendrelay/platform/dist/commonjs/backups.d.ts +146 -0
  174. package/node_modules/@backendrelay/platform/dist/commonjs/backups.d.ts.map +1 -0
  175. package/node_modules/@backendrelay/platform/dist/commonjs/backups.js +251 -0
  176. package/node_modules/@backendrelay/platform/dist/commonjs/backups.js.map +1 -0
  177. package/node_modules/@backendrelay/platform/dist/commonjs/clerk.d.ts +2 -0
  178. package/node_modules/@backendrelay/platform/dist/commonjs/clerk.d.ts.map +1 -0
  179. package/node_modules/@backendrelay/platform/dist/commonjs/clerk.js +29 -0
  180. package/node_modules/@backendrelay/platform/dist/commonjs/clerk.js.map +1 -0
  181. package/node_modules/@backendrelay/platform/dist/commonjs/consts.d.ts +11 -0
  182. package/node_modules/@backendrelay/platform/dist/commonjs/consts.d.ts.map +1 -0
  183. package/node_modules/@backendrelay/platform/dist/commonjs/consts.js +17 -0
  184. package/node_modules/@backendrelay/platform/dist/commonjs/consts.js.map +1 -0
  185. package/node_modules/@backendrelay/platform/dist/commonjs/crypto.d.ts +4 -0
  186. package/node_modules/@backendrelay/platform/dist/commonjs/crypto.d.ts.map +1 -0
  187. package/node_modules/@backendrelay/platform/dist/commonjs/crypto.js +26 -0
  188. package/node_modules/@backendrelay/platform/dist/commonjs/crypto.js.map +1 -0
  189. package/node_modules/@backendrelay/platform/dist/commonjs/index.d.ts +19 -0
  190. package/node_modules/@backendrelay/platform/dist/commonjs/index.d.ts.map +1 -0
  191. package/node_modules/@backendrelay/platform/dist/commonjs/index.js +76 -0
  192. package/node_modules/@backendrelay/platform/dist/commonjs/index.js.map +1 -0
  193. package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.d.ts +4 -0
  194. package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.d.ts.map +1 -0
  195. package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.js +52 -0
  196. package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.js.map +1 -0
  197. package/node_modules/@backendrelay/platform/dist/commonjs/migrations.d.ts +99 -0
  198. package/node_modules/@backendrelay/platform/dist/commonjs/migrations.d.ts.map +1 -0
  199. package/node_modules/@backendrelay/platform/dist/commonjs/migrations.js +597 -0
  200. package/node_modules/@backendrelay/platform/dist/commonjs/migrations.js.map +1 -0
  201. package/node_modules/@backendrelay/platform/dist/commonjs/oauth.d.ts +98 -0
  202. package/node_modules/@backendrelay/platform/dist/commonjs/oauth.d.ts.map +1 -0
  203. package/node_modules/@backendrelay/platform/dist/commonjs/oauth.js +275 -0
  204. package/node_modules/@backendrelay/platform/dist/commonjs/oauth.js.map +1 -0
  205. package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.d.ts +12 -0
  206. package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.d.ts.map +1 -0
  207. package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.js +26 -0
  208. package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.js.map +1 -0
  209. package/node_modules/@backendrelay/platform/dist/commonjs/package.json +3 -0
  210. package/node_modules/@backendrelay/platform/dist/commonjs/perms.d.ts +3 -0
  211. package/node_modules/@backendrelay/platform/dist/commonjs/perms.d.ts.map +1 -0
  212. package/node_modules/@backendrelay/platform/dist/commonjs/perms.js +66 -0
  213. package/node_modules/@backendrelay/platform/dist/commonjs/perms.js.map +1 -0
  214. package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.d.ts +13 -0
  215. package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.d.ts.map +1 -0
  216. package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.js +31 -0
  217. package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.js.map +1 -0
  218. package/node_modules/@backendrelay/platform/dist/commonjs/relationships.d.ts +7 -0
  219. package/node_modules/@backendrelay/platform/dist/commonjs/relationships.d.ts.map +1 -0
  220. package/node_modules/@backendrelay/platform/dist/commonjs/relationships.js +46 -0
  221. package/node_modules/@backendrelay/platform/dist/commonjs/relationships.js.map +1 -0
  222. package/node_modules/@backendrelay/platform/dist/commonjs/schema.d.ts +161 -0
  223. package/node_modules/@backendrelay/platform/dist/commonjs/schema.d.ts.map +1 -0
  224. package/node_modules/@backendrelay/platform/dist/commonjs/schema.js +174 -0
  225. package/node_modules/@backendrelay/platform/dist/commonjs/schema.js.map +1 -0
  226. package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.d.ts +25 -0
  227. package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.d.ts.map +1 -0
  228. package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.js +68 -0
  229. package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.js.map +1 -0
  230. package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.d.ts +17 -0
  231. package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.d.ts.map +1 -0
  232. package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.js +314 -0
  233. package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.js.map +1 -0
  234. package/node_modules/@backendrelay/platform/dist/commonjs/util.d.ts +13 -0
  235. package/node_modules/@backendrelay/platform/dist/commonjs/util.d.ts.map +1 -0
  236. package/node_modules/@backendrelay/platform/dist/commonjs/util.js +55 -0
  237. package/node_modules/@backendrelay/platform/dist/commonjs/util.js.map +1 -0
  238. package/node_modules/@backendrelay/platform/dist/commonjs/version.d.ts +3 -0
  239. package/node_modules/@backendrelay/platform/dist/commonjs/version.d.ts.map +1 -0
  240. package/node_modules/@backendrelay/platform/dist/commonjs/version.js +5 -0
  241. package/node_modules/@backendrelay/platform/dist/commonjs/version.js.map +1 -0
  242. package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.d.ts +18 -0
  243. package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.d.ts.map +1 -0
  244. package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.js +73 -0
  245. package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.js.map +1 -0
  246. package/node_modules/@backendrelay/platform/dist/esm/api/apps.d.ts +99 -0
  247. package/node_modules/@backendrelay/platform/dist/esm/api/apps.d.ts.map +1 -0
  248. package/node_modules/@backendrelay/platform/dist/esm/api/apps.js +165 -0
  249. package/node_modules/@backendrelay/platform/dist/esm/api/apps.js.map +1 -0
  250. package/node_modules/@backendrelay/platform/dist/esm/api/auth.d.ts +7 -0
  251. package/node_modules/@backendrelay/platform/dist/esm/api/auth.d.ts.map +1 -0
  252. package/node_modules/@backendrelay/platform/dist/esm/api/auth.js +12 -0
  253. package/node_modules/@backendrelay/platform/dist/esm/api/auth.js.map +1 -0
  254. package/node_modules/@backendrelay/platform/dist/esm/api/http.d.ts +3 -0
  255. package/node_modules/@backendrelay/platform/dist/esm/api/http.d.ts.map +1 -0
  256. package/node_modules/@backendrelay/platform/dist/esm/api/http.js +39 -0
  257. package/node_modules/@backendrelay/platform/dist/esm/api/http.js.map +1 -0
  258. package/node_modules/@backendrelay/platform/dist/esm/api/perms.d.ts +13 -0
  259. package/node_modules/@backendrelay/platform/dist/esm/api/perms.d.ts.map +1 -0
  260. package/node_modules/@backendrelay/platform/dist/esm/api/perms.js +21 -0
  261. package/node_modules/@backendrelay/platform/dist/esm/api/perms.js.map +1 -0
  262. package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.d.ts +285 -0
  263. package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.d.ts.map +1 -0
  264. package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.js +421 -0
  265. package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.js.map +1 -0
  266. package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.d.ts +24 -0
  267. package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.d.ts.map +1 -0
  268. package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.js +99 -0
  269. package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.js.map +1 -0
  270. package/node_modules/@backendrelay/platform/dist/esm/api/schema.d.ts +188 -0
  271. package/node_modules/@backendrelay/platform/dist/esm/api/schema.d.ts.map +1 -0
  272. package/node_modules/@backendrelay/platform/dist/esm/api/schema.js +393 -0
  273. package/node_modules/@backendrelay/platform/dist/esm/api/schema.js.map +1 -0
  274. package/node_modules/@backendrelay/platform/dist/esm/api.d.ts +9 -0
  275. package/node_modules/@backendrelay/platform/dist/esm/api.d.ts.map +1 -0
  276. package/node_modules/@backendrelay/platform/dist/esm/api.js +4 -0
  277. package/node_modules/@backendrelay/platform/dist/esm/api.js.map +1 -0
  278. package/node_modules/@backendrelay/platform/dist/esm/backupDownload.d.ts +89 -0
  279. package/node_modules/@backendrelay/platform/dist/esm/backupDownload.d.ts.map +1 -0
  280. package/node_modules/@backendrelay/platform/dist/esm/backupDownload.js +354 -0
  281. package/node_modules/@backendrelay/platform/dist/esm/backupDownload.js.map +1 -0
  282. package/node_modules/@backendrelay/platform/dist/esm/backups.d.ts +146 -0
  283. package/node_modules/@backendrelay/platform/dist/esm/backups.d.ts.map +1 -0
  284. package/node_modules/@backendrelay/platform/dist/esm/backups.js +240 -0
  285. package/node_modules/@backendrelay/platform/dist/esm/backups.js.map +1 -0
  286. package/node_modules/@backendrelay/platform/dist/esm/clerk.d.ts +2 -0
  287. package/node_modules/@backendrelay/platform/dist/esm/clerk.d.ts.map +1 -0
  288. package/node_modules/@backendrelay/platform/dist/esm/clerk.js +26 -0
  289. package/node_modules/@backendrelay/platform/dist/esm/clerk.js.map +1 -0
  290. package/node_modules/@backendrelay/platform/dist/esm/consts.d.ts +11 -0
  291. package/node_modules/@backendrelay/platform/dist/esm/consts.d.ts.map +1 -0
  292. package/node_modules/@backendrelay/platform/dist/esm/consts.js +13 -0
  293. package/node_modules/@backendrelay/platform/dist/esm/consts.js.map +1 -0
  294. package/node_modules/@backendrelay/platform/dist/esm/crypto.d.ts +4 -0
  295. package/node_modules/@backendrelay/platform/dist/esm/crypto.d.ts.map +1 -0
  296. package/node_modules/@backendrelay/platform/dist/esm/crypto.js +21 -0
  297. package/node_modules/@backendrelay/platform/dist/esm/crypto.js.map +1 -0
  298. package/node_modules/@backendrelay/platform/dist/esm/index.d.ts +19 -0
  299. package/node_modules/@backendrelay/platform/dist/esm/index.d.ts.map +1 -0
  300. package/node_modules/@backendrelay/platform/dist/esm/index.js +18 -0
  301. package/node_modules/@backendrelay/platform/dist/esm/index.js.map +1 -0
  302. package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.d.ts +4 -0
  303. package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.d.ts.map +1 -0
  304. package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.js +47 -0
  305. package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.js.map +1 -0
  306. package/node_modules/@backendrelay/platform/dist/esm/migrations.d.ts +99 -0
  307. package/node_modules/@backendrelay/platform/dist/esm/migrations.d.ts.map +1 -0
  308. package/node_modules/@backendrelay/platform/dist/esm/migrations.js +588 -0
  309. package/node_modules/@backendrelay/platform/dist/esm/migrations.js.map +1 -0
  310. package/node_modules/@backendrelay/platform/dist/esm/oauth.d.ts +98 -0
  311. package/node_modules/@backendrelay/platform/dist/esm/oauth.d.ts.map +1 -0
  312. package/node_modules/@backendrelay/platform/dist/esm/oauth.js +266 -0
  313. package/node_modules/@backendrelay/platform/dist/esm/oauth.js.map +1 -0
  314. package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.d.ts +12 -0
  315. package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.d.ts.map +1 -0
  316. package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.js +22 -0
  317. package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.js.map +1 -0
  318. package/node_modules/@backendrelay/platform/dist/esm/package.json +3 -0
  319. package/node_modules/@backendrelay/platform/dist/esm/perms.d.ts +3 -0
  320. package/node_modules/@backendrelay/platform/dist/esm/perms.d.ts.map +1 -0
  321. package/node_modules/@backendrelay/platform/dist/esm/perms.js +62 -0
  322. package/node_modules/@backendrelay/platform/dist/esm/perms.js.map +1 -0
  323. package/node_modules/@backendrelay/platform/dist/esm/privateFields.d.ts +13 -0
  324. package/node_modules/@backendrelay/platform/dist/esm/privateFields.d.ts.map +1 -0
  325. package/node_modules/@backendrelay/platform/dist/esm/privateFields.js +28 -0
  326. package/node_modules/@backendrelay/platform/dist/esm/privateFields.js.map +1 -0
  327. package/node_modules/@backendrelay/platform/dist/esm/relationships.d.ts +7 -0
  328. package/node_modules/@backendrelay/platform/dist/esm/relationships.d.ts.map +1 -0
  329. package/node_modules/@backendrelay/platform/dist/esm/relationships.js +43 -0
  330. package/node_modules/@backendrelay/platform/dist/esm/relationships.js.map +1 -0
  331. package/node_modules/@backendrelay/platform/dist/esm/schema.d.ts +161 -0
  332. package/node_modules/@backendrelay/platform/dist/esm/schema.d.ts.map +1 -0
  333. package/node_modules/@backendrelay/platform/dist/esm/schema.js +158 -0
  334. package/node_modules/@backendrelay/platform/dist/esm/schema.js.map +1 -0
  335. package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.d.ts +25 -0
  336. package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.d.ts.map +1 -0
  337. package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.js +64 -0
  338. package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.js.map +1 -0
  339. package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.d.ts +17 -0
  340. package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.d.ts.map +1 -0
  341. package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.js +310 -0
  342. package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.js.map +1 -0
  343. package/node_modules/@backendrelay/platform/dist/esm/util.d.ts +13 -0
  344. package/node_modules/@backendrelay/platform/dist/esm/util.d.ts.map +1 -0
  345. package/node_modules/@backendrelay/platform/dist/esm/util.js +46 -0
  346. package/node_modules/@backendrelay/platform/dist/esm/util.js.map +1 -0
  347. package/node_modules/@backendrelay/platform/dist/esm/version.d.ts +3 -0
  348. package/node_modules/@backendrelay/platform/dist/esm/version.d.ts.map +1 -0
  349. package/node_modules/@backendrelay/platform/dist/esm/version.js +3 -0
  350. package/node_modules/@backendrelay/platform/dist/esm/version.js.map +1 -0
  351. package/node_modules/@backendrelay/platform/dist/standalone/index.js +13738 -0
  352. package/node_modules/@backendrelay/platform/dist/standalone/index.umd.cjs +72 -0
  353. package/node_modules/@backendrelay/platform/package.json +51 -0
  354. package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.d.ts +67 -0
  355. package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.d.ts.map +1 -0
  356. package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.js +129 -0
  357. package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.js.map +1 -0
  358. package/node_modules/@backendrelay/resumable-stream/dist/commonjs/package.json +3 -0
  359. package/node_modules/@backendrelay/resumable-stream/dist/esm/index.d.ts +67 -0
  360. package/node_modules/@backendrelay/resumable-stream/dist/esm/index.d.ts.map +1 -0
  361. package/node_modules/@backendrelay/resumable-stream/dist/esm/index.js +126 -0
  362. package/node_modules/@backendrelay/resumable-stream/dist/esm/index.js.map +1 -0
  363. package/node_modules/@backendrelay/resumable-stream/dist/esm/package.json +3 -0
  364. package/node_modules/@backendrelay/resumable-stream/dist/standalone/index.js +4354 -0
  365. package/node_modules/@backendrelay/resumable-stream/dist/standalone/index.umd.cjs +6 -0
  366. package/node_modules/@backendrelay/resumable-stream/package.json +47 -0
  367. package/node_modules/@backendrelay/rules/README.md +34 -0
  368. package/node_modules/@backendrelay/rules/dist/commonjs/index.d.ts +117 -0
  369. package/node_modules/@backendrelay/rules/dist/commonjs/index.d.ts.map +1 -0
  370. package/node_modules/@backendrelay/rules/dist/commonjs/index.js +68 -0
  371. package/node_modules/@backendrelay/rules/dist/commonjs/index.js.map +1 -0
  372. package/node_modules/@backendrelay/rules/dist/commonjs/package.json +3 -0
  373. package/node_modules/@backendrelay/rules/dist/esm/index.d.ts +117 -0
  374. package/node_modules/@backendrelay/rules/dist/esm/index.d.ts.map +1 -0
  375. package/node_modules/@backendrelay/rules/dist/esm/index.js +64 -0
  376. package/node_modules/@backendrelay/rules/dist/esm/index.js.map +1 -0
  377. package/node_modules/@backendrelay/rules/dist/esm/package.json +3 -0
  378. package/node_modules/@backendrelay/rules/package.json +46 -0
  379. package/node_modules/@backendrelay/test/README.md +75 -0
  380. package/node_modules/@backendrelay/test/dist/commonjs/index.d.ts +74 -0
  381. package/node_modules/@backendrelay/test/dist/commonjs/index.d.ts.map +1 -0
  382. package/node_modules/@backendrelay/test/dist/commonjs/index.js +197 -0
  383. package/node_modules/@backendrelay/test/dist/commonjs/index.js.map +1 -0
  384. package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.d.ts +2 -0
  385. package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.d.ts.map +1 -0
  386. package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.js +45 -0
  387. package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.js.map +1 -0
  388. package/node_modules/@backendrelay/test/dist/commonjs/package.json +3 -0
  389. package/node_modules/@backendrelay/test/dist/esm/index.d.ts +74 -0
  390. package/node_modules/@backendrelay/test/dist/esm/index.d.ts.map +1 -0
  391. package/node_modules/@backendrelay/test/dist/esm/index.js +192 -0
  392. package/node_modules/@backendrelay/test/dist/esm/index.js.map +1 -0
  393. package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.d.ts +2 -0
  394. package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.d.ts.map +1 -0
  395. package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.js +43 -0
  396. package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.js.map +1 -0
  397. package/node_modules/@backendrelay/test/dist/esm/package.json +3 -0
  398. package/node_modules/@backendrelay/test/package.json +49 -0
  399. package/node_modules/@backendrelay/version/dist/commonjs/index.d.ts +3 -0
  400. package/node_modules/@backendrelay/version/dist/commonjs/index.d.ts.map +1 -0
  401. package/node_modules/@backendrelay/version/dist/commonjs/index.js +6 -0
  402. package/node_modules/@backendrelay/version/dist/commonjs/index.js.map +1 -0
  403. package/node_modules/@backendrelay/version/dist/commonjs/package.json +3 -0
  404. package/node_modules/@backendrelay/version/dist/commonjs/version.d.ts +3 -0
  405. package/node_modules/@backendrelay/version/dist/commonjs/version.d.ts.map +1 -0
  406. package/node_modules/@backendrelay/version/dist/commonjs/version.js +10 -0
  407. package/node_modules/@backendrelay/version/dist/commonjs/version.js.map +1 -0
  408. package/node_modules/@backendrelay/version/dist/esm/index.d.ts +3 -0
  409. package/node_modules/@backendrelay/version/dist/esm/index.d.ts.map +1 -0
  410. package/node_modules/@backendrelay/version/dist/esm/index.js +3 -0
  411. package/node_modules/@backendrelay/version/dist/esm/index.js.map +1 -0
  412. package/node_modules/@backendrelay/version/dist/esm/package.json +3 -0
  413. package/node_modules/@backendrelay/version/dist/esm/version.d.ts +3 -0
  414. package/node_modules/@backendrelay/version/dist/esm/version.d.ts.map +1 -0
  415. package/node_modules/@backendrelay/version/dist/esm/version.js +7 -0
  416. package/node_modules/@backendrelay/version/dist/esm/version.js.map +1 -0
  417. package/node_modules/@backendrelay/version/dist/standalone/index.js +4 -0
  418. package/node_modules/@backendrelay/version/dist/standalone/index.umd.cjs +1 -0
  419. package/node_modules/@backendrelay/version/package.json +44 -0
  420. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.d.ts +12 -0
  421. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
  422. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.js +5 -0
  423. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.js.map +1 -0
  424. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.d.ts +2 -0
  425. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
  426. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.js +82 -0
  427. package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.js.map +1 -0
  428. package/node_modules/@backendrelay/webhooks/dist/commonjs/index.d.ts +607 -0
  429. package/node_modules/@backendrelay/webhooks/dist/commonjs/index.d.ts.map +1 -0
  430. package/node_modules/@backendrelay/webhooks/dist/commonjs/index.js +830 -0
  431. package/node_modules/@backendrelay/webhooks/dist/commonjs/index.js.map +1 -0
  432. package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.d.ts +2 -0
  433. package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.d.ts.map +1 -0
  434. package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.js +139 -0
  435. package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.js.map +1 -0
  436. package/node_modules/@backendrelay/webhooks/dist/commonjs/package.json +3 -0
  437. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.d.ts +12 -0
  438. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.d.ts.map +1 -0
  439. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.js +4 -0
  440. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.js.map +1 -0
  441. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.d.ts +2 -0
  442. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.d.ts.map +1 -0
  443. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.js +80 -0
  444. package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.js.map +1 -0
  445. package/node_modules/@backendrelay/webhooks/dist/esm/index.d.ts +607 -0
  446. package/node_modules/@backendrelay/webhooks/dist/esm/index.d.ts.map +1 -0
  447. package/node_modules/@backendrelay/webhooks/dist/esm/index.js +825 -0
  448. package/node_modules/@backendrelay/webhooks/dist/esm/index.js.map +1 -0
  449. package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.d.ts +2 -0
  450. package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.d.ts.map +1 -0
  451. package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.js +137 -0
  452. package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.js.map +1 -0
  453. package/node_modules/@backendrelay/webhooks/dist/esm/package.json +3 -0
  454. package/node_modules/@backendrelay/webhooks/package.json +46 -0
  455. package/package.json +129 -56
  456. package/subpaths/admin/index.cjs +1 -0
  457. package/subpaths/admin/index.d.ts +1 -0
  458. package/subpaths/admin/index.mjs +3 -0
  459. package/subpaths/functions/index.cjs +1 -0
  460. package/subpaths/functions/index.d.ts +1 -0
  461. package/subpaths/functions/index.mjs +3 -0
  462. package/subpaths/hatchet/index.cjs +1 -0
  463. package/subpaths/hatchet/index.d.ts +1 -0
  464. package/subpaths/hatchet/index.mjs +3 -0
  465. package/subpaths/platform/index.cjs +1 -0
  466. package/subpaths/platform/index.d.ts +1 -0
  467. package/subpaths/platform/index.mjs +3 -0
  468. package/subpaths/resumable-stream/index.cjs +1 -0
  469. package/subpaths/resumable-stream/index.d.ts +1 -0
  470. package/subpaths/resumable-stream/index.mjs +3 -0
  471. package/subpaths/rules/index.cjs +1 -0
  472. package/subpaths/rules/index.d.ts +1 -0
  473. package/subpaths/rules/index.mjs +3 -0
  474. package/subpaths/test/index.cjs +1 -0
  475. package/subpaths/test/index.d.ts +1 -0
  476. package/subpaths/test/index.mjs +3 -0
  477. package/subpaths/version/index.cjs +1 -0
  478. package/subpaths/version/index.d.ts +1 -0
  479. package/subpaths/version/index.mjs +3 -0
  480. package/subpaths/webhooks/index.cjs +1 -0
  481. package/subpaths/webhooks/index.d.ts +1 -0
  482. package/subpaths/webhooks/index.mjs +3 -0
  483. package/.tshy/build.json +0 -8
  484. package/.tshy/commonjs.json +0 -16
  485. package/.tshy/esm.json +0 -15
  486. package/__example__/standalone.esm.html +0 -23
  487. package/__example__/standalone.umd.html +0 -21
  488. package/__tests__/src/Connection.test.ts +0 -292
  489. package/__tests__/src/IndexedDBStorage.test.ts +0 -96
  490. package/__tests__/src/Reactor.test.ts +0 -1179
  491. package/__tests__/src/auth-extra-fields.e2e.test.ts +0 -160
  492. package/__tests__/src/byop.e2e.test.ts +0 -762
  493. package/__tests__/src/config.test.ts +0 -85
  494. package/__tests__/src/cookieSync.e2e.test.ts +0 -163
  495. package/__tests__/src/data/movies/attrs.json +0 -145
  496. package/__tests__/src/data/movies/triples.json +0 -1507
  497. package/__tests__/src/data/zeneca/attrs.json +0 -251
  498. package/__tests__/src/data/zeneca/triples.json +0 -15854
  499. package/__tests__/src/datalog.test.ts +0 -175
  500. package/__tests__/src/devtool.test.ts +0 -23
  501. package/__tests__/src/framework.test.ts +0 -173
  502. package/__tests__/src/infiniteQuery.e2e.test.ts +0 -467
  503. package/__tests__/src/instaml.test.ts +0 -1593
  504. package/__tests__/src/instaql.bench.ts +0 -34
  505. package/__tests__/src/instaql.test.ts +0 -1497
  506. package/__tests__/src/instaqlInference.test.ts +0 -243
  507. package/__tests__/src/presence.test.ts +0 -49
  508. package/__tests__/src/queryValidation.test.ts +0 -1101
  509. package/__tests__/src/schema.test.ts +0 -653
  510. package/__tests__/src/serializeSchema.test.ts +0 -123
  511. package/__tests__/src/simple.e2e.test.ts +0 -133
  512. package/__tests__/src/storage-upload.test.ts +0 -37
  513. package/__tests__/src/store.test.ts +0 -960
  514. package/__tests__/src/syncTable.e2e.test.ts +0 -245
  515. package/__tests__/src/syncTable.test.ts +0 -235
  516. package/__tests__/src/transactionValidation.test.ts +0 -450
  517. package/__tests__/src/typeUtils.ts +0 -39
  518. package/__tests__/src/upstream-improvements.e2e.test.ts +0 -54
  519. package/__tests__/src/utils/MutationStorage.test.ts +0 -77
  520. package/__tests__/src/utils/PersistedObject.test.ts +0 -569
  521. package/__tests__/src/utils/dates.test.ts +0 -111
  522. package/__tests__/src/utils/e2e.ts +0 -100
  523. package/__tests__/src/utils/msw.ts +0 -3
  524. package/__tests__/src/utils/object.test.ts +0 -78
  525. package/__tests__/src/utils/weakHash.test.ts +0 -68
  526. package/__tests__/src/utils/weakHashLegacy.test.ts +0 -22
  527. package/__tests__/src/vite.env.d.ts +0 -1
  528. package/src/BackendRelayError.ts +0 -50
  529. package/src/Connection.ts +0 -361
  530. package/src/InMemoryStorage.ts +0 -34
  531. package/src/IndexedDBStorage.ts +0 -398
  532. package/src/Reactor.js +0 -1541
  533. package/src/StorageAPI.ts +0 -147
  534. package/src/Stream.ts +0 -1252
  535. package/src/SyncTable.ts +0 -750
  536. package/src/WindowNetworkListener.js +0 -19
  537. package/src/__types__/fieldsTypeTest.ts +0 -111
  538. package/src/__types__/typeUtils.ts +0 -39
  539. package/src/__types__/useDatesTypeTest.ts +0 -66
  540. package/src/attrTypes.ts +0 -37
  541. package/src/authAPI.ts +0 -205
  542. package/src/clientTypes.ts +0 -28
  543. package/src/coreTypes.ts +0 -58
  544. package/src/createRouteHandler.ts +0 -68
  545. package/src/datalog.js +0 -116
  546. package/src/devtool.ts +0 -179
  547. package/src/framework.ts +0 -450
  548. package/src/helperTypes.ts +0 -117
  549. package/src/index.ts +0 -1293
  550. package/src/infiniteQuery.ts +0 -599
  551. package/src/instaml.ts +0 -676
  552. package/src/instaql.ts +0 -999
  553. package/src/instatx.ts +0 -265
  554. package/src/model/instaqlResult.js +0 -25
  555. package/src/parseSchemaFromJSON.ts +0 -176
  556. package/src/presence.ts +0 -123
  557. package/src/presenceTypes.ts +0 -19
  558. package/src/queryTypes.ts +0 -749
  559. package/src/queryValidation.ts +0 -598
  560. package/src/reactorAuth.js +0 -236
  561. package/src/reactorEvents.js +0 -414
  562. package/src/reactorMutations.js +0 -354
  563. package/src/reactorRooms.js +0 -297
  564. package/src/reactorStorage.js +0 -180
  565. package/src/reactorSubs.js +0 -275
  566. package/src/reactorTransport.js +0 -391
  567. package/src/reactorTypes.ts +0 -41
  568. package/src/routeHandlerProtocol.ts +0 -25
  569. package/src/rulesTypes.ts +0 -132
  570. package/src/sanityCheckQueries.ts +0 -191
  571. package/src/schema.ts +0 -206
  572. package/src/schemaTypes.ts +0 -664
  573. package/src/store.ts +0 -1165
  574. package/src/transactionValidation.ts +0 -204
  575. package/src/urls.ts +0 -50
  576. package/src/utils/Deferred.ts +0 -20
  577. package/src/utils/MutationStorage.ts +0 -89
  578. package/src/utils/PersistedObject.ts +0 -612
  579. package/src/utils/dates.ts +0 -269
  580. package/src/utils/error.ts +0 -9
  581. package/src/utils/fetch.ts +0 -131
  582. package/src/utils/flags.ts +0 -14
  583. package/src/utils/id.ts +0 -28
  584. package/src/utils/linkIndex.ts +0 -33
  585. package/src/utils/log.ts +0 -23
  586. package/src/utils/object.js +0 -180
  587. package/src/utils/pgtime.ts +0 -199
  588. package/src/utils/pick.js +0 -9
  589. package/src/utils/strings.ts +0 -19
  590. package/src/utils/weakHash.ts +0 -77
  591. package/src/utils/weakHashLegacy.ts +0 -75
  592. package/src/warningToggle.ts +0 -5
  593. package/tsconfig.cjs.dev.json +0 -15
  594. package/tsconfig.dev.json +0 -14
  595. package/tsconfig.json +0 -13
  596. package/tsconfig.test.json +0 -5
  597. package/vite.config.ts +0 -19
  598. package/vitest.config.ts +0 -54
@@ -0,0 +1,6 @@
1
+ (function(we,xe){typeof exports=="object"&&typeof module<"u"?xe(exports):typeof define=="function"&&define.amd?define(["exports"],xe):(we=typeof globalThis<"u"?globalThis:we||self,xe(we.instant={}))})(this,(function(we){"use strict";const xe=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Se(t){return typeof t=="string"&&xe.test(t)}const F=[];for(let t=0;t<256;++t)F.push((t+256).toString(16).slice(1));function dn(t,e=0){return(F[t[e+0]]+F[t[e+1]]+F[t[e+2]]+F[t[e+3]]+"-"+F[t[e+4]]+F[t[e+5]]+"-"+F[t[e+6]]+F[t[e+7]]+"-"+F[t[e+8]]+F[t[e+9]]+"-"+F[t[e+10]]+F[t[e+11]]+F[t[e+12]]+F[t[e+13]]+F[t[e+14]]+F[t[e+15]]).toLowerCase()}let et;const hn=new Uint8Array(16);function pn(){if(!et){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");et=crypto.getRandomValues.bind(crypto)}return et(hn)}const $t={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function yn(t,e,n){if($t.randomUUID&&!t)return $t.randomUUID();t=t||{};const s=t.random??t.rng?.()??pn();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,dn(s)}const N={Remove:"remove",Replace:"replace",Add:"add"},Et=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),We=Symbol.iterator,Q={mutable:"mutable",immutable:"immutable"},tt={};function Te(t,e){return t instanceof Map?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ot(t,e){if(e in t){let n=Reflect.getPrototypeOf(t);for(;n;){const s=Reflect.getOwnPropertyDescriptor(n,e);if(s)return s;n=Reflect.getPrototypeOf(n)}}}function _t(t){return Object.getPrototypeOf(t)===Set.prototype}function Rt(t){return Object.getPrototypeOf(t)===Map.prototype}function q(t){var e;return(e=t.copy)!==null&&e!==void 0?e:t.original}function nt(t){return!!O(t)}function O(t){return typeof t!="object"?null:t?.[Et]}function st(t){var e;const n=O(t);return n?(e=n.copy)!==null&&e!==void 0?e:n.original:t}function le(t,e){if(!t||typeof t!="object")return!1;let n;return Object.getPrototypeOf(t)===Object.prototype||Array.isArray(t)||t instanceof Map||t instanceof Set||!!e?.mark&&((n=e.mark(t,Q))===Q.immutable||typeof n=="function")}function Ct(t,e=[]){if(Object.hasOwnProperty.call(t,"key")){const n=t.parent.copy,s=O(oe(n,t.key));if(s!==null&&s?.original!==t.original)return null;const i=t.parent.type===3,o=i?Array.from(t.parent.setMap.keys()).indexOf(t.key):t.key;if(!(i&&n.size>o||Te(n,o)))return null;e.push(o)}if(t.parent)return Ct(t.parent,e);e.reverse();try{mn(t.copy,e)}catch{return null}return e}function Ae(t){return Array.isArray(t)?1:t instanceof Map?2:t instanceof Set?3:0}function oe(t,e){return Ae(t)===2?t.get(e):t[e]}function it(t,e,n){Ae(t)===2?t.set(e,n):t[e]=n}function rt(t,e){const n=O(t);return(n?q(n):t)[e]}function ue(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function fe(t,e){return e?t:[""].concat(t).map(n=>{const s=`${n}`;return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function mn(t,e){for(let n=0;n<e.length-1;n+=1){const s=e[n];if(t=oe(Ae(t)===3?Array.from(t):t,s),typeof t!="object")throw new Error(`Cannot resolve patch at '${e.join("/")}'.`)}return t}function bn(t){const e=Object.create(Object.getPrototypeOf(t));return Reflect.ownKeys(t).forEach(n=>{let s=Reflect.getOwnPropertyDescriptor(t,n);if(s.enumerable&&s.configurable&&s.writable){e[n]=t[n];return}s.writable||(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(s={configurable:!0,writable:!0,enumerable:s.enumerable,value:t[n]}),Reflect.defineProperty(e,n,s)}),e}const gn=Object.prototype.propertyIsEnumerable;function wn(t,e){let n;if(Array.isArray(t))return Array.prototype.concat.call(t);if(t instanceof Set){if(!_t(t)){const s=Object.getPrototypeOf(t).constructor;return new s(t.values())}return Set.prototype.difference?Set.prototype.difference.call(t,new Set):new Set(t.values())}else if(t instanceof Map){if(!Rt(t)){const s=Object.getPrototypeOf(t).constructor;return new s(t)}return new Map(t)}else if(e?.mark&&(n=e.mark(t,Q),n!==void 0)&&n!==Q.mutable){if(n===Q.immutable)return bn(t);if(typeof n=="function"){if(e.enablePatches||e.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype){const s={};return Object.keys(t).forEach(i=>{s[i]=t[i]}),Object.getOwnPropertySymbols(t).forEach(i=>{gn.call(t,i)&&(s[i]=t[i])}),s}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function B(t){t.copy||(t.copy=wn(t.original,t.options))}function Pe(t){if(!le(t))return st(t);if(Array.isArray(t))return t.map(Pe);if(t instanceof Map){const n=Array.from(t.entries()).map(([s,i])=>[s,Pe(i)]);if(!Rt(t)){const s=Object.getPrototypeOf(t).constructor;return new s(n)}return new Map(n)}if(t instanceof Set){const n=Array.from(t).map(Pe);if(!_t(t)){const s=Object.getPrototypeOf(t).constructor;return new s(n)}return new Set(n)}const e=Object.create(Object.getPrototypeOf(t));for(const n in t)e[n]=Pe(t[n]);return e}function ze(t){return nt(t)?Pe(t):t}function ee(t){var e;t.assignedMap=(e=t.assignedMap)!==null&&e!==void 0?e:new Map,t.operated||(t.operated=!0,t.parent&&ee(t.parent))}function Sn(t,e){const n=Ae(t);if(n===0)Reflect.ownKeys(t).forEach(s=>{e(s,t[s],t)});else if(n===1){let s=0;for(const i of t)e(s,i,t),s+=1}else t.forEach((s,i)=>e(i,s,t))}function xt(t,e,n){if(nt(t)||!le(t,n)||e.has(t)||Object.isFrozen(t))return;const s=t instanceof Set,i=s?new Map:void 0;if(e.add(t),Sn(t,(o,r)=>{var a;if(nt(r)){const u=O(r);B(u);const l=!((a=u.assignedMap)===null||a===void 0)&&a.size||u.operated?u.copy:u.original;it(s?i:t,o,l)}else xt(r,e,n)}),i){const o=t,r=Array.from(o);o.clear(),r.forEach(a=>{o.add(i.has(a)?i.get(a):a)})}}function vn(t,e){const n=t.type===3?t.setMap:t.copy;t.finalities.revoke.length>1&&t.assignedMap.get(e)&&n&&xt(oe(n,e),t.finalities.handledSet,t.options)}function ot(t){t.type===3&&t.copy&&(t.copy.clear(),t.setMap.forEach(e=>{t.copy.add(st(e))}))}function at(t,e,n,s){if(t.operated&&t.assignedMap&&t.assignedMap.size>0&&!t.finalized){if(n&&s){const o=Ct(t);o&&e(t,o,n,s)}t.finalized=!0}}function ct(t,e,n,s){const i=O(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((o,r)=>{var a;const u=t.type===3?t.setMap:t.copy;if(ue(oe(u,e),n)){let l=i.original;i.copy&&(l=i.copy),ot(t),at(t,s,o,r),t.options.enableAutoFreeze&&(t.options.updatedValues=(a=t.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,t.options.updatedValues.set(l,i.original)),it(u,e,l)}}),t.options.enableAutoFreeze&&i.finalities!==t.finalities&&(t.options.enableAutoFreeze=!1)),le(n,t.options)&&t.finalities.draft.push(()=>{const o=t.type===3?t.setMap:t.copy;ue(oe(o,e),n)&&vn(t,e)})}function kn(t,e,n,s,i){let{original:o,assignedMap:r,options:a}=t,u=t.copy;u.length<o.length&&([o,u]=[u,o],[n,s]=[s,n]);for(let l=0;l<o.length;l+=1)if(r.get(l.toString())&&u[l]!==o[l]){const f=e.concat([l]),h=fe(f,i);n.push({op:N.Replace,path:h,value:ze(u[l])}),s.push({op:N.Replace,path:h,value:ze(o[l])})}for(let l=o.length;l<u.length;l+=1){const f=e.concat([l]),h=fe(f,i);n.push({op:N.Add,path:h,value:ze(u[l])})}if(o.length<u.length){const{arrayLengthAssignment:l=!0}=a.enablePatches;if(l){const f=e.concat(["length"]),h=fe(f,i);s.push({op:N.Replace,path:h,value:o.length})}else for(let f=u.length;o.length<f;f-=1){const h=e.concat([f-1]),p=fe(h,i);s.push({op:N.Remove,path:p})}}}function In({original:t,copy:e,assignedMap:n},s,i,o,r){n.forEach((a,u)=>{const l=oe(t,u),f=ze(oe(e,u)),h=a?Te(t,u)?N.Replace:N.Add:N.Remove;if(ue(l,f)&&h===N.Replace)return;const p=s.concat(u),m=fe(p,r);i.push(h===N.Remove?{op:h,path:m}:{op:h,path:m,value:f}),o.push(h===N.Add?{op:N.Remove,path:m}:h===N.Remove?{op:N.Add,path:m,value:l}:{op:N.Replace,path:m,value:l})})}function $n({original:t,copy:e},n,s,i,o){let r=0;t.forEach(a=>{if(!e.has(a)){const u=n.concat([r]),l=fe(u,o);s.push({op:N.Remove,path:l,value:a}),i.unshift({op:N.Add,path:l,value:a})}r+=1}),r=0,e.forEach(a=>{if(!t.has(a)){const u=n.concat([r]),l=fe(u,o);s.push({op:N.Add,path:l,value:a}),i.unshift({op:N.Remove,path:l,value:a})}r+=1})}function Ue(t,e,n,s){const{pathAsArray:i=!0}=t.options.enablePatches;switch(t.type){case 0:case 2:return In(t,e,n,s,i);case 1:return kn(t,e,n,s,i);case 3:return $n(t,e,n,s,i)}}const Be=(t,e,n=!1)=>{if(typeof t=="object"&&t!==null&&(!le(t,e)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},lt={get size(){return q(O(this)).size},has(t){return q(O(this)).has(t)},set(t,e){const n=O(this),s=q(n);return(!s.has(t)||!ue(s.get(t),e))&&(B(n),ee(n),n.assignedMap.set(t,!0),n.copy.set(t,e),ct(n,t,e,Ue)),this},delete(t){if(!this.has(t))return!1;const e=O(this);return B(e),ee(e),e.original.has(t)?e.assignedMap.set(t,!1):e.assignedMap.delete(t),e.copy.delete(t),!0},clear(){const t=O(this);if(this.size){B(t),ee(t),t.assignedMap=new Map;for(const[e]of t.original)t.assignedMap.set(e,!1);t.copy.clear()}},forEach(t,e){const n=O(this);q(n).forEach((s,i)=>{t.call(e,this.get(i),i,this)})},get(t){var e,n;const s=O(this),i=q(s).get(t),o=((n=(e=s.options).mark)===null||n===void 0?void 0:n.call(e,i,Q))===Q.mutable;if(s.options.strict&&Be(i,s.options,o),o||s.finalized||!le(i,s.options)||i!==s.original.get(t))return i;const r=tt.createDraft({original:i,parentDraft:s,key:t,finalities:s.finalities,options:s.options});return B(s),s.copy.set(t,r),r},keys(){return q(O(this)).keys()},values(){const t=this.keys();return{[We]:()=>this.values(),next:()=>{const e=t.next();return e.done?e:{done:!1,value:this.get(e.value)}}}},entries(){const t=this.keys();return{[We]:()=>this.entries(),next:()=>{const e=t.next();if(e.done)return e;const n=this.get(e.value);return{done:!1,value:[e.value,n]}}}},[We](){return this.entries()}},En=Reflect.ownKeys(lt),Tt=(t,e,{isValuesIterator:n})=>()=>{var s,i;const o=e.next();if(o.done)return o;const r=o.value;let a=t.setMap.get(r);const u=O(a),l=((i=(s=t.options).mark)===null||i===void 0?void 0:i.call(s,a,Q))===Q.mutable;if(t.options.strict&&Be(r,t.options,l),!l&&!u&&le(r,t.options)&&!t.finalized&&t.original.has(r)){const f=tt.createDraft({original:r,parentDraft:t,key:r,finalities:t.finalities,options:t.options});t.setMap.set(r,f),a=f}else u&&(a=u.proxy);return{done:!1,value:n?a:[a,a]}},Je={get size(){return O(this).setMap.size},has(t){const e=O(this);if(e.setMap.has(t))return!0;B(e);const n=O(t);return!!(n&&e.setMap.has(n.original))},add(t){const e=O(this);return this.has(t)||(B(e),ee(e),e.assignedMap.set(t,!0),e.setMap.set(t,t),ct(e,t,t,Ue)),this},delete(t){if(!this.has(t))return!1;const e=O(this);B(e),ee(e);const n=O(t);return n&&e.setMap.has(n.original)?(e.assignedMap.set(n.original,!1),e.setMap.delete(n.original)):(!n&&e.setMap.has(t)?e.assignedMap.set(t,!1):e.assignedMap.delete(t),e.setMap.delete(t))},clear(){if(!this.size)return;const t=O(this);B(t),ee(t);for(const e of t.original)t.assignedMap.set(e,!1);t.setMap.clear()},values(){const t=O(this);B(t);const e=t.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:Tt(t,e,{isValuesIterator:!0})}},entries(){const t=O(this);B(t);const e=t.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:Tt(t,e,{isValuesIterator:!1})}},keys(){return this.values()},[We](){return this.values()},forEach(t,e){const n=this.values();let s=n.next();for(;!s.done;)t.call(e,s.value,s.value,this),s=n.next()}};Set.prototype.difference&&Object.assign(Je,{intersection(t){return Set.prototype.intersection.call(new Set(this.values()),t)},union(t){return Set.prototype.union.call(new Set(this.values()),t)},difference(t){return Set.prototype.difference.call(new Set(this.values()),t)},symmetricDifference(t){return Set.prototype.symmetricDifference.call(new Set(this.values()),t)},isSubsetOf(t){return Set.prototype.isSubsetOf.call(new Set(this.values()),t)},isSupersetOf(t){return Set.prototype.isSupersetOf.call(new Set(this.values()),t)},isDisjointFrom(t){return Set.prototype.isDisjointFrom.call(new Set(this.values()),t)}});const On=Reflect.ownKeys(Je),At=new WeakSet,Pt={get(t,e,n){var s,i;const o=(s=t.copy)===null||s===void 0?void 0:s[e];if(o&&At.has(o))return o;if(e===Et)return t;let r;if(t.options.mark){const l=e==="size"&&(t.original instanceof Map||t.original instanceof Set)?Reflect.get(t.original,e):Reflect.get(t.original,e,n);if(r=t.options.mark(l,Q),r===Q.mutable)return t.options.strict&&Be(l,t.options,!0),l}const a=q(t);if(a instanceof Map&&En.includes(e)){if(e==="size")return Object.getOwnPropertyDescriptor(lt,"size").get.call(t.proxy);const l=lt[e];if(l)return l.bind(t.proxy)}if(a instanceof Set&&On.includes(e)){if(e==="size")return Object.getOwnPropertyDescriptor(Je,"size").get.call(t.proxy);const l=Je[e];if(l)return l.bind(t.proxy)}if(!Te(a,e)){const l=Ot(a,e);return l?"value"in l?l.value:(i=l.get)===null||i===void 0?void 0:i.call(t.proxy):void 0}const u=a[e];if(t.options.strict&&Be(u,t.options),t.finalized||!le(u,t.options))return u;if(u===rt(t.original,e)){if(B(t),t.copy[e]=Ut({original:t.original[e],parentDraft:t,key:t.type===1?Number(e):e,finalities:t.finalities,options:t.options}),typeof r=="function"){const l=O(t.copy[e]);return B(l),ee(l),l.copy}return t.copy[e]}return u},set(t,e,n){var s;if(t.type===3||t.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(t.type===1&&e!=="length"&&!(Number.isInteger(i=Number(e))&&i>=0&&(e===0||i===0||String(i)===String(e))))throw new Error("Only supports setting array indices and the 'length' property.");const o=Ot(q(t),e);if(o?.set)return o.set.call(t.proxy,n),!0;const r=rt(q(t),e),a=O(r);return a&&ue(a.original,n)?(t.copy[e]=n,t.assignedMap=(s=t.assignedMap)!==null&&s!==void 0?s:new Map,t.assignedMap.set(e,!1),!0):(ue(n,r)&&(n!==void 0||Te(t.original,e))||(B(t),ee(t),Te(t.original,e)&&ue(n,t.original[e])?t.assignedMap.delete(e):t.assignedMap.set(e,!0),t.copy[e]=n,ct(t,e,n,Ue)),!0)},has(t,e){return e in q(t)},ownKeys(t){return Reflect.ownKeys(q(t))},getOwnPropertyDescriptor(t,e){const n=q(t),s=Reflect.getOwnPropertyDescriptor(n,e);return s&&{writable:!0,configurable:t.type!==1||e!=="length",enumerable:s.enumerable,value:n[e]}},getPrototypeOf(t){return Reflect.getPrototypeOf(t.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(t,e){var n;return t.type===1?Pt.set.call(this,t,e,void 0,t.proxy):(rt(t.original,e)!==void 0||e in t.original?(B(t),ee(t),t.assignedMap.set(e,!1)):(t.assignedMap=(n=t.assignedMap)!==null&&n!==void 0?n:new Map,t.assignedMap.delete(e)),t.copy&&delete t.copy[e],!0)}};function Ut(t){const{original:e,parentDraft:n,key:s,finalities:i,options:o}=t,r=Ae(e),a={type:r,finalized:!1,parent:n,original:e,copy:null,proxy:null,finalities:i,options:o,setMap:r===3?new Map(e.entries()):void 0};(s||"key"in t)&&(a.key=s);const{proxy:u,revoke:l}=Proxy.revocable(r===1?Object.assign([],a):a,Pt);if(i.revoke.push(l),At.add(u),a.proxy=u,n){const f=n;f.finalities.draft.push((h,p)=>{var m,$;const w=O(u);let c=f.type===3?f.setMap:f.copy;const b=oe(c,s),S=O(b);if(S){let d=S.original;S.operated&&(d=st(b)),ot(S),at(S,Ue,h,p),f.options.enableAutoFreeze&&(f.options.updatedValues=(m=f.options.updatedValues)!==null&&m!==void 0?m:new WeakMap,f.options.updatedValues.set(d,S.original)),it(c,s,d)}($=w.callbacks)===null||$===void 0||$.forEach(d=>{d(h,p)})})}else{const f=O(u);f.finalities.draft.push((h,p)=>{ot(f),at(f,Ue,h,p)})}return u}tt.createDraft=Ut,Object.prototype.constructor.toString();function _n(){const e={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(e))}const Rn=_n();function qe(t,e,n){const s={__etype:t,__ops:n};return new Proxy(s,{get:(i,o)=>{if(o==="__ops")return n;if(o==="__etype")return t;if(Rn.has(o))return(r,a)=>qe(t,e,[...n,a?[o,t,e,r,a]:[o,t,e,r]])}})}function Cn(t,e){return`lookup__${t}__${JSON.stringify(e)}`}function jt(t){return t.startsWith("lookup__")}function Mt(t){const[e,n,...s]=t.split("__");return[n,JSON.parse(s.join("__"))]}function xn(t){return new Proxy({__etype:t},{get(e,n){if(n==="lookup")return(i,o)=>qe(t,Mt(Cn(i,o)),[]);if(n==="__etype")return t;const s=n;return jt(s)?qe(t,Mt(s),[]):qe(t,s,[])}})}function Dt(){return new Proxy({},{get(t,e){return xn(e)}})}Dt();function Tn(t){return t.__ops}function ve(){return yn()}function An(t,e){if(typeof t!="function")return;const n=e instanceof Error?e:new R(String(e));try{t(n)}catch{}}class R extends Error{hint;traceId;constructor(e,n,s){super(e),this.hint=n,s&&(this.traceId=s);const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,R),this.name="BackendRelayError"}get[Symbol.toStringTag](){return"BackendRelayError"}}class ie extends R{body;status;constructor(e){const n=e.body?.message||`API Error (${e.status})`;super(n,e.body.hint,e.body?.traceId||e.body["trace-id"]);const s=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,s),Error.captureStackTrace&&Error.captureStackTrace(this,ie),this.name="BackendRelayAPIError",this.status=e.status,this.body=e.body}get[Symbol.toStringTag](){return"BackendRelayAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const de="v2.0.0";class te{valueType;required;isIndexed;config;metadata={};constructor(e,n,s,i={indexed:!1,unique:!1}){this.valueType=e,this.required=n,this.isIndexed=s,this.config=i}clientRequired(){return new te(this.valueType,!1,this.isIndexed,this.config)}optional(){return new te(this.valueType,!1,this.isIndexed,this.config)}private(){return new te(this.valueType,this.required,this.isIndexed,{...this.config,private:!0})}unique(){return new te(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new te(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class _ extends Error{constructor(e,n){const s=n?`At path '${n}': ${e}`:e;super(s),this.name="QueryValidationError"}}const Nt=["where","order","limit","last","first","offset","after","afterInclusive","before","beforeInclusive","fields","aggregate"],Pn=t=>t.valueType||"unknown",Lt=(t,e,n=!1)=>{if(n||t==null)return!0;switch(e){case"string":return typeof t=="string";case"number":return typeof t=="number"&&!isNaN(t);case"boolean":return typeof t=="boolean";case"date":return t instanceof Date||typeof t=="string"||typeof t=="number";default:return!0}},Ft=(t,e,n,s,i,o,r)=>{const a=o.valueType==="json",u=(l,f,h)=>{if(!Lt(h,f,a))throw new _(`Invalid value for operator '${l}' on attribute '${s}' in entity '${i}'. Expected ${f}, but received: ${typeof h}`,r)};switch(t){case"in":case"$in":if(!Array.isArray(e))throw new _(`Operator '${t}' for attribute '${s}' in entity '${i}' must be an array, but received: ${typeof e}`,r);for(const l of e)u(t,n,l);break;case"$not":case"$ne":case"$gt":case"$lt":case"$gte":case"$lte":u(t,n,e);break;case"$search":if(u(t,"string",e),o.valueType!=="string"||!o.isIndexed)throw new _(`Operator '$search' can only be used with indexed string attributes, but '${s}' in entity '${i}' is not an indexed string`,r);break;case"$like":case"$ilike":if(u(t,"string",e),t==="$ilike"&&!o.isIndexed)throw new _(`Operator '${t}' can only be used with indexed attributes, but '${s}' in entity '${i}' is not indexed`,r);break;case"$isNull":u(t,"boolean",e);break;case"$nearest":{const l=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.vector)?e.vector:null;if(l===null)throw new _("Operator '$nearest' requires a vector array or { vector, limit } object",r);if(l.length===0||l.some(f=>typeof f!="number"||!Number.isFinite(f)))throw new _("Operator '$nearest' requires finite numbers",r);if(!Array.isArray(e)&&e&&typeof e=="object"&&"limit"in e&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<1))throw new _("Operator '$nearest' limit must be a positive integer",r);break}default:throw new _(`Unknown operator '${t}' for attribute '${s}' in entity '${i}'`,r)}},ke=(t,e,n,s,i)=>{const o=Pn(n),r=n.valueType==="json";if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const u=t;if(r&&"$nearest"in u){Ft("$nearest",u.$nearest,o,e,s,n,`${i}.$nearest`);return}if(r)return;for(const[l,f]of Object.entries(u))Ft(l,f,o,e,s,n,`${i}.${l}`)}else if(!Lt(t,o,r))throw new _(`Invalid value for attribute '${e}' in entity '${s}'. Expected ${o}, but received: ${typeof t}`,i)},Un=(t,e,n,s,i)=>{const o=t.split(".");if(o.length<2)throw new _(`Invalid dot notation path '${t}'. Must contain at least one dot.`,i);let r=n;for(let f=0;f<o.length-1;f++){const h=o[f],p=s.entities[r];if(!p)throw new _(`Entity '${r}' does not exist in schema while traversing dot notation path '${t}'.`,i);const m=p.links[h];if(!m){const $=Object.keys(p.links);throw new _(`Link '${h}' does not exist on entity '${r}' in dot notation path '${t}'. Available links: ${$.length>0?$.join(", "):"none"}`,i)}r=m.entityName}const a=o[o.length-1],u=s.entities[r];if(!u)throw new _(`Target entity '${r}' does not exist in schema for dot notation path '${t}'.`,i);if(a==="id"){if(typeof e=="string"&&!Se(e))throw new _(`Invalid value for id field in entity '${r}'. Expected a UUID, but received: ${e}`,i);ke(e,t,new te("string",!1,!0),n,i);return}const l=u.attrs[a];if(Object.keys(u.links).includes(a)){if(typeof e=="string"&&!Se(e))throw new _(`Invalid value for link '${a}' in entity '${r}'. Expected a UUID, but received: ${e}`,i);ke(e,t,new te("string",!1,!0),n,i);return}if(!l){const f=Object.keys(u.attrs);throw new _(`Attribute '${a}' does not exist on entity '${r}' in dot notation path '${t}'. Available attributes: ${f.length>0?f.join(", ")+", id":"id"}`,i)}ke(e,t,l,n,i)},Wt=(t,e,n,s)=>{for(const[i,o]of Object.entries(t)){if(i==="or"||i==="and"){if(Array.isArray(o))for(const l of o)typeof l=="object"&&l!==null&&Wt(l,e,n,`${s}.${i}[${l}]`);continue}if(i==="id"){ke(o,"id",new te("string",!1,!0),e,`${s}.id`);continue}if(i.includes(".")){Un(i,o,e,n,`${s}.${i}`);continue}const r=n.entities[e];if(!r)continue;const a=r.attrs[i],u=r.links[i];if(!a&&!u){const l=Object.keys(r.attrs),f=Object.keys(r.links);throw new _(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${l.length>0?l.join(", "):"none"}. Available links: ${f.length>0?f.join(", "):"none"}`,`${s}.${i}`)}if(a)ke(o,i,a,e,`${s}.${i}`);else if(u){if(typeof o=="string"&&!Se(o))throw new _(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${o}`,`${s}.${i}`);const l=new te("string",!1,!0);ke(o,i,l,e,`${s}.${i}`)}}},jn=(t,e,n,s,i=0)=>{for(const r of Object.keys(t))if(!Nt.includes(r))throw new _(`Invalid query parameter '${r}' in $ object. Valid parameters are: ${Nt.join(", ")}. Found: ${r}`,s);const o=["offset","before","beforeInclusive","after","afterInclusive","first","last"];for(const r of o)if(t[r]!==void 0&&i>0)throw new _(`'${r}' can only be used on top-level namespaces. It cannot be used in nested queries.`,s);if(t.where&&n){if(typeof t.where!="object"||t.where===null)throw new _(`'where' clause must be an object in entity '${e}', but received: ${typeof t.where}`,s?`${s}.where`:void 0);Wt(t.where,e,n,s?`${s}.where`:"where")}},zt=(t,e,n,s,i=0)=>{if(!t||typeof t!="object")throw new _(`Query part for entity '${e}' must be an object, but received: ${typeof t}`,s);for(const o of Object.keys(t))if(o!=="$"){if(n&&!(o in n.entities[e].links)){const a=Object.keys(n.entities[e].links);throw new _(`Link '${o}' does not exist on entity '${e}'. Available links: ${a.length>0?a.join(", "):"none"}`,`${s}.${o}`)}const r=t[o];if(typeof r=="object"&&r!==null){const a=n?.entities[e].links[o]?.entityName;a&&zt(r,a,n,`${s}.${o}`,i+1)}}else{const r=t[o];if(typeof r!="object"||r===null)throw new _(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof r}`,`${s}.$`);jn(r,e,n,`${s}.$`,i)}},Bt=(t,e)=>{if(typeof t!="object"||t===null)throw new _(`Query must be an object, but received: ${typeof t}${t===null?" (null)":""}`);if(Array.isArray(t))throw new _(`Query must be an object, but received: ${typeof t}`);const n=t;for(const s of Object.keys(n)){if(Array.isArray(t[s]))throw new _(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(typeof s!="string")throw new _(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(s!=="$$ruleParams"){if(e&&!e.entities[s]){const i=Object.keys(e.entities);throw new _(`Entity '${s}' does not exist in schema. Available entities: ${i.length>0?i.join(", "):"none"}`,s)}zt(n[s],s,e,s,0)}}},Jt=t=>typeof t!="string"?!1:jt(t)?!0:Se(t);class H extends Error{constructor(e){super(e),this.name="TransactionValidationError"}}const qt=t=>t.length>0?t.join(", "):"none",Mn=(t,e)=>new H(`Entity '${t}' does not exist in schema. Available entities: ${qt(e)}`),Dn={string:t=>typeof t=="string",number:t=>typeof t=="number"&&!isNaN(t),boolean:t=>typeof t=="boolean",date:t=>t instanceof Date||typeof t=="string"||typeof t=="number",json:()=>!0},Nn=(t,e)=>t==null?!0:Dn[e.valueType]?.(t)??!1,Kt=(t,e)=>{const n=e.entities[t];if(!n)throw Mn(t,Object.keys(e.entities));return n},ut=(t,e,n)=>{const s=Kt(t,n);if(typeof e!="object"||e===null)throw new H(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);for(const[i,o]of Object.entries(e)){if(i==="id")continue;const r=s.attrs[i];if(r&&!Nn(o,r))throw new H(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${r.valueType}, but received: ${typeof o}`)}},Ht=(t,e,n)=>{const s=Kt(t,n);if(typeof e!="object"||e===null)throw new H(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);for(const[i,o]of Object.entries(e)){if(!s.links[i]){const a=Object.keys(s.links);throw new H(`Link '${i}' does not exist on entity '${t}'. Available links: ${qt(a)}`)}if(o!=null){if(Array.isArray(o)){for(const a of o)if(!Jt(a))throw new H(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`)}else if(!Jt(o))throw new H(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${o}`)}}},Ln={create:ut,update:ut,merge:ut,link:Ht,unlink:Ht,delete:()=>{}},Fn=(t,e)=>{if(!e)return;const[n,s,i,o]=t;if(!Array.isArray(i)&&!Se(i))throw new H(`Invalid id for entity '${s}'. Expected a UUID, but received: ${i}`);if(typeof s!="string")throw new H(`Entity name must be a string, but received: ${typeof s}`);const r=Ln[n];r&&o!==void 0&&r(s,o,e)},Wn=(t,e)=>{const n=Array.isArray(t)?t:[t];for(const s of n){if(!s||typeof s!="object")throw new H(`Transaction chunk must be an object, but received: ${typeof s}`);if(!Array.isArray(s.__ops))throw new H(`Transaction chunk must have __ops array, but received: ${typeof s.__ops}`);for(const i of s.__ops){if(!Array.isArray(i))throw new H(`Transaction operation must be an array, but received: ${typeof i}`);Fn(i,e)}}};class zn extends Error{constructor(e){super(`${e} requires \`apiURI\`. Pass the BackendRelay API origin, for example init({ appId, apiURI: 'https://api.example.com' }). The SDK no longer falls back to backendrelay.com.`),this.name="MissingApiURIError"}}function Vt(t,e="BackendRelay"){const n=t?.trim();if(!n)throw new zn(e);let s;try{s=new URL(n)}catch{throw new Error(`${e} \`apiURI\` must be an absolute http(s) URL. Received: ${n}`)}if(s.protocol!=="http:"&&s.protocol!=="https:")throw new Error(`${e} \`apiURI\` must use http:// or https://. Received: ${n}`);return n.replace(/\/+$/,"")}function Bn(t,e){return t.localeCompare(e)}function Jn(){let t=Bn;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{t=Intl.Collator("en-US").compare}catch{}return t}Jn();var Qt;(function(t){t.InitialSyncBatch="InitialSyncBatch",t.InitialSyncComplete="InitialSyncComplete",t.LoadFromStorage="LoadFromStorage",t.SyncTransaction="SyncTransaction",t.Error="Error"})(Qt||(Qt={}));function qn({WStream:t,opts:e,startStream:n,appendStream:s,registerStream:i,persistence:o}){const r=e.clientId;let a=null,u=null,l=null,f=ve(),h=!1,p=!1,m=!1,$=!1;const w=[],c=[],b=[];let S=!1,d=0,x=0;const E=[],P=new TextEncoder;function g(){o.save(r,{reconnectToken:f,...a?{streamId:a}:{},buffer:E.map(y=>({...y})),bufferOffset:d,closeRequested:m})}async function I(){const y=await o.load(r);if(!y){g();return}$=!0,f=y.reconnectToken,d=y.bufferOffset,E.push(...y.buffer),x=E.reduce((v,W)=>v+W.byteLen,0),m=y.closeRequested,h=y.closeRequested,y.streamId&&j(y.streamId)}function L(){p=!0;for(const y of w)y(u??void 0)}function U(y){return w.push(y),p&&y(u??void 0),()=>{const v=w.indexOf(y);v!==-1&&w.splice(v,1)}}function T(y){return b.push(y),()=>{const v=b.indexOf(y);v!==-1&&b.splice(v,1)}}e.waitUntil&&e.waitUntil(new Promise(y=>{b.push(y)}));function M(){for(const y of b)try{y()}catch{}}function z(y){return c.push(y),a&&y(a),()=>{const v=c.indexOf(y);v!==-1&&c.splice(v,1)}}function j(y){a=y,g();for(const v of c)v(a)}function pe(){S=!0}function Ye(y){let v=d,W=0,V=0;for(const{byteLen:Z}of E){const se=v+Z;if(se>y)break;v=se,W++,V+=Z}W>0&&(d+=V,x-=V,E.splice(0,W),g())}function ye(y){!E.length&&!m||s({streamId:y,chunks:E.map(v=>v.chunk),offset:d,isDone:m})}function K(y,v){u=v,L(),y.error(v),M()}async function ne(){const y=await n({clientId:r,reconnectToken:f,ruleParams:e.ruleParams});switch(y.type){case"ok":{const{streamId:v,offset:W}=y;j(v),Ye(W),i(v,Xe),ye(v),S=!1;break}case"disconnect":{pe();break}case"error":{l&&K(l,y.error);break}}}function me(){pe(),ne()}function be({offset:y,done:v}){Ye(y),v&&(h=!0,o.remove(r),M())}const Xe={onDisconnect:pe,onFlush:be,onConnectionReconnect:ne,onAppendFailed:me};function Ws(y){return h?(K(y,new R("Stream has been closed.")),null):a||(K(y,new R("Stream has not been initialized.")),null)}async function zs(y){l=y,await I();let v=!0,W=0;for(;v;){let V=Date.now()+Math.min(15e3,500*(W-1));v=!1;const Z=await n({clientId:e.clientId,reconnectToken:f,ruleParams:e.ruleParams});switch(Z.type){case"ok":{const{streamId:se,offset:Ze}=Z;if(!$&&Ze!==0){const ge=new R("Write stream is corrupted");K(y,ge);return}j(se),Ye(Ze),i(se,Xe),ye(se),S=!1;return}case"disconnect":{v=!0,pe(),W++,await new Promise(se=>{setTimeout(se,Math.max(0,V-Date.now()))});break}case"error":{K(y,Z.error);return}}}}class Bs extends t{constructor(v,W){super(v,W)}async streamId(){return a||new Promise((v,W)=>{const V=[],Z=()=>{for(const ge of V)ge()},se=ge=>{v(ge),Z()},Ze=ge=>{W(ge||new R("Stream is closed.")),Z()};V.push(z(se)),V.push(U(Ze))})}}return{stream:new Bs({async start(y){try{await zs(y)}catch(v){K(y,v)}},write(y,v){const W=Ws(v);if(W){const V=P.encode(y).length;E.push({chunk:y,byteLen:V});const Z=d+x;x+=V,g(),S||s({streamId:W,chunks:[y],offset:Z})}},close(){m=!0,g(),a?s({streamId:a,chunks:[],offset:d+x,isDone:!0}):M(),L()},abort(y){o.remove(r),a?s({streamId:a,chunks:[],offset:d+x,isDone:!0,abortReason:y}):M(),L()}}),addCompleteCb:T,closed(){return p}}}class Kn{items=[];resolvers=[];isClosed=!1;constructor(){}push(e){if(this.isClosed)return;const n=this.resolvers.shift();n?n({value:e,done:!1}):this.items.push(e)}close(){for(this.isClosed=!0;this.resolvers.length>0;)this.resolvers.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.items.length>0)yield this.items.shift();else{if(this.isClosed)return;{const{value:e,done:n}=await new Promise(s=>{this.resolvers.push(s)});if(n||!e)return;yield e}}}}function Hn({RStream:t,opts:e,startStream:n,cancelStream:s}){let i=e.byteOffset||0,o=!1;const r=new TextDecoder("utf-8"),a=new TextEncoder;let u,l=!1;const f=[],h=[];let p=null,m=null;function $(g){l=!0;for(const I of f)I(g)}function w(g){return f.push(g),()=>{const I=f.indexOf(g);I!==-1&&f.splice(I,1)}}function c(g){return h.push(g),p&&g(p),()=>{const I=h.indexOf(g);I!==-1&&h.splice(I,1)}}function b(g,I){m=I,g.error(I),$(I)}let S=0;async function d(g,I){u=ve();const L={...g||{},eventId:u};for await(const U of n(L)){if(o)return;if(U.type==="reconnect")return{retry:!0};if(U.type==="error"){b(I,U.error);return}if(U.offset>i){b(I,new R("Stream is corrupted.")),o=!0;return}p=U.streamId;for(const M of h)M(p);let T=i-U.offset;if(U.files&&U.files.length){const M=new AbortController;let z=fetch(U.files[0].url,{signal:M.signal});for(let j=0;j<U.files.length;j++){const pe=U.files[j+1],ye=await z;if(pe&&(z=fetch(pe.url,{signal:M.signal})),!ye.ok){if(S++,S>10){b(I,new R("Unable to process stream."));return}return{retry:!0}}if(ye.body){const K=ye.body.getReader();try{for(;;){const{done:ne,value:me}=await K.read();if(ne)break;if(o){M.abort();return}let be=me;if(T>0&&(be=me.subarray(T),T-=me.length-be.length),!be.length)continue;i+=be.length;const Xe=r.decode(be);I.enqueue(Xe)}}finally{K.releaseLock()}}else{const K=await ye.arrayBuffer();let ne=K;if(o){M.abort();return}if(T>0&&(ne=new Uint8Array(K).subarray(T),T-=K.byteLength-ne.length),!ne.byteLength)continue;i+=ne.byteLength;const me=r.decode(ne);I.enqueue(me)}}}if(S=0,U.content){let M=U.content,z=a.encode(U.content);if(T>0){const j=z.subarray(T);if(T-=z.length-j.length,!j.length)continue;z=j,M=r.decode(j)}i+=z.length,I.enqueue(M)}}}async function x(g){let I=!0,L=0;for(;I;){I=!1;let U=Date.now()+Math.min(15e3,500*(L-1));(await d({...e,offset:i},g))?.retry&&(I=!0,L++,U<Date.now()-3e5&&(L=0),await new Promise(M=>{setTimeout(M,Math.max(0,U-Date.now()))}))}!o&&!l&&(g.close(),$())}class E extends t{constructor(I,L){super(I,L)}async streamId(){if(p)return p;if(m)throw m;return new Promise((I,L)=>{const U=[],T=()=>{for(const j of U)j()},M=j=>{I(j),T()},z=j=>{L(j||new R("Stream is closed.")),T()};U.push(c(M)),U.push(w(z))})}}return{stream:new E({start(g){x(g)},cancel(g){o=!0,u&&s({eventId:u}),$()}}),addCloseCb:w,closed(){return l}}}class Vn{trySend;WStream;RStream;writeStreams={};startWriteStreamCbs={};readStreamIterators={};log;writeStreamPersistence;activeStreams=new Set;constructor({WStream:e,RStream:n,trySend:s,log:i,writeStreamPersistence:o}){this.WStream=e,this.RStream=n,this.trySend=s,this.log=i,this.writeStreamPersistence=o??{load:async()=>null,save:()=>{},remove:()=>{}}}createWriteStream(e){const{stream:n,addCompleteCb:s}=qn({WStream:this.WStream,startStream:this.startWriteStream.bind(this),appendStream:this.appendStream.bind(this),registerStream:this.registerWriteStream.bind(this),persistence:this.writeStreamPersistence,opts:e});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}createReadStream(e){const{stream:n,addCloseCb:s}=Hn({RStream:this.RStream,opts:e,startStream:this.startReadStream.bind(this),cancelStream:this.cancelReadStream.bind(this)});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}startWriteStream(e){const n=ve();let s=null;const i=new Promise(r=>{s=r});this.startWriteStreamCbs[n]=s;const o={op:"start-stream","client-id":e.clientId,"reconnect-token":e.reconnectToken};return e.ruleParams&&(o["rule-params"]=e.ruleParams),this.trySend(n,o),i}registerWriteStream(e,n){this.writeStreams[e]=n}appendStream({streamId:e,chunks:n,isDone:s,offset:i,abortReason:o}){const r={op:"append-stream","stream-id":e,chunks:n,offset:i,done:!!s};o&&(r["abort-reason"]=o),this.trySend(ve(),r)}onAppendFailed(e){const n=this.writeStreams[e["stream-id"]];n&&n.onAppendFailed()}onStartStreamOk(e){const n=this.startWriteStreamCbs[e["client-event-id"]];if(!n){this.log.info("No stream for start-stream-ok",e);return}n({type:"ok",streamId:e["stream-id"],offset:e.offset}),delete this.startWriteStreamCbs[e["client-event-id"]]}onStreamFlushed(e){const n=e["stream-id"],s=this.writeStreams[n];if(!s){this.log.info("No stream cbs for stream-flushed",e);return}s.onFlush({offset:e.offset,done:e.done}),e.done&&delete this.writeStreams[n]}startReadStream({eventId:e,clientId:n,streamId:s,offset:i,ruleParams:o}){const r={op:"subscribe-stream"};if(!s&&!n)throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");s&&(r["stream-id"]=s),n&&(r["client-id"]=n),i&&(r.offset=i),o&&(r["rule-params"]=o);const a=new Kn;return this.readStreamIterators[e]=a,this.trySend(e,r),a}cancelReadStream({eventId:e}){const n={op:"unsubscribe-stream","subscribe-event-id":e};this.trySend(ve(),n),delete this.readStreamIterators[e]}onStreamAppend(e){const n=e["client-event-id"],s=this.readStreamIterators[n];if(!s){this.log.info("No iterator for read stream",e);return}if(e.error){e.retry?s.push({type:"reconnect"}):s.push({type:"error",error:new R(e.error)}),s.close(),delete this.readStreamIterators[n];return}s.push({type:"append",offset:e.offset,files:e.files,content:e.content,streamId:e["stream-id"]}),e.done&&(s.close(),delete this.readStreamIterators[n])}onConnectionStatusChange(e){for(const n of Object.values(this.startWriteStreamCbs))n({type:"disconnect"});if(this.startWriteStreamCbs={},e!==Qn.AUTHENTICATED)for(const{onDisconnect:n}of Object.values(this.writeStreams))n();else{for(const{onConnectionReconnect:n}of Object.values(this.writeStreams))n();for(const n of Object.values(this.readStreamIterators))n.push({type:"reconnect"}),n.close();this.readStreamIterators={}}}onRecieveError(e){const n=e["original-event"];switch(n.op){case"append-stream":{const s=n["stream-id"];this.writeStreams[s]?.onAppendFailed();break}case"start-stream":{const s=e["client-event-id"],i=this.startWriteStreamCbs[s];i&&(i({type:"error",error:new R(e.message||"Unknown error",e.hint)}),delete this.startWriteStreamCbs[s]);break}case"subscribe-stream":{const s=e["client-event-id"],i=this.readStreamIterators[s];i&&(i.push({type:"error",error:new R(e.message||"Unknown error",e.hint)}),i.close(),delete this.readStreamIterators[s]);break}}}hasActiveStreams(){return this.activeStreams.size>0}}const Qn={AUTHENTICATED:"authenticated"};let Gn=0;const Yn="X-BackendRelay-SSE-Push-Format",Xn="ndjson",Zn=100,es=1e4;class ts{type="sse";initParams=null;sendQueue=[];sendPromise;flushScheduled=!1;supportsNdjson=!1;closeFired=!1;sseInitTimeout=void 0;pushTimeout;pushController=null;ES;messageUrl;conn;url;id;onopen;onmessage;onclose;onerror;constructor(e,n,s){this.id=`${this.type}_${Gn++}`,this.url=n,this.messageUrl=s||this.url,this.ES=e,this.conn=new e(n),this.sseInitTimeout=setTimeout(()=>{this.initParams||this.handleError()},1e4),this.conn.onmessage=i=>{const o=JSON.parse(i.data);if(Array.isArray(o))for(const r of o)this.handleMessage(r);else this.handleMessage(o)},this.conn.onerror=i=>{this.handleError()}}handleMessage(e){if(!this.closeFired){if(e.op==="sse-init"){this.initParams={machineId:e["machine-id"],sessionId:e["session-id"],sseToken:e["sse-token"]},this.onopen&&this.onopen({target:this}),clearTimeout(this.sseInitTimeout);return}this.onmessage&&this.onmessage({target:this,message:e})}}handleError(){if(!this.closeFired)try{this.onerror&&this.onerror({target:this})}finally{this.handleClose()}}handleClose(){this.closeFired||(this.closeFired=!0,clearTimeout(this.sseInitTimeout),clearTimeout(this.pushTimeout),this.sendQueue=[],this.pushController?.abort(),this.pushController=null,this.conn.close(),this.onclose&&this.onclose({target:this}))}post(e,n,s){const i=this.initParams,o=n?[JSON.stringify({machine_id:i?.machineId,session_id:i?.sessionId,sse_token:i?.sseToken}),...e.map(r=>JSON.stringify(r)),""].join(`
2
+ `):JSON.stringify({machine_id:i?.machineId,session_id:i?.sessionId,sse_token:i?.sseToken,messages:e});return fetch(this.messageUrl,{method:"POST",headers:{Accept:"application/x-ndjson, application/json","Content-Type":n?"application/x-ndjson":"application/json"},body:o,signal:s})}async postMessages(e){const n=new AbortController;this.pushController=n,this.pushTimeout=setTimeout(()=>this.handleError(),es);try{let s=await this.post(e,this.supportsNdjson,n.signal);if(this.closeFired||this.supportsNdjson&&(s.status===406||s.status===415)&&(this.supportsNdjson=!1,s=await this.post(e,!1,n.signal),this.closeFired))return;if(!s.ok){this.handleError();return}this.supportsNdjson=s.headers.get(Yn)===Xn}catch{this.handleError()}finally{clearTimeout(this.pushTimeout),this.pushController=null}}async flushQueue(){if(!this.isOpen()||this.sendPromise||!this.sendQueue.length)return;const e=this.sendQueue.splice(0,Zn),n=this.postMessages(e);this.sendPromise=n,n.then(()=>{this.sendPromise=null,this.isOpen()&&this.flushQueue()})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,Promise.resolve().then(()=>{this.flushScheduled=!1,this.flushQueue()}))}send(e){if(!this.isOpen()||!this.initParams)throw this.isConnecting()?new Error("Failed to execute 'send' on 'EventSource': Still in CONNECTING state."):this.conn.readyState===this.ES.CLOSED?new Error("EventSource is already in CLOSING or CLOSED state."):new Error("EventSource is in invalid state.");this.sendQueue.push(e),this.scheduleFlush()}isOpen(){return!this.closeFired&&this.conn.readyState===this.ES.OPEN&&this.initParams!==null}isConnecting(){return!this.closeFired&&(this.conn.readyState===this.ES.CONNECTING||this.conn.readyState===this.ES.OPEN&&this.initParams===null)}close(){this.handleClose()}}function ns(){return globalThis.__backendrelayDbSchemaHashStore=globalThis.__backendrelayDbSchemaHashStore??new WeakMap,globalThis.__backendrelayDbSchemaHashStore}function ss(){return globalThis.__backendrelayDbStore=globalThis.__backendrelayDbStore??{},globalThis.__backendrelayDbStore}ss(),ns();class Gt extends Error{constructor(e,n){super(e),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function ft(t){}function is(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=ft,onError:n=ft,onRetry:s=ft,onComment:i}=t;let o="",r=!0,a,u="",l="";function f(w){const c=r?w.replace(/^\xEF\xBB\xBF/,""):w,[b,S]=rs(`${o}${c}`);for(const d of b)h(d);o=S,r=!1}function h(w){if(w===""){m();return}if(w.startsWith(":")){i&&i(w.slice(w.startsWith(": ")?2:1));return}const c=w.indexOf(":");if(c!==-1){const b=w.slice(0,c),S=w[c+1]===" "?2:1,d=w.slice(c+S);p(b,d,w);return}p(w,"",w)}function p(w,c,b){switch(w){case"event":l=c;break;case"data":u=`${u}${c}
3
+ `;break;case"id":a=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?s(parseInt(c,10)):n(new Gt(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:b}));break;default:n(new Gt(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:c,line:b}));break}}function m(){u.length>0&&e({id:a,event:l||void 0,data:u.endsWith(`
4
+ `)?u.slice(0,-1):u}),a=void 0,u="",l=""}function $(w={}){o&&w.consume&&h(o),r=!0,a=void 0,u="",l="",o=""}return{feed:f,reset:$}}function rs(t){const e=[];let n="",s=0;for(;s<t.length;){const i=t.indexOf("\r",s),o=t.indexOf(`
5
+ `,s);let r=-1;if(i!==-1&&o!==-1?r=Math.min(i,o):i!==-1?i===t.length-1?r=-1:r=i:o!==-1&&(r=o),r===-1){n=t.slice(s);break}else{const a=t.slice(s,r);e.push(a),s=r+1,t[s-1]==="\r"&&t[s]===`
6
+ `&&s++}}return[e,n]}class Yt extends Event{constructor(e,n){var s,i;super(e),this.code=(s=n?.code)!=null?s:void 0,this.message=(i=n?.message)!=null?i:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,n,s){return s(Xt(this),n)}[Symbol.for("Deno.customInspect")](e,n){return e(Xt(this),n)}}function os(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function dt(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(dt).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${dt(t.cause)}`:t.message:`${t}`}function Xt(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Zt=t=>{throw TypeError(t)},ht=(t,e,n)=>e.has(t)||Zt("Cannot "+n),k=(t,e,n)=>(ht(t,e,"read from private field"),n?n.call(t):e.get(t)),D=(t,e,n)=>e.has(t)?Zt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),A=(t,e,n,s)=>(ht(t,e,"write to private field"),e.set(t,n),n),re=(t,e,n)=>(ht(t,e,"access private method"),n),J,he,Ie,Ke,He,Ve,je,$e,Me,ae,Ee,Oe,_e,De,G,pt,yt,mt,en,bt,gt,Ne,wt,St;class Y extends EventTarget{constructor(e,n){var s,i,o;super(),D(this,G),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,D(this,J),D(this,he),D(this,Ie),D(this,Ke),D(this,He),D(this,Ve),D(this,je),D(this,$e),D(this,Me,null),D(this,ae),D(this,Ee),D(this,Oe,null),D(this,_e,null),D(this,De,null),D(this,yt,async r=>{var a;k(this,Ee).reset();const{body:u,redirected:l,status:f,headers:h}=r;if(f===204){re(this,G,Ne).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?A(this,Ie,new URL(r.url)):A(this,Ie,void 0),f!==200){re(this,G,Ne).call(this,`Non-200 status code (${f})`,f);return}if(!(h.get("content-type")||"").startsWith("text/event-stream")){re(this,G,Ne).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(k(this,J)===this.CLOSED)return;A(this,J,this.OPEN);const p=new Event("open");if((a=k(this,De))==null||a.call(this,p),this.dispatchEvent(p),typeof u!="object"||!u||!("getReader"in u)){re(this,G,Ne).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const m=new TextDecoder,$=u.getReader();let w=!0;do{const{done:c,value:b}=await $.read();b&&k(this,Ee).feed(m.decode(b,{stream:!c})),c&&(w=!1,k(this,Ee).reset(),re(this,G,wt).call(this))}while(w)}),D(this,mt,r=>{A(this,ae,void 0),!(r.name==="AbortError"||r.type==="aborted")&&re(this,G,wt).call(this,dt(r))}),D(this,bt,r=>{typeof r.id=="string"&&A(this,Me,r.id);const a=new(k(this,Ve))(r.event||"message",{data:r.data,origin:k(this,Ie)?k(this,Ie).origin:k(this,he).origin,lastEventId:r.id||""});k(this,_e)&&(!r.event||r.event==="message")&&k(this,_e).call(this,a),this.dispatchEvent(a)}),D(this,gt,r=>{A(this,je,r)}),D(this,St,()=>{A(this,$e,void 0),k(this,J)===this.CONNECTING&&re(this,G,pt).call(this)});try{if(e instanceof URL)A(this,he,e);else if(typeof e=="string")A(this,he,new URL(e,as()));else throw new Error("Invalid URL")}catch{throw os("An invalid or illegal string was specified")}A(this,Ee,is({onEvent:k(this,bt),onRetry:k(this,gt)})),A(this,J,this.CONNECTING),A(this,je,3e3),A(this,He,(s=n?.fetch)!=null?s:globalThis.fetch),A(this,Ve,(i=n?.messageEvent)!=null?i:globalThis.MessageEvent),A(this,Ke,(o=n?.withCredentials)!=null?o:!1),re(this,G,pt).call(this)}get readyState(){return k(this,J)}get url(){return k(this,he).href}get withCredentials(){return k(this,Ke)}get onerror(){return k(this,Oe)}set onerror(e){A(this,Oe,e)}get onmessage(){return k(this,_e)}set onmessage(e){A(this,_e,e)}get onopen(){return k(this,De)}set onopen(e){A(this,De,e)}addEventListener(e,n,s){const i=n;super.addEventListener(e,i,s)}removeEventListener(e,n,s){const i=n;super.removeEventListener(e,i,s)}close(){k(this,$e)&&clearTimeout(k(this,$e)),k(this,J)!==this.CLOSED&&(k(this,ae)&&k(this,ae).abort(),A(this,J,this.CLOSED),A(this,ae,void 0))}}J=new WeakMap,he=new WeakMap,Ie=new WeakMap,Ke=new WeakMap,He=new WeakMap,Ve=new WeakMap,je=new WeakMap,$e=new WeakMap,Me=new WeakMap,ae=new WeakMap,Ee=new WeakMap,Oe=new WeakMap,_e=new WeakMap,De=new WeakMap,G=new WeakSet,pt=function(){A(this,J,this.CONNECTING),A(this,ae,new AbortController),k(this,He)(k(this,he),re(this,G,en).call(this)).then(k(this,yt)).catch(k(this,mt))},yt=new WeakMap,mt=new WeakMap,en=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...k(this,Me)?{"Last-Event-ID":k(this,Me)}:void 0},cache:"no-store",signal:(t=k(this,ae))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},bt=new WeakMap,gt=new WeakMap,Ne=function(t,e){var n;k(this,J)!==this.CLOSED&&A(this,J,this.CLOSED);const s=new Yt("error",{code:e,message:t});(n=k(this,Oe))==null||n.call(this,s),this.dispatchEvent(s)},wt=function(t,e){var n;if(k(this,J)===this.CLOSED)return;A(this,J,this.CONNECTING);const s=new Yt("error",{code:e,message:t});(n=k(this,Oe))==null||n.call(this,s),this.dispatchEvent(s),A(this,$e,setTimeout(k(this,St),k(this,je)))},St=new WeakMap,Y.CONNECTING=0,Y.OPEN=1,Y.CLOSED=2,Object.defineProperty(Y,Symbol.for("eventsource.supports-fetch-override"),{value:!0,writable:!1,configurable:!1,enumerable:!1});function as(){const t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}class tn extends Event{data;origin;lastEventId;source;ports;constructor(e,n){super(e),this.data=n?.data??null,this.origin=n?.origin??"",this.lastEventId=n?.lastEventId??"",this.source=n?.source??null,this.ports=n?.ports??[]}initMessageEvent(e,n,s,i,o,r,a,u){}}function cs(t,e,n,s){let i=null,o=!1;const r=[],a=h=>{r.push(h),r.length>100&&r.shift(),i&&(i(),i=null)};t(a);const u=()=>(n(a),Promise.resolve({done:!0,value:void 0}));return e(()=>{o=!0,i&&i(),u()}),{next:async()=>{for(;;){if(s()==="closed"||o)return u();const h=r.shift();if(h)return{value:h,done:!1};await new Promise(m=>{i=m})}},return:u,throw(h){return n(a),Promise.reject(h)},[Symbol.asyncIterator](){return this}}}function ce(t){switch(t.readyState){case t.CLOSED:return"closed";case t.CONNECTING:return"connecting";case t.OPEN:return"open";default:return"connecting"}}function ls(t){let e=null;return{...t,text(){return e||(e=t.text()),e},json(){return e||(e=t.text()),e.then(n=>JSON.parse(n))}}}function nn(t){if(!t)return;const e={};for(const[n,s]of Object.entries(t))e[n]={startCursor:s["start-cursor"],endCursor:s["end-cursor"],hasNextPage:s["has-next-page?"],hasPreviousPage:s["has-previous-page?"]};return e}function us(t,e,n){let s,i=!1;const o=ve(),r=new Y(`${n.apiURI}/admin/subscribe-query?local_connection_id=${o}`,{messageEvent:tn,fetch(c,b){return s=null,fetch(c,{...b,method:"POST",headers:n.headers,body:JSON.stringify({query:t,"inference?":n.inference,versions:{"@backendrelay/admin":de,"@backendrelay/core":de}})}).then(S=>(S.ok||(s=ls(S)),S))}}),a=[],u=[],l=c=>{a.push(c)},f=c=>{a.splice(a.indexOf(c),1)},h=c=>{u.push(c)};e&&l(e);let p=null;function m(c){if(!i)for(const b of a)try{b(c)}catch(S){console.error("Error in subscribeQuery callback",S)}}function $(c){switch(c.op){case"sse-init":{const b=c["machine-id"],S=c["session-id"];p={machineId:b,sessionId:S};break}case"add-query-ok":{m({type:"ok",data:c.result,pageInfo:nn(c["result-meta"]?.["page-info"]),sessionInfo:p});break}case"refresh-ok":{c.computations.length&&m({type:"ok",data:c.computations[0]["instaql-result"],pageInfo:nn(c.computations[0]["result-meta"]?.["page-info"]),sessionInfo:p});break}case"error":{m({type:"error",error:new ie({body:c,status:c.status}),get readyState(){return ce(r)},get isClosed(){return ce(r)==="closed"},sessionInfo:p});break}}}return r.onerror=c=>{if(s)s.text().then(b=>{let S={type:void 0,message:b};try{S=JSON.parse(b)}catch{}m({type:"error",error:new ie({status:s.status,body:S}),get readyState(){return ce(r)},get isClosed(){return ce(r)==="closed"},sessionInfo:p})});else{const b=()=>{m({type:"error",error:new ie({status:c.code||500,body:{type:void 0,message:c.message||"Unknown error in subscribe query."}}),get readyState(){return ce(r)},get isClosed(){return ce(r)==="closed"},sessionInfo:p})};if(r.readyState===Y.CLOSED){b();return}setTimeout(()=>{r.readyState!==Y.OPEN&&b()},5e3)}},r.onmessage=c=>{$(JSON.parse(c.data))},{close:()=>{i=!0;for(const c of u)try{c()}catch(b){console.error("Error in onClose callback",b)}r.close()},[Symbol.iterator]:()=>{throw new Error("subscribeQuery does not support synchronous iteration. Use `for await` instead.")},get sessionInfo(){return p},get readyState(){return ce(r)},get isClosed(){return ce(r)==="closed"},[Symbol.asyncIterator]:cs.bind(this,l,h,f,()=>1)}}var X={},sn;function fs(){if(sn)return X;sn=1,Object.defineProperty(X,"__esModule",{value:!0}),X.parseCookie=a,X.parse=a,X.stringifyCookie=u,X.stringifySetCookie=l,X.serialize=l,X.parseSetCookie=f,X.stringifySetCookie=l,X.serialize=l;const t=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,e=/^[\u0021-\u003A\u003C-\u007E]*$/,n=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,s=/^[\u0020-\u003A\u003D-\u007E]*$/,i=/^-?\d+$/,o=Object.prototype.toString,r=(()=>{const c=function(){};return c.prototype=Object.create(null),c})();function a(c,b){const S=new r,d=c.length;if(d<2)return S;const x=b?.decode||$;let E=0;do{const P=p(c,E,d);if(P===-1)break;const g=h(c,E,d);if(P>g){E=c.lastIndexOf(";",P-1)+1;continue}const I=m(c,E,P);S[I]===void 0&&(S[I]=x(m(c,P+1,g))),E=g+1}while(E<d);return S}function u(c,b){const S=b?.encode||encodeURIComponent,d=[];for(const x of Object.keys(c)){const E=c[x];if(E===void 0)continue;if(!t.test(x))throw new TypeError(`cookie name is invalid: ${x}`);const P=S(E);if(!e.test(P))throw new TypeError(`cookie val is invalid: ${E}`);d.push(`${x}=${P}`)}return d.join("; ")}function l(c,b,S){const d=typeof c=="object"?c:{...S,name:c,value:String(b)},E=(typeof b=="object"?b:S)?.encode||encodeURIComponent;if(!t.test(d.name))throw new TypeError(`argument name is invalid: ${d.name}`);const P=d.value?E(d.value):"";if(!e.test(P))throw new TypeError(`argument val is invalid: ${d.value}`);let g=d.name+"="+P;if(d.maxAge!==void 0){if(!Number.isInteger(d.maxAge))throw new TypeError(`option maxAge is invalid: ${d.maxAge}`);g+="; Max-Age="+d.maxAge}if(d.domain){if(!n.test(d.domain))throw new TypeError(`option domain is invalid: ${d.domain}`);g+="; Domain="+d.domain}if(d.path){if(!s.test(d.path))throw new TypeError(`option path is invalid: ${d.path}`);g+="; Path="+d.path}if(d.expires){if(!w(d.expires)||!Number.isFinite(d.expires.valueOf()))throw new TypeError(`option expires is invalid: ${d.expires}`);g+="; Expires="+d.expires.toUTCString()}if(d.httpOnly&&(g+="; HttpOnly"),d.secure&&(g+="; Secure"),d.partitioned&&(g+="; Partitioned"),d.priority)switch(typeof d.priority=="string"?d.priority.toLowerCase():void 0){case"low":g+="; Priority=Low";break;case"medium":g+="; Priority=Medium";break;case"high":g+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${d.priority}`)}if(d.sameSite)switch(typeof d.sameSite=="string"?d.sameSite.toLowerCase():d.sameSite){case!0:case"strict":g+="; SameSite=Strict";break;case"lax":g+="; SameSite=Lax";break;case"none":g+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${d.sameSite}`)}return g}function f(c,b){const S=b?.decode||$,d=c.length,x=h(c,0,d),E=p(c,0,x),P=E===-1?{name:"",value:S(m(c,0,x))}:{name:m(c,0,E),value:S(m(c,E+1,x))};let g=x+1;for(;g<d;){const I=h(c,g,d),L=p(c,g,I),U=L===-1?m(c,g,I):m(c,g,L),T=L===-1?void 0:m(c,L+1,I);switch(U.toLowerCase()){case"httponly":P.httpOnly=!0;break;case"secure":P.secure=!0;break;case"partitioned":P.partitioned=!0;break;case"domain":P.domain=T;break;case"path":P.path=T;break;case"max-age":T&&i.test(T)&&(P.maxAge=Number(T));break;case"expires":if(!T)break;const M=new Date(T);Number.isFinite(M.valueOf())&&(P.expires=M);break;case"priority":if(!T)break;const z=T.toLowerCase();(z==="low"||z==="medium"||z==="high")&&(P.priority=z);break;case"samesite":if(!T)break;const j=T.toLowerCase();(j==="lax"||j==="strict"||j==="none")&&(P.sameSite=j);break}g=I+1}return P}function h(c,b,S){const d=c.indexOf(";",b);return d===-1?S:d}function p(c,b,S){const d=c.indexOf("=",b);return d<S?d:-1}function m(c,b,S){let d=b,x=S;do{const E=c.charCodeAt(d);if(E!==32&&E!==9)break}while(++d<x);for(;x>d;){const E=c.charCodeAt(x-1);if(E!==32&&E!==9)break;x--}return c.slice(d,x)}function $(c){if(c.indexOf("%")===-1)return c;try{return decodeURIComponent(c)}catch{return c}}function w(c){return o.call(c)==="[object Date]"}return X}var ds=fs();const hs={"https://api.backendrelay.com":{keys:[{kty:"OKP",crv:"Ed25519",alg:"EdDSA",use:"sig",kid:"1034696293",x:"N-C41432STKAKkXAWmeIOXMnZcGRR1b9u1L3bTVqI_o"}]},"http://localhost:8888":{keys:[{kty:"OKP",crv:"Ed25519",alg:"EdDSA",use:"sig",kid:"503090235",x:"qrSkwDaMITRMF9nOgpueqxgaAiuFmJperYE3mkyl8Ow"}]}};function ps(t){if(t.kty==="OKP"&&t.crv==="Ed25519")return{name:"Ed25519"};if(t.kty==="EC")return{name:"ECDSA",namedCurve:t.crv};if(t.kty==="RSA")return{name:"RSASSA-PKCS1-v1_5",hash:{RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"}[t.alg]||"SHA-256"};throw new Error(`Unsupported JWK configuration: kty=${t.kty}, crv=${t.crv}`)}async function ys(t){const e=ps(t),n=await crypto.subtle.importKey("jwk",t,e,!1,["verify"]);return{alg:e,key:n}}function ms(t,e,n,s){return crypto.subtle.verify(t,e,n,s)}function bs(t){const e=new Uint8Array(Math.ceil(t.length/2));for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(n*2,n*2+2),16);return e}function gs(t){let e,n,s;for(const o of t.split(",")){const[r,a]=o.split("=");switch(r){case"t":{e=a;break}case"kid":{n=a;break}case"v1":{s=a;break}}}const i=[];if(e||i.push("t"),n||i.push("kid"),s||i.push("v1"),i.length||!e||!n||!s)throw new R("Invalid BackendRelay-Signature header.",{header:t,missingKeys:i});return{t:e,kid:n,v1:s}}function ws(t,e,n){if(Math.floor(t.getTime()/1e3)-parseInt(e,10)>n)throw new R("Webhook signature is too old",{tolerance:n,receivedAt:t,t:e})}const Le=new Map,Re=new Map,rn=6e4,Ss=32;function vs(t){let e=Re.get(t);if(e?Re.delete(t):e={keys:null,fetchedAt:0,failedAt:0,inflight:null},Re.set(t,e),Re.size>Ss){const n=Re.keys().next().value;if(n!==void 0){Re.delete(n);const s=`${n}:`;for(const i of Le.keys())i.startsWith(s)&&Le.delete(i)}}return e}const ks=300;async function Is(t,e){const n=await e.text();try{const s=JSON.parse(n);return t(new ie({status:e.status,body:s}))}catch{return t(new ie({status:e.status,body:{type:void 0,message:n}}))}}const $s=async(t,e)=>{const n={...e?.headers||{},"BackendRelay-Core-Version":de},s=await fetch(t,{...e,headers:n});return s.status===200?s.json():Is(i=>Promise.reject(i),s)};function on(t){return t?new Date(t):null}function Ce(t){return{id:t.id,sink:t.sink,namespaces:t.namespaces??[],actions:t.actions,status:t.status,disabledReason:t.disabled_reason??null,createdAt:new Date(t.created_at),updatedAt:new Date(t.updated_at)}}function Es(t){return{attemptAt:on(t["attempt-at"]),durationMs:t["duration-ms"]??null,success:t["success?"]??null,statusCode:t["status-code"]??null,responseText:t["response-text"]??null,errorType:t["error-type"]??null,errorMessage:t["error-message"]??null}}function vt(t){return{isn:t.isn,status:t.status,attempts:t.attempts?t.attempts.map(Es):null,nextAttemptAfter:on(t.next_attempt_after),createdAt:new Date(t.created_at),updatedAt:new Date(t.updated_at)}}class Os{#e;#i;#t;#n;#r;constructor(e){this.#e=e.appId,this.#i=e.apiURI,this.#t=e.token,this.#n=e.withAuth,this.#r=e.jsonFetch}#s(e,n){if(!this.#e)throw new R("appId is required to manage webhooks. Pass it to the Webhooks constructor.");const s=i=>{const o={method:n?.method,headers:{authorization:`Bearer ${i}`,"content-type":"application/json"}};return n?.body!==void 0&&(o.body=JSON.stringify(n.body)),this.#r(`${this.#i}${e}`,o)};if(this.#n)return this.#n(s);if(!this.#t)throw new R("A token is required to manage webhooks. Pass `adminToken` or `token` to the Webhooks constructor.");return s(this.#t)}async list(){return((await this.#s(`/dash/apps/${this.#e}/webhooks`)).webhooks||[]).map(Ce)}async create(e){const n=await this.#s(`/dash/apps/${this.#e}/webhooks`,{method:"POST",body:e});return Ce(n.webhook)}async update(e,n){const s=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}`,{method:"POST",body:n});return Ce(s.webhook)}async delete(e){const n=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}`,{method:"DELETE"});return Ce(n.webhook)}async enable(e){const n=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}/enable`,{method:"POST",body:{}});return Ce(n.webhook)}async disable(e,n){const s=n?.reason?{reason:n.reason}:{},i=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}/disable`,{method:"POST",body:s});return Ce(i.webhook)}async listEvents(e,n){const s=n?.after?`?after=${encodeURIComponent(n.after)}`:"",i=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}/events${s}`);return{events:(i.events||[]).map(vt),pageInfo:{startCursor:i.pageInfo?.startCursor??null,endCursor:i.pageInfo?.endCursor??null,hasNextPage:!!i.pageInfo?.hasNextPage}}}async getEvent(e,n){const s=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}/events/${n}`);return vt(s.event)}async getPayload(e,n){return this.#s(`/webhooks/payload/${this.#e}/${e}/${n}`)}async resendEvent(e,n){const s=await this.#s(`/dash/apps/${this.#e}/webhooks/${e}/events/${n}`,{method:"POST",body:{}});return vt(s.event)}}class kt{appId;schema;#e;apiURI;#i;manager;static helpers(){function e(...s){if(s.length===2)return{$default:s[1]};const[i,o,r]=s;return{[i]:{[o]:r}}}function n(...s){const i={};for(const o of s)for(const r of Object.keys(o))r==="$default"?i.$default=o.$default:i[r]={...i[r],...o[r]};return i}return{typedHandlers:e,combineHandlers:n}}helpers(){return kt.helpers()}constructor(e,n){this.appId=e.appId,this.schema=e.schema,this.#e=e.adminToken||e.token,this.apiURI=Vt(e.apiURI,"BackendRelay webhooks"),this.#i=n||$s,this.manager=new Os({appId:this.appId,apiURI:this.apiURI,token:this.#e,withAuth:e.withAuth,jsonFetch:this.#i})}async fetchJwks(){return await this.#i(`${this.apiURI}/.well-known/webhooks/jwks.json`)}async keyOfKid(e){const n=`${this.apiURI}:${e}`,s=Le.get(n);if(s&&(s.exp===null||Date.now()<s.exp))return s;s&&Le.delete(n);const i=hs[this.apiURI]?.keys.find(a=>a.kid===e)||(await this.#t(s!==void 0)).find(a=>a.kid===e);if(!i)throw new R("Could not find matching signing key",{kid:e});const o=await ys(i),r=typeof i.exp=="number"?i.exp*1e3:null;return Le.set(n,{...o,exp:r}),o}async#t(e=!1){const n=vs(this.apiURI),s=Date.now();if(!e&&n.keys&&s-n.fetchedAt<rn)return n.keys;if(s-n.failedAt<rn)throw new R("Could not fetch issuer signing keys",{issuer:this.apiURI});return n.inflight||(n.inflight=this.fetchJwks().then(i=>{const o=i?.keys??[];return n.keys=o,n.fetchedAt=Date.now(),o}).catch(i=>{throw n.failedAt=Date.now(),i}).finally(()=>{n.inflight=null})),n.inflight}async validate(e,n,s){const i=s?.receivedAt||new Date,{t:o,kid:r,v1:a}=gs(e),u=s?.tolerance??ks;ws(i,o,u);const{alg:l,key:f}=await this.keyOfKid(r),h=typeof n=="function"?await n():n,p=new TextEncoder().encode(`${o}.${h}`);if(!await ms(l,f,bs(a),p))throw new R("BackendRelay Signature did not validate",{header:e});const $=JSON.parse(h);if(typeof $!="object"||typeof $.payloadUrl!="string"||typeof $.token!="string")throw new R("Invalid webhook body, expected an object with payloadUrl and token fields",{body:$});return $}async validateRequest(e,n){const s=e.headers.get("BackendRelay-Signature");if(!s)throw new R("Request is missing BackendRelay-Signature header");return this.validate(s,()=>e.text(),n)}fetchPayloads({payloadUrl:e,token:n}){return this.#i(e,{headers:{Authorization:`Bearer ${n}`,accept:"application/json"}})}async processPayload(e,n){const s=[];for(const i of n.data){const{namespace:o,action:r}=i,a=e?.[o]?.[r]||e?.[o]?.$default||e?.$default;a&&s.push(a(i))}await Promise.all(s)}async processRequest(e,n,s){const i=await this.validateRequest(n,s),o=await this.fetchPayloads(i);await this.processPayload(e,o)}async processNodeRequest(e,n,s){let i,o=!1,r=s?.body??n.rawBody??n.body;if(r!=null&&typeof r.then=="function"&&(r=await r),typeof r=="string")i=r;else if(r instanceof Uint8Array)i=new TextDecoder("utf-8").decode(r);else if(r!=null&&typeof r=="object")try{i=JSON.stringify(r),o=!0}catch{throw new R("Webhook request body has already been parsed and could not be re-serialized. Configure this route to receive the raw request body instead of parsed JSON.")}else if(n[Symbol.asyncIterator]){const h=new TextEncoder,p=[];for await(const c of n)p.push(typeof c=="string"?h.encode(c):c);let m=0;for(const c of p)m+=c.byteLength;const $=new Uint8Array(m);let w=0;for(const c of p)$.set(c,w),w+=c.byteLength;i=new TextDecoder("utf-8").decode($)}else throw new R("Could not read the webhook request body. Pass a Node IncomingMessage with an unconsumed stream, or set `req.body` to the raw bytes (Buffer/Uint8Array) or string.");const a=typeof n.headers.host=="string"?n.headers.host:"localhost",u=new URL(n.url??"/",`https://${a}`),l=new Headers;for(const[h,p]of Object.entries(n.headers))typeof p=="string"?l.set(h,p):Array.isArray(p)&&l.set(h,p.join(", "));const f=new Request(u,{method:n.method??"POST",headers:l,body:i});try{await this.processRequest(e,f,s)}catch(h){throw o&&h instanceof R&&h.message==="BackendRelay Signature did not validate"?new R("Webhook signature did not validate. The request body was re-serialized from a parsed JSON object, which can produce different bytes than the server signed. Configure this route to receive the raw request body instead of parsed JSON.",{hint:h.hint}):h}}}function _s(t){return{...t,apiURI:Vt(t.apiURI,"BackendRelay admin SDK")}}function Rs(t,e){return"email"in e?t["as-email"]=e.email:"token"in e?t["as-token"]=e.token:"guest"in e&&(t["as-guest"]="true"),t}function Cs(t,e){if(!(e&&("token"in e||"guest"in e))&&!t.adminToken)throw e&&"email"in e?new Error("Admin token required. To impersonate users with an email you must pass `adminToken` to `init`."):new Error("Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.")}function C(t,e){Cs(t,e);const{adminToken:n,appId:s}=t,i={"content-type":"application/json","app-id":s};return n&&(i.authorization=`Bearer ${n}`),t.requestId&&(i["x-request-id"]=t.requestId),e?Rs(i,e):i}function xs(){return fetch.__nextPatched&&!globalThis[Symbol.for("next-patch")]}function Ts(){return xs()?{cache:"no-store"}:{}}async function As(t,e){const n=await e.text();try{const s=JSON.parse(n);return t(new ie({status:e.status,body:s}))}catch{return t(new ie({status:e.status,body:{type:void 0,message:n}}))}}async function Fe(t,e,n){try{const s=Ts(),i={...e?.headers||{},"BackendRelay-Admin-Version":de,"BackendRelay-Core-Version":de},o=await fetch(t,{...s,...e,headers:i});if(o.status===200){const r=await o.json();return Promise.resolve(r)}return await As(r=>Promise.reject(r),o)}catch(s){throw An(n,s),s}}function Ps(t){return class{source;static OPEN=Y.OPEN;static CONNECTING=Y.CONNECTING;static CLOSED=Y.CLOSED;url;constructor(n){this.url=n,this.source=this.#e(n)}get onopen(){return this.source.onopen}set onopen(n){this.source.onopen=n}get onmessage(){return this.source.onmessage}set onmessage(n){this.source.onmessage=n}get onerror(){return this.source.onerror}set onerror(n){this.source.onerror=n}get readyState(){return this.source.readyState}close(){this.source.close()}#e(n){return new Y(n,{messageEvent:tn,fetch(i,o){return fetch(i,{...o,method:"POST",headers:t.headers,body:JSON.stringify({"inference?":t.inference,versions:{"@backendrelay/admin":de,"@backendrelay/core":de}})})}})}}}function Us(t){(!t.appId||!Se(t.appId))&&console.warn("warning: BackendRelay Admin DB must be initialized with a valid appId. Received: "+JSON.stringify(t.appId));const e={...t,appId:t.appId?.trim(),adminToken:t.adminToken?.trim(),useDateObjects:t.useDateObjects??!1};return new It(e)}function an(t){return(Array.isArray(t)?t:[t]).flatMap(Tn)}class js{config;_fetch=(e,n)=>Fe(e,n,this.config.onError);constructor(e){this.config=e}async getPresence(e,n){return(await this._fetch(`${this.config.apiURI}/admin/rooms/presence?app_id=${this.config.appId}&room-type=${String(e)}&room-id=${n}`,{method:"GET",headers:C(this.config)})).sessions||{}}}class Ms{config;_fetch=(e,n)=>Fe(e,n,this.config.onError);constructor(e){this.config=e,this.createToken=this.createToken.bind(this)}generateMagicCode=async e=>this._fetch(`${this.config.apiURI}/admin/magic_code?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config),body:JSON.stringify({email:e})});sendMagicCode=async e=>this._fetch(`${this.config.apiURI}/admin/send_magic_code?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config),body:JSON.stringify({email:e})});verifyMagicCode=async(e,n)=>{const{user:s}=await this._fetch(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config),body:JSON.stringify({email:e,code:n})});return s};checkMagicCode=async(e,n,s)=>{const i=await this._fetch(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config),body:JSON.stringify({email:e,code:n,...s?.extraFields?{"extra-fields":s.extraFields}:{}})});return{user:i.user,created:i.created}};async createToken(e){const n=typeof e=="string"?{email:e}:e;return(await this._fetch(`${this.config.apiURI}/admin/refresh_tokens?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config),body:JSON.stringify(n)})).user.refresh_token}verifyToken=async e=>(await this._fetch(`${this.config.apiURI}/runtime/auth/verify_refresh_token?app_id=${this.config.appId}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({"app-id":this.config.appId,"refresh-token":e})})).user;getUser=async e=>{const n=new URLSearchParams(Object.entries(e)).toString();return(await this._fetch(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${n}`,{method:"GET",headers:C(this.config)})).user};deleteUser=async e=>{const n=new URLSearchParams(Object.entries(e)).toString();return(await this._fetch(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${n}`,{method:"DELETE",headers:C(this.config)})).deleted};async signOut(e){const n=typeof e=="string"?{email:e}:e,s=this.config;await this._fetch(`${s.apiURI}/admin/sign_out?app_id=${this.config.appId}`,{method:"POST",headers:C(s),body:JSON.stringify(n)})}getUserFromRequest=async(e,n)=>{const s=e.headers.get("cookie")||"",i=ds.parseCookie(s),o="backendrelay_user_"+this.config.appId;if(!i[o])return null;const r=i[o],a=JSON.parse(r);return a?.refresh_token?n?.disableValidation?a:await this.verifyToken(a.refresh_token):null}}const cn=t=>t&&typeof t=="object"&&typeof t.pipe=="function"&&typeof t.read=="function",Ds=t=>t&&typeof t.getReader=="function";function ln(t){return/^[\x20-\x7e]*$/.test(t)}class un{config;impersonationOpts;_fetch=(e,n)=>Fe(e,n,this.config.onError);constructor(e,n){this.config=e,this.impersonationOpts=n}uploadFile=async(e,n,s={})=>{const i={...C(this.config,this.impersonationOpts)};ln(e)&&(i.path=e),s.contentDisposition&&ln(s.contentDisposition)&&(i["content-disposition"]=s.contentDisposition),delete i["content-type"],s.contentType&&(i["content-type"]=s.contentType);let o;if(cn(n)&&(o="half"),cn(n)||Ds(n)){if(!s.fileSize)throw new Error("fileSize is required in metadata when uploading streams");i["content-length"]=s.fileSize.toString()}let r={method:"PUT",headers:i,body:n,...o&&{duplex:o}},a=`${this.config.apiURI}/admin/storage/upload?app_id=${encodeURIComponent(this.config.appId)}&path=${encodeURIComponent(e)}`;return s.contentDisposition&&(a+=`&content-disposition=${encodeURIComponent(s.contentDisposition)}`),this._fetch(a,r)};delete=async e=>this._fetch(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}&filename=${encodeURIComponent(e)}`,{method:"DELETE",headers:C(this.config,this.impersonationOpts)});deleteMany=async e=>this._fetch(`${this.config.apiURI}/admin/storage/files/delete?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify({filenames:e})});upload=async(e,n,s={})=>{const{data:i}=await this._fetch(`${this.config.apiURI}/admin/storage/signed-upload-url?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config),body:JSON.stringify({app_id:this.config.appId,filename:e})}),o={},r=s.contentType;r&&(o["Content-Type"]=r);const{ok:a}=await fetch(i,{method:"PUT",body:n,headers:o});return a};list=async()=>{const{data:e}=await this._fetch(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}`,{method:"GET",headers:C(this.config)});return e};getDownloadUrl=async e=>{const{data:n}=await this._fetch(`${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(e)}`,{method:"GET",headers:C(this.config)});return n}}class Ns{#e;constructor(e){this.#e=e}createReadStream=e=>this.#e().createReadStream(e);createWriteStream=e=>this.#e().createWriteStream(e)}function Ls(t,e=console){return{info:t?(...n)=>e.info(...n):()=>{},debug:t?(...n)=>e.debug(...n):()=>{},error:t?(...n)=>e.error(...n):()=>{}}}class It{config;auth;storage;streams;rooms;impersonationOpts;webhooks;hatchet;#e=null;#i=0;#t=null;#n;_fetch=(e,n)=>Fe(e,n,this.config.onError);tx=Dt();constructor(e){this.config=_s(e),this.auth=new Ms(this.config),this.storage=new un(this.config,this.impersonationOpts),this.streams=new Ns(this.#l.bind(this)),this.rooms=new js(this.config),this.webhooks=new kt(this.config,(n,s)=>Fe(n,s,this.config.onError)),this.hatchet={credentials:()=>this._fetch(`${this.config.apiURI}/dash/apps/${this.config.appId}/hatchet`,{headers:C(this.config,this.impersonationOpts)})},this.#n=Ls(!!this.config.verbose,this.config.logger)}asUser=e=>{const n=new It({...this.config});return n.impersonationOpts=e,n.storage=new un(this.config,e),n};query=(e,n={})=>{e&&n&&"ruleParams"in n&&(e={$$ruleParams:n.ruleParams,...e}),this.config.disableValidation||Bt(e,this.config.schema);const s=n.fetchOpts||{},i=s.headers||{};return this._fetch(`${this.config.apiURI}/admin/query?app_id=${this.config.appId}`,{...s,method:"POST",headers:{...i,...C(this.config,this.impersonationOpts)},body:JSON.stringify({query:e,"inference?":!!this.config.schema})})};versions=async e=>(await this._fetch(`${this.config.apiURI}/admin/versions?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify({"entity-ids":e})})).versions??{};log=async(e,n)=>{await this._fetch(`${this.config.apiURI}/admin/logs?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify({"request-id":n??void 0,entries:e})})};trace=e=>this._fetch(`${this.config.apiURI}/admin/traces/${encodeURIComponent(e)}?app_id=${this.config.appId}`,{method:"GET",headers:C(this.config,this.impersonationOpts)});aggregate=e=>this._fetch(`${this.config.apiURI}/admin/aggregate?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify({etype:e.etype,filters:e.filters??{},"group-by":e.groupBy,aggregate:{field:e.field,sum:e.sum,avg:e.avg,min:e.min,max:e.max}})});nearest=e=>this._fetch(`${this.config.apiURI}/admin/nearest?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify({etype:e.etype,attr:e.attr,vector:e.vector,limit:e.limit??10})});subscribeQuery(e,n,s={}){e&&s&&"ruleParams"in s&&(e={$$ruleParams:s.ruleParams,...e}),this.config.disableValidation||Bt(e,this.config.schema);const r={...(s.fetchOpts||{}).headers||{},...C(this.config,this.impersonationOpts)},a=!!this.config.schema;return us(e,n,{headers:r,inference:a,apiURI:this.config.apiURI})}transact=(e,n)=>n&&"enqueue"in n?Promise.reject(new Error("Transaction options are no longer supported. Use db.transact(chunks).")):(this.config.disableValidation||Wn(e,this.config.schema),this._fetch(`${this.config.apiURI}/admin/transact?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify({steps:an(e),"throw-on-missing-attrs?":!!this.config.schema,conditions:n?.conditions})}));debugQuery=async(e,n)=>{e&&n&&"ruleParams"in n&&(e={$$ruleParams:n.ruleParams,...e});const s={query:e,"rules-override":n?.rules,"inference?":n?.cardinalityInference??!!this.config.schema};n?.ip&&(s["ip-override"]=n.ip),n?.origin&&(s["origin-override"]=n.origin);const i=await this._fetch(`${this.config.apiURI}/admin/query_perms_check?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify(s)});return{result:i.result,checkResults:i["check-results"]}};debugTransact=(e,n)=>{const s={steps:an(e),"rules-override":n?.rules,"dangerously-commit-tx":n?.__dangerouslyCommit};return n?.ip&&(s["ip-override"]=n.ip),n?.origin&&(s["origin-override"]=n.origin),this._fetch(`${this.config.apiURI}/admin/transact_perms_check?app_id=${this.config.appId}`,{method:"POST",headers:C(this.config,this.impersonationOpts),body:JSON.stringify(s)})};#r(){this.#e&&this.#e.close();const e={...C(this.config,this.impersonationOpts)},n=!!this.config.schema,s=Ps({headers:e,inference:n}),i=new ts(s,`${this.config.apiURI}/admin/sse?app_id=${this.config.appId}`,`${this.config.apiURI}/admin/sse/push?app_id=${this.config.appId}`);return i.onopen=this.#u,i.onmessage=this.#p,i.onclose=this.#f,i.onerror=this.#d,this.#e=i,i}#s(){return this.#e||this.#r()}#a(e,n){const s=this.#s();this.#n.info("[send]",e,n,{isOpen:s.isOpen()}),s.isOpen()&&s.send({"client-event-id":e,...n})}#c(){this.#s();const e=new Vn({WStream:this.config.WritableStream||WritableStream,RStream:this.config.ReadableStream||ReadableStream,trySend:(n,s)=>{this.#a(n,s)},log:this.#n});return this.#t=e,e}#l(){return this.#t||this.#c()}#u=e=>{if(e.target!==this.#e){this.#n.info("[socket][open]",e.target.id,"skip; this is no longer the current transport");return}this.#n.info("[socket][open]",e.target.id),this.#i=0,this.#t?.onConnectionStatusChange("authenticated")};#f=e=>{if(e.target!==this.#e){this.#n.info("[socket][close]",e.target.id,"skip; this is no longer the current transport");return}this.#n.info("[socket][close]",e.target.id),this.#t?.onConnectionStatusChange("closed"),this.#e&&(this.#e=null,this.#o()||(setTimeout(()=>this.#s(),this.#i),this.#i=Math.min(15e3,Math.max(this.#i,500)*2)))};#d=e=>{if(e.target!==this.#e){this.#n.info("[socket][error]",e.target.id,"skip; this is no longer the current transport");return}this.#n.info("[socket][error]",e.target.id),this.#t?.onConnectionStatusChange("closed")};#o(){return!this.#t||!this.#t.hasActiveStreams()}#h(){if(this.#e&&this.#o()){const e=this.#e;this.#n.info("cleaning up unused socket",e.id),this.#e=null,e.close()}}#p=e=>{if(e.target!==this.#e){this.#n.info("[socket][message]",e.target.id,"skip; this is no longer the current transport");return}const n=e.message;switch(this.#n.info("[receive]",n),n.op){case"start-stream-ok":{this.#t?.onStartStreamOk(n);break}case"stream-flushed":{this.#t?.onStreamFlushed(n);break}case"append-failed":{this.#t?.onAppendFailed(n);break}case"stream-append":{this.#t?.onStreamAppend(n);break}case"error":{switch(n["original-event"]?.op){case"start-stream":case"append-stream":case"subscribe-stream":case"unsubscribe-stream":{this.#t?.onRecieveError(n);break}}break}}this.#h()}}var Qe={};function fn(t,e){e.catch(n=>{console.error(`[resumable-stream] stream '${t}' stopped: ${n}`)})}function Ge(t){let e=t;return new TransformStream({transform(n,s){if(!e){s.enqueue(n);return}if(e>n.length){e-=n.length;return}const i=n.slice(e);e=0,s.enqueue(i)}})}function Fs(t){const e=t.appId||Qe.BACKENDRELAY_APP_ID||Qe.NEXT_PUBLIC_BACKENDRELAY_APP_ID;if(!e)throw new Error("Missing appId. Pass it as an argument to createResumableStreamContext or set either the BACKENDRELAY_APP_ID or NEXT_PUBLIC_BACKENDRELAY_APP_ID environment variable.");const n=t.adminToken||Qe.BACKENDRELAY_APP_ADMIN_TOKEN;if(!n)throw new Error("Missing adminToken. Pass it as an argument to createResumableStreamContext or set the BACKENDRELAY_APP_ADMIN_TOKEN environment variable.");const s={appId:e,adminToken:n},i=t.apiURI||Qe.BACKENDRELAY_API_URI;i&&(s.apiURI=i),t.verbose&&(s.verbose=t.verbose);const o=Us(s);async function r(f,h,p){const m=o.streams.createWriteStream({clientId:f,waitUntil:t.waitUntil??void 0});try{const $=await m.streamId(),w=h();fn(f,w.pipeTo(m));const c=o.streams.createReadStream({streamId:$});return p?c.pipeThrough(Ge(p)):c}catch{const w=o.streams.createReadStream({clientId:f});return p?w.pipeThrough(Ge(p)):w}}async function a(f,h){const p=o.streams.createReadStream({clientId:f});try{await p.streamId()}catch(m){if(m instanceof R&&m.hint?.errors?.[0]?.message==="Stream is missing.")return;throw m}return h?p.pipeThrough(Ge(h)):p}async function u(f,h,p){const m=h(),$=o.streams.createWriteStream({clientId:f,waitUntil:t.waitUntil??void 0});await $.streamId(),fn(f,m.pipeTo($));const w=o.streams.createReadStream({clientId:f});return p?w.pipeThrough(Ge(p)):w}async function l(f){const p=(await o.query({$streams:{$:{where:{clientId:f}}}}))?.$streams?.[0];return p?.done?"DONE":p?!0:null}return{resumableStream:r,resumeExistingStream:a,createNewResumableStream:u,hasExistingStream:l}}we.createResumableStreamContext=Fs,Object.defineProperty(we,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@backendrelay/resumable-stream",
3
+ "version": "2.0.0",
4
+ "description": "BackendRelay's drop-in replacement for Vercel's resumable-stream package.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/orenaksakal/backendrelay",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/orenaksakal/backendrelay.git",
10
+ "directory": "client/packages/resumable-stream"
11
+ },
12
+ "type": "module",
13
+ "main": "./dist/commonjs/index.js",
14
+ "types": "./dist/commonjs/index.d.ts",
15
+ "module": "./dist/esm/index.js",
16
+ "unpkg": "standalone/index.umd.js",
17
+ "exports": {
18
+ "./package.json": "./package.json",
19
+ ".": {
20
+ "import": {
21
+ "types": "./dist/esm/index.d.ts",
22
+ "default": "./dist/esm/index.js"
23
+ },
24
+ "require": {
25
+ "types": "./dist/commonjs/index.d.ts",
26
+ "default": "./dist/commonjs/index.js"
27
+ }
28
+ }
29
+ },
30
+ "tshy": {
31
+ "selfLink": false,
32
+ "main": true,
33
+ "module": true,
34
+ "project": "./tsconfig.json",
35
+ "exports": {
36
+ "./package.json": "./package.json",
37
+ ".": "./src/index.ts"
38
+ }
39
+ },
40
+ "dependencies": {
41
+ "@backendrelay/admin": "2.0.0"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public",
45
+ "registry": "https://registry.npmjs.org/"
46
+ }
47
+ }
@@ -0,0 +1,34 @@
1
+ # @backendrelay/rules
2
+
3
+ TypeScript helpers that compile to BackendRelay permission CEL. Use them in
4
+ `backendrelay.perms.ts` with `satisfies BackendRelayRules`; the values are
5
+ ordinary strings and the server validates them on push.
6
+
7
+ ```ts
8
+ import type { BackendRelayRules } from '@backendrelay/core';
9
+ import { r } from '@backendrelay/rules';
10
+
11
+ const rules = {
12
+ posts: {
13
+ allow: {
14
+ view: r.auth(),
15
+ create: r.creator('authorId'),
16
+ update: r.owner('authorId'),
17
+ delete: r.owner('authorId'),
18
+ $default: r.false,
19
+ },
20
+ },
21
+ $default: { allow: { $default: r.false } },
22
+ } satisfies BackendRelayRules;
23
+ ```
24
+
25
+ Helpers:
26
+
27
+ - `r.auth()`, `r.true`, `r.false`
28
+ - `r.eq`, `r.ne`, `r.gt`, `r.gte`, `r.lt`, `r.lte`, `r.matches`
29
+ - `r.and(...)`, `r.or(...)`, `r.not(...)`
30
+ - `r.owner(field = 'ownerId')`, `r.creator(field = 'ownerId')`
31
+ - `r.has(path)`, `r.inList(value, values)`
32
+
33
+ Nested boolean expressions are parenthesized so `and`/`or` precedence is
34
+ unambiguous.
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Helpers that compile to BackendRelay permission CEL. The values are plain
3
+ * strings, so they work with `satisfies BackendRelayRules` and are validated by
4
+ * the server when the rules are pushed.
5
+ */
6
+ export declare const cel: {
7
+ true: string;
8
+ false: string;
9
+ /** `auth.id != null` */
10
+ auth: () => string;
11
+ /** `left == right` */
12
+ eq: (left: string, right: string) => string;
13
+ /** `left != right` */
14
+ ne: (left: string, right: string) => string;
15
+ gt: (left: string, right: string) => string;
16
+ gte: (left: string, right: string) => string;
17
+ lt: (left: string, right: string) => string;
18
+ lte: (left: string, right: string) => string;
19
+ /** `left.matches('pattern')` */
20
+ matches: (left: string, pattern: string) => string;
21
+ /** `path != null` — CEL's null check for a field. */
22
+ has: (path: string) => string;
23
+ /** `has(path)` — CEL's presence macro, safe for unset fields. */
24
+ exists: (path: string) => string;
25
+ /** `value in [a, b, c]` */
26
+ inList: (value: string, values: string[]) => string;
27
+ and: (...parts: string[]) => string;
28
+ or: (...parts: string[]) => string;
29
+ not: (part: string) => string;
30
+ /** `auth.id != null && auth.id == data.ownerId` */
31
+ owner: (field?: string) => string;
32
+ /** `auth.id != null && newData.ownerId == auth.id` */
33
+ creator: (field?: string) => string;
34
+ };
35
+ export declare const r: {
36
+ true: string;
37
+ false: string;
38
+ /** `auth.id != null` */
39
+ auth: () => string;
40
+ /** `left == right` */
41
+ eq: (left: string, right: string) => string;
42
+ /** `left != right` */
43
+ ne: (left: string, right: string) => string;
44
+ gt: (left: string, right: string) => string;
45
+ gte: (left: string, right: string) => string;
46
+ lt: (left: string, right: string) => string;
47
+ lte: (left: string, right: string) => string;
48
+ /** `left.matches('pattern')` */
49
+ matches: (left: string, pattern: string) => string;
50
+ /** `path != null` — CEL's null check for a field. */
51
+ has: (path: string) => string;
52
+ /** `has(path)` — CEL's presence macro, safe for unset fields. */
53
+ exists: (path: string) => string;
54
+ /** `value in [a, b, c]` */
55
+ inList: (value: string, values: string[]) => string;
56
+ and: (...parts: string[]) => string;
57
+ or: (...parts: string[]) => string;
58
+ not: (part: string) => string;
59
+ /** `auth.id != null && auth.id == data.ownerId` */
60
+ owner: (field?: string) => string;
61
+ /** `auth.id != null && newData.ownerId == auth.id` */
62
+ creator: (field?: string) => string;
63
+ };
64
+ type SchemaShape = {
65
+ entities: Record<string, {
66
+ attrs: Record<string, unknown>;
67
+ }>;
68
+ };
69
+ type EntityName<S extends SchemaShape> = keyof S['entities'] & string;
70
+ type AttrName<S extends SchemaShape, E extends EntityName<S>> = (keyof S['entities'][E]['attrs'] & string) | 'id';
71
+ type AttrValue<D> = D extends {
72
+ readonly __valueType?: infer V;
73
+ } ? V : unknown;
74
+ type PathValue<S extends SchemaShape, E extends EntityName<S>, K extends AttrName<S, E>> = K extends 'id' ? string : AttrValue<S['entities'][E]['attrs'][K]>;
75
+ /** A CEL path string branded with the attribute's value type. */
76
+ export type CelPath<P extends string, V> = P & {
77
+ readonly __celValue?: V;
78
+ };
79
+ type AuthPaths<S extends SchemaShape> = {
80
+ [K in AttrName<S, '$users'>]: CelPath<`auth.${K}`, PathValue<S, '$users', K>>;
81
+ };
82
+ type DataPaths<S extends SchemaShape, E extends EntityName<S>> = {
83
+ [K in AttrName<S, E>]: CelPath<`data.${K}`, PathValue<S, E, K>>;
84
+ };
85
+ type NewDataPaths<S extends SchemaShape, E extends EntityName<S>> = {
86
+ [K in AttrName<S, E>]: CelPath<`newData.${K}`, PathValue<S, E, K>>;
87
+ };
88
+ type CelValue<P extends string> = P extends {
89
+ readonly __celValue?: infer V;
90
+ } ? unknown extends V ? string : V : string;
91
+ /**
92
+ * Schema-aware rule helpers. Pass the app schema type and use property access
93
+ * for paths: `auth.isPro`, `table('feedbacks').data.ownerId`.
94
+ *
95
+ * @example
96
+ * const t = typedCel<typeof schema>();
97
+ * t.auth.isPro; // "auth.isPro"
98
+ * t.table('feedbacks').data.ownerId; // "data.ownerId"
99
+ */
100
+ export type TypedCel<S extends SchemaShape> = Omit<typeof cel, 'eq' | 'ne' | 'inList' | 'gt' | 'gte' | 'lt' | 'lte' | 'auth'> & {
101
+ auth: AuthPaths<S> & (() => string);
102
+ table: <E extends EntityName<S>>(entity: E) => {
103
+ data: DataPaths<S, E>;
104
+ newData: NewDataPaths<S, E>;
105
+ };
106
+ eq: <P extends string>(left: P, right: CelValue<P> | string) => string;
107
+ ne: <P extends string>(left: P, right: CelValue<P> | string) => string;
108
+ gt: <P extends string>(left: P, right: CelValue<P> | string) => string;
109
+ gte: <P extends string>(left: P, right: CelValue<P> | string) => string;
110
+ lt: <P extends string>(left: P, right: CelValue<P> | string) => string;
111
+ lte: <P extends string>(left: P, right: CelValue<P> | string) => string;
112
+ inList: <P extends string>(left: P, values: Array<CelValue<P> | string>) => string;
113
+ json: <P extends string, V, K extends keyof V & string>(path: CelPath<P, V>, key: K) => CelPath<`${P}.${K}`, V[K]>;
114
+ };
115
+ export declare function typedCel<S extends SchemaShape>(): TypedCel<S>;
116
+ export {};
117
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.r = exports.cel = void 0;
4
+ exports.typedCel = typedCel;
5
+ /**
6
+ * Helpers that compile to BackendRelay permission CEL. The values are plain
7
+ * strings, so they work with `satisfies BackendRelayRules` and are validated by
8
+ * the server when the rules are pushed.
9
+ */
10
+ exports.cel = {
11
+ true: 'true',
12
+ false: 'false',
13
+ /** `auth.id != null` */
14
+ auth: () => 'auth.id != null',
15
+ /** `left == right` */
16
+ eq: (left, right) => `${left} == ${right}`,
17
+ /** `left != right` */
18
+ ne: (left, right) => `${left} != ${right}`,
19
+ gt: (left, right) => `${left} > ${right}`,
20
+ gte: (left, right) => `${left} >= ${right}`,
21
+ lt: (left, right) => `${left} < ${right}`,
22
+ lte: (left, right) => `${left} <= ${right}`,
23
+ /** `left.matches('pattern')` */
24
+ matches: (left, pattern) => `${left}.matches(${JSON.stringify(pattern)})`,
25
+ /** `path != null` — CEL's null check for a field. */
26
+ has: (path) => `${path} != null`,
27
+ /** `has(path)` — CEL's presence macro, safe for unset fields. */
28
+ exists: (path) => `has(${path})`,
29
+ /** `value in [a, b, c]` */
30
+ inList: (value, values) => `${value} in [${values.map((item) => JSON.stringify(item)).join(', ')}]`,
31
+ and: (...parts) => parts.map(joinable).join(' && '),
32
+ or: (...parts) => parts.map(joinable).join(' || '),
33
+ not: (part) => `!(${part})`,
34
+ /** `auth.id != null && auth.id == data.ownerId` */
35
+ owner: (field = 'ownerId') => `auth.id != null && auth.id == data.${field}`,
36
+ /** `auth.id != null && newData.ownerId == auth.id` */
37
+ creator: (field = 'ownerId') => `auth.id != null && newData.${field} == auth.id`,
38
+ };
39
+ exports.r = exports.cel;
40
+ function joinable(part) {
41
+ // A bare `a && b` already groups correctly, but parenthesizing keeps nested
42
+ // and/or expressions unambiguous and matches what the editor displays.
43
+ return part.includes(' && ') || part.includes(' || ') ? `(${part})` : part;
44
+ }
45
+ function pathProxy(prefix, target = {}) {
46
+ return new Proxy(target, {
47
+ get: (_target, property) => `${prefix}.${String(property)}`,
48
+ });
49
+ }
50
+ function typedCel() {
51
+ return {
52
+ ...exports.cel,
53
+ auth: pathProxy('auth', () => 'auth.id != null'),
54
+ table: (_entity) => ({
55
+ data: pathProxy('data'),
56
+ newData: pathProxy('newData'),
57
+ }),
58
+ eq: (left, right) => `${left} == ${right}`,
59
+ ne: (left, right) => `${left} != ${right}`,
60
+ gt: (left, right) => `${left} > ${right}`,
61
+ gte: (left, right) => `${left} >= ${right}`,
62
+ lt: (left, right) => `${left} < ${right}`,
63
+ lte: (left, right) => `${left} <= ${right}`,
64
+ inList: (left, values) => `${left} in [${values.map((value) => JSON.stringify(value)).join(', ')}]`,
65
+ json: ((path, key) => `${path}.${key}`),
66
+ };
67
+ }
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Helpers that compile to BackendRelay permission CEL. The values are plain\n * strings, so they work with `satisfies BackendRelayRules` and are validated by\n * the server when the rules are pushed.\n */\nexport const cel = {\n true: 'true',\n false: 'false',\n\n /** `auth.id != null` */\n auth: () => 'auth.id != null',\n\n /** `left == right` */\n eq: (left: string, right: string) => `${left} == ${right}`,\n\n /** `left != right` */\n ne: (left: string, right: string) => `${left} != ${right}`,\n\n gt: (left: string, right: string) => `${left} > ${right}`,\n gte: (left: string, right: string) => `${left} >= ${right}`,\n lt: (left: string, right: string) => `${left} < ${right}`,\n lte: (left: string, right: string) => `${left} <= ${right}`,\n\n /** `left.matches('pattern')` */\n matches: (left: string, pattern: string) =>\n `${left}.matches(${JSON.stringify(pattern)})`,\n\n /** `path != null` — CEL's null check for a field. */\n has: (path: string) => `${path} != null`,\n\n /** `has(path)` — CEL's presence macro, safe for unset fields. */\n exists: (path: string) => `has(${path})`,\n\n /** `value in [a, b, c]` */\n inList: (value: string, values: string[]) =>\n `${value} in [${values.map((item) => JSON.stringify(item)).join(', ')}]`,\n\n and: (...parts: string[]) => parts.map(joinable).join(' && '),\n or: (...parts: string[]) => parts.map(joinable).join(' || '),\n not: (part: string) => `!(${part})`,\n\n /** `auth.id != null && auth.id == data.ownerId` */\n owner: (field = 'ownerId') => `auth.id != null && auth.id == data.${field}`,\n\n /** `auth.id != null && newData.ownerId == auth.id` */\n creator: (field = 'ownerId') =>\n `auth.id != null && newData.${field} == auth.id`,\n};\n\nexport const r = cel;\n\nfunction joinable(part: string): string {\n // A bare `a && b` already groups correctly, but parenthesizing keeps nested\n // and/or expressions unambiguous and matches what the editor displays.\n return part.includes(' && ') || part.includes(' || ') ? `(${part})` : part;\n}\n\ntype SchemaShape = {\n entities: Record<string, { attrs: Record<string, unknown> }>;\n};\n\ntype EntityName<S extends SchemaShape> = keyof S['entities'] & string;\ntype AttrName<S extends SchemaShape, E extends EntityName<S>> =\n | (keyof S['entities'][E]['attrs'] & string)\n | 'id';\ntype AttrValue<D> = D extends { readonly __valueType?: infer V } ? V : unknown;\ntype PathValue<\n S extends SchemaShape,\n E extends EntityName<S>,\n K extends AttrName<S, E>,\n> = K extends 'id' ? string : AttrValue<S['entities'][E]['attrs'][K]>;\n\n/** A CEL path string branded with the attribute's value type. */\nexport type CelPath<P extends string, V> = P & {\n readonly __celValue?: V;\n};\n\ntype AuthPaths<S extends SchemaShape> = {\n [K in AttrName<S, '$users'>]: CelPath<`auth.${K}`, PathValue<S, '$users', K>>;\n};\n\ntype DataPaths<S extends SchemaShape, E extends EntityName<S>> = {\n [K in AttrName<S, E>]: CelPath<`data.${K}`, PathValue<S, E, K>>;\n};\n\ntype NewDataPaths<S extends SchemaShape, E extends EntityName<S>> = {\n [K in AttrName<S, E>]: CelPath<`newData.${K}`, PathValue<S, E, K>>;\n};\n\ntype CelValue<P extends string> = P extends {\n readonly __celValue?: infer V;\n}\n ? unknown extends V\n ? string\n : V\n : string;\n\n/**\n * Schema-aware rule helpers. Pass the app schema type and use property access\n * for paths: `auth.isPro`, `table('feedbacks').data.ownerId`.\n *\n * @example\n * const t = typedCel<typeof schema>();\n * t.auth.isPro; // \"auth.isPro\"\n * t.table('feedbacks').data.ownerId; // \"data.ownerId\"\n */\nexport type TypedCel<S extends SchemaShape> = Omit<\n typeof cel,\n 'eq' | 'ne' | 'inList' | 'gt' | 'gte' | 'lt' | 'lte' | 'auth'\n> & {\n auth: AuthPaths<S> & (() => string);\n table: <E extends EntityName<S>>(\n entity: E,\n ) => {\n data: DataPaths<S, E>;\n newData: NewDataPaths<S, E>;\n };\n eq: <P extends string>(left: P, right: CelValue<P> | string) => string;\n ne: <P extends string>(left: P, right: CelValue<P> | string) => string;\n gt: <P extends string>(left: P, right: CelValue<P> | string) => string;\n gte: <P extends string>(left: P, right: CelValue<P> | string) => string;\n lt: <P extends string>(left: P, right: CelValue<P> | string) => string;\n lte: <P extends string>(left: P, right: CelValue<P> | string) => string;\n inList: <P extends string>(\n left: P,\n values: Array<CelValue<P> | string>,\n ) => string;\n json: <P extends string, V, K extends keyof V & string>(\n path: CelPath<P, V>,\n key: K,\n ) => CelPath<`${P}.${K}`, V[K]>;\n};\n\nfunction pathProxy<T extends object>(prefix: string, target: object = {}): T {\n return new Proxy(target, {\n get: (_target, property) => `${prefix}.${String(property)}`,\n }) as T;\n}\n\nexport function typedCel<S extends SchemaShape>(): TypedCel<S> {\n return {\n ...cel,\n auth: pathProxy<AuthPaths<S> & (() => string)>(\n 'auth',\n () => 'auth.id != null',\n ),\n table: <E extends EntityName<S>>(_entity: E) => ({\n data: pathProxy<DataPaths<S, E>>('data'),\n newData: pathProxy<NewDataPaths<S, E>>('newData'),\n }),\n eq: (left, right) => `${left} == ${right}`,\n ne: (left, right) => `${left} != ${right}`,\n gt: (left, right) => `${left} > ${right}`,\n gte: (left, right) => `${left} >= ${right}`,\n lt: (left, right) => `${left} < ${right}`,\n lte: (left, right) => `${left} <= ${right}`,\n inList: (left, values) =>\n `${left} in [${values.map((value) => JSON.stringify(value)).join(', ')}]`,\n json: ((path: string, key: string) =>\n `${path}.${key}`) as unknown as TypedCel<S>['json'],\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }