@astrogate/sdk 0.0.0-stage → 0.1.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 (440) hide show
  1. package/README.md +6 -2
  2. package/THIRD_PARTY_NOTICES.md +17 -0
  3. package/dist/browser.d.ts +85 -0
  4. package/dist/browser.js +16 -0
  5. package/dist/database-binding.d.ts +7 -0
  6. package/dist/database-binding.js +11 -0
  7. package/dist/hosted-session.d.ts +1 -0
  8. package/dist/hosted-session.js +11 -0
  9. package/dist/http.d.ts +24 -0
  10. package/dist/http.js +92 -0
  11. package/dist/inventory.d.ts +7 -0
  12. package/dist/inventory.js +18 -0
  13. package/dist/management-read.d.ts +17 -0
  14. package/dist/management-read.js +104 -0
  15. package/dist/management.d.ts +347 -0
  16. package/dist/management.js +137 -0
  17. package/dist/operator.d.ts +136 -0
  18. package/dist/operator.js +53 -0
  19. package/dist/react.d.ts +16 -0
  20. package/dist/react.js +10 -0
  21. package/dist/server.d.ts +27 -0
  22. package/dist/server.js +30 -0
  23. package/dist/services.d.ts +7 -0
  24. package/dist/services.js +53 -0
  25. package/dist/storage.d.ts +68 -0
  26. package/dist/storage.js +30 -0
  27. package/dist/tasks.d.ts +42 -0
  28. package/dist/tasks.js +24 -0
  29. package/dist/wire.gen.d.ts +7107 -0
  30. package/dist/wire.gen.js +5 -0
  31. package/native-provenance.json +15 -0
  32. package/node_modules/@instantdb/admin/LICENSE +202 -0
  33. package/node_modules/@instantdb/admin/dist/esm/index.d.ts +607 -0
  34. package/node_modules/@instantdb/admin/dist/esm/index.js +1036 -0
  35. package/node_modules/@instantdb/admin/dist/esm/polyfill.d.ts +16 -0
  36. package/node_modules/@instantdb/admin/dist/esm/polyfill.js +21 -0
  37. package/node_modules/@instantdb/admin/dist/esm/subscribe.d.ts +38 -0
  38. package/node_modules/@instantdb/admin/dist/esm/subscribe.js +301 -0
  39. package/node_modules/@instantdb/admin/dist/esm/version.d.ts +2 -0
  40. package/node_modules/@instantdb/admin/dist/esm/version.js +2 -0
  41. package/node_modules/@instantdb/admin/package.json +23 -0
  42. package/node_modules/@instantdb/core/LICENSE +202 -0
  43. package/node_modules/@instantdb/core/dist/esm/Connection.d.ts +92 -0
  44. package/node_modules/@instantdb/core/dist/esm/Connection.js +188 -0
  45. package/node_modules/@instantdb/core/dist/esm/InMemoryStorage.d.ts +10 -0
  46. package/node_modules/@instantdb/core/dist/esm/InMemoryStorage.js +25 -0
  47. package/node_modules/@instantdb/core/dist/esm/IndexedDBStorage.d.ts +17 -0
  48. package/node_modules/@instantdb/core/dist/esm/IndexedDBStorage.js +309 -0
  49. package/node_modules/@instantdb/core/dist/esm/InstantError.d.ts +6 -0
  50. package/node_modules/@instantdb/core/dist/esm/InstantError.js +23 -0
  51. package/node_modules/@instantdb/core/dist/esm/Reactor.d.ts +430 -0
  52. package/node_modules/@instantdb/core/dist/esm/Reactor.js +2369 -0
  53. package/node_modules/@instantdb/core/dist/esm/StorageAPI.d.ts +39 -0
  54. package/node_modules/@instantdb/core/dist/esm/StorageAPI.js +65 -0
  55. package/node_modules/@instantdb/core/dist/esm/Stream.d.ts +120 -0
  56. package/node_modules/@instantdb/core/dist/esm/Stream.js +811 -0
  57. package/node_modules/@instantdb/core/dist/esm/SyncTable.d.ts +144 -0
  58. package/node_modules/@instantdb/core/dist/esm/SyncTable.js +523 -0
  59. package/node_modules/@instantdb/core/dist/esm/WindowNetworkListener.d.ts +4 -0
  60. package/node_modules/@instantdb/core/dist/esm/WindowNetworkListener.js +19 -0
  61. package/node_modules/@instantdb/core/dist/esm/attrTypes.d.ts +25 -0
  62. package/node_modules/@instantdb/core/dist/esm/attrTypes.js +1 -0
  63. package/node_modules/@instantdb/core/dist/esm/authAPI.d.ts +64 -0
  64. package/node_modules/@instantdb/core/dist/esm/authAPI.js +103 -0
  65. package/node_modules/@instantdb/core/dist/esm/clientTypes.d.ts +40 -0
  66. package/node_modules/@instantdb/core/dist/esm/clientTypes.js +1 -0
  67. package/node_modules/@instantdb/core/dist/esm/coreTypes.d.ts +33 -0
  68. package/node_modules/@instantdb/core/dist/esm/coreTypes.js +1 -0
  69. package/node_modules/@instantdb/core/dist/esm/createRouteHandler.d.ts +7 -0
  70. package/node_modules/@instantdb/core/dist/esm/createRouteHandler.js +51 -0
  71. package/node_modules/@instantdb/core/dist/esm/datalog.d.ts +7 -0
  72. package/node_modules/@instantdb/core/dist/esm/datalog.js +99 -0
  73. package/node_modules/@instantdb/core/dist/esm/devtool.d.ts +3 -0
  74. package/node_modules/@instantdb/core/dist/esm/devtool.js +144 -0
  75. package/node_modules/@instantdb/core/dist/esm/framework.d.ts +80 -0
  76. package/node_modules/@instantdb/core/dist/esm/framework.js +243 -0
  77. package/node_modules/@instantdb/core/dist/esm/helperTypes.d.ts +75 -0
  78. package/node_modules/@instantdb/core/dist/esm/helperTypes.js +1 -0
  79. package/node_modules/@instantdb/core/dist/esm/index.d.ts +597 -0
  80. package/node_modules/@instantdb/core/dist/esm/index.js +649 -0
  81. package/node_modules/@instantdb/core/dist/esm/infiniteQuery.d.ts +25 -0
  82. package/node_modules/@instantdb/core/dist/esm/infiniteQuery.js +430 -0
  83. package/node_modules/@instantdb/core/dist/esm/instaml.d.ts +17 -0
  84. package/node_modules/@instantdb/core/dist/esm/instaml.js +576 -0
  85. package/node_modules/@instantdb/core/dist/esm/instaql.d.ts +12 -0
  86. package/node_modules/@instantdb/core/dist/esm/instaql.js +632 -0
  87. package/node_modules/@instantdb/core/dist/esm/instatx.d.ts +127 -0
  88. package/node_modules/@instantdb/core/dist/esm/instatx.js +93 -0
  89. package/node_modules/@instantdb/core/dist/esm/model/instaqlResult.d.ts +7 -0
  90. package/node_modules/@instantdb/core/dist/esm/model/instaqlResult.js +24 -0
  91. package/node_modules/@instantdb/core/dist/esm/parseSchemaFromJSON.d.ts +2 -0
  92. package/node_modules/@instantdb/core/dist/esm/parseSchemaFromJSON.js +142 -0
  93. package/node_modules/@instantdb/core/dist/esm/presence.d.ts +50 -0
  94. package/node_modules/@instantdb/core/dist/esm/presence.js +50 -0
  95. package/node_modules/@instantdb/core/dist/esm/presenceTypes.d.ts +9 -0
  96. package/node_modules/@instantdb/core/dist/esm/presenceTypes.js +3 -0
  97. package/node_modules/@instantdb/core/dist/esm/queryTypes.d.ts +271 -0
  98. package/node_modules/@instantdb/core/dist/esm/queryTypes.js +3 -0
  99. package/node_modules/@instantdb/core/dist/esm/queryValidation.d.ts +5 -0
  100. package/node_modules/@instantdb/core/dist/esm/queryValidation.js +287 -0
  101. package/node_modules/@instantdb/core/dist/esm/reactorTypes.d.ts +29 -0
  102. package/node_modules/@instantdb/core/dist/esm/reactorTypes.js +1 -0
  103. package/node_modules/@instantdb/core/dist/esm/routeHandlerProtocol.d.ts +19 -0
  104. package/node_modules/@instantdb/core/dist/esm/routeHandlerProtocol.js +1 -0
  105. package/node_modules/@instantdb/core/dist/esm/rulesTypes.d.ts +85 -0
  106. package/node_modules/@instantdb/core/dist/esm/rulesTypes.js +1 -0
  107. package/node_modules/@instantdb/core/dist/esm/sanityCheckQueries.d.ts +18 -0
  108. package/node_modules/@instantdb/core/dist/esm/sanityCheckQueries.js +152 -0
  109. package/node_modules/@instantdb/core/dist/esm/schema.d.ts +72 -0
  110. package/node_modules/@instantdb/core/dist/esm/schema.js +128 -0
  111. package/node_modules/@instantdb/core/dist/esm/schemaTypes.d.ts +244 -0
  112. package/node_modules/@instantdb/core/dist/esm/schemaTypes.js +106 -0
  113. package/node_modules/@instantdb/core/dist/esm/store.d.ts +89 -0
  114. package/node_modules/@instantdb/core/dist/esm/store.js +722 -0
  115. package/node_modules/@instantdb/core/dist/esm/transactionValidation.d.ts +7 -0
  116. package/node_modules/@instantdb/core/dist/esm/transactionValidation.js +130 -0
  117. package/node_modules/@instantdb/core/dist/esm/utils/Deferred.d.ts +8 -0
  118. package/node_modules/@instantdb/core/dist/esm/utils/Deferred.js +17 -0
  119. package/node_modules/@instantdb/core/dist/esm/utils/PersistedObject.d.ts +80 -0
  120. package/node_modules/@instantdb/core/dist/esm/utils/PersistedObject.js +448 -0
  121. package/node_modules/@instantdb/core/dist/esm/utils/dates.d.ts +1 -0
  122. package/node_modules/@instantdb/core/dist/esm/utils/dates.js +211 -0
  123. package/node_modules/@instantdb/core/dist/esm/utils/error.d.ts +2 -0
  124. package/node_modules/@instantdb/core/dist/esm/utils/error.js +8 -0
  125. package/node_modules/@instantdb/core/dist/esm/utils/fetch.d.ts +125 -0
  126. package/node_modules/@instantdb/core/dist/esm/utils/fetch.js +31 -0
  127. package/node_modules/@instantdb/core/dist/esm/utils/flags.d.ts +4 -0
  128. package/node_modules/@instantdb/core/dist/esm/utils/flags.js +10 -0
  129. package/node_modules/@instantdb/core/dist/esm/utils/id.d.ts +3 -0
  130. package/node_modules/@instantdb/core/dist/esm/utils/id.js +25 -0
  131. package/node_modules/@instantdb/core/dist/esm/utils/linkIndex.d.ts +7 -0
  132. package/node_modules/@instantdb/core/dist/esm/utils/linkIndex.js +17 -0
  133. package/node_modules/@instantdb/core/dist/esm/utils/log.d.ts +6 -0
  134. package/node_modules/@instantdb/core/dist/esm/utils/log.js +13 -0
  135. package/node_modules/@instantdb/core/dist/esm/utils/object.d.ts +16 -0
  136. package/node_modules/@instantdb/core/dist/esm/utils/object.js +143 -0
  137. package/node_modules/@instantdb/core/dist/esm/utils/pgtime.d.ts +197 -0
  138. package/node_modules/@instantdb/core/dist/esm/utils/pgtime.js +197 -0
  139. package/node_modules/@instantdb/core/dist/esm/utils/pick.d.ts +1 -0
  140. package/node_modules/@instantdb/core/dist/esm/utils/pick.js +9 -0
  141. package/node_modules/@instantdb/core/dist/esm/utils/strings.d.ts +1 -0
  142. package/node_modules/@instantdb/core/dist/esm/utils/strings.js +15 -0
  143. package/node_modules/@instantdb/core/dist/esm/utils/weakHash.d.ts +15 -0
  144. package/node_modules/@instantdb/core/dist/esm/utils/weakHash.js +71 -0
  145. package/node_modules/@instantdb/core/dist/esm/utils/weakHashLegacy.d.ts +7 -0
  146. package/node_modules/@instantdb/core/dist/esm/utils/weakHashLegacy.js +72 -0
  147. package/node_modules/@instantdb/core/dist/esm/version.d.ts +2 -0
  148. package/node_modules/@instantdb/core/dist/esm/version.js +2 -0
  149. package/node_modules/@instantdb/core/dist/esm/warningToggle.d.ts +2 -0
  150. package/node_modules/@instantdb/core/dist/esm/warningToggle.js +4 -0
  151. package/node_modules/@instantdb/core/package.json +20 -0
  152. package/node_modules/@instantdb/eventsource/LICENSE +22 -0
  153. package/node_modules/@instantdb/eventsource/README.md +226 -0
  154. package/node_modules/@instantdb/eventsource/dist/index.cjs +279 -0
  155. package/node_modules/@instantdb/eventsource/dist/index.cjs.map +1 -0
  156. package/node_modules/@instantdb/eventsource/dist/index.d.cts +346 -0
  157. package/node_modules/@instantdb/eventsource/dist/index.d.ts +346 -0
  158. package/node_modules/@instantdb/eventsource/dist/index.js +279 -0
  159. package/node_modules/@instantdb/eventsource/dist/index.js.map +1 -0
  160. package/node_modules/@instantdb/eventsource/package.json +128 -0
  161. package/node_modules/@instantdb/eventsource/src/EventSource.ts +614 -0
  162. package/node_modules/@instantdb/eventsource/src/errors.ts +141 -0
  163. package/node_modules/@instantdb/eventsource/src/index.ts +3 -0
  164. package/node_modules/@instantdb/eventsource/src/types.ts +164 -0
  165. package/node_modules/@instantdb/react/LICENSE +202 -0
  166. package/node_modules/@instantdb/react/dist/esm/Cursors.d.ts +18 -0
  167. package/node_modules/@instantdb/react/dist/esm/Cursors.js +103 -0
  168. package/node_modules/@instantdb/react/dist/esm/InstantReactWebDatabase.d.ts +5 -0
  169. package/node_modules/@instantdb/react/dist/esm/InstantReactWebDatabase.js +5 -0
  170. package/node_modules/@instantdb/react/dist/esm/index.d.ts +6 -0
  171. package/node_modules/@instantdb/react/dist/esm/index.js +22 -0
  172. package/node_modules/@instantdb/react/dist/esm/init.d.ts +40 -0
  173. package/node_modules/@instantdb/react/dist/esm/init.js +49 -0
  174. package/node_modules/@instantdb/react/dist/esm/next-ssr/HydrationStreamProvider.d.ts +65 -0
  175. package/node_modules/@instantdb/react/dist/esm/next-ssr/HydrationStreamProvider.js +96 -0
  176. package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantNextDatabase.d.ts +11 -0
  177. package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantNextDatabase.js +31 -0
  178. package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantSuspenseProvider.d.ts +24 -0
  179. package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantSuspenseProvider.js +162 -0
  180. package/node_modules/@instantdb/react/dist/esm/next-ssr/getUserFromInstantCookie.d.ts +9 -0
  181. package/node_modules/@instantdb/react/dist/esm/next-ssr/getUserFromInstantCookie.js +16 -0
  182. package/node_modules/@instantdb/react/dist/esm/next-ssr/htmlescape.d.ts +2 -0
  183. package/node_modules/@instantdb/react/dist/esm/next-ssr/htmlescape.js +20 -0
  184. package/node_modules/@instantdb/react/dist/esm/next-ssr/index.d.ts +29 -0
  185. package/node_modules/@instantdb/react/dist/esm/next-ssr/index.js +34 -0
  186. package/node_modules/@instantdb/react/dist/esm/version.d.ts +2 -0
  187. package/node_modules/@instantdb/react/dist/esm/version.js +2 -0
  188. package/node_modules/@instantdb/react/package.json +24 -0
  189. package/node_modules/@instantdb/react-common/LICENSE +202 -0
  190. package/node_modules/@instantdb/react-common/dist/esm/InstantReactAbstractDatabase.d.ts +282 -0
  191. package/node_modules/@instantdb/react-common/dist/esm/InstantReactAbstractDatabase.js +386 -0
  192. package/node_modules/@instantdb/react-common/dist/esm/InstantReactRoom.d.ts +182 -0
  193. package/node_modules/@instantdb/react-common/dist/esm/InstantReactRoom.js +280 -0
  194. package/node_modules/@instantdb/react-common/dist/esm/index.d.ts +4 -0
  195. package/node_modules/@instantdb/react-common/dist/esm/index.js +3 -0
  196. package/node_modules/@instantdb/react-common/dist/esm/useInfiniteQuerySubscription.d.ts +27 -0
  197. package/node_modules/@instantdb/react-common/dist/esm/useInfiniteQuerySubscription.js +53 -0
  198. package/node_modules/@instantdb/react-common/dist/esm/useQuery.d.ts +6 -0
  199. package/node_modules/@instantdb/react-common/dist/esm/useQuery.js +75 -0
  200. package/node_modules/@instantdb/react-common/dist/esm/useTimeout.d.ts +4 -0
  201. package/node_modules/@instantdb/react-common/dist/esm/useTimeout.js +17 -0
  202. package/node_modules/@instantdb/react-common/dist/esm/version.d.ts +2 -0
  203. package/node_modules/@instantdb/react-common/dist/esm/version.js +2 -0
  204. package/node_modules/@instantdb/react-common/package.json +22 -0
  205. package/node_modules/@instantdb/version/LICENSE +202 -0
  206. package/node_modules/@instantdb/version/dist/esm/index.d.ts +2 -0
  207. package/node_modules/@instantdb/version/dist/esm/index.js +2 -0
  208. package/node_modules/@instantdb/version/dist/esm/version.d.ts +2 -0
  209. package/node_modules/@instantdb/version/dist/esm/version.js +5 -0
  210. package/node_modules/@instantdb/version/package.json +16 -0
  211. package/node_modules/@instantdb/webhooks/LICENSE +202 -0
  212. package/node_modules/@instantdb/webhooks/dist/esm/index.d.ts +587 -0
  213. package/node_modules/@instantdb/webhooks/dist/esm/index.js +748 -0
  214. package/node_modules/@instantdb/webhooks/package.json +18 -0
  215. package/node_modules/cookie/LICENSE +24 -0
  216. package/node_modules/cookie/README.md +295 -0
  217. package/node_modules/cookie/dist/index.d.ts +143 -0
  218. package/node_modules/cookie/dist/index.js +355 -0
  219. package/node_modules/cookie/dist/index.js.map +1 -0
  220. package/node_modules/cookie/package.json +57 -0
  221. package/node_modules/eventsource/LICENSE +22 -0
  222. package/node_modules/eventsource/README.md +252 -0
  223. package/node_modules/eventsource/dist/EventSource.d.ts +128 -0
  224. package/node_modules/eventsource/dist/EventSource.d.ts.map +1 -0
  225. package/node_modules/eventsource/dist/EventSource.js +556 -0
  226. package/node_modules/eventsource/dist/EventSource.js.map +1 -0
  227. package/node_modules/eventsource/dist/errors.d.ts +53 -0
  228. package/node_modules/eventsource/dist/errors.d.ts.map +1 -0
  229. package/node_modules/eventsource/dist/errors.js +120 -0
  230. package/node_modules/eventsource/dist/errors.js.map +1 -0
  231. package/node_modules/eventsource/dist/index.d.ts +4 -0
  232. package/node_modules/eventsource/dist/index.d.ts.map +1 -0
  233. package/node_modules/eventsource/dist/index.js +3 -0
  234. package/node_modules/eventsource/dist/index.js.map +1 -0
  235. package/node_modules/eventsource/dist/types.d.ts +156 -0
  236. package/node_modules/eventsource/dist/types.d.ts.map +1 -0
  237. package/node_modules/eventsource/dist/types.js +2 -0
  238. package/node_modules/eventsource/dist/types.js.map +1 -0
  239. package/node_modules/eventsource/node_modules/eventsource-parser/LICENSE +21 -0
  240. package/node_modules/eventsource/node_modules/eventsource-parser/README.md +177 -0
  241. package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.d.ts +35 -0
  242. package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.d.ts.map +1 -0
  243. package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.js +16 -0
  244. package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.js.map +1 -0
  245. package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.d.ts +4 -0
  246. package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.d.ts.map +1 -0
  247. package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.js +3 -0
  248. package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.js.map +1 -0
  249. package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.d.ts +12 -0
  250. package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.d.ts.map +1 -0
  251. package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.js +509 -0
  252. package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.js.map +1 -0
  253. package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.d.ts +76 -0
  254. package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.d.ts.map +1 -0
  255. package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.js +59 -0
  256. package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.js.map +1 -0
  257. package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.d.ts +130 -0
  258. package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.d.ts.map +1 -0
  259. package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.js +1 -0
  260. package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.js.map +1 -0
  261. package/node_modules/eventsource/node_modules/eventsource-parser/package.json +96 -0
  262. package/node_modules/eventsource/node_modules/eventsource-parser/src/errors.ts +44 -0
  263. package/node_modules/eventsource/node_modules/eventsource-parser/src/index.ts +3 -0
  264. package/node_modules/eventsource/node_modules/eventsource-parser/src/parse.ts +576 -0
  265. package/node_modules/eventsource/node_modules/eventsource-parser/src/stream.ts +118 -0
  266. package/node_modules/eventsource/node_modules/eventsource-parser/src/types.ts +138 -0
  267. package/node_modules/eventsource/package.json +103 -0
  268. package/node_modules/eventsource/src/EventSource.ts +844 -0
  269. package/node_modules/eventsource/src/errors.ts +141 -0
  270. package/node_modules/eventsource/src/index.ts +3 -0
  271. package/node_modules/eventsource/src/types.ts +166 -0
  272. package/node_modules/eventsource-parser/LICENSE +21 -0
  273. package/node_modules/eventsource-parser/README.md +157 -0
  274. package/node_modules/eventsource-parser/dist/index.cjs +177 -0
  275. package/node_modules/eventsource-parser/dist/index.cjs.map +1 -0
  276. package/node_modules/eventsource-parser/dist/index.d.cts +169 -0
  277. package/node_modules/eventsource-parser/dist/index.d.ts +169 -0
  278. package/node_modules/eventsource-parser/dist/index.js +177 -0
  279. package/node_modules/eventsource-parser/dist/index.js.map +1 -0
  280. package/node_modules/eventsource-parser/dist/stream.cjs +29 -0
  281. package/node_modules/eventsource-parser/dist/stream.cjs.map +1 -0
  282. package/node_modules/eventsource-parser/dist/stream.d.cts +134 -0
  283. package/node_modules/eventsource-parser/dist/stream.d.ts +134 -0
  284. package/node_modules/eventsource-parser/dist/stream.js +30 -0
  285. package/node_modules/eventsource-parser/dist/stream.js.map +1 -0
  286. package/node_modules/eventsource-parser/package.json +92 -0
  287. package/node_modules/eventsource-parser/src/errors.ts +44 -0
  288. package/node_modules/eventsource-parser/src/index.ts +8 -0
  289. package/node_modules/eventsource-parser/src/parse.ts +439 -0
  290. package/node_modules/eventsource-parser/src/stream.ts +107 -0
  291. package/node_modules/eventsource-parser/src/types.ts +122 -0
  292. package/node_modules/eventsource-parser/stream.js +2 -0
  293. package/node_modules/mutative/LICENSE +21 -0
  294. package/node_modules/mutative/README.md +870 -0
  295. package/node_modules/mutative/dist/apply.d.ts +31 -0
  296. package/node_modules/mutative/dist/array.d.ts +45 -0
  297. package/node_modules/mutative/dist/constant.d.ts +8 -0
  298. package/node_modules/mutative/dist/create.d.ts +46 -0
  299. package/node_modules/mutative/dist/current.d.ts +23 -0
  300. package/node_modules/mutative/dist/draft.d.ts +3 -0
  301. package/node_modules/mutative/dist/draftify.d.ts +2 -0
  302. package/node_modules/mutative/dist/error.d.ts +54 -0
  303. package/node_modules/mutative/dist/index.d.mts +1 -0
  304. package/node_modules/mutative/dist/index.d.ts +12 -0
  305. package/node_modules/mutative/dist/index.js +8 -0
  306. package/node_modules/mutative/dist/index.mjs +3 -0
  307. package/node_modules/mutative/dist/interface.d.ts +200 -0
  308. package/node_modules/mutative/dist/internal.d.ts +4 -0
  309. package/node_modules/mutative/dist/makeCreator.d.ts +54 -0
  310. package/node_modules/mutative/dist/map.d.ts +15 -0
  311. package/node_modules/mutative/dist/mutative.cjs.development.js +2126 -0
  312. package/node_modules/mutative/dist/mutative.cjs.development.js.map +1 -0
  313. package/node_modules/mutative/dist/mutative.cjs.production.min.js +2 -0
  314. package/node_modules/mutative/dist/mutative.cjs.production.min.js.map +1 -0
  315. package/node_modules/mutative/dist/mutative.esm.js +2123 -0
  316. package/node_modules/mutative/dist/mutative.esm.js.map +1 -0
  317. package/node_modules/mutative/dist/mutative.esm.mjs +2123 -0
  318. package/node_modules/mutative/dist/mutative.esm.mjs.map +1 -0
  319. package/node_modules/mutative/dist/mutative.esm.production.min.mjs +2 -0
  320. package/node_modules/mutative/dist/mutative.esm.production.min.mjs.map +1 -0
  321. package/node_modules/mutative/dist/mutative.umd.development.js +2132 -0
  322. package/node_modules/mutative/dist/mutative.umd.development.js.map +1 -0
  323. package/node_modules/mutative/dist/mutative.umd.production.min.js +2 -0
  324. package/node_modules/mutative/dist/mutative.umd.production.min.js.map +1 -0
  325. package/node_modules/mutative/dist/original.d.ts +19 -0
  326. package/node_modules/mutative/dist/patch.d.ts +2 -0
  327. package/node_modules/mutative/dist/rawReturn.d.ts +19 -0
  328. package/node_modules/mutative/dist/set.d.ts +14 -0
  329. package/node_modules/mutative/dist/unsafe.d.ts +34 -0
  330. package/node_modules/mutative/dist/utils/cast.d.ts +13 -0
  331. package/node_modules/mutative/dist/utils/copy.d.ts +5 -0
  332. package/node_modules/mutative/dist/utils/deepFreeze.d.ts +1 -0
  333. package/node_modules/mutative/dist/utils/draft.d.ts +27 -0
  334. package/node_modules/mutative/dist/utils/finalize.d.ts +13 -0
  335. package/node_modules/mutative/dist/utils/forEach.d.ts +1 -0
  336. package/node_modules/mutative/dist/utils/index.d.ts +7 -0
  337. package/node_modules/mutative/dist/utils/mark.d.ts +2 -0
  338. package/node_modules/mutative/dist/utils/marker.d.ts +5 -0
  339. package/node_modules/mutative/dist/utils/proto.d.ts +10 -0
  340. package/node_modules/mutative/package.json +142 -0
  341. package/node_modules/mutative/src/apply.ts +239 -0
  342. package/node_modules/mutative/src/array.ts +679 -0
  343. package/node_modules/mutative/src/constant.ts +17 -0
  344. package/node_modules/mutative/src/create.ts +27 -0
  345. package/node_modules/mutative/src/current.ts +206 -0
  346. package/node_modules/mutative/src/draft.ts +489 -0
  347. package/node_modules/mutative/src/draftify.ts +57 -0
  348. package/node_modules/mutative/src/error.ts +129 -0
  349. package/node_modules/mutative/src/index.ts +21 -0
  350. package/node_modules/mutative/src/interface.ts +321 -0
  351. package/node_modules/mutative/src/internal.ts +5 -0
  352. package/node_modules/mutative/src/makeCreator.ts +382 -0
  353. package/node_modules/mutative/src/map.ts +160 -0
  354. package/node_modules/mutative/src/original.ts +28 -0
  355. package/node_modules/mutative/src/patch.ts +386 -0
  356. package/node_modules/mutative/src/rawReturn.ts +41 -0
  357. package/node_modules/mutative/src/set.ts +201 -0
  358. package/node_modules/mutative/src/unsafe.ts +66 -0
  359. package/node_modules/mutative/src/utils/cast.ts +22 -0
  360. package/node_modules/mutative/src/utils/copy.ts +224 -0
  361. package/node_modules/mutative/src/utils/deepFreeze.ts +103 -0
  362. package/node_modules/mutative/src/utils/draft.ts +189 -0
  363. package/node_modules/mutative/src/utils/finalize.ts +232 -0
  364. package/node_modules/mutative/src/utils/forEach.ts +24 -0
  365. package/node_modules/mutative/src/utils/index.ts +7 -0
  366. package/node_modules/mutative/src/utils/mark.ts +11 -0
  367. package/node_modules/mutative/src/utils/marker.ts +34 -0
  368. package/node_modules/mutative/src/utils/proto.ts +38 -0
  369. package/node_modules/uuid/LICENSE.md +9 -0
  370. package/node_modules/uuid/README.md +491 -0
  371. package/node_modules/uuid/dist/index.d.ts +15 -0
  372. package/node_modules/uuid/dist/index.js +14 -0
  373. package/node_modules/uuid/dist/max.d.ts +2 -0
  374. package/node_modules/uuid/dist/max.js +1 -0
  375. package/node_modules/uuid/dist/md5.d.ts +2 -0
  376. package/node_modules/uuid/dist/md5.js +135 -0
  377. package/node_modules/uuid/dist/nil.d.ts +2 -0
  378. package/node_modules/uuid/dist/nil.js +1 -0
  379. package/node_modules/uuid/dist/parse.d.ts +3 -0
  380. package/node_modules/uuid/dist/parse.js +9 -0
  381. package/node_modules/uuid/dist/regex.d.ts +2 -0
  382. package/node_modules/uuid/dist/regex.js +1 -0
  383. package/node_modules/uuid/dist/rng.d.ts +1 -0
  384. package/node_modules/uuid/dist/rng.js +4 -0
  385. package/node_modules/uuid/dist/sha1.d.ts +2 -0
  386. package/node_modules/uuid/dist/sha1.js +70 -0
  387. package/node_modules/uuid/dist/stringify.d.ts +3 -0
  388. package/node_modules/uuid/dist/stringify.js +35 -0
  389. package/node_modules/uuid/dist/types.d.ts +22 -0
  390. package/node_modules/uuid/dist/types.js +1 -0
  391. package/node_modules/uuid/dist/uuid-bin.d.ts +1 -0
  392. package/node_modules/uuid/dist/uuid-bin.js +70 -0
  393. package/node_modules/uuid/dist/v1.d.ts +11 -0
  394. package/node_modules/uuid/dist/v1.js +87 -0
  395. package/node_modules/uuid/dist/v1ToV6.d.ts +3 -0
  396. package/node_modules/uuid/dist/v1ToV6.js +10 -0
  397. package/node_modules/uuid/dist/v3.d.ts +9 -0
  398. package/node_modules/uuid/dist/v3.js +9 -0
  399. package/node_modules/uuid/dist/v35.d.ts +7 -0
  400. package/node_modules/uuid/dist/v35.js +39 -0
  401. package/node_modules/uuid/dist/v4.d.ts +4 -0
  402. package/node_modules/uuid/dist/v4.js +29 -0
  403. package/node_modules/uuid/dist/v5.d.ts +9 -0
  404. package/node_modules/uuid/dist/v5.js +9 -0
  405. package/node_modules/uuid/dist/v6.d.ts +4 -0
  406. package/node_modules/uuid/dist/v6.js +20 -0
  407. package/node_modules/uuid/dist/v6ToV1.d.ts +2 -0
  408. package/node_modules/uuid/dist/v6ToV1.js +10 -0
  409. package/node_modules/uuid/dist/v7.d.ts +9 -0
  410. package/node_modules/uuid/dist/v7.js +68 -0
  411. package/node_modules/uuid/dist/validate.d.ts +2 -0
  412. package/node_modules/uuid/dist/validate.js +5 -0
  413. package/node_modules/uuid/dist/version.d.ts +2 -0
  414. package/node_modules/uuid/dist/version.js +8 -0
  415. package/node_modules/uuid/dist-node/bin/uuid +2 -0
  416. package/node_modules/uuid/dist-node/index.js +14 -0
  417. package/node_modules/uuid/dist-node/max.js +1 -0
  418. package/node_modules/uuid/dist-node/md5.js +11 -0
  419. package/node_modules/uuid/dist-node/nil.js +1 -0
  420. package/node_modules/uuid/dist-node/parse.js +9 -0
  421. package/node_modules/uuid/dist-node/regex.js +1 -0
  422. package/node_modules/uuid/dist-node/rng.js +4 -0
  423. package/node_modules/uuid/dist-node/sha1.js +11 -0
  424. package/node_modules/uuid/dist-node/stringify.js +35 -0
  425. package/node_modules/uuid/dist-node/types.js +1 -0
  426. package/node_modules/uuid/dist-node/uuid-bin.js +70 -0
  427. package/node_modules/uuid/dist-node/v1.js +87 -0
  428. package/node_modules/uuid/dist-node/v1ToV6.js +10 -0
  429. package/node_modules/uuid/dist-node/v3.js +9 -0
  430. package/node_modules/uuid/dist-node/v35.js +39 -0
  431. package/node_modules/uuid/dist-node/v4.js +29 -0
  432. package/node_modules/uuid/dist-node/v5.js +9 -0
  433. package/node_modules/uuid/dist-node/v6.js +20 -0
  434. package/node_modules/uuid/dist-node/v6ToV1.js +10 -0
  435. package/node_modules/uuid/dist-node/v7.js +68 -0
  436. package/node_modules/uuid/dist-node/validate.js +5 -0
  437. package/node_modules/uuid/dist-node/version.js +8 -0
  438. package/node_modules/uuid/package.json +115 -0
  439. package/package.json +80 -4
  440. package/release.json +78 -0
@@ -0,0 +1,649 @@
1
+ import Reactor from './Reactor.js';
2
+ import { tx, txInit, lookup, getOps, } from './instatx.js';
3
+ import weakHash from './utils/weakHash.js';
4
+ import id from './utils/id.js';
5
+ import IndexedDBStorage from './IndexedDBStorage.js';
6
+ import { coerceToDate } from './utils/dates.js';
7
+ import WindowNetworkListener from './WindowNetworkListener.js';
8
+ import { i } from './schema.js';
9
+ import { createDevtool } from './devtool.js';
10
+ import version from './version.js';
11
+ import { validateQuery, QueryValidationError } from './queryValidation.js';
12
+ import { validateTransactions, TransactionValidationError, } from './transactionValidation.js';
13
+ import { setInstantWarningsEnabled } from './warningToggle.js';
14
+ import { StoreInterface, } from './utils/PersistedObject.js';
15
+ import { createInstantRouteHandler } from './createRouteHandler.js';
16
+ import { parseSchemaFromJSON } from './parseSchemaFromJSON.js';
17
+ import { FrameworkClient } from './framework.js';
18
+ import { InstantAPIError } from './utils/fetch.js';
19
+ import { InstantError } from './InstantError.js';
20
+ import { SSEConnection, } from './Connection.js';
21
+ import { CallbackEventType as SyncTableCallbackEventType } from './SyncTable.js';
22
+ import { InstantStream, } from './Stream.js';
23
+ import { subscribeInfiniteQuery, getInfiniteQueryInitialSnapshot, } from './infiniteQuery.js';
24
+ const defaultOpenDevtool = true;
25
+ // consts
26
+ const defaultConfig = {
27
+ apiURI: 'https://api.instantdb.com',
28
+ websocketURI: 'wss://api.instantdb.com/runtime/session',
29
+ };
30
+ // hmr
31
+ function initSchemaHashStore() {
32
+ globalThis.__instantDbSchemaHashStore =
33
+ globalThis.__instantDbSchemaHashStore ?? new WeakMap();
34
+ return globalThis.__instantDbSchemaHashStore;
35
+ }
36
+ function initGlobalInstantCoreStore() {
37
+ globalThis.__instantDbStore = globalThis.__instantDbStore ?? {};
38
+ return globalThis.__instantDbStore;
39
+ }
40
+ function reactorKey(config) {
41
+ // @ts-expect-error
42
+ const adminToken = config.__adminToken;
43
+ // Sometimes you _want_ to simulate two separate db instances in the same
44
+ // page. This can happen when doing real-time demos. To make this work we
45
+ // have a hidden `__extraDedupeKey` that you can use to differentiate db
46
+ // configs that are otherwise exactly the same.
47
+ // @ts-expect-error
48
+ const extraDedupeKey = config.__extraDedupeKey;
49
+ return (config.appId +
50
+ '_' +
51
+ (config.websocketURI || 'default_ws_uri') +
52
+ '_' +
53
+ (config.apiURI || 'default_api_uri') +
54
+ '_' +
55
+ (adminToken || 'client_only') +
56
+ '_' +
57
+ config.useDateObjects +
58
+ '_' +
59
+ (extraDedupeKey || ''));
60
+ }
61
+ const globalInstantCoreStore = initGlobalInstantCoreStore();
62
+ const schemaHashStore = initSchemaHashStore();
63
+ /**
64
+ * Functions to log users in and out.
65
+ *
66
+ * @see https://instantdb.com/docs/auth
67
+ */
68
+ class Auth {
69
+ db;
70
+ constructor(db) {
71
+ this.db = db;
72
+ }
73
+ /**
74
+ * Sends a magic code to the user's email address.
75
+ *
76
+ * Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
77
+ * user verify.
78
+ *
79
+ * @see https://instantdb.com/docs/auth
80
+ * @example
81
+ * db.auth.sendMagicCode({email: "example@gmail.com"})
82
+ * .catch((err) => console.error(err.body?.message))
83
+ */
84
+ sendMagicCode = (params) => {
85
+ return this.db.sendMagicCode(params);
86
+ };
87
+ /**
88
+ * Verify a magic code that was sent to the user's email address.
89
+ *
90
+ * @see https://instantdb.com/docs/auth
91
+ *
92
+ * @example
93
+ * db.auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
94
+ * .catch((err) => console.error(err.body?.message))
95
+ */
96
+ signInWithMagicCode = (params) => {
97
+ return this.db.signInWithMagicCode(params);
98
+ };
99
+ /**
100
+ * Sign in a user with a refresh token
101
+ *
102
+ * @see https://instantdb.com/docs/backend#frontend-auth-sign-in-with-token
103
+ *
104
+ * @example
105
+ * // Get the token from your backend
106
+ * const token = await fetch('/signin', ...);
107
+ * //Sign in
108
+ * db.auth.signInWithToken(token);
109
+ */
110
+ signInWithToken = (token) => {
111
+ return this.db.signInWithCustomToken(token);
112
+ };
113
+ /**
114
+ * Sign in as guest, creating a new user without email
115
+ *
116
+ * @see https://instantdb.com/docs/auth
117
+ *
118
+ * @example
119
+ * db.auth.signInAsGuest();
120
+ */
121
+ signInAsGuest = (params) => {
122
+ return this.db.signInAsGuest(params);
123
+ };
124
+ /**
125
+ * Create an authorization url to sign in with an external provider.
126
+ *
127
+ * @see https://instantdb.com/docs/auth
128
+ *
129
+ * @example
130
+ * // Get the authorization url from your backend
131
+ * const url = db.auth.createAuthorizationUrl({
132
+ * clientName: "google",
133
+ * redirectURL: window.location.href,
134
+ * });
135
+ *
136
+ * // Put it in a sign in link
137
+ * <a href={url}>Log in with Google</a>
138
+ */
139
+ createAuthorizationURL = (params) => {
140
+ return this.db.createAuthorizationURL(params);
141
+ };
142
+ /**
143
+ * Sign in with the id_token from an external provider like Google
144
+ *
145
+ * @see https://instantdb.com/docs/auth
146
+ * @example
147
+ * db.auth
148
+ * .signInWithIdToken({
149
+ * // Token from external service
150
+ * idToken: id_token,
151
+ * // The name you gave the client when you registered it with Instant
152
+ * clientName: "google",
153
+ * // The nonce, if any, that you used when you initiated the auth flow
154
+ * // with the external service.
155
+ * nonce: your_nonce
156
+ * })
157
+ * .catch((err) => console.error(err.body?.message));
158
+ *
159
+ */
160
+ signInWithIdToken = (params) => {
161
+ return this.db.signInWithIdToken(params);
162
+ };
163
+ /**
164
+ * Sign in with the id_token from an external provider like Google
165
+ *
166
+ * @see https://instantdb.com/docs/auth
167
+ * @example
168
+ * db.auth
169
+ * .exchangeOAuthCode({
170
+ * // code received in redirect from OAuth callback
171
+ * code: code
172
+ * // The PKCE code_verifier, if any, that you used when you
173
+ * // initiated the auth flow
174
+ * codeVerifier: your_code_verifier
175
+ * })
176
+ * .catch((err) => console.error(err.body?.message));
177
+ *
178
+ */
179
+ exchangeOAuthCode = (params) => {
180
+ return this.db.exchangeCodeForToken(params);
181
+ };
182
+ /**
183
+ * OpenID Discovery path for use with tools like
184
+ * expo-auth-session that use auto-discovery of
185
+ * OAuth parameters.
186
+ *
187
+ * @see https://instantdb.com/docs/auth
188
+ * @example
189
+ * const discovery = useAutoDiscovery(
190
+ * db.auth.issuerURI()
191
+ * );
192
+ */
193
+ issuerURI = () => {
194
+ return this.db.issuerURI();
195
+ };
196
+ /**
197
+ * Sign out the current user
198
+ */
199
+ signOut = (opts = { invalidateToken: true }) => {
200
+ return this.db.signOut(opts);
201
+ };
202
+ }
203
+ /**
204
+ * Functions to manage file storage.
205
+ */
206
+ class Storage {
207
+ db;
208
+ constructor(db) {
209
+ this.db = db;
210
+ }
211
+ /**
212
+ * Uploads file at the provided path.
213
+ *
214
+ * @see https://instantdb.com/docs/storage
215
+ * @example
216
+ * const [file] = e.target.files; // result of file input
217
+ * const data = await db.storage.uploadFile('photos/demo.png', file);
218
+ */
219
+ uploadFile = (path, file, opts = {}) => {
220
+ return this.db.uploadFile(path, file, opts);
221
+ };
222
+ /**
223
+ * Deletes a file by path name.
224
+ *
225
+ * @deprecated Use `db.transact` to delete files instead:
226
+ * @example
227
+ * // Delete by id
228
+ * db.transact(db.tx.$files[fileId].delete());
229
+ *
230
+ * // Delete by path
231
+ * db.transact(db.tx.$files[lookup('path', 'photos/demo.png')].delete());
232
+ *
233
+ * // Delete multiple files
234
+ * db.transact(fileIds.map(id => db.tx.$files[id].delete()));
235
+ *
236
+ * @see https://instantdb.com/docs/storage
237
+ */
238
+ delete = (pathname) => {
239
+ return this.db.deleteFile(pathname);
240
+ };
241
+ // Deprecated Storage API (Jan 2025)
242
+ // ---------------------------------
243
+ /**
244
+ * @deprecated. Use `db.storage.uploadFile` instead
245
+ * remove in the future.
246
+ */
247
+ upload = (pathname, file) => {
248
+ return this.db.upload(pathname, file);
249
+ };
250
+ /**
251
+ * @deprecated Use `db.storage.uploadFile` instead
252
+ */
253
+ put = this.upload;
254
+ /**
255
+ * @deprecated. getDownloadUrl will be removed in the future.
256
+ * Use `useQuery` instead to query and fetch for valid urls
257
+ *
258
+ * db.useQuery({
259
+ * $files: {
260
+ * $: {
261
+ * where: {
262
+ * path: "moop.png"
263
+ * }
264
+ * }
265
+ * }
266
+ * })
267
+ */
268
+ getDownloadUrl = (pathname) => {
269
+ return this.db.getDownloadUrl(pathname);
270
+ };
271
+ }
272
+ /**
273
+ * Functions to manage streams.
274
+ */
275
+ class Streams {
276
+ db;
277
+ constructor(db) {
278
+ this.db = db;
279
+ }
280
+ /**
281
+ * Creates a new ReadableStream for the given clientId.
282
+ *
283
+ * @example
284
+ * const stream = db.streams.createReadStream({clientId: clientId})
285
+ * for await (const chunk of stream) {
286
+ * console.log(chunk);
287
+ * }
288
+ */
289
+ createReadStream = (opts) => {
290
+ return this.db.createReadStream(opts);
291
+ };
292
+ /**
293
+ * Creates a new WritableStream for the given clientId.
294
+ *
295
+ * @example
296
+ * const writeStream = db.streams.createWriteStream({clientId: clientId})
297
+ * const writer = writeStream.getWriter();
298
+ * writer.write('Hello world');
299
+ * writer.close();
300
+ */
301
+ createWriteStream = (opts) => {
302
+ return this.db.createWriteStream(opts);
303
+ };
304
+ }
305
+ // util
306
+ function coerceQuery(o) {
307
+ // stringify and parse to remove undefined values
308
+ return JSON.parse(JSON.stringify(o));
309
+ }
310
+ class InstantCoreDatabase {
311
+ _reactor;
312
+ auth;
313
+ storage;
314
+ streams;
315
+ tx = txInit();
316
+ constructor(reactor) {
317
+ this._reactor = reactor;
318
+ this.auth = new Auth(this._reactor);
319
+ this.storage = new Storage(this._reactor);
320
+ this.streams = new Streams(this._reactor);
321
+ }
322
+ /**
323
+ * Use this to write data! You can create, update, delete, and link objects
324
+ *
325
+ * @see https://instantdb.com/docs/instaml
326
+ *
327
+ * @example
328
+ * // Create a new object in the `goals` namespace
329
+ * const goalId = id();
330
+ * db.transact(db.tx.goals[goalId].update({title: "Get fit"}))
331
+ *
332
+ * // Update the title
333
+ * db.transact(db.tx.goals[goalId].update({title: "Get super fit"}))
334
+ *
335
+ * // Delete it
336
+ * db.transact(db.tx.goals[goalId].delete())
337
+ *
338
+ * // Or create an association:
339
+ * todoId = id();
340
+ * db.transact([
341
+ * db.tx.todos[todoId].update({ title: 'Go on a run' }),
342
+ * db.tx.goals[goalId].link({todos: todoId}),
343
+ * ])
344
+ */
345
+ transact(chunks) {
346
+ return this._reactor.pushTx(chunks);
347
+ }
348
+ getLocalId(name) {
349
+ return this._reactor.getLocalId(name);
350
+ }
351
+ /**
352
+ * Use this to query your data!
353
+ *
354
+ * @see https://instantdb.com/docs/instaql
355
+ *
356
+ * @example
357
+ * // listen to all goals
358
+ * db.subscribeQuery({ goals: {} }, (resp) => {
359
+ * console.log(resp.data.goals)
360
+ * })
361
+ *
362
+ * // goals where the title is "Get Fit"
363
+ * db.subscribeQuery(
364
+ * { goals: { $: { where: { title: "Get Fit" } } } },
365
+ * (resp) => {
366
+ * console.log(resp.data.goals)
367
+ * }
368
+ * )
369
+ *
370
+ * // all goals, _alongside_ their todos
371
+ * db.subscribeQuery({ goals: { todos: {} } }, (resp) => {
372
+ * console.log(resp.data.goals)
373
+ * });
374
+ */
375
+ subscribeQuery(query, cb, opts) {
376
+ return this._reactor.subscribeQuery(query, cb, opts);
377
+ }
378
+ /**
379
+ * Subscribe to a query and incrementally load more items
380
+ *
381
+ * Only one top level namespace in the query is allowed.
382
+ * @example
383
+ * const { unsubscribe, loadNextPage } = db.subscribeInfiniteQuery({
384
+ * posts: {
385
+ * $: {
386
+ * limit: 20, // Load 20 posts at a time
387
+ * order: {
388
+ * createdAt: 'desc',
389
+ * },
390
+ * },
391
+ * },
392
+ * (resp) => {
393
+ * console.log(resp.data.posts);
394
+ * }
395
+ * });
396
+ */
397
+ subscribeInfiniteQuery(query, cb, opts) {
398
+ return subscribeInfiniteQuery(this, query, cb, opts);
399
+ }
400
+ /**
401
+ * Listen for the logged in state. This is useful
402
+ * for deciding when to show a login screen.
403
+ *
404
+ * @see https://instantdb.com/docs/auth
405
+ * @example
406
+ * const unsub = db.subscribeAuth((auth) => {
407
+ * if (auth.user) {
408
+ * console.log('logged in as', auth.user.email)
409
+ * } else {
410
+ * console.log('logged out')
411
+ * }
412
+ * })
413
+ */
414
+ subscribeAuth(cb) {
415
+ return this._reactor.subscribeAuth(cb);
416
+ }
417
+ /**
418
+ * One time query for the logged in state. This is useful
419
+ * for scenarios where you want to know the current auth
420
+ * state without subscribing to changes.
421
+ *
422
+ * @see https://instantdb.com/docs/auth
423
+ * @example
424
+ * const user = await db.getAuth();
425
+ * console.log('logged in as', user.email)
426
+ */
427
+ getAuth() {
428
+ return this._reactor.getAuth();
429
+ }
430
+ /**
431
+ * Listen for connection status changes to Instant. This is useful
432
+ * for building things like connectivity indicators
433
+ *
434
+ * @see https://www.instantdb.com/docs/patterns#connection-status
435
+ * @example
436
+ * const unsub = db.subscribeConnectionStatus((status) => {
437
+ * const connectionState =
438
+ * status === 'connecting' || status === 'opened'
439
+ * ? 'authenticating'
440
+ * : status === 'authenticated'
441
+ * ? 'connected'
442
+ * : status === 'closed'
443
+ * ? 'closed'
444
+ * : status === 'errored'
445
+ * ? 'errored'
446
+ * : 'unexpected state';
447
+ *
448
+ * console.log('Connection status:', connectionState);
449
+ * });
450
+ */
451
+ subscribeConnectionStatus(cb) {
452
+ return this._reactor.subscribeConnectionStatus(cb);
453
+ }
454
+ /**
455
+ * Observe the app's maintenance-mode state. While read-only, reads and
456
+ * live queries keep working but writes are rejected. The callback fires
457
+ * immediately with the current state and again on every change.
458
+ *
459
+ * @example
460
+ * const unsub = db.subscribeAppStatus(({ isLoading, isReadOnly }) => {
461
+ * if (isLoading) return;
462
+ * if (isReadOnly) showMaintenanceBanner();
463
+ * });
464
+ */
465
+ subscribeAppStatus(cb) {
466
+ return this._reactor.subscribeAppStatus(cb);
467
+ }
468
+ /**
469
+ * Join a room to publish and subscribe to topics and presence.
470
+ *
471
+ * @see https://instantdb.com/docs/presence-and-topics
472
+ * @example
473
+ * // init
474
+ * const db = init();
475
+ * const room = db.joinRoom(roomType, roomId);
476
+ * // usage
477
+ * const unsubscribeTopic = room.subscribeTopic("foo", console.log);
478
+ * const unsubscribePresence = room.subscribePresence({}, console.log);
479
+ * room.publishTopic("hello", { message: "hello world!" });
480
+ * room.publishPresence({ name: "joe" });
481
+ * // later
482
+ * unsubscribePresence();
483
+ * unsubscribeTopic();
484
+ * room.leaveRoom();
485
+ */
486
+ joinRoom(roomType = '_defaultRoomType', roomId = '_defaultRoomId', opts) {
487
+ const leaveRoom = this._reactor.joinRoom(roomType, roomId, opts?.initialPresence);
488
+ return {
489
+ leaveRoom,
490
+ subscribeTopic: (topic, onEvent) => this._reactor.subscribeTopic(roomType, roomId, topic, onEvent),
491
+ subscribePresence: (opts, onChange) => this._reactor.subscribePresence(roomType, roomId, opts, onChange),
492
+ publishTopic: (topic, data) => this._reactor.publishTopic({ roomType, roomId, topic, data }),
493
+ publishPresence: (data) => this._reactor.publishPresence(roomType, roomId, data),
494
+ getPresence: (opts) => this._reactor.getPresence(roomType, roomId, opts),
495
+ };
496
+ }
497
+ shutdown() {
498
+ delete globalInstantCoreStore[reactorKey(this._reactor.config)];
499
+ this._reactor.shutdown();
500
+ }
501
+ /**
502
+ * Use this for one-off queries.
503
+ * Returns local data if available, otherwise fetches from the server.
504
+ * Because we want to avoid stale data, this method will throw an error
505
+ * if the user is offline or there is no active connection to the server.
506
+ *
507
+ * @see https://instantdb.com/docs/instaql
508
+ *
509
+ * @example
510
+ *
511
+ * const resp = await db.queryOnce({ goals: {} });
512
+ * console.log(resp.data.goals)
513
+ */
514
+ queryOnce(query, opts) {
515
+ return this._reactor.queryOnce(query, opts);
516
+ }
517
+ /**
518
+ * @deprecated This is an experimental function that is not yet ready for production use.
519
+ * Use this function to sync an entire namespace.
520
+ * It has many limitations that will be removed in the future:
521
+ * 1. Must be used with an admin token
522
+ * 2. Does not support permissions
523
+ * 3. Does not support where clauses
524
+ * 4. Does not support links
525
+ * It also does not support multiple top-level namespaces. For example,
526
+ * {posts: {}, users: {}} is invalid. Only `posts` or `users` is allowed, but not both.
527
+ */
528
+ _syncTableExperimental(query, cb) {
529
+ return this._reactor.subscribeTable(query, cb);
530
+ }
531
+ }
532
+ function schemaHash(schema) {
533
+ if (!schema) {
534
+ return '0';
535
+ }
536
+ const fromStore = schemaHashStore.get(schema);
537
+ if (fromStore) {
538
+ return fromStore;
539
+ }
540
+ const hash = weakHash(schema);
541
+ schemaHashStore.set(schema, hash);
542
+ return hash;
543
+ }
544
+ function schemaChanged(existingClient, newSchema) {
545
+ return (schemaHash(existingClient._reactor.config.schema) !== schemaHash(newSchema));
546
+ }
547
+ /**
548
+ *
549
+ * The first step: init your application!
550
+ *
551
+ * Visit https://instantdb.com/dash to get your `appId` :)
552
+ *
553
+ * @example
554
+ * import { init } from "@instantdb/core"
555
+ *
556
+ * const db = init({ appId: "my-app-id" })
557
+ *
558
+ * // You can also provide a schema for type safety and editor autocomplete!
559
+ *
560
+ * import { init } from "@instantdb/core"
561
+ * import schema from ""../instant.schema.ts";
562
+ *
563
+ * const db = init({ appId: "my-app-id", schema })
564
+ *
565
+ * // To learn more: https://instantdb.com/docs/modeling-data
566
+ */
567
+ function init(
568
+ // Allows config with missing `useDateObjects`, but keeps `UseDates`
569
+ // as a non-nullable in the InstantConfig type.
570
+ config, Store, NetworkListener, versions, EventSourceImpl) {
571
+ const configStrict = {
572
+ ...config,
573
+ appId: config.appId?.trim(),
574
+ useDateObjects: (config.useDateObjects ?? false),
575
+ };
576
+ const existingClient = globalInstantCoreStore[reactorKey(configStrict)];
577
+ if (existingClient) {
578
+ if (schemaChanged(existingClient, configStrict.schema)) {
579
+ existingClient._reactor.updateSchema(configStrict.schema);
580
+ }
581
+ return existingClient;
582
+ }
583
+ const reactor = new Reactor({
584
+ ...defaultConfig,
585
+ ...configStrict,
586
+ cardinalityInference: configStrict.schema ? true : false,
587
+ }, Store || IndexedDBStorage, NetworkListener || WindowNetworkListener, { ...(versions || {}), '@instantdb/core': version }, EventSourceImpl);
588
+ const client = new InstantCoreDatabase(reactor);
589
+ globalInstantCoreStore[reactorKey(configStrict)] = client;
590
+ handleDevtool(configStrict.appId, configStrict.devtool);
591
+ return client;
592
+ }
593
+ function handleDevtool(appId, devtool) {
594
+ if (typeof window === 'undefined' ||
595
+ typeof window.location === 'undefined' ||
596
+ typeof document === 'undefined') {
597
+ return;
598
+ }
599
+ if (typeof devtool === 'boolean' && !devtool) {
600
+ return;
601
+ }
602
+ const config = {
603
+ position: 'bottom-right',
604
+ allowedHosts: ['localhost'],
605
+ ...(typeof devtool === 'object' ? devtool : {}),
606
+ };
607
+ if (!config.allowedHosts.includes(window.location.hostname)) {
608
+ return;
609
+ }
610
+ createDevtool(appId, config);
611
+ }
612
+ /**
613
+ * @deprecated
614
+ * `init_experimental` is deprecated. You can replace it with `init`.
615
+ *
616
+ * @example
617
+ *
618
+ * // Before
619
+ * import { init_experimental } from "@instantdb/core"
620
+ * const db = init_experimental({ ... });
621
+ *
622
+ * // After
623
+ * import { init } from "@instantdb/core"
624
+ * const db = init({ ... });
625
+ */
626
+ const init_experimental = init;
627
+ export {
628
+ // bada bing bada boom
629
+ init, init_experimental, id, tx, txInit, lookup, validateQuery, QueryValidationError, validateTransactions, parseSchemaFromJSON, TransactionValidationError, FrameworkClient, Reactor,
630
+ // error
631
+ InstantAPIError,
632
+ // warnings
633
+ setInstantWarningsEnabled,
634
+ // cli
635
+ i,
636
+ // util
637
+ getOps, coerceQuery, weakHash, coerceToDate, IndexedDBStorage, WindowNetworkListener, InstantCoreDatabase, Auth, Storage, Streams, version, InstantError,
638
+ // infinite query
639
+ getInfiniteQueryInitialSnapshot,
640
+ // sync table enums
641
+ SyncTableCallbackEventType,
642
+ // SSE
643
+ SSEConnection,
644
+ // streams
645
+ InstantStream,
646
+ // store (e.g. indexeddb) interface
647
+ StoreInterface, createInstantRouteHandler, };
648
+ /** @deprecated Use StoreInterface instead */
649
+ export const StorageInterface = StoreInterface;
@@ -0,0 +1,25 @@
1
+ import { type InstantCoreDatabase, type ValidQuery } from './index.ts';
2
+ import { InstaQLResponse, InstaQLOptions } from './queryTypes.ts';
3
+ import { InstantSchemaDef } from './schemaTypes.ts';
4
+ export type ChunkStatus = 'pre-bootstrap' | 'bootstrapping' | 'frozen';
5
+ export interface InfiniteQuerySubscription {
6
+ unsubscribe: () => void;
7
+ loadNextPage: () => void;
8
+ }
9
+ export type InfiniteQueryCallbackResponse<Schema extends InstantSchemaDef<any, any, any>, Query extends Record<string, any>, UseDatesLocal extends boolean> = {
10
+ error: {
11
+ message: string;
12
+ };
13
+ data: undefined;
14
+ canLoadNextPage: boolean;
15
+ } | {
16
+ error: undefined;
17
+ data: InstaQLResponse<Schema, Query, UseDatesLocal>;
18
+ canLoadNextPage: boolean;
19
+ };
20
+ export declare const subscribeInfiniteQuery: <Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean>(db: InstantCoreDatabase<Schema, UseDates>, fullQuery: Q, cb: (resp: InfiniteQueryCallbackResponse<Schema, Q, UseDates>) => void, opts?: InstaQLOptions) => InfiniteQuerySubscription;
21
+ export declare const getInfiniteQueryInitialSnapshot: <Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean>(db: InstantCoreDatabase<Schema, UseDates>, fullQuery: Q | null, opts?: InstaQLOptions) => InfiniteQueryCallbackResponse<Schema, Q, UseDates> | {
22
+ canLoadNextPage: false;
23
+ data: undefined;
24
+ error: undefined;
25
+ };