@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.
- package/README.md +6 -2
- package/THIRD_PARTY_NOTICES.md +17 -0
- package/dist/browser.d.ts +85 -0
- package/dist/browser.js +16 -0
- package/dist/database-binding.d.ts +7 -0
- package/dist/database-binding.js +11 -0
- package/dist/hosted-session.d.ts +1 -0
- package/dist/hosted-session.js +11 -0
- package/dist/http.d.ts +24 -0
- package/dist/http.js +92 -0
- package/dist/inventory.d.ts +7 -0
- package/dist/inventory.js +18 -0
- package/dist/management-read.d.ts +17 -0
- package/dist/management-read.js +104 -0
- package/dist/management.d.ts +347 -0
- package/dist/management.js +137 -0
- package/dist/operator.d.ts +136 -0
- package/dist/operator.js +53 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +10 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.js +30 -0
- package/dist/services.d.ts +7 -0
- package/dist/services.js +53 -0
- package/dist/storage.d.ts +68 -0
- package/dist/storage.js +30 -0
- package/dist/tasks.d.ts +42 -0
- package/dist/tasks.js +24 -0
- package/dist/wire.gen.d.ts +7107 -0
- package/dist/wire.gen.js +5 -0
- package/native-provenance.json +15 -0
- package/node_modules/@instantdb/admin/LICENSE +202 -0
- package/node_modules/@instantdb/admin/dist/esm/index.d.ts +607 -0
- package/node_modules/@instantdb/admin/dist/esm/index.js +1036 -0
- package/node_modules/@instantdb/admin/dist/esm/polyfill.d.ts +16 -0
- package/node_modules/@instantdb/admin/dist/esm/polyfill.js +21 -0
- package/node_modules/@instantdb/admin/dist/esm/subscribe.d.ts +38 -0
- package/node_modules/@instantdb/admin/dist/esm/subscribe.js +301 -0
- package/node_modules/@instantdb/admin/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/admin/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/admin/package.json +23 -0
- package/node_modules/@instantdb/core/LICENSE +202 -0
- package/node_modules/@instantdb/core/dist/esm/Connection.d.ts +92 -0
- package/node_modules/@instantdb/core/dist/esm/Connection.js +188 -0
- package/node_modules/@instantdb/core/dist/esm/InMemoryStorage.d.ts +10 -0
- package/node_modules/@instantdb/core/dist/esm/InMemoryStorage.js +25 -0
- package/node_modules/@instantdb/core/dist/esm/IndexedDBStorage.d.ts +17 -0
- package/node_modules/@instantdb/core/dist/esm/IndexedDBStorage.js +309 -0
- package/node_modules/@instantdb/core/dist/esm/InstantError.d.ts +6 -0
- package/node_modules/@instantdb/core/dist/esm/InstantError.js +23 -0
- package/node_modules/@instantdb/core/dist/esm/Reactor.d.ts +430 -0
- package/node_modules/@instantdb/core/dist/esm/Reactor.js +2369 -0
- package/node_modules/@instantdb/core/dist/esm/StorageAPI.d.ts +39 -0
- package/node_modules/@instantdb/core/dist/esm/StorageAPI.js +65 -0
- package/node_modules/@instantdb/core/dist/esm/Stream.d.ts +120 -0
- package/node_modules/@instantdb/core/dist/esm/Stream.js +811 -0
- package/node_modules/@instantdb/core/dist/esm/SyncTable.d.ts +144 -0
- package/node_modules/@instantdb/core/dist/esm/SyncTable.js +523 -0
- package/node_modules/@instantdb/core/dist/esm/WindowNetworkListener.d.ts +4 -0
- package/node_modules/@instantdb/core/dist/esm/WindowNetworkListener.js +19 -0
- package/node_modules/@instantdb/core/dist/esm/attrTypes.d.ts +25 -0
- package/node_modules/@instantdb/core/dist/esm/attrTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/authAPI.d.ts +64 -0
- package/node_modules/@instantdb/core/dist/esm/authAPI.js +103 -0
- package/node_modules/@instantdb/core/dist/esm/clientTypes.d.ts +40 -0
- package/node_modules/@instantdb/core/dist/esm/clientTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/coreTypes.d.ts +33 -0
- package/node_modules/@instantdb/core/dist/esm/coreTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/createRouteHandler.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/createRouteHandler.js +51 -0
- package/node_modules/@instantdb/core/dist/esm/datalog.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/datalog.js +99 -0
- package/node_modules/@instantdb/core/dist/esm/devtool.d.ts +3 -0
- package/node_modules/@instantdb/core/dist/esm/devtool.js +144 -0
- package/node_modules/@instantdb/core/dist/esm/framework.d.ts +80 -0
- package/node_modules/@instantdb/core/dist/esm/framework.js +243 -0
- package/node_modules/@instantdb/core/dist/esm/helperTypes.d.ts +75 -0
- package/node_modules/@instantdb/core/dist/esm/helperTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/index.d.ts +597 -0
- package/node_modules/@instantdb/core/dist/esm/index.js +649 -0
- package/node_modules/@instantdb/core/dist/esm/infiniteQuery.d.ts +25 -0
- package/node_modules/@instantdb/core/dist/esm/infiniteQuery.js +430 -0
- package/node_modules/@instantdb/core/dist/esm/instaml.d.ts +17 -0
- package/node_modules/@instantdb/core/dist/esm/instaml.js +576 -0
- package/node_modules/@instantdb/core/dist/esm/instaql.d.ts +12 -0
- package/node_modules/@instantdb/core/dist/esm/instaql.js +632 -0
- package/node_modules/@instantdb/core/dist/esm/instatx.d.ts +127 -0
- package/node_modules/@instantdb/core/dist/esm/instatx.js +93 -0
- package/node_modules/@instantdb/core/dist/esm/model/instaqlResult.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/model/instaqlResult.js +24 -0
- package/node_modules/@instantdb/core/dist/esm/parseSchemaFromJSON.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/parseSchemaFromJSON.js +142 -0
- package/node_modules/@instantdb/core/dist/esm/presence.d.ts +50 -0
- package/node_modules/@instantdb/core/dist/esm/presence.js +50 -0
- package/node_modules/@instantdb/core/dist/esm/presenceTypes.d.ts +9 -0
- package/node_modules/@instantdb/core/dist/esm/presenceTypes.js +3 -0
- package/node_modules/@instantdb/core/dist/esm/queryTypes.d.ts +271 -0
- package/node_modules/@instantdb/core/dist/esm/queryTypes.js +3 -0
- package/node_modules/@instantdb/core/dist/esm/queryValidation.d.ts +5 -0
- package/node_modules/@instantdb/core/dist/esm/queryValidation.js +287 -0
- package/node_modules/@instantdb/core/dist/esm/reactorTypes.d.ts +29 -0
- package/node_modules/@instantdb/core/dist/esm/reactorTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/routeHandlerProtocol.d.ts +19 -0
- package/node_modules/@instantdb/core/dist/esm/routeHandlerProtocol.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/rulesTypes.d.ts +85 -0
- package/node_modules/@instantdb/core/dist/esm/rulesTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/sanityCheckQueries.d.ts +18 -0
- package/node_modules/@instantdb/core/dist/esm/sanityCheckQueries.js +152 -0
- package/node_modules/@instantdb/core/dist/esm/schema.d.ts +72 -0
- package/node_modules/@instantdb/core/dist/esm/schema.js +128 -0
- package/node_modules/@instantdb/core/dist/esm/schemaTypes.d.ts +244 -0
- package/node_modules/@instantdb/core/dist/esm/schemaTypes.js +106 -0
- package/node_modules/@instantdb/core/dist/esm/store.d.ts +89 -0
- package/node_modules/@instantdb/core/dist/esm/store.js +722 -0
- package/node_modules/@instantdb/core/dist/esm/transactionValidation.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/transactionValidation.js +130 -0
- package/node_modules/@instantdb/core/dist/esm/utils/Deferred.d.ts +8 -0
- package/node_modules/@instantdb/core/dist/esm/utils/Deferred.js +17 -0
- package/node_modules/@instantdb/core/dist/esm/utils/PersistedObject.d.ts +80 -0
- package/node_modules/@instantdb/core/dist/esm/utils/PersistedObject.js +448 -0
- package/node_modules/@instantdb/core/dist/esm/utils/dates.d.ts +1 -0
- package/node_modules/@instantdb/core/dist/esm/utils/dates.js +211 -0
- package/node_modules/@instantdb/core/dist/esm/utils/error.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/utils/error.js +8 -0
- package/node_modules/@instantdb/core/dist/esm/utils/fetch.d.ts +125 -0
- package/node_modules/@instantdb/core/dist/esm/utils/fetch.js +31 -0
- package/node_modules/@instantdb/core/dist/esm/utils/flags.d.ts +4 -0
- package/node_modules/@instantdb/core/dist/esm/utils/flags.js +10 -0
- package/node_modules/@instantdb/core/dist/esm/utils/id.d.ts +3 -0
- package/node_modules/@instantdb/core/dist/esm/utils/id.js +25 -0
- package/node_modules/@instantdb/core/dist/esm/utils/linkIndex.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/utils/linkIndex.js +17 -0
- package/node_modules/@instantdb/core/dist/esm/utils/log.d.ts +6 -0
- package/node_modules/@instantdb/core/dist/esm/utils/log.js +13 -0
- package/node_modules/@instantdb/core/dist/esm/utils/object.d.ts +16 -0
- package/node_modules/@instantdb/core/dist/esm/utils/object.js +143 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pgtime.d.ts +197 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pgtime.js +197 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pick.d.ts +1 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pick.js +9 -0
- package/node_modules/@instantdb/core/dist/esm/utils/strings.d.ts +1 -0
- package/node_modules/@instantdb/core/dist/esm/utils/strings.js +15 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHash.d.ts +15 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHash.js +71 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHashLegacy.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHashLegacy.js +72 -0
- package/node_modules/@instantdb/core/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/core/dist/esm/warningToggle.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/warningToggle.js +4 -0
- package/node_modules/@instantdb/core/package.json +20 -0
- package/node_modules/@instantdb/eventsource/LICENSE +22 -0
- package/node_modules/@instantdb/eventsource/README.md +226 -0
- package/node_modules/@instantdb/eventsource/dist/index.cjs +279 -0
- package/node_modules/@instantdb/eventsource/dist/index.cjs.map +1 -0
- package/node_modules/@instantdb/eventsource/dist/index.d.cts +346 -0
- package/node_modules/@instantdb/eventsource/dist/index.d.ts +346 -0
- package/node_modules/@instantdb/eventsource/dist/index.js +279 -0
- package/node_modules/@instantdb/eventsource/dist/index.js.map +1 -0
- package/node_modules/@instantdb/eventsource/package.json +128 -0
- package/node_modules/@instantdb/eventsource/src/EventSource.ts +614 -0
- package/node_modules/@instantdb/eventsource/src/errors.ts +141 -0
- package/node_modules/@instantdb/eventsource/src/index.ts +3 -0
- package/node_modules/@instantdb/eventsource/src/types.ts +164 -0
- package/node_modules/@instantdb/react/LICENSE +202 -0
- package/node_modules/@instantdb/react/dist/esm/Cursors.d.ts +18 -0
- package/node_modules/@instantdb/react/dist/esm/Cursors.js +103 -0
- package/node_modules/@instantdb/react/dist/esm/InstantReactWebDatabase.d.ts +5 -0
- package/node_modules/@instantdb/react/dist/esm/InstantReactWebDatabase.js +5 -0
- package/node_modules/@instantdb/react/dist/esm/index.d.ts +6 -0
- package/node_modules/@instantdb/react/dist/esm/index.js +22 -0
- package/node_modules/@instantdb/react/dist/esm/init.d.ts +40 -0
- package/node_modules/@instantdb/react/dist/esm/init.js +49 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/HydrationStreamProvider.d.ts +65 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/HydrationStreamProvider.js +96 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantNextDatabase.d.ts +11 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantNextDatabase.js +31 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantSuspenseProvider.d.ts +24 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantSuspenseProvider.js +162 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/getUserFromInstantCookie.d.ts +9 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/getUserFromInstantCookie.js +16 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/htmlescape.d.ts +2 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/htmlescape.js +20 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/index.d.ts +29 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/index.js +34 -0
- package/node_modules/@instantdb/react/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/react/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/react/package.json +24 -0
- package/node_modules/@instantdb/react-common/LICENSE +202 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactAbstractDatabase.d.ts +282 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactAbstractDatabase.js +386 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactRoom.d.ts +182 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactRoom.js +280 -0
- package/node_modules/@instantdb/react-common/dist/esm/index.d.ts +4 -0
- package/node_modules/@instantdb/react-common/dist/esm/index.js +3 -0
- package/node_modules/@instantdb/react-common/dist/esm/useInfiniteQuerySubscription.d.ts +27 -0
- package/node_modules/@instantdb/react-common/dist/esm/useInfiniteQuerySubscription.js +53 -0
- package/node_modules/@instantdb/react-common/dist/esm/useQuery.d.ts +6 -0
- package/node_modules/@instantdb/react-common/dist/esm/useQuery.js +75 -0
- package/node_modules/@instantdb/react-common/dist/esm/useTimeout.d.ts +4 -0
- package/node_modules/@instantdb/react-common/dist/esm/useTimeout.js +17 -0
- package/node_modules/@instantdb/react-common/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/react-common/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/react-common/package.json +22 -0
- package/node_modules/@instantdb/version/LICENSE +202 -0
- package/node_modules/@instantdb/version/dist/esm/index.d.ts +2 -0
- package/node_modules/@instantdb/version/dist/esm/index.js +2 -0
- package/node_modules/@instantdb/version/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/version/dist/esm/version.js +5 -0
- package/node_modules/@instantdb/version/package.json +16 -0
- package/node_modules/@instantdb/webhooks/LICENSE +202 -0
- package/node_modules/@instantdb/webhooks/dist/esm/index.d.ts +587 -0
- package/node_modules/@instantdb/webhooks/dist/esm/index.js +748 -0
- package/node_modules/@instantdb/webhooks/package.json +18 -0
- package/node_modules/cookie/LICENSE +24 -0
- package/node_modules/cookie/README.md +295 -0
- package/node_modules/cookie/dist/index.d.ts +143 -0
- package/node_modules/cookie/dist/index.js +355 -0
- package/node_modules/cookie/dist/index.js.map +1 -0
- package/node_modules/cookie/package.json +57 -0
- package/node_modules/eventsource/LICENSE +22 -0
- package/node_modules/eventsource/README.md +252 -0
- package/node_modules/eventsource/dist/EventSource.d.ts +128 -0
- package/node_modules/eventsource/dist/EventSource.d.ts.map +1 -0
- package/node_modules/eventsource/dist/EventSource.js +556 -0
- package/node_modules/eventsource/dist/EventSource.js.map +1 -0
- package/node_modules/eventsource/dist/errors.d.ts +53 -0
- package/node_modules/eventsource/dist/errors.d.ts.map +1 -0
- package/node_modules/eventsource/dist/errors.js +120 -0
- package/node_modules/eventsource/dist/errors.js.map +1 -0
- package/node_modules/eventsource/dist/index.d.ts +4 -0
- package/node_modules/eventsource/dist/index.d.ts.map +1 -0
- package/node_modules/eventsource/dist/index.js +3 -0
- package/node_modules/eventsource/dist/index.js.map +1 -0
- package/node_modules/eventsource/dist/types.d.ts +156 -0
- package/node_modules/eventsource/dist/types.d.ts.map +1 -0
- package/node_modules/eventsource/dist/types.js +2 -0
- package/node_modules/eventsource/dist/types.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/LICENSE +21 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/README.md +177 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.d.ts +35 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.js +16 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.d.ts +4 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.js +3 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.d.ts +12 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.js +509 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.d.ts +76 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.js +59 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.d.ts +130 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.js +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/package.json +96 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/errors.ts +44 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/index.ts +3 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/parse.ts +576 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/stream.ts +118 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/types.ts +138 -0
- package/node_modules/eventsource/package.json +103 -0
- package/node_modules/eventsource/src/EventSource.ts +844 -0
- package/node_modules/eventsource/src/errors.ts +141 -0
- package/node_modules/eventsource/src/index.ts +3 -0
- package/node_modules/eventsource/src/types.ts +166 -0
- package/node_modules/eventsource-parser/LICENSE +21 -0
- package/node_modules/eventsource-parser/README.md +157 -0
- package/node_modules/eventsource-parser/dist/index.cjs +177 -0
- package/node_modules/eventsource-parser/dist/index.cjs.map +1 -0
- package/node_modules/eventsource-parser/dist/index.d.cts +169 -0
- package/node_modules/eventsource-parser/dist/index.d.ts +169 -0
- package/node_modules/eventsource-parser/dist/index.js +177 -0
- package/node_modules/eventsource-parser/dist/index.js.map +1 -0
- package/node_modules/eventsource-parser/dist/stream.cjs +29 -0
- package/node_modules/eventsource-parser/dist/stream.cjs.map +1 -0
- package/node_modules/eventsource-parser/dist/stream.d.cts +134 -0
- package/node_modules/eventsource-parser/dist/stream.d.ts +134 -0
- package/node_modules/eventsource-parser/dist/stream.js +30 -0
- package/node_modules/eventsource-parser/dist/stream.js.map +1 -0
- package/node_modules/eventsource-parser/package.json +92 -0
- package/node_modules/eventsource-parser/src/errors.ts +44 -0
- package/node_modules/eventsource-parser/src/index.ts +8 -0
- package/node_modules/eventsource-parser/src/parse.ts +439 -0
- package/node_modules/eventsource-parser/src/stream.ts +107 -0
- package/node_modules/eventsource-parser/src/types.ts +122 -0
- package/node_modules/eventsource-parser/stream.js +2 -0
- package/node_modules/mutative/LICENSE +21 -0
- package/node_modules/mutative/README.md +870 -0
- package/node_modules/mutative/dist/apply.d.ts +31 -0
- package/node_modules/mutative/dist/array.d.ts +45 -0
- package/node_modules/mutative/dist/constant.d.ts +8 -0
- package/node_modules/mutative/dist/create.d.ts +46 -0
- package/node_modules/mutative/dist/current.d.ts +23 -0
- package/node_modules/mutative/dist/draft.d.ts +3 -0
- package/node_modules/mutative/dist/draftify.d.ts +2 -0
- package/node_modules/mutative/dist/error.d.ts +54 -0
- package/node_modules/mutative/dist/index.d.mts +1 -0
- package/node_modules/mutative/dist/index.d.ts +12 -0
- package/node_modules/mutative/dist/index.js +8 -0
- package/node_modules/mutative/dist/index.mjs +3 -0
- package/node_modules/mutative/dist/interface.d.ts +200 -0
- package/node_modules/mutative/dist/internal.d.ts +4 -0
- package/node_modules/mutative/dist/makeCreator.d.ts +54 -0
- package/node_modules/mutative/dist/map.d.ts +15 -0
- package/node_modules/mutative/dist/mutative.cjs.development.js +2126 -0
- package/node_modules/mutative/dist/mutative.cjs.development.js.map +1 -0
- package/node_modules/mutative/dist/mutative.cjs.production.min.js +2 -0
- package/node_modules/mutative/dist/mutative.cjs.production.min.js.map +1 -0
- package/node_modules/mutative/dist/mutative.esm.js +2123 -0
- package/node_modules/mutative/dist/mutative.esm.js.map +1 -0
- package/node_modules/mutative/dist/mutative.esm.mjs +2123 -0
- package/node_modules/mutative/dist/mutative.esm.mjs.map +1 -0
- package/node_modules/mutative/dist/mutative.esm.production.min.mjs +2 -0
- package/node_modules/mutative/dist/mutative.esm.production.min.mjs.map +1 -0
- package/node_modules/mutative/dist/mutative.umd.development.js +2132 -0
- package/node_modules/mutative/dist/mutative.umd.development.js.map +1 -0
- package/node_modules/mutative/dist/mutative.umd.production.min.js +2 -0
- package/node_modules/mutative/dist/mutative.umd.production.min.js.map +1 -0
- package/node_modules/mutative/dist/original.d.ts +19 -0
- package/node_modules/mutative/dist/patch.d.ts +2 -0
- package/node_modules/mutative/dist/rawReturn.d.ts +19 -0
- package/node_modules/mutative/dist/set.d.ts +14 -0
- package/node_modules/mutative/dist/unsafe.d.ts +34 -0
- package/node_modules/mutative/dist/utils/cast.d.ts +13 -0
- package/node_modules/mutative/dist/utils/copy.d.ts +5 -0
- package/node_modules/mutative/dist/utils/deepFreeze.d.ts +1 -0
- package/node_modules/mutative/dist/utils/draft.d.ts +27 -0
- package/node_modules/mutative/dist/utils/finalize.d.ts +13 -0
- package/node_modules/mutative/dist/utils/forEach.d.ts +1 -0
- package/node_modules/mutative/dist/utils/index.d.ts +7 -0
- package/node_modules/mutative/dist/utils/mark.d.ts +2 -0
- package/node_modules/mutative/dist/utils/marker.d.ts +5 -0
- package/node_modules/mutative/dist/utils/proto.d.ts +10 -0
- package/node_modules/mutative/package.json +142 -0
- package/node_modules/mutative/src/apply.ts +239 -0
- package/node_modules/mutative/src/array.ts +679 -0
- package/node_modules/mutative/src/constant.ts +17 -0
- package/node_modules/mutative/src/create.ts +27 -0
- package/node_modules/mutative/src/current.ts +206 -0
- package/node_modules/mutative/src/draft.ts +489 -0
- package/node_modules/mutative/src/draftify.ts +57 -0
- package/node_modules/mutative/src/error.ts +129 -0
- package/node_modules/mutative/src/index.ts +21 -0
- package/node_modules/mutative/src/interface.ts +321 -0
- package/node_modules/mutative/src/internal.ts +5 -0
- package/node_modules/mutative/src/makeCreator.ts +382 -0
- package/node_modules/mutative/src/map.ts +160 -0
- package/node_modules/mutative/src/original.ts +28 -0
- package/node_modules/mutative/src/patch.ts +386 -0
- package/node_modules/mutative/src/rawReturn.ts +41 -0
- package/node_modules/mutative/src/set.ts +201 -0
- package/node_modules/mutative/src/unsafe.ts +66 -0
- package/node_modules/mutative/src/utils/cast.ts +22 -0
- package/node_modules/mutative/src/utils/copy.ts +224 -0
- package/node_modules/mutative/src/utils/deepFreeze.ts +103 -0
- package/node_modules/mutative/src/utils/draft.ts +189 -0
- package/node_modules/mutative/src/utils/finalize.ts +232 -0
- package/node_modules/mutative/src/utils/forEach.ts +24 -0
- package/node_modules/mutative/src/utils/index.ts +7 -0
- package/node_modules/mutative/src/utils/mark.ts +11 -0
- package/node_modules/mutative/src/utils/marker.ts +34 -0
- package/node_modules/mutative/src/utils/proto.ts +38 -0
- package/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/uuid/README.md +491 -0
- package/node_modules/uuid/dist/index.d.ts +15 -0
- package/node_modules/uuid/dist/index.js +14 -0
- package/node_modules/uuid/dist/max.d.ts +2 -0
- package/node_modules/uuid/dist/max.js +1 -0
- package/node_modules/uuid/dist/md5.d.ts +2 -0
- package/node_modules/uuid/dist/md5.js +135 -0
- package/node_modules/uuid/dist/nil.d.ts +2 -0
- package/node_modules/uuid/dist/nil.js +1 -0
- package/node_modules/uuid/dist/parse.d.ts +3 -0
- package/node_modules/uuid/dist/parse.js +9 -0
- package/node_modules/uuid/dist/regex.d.ts +2 -0
- package/node_modules/uuid/dist/regex.js +1 -0
- package/node_modules/uuid/dist/rng.d.ts +1 -0
- package/node_modules/uuid/dist/rng.js +4 -0
- package/node_modules/uuid/dist/sha1.d.ts +2 -0
- package/node_modules/uuid/dist/sha1.js +70 -0
- package/node_modules/uuid/dist/stringify.d.ts +3 -0
- package/node_modules/uuid/dist/stringify.js +35 -0
- package/node_modules/uuid/dist/types.d.ts +22 -0
- package/node_modules/uuid/dist/types.js +1 -0
- package/node_modules/uuid/dist/uuid-bin.d.ts +1 -0
- package/node_modules/uuid/dist/uuid-bin.js +70 -0
- package/node_modules/uuid/dist/v1.d.ts +11 -0
- package/node_modules/uuid/dist/v1.js +87 -0
- package/node_modules/uuid/dist/v1ToV6.d.ts +3 -0
- package/node_modules/uuid/dist/v1ToV6.js +10 -0
- package/node_modules/uuid/dist/v3.d.ts +9 -0
- package/node_modules/uuid/dist/v3.js +9 -0
- package/node_modules/uuid/dist/v35.d.ts +7 -0
- package/node_modules/uuid/dist/v35.js +39 -0
- package/node_modules/uuid/dist/v4.d.ts +4 -0
- package/node_modules/uuid/dist/v4.js +29 -0
- package/node_modules/uuid/dist/v5.d.ts +9 -0
- package/node_modules/uuid/dist/v5.js +9 -0
- package/node_modules/uuid/dist/v6.d.ts +4 -0
- package/node_modules/uuid/dist/v6.js +20 -0
- package/node_modules/uuid/dist/v6ToV1.d.ts +2 -0
- package/node_modules/uuid/dist/v6ToV1.js +10 -0
- package/node_modules/uuid/dist/v7.d.ts +9 -0
- package/node_modules/uuid/dist/v7.js +68 -0
- package/node_modules/uuid/dist/validate.d.ts +2 -0
- package/node_modules/uuid/dist/validate.js +5 -0
- package/node_modules/uuid/dist/version.d.ts +2 -0
- package/node_modules/uuid/dist/version.js +8 -0
- package/node_modules/uuid/dist-node/bin/uuid +2 -0
- package/node_modules/uuid/dist-node/index.js +14 -0
- package/node_modules/uuid/dist-node/max.js +1 -0
- package/node_modules/uuid/dist-node/md5.js +11 -0
- package/node_modules/uuid/dist-node/nil.js +1 -0
- package/node_modules/uuid/dist-node/parse.js +9 -0
- package/node_modules/uuid/dist-node/regex.js +1 -0
- package/node_modules/uuid/dist-node/rng.js +4 -0
- package/node_modules/uuid/dist-node/sha1.js +11 -0
- package/node_modules/uuid/dist-node/stringify.js +35 -0
- package/node_modules/uuid/dist-node/types.js +1 -0
- package/node_modules/uuid/dist-node/uuid-bin.js +70 -0
- package/node_modules/uuid/dist-node/v1.js +87 -0
- package/node_modules/uuid/dist-node/v1ToV6.js +10 -0
- package/node_modules/uuid/dist-node/v3.js +9 -0
- package/node_modules/uuid/dist-node/v35.js +39 -0
- package/node_modules/uuid/dist-node/v4.js +29 -0
- package/node_modules/uuid/dist-node/v5.js +9 -0
- package/node_modules/uuid/dist-node/v6.js +20 -0
- package/node_modules/uuid/dist-node/v6ToV1.js +10 -0
- package/node_modules/uuid/dist-node/v7.js +68 -0
- package/node_modules/uuid/dist-node/validate.js +5 -0
- package/node_modules/uuid/dist-node/version.js +8 -0
- package/node_modules/uuid/package.json +115 -0
- package/package.json +80 -4
- package/release.json +78 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { txInit, init as core_init, InstantError, } from '@instantdb/core';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState, useSyncExternalStore, } from 'react';
|
|
5
|
+
import { useQueryInternal } from './useQuery.js';
|
|
6
|
+
import { useInfiniteQuerySubscription, } from './useInfiniteQuerySubscription.js';
|
|
7
|
+
import { InstantReactRoom, rooms } from './InstantReactRoom.js';
|
|
8
|
+
const defaultAuthState = {
|
|
9
|
+
isLoading: true,
|
|
10
|
+
user: undefined,
|
|
11
|
+
error: undefined,
|
|
12
|
+
};
|
|
13
|
+
const defaultAppStatusState = {
|
|
14
|
+
isLoading: true,
|
|
15
|
+
isReadOnly: undefined,
|
|
16
|
+
};
|
|
17
|
+
export default class InstantReactAbstractDatabase {
|
|
18
|
+
tx = txInit();
|
|
19
|
+
auth;
|
|
20
|
+
storage;
|
|
21
|
+
streams;
|
|
22
|
+
core;
|
|
23
|
+
/** @deprecated use `core` instead */
|
|
24
|
+
_core;
|
|
25
|
+
static Store;
|
|
26
|
+
static NetworkListener;
|
|
27
|
+
static EventSourceImpl;
|
|
28
|
+
constructor(config, versions) {
|
|
29
|
+
this.core = core_init(config,
|
|
30
|
+
// @ts-expect-error because TS can't resolve subclass statics
|
|
31
|
+
config.Store || this.constructor.Store,
|
|
32
|
+
// @ts-expect-error because TS can't resolve subclass statics
|
|
33
|
+
this.constructor.NetworkListener, versions,
|
|
34
|
+
// @ts-expect-error because TS can't resolve subclass statics
|
|
35
|
+
this.constructor.EventSourceImpl);
|
|
36
|
+
this._core = this.core;
|
|
37
|
+
this.auth = this.core.auth;
|
|
38
|
+
this.storage = this.core.storage;
|
|
39
|
+
this.streams = this.core.streams;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns a unique ID for a given `name`. It's stored in local storage,
|
|
43
|
+
* so you will get the same ID across sessions.
|
|
44
|
+
*
|
|
45
|
+
* This is useful for generating IDs that could identify a local device or user.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const deviceId = await db.getLocalId('device');
|
|
49
|
+
*/
|
|
50
|
+
getLocalId = (name) => {
|
|
51
|
+
return this.core.getLocalId(name);
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A hook that returns a unique ID for a given `name`. localIds are
|
|
55
|
+
* stored in local storage, so you will get the same ID across sessions.
|
|
56
|
+
*
|
|
57
|
+
* Initially returns `null`, and then loads the localId.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const deviceId = db.useLocalId('device');
|
|
61
|
+
* if (!deviceId) return null; // loading
|
|
62
|
+
* console.log('Device ID:', deviceId)
|
|
63
|
+
*/
|
|
64
|
+
useLocalId = (name) => {
|
|
65
|
+
const [localId, setLocalId] = useState(null);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let mounted = true;
|
|
68
|
+
const f = async () => {
|
|
69
|
+
const id = await this.getLocalId(name);
|
|
70
|
+
if (!mounted)
|
|
71
|
+
return;
|
|
72
|
+
setLocalId(id);
|
|
73
|
+
};
|
|
74
|
+
f();
|
|
75
|
+
return;
|
|
76
|
+
}, [name]);
|
|
77
|
+
return localId;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Obtain a handle to a room, which allows you to listen to topics and presence data
|
|
81
|
+
*
|
|
82
|
+
* If you don't provide a `type` or `id`, Instant will default to `_defaultRoomType` and `_defaultRoomId`
|
|
83
|
+
* as the room type and id, respectively.
|
|
84
|
+
*
|
|
85
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const room = db.room('chat', roomId);
|
|
89
|
+
* const { peers } = db.rooms.usePresence(room);
|
|
90
|
+
*/
|
|
91
|
+
room(type = '_defaultRoomType', id = '_defaultRoomId') {
|
|
92
|
+
return new InstantReactRoom(this.core, type, id);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Hooks for working with rooms
|
|
96
|
+
*
|
|
97
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const room = db.room('chat', roomId);
|
|
101
|
+
* const { peers } = db.rooms.usePresence(room);
|
|
102
|
+
* const publish = db.rooms.usePublishTopic(room, 'emoji');
|
|
103
|
+
* // ...
|
|
104
|
+
*/
|
|
105
|
+
rooms = rooms;
|
|
106
|
+
/**
|
|
107
|
+
* Use this to write data! You can create, update, delete, and link objects
|
|
108
|
+
*
|
|
109
|
+
* @see https://instantdb.com/docs/instaml
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Create a new object in the `goals` namespace
|
|
113
|
+
* const goalId = id();
|
|
114
|
+
* db.transact(db.tx.goals[goalId].update({title: "Get fit"}))
|
|
115
|
+
*
|
|
116
|
+
* // Update the title
|
|
117
|
+
* db.transact(db.tx.goals[goalId].update({title: "Get super fit"}))
|
|
118
|
+
*
|
|
119
|
+
* // Delete it
|
|
120
|
+
* db.transact(db.tx.goals[goalId].delete())
|
|
121
|
+
*
|
|
122
|
+
* // Or create an association:
|
|
123
|
+
* todoId = id();
|
|
124
|
+
* db.transact([
|
|
125
|
+
* db.tx.todos[todoId].update({ title: 'Go on a run' }),
|
|
126
|
+
* db.tx.goals[goalId].link({todos: todoId}),
|
|
127
|
+
* ])
|
|
128
|
+
*/
|
|
129
|
+
transact = (chunks) => {
|
|
130
|
+
return this.core.transact(chunks);
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Use this to query your data!
|
|
134
|
+
*
|
|
135
|
+
* @see https://instantdb.com/docs/instaql
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* // listen to all goals
|
|
139
|
+
* const { isLoading, error, data } = db.useQuery({ goals: {} });
|
|
140
|
+
*
|
|
141
|
+
* // goals where the title is "Get Fit"
|
|
142
|
+
* const { isLoading, error, data } = db.useQuery({
|
|
143
|
+
* goals: { $: { where: { title: 'Get Fit' } } },
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // all goals, _alongside_ their todos
|
|
147
|
+
* const { isLoading, error, data } = db.useQuery({
|
|
148
|
+
* goals: { todos: {} },
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* // skip if `user` is not logged in
|
|
152
|
+
* const { isLoading, error, data } = db.useQuery(
|
|
153
|
+
* auth.user ? { goals: {} } : null,
|
|
154
|
+
* );
|
|
155
|
+
*/
|
|
156
|
+
useQuery = (query, opts) => {
|
|
157
|
+
return useQueryInternal(this.core, query, opts).state;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Listen for the logged in state. This is useful
|
|
161
|
+
* for deciding when to show a login screen.
|
|
162
|
+
*
|
|
163
|
+
* Check out the docs for an example `Login` component too!
|
|
164
|
+
*
|
|
165
|
+
* @see https://instantdb.com/docs/auth
|
|
166
|
+
* @example
|
|
167
|
+
* function App() {
|
|
168
|
+
* const { isLoading, user, error } = db.useAuth()
|
|
169
|
+
* if (isLoading) {
|
|
170
|
+
* return <div>Loading...</div>
|
|
171
|
+
* }
|
|
172
|
+
* if (error) {
|
|
173
|
+
* return <div>Uh oh! {error.message}</div>
|
|
174
|
+
* }
|
|
175
|
+
* if (user) {
|
|
176
|
+
* return <Main user={user} />
|
|
177
|
+
* }
|
|
178
|
+
* return <Login />
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
*/
|
|
182
|
+
useAuth = () => {
|
|
183
|
+
return this._useAuth();
|
|
184
|
+
};
|
|
185
|
+
_useAuth() {
|
|
186
|
+
// We use a ref to store the result of the query.
|
|
187
|
+
// This is becuase `useSyncExternalStore` uses `Object.is`
|
|
188
|
+
// to compare the previous and next state.
|
|
189
|
+
// If we don't use a ref, the state will always be considered different, so
|
|
190
|
+
// the component will always re-render.
|
|
191
|
+
const resultCacheRef = useRef(this.core._reactor._currentUserCached);
|
|
192
|
+
// Similar to `resultCacheRef`, `useSyncExternalStore` will unsubscribe
|
|
193
|
+
// if `subscribe` changes, so we use `useCallback` to memoize the function.
|
|
194
|
+
const subscribe = useCallback((cb) => {
|
|
195
|
+
const unsubscribe = this.core.subscribeAuth((auth) => {
|
|
196
|
+
resultCacheRef.current = { isLoading: false, ...auth };
|
|
197
|
+
cb();
|
|
198
|
+
});
|
|
199
|
+
return unsubscribe;
|
|
200
|
+
}, []);
|
|
201
|
+
const state = useSyncExternalStore(subscribe, () => resultCacheRef.current, () => defaultAuthState);
|
|
202
|
+
return state;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Subscribe to the currently logged in user.
|
|
206
|
+
* If the user is not logged in, this hook with throw an Error.
|
|
207
|
+
* You will want to protect any calls of this hook with a
|
|
208
|
+
* <db.SignedIn> component, or your own logic based on db.useAuth()
|
|
209
|
+
*
|
|
210
|
+
* @see https://instantdb.com/docs/auth
|
|
211
|
+
* @throws Error indicating user not signed in
|
|
212
|
+
* @example
|
|
213
|
+
* function UserDisplay() {
|
|
214
|
+
* const user = db.useUser()
|
|
215
|
+
* return <div>Logged in as: {user.email}</div>
|
|
216
|
+
* }
|
|
217
|
+
*
|
|
218
|
+
* <db.SignedIn>
|
|
219
|
+
* <UserDisplay />
|
|
220
|
+
* </db.SignedIn>
|
|
221
|
+
*
|
|
222
|
+
*/
|
|
223
|
+
useUser = () => {
|
|
224
|
+
const { user } = this.useAuth();
|
|
225
|
+
if (!user) {
|
|
226
|
+
throw new InstantError('useUser must be used within an auth-protected route');
|
|
227
|
+
}
|
|
228
|
+
return user;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* One time query for the logged in state. This is useful
|
|
232
|
+
* for scenarios where you want to know the current auth
|
|
233
|
+
* state without subscribing to changes.
|
|
234
|
+
*
|
|
235
|
+
* @see https://instantdb.com/docs/auth
|
|
236
|
+
* @example
|
|
237
|
+
* const user = await db.getAuth();
|
|
238
|
+
* console.log('logged in as', user.email)
|
|
239
|
+
*/
|
|
240
|
+
getAuth() {
|
|
241
|
+
return this.core.getAuth();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Listen for connection status changes to Instant. Use this for things like
|
|
245
|
+
* showing connection state to users
|
|
246
|
+
*
|
|
247
|
+
* @see https://www.instantdb.com/docs/patterns#connection-status
|
|
248
|
+
* @example
|
|
249
|
+
* function App() {
|
|
250
|
+
* const status = db.useConnectionStatus()
|
|
251
|
+
* const connectionState =
|
|
252
|
+
* status === 'connecting' || status === 'opened'
|
|
253
|
+
* ? 'authenticating'
|
|
254
|
+
* : status === 'authenticated'
|
|
255
|
+
* ? 'connected'
|
|
256
|
+
* : status === 'closed'
|
|
257
|
+
* ? 'closed'
|
|
258
|
+
* : status === 'errored'
|
|
259
|
+
* ? 'errored'
|
|
260
|
+
* : 'unexpected state';
|
|
261
|
+
*
|
|
262
|
+
* return <div>Connection state: {connectionState}</div>
|
|
263
|
+
* }
|
|
264
|
+
*/
|
|
265
|
+
useConnectionStatus = () => {
|
|
266
|
+
const statusRef = useRef(this.core._reactor.status);
|
|
267
|
+
const subscribe = useCallback((cb) => {
|
|
268
|
+
const unsubscribe = this.core.subscribeConnectionStatus((newStatus) => {
|
|
269
|
+
if (newStatus !== statusRef.current) {
|
|
270
|
+
statusRef.current = newStatus;
|
|
271
|
+
cb();
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return unsubscribe;
|
|
275
|
+
}, []);
|
|
276
|
+
const status = useSyncExternalStore(subscribe, () => statusRef.current,
|
|
277
|
+
// For SSR, always return 'connecting' as the initial state
|
|
278
|
+
() => 'connecting');
|
|
279
|
+
return status;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Observe the app's maintenance-mode state. While read-only, reads and
|
|
283
|
+
* live queries keep working but writes are rejected.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* function App() {
|
|
287
|
+
* const { isLoading, isReadOnly } = db.useAppStatus()
|
|
288
|
+
* if (isLoading) return null
|
|
289
|
+
* if (isReadOnly) return <MaintenanceBanner />
|
|
290
|
+
* // ...
|
|
291
|
+
* }
|
|
292
|
+
*/
|
|
293
|
+
useAppStatus = () => {
|
|
294
|
+
const stateRef = useRef(this.core._reactor._appStatusState);
|
|
295
|
+
const subscribe = useCallback((cb) => {
|
|
296
|
+
return this.core.subscribeAppStatus((state) => {
|
|
297
|
+
if (state.isLoading !== stateRef.current.isLoading ||
|
|
298
|
+
state.isReadOnly !== stateRef.current.isReadOnly) {
|
|
299
|
+
stateRef.current = state;
|
|
300
|
+
cb();
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}, []);
|
|
304
|
+
const state = useSyncExternalStore(subscribe, () => stateRef.current, () => defaultAppStatusState);
|
|
305
|
+
return state;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Use this for one-off queries.
|
|
309
|
+
* Returns local data if available, otherwise fetches from the server.
|
|
310
|
+
* Because we want to avoid stale data, this method will throw an error
|
|
311
|
+
* if the user is offline or there is no active connection to the server.
|
|
312
|
+
*
|
|
313
|
+
* @see https://instantdb.com/docs/instaql
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
*
|
|
317
|
+
* const resp = await db.queryOnce({ goals: {} });
|
|
318
|
+
* console.log(resp.data.goals)
|
|
319
|
+
*/
|
|
320
|
+
queryOnce = (query, opts) => {
|
|
321
|
+
return this.core.queryOnce(query, opts);
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Subscribe to a query and incrementally load more items
|
|
325
|
+
*
|
|
326
|
+
* Only one top level namespace in the query is allowed.
|
|
327
|
+
*
|
|
328
|
+
* Changing the query or options while the subscription is active will
|
|
329
|
+
* reset the subscription and start over with new data.
|
|
330
|
+
* @example
|
|
331
|
+
* const {
|
|
332
|
+
* data,
|
|
333
|
+
* loadNextPage,
|
|
334
|
+
* canLoadNextPage,
|
|
335
|
+
* } = db.useInfiniteQuery({
|
|
336
|
+
* posts: {
|
|
337
|
+
* $: {
|
|
338
|
+
* limit: 20, // Load 20 posts at a time
|
|
339
|
+
* order: {
|
|
340
|
+
* createdAt: 'desc',
|
|
341
|
+
* },
|
|
342
|
+
* },
|
|
343
|
+
* },
|
|
344
|
+
* });
|
|
345
|
+
*/
|
|
346
|
+
useInfiniteQuery = (query, opts) => {
|
|
347
|
+
const result = useInfiniteQuerySubscription({
|
|
348
|
+
core: this.core,
|
|
349
|
+
query: query,
|
|
350
|
+
opts,
|
|
351
|
+
});
|
|
352
|
+
return result;
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Only render children if the user is signed in.
|
|
356
|
+
* @see https://instantdb.com/docs/auth
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* <db.SignedIn>
|
|
360
|
+
* <MyComponent />
|
|
361
|
+
* </db.SignedIn>
|
|
362
|
+
*
|
|
363
|
+
*/
|
|
364
|
+
SignedIn = ({ children }) => {
|
|
365
|
+
const auth = this.useAuth();
|
|
366
|
+
if (auth.isLoading || auth.error || !auth.user)
|
|
367
|
+
return null;
|
|
368
|
+
return _jsx(_Fragment, { children: children });
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Only render children if the user is signed out.
|
|
372
|
+
* @see https://instantdb.com/docs/auth
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* <db.SignedOut>
|
|
376
|
+
* <MyComponent />
|
|
377
|
+
* </db.SignedOut>
|
|
378
|
+
*
|
|
379
|
+
*/
|
|
380
|
+
SignedOut = ({ children }) => {
|
|
381
|
+
const auth = this.useAuth();
|
|
382
|
+
if (auth.isLoading || auth.error || auth.user)
|
|
383
|
+
return null;
|
|
384
|
+
return _jsx(_Fragment, { children: children });
|
|
385
|
+
};
|
|
386
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { type PresenceOpts, type PresenceResponse, type RoomSchemaShape, InstantCoreDatabase, InstantSchemaDef } from '@instantdb/core';
|
|
2
|
+
import { KeyboardEvent } from 'react';
|
|
3
|
+
export type PresenceHandle<PresenceShape, Keys extends keyof PresenceShape> = PresenceResponse<PresenceShape, Keys> & {
|
|
4
|
+
publishPresence: (data: Partial<PresenceShape>) => void;
|
|
5
|
+
};
|
|
6
|
+
export type TypingIndicatorOpts = {
|
|
7
|
+
timeout?: number | null;
|
|
8
|
+
stopOnEnter?: boolean;
|
|
9
|
+
writeOnly?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type TypingIndicatorHandle<PresenceShape> = {
|
|
12
|
+
active: PresenceShape[];
|
|
13
|
+
setActive(active: boolean): void;
|
|
14
|
+
inputProps: {
|
|
15
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
16
|
+
onBlur: () => void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const defaultActivityStopTimeout = 1000;
|
|
20
|
+
/**
|
|
21
|
+
* Listen for broadcasted events given a room and topic.
|
|
22
|
+
*
|
|
23
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
24
|
+
* @example
|
|
25
|
+
* function App({ roomId }) {
|
|
26
|
+
* const room = db.room('chats', roomId);
|
|
27
|
+
* db.rooms.useTopicEffect(room, 'emoji', (message, peer) => {
|
|
28
|
+
* console.log(peer.name, 'sent', message);
|
|
29
|
+
* });
|
|
30
|
+
* // ...
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
33
|
+
export declare function useTopicEffect<RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema, TopicType extends keyof RoomSchema[RoomType]['topics']>(room: InstantReactRoom<any, RoomSchema, RoomType>, topic: TopicType, onEvent: (event: RoomSchema[RoomType]['topics'][TopicType], peer: RoomSchema[RoomType]['presence']) => any): void;
|
|
34
|
+
/**
|
|
35
|
+
* Broadcast an event to a room.
|
|
36
|
+
*
|
|
37
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
38
|
+
* @example
|
|
39
|
+
* function App({ roomId }) {
|
|
40
|
+
* const room = db.room('chat', roomId);
|
|
41
|
+
* const publishTopic = db.rooms.usePublishTopic(room, "emoji");
|
|
42
|
+
*
|
|
43
|
+
* return (
|
|
44
|
+
* <button onClick={() => publishTopic({ emoji: "🔥" })}>Send emoji</button>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export declare function usePublishTopic<RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema, TopicType extends keyof RoomSchema[RoomType]['topics']>(room: InstantReactRoom<any, RoomSchema, RoomType>, topic: TopicType): (data: RoomSchema[RoomType]['topics'][TopicType]) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Listen for peer's presence data in a room, and publish the current user's presence.
|
|
52
|
+
*
|
|
53
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
54
|
+
* @example
|
|
55
|
+
* function App({ roomId }) {
|
|
56
|
+
* const {
|
|
57
|
+
* peers,
|
|
58
|
+
* publishPresence
|
|
59
|
+
* } = db.room(roomType, roomId).usePresence({ keys: ["name", "avatar"] });
|
|
60
|
+
*
|
|
61
|
+
* // ...
|
|
62
|
+
* }
|
|
63
|
+
*/
|
|
64
|
+
export declare function usePresence<RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema, Keys extends keyof RoomSchema[RoomType]['presence']>(room: InstantReactRoom<any, RoomSchema, RoomType>, opts?: PresenceOpts<RoomSchema[RoomType]['presence'], Keys>): PresenceHandle<RoomSchema[RoomType]['presence'], Keys>;
|
|
65
|
+
/**
|
|
66
|
+
* Publishes presence data to a room
|
|
67
|
+
*
|
|
68
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
69
|
+
* @example
|
|
70
|
+
* function App({ roomId, nickname }) {
|
|
71
|
+
* const room = db.room('chat', roomId);
|
|
72
|
+
* db.rooms.useSyncPresence(room, { nickname });
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export declare function useSyncPresence<RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema>(room: InstantReactRoom<any, RoomSchema, RoomType>, data: Partial<RoomSchema[RoomType]['presence']>, deps?: any[]): void;
|
|
76
|
+
/**
|
|
77
|
+
* Manage typing indicator state
|
|
78
|
+
*
|
|
79
|
+
* @see https://instantdb.com/docs/presence-and-topics
|
|
80
|
+
* @example
|
|
81
|
+
* function App({ roomId }) {
|
|
82
|
+
* const room = db.room('chat', roomId);
|
|
83
|
+
* const {
|
|
84
|
+
* active,
|
|
85
|
+
* setActive,
|
|
86
|
+
* inputProps,
|
|
87
|
+
* } = db.rooms.useTypingIndicator(room, "chat-input");
|
|
88
|
+
*
|
|
89
|
+
* return <input {...inputProps} />;
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
92
|
+
export declare function useTypingIndicator<RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema>(room: InstantReactRoom<any, RoomSchema, RoomType>, inputName: string, opts?: TypingIndicatorOpts): TypingIndicatorHandle<RoomSchema[RoomType]['presence']>;
|
|
93
|
+
export declare const rooms: {
|
|
94
|
+
useTopicEffect: typeof useTopicEffect;
|
|
95
|
+
usePublishTopic: typeof usePublishTopic;
|
|
96
|
+
usePresence: typeof usePresence;
|
|
97
|
+
useSyncPresence: typeof useSyncPresence;
|
|
98
|
+
useTypingIndicator: typeof useTypingIndicator;
|
|
99
|
+
};
|
|
100
|
+
export declare class InstantReactRoom<Schema extends InstantSchemaDef<any, any, any>, RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema> {
|
|
101
|
+
core: InstantCoreDatabase<Schema, boolean>;
|
|
102
|
+
/** @deprecated use `core` instead */
|
|
103
|
+
_core: InstantCoreDatabase<Schema, boolean>;
|
|
104
|
+
type: RoomType;
|
|
105
|
+
id: string;
|
|
106
|
+
constructor(core: InstantCoreDatabase<Schema, boolean>, type: RoomType, id: string);
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated
|
|
109
|
+
* `db.room(...).useTopicEffect` is deprecated. You can replace it with `db.rooms.useTopicEffect`.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
*
|
|
113
|
+
* // Before
|
|
114
|
+
* const room = db.room('chat', 'room-id');
|
|
115
|
+
* room.useTopicEffect('emoji', (message, peer) => { });
|
|
116
|
+
*
|
|
117
|
+
* // After
|
|
118
|
+
* const room = db.room('chat', 'room-id');
|
|
119
|
+
* db.rooms.useTopicEffect(room, 'emoji', (message, peer) => { });
|
|
120
|
+
*/
|
|
121
|
+
useTopicEffect: <TopicType extends keyof RoomSchema[RoomType]['topics']>(topic: TopicType, onEvent: (event: RoomSchema[RoomType]['topics'][TopicType], peer: RoomSchema[RoomType]['presence']) => any) => void;
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated
|
|
124
|
+
* `db.room(...).usePublishTopic` is deprecated. You can replace it with `db.rooms.usePublishTopic`.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
*
|
|
128
|
+
* // Before
|
|
129
|
+
* const room = db.room('chat', 'room-id');
|
|
130
|
+
* const publish = room.usePublishTopic('emoji');
|
|
131
|
+
*
|
|
132
|
+
* // After
|
|
133
|
+
* const room = db.room('chat', 'room-id');
|
|
134
|
+
* const publish = db.rooms.usePublishTopic(room, 'emoji');
|
|
135
|
+
*/
|
|
136
|
+
usePublishTopic: <Topic extends keyof RoomSchema[RoomType]['topics']>(topic: Topic) => ((data: RoomSchema[RoomType]['topics'][Topic]) => void);
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated
|
|
139
|
+
* `db.room(...).usePresence` is deprecated. You can replace it with `db.rooms.usePresence`.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
*
|
|
143
|
+
* // Before
|
|
144
|
+
* const room = db.room('chat', 'room-id');
|
|
145
|
+
* const { peers } = room.usePresence({ keys: ["name", "avatar"] });
|
|
146
|
+
*
|
|
147
|
+
* // After
|
|
148
|
+
* const room = db.room('chat', 'room-id');
|
|
149
|
+
* const { peers } = db.rooms.usePresence(room, { keys: ["name", "avatar"] });
|
|
150
|
+
*/
|
|
151
|
+
usePresence: <Keys extends keyof RoomSchema[RoomType]['presence']>(opts?: PresenceOpts<RoomSchema[RoomType]['presence'], Keys>) => PresenceHandle<RoomSchema[RoomType]['presence'], Keys>;
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated
|
|
154
|
+
* `db.room(...).useSyncPresence` is deprecated. You can replace it with `db.rooms.useSyncPresence`.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
*
|
|
158
|
+
* // Before
|
|
159
|
+
* const room = db.room('chat', 'room-id');
|
|
160
|
+
* room.useSyncPresence(room, { nickname });
|
|
161
|
+
*
|
|
162
|
+
* // After
|
|
163
|
+
* const room = db.room('chat', 'room-id');
|
|
164
|
+
* db.rooms.useSyncPresence(room, { nickname });
|
|
165
|
+
*/
|
|
166
|
+
useSyncPresence: (data: Partial<RoomSchema[RoomType]['presence']>, deps?: any[]) => void;
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated
|
|
169
|
+
* `db.room(...).useTypingIndicator` is deprecated. You can replace it with `db.rooms.useTypingIndicator`.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
*
|
|
173
|
+
* // Before
|
|
174
|
+
* const room = db.room('chat', 'room-id');
|
|
175
|
+
* const typing = room.useTypingIndiactor(room, 'chat-input');
|
|
176
|
+
*
|
|
177
|
+
* // After
|
|
178
|
+
* const room = db.room('chat', 'room-id');
|
|
179
|
+
* const typing = db.rooms.useTypingIndiactor(room, 'chat-input');
|
|
180
|
+
*/
|
|
181
|
+
useTypingIndicator: (inputName: string, opts?: TypingIndicatorOpts) => TypingIndicatorHandle<RoomSchema[RoomType]['presence']>;
|
|
182
|
+
}
|