@sidekickdb/core 0.0.0 → 2.0.1

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