@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,85 @@
1
+ import { InstantSchemaDef, InstantUnknownSchema } from './schemaTypes.ts';
2
+ type InstantRulesAttrsAllowBlock = {
3
+ $default?: string | null | undefined;
4
+ view?: string | null | undefined;
5
+ create?: string | null | undefined;
6
+ update?: string | null | undefined;
7
+ delete?: string | null | undefined;
8
+ };
9
+ export type InstantRulesAllowBlock = InstantRulesAttrsAllowBlock & {
10
+ link?: {
11
+ [key: string]: string;
12
+ } | null | undefined;
13
+ unlink?: {
14
+ [key: string]: string;
15
+ } | null | undefined;
16
+ };
17
+ /**
18
+ * How tokens refill in a rate limit bucket.
19
+ * - `'greedy'`: tokens trickle in continuously over the period.
20
+ * - `'interval'`: all tokens are added at once when the period elapses.
21
+ */
22
+ export type InstantRulesRateLimitRefillType = 'interval' | 'greedy';
23
+ /**
24
+ * Configuration for how a rate limit bucket refills.
25
+ * All fields are optional and have sensible defaults.
26
+ */
27
+ export type InstantRulesRateLimitRefill = {
28
+ /** Number of tokens added per refill. Defaults to the bucket's capacity. */
29
+ amount?: number | null | undefined;
30
+ /**
31
+ * How often tokens refill, as a duration string (e.g. `"1 hour"`, `"30 minutes"`, `"1 day"`).
32
+ * Must be between 1 second and 24 hours. Defaults to `"1 hour"`.
33
+ */
34
+ period?: string | null | undefined;
35
+ /** Refill strategy. Defaults to `"greedy"`. */
36
+ type?: InstantRulesRateLimitRefillType | null | undefined;
37
+ };
38
+ /**
39
+ * A single rate limit within a bucket. Each limit represents one token bucket
40
+ * constraint. You can combine multiple limits (e.g. a burst limit and a sustained limit).
41
+ */
42
+ export type InstantRulesRateLimitLimit = {
43
+ /** Maximum number of tokens in the bucket. */
44
+ capacity: number;
45
+ /** Refill configuration. Defaults to greedy refill of the full capacity every hour. */
46
+ refill?: InstantRulesRateLimitRefill | null | undefined;
47
+ };
48
+ /**
49
+ * A named rate limit bucket configuration. Use in permission rules via
50
+ * `rateLimit.bucketName.limit(key)`.
51
+ */
52
+ export type InstantRulesRateLimit = {
53
+ /** One or more token bucket limits to apply. */
54
+ limits: Array<InstantRulesRateLimitLimit>;
55
+ };
56
+ /**
57
+ * Map of rate limit names to their configurations.
58
+ * Defined under the `$rateLimits` key in your permission rules.
59
+ */
60
+ export type InstantRulesRateLimits = Record<string, InstantRulesRateLimit>;
61
+ type InstantRulesEntityBlock<Schema extends InstantSchemaDef<any, any, any>, EntityName extends keyof Schema['entities']> = {
62
+ bind?: string[] | Record<string, string>;
63
+ allow: InstantRulesAllowBlock;
64
+ fields?: {
65
+ [AttrName in Exclude<keyof Schema['entities'][EntityName]['attrs'], 'id'>]?: string;
66
+ };
67
+ };
68
+ export type InstantRules<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema> = {
69
+ [K in 'attrs' | '$default' | '$rateLimits']?: K extends 'attrs' ? {
70
+ bind?: string[] | Record<string, string>;
71
+ allow: InstantRulesAttrsAllowBlock;
72
+ } : K extends '$default' ? {
73
+ bind?: string[] | Record<string, string>;
74
+ allow: InstantRulesAllowBlock;
75
+ } : K extends '$rateLimits' ? InstantRulesRateLimits : never;
76
+ } & {
77
+ [K in keyof Schema['entities'] | 'attrs' | '$default' | '$rateLimits']?: K extends 'attrs' ? {
78
+ bind?: string[] | Record<string, string>;
79
+ allow: InstantRulesAttrsAllowBlock;
80
+ } : K extends '$default' ? {
81
+ bind?: string[] | Record<string, string>;
82
+ allow: InstantRulesAllowBlock;
83
+ } : K extends '$rateLimits' ? InstantRulesRateLimits : K extends keyof Schema['entities'] ? InstantRulesEntityBlock<Schema, K> : never;
84
+ };
85
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { InstaQLResponse, ValidQuery } from './queryTypes.ts';
2
+ import { InstantUnknownSchema } from './schemaTypes.ts';
3
+ /**
4
+ * The purpose of these sanity checks:
5
+ * If we make changes and something breaks, our build will fail.
6
+ *
7
+ * AFAIK we _could_ write this in our `tests` folder.
8
+ * The latest version of `vitest` does support `assertType`, but:
9
+ * * it's easy to get false positives if configured incorrectly
10
+ * * the api is more vebose than this
11
+ */
12
+ export declare function dummyQuery<Q extends ValidQuery<Q, InstantUnknownSchema>>(_query: Q): InstaQLResponse<InstantUnknownSchema, Q>;
13
+ export interface ExUser {
14
+ name: string;
15
+ }
16
+ export interface ExPost {
17
+ title: string;
18
+ }
@@ -0,0 +1,152 @@
1
+ // --------
2
+ // Sanity check tests
3
+ /**
4
+ * The purpose of these sanity checks:
5
+ * If we make changes and something breaks, our build will fail.
6
+ *
7
+ * AFAIK we _could_ write this in our `tests` folder.
8
+ * The latest version of `vitest` does support `assertType`, but:
9
+ * * it's easy to get false positives if configured incorrectly
10
+ * * the api is more vebose than this
11
+ */
12
+ export function dummyQuery(_query) {
13
+ return 1;
14
+ }
15
+ const sanityCheckQueries = () => {
16
+ // -----------
17
+ // Basic good inputs succeed
18
+ const r = dummyQuery({ users: {} });
19
+ // -----------
20
+ // Basic bad inputs fails
21
+ // @ts-expect-error
22
+ const r2 = dummyQuery({ users: 1 });
23
+ // @ts-expect-error
24
+ const r3 = dummyQuery({ users: '' });
25
+ // ----------------------
26
+ // Good $ clauses succeed
27
+ const r4 = dummyQuery({ users: { $: { where: { foo: 1 } } } });
28
+ const r5 = dummyQuery({ users: { $: { where: { foo: 'str' } } } });
29
+ const r6 = dummyQuery({ users: { $: { where: { foo: true } } } });
30
+ const r7 = dummyQuery({ users: { $: { where: { 'foo.bar.baz': 1 } } } });
31
+ const s1 = dummyQuery({
32
+ users: { $: { where: { foo: { in: [1, 2, 3] } } } },
33
+ });
34
+ const s1_5 = dummyQuery({
35
+ users: { $: { where: { foo: { $in: [1, 2, 3] } } } },
36
+ });
37
+ const t1 = dummyQuery({
38
+ users: { $: { where: { or: [{ foo: 1 }] } } },
39
+ });
40
+ // You can have a field named or
41
+ const t2 = dummyQuery({
42
+ users: { $: { where: { or: 'fieldNamedOr' } } },
43
+ });
44
+ const t3 = dummyQuery({
45
+ users: { $: { where: { and: [{ foo: 1 }] } } },
46
+ });
47
+ // You can have a field named and
48
+ const t4 = dummyQuery({
49
+ users: { $: { where: { and: 'fieldNamedAnd' } } },
50
+ });
51
+ const t5 = dummyQuery({
52
+ users: { $: { where: { and: [{ or: [{ foo: 1 }] }] } } },
53
+ });
54
+ // Pagination
55
+ const t6 = dummyQuery({
56
+ users: { $: { limit: 10 } },
57
+ });
58
+ const t7 = dummyQuery({
59
+ users: { $: { limit: 10, offset: 10 } },
60
+ });
61
+ const t8 = dummyQuery({
62
+ users: { $: { where: { foo: 1 }, limit: 10, offset: 10 } },
63
+ });
64
+ const cursor = [
65
+ '61935703-bec6-4ade-ad9b-8bf382b92f69',
66
+ '995f5a9b-9ae1-4e59-97d1-df33afb44aee',
67
+ '61935703-bec6-4ade-ad9b-8bf382b92f69',
68
+ 10,
69
+ ];
70
+ const t9 = dummyQuery({
71
+ users: {
72
+ $: { where: { foo: 1 }, after: cursor },
73
+ },
74
+ });
75
+ const t10 = dummyQuery({
76
+ users: { $: { before: cursor } },
77
+ });
78
+ const t12 = dummyQuery({
79
+ users: { $: { where: { val: { $isNull: true } } } },
80
+ });
81
+ const t13 = dummyQuery({
82
+ users: { $: { where: { val: { $not: 'a' } } } },
83
+ });
84
+ const t14 = dummyQuery({
85
+ users: {
86
+ $: { fields: ['name', 'age', 'dob'] },
87
+ posts: { $: { fields: ['title'] } },
88
+ },
89
+ });
90
+ // ------------------
91
+ // Bad $ clauses fail
92
+ // @ts-expect-error
93
+ const r8 = dummyQuery({ users: { $: { where: 'foo' } } });
94
+ // #ts-expect-error
95
+ const r9 = dummyQuery({ users: { $: { where: { foo: {} } } } });
96
+ // @ts-expect-error
97
+ const r10 = dummyQuery({ users: { $: { where2: 1 } } });
98
+ const s2 = dummyQuery({
99
+ // #ts-expect-error
100
+ users: { $: { where: { foo: { ini: [1, 2, 3] } } } },
101
+ });
102
+ const s3 = dummyQuery({
103
+ // #ts-expect-error
104
+ users: { $: { where: { foo: [] } } },
105
+ });
106
+ const s4 = dummyQuery({
107
+ // #ts-expect-error
108
+ users: { $: { where: { val: { $isNull: 'a' } } } },
109
+ });
110
+ const s5 = dummyQuery({
111
+ // @ts-expect-error
112
+ users: { $: { where: { 'josijf.jsdfli': { $isNull: 'a' } } } },
113
+ });
114
+ // NOTE: Used to error before adding typesafe-where operator, issue is incompatibility
115
+ // with NonEmpty and dynamic $isNull checks
116
+ const s6 = dummyQuery({
117
+ users: { $: { where: { val: { $gt: { val: 'a' } } } } },
118
+ });
119
+ // ----------------
120
+ // Good Nested queries succeed
121
+ const r11 = dummyQuery({ users: { posts: {} } });
122
+ const r12 = dummyQuery({ users: {}, posts: {} });
123
+ const r13 = dummyQuery({
124
+ users: {
125
+ $: { where: { foo: 1 } },
126
+ posts: { $: { where: { foo: 1 } } },
127
+ },
128
+ });
129
+ // ----------
130
+ // Bad nested queries fail
131
+ // #ts-expect-error
132
+ const r14 = dummyQuery({ users: { foo: 1 } });
133
+ const r15 = dummyQuery({
134
+ // @ts-expect-error
135
+ users: { $: { fields: 'name' } },
136
+ });
137
+ };
138
+ const sanityCheckSchemalessResponses = () => {
139
+ // Simple Response
140
+ const r1 = dummyQuery({ users: {} });
141
+ // Nested Response
142
+ const r2 = dummyQuery({ users: { posts: {} } });
143
+ // $ are ignored
144
+ const r3 = dummyQuery({
145
+ users: {
146
+ $: { where: { foo: 1 } },
147
+ posts: {},
148
+ },
149
+ });
150
+ // @ts-expect-error
151
+ r3.$;
152
+ };
@@ -0,0 +1,72 @@
1
+ import { EntityDef, DataAttrDef, InstantSchemaDef, type EntitiesDef, type AttrsDefs, type EntitiesWithLinks, type LinksDef, type RoomsDef, type UnknownRooms } from './schemaTypes.ts';
2
+ /**
3
+ * @deprecated
4
+ * `i.graph` is deprecated. Use `i.schema` instead.
5
+ *
6
+ * @example
7
+ * // Before
8
+ * i.graph(entities, links).withRoomSchema<RoomType>();
9
+ *
10
+ * // After
11
+ * i.schema({ entities, links, rooms })
12
+ *
13
+ * @see
14
+ * https://instantdb.com/docs/modeling-data
15
+ */
16
+ declare function graph<EntitiesWithoutLinks extends EntitiesDef, const Links extends LinksDef<EntitiesWithoutLinks>>(entities: EntitiesWithoutLinks, links: Links): InstantSchemaDef<EntitiesWithLinks<EntitiesWithoutLinks, Links>, LinksDef<any>, UnknownRooms>;
17
+ /**
18
+ * Creates an entity definition, to be used in conjunction with `i.graph`.
19
+ *
20
+ * @see https://instantdb.com/docs/modeling-data
21
+ * @example
22
+ * {
23
+ * posts: i.entity({
24
+ * title: i.string(),
25
+ * body: i.string(),
26
+ * }),
27
+ * comments: i.entity({
28
+ * body: i.string(),
29
+ * })
30
+ * }
31
+ */
32
+ declare function entity<Attrs extends AttrsDefs>(attrs: Attrs): EntityDef<Attrs, {}, void>;
33
+ declare function string<StringEnum extends string = string>(): DataAttrDef<StringEnum, true, false>;
34
+ declare function number(): DataAttrDef<number, true, false>;
35
+ declare function boolean(): DataAttrDef<boolean, true, false>;
36
+ declare function date(): DataAttrDef<Date, true, false>;
37
+ declare function json<T = any>(): DataAttrDef<T, true, false>;
38
+ declare function any(): DataAttrDef<any, true, false>;
39
+ /**
40
+ * Lets you define a schema for your database.
41
+ *
42
+ * You can define entities, links between entities, and if you use
43
+ * presence, you can define rooms.
44
+ *
45
+ * You can push this schema to your database with the CLI,
46
+ * or use it inside `init`, to get typesafety and autocompletion.
47
+ *
48
+ * @see https://instantdb.com/docs/modeling-data
49
+ * @example
50
+ * i.schema({
51
+ * entities: { },
52
+ * links: { },
53
+ * rooms: { }
54
+ * });
55
+ */
56
+ declare function schema<EntitiesWithoutLinks extends EntitiesDef, const Links extends LinksDef<EntitiesWithoutLinks>, Rooms extends RoomsDef = {}>({ entities, links, rooms, }: {
57
+ entities: EntitiesWithoutLinks;
58
+ links?: Links;
59
+ rooms?: Rooms;
60
+ }): InstantSchemaDef<EntitiesWithLinks<EntitiesWithoutLinks, Links>, LinksDef<any>, Rooms>;
61
+ export declare const i: {
62
+ graph: typeof graph;
63
+ schema: typeof schema;
64
+ entity: typeof entity;
65
+ string: typeof string;
66
+ number: typeof number;
67
+ boolean: typeof boolean;
68
+ date: typeof date;
69
+ json: typeof json;
70
+ any: typeof any;
71
+ };
72
+ export {};
@@ -0,0 +1,128 @@
1
+ import { EntityDef, DataAttrDef, InstantSchemaDef, } from './schemaTypes.js';
2
+ // ==========
3
+ // API
4
+ /**
5
+ * @deprecated
6
+ * `i.graph` is deprecated. Use `i.schema` instead.
7
+ *
8
+ * @example
9
+ * // Before
10
+ * i.graph(entities, links).withRoomSchema<RoomType>();
11
+ *
12
+ * // After
13
+ * i.schema({ entities, links, rooms })
14
+ *
15
+ * @see
16
+ * https://instantdb.com/docs/modeling-data
17
+ */
18
+ function graph(entities, links) {
19
+ return new InstantSchemaDef(enrichEntitiesWithLinks(entities, links),
20
+ // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
21
+ // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
22
+ // EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
23
+ // correctly aligned and does not allow for substituting a type that might
24
+ // be broader or have additional properties.
25
+ links, undefined);
26
+ }
27
+ /**
28
+ * Creates an entity definition, to be used in conjunction with `i.graph`.
29
+ *
30
+ * @see https://instantdb.com/docs/modeling-data
31
+ * @example
32
+ * {
33
+ * posts: i.entity({
34
+ * title: i.string(),
35
+ * body: i.string(),
36
+ * }),
37
+ * comments: i.entity({
38
+ * body: i.string(),
39
+ * })
40
+ * }
41
+ */
42
+ function entity(attrs) {
43
+ return new EntityDef(attrs, {});
44
+ }
45
+ function string() {
46
+ return new DataAttrDef('string', true, false);
47
+ }
48
+ function number() {
49
+ return new DataAttrDef('number', true, false);
50
+ }
51
+ function boolean() {
52
+ return new DataAttrDef('boolean', true, false);
53
+ }
54
+ function date() {
55
+ return new DataAttrDef('date', true, false);
56
+ }
57
+ function json() {
58
+ return new DataAttrDef('json', true, false);
59
+ }
60
+ function any() {
61
+ return new DataAttrDef('json', true, false);
62
+ }
63
+ // ==========
64
+ // internal
65
+ function enrichEntitiesWithLinks(entities, links) {
66
+ const linksIndex = { fwd: {}, rev: {} };
67
+ for (const linkDef of Object.values(links)) {
68
+ linksIndex.fwd[linkDef.forward.on] ||= {};
69
+ linksIndex.rev[linkDef.reverse.on] ||= {};
70
+ linksIndex.fwd[linkDef.forward.on][linkDef.forward.label] = {
71
+ entityName: linkDef.reverse.on,
72
+ cardinality: linkDef.forward.has,
73
+ };
74
+ linksIndex.rev[linkDef.reverse.on][linkDef.reverse.label] = {
75
+ entityName: linkDef.forward.on,
76
+ cardinality: linkDef.reverse.has,
77
+ };
78
+ }
79
+ const enrichedEntities = Object.fromEntries(Object.entries(entities).map(([name, def]) => [
80
+ name,
81
+ new EntityDef(def.attrs, {
82
+ ...linksIndex.fwd[name],
83
+ ...linksIndex.rev[name],
84
+ }),
85
+ ]));
86
+ return enrichedEntities;
87
+ }
88
+ /**
89
+ * Lets you define a schema for your database.
90
+ *
91
+ * You can define entities, links between entities, and if you use
92
+ * presence, you can define rooms.
93
+ *
94
+ * You can push this schema to your database with the CLI,
95
+ * or use it inside `init`, to get typesafety and autocompletion.
96
+ *
97
+ * @see https://instantdb.com/docs/modeling-data
98
+ * @example
99
+ * i.schema({
100
+ * entities: { },
101
+ * links: { },
102
+ * rooms: { }
103
+ * });
104
+ */
105
+ function schema({ entities, links, rooms, }) {
106
+ const linksDef = (links ?? {});
107
+ const roomsDef = (rooms ?? {});
108
+ return new InstantSchemaDef(enrichEntitiesWithLinks(entities, linksDef),
109
+ // (XXX): LinksDef<any> stems from TypeScript's inability to reconcile the
110
+ // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
111
+ // EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
112
+ // correctly aligned and does not allow for substituting a type that might
113
+ // be broader or have additional properties.
114
+ linksDef, roomsDef);
115
+ }
116
+ export const i = {
117
+ // constructs
118
+ graph,
119
+ schema,
120
+ entity,
121
+ // value types
122
+ string,
123
+ number,
124
+ boolean,
125
+ date,
126
+ json,
127
+ any,
128
+ };