@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,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 @@
|
|
|
1
|
+
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
|
+
};
|