@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,825 @@
1
+ import { BackendRelayAPIError, BackendRelayError, requireApiURI, version as coreVersion, } from '@backendrelay/core';
2
+ const knownKeys = {
3
+ 'https://api.backendrelay.com': {
4
+ keys: [
5
+ {
6
+ kty: 'OKP',
7
+ crv: 'Ed25519',
8
+ alg: 'EdDSA',
9
+ use: 'sig',
10
+ kid: '1034696293',
11
+ x: 'N-C41432STKAKkXAWmeIOXMnZcGRR1b9u1L3bTVqI_o',
12
+ },
13
+ ],
14
+ },
15
+ 'http://localhost:8888': {
16
+ keys: [
17
+ {
18
+ kty: 'OKP',
19
+ crv: 'Ed25519',
20
+ alg: 'EdDSA',
21
+ use: 'sig',
22
+ kid: '503090235',
23
+ x: 'qrSkwDaMITRMF9nOgpueqxgaAiuFmJperYE3mkyl8Ow',
24
+ },
25
+ ],
26
+ },
27
+ };
28
+ function inferWebCryptoAlg(jwk) {
29
+ if (jwk.kty === 'OKP' && jwk.crv === 'Ed25519') {
30
+ return { name: 'Ed25519' };
31
+ }
32
+ if (jwk.kty === 'EC') {
33
+ return { name: 'ECDSA', namedCurve: jwk.crv }; // e.g., P-256, P-384
34
+ }
35
+ if (jwk.kty === 'RSA') {
36
+ // RSA keys often specify the exact hash in the 'alg' field (e.g., RS256)
37
+ const hashMap = {
38
+ RS256: 'SHA-256',
39
+ RS384: 'SHA-384',
40
+ RS512: 'SHA-512',
41
+ };
42
+ return {
43
+ name: 'RSASSA-PKCS1-v1_5',
44
+ hash: hashMap[jwk.alg] || 'SHA-256',
45
+ };
46
+ }
47
+ throw new Error(`Unsupported JWK configuration: kty=${jwk.kty}, crv=${jwk.crv}`);
48
+ }
49
+ async function importKey(jwk) {
50
+ const alg = inferWebCryptoAlg(jwk);
51
+ const key = await crypto.subtle.importKey('jwk', jwk, alg, false, ['verify']);
52
+ return { alg, key };
53
+ }
54
+ function verify(alg, key, signature, message) {
55
+ return crypto.subtle.verify(alg, key, signature, message);
56
+ }
57
+ function hexToUint8Array(hexString) {
58
+ const bytes = new Uint8Array(Math.ceil(hexString.length / 2));
59
+ for (let i = 0; i < bytes.length; i++) {
60
+ bytes[i] = parseInt(hexString.substring(i * 2, i * 2 + 2), 16);
61
+ }
62
+ return bytes;
63
+ }
64
+ function parseSignatureHeader(h) {
65
+ let t, kid, v1;
66
+ for (const part of h.split(',')) {
67
+ const [k, v] = part.split('=');
68
+ switch (k) {
69
+ case 't': {
70
+ t = v;
71
+ break;
72
+ }
73
+ case 'kid': {
74
+ kid = v;
75
+ break;
76
+ }
77
+ case 'v1': {
78
+ v1 = v;
79
+ break;
80
+ }
81
+ }
82
+ }
83
+ const missingKeys = [];
84
+ if (!t) {
85
+ missingKeys.push('t');
86
+ }
87
+ if (!kid) {
88
+ missingKeys.push('kid');
89
+ }
90
+ if (!v1) {
91
+ missingKeys.push('v1');
92
+ }
93
+ if (missingKeys.length || !t || !kid || !v1) {
94
+ throw new BackendRelayError('Invalid BackendRelay-Signature header.', {
95
+ header: h,
96
+ missingKeys,
97
+ });
98
+ }
99
+ return { t, kid, v1 };
100
+ }
101
+ function validateT(receivedAt, t, tolerance) {
102
+ const age = Math.floor(receivedAt.getTime() / 1000) - parseInt(t, 10);
103
+ if (age > tolerance) {
104
+ throw new BackendRelayError('Webhook signature is too old', {
105
+ tolerance,
106
+ receivedAt,
107
+ t,
108
+ });
109
+ }
110
+ }
111
+ // We make this a global cache so that it will survive across
112
+ // restarts. It will only store valid signing keys from instant, and we don't
113
+ // create many of them, so the memory usage will be only 1 or 2 keys.
114
+ const keyCache = new Map();
115
+ const issuerCache = new Map();
116
+ const jwksCacheTtlMs = 60_000;
117
+ const maxCachedIssuers = 32;
118
+ function issuerState(apiURI) {
119
+ let issuer = issuerCache.get(apiURI);
120
+ if (issuer) {
121
+ // Re-insert to mark the issuer as most recently used.
122
+ issuerCache.delete(apiURI);
123
+ }
124
+ else {
125
+ issuer = { keys: null, fetchedAt: 0, failedAt: 0, inflight: null };
126
+ }
127
+ issuerCache.set(apiURI, issuer);
128
+ if (issuerCache.size > maxCachedIssuers) {
129
+ const oldest = issuerCache.keys().next().value;
130
+ if (oldest !== undefined) {
131
+ issuerCache.delete(oldest);
132
+ // Drop the evicted issuer's imported keys with it, so imported-key
133
+ // memory stays bounded by the same cap.
134
+ const prefix = `${oldest}:`;
135
+ for (const cacheKey of keyCache.keys()) {
136
+ if (cacheKey.startsWith(prefix)) {
137
+ keyCache.delete(cacheKey);
138
+ }
139
+ }
140
+ }
141
+ }
142
+ return issuer;
143
+ }
144
+ const defaultTolerance = 300; // 5 minutes
145
+ async function jsonReject(rejectFn, res) {
146
+ const body = await res.text();
147
+ try {
148
+ const json = JSON.parse(body);
149
+ return rejectFn(new BackendRelayAPIError({ status: res.status, body: json }));
150
+ }
151
+ catch (_e) {
152
+ return rejectFn(new BackendRelayAPIError({
153
+ status: res.status,
154
+ body: { type: undefined, message: body },
155
+ }));
156
+ }
157
+ }
158
+ const defaultJsonFetch = async (input, init) => {
159
+ const headers = {
160
+ ...(init?.headers || {}),
161
+ 'BackendRelay-Core-Version': coreVersion,
162
+ };
163
+ const res = await fetch(input, { ...init, headers });
164
+ if (res.status === 200) {
165
+ return res.json();
166
+ }
167
+ return jsonReject((x) => Promise.reject(x), res);
168
+ };
169
+ function parseDate(s) {
170
+ return s ? new Date(s) : null;
171
+ }
172
+ function toWebhookInfo(raw) {
173
+ return {
174
+ id: raw.id,
175
+ sink: raw.sink,
176
+ namespaces: raw.namespaces ?? [],
177
+ actions: raw.actions,
178
+ status: raw.status,
179
+ disabledReason: raw.disabled_reason ?? null,
180
+ createdAt: new Date(raw.created_at),
181
+ updatedAt: new Date(raw.updated_at),
182
+ };
183
+ }
184
+ function toWebhookAttempt(raw) {
185
+ return {
186
+ attemptAt: parseDate(raw['attempt-at']),
187
+ durationMs: raw['duration-ms'] ?? null,
188
+ success: raw['success?'] ?? null,
189
+ statusCode: raw['status-code'] ?? null,
190
+ responseText: raw['response-text'] ?? null,
191
+ errorType: raw['error-type'] ?? null,
192
+ errorMessage: raw['error-message'] ?? null,
193
+ };
194
+ }
195
+ function toWebhookEventInfo(raw) {
196
+ return {
197
+ isn: raw.isn,
198
+ status: raw.status,
199
+ attempts: raw.attempts ? raw.attempts.map(toWebhookAttempt) : null,
200
+ nextAttemptAfter: parseDate(raw.next_attempt_after),
201
+ createdAt: new Date(raw.created_at),
202
+ updatedAt: new Date(raw.updated_at),
203
+ };
204
+ }
205
+ export class WebhooksManager {
206
+ #appId;
207
+ #apiURI;
208
+ #token;
209
+ #withAuth;
210
+ #jsonFetch;
211
+ constructor(opts) {
212
+ this.#appId = opts.appId;
213
+ this.#apiURI = opts.apiURI;
214
+ this.#token = opts.token;
215
+ this.#withAuth = opts.withAuth;
216
+ this.#jsonFetch = opts.jsonFetch;
217
+ }
218
+ #authedFetch(path, opts) {
219
+ if (!this.#appId) {
220
+ throw new BackendRelayError('appId is required to manage webhooks. Pass it to the Webhooks constructor.');
221
+ }
222
+ const run = (token) => {
223
+ const init = {
224
+ method: opts?.method,
225
+ headers: {
226
+ authorization: `Bearer ${token}`,
227
+ 'content-type': 'application/json',
228
+ },
229
+ };
230
+ if (opts?.body !== undefined) {
231
+ init.body = JSON.stringify(opts.body);
232
+ }
233
+ return this.#jsonFetch(`${this.#apiURI}${path}`, init);
234
+ };
235
+ if (this.#withAuth) {
236
+ return this.#withAuth(run);
237
+ }
238
+ if (!this.#token) {
239
+ throw new BackendRelayError('A token is required to manage webhooks. Pass `adminToken` or `token` to the Webhooks constructor.');
240
+ }
241
+ return run(this.#token);
242
+ }
243
+ /**
244
+ * Returns every webhook configured on the app, newest first. Includes both
245
+ * active and disabled webhooks.
246
+ */
247
+ async list() {
248
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks`);
249
+ return (res.webhooks || []).map(toWebhookInfo);
250
+ }
251
+ /**
252
+ * Creates a new webhook. The webhook is created in the `active` state and
253
+ * starts receiving matching events immediately.
254
+ *
255
+ * The server rejects the request if `url` is not an HTTPS URL pointing at a
256
+ * public host, if `namespaces` doesn't reference any entity in the app's
257
+ * schema, if `actions` is empty, or if the app has hit its webhook limit.
258
+ *
259
+ * An app may have at most **100 active webhooks** at a time; {@link delete}
260
+ * a webhook to free up a slot before creating another.
261
+ *
262
+ * @example
263
+ * const webhook = await db.webhooks.manager.create({
264
+ * url: 'https://example.com/instant',
265
+ * namespaces: ['posts', 'comments'],
266
+ * actions: ['create', 'update'],
267
+ * });
268
+ */
269
+ async create(params) {
270
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks`, {
271
+ method: 'POST',
272
+ body: params,
273
+ });
274
+ return toWebhookInfo(res.webhook);
275
+ }
276
+ /**
277
+ * Updates a webhook's `url`, `namespaces`, and/or `actions`. Pass only the
278
+ * fields you want to change; omitted fields keep their current value.
279
+ *
280
+ * Does not affect the webhook's status — use {@link enable} or
281
+ * {@link disable} for that.
282
+ */
283
+ async update(webhookId, params) {
284
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}`, { method: 'POST', body: params });
285
+ return toWebhookInfo(res.webhook);
286
+ }
287
+ /**
288
+ * Deletes a webhook. No further events will be queued for it. Returns the
289
+ * webhook as it looked just before deletion.
290
+ */
291
+ async delete(webhookId) {
292
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}`, { method: 'DELETE' });
293
+ return toWebhookInfo(res.webhook);
294
+ }
295
+ /**
296
+ * Re-enables a disabled webhook. Clears `disabledReason` and resumes
297
+ * delivery for new events. Has no effect if the webhook is already active.
298
+ *
299
+ * Events that occurred while the webhook was disabled are not retroactively
300
+ * delivered.
301
+ */
302
+ async enable(webhookId) {
303
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}/enable`, { method: 'POST', body: {} });
304
+ return toWebhookInfo(res.webhook);
305
+ }
306
+ /**
307
+ * Disables a webhook. No new events will be queued until it is re-enabled
308
+ * via {@link enable}. In-flight events already being processed will still
309
+ * complete.
310
+ *
311
+ * @param opts.reason Optional human-readable note stored on the webhook
312
+ * and surfaced in the dashboard.
313
+ */
314
+ async disable(webhookId, opts) {
315
+ const body = opts?.reason ? { reason: opts.reason } : {};
316
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}/disable`, { method: 'POST', body });
317
+ return toWebhookInfo(res.webhook);
318
+ }
319
+ /**
320
+ * Returns a page of events for a webhook, newest first.
321
+ *
322
+ * Events are retained for ~60 days. To paginate, pass the previous page's
323
+ * `pageInfo.endCursor` as `opts.after`; stop when `pageInfo.hasNextPage`
324
+ * is `false`.
325
+ */
326
+ async listEvents(webhookId, opts) {
327
+ const qs = opts?.after ? `?after=${encodeURIComponent(opts.after)}` : '';
328
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}/events${qs}`);
329
+ return {
330
+ events: (res.events || []).map(toWebhookEventInfo),
331
+ pageInfo: {
332
+ startCursor: res.pageInfo?.startCursor ?? null,
333
+ endCursor: res.pageInfo?.endCursor ?? null,
334
+ hasNextPage: !!res.pageInfo?.hasNextPage,
335
+ },
336
+ };
337
+ }
338
+ /**
339
+ * Fetches a single webhook event by its `isn`.
340
+ */
341
+ async getEvent(webhookId, isn) {
342
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}/events/${isn}`);
343
+ return toWebhookEventInfo(res.event);
344
+ }
345
+ /** Returns the full payload for an event. */
346
+ async getPayload(webhookId, isn) {
347
+ return this.#authedFetch(`/webhooks/payload/${this.#appId}/${webhookId}/${isn}`);
348
+ }
349
+ /**
350
+ * Re-queues an event for delivery, regardless of its current status. Use
351
+ * this to retry a `failed` event or force a redelivery of a `success` one.
352
+ *
353
+ * The server rate-limits resends; if the event was queued or resent very
354
+ * recently the call will fail with a validation error asking you to try
355
+ * again in about a minute.
356
+ */
357
+ async resendEvent(webhookId, isn) {
358
+ const res = await this.#authedFetch(`/dash/apps/${this.#appId}/webhooks/${webhookId}/events/${isn}`, { method: 'POST', body: {} });
359
+ return toWebhookEventInfo(res.event);
360
+ }
361
+ }
362
+ /**
363
+ * Verify incoming webhook requests from BackendRelay, dispatch their records to
364
+ * typed handlers, and manage webhook subscriptions (via {@link manager}).
365
+ *
366
+ * Usually accessed as `db.webhooks` on the admin or platform SDK rather than
367
+ * constructed directly.
368
+ */
369
+ export class Webhooks {
370
+ /** App this instance is bound to. */
371
+ appId;
372
+ /** Schema used to type webhook payloads and handler records. */
373
+ schema;
374
+ #token;
375
+ /** Base URL for the BackendRelay API. */
376
+ apiURI;
377
+ #jsonFetch;
378
+ /** Manage webhook subscriptions and inspect delivery events. */
379
+ manager;
380
+ /**
381
+ * Schema-bound helpers for building typed handler maps.
382
+ *
383
+ * - `typedHandlers(namespace, action, handler)` builds a single typed entry.
384
+ * Pass `'$default'` for `namespace` to register a catch-all handler.
385
+ * - `combineHandlers(...entries)` merges entries into a
386
+ * {@link WebhookHandlers} object suitable for {@link processPayload} and
387
+ * {@link processRequest}.
388
+ *
389
+ * If you already have a {@link Webhooks} instance, prefer the instance
390
+ * form (`db.webhooks.helpers()`) — it infers `Schema` automatically.
391
+ *
392
+ * @example
393
+ * const { typedHandlers, combineHandlers } = Webhooks.helpers<typeof schema>();
394
+ * const handlers = combineHandlers(
395
+ * typedHandlers('posts', 'create', (record) => { ... }),
396
+ * typedHandlers('comments', '$default', (record) => { ... }),
397
+ * typedHandlers('$default', (record) => { ... }),
398
+ * );
399
+ */
400
+ static helpers() {
401
+ function typedHandlers(...args) {
402
+ if (args.length === 2) {
403
+ return { $default: args[1] };
404
+ }
405
+ const [namespace, action, handler] = args;
406
+ return { [namespace]: { [action]: handler } };
407
+ }
408
+ function combineHandlers(...entries) {
409
+ const result = {};
410
+ for (const entry of entries) {
411
+ for (const key of Object.keys(entry)) {
412
+ if (key === '$default') {
413
+ result.$default = entry.$default;
414
+ }
415
+ else {
416
+ result[key] = { ...result[key], ...entry[key] };
417
+ }
418
+ }
419
+ }
420
+ return result;
421
+ }
422
+ return {
423
+ typedHandlers: typedHandlers,
424
+ combineHandlers: combineHandlers,
425
+ };
426
+ }
427
+ /**
428
+ * Instance form of {@link Webhooks.helpers} that infers `Schema` from this
429
+ * instance — no `<typeof schema>` type argument required.
430
+ *
431
+ * @example
432
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
433
+ */
434
+ helpers() {
435
+ return Webhooks.helpers();
436
+ }
437
+ constructor(config, jsonFetch) {
438
+ this.appId = config.appId;
439
+ this.schema = config.schema;
440
+ this.#token = config.adminToken || config.token;
441
+ this.apiURI = requireApiURI(config.apiURI, 'BackendRelay webhooks');
442
+ this.#jsonFetch = jsonFetch || defaultJsonFetch;
443
+ this.manager = new WebhooksManager({
444
+ appId: this.appId,
445
+ apiURI: this.apiURI,
446
+ token: this.#token,
447
+ withAuth: config.withAuth,
448
+ jsonFetch: this.#jsonFetch,
449
+ });
450
+ }
451
+ /** Fetches BackendRelay's JWK set for verifying webhook signatures. */
452
+ async fetchJwks() {
453
+ const resp = await this.#jsonFetch(`${this.apiURI}/.well-known/webhooks/jwks.json`);
454
+ return resp;
455
+ }
456
+ /**
457
+ * Resolves a `kid` to an imported {@link CryptoKey}, hitting a
458
+ * process-wide cache on repeat calls. Falls back to {@link fetchJwks} if
459
+ * the key isn't already known; per issuer the fetch is cached for
460
+ * `jwksCacheTtlMs` (see {@link issuerState}).
461
+ */
462
+ async keyOfKid(kid) {
463
+ const cacheKey = `${this.apiURI}:${kid}`;
464
+ const cached = keyCache.get(cacheKey);
465
+ if (cached && (cached.exp === null || Date.now() < cached.exp)) {
466
+ return cached;
467
+ }
468
+ if (cached) {
469
+ // The JWK advertised an `exp` that has passed; drop it so the lookup
470
+ // below refetches.
471
+ keyCache.delete(cacheKey);
472
+ }
473
+ const jwk = knownKeys[this.apiURI]?.keys.find((k) => k.kid === kid) ||
474
+ // An expired entry forces a fresh JWKS fetch, so a rotated key
475
+ // replaces it right away instead of waiting out the issuer TTL.
476
+ (await this.#issuerKeys(cached !== undefined)).find((k) => k.kid === kid);
477
+ if (!jwk) {
478
+ throw new BackendRelayError('Could not find matching signing key', {
479
+ kid,
480
+ });
481
+ }
482
+ const res = await importKey(jwk);
483
+ // RFC 7517 `exp` is a NumericDate in seconds.
484
+ const exp = typeof jwk.exp === 'number' ? jwk.exp * 1000 : null;
485
+ keyCache.set(cacheKey, { ...res, exp });
486
+ return res;
487
+ }
488
+ /**
489
+ * The issuer's signing keys from {@link fetchJwks}, through the per-issuer
490
+ * cache: inside the TTL window a fetched set is reused, a failed fetch
491
+ * fails fast until the window passes, and concurrent misses share one
492
+ * request.
493
+ */
494
+ async #issuerKeys(force = false) {
495
+ const issuer = issuerState(this.apiURI);
496
+ const now = Date.now();
497
+ if (!force && issuer.keys && now - issuer.fetchedAt < jwksCacheTtlMs) {
498
+ return issuer.keys;
499
+ }
500
+ if (now - issuer.failedAt < jwksCacheTtlMs) {
501
+ throw new BackendRelayError('Could not fetch issuer signing keys', {
502
+ issuer: this.apiURI,
503
+ });
504
+ }
505
+ if (!issuer.inflight) {
506
+ issuer.inflight = this.fetchJwks()
507
+ .then((resp) => {
508
+ const keys = resp?.keys ?? [];
509
+ issuer.keys = keys;
510
+ issuer.fetchedAt = Date.now();
511
+ return keys;
512
+ })
513
+ .catch((e) => {
514
+ issuer.failedAt = Date.now();
515
+ throw e;
516
+ })
517
+ .finally(() => {
518
+ issuer.inflight = null;
519
+ });
520
+ }
521
+ return issuer.inflight;
522
+ }
523
+ /**
524
+ * Verifies an `BackendRelay-Signature` header against a body and returns the
525
+ * parsed {@link WebhookBody} (containing the `payloadUrl` and a JWT
526
+ * `token` for fetching the records).
527
+ *
528
+ * Throws if the signature doesn't validate, the signature is older than
529
+ * `opts.tolerance` (default 300 seconds), or the body doesn't decode to
530
+ * the expected shape.
531
+ *
532
+ * @param body Either the raw body string, or a function returning it.
533
+ * Use a function to defer reading the body until after the
534
+ * header has been parsed.
535
+ */
536
+ async validate(signatureHeader, body, opts) {
537
+ const receivedAt = opts?.receivedAt || new Date();
538
+ const { t, kid, v1 } = parseSignatureHeader(signatureHeader);
539
+ const tolerance = opts?.tolerance ?? defaultTolerance;
540
+ validateT(receivedAt, t, tolerance);
541
+ const { alg, key } = await this.keyOfKid(kid);
542
+ const bodyText = typeof body === 'function' ? await body() : body;
543
+ const message = new TextEncoder().encode(`${t}.${bodyText}`);
544
+ const verified = await verify(alg, key, hexToUint8Array(v1), message);
545
+ if (!verified) {
546
+ throw new BackendRelayError('BackendRelay Signature did not validate', {
547
+ header: signatureHeader,
548
+ });
549
+ }
550
+ const res = JSON.parse(bodyText);
551
+ if (typeof res !== 'object' ||
552
+ typeof res.payloadUrl !== 'string' ||
553
+ typeof res.token !== 'string') {
554
+ throw new BackendRelayError('Invalid webhook body, expected an object with payloadUrl and token fields', { body: res });
555
+ }
556
+ return res;
557
+ }
558
+ /**
559
+ * Pulls the `BackendRelay-Signature` header and body from a `Request` and
560
+ * delegates to {@link validate}. Throws if the header is missing.
561
+ */
562
+ async validateRequest(req, opts) {
563
+ const signatureHeader = req.headers.get('BackendRelay-Signature');
564
+ if (!signatureHeader) {
565
+ throw new BackendRelayError('Request is missing BackendRelay-Signature header');
566
+ }
567
+ return this.validate(signatureHeader, () => req.text(), opts);
568
+ }
569
+ /**
570
+ * Fetches the records and `idempotencyKey` for a validated
571
+ * {@link WebhookBody}, authenticating with the JWT `token` it carries.
572
+ */
573
+ fetchPayloads({ payloadUrl, token, }) {
574
+ return this.#jsonFetch(payloadUrl, {
575
+ headers: { Authorization: `Bearer ${token}`, accept: 'application/json' },
576
+ });
577
+ }
578
+ /**
579
+ * Dispatches each record in `payload` to its matching handler in
580
+ * `handlers`. Resolution order per record: exact `namespace` + `action` →
581
+ * `namespace`'s `$default` → top-level `$default`. Records with no matching
582
+ * handler are skipped.
583
+ *
584
+ * Handlers run concurrently. If any handler rejects, the call rejects so
585
+ * the caller (e.g. {@link processRequest}) can return a non-2xx response
586
+ * and let BackendRelay retry the event.
587
+ */
588
+ async processPayload(handlers, payload) {
589
+ const results = [];
590
+ for (const record of payload.data) {
591
+ const { namespace, action } = record;
592
+ const handler = handlers?.[namespace]?.[action] ||
593
+ handlers?.[namespace]?.$default ||
594
+ handlers?.$default;
595
+ if (handler) {
596
+ // We need the as any here because typescript
597
+ // has trouble correlating the handler to the
598
+ // record namespace and action
599
+ results.push(handler(record));
600
+ }
601
+ }
602
+ await Promise.all(results);
603
+ }
604
+ /**
605
+ * The one-liner for handling webhooks. Hand it your handlers and the
606
+ * incoming `Request` — it verifies the signature, fetches the records, and
607
+ * dispatches each one to your code.
608
+ *
609
+ * Async handlers are executed in parallel, the return promise will resolve once
610
+ * all handlers complete and will reject if any of the handlers fails.
611
+ *
612
+ * @example
613
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
614
+ *
615
+ * const handlers = combineHandlers(
616
+ * typedHandlers('posts', 'create', async (record) => {
617
+ * await sendNewPostEmail(record.after);
618
+ * }),
619
+ * typedHandlers('$default', (record) => {
620
+ * console.log('webhook event', record);
621
+ * }),
622
+ * );
623
+ *
624
+ * export async function POST(req: Request) {
625
+ * await db.webhooks.processRequest(handlers, req);
626
+ * return new Response('ok');
627
+ * }
628
+ */
629
+ async processRequest(handlers, req, opts) {
630
+ const body = await this.validateRequest(req, opts);
631
+ const payload = await this.fetchPayloads(body);
632
+ await this.processPayload(handlers, payload);
633
+ }
634
+ /**
635
+ * Adapter for frameworks that hand you a Node-style `http.IncomingMessage`
636
+ * (Next.js Pages Router, Express, Koa, etc.) instead of a Web `Request`.
637
+ * Wraps the request in a Web `Request` and delegates to
638
+ * {@link processRequest}. You still send the HTTP response yourself.
639
+ *
640
+ * The raw body is required for signature verification. The adapter picks
641
+ * it up from one of:
642
+ *
643
+ * - `req.body` if it's a `Buffer` or `Uint8Array` (set by middleware like
644
+ * `express.raw({ type: 'application/json' })`)
645
+ * - `req.body` if it's a string (set by middleware like `express.text()`)
646
+ * - otherwise the unconsumed request stream
647
+ *
648
+ * Don't use a JSON body parser on this route — `express.json()` and
649
+ * `bodyParser: true` in Next.js both parse the body into an object,
650
+ * destroying the raw bytes the signature was computed over.
651
+ *
652
+ * @example
653
+ * // Next.js Pages Router (`pages/api/webhooks.ts`)
654
+ * import type { NextApiRequest, NextApiResponse } from 'next';
655
+ *
656
+ * export const config = { api: { bodyParser: false } };
657
+ *
658
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
659
+ *
660
+ * const handlers = combineHandlers(
661
+ * typedHandlers('posts', 'create', async (record) => {
662
+ * await sendNewPostEmail(record.after);
663
+ * }),
664
+ * typedHandlers('$default', (record) => {
665
+ * console.log('unhandled record', record);
666
+ * }),
667
+ * );
668
+ *
669
+ * export default async function handler(
670
+ * req: NextApiRequest,
671
+ * res: NextApiResponse,
672
+ * ) {
673
+ * try {
674
+ * await db.webhooks.processNodeRequest(handlers, req);
675
+ * res.status(200).end();
676
+ * } catch (e) {
677
+ * res.status(400).json({ error: String(e) });
678
+ * }
679
+ * }
680
+ *
681
+ * @example
682
+ * // Express — skip the JSON body parser on the webhook route and use
683
+ * // `express.raw()` so `req.body` arrives as a Buffer.
684
+ * import express from 'express';
685
+ *
686
+ * const app = express();
687
+ *
688
+ * app.use((req, res, next) => {
689
+ * if (req.originalUrl === '/webhooks/backendrelay') return next();
690
+ * express.json()(req, res, next);
691
+ * });
692
+ *
693
+ * app.post(
694
+ * '/webhooks/backendrelay',
695
+ * express.raw({ type: 'application/json' }),
696
+ * async (req, res) => {
697
+ * try {
698
+ * await db.webhooks.processNodeRequest(handlers, req);
699
+ * res.status(200).end();
700
+ * } catch (e) {
701
+ * res.status(400).json({ error: String(e) });
702
+ * }
703
+ * },
704
+ * );
705
+ *
706
+ * @example
707
+ * // Koa — `ctx.req` is the raw IncomingMessage. If `koa-bodyparser` (or
708
+ * // similar) runs on this route it consumes the stream, so either skip it
709
+ * // here or pull the raw body yourself and shim it onto the request:
710
+ * import Koa from 'koa';
711
+ * import Router from '@koa/router';
712
+ * import rawBody from 'raw-body';
713
+ *
714
+ * const router = new Router();
715
+ *
716
+ * router.post('/webhooks/backendrelay', async (ctx) => {
717
+ * try {
718
+ * await db.webhooks.processNodeRequest(handlers, ctx.req, {
719
+ * body: rawBody(ctx.req), // adapter awaits the Promise
720
+ * });
721
+ * ctx.status = 200;
722
+ * } catch (e) {
723
+ * ctx.status = 400;
724
+ * ctx.body = { error: String(e) };
725
+ * }
726
+ * });
727
+ *
728
+ * @example
729
+ * // NestJS (Express adapter). With `rawBody: true` on the factory, Nest
730
+ * // populates `req.rawBody` itself — just pass `req`.
731
+ * import { Controller, Post, Req, HttpCode } from '@nestjs/common';
732
+ * import type { Request } from 'express';
733
+ *
734
+ * @Controller('webhooks')
735
+ * export class WebhooksController {
736
+ * @Post('instant')
737
+ * @HttpCode(200)
738
+ * async handle(@Req() req: Request) {
739
+ * await db.webhooks.processNodeRequest(handlers, req);
740
+ * }
741
+ * }
742
+ *
743
+ * // (Pair with `NestFactory.create(AppModule, { rawBody: true })` in main.ts.)
744
+ */
745
+ async processNodeRequest(handlers, req, opts) {
746
+ let rawBody;
747
+ let bodyWasReserialized = false;
748
+ // Priority: an explicit `opts.body`, then `req.rawBody` (set by
749
+ // middleware like Firebase Functions or body-parser's `verify` hook),
750
+ // then `req.body`, then the unconsumed request stream.
751
+ let bodyValue = opts?.body ?? req.rawBody ?? req.body;
752
+ // Allow callers to pass a Promise (e.g. the result of `raw-body(ctx.req)`
753
+ // in Koa) without having to await first.
754
+ if (bodyValue != null &&
755
+ typeof bodyValue.then === 'function') {
756
+ bodyValue = await bodyValue;
757
+ }
758
+ if (typeof bodyValue === 'string') {
759
+ rawBody = bodyValue;
760
+ }
761
+ else if (bodyValue instanceof Uint8Array) {
762
+ rawBody = new TextDecoder('utf-8').decode(bodyValue);
763
+ }
764
+ else if (bodyValue != null && typeof bodyValue === 'object') {
765
+ // A JSON parser middleware (e.g. `express.json()`) has consumed the
766
+ // stream and handed us a parsed object. Re-serialize and try anyway —
767
+ // for BackendRelay's webhook body shape this typically round-trips to the
768
+ // bytes the server signed. If it doesn't, we surface a targeted error
769
+ // below.
770
+ try {
771
+ rawBody = JSON.stringify(bodyValue);
772
+ bodyWasReserialized = true;
773
+ }
774
+ catch {
775
+ throw new BackendRelayError('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.');
776
+ }
777
+ }
778
+ else if (req[Symbol.asyncIterator]) {
779
+ const encoder = new TextEncoder();
780
+ const chunks = [];
781
+ for await (const chunk of req) {
782
+ chunks.push(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);
783
+ }
784
+ let total = 0;
785
+ for (const c of chunks)
786
+ total += c.byteLength;
787
+ const buf = new Uint8Array(total);
788
+ let offset = 0;
789
+ for (const c of chunks) {
790
+ buf.set(c, offset);
791
+ offset += c.byteLength;
792
+ }
793
+ rawBody = new TextDecoder('utf-8').decode(buf);
794
+ }
795
+ else {
796
+ throw new BackendRelayError('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.');
797
+ }
798
+ const host = typeof req.headers.host === 'string' ? req.headers.host : 'localhost';
799
+ const url = new URL(req.url ?? '/', `https://${host}`);
800
+ const headers = new Headers();
801
+ for (const [k, v] of Object.entries(req.headers)) {
802
+ if (typeof v === 'string')
803
+ headers.set(k, v);
804
+ else if (Array.isArray(v))
805
+ headers.set(k, v.join(', '));
806
+ }
807
+ const webReq = new Request(url, {
808
+ method: req.method ?? 'POST',
809
+ headers,
810
+ body: rawBody,
811
+ });
812
+ try {
813
+ await this.processRequest(handlers, webReq, opts);
814
+ }
815
+ catch (e) {
816
+ if (bodyWasReserialized &&
817
+ e instanceof BackendRelayError &&
818
+ e.message === 'BackendRelay Signature did not validate') {
819
+ throw new BackendRelayError('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: e.hint });
820
+ }
821
+ throw e;
822
+ }
823
+ }
824
+ }
825
+ //# sourceMappingURL=index.js.map