@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
package/src/Reactor.js DELETED
@@ -1,1541 +0,0 @@
1
- // @ts-check
2
- import weakHash from './utils/weakHash.ts';
3
- import * as instaml from './instaml.ts';
4
- import * as s from './store.ts';
5
- import uuid from './utils/id.ts';
6
- import IndexedDBStorage from './IndexedDBStorage.ts';
7
- import WindowNetworkListener from './WindowNetworkListener.js';
8
- import * as authAPI from './authAPI.ts';
9
- import * as StorageApi from './StorageAPI.ts';
10
- import * as flags from './utils/flags.ts';
11
- import { Deferred } from './utils/Deferred.ts';
12
- import { PersistedObject, StoreInterface } from './utils/PersistedObject.ts';
13
-
14
- import { areObjectsDeepEqual } from './utils/object.js';
15
- import { createLinkIndex } from './utils/linkIndex.ts';
16
- import version from './version.ts';
17
- import createLogger from './utils/log.ts';
18
- import { validateQuery } from './queryValidation.ts';
19
- import { validateTransactions } from './transactionValidation.ts';
20
- import { BackendRelayError, notifyError } from './BackendRelayError.ts';
21
- import { deriveWebsocketURI, requireApiURI } from './urls.ts';
22
- import { validate as validateUUID } from 'uuid';
23
- import { SyncTable } from './SyncTable.ts';
24
- import { BackendRelayStream } from './Stream.ts';
25
- import { STATUS } from './reactorTypes.ts';
26
- import {
27
- createKvStore,
28
- createMutationsStore,
29
- createQuerySubsStore,
30
- writeStreamsKey,
31
- } from './reactorStorage.js';
32
- import {
33
- PENDING_TX_CLEANUP_TIMEOUT,
34
- PENDING_MUTATION_CLEANUP_THRESHOLD,
35
- applyOptimisticUpdates,
36
- cleanupPendingMutationsQueries,
37
- cleanupPendingMutationsTimeout,
38
- finishTransaction,
39
- handleMutationError,
40
- optimisticAttrs,
41
- rewriteMutations,
42
- rewriteMutationsSorted,
43
- sendMutation,
44
- } from './reactorMutations.js';
45
- import {
46
- QUERY_ONCE_TIMEOUT,
47
- addQueryData,
48
- cleanupQuery,
49
- completeQueryOnce,
50
- completeQueryOnceWithResult,
51
- dataForQuery,
52
- getPreviousResult,
53
- hasQueryListeners,
54
- notifyAll,
55
- notifyOne,
56
- notifyOneQueryOnce,
57
- notifyQueryError,
58
- notifyQueryOnceError,
59
- startQuerySub,
60
- tryMigrateLegacyQuerySub,
61
- unsubQuery,
62
- } from './reactorSubs.js';
63
- import {
64
- flushPendingMessages,
65
- retryAddQuery,
66
- scheduleReconnect,
67
- startSocket,
68
- transportOnClose,
69
- transportOnMessage,
70
- transportOnOpen,
71
- transportOnError,
72
- trySend,
73
- trySendAuthed,
74
- } from './reactorTransport.js';
75
- import { handleReceive, handleReceiveError } from './reactorEvents.js';
76
- import {
77
- cleanupRoom,
78
- flushEnqueuedRoomData,
79
- getPresence,
80
- joinRoom,
81
- notifyBroadcastSubs,
82
- notifyPresenceSub,
83
- notifyPresenceSubs,
84
- patchPresencePeers,
85
- publishPresence,
86
- publishTopic,
87
- setPresencePeers,
88
- subscribePresence,
89
- subscribeTopic,
90
- tryBroadcast,
91
- tryJoinRoom,
92
- tryLeaveRoom,
93
- trySetPresence,
94
- trySetRoomConnected,
95
- } from './reactorRooms.js';
96
- import {
97
- COOKIE_SYNC_LAST_UPDATED_KEY,
98
- currentUserKey,
99
- createAuthorizationUrl,
100
- getCurrentUserFromStorage,
101
- hasCurrentUser,
102
- oauthLoginInit,
103
- replaceUrlAfterOAuth,
104
- setCurrentUser,
105
- setupUserSyncTimer,
106
- syncUserToEndpoint,
107
- } from './reactorAuth.js';
108
-
109
- /** @typedef {import('./utils/log.ts').Logger} Logger */
110
- /** @typedef {import('./Connection.ts').Connection} Connection */
111
- /** @typedef {import('./Connection.ts').TransportType} TransportType */
112
- /** @typedef {import('./Connection.ts').EventSourceConstructor} EventSourceConstructor */
113
- /** @typedef {import('./reactorTypes.ts').QuerySub} QuerySub */
114
- /** @typedef {import('./reactorTypes.ts').QuerySubInStorage} QuerySubInStorage */
115
- /** @typedef {import('./clientTypes.ts').User} User */
116
- /** @typedef {import('./clientTypes.ts').AuthState} AuthState */
117
- /** @typedef {import('./framework.ts').FrameworkClient} FrameworkClient */
118
-
119
- export { STATUS };
120
- export { COOKIE_SYNC_LAST_UPDATED_KEY };
121
-
122
- function isClient() {
123
- const hasWindow = typeof window !== 'undefined';
124
- // this checks if we are running in a chrome extension
125
- // @ts-expect-error
126
- const isChrome = typeof chrome !== 'undefined';
127
-
128
- return hasWindow || isChrome;
129
- }
130
-
131
- /**
132
- * @template {import('./presence.ts').RoomSchemaShape} [RoomSchema = {}]
133
- */
134
- export default class Reactor {
135
- /** @type {s.AttrsStore | undefined} */
136
- attrs;
137
- _isOnline = true;
138
- _isShutdown = false;
139
- status = STATUS.CONNECTING;
140
-
141
- /** @type {PersistedObject<string, QuerySub, QuerySubInStorage>} */
142
- querySubs;
143
-
144
- /** @type {PersistedObject} */
145
- kv;
146
-
147
- /** @type {PersistedObject} */
148
- mutations;
149
-
150
- /** @type {SyncTable} */
151
- _syncTable;
152
- /** @type {BackendRelayStream} */
153
- _backendrelayStream;
154
-
155
- /** @type {Record<string, Array<{ q: any, cb: (data: any) => any }>>} */
156
- queryCbs = {};
157
- /** @type {Record<string, Array<{ q: any, eventId: string, dfd: Deferred }>>} */
158
- queryOnceDfds = {};
159
- authCbs = [];
160
- attrsCbs = [];
161
- mutationErrorCbs = [];
162
- connectionStatusCbs = [];
163
- appStatusCbs = [];
164
- /**
165
- * Carries the raw server status off the public type: `disabled` is an
166
- * operator-level state we don't surface to apps.
167
- * @type {import('./clientTypes.ts').AppStatusState & { status?: 'active' | 'read-only' | 'disabled' }}
168
- */
169
- _appStatusState = { isLoading: true, isReadOnly: undefined };
170
- config;
171
- mutationDeferredStore = new Map();
172
- _reconnectTimeoutId = null;
173
- _reconnectTimeoutMs = 0;
174
- _reconnectAttempt = 0;
175
- _addQueryRetryAttempts = new Map();
176
- /** @type {Connection} */
177
- _transport;
178
- /** @type {TransportType} */
179
- _transportType = 'ws';
180
-
181
- /** @type {EventSourceConstructor} */
182
- _EventSource;
183
- /** @type {boolean | null} */
184
- _wsOk = null;
185
- _localIdPromises = {};
186
- _errorMessage = null;
187
- /** @type {Promise<null | {error: {message: string}}> | null}**/
188
- _oauthCallbackResponse = null;
189
-
190
- /** @type {null | import('./utils/linkIndex.ts').LinkIndex}} */
191
- _linkIndex = null;
192
-
193
- /** @type BroadcastChannel | undefined */
194
- _broadcastChannel;
195
-
196
- /** @type {Record<string, {roomType: string; isConnected: boolean; error: any}>} */
197
- _rooms = {};
198
- /** @type {Record<string, boolean>} */
199
- _roomsPendingLeave = {};
200
- _presence = {};
201
- _broadcastQueue = [];
202
- _broadcastSubs = {};
203
- /** @type {{isLoading: boolean; error: any | undefined, user: any | undefined}} */
204
- _currentUserCached = { isLoading: true, error: undefined, user: undefined };
205
- _beforeUnloadCbs = [];
206
- _dataForQueryCache = {};
207
- // True once the mutations store has loaded (or a local write happened),
208
- // which gates optimistic query results the way the old single
209
- // `pendingMutations` kv key did.
210
- _pendingMutationsReady = false;
211
- /** @type {{version: number, muts: Map<string, any>} | null} */
212
- _pendingMutationsCache = null;
213
- /** @type {Promise<void>} */
214
- _pendingMutationsLoaded = Promise.resolve();
215
- // eventIds found in storage during load that no in-memory write claimed;
216
- // unconfirmed ones are re-sent once the full set has loaded.
217
- _recoveredMutationIds = new Set();
218
- _ignoreStoredMutations = false;
219
- /** @type {Logger} */
220
- _log;
221
- _pendingTxCleanupTimeout;
222
- _pendingMutationCleanupThreshold;
223
- _inFlightMutationEventIds = new Set();
224
- /** @type FrameworkClient | null */
225
- _frameworkClient = null;
226
-
227
- constructor(
228
- config,
229
- Storage = IndexedDBStorage,
230
- NetworkListener = WindowNetworkListener,
231
- versions,
232
- EventSourceConstructor,
233
- ) {
234
- this._EventSource = EventSourceConstructor;
235
-
236
- this.config = { ...config };
237
- this.queryCacheLimit = this.config.queryCacheLimit ?? 10;
238
- this._pendingTxCleanupTimeout =
239
- this.config.pendingTxCleanupTimeout ?? PENDING_TX_CLEANUP_TIMEOUT;
240
- this._pendingMutationCleanupThreshold =
241
- this.config.pendingMutationCleanupThreshold ??
242
- PENDING_MUTATION_CLEANUP_THRESHOLD;
243
-
244
- this._log = createLogger(
245
- config.verbose || flags.devBackend || flags.backendrelayLogs,
246
- () => this._reactorStats(),
247
- config.logger,
248
- );
249
-
250
- this.versions = { ...(versions || {}), '@backendrelay/core': version };
251
-
252
- if (this.config.schema) {
253
- this._linkIndex = createLinkIndex(this.config.schema);
254
- }
255
-
256
- // This is to protect us against running
257
- // server-side.
258
- if (!isClient()) {
259
- return;
260
- }
261
-
262
- if (!config.appId) {
263
- throw new Error('BackendRelay must be initialized with an appId.');
264
- }
265
-
266
- if (!validateUUID(config.appId)) {
267
- throw new Error(
268
- `BackendRelay must be initialized with a valid appId. \`${config.appId}\` is not a valid uuid.`,
269
- );
270
- }
271
-
272
- this.config.apiURI = requireApiURI(
273
- this.config.apiURI,
274
- 'BackendRelay core SDK',
275
- );
276
- if (!this.config.websocketURI) {
277
- this.config.websocketURI = deriveWebsocketURI(this.config.apiURI);
278
- }
279
-
280
- if (typeof BroadcastChannel === 'function') {
281
- this._broadcastChannel = new BroadcastChannel('@instantdb');
282
- this._broadcastChannel.addEventListener('message', async (e) => {
283
- try {
284
- if (e.data?.type === 'auth') {
285
- const res = await this.getCurrentUser({
286
- forceReadFromStorage: true,
287
- });
288
- await this.updateUser(res.user).catch((error) => {
289
- this._log.error('[error] update user', error);
290
- });
291
- }
292
- } catch (e) {
293
- this._log.error('[error] handle broadcast channel', e);
294
- }
295
- });
296
- }
297
-
298
- this._initStorage(Storage);
299
-
300
- this._syncTable = new SyncTable(
301
- this._trySendAuthed.bind(this),
302
- new Storage(this.config.appId, 'syncSubs'),
303
- {
304
- useDateObjects: this.config.useDateObjects,
305
- },
306
- this._log,
307
- (triples) => {
308
- return s.createStore(
309
- this.ensureAttrs(),
310
- triples,
311
- this.config.cardinalityInference,
312
- this.config.useDateObjects,
313
- );
314
- },
315
- () => this.ensureAttrs(),
316
- );
317
-
318
- this._backendrelayStream = new BackendRelayStream({
319
- WStream: this.config.WritableStream || WritableStream,
320
- RStream: this.config.ReadableStream || ReadableStream,
321
- trySend: this._trySendAuthed.bind(this),
322
- log: this._log,
323
- writeStreamPersistence: {
324
- load: async (clientId) => {
325
- await this.kv.waitForKeyToLoad(writeStreamsKey);
326
- return this.kv.currentValue[writeStreamsKey]?.[clientId];
327
- },
328
- save: (clientId, stream) => {
329
- this.kv.updateInPlace((prev) => {
330
- const streams = prev[writeStreamsKey] || {};
331
- streams[clientId] = stream;
332
- prev[writeStreamsKey] = streams;
333
- });
334
- },
335
- remove: (clientId) => {
336
- this.kv.updateInPlace((prev) => {
337
- const streams = prev[writeStreamsKey];
338
- if (!streams) {
339
- return;
340
- }
341
- delete streams[clientId];
342
- if (!Object.keys(streams).length) {
343
- delete prev[writeStreamsKey];
344
- }
345
- });
346
- },
347
- },
348
- });
349
-
350
- this._oauthCallbackResponse = this._oauthLoginInit();
351
- this.setupUserSyncTimer();
352
-
353
- NetworkListener.getIsOnline().then((isOnline) => {
354
- this._isOnline = isOnline;
355
- this._startSocket();
356
- NetworkListener.listen((isOnline) => {
357
- // We do this because react native's NetInfo
358
- // fires multiple online events.
359
- // We only want to handle one state change
360
- if (isOnline === this._isOnline) {
361
- return;
362
- }
363
- this._log.info('[network] online =', isOnline);
364
- this._isOnline = isOnline;
365
- if (this._isOnline) {
366
- this._startSocket();
367
- } else {
368
- this._log.info(
369
- 'Changing status from',
370
- this.status,
371
- 'to',
372
- STATUS.CLOSED,
373
- );
374
- this._setStatus(STATUS.CLOSED);
375
- }
376
- });
377
- });
378
-
379
- if (typeof addEventListener !== 'undefined') {
380
- this._beforeUnload = this._beforeUnload.bind(this);
381
- addEventListener('beforeunload', this._beforeUnload);
382
- }
383
- }
384
-
385
- getFrameworkClient() {
386
- return this._frameworkClient;
387
- }
388
-
389
- /** @param {FrameworkClient} client */
390
- setFrameworkClient(client) {
391
- this._frameworkClient = client;
392
- }
393
-
394
- ensureAttrs() {
395
- if (!this.attrs) {
396
- throw new Error('attrs have not loaded.');
397
- }
398
- return this.attrs;
399
- }
400
-
401
- updateSchema(schema) {
402
- this.config = {
403
- ...this.config,
404
- schema: schema,
405
- cardinalityInference: Boolean(schema),
406
- };
407
- this._linkIndex = schema ? createLinkIndex(this.config.schema) : null;
408
- }
409
-
410
- _reactorStats() {
411
- return {
412
- inFlightMutationCount: this._inFlightMutationEventIds.size,
413
- storedMutationCount: this._pendingMutations().size,
414
- transportType: this._transportType,
415
- };
416
- }
417
-
418
- _onQuerySubLoaded(hash) {
419
- this._pendingMutationsLoaded.then(() => this.notifyOne(hash));
420
- }
421
-
422
- _initStorage(Storage) {
423
- this.querySubs = createQuerySubsStore({
424
- appId: this.config.appId,
425
- Storage,
426
- log: this._log,
427
- useDateObjects: this.config.useDateObjects,
428
- });
429
- this.querySubs.onKeyLoaded = (k) => this._onQuerySubLoaded(k);
430
- this.kv = createKvStore({
431
- appId: this.config.appId,
432
- Storage,
433
- log: this._log,
434
- });
435
- this.mutations = createMutationsStore({
436
- appId: this.config.appId,
437
- Storage,
438
- log: this._log,
439
- isIgnoringStoredMutations: () => this._ignoreStoredMutations,
440
- onRecoveredMutation: (eventId) => this._recoveredMutationIds.add(eventId),
441
- });
442
- // Trigger immediate load for pendingMutations and currentUser
443
- this._pendingMutationsLoaded = this.mutations
444
- .waitForAllKeysToLoad()
445
- .catch((e) => this._log.error('Failed to load pending mutations', e))
446
- .then(() => this._onPendingMutationsLoaded());
447
- this.kv.waitForKeyToLoad(currentUserKey);
448
- this._beforeUnloadCbs.push(() => {
449
- this.kv.flush();
450
- this.mutations.flush();
451
- this.querySubs.flush();
452
- });
453
- }
454
-
455
- _beforeUnload() {
456
- for (const cb of this._beforeUnloadCbs) {
457
- cb();
458
- }
459
- this._syncTable.beforeUnload();
460
- }
461
-
462
- /**
463
- * @param {'enqueued' | 'pending' | 'synced' | 'timeout' | 'error' } status
464
- * @param {string} eventId
465
- * @param {{message?: string, type?: string, status?: number, hint?: unknown, traceId?: string}} [errorMsg]
466
- */
467
- _finishTransaction(status, eventId, errorMsg) {
468
- return finishTransaction(this, status, eventId, errorMsg);
469
- }
470
-
471
- _setStatus(status, err) {
472
- this.status = status;
473
- this._errorMessage = err;
474
- this.notifyConnectionStatusSubs(status);
475
- this._backendrelayStream.onConnectionStatusChange(status);
476
- }
477
-
478
- _onPendingMutationsLoaded() {
479
- this._pendingMutationsReady = true;
480
- // Loading keys doesn't bump the store version, so bump it here to
481
- // invalidate caches keyed on it (dataForQuery, _pendingMutations).
482
- this.mutations.updateInPlace(() => {});
483
- // Optimistic function updates only live for the duration of one call.
484
- // A reload cannot finish that call, so drop them instead of replaying.
485
- this._updatePendingMutations((prev) => {
486
- for (const [eventId, mut] of Object.entries(prev)) {
487
- if (mut.optimistic) {
488
- delete prev[eventId];
489
- }
490
- }
491
- });
492
- const recovered = this._recoveredMutationIds;
493
- this._recoveredMutationIds = new Set();
494
- if (recovered.size) {
495
- const rewritten = this._rewriteMutationsSorted(
496
- this.attrs,
497
- this._pendingMutations(),
498
- );
499
- rewritten.forEach(([eventId, mut]) => {
500
- if (recovered.has(eventId) && !mut['tx-id'] && !mut.optimistic) {
501
- this._sendMutation(eventId, mut);
502
- }
503
- });
504
- }
505
- this.notifyAll();
506
- }
507
-
508
- _flushEnqueuedRoomData(roomId) {
509
- flushEnqueuedRoomData(this, roomId);
510
- }
511
-
512
- /**
513
- * Does the same thing as add-query-ok
514
- * but called as a result of receiving query info from ssr
515
- * @param {any} q
516
- * @param {{ triples: any; pageInfo: any; }} result
517
- * @param {boolean} enableCardinalityInference
518
- */
519
- _addQueryData(q, result, enableCardinalityInference) {
520
- return addQueryData(this, q, result, enableCardinalityInference);
521
- }
522
-
523
- _handleReceive(connId, msg) {
524
- handleReceive(this, connId, msg);
525
- }
526
-
527
- createWriteStream(opts) {
528
- return this._backendrelayStream.createWriteStream(opts);
529
- }
530
-
531
- createReadStream(opts) {
532
- return this._backendrelayStream.createReadStream(opts);
533
- }
534
-
535
- // Read-only Map view over the mutations store, cached per store version.
536
- // Mutate through _updatePendingMutations, never through this Map.
537
- _pendingMutations() {
538
- const version = this.mutations.version();
539
- if (
540
- !this._pendingMutationsCache ||
541
- this._pendingMutationsCache.version !== version
542
- ) {
543
- this._pendingMutationsCache = {
544
- version,
545
- muts: new Map(Object.entries(this.mutations.currentValue)),
546
- };
547
- }
548
- return this._pendingMutationsCache.muts;
549
- }
550
-
551
- _updatePendingMutations(f) {
552
- this._pendingMutationsReady = true;
553
- this.mutations.updateInPlace((prev) => {
554
- f(prev);
555
- });
556
- }
557
-
558
- // Replaces the pending mutations with a rewritten map. Only entries whose
559
- // tx-steps actually changed get reassigned, so we only persist those rows.
560
- _setPendingMutations(muts) {
561
- this._updatePendingMutations((prev) => {
562
- for (const eventId of Object.keys(prev)) {
563
- if (!muts.has(eventId)) {
564
- delete prev[eventId];
565
- }
566
- }
567
- for (const [eventId, mut] of muts) {
568
- const prevMut = prev[eventId];
569
- if (!prevMut || prevMut['tx-steps'] !== mut['tx-steps']) {
570
- prev[eventId] = mut;
571
- }
572
- }
573
- });
574
- }
575
-
576
- /**
577
- * @param {'timeout' | 'error'} status
578
- * @param {string} eventId
579
- * @param {{message?: string, type?: string, status?: number, hint?: unknown, traceId?: string}} errorMsg
580
- */
581
- _handleMutationError(status, eventId, errorMsg) {
582
- handleMutationError(this, status, eventId, errorMsg);
583
- }
584
-
585
- /**
586
- * Re-sends an `add-query` whose last error was transient. Returns true when
587
- * the retry was scheduled, or false when the error should surface because the
588
- * attempt budget is exhausted.
589
- */
590
- _retryAddQuery(q, hash) {
591
- return retryAddQuery(this, q, hash);
592
- }
593
-
594
- _handleReceiveError(msg) {
595
- handleReceiveError(this, msg);
596
- }
597
-
598
- notifyQueryOnceError(q, hash, eventId, e) {
599
- notifyQueryOnceError(this, q, hash, eventId, e);
600
- }
601
-
602
- _setAttrs(attrs) {
603
- this.attrs = new s.AttrsStoreClass(
604
- attrs.reduce((acc, attr) => {
605
- acc[attr.id] = attr;
606
- return acc;
607
- }, {}),
608
- this._linkIndex,
609
- );
610
-
611
- this.notifyAttrsSubs();
612
- }
613
-
614
- // ---------------------------
615
- // Queries
616
-
617
- getPreviousResult = (q) => {
618
- return getPreviousResult(this, q);
619
- };
620
-
621
- _startQuerySub(q, hash) {
622
- return startQuerySub(this, q, hash);
623
- }
624
-
625
- // Legacy hash migration (async): covers entries that weren't preloaded
626
- // into currentValue. Actively loads the legacy key from storage, moves
627
- // its result onto the new key, and notifies subscribers. Safe to remove
628
- // a few releases after v1.0.39.
629
- _tryMigrateLegacyQuerySub(q, newHash) {
630
- return tryMigrateLegacyQuerySub(this, q, newHash);
631
- }
632
-
633
- subscribeTable(q, cb) {
634
- return this._syncTable.subscribe(q, cb);
635
- }
636
-
637
- /**
638
- * When a user subscribes to a query the following side effects occur:
639
- *
640
- * - We update querySubs to include the new query
641
- * - We update queryCbs to include the new cb
642
- * - If we already have a result for the query we call cb immediately
643
- * - We send the server an `add-query` message
644
- *
645
- * Returns an unsubscribe function
646
- */
647
- subscribeQuery(q, cb, opts) {
648
- if (!this.config.disableValidation) {
649
- validateQuery(q, this.config.schema);
650
- }
651
- if (opts && 'ruleParams' in opts) {
652
- q = { $$ruleParams: opts['ruleParams'], ...q };
653
- }
654
-
655
- const hash = weakHash(q);
656
-
657
- const prevResult = this.getPreviousResult(q);
658
- if (prevResult) {
659
- cb(prevResult);
660
- }
661
-
662
- this.queryCbs[hash] = this.queryCbs[hash] ?? [];
663
- this.queryCbs[hash].push({ q, cb });
664
-
665
- this._startQuerySub(q, hash);
666
-
667
- return () => {
668
- this._unsubQuery(q, hash, cb);
669
- };
670
- }
671
-
672
- queryOnce(q, opts) {
673
- if (!this.config.disableValidation) {
674
- validateQuery(q, this.config.schema);
675
- }
676
-
677
- if (opts && 'ruleParams' in opts) {
678
- q = { $$ruleParams: opts['ruleParams'], ...q };
679
- }
680
-
681
- const dfd = new Deferred();
682
-
683
- if (!this._isOnline) {
684
- dfd.reject(
685
- new Error("We can't run `queryOnce`, because the device is offline."),
686
- );
687
- return dfd.promise;
688
- }
689
-
690
- if (!this.querySubs) {
691
- dfd.reject(
692
- new Error(
693
- "We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.backendrelay.com/docs/backend#query",
694
- ),
695
- );
696
- return dfd.promise;
697
- }
698
-
699
- const hash = weakHash(q);
700
- const eventId = uuid();
701
-
702
- this.queryOnceDfds[hash] = this.queryOnceDfds[hash] ?? [];
703
- this.queryOnceDfds[hash].push({ q, dfd, eventId });
704
- this._trySendAuthed(eventId, { op: 'query-once', q });
705
-
706
- setTimeout(() => {
707
- const pending = this.queryOnceDfds[hash];
708
- if (pending) {
709
- this.queryOnceDfds[hash] = pending.filter((r) => r.dfd !== dfd);
710
- }
711
- dfd.reject(new Error('Query timed out'));
712
- }, QUERY_ONCE_TIMEOUT);
713
-
714
- return dfd.promise;
715
- }
716
-
717
- _completeQueryOnce(q, hash, dfd) {
718
- completeQueryOnce(this, q, hash, dfd);
719
- }
720
-
721
- _completeQueryOnceWithResult(q, msg) {
722
- completeQueryOnceWithResult(this, q, msg);
723
- }
724
-
725
- _unsubQuery(q, hash, cb) {
726
- unsubQuery(this, q, hash, cb);
727
- }
728
-
729
- _hasQueryListeners(hash) {
730
- return hasQueryListeners(this, hash);
731
- }
732
-
733
- _cleanupQuery(q, hash) {
734
- cleanupQuery(this, q, hash);
735
- }
736
-
737
- /**
738
- *
739
- * @param {s.AttrsStore} attrs
740
- * @param {any} muts
741
- * @param {number} [processedTxId]
742
- */
743
- _rewriteMutations(attrs, muts, processedTxId) {
744
- return rewriteMutations(attrs, muts, processedTxId);
745
- }
746
-
747
- _rewriteMutationsSorted(attrs, muts) {
748
- return rewriteMutationsSorted(this, attrs, muts);
749
- }
750
-
751
- // ---------------------------
752
- // Transact
753
-
754
- /**
755
- * @returns {s.AttrsStore}
756
- */
757
- optimisticAttrs() {
758
- return optimisticAttrs(this);
759
- }
760
-
761
- /** Runs instaql on a query and a store */
762
- dataForQuery(hash, applyOptimistic = true) {
763
- return dataForQuery(this, hash, applyOptimistic);
764
- }
765
-
766
- _applyOptimisticUpdates(store, attrsStore, mutations, processedTxId) {
767
- return applyOptimisticUpdates(store, attrsStore, mutations, processedTxId);
768
- }
769
-
770
- /** Re-run instaql and call all callbacks with new data */
771
- notifyOne = (hash) => {
772
- notifyOne(this, hash);
773
- };
774
-
775
- notifyOneQueryOnce = (hash) => {
776
- notifyOneQueryOnce(this, hash);
777
- };
778
-
779
- notifyQueryError = (hash, error) => {
780
- notifyQueryError(this, hash, error);
781
- };
782
-
783
- /** Re-compute all subscriptions */
784
- notifyAll() {
785
- notifyAll(this);
786
- }
787
-
788
- loadedNotifyAll() {
789
- this._pendingMutationsLoaded.then(() => this.notifyAll());
790
- }
791
-
792
- /** Applies transactions locally and sends transact message to server */
793
- pushTx = (chunks) => {
794
- // The server rejects every write while read-only or disabled, so reject
795
- // locally instead of applying an optimistic update
796
- if (this._appStatusState.isReadOnly) {
797
- return Promise.reject(
798
- this._appStatusState.status === 'disabled'
799
- ? new BackendRelayError('This app is currently disabled.', {
800
- status: 'disabled',
801
- })
802
- : new BackendRelayError('This app is in read-only mode.', {
803
- status: 'read-only',
804
- }),
805
- );
806
- }
807
- // Throws if transactions are invalid
808
- if (!this.config.disableValidation) {
809
- validateTransactions(chunks, this.config.schema);
810
- }
811
- try {
812
- const txSteps = instaml.transform(
813
- {
814
- attrsStore: this.optimisticAttrs(),
815
- schema: this.config.schema,
816
- stores: Object.values(this.querySubs.currentValue).map(
817
- (sub) => sub?.result?.store,
818
- ),
819
- useDateObjects: this.config.useDateObjects,
820
- },
821
- chunks,
822
- );
823
- return this.pushOps(txSteps);
824
- } catch (e) {
825
- return this.pushOps([], e);
826
- }
827
- };
828
-
829
- /**
830
- * @param {*} txSteps
831
- * @param {*} [error]
832
- * @returns
833
- */
834
- pushOps = (txSteps, error) => {
835
- const eventId = uuid();
836
- const mutations = [...this._pendingMutations().values()];
837
- const order = Math.max(0, ...mutations.map((mut) => mut.order || 0)) + 1;
838
- const mutation = {
839
- op: 'transact',
840
- 'tx-steps': txSteps,
841
- created: Date.now(),
842
- error,
843
- order,
844
- };
845
- this._updatePendingMutations((prev) => {
846
- prev[eventId] = mutation;
847
- });
848
-
849
- const dfd = new Deferred();
850
- this.mutationDeferredStore.set(eventId, dfd);
851
- this._sendMutation(eventId, mutation);
852
-
853
- this.notifyAll();
854
-
855
- return dfd.promise;
856
- };
857
-
858
- /**
859
- * Applies a transaction to local queries without sending it to the server.
860
- * The caller rolls it back when the real write completes or fails. Used by
861
- * server-function calls, whose real write is not a client transaction.
862
- */
863
- pushOptimisticTx = (chunks) => {
864
- if (!this.config.disableValidation) {
865
- validateTransactions(chunks, this.config.schema);
866
- }
867
- const txSteps = instaml.transform(
868
- {
869
- attrsStore: this.optimisticAttrs(),
870
- schema: this.config.schema,
871
- stores: Object.values(this.querySubs.currentValue).map(
872
- (sub) => sub?.result?.store,
873
- ),
874
- useDateObjects: this.config.useDateObjects,
875
- },
876
- chunks,
877
- );
878
- const eventId = uuid();
879
- const mutations = [...this._pendingMutations().values()];
880
- const order = Math.max(0, ...mutations.map((mut) => mut.order || 0)) + 1;
881
- this._updatePendingMutations((prev) => {
882
- prev[eventId] = {
883
- op: 'optimistic',
884
- 'tx-steps': txSteps,
885
- created: Date.now(),
886
- order,
887
- optimistic: true,
888
- };
889
- });
890
- this.notifyAll();
891
- return {
892
- eventId,
893
- rollback: () => {
894
- this._updatePendingMutations((prev) => {
895
- delete prev[eventId];
896
- });
897
- this.notifyAll();
898
- },
899
- };
900
- };
901
-
902
- shutdown() {
903
- this._log.info('[shutdown]', this.config.appId);
904
- this._isShutdown = true;
905
- this._transport?.close();
906
- }
907
-
908
- /**
909
- * Sends mutation to server and schedules a timeout to cancel it if
910
- * we don't hear back in time.
911
- * Note: If we're offline we don't schedule a timeout, we'll schedule it
912
- * later once we're back online and send the mutation again
913
- *
914
- */
915
- _sendMutation(eventId, mutation) {
916
- sendMutation(this, eventId, mutation);
917
- }
918
-
919
- // ---------------------------
920
- // Websocket
921
-
922
- /** Send messages we accumulated while we were connecting */
923
- _flushPendingMessages() {
924
- flushPendingMessages(this);
925
- }
926
-
927
- /**
928
- * Clean up pendingMutations that all queries have seen
929
- */
930
- _cleanupPendingMutationsQueries() {
931
- cleanupPendingMutationsQueries(this);
932
- }
933
-
934
- /**
935
- * After mutations is confirmed by server, we give each query 30 sec
936
- * to update its results. If that doesn't happen, we assume query is
937
- * unaffected by this mutation and it’s safe to delete it from local queue
938
- */
939
- _cleanupPendingMutationsTimeout() {
940
- cleanupPendingMutationsTimeout(this);
941
- }
942
-
943
- _trySendAuthed(...args) {
944
- trySendAuthed(this, ...args);
945
- }
946
-
947
- _trySend(eventId, msg, opts) {
948
- trySend(this, eventId, msg, opts);
949
- }
950
-
951
- _transportOnOpen = (e) => {
952
- transportOnOpen(this, e);
953
- };
954
-
955
- _transportOnMessage = (e) => {
956
- transportOnMessage(this, e);
957
- };
958
-
959
- _transportOnError = (e) => {
960
- transportOnError(this, e);
961
- };
962
-
963
- _scheduleReconnect = ({ immediate = false } = {}) => {
964
- scheduleReconnect(this, { immediate });
965
- };
966
-
967
- _transportOnClose = (e) => {
968
- transportOnClose(this, e);
969
- };
970
-
971
- _startSocket() {
972
- startSocket(this);
973
- }
974
-
975
- /**
976
- * Given a key, returns a stable local id, unique to this device and app.
977
- *
978
- * This can be useful if you want to create guest ids for example.
979
- *
980
- * Note: If the user deletes their local storage, this id will change.
981
- *
982
- */
983
- async getLocalId(name) {
984
- const k = `localToken_${name}`;
985
- if (this.kv.currentValue[k]) {
986
- return this.kv.currentValue[k];
987
- }
988
-
989
- const current = await this.kv.waitForKeyToLoad(k);
990
- if (current) {
991
- return current;
992
- }
993
- const newId = uuid();
994
- this.kv.updateInPlace((prev) => {
995
- if (prev[k]) return;
996
- prev[k] = newId;
997
- });
998
- return await this.kv.waitForKeyToLoad(k);
999
- }
1000
-
1001
- // ----
1002
- // Auth
1003
-
1004
- _replaceUrlAfterOAuth() {
1005
- replaceUrlAfterOAuth();
1006
- }
1007
-
1008
- /**
1009
- *
1010
- * @returns Promise<null | {error: {message: string}}>
1011
- */
1012
- _oauthLoginInit() {
1013
- return oauthLoginInit(this);
1014
- }
1015
-
1016
- async _waitForOAuthCallbackResponse() {
1017
- return await this._oauthCallbackResponse;
1018
- }
1019
-
1020
- __subscribeMutationErrors(cb) {
1021
- this.mutationErrorCbs.push(cb);
1022
-
1023
- return () => {
1024
- this.mutationErrorCbs = this.mutationErrorCbs.filter((x) => x !== cb);
1025
- };
1026
- }
1027
-
1028
- subscribeAuth(cb) {
1029
- this.authCbs.push(cb);
1030
- const currUserCached = this._currentUserCached;
1031
- if (!currUserCached.isLoading) {
1032
- cb(this._currentUserCached);
1033
- }
1034
- let unsubbed = false;
1035
- this.getCurrentUser().then((resp) => {
1036
- if (unsubbed) return;
1037
- if (areObjectsDeepEqual(resp, currUserCached)) return;
1038
- cb(resp);
1039
- });
1040
- return () => {
1041
- unsubbed = true;
1042
- this.authCbs = this.authCbs.filter((x) => x !== cb);
1043
- };
1044
- }
1045
-
1046
- async getAuth() {
1047
- const { user, error } = await this.getCurrentUser();
1048
- if (error) {
1049
- throw new BackendRelayError(
1050
- 'Could not get current user: ' + error.message,
1051
- );
1052
- }
1053
- return user ?? null;
1054
- }
1055
-
1056
- subscribeConnectionStatus(cb) {
1057
- this.connectionStatusCbs.push(cb);
1058
-
1059
- return () => {
1060
- this.connectionStatusCbs = this.connectionStatusCbs.filter(
1061
- (x) => x !== cb,
1062
- );
1063
- };
1064
- }
1065
-
1066
- /**
1067
- * @param {'active' | 'read-only' | 'disabled' | undefined} status
1068
- */
1069
- _setAppStatus(status) {
1070
- if (!status || status === this._appStatusState.status) return;
1071
- this._appStatusState = {
1072
- isLoading: false,
1073
- isReadOnly: status !== 'active',
1074
- status,
1075
- };
1076
- this.notifyAppStatusSubs(this._appStatusState);
1077
- }
1078
-
1079
- subscribeAppStatus(cb) {
1080
- this.appStatusCbs.push(cb);
1081
- cb(this._appStatusState);
1082
-
1083
- return () => {
1084
- this.appStatusCbs = this.appStatusCbs.filter((x) => x !== cb);
1085
- };
1086
- }
1087
-
1088
- subscribeAttrs(cb) {
1089
- this.attrsCbs.push(cb);
1090
-
1091
- if (this.attrs) {
1092
- cb(this.attrs.attrs);
1093
- }
1094
-
1095
- return () => {
1096
- this.attrsCbs = this.attrsCbs.filter((x) => x !== cb);
1097
- };
1098
- }
1099
-
1100
- notifyAuthSubs(user) {
1101
- this.authCbs.forEach((cb) => cb(user));
1102
- }
1103
-
1104
- notifyMutationErrorSubs(error) {
1105
- this.mutationErrorCbs.forEach((cb) => cb(error));
1106
- }
1107
-
1108
- _notifyError(error) {
1109
- notifyError(this.config.onError, error);
1110
- }
1111
-
1112
- notifyAttrsSubs() {
1113
- if (!this.attrs) return;
1114
- const oas = this.optimisticAttrs();
1115
- this.attrsCbs.forEach((cb) => cb(oas.attrs));
1116
- }
1117
-
1118
- notifyConnectionStatusSubs(status) {
1119
- this.connectionStatusCbs.forEach((cb) => cb(status));
1120
- }
1121
-
1122
- notifyAppStatusSubs(state) {
1123
- this.appStatusCbs.forEach((cb) => cb(state));
1124
- }
1125
-
1126
- async setCurrentUser(user) {
1127
- await setCurrentUser(this, user);
1128
- }
1129
-
1130
- getCurrentUserCached() {
1131
- return this._currentUserCached;
1132
- }
1133
-
1134
- /**
1135
- * @param {{ forceReadFromStorage?: boolean }} [opts]
1136
- * @returns {Promise<User | undefined>}
1137
- */
1138
- async _getCurrentUser(opts) {
1139
- return await getCurrentUserFromStorage(this, opts);
1140
- }
1141
-
1142
- /**
1143
- * @param {{ forceReadFromStorage?: boolean }} [opts]
1144
- * @returns {Promise<AuthState>}
1145
- */
1146
- async getCurrentUser(opts) {
1147
- const oauthResp = await this._waitForOAuthCallbackResponse();
1148
- if (oauthResp?.error) {
1149
- const errorV = { error: oauthResp.error, user: undefined };
1150
- this._currentUserCached = { isLoading: false, ...errorV };
1151
- return this._currentUserCached;
1152
- }
1153
- try {
1154
- const user = await this._getCurrentUser(opts);
1155
- const userV = { user: user, error: undefined };
1156
- this._currentUserCached = {
1157
- isLoading: false,
1158
- ...userV,
1159
- };
1160
- return this._currentUserCached;
1161
- } catch (e) {
1162
- return {
1163
- user: undefined,
1164
- isLoading: false,
1165
- error: { message: e?.message || 'Error loading user' },
1166
- };
1167
- }
1168
- }
1169
-
1170
- async _hasCurrentUser() {
1171
- return await hasCurrentUser(this);
1172
- }
1173
-
1174
- async changeCurrentUser(newUser) {
1175
- const { user: oldUser } = await this.getCurrentUser();
1176
- if (areObjectsDeepEqual(oldUser, newUser)) {
1177
- // We were already logged in as the newUser, don't
1178
- // bother updating
1179
- return;
1180
- }
1181
-
1182
- // Clear any data in the framework client
1183
- this._frameworkClient = null;
1184
- // The queue and identity now live in different stores. Clear the old
1185
- // user's durable queue before publishing the new identity, including
1186
- // when storage fails or the process exits between these operations.
1187
- await this._clearPendingMutationsForAuth();
1188
- await this.setCurrentUser(newUser);
1189
- // We need to remove all `result` from querySubs,
1190
- // as they are no longer valid for the new user
1191
- await this.updateUser(newUser);
1192
-
1193
- try {
1194
- // Make sure everything is written to storage before we tell the
1195
- // other tab to refetch
1196
- await this.kv.flush();
1197
- await this.mutations.flush();
1198
- this._broadcastChannel?.postMessage({ type: 'auth' });
1199
- } catch (error) {
1200
- console.error('Error posting message to broadcast channel', error);
1201
- }
1202
- }
1203
-
1204
- async setupUserSyncTimer() {
1205
- await setupUserSyncTimer(this);
1206
- }
1207
-
1208
- async syncUserToEndpoint(user) {
1209
- await syncUserToEndpoint(this, user);
1210
- }
1211
-
1212
- async _clearPendingMutationsForAuth() {
1213
- this._ignoreStoredMutations = true;
1214
- this._recoveredMutationIds.clear();
1215
- this._updatePendingMutations((prev) => {
1216
- // Mark all pending mutations with an error, since we won't be able to
1217
- // deliver the result
1218
- for (const eventId of Object.keys(prev)) {
1219
- if (this.mutationDeferredStore.get(eventId)) {
1220
- this._finishTransaction('error', eventId, {
1221
- message: 'User changed while transaction was in progress.',
1222
- type: 'user-changed',
1223
- });
1224
- }
1225
- delete prev[eventId];
1226
- }
1227
- });
1228
- await this.mutations.clearUnloadedKeys();
1229
- await this.mutations.flush();
1230
- }
1231
-
1232
- async updateUser(newUser) {
1233
- this._ignoreStoredMutations = true;
1234
- this._recoveredMutationIds.clear();
1235
- const newV = { error: undefined, user: newUser };
1236
- this._currentUserCached = { isLoading: false, ...newV };
1237
- this._dataForQueryCache = {};
1238
- this.querySubs.updateInPlace((prev) => {
1239
- Object.keys(prev).forEach((k) => {
1240
- delete prev[k].result;
1241
- });
1242
- });
1243
- this.querySubs.clearUnloadedKeys();
1244
- await this._clearPendingMutationsForAuth();
1245
-
1246
- this._reconnectTimeoutMs = 0;
1247
- this._reconnectAttempt = 0;
1248
- this._transport.close();
1249
- this._oauthCallbackResponse = null;
1250
- this.notifyAuthSubs(newV);
1251
- try {
1252
- await this.syncUserToEndpoint(newUser);
1253
- } catch (error) {
1254
- this._log.error('Error syncing user with external endpoint', error);
1255
- }
1256
- }
1257
-
1258
- sendMagicCode({ email }) {
1259
- return authAPI.sendMagicCode({
1260
- apiURI: this.config.apiURI,
1261
- appId: this.config.appId,
1262
- email: email,
1263
- });
1264
- }
1265
-
1266
- async signInWithMagicCode(params) {
1267
- const currentUser = await this.getCurrentUser();
1268
- const isGuest = currentUser?.user?.type === 'guest';
1269
- const res = await authAPI.checkMagicCode({
1270
- apiURI: this.config.apiURI,
1271
- appId: this.config.appId,
1272
- email: params.email,
1273
- code: params.code,
1274
- refreshToken: isGuest ? currentUser?.user?.refresh_token : undefined,
1275
- extraFields: params.extraFields,
1276
- });
1277
- await this.changeCurrentUser(res.user);
1278
- return res;
1279
- }
1280
-
1281
- async signInWithCustomToken(authToken) {
1282
- const res = await authAPI.verifyRefreshToken({
1283
- apiURI: this.config.apiURI,
1284
- appId: this.config.appId,
1285
- refreshToken: authToken,
1286
- });
1287
- await this.changeCurrentUser(res.user);
1288
- return res;
1289
- }
1290
-
1291
- async signInAsGuest(params) {
1292
- const res = await authAPI.signInAsGuest({
1293
- apiURI: this.config.apiURI,
1294
- appId: this.config.appId,
1295
- extraFields: params?.extraFields,
1296
- });
1297
- await this.changeCurrentUser(res.user);
1298
- return res;
1299
- }
1300
-
1301
- potentiallyInvalidateToken(currentUser, opts) {
1302
- const refreshToken = currentUser?.user?.refresh_token;
1303
- if (!refreshToken) {
1304
- return;
1305
- }
1306
- const wantsToSkip = opts.invalidateToken === false;
1307
- if (wantsToSkip) {
1308
- this._log.info('[auth-invalidate] skipped invalidateToken');
1309
- return;
1310
- }
1311
- authAPI
1312
- .signOut({
1313
- apiURI: this.config.apiURI,
1314
- appId: this.config.appId,
1315
- refreshToken,
1316
- })
1317
- .then(() => {
1318
- this._log.info('[auth-invalidate] completed invalidateToken');
1319
- })
1320
- .catch((e) => {});
1321
- }
1322
-
1323
- async signOut(opts) {
1324
- const currentUser = await this.getCurrentUser();
1325
- this.potentiallyInvalidateToken(currentUser, opts);
1326
- await this.changeCurrentUser(null);
1327
- }
1328
-
1329
- /**
1330
- * Creates an OAuth authorization URL.
1331
- *
1332
- * @param {Object} params - The parameters to create the authorization URL.
1333
- * @param {string} params.clientName - The name of the client requesting authorization.
1334
- * @param {string} params.redirectURL - The URL to redirect users to after authorization.
1335
- * @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
1336
- * @returns {string} The created authorization URL.
1337
- */
1338
- createAuthorizationURL({ clientName, redirectURL, extraFields }) {
1339
- return createAuthorizationUrl(this, {
1340
- clientName,
1341
- redirectURL,
1342
- extraFields,
1343
- });
1344
- }
1345
-
1346
- /**
1347
- * @param {Object} params
1348
- * @param {string} params.code - The code received from the OAuth service.
1349
- * @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
1350
- * @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
1351
- */
1352
- async exchangeCodeForToken({ code, codeVerifier, extraFields }) {
1353
- const currentUser = await this.getCurrentUser();
1354
- const isGuest = currentUser?.user?.type === 'guest';
1355
- const res = await authAPI.exchangeCodeForToken({
1356
- apiURI: this.config.apiURI,
1357
- appId: this.config.appId,
1358
- code: code,
1359
- codeVerifier,
1360
- refreshToken: isGuest ? currentUser?.user?.refresh_token : undefined,
1361
- extraFields,
1362
- });
1363
- await this.changeCurrentUser(res.user);
1364
- return res;
1365
- }
1366
-
1367
- issuerURI() {
1368
- const { apiURI, appId } = this.config;
1369
- return `${apiURI}/runtime/${appId}`;
1370
- }
1371
-
1372
- /**
1373
- * @param {Object} params
1374
- * @param {string} params.clientName - The name of the client requesting authorization.
1375
- * @param {string} params.idToken - The id_token from the external service
1376
- * @param {string | null | undefined} [params.nonce] - The nonce used when requesting the id_token from the external service
1377
- * @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
1378
- */
1379
- async signInWithIdToken(params) {
1380
- const currentUser = await this.getCurrentUser();
1381
- const refreshToken = currentUser?.user?.refresh_token;
1382
-
1383
- const res = await authAPI.signInWithIdToken({
1384
- apiURI: this.config.apiURI,
1385
- appId: this.config.appId,
1386
- idToken: params.idToken,
1387
- clientName: params.clientName,
1388
- nonce: params.nonce,
1389
- refreshToken,
1390
- extraFields: params.extraFields,
1391
- });
1392
- await this.changeCurrentUser(res.user);
1393
- return res;
1394
- }
1395
-
1396
- // --------
1397
- // Rooms
1398
-
1399
- /**
1400
- * @param {string} roomType
1401
- * @param {string} roomId
1402
- * @param {any | null | undefined} [initialPresence] -- initial presence data to send when joining the room
1403
- * @returns () => void
1404
- */
1405
- joinRoom(roomType, roomId, initialPresence) {
1406
- return joinRoom(this, roomType, roomId, initialPresence);
1407
- }
1408
-
1409
- _cleanupRoom(roomId) {
1410
- cleanupRoom(this, roomId);
1411
- }
1412
-
1413
- // --------
1414
- // Presence
1415
-
1416
- // TODO: look into typing again
1417
- getPresence(roomType, roomId, opts = {}) {
1418
- return getPresence(this, roomType, roomId, opts);
1419
- }
1420
-
1421
- // TODO: look into typing again
1422
- publishPresence(roomType, roomId, partialData) {
1423
- publishPresence(this, roomType, roomId, partialData);
1424
- }
1425
-
1426
- _trySetPresence(roomId, data) {
1427
- trySetPresence(this, roomId, data);
1428
- }
1429
-
1430
- _tryJoinRoom(roomType, roomId, data) {
1431
- tryJoinRoom(this, roomType, roomId, data);
1432
- }
1433
-
1434
- _tryLeaveRoom(roomId) {
1435
- tryLeaveRoom(this, roomId);
1436
- }
1437
-
1438
- _trySetRoomConnected(roomId, isConnected) {
1439
- trySetRoomConnected(this, roomId, isConnected);
1440
- }
1441
-
1442
- // TODO: look into typing again
1443
- subscribePresence(roomType, roomId, opts, cb) {
1444
- return subscribePresence(this, roomType, roomId, opts, cb);
1445
- }
1446
-
1447
- _notifyPresenceSubs(roomId) {
1448
- notifyPresenceSubs(this, roomId);
1449
- }
1450
-
1451
- _notifyPresenceSub(roomId, handler) {
1452
- notifyPresenceSub(this, roomId, handler);
1453
- }
1454
-
1455
- _patchPresencePeers(roomId, edits) {
1456
- patchPresencePeers(this, roomId, edits);
1457
- }
1458
-
1459
- _setPresencePeers(roomId, data) {
1460
- setPresencePeers(this, roomId, data);
1461
- }
1462
-
1463
- // --------
1464
- // Broadcast
1465
-
1466
- publishTopic({ roomType, roomId, topic, data }) {
1467
- publishTopic(this, { roomType, roomId, topic, data });
1468
- }
1469
-
1470
- _tryBroadcast(roomId, roomType, topic, data) {
1471
- tryBroadcast(this, roomId, roomType, topic, data);
1472
- }
1473
-
1474
- subscribeTopic(roomType, roomId, topic, cb) {
1475
- return subscribeTopic(this, roomType, roomId, topic, cb);
1476
- }
1477
-
1478
- _notifyBroadcastSubs(room, topic, msg) {
1479
- notifyBroadcastSubs(this, room, topic, msg);
1480
- }
1481
-
1482
- // --------
1483
- // Storage
1484
-
1485
- async uploadFile(path, file, opts) {
1486
- const currentUser = await this.getCurrentUser();
1487
- const refreshToken = currentUser?.user?.refresh_token;
1488
- return StorageApi.uploadFile({
1489
- ...opts,
1490
- apiURI: this.config.apiURI,
1491
- appId: this.config.appId,
1492
- path: path,
1493
- file,
1494
- refreshToken: refreshToken,
1495
- });
1496
- }
1497
-
1498
- async deleteFile(path) {
1499
- const currentUser = await this.getCurrentUser();
1500
- const refreshToken = currentUser?.user?.refresh_token;
1501
- const result = await StorageApi.deleteFile({
1502
- apiURI: this.config.apiURI,
1503
- appId: this.config.appId,
1504
- path,
1505
- refreshToken: refreshToken,
1506
- });
1507
-
1508
- return result;
1509
- }
1510
-
1511
- // Deprecated Storage API (Jan 2025)
1512
- // ---------------------------------
1513
-
1514
- async upload(path, file) {
1515
- const currentUser = await this.getCurrentUser();
1516
- const refreshToken = currentUser?.user?.refresh_token;
1517
- const fileName = path || file.name;
1518
- const url = await StorageApi.getSignedUploadUrl({
1519
- apiURI: this.config.apiURI,
1520
- appId: this.config.appId,
1521
- fileName: fileName,
1522
- refreshToken: refreshToken,
1523
- });
1524
- const isSuccess = await StorageApi.upload(url, file);
1525
-
1526
- return isSuccess;
1527
- }
1528
-
1529
- async getDownloadUrl(path) {
1530
- const currentUser = await this.getCurrentUser();
1531
- const refreshToken = currentUser?.user?.refresh_token;
1532
- const url = await StorageApi.getDownloadUrl({
1533
- apiURI: this.config.apiURI,
1534
- appId: this.config.appId,
1535
- path: path,
1536
- refreshToken: refreshToken,
1537
- });
1538
-
1539
- return url;
1540
- }
1541
- }